StackFrame.h revision 69aa5d9a7620a183cdc4da12cc87ea82e2ffcbf9
1//===-- StackFrame.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_StackFrame_h_
11#define liblldb_StackFrame_h_
12
13// C Includes
14// C++ Includes
15// Other libraries and framework includes
16// Project includes
17#include "lldb/Core/Error.h"
18#include "lldb/Core/Flags.h"
19#include "lldb/Core/Scalar.h"
20#include "lldb/Core/StreamString.h"
21#include "lldb/Core/UserID.h"
22#include "lldb/Core/ValueObjectList.h"
23#include "lldb/Symbol/SymbolContext.h"
24#include "lldb/Target/ExecutionContextScope.h"
25#include "lldb/Target/StackID.h"
26
27namespace lldb_private {
28
29class StackFrame :
30    public ExecutionContextScope
31{
32public:
33    //------------------------------------------------------------------
34    // Constructors and Destructors
35    //------------------------------------------------------------------
36    StackFrame (lldb::user_id_t frame_idx,
37                lldb::user_id_t unwind_frame_idx,
38                Thread &thread,
39                lldb::addr_t cfa,
40                lldb::addr_t pc,
41                const SymbolContext *sc_ptr);
42
43    StackFrame (lldb::user_id_t frame_idx,
44                lldb::user_id_t unwind_frame_idx,
45                Thread &thread,
46                const lldb::RegisterContextSP &reg_context_sp,
47                lldb::addr_t cfa,
48                lldb::addr_t pc,
49                const SymbolContext *sc_ptr);
50
51    StackFrame (lldb::user_id_t frame_idx,
52                lldb::user_id_t unwind_frame_idx,
53                Thread &thread,
54                const lldb::RegisterContextSP &reg_context_sp,
55                lldb::addr_t cfa,
56                const Address& pc,
57                const SymbolContext *sc_ptr);
58
59    virtual ~StackFrame ();
60
61    Thread &
62    GetThread()
63    { return m_thread; }
64
65    const Thread &
66    GetThread() const
67    { return m_thread; }
68
69    StackID&
70    GetStackID();
71
72    Address&
73    GetFrameCodeAddress();
74
75    void
76    ChangePC (lldb::addr_t pc);
77
78    const SymbolContext&
79    GetSymbolContext (uint32_t resolve_scope);
80
81    bool
82    GetFrameBaseValue(Scalar &value, Error *error_ptr);
83
84    Block *
85    GetFrameBlock ();
86
87    RegisterContext *
88    GetRegisterContext ();
89
90    const lldb::RegisterContextSP &
91    GetRegisterContextSP () const
92    {
93        return m_reg_context_sp;
94    }
95
96    VariableList *
97    GetVariableList (bool get_file_globals);
98
99    bool
100    HasDebugInformation ();
101
102    const char *
103    Disassemble ();
104
105    void
106    Dump (Stream *strm, bool show_frame_index, bool show_fullpaths);
107
108    bool
109    IsInlined ();
110
111    uint32_t
112    GetFrameIndex () const
113    {
114        return m_frame_index;
115    }
116
117    uint32_t
118    GetUnwindFrameIndex () const
119    {
120        return m_unwind_frame_index;
121    }
122
123    lldb::ValueObjectSP
124    GetValueObjectForFrameVariable (const lldb::VariableSP &variable_sp);
125
126    lldb::ValueObjectSP
127    TrackGlobalVariable (const lldb::VariableSP &variable_sp);
128
129    //------------------------------------------------------------------
130    // lldb::ExecutionContextScope pure virtual functions
131    //------------------------------------------------------------------
132    virtual Target *
133    CalculateTarget ();
134
135    virtual Process *
136    CalculateProcess ();
137
138    virtual Thread *
139    CalculateThread ();
140
141    virtual StackFrame *
142    CalculateStackFrame ();
143
144    virtual void
145    Calculate (ExecutionContext &exe_ctx);
146
147protected:
148    friend class StackFrameList;
149
150    void
151    SetSymbolContextScope (SymbolContextScope *symbol_scope);
152
153    void
154    UpdateCurrentFrameFromPreviousFrame (StackFrame &prev_frame);
155
156    void
157    UpdatePreviousFrameFromCurrentFrame (StackFrame &curr_frame);
158
159    bool
160    HasCachedData () const;
161private:
162    //------------------------------------------------------------------
163    // For StackFrame only
164    //------------------------------------------------------------------
165    Thread &m_thread;
166    uint32_t m_frame_index;
167    uint32_t m_unwind_frame_index;
168    lldb::RegisterContextSP m_reg_context_sp;
169    StackID m_id;
170    Address m_frame_code_addr;   // The frame code address (might not be the same as the actual PC for inlined frames) as a section/offset address
171    SymbolContext m_sc;
172    Flags m_flags;
173    Scalar m_frame_base;
174    Error m_frame_base_error;
175    lldb::VariableListSP m_variable_list_sp;
176    ValueObjectList m_variable_list_value_objects;  // Value objects for each variable in m_variable_list_sp
177    StreamString m_disassembly;
178    DISALLOW_COPY_AND_ASSIGN (StackFrame);
179};
180
181} // namespace lldb_private
182
183#endif  // liblldb_StackFrame_h_
184