Don't use a function-scope static varaibles in
authorJason Molenda <jmolenda@apple.com>
Fri, 19 Jul 2013 04:39:22 +0000 (04:39 +0000)
committerJason Molenda <jmolenda@apple.com>
Fri, 19 Jul 2013 04:39:22 +0000 (04:39 +0000)
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.

llvm-svn: 186651

lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp

index b0d6231..1ffc30d 100644 (file)
@@ -936,15 +936,10 @@ RegisterContextLLDB::SavedLocationForRegister (uint32_t lldb_regnum, lldb_privat
         }
     }
 
-    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.