]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/include/lldb/Symbol/LineEntry.h
Merge llvm, clang, lld, lldb, compiler-rt and libc++ r305575, and update
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / include / lldb / Symbol / LineEntry.h
1 //===-- LineEntry.h ---------------------------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #ifndef liblldb_LineEntry_h_
11 #define liblldb_LineEntry_h_
12
13 #include "lldb/Core/AddressRange.h"
14 #include "lldb/Utility/FileSpec.h"
15 #include "lldb/lldb-private.h"
16
17 namespace lldb_private {
18
19 //----------------------------------------------------------------------
20 /// @class LineEntry LineEntry.h "lldb/Symbol/LineEntry.h"
21 /// @brief A line table entry class.
22 //----------------------------------------------------------------------
23 struct LineEntry {
24   //------------------------------------------------------------------
25   /// Default constructor.
26   ///
27   /// Initialize all member variables to invalid values.
28   //------------------------------------------------------------------
29   LineEntry();
30
31   LineEntry(const lldb::SectionSP &section_sp, lldb::addr_t section_offset,
32             lldb::addr_t byte_size, const FileSpec &file, uint32_t _line,
33             uint16_t _column, bool _is_start_of_statement,
34             bool _is_start_of_basic_block, bool _is_prologue_end,
35             bool _is_epilogue_begin, bool _is_terminal_entry);
36
37   //------------------------------------------------------------------
38   /// Clear the object's state.
39   ///
40   /// Clears all member variables to invalid values.
41   //------------------------------------------------------------------
42   void Clear();
43
44   //------------------------------------------------------------------
45   /// Dump a description of this object to a Stream.
46   ///
47   /// Dump a description of the contents of this object to the
48   /// supplied stream \a s.
49   ///
50   /// @param[in] s
51   ///     The stream to which to dump the object description.
52   ///
53   /// @param[in] comp_unit
54   ///     The compile unit object that contains the support file
55   ///     list so the line entry can dump the file name (since this
56   ///     object contains a file index into the support file list).
57   ///
58   /// @param[in] show_file
59   ///     If \b true, display the filename with the line entry which
60   ///     requires that the compile unit object \a comp_unit be a
61   ///     valid pointer.
62   ///
63   /// @param[in] style
64   ///     The display style for the section offset address.
65   ///
66   /// @return
67   ///     Returns \b true if the address was able to be displayed
68   ///     using \a style. File and load addresses may be unresolved
69   ///     and it may not be possible to display a valid address value.
70   ///     Returns \b false if the address was not able to be properly
71   ///     dumped.
72   ///
73   /// @see Address::DumpStyle
74   //------------------------------------------------------------------
75   bool Dump(Stream *s, Target *target, bool show_file, Address::DumpStyle style,
76             Address::DumpStyle fallback_style, bool show_range) const;
77
78   bool GetDescription(Stream *s, lldb::DescriptionLevel level, CompileUnit *cu,
79                       Target *target, bool show_address_only) const;
80
81   //------------------------------------------------------------------
82   /// Dumps information specific to a process that stops at this
83   /// line entry to the supplied stream \a s.
84   ///
85   /// @param[in] s
86   ///     The stream to which to dump the object description.
87   ///
88   /// @param[in] comp_unit
89   ///     The compile unit object that contains the support file
90   ///     list so the line entry can dump the file name (since this
91   ///     object contains a file index into the support file list).
92   ///
93   /// @return
94   ///     Returns \b true if the file and line were properly dumped,
95   ///     \b false otherwise.
96   //------------------------------------------------------------------
97   bool DumpStopContext(Stream *s, bool show_fullpaths) const;
98
99   //------------------------------------------------------------------
100   /// Check if a line entry object is valid.
101   ///
102   /// @return
103   ///     Returns \b true if the line entry contains a valid section
104   ///     offset address, file index, and line number, \b false
105   ///     otherwise.
106   //------------------------------------------------------------------
107   bool IsValid() const;
108
109   //------------------------------------------------------------------
110   /// Compare two LineEntry objects.
111   ///
112   /// @param[in] lhs
113   ///     The Left Hand Side const LineEntry object reference.
114   ///
115   /// @param[in] rhs
116   ///     The Right Hand Side const LineEntry object reference.
117   ///
118   /// @return
119   ///     @li -1 if lhs < rhs
120   ///     @li 0 if lhs == rhs
121   ///     @li 1 if lhs > rhs
122   //------------------------------------------------------------------
123   static int Compare(const LineEntry &lhs, const LineEntry &rhs);
124
125   //------------------------------------------------------------------
126   /// Give the range for this LineEntry + any additional LineEntries for
127   /// this same source line that are contiguous.
128   ///
129   /// A compiler may emit multiple line entries for a single source line,
130   /// e.g. to indicate subexpressions at different columns.  This method
131   /// will get the AddressRange for all of the LineEntries for this source
132   /// line that are contiguous.
133   //
134   /// Line entries with a line number of 0 are treated specially - these
135   /// are compiler-generated line table entries that the user did not
136   /// write in their source code, and we want to skip past in the debugger.
137   /// If this LineEntry is for line 32, and the following LineEntry is for
138   /// line 0, we will extend the range to include the AddressRange of the
139   /// line 0 LineEntry (and it will include the range of the following
140   /// LineEntries that match either 32 or 0.)
141   ///
142   /// If the initial LineEntry this method is called on is a line #0, only
143   /// the range of contiuous LineEntries with line #0 will be included in
144   /// the complete range.
145   ///
146   /// @return
147   ///     The contiguous AddressRange for this source line.
148   //------------------------------------------------------------------
149   AddressRange GetSameLineContiguousAddressRange() const;
150
151   //------------------------------------------------------------------
152   /// Apply file mappings from target.source-map to the LineEntry's file.
153   ///
154   /// @param[in] target_sp
155   ///     Shared pointer to the target this LineEntry belongs to.
156   //------------------------------------------------------------------
157
158   void ApplyFileMappings(lldb::TargetSP target_sp);
159
160   //------------------------------------------------------------------
161   // Member variables.
162   //------------------------------------------------------------------
163   AddressRange range; ///< The section offset address range for this line entry.
164   FileSpec file; ///< The source file, possibly mapped by the target.source-map
165                  ///setting
166   FileSpec original_file; ///< The original source file, from debug info.
167   uint32_t line; ///< The source line number, or zero if there is no line number
168                  ///information.
169   uint16_t column; ///< The column number of the source line, or zero if there
170                    ///is no column information.
171   uint16_t is_start_of_statement : 1, ///< Indicates this entry is the beginning
172                                       ///of a statement.
173       is_start_of_basic_block : 1, ///< Indicates this entry is the beginning of
174                                    ///a basic block.
175       is_prologue_end : 1,   ///< Indicates this entry is one (of possibly many)
176                              ///where execution should be suspended for an entry
177                              ///breakpoint of a function.
178       is_epilogue_begin : 1, ///< Indicates this entry is one (of possibly many)
179                              ///where execution should be suspended for an exit
180                              ///breakpoint of a function.
181       is_terminal_entry : 1; ///< Indicates this entry is that of the first byte
182                              ///after the end of a sequence of target machine
183                              ///instructions.
184 };
185
186 //------------------------------------------------------------------
187 /// Less than operator.
188 ///
189 /// @param[in] lhs
190 ///     The Left Hand Side const LineEntry object reference.
191 ///
192 /// @param[in] rhs
193 ///     The Right Hand Side const LineEntry object reference.
194 ///
195 /// @return
196 ///     Returns \b true if lhs < rhs, false otherwise.
197 //------------------------------------------------------------------
198 bool operator<(const LineEntry &lhs, const LineEntry &rhs);
199
200 } // namespace lldb_private
201
202 #endif // liblldb_LineEntry_h_