ted updated this revision to Diff 42555.
ted added a comment.

Updated to check for invalid register numbers.


http://reviews.llvm.org/D15457

Files:
  source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.cpp

Index: source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.cpp
===================================================================
--- source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.cpp
+++ source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.cpp
@@ -226,7 +226,7 @@
 //  . handle 64bit values and their register / stack requirements
 
 */
-#define HEX_ABI_DEBUG 1
+#define HEX_ABI_DEBUG 0
 bool
 ABISysV_hexagon::PrepareTrivialCall ( Thread &thread, 
                                       lldb::addr_t  sp  , 
@@ -242,6 +242,23 @@
     // grab the process so we have access to the memory for spilling
     lldb::ProcessSP proc = thread.GetProcess( );
 
+    // get the register context for modifying all of the registers
+    RegisterContext *reg_ctx = thread.GetRegisterContext().get();
+    if (!reg_ctx)
+        return false;
+    
+    uint32_t pc_reg = 
reg_ctx->ConvertRegisterKindToRegisterNumber(eRegisterKindGeneric, 
LLDB_REGNUM_GENERIC_PC);
+    if (pc_reg == LLDB_INVALID_REGNUM)
+        return false;
+
+    uint32_t ra_reg = 
reg_ctx->ConvertRegisterKindToRegisterNumber(eRegisterKindGeneric, 
LLDB_REGNUM_GENERIC_RA);
+    if (ra_reg == LLDB_INVALID_REGNUM)
+        return false;
+
+    uint32_t sp_reg = 
reg_ctx->ConvertRegisterKindToRegisterNumber(eRegisterKindGeneric, 
LLDB_REGNUM_GENERIC_SP);
+    if (sp_reg == LLDB_INVALID_REGNUM)
+        return false;
+
     // push host data onto target
     for ( size_t i = 0; i < args.size( ); i++ )
     {
@@ -276,11 +293,6 @@
     // check if this is a variable argument function
     bool isVArg = prototype.isFunctionVarArg();
 
-    // get the register context for modifying all of the registers
-    RegisterContext *reg_ctx = thread.GetRegisterContext().get();
-    if (!reg_ctx)
-        return false;
-    
     // number of arguments passed by register
     int nRegArgs = nVArgRegParams;
     if (! isVArg )
@@ -323,10 +335,9 @@
     }
 
     // update registers with current function call state
-    reg_ctx->WriteRegisterFromUnsigned ( 41, pc );
-    reg_ctx->WriteRegisterFromUnsigned ( 31, ra );
-    reg_ctx->WriteRegisterFromUnsigned ( 29, sp );
-//  reg_ctx->WriteRegisterFromUnsigned ( FP ??? );
+    reg_ctx->WriteRegisterFromUnsigned(pc_reg, pc);
+    reg_ctx->WriteRegisterFromUnsigned(ra_reg, ra);
+    reg_ctx->WriteRegisterFromUnsigned(sp_reg, sp);
 
 #if HEX_ABI_DEBUG
     // quick and dirty stack dumper for debugging


Index: source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.cpp
===================================================================
--- source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.cpp
+++ source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.cpp
@@ -226,7 +226,7 @@
 //  . handle 64bit values and their register / stack requirements
 
 */
-#define HEX_ABI_DEBUG 1
+#define HEX_ABI_DEBUG 0
 bool
 ABISysV_hexagon::PrepareTrivialCall ( Thread &thread, 
                                       lldb::addr_t  sp  , 
@@ -242,6 +242,23 @@
     // grab the process so we have access to the memory for spilling
     lldb::ProcessSP proc = thread.GetProcess( );
 
+    // get the register context for modifying all of the registers
+    RegisterContext *reg_ctx = thread.GetRegisterContext().get();
+    if (!reg_ctx)
+        return false;
+    
+    uint32_t pc_reg = reg_ctx->ConvertRegisterKindToRegisterNumber(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC);
+    if (pc_reg == LLDB_INVALID_REGNUM)
+        return false;
+
+    uint32_t ra_reg = reg_ctx->ConvertRegisterKindToRegisterNumber(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_RA);
+    if (ra_reg == LLDB_INVALID_REGNUM)
+        return false;
+
+    uint32_t sp_reg = reg_ctx->ConvertRegisterKindToRegisterNumber(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP);
+    if (sp_reg == LLDB_INVALID_REGNUM)
+        return false;
+
     // push host data onto target
     for ( size_t i = 0; i < args.size( ); i++ )
     {
@@ -276,11 +293,6 @@
     // check if this is a variable argument function
     bool isVArg = prototype.isFunctionVarArg();
 
-    // get the register context for modifying all of the registers
-    RegisterContext *reg_ctx = thread.GetRegisterContext().get();
-    if (!reg_ctx)
-        return false;
-    
     // number of arguments passed by register
     int nRegArgs = nVArgRegParams;
     if (! isVArg )
@@ -323,10 +335,9 @@
     }
 
     // update registers with current function call state
-    reg_ctx->WriteRegisterFromUnsigned ( 41, pc );
-    reg_ctx->WriteRegisterFromUnsigned ( 31, ra );
-    reg_ctx->WriteRegisterFromUnsigned ( 29, sp );
-//  reg_ctx->WriteRegisterFromUnsigned ( FP ??? );
+    reg_ctx->WriteRegisterFromUnsigned(pc_reg, pc);
+    reg_ctx->WriteRegisterFromUnsigned(ra_reg, ra);
+    reg_ctx->WriteRegisterFromUnsigned(sp_reg, sp);
 
 #if HEX_ABI_DEBUG
     // quick and dirty stack dumper for debugging
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to