LineEntry.h revision 24943d2ee8bfaa7cf5893e4709143924157a5c1e
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/Core/FileSpec.h"
16
17namespace lldb_private {
18
19//----------------------------------------------------------------------
20/// @class LineEntry LineEntry.h "lldb/Symbol/LineEntry.h"
21/// @brief A line table entry class.
22//----------------------------------------------------------------------
23struct LineEntry
24{
25    //------------------------------------------------------------------
26    /// Default constructor.
27    ///
28    /// Initialize all member variables to invalid values.
29    //------------------------------------------------------------------
30    LineEntry ();
31
32    LineEntry
33    (
34        Section *section,
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, Process *process, bool show_file, Address::DumpStyle style, Address::DumpStyle fallback_style, bool show_range) const;
88
89    bool
90    GetDescription (Stream *s, lldb::DescriptionLevel level, CompileUnit* cu, Process *process) const;
91
92    //------------------------------------------------------------------
93    /// Dumps information specific to a process that stops at this
94    /// line entry to the supplied stream \a s.
95    ///
96    /// @param[in] s
97    ///     The stream to which to dump the object descripton.
98    ///
99    /// @param[in] comp_unit
100    ///     The compile unit object that contains the support file
101    ///     list so the line entry can dump the file name (since this
102    ///     object contains a file index into the support file list).
103    ///
104    /// @return
105    ///     Returns \b true if the file and line were properly dumped,
106    ///     \b false otherwise.
107    //------------------------------------------------------------------
108    bool
109    DumpStopContext (Stream *s) const;
110
111    //------------------------------------------------------------------
112    /// Check if a line entry object is valid.
113    ///
114    /// @return
115    ///     Returns \b true if the line entry contains a valid section
116    ///     offset address, file index, and line number, \b false
117    ///     otherwise.
118    //------------------------------------------------------------------
119    bool
120    IsValid () const;
121
122    //------------------------------------------------------------------
123    /// Compare two LineEntry objects.
124    ///
125    /// @param[in] lhs
126    ///     The Left Hand Side const LineEntry object reference.
127    ///
128    /// @param[in] rhs
129    ///     The Right Hand Side const LineEntry object reference.
130    ///
131    /// @return
132    ///     @li -1 if lhs < rhs
133    ///     @li 0 if lhs == rhs
134    ///     @li 1 if lhs > rhs
135    //------------------------------------------------------------------
136    static int
137    Compare (const LineEntry& lhs, const LineEntry& rhs);
138
139
140    //------------------------------------------------------------------
141    // Member variables.
142    //------------------------------------------------------------------
143    AddressRange    range;                      ///< The section offset address range for this line entry.
144    FileSpec        file;
145    uint32_t        line;                       ///< The source line number, or zero if there is no line number information.
146    uint16_t        column;                     ///< The column number of the source line, or zero if there is no column information.
147    uint16_t        is_start_of_statement:1,    ///< Indicates this entry is the beginning of a statement.
148                    is_start_of_basic_block:1,  ///< Indicates this entry is the beginning of a basic block.
149                    is_prologue_end:1,          ///< Indicates this entry is one (of possibly many) where execution should be suspended for an entry breakpoint of a function.
150                    is_epilogue_begin:1,        ///< Indicates this entry is one (of possibly many) where execution should be suspended for an exit breakpoint of a function.
151                    is_terminal_entry:1;        ///< Indicates this entry is that of the first byte after the end of a sequence of target machine instructions.
152};
153
154//------------------------------------------------------------------
155/// Less than operator.
156///
157/// @param[in] lhs
158///     The Left Hand Side const LineEntry object reference.
159///
160/// @param[in] rhs
161///     The Right Hand Side const LineEntry object reference.
162///
163/// @return
164///     Returns \b true if lhs < rhs, false otherwise.
165//------------------------------------------------------------------
166bool operator<(const LineEntry& lhs, const LineEntry& rhs);
167
168} // namespace lldb_private
169
170#endif  // liblldb_LineEntry_h_
171