[Lldb-commits] [lldb] r244875 - Set orig_eax to -1 for Linux x86 platforms
Ravitheja Addepally via lldb-commits
lldb-commits at lists.llvm.org
Thu Aug 13 02:05:11 PDT 2015
Author: ravitheja
Date: Thu Aug 13 04:05:11 2015
New Revision: 244875
URL: http://llvm.org/viewvc/llvm-project?rev=244875&view=rev
Log:
Set orig_eax to -1 for Linux x86 platforms
Summary:
For Linux x86 based environments the orig_eax/orig_rax
register should be set to -1 to prevent the instruction pointer
to be decremented, which was the cause for the SIGILL exception.
Fix for Bug 23659
Reviewers: zturner, ashok.thirumurthi, mikesart, jingham, clayborg
Subscribers: clayborg, labath
Differential Revision: http://reviews.llvm.org/D11411
Modified:
lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp
lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_i386.cpp
lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_i386.h
lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_x86_64.cpp
lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_x86_64.h
lldb/trunk/source/Plugins/Process/Utility/RegisterInfoInterface.h
lldb/trunk/test/expression_command/expr-in-syscall/TestExpressionInSyscall.py
Modified: lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp?rev=244875&r1=244874&r2=244875&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp Thu Aug 13 04:05:11 2015
@@ -706,6 +706,34 @@ NativeRegisterContextLinux_x86_64::ReadA
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<NativeProcessLinux*>(process_sp.get());
+ return process_p->DoOperation([&] {
+ return DoWriteRegisterValue(reg_info->byte_offset,reg_info->name,value);
+ });
+ }
+ }
return error;
}
Modified: lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_i386.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_i386.cpp?rev=244875&r1=244874&r2=244875&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_i386.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_i386.cpp Thu Aug 13 04:05:11 2015
@@ -26,7 +26,7 @@ struct GPR
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 @@ struct UserArea
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 @@ RegisterContextLinux_i386::GetUserRegist
{
return static_cast<uint32_t> (k_num_user_registers_i386);
}
+
+const std::vector<lldb_private::RegisterInfo> *
+RegisterContextLinux_i386::GetDynamicRegisterInfoP() const
+{
+ return &d_register_infos;
+}
Modified: lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_i386.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_i386.h?rev=244875&r1=244874&r2=244875&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_i386.h (original)
+++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_i386.h Thu Aug 13 04:05:11 2015
@@ -29,6 +29,12 @@ public:
uint32_t
GetUserRegisterCount () const override;
+
+ const std::vector<lldb_private::RegisterInfo> *
+ GetDynamicRegisterInfoP() const override;
+
+private:
+ std::vector<lldb_private::RegisterInfo> d_register_infos;
};
#endif
Modified: lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_x86_64.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_x86_64.cpp?rev=244875&r1=244874&r2=244875&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_x86_64.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_x86_64.cpp Thu Aug 13 04:05:11 2015
@@ -32,7 +32,7 @@ typedef struct _GPR
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 @@ RegisterContextLinux_x86_64::RegisterCon
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 @@ RegisterContextLinux_x86_64::GetGPRSize(
return sizeof(GPR);
}
+const std::vector<lldb_private::RegisterInfo> *
+RegisterContextLinux_x86_64::GetDynamicRegisterInfoP() const
+{
+ return &d_register_infos;
+}
+
const RegisterInfo *
RegisterContextLinux_x86_64::GetRegisterInfo() const
{
Modified: lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_x86_64.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_x86_64.h?rev=244875&r1=244874&r2=244875&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_x86_64.h (original)
+++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_x86_64.h Thu Aug 13 04:05:11 2015
@@ -30,10 +30,15 @@ public:
uint32_t
GetUserRegisterCount () const override;
+ const std::vector<lldb_private::RegisterInfo> *
+ 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<lldb_private::RegisterInfo> d_register_infos;
+
};
#endif
Modified: lldb/trunk/source/Plugins/Process/Utility/RegisterInfoInterface.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterInfoInterface.h?rev=244875&r1=244874&r2=244875&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/RegisterInfoInterface.h (original)
+++ lldb/trunk/source/Plugins/Process/Utility/RegisterInfoInterface.h Thu Aug 13 04:05:11 2015
@@ -50,6 +50,26 @@ namespace lldb_private
GetTargetArchitecture() const
{ return m_target_arch; }
+ virtual const lldb_private::RegisterInfo *
+ GetDynamicRegisterInfo(const char *reg_name) const
+ {
+ const std::vector <lldb_private::RegisterInfo> * d_register_infos = GetDynamicRegisterInfoP();
+ if(d_register_infos != nullptr)
+ {
+ std::vector <lldb_private::RegisterInfo> ::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<lldb_private::RegisterInfo> *
+ GetDynamicRegisterInfoP() const
+ { return nullptr; }
+
public:
// FIXME make private.
lldb_private::ArchSpec m_target_arch;
Modified: lldb/trunk/test/expression_command/expr-in-syscall/TestExpressionInSyscall.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/expression_command/expr-in-syscall/TestExpressionInSyscall.py?rev=244875&r1=244874&r2=244875&view=diff
==============================================================================
--- lldb/trunk/test/expression_command/expr-in-syscall/TestExpressionInSyscall.py (original)
+++ lldb/trunk/test/expression_command/expr-in-syscall/TestExpressionInSyscall.py Thu Aug 13 04:05:11 2015
@@ -17,7 +17,6 @@ class ExprSyscallTestCase(TestBase):
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()
More information about the lldb-commits
mailing list