Index: source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp =================================================================== --- source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp +++ source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp @@ -9,6 +9,9 @@ #if defined(__i386__) || defined(__x86_64__) +#include "Plugins/Process/Utility/RegisterContextLinux_i386.h" +#include "Plugins/Process/Utility/RegisterContextLinux_x86_64.h" + #include "NativeRegisterContextLinux_x86_64.h" #include "lldb/Core/Log.h" @@ -17,9 +20,6 @@ #include "lldb/Core/RegisterValue.h" #include "lldb/Host/HostInfo.h" -#include "Plugins/Process/Utility/RegisterContextLinux_i386.h" -#include "Plugins/Process/Utility/RegisterContextLinux_x86_64.h" - using namespace lldb_private; using namespace lldb_private::process_linux; @@ -49,6 +49,7 @@ lldb_ss_i386, lldb_ds_i386, lldb_es_i386, + lldb_orig_eax_i386, lldb_ax_i386, lldb_bx_i386, lldb_cx_i386, @@ -158,6 +159,7 @@ lldb_ss_x86_64, lldb_ds_x86_64, lldb_es_x86_64, + lldb_orig_rax_x86_64, lldb_eax_x86_64, lldb_ebx_x86_64, lldb_ecx_x86_64, Index: source/Plugins/Process/Utility/RegisterContextLinux_i386.cpp =================================================================== --- source/Plugins/Process/Utility/RegisterContextLinux_i386.cpp +++ source/Plugins/Process/Utility/RegisterContextLinux_i386.cpp @@ -7,8 +7,8 @@ // //===---------------------------------------------------------------------===// -#include "RegisterContextPOSIX_x86.h" #include "RegisterContextLinux_i386.h" +#include "RegisterContextPOSIX_x86.h" using namespace lldb_private; using namespace lldb; @@ -26,7 +26,7 @@ uint32_t es; uint32_t fs; uint32_t gs; - uint32_t orig_ax; + uint32_t orig_eax; uint32_t eip; uint32_t cs; uint32_t eflags; @@ -91,9 +91,11 @@ //--------------------------------------------------------------------------- // Include RegisterInfos_i386 to declare our g_register_infos_i386 structure. //--------------------------------------------------------------------------- +#define LINUX #define DECLARE_REGISTER_INFOS_I386_STRUCT #include "RegisterInfos_i386.h" #undef DECLARE_REGISTER_INFOS_I386_STRUCT +#undef LINUX RegisterContextLinux_i386::RegisterContextLinux_i386(const ArchSpec &target_arch) : RegisterInfoInterface(target_arch) Index: source/Plugins/Process/Utility/RegisterContextLinux_x86_64.cpp =================================================================== --- source/Plugins/Process/Utility/RegisterContextLinux_x86_64.cpp +++ source/Plugins/Process/Utility/RegisterContextLinux_x86_64.cpp @@ -8,9 +8,10 @@ //===---------------------------------------------------------------------===// #include -#include "RegisterContextPOSIX_x86.h" -#include "RegisterContextLinux_i386.h" + #include "RegisterContextLinux_x86_64.h" +#include "RegisterContextLinux_i386.h" +#include "RegisterContextPOSIX_x86.h" using namespace lldb_private; using namespace lldb; @@ -32,7 +33,7 @@ uint64_t rdx; uint64_t rsi; uint64_t rdi; - uint64_t orig_ax; + uint64_t orig_rax; uint64_t rip; uint64_t cs; uint64_t rflags; @@ -81,9 +82,11 @@ //--------------------------------------------------------------------------- // Include RegisterInfos_x86_64 to declare our g_register_infos_x86_64 structure. //--------------------------------------------------------------------------- +#define LINUX #define DECLARE_REGISTER_INFOS_X86_64_STRUCT #include "RegisterInfos_x86_64.h" #undef DECLARE_REGISTER_INFOS_X86_64_STRUCT +#undef LINUX static std::vector& GetPrivateRegisterInfoVector () @@ -109,9 +112,11 @@ // Include RegisterInfos_x86_64 to update the g_register_infos structure // with x86_64 offsets. //--------------------------------------------------------------------------- + #define LINUX #define UPDATE_REGISTER_INFOS_I386_STRUCT_WITH_X86_64_OFFSETS #include "RegisterInfos_x86_64.h" #undef UPDATE_REGISTER_INFOS_I386_STRUCT_WITH_X86_64_OFFSETS + #undef LINUX } return &g_register_infos[0]; Index: source/Plugins/Process/Utility/RegisterInfos_i386.h =================================================================== --- source/Plugins/Process/Utility/RegisterInfos_i386.h +++ source/Plugins/Process/Utility/RegisterInfos_i386.h @@ -114,6 +114,9 @@ DEFINE_GPR(ss, NULL, LLDB_INVALID_REGNUM, dwarf_ss_i386, LLDB_INVALID_REGNUM, gdb_ss_i386), DEFINE_GPR(ds, NULL, LLDB_INVALID_REGNUM, dwarf_ds_i386, LLDB_INVALID_REGNUM, gdb_ds_i386), DEFINE_GPR(es, NULL, LLDB_INVALID_REGNUM, dwarf_es_i386, LLDB_INVALID_REGNUM, gdb_es_i386), +#ifdef LINUX + DEFINE_GPR(orig_eax, NULL, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM), +#endif DEFINE_GPR_PSEUDO_16(ax, eax), DEFINE_GPR_PSEUDO_16(bx, ebx), Index: source/Plugins/Process/Utility/RegisterInfos_x86_64.h =================================================================== --- source/Plugins/Process/Utility/RegisterInfos_x86_64.h +++ source/Plugins/Process/Utility/RegisterInfos_x86_64.h @@ -125,6 +125,9 @@ DEFINE_GPR(ss, NULL, gcc_dwarf_ss_x86_64, gcc_dwarf_ss_x86_64, LLDB_INVALID_REGNUM, gdb_ss_x86_64), DEFINE_GPR(ds, NULL, gcc_dwarf_ds_x86_64, gcc_dwarf_ds_x86_64, LLDB_INVALID_REGNUM, gdb_ds_x86_64), DEFINE_GPR(es, NULL, gcc_dwarf_es_x86_64, gcc_dwarf_es_x86_64, LLDB_INVALID_REGNUM, gdb_es_x86_64), +#ifdef LINUX + DEFINE_GPR(orig_rax, NULL, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM), +#endif DEFINE_GPR_PSEUDO_32(eax, rax), DEFINE_GPR_PSEUDO_32(ebx, rbx), @@ -330,7 +333,9 @@ UPDATE_GPR_INFO(ss, ss); UPDATE_GPR_INFO(ds, ds); UPDATE_GPR_INFO(es, es); - +#ifdef LINUX + UPDATE_GPR_INFO(orig_eax, orig_rax); +#endif UPDATE_GPR_INFO(ax, rax); UPDATE_GPR_INFO(bx, rbx); UPDATE_GPR_INFO(cx, rcx); Index: source/Plugins/Process/Utility/lldb-x86-register-enums.h =================================================================== --- source/Plugins/Process/Utility/lldb-x86-register-enums.h +++ source/Plugins/Process/Utility/lldb-x86-register-enums.h @@ -36,7 +36,9 @@ lldb_ss_i386, lldb_ds_i386, lldb_es_i386, - +#ifdef liblldb_RegisterContextLinux_i386_H_ + lldb_orig_eax_i386, +#endif k_first_alias_i386, lldb_ax_i386 = k_first_alias_i386, lldb_bx_i386, @@ -152,7 +154,9 @@ lldb_ss_x86_64, lldb_ds_x86_64, lldb_es_x86_64, - +#ifdef liblldb_RegisterContextLinux_x86_64_H_ + lldb_orig_rax_x86_64, +#endif k_first_alias_x86_64, lldb_eax_x86_64 = k_first_alias_x86_64, lldb_ebx_x86_64, Index: source/Target/ThreadPlanCallFunction.cpp =================================================================== --- source/Target/ThreadPlanCallFunction.cpp +++ source/Target/ThreadPlanCallFunction.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +#include "llvm/ADT/Triple.h" + #include "lldb/Target/ThreadPlanCallFunction.h" // C Includes @@ -167,6 +169,36 @@ args)) return; + /** The following code is specific to Linux x86 based architectures, + * where the register orig_eax (32 bit)/orig_rax (64 bit) is set to + * -1 to solve the bug 23659, such a setting prevents the automatic + * decrement of the instruction pointer which was causing the SIGILL + * exception. + * **/ + ProcessSP process_sp (thread.GetProcess()); + if (!process_sp) + return; + + llvm::Triple t_triple = process_sp->GetTarget().GetArchitecture().GetTriple(); + + if (t_triple.getOS() == llvm::Triple::Linux && + (t_triple.getArch() == llvm::Triple::x86 || + t_triple.getArch() == llvm::Triple::x86_64)) + { + RegisterContext *reg_ctx = m_thread.GetRegisterContext().get(); + for (uint32_t reg_idx = 0, num_registers = reg_ctx->GetRegisterCount(); + reg_idx < num_registers; + ++reg_idx) + { + const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoAtIndex (reg_idx); + if (strcmp(reg_info->name, "orig_rax") != 0 || strcmp(reg_info->name, "orig_eax") != 0 ) + { + reg_ctx->WriteRegisterFromUnsigned(reg_info, -1); + break; + } + } + } + ReportRegisterState ("Function call was set up. Register state was:"); m_valid = true; Index: test/expression_command/expr-in-syscall/TestExpressionInSyscall.py =================================================================== --- test/expression_command/expr-in-syscall/TestExpressionInSyscall.py +++ test/expression_command/expr-in-syscall/TestExpressionInSyscall.py @@ -17,7 +17,6 @@ self.buildDsym() self.expr_syscall() - @expectedFailureAll("llvm.org/pr23659", oslist=["linux"], archs=["i386", "x86_64"]) @dwarf_test def test_setpgid_with_dwarf(self): self.buildDwarf()