Author: ted Date: Fri Dec 11 15:52:47 2015 New Revision: 255374 URL: http://llvm.org/viewvc/llvm-project?rev=255374&view=rev Log: Remove hardcoded registers from Hexagon ABI
Summary: The Hexagon ABI plugin uses hardcoded registers when setting up function calls. This is OK for the Hexagon simulator, but the register numbers are different on the gdbserver running on hardware. Change the hardcoded registers to LLDB generic registers. Reviewers: clayborg Subscribers: lldb-commits Differential Revision: http://reviews.llvm.org/D15457 Modified: lldb/trunk/source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.cpp Modified: lldb/trunk/source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.cpp?rev=255374&r1=255373&r2=255374&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.cpp (original) +++ lldb/trunk/source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.cpp Fri Dec 11 15:52:47 2015 @@ -226,7 +226,7 @@ ABISysV_hexagon::PrepareTrivialCall ( Th // . 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 @@ ABISysV_hexagon::PrepareTrivialCall ( Th // 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 @@ ABISysV_hexagon::PrepareTrivialCall ( Th // 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 @@ ABISysV_hexagon::PrepareTrivialCall ( Th } // 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