[Lldb-commits] [lldb] r191262 - Update RegisterContextLLDB::GetFullUnwindPlanForFrame() to use the architectural-
Jason Molenda
jmolenda at apple.com
Mon Sep 23 19:42:54 PDT 2013
Author: jmolenda
Date: Mon Sep 23 21:42:54 2013
New Revision: 191262
URL: http://llvm.org/viewvc/llvm-project?rev=191262&view=rev
Log:
Update RegisterContextLLDB::GetFullUnwindPlanForFrame() to use the architectural-
default-at-first-instruction UnwindPlan if we're at the beginning of a function and
the ABI can provide us with an UnwindPlan to get out of there before falling back
to the generic architectural default UnwindPlan (which usually assumes that the stack
has already been set up.)
Update the FuncUnwinders methods to gracefully handle the case where an assembly
profiler may not be available.
Fix a bug where FuncUnwinders::GetUnwindPlanArchitectureDefaultAtFunctionEntry was
returning the wrong UnwindPlan to its caller.
Modified:
lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
lldb/trunk/source/Symbol/FuncUnwinders.cpp
Modified: lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp?rev=191262&r1=191261&r2=191262&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp Mon Sep 23 21:42:54 2013
@@ -632,9 +632,10 @@ RegisterContextLLDB::GetFullUnwindPlanFo
// in the zeroth frame, we need to use the "unwind at first instruction" arch default UnwindPlan
// Also, if this Process can report on memory region attributes, any non-executable region means
// we jumped through a bad function pointer - handle the same way as 0x0.
- // Note, if the symbol context has a function for the symbol, then we don't need to do this check.
+ // Note, if we have a symbol context & a symbol, we don't want to follow this code path. This is
+ // for jumping to memory regions without any information available.
- if ((!m_sym_ctx_valid || m_sym_ctx.function == NULL) && behaves_like_zeroth_frame && m_current_pc.IsValid())
+ if ((!m_sym_ctx_valid || m_sym_ctx.symbol == NULL) && behaves_like_zeroth_frame && m_current_pc.IsValid())
{
uint32_t permissions;
addr_t current_pc_addr = m_current_pc.GetLoadAddress (exe_ctx.GetTargetPtr());
@@ -741,6 +742,18 @@ RegisterContextLLDB::GetFullUnwindPlanFo
return unwind_plan_sp;
}
+ // If we're on the first instruction of a function, and we have an architectural default UnwindPlan
+ // for the initial instruction of a function, use that.
+ if (m_current_offset_backed_up_one == 0)
+ {
+ unwind_plan_sp = func_unwinders_sp->GetUnwindPlanArchitectureDefaultAtFunctionEntry (m_thread);
+ if (unwind_plan_sp)
+ {
+ UnwindLogMsgVerbose ("frame uses %s for full UnwindPlan", unwind_plan_sp->GetSourceName().GetCString());
+ return unwind_plan_sp;
+ }
+ }
+
// If nothing else, use the architectural default UnwindPlan and hope that does the job.
UnwindLogMsgVerbose ("frame uses %s for full UnwindPlan", arch_default_unwind_plan_sp->GetSourceName().GetCString());
return arch_default_unwind_plan_sp;
Modified: lldb/trunk/source/Symbol/FuncUnwinders.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/FuncUnwinders.cpp?rev=191262&r1=191261&r2=191262&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/FuncUnwinders.cpp (original)
+++ lldb/trunk/source/Symbol/FuncUnwinders.cpp Mon Sep 23 21:42:54 2013
@@ -114,9 +114,12 @@ FuncUnwinders::GetUnwindPlanAtNonCallSit
if (m_tried_unwind_at_non_call_site == false && m_unwind_plan_non_call_site_sp.get() == NULL)
{
m_tried_unwind_at_non_call_site = true;
- m_unwind_plan_non_call_site_sp.reset (new UnwindPlan (lldb::eRegisterKindGeneric));
- if (!m_assembly_profiler->GetNonCallSiteUnwindPlanFromAssembly (m_range, thread, *m_unwind_plan_non_call_site_sp))
- m_unwind_plan_non_call_site_sp.reset();
+ if (m_assembly_profiler)
+ {
+ m_unwind_plan_non_call_site_sp.reset (new UnwindPlan (lldb::eRegisterKindGeneric));
+ if (!m_assembly_profiler->GetNonCallSiteUnwindPlanFromAssembly (m_range, thread, *m_unwind_plan_non_call_site_sp))
+ m_unwind_plan_non_call_site_sp.reset();
+ }
}
return m_unwind_plan_non_call_site_sp;
}
@@ -140,9 +143,12 @@ FuncUnwinders::GetUnwindPlanFastUnwind (
if (m_tried_unwind_fast == false && m_unwind_plan_fast_sp.get() == NULL)
{
m_tried_unwind_fast = true;
- m_unwind_plan_fast_sp.reset (new UnwindPlan (lldb::eRegisterKindGeneric));
- if (!m_assembly_profiler->GetFastUnwindPlan (m_range, thread, *m_unwind_plan_fast_sp))
- m_unwind_plan_fast_sp.reset();
+ if (m_assembly_profiler)
+ {
+ m_unwind_plan_fast_sp.reset (new UnwindPlan (lldb::eRegisterKindGeneric));
+ if (!m_assembly_profiler->GetFastUnwindPlan (m_range, thread, *m_unwind_plan_fast_sp))
+ m_unwind_plan_fast_sp.reset();
+ }
}
return m_unwind_plan_fast_sp;
}
@@ -216,7 +222,7 @@ FuncUnwinders::GetUnwindPlanArchitecture
}
}
- return m_unwind_plan_arch_default_sp;
+ return m_unwind_plan_arch_default_at_func_entry_sp;
}
@@ -226,7 +232,8 @@ FuncUnwinders::GetFirstNonPrologueInsn (
if (m_first_non_prologue_insn.IsValid())
return m_first_non_prologue_insn;
ExecutionContext exe_ctx (target.shared_from_this(), false);
- m_assembly_profiler->FirstNonPrologueInsn (m_range, exe_ctx, m_first_non_prologue_insn);
+ if (m_assembly_profiler)
+ m_assembly_profiler->FirstNonPrologueInsn (m_range, exe_ctx, m_first_non_prologue_insn);
return m_first_non_prologue_insn;
}
More information about the lldb-commits
mailing list