1 //===-- LineEntry.h ---------------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef liblldb_LineEntry_h_
11 #define liblldb_LineEntry_h_
13 #include "lldb/Core/AddressRange.h"
14 #include "lldb/Utility/FileSpec.h"
15 #include "lldb/lldb-private.h"
17 namespace lldb_private {
19 //----------------------------------------------------------------------
20 /// @class LineEntry LineEntry.h "lldb/Symbol/LineEntry.h"
21 /// @brief A line table entry class.
22 //----------------------------------------------------------------------
24 //------------------------------------------------------------------
25 /// Default constructor.
27 /// Initialize all member variables to invalid values.
28 //------------------------------------------------------------------
31 LineEntry(const lldb::SectionSP §ion_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);
37 //------------------------------------------------------------------
38 /// Clear the object's state.
40 /// Clears all member variables to invalid values.
41 //------------------------------------------------------------------
44 //------------------------------------------------------------------
45 /// Dump a description of this object to a Stream.
47 /// Dump a description of the contents of this object to the
48 /// supplied stream \a s.
51 /// The stream to which to dump the object description.
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).
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
64 /// The display style for the section offset address.
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
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;
78 bool GetDescription(Stream *s, lldb::DescriptionLevel level, CompileUnit *cu,
79 Target *target, bool show_address_only) const;
81 //------------------------------------------------------------------
82 /// Dumps information specific to a process that stops at this
83 /// line entry to the supplied stream \a s.
86 /// The stream to which to dump the object description.
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).
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;
99 //------------------------------------------------------------------
100 /// Check if a line entry object is valid.
103 /// Returns \b true if the line entry contains a valid section
104 /// offset address, file index, and line number, \b false
106 //------------------------------------------------------------------
107 bool IsValid() const;
109 //------------------------------------------------------------------
110 /// Compare two LineEntry objects.
113 /// The Left Hand Side const LineEntry object reference.
116 /// The Right Hand Side const LineEntry object reference.
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);
125 //------------------------------------------------------------------
126 /// Give the range for this LineEntry + any additional LineEntries for
127 /// this same source line that are contiguous.
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.
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.)
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.
147 /// The contiguous AddressRange for this source line.
148 //------------------------------------------------------------------
149 AddressRange GetSameLineContiguousAddressRange() const;
151 //------------------------------------------------------------------
152 /// Apply file mappings from target.source-map to the LineEntry's file.
154 /// @param[in] target_sp
155 /// Shared pointer to the target this LineEntry belongs to.
156 //------------------------------------------------------------------
158 void ApplyFileMappings(lldb::TargetSP target_sp);
160 //------------------------------------------------------------------
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
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
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
173 is_start_of_basic_block : 1, ///< Indicates this entry is the beginning of
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
186 //------------------------------------------------------------------
187 /// Less than operator.
190 /// The Left Hand Side const LineEntry object reference.
193 /// The Right Hand Side const LineEntry object reference.
196 /// Returns \b true if lhs < rhs, false otherwise.
197 //------------------------------------------------------------------
198 bool operator<(const LineEntry &lhs, const LineEntry &rhs);
200 } // namespace lldb_private
202 #endif // liblldb_LineEntry_h_