Add an SBFrame::FindRegister() method to make it a little
easier to retrieve a register value.
llvm-svn: 187184
diff --git a/lldb/source/API/SBFrame.cpp b/lldb/source/API/SBFrame.cpp
index 2822060..409603a 100644
--- a/lldb/source/API/SBFrame.cpp
+++ b/lldb/source/API/SBFrame.cpp
@@ -1214,6 +1214,64 @@
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)
{
diff --git a/lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp b/lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp
index 330a818..a904d8b 100644
--- a/lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp
+++ b/lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp
@@ -1187,6 +1187,7 @@
// "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