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.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2015-10-31 09:22:59 +08:00
|
|
|
// C Includes
|
|
|
|
// C++ Includes
|
2010-06-09 00:52:24 +08:00
|
|
|
#include <algorithm>
|
2016-04-30 05:00:38 +08:00
|
|
|
#include <set>
|
2015-10-31 09:22:59 +08:00
|
|
|
#include <string>
|
|
|
|
|
|
|
|
// Other libraries and framework includes
|
|
|
|
// Project includes
|
|
|
|
#include "lldb/API/SBFrame.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
#include "lldb/lldb-types.h"
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
#include "Plugins/ExpressionParser/Clang/ClangPersistentVariables.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#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"
|
2015-09-16 05:13:50 +08:00
|
|
|
#include "lldb/Expression/UserExpression.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"
|
<rdar://problem/11757916>
Make breakpoint setting by file and line much more efficient by only looking for inlined breakpoint locations if we are setting a breakpoint in anything but a source implementation file. Implementing this complex for a many reasons. Turns out that parsing compile units lazily had some issues with respect to how we need to do things with DWARF in .o files. So the fixes in the checkin for this makes these changes:
- Add a new setting called "target.inline-breakpoint-strategy" which can be set to "never", "always", or "headers". "never" will never try and set any inlined breakpoints (fastest). "always" always looks for inlined breakpoint locations (slowest, but most accurate). "headers", which is the default setting, will only look for inlined breakpoint locations if the breakpoint is set in what are consudered to be header files, which is realy defined as "not in an implementation source file".
- modify the breakpoint setting by file and line to check the current "target.inline-breakpoint-strategy" setting and act accordingly
- Modify compile units to be able to get their language and other info lazily. This allows us to create compile units from the debug map and not have to fill all of the details in, and then lazily discover this information as we go on debuggging. This is needed to avoid parsing all .o files when setting breakpoints in implementation only files (no inlines). Otherwise we would need to parse the .o file, the object file (mach-o in our case) and the symbol file (DWARF in the object file) just to see what the compile unit was.
- modify the "SymbolFileDWARFDebugMap" to subclass lldb_private::Module so that the virtual "GetObjectFile()" and "GetSymbolVendor()" functions can be intercepted when the .o file contenst are later lazilly needed. Prior to this fix, when we first instantiated the "SymbolFileDWARFDebugMap" class, we would also make modules, object files and symbol files for every .o file in the debug map because we needed to fix up the sections in the .o files with information that is in the executable debug map. Now we lazily do this in the DebugMapModule::GetObjectFile()
Cleaned up header includes a bit as well.
llvm-svn: 162860
2012-08-30 05:13:06 +08:00
|
|
|
#include "lldb/Symbol/Function.h"
|
|
|
|
#include "lldb/Symbol/Symbol.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/Symbol/SymbolContext.h"
|
|
|
|
#include "lldb/Symbol/Variable.h"
|
2016-09-07 04:57:50 +08:00
|
|
|
#include "lldb/Symbol/VariableList.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/Target/ExecutionContext.h"
|
|
|
|
#include "lldb/Target/Process.h"
|
|
|
|
#include "lldb/Target/RegisterContext.h"
|
2013-11-04 17:33:30 +08:00
|
|
|
#include "lldb/Target/StackFrame.h"
|
2012-01-30 15:41:31 +08:00
|
|
|
#include "lldb/Target/StackID.h"
|
2016-09-07 04:57:50 +08:00
|
|
|
#include "lldb/Target/Target.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/SBAddress.h"
|
2016-09-07 04:57:50 +08:00
|
|
|
#include "lldb/API/SBDebugger.h"
|
2012-10-17 05:41:58 +08:00
|
|
|
#include "lldb/API/SBExpressionOptions.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"
|
2016-09-07 04:57:50 +08:00
|
|
|
#include "lldb/API/SBValue.h"
|
2015-02-18 01:55:50 +08:00
|
|
|
#include "lldb/API/SBVariablesOptions.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2016-12-15 05:31:31 +08:00
|
|
|
#include "llvm/Support/PrettyStackTrace.h"
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
using namespace lldb;
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
SBFrame::SBFrame() : m_opaque_sp(new ExecutionContextRef()) {}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
SBFrame::SBFrame(const StackFrameSP &lldb_object_sp)
|
|
|
|
: m_opaque_sp(new ExecutionContextRef(lldb_object_sp)) {
|
|
|
|
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
if (log) {
|
|
|
|
SBStream sstr;
|
|
|
|
GetDescription(sstr);
|
|
|
|
log->Printf("SBFrame::SBFrame (sp=%p) => SBFrame(%p): %s",
|
|
|
|
static_cast<void *>(lldb_object_sp.get()),
|
|
|
|
static_cast<void *>(lldb_object_sp.get()), sstr.GetData());
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
SBFrame::SBFrame(const SBFrame &rhs)
|
|
|
|
: m_opaque_sp(new ExecutionContextRef(*rhs.m_opaque_sp)) {}
|
2010-11-06 07:17:00 +08:00
|
|
|
|
2015-10-31 09:22:59 +08:00
|
|
|
SBFrame::~SBFrame() = default;
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
const SBFrame &SBFrame::operator=(const SBFrame &rhs) {
|
|
|
|
if (this != &rhs)
|
|
|
|
*m_opaque_sp = *rhs.m_opaque_sp;
|
|
|
|
return *this;
|
2010-11-06 07:17:00 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
StackFrameSP SBFrame::GetFrameSP() const {
|
|
|
|
return (m_opaque_sp ? m_opaque_sp->GetFrameSP() : StackFrameSP());
|
2012-01-30 15:41:31 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
void SBFrame::SetFrameSP(const StackFrameSP &lldb_object_sp) {
|
|
|
|
return m_opaque_sp->SetFrameSP(lldb_object_sp);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
bool SBFrame::IsValid() const {
|
|
|
|
std::unique_lock<std::recursive_mutex> lock;
|
|
|
|
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
|
|
|
|
|
|
|
|
Target *target = exe_ctx.GetTargetPtr();
|
|
|
|
Process *process = exe_ctx.GetProcessPtr();
|
|
|
|
if (target && process) {
|
|
|
|
Process::StopLocker stop_locker;
|
|
|
|
if (stop_locker.TryLock(&process->GetRunLock()))
|
|
|
|
return GetFrameSP().get() != nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Without a target & process we can't have a valid stack frame.
|
|
|
|
return false;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
SBSymbolContext SBFrame::GetSymbolContext(uint32_t resolve_scope) const {
|
|
|
|
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
|
|
|
|
SBSymbolContext sb_sym_ctx;
|
|
|
|
std::unique_lock<std::recursive_mutex> lock;
|
|
|
|
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
|
|
|
|
|
|
|
|
StackFrame *frame = nullptr;
|
|
|
|
Target *target = exe_ctx.GetTargetPtr();
|
|
|
|
Process *process = exe_ctx.GetProcessPtr();
|
|
|
|
if (target && process) {
|
|
|
|
Process::StopLocker stop_locker;
|
|
|
|
if (stop_locker.TryLock(&process->GetRunLock())) {
|
|
|
|
frame = exe_ctx.GetFramePtr();
|
|
|
|
if (frame) {
|
|
|
|
sb_sym_ctx.SetSymbolContext(&frame->GetSymbolContext(resolve_scope));
|
|
|
|
} else {
|
|
|
|
if (log)
|
|
|
|
log->Printf("SBFrame::GetVariables () => error: could not "
|
|
|
|
"reconstruct frame object for this SBFrame.");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (log)
|
|
|
|
log->Printf(
|
|
|
|
"SBFrame::GetSymbolContext () => error: process is running");
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
if (log)
|
|
|
|
log->Printf("SBFrame(%p)::GetSymbolContext (resolve_scope=0x%8.8x) => "
|
|
|
|
"SBSymbolContext(%p)",
|
|
|
|
static_cast<void *>(frame), resolve_scope,
|
|
|
|
static_cast<void *>(sb_sym_ctx.get()));
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
return sb_sym_ctx;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
SBModule SBFrame::GetModule() const {
|
|
|
|
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
|
|
|
|
SBModule sb_module;
|
|
|
|
ModuleSP module_sp;
|
|
|
|
std::unique_lock<std::recursive_mutex> lock;
|
|
|
|
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
|
|
|
|
|
|
|
|
StackFrame *frame = nullptr;
|
|
|
|
Target *target = exe_ctx.GetTargetPtr();
|
|
|
|
Process *process = exe_ctx.GetProcessPtr();
|
|
|
|
if (target && process) {
|
|
|
|
Process::StopLocker stop_locker;
|
|
|
|
if (stop_locker.TryLock(&process->GetRunLock())) {
|
|
|
|
frame = exe_ctx.GetFramePtr();
|
|
|
|
if (frame) {
|
|
|
|
module_sp = frame->GetSymbolContext(eSymbolContextModule).module_sp;
|
|
|
|
sb_module.SetSP(module_sp);
|
|
|
|
} else {
|
|
|
|
if (log)
|
|
|
|
log->Printf("SBFrame::GetModule () => error: could not reconstruct "
|
|
|
|
"frame object for this SBFrame.");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (log)
|
|
|
|
log->Printf("SBFrame::GetModule () => error: process is running");
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2010-12-14 12:58:53 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
if (log)
|
|
|
|
log->Printf("SBFrame(%p)::GetModule () => SBModule(%p)",
|
|
|
|
static_cast<void *>(frame),
|
|
|
|
static_cast<void *>(module_sp.get()));
|
2010-10-30 12:51:46 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
return sb_module;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
SBCompileUnit SBFrame::GetCompileUnit() const {
|
|
|
|
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
|
|
|
|
SBCompileUnit sb_comp_unit;
|
|
|
|
std::unique_lock<std::recursive_mutex> lock;
|
|
|
|
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
|
|
|
|
|
|
|
|
StackFrame *frame = nullptr;
|
|
|
|
Target *target = exe_ctx.GetTargetPtr();
|
|
|
|
Process *process = exe_ctx.GetProcessPtr();
|
|
|
|
if (target && process) {
|
|
|
|
Process::StopLocker stop_locker;
|
|
|
|
if (stop_locker.TryLock(&process->GetRunLock())) {
|
|
|
|
frame = exe_ctx.GetFramePtr();
|
|
|
|
if (frame) {
|
|
|
|
sb_comp_unit.reset(
|
|
|
|
frame->GetSymbolContext(eSymbolContextCompUnit).comp_unit);
|
|
|
|
} else {
|
|
|
|
if (log)
|
|
|
|
log->Printf("SBFrame::GetCompileUnit () => error: could not "
|
|
|
|
"reconstruct frame object for this SBFrame.");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (log)
|
|
|
|
log->Printf("SBFrame::GetCompileUnit () => error: process is running");
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
if (log)
|
|
|
|
log->Printf("SBFrame(%p)::GetCompileUnit () => SBCompileUnit(%p)",
|
|
|
|
static_cast<void *>(frame),
|
|
|
|
static_cast<void *>(sb_comp_unit.get()));
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
return sb_comp_unit;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
SBFunction SBFrame::GetFunction() const {
|
|
|
|
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
|
|
|
|
SBFunction sb_function;
|
|
|
|
std::unique_lock<std::recursive_mutex> lock;
|
|
|
|
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
|
|
|
|
|
|
|
|
StackFrame *frame = nullptr;
|
|
|
|
Target *target = exe_ctx.GetTargetPtr();
|
|
|
|
Process *process = exe_ctx.GetProcessPtr();
|
|
|
|
if (target && process) {
|
|
|
|
Process::StopLocker stop_locker;
|
|
|
|
if (stop_locker.TryLock(&process->GetRunLock())) {
|
|
|
|
frame = exe_ctx.GetFramePtr();
|
|
|
|
if (frame) {
|
|
|
|
sb_function.reset(
|
|
|
|
frame->GetSymbolContext(eSymbolContextFunction).function);
|
|
|
|
} else {
|
|
|
|
if (log)
|
|
|
|
log->Printf("SBFrame::GetFunction () => error: could not reconstruct "
|
|
|
|
"frame object for this SBFrame.");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (log)
|
|
|
|
log->Printf("SBFrame::GetFunction () => error: process is running");
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
if (log)
|
|
|
|
log->Printf("SBFrame(%p)::GetFunction () => SBFunction(%p)",
|
|
|
|
static_cast<void *>(frame),
|
|
|
|
static_cast<void *>(sb_function.get()));
|
2010-10-30 12:51:46 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
return sb_function;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
SBSymbol SBFrame::GetSymbol() const {
|
|
|
|
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
|
|
|
|
SBSymbol sb_symbol;
|
|
|
|
std::unique_lock<std::recursive_mutex> lock;
|
|
|
|
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
|
|
|
|
|
|
|
|
StackFrame *frame = nullptr;
|
|
|
|
Target *target = exe_ctx.GetTargetPtr();
|
|
|
|
Process *process = exe_ctx.GetProcessPtr();
|
|
|
|
if (target && process) {
|
|
|
|
Process::StopLocker stop_locker;
|
|
|
|
if (stop_locker.TryLock(&process->GetRunLock())) {
|
|
|
|
frame = exe_ctx.GetFramePtr();
|
|
|
|
if (frame) {
|
|
|
|
sb_symbol.reset(frame->GetSymbolContext(eSymbolContextSymbol).symbol);
|
|
|
|
} else {
|
|
|
|
if (log)
|
|
|
|
log->Printf("SBFrame::GetSymbol () => error: could not reconstruct "
|
|
|
|
"frame object for this SBFrame.");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (log)
|
|
|
|
log->Printf("SBFrame::GetSymbol () => error: process is running");
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
if (log)
|
|
|
|
log->Printf("SBFrame(%p)::GetSymbol () => SBSymbol(%p)",
|
|
|
|
static_cast<void *>(frame),
|
|
|
|
static_cast<void *>(sb_symbol.get()));
|
|
|
|
return sb_symbol;
|
2010-10-05 02:37:52 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
SBBlock SBFrame::GetBlock() const {
|
|
|
|
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
|
|
|
|
SBBlock sb_block;
|
|
|
|
std::unique_lock<std::recursive_mutex> lock;
|
|
|
|
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
|
|
|
|
|
|
|
|
StackFrame *frame = nullptr;
|
|
|
|
Target *target = exe_ctx.GetTargetPtr();
|
|
|
|
Process *process = exe_ctx.GetProcessPtr();
|
|
|
|
if (target && process) {
|
|
|
|
Process::StopLocker stop_locker;
|
|
|
|
if (stop_locker.TryLock(&process->GetRunLock())) {
|
|
|
|
frame = exe_ctx.GetFramePtr();
|
|
|
|
if (frame) {
|
|
|
|
sb_block.SetPtr(frame->GetSymbolContext(eSymbolContextBlock).block);
|
|
|
|
} else {
|
|
|
|
if (log)
|
|
|
|
log->Printf("SBFrame::GetBlock () => error: could not reconstruct "
|
|
|
|
"frame object for this SBFrame.");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (log)
|
|
|
|
log->Printf("SBFrame(%p)::GetBlock () => error: process is running",
|
|
|
|
static_cast<void *>(frame));
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
if (log)
|
|
|
|
log->Printf("SBFrame(%p)::GetBlock () => SBBlock(%p)",
|
|
|
|
static_cast<void *>(frame),
|
|
|
|
static_cast<void *>(sb_block.GetPtr()));
|
|
|
|
return sb_block;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
SBBlock SBFrame::GetFrameBlock() const {
|
|
|
|
SBBlock sb_block;
|
|
|
|
std::unique_lock<std::recursive_mutex> lock;
|
|
|
|
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
|
|
|
|
|
|
|
|
StackFrame *frame = nullptr;
|
|
|
|
Target *target = exe_ctx.GetTargetPtr();
|
|
|
|
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
|
|
|
|
Process *process = exe_ctx.GetProcessPtr();
|
|
|
|
if (target && process) {
|
|
|
|
Process::StopLocker stop_locker;
|
|
|
|
if (stop_locker.TryLock(&process->GetRunLock())) {
|
|
|
|
frame = exe_ctx.GetFramePtr();
|
|
|
|
if (frame) {
|
|
|
|
sb_block.SetPtr(frame->GetFrameBlock());
|
|
|
|
} else {
|
|
|
|
if (log)
|
|
|
|
log->Printf("SBFrame::GetFrameBlock () => error: could not "
|
|
|
|
"reconstruct frame object for this SBFrame.");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (log)
|
|
|
|
log->Printf("SBFrame::GetFrameBlock () => error: process is running");
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
if (log)
|
|
|
|
log->Printf("SBFrame(%p)::GetFrameBlock () => SBBlock(%p)",
|
|
|
|
static_cast<void *>(frame),
|
|
|
|
static_cast<void *>(sb_block.GetPtr()));
|
|
|
|
return sb_block;
|
2010-09-07 12:20:48 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
SBLineEntry SBFrame::GetLineEntry() const {
|
|
|
|
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
|
|
|
|
SBLineEntry sb_line_entry;
|
|
|
|
std::unique_lock<std::recursive_mutex> lock;
|
|
|
|
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
|
|
|
|
|
|
|
|
StackFrame *frame = nullptr;
|
|
|
|
Target *target = exe_ctx.GetTargetPtr();
|
|
|
|
Process *process = exe_ctx.GetProcessPtr();
|
|
|
|
if (target && process) {
|
|
|
|
Process::StopLocker stop_locker;
|
|
|
|
if (stop_locker.TryLock(&process->GetRunLock())) {
|
|
|
|
frame = exe_ctx.GetFramePtr();
|
|
|
|
if (frame) {
|
|
|
|
sb_line_entry.SetLineEntry(
|
|
|
|
frame->GetSymbolContext(eSymbolContextLineEntry).line_entry);
|
|
|
|
} else {
|
|
|
|
if (log)
|
|
|
|
log->Printf("SBFrame::GetLineEntry () => error: could not "
|
|
|
|
"reconstruct frame object for this SBFrame.");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (log)
|
|
|
|
log->Printf("SBFrame::GetLineEntry () => error: process is running");
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
if (log)
|
|
|
|
log->Printf("SBFrame(%p)::GetLineEntry () => SBLineEntry(%p)",
|
|
|
|
static_cast<void *>(frame),
|
|
|
|
static_cast<void *>(sb_line_entry.get()));
|
|
|
|
return sb_line_entry;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
uint32_t SBFrame::GetFrameID() const {
|
|
|
|
uint32_t frame_idx = UINT32_MAX;
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
std::unique_lock<std::recursive_mutex> lock;
|
|
|
|
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
|
2016-06-10 08:37:44 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
StackFrame *frame = exe_ctx.GetFramePtr();
|
|
|
|
if (frame)
|
|
|
|
frame_idx = frame->GetFrameIndex();
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
|
|
|
|
if (log)
|
|
|
|
log->Printf("SBFrame(%p)::GetFrameID () => %u", static_cast<void *>(frame),
|
|
|
|
frame_idx);
|
|
|
|
return frame_idx;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
lldb::addr_t SBFrame::GetCFA() const {
|
|
|
|
std::unique_lock<std::recursive_mutex> lock;
|
|
|
|
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
|
2016-06-10 08:37:44 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
StackFrame *frame = exe_ctx.GetFramePtr();
|
|
|
|
if (frame)
|
|
|
|
return frame->GetStackID().GetCallFrameAddress();
|
|
|
|
return LLDB_INVALID_ADDRESS;
|
2015-05-28 11:27:22 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
addr_t SBFrame::GetPC() const {
|
|
|
|
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
|
|
|
|
addr_t addr = LLDB_INVALID_ADDRESS;
|
|
|
|
std::unique_lock<std::recursive_mutex> lock;
|
|
|
|
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
|
|
|
|
|
|
|
|
StackFrame *frame = nullptr;
|
|
|
|
Target *target = exe_ctx.GetTargetPtr();
|
|
|
|
Process *process = exe_ctx.GetProcessPtr();
|
|
|
|
if (target && process) {
|
|
|
|
Process::StopLocker stop_locker;
|
|
|
|
if (stop_locker.TryLock(&process->GetRunLock())) {
|
|
|
|
frame = exe_ctx.GetFramePtr();
|
|
|
|
if (frame) {
|
|
|
|
addr = frame->GetFrameCodeAddress().GetOpcodeLoadAddress(
|
|
|
|
target, eAddressClassCode);
|
|
|
|
} else {
|
|
|
|
if (log)
|
|
|
|
log->Printf("SBFrame::GetPC () => error: could not reconstruct frame "
|
|
|
|
"object for this SBFrame.");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (log)
|
|
|
|
log->Printf("SBFrame::GetPC () => error: process is running");
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
if (log)
|
|
|
|
log->Printf("SBFrame(%p)::GetPC () => 0x%" PRIx64,
|
|
|
|
static_cast<void *>(frame), addr);
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
return addr;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
bool SBFrame::SetPC(addr_t new_pc) {
|
|
|
|
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
|
|
|
|
bool ret_val = false;
|
|
|
|
std::unique_lock<std::recursive_mutex> lock;
|
|
|
|
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
|
|
|
|
|
|
|
|
StackFrame *frame = nullptr;
|
|
|
|
Target *target = exe_ctx.GetTargetPtr();
|
|
|
|
Process *process = exe_ctx.GetProcessPtr();
|
|
|
|
if (target && process) {
|
|
|
|
Process::StopLocker stop_locker;
|
|
|
|
if (stop_locker.TryLock(&process->GetRunLock())) {
|
|
|
|
frame = exe_ctx.GetFramePtr();
|
|
|
|
if (frame) {
|
|
|
|
ret_val = frame->GetRegisterContext()->SetPC(new_pc);
|
|
|
|
} else {
|
|
|
|
if (log)
|
|
|
|
log->Printf("SBFrame::SetPC () => error: could not reconstruct frame "
|
|
|
|
"object for this SBFrame.");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (log)
|
|
|
|
log->Printf("SBFrame::SetPC () => error: process is running");
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
if (log)
|
|
|
|
log->Printf("SBFrame(%p)::SetPC (new_pc=0x%" PRIx64 ") => %i",
|
|
|
|
static_cast<void *>(frame), new_pc, ret_val);
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
return ret_val;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
addr_t SBFrame::GetSP() const {
|
|
|
|
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
|
|
|
|
addr_t addr = LLDB_INVALID_ADDRESS;
|
|
|
|
std::unique_lock<std::recursive_mutex> lock;
|
|
|
|
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
|
|
|
|
|
|
|
|
StackFrame *frame = nullptr;
|
|
|
|
Target *target = exe_ctx.GetTargetPtr();
|
|
|
|
Process *process = exe_ctx.GetProcessPtr();
|
|
|
|
if (target && process) {
|
|
|
|
Process::StopLocker stop_locker;
|
|
|
|
if (stop_locker.TryLock(&process->GetRunLock())) {
|
|
|
|
frame = exe_ctx.GetFramePtr();
|
|
|
|
if (frame) {
|
|
|
|
addr = frame->GetRegisterContext()->GetSP();
|
|
|
|
} else {
|
|
|
|
if (log)
|
|
|
|
log->Printf("SBFrame::GetSP () => error: could not reconstruct frame "
|
|
|
|
"object for this SBFrame.");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (log)
|
|
|
|
log->Printf("SBFrame::GetSP () => error: process is running");
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
if (log)
|
|
|
|
log->Printf("SBFrame(%p)::GetSP () => 0x%" PRIx64,
|
|
|
|
static_cast<void *>(frame), addr);
|
2010-10-30 12:51:46 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
return addr;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
addr_t SBFrame::GetFP() const {
|
|
|
|
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
|
|
|
|
addr_t addr = LLDB_INVALID_ADDRESS;
|
|
|
|
std::unique_lock<std::recursive_mutex> lock;
|
|
|
|
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
|
|
|
|
|
|
|
|
StackFrame *frame = nullptr;
|
|
|
|
Target *target = exe_ctx.GetTargetPtr();
|
|
|
|
Process *process = exe_ctx.GetProcessPtr();
|
|
|
|
if (target && process) {
|
|
|
|
Process::StopLocker stop_locker;
|
|
|
|
if (stop_locker.TryLock(&process->GetRunLock())) {
|
|
|
|
frame = exe_ctx.GetFramePtr();
|
|
|
|
if (frame) {
|
|
|
|
addr = frame->GetRegisterContext()->GetFP();
|
|
|
|
} else {
|
|
|
|
if (log)
|
|
|
|
log->Printf("SBFrame::GetFP () => error: could not reconstruct frame "
|
|
|
|
"object for this SBFrame.");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (log)
|
|
|
|
log->Printf("SBFrame::GetFP () => error: process is running");
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
if (log)
|
|
|
|
log->Printf("SBFrame(%p)::GetFP () => 0x%" PRIx64,
|
|
|
|
static_cast<void *>(frame), addr);
|
|
|
|
return addr;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
SBAddress SBFrame::GetPCAddress() const {
|
|
|
|
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
|
|
|
|
SBAddress sb_addr;
|
|
|
|
std::unique_lock<std::recursive_mutex> lock;
|
|
|
|
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
|
|
|
|
|
|
|
|
StackFrame *frame = exe_ctx.GetFramePtr();
|
|
|
|
Target *target = exe_ctx.GetTargetPtr();
|
|
|
|
Process *process = exe_ctx.GetProcessPtr();
|
|
|
|
if (target && process) {
|
|
|
|
Process::StopLocker stop_locker;
|
|
|
|
if (stop_locker.TryLock(&process->GetRunLock())) {
|
|
|
|
frame = exe_ctx.GetFramePtr();
|
|
|
|
if (frame) {
|
|
|
|
sb_addr.SetAddress(&frame->GetFrameCodeAddress());
|
|
|
|
} else {
|
|
|
|
if (log)
|
|
|
|
log->Printf("SBFrame::GetPCAddress () => error: could not "
|
|
|
|
"reconstruct frame object for this SBFrame.");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (log)
|
|
|
|
log->Printf("SBFrame::GetPCAddress () => error: process is running");
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
if (log)
|
|
|
|
log->Printf("SBFrame(%p)::GetPCAddress () => SBAddress(%p)",
|
|
|
|
static_cast<void *>(frame), static_cast<void *>(sb_addr.get()));
|
|
|
|
return sb_addr;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
void SBFrame::Clear() { m_opaque_sp->Clear(); }
|
|
|
|
|
|
|
|
lldb::SBValue SBFrame::GetValueForVariablePath(const char *var_path) {
|
|
|
|
SBValue sb_value;
|
|
|
|
std::unique_lock<std::recursive_mutex> lock;
|
|
|
|
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
|
|
|
|
|
|
|
|
StackFrame *frame = exe_ctx.GetFramePtr();
|
|
|
|
Target *target = exe_ctx.GetTargetPtr();
|
|
|
|
if (frame && target) {
|
|
|
|
lldb::DynamicValueType use_dynamic =
|
|
|
|
frame->CalculateTarget()->GetPreferDynamicValue();
|
|
|
|
sb_value = GetValueForVariablePath(var_path, use_dynamic);
|
|
|
|
}
|
|
|
|
return sb_value;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
lldb::SBValue SBFrame::GetValueForVariablePath(const char *var_path,
|
|
|
|
DynamicValueType use_dynamic) {
|
|
|
|
SBValue sb_value;
|
|
|
|
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
|
|
|
|
if (var_path == nullptr || var_path[0] == '\0') {
|
|
|
|
if (log)
|
|
|
|
log->Printf(
|
|
|
|
"SBFrame::GetValueForVariablePath called with empty variable path.");
|
2012-02-03 15:02:37 +08:00
|
|
|
return sb_value;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
std::unique_lock<std::recursive_mutex> lock;
|
|
|
|
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
|
|
|
|
|
|
|
|
StackFrame *frame = nullptr;
|
|
|
|
Target *target = exe_ctx.GetTargetPtr();
|
|
|
|
Process *process = exe_ctx.GetProcessPtr();
|
|
|
|
if (target && process) {
|
|
|
|
Process::StopLocker stop_locker;
|
|
|
|
if (stop_locker.TryLock(&process->GetRunLock())) {
|
|
|
|
frame = exe_ctx.GetFramePtr();
|
|
|
|
if (frame) {
|
|
|
|
VariableSP var_sp;
|
|
|
|
Error error;
|
|
|
|
ValueObjectSP value_sp(frame->GetValueForVariableExpressionPath(
|
|
|
|
var_path, eNoDynamicValues,
|
|
|
|
StackFrame::eExpressionPathOptionCheckPtrVsMember |
|
|
|
|
StackFrame::eExpressionPathOptionsAllowDirectIVarAccess,
|
|
|
|
var_sp, error));
|
|
|
|
sb_value.SetSP(value_sp, use_dynamic);
|
|
|
|
} else {
|
2012-11-29 08:26:19 +08:00
|
|
|
if (log)
|
2016-09-07 04:57:50 +08:00
|
|
|
log->Printf("SBFrame::GetValueForVariablePath () => error: could not "
|
|
|
|
"reconstruct frame object for this SBFrame.");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (log)
|
|
|
|
log->Printf(
|
|
|
|
"SBFrame::GetValueForVariablePath () => error: process is running");
|
2012-11-29 08:26:19 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
return sb_value;
|
2012-02-03 15:02:37 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
SBValue SBFrame::FindVariable(const char *name) {
|
|
|
|
SBValue value;
|
|
|
|
std::unique_lock<std::recursive_mutex> lock;
|
|
|
|
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
|
|
|
|
|
|
|
|
StackFrame *frame = exe_ctx.GetFramePtr();
|
|
|
|
Target *target = exe_ctx.GetTargetPtr();
|
|
|
|
if (frame && target) {
|
|
|
|
lldb::DynamicValueType use_dynamic =
|
|
|
|
frame->CalculateTarget()->GetPreferDynamicValue();
|
|
|
|
value = FindVariable(name, use_dynamic);
|
|
|
|
}
|
|
|
|
return value;
|
2011-04-16 08:01:13 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
SBValue SBFrame::FindVariable(const char *name,
|
|
|
|
lldb::DynamicValueType use_dynamic) {
|
|
|
|
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
|
|
|
|
VariableSP var_sp;
|
|
|
|
SBValue sb_value;
|
2011-06-19 04:06:08 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
if (name == nullptr || name[0] == '\0') {
|
|
|
|
if (log)
|
|
|
|
log->Printf("SBFrame::FindVariable called with empty name");
|
|
|
|
return sb_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
ValueObjectSP value_sp;
|
|
|
|
std::unique_lock<std::recursive_mutex> lock;
|
|
|
|
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
|
|
|
|
|
|
|
|
StackFrame *frame = nullptr;
|
|
|
|
Target *target = exe_ctx.GetTargetPtr();
|
|
|
|
Process *process = exe_ctx.GetProcessPtr();
|
|
|
|
if (target && process) {
|
|
|
|
Process::StopLocker stop_locker;
|
|
|
|
if (stop_locker.TryLock(&process->GetRunLock())) {
|
|
|
|
frame = exe_ctx.GetFramePtr();
|
|
|
|
if (frame) {
|
|
|
|
VariableList variable_list;
|
|
|
|
SymbolContext sc(frame->GetSymbolContext(eSymbolContextBlock));
|
|
|
|
|
|
|
|
if (sc.block) {
|
|
|
|
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,
|
|
|
|
[frame](Variable *v) { return v->IsInScope(frame); },
|
|
|
|
&variable_list)) {
|
|
|
|
var_sp = variable_list.FindVariable(ConstString(name));
|
|
|
|
}
|
2012-02-04 10:27:34 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
|
|
|
if (var_sp) {
|
|
|
|
value_sp =
|
|
|
|
frame->GetValueObjectForFrameVariable(var_sp, eNoDynamicValues);
|
|
|
|
sb_value.SetSP(value_sp, use_dynamic);
|
2012-04-06 10:17:47 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
} else {
|
|
|
|
if (log)
|
|
|
|
log->Printf("SBFrame::FindVariable () => error: could not "
|
|
|
|
"reconstruct frame object for this SBFrame.");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (log)
|
|
|
|
log->Printf("SBFrame::FindVariable () => error: process is running");
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
if (log)
|
|
|
|
log->Printf("SBFrame(%p)::FindVariable (name=\"%s\") => SBValue(%p)",
|
|
|
|
static_cast<void *>(frame), name,
|
|
|
|
static_cast<void *>(value_sp.get()));
|
2010-10-30 12:51:46 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
return sb_value;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
SBValue SBFrame::FindValue(const char *name, ValueType value_type) {
|
|
|
|
SBValue value;
|
|
|
|
std::unique_lock<std::recursive_mutex> lock;
|
|
|
|
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
|
|
|
|
|
|
|
|
StackFrame *frame = exe_ctx.GetFramePtr();
|
|
|
|
Target *target = exe_ctx.GetTargetPtr();
|
|
|
|
if (frame && target) {
|
|
|
|
lldb::DynamicValueType use_dynamic =
|
|
|
|
frame->CalculateTarget()->GetPreferDynamicValue();
|
|
|
|
value = FindValue(name, value_type, use_dynamic);
|
|
|
|
}
|
|
|
|
return value;
|
2011-04-16 08:01:13 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
SBValue SBFrame::FindValue(const char *name, ValueType value_type,
|
|
|
|
lldb::DynamicValueType use_dynamic) {
|
|
|
|
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
|
|
|
|
SBValue sb_value;
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
if (name == nullptr || name[0] == '\0') {
|
|
|
|
if (log)
|
|
|
|
log->Printf("SBFrame::FindValue called with empty name.");
|
|
|
|
return sb_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
ValueObjectSP value_sp;
|
|
|
|
std::unique_lock<std::recursive_mutex> lock;
|
|
|
|
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
|
|
|
|
|
|
|
|
StackFrame *frame = nullptr;
|
|
|
|
Target *target = exe_ctx.GetTargetPtr();
|
|
|
|
Process *process = exe_ctx.GetProcessPtr();
|
|
|
|
if (target && process) {
|
|
|
|
Process::StopLocker stop_locker;
|
|
|
|
if (stop_locker.TryLock(&process->GetRunLock())) {
|
|
|
|
frame = exe_ctx.GetFramePtr();
|
|
|
|
if (frame) {
|
|
|
|
VariableList variable_list;
|
|
|
|
|
|
|
|
switch (value_type) {
|
|
|
|
case eValueTypeVariableGlobal: // global variable
|
|
|
|
case eValueTypeVariableStatic: // static variable
|
|
|
|
case eValueTypeVariableArgument: // function argument variables
|
|
|
|
case eValueTypeVariableLocal: // function local variables
|
|
|
|
case eValueTypeVariableThreadLocal: // thread local variables
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2016-09-07 04:57:50 +08:00
|
|
|
SymbolContext sc(frame->GetSymbolContext(eSymbolContextBlock));
|
|
|
|
|
|
|
|
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,
|
|
|
|
[frame](Variable *v) { return v->IsInScope(frame); },
|
|
|
|
&variable_list);
|
|
|
|
if (value_type == eValueTypeVariableGlobal) {
|
|
|
|
const bool get_file_globals = true;
|
|
|
|
VariableList *frame_vars = frame->GetVariableList(get_file_globals);
|
|
|
|
if (frame_vars)
|
|
|
|
frame_vars->AppendVariablesIfUnique(variable_list);
|
|
|
|
}
|
|
|
|
ConstString const_name(name);
|
|
|
|
VariableSP variable_sp(
|
|
|
|
variable_list.FindVariable(const_name, value_type));
|
|
|
|
if (variable_sp) {
|
|
|
|
value_sp = frame->GetValueObjectForFrameVariable(variable_sp,
|
|
|
|
eNoDynamicValues);
|
|
|
|
sb_value.SetSP(value_sp, use_dynamic);
|
|
|
|
}
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case eValueTypeRegister: // stack frame register value
|
|
|
|
{
|
|
|
|
RegisterContextSP reg_ctx(frame->GetRegisterContext());
|
|
|
|
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))) {
|
|
|
|
value_sp = ValueObjectRegister::Create(frame, reg_ctx, reg_idx);
|
|
|
|
sb_value.SetSP(value_sp);
|
|
|
|
break;
|
|
|
|
}
|
2012-11-29 08:26:19 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case eValueTypeRegisterSet: // A collection of stack frame register
|
|
|
|
// values
|
|
|
|
{
|
|
|
|
RegisterContextSP reg_ctx(frame->GetRegisterContext());
|
|
|
|
if (reg_ctx) {
|
|
|
|
const uint32_t num_sets = reg_ctx->GetRegisterSetCount();
|
|
|
|
for (uint32_t set_idx = 0; set_idx < num_sets; ++set_idx) {
|
|
|
|
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))) {
|
|
|
|
value_sp =
|
|
|
|
ValueObjectRegisterSet::Create(frame, reg_ctx, set_idx);
|
|
|
|
sb_value.SetSP(value_sp);
|
|
|
|
break;
|
|
|
|
}
|
2012-04-06 00:12:35 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case eValueTypeConstResult: // constant result variables
|
2012-04-06 10:17:47 +08:00
|
|
|
{
|
2016-09-07 04:57:50 +08:00
|
|
|
ConstString const_name(name);
|
|
|
|
ExpressionVariableSP expr_var_sp(
|
|
|
|
target->GetPersistentVariable(const_name));
|
|
|
|
if (expr_var_sp) {
|
|
|
|
value_sp = expr_var_sp->GetValueObject();
|
|
|
|
sb_value.SetSP(value_sp, use_dynamic);
|
|
|
|
}
|
|
|
|
} break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2012-04-06 10:17:47 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
} else {
|
|
|
|
if (log)
|
|
|
|
log->Printf("SBFrame::FindValue () => error: could not reconstruct "
|
|
|
|
"frame object for this SBFrame.");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (log)
|
|
|
|
log->Printf("SBFrame::FindValue () => error: process is running");
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
if (log)
|
|
|
|
log->Printf("SBFrame(%p)::FindVariableInScope (name=\"%s\", value_type=%i) "
|
|
|
|
"=> SBValue(%p)",
|
|
|
|
static_cast<void *>(frame), name, value_type,
|
|
|
|
static_cast<void *>(value_sp.get()));
|
2010-10-30 12:51:46 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
return sb_value;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
bool SBFrame::IsEqual(const SBFrame &that) const {
|
|
|
|
lldb::StackFrameSP this_sp = GetFrameSP();
|
|
|
|
lldb::StackFrameSP that_sp = that.GetFrameSP();
|
|
|
|
return (this_sp && that_sp && this_sp->GetStackID() == that_sp->GetStackID());
|
2012-03-06 03:53:24 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
bool SBFrame::operator==(const SBFrame &rhs) const { return IsEqual(rhs); }
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
bool SBFrame::operator!=(const SBFrame &rhs) const { return !IsEqual(rhs); }
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
SBThread SBFrame::GetThread() const {
|
|
|
|
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
std::unique_lock<std::recursive_mutex> lock;
|
|
|
|
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
|
2016-06-10 08:37:44 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
ThreadSP thread_sp(exe_ctx.GetThreadSP());
|
|
|
|
SBThread sb_thread(thread_sp);
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
if (log) {
|
|
|
|
SBStream sstr;
|
|
|
|
sb_thread.GetDescription(sstr);
|
|
|
|
log->Printf("SBFrame(%p)::GetThread () => SBThread(%p): %s",
|
|
|
|
static_cast<void *>(exe_ctx.GetFramePtr()),
|
|
|
|
static_cast<void *>(thread_sp.get()), sstr.GetData());
|
|
|
|
}
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
return sb_thread;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
const char *SBFrame::Disassemble() const {
|
|
|
|
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
|
|
|
|
const char *disassembly = nullptr;
|
|
|
|
std::unique_lock<std::recursive_mutex> lock;
|
|
|
|
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
|
|
|
|
|
|
|
|
StackFrame *frame = nullptr;
|
|
|
|
Target *target = exe_ctx.GetTargetPtr();
|
|
|
|
Process *process = exe_ctx.GetProcessPtr();
|
|
|
|
if (target && process) {
|
|
|
|
Process::StopLocker stop_locker;
|
|
|
|
if (stop_locker.TryLock(&process->GetRunLock())) {
|
|
|
|
frame = exe_ctx.GetFramePtr();
|
|
|
|
if (frame) {
|
|
|
|
disassembly = frame->Disassemble();
|
|
|
|
} else {
|
|
|
|
if (log)
|
|
|
|
log->Printf("SBFrame::Disassemble () => error: could not reconstruct "
|
|
|
|
"frame object for this SBFrame.");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (log)
|
|
|
|
log->Printf("SBFrame::Disassemble () => error: process is running");
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
if (log)
|
|
|
|
log->Printf("SBFrame(%p)::Disassemble () => %s", static_cast<void *>(frame),
|
|
|
|
disassembly);
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
return disassembly;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
SBValueList SBFrame::GetVariables(bool arguments, bool locals, bool statics,
|
|
|
|
bool in_scope_only) {
|
|
|
|
SBValueList value_list;
|
|
|
|
std::unique_lock<std::recursive_mutex> lock;
|
|
|
|
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
|
|
|
|
|
|
|
|
StackFrame *frame = exe_ctx.GetFramePtr();
|
|
|
|
Target *target = exe_ctx.GetTargetPtr();
|
|
|
|
if (frame && target) {
|
|
|
|
lldb::DynamicValueType use_dynamic =
|
|
|
|
frame->CalculateTarget()->GetPreferDynamicValue();
|
|
|
|
const bool include_runtime_support_values =
|
|
|
|
target ? target->GetDisplayRuntimeSupportValues() : false;
|
2011-04-16 08:01:13 +08:00
|
|
|
|
2015-02-18 01:55:50 +08:00
|
|
|
SBVariablesOptions options;
|
|
|
|
options.SetIncludeArguments(arguments);
|
|
|
|
options.SetIncludeLocals(locals);
|
|
|
|
options.SetIncludeStatics(statics);
|
|
|
|
options.SetInScopeOnly(in_scope_only);
|
|
|
|
options.SetIncludeRuntimeSupportValues(include_runtime_support_values);
|
|
|
|
options.SetUseDynamic(use_dynamic);
|
2016-09-07 04:57:50 +08:00
|
|
|
|
|
|
|
value_list = GetVariables(options);
|
|
|
|
}
|
|
|
|
return value_list;
|
2015-02-11 10:35:39 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
lldb::SBValueList SBFrame::GetVariables(bool arguments, bool locals,
|
|
|
|
bool statics, bool in_scope_only,
|
|
|
|
lldb::DynamicValueType use_dynamic) {
|
|
|
|
std::unique_lock<std::recursive_mutex> lock;
|
|
|
|
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
|
|
|
|
|
|
|
|
Target *target = exe_ctx.GetTargetPtr();
|
|
|
|
const bool include_runtime_support_values =
|
|
|
|
target ? target->GetDisplayRuntimeSupportValues() : false;
|
|
|
|
SBVariablesOptions options;
|
|
|
|
options.SetIncludeArguments(arguments);
|
|
|
|
options.SetIncludeLocals(locals);
|
|
|
|
options.SetIncludeStatics(statics);
|
|
|
|
options.SetInScopeOnly(in_scope_only);
|
|
|
|
options.SetIncludeRuntimeSupportValues(include_runtime_support_values);
|
|
|
|
options.SetUseDynamic(use_dynamic);
|
|
|
|
return GetVariables(options);
|
|
|
|
}
|
|
|
|
|
|
|
|
SBValueList SBFrame::GetVariables(const lldb::SBVariablesOptions &options) {
|
|
|
|
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
|
|
|
|
|
|
|
|
SBValueList value_list;
|
|
|
|
std::unique_lock<std::recursive_mutex> lock;
|
|
|
|
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
|
|
|
|
|
|
|
|
StackFrame *frame = nullptr;
|
|
|
|
Target *target = exe_ctx.GetTargetPtr();
|
|
|
|
|
|
|
|
const bool statics = options.GetIncludeStatics();
|
|
|
|
const bool arguments = options.GetIncludeArguments();
|
|
|
|
const bool locals = options.GetIncludeLocals();
|
|
|
|
const bool in_scope_only = options.GetInScopeOnly();
|
|
|
|
const bool include_runtime_support_values =
|
|
|
|
options.GetIncludeRuntimeSupportValues();
|
|
|
|
const lldb::DynamicValueType use_dynamic = options.GetUseDynamic();
|
|
|
|
|
|
|
|
if (log)
|
|
|
|
log->Printf("SBFrame::GetVariables (arguments=%i, locals=%i, statics=%i, "
|
|
|
|
"in_scope_only=%i runtime=%i dynamic=%i)",
|
|
|
|
arguments, locals, statics, in_scope_only,
|
|
|
|
include_runtime_support_values, use_dynamic);
|
|
|
|
|
|
|
|
std::set<VariableSP> variable_set;
|
|
|
|
Process *process = exe_ctx.GetProcessPtr();
|
|
|
|
if (target && process) {
|
|
|
|
Process::StopLocker stop_locker;
|
|
|
|
if (stop_locker.TryLock(&process->GetRunLock())) {
|
|
|
|
frame = exe_ctx.GetFramePtr();
|
|
|
|
if (frame) {
|
|
|
|
size_t i;
|
|
|
|
VariableList *variable_list = nullptr;
|
|
|
|
variable_list = frame->GetVariableList(true);
|
|
|
|
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:
|
|
|
|
case eValueTypeVariableThreadLocal:
|
|
|
|
add_variable = statics;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eValueTypeVariableArgument:
|
|
|
|
add_variable = arguments;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eValueTypeVariableLocal:
|
|
|
|
add_variable = locals;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
if (add_variable) {
|
|
|
|
// Only add variables once so we don't end up with duplicates
|
|
|
|
if (variable_set.find(variable_sp) == variable_set.end())
|
|
|
|
variable_set.insert(variable_sp);
|
|
|
|
else
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (in_scope_only && !variable_sp->IsInScope(frame))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
ValueObjectSP valobj_sp(frame->GetValueObjectForFrameVariable(
|
|
|
|
variable_sp, eNoDynamicValues));
|
|
|
|
|
|
|
|
if (!include_runtime_support_values && valobj_sp != nullptr &&
|
|
|
|
valobj_sp->IsRuntimeSupportValue())
|
|
|
|
continue;
|
|
|
|
|
|
|
|
SBValue value_sb;
|
|
|
|
value_sb.SetSP(valobj_sp, use_dynamic);
|
|
|
|
value_list.Append(value_sb);
|
|
|
|
}
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2014-04-04 12:06:10 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
} else {
|
|
|
|
if (log)
|
|
|
|
log->Printf("SBFrame::GetVariables () => error: could not "
|
|
|
|
"reconstruct frame object for this SBFrame.");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (log)
|
|
|
|
log->Printf("SBFrame::GetVariables () => error: process is running");
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
if (log)
|
|
|
|
log->Printf("SBFrame(%p)::GetVariables (...) => SBValueList(%p)",
|
|
|
|
static_cast<void *>(frame),
|
|
|
|
static_cast<void *>(value_list.opaque_ptr()));
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
return value_list;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
SBValueList SBFrame::GetRegisters() {
|
|
|
|
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
|
|
|
|
|
|
|
|
SBValueList value_list;
|
|
|
|
std::unique_lock<std::recursive_mutex> lock;
|
|
|
|
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
|
|
|
|
|
|
|
|
StackFrame *frame = nullptr;
|
|
|
|
Target *target = exe_ctx.GetTargetPtr();
|
|
|
|
Process *process = exe_ctx.GetProcessPtr();
|
|
|
|
if (target && process) {
|
|
|
|
Process::StopLocker stop_locker;
|
|
|
|
if (stop_locker.TryLock(&process->GetRunLock())) {
|
|
|
|
frame = exe_ctx.GetFramePtr();
|
|
|
|
if (frame) {
|
|
|
|
RegisterContextSP reg_ctx(frame->GetRegisterContext());
|
|
|
|
if (reg_ctx) {
|
|
|
|
const uint32_t num_sets = reg_ctx->GetRegisterSetCount();
|
|
|
|
for (uint32_t set_idx = 0; set_idx < num_sets; ++set_idx) {
|
|
|
|
value_list.Append(
|
|
|
|
ValueObjectRegisterSet::Create(frame, reg_ctx, set_idx));
|
|
|
|
}
|
2014-04-04 12:06:10 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
} else {
|
|
|
|
if (log)
|
|
|
|
log->Printf("SBFrame::GetRegisters () => error: could not "
|
|
|
|
"reconstruct frame object for this SBFrame.");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (log)
|
|
|
|
log->Printf("SBFrame::GetRegisters () => error: process is running");
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
if (log)
|
|
|
|
log->Printf("SBFrame(%p)::GetRegisters () => SBValueList(%p)",
|
|
|
|
static_cast<void *>(frame),
|
|
|
|
static_cast<void *>(value_list.opaque_ptr()));
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
return value_list;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
SBValue SBFrame::FindRegister(const char *name) {
|
|
|
|
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
|
|
|
|
|
|
|
|
SBValue result;
|
|
|
|
ValueObjectSP value_sp;
|
|
|
|
std::unique_lock<std::recursive_mutex> lock;
|
|
|
|
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
|
|
|
|
|
|
|
|
StackFrame *frame = nullptr;
|
|
|
|
Target *target = exe_ctx.GetTargetPtr();
|
|
|
|
Process *process = exe_ctx.GetProcessPtr();
|
|
|
|
if (target && process) {
|
|
|
|
Process::StopLocker stop_locker;
|
|
|
|
if (stop_locker.TryLock(&process->GetRunLock())) {
|
|
|
|
frame = exe_ctx.GetFramePtr();
|
|
|
|
if (frame) {
|
|
|
|
RegisterContextSP reg_ctx(frame->GetRegisterContext());
|
|
|
|
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))) {
|
|
|
|
value_sp = ValueObjectRegister::Create(frame, reg_ctx, reg_idx);
|
|
|
|
result.SetSP(value_sp);
|
|
|
|
break;
|
2013-07-26 10:08:48 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2014-04-04 12:06:10 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
} else {
|
|
|
|
if (log)
|
|
|
|
log->Printf("SBFrame::FindRegister () => error: could not "
|
|
|
|
"reconstruct frame object for this SBFrame.");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (log)
|
|
|
|
log->Printf("SBFrame::FindRegister () => error: process is running");
|
2013-07-26 10:08:48 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2013-07-26 10:08:48 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
if (log)
|
|
|
|
log->Printf("SBFrame(%p)::FindRegister () => SBValue(%p)",
|
|
|
|
static_cast<void *>(frame),
|
|
|
|
static_cast<void *>(value_sp.get()));
|
2013-07-26 10:08:48 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
return result;
|
2013-07-26 10:08:48 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
bool SBFrame::GetDescription(SBStream &description) {
|
|
|
|
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
|
|
|
|
Stream &strm = description.ref();
|
|
|
|
|
|
|
|
std::unique_lock<std::recursive_mutex> lock;
|
|
|
|
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
|
|
|
|
|
|
|
|
StackFrame *frame;
|
|
|
|
Target *target = exe_ctx.GetTargetPtr();
|
|
|
|
Process *process = exe_ctx.GetProcessPtr();
|
|
|
|
if (target && process) {
|
|
|
|
Process::StopLocker stop_locker;
|
|
|
|
if (stop_locker.TryLock(&process->GetRunLock())) {
|
|
|
|
frame = exe_ctx.GetFramePtr();
|
|
|
|
if (frame) {
|
|
|
|
frame->DumpUsingSettingsFormat(&strm);
|
|
|
|
} else {
|
|
|
|
if (log)
|
|
|
|
log->Printf("SBFrame::GetDescription () => error: could not "
|
|
|
|
"reconstruct frame object for this SBFrame.");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (log)
|
|
|
|
log->Printf("SBFrame::GetDescription () => error: process is running");
|
2010-09-20 13:20:02 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
} else
|
|
|
|
strm.PutCString("No value");
|
2010-10-05 08:00:42 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
return true;
|
2011-04-16 08:01:13 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
SBValue SBFrame::EvaluateExpression(const char *expr) {
|
|
|
|
SBValue result;
|
|
|
|
std::unique_lock<std::recursive_mutex> lock;
|
|
|
|
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
|
|
|
|
|
|
|
|
StackFrame *frame = exe_ctx.GetFramePtr();
|
|
|
|
Target *target = exe_ctx.GetTargetPtr();
|
|
|
|
if (frame && target) {
|
2012-10-17 05:41:58 +08:00
|
|
|
SBExpressionOptions options;
|
2016-09-07 04:57:50 +08:00
|
|
|
lldb::DynamicValueType fetch_dynamic_value =
|
|
|
|
frame->CalculateTarget()->GetPreferDynamicValue();
|
|
|
|
options.SetFetchDynamicValue(fetch_dynamic_value);
|
|
|
|
options.SetUnwindOnError(true);
|
|
|
|
options.SetIgnoreBreakpoints(true);
|
|
|
|
if (target->GetLanguage() != eLanguageTypeUnknown)
|
|
|
|
options.SetLanguage(target->GetLanguage());
|
|
|
|
else
|
|
|
|
options.SetLanguage(frame->GetLanguage());
|
|
|
|
return EvaluateExpression(expr, options);
|
|
|
|
}
|
|
|
|
return result;
|
2012-05-12 07:47:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
SBValue
|
2016-09-07 04:57:50 +08:00
|
|
|
SBFrame::EvaluateExpression(const char *expr,
|
|
|
|
lldb::DynamicValueType fetch_dynamic_value) {
|
|
|
|
SBExpressionOptions options;
|
|
|
|
options.SetFetchDynamicValue(fetch_dynamic_value);
|
|
|
|
options.SetUnwindOnError(true);
|
|
|
|
options.SetIgnoreBreakpoints(true);
|
|
|
|
std::unique_lock<std::recursive_mutex> lock;
|
|
|
|
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
|
|
|
|
|
|
|
|
StackFrame *frame = exe_ctx.GetFramePtr();
|
|
|
|
Target *target = exe_ctx.GetTargetPtr();
|
|
|
|
if (target && target->GetLanguage() != eLanguageTypeUnknown)
|
|
|
|
options.SetLanguage(target->GetLanguage());
|
|
|
|
else if (frame)
|
|
|
|
options.SetLanguage(frame->GetLanguage());
|
|
|
|
return EvaluateExpression(expr, options);
|
2012-10-17 05:41:58 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
SBValue SBFrame::EvaluateExpression(const char *expr,
|
|
|
|
lldb::DynamicValueType fetch_dynamic_value,
|
|
|
|
bool unwind_on_error) {
|
|
|
|
SBExpressionOptions options;
|
|
|
|
std::unique_lock<std::recursive_mutex> lock;
|
|
|
|
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
|
|
|
|
|
|
|
|
options.SetFetchDynamicValue(fetch_dynamic_value);
|
|
|
|
options.SetUnwindOnError(unwind_on_error);
|
|
|
|
options.SetIgnoreBreakpoints(true);
|
|
|
|
StackFrame *frame = exe_ctx.GetFramePtr();
|
|
|
|
Target *target = exe_ctx.GetTargetPtr();
|
|
|
|
if (target && target->GetLanguage() != eLanguageTypeUnknown)
|
|
|
|
options.SetLanguage(target->GetLanguage());
|
|
|
|
else if (frame)
|
|
|
|
options.SetLanguage(frame->GetLanguage());
|
|
|
|
return EvaluateExpression(expr, options);
|
|
|
|
}
|
|
|
|
|
|
|
|
lldb::SBValue SBFrame::EvaluateExpression(const char *expr,
|
|
|
|
const SBExpressionOptions &options) {
|
|
|
|
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2016-04-22 00:56:02 +08:00
|
|
|
#ifndef LLDB_DISABLE_PYTHON
|
2016-09-07 04:57:50 +08:00
|
|
|
Log *expr_log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
|
2016-04-22 00:56:02 +08:00
|
|
|
#endif
|
2010-10-30 12:51:46 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
ExpressionResults exe_results = eExpressionSetupError;
|
|
|
|
SBValue expr_result;
|
2012-08-23 05:34:33 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
if (expr == nullptr || expr[0] == '\0') {
|
2010-10-30 12:51:46 +08:00
|
|
|
if (log)
|
2016-09-07 04:57:50 +08:00
|
|
|
log->Printf(
|
|
|
|
"SBFrame::EvaluateExpression called with an empty expression");
|
|
|
|
return expr_result;
|
|
|
|
}
|
|
|
|
|
|
|
|
ValueObjectSP expr_value_sp;
|
|
|
|
|
|
|
|
std::unique_lock<std::recursive_mutex> lock;
|
|
|
|
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
|
|
|
|
|
|
|
|
if (log)
|
|
|
|
log->Printf("SBFrame()::EvaluateExpression (expr=\"%s\")...", expr);
|
|
|
|
|
|
|
|
StackFrame *frame = nullptr;
|
|
|
|
Target *target = exe_ctx.GetTargetPtr();
|
|
|
|
Process *process = exe_ctx.GetProcessPtr();
|
|
|
|
|
|
|
|
if (target && process) {
|
|
|
|
Process::StopLocker stop_locker;
|
|
|
|
if (stop_locker.TryLock(&process->GetRunLock())) {
|
|
|
|
frame = exe_ctx.GetFramePtr();
|
|
|
|
if (frame) {
|
2016-12-15 05:31:31 +08:00
|
|
|
std::unique_ptr<llvm::PrettyStackTraceFormat> PST;
|
2016-09-07 04:57:50 +08:00
|
|
|
if (target->GetDisplayExpressionsInCrashlogs()) {
|
|
|
|
StreamString frame_description;
|
|
|
|
frame->DumpUsingSettingsFormat(&frame_description);
|
2016-12-15 05:31:31 +08:00
|
|
|
PST = llvm::make_unique<llvm::PrettyStackTraceFormat>(
|
2016-09-07 04:57:50 +08:00
|
|
|
"SBFrame::EvaluateExpression (expr = \"%s\", fetch_dynamic_value "
|
|
|
|
"= %u) %s",
|
|
|
|
expr, options.GetFetchDynamicValue(),
|
2016-11-17 05:15:24 +08:00
|
|
|
frame_description.GetData());
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
exe_results = target->EvaluateExpression(expr, frame, expr_value_sp,
|
|
|
|
options.ref());
|
|
|
|
expr_result.SetSP(expr_value_sp, options.GetFetchDynamicValue());
|
|
|
|
} else {
|
|
|
|
if (log)
|
|
|
|
log->Printf("SBFrame::EvaluateExpression () => error: could not "
|
|
|
|
"reconstruct frame object for this SBFrame.");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (log)
|
|
|
|
log->Printf(
|
|
|
|
"SBFrame::EvaluateExpression () => error: process is running");
|
2010-10-05 08:00:42 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2012-02-21 13:33:55 +08:00
|
|
|
|
|
|
|
#ifndef LLDB_DISABLE_PYTHON
|
2016-09-07 04:57:50 +08:00
|
|
|
if (expr_log)
|
|
|
|
expr_log->Printf("** [SBFrame::EvaluateExpression] Expression result is "
|
|
|
|
"%s, summary %s **",
|
|
|
|
expr_result.GetValue(), expr_result.GetSummary());
|
|
|
|
|
|
|
|
if (log)
|
|
|
|
log->Printf("SBFrame(%p)::EvaluateExpression (expr=\"%s\") => SBValue(%p) "
|
|
|
|
"(execution result=%d)",
|
|
|
|
static_cast<void *>(frame), expr,
|
|
|
|
static_cast<void *>(expr_value_sp.get()), exe_results);
|
2012-02-21 13:33:55 +08:00
|
|
|
#endif
|
2010-10-30 12:51:46 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
return expr_result;
|
2010-10-05 08:00:42 +08:00
|
|
|
}
|
2011-06-19 04:06:08 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
bool SBFrame::IsInlined() {
|
|
|
|
return static_cast<const SBFrame *>(this)->IsInlined();
|
2015-06-26 01:41:41 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
bool SBFrame::IsInlined() const {
|
|
|
|
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
|
|
|
|
std::unique_lock<std::recursive_mutex> lock;
|
|
|
|
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
|
|
|
|
|
|
|
|
StackFrame *frame = nullptr;
|
|
|
|
Target *target = exe_ctx.GetTargetPtr();
|
|
|
|
Process *process = exe_ctx.GetProcessPtr();
|
|
|
|
if (target && process) {
|
|
|
|
Process::StopLocker stop_locker;
|
|
|
|
if (stop_locker.TryLock(&process->GetRunLock())) {
|
|
|
|
frame = exe_ctx.GetFramePtr();
|
|
|
|
if (frame) {
|
|
|
|
|
|
|
|
Block *block = frame->GetSymbolContext(eSymbolContextBlock).block;
|
|
|
|
if (block)
|
|
|
|
return block->GetContainingInlinedBlock() != nullptr;
|
|
|
|
} else {
|
|
|
|
if (log)
|
|
|
|
log->Printf("SBFrame::IsInlined () => error: could not reconstruct "
|
|
|
|
"frame object for this SBFrame.");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (log)
|
|
|
|
log->Printf("SBFrame::IsInlined () => error: process is running");
|
2011-06-19 04:06:08 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
return false;
|
2011-06-19 04:06:08 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
const char *SBFrame::GetFunctionName() {
|
|
|
|
return static_cast<const SBFrame *>(this)->GetFunctionName();
|
2015-06-26 01:41:41 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
const char *SBFrame::GetFunctionName() const {
|
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
|
|
|
|
const char *name = nullptr;
|
|
|
|
std::unique_lock<std::recursive_mutex> lock;
|
|
|
|
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
|
|
|
|
|
|
|
|
StackFrame *frame = nullptr;
|
|
|
|
Target *target = exe_ctx.GetTargetPtr();
|
|
|
|
Process *process = exe_ctx.GetProcessPtr();
|
|
|
|
if (target && process) {
|
|
|
|
Process::StopLocker stop_locker;
|
|
|
|
if (stop_locker.TryLock(&process->GetRunLock())) {
|
|
|
|
frame = exe_ctx.GetFramePtr();
|
|
|
|
if (frame) {
|
|
|
|
SymbolContext sc(frame->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(sc.function->GetLanguage()).AsCString();
|
|
|
|
}
|
|
|
|
}
|
2011-06-19 04:06:08 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
if (name == nullptr) {
|
|
|
|
if (sc.function)
|
|
|
|
name = sc.function->GetName().GetCString();
|
2011-06-19 04:06:08 +08:00
|
|
|
}
|
2012-04-06 10:17:47 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
if (name == nullptr) {
|
|
|
|
if (sc.symbol)
|
|
|
|
name = sc.symbol->GetName().GetCString();
|
2012-04-06 10:17:47 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
} else {
|
|
|
|
if (log)
|
|
|
|
log->Printf("SBFrame::GetFunctionName () => error: could not "
|
|
|
|
"reconstruct frame object for this SBFrame.");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (log)
|
|
|
|
log->Printf("SBFrame::GetFunctionName() => error: process is running");
|
2011-06-19 04:06:08 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
return name;
|
2011-06-19 04:06:08 +08:00
|
|
|
}
|
2015-07-07 02:28:46 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
const char *SBFrame::GetDisplayFunctionName() {
|
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
|
|
|
|
const char *name = nullptr;
|
|
|
|
|
|
|
|
std::unique_lock<std::recursive_mutex> lock;
|
|
|
|
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
|
|
|
|
|
|
|
|
StackFrame *frame = nullptr;
|
|
|
|
Target *target = exe_ctx.GetTargetPtr();
|
|
|
|
Process *process = exe_ctx.GetProcessPtr();
|
|
|
|
if (target && process) {
|
|
|
|
Process::StopLocker stop_locker;
|
|
|
|
if (stop_locker.TryLock(&process->GetRunLock())) {
|
|
|
|
frame = exe_ctx.GetFramePtr();
|
|
|
|
if (frame) {
|
|
|
|
SymbolContext sc(frame->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->GetDisplayName(sc.function->GetLanguage())
|
|
|
|
.AsCString();
|
|
|
|
}
|
2015-07-07 02:28:46 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
|
|
|
if (name == nullptr) {
|
|
|
|
if (sc.function)
|
|
|
|
name = sc.function->GetDisplayName().GetCString();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (name == nullptr) {
|
|
|
|
if (sc.symbol)
|
|
|
|
name = sc.symbol->GetDisplayName().GetCString();
|
2015-07-07 02:28:46 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
} else {
|
|
|
|
if (log)
|
|
|
|
log->Printf("SBFrame::GetDisplayFunctionName () => error: could not "
|
|
|
|
"reconstruct frame object for this SBFrame.");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (log)
|
|
|
|
log->Printf(
|
|
|
|
"SBFrame::GetDisplayFunctionName() => error: process is running");
|
2015-07-07 02:28:46 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
return name;
|
2015-07-07 02:28:46 +08:00
|
|
|
}
|