summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
diff options
context:
space:
mode:
authorJason Molenda <jmolenda@apple.com>2014-11-08 05:38:17 +0000
committerJason Molenda <jmolenda@apple.com>2014-11-08 05:38:17 +0000
commitcf29675d9501cfff2a37acb8af3eefa6cbba19c1 (patch)
treef2bc714a1cd18a02e0972b281187fe56c6f3e974 /lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
parent13307f5f24299d35a0bf944153bc3d673fccadf6 (diff)
downloadbcm5719-llvm-cf29675d9501cfff2a37acb8af3eefa6cbba19c1.tar.gz
bcm5719-llvm-cf29675d9501cfff2a37acb8af3eefa6cbba19c1.zip
Fix a corner case with the handling of noreturn functions.
If a noreturn function was the last function in a section, we wouldn't correctly back up the saved-pc value into the correct section leading to us showing the wrong function in the backtrace. Also add a backtrace test with an attempt to elicit this particular layout. It happens to work out with clang -Os but other compilers may not quite get the same layout I'm getting at that opt setting. We'll still be exercising the basic noreturn handling in the unwinder even if we don't get one function at the very end of a section. <rdar://problem/16051613> llvm-svn: 221575
Diffstat (limited to 'lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp')
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp54
1 files changed, 45 insertions, 9 deletions
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp b/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
index 61f3400091b..9e24f24f6e9 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
@@ -172,6 +172,21 @@ RegisterContextLLDB::InitializeZerothFrame()
m_sym_ctx_valid = true;
}
+ if (m_sym_ctx.symbol)
+ {
+ UnwindLogMsg ("with pc value of 0x%" PRIx64 ", symbol name is '%s'",
+ current_pc, m_sym_ctx.symbol == NULL ? "" : m_sym_ctx.symbol->GetName().AsCString());
+ }
+ else if (m_sym_ctx.function)
+ {
+ UnwindLogMsg ("with pc value of 0x%" PRIx64 ", function name is '%s'",
+ current_pc, m_sym_ctx.symbol == NULL ? "" : m_sym_ctx.function->GetName().AsCString());
+ }
+ else
+ {
+ UnwindLogMsg ("with pc value of 0x%" PRIx64 ", no symbol/function name is known.", current_pc);
+ }
+
AddressRange addr_range;
m_sym_ctx.GetAddressRange (resolve_scope, 0, false, addr_range);
@@ -294,12 +309,12 @@ RegisterContextLLDB::InitializeNonZerothFrame()
if (log)
{
- UnwindLogMsg ("pc = 0x%16.16" PRIx64, pc);
+ UnwindLogMsg ("pc = 0x%" PRIx64, pc);
addr_t reg_val;
if (ReadGPRValue (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_FP, reg_val))
- UnwindLogMsg ("fp = 0x%16.16" PRIx64, reg_val);
+ UnwindLogMsg ("fp = 0x%" PRIx64, reg_val);
if (ReadGPRValue (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP, reg_val))
- UnwindLogMsg ("sp = 0x%16.16" PRIx64, reg_val);
+ UnwindLogMsg ("sp = 0x%" PRIx64, reg_val);
}
// A pc of 0x0 means it's the end of the stack crawl
@@ -442,6 +457,21 @@ RegisterContextLLDB::InitializeNonZerothFrame()
m_sym_ctx_valid = true;
}
+ if (m_sym_ctx.symbol)
+ {
+ UnwindLogMsg ("with pc value of 0x%" PRIx64 ", symbol name is '%s'",
+ pc, m_sym_ctx.symbol == NULL ? "" : m_sym_ctx.symbol->GetName().AsCString());
+ }
+ else if (m_sym_ctx.function)
+ {
+ UnwindLogMsg ("with pc value of 0x%" PRIx64 ", function name is '%s'",
+ pc, m_sym_ctx.symbol == NULL ? "" : m_sym_ctx.function->GetName().AsCString());
+ }
+ else
+ {
+ UnwindLogMsg ("with pc value of 0x%" PRIx64 ", no symbol/function name is known.", pc);
+ }
+
AddressRange addr_range;
if (!m_sym_ctx.GetAddressRange (resolve_scope, 0, false, addr_range))
{
@@ -472,17 +502,21 @@ RegisterContextLLDB::InitializeNonZerothFrame()
// to the ABI plugin and consult that.
if (decr_pc_and_recompute_addr_range)
{
- Address temporary_pc(m_current_pc);
- temporary_pc.SetOffset(m_current_pc.GetOffset() - 1);
- m_sym_ctx.Clear(false);
+ UnwindLogMsg ("Backing up the pc value of 0x%" PRIx64 " by 1 and re-doing symbol lookup; old symbol was %s",
+ pc, m_sym_ctx.symbol == NULL ? "" : m_sym_ctx.symbol->GetName().AsCString());
+ Address temporary_pc;
+ temporary_pc.SetLoadAddress (pc - 1, &process->GetTarget());
+ m_sym_ctx.Clear (false);
m_sym_ctx_valid = false;
uint32_t resolve_scope = eSymbolContextFunction | eSymbolContextSymbol;
- if (pc_module_sp->ResolveSymbolContextForAddress (temporary_pc, resolve_scope, m_sym_ctx) & resolve_scope)
+ ModuleSP temporary_module_sp = temporary_pc.GetModule();
+ if (temporary_module_sp->ResolveSymbolContextForAddress (temporary_pc, resolve_scope, m_sym_ctx) & resolve_scope)
{
if (m_sym_ctx.GetAddressRange (resolve_scope, 0, false, addr_range))
m_sym_ctx_valid = true;
}
+ UnwindLogMsg ("Symbol is now %s", m_sym_ctx.symbol == NULL ? "" : m_sym_ctx.symbol->GetName().AsCString());
}
// If we were able to find a symbol/function, set addr_range_ptr to the bounds of that symbol/function.
@@ -490,13 +524,15 @@ RegisterContextLLDB::InitializeNonZerothFrame()
if (addr_range.GetBaseAddress().IsValid())
{
m_start_pc = addr_range.GetBaseAddress();
- m_current_offset = m_current_pc.GetOffset() - m_start_pc.GetOffset();
+ m_current_offset = pc - m_start_pc.GetLoadAddress (&process->GetTarget());
m_current_offset_backed_up_one = m_current_offset;
if (decr_pc_and_recompute_addr_range && m_current_offset_backed_up_one > 0)
{
m_current_offset_backed_up_one--;
if (m_sym_ctx_valid)
- m_current_pc.SetOffset(m_current_pc.GetOffset() - 1);
+ {
+ m_current_pc.SetLoadAddress (pc - 1, &process->GetTarget());
+ }
}
}
else
OpenPOWER on IntegriCloud