xref: /freebsd/contrib/llvm-project/lldb/include/lldb/API/SBFrame.h (revision 5f757f3ff9144b609b3c433dfd370cc6bdc191ad)
10b57cec5SDimitry Andric //===-- SBFrame.h -----------------------------------------------*- C++ -*-===//
20b57cec5SDimitry Andric //
30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
60b57cec5SDimitry Andric //
70b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
80b57cec5SDimitry Andric 
95ffd83dbSDimitry Andric #ifndef LLDB_API_SBFRAME_H
105ffd83dbSDimitry Andric #define LLDB_API_SBFRAME_H
110b57cec5SDimitry Andric 
120b57cec5SDimitry Andric #include "lldb/API/SBDefines.h"
130b57cec5SDimitry Andric #include "lldb/API/SBValueList.h"
140b57cec5SDimitry Andric 
1506c3fb27SDimitry Andric namespace lldb_private {
1606c3fb27SDimitry Andric namespace python {
1706c3fb27SDimitry Andric class SWIGBridge;
1806c3fb27SDimitry Andric }
1906c3fb27SDimitry Andric namespace lua {
2006c3fb27SDimitry Andric class SWIGBridge;
2106c3fb27SDimitry Andric }
2206c3fb27SDimitry Andric } // namespace lldb_private
2306c3fb27SDimitry Andric 
240b57cec5SDimitry Andric namespace lldb {
250b57cec5SDimitry Andric 
260b57cec5SDimitry Andric class LLDB_API SBFrame {
270b57cec5SDimitry Andric public:
280b57cec5SDimitry Andric   SBFrame();
290b57cec5SDimitry Andric 
300b57cec5SDimitry Andric   SBFrame(const lldb::SBFrame &rhs);
310b57cec5SDimitry Andric 
320b57cec5SDimitry Andric   const lldb::SBFrame &operator=(const lldb::SBFrame &rhs);
330b57cec5SDimitry Andric 
340b57cec5SDimitry Andric   ~SBFrame();
350b57cec5SDimitry Andric 
360b57cec5SDimitry Andric   bool IsEqual(const lldb::SBFrame &that) const;
370b57cec5SDimitry Andric 
380b57cec5SDimitry Andric   explicit operator bool() const;
390b57cec5SDimitry Andric 
400b57cec5SDimitry Andric   bool IsValid() const;
410b57cec5SDimitry Andric 
420b57cec5SDimitry Andric   uint32_t GetFrameID() const;
430b57cec5SDimitry Andric 
440b57cec5SDimitry Andric   lldb::addr_t GetCFA() const;
450b57cec5SDimitry Andric 
460b57cec5SDimitry Andric   lldb::addr_t GetPC() const;
470b57cec5SDimitry Andric 
480b57cec5SDimitry Andric   bool SetPC(lldb::addr_t new_pc);
490b57cec5SDimitry Andric 
500b57cec5SDimitry Andric   lldb::addr_t GetSP() const;
510b57cec5SDimitry Andric 
520b57cec5SDimitry Andric   lldb::addr_t GetFP() const;
530b57cec5SDimitry Andric 
540b57cec5SDimitry Andric   lldb::SBAddress GetPCAddress() const;
550b57cec5SDimitry Andric 
560b57cec5SDimitry Andric   lldb::SBSymbolContext GetSymbolContext(uint32_t resolve_scope) const;
570b57cec5SDimitry Andric 
580b57cec5SDimitry Andric   lldb::SBModule GetModule() const;
590b57cec5SDimitry Andric 
600b57cec5SDimitry Andric   lldb::SBCompileUnit GetCompileUnit() const;
610b57cec5SDimitry Andric 
620b57cec5SDimitry Andric   lldb::SBFunction GetFunction() const;
630b57cec5SDimitry Andric 
640b57cec5SDimitry Andric   lldb::SBSymbol GetSymbol() const;
650b57cec5SDimitry Andric 
660b57cec5SDimitry Andric   /// Gets the deepest block that contains the frame PC.
670b57cec5SDimitry Andric   ///
680b57cec5SDimitry Andric   /// See also GetFrameBlock().
690b57cec5SDimitry Andric   lldb::SBBlock GetBlock() const;
700b57cec5SDimitry Andric 
710b57cec5SDimitry Andric   /// Get the appropriate function name for this frame. Inlined functions in
720b57cec5SDimitry Andric   /// LLDB are represented by Blocks that have inlined function information, so
730b57cec5SDimitry Andric   /// just looking at the SBFunction or SBSymbol for a frame isn't enough.
740b57cec5SDimitry Andric   /// This function will return the appropriate function, symbol or inlined
750b57cec5SDimitry Andric   /// function name for the frame.
760b57cec5SDimitry Andric   ///
770b57cec5SDimitry Andric   /// This function returns:
780b57cec5SDimitry Andric   /// - the name of the inlined function (if there is one)
790b57cec5SDimitry Andric   /// - the name of the concrete function (if there is one)
800b57cec5SDimitry Andric   /// - the name of the symbol (if there is one)
810b57cec5SDimitry Andric   /// - NULL
820b57cec5SDimitry Andric   ///
830b57cec5SDimitry Andric   /// See also IsInlined().
840b57cec5SDimitry Andric   const char *GetFunctionName();
850b57cec5SDimitry Andric 
860b57cec5SDimitry Andric   // Get an appropriate function name for this frame that is suitable for
870b57cec5SDimitry Andric   // display to a user
880b57cec5SDimitry Andric   const char *GetDisplayFunctionName();
890b57cec5SDimitry Andric 
900b57cec5SDimitry Andric   const char *GetFunctionName() const;
910b57cec5SDimitry Andric 
920b57cec5SDimitry Andric   // Return the frame function's language.  If there isn't a function, then
930b57cec5SDimitry Andric   // guess the language type from the mangled name.
940b57cec5SDimitry Andric   lldb::LanguageType GuessLanguage() const;
950b57cec5SDimitry Andric 
960b57cec5SDimitry Andric   /// Return true if this frame represents an inlined function.
970b57cec5SDimitry Andric   ///
980b57cec5SDimitry Andric   /// See also GetFunctionName().
990b57cec5SDimitry Andric   bool IsInlined();
1000b57cec5SDimitry Andric 
1010b57cec5SDimitry Andric   bool IsInlined() const;
1020b57cec5SDimitry Andric 
1030b57cec5SDimitry Andric   bool IsArtificial();
1040b57cec5SDimitry Andric 
1050b57cec5SDimitry Andric   bool IsArtificial() const;
1060b57cec5SDimitry Andric 
1070b57cec5SDimitry Andric   /// The version that doesn't supply a 'use_dynamic' value will use the
1080b57cec5SDimitry Andric   /// target's default.
1090b57cec5SDimitry Andric   lldb::SBValue EvaluateExpression(const char *expr);
1100b57cec5SDimitry Andric 
1110b57cec5SDimitry Andric   lldb::SBValue EvaluateExpression(const char *expr,
1120b57cec5SDimitry Andric                                    lldb::DynamicValueType use_dynamic);
1130b57cec5SDimitry Andric 
1140b57cec5SDimitry Andric   lldb::SBValue EvaluateExpression(const char *expr,
1150b57cec5SDimitry Andric                                    lldb::DynamicValueType use_dynamic,
1160b57cec5SDimitry Andric                                    bool unwind_on_error);
1170b57cec5SDimitry Andric 
1180b57cec5SDimitry Andric   lldb::SBValue EvaluateExpression(const char *expr,
1190b57cec5SDimitry Andric                                    const SBExpressionOptions &options);
1200b57cec5SDimitry Andric 
1210b57cec5SDimitry Andric   /// Gets the lexical block that defines the stack frame. Another way to think
1220b57cec5SDimitry Andric   /// of this is it will return the block that contains all of the variables
1230b57cec5SDimitry Andric   /// for a stack frame. Inlined functions are represented as SBBlock objects
1240b57cec5SDimitry Andric   /// that have inlined function information: the name of the inlined function,
1250b57cec5SDimitry Andric   /// where it was called from. The block that is returned will be the first
1260b57cec5SDimitry Andric   /// block at or above the block for the PC (SBFrame::GetBlock()) that defines
1270b57cec5SDimitry Andric   /// the scope of the frame. When a function contains no inlined functions,
1280b57cec5SDimitry Andric   /// this will be the top most lexical block that defines the function.
1290b57cec5SDimitry Andric   /// When a function has inlined functions and the PC is currently
1300b57cec5SDimitry Andric   /// in one of those inlined functions, this method will return the inlined
1310b57cec5SDimitry Andric   /// block that defines this frame. If the PC isn't currently in an inlined
1320b57cec5SDimitry Andric   /// function, the lexical block that defines the function is returned.
1330b57cec5SDimitry Andric   lldb::SBBlock GetFrameBlock() const;
1340b57cec5SDimitry Andric 
1350b57cec5SDimitry Andric   lldb::SBLineEntry GetLineEntry() const;
1360b57cec5SDimitry Andric 
1370b57cec5SDimitry Andric   lldb::SBThread GetThread() const;
1380b57cec5SDimitry Andric 
1390b57cec5SDimitry Andric   const char *Disassemble() const;
1400b57cec5SDimitry Andric 
1410b57cec5SDimitry Andric   void Clear();
1420b57cec5SDimitry Andric 
1430b57cec5SDimitry Andric   bool operator==(const lldb::SBFrame &rhs) const;
1440b57cec5SDimitry Andric 
1450b57cec5SDimitry Andric   bool operator!=(const lldb::SBFrame &rhs) const;
1460b57cec5SDimitry Andric 
1470b57cec5SDimitry Andric   /// The version that doesn't supply a 'use_dynamic' value will use the
1480b57cec5SDimitry Andric   /// target's default.
1490b57cec5SDimitry Andric   lldb::SBValueList GetVariables(bool arguments, bool locals, bool statics,
1500b57cec5SDimitry Andric                                  bool in_scope_only);
1510b57cec5SDimitry Andric 
1520b57cec5SDimitry Andric   lldb::SBValueList GetVariables(bool arguments, bool locals, bool statics,
1530b57cec5SDimitry Andric                                  bool in_scope_only,
1540b57cec5SDimitry Andric                                  lldb::DynamicValueType use_dynamic);
1550b57cec5SDimitry Andric 
1560b57cec5SDimitry Andric   lldb::SBValueList GetVariables(const lldb::SBVariablesOptions &options);
1570b57cec5SDimitry Andric 
1580b57cec5SDimitry Andric   lldb::SBValueList GetRegisters();
1590b57cec5SDimitry Andric 
1600b57cec5SDimitry Andric   lldb::SBValue FindRegister(const char *name);
1610b57cec5SDimitry Andric 
1620b57cec5SDimitry Andric   /// The version that doesn't supply a 'use_dynamic' value will use the
1630b57cec5SDimitry Andric   /// target's default.
1640b57cec5SDimitry Andric   lldb::SBValue FindVariable(const char *var_name);
1650b57cec5SDimitry Andric 
1660b57cec5SDimitry Andric   lldb::SBValue FindVariable(const char *var_name,
1670b57cec5SDimitry Andric                              lldb::DynamicValueType use_dynamic);
1680b57cec5SDimitry Andric 
1690b57cec5SDimitry Andric   // Find a value for a variable expression path like "rect.origin.x" or
1700b57cec5SDimitry Andric   // "pt_ptr->x", "*self", "*this->obj_ptr". The returned value is _not_ and
1710b57cec5SDimitry Andric   // expression result and is not a constant object like
1720b57cec5SDimitry Andric   // SBFrame::EvaluateExpression(...) returns, but a child object of the
1730b57cec5SDimitry Andric   // variable value.
1740b57cec5SDimitry Andric   lldb::SBValue GetValueForVariablePath(const char *var_expr_cstr,
1750b57cec5SDimitry Andric                                         DynamicValueType use_dynamic);
1760b57cec5SDimitry Andric 
1770b57cec5SDimitry Andric   /// The version that doesn't supply a 'use_dynamic' value will use the
1780b57cec5SDimitry Andric   /// target's default.
1790b57cec5SDimitry Andric   lldb::SBValue GetValueForVariablePath(const char *var_path);
1800b57cec5SDimitry Andric 
1810b57cec5SDimitry Andric   /// Find variables, register sets, registers, or persistent variables using
1820b57cec5SDimitry Andric   /// the frame as the scope.
1830b57cec5SDimitry Andric   ///
1840b57cec5SDimitry Andric   /// NB. This function does not look up ivars in the function object pointer.
1850b57cec5SDimitry Andric   /// To do that use GetValueForVariablePath.
1860b57cec5SDimitry Andric   ///
1870b57cec5SDimitry Andric   /// The version that doesn't supply a 'use_dynamic' value will use the
1880b57cec5SDimitry Andric   /// target's default.
1890b57cec5SDimitry Andric   lldb::SBValue FindValue(const char *name, ValueType value_type);
1900b57cec5SDimitry Andric 
1910b57cec5SDimitry Andric   lldb::SBValue FindValue(const char *name, ValueType value_type,
1920b57cec5SDimitry Andric                           lldb::DynamicValueType use_dynamic);
1930b57cec5SDimitry Andric 
1940b57cec5SDimitry Andric   bool GetDescription(lldb::SBStream &description);
195*5f757f3fSDimitry Andric 
196*5f757f3fSDimitry Andric   /// Similar to \a GetDescription() but the format of the description can be
197*5f757f3fSDimitry Andric   /// configured via the \p format parameter. See
198*5f757f3fSDimitry Andric   /// https://lldb.llvm.org/use/formatting.html for more information on format
199*5f757f3fSDimitry Andric   /// strings.
200*5f757f3fSDimitry Andric   ///
201*5f757f3fSDimitry Andric   /// \param[in] format
202*5f757f3fSDimitry Andric   ///   The format to use for generating the description.
203*5f757f3fSDimitry Andric   ///
204*5f757f3fSDimitry Andric   /// \param[out] output
205*5f757f3fSDimitry Andric   ///   The stream where the description will be written to.
206*5f757f3fSDimitry Andric   ///
207*5f757f3fSDimitry Andric   /// \return
208*5f757f3fSDimitry Andric   ///   An error object with an error message in case of failures.
209*5f757f3fSDimitry Andric   SBError GetDescriptionWithFormat(const SBFormat &format, SBStream &output);
2100b57cec5SDimitry Andric 
2110b57cec5SDimitry Andric protected:
2120b57cec5SDimitry Andric   friend class SBBlock;
2130b57cec5SDimitry Andric   friend class SBExecutionContext;
2140b57cec5SDimitry Andric   friend class SBInstruction;
2150b57cec5SDimitry Andric   friend class SBThread;
2160b57cec5SDimitry Andric   friend class SBValue;
2170b57cec5SDimitry Andric 
21806c3fb27SDimitry Andric   friend class lldb_private::python::SWIGBridge;
21906c3fb27SDimitry Andric   friend class lldb_private::lua::SWIGBridge;
22006c3fb27SDimitry Andric 
22106c3fb27SDimitry Andric   SBFrame(const lldb::StackFrameSP &lldb_object_sp);
22206c3fb27SDimitry Andric 
2230b57cec5SDimitry Andric   lldb::StackFrameSP GetFrameSP() const;
2240b57cec5SDimitry Andric 
2250b57cec5SDimitry Andric   void SetFrameSP(const lldb::StackFrameSP &lldb_object_sp);
2260b57cec5SDimitry Andric 
2270b57cec5SDimitry Andric   lldb::ExecutionContextRefSP m_opaque_sp;
2280b57cec5SDimitry Andric };
2290b57cec5SDimitry Andric 
2300b57cec5SDimitry Andric } // namespace lldb
2310b57cec5SDimitry Andric 
2325ffd83dbSDimitry Andric #endif // LLDB_API_SBFRAME_H
233