mirror of
https://github.com/intel/llvm.git
synced 2026-01-22 23:49:22 +08:00
Fixing TestRegisters on Linux with LLGS
This patch fixes TestRegisters on Linux with LLGS Introduce GetUserRegisterCount on RegisterInfoInterface to distinguish lldb internal registers (e.g.: DR0-DR7) during register counting. Update GDBRemoteCommunicationServer to skip lldb internal registers on read/write register and on discover register. Submitted for Tamas Berghammer llvm-svn: 226959
This commit is contained in:
@@ -44,6 +44,9 @@ public:
|
||||
virtual uint32_t
|
||||
GetRegisterCount () const = 0;
|
||||
|
||||
virtual uint32_t
|
||||
GetUserRegisterCount () const = 0;
|
||||
|
||||
virtual const RegisterInfo *
|
||||
GetRegisterInfoAtIndex (uint32_t reg) const = 0;
|
||||
|
||||
|
||||
@@ -31,6 +31,9 @@ namespace lldb_private
|
||||
uint32_t
|
||||
GetRegisterCount () const override;
|
||||
|
||||
uint32_t
|
||||
GetUserRegisterCount () const override;
|
||||
|
||||
const RegisterInfo *
|
||||
GetRegisterInfoAtIndex (uint32_t reg_index) const override;
|
||||
|
||||
|
||||
@@ -125,3 +125,8 @@ RegisterContextLinux_i386::GetRegisterCount () const
|
||||
return static_cast<uint32_t> (sizeof (g_register_infos_i386) / sizeof (g_register_infos_i386 [0]));
|
||||
}
|
||||
|
||||
uint32_t
|
||||
RegisterContextLinux_i386::GetUserRegisterCount () const
|
||||
{
|
||||
return static_cast<uint32_t> (k_num_user_registers_i386);
|
||||
}
|
||||
|
||||
@@ -26,6 +26,9 @@ public:
|
||||
|
||||
uint32_t
|
||||
GetRegisterCount () const override;
|
||||
|
||||
uint32_t
|
||||
GetUserRegisterCount () const override;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -145,10 +145,26 @@ GetRegisterInfoCount (const ArchSpec &target_arch)
|
||||
}
|
||||
}
|
||||
|
||||
static uint32_t
|
||||
GetUserRegisterInfoCount (const ArchSpec &target_arch)
|
||||
{
|
||||
switch (target_arch.GetMachine())
|
||||
{
|
||||
case llvm::Triple::x86:
|
||||
return static_cast<uint32_t> (k_num_user_registers_i386);
|
||||
case llvm::Triple::x86_64:
|
||||
return static_cast<uint32_t> (k_num_user_registers_x86_64);
|
||||
default:
|
||||
assert(false && "Unhandled target architecture.");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
RegisterContextLinux_x86_64::RegisterContextLinux_x86_64(const ArchSpec &target_arch) :
|
||||
lldb_private::RegisterInfoInterface(target_arch),
|
||||
m_register_info_p (GetRegisterInfoPtr (target_arch)),
|
||||
m_register_info_count (GetRegisterInfoCount (target_arch))
|
||||
m_register_info_count (GetRegisterInfoCount (target_arch)),
|
||||
m_user_register_count (GetUserRegisterInfoCount (target_arch))
|
||||
{
|
||||
}
|
||||
|
||||
@@ -169,3 +185,9 @@ RegisterContextLinux_x86_64::GetRegisterCount () const
|
||||
{
|
||||
return m_register_info_count;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
RegisterContextLinux_x86_64::GetUserRegisterCount () const
|
||||
{
|
||||
return m_user_register_count;
|
||||
}
|
||||
|
||||
@@ -27,9 +27,13 @@ public:
|
||||
uint32_t
|
||||
GetRegisterCount () const override;
|
||||
|
||||
uint32_t
|
||||
GetUserRegisterCount () const override;
|
||||
|
||||
private:
|
||||
const lldb_private::RegisterInfo *m_register_info_p;
|
||||
uint32_t m_register_info_count;
|
||||
uint32_t m_user_register_count;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -32,9 +32,20 @@ namespace lldb_private
|
||||
virtual const lldb_private::RegisterInfo *
|
||||
GetRegisterInfo () const = 0;
|
||||
|
||||
// Returns the number of registers including the user registers and the
|
||||
// lldb internal registers also
|
||||
virtual uint32_t
|
||||
GetRegisterCount () const = 0;
|
||||
|
||||
// Returns the number of the user registers (excluding the registers
|
||||
// kept for lldb internal use only). Subclasses should override it if
|
||||
// they belongs to an architecture with lldb internal registers.
|
||||
virtual uint32_t
|
||||
GetUserRegisterCount () const
|
||||
{
|
||||
return GetRegisterCount();
|
||||
}
|
||||
|
||||
const lldb_private::ArchSpec&
|
||||
GetTargetArchitecture() const
|
||||
{ return m_target_arch; }
|
||||
|
||||
@@ -118,7 +118,8 @@ namespace lldb_private
|
||||
k_num_registers_i386,
|
||||
k_num_gpr_registers_i386 = k_last_gpr_i386 - k_first_gpr_i386 + 1,
|
||||
k_num_fpr_registers_i386 = k_last_fpr_i386 - k_first_fpr_i386 + 1,
|
||||
k_num_avx_registers_i386 = k_last_avx_i386 - k_first_avx_i386 + 1
|
||||
k_num_avx_registers_i386 = k_last_avx_i386 - k_first_avx_i386 + 1,
|
||||
k_num_user_registers_i386 = k_num_gpr_registers_i386 + k_num_fpr_registers_i386 + k_num_avx_registers_i386,
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
@@ -285,7 +286,8 @@ namespace lldb_private
|
||||
k_num_registers_x86_64,
|
||||
k_num_gpr_registers_x86_64 = k_last_gpr_x86_64 - k_first_gpr_x86_64 + 1,
|
||||
k_num_fpr_registers_x86_64 = k_last_fpr_x86_64 - k_first_fpr_x86_64 + 1,
|
||||
k_num_avx_registers_x86_64 = k_last_avx_x86_64 - k_first_avx_x86_64 + 1
|
||||
k_num_avx_registers_x86_64 = k_last_avx_x86_64 - k_first_avx_x86_64 + 1,
|
||||
k_num_user_registers_x86_64 = k_num_gpr_registers_x86_64 + k_num_fpr_registers_x86_64 + k_num_avx_registers_x86_64,
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -2995,7 +2995,7 @@ GDBRemoteCommunicationServer::Handle_qRegisterInfo (StringExtractorGDBRemote &pa
|
||||
return SendErrorResponse (69);
|
||||
|
||||
// Return the end of registers response if we've iterated one past the end of the register set.
|
||||
if (reg_index >= reg_context_sp->GetRegisterCount ())
|
||||
if (reg_index >= reg_context_sp->GetUserRegisterCount ())
|
||||
return SendErrorResponse (69);
|
||||
|
||||
const RegisterInfo *reg_info = reg_context_sp->GetRegisterInfoAtIndex(reg_index);
|
||||
@@ -3196,10 +3196,10 @@ GDBRemoteCommunicationServer::Handle_p (StringExtractorGDBRemote &packet)
|
||||
}
|
||||
|
||||
// Return the end of registers response if we've iterated one past the end of the register set.
|
||||
if (reg_index >= reg_context_sp->GetRegisterCount ())
|
||||
if (reg_index >= reg_context_sp->GetUserRegisterCount ())
|
||||
{
|
||||
if (log)
|
||||
log->Printf ("GDBRemoteCommunicationServer::%s failed, requested register %" PRIu32 " beyond register count %" PRIu32, __FUNCTION__, reg_index, reg_context_sp->GetRegisterCount ());
|
||||
log->Printf ("GDBRemoteCommunicationServer::%s failed, requested register %" PRIu32 " beyond register count %" PRIu32, __FUNCTION__, reg_index, reg_context_sp->GetUserRegisterCount ());
|
||||
return SendErrorResponse (0x15);
|
||||
}
|
||||
|
||||
@@ -3305,10 +3305,10 @@ GDBRemoteCommunicationServer::Handle_P (StringExtractorGDBRemote &packet)
|
||||
}
|
||||
|
||||
// Return the end of registers response if we've iterated one past the end of the register set.
|
||||
if (reg_index >= reg_context_sp->GetRegisterCount ())
|
||||
if (reg_index >= reg_context_sp->GetUserRegisterCount ())
|
||||
{
|
||||
if (log)
|
||||
log->Printf ("GDBRemoteCommunicationServer::%s failed, requested register %" PRIu32 " beyond register count %" PRIu32, __FUNCTION__, reg_index, reg_context_sp->GetRegisterCount ());
|
||||
log->Printf ("GDBRemoteCommunicationServer::%s failed, requested register %" PRIu32 " beyond register count %" PRIu32, __FUNCTION__, reg_index, reg_context_sp->GetUserRegisterCount ());
|
||||
return SendErrorResponse (0x47);
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,12 @@ NativeRegisterContextRegisterInfo::GetRegisterCount () const
|
||||
return m_register_info_interface_up->GetRegisterCount ();
|
||||
}
|
||||
|
||||
uint32_t
|
||||
NativeRegisterContextRegisterInfo::GetUserRegisterCount () const
|
||||
{
|
||||
return m_register_info_interface_up->GetUserRegisterCount ();
|
||||
}
|
||||
|
||||
const RegisterInfo *
|
||||
NativeRegisterContextRegisterInfo::GetRegisterInfoAtIndex (uint32_t reg_index) const
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user