[Lldb-commits] [lldb] r186651 - Don't use a function-scope static varaibles in

Jason Molenda jmolenda at apple.com
Thu Jul 18 21:39:23 PDT 2013


Author: jmolenda
Date: Thu Jul 18 23:39:22 2013
New Revision: 186651

URL: http://llvm.org/viewvc/llvm-project?rev=186651&view=rev
Log:
Don't use a function-scope static varaibles in
RegisterContextLLDB::SavedLocationForRegister to cache the pc and
sp register numbers -- if lldb is debugging multiple Targets of
different architectures, this will be incorrect.  If these were
to be cached anywhere, it would have to be up in the Target.


Modified:
    lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.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=186651&r1=186650&r2=186651&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp Thu Jul 18 23:39:22 2013
@@ -936,15 +936,10 @@ RegisterContextLLDB::SavedLocationForReg
         }
     }
 
-    static uint32_t sp_regnum = LLDB_INVALID_REGNUM;
-    static uint32_t pc_regnum = LLDB_INVALID_REGNUM;
-    static bool generic_registers_initialized = false;
-    if (!generic_registers_initialized)
-    {
-        m_thread.GetRegisterContext()->ConvertBetweenRegisterKinds (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP, eRegisterKindLLDB, sp_regnum);
-        m_thread.GetRegisterContext()->ConvertBetweenRegisterKinds (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC, eRegisterKindLLDB, pc_regnum);
-        generic_registers_initialized = true;
-    }
+    uint32_t sp_regnum = LLDB_INVALID_REGNUM;
+    uint32_t pc_regnum = LLDB_INVALID_REGNUM;
+    m_thread.GetRegisterContext()->ConvertBetweenRegisterKinds (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP, eRegisterKindLLDB, sp_regnum);
+    m_thread.GetRegisterContext()->ConvertBetweenRegisterKinds (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC, eRegisterKindLLDB, pc_regnum);
 
     // Are we looking for the CALLER's stack pointer?  The stack pointer is defined to be the same as THIS frame's
     // CFA so just return the CFA value.  This is true on x86-32/x86-64 at least.





More information about the lldb-commits mailing list