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 @@ -706,6 +706,34 @@ assert (false && "how do we save the floating point registers?"); error.SetErrorString ("unsure how to save the floating point registers"); } + /** 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. + * **/ + llvm::Triple t_triple = GetRegisterInfoInterface().GetTargetArchitecture().GetTriple(); + + if (t_triple.getOS() == llvm::Triple::Linux && + (t_triple.getArch() == llvm::Triple::x86 || + t_triple.getArch() == llvm::Triple::x86_64)) + { + RegisterValue value((uint64_t) -1); + const RegisterInfo *reg_info = GetRegisterInfoInterface().GetDynamicRegisterInfo("orig_eax"); + if (reg_info == nullptr) + reg_info = GetRegisterInfoInterface().GetDynamicRegisterInfo("orig_rax"); + + if (reg_info != nullptr) { + NativeProcessProtocolSP process_sp(m_thread.GetProcess()); + if (!process_sp) + return Error("NativeProcessProtocol is NULL"); + + NativeProcessLinux* process_p = static_cast(process_sp.get()); + return process_p->DoOperation([&] { + return DoWriteRegisterValue(reg_info->byte_offset,reg_info->name,value); + }); + } + } return error; } Index: source/Plugins/Process/Utility/RegisterContextLinux_i386.h =================================================================== --- source/Plugins/Process/Utility/RegisterContextLinux_i386.h +++ source/Plugins/Process/Utility/RegisterContextLinux_i386.h @@ -29,6 +29,12 @@ uint32_t GetUserRegisterCount () const override; + + const std::vector * + GetDynamicRegisterInfoP() const override; + +private: + std::vector d_register_infos; }; #endif Index: source/Plugins/Process/Utility/RegisterContextLinux_i386.cpp =================================================================== --- source/Plugins/Process/Utility/RegisterContextLinux_i386.cpp +++ source/Plugins/Process/Utility/RegisterContextLinux_i386.cpp @@ -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; @@ -98,6 +98,9 @@ RegisterContextLinux_i386::RegisterContextLinux_i386(const ArchSpec &target_arch) : RegisterInfoInterface(target_arch) { + RegisterInfo orig_ax = { "orig_eax", NULL, sizeof(((GPR*)NULL)->orig_eax), (LLVM_EXTENSION offsetof(GPR, orig_eax)), eEncodingUint, \ + eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL }; + d_register_infos.push_back(orig_ax); } size_t @@ -131,3 +134,9 @@ { return static_cast (k_num_user_registers_i386); } + +const std::vector * +RegisterContextLinux_i386::GetDynamicRegisterInfoP() const +{ + return &d_register_infos; +} Index: source/Plugins/Process/Utility/RegisterContextLinux_x86_64.h =================================================================== --- source/Plugins/Process/Utility/RegisterContextLinux_x86_64.h +++ source/Plugins/Process/Utility/RegisterContextLinux_x86_64.h @@ -30,10 +30,15 @@ uint32_t GetUserRegisterCount () const override; + const std::vector * + GetDynamicRegisterInfoP() const override; + private: const lldb_private::RegisterInfo *m_register_info_p; uint32_t m_register_info_count; uint32_t m_user_register_count; + std::vector d_register_infos; + }; #endif 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 @@ -32,7 +32,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; @@ -171,6 +171,9 @@ m_register_info_count (GetRegisterInfoCount (target_arch)), m_user_register_count (GetUserRegisterInfoCount (target_arch)) { + RegisterInfo orig_ax = { "orig_rax", NULL, sizeof(((GPR*)NULL)->orig_rax), (LLVM_EXTENSION offsetof(GPR, orig_rax)), eEncodingUint, \ + eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL }; + d_register_infos.push_back(orig_ax); } size_t @@ -179,6 +182,12 @@ return sizeof(GPR); } +const std::vector * +RegisterContextLinux_x86_64::GetDynamicRegisterInfoP() const +{ + return &d_register_infos; +} + const RegisterInfo * RegisterContextLinux_x86_64::GetRegisterInfo() const { Index: source/Plugins/Process/Utility/RegisterInfoInterface.h =================================================================== --- source/Plugins/Process/Utility/RegisterInfoInterface.h +++ source/Plugins/Process/Utility/RegisterInfoInterface.h @@ -50,6 +50,26 @@ GetTargetArchitecture() const { return m_target_arch; } + virtual const lldb_private::RegisterInfo * + GetDynamicRegisterInfo(const char *reg_name) const + { + const std::vector * d_register_infos = GetDynamicRegisterInfoP(); + if(d_register_infos != nullptr) + { + std::vector ::const_iterator pos = d_register_infos->begin(); + for(; pos < d_register_infos->end() ; pos++) + { + if(::strcmp(reg_name, pos->name) == 0) + return(d_register_infos->data() + (pos - d_register_infos->begin()) ); + } + } + return nullptr; + } + + virtual const std::vector * + GetDynamicRegisterInfoP() const + { return nullptr; } + public: // FIXME make private. lldb_private::ArchSpec m_target_arch; 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()