Skip to content

Instantly share code, notes, and snippets.

@yurydelendik
Created February 12, 2019 18:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yurydelendik/12e95a8eb474cc72b6f57a5e23091416 to your computer and use it in GitHub Desktop.
Save yurydelendik/12e95a8eb474cc72b6f57a5e23091416 to your computer and use it in GitHub Desktop.
Trust JIT unwind plan patch for lldb
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp b/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
index 423b2e53c66..62dedbd75a6 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
@@ -829,6 +829,22 @@ UnwindPlanSP RegisterContextLLDB::GetFullUnwindPlanForFrame() {
}
}
+ // The JIT generated module may generate their .eh_frame or .debug_frame
+ // sections. It makes sense to trust that unwind plan if it is valid.
+ if (pc_module_sp->GetFileSpec().GetFilename().GetStringRef().startswith("JIT(0x") &&
+ process) {
+ m_fast_unwind_plan_sp.reset();
+ UnwindPlanSP unwind_plan_sp =
+ func_unwinders_sp->GetEHFrameUnwindPlan(process->GetTarget(), m_current_offset_backed_up_one);
+ if (!unwind_plan_sp) {
+ unwind_plan_sp =
+ func_unwinders_sp->GetDebugFrameUnwindPlan(process->GetTarget(), m_current_offset_backed_up_one);
+ }
+ if (unwind_plan_sp && unwind_plan_sp->PlanValidAtAddress(m_current_pc)) {
+ return unwind_plan_sp;
+ }
+ }
+
// Ask the DynamicLoader if the eh_frame CFI should be trusted in this frame
// even when it's frame zero This comes up if we have hand-written functions
// in a Module and hand-written eh_frame. The assembly instruction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment