LineEntry.h 6.8 KB

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