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"
|
|
|
|
#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
|
|
|
|
|
|
|
using namespace lldb;
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
|
|
|
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) :
|
2010-06-23 09:19:29 +08:00
|
|
|
m_opaque_sp (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",
|
|
|
|
lldb_object_sp.get(), m_opaque_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()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2010-12-15 02:39:31 +08:00
|
|
|
SBFrame::SetFrame (const StackFrameSP &lldb_object_sp)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-10-30 12:51:46 +08:00
|
|
|
void *old_ptr = m_opaque_sp.get();
|
2010-06-23 09:19:29 +08:00
|
|
|
m_opaque_sp = lldb_object_sp;
|
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)::SetFrame(sp=%p) := SBFrame(%p)",
|
|
|
|
old_ptr, lldb_object_sp.get(), m_opaque_sp.get());
|
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
SBFrame::IsValid() const
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
return (m_opaque_sp.get() != NULL);
|
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;
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp)
|
2010-12-21 04:49:23 +08:00
|
|
|
{
|
|
|
|
Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
|
2010-06-23 09:19:29 +08:00
|
|
|
sb_sym_ctx.SetSymbolContext(&m_opaque_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)",
|
2010-10-27 07:49:36 +08:00
|
|
|
m_opaque_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;
|
|
|
|
if (m_opaque_sp)
|
2010-12-21 04:49:23 +08:00
|
|
|
{
|
|
|
|
Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
|
2010-12-14 12:58:53 +08:00
|
|
|
*sb_module = m_opaque_sp->GetSymbolContext (eSymbolContextModule).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)",
|
|
|
|
m_opaque_sp.get(), sb_module.get());
|
|
|
|
|
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;
|
|
|
|
if (m_opaque_sp)
|
2010-12-21 04:49:23 +08:00
|
|
|
{
|
|
|
|
Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
|
2010-12-14 12:58:53 +08:00
|
|
|
sb_comp_unit.reset (m_opaque_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)",
|
|
|
|
m_opaque_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;
|
|
|
|
if (m_opaque_sp)
|
2010-12-21 04:49:23 +08:00
|
|
|
{
|
|
|
|
Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
|
2010-12-14 12:58:53 +08:00
|
|
|
sb_function.reset(m_opaque_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)",
|
|
|
|
m_opaque_sp.get(), sb_function.get());
|
|
|
|
|
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;
|
|
|
|
if (m_opaque_sp)
|
2010-12-21 04:49:23 +08:00
|
|
|
{
|
|
|
|
Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
|
2010-12-14 12:58:53 +08:00
|
|
|
sb_symbol.reset(m_opaque_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)",
|
|
|
|
m_opaque_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;
|
|
|
|
if (m_opaque_sp)
|
2010-12-21 04:49:23 +08:00
|
|
|
{
|
|
|
|
Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
|
2010-12-14 12:58:53 +08:00
|
|
|
sb_block.reset (m_opaque_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)",
|
|
|
|
m_opaque_sp.get(), sb_block.get());
|
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;
|
|
|
|
if (m_opaque_sp)
|
2010-12-21 04:49:23 +08:00
|
|
|
{
|
|
|
|
Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
|
2010-12-14 12:58:53 +08:00
|
|
|
sb_block.reset(m_opaque_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)",
|
|
|
|
m_opaque_sp.get(), sb_block.get());
|
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;
|
|
|
|
if (m_opaque_sp)
|
2010-12-21 04:49:23 +08:00
|
|
|
{
|
|
|
|
Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
|
2010-12-14 12:58:53 +08:00
|
|
|
sb_line_entry.SetLineEntry (m_opaque_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)",
|
|
|
|
m_opaque_sp.get(), sb_line_entry.get());
|
2010-06-09 00:52:24 +08:00
|
|
|
return sb_line_entry;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t
|
|
|
|
SBFrame::GetFrameID () const
|
|
|
|
{
|
2010-10-30 12:51:46 +08:00
|
|
|
uint32_t frame_idx = m_opaque_sp ? m_opaque_sp->GetFrameIndex () : UINT32_MAX;
|
|
|
|
|
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",
|
|
|
|
m_opaque_sp.get(), frame_idx);
|
|
|
|
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;
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp)
|
2010-12-21 04:49:23 +08:00
|
|
|
{
|
|
|
|
Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
|
2011-07-06 12:07:21 +08:00
|
|
|
addr = m_opaque_sp->GetFrameCodeAddress().GetOpcodeLoadAddress (&m_opaque_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)
|
2010-10-31 11:01:06 +08:00
|
|
|
log->Printf ("SBFrame(%p)::GetPC () => 0x%llx", m_opaque_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;
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp)
|
2010-12-21 04:49:23 +08:00
|
|
|
{
|
|
|
|
Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
|
2010-10-26 11:11:13 +08:00
|
|
|
ret_val = m_opaque_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",
|
|
|
|
m_opaque_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;
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp)
|
2010-12-21 04:49:23 +08:00
|
|
|
{
|
|
|
|
Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
|
2010-10-30 12:51:46 +08:00
|
|
|
addr = m_opaque_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)
|
2010-10-31 11:01:06 +08:00
|
|
|
log->Printf ("SBFrame(%p)::GetSP () => 0x%llx", m_opaque_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;
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp)
|
2010-12-21 04:49:23 +08:00
|
|
|
{
|
|
|
|
Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
|
2010-10-26 11:11:13 +08:00
|
|
|
addr = m_opaque_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)
|
2010-10-31 11:01:06 +08:00
|
|
|
log->Printf ("SBFrame(%p)::GetFP () => 0x%llx", m_opaque_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;
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp)
|
2010-12-21 04:49:23 +08:00
|
|
|
{
|
|
|
|
Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
|
2010-08-25 05:05:24 +08:00
|
|
|
sb_addr.SetAddress (&m_opaque_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)
|
|
|
|
log->Printf ("SBFrame(%p)::GetPCAddress () => SBAddress(%p)", m_opaque_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
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
if (m_opaque_sp)
|
|
|
|
{
|
|
|
|
lldb::DynamicValueType use_dynamic = m_opaque_sp->CalculateTarget()->GetPreferDynamicValue();
|
|
|
|
value = FindVariable (name, use_dynamic);
|
|
|
|
}
|
|
|
|
return value;
|
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;
|
|
|
|
|
2010-12-15 02:39:31 +08:00
|
|
|
if (m_opaque_sp && name && name[0])
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-12-15 02:39:31 +08:00
|
|
|
VariableList variable_list;
|
2010-12-21 04:49:23 +08:00
|
|
|
Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
|
2010-12-14 12:58:53 +08:00
|
|
|
SymbolContext sc (m_opaque_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)
|
|
|
|
*sb_value = ValueObjectSP (m_opaque_sp->GetValueObjectForFrameVariable(var_sp, use_dynamic));
|
|
|
|
|
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)",
|
|
|
|
m_opaque_sp.get(), name, sb_value.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;
|
|
|
|
if (m_opaque_sp)
|
|
|
|
{
|
|
|
|
lldb::DynamicValueType use_dynamic = m_opaque_sp->CalculateTarget()->GetPreferDynamicValue();
|
|
|
|
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;
|
|
|
|
if (m_opaque_sp && name && name[0])
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-12-21 04:49:23 +08:00
|
|
|
Mutex::Locker api_locker (m_opaque_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
|
|
|
|
{
|
|
|
|
VariableList *variable_list = m_opaque_sp->GetVariableList(true);
|
2010-12-14 12:58:53 +08:00
|
|
|
|
2010-12-15 02:39:31 +08:00
|
|
|
SymbolContext sc (m_opaque_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)
|
|
|
|
{
|
2011-04-16 08:01:13 +08:00
|
|
|
*sb_value = ValueObjectSP (m_opaque_sp->GetValueObjectForFrameVariable(variable_sp,
|
|
|
|
use_dynamic));
|
2010-12-15 02:39:31 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eValueTypeRegister: // stack frame register value
|
|
|
|
{
|
2011-01-07 06:15:06 +08:00
|
|
|
RegisterContextSP reg_ctx (m_opaque_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)))
|
|
|
|
{
|
2011-04-23 07:53:53 +08:00
|
|
|
*sb_value = ValueObjectRegister::Create (m_opaque_sp.get(), reg_ctx, reg_idx);
|
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
|
|
|
{
|
2011-01-07 06:15:06 +08:00
|
|
|
RegisterContextSP reg_ctx (m_opaque_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)))
|
|
|
|
{
|
2011-04-23 07:53:53 +08:00
|
|
|
*sb_value = ValueObjectRegisterSet::Create (m_opaque_sp.get(), reg_ctx, set_idx);
|
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);
|
|
|
|
ClangExpressionVariableSP expr_var_sp (m_opaque_sp->GetThread().GetProcess().GetTarget().GetPersistentVariables().GetVariable (const_name));
|
|
|
|
if (expr_var_sp)
|
|
|
|
*sb_value = expr_var_sp->GetValueObject();
|
|
|
|
}
|
|
|
|
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)",
|
|
|
|
m_opaque_sp.get(), name, value_type, sb_value.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
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
return m_opaque_sp.get() == rhs.m_opaque_sp.get();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
SBFrame::operator != (const SBFrame &rhs) const
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
return m_opaque_sp.get() != rhs.m_opaque_sp.get();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
lldb_private::StackFrame *
|
|
|
|
SBFrame::operator->() const
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
return m_opaque_sp.get();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
lldb_private::StackFrame *
|
|
|
|
SBFrame::get() const
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
return m_opaque_sp.get();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2011-09-10 07:04:00 +08:00
|
|
|
lldb::StackFrameSP &
|
|
|
|
SBFrame::get_sp()
|
2011-01-21 14:11:58 +08:00
|
|
|
{
|
|
|
|
return m_opaque_sp;
|
|
|
|
}
|
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;
|
2010-12-14 12:58:53 +08:00
|
|
|
if (m_opaque_sp)
|
2010-12-21 04:49:23 +08:00
|
|
|
{
|
|
|
|
Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
|
2012-01-30 10:53:15 +08:00
|
|
|
thread_sp = m_opaque_sp->GetThread().shared_from_this();
|
|
|
|
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);
|
2010-10-30 12:51:46 +08:00
|
|
|
log->Printf ("SBFrame(%p)::GetThread () => SBThread(%p): %s", m_opaque_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;
|
|
|
|
if (m_opaque_sp)
|
2010-12-21 04:49:23 +08:00
|
|
|
{
|
|
|
|
Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
|
2010-10-30 12:51:46 +08:00
|
|
|
disassembly = m_opaque_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)
|
|
|
|
log->Printf ("SBFrame(%p)::Disassemble () => %s", m_opaque_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;
|
|
|
|
if (m_opaque_sp)
|
|
|
|
{
|
|
|
|
lldb::DynamicValueType use_dynamic = m_opaque_sp->CalculateTarget()->GetPreferDynamicValue();
|
|
|
|
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
|
|
|
|
|
|
|
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)",
|
2010-10-27 07:49:36 +08:00
|
|
|
m_opaque_sp.get(),
|
2010-10-30 12:51:46 +08:00
|
|
|
arguments,
|
|
|
|
locals,
|
|
|
|
statics,
|
|
|
|
in_scope_only);
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
SBValueList value_list;
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_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
|
|
|
|
{
|
|
|
|
Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
|
|
|
|
variable_list = m_opaque_sp->GetVariableList(true);
|
|
|
|
}
|
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)
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
if (in_scope_only && !variable_sp->IsInScope(m_opaque_sp.get()))
|
2010-06-09 00:52:24 +08:00
|
|
|
continue;
|
|
|
|
|
2011-04-16 08:01:13 +08:00
|
|
|
value_list.Append(m_opaque_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)
|
|
|
|
{
|
2010-10-30 12:51:46 +08:00
|
|
|
log->Printf ("SBFrame(%p)::GetVariables (...) => SBValueList(%p)", m_opaque_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;
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-12-21 04:49:23 +08:00
|
|
|
Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
|
2011-01-07 06:15:06 +08:00
|
|
|
RegisterContextSP reg_ctx (m_opaque_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)
|
|
|
|
{
|
2011-04-23 07:53:53 +08:00
|
|
|
value_list.Append(ValueObjectRegisterSet::Create (m_opaque_sp.get(), reg_ctx, set_idx));
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-10-26 11:11:13 +08:00
|
|
|
|
|
|
|
if (log)
|
2010-10-30 12:51:46 +08:00
|
|
|
log->Printf ("SBFrame(%p)::Registers () => SBValueList(%p)", m_opaque_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();
|
|
|
|
|
2010-09-20 13:20:02 +08:00
|
|
|
if (m_opaque_sp)
|
|
|
|
{
|
2010-12-21 04:49:23 +08:00
|
|
|
Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
|
2011-11-13 14:57:31 +08:00
|
|
|
m_opaque_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;
|
|
|
|
if (m_opaque_sp)
|
|
|
|
{
|
|
|
|
lldb::DynamicValueType use_dynamic = m_opaque_sp->CalculateTarget()->GetPreferDynamicValue();
|
|
|
|
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;
|
2010-10-30 12:51:46 +08:00
|
|
|
if (log)
|
|
|
|
log->Printf ("SBFrame(%p)::EvaluateExpression (expr=\"%s\")...", m_opaque_sp.get(), expr);
|
|
|
|
|
2010-10-05 08:00:42 +08:00
|
|
|
if (m_opaque_sp)
|
|
|
|
{
|
2011-06-19 04:06:08 +08:00
|
|
|
Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
|
|
|
|
|
2011-06-25 12:35:01 +08:00
|
|
|
|
|
|
|
StreamString frame_description;
|
|
|
|
m_opaque_sp->DumpUsingSettingsFormat (&frame_description);
|
|
|
|
|
|
|
|
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
|
|
|
|
2011-04-16 08:01:13 +08:00
|
|
|
exe_results = m_opaque_sp->GetThread().GetProcess().GetTarget().EvaluateExpression(expr,
|
This patch modifies the expression parser to allow it
to execute expressions even in the absence of a process.
This allows expressions to run in situations where the
target cannot run -- e.g., to perform calculations based
on type information, or to inspect a binary's static
data.
This modification touches the following files:
lldb-private-enumerations.h
Introduce a new enum specifying the policy for
processing an expression. Some expressions should
always be JITted, for example if they are functions
that will be used over and over again. Some
expressions should always be interpreted, for
example if the target is unsafe to run. For most,
it is acceptable to JIT them, but interpretation
is preferable when possible.
Target.[h,cpp]
Have EvaluateExpression now accept the new enum.
ClangExpressionDeclMap.[cpp,h]
Add support for the IR interpreter and also make
the ClangExpressionDeclMap more robust in the
absence of a process.
ClangFunction.[cpp,h]
Add support for the new enum.
IRInterpreter.[cpp,h]
New implementation.
ClangUserExpression.[cpp,h]
Add support for the new enum, and for running
expressions in the absence of a process.
ClangExpression.h
Remove references to the old DWARF-based method
of evaluating expressions, because it has been
superseded for now.
ClangUtilityFunction.[cpp,h]
Add support for the new enum.
ClangExpressionParser.[cpp,h]
Add support for the new enum, remove references
to DWARF, and add support for checking whether
the expression could be evaluated statically.
IRForTarget.[h,cpp]
Add support for the new enum, and add utility
functions to support the interpreter.
IRToDWARF.cpp
Removed
CommandObjectExpression.cpp
Remove references to the obsolete -i option.
Process.cpp
Modify calls to ClangUserExpression::Evaluate
to pass the correct enum (for dlopen/dlclose)
SBValue.cpp
Add support for the new enum.
SBFrame.cpp
Add support for he new enum.
BreakpointOptions.cpp
Add support for the new enum.
llvm-svn: 139772
2011-09-15 10:13:07 +08:00
|
|
|
m_opaque_sp.get(),
|
|
|
|
eExecutionPolicyOnlyWhenNeeded,
|
2011-12-22 06:22:58 +08:00
|
|
|
coerce_to_id,
|
2011-04-16 08:01:13 +08:00
|
|
|
unwind_on_error,
|
|
|
|
keep_in_memory,
|
2011-05-04 11:43:18 +08:00
|
|
|
fetch_dynamic_value,
|
2011-04-16 08:01:13 +08:00
|
|
|
*expr_result);
|
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)
|
2011-08-11 06:06:24 +08:00
|
|
|
log->Printf ("SBFrame(%p)::EvaluateExpression (expr=\"%s\") => SBValue(%p) (execution result=%d)", m_opaque_sp.get(),
|
2011-04-16 08:01:13 +08:00
|
|
|
expr,
|
2011-08-11 06:06:24 +08:00
|
|
|
expr_result.get(),
|
|
|
|
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()
|
|
|
|
{
|
|
|
|
if (m_opaque_sp)
|
|
|
|
{
|
|
|
|
Block *block = m_opaque_sp->GetSymbolContext(eSymbolContextBlock).block;
|
|
|
|
if (block)
|
|
|
|
return block->GetContainingInlinedBlock () != NULL;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *
|
|
|
|
SBFrame::GetFunctionName()
|
|
|
|
{
|
|
|
|
const char *name = NULL;
|
|
|
|
if (m_opaque_sp)
|
|
|
|
{
|
|
|
|
SymbolContext sc (m_opaque_sp->GetSymbolContext(eSymbolContextFunction | eSymbolContextBlock | eSymbolContextSymbol));
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|