[Lldb-commits] [lldb] r187184 - Add an SBFrame::FindRegister() method to make it a little
Jason Molenda
jmolenda at apple.com
Thu Jul 25 19:08:48 PDT 2013
Author: jmolenda
Date: Thu Jul 25 21:08:48 2013
New Revision: 187184
URL: http://llvm.org/viewvc/llvm-project?rev=187184&view=rev
Log:
Add an SBFrame::FindRegister() method to make it a little
easier to retrieve a register value.
Modified:
lldb/trunk/include/lldb/API/SBFrame.h
lldb/trunk/scripts/Python/interface/SBFrame.i
lldb/trunk/source/API/SBFrame.cpp
lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp
Modified: lldb/trunk/include/lldb/API/SBFrame.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBFrame.h?rev=187184&r1=187183&r2=187184&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBFrame.h (original)
+++ lldb/trunk/include/lldb/API/SBFrame.h Thu Jul 25 21:08:48 2013
@@ -159,6 +159,9 @@ public:
lldb::SBValueList
GetRegisters ();
+ lldb::SBValue
+ FindRegister (const char *name);
+
/// The version that doesn't supply a 'use_dynamic' value will use the
/// target's default.
lldb::SBValue
Modified: lldb/trunk/scripts/Python/interface/SBFrame.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBFrame.i?rev=187184&r1=187183&r2=187184&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBFrame.i (original)
+++ lldb/trunk/scripts/Python/interface/SBFrame.i Thu Jul 25 21:08:48 2013
@@ -211,6 +211,9 @@ public:
lldb::SBValue
FindVariable (const char *var_name, lldb::DynamicValueType use_dynamic);
+ lldb::SBValue
+ FindRegister (const char *name);
+
%feature("docstring", "
/// Get a lldb.SBValue for a variable path.
///
Modified: lldb/trunk/source/API/SBFrame.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBFrame.cpp?rev=187184&r1=187183&r2=187184&view=diff
==============================================================================
--- lldb/trunk/source/API/SBFrame.cpp (original)
+++ lldb/trunk/source/API/SBFrame.cpp Thu Jul 25 21:08:48 2013
@@ -1214,6 +1214,64 @@ SBFrame::GetRegisters ()
return value_list;
}
+SBValue
+SBFrame::FindRegister (const char *name)
+{
+ Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+
+ SBValue result;
+ ValueObjectSP value_sp;
+ Mutex::Locker api_locker;
+ ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
+
+ StackFrame *frame = NULL;
+ 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;
+ }
+ }
+ }
+ }
+ else
+ {
+ if (log)
+ log->Printf ("SBFrame::GetRegisterByName () => error: could not reconstruct frame object for this SBFrame.");
+ }
+ }
+ else
+ {
+ if (log)
+ log->Printf ("SBFrame::GetRegisterByName () => error: process is running");
+ }
+ }
+
+ if (log)
+ log->Printf ("SBFrame(%p)::GetRegisterByName () => SBValue(%p)", frame, value_sp.get());
+
+ return result;
+}
+
bool
SBFrame::GetDescription (SBStream &description)
{
Modified: lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp?rev=187184&r1=187183&r2=187184&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp (original)
+++ lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp Thu Jul 25 21:08:48 2013
@@ -1187,6 +1187,7 @@ ABISysV_x86_64::RegisterIsVolatile (cons
// "System V Application Binary Interface"
// "AMD64 Architecture Processor Supplement"
// (or "x86-64(tm) Architecture Processor Supplement" in earlier revisions)
+// (this doc is also commonly referred to as the x86-64/AMD64 psABI)
// Edited by Michael Matz, Jan Hubicka, Andreas Jaeger, and Mark Mitchell
// current version is 0.99.6 released 2012-07-02 at http://refspecs.linuxfoundation.org/elf/x86-64-abi-0.99.pdf
More information about the lldb-commits
mailing list