LLDB mainline
LineEntry.h
Go to the documentation of this file.
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
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
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.
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 /// Helper to access the file.
134 const FileSpec &GetFile() const { return file_sp->GetSpecOnly(); }
135
136 /// The section offset address range for this line entry.
138
139 /// The source file, possibly mapped by the target.source-map setting.
141
142 /// The original source file, from debug info.
144
145 /// The source line number, or LLDB_INVALID_LINE_NUMBER if there is no line
146 /// number information.
148
149 /// The column number of the source line, or zero if there is no column
150 /// information.
151 uint16_t column = 0;
152
153 /// Indicates this entry is the beginning of a statement.
155
156 /// Indicates this entry is the beginning of a basic block.
158
159 /// Indicates this entry is one (of possibly many) where execution should be
160 /// suspended for an entry breakpoint of a function.
161 uint16_t is_prologue_end : 1;
162
163 /// Indicates this entry is one (of possibly many) where execution should be
164 /// suspended for an exit breakpoint of a function.
165 uint16_t is_epilogue_begin : 1;
166
167 /// Indicates this entry is that of the first byte after the end of a sequence
168 /// of target machine instructions.
169 uint16_t is_terminal_entry : 1;
170};
171
172/// Less than operator.
173///
174/// \param[in] lhs
175/// The Left Hand Side const LineEntry object reference.
176///
177/// \param[in] rhs
178/// The Right Hand Side const LineEntry object reference.
179///
180/// \return
181/// Returns \b true if lhs < rhs, false otherwise.
182bool operator<(const LineEntry &lhs, const LineEntry &rhs);
183
184} // namespace lldb_private
185
186#endif // LLDB_SYMBOL_LINEENTRY_H
A section + offset based address range class.
Definition: AddressRange.h:25
DumpStyle
Dump styles allow the Address::Dump(Stream *,DumpStyle) const function to display Address contents in...
Definition: Address.h:66
A class that describes a compilation unit.
Definition: CompileUnit.h:43
A file utility class.
Definition: FileSpec.h:56
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
#define LLDB_INVALID_LINE_NUMBER
Definition: lldb-defines.h:94
A class that represents a running process on the host machine.
bool operator<(const Address &lhs, const Address &rhs)
Definition: Address.cpp:992
DescriptionLevel
Description levels for "void GetDescription(Stream *, DescriptionLevel)" calls.
std::shared_ptr< lldb_private::SupportFile > SupportFileSP
Definition: lldb-forward.h:475
std::shared_ptr< lldb_private::Target > TargetSP
Definition: lldb-forward.h:444
A line table entry class.
Definition: LineEntry.h:21
uint16_t column
The column number of the source line, or zero if there is no column information.
Definition: LineEntry.h:151
uint16_t is_epilogue_begin
Indicates this entry is one (of possibly many) where execution should be suspended for an exit breakp...
Definition: LineEntry.h:165
void Clear()
Clear the object's state.
Definition: LineEntry.cpp:22
bool Dump(Stream *s, Target *target, bool show_file, Address::DumpStyle style, Address::DumpStyle fallback_style, bool show_range) const
Dump a description of this object to a Stream.
Definition: LineEntry.cpp:60
lldb::SupportFileSP original_file_sp
The original source file, from debug info.
Definition: LineEntry.h:143
AddressRange GetSameLineContiguousAddressRange(bool include_inlined_functions) const
Give the range for this LineEntry + any additional LineEntries for this same source line that are con...
Definition: LineEntry.cpp:182
bool IsValid() const
Check if a line entry object is valid.
Definition: LineEntry.cpp:35
static int Compare(const LineEntry &lhs, const LineEntry &rhs)
Compare two LineEntry objects.
Definition: LineEntry.cpp:147
AddressRange range
The section offset address range for this line entry.
Definition: LineEntry.h:137
uint32_t line
The source line number, or LLDB_INVALID_LINE_NUMBER if there is no line number information.
Definition: LineEntry.h:147
LineEntry()
Default constructor.
Definition: LineEntry.cpp:16
bool GetDescription(Stream *s, lldb::DescriptionLevel level, CompileUnit *cu, Target *target, bool show_address_only) const
Definition: LineEntry.cpp:95
uint16_t is_start_of_basic_block
Indicates this entry is the beginning of a basic block.
Definition: LineEntry.h:157
bool DumpStopContext(Stream *s, bool show_fullpaths) const
Dumps information specific to a process that stops at this line entry to the supplied stream s.
Definition: LineEntry.cpp:39
const FileSpec & GetFile() const
Helper to access the file.
Definition: LineEntry.h:134
uint16_t is_prologue_end
Indicates this entry is one (of possibly many) where execution should be suspended for an entry break...
Definition: LineEntry.h:161
lldb::SupportFileSP file_sp
The source file, possibly mapped by the target.source-map setting.
Definition: LineEntry.h:140
uint16_t is_terminal_entry
Indicates this entry is that of the first byte after the end of a sequence of target machine instruct...
Definition: LineEntry.h:169
void ApplyFileMappings(lldb::TargetSP target_sp)
Apply file mappings from target.source-map to the LineEntry's file.
Definition: LineEntry.cpp:244
uint16_t is_start_of_statement
Indicates this entry is the beginning of a statement.
Definition: LineEntry.h:154