2010-06-09 00:52:24 +08:00
|
|
|
//===-- SBFrame.cpp ---------------------------------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2010-06-09 15:44:37 +08:00
|
|
|
#include "lldb/API/SBFrame.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <algorithm>
|
|
|
|
|
|
|
|
#include "lldb/lldb-types.h"
|
|
|
|
|
|
|
|
#include "lldb/Core/Address.h"
|
|
|
|
#include "lldb/Core/ConstString.h"
|
2010-10-26 11:11:13 +08:00
|
|
|
#include "lldb/Core/Log.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/Core/Stream.h"
|
|
|
|
#include "lldb/Core/StreamFile.h"
|
|
|
|
#include "lldb/Core/ValueObjectRegister.h"
|
|
|
|
#include "lldb/Core/ValueObjectVariable.h"
|
2010-10-05 11:13:51 +08:00
|
|
|
#include "lldb/Expression/ClangUserExpression.h"
|
2011-06-25 12:35:01 +08:00
|
|
|
#include "lldb/Host/Host.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/Symbol/Block.h"
|
|
|
|
#include "lldb/Symbol/SymbolContext.h"
|
|
|
|
#include "lldb/Symbol/VariableList.h"
|
|
|
|
#include "lldb/Symbol/Variable.h"
|
|
|
|
#include "lldb/Target/ExecutionContext.h"
|
|
|
|
#include "lldb/Target/Target.h"
|
|
|
|
#include "lldb/Target/Process.h"
|
|
|
|
#include "lldb/Target/RegisterContext.h"
|
|
|
|
#include "lldb/Target/StackFrame.h"
|
2012-01-30 15:41:31 +08:00
|
|
|
#include "lldb/Target/StackID.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/Target/Thread.h"
|
|
|
|
|
2010-06-09 15:44:37 +08:00
|
|
|
#include "lldb/API/SBDebugger.h"
|
|
|
|
#include "lldb/API/SBValue.h"
|
|
|
|
#include "lldb/API/SBAddress.h"
|
2010-09-20 13:20:02 +08:00
|
|
|
#include "lldb/API/SBStream.h"
|
2010-06-09 15:44:37 +08:00
|
|
|
#include "lldb/API/SBSymbolContext.h"
|
|
|
|
#include "lldb/API/SBThread.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2012-01-30 15:41:31 +08:00
|
|
|
namespace lldb_private {
|
|
|
|
|
|
|
|
class StackFrameImpl
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
StackFrameImpl (const lldb::StackFrameSP &frame_sp) :
|
|
|
|
m_frame_wp (frame_sp),
|
|
|
|
m_thread_wp (),
|
|
|
|
m_stack_id ()
|
|
|
|
{
|
|
|
|
if (frame_sp)
|
|
|
|
{
|
|
|
|
m_thread_wp = frame_sp->GetThread().shared_from_this();
|
|
|
|
m_stack_id = frame_sp->GetStackID();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
~StackFrameImpl()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
lldb::StackFrameSP
|
|
|
|
GetFrameSP ()
|
|
|
|
{
|
|
|
|
lldb::StackFrameSP frame_sp;
|
|
|
|
// We have a weak pointer to our thread, which might
|
|
|
|
// be NULL'ed out if the thread went away, so first
|
|
|
|
// make sure our thread is still alive.
|
|
|
|
lldb::ThreadSP thread_sp (m_thread_wp.lock());
|
|
|
|
if (thread_sp)
|
|
|
|
{
|
|
|
|
// Our thread is still here, check if our frame
|
|
|
|
// is still alive as well.
|
|
|
|
frame_sp = m_frame_wp.lock();
|
|
|
|
if (frame_sp)
|
|
|
|
{
|
|
|
|
// Our frame is still alive, make sure that our thread
|
|
|
|
// still has this exact frame...
|
|
|
|
lldb::StackFrameSP tmp_frame_sp (thread_sp->GetStackFrameAtIndex (frame_sp->GetFrameIndex()));
|
|
|
|
if (tmp_frame_sp.get() == frame_sp.get())
|
|
|
|
return frame_sp;
|
|
|
|
}
|
|
|
|
// The original stack frame might have gone away,
|
|
|
|
// we need to check for the stac
|
|
|
|
frame_sp = thread_sp->GetFrameWithStackID (m_stack_id);
|
|
|
|
m_frame_wp = frame_sp;
|
|
|
|
}
|
|
|
|
return frame_sp;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SetFrameSP (const lldb::StackFrameSP &frame_sp)
|
|
|
|
{
|
|
|
|
if (frame_sp)
|
|
|
|
{
|
|
|
|
m_frame_wp = frame_sp;
|
|
|
|
m_thread_wp = frame_sp->GetThread().shared_from_this();
|
|
|
|
m_stack_id = frame_sp->GetStackID();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_frame_wp.reset();
|
|
|
|
m_thread_wp.reset();
|
|
|
|
m_stack_id.Clear();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
lldb::StackFrameWP m_frame_wp;
|
|
|
|
lldb::ThreadWP m_thread_wp;
|
|
|
|
StackID m_stack_id;
|
|
|
|
};
|
|
|
|
} // namespace lldb_private
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
using namespace lldb;
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
2012-01-30 15:41:31 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
SBFrame::SBFrame () :
|
2010-06-23 09:19:29 +08:00
|
|
|
m_opaque_sp ()
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2010-12-15 02:39:31 +08:00
|
|
|
SBFrame::SBFrame (const StackFrameSP &lldb_object_sp) :
|
2012-01-30 15:41:31 +08:00
|
|
|
m_opaque_sp (new StackFrameImpl (lldb_object_sp))
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-12-15 02:39:31 +08:00
|
|
|
LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-26 11:11:13 +08:00
|
|
|
|
|
|
|
if (log)
|
|
|
|
{
|
|
|
|
SBStream sstr;
|
|
|
|
GetDescription (sstr);
|
2010-10-30 12:51:46 +08:00
|
|
|
log->Printf ("SBFrame::SBFrame (sp=%p) => SBFrame(%p): %s",
|
2012-01-30 15:41:31 +08:00
|
|
|
lldb_object_sp.get(), lldb_object_sp.get(), sstr.GetData());
|
2010-10-27 07:49:36 +08:00
|
|
|
|
2010-10-26 11:11:13 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2010-11-06 07:17:00 +08:00
|
|
|
SBFrame::SBFrame(const SBFrame &rhs) :
|
|
|
|
m_opaque_sp (rhs.m_opaque_sp)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
const SBFrame &
|
|
|
|
SBFrame::operator = (const SBFrame &rhs)
|
|
|
|
{
|
|
|
|
if (this != &rhs)
|
|
|
|
m_opaque_sp = rhs.m_opaque_sp;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
SBFrame::~SBFrame()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-01-30 15:41:31 +08:00
|
|
|
StackFrameSP
|
|
|
|
SBFrame::GetFrameSP() const
|
|
|
|
{
|
|
|
|
StackFrameImplSP impl_sp (m_opaque_sp);
|
|
|
|
StackFrameSP frame_sp;
|
|
|
|
if (impl_sp)
|
|
|
|
frame_sp = impl_sp->GetFrameSP();
|
|
|
|
return frame_sp;
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
void
|
2012-01-30 15:41:31 +08:00
|
|
|
SBFrame::SetFrameSP (const StackFrameSP &lldb_object_sp)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2012-01-30 15:41:31 +08:00
|
|
|
if (lldb_object_sp)
|
2010-10-30 12:51:46 +08:00
|
|
|
{
|
2012-01-30 15:41:31 +08:00
|
|
|
if (m_opaque_sp)
|
|
|
|
{
|
|
|
|
StackFrameImplSP impl_sp (m_opaque_sp);
|
|
|
|
if (impl_sp)
|
|
|
|
impl_sp->SetFrameSP (lldb_object_sp);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_opaque_sp = StackFrameImplSP (new StackFrameImpl(lldb_object_sp));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_opaque_sp.reset();
|
2010-10-30 12:51:46 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
SBFrame::IsValid() const
|
|
|
|
{
|
2012-01-30 15:41:31 +08:00
|
|
|
StackFrameImplSP impl_sp (m_opaque_sp);
|
|
|
|
if (impl_sp)
|
|
|
|
return (impl_sp->GetFrameSP().get() != NULL);
|
|
|
|
return false;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
SBSymbolContext
|
|
|
|
SBFrame::GetSymbolContext (uint32_t resolve_scope) const
|
|
|
|
{
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
SBSymbolContext sb_sym_ctx;
|
2012-01-30 15:41:31 +08:00
|
|
|
StackFrameSP frame_sp(GetFrameSP());
|
|
|
|
if (frame_sp)
|
2010-12-21 04:49:23 +08:00
|
|
|
{
|
2012-01-30 15:41:31 +08:00
|
|
|
Mutex::Locker api_locker (frame_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
|
|
|
|
sb_sym_ctx.SetSymbolContext(&frame_sp->GetSymbolContext (resolve_scope));
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2010-12-15 02:39:31 +08:00
|
|
|
LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-26 11:11:13 +08:00
|
|
|
if (log)
|
2010-10-30 12:51:46 +08:00
|
|
|
log->Printf ("SBFrame(%p)::GetSymbolContext (resolve_scope=0x%8.8x) => SBSymbolContext(%p)",
|
2012-01-30 15:41:31 +08:00
|
|
|
frame_sp.get(), resolve_scope, sb_sym_ctx.get());
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
return sb_sym_ctx;
|
|
|
|
}
|
|
|
|
|
|
|
|
SBModule
|
|
|
|
SBFrame::GetModule () const
|
|
|
|
{
|
2010-12-14 12:58:53 +08:00
|
|
|
SBModule sb_module;
|
2012-01-30 17:04:36 +08:00
|
|
|
ModuleSP module_sp;
|
2012-01-30 15:41:31 +08:00
|
|
|
StackFrameSP frame_sp(GetFrameSP());
|
|
|
|
if (frame_sp)
|
2010-12-21 04:49:23 +08:00
|
|
|
{
|
2012-01-30 15:41:31 +08:00
|
|
|
Mutex::Locker api_locker (frame_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
|
2012-01-30 17:04:36 +08:00
|
|
|
module_sp = frame_sp->GetSymbolContext (eSymbolContextModule).module_sp;
|
|
|
|
sb_module.SetSP (module_sp);
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2010-12-14 12:58:53 +08:00
|
|
|
|
2010-12-15 02:39:31 +08:00
|
|
|
LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-30 12:51:46 +08:00
|
|
|
if (log)
|
|
|
|
log->Printf ("SBFrame(%p)::GetModule () => SBModule(%p)",
|
2012-01-30 17:04:36 +08:00
|
|
|
frame_sp.get(), module_sp.get());
|
2010-10-30 12:51:46 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
return sb_module;
|
|
|
|
}
|
|
|
|
|
|
|
|
SBCompileUnit
|
|
|
|
SBFrame::GetCompileUnit () const
|
|
|
|
{
|
2010-12-14 12:58:53 +08:00
|
|
|
SBCompileUnit sb_comp_unit;
|
2012-01-30 15:41:31 +08:00
|
|
|
StackFrameSP frame_sp(GetFrameSP());
|
|
|
|
if (frame_sp)
|
2010-12-21 04:49:23 +08:00
|
|
|
{
|
2012-01-30 15:41:31 +08:00
|
|
|
Mutex::Locker api_locker (frame_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
|
|
|
|
sb_comp_unit.reset (frame_sp->GetSymbolContext (eSymbolContextCompUnit).comp_unit);
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2010-12-15 02:39:31 +08:00
|
|
|
LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-26 11:11:13 +08:00
|
|
|
if (log)
|
2010-10-30 12:51:46 +08:00
|
|
|
log->Printf ("SBFrame(%p)::GetModule () => SBCompileUnit(%p)",
|
2012-01-30 15:41:31 +08:00
|
|
|
frame_sp.get(), sb_comp_unit.get());
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
return sb_comp_unit;
|
|
|
|
}
|
|
|
|
|
|
|
|
SBFunction
|
|
|
|
SBFrame::GetFunction () const
|
|
|
|
{
|
2010-12-14 12:58:53 +08:00
|
|
|
SBFunction sb_function;
|
2012-01-30 15:41:31 +08:00
|
|
|
StackFrameSP frame_sp(GetFrameSP());
|
|
|
|
if (frame_sp)
|
2010-12-21 04:49:23 +08:00
|
|
|
{
|
2012-01-30 15:41:31 +08:00
|
|
|
Mutex::Locker api_locker (frame_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
|
|
|
|
sb_function.reset(frame_sp->GetSymbolContext (eSymbolContextFunction).function);
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2010-12-15 02:39:31 +08:00
|
|
|
LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-30 12:51:46 +08:00
|
|
|
if (log)
|
|
|
|
log->Printf ("SBFrame(%p)::GetFunction () => SBFunction(%p)",
|
2012-01-30 15:41:31 +08:00
|
|
|
frame_sp.get(), sb_function.get());
|
2010-10-30 12:51:46 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
return sb_function;
|
|
|
|
}
|
|
|
|
|
2010-10-05 02:37:52 +08:00
|
|
|
SBSymbol
|
|
|
|
SBFrame::GetSymbol () const
|
|
|
|
{
|
2010-12-14 12:58:53 +08:00
|
|
|
SBSymbol sb_symbol;
|
2012-01-30 15:41:31 +08:00
|
|
|
StackFrameSP frame_sp(GetFrameSP());
|
|
|
|
if (frame_sp)
|
2010-12-21 04:49:23 +08:00
|
|
|
{
|
2012-01-30 15:41:31 +08:00
|
|
|
Mutex::Locker api_locker (frame_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
|
|
|
|
sb_symbol.reset(frame_sp->GetSymbolContext (eSymbolContextSymbol).symbol);
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2010-12-15 02:39:31 +08:00
|
|
|
LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-30 12:51:46 +08:00
|
|
|
if (log)
|
|
|
|
log->Printf ("SBFrame(%p)::GetSymbol () => SBSymbol(%p)",
|
2012-01-30 15:41:31 +08:00
|
|
|
frame_sp.get(), sb_symbol.get());
|
2010-10-05 02:37:52 +08:00
|
|
|
return sb_symbol;
|
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
SBBlock
|
|
|
|
SBFrame::GetBlock () const
|
|
|
|
{
|
2010-12-14 12:58:53 +08:00
|
|
|
SBBlock sb_block;
|
2012-01-30 15:41:31 +08:00
|
|
|
StackFrameSP frame_sp(GetFrameSP());
|
|
|
|
if (frame_sp)
|
2010-12-21 04:49:23 +08:00
|
|
|
{
|
2012-01-30 15:41:31 +08:00
|
|
|
Mutex::Locker api_locker (frame_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
|
Removed all of the "#ifndef SWIG" from the SB header files since we are using
interface (.i) files for each class.
Changed the FindFunction class from:
uint32_t
SBTarget::FindFunctions (const char *name,
uint32_t name_type_mask,
bool append,
lldb::SBSymbolContextList& sc_list)
uint32_t
SBModule::FindFunctions (const char *name,
uint32_t name_type_mask,
bool append,
lldb::SBSymbolContextList& sc_list)
To:
lldb::SBSymbolContextList
SBTarget::FindFunctions (const char *name,
uint32_t name_type_mask = lldb::eFunctionNameTypeAny);
lldb::SBSymbolContextList
SBModule::FindFunctions (const char *name,
uint32_t name_type_mask = lldb::eFunctionNameTypeAny);
This makes the API easier to use from python. Also added the ability to
append a SBSymbolContext or a SBSymbolContextList to a SBSymbolContextList.
Exposed properties for lldb.SBSymbolContextList in python:
lldb.SBSymbolContextList.modules => list() or all lldb.SBModule objects in the list
lldb.SBSymbolContextList.compile_units => list() or all lldb.SBCompileUnits objects in the list
lldb.SBSymbolContextList.functions => list() or all lldb.SBFunction objects in the list
lldb.SBSymbolContextList.blocks => list() or all lldb.SBBlock objects in the list
lldb.SBSymbolContextList.line_entries => list() or all lldb.SBLineEntry objects in the list
lldb.SBSymbolContextList.symbols => list() or all lldb.SBSymbol objects in the list
This allows a call to the SBTarget::FindFunctions(...) and SBModule::FindFunctions(...)
and then the result can be used to extract the desired information:
sc_list = lldb.target.FindFunctions("erase")
for function in sc_list.functions:
print function
for symbol in sc_list.symbols:
print symbol
Exposed properties for the lldb.SBSymbolContext objects in python:
lldb.SBSymbolContext.module => lldb.SBModule
lldb.SBSymbolContext.compile_unit => lldb.SBCompileUnit
lldb.SBSymbolContext.function => lldb.SBFunction
lldb.SBSymbolContext.block => lldb.SBBlock
lldb.SBSymbolContext.line_entry => lldb.SBLineEntry
lldb.SBSymbolContext.symbol => lldb.SBSymbol
Exposed properties for the lldb.SBBlock objects in python:
lldb.SBBlock.parent => lldb.SBBlock for the parent block that contains
lldb.SBBlock.sibling => lldb.SBBlock for the sibling block to the current block
lldb.SBBlock.first_child => lldb.SBBlock for the first child block to the current block
lldb.SBBlock.call_site => for inline functions, return a lldb.declaration object that gives the call site file, line and column
lldb.SBBlock.name => for inline functions this is the name of the inline function that this block represents
lldb.SBBlock.inlined_block => returns the inlined function block that contains this block (might return itself if the current block is an inlined block)
lldb.SBBlock.range[int] => access the address ranges for a block by index, a list() with start and end address is returned
lldb.SBBlock.ranges => an array or all address ranges for this block
lldb.SBBlock.num_ranges => the number of address ranges for this blcok
SBFunction objects can now get the SBType and the SBBlock that represents the
top scope of the function.
SBBlock objects can now get the variable list from the current block. The value
list returned allows varaibles to be viewed prior with no process if code
wants to check the variables in a function. There are two ways to get a variable
list from a SBBlock:
lldb::SBValueList
SBBlock::GetVariables (lldb::SBFrame& frame,
bool arguments,
bool locals,
bool statics,
lldb::DynamicValueType use_dynamic);
lldb::SBValueList
SBBlock::GetVariables (lldb::SBTarget& target,
bool arguments,
bool locals,
bool statics);
When a SBFrame is used, the values returned will be locked down to the frame
and the values will be evaluated in the context of that frame.
When a SBTarget is used, global an static variables can be viewed without a
running process.
llvm-svn: 149853
2012-02-06 09:44:54 +08:00
|
|
|
sb_block.SetPtr (frame_sp->GetSymbolContext (eSymbolContextBlock).block);
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2010-12-15 02:39:31 +08:00
|
|
|
LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-30 12:51:46 +08:00
|
|
|
if (log)
|
|
|
|
log->Printf ("SBFrame(%p)::GetBlock () => SBBlock(%p)",
|
Removed all of the "#ifndef SWIG" from the SB header files since we are using
interface (.i) files for each class.
Changed the FindFunction class from:
uint32_t
SBTarget::FindFunctions (const char *name,
uint32_t name_type_mask,
bool append,
lldb::SBSymbolContextList& sc_list)
uint32_t
SBModule::FindFunctions (const char *name,
uint32_t name_type_mask,
bool append,
lldb::SBSymbolContextList& sc_list)
To:
lldb::SBSymbolContextList
SBTarget::FindFunctions (const char *name,
uint32_t name_type_mask = lldb::eFunctionNameTypeAny);
lldb::SBSymbolContextList
SBModule::FindFunctions (const char *name,
uint32_t name_type_mask = lldb::eFunctionNameTypeAny);
This makes the API easier to use from python. Also added the ability to
append a SBSymbolContext or a SBSymbolContextList to a SBSymbolContextList.
Exposed properties for lldb.SBSymbolContextList in python:
lldb.SBSymbolContextList.modules => list() or all lldb.SBModule objects in the list
lldb.SBSymbolContextList.compile_units => list() or all lldb.SBCompileUnits objects in the list
lldb.SBSymbolContextList.functions => list() or all lldb.SBFunction objects in the list
lldb.SBSymbolContextList.blocks => list() or all lldb.SBBlock objects in the list
lldb.SBSymbolContextList.line_entries => list() or all lldb.SBLineEntry objects in the list
lldb.SBSymbolContextList.symbols => list() or all lldb.SBSymbol objects in the list
This allows a call to the SBTarget::FindFunctions(...) and SBModule::FindFunctions(...)
and then the result can be used to extract the desired information:
sc_list = lldb.target.FindFunctions("erase")
for function in sc_list.functions:
print function
for symbol in sc_list.symbols:
print symbol
Exposed properties for the lldb.SBSymbolContext objects in python:
lldb.SBSymbolContext.module => lldb.SBModule
lldb.SBSymbolContext.compile_unit => lldb.SBCompileUnit
lldb.SBSymbolContext.function => lldb.SBFunction
lldb.SBSymbolContext.block => lldb.SBBlock
lldb.SBSymbolContext.line_entry => lldb.SBLineEntry
lldb.SBSymbolContext.symbol => lldb.SBSymbol
Exposed properties for the lldb.SBBlock objects in python:
lldb.SBBlock.parent => lldb.SBBlock for the parent block that contains
lldb.SBBlock.sibling => lldb.SBBlock for the sibling block to the current block
lldb.SBBlock.first_child => lldb.SBBlock for the first child block to the current block
lldb.SBBlock.call_site => for inline functions, return a lldb.declaration object that gives the call site file, line and column
lldb.SBBlock.name => for inline functions this is the name of the inline function that this block represents
lldb.SBBlock.inlined_block => returns the inlined function block that contains this block (might return itself if the current block is an inlined block)
lldb.SBBlock.range[int] => access the address ranges for a block by index, a list() with start and end address is returned
lldb.SBBlock.ranges => an array or all address ranges for this block
lldb.SBBlock.num_ranges => the number of address ranges for this blcok
SBFunction objects can now get the SBType and the SBBlock that represents the
top scope of the function.
SBBlock objects can now get the variable list from the current block. The value
list returned allows varaibles to be viewed prior with no process if code
wants to check the variables in a function. There are two ways to get a variable
list from a SBBlock:
lldb::SBValueList
SBBlock::GetVariables (lldb::SBFrame& frame,
bool arguments,
bool locals,
bool statics,
lldb::DynamicValueType use_dynamic);
lldb::SBValueList
SBBlock::GetVariables (lldb::SBTarget& target,
bool arguments,
bool locals,
bool statics);
When a SBFrame is used, the values returned will be locked down to the frame
and the values will be evaluated in the context of that frame.
When a SBTarget is used, global an static variables can be viewed without a
running process.
llvm-svn: 149853
2012-02-06 09:44:54 +08:00
|
|
|
frame_sp.get(), sb_block.GetPtr());
|
2010-06-09 00:52:24 +08:00
|
|
|
return sb_block;
|
|
|
|
}
|
|
|
|
|
2010-09-07 12:20:48 +08:00
|
|
|
SBBlock
|
|
|
|
SBFrame::GetFrameBlock () const
|
|
|
|
{
|
2010-12-14 12:58:53 +08:00
|
|
|
SBBlock sb_block;
|
2012-01-30 15:41:31 +08:00
|
|
|
StackFrameSP frame_sp(GetFrameSP());
|
|
|
|
if (frame_sp)
|
2010-12-21 04:49:23 +08:00
|
|
|
{
|
2012-01-30 15:41:31 +08:00
|
|
|
Mutex::Locker api_locker (frame_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
|
Removed all of the "#ifndef SWIG" from the SB header files since we are using
interface (.i) files for each class.
Changed the FindFunction class from:
uint32_t
SBTarget::FindFunctions (const char *name,
uint32_t name_type_mask,
bool append,
lldb::SBSymbolContextList& sc_list)
uint32_t
SBModule::FindFunctions (const char *name,
uint32_t name_type_mask,
bool append,
lldb::SBSymbolContextList& sc_list)
To:
lldb::SBSymbolContextList
SBTarget::FindFunctions (const char *name,
uint32_t name_type_mask = lldb::eFunctionNameTypeAny);
lldb::SBSymbolContextList
SBModule::FindFunctions (const char *name,
uint32_t name_type_mask = lldb::eFunctionNameTypeAny);
This makes the API easier to use from python. Also added the ability to
append a SBSymbolContext or a SBSymbolContextList to a SBSymbolContextList.
Exposed properties for lldb.SBSymbolContextList in python:
lldb.SBSymbolContextList.modules => list() or all lldb.SBModule objects in the list
lldb.SBSymbolContextList.compile_units => list() or all lldb.SBCompileUnits objects in the list
lldb.SBSymbolContextList.functions => list() or all lldb.SBFunction objects in the list
lldb.SBSymbolContextList.blocks => list() or all lldb.SBBlock objects in the list
lldb.SBSymbolContextList.line_entries => list() or all lldb.SBLineEntry objects in the list
lldb.SBSymbolContextList.symbols => list() or all lldb.SBSymbol objects in the list
This allows a call to the SBTarget::FindFunctions(...) and SBModule::FindFunctions(...)
and then the result can be used to extract the desired information:
sc_list = lldb.target.FindFunctions("erase")
for function in sc_list.functions:
print function
for symbol in sc_list.symbols:
print symbol
Exposed properties for the lldb.SBSymbolContext objects in python:
lldb.SBSymbolContext.module => lldb.SBModule
lldb.SBSymbolContext.compile_unit => lldb.SBCompileUnit
lldb.SBSymbolContext.function => lldb.SBFunction
lldb.SBSymbolContext.block => lldb.SBBlock
lldb.SBSymbolContext.line_entry => lldb.SBLineEntry
lldb.SBSymbolContext.symbol => lldb.SBSymbol
Exposed properties for the lldb.SBBlock objects in python:
lldb.SBBlock.parent => lldb.SBBlock for the parent block that contains
lldb.SBBlock.sibling => lldb.SBBlock for the sibling block to the current block
lldb.SBBlock.first_child => lldb.SBBlock for the first child block to the current block
lldb.SBBlock.call_site => for inline functions, return a lldb.declaration object that gives the call site file, line and column
lldb.SBBlock.name => for inline functions this is the name of the inline function that this block represents
lldb.SBBlock.inlined_block => returns the inlined function block that contains this block (might return itself if the current block is an inlined block)
lldb.SBBlock.range[int] => access the address ranges for a block by index, a list() with start and end address is returned
lldb.SBBlock.ranges => an array or all address ranges for this block
lldb.SBBlock.num_ranges => the number of address ranges for this blcok
SBFunction objects can now get the SBType and the SBBlock that represents the
top scope of the function.
SBBlock objects can now get the variable list from the current block. The value
list returned allows varaibles to be viewed prior with no process if code
wants to check the variables in a function. There are two ways to get a variable
list from a SBBlock:
lldb::SBValueList
SBBlock::GetVariables (lldb::SBFrame& frame,
bool arguments,
bool locals,
bool statics,
lldb::DynamicValueType use_dynamic);
lldb::SBValueList
SBBlock::GetVariables (lldb::SBTarget& target,
bool arguments,
bool locals,
bool statics);
When a SBFrame is used, the values returned will be locked down to the frame
and the values will be evaluated in the context of that frame.
When a SBTarget is used, global an static variables can be viewed without a
running process.
llvm-svn: 149853
2012-02-06 09:44:54 +08:00
|
|
|
sb_block.SetPtr(frame_sp->GetFrameBlock ());
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2010-12-15 02:39:31 +08:00
|
|
|
LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-30 12:51:46 +08:00
|
|
|
if (log)
|
|
|
|
log->Printf ("SBFrame(%p)::GetFrameBlock () => SBBlock(%p)",
|
Removed all of the "#ifndef SWIG" from the SB header files since we are using
interface (.i) files for each class.
Changed the FindFunction class from:
uint32_t
SBTarget::FindFunctions (const char *name,
uint32_t name_type_mask,
bool append,
lldb::SBSymbolContextList& sc_list)
uint32_t
SBModule::FindFunctions (const char *name,
uint32_t name_type_mask,
bool append,
lldb::SBSymbolContextList& sc_list)
To:
lldb::SBSymbolContextList
SBTarget::FindFunctions (const char *name,
uint32_t name_type_mask = lldb::eFunctionNameTypeAny);
lldb::SBSymbolContextList
SBModule::FindFunctions (const char *name,
uint32_t name_type_mask = lldb::eFunctionNameTypeAny);
This makes the API easier to use from python. Also added the ability to
append a SBSymbolContext or a SBSymbolContextList to a SBSymbolContextList.
Exposed properties for lldb.SBSymbolContextList in python:
lldb.SBSymbolContextList.modules => list() or all lldb.SBModule objects in the list
lldb.SBSymbolContextList.compile_units => list() or all lldb.SBCompileUnits objects in the list
lldb.SBSymbolContextList.functions => list() or all lldb.SBFunction objects in the list
lldb.SBSymbolContextList.blocks => list() or all lldb.SBBlock objects in the list
lldb.SBSymbolContextList.line_entries => list() or all lldb.SBLineEntry objects in the list
lldb.SBSymbolContextList.symbols => list() or all lldb.SBSymbol objects in the list
This allows a call to the SBTarget::FindFunctions(...) and SBModule::FindFunctions(...)
and then the result can be used to extract the desired information:
sc_list = lldb.target.FindFunctions("erase")
for function in sc_list.functions:
print function
for symbol in sc_list.symbols:
print symbol
Exposed properties for the lldb.SBSymbolContext objects in python:
lldb.SBSymbolContext.module => lldb.SBModule
lldb.SBSymbolContext.compile_unit => lldb.SBCompileUnit
lldb.SBSymbolContext.function => lldb.SBFunction
lldb.SBSymbolContext.block => lldb.SBBlock
lldb.SBSymbolContext.line_entry => lldb.SBLineEntry
lldb.SBSymbolContext.symbol => lldb.SBSymbol
Exposed properties for the lldb.SBBlock objects in python:
lldb.SBBlock.parent => lldb.SBBlock for the parent block that contains
lldb.SBBlock.sibling => lldb.SBBlock for the sibling block to the current block
lldb.SBBlock.first_child => lldb.SBBlock for the first child block to the current block
lldb.SBBlock.call_site => for inline functions, return a lldb.declaration object that gives the call site file, line and column
lldb.SBBlock.name => for inline functions this is the name of the inline function that this block represents
lldb.SBBlock.inlined_block => returns the inlined function block that contains this block (might return itself if the current block is an inlined block)
lldb.SBBlock.range[int] => access the address ranges for a block by index, a list() with start and end address is returned
lldb.SBBlock.ranges => an array or all address ranges for this block
lldb.SBBlock.num_ranges => the number of address ranges for this blcok
SBFunction objects can now get the SBType and the SBBlock that represents the
top scope of the function.
SBBlock objects can now get the variable list from the current block. The value
list returned allows varaibles to be viewed prior with no process if code
wants to check the variables in a function. There are two ways to get a variable
list from a SBBlock:
lldb::SBValueList
SBBlock::GetVariables (lldb::SBFrame& frame,
bool arguments,
bool locals,
bool statics,
lldb::DynamicValueType use_dynamic);
lldb::SBValueList
SBBlock::GetVariables (lldb::SBTarget& target,
bool arguments,
bool locals,
bool statics);
When a SBFrame is used, the values returned will be locked down to the frame
and the values will be evaluated in the context of that frame.
When a SBTarget is used, global an static variables can be viewed without a
running process.
llvm-svn: 149853
2012-02-06 09:44:54 +08:00
|
|
|
frame_sp.get(), sb_block.GetPtr());
|
2010-09-07 12:20:48 +08:00
|
|
|
return sb_block;
|
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
SBLineEntry
|
|
|
|
SBFrame::GetLineEntry () const
|
|
|
|
{
|
2010-12-14 12:58:53 +08:00
|
|
|
SBLineEntry sb_line_entry;
|
2012-01-30 15:41:31 +08:00
|
|
|
StackFrameSP frame_sp(GetFrameSP());
|
|
|
|
if (frame_sp)
|
2010-12-21 04:49:23 +08:00
|
|
|
{
|
2012-01-30 15:41:31 +08:00
|
|
|
Mutex::Locker api_locker (frame_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
|
|
|
|
sb_line_entry.SetLineEntry (frame_sp->GetSymbolContext (eSymbolContextLineEntry).line_entry);
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2010-12-15 02:39:31 +08:00
|
|
|
LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-30 12:51:46 +08:00
|
|
|
if (log)
|
|
|
|
log->Printf ("SBFrame(%p)::GetLineEntry () => SBLineEntry(%p)",
|
2012-01-30 15:41:31 +08:00
|
|
|
frame_sp.get(), sb_line_entry.get());
|
2010-06-09 00:52:24 +08:00
|
|
|
return sb_line_entry;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t
|
|
|
|
SBFrame::GetFrameID () const
|
|
|
|
{
|
2012-01-30 15:41:31 +08:00
|
|
|
uint32_t frame_idx = UINT32_MAX;
|
|
|
|
|
|
|
|
|
|
|
|
StackFrameSP frame_sp(GetFrameSP());
|
|
|
|
if (frame_sp)
|
|
|
|
frame_idx = frame_sp->GetFrameIndex ();
|
2010-10-30 12:51:46 +08:00
|
|
|
|
2010-12-15 02:39:31 +08:00
|
|
|
LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-30 12:51:46 +08:00
|
|
|
if (log)
|
|
|
|
log->Printf ("SBFrame(%p)::GetFrameID () => %u",
|
2012-01-30 15:41:31 +08:00
|
|
|
frame_sp.get(), frame_idx);
|
2010-10-30 12:51:46 +08:00
|
|
|
return frame_idx;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2010-12-15 02:39:31 +08:00
|
|
|
addr_t
|
2010-06-09 00:52:24 +08:00
|
|
|
SBFrame::GetPC () const
|
|
|
|
{
|
2010-12-15 02:39:31 +08:00
|
|
|
addr_t addr = LLDB_INVALID_ADDRESS;
|
2012-01-30 15:41:31 +08:00
|
|
|
StackFrameSP frame_sp(GetFrameSP());
|
|
|
|
if (frame_sp)
|
2010-12-21 04:49:23 +08:00
|
|
|
{
|
2012-01-30 15:41:31 +08:00
|
|
|
Mutex::Locker api_locker (frame_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
|
|
|
|
addr = frame_sp->GetFrameCodeAddress().GetOpcodeLoadAddress (&frame_sp->GetThread().GetProcess().GetTarget());
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2010-12-15 02:39:31 +08:00
|
|
|
LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-26 11:11:13 +08:00
|
|
|
if (log)
|
2012-01-30 15:41:31 +08:00
|
|
|
log->Printf ("SBFrame(%p)::GetPC () => 0x%llx", frame_sp.get(), addr);
|
2010-10-26 11:11:13 +08:00
|
|
|
|
|
|
|
return addr;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2010-12-15 02:39:31 +08:00
|
|
|
SBFrame::SetPC (addr_t new_pc)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-10-26 11:11:13 +08:00
|
|
|
bool ret_val = false;
|
2012-01-30 15:41:31 +08:00
|
|
|
StackFrameSP frame_sp(GetFrameSP());
|
|
|
|
if (frame_sp)
|
2010-12-21 04:49:23 +08:00
|
|
|
{
|
2012-01-30 15:41:31 +08:00
|
|
|
Mutex::Locker api_locker (frame_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
|
|
|
|
ret_val = frame_sp->GetRegisterContext()->SetPC (new_pc);
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2010-12-15 02:39:31 +08:00
|
|
|
LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-26 11:11:13 +08:00
|
|
|
if (log)
|
2010-10-30 12:51:46 +08:00
|
|
|
log->Printf ("SBFrame(%p)::SetPC (new_pc=0x%llx) => %i",
|
2012-01-30 15:41:31 +08:00
|
|
|
frame_sp.get(), new_pc, ret_val);
|
2010-10-26 11:11:13 +08:00
|
|
|
|
|
|
|
return ret_val;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2010-12-15 02:39:31 +08:00
|
|
|
addr_t
|
2010-06-09 00:52:24 +08:00
|
|
|
SBFrame::GetSP () const
|
|
|
|
{
|
2010-10-30 12:51:46 +08:00
|
|
|
addr_t addr = LLDB_INVALID_ADDRESS;
|
2012-01-30 15:41:31 +08:00
|
|
|
StackFrameSP frame_sp(GetFrameSP());
|
|
|
|
if (frame_sp)
|
2010-12-21 04:49:23 +08:00
|
|
|
{
|
2012-01-30 15:41:31 +08:00
|
|
|
Mutex::Locker api_locker (frame_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
|
|
|
|
addr = frame_sp->GetRegisterContext()->GetSP();
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2010-12-15 02:39:31 +08:00
|
|
|
LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-30 12:51:46 +08:00
|
|
|
if (log)
|
2012-01-30 15:41:31 +08:00
|
|
|
log->Printf ("SBFrame(%p)::GetSP () => 0x%llx", frame_sp.get(), addr);
|
2010-10-30 12:51:46 +08:00
|
|
|
|
|
|
|
return addr;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-15 02:39:31 +08:00
|
|
|
addr_t
|
2010-06-09 00:52:24 +08:00
|
|
|
SBFrame::GetFP () const
|
|
|
|
{
|
2010-12-15 02:39:31 +08:00
|
|
|
addr_t addr = LLDB_INVALID_ADDRESS;
|
2012-01-30 15:41:31 +08:00
|
|
|
StackFrameSP frame_sp(GetFrameSP());
|
|
|
|
if (frame_sp)
|
2010-12-21 04:49:23 +08:00
|
|
|
{
|
2012-01-30 15:41:31 +08:00
|
|
|
Mutex::Locker api_locker (frame_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
|
|
|
|
addr = frame_sp->GetRegisterContext()->GetFP();
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2010-12-15 02:39:31 +08:00
|
|
|
LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-26 11:11:13 +08:00
|
|
|
if (log)
|
2012-01-30 15:41:31 +08:00
|
|
|
log->Printf ("SBFrame(%p)::GetFP () => 0x%llx", frame_sp.get(), addr);
|
2010-10-26 11:11:13 +08:00
|
|
|
return addr;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SBAddress
|
|
|
|
SBFrame::GetPCAddress () const
|
|
|
|
{
|
|
|
|
SBAddress sb_addr;
|
2012-01-30 15:41:31 +08:00
|
|
|
StackFrameSP frame_sp(GetFrameSP());
|
|
|
|
if (frame_sp)
|
2010-12-21 04:49:23 +08:00
|
|
|
{
|
2012-01-30 15:41:31 +08:00
|
|
|
Mutex::Locker api_locker (frame_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
|
|
|
|
sb_addr.SetAddress (&frame_sp->GetFrameCodeAddress());
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2010-12-15 02:39:31 +08:00
|
|
|
LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-30 12:51:46 +08:00
|
|
|
if (log)
|
2012-01-30 15:41:31 +08:00
|
|
|
log->Printf ("SBFrame(%p)::GetPCAddress () => SBAddress(%p)", frame_sp.get(), sb_addr.get());
|
2010-06-09 00:52:24 +08:00
|
|
|
return sb_addr;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SBFrame::Clear()
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
m_opaque_sp.reset();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2012-02-03 15:02:37 +08:00
|
|
|
lldb::SBValue
|
|
|
|
SBFrame::GetValueForVariablePath (const char *var_path)
|
|
|
|
{
|
|
|
|
SBValue sb_value;
|
|
|
|
StackFrameSP frame_sp(GetFrameSP());
|
|
|
|
if (frame_sp)
|
|
|
|
{
|
|
|
|
lldb::DynamicValueType use_dynamic = frame_sp->CalculateTarget()->GetPreferDynamicValue();
|
|
|
|
sb_value = GetValueForVariablePath (var_path, use_dynamic);
|
|
|
|
}
|
|
|
|
return sb_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
lldb::SBValue
|
|
|
|
SBFrame::GetValueForVariablePath (const char *var_path, DynamicValueType use_dynamic)
|
|
|
|
{
|
|
|
|
SBValue sb_value;
|
|
|
|
StackFrameSP frame_sp(GetFrameSP());
|
|
|
|
if (frame_sp && var_path && var_path[0])
|
|
|
|
{
|
|
|
|
Mutex::Locker api_locker (frame_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
|
|
|
|
VariableSP var_sp;
|
|
|
|
Error error;
|
|
|
|
ValueObjectSP value_sp (frame_sp->GetValueForVariableExpressionPath (var_path,
|
|
|
|
use_dynamic,
|
|
|
|
StackFrame::eExpressionPathOptionCheckPtrVsMember,
|
|
|
|
var_sp,
|
|
|
|
error));
|
2012-02-04 10:27:34 +08:00
|
|
|
sb_value.SetSP(value_sp);
|
2012-02-03 15:02:37 +08:00
|
|
|
}
|
|
|
|
return sb_value;
|
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
SBValue
|
2010-12-15 02:39:31 +08:00
|
|
|
SBFrame::FindVariable (const char *name)
|
2011-04-16 08:01:13 +08:00
|
|
|
{
|
2011-06-19 04:06:08 +08:00
|
|
|
SBValue value;
|
2012-01-30 15:41:31 +08:00
|
|
|
StackFrameSP frame_sp(GetFrameSP());
|
|
|
|
if (frame_sp)
|
2011-06-19 04:06:08 +08:00
|
|
|
{
|
2012-01-30 15:41:31 +08:00
|
|
|
lldb::DynamicValueType use_dynamic = frame_sp->CalculateTarget()->GetPreferDynamicValue();
|
2011-06-19 04:06:08 +08:00
|
|
|
value = FindVariable (name, use_dynamic);
|
|
|
|
}
|
|
|
|
return value;
|
2011-04-16 08:01:13 +08:00
|
|
|
}
|
2012-02-03 15:02:37 +08:00
|
|
|
|
2011-04-16 08:01:13 +08:00
|
|
|
|
|
|
|
SBValue
|
2011-05-04 11:43:18 +08:00
|
|
|
SBFrame::FindVariable (const char *name, lldb::DynamicValueType use_dynamic)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-12-15 02:39:31 +08:00
|
|
|
VariableSP var_sp;
|
2011-04-23 07:53:53 +08:00
|
|
|
SBValue sb_value;
|
2012-02-04 10:27:34 +08:00
|
|
|
ValueObjectSP value_sp;
|
2012-01-30 15:41:31 +08:00
|
|
|
StackFrameSP frame_sp(GetFrameSP());
|
|
|
|
if (frame_sp && name && name[0])
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-12-15 02:39:31 +08:00
|
|
|
VariableList variable_list;
|
2012-01-30 15:41:31 +08:00
|
|
|
Mutex::Locker api_locker (frame_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
|
|
|
|
SymbolContext sc (frame_sp->GetSymbolContext (eSymbolContextBlock));
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2010-12-14 12:58:53 +08:00
|
|
|
if (sc.block)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-12-14 12:58:53 +08:00
|
|
|
const bool can_create = true;
|
|
|
|
const bool get_parent_variables = true;
|
|
|
|
const bool stop_if_block_is_inlined_function = true;
|
|
|
|
|
|
|
|
if (sc.block->AppendVariables (can_create,
|
|
|
|
get_parent_variables,
|
|
|
|
stop_if_block_is_inlined_function,
|
|
|
|
&variable_list))
|
|
|
|
{
|
2010-12-15 02:39:31 +08:00
|
|
|
var_sp = variable_list.FindVariable (ConstString(name));
|
2010-12-14 12:58:53 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2011-06-19 04:06:08 +08:00
|
|
|
|
|
|
|
if (var_sp)
|
2012-02-04 10:27:34 +08:00
|
|
|
{
|
|
|
|
value_sp = frame_sp->GetValueObjectForFrameVariable(var_sp, use_dynamic);
|
|
|
|
sb_value.SetSP(value_sp);
|
|
|
|
}
|
2011-06-19 04:06:08 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2010-09-20 13:20:02 +08:00
|
|
|
|
2010-12-15 02:39:31 +08:00
|
|
|
LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-30 12:51:46 +08:00
|
|
|
if (log)
|
2010-12-15 02:39:31 +08:00
|
|
|
log->Printf ("SBFrame(%p)::FindVariable (name=\"%s\") => SBValue(%p)",
|
2012-02-04 10:27:34 +08:00
|
|
|
frame_sp.get(), name, value_sp.get());
|
2010-10-30 12:51:46 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
return sb_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
SBValue
|
2010-12-15 02:39:31 +08:00
|
|
|
SBFrame::FindValue (const char *name, ValueType value_type)
|
2011-04-16 08:01:13 +08:00
|
|
|
{
|
2011-06-19 04:06:08 +08:00
|
|
|
SBValue value;
|
2012-01-30 15:41:31 +08:00
|
|
|
StackFrameSP frame_sp(GetFrameSP());
|
|
|
|
if (frame_sp)
|
2011-06-19 04:06:08 +08:00
|
|
|
{
|
2012-01-30 15:41:31 +08:00
|
|
|
lldb::DynamicValueType use_dynamic = frame_sp->CalculateTarget()->GetPreferDynamicValue();
|
2011-06-19 04:06:08 +08:00
|
|
|
value = FindValue (name, value_type, use_dynamic);
|
|
|
|
}
|
|
|
|
return value;
|
2011-04-16 08:01:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
SBValue
|
2011-05-04 11:43:18 +08:00
|
|
|
SBFrame::FindValue (const char *name, ValueType value_type, lldb::DynamicValueType use_dynamic)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-12-15 02:39:31 +08:00
|
|
|
SBValue sb_value;
|
2012-02-04 10:27:34 +08:00
|
|
|
ValueObjectSP value_sp;
|
2012-01-30 15:41:31 +08:00
|
|
|
StackFrameSP frame_sp(GetFrameSP());
|
|
|
|
if (frame_sp && name && name[0])
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2012-01-30 15:41:31 +08:00
|
|
|
Mutex::Locker api_locker (frame_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
|
2010-12-15 02:39:31 +08:00
|
|
|
|
|
|
|
switch (value_type)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-12-15 02:39:31 +08:00
|
|
|
case eValueTypeVariableGlobal: // global variable
|
|
|
|
case eValueTypeVariableStatic: // static variable
|
|
|
|
case eValueTypeVariableArgument: // function argument variables
|
|
|
|
case eValueTypeVariableLocal: // function local variables
|
|
|
|
{
|
2012-01-30 15:41:31 +08:00
|
|
|
VariableList *variable_list = frame_sp->GetVariableList(true);
|
2010-12-14 12:58:53 +08:00
|
|
|
|
2012-01-30 15:41:31 +08:00
|
|
|
SymbolContext sc (frame_sp->GetSymbolContext (eSymbolContextBlock));
|
2010-12-14 12:58:53 +08:00
|
|
|
|
2010-12-15 02:39:31 +08:00
|
|
|
const bool can_create = true;
|
|
|
|
const bool get_parent_variables = true;
|
|
|
|
const bool stop_if_block_is_inlined_function = true;
|
|
|
|
|
|
|
|
if (sc.block && sc.block->AppendVariables (can_create,
|
|
|
|
get_parent_variables,
|
|
|
|
stop_if_block_is_inlined_function,
|
|
|
|
variable_list))
|
|
|
|
{
|
|
|
|
ConstString const_name(name);
|
|
|
|
const uint32_t num_variables = variable_list->GetSize();
|
|
|
|
for (uint32_t i = 0; i < num_variables; ++i)
|
|
|
|
{
|
|
|
|
VariableSP variable_sp (variable_list->GetVariableAtIndex(i));
|
|
|
|
if (variable_sp &&
|
|
|
|
variable_sp->GetScope() == value_type &&
|
|
|
|
variable_sp->GetName() == const_name)
|
|
|
|
{
|
2012-02-04 10:27:34 +08:00
|
|
|
value_sp = frame_sp->GetValueObjectForFrameVariable (variable_sp, use_dynamic);
|
|
|
|
sb_value.SetSP (value_sp);
|
2010-12-15 02:39:31 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eValueTypeRegister: // stack frame register value
|
|
|
|
{
|
2012-01-30 15:41:31 +08:00
|
|
|
RegisterContextSP reg_ctx (frame_sp->GetRegisterContext());
|
2010-12-15 02:39:31 +08:00
|
|
|
if (reg_ctx)
|
|
|
|
{
|
|
|
|
const uint32_t num_regs = reg_ctx->GetRegisterCount();
|
|
|
|
for (uint32_t reg_idx = 0; reg_idx < num_regs; ++reg_idx)
|
|
|
|
{
|
|
|
|
const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoAtIndex (reg_idx);
|
|
|
|
if (reg_info &&
|
|
|
|
((reg_info->name && strcasecmp (reg_info->name, name) == 0) ||
|
|
|
|
(reg_info->alt_name && strcasecmp (reg_info->alt_name, name) == 0)))
|
|
|
|
{
|
2012-02-04 10:27:34 +08:00
|
|
|
value_sp = ValueObjectRegister::Create (frame_sp.get(), reg_ctx, reg_idx);
|
|
|
|
sb_value.SetSP (value_sp);
|
|
|
|
break;
|
2010-12-15 02:39:31 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2010-12-14 12:58:53 +08:00
|
|
|
|
2010-12-15 02:39:31 +08:00
|
|
|
case eValueTypeRegisterSet: // A collection of stack frame register values
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2012-01-30 15:41:31 +08:00
|
|
|
RegisterContextSP reg_ctx (frame_sp->GetRegisterContext());
|
2010-12-15 02:39:31 +08:00
|
|
|
if (reg_ctx)
|
2010-11-20 02:07:14 +08:00
|
|
|
{
|
2010-12-15 02:39:31 +08:00
|
|
|
const uint32_t num_sets = reg_ctx->GetRegisterSetCount();
|
|
|
|
for (uint32_t set_idx = 0; set_idx < num_sets; ++set_idx)
|
2010-11-20 02:07:14 +08:00
|
|
|
{
|
2010-12-15 02:39:31 +08:00
|
|
|
const RegisterSet *reg_set = reg_ctx->GetRegisterSet (set_idx);
|
|
|
|
if (reg_set &&
|
|
|
|
((reg_set->name && strcasecmp (reg_set->name, name) == 0) ||
|
|
|
|
(reg_set->short_name && strcasecmp (reg_set->short_name, name) == 0)))
|
|
|
|
{
|
2012-02-04 10:27:34 +08:00
|
|
|
value_sp = ValueObjectRegisterSet::Create (frame_sp.get(), reg_ctx, set_idx);
|
|
|
|
sb_value.SetSP (value_sp);
|
|
|
|
break;
|
2010-12-15 02:39:31 +08:00
|
|
|
}
|
2010-11-20 02:07:14 +08:00
|
|
|
}
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2010-12-15 02:39:31 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case eValueTypeConstResult: // constant result variables
|
|
|
|
{
|
|
|
|
ConstString const_name(name);
|
2012-01-30 15:41:31 +08:00
|
|
|
ClangExpressionVariableSP expr_var_sp (frame_sp->GetThread().GetProcess().GetTarget().GetPersistentVariables().GetVariable (const_name));
|
2010-12-15 02:39:31 +08:00
|
|
|
if (expr_var_sp)
|
2012-02-04 10:27:34 +08:00
|
|
|
{
|
|
|
|
value_sp = expr_var_sp->GetValueObject();
|
|
|
|
sb_value.SetSP (value_sp);
|
|
|
|
}
|
2010-12-15 02:39:31 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
}
|
2010-09-20 13:20:02 +08:00
|
|
|
|
2010-12-15 02:39:31 +08:00
|
|
|
LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-30 12:51:46 +08:00
|
|
|
if (log)
|
2010-12-15 02:39:31 +08:00
|
|
|
log->Printf ("SBFrame(%p)::FindVariableInScope (name=\"%s\", value_type=%i) => SBValue(%p)",
|
2012-02-04 10:27:34 +08:00
|
|
|
frame_sp.get(), name, value_type, value_sp.get());
|
2010-10-30 12:51:46 +08:00
|
|
|
|
2010-09-20 13:20:02 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
return sb_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
SBFrame::operator == (const SBFrame &rhs) const
|
|
|
|
{
|
2012-01-30 15:41:31 +08:00
|
|
|
return GetFrameSP().get() == rhs.GetFrameSP().get();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
SBFrame::operator != (const SBFrame &rhs) const
|
|
|
|
{
|
2012-01-30 15:41:31 +08:00
|
|
|
return GetFrameSP().get() != rhs.GetFrameSP().get();
|
2011-01-21 14:11:58 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
SBThread
|
|
|
|
SBFrame::GetThread () const
|
|
|
|
{
|
2010-12-15 02:39:31 +08:00
|
|
|
LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2010-12-14 12:58:53 +08:00
|
|
|
SBThread sb_thread;
|
2012-01-30 10:53:15 +08:00
|
|
|
ThreadSP thread_sp;
|
2012-01-30 15:41:31 +08:00
|
|
|
StackFrameSP frame_sp(GetFrameSP());
|
|
|
|
if (frame_sp)
|
2010-12-21 04:49:23 +08:00
|
|
|
{
|
2012-01-30 15:41:31 +08:00
|
|
|
Mutex::Locker api_locker (frame_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
|
|
|
|
thread_sp = frame_sp->GetThread().shared_from_this();
|
2012-01-30 10:53:15 +08:00
|
|
|
sb_thread.SetThread (thread_sp);
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2010-10-26 11:11:13 +08:00
|
|
|
|
|
|
|
if (log)
|
2010-10-27 07:49:36 +08:00
|
|
|
{
|
|
|
|
SBStream sstr;
|
|
|
|
sb_thread.GetDescription (sstr);
|
2012-01-30 15:41:31 +08:00
|
|
|
log->Printf ("SBFrame(%p)::GetThread () => SBThread(%p): %s", frame_sp.get(),
|
2012-01-30 10:53:15 +08:00
|
|
|
thread_sp.get(), sstr.GetData());
|
2010-10-27 07:49:36 +08:00
|
|
|
}
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
return sb_thread;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *
|
|
|
|
SBFrame::Disassemble () const
|
|
|
|
{
|
2010-10-30 12:51:46 +08:00
|
|
|
const char *disassembly = NULL;
|
2012-01-30 15:41:31 +08:00
|
|
|
StackFrameSP frame_sp(GetFrameSP());
|
|
|
|
if (frame_sp)
|
2010-12-21 04:49:23 +08:00
|
|
|
{
|
2012-01-30 15:41:31 +08:00
|
|
|
Mutex::Locker api_locker (frame_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
|
|
|
|
disassembly = frame_sp->Disassemble();
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2010-12-15 02:39:31 +08:00
|
|
|
LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2010-10-30 12:51:46 +08:00
|
|
|
if (log)
|
2012-01-30 15:41:31 +08:00
|
|
|
log->Printf ("SBFrame(%p)::Disassemble () => %s", frame_sp.get(), disassembly);
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2010-10-30 12:51:46 +08:00
|
|
|
return disassembly;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SBValueList
|
|
|
|
SBFrame::GetVariables (bool arguments,
|
|
|
|
bool locals,
|
|
|
|
bool statics,
|
|
|
|
bool in_scope_only)
|
2011-04-16 08:01:13 +08:00
|
|
|
{
|
2011-06-19 04:06:08 +08:00
|
|
|
SBValueList value_list;
|
2012-01-30 15:41:31 +08:00
|
|
|
StackFrameSP frame_sp(GetFrameSP());
|
|
|
|
if (frame_sp)
|
2011-06-19 04:06:08 +08:00
|
|
|
{
|
2012-01-30 15:41:31 +08:00
|
|
|
lldb::DynamicValueType use_dynamic = frame_sp->CalculateTarget()->GetPreferDynamicValue();
|
2011-06-19 04:06:08 +08:00
|
|
|
value_list = GetVariables (arguments, locals, statics, in_scope_only, use_dynamic);
|
|
|
|
}
|
|
|
|
return value_list;
|
2011-04-16 08:01:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
SBValueList
|
|
|
|
SBFrame::GetVariables (bool arguments,
|
|
|
|
bool locals,
|
|
|
|
bool statics,
|
|
|
|
bool in_scope_only,
|
2011-05-04 11:43:18 +08:00
|
|
|
lldb::DynamicValueType use_dynamic)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-12-15 02:39:31 +08:00
|
|
|
LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2012-01-30 15:41:31 +08:00
|
|
|
SBValueList value_list;
|
|
|
|
StackFrameSP frame_sp(GetFrameSP());
|
|
|
|
|
2010-10-26 11:11:13 +08:00
|
|
|
if (log)
|
2010-10-30 12:51:46 +08:00
|
|
|
log->Printf ("SBFrame(%p)::GetVariables (arguments=%i, locals=%i, statics=%i, in_scope_only=%i)",
|
2012-01-30 15:41:31 +08:00
|
|
|
frame_sp.get(),
|
2010-10-30 12:51:46 +08:00
|
|
|
arguments,
|
|
|
|
locals,
|
|
|
|
statics,
|
|
|
|
in_scope_only);
|
2012-01-30 15:41:31 +08:00
|
|
|
|
|
|
|
if (frame_sp)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-12-21 04:49:23 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
size_t i;
|
2010-12-21 04:49:23 +08:00
|
|
|
VariableList *variable_list = NULL;
|
|
|
|
// Scope for locker
|
|
|
|
{
|
2012-01-30 15:41:31 +08:00
|
|
|
Mutex::Locker api_locker (frame_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
|
|
|
|
variable_list = frame_sp->GetVariableList(true);
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
if (variable_list)
|
|
|
|
{
|
|
|
|
const size_t num_variables = variable_list->GetSize();
|
|
|
|
if (num_variables)
|
|
|
|
{
|
|
|
|
for (i = 0; i < num_variables; ++i)
|
|
|
|
{
|
|
|
|
VariableSP variable_sp (variable_list->GetVariableAtIndex(i));
|
|
|
|
if (variable_sp)
|
|
|
|
{
|
|
|
|
bool add_variable = false;
|
|
|
|
switch (variable_sp->GetScope())
|
|
|
|
{
|
|
|
|
case eValueTypeVariableGlobal:
|
|
|
|
case eValueTypeVariableStatic:
|
|
|
|
add_variable = statics;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eValueTypeVariableArgument:
|
|
|
|
add_variable = arguments;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eValueTypeVariableLocal:
|
|
|
|
add_variable = locals;
|
|
|
|
break;
|
2010-07-10 04:39:50 +08:00
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
if (add_variable)
|
|
|
|
{
|
2012-01-30 15:41:31 +08:00
|
|
|
if (in_scope_only && !variable_sp->IsInScope(frame_sp.get()))
|
2010-06-09 00:52:24 +08:00
|
|
|
continue;
|
|
|
|
|
2012-01-30 15:41:31 +08:00
|
|
|
value_list.Append(frame_sp->GetValueObjectForFrameVariable (variable_sp, use_dynamic));
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-09-02 10:59:18 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2010-10-26 11:11:13 +08:00
|
|
|
|
|
|
|
if (log)
|
|
|
|
{
|
2012-01-30 15:41:31 +08:00
|
|
|
log->Printf ("SBFrame(%p)::GetVariables (...) => SBValueList(%p)", frame_sp.get(),
|
2010-10-27 07:49:36 +08:00
|
|
|
value_list.get());
|
2010-10-26 11:11:13 +08:00
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
return value_list;
|
|
|
|
}
|
|
|
|
|
2010-12-15 02:39:31 +08:00
|
|
|
SBValueList
|
2010-06-09 00:52:24 +08:00
|
|
|
SBFrame::GetRegisters ()
|
|
|
|
{
|
2010-12-15 02:39:31 +08:00
|
|
|
LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
SBValueList value_list;
|
2012-01-30 15:41:31 +08:00
|
|
|
StackFrameSP frame_sp(GetFrameSP());
|
|
|
|
if (frame_sp)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2012-01-30 15:41:31 +08:00
|
|
|
Mutex::Locker api_locker (frame_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
|
|
|
|
RegisterContextSP reg_ctx (frame_sp->GetRegisterContext());
|
2010-06-09 00:52:24 +08:00
|
|
|
if (reg_ctx)
|
|
|
|
{
|
|
|
|
const uint32_t num_sets = reg_ctx->GetRegisterSetCount();
|
|
|
|
for (uint32_t set_idx = 0; set_idx < num_sets; ++set_idx)
|
|
|
|
{
|
2012-01-30 15:41:31 +08:00
|
|
|
value_list.Append(ValueObjectRegisterSet::Create (frame_sp.get(), reg_ctx, set_idx));
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-10-26 11:11:13 +08:00
|
|
|
|
|
|
|
if (log)
|
2012-01-30 15:41:31 +08:00
|
|
|
log->Printf ("SBFrame(%p)::Registers () => SBValueList(%p)", frame_sp.get(), value_list.get());
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
return value_list;
|
|
|
|
}
|
|
|
|
|
2010-09-20 13:20:02 +08:00
|
|
|
bool
|
|
|
|
SBFrame::GetDescription (SBStream &description)
|
|
|
|
{
|
2011-11-13 14:57:31 +08:00
|
|
|
Stream &strm = description.ref();
|
|
|
|
|
2012-01-30 15:41:31 +08:00
|
|
|
StackFrameSP frame_sp(GetFrameSP());
|
|
|
|
if (frame_sp)
|
2010-09-20 13:20:02 +08:00
|
|
|
{
|
2012-01-30 15:41:31 +08:00
|
|
|
Mutex::Locker api_locker (frame_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
|
|
|
|
frame_sp->DumpUsingSettingsFormat (&strm);
|
2010-09-20 13:20:02 +08:00
|
|
|
}
|
|
|
|
else
|
2011-11-13 14:57:31 +08:00
|
|
|
strm.PutCString ("No value");
|
2010-09-20 13:20:02 +08:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2010-10-05 08:00:42 +08:00
|
|
|
|
2010-12-15 02:39:31 +08:00
|
|
|
SBValue
|
2010-10-05 08:00:42 +08:00
|
|
|
SBFrame::EvaluateExpression (const char *expr)
|
2011-04-16 08:01:13 +08:00
|
|
|
{
|
2011-06-19 04:06:08 +08:00
|
|
|
SBValue result;
|
2012-01-30 15:41:31 +08:00
|
|
|
StackFrameSP frame_sp(GetFrameSP());
|
|
|
|
if (frame_sp)
|
2011-06-19 04:06:08 +08:00
|
|
|
{
|
2012-01-30 15:41:31 +08:00
|
|
|
lldb::DynamicValueType use_dynamic = frame_sp->CalculateTarget()->GetPreferDynamicValue();
|
2011-06-19 04:06:08 +08:00
|
|
|
result = EvaluateExpression (expr, use_dynamic);
|
|
|
|
}
|
|
|
|
return result;
|
2011-04-16 08:01:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
SBValue
|
2011-05-04 11:43:18 +08:00
|
|
|
SBFrame::EvaluateExpression (const char *expr, lldb::DynamicValueType fetch_dynamic_value)
|
2010-10-05 08:00:42 +08:00
|
|
|
{
|
2010-12-15 02:39:31 +08:00
|
|
|
LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-12-08 06:55:01 +08:00
|
|
|
|
2010-12-15 02:39:31 +08:00
|
|
|
LogSP expr_log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
|
2010-10-30 12:51:46 +08:00
|
|
|
|
2011-08-11 06:06:24 +08:00
|
|
|
ExecutionResults exe_results;
|
2010-12-15 02:39:31 +08:00
|
|
|
SBValue expr_result;
|
2012-02-04 10:27:34 +08:00
|
|
|
ValueObjectSP expr_value_sp;
|
2012-01-30 15:41:31 +08:00
|
|
|
|
|
|
|
StackFrameSP frame_sp(GetFrameSP());
|
2010-10-30 12:51:46 +08:00
|
|
|
if (log)
|
2012-01-30 15:41:31 +08:00
|
|
|
log->Printf ("SBFrame(%p)::EvaluateExpression (expr=\"%s\")...", frame_sp.get(), expr);
|
2010-10-30 12:51:46 +08:00
|
|
|
|
2012-01-30 15:41:31 +08:00
|
|
|
if (frame_sp)
|
2010-10-05 08:00:42 +08:00
|
|
|
{
|
2012-01-30 15:41:31 +08:00
|
|
|
Mutex::Locker api_locker (frame_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
|
2011-06-19 04:06:08 +08:00
|
|
|
|
2011-06-25 12:35:01 +08:00
|
|
|
|
|
|
|
StreamString frame_description;
|
2012-01-30 15:41:31 +08:00
|
|
|
frame_sp->DumpUsingSettingsFormat (&frame_description);
|
2011-06-25 12:35:01 +08:00
|
|
|
|
|
|
|
Host::SetCrashDescriptionWithFormat ("SBFrame::EvaluateExpression (expr = \"%s\", fetch_dynamic_value = %u) %s",
|
|
|
|
expr, fetch_dynamic_value, frame_description.GetString().c_str());
|
|
|
|
|
2011-12-22 06:22:58 +08:00
|
|
|
const bool coerce_to_id = false;
|
2010-12-14 10:59:59 +08:00
|
|
|
const bool unwind_on_error = true;
|
2011-01-13 16:53:35 +08:00
|
|
|
const bool keep_in_memory = false;
|
2010-12-14 10:59:59 +08:00
|
|
|
|
2012-01-30 15:41:31 +08:00
|
|
|
exe_results = frame_sp->GetThread().GetProcess().GetTarget().EvaluateExpression(expr,
|
|
|
|
frame_sp.get(),
|
|
|
|
eExecutionPolicyOnlyWhenNeeded,
|
|
|
|
coerce_to_id,
|
|
|
|
unwind_on_error,
|
|
|
|
keep_in_memory,
|
|
|
|
fetch_dynamic_value,
|
2012-02-04 10:27:34 +08:00
|
|
|
expr_value_sp);
|
|
|
|
expr_result.SetSP(expr_value_sp);
|
2011-11-11 02:31:53 +08:00
|
|
|
Host::SetCrashDescription (NULL);
|
2010-10-05 08:00:42 +08:00
|
|
|
}
|
2010-10-30 12:51:46 +08:00
|
|
|
|
2010-12-08 06:55:01 +08:00
|
|
|
if (expr_log)
|
2011-04-16 08:01:13 +08:00
|
|
|
expr_log->Printf("** [SBFrame::EvaluateExpression] Expression result is %s, summary %s **",
|
2011-08-04 06:57:10 +08:00
|
|
|
expr_result.GetValue(),
|
|
|
|
expr_result.GetSummary());
|
2010-12-08 06:55:01 +08:00
|
|
|
|
2010-10-30 12:51:46 +08:00
|
|
|
if (log)
|
2012-01-30 15:41:31 +08:00
|
|
|
log->Printf ("SBFrame(%p)::EvaluateExpression (expr=\"%s\") => SBValue(%p) (execution result=%d)", frame_sp.get(),
|
2011-04-16 08:01:13 +08:00
|
|
|
expr,
|
2012-02-04 10:27:34 +08:00
|
|
|
expr_value_sp.get(),
|
2011-08-11 06:06:24 +08:00
|
|
|
exe_results);
|
2010-10-30 12:51:46 +08:00
|
|
|
|
2010-10-31 11:01:06 +08:00
|
|
|
return expr_result;
|
2010-10-05 08:00:42 +08:00
|
|
|
}
|
2011-06-19 04:06:08 +08:00
|
|
|
|
|
|
|
bool
|
|
|
|
SBFrame::IsInlined()
|
|
|
|
{
|
2012-01-30 15:41:31 +08:00
|
|
|
StackFrameSP frame_sp(GetFrameSP());
|
|
|
|
if (frame_sp)
|
2011-06-19 04:06:08 +08:00
|
|
|
{
|
2012-01-30 15:41:31 +08:00
|
|
|
Block *block = frame_sp->GetSymbolContext(eSymbolContextBlock).block;
|
2011-06-19 04:06:08 +08:00
|
|
|
if (block)
|
|
|
|
return block->GetContainingInlinedBlock () != NULL;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *
|
|
|
|
SBFrame::GetFunctionName()
|
|
|
|
{
|
|
|
|
const char *name = NULL;
|
2012-01-30 15:41:31 +08:00
|
|
|
StackFrameSP frame_sp(GetFrameSP());
|
|
|
|
if (frame_sp)
|
2011-06-19 04:06:08 +08:00
|
|
|
{
|
2012-01-30 15:41:31 +08:00
|
|
|
SymbolContext sc (frame_sp->GetSymbolContext(eSymbolContextFunction | eSymbolContextBlock | eSymbolContextSymbol));
|
2011-06-19 04:06:08 +08:00
|
|
|
if (sc.block)
|
|
|
|
{
|
|
|
|
Block *inlined_block = sc.block->GetContainingInlinedBlock ();
|
|
|
|
if (inlined_block)
|
|
|
|
{
|
|
|
|
const InlineFunctionInfo* inlined_info = inlined_block->GetInlinedFunctionInfo();
|
|
|
|
name = inlined_info->GetName().AsCString();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (name == NULL)
|
|
|
|
{
|
|
|
|
if (sc.function)
|
|
|
|
name = sc.function->GetName().GetCString();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (name == NULL)
|
|
|
|
{
|
|
|
|
if (sc.symbol)
|
|
|
|
name = sc.symbol->GetName().GetCString();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|