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

source code of lldb/include/lldb/Symbol/LineEntry.h