[Lldb-commits] [lldb] r159924 - in /lldb/trunk: include/lldb/Core/EmulateInstruction.h source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp

Jason Molenda jmolenda at apple.com
Mon Jul 9 00:47:48 PDT 2012


Author: jmolenda
Date: Mon Jul  9 02:47:47 2012
New Revision: 159924

URL: http://llvm.org/viewvc/llvm-project?rev=159924&view=rev
Log:
Simplify the CreateDefaultUnwindPlan methods for the x86 and arm unwinders
a bit -- we're creating the UnwindPlan here, we can set the register set to
whatever is convenient for us, no need to handle different register sets.

A handful of small comment fixes I noticed while reading through the code.

Modified:
    lldb/trunk/include/lldb/Core/EmulateInstruction.h
    lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp
    lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp
    lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp

Modified: lldb/trunk/include/lldb/Core/EmulateInstruction.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/EmulateInstruction.h?rev=159924&r1=159923&r2=159924&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/EmulateInstruction.h (original)
+++ lldb/trunk/include/lldb/Core/EmulateInstruction.h Mon Jul  9 02:47:47 2012
@@ -57,7 +57,7 @@
 /// Instruction Set Architecture (ISA) will be emulated. 
 ///
 /// Subclasses at the very least should implement the instructions that
-/// save and restore regiters onto the stack and adjustment to the stack
+/// save and restore registers onto the stack and adjustment to the stack
 /// pointer. By just implementing a few instructions for an ISA that are
 /// the typical prologue opcodes, you can then generate CFI using a 
 /// class that will soon be available.
@@ -68,15 +68,15 @@
 /// Implmenting all of the instructions allows for emulation of opcodes
 /// for breakpoint traps and will pave the way for "thread centric"
 /// debugging. The current debugging model is "process centric" where
-/// all threads must be stopped when any thread is stopped since when
-/// hitting software breakpoints once must disable the breakpoint by
+/// all threads must be stopped when any thread is stopped; when
+/// hitting software breakpoints we must disable the breakpoint by
 /// restoring the original breakpoint opcde, single stepping and 
 /// restoring the breakpoint trap. If all threads were allowed to run
 /// then other threads could miss the breakpoint. 
 ///
 /// This class centralizes the code that usually is done in separate 
 /// code paths in a debugger (single step prediction, finding save
-/// restore locations of registers for unwinding stack frame variables,
+/// restore locations of registers for unwinding stack frame variables)
 /// and emulating the intruction is just a bonus.
 //----------------------------------------------------------------------
 
@@ -98,7 +98,7 @@
         // Read an instruciton opcode from memory
         eContextReadOpcode,
         
-        // Usually used for writing a register value whose source value in an 
+        // Usually used for writing a register value whose source value is an 
         // immediate
         eContextImmediate,
 

Modified: lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp?rev=159924&r1=159923&r2=159924&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp (original)
+++ lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp Mon Jul  9 02:47:47 2012
@@ -538,10 +538,10 @@
 
     UnwindPlan::Row row;
     
-    // Our previous Call Frame Address is the stack pointer
+    // Our Call Frame Address is the stack pointer value
     row.SetCFARegister (sp_reg_num);
     
-    // Our previous PC is in the LR
+    // The previous PC is in the LR
     row.SetRegisterLocationToRegister(pc_reg_num, lr_reg_num, true);
     unwind_plan.AppendRow (row);
     
@@ -554,36 +554,15 @@
 bool
 ABIMacOSX_arm::CreateDefaultUnwindPlan (UnwindPlan &unwind_plan)
 {
-    uint32_t reg_kind = unwind_plan.GetRegisterKind();
-    uint32_t fp_reg_num = LLDB_INVALID_REGNUM;
-    uint32_t sp_reg_num = LLDB_INVALID_REGNUM;
-    uint32_t pc_reg_num = LLDB_INVALID_REGNUM;
-    
-    switch (reg_kind)
-    {
-        case eRegisterKindDWARF:
-        case eRegisterKindGCC:
-            fp_reg_num = dwarf_r7; // apple uses r7 for all frames. Normal arm uses r11
-            sp_reg_num = dwarf_sp;
-            pc_reg_num = dwarf_pc;
-            break;
-            
-        case eRegisterKindGeneric:
-            fp_reg_num = LLDB_REGNUM_GENERIC_FP;
-            sp_reg_num = LLDB_REGNUM_GENERIC_SP;
-            pc_reg_num = LLDB_REGNUM_GENERIC_PC;
-            break;
-    }
-    
-    if (fp_reg_num == LLDB_INVALID_REGNUM ||
-        sp_reg_num == LLDB_INVALID_REGNUM ||
-        pc_reg_num == LLDB_INVALID_REGNUM)
-        return false;
+    uint32_t fp_reg_num = dwarf_r7; // apple uses r7 for all frames. Normal arm uses r11;
+    uint32_t sp_reg_num = dwarf_sp;
+    uint32_t pc_reg_num = dwarf_pc;
     
     UnwindPlan::Row row;    
     const int32_t ptr_size = 4;
     
-    unwind_plan.SetRegisterKind (eRegisterKindGeneric);
+    unwind_plan.Clear ();
+    unwind_plan.SetRegisterKind (eRegisterKindDWARF);
     row.SetCFARegister (fp_reg_num);
     row.SetCFAOffset (2 * ptr_size);
     row.SetOffset (0);
@@ -601,7 +580,7 @@
 {
     if (reg_info)
     {
-        // Volatile registers include: ebx, ebp, esi, edi, esp, eip
+        // Volatile registers include: r0, r1, r2, r3, r9, r12, r13
         const char *name = reg_info->name;
         if (name[0] == 'r')
         {

Modified: lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp?rev=159924&r1=159923&r2=159924&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp (original)
+++ lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp Mon Jul  9 02:47:47 2012
@@ -820,47 +820,15 @@
 bool
 ABIMacOSX_i386::CreateDefaultUnwindPlan (UnwindPlan &unwind_plan)
 {
-    uint32_t reg_kind = unwind_plan.GetRegisterKind();
-    uint32_t fp_reg_num = LLDB_INVALID_REGNUM;
-    uint32_t sp_reg_num = LLDB_INVALID_REGNUM;
-    uint32_t pc_reg_num = LLDB_INVALID_REGNUM;
+    uint32_t fp_reg_num = dwarf_ebp;
+    uint32_t sp_reg_num = dwarf_esp;
+    uint32_t pc_reg_num = dwarf_eip;
     
-    switch (reg_kind)
-    {
-        case eRegisterKindDWARF:
-            fp_reg_num = dwarf_ebp;
-            sp_reg_num = dwarf_esp;
-            pc_reg_num = dwarf_eip;
-            break;
-            
-        case eRegisterKindGCC:
-            fp_reg_num = gcc_ebp;
-            sp_reg_num = gcc_esp;
-            pc_reg_num = gcc_eip;
-            break;
-            
-        case eRegisterKindGDB:
-            fp_reg_num = gdb_ebp;
-            sp_reg_num = gdb_esp;
-            pc_reg_num = gdb_eip;
-            break;
-            
-        case eRegisterKindGeneric:
-            fp_reg_num = LLDB_REGNUM_GENERIC_FP;
-            sp_reg_num = LLDB_REGNUM_GENERIC_SP;
-            pc_reg_num = LLDB_REGNUM_GENERIC_PC;
-            break;
-    }
-    
-    if (fp_reg_num == LLDB_INVALID_REGNUM ||
-        sp_reg_num == LLDB_INVALID_REGNUM ||
-        pc_reg_num == LLDB_INVALID_REGNUM)
-        return false;
-
     UnwindPlan::Row row;    
     const int32_t ptr_size = 4;
 
-    unwind_plan.SetRegisterKind (eRegisterKindGeneric);
+    unwind_plan.Clear ();
+    unwind_plan.SetRegisterKind (eRegisterKindDWARF);
     row.SetCFARegister (fp_reg_num);
     row.SetCFAOffset (2 * ptr_size);
     row.SetOffset (0);

Modified: lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp?rev=159924&r1=159923&r2=159924&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp (original)
+++ lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp Mon Jul  9 02:47:47 2012
@@ -30,7 +30,7 @@
 
 
 //-----------------------------------------------------------------------------------------------
-//  UnwindAssemblyParser_x86 method definitions 
+//  UnwindAssemblyInstEmulation method definitions 
 //-----------------------------------------------------------------------------------------------
 
 bool
@@ -71,9 +71,6 @@
             const uint32_t addr_byte_size = m_arch.GetAddressByteSize();
             const bool show_address = true;
             const bool show_bytes = true;
-            // Initialize the CFA with a known value. In the 32 bit case
-            // it will be 0x80000000, and in the 64 bit case 0x8000000000000000.
-            // We use the address byte size to be safe for any future addresss sizes
             m_inst_emulator_ap->GetRegisterInfo (unwind_plan.GetRegisterKind(), 
                                                  unwind_plan.GetInitialCFARegister(), 
                                                  m_cfa_reg_info);
@@ -82,6 +79,9 @@
             m_register_values.clear();
             m_pushed_regs.clear();
 
+            // Initialize the CFA with a known value. In the 32 bit case
+            // it will be 0x80000000, and in the 64 bit case 0x8000000000000000.
+            // We use the address byte size to be safe for any future addresss sizes
             m_initial_sp = (1ull << ((addr_byte_size * 8) - 1));
             RegisterValue cfa_reg_value;
             cfa_reg_value.SetUInt (m_initial_sp, m_cfa_reg_info.byte_size);





More information about the lldb-commits mailing list