[Lldb-commits] [lldb] r191267 - Fix a bug where the x86 assembly instruction profiler would not correctly adjust

Jason Molenda jmolenda at apple.com
Mon Sep 23 20:28:54 PDT 2013


Author: jmolenda
Date: Mon Sep 23 22:28:54 2013
New Revision: 191267

URL: http://llvm.org/viewvc/llvm-project?rev=191267&view=rev
Log:
Fix a bug where the x86 assembly instruction profiler would not correctly adjust
the CFA instructions when it was profiling an -fomit-frame-pointer function
and a "volatile" register was saved on the stack (e.g. an argument register).
<rdar://problem/15036546>

Modified:
    lldb/trunk/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp

Modified: lldb/trunk/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp?rev=191267&r1=191266&r2=191267&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp (original)
+++ lldb/trunk/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp Mon Sep 23 22:28:54 2013
@@ -597,16 +597,25 @@ AssemblyParse_x86::get_non_call_site_unw
         if (push_reg_p (machine_regno))
         {
             current_sp_bytes_offset_from_cfa += m_wordsize;
+            bool need_to_push_row = false;
+            // the PUSH instruction has moved the stack pointer - if the CFA is set in terms of the stack pointer,
+            // we need to add a new row of instructions.
+            if (row->GetCFARegister() == m_lldb_sp_regnum)
+            {
+                need_to_push_row = true;
+                row->SetCFAOffset (current_sp_bytes_offset_from_cfa);
+            }
+            // record where non-volatile (callee-saved, spilled) registers are saved on the stack
             if (nonvolatile_reg_p (machine_regno) && machine_regno_to_lldb_regno (machine_regno, lldb_regno))
             {
-                row->SetOffset (current_func_text_offset + insn_len);
-                if (row->GetCFARegister() == m_lldb_sp_regnum)
-                {
-                    row->SetCFAOffset (current_sp_bytes_offset_from_cfa);
-                }
+                need_to_push_row = true;
                 UnwindPlan::Row::RegisterLocation regloc;
                 regloc.SetAtCFAPlusOffset (-current_sp_bytes_offset_from_cfa);
                 row->SetRegisterInfo (lldb_regno, regloc);
+            }
+            if (need_to_push_row)
+            {
+                row->SetOffset (current_func_text_offset + insn_len);
                 unwind_plan.AppendRow (row);
                 // Allocate a new Row, populate it with the existing Row contents.
                 newrow = new UnwindPlan::Row;





More information about the lldb-commits mailing list