1 //===-- LineEntry.h ---------------------------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #ifndef liblldb_LineEntry_h_
11 #define liblldb_LineEntry_h_
12 
13 #include "lldb/lldb-private.h"
14 #include "lldb/Core/AddressRange.h"
15 #include "lldb/Host/FileSpec.h"
16 
17 namespace lldb_private {
18 
19 //----------------------------------------------------------------------
20 /// @class LineEntry LineEntry.h "lldb/Symbol/LineEntry.h"
21 /// @brief A line table entry class.
22 //----------------------------------------------------------------------
23 struct LineEntry
24 {
25     //------------------------------------------------------------------
26     /// Default constructor.
27     ///
28     /// Initialize all member variables to invalid values.
29     //------------------------------------------------------------------
30     LineEntry ();
31 
32     LineEntry
33     (
34         const lldb::SectionSP &section_sp,
35         lldb::addr_t section_offset,
36         lldb::addr_t byte_size,
37         const FileSpec &file,
38         uint32_t _line,
39         uint16_t _column,
40         bool _is_start_of_statement,
41         bool _is_start_of_basic_block,
42         bool _is_prologue_end,
43         bool _is_epilogue_begin,
44         bool _is_terminal_entry
45     );
46 
47     //------------------------------------------------------------------
48     /// Clear the object's state.
49     ///
50     /// Clears all member variables to invalid values.
51     //------------------------------------------------------------------
52     void
53     Clear ();
54 
55     //------------------------------------------------------------------
56     /// Dump a description of this object to a Stream.
57     ///
58     /// Dump a description of the contents of this object to the
59     /// supplied stream \a s.
60     ///
61     /// @param[in] s
62     ///     The stream to which to dump the object descripton.
63     ///
64     /// @param[in] comp_unit
65     ///     The compile unit object that contains the support file
66     ///     list so the line entry can dump the file name (since this
67     ///     object contains a file index into the support file list).
68     ///
69     /// @param[in] show_file
70     ///     If \b true, display the filename with the line entry which
71     ///     requires that the compile unit object \a comp_unit be a
72     ///     valid pointer.
73     ///
74     /// @param[in] style
75     ///     The display style for the section offset address.
76     ///
77     /// @return
78     ///     Returns \b true if the address was able to be displayed
79     ///     using \a style. File and load addresses may be unresolved
80     ///     and it may not be possible to display a valid address value.
81     ///     Returns \b false if the address was not able to be properly
82     ///     dumped.
83     ///
84     /// @see Address::DumpStyle
85     //------------------------------------------------------------------
86     bool
87     Dump (Stream *s, Target *target, bool show_file, Address::DumpStyle style, Address::DumpStyle fallback_style, bool show_range) const;
88 
89     bool
90     GetDescription (Stream *s,
91                     lldb::DescriptionLevel level,
92                     CompileUnit* cu,
93                     Target *target,
94                     bool show_address_only) const;
95 
96     //------------------------------------------------------------------
97     /// Dumps information specific to a process that stops at this
98     /// line entry to the supplied stream \a s.
99     ///
100     /// @param[in] s
101     ///     The stream to which to dump the object descripton.
102     ///
103     /// @param[in] comp_unit
104     ///     The compile unit object that contains the support file
105     ///     list so the line entry can dump the file name (since this
106     ///     object contains a file index into the support file list).
107     ///
108     /// @return
109     ///     Returns \b true if the file and line were properly dumped,
110     ///     \b false otherwise.
111     //------------------------------------------------------------------
112     bool
113     DumpStopContext (Stream *s, bool show_fullpaths) const;
114 
115     //------------------------------------------------------------------
116     /// Check if a line entry object is valid.
117     ///
118     /// @return
119     ///     Returns \b true if the line entry contains a valid section
120     ///     offset address, file index, and line number, \b false
121     ///     otherwise.
122     //------------------------------------------------------------------
123     bool
124     IsValid () const;
125 
126     //------------------------------------------------------------------
127     /// Compare two LineEntry objects.
128     ///
129     /// @param[in] lhs
130     ///     The Left Hand Side const LineEntry object reference.
131     ///
132     /// @param[in] rhs
133     ///     The Right Hand Side const LineEntry object reference.
134     ///
135     /// @return
136     ///     @li -1 if lhs < rhs
137     ///     @li 0 if lhs == rhs
138     ///     @li 1 if lhs > rhs
139     //------------------------------------------------------------------
140     static int
141     Compare (const LineEntry& lhs, const LineEntry& rhs);
142 
143 
144     //------------------------------------------------------------------
145     // Member variables.
146     //------------------------------------------------------------------
147     AddressRange    range;                      ///< The section offset address range for this line entry.
148     FileSpec        file;
149     uint32_t        line;                       ///< The source line number, or zero if there is no line number information.
150     uint16_t        column;                     ///< The column number of the source line, or zero if there is no column information.
151     uint16_t        is_start_of_statement:1,    ///< Indicates this entry is the beginning of a statement.
152                     is_start_of_basic_block:1,  ///< Indicates this entry is the beginning of a basic block.
153                     is_prologue_end:1,          ///< Indicates this entry is one (of possibly many) where execution should be suspended for an entry breakpoint of a function.
154                     is_epilogue_begin:1,        ///< Indicates this entry is one (of possibly many) where execution should be suspended for an exit breakpoint of a function.
155                     is_terminal_entry:1;        ///< Indicates this entry is that of the first byte after the end of a sequence of target machine instructions.
156 };
157 
158 //------------------------------------------------------------------
159 /// Less than operator.
160 ///
161 /// @param[in] lhs
162 ///     The Left Hand Side const LineEntry object reference.
163 ///
164 /// @param[in] rhs
165 ///     The Right Hand Side const LineEntry object reference.
166 ///
167 /// @return
168 ///     Returns \b true if lhs < rhs, false otherwise.
169 //------------------------------------------------------------------
170 bool operator<(const LineEntry& lhs, const LineEntry& rhs);
171 
172 } // namespace lldb_private
173 
174 #endif  // liblldb_LineEntry_h_
175