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 17 namespace lldb_private { 18 19 /// \class LineEntry LineEntry.h "lldb/Symbol/LineEntry.h" 20 /// A line table entry class. 21 struct 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 /// Helper to access the file. GetFileLineEntry134 const FileSpec &GetFile() const { return file_sp->GetSpecOnly(); } 135 136 /// The section offset address range for this line entry. 137 AddressRange range; 138 139 /// The source file, possibly mapped by the target.source-map setting. 140 lldb::SupportFileSP file_sp; 141 142 /// The original source file, from debug info. 143 lldb::SupportFileSP original_file_sp; 144 145 /// The source line number, or LLDB_INVALID_LINE_NUMBER if there is no line 146 /// number information. 147 uint32_t line = LLDB_INVALID_LINE_NUMBER; 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. 154 uint16_t is_start_of_statement : 1; 155 156 /// Indicates this entry is the beginning of a basic block. 157 uint16_t is_start_of_basic_block : 1; 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. 182 bool operator<(const LineEntry &lhs, const LineEntry &rhs); 183 184 } // namespace lldb_private 185 186 #endif // LLDB_SYMBOL_LINEENTRY_H 187