Skip to content

Commit 6eca4f4

Browse files
committed
[lldb] [Process/NetBSD] Add register info for missing register sets
Add info for all register sets supported in NetBSD, particularly for all registers 'expected' by LLDB. This is necessary in order to fix python_api/lldbutil/iter/TestRegistersIterator.py test that currently fails due to missing names of register sets (None). This copies fpreg descriptions from Linux, and combines Linux' AVX and MPX registers into a single XState group, to fit NetBSD register group design. Technically, we do not support MPX registers at the moment but gdb-remote insists on passing their errors anyway, and if we do not include it in any group, they end up in a separate anonymous group that breaks the test. While at it, swap the enums for XState and DBRegs to match register set ordering. This also adds a few consts to the lldb-x86-register-enums.h to provide more consistency between user registers and debug registers. Differential Revision: https://reviews.llvm.org/D69667
1 parent bd14bb4 commit 6eca4f4

File tree

4 files changed

+64
-4
lines changed

4 files changed

+64
-4
lines changed

lldb/packages/Python/lldbsuite/test/commands/register/register/register_command/TestRegisters.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ def test_register_commands(self):
5959
@skipIfTargetAndroid(archs=["i386"])
6060
@skipIf(archs=no_match(['amd64', 'arm', 'i386', 'x86_64']))
6161
@expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr37995")
62-
@expectedFailureNetBSD
6362
def test_fp_register_write(self):
6463
"""Test commands that write to registers, in particular floating-point registers."""
6564
self.build()

lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,71 @@ static_assert((sizeof(g_gpr_regnums_x86_64) / sizeof(g_gpr_regnums_x86_64[0])) -
8484
k_num_gpr_registers_x86_64,
8585
"g_gpr_regnums_x86_64 has wrong number of register infos");
8686

87+
// x86 64-bit floating point registers.
88+
static const uint32_t g_fpu_regnums_x86_64[] = {
89+
lldb_fctrl_x86_64, lldb_fstat_x86_64, lldb_ftag_x86_64,
90+
lldb_fop_x86_64, lldb_fiseg_x86_64, lldb_fioff_x86_64,
91+
lldb_foseg_x86_64, lldb_fooff_x86_64, lldb_mxcsr_x86_64,
92+
lldb_mxcsrmask_x86_64, lldb_st0_x86_64, lldb_st1_x86_64,
93+
lldb_st2_x86_64, lldb_st3_x86_64, lldb_st4_x86_64,
94+
lldb_st5_x86_64, lldb_st6_x86_64, lldb_st7_x86_64,
95+
lldb_mm0_x86_64, lldb_mm1_x86_64, lldb_mm2_x86_64,
96+
lldb_mm3_x86_64, lldb_mm4_x86_64, lldb_mm5_x86_64,
97+
lldb_mm6_x86_64, lldb_mm7_x86_64, lldb_xmm0_x86_64,
98+
lldb_xmm1_x86_64, lldb_xmm2_x86_64, lldb_xmm3_x86_64,
99+
lldb_xmm4_x86_64, lldb_xmm5_x86_64, lldb_xmm6_x86_64,
100+
lldb_xmm7_x86_64, lldb_xmm8_x86_64, lldb_xmm9_x86_64,
101+
lldb_xmm10_x86_64, lldb_xmm11_x86_64, lldb_xmm12_x86_64,
102+
lldb_xmm13_x86_64, lldb_xmm14_x86_64, lldb_xmm15_x86_64,
103+
LLDB_INVALID_REGNUM // register sets need to end with this flag
104+
};
105+
static_assert((sizeof(g_fpu_regnums_x86_64) / sizeof(g_fpu_regnums_x86_64[0])) -
106+
1 ==
107+
k_num_fpr_registers_x86_64,
108+
"g_fpu_regnums_x86_64 has wrong number of register infos");
109+
110+
// x86 64-bit registers available via XState.
111+
static const uint32_t g_xstate_regnums_x86_64[] = {
112+
lldb_ymm0_x86_64, lldb_ymm1_x86_64, lldb_ymm2_x86_64, lldb_ymm3_x86_64,
113+
lldb_ymm4_x86_64, lldb_ymm5_x86_64, lldb_ymm6_x86_64, lldb_ymm7_x86_64,
114+
lldb_ymm8_x86_64, lldb_ymm9_x86_64, lldb_ymm10_x86_64, lldb_ymm11_x86_64,
115+
lldb_ymm12_x86_64, lldb_ymm13_x86_64, lldb_ymm14_x86_64, lldb_ymm15_x86_64,
116+
// Note: we currently do not provide them but this is needed to avoid
117+
// unnamed groups in SBFrame::GetRegisterContext().
118+
lldb_bnd0_x86_64, lldb_bnd1_x86_64, lldb_bnd2_x86_64,
119+
lldb_bnd3_x86_64, lldb_bndcfgu_x86_64, lldb_bndstatus_x86_64,
120+
LLDB_INVALID_REGNUM // register sets need to end with this flag
121+
};
122+
static_assert((sizeof(g_xstate_regnums_x86_64) / sizeof(g_xstate_regnums_x86_64[0])) -
123+
1 ==
124+
k_num_avx_registers_x86_64 + k_num_mpx_registers_x86_64,
125+
"g_xstate_regnums_x86_64 has wrong number of register infos");
126+
127+
// x86 debug registers.
128+
static const uint32_t g_dbr_regnums_x86_64[] = {
129+
lldb_dr0_x86_64, lldb_dr1_x86_64, lldb_dr2_x86_64, lldb_dr3_x86_64,
130+
lldb_dr4_x86_64, lldb_dr5_x86_64, lldb_dr6_x86_64, lldb_dr7_x86_64,
131+
LLDB_INVALID_REGNUM // register sets need to end with this flag
132+
};
133+
static_assert((sizeof(g_dbr_regnums_x86_64) / sizeof(g_dbr_regnums_x86_64[0])) -
134+
1 ==
135+
k_num_dbr_registers_x86_64,
136+
"g_dbr_regnums_x86_64 has wrong number of register infos");
137+
87138
// Number of register sets provided by this context.
88-
enum { k_num_extended_register_sets = 2, k_num_register_sets = 4 };
139+
enum { k_num_register_sets = 4 };
89140

90141
// Register sets for x86 64-bit.
91142
static const RegisterSet g_reg_sets_x86_64[k_num_register_sets] = {
92143
{"General Purpose Registers", "gpr", k_num_gpr_registers_x86_64,
93144
g_gpr_regnums_x86_64},
145+
{"Floating Point Registers", "fpu", k_num_fpr_registers_x86_64,
146+
g_fpu_regnums_x86_64},
147+
{"Extended State Registers", "xstate",
148+
k_num_avx_registers_x86_64 + k_num_mpx_registers_x86_64,
149+
g_xstate_regnums_x86_64},
150+
{"Debug Registers", "dbr", k_num_dbr_registers_x86_64,
151+
g_dbr_regnums_x86_64},
94152
};
95153

96154
#define REG_CONTEXT_SIZE (GetRegisterInfoInterface().GetGPRSize())

lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class NativeRegisterContextNetBSD_x86_64 : public NativeRegisterContextNetBSD {
7373

7474
private:
7575
// Private member types.
76-
enum { GPRegSet, FPRegSet, DBRegSet, XStateRegSet };
76+
enum { GPRegSet, FPRegSet, XStateRegSet, DBRegSet };
7777

7878
// Private member variables.
7979
struct reg m_gpr_x86_64;

lldb/source/Plugins/Process/Utility/lldb-x86-register-enums.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,14 +294,16 @@ enum {
294294
lldb_bndstatus_x86_64,
295295
k_last_mpxc_x86_64 = lldb_bndstatus_x86_64,
296296

297-
lldb_dr0_x86_64,
297+
k_first_dbr_x86_64,
298+
lldb_dr0_x86_64 = k_first_dbr_x86_64,
298299
lldb_dr1_x86_64,
299300
lldb_dr2_x86_64,
300301
lldb_dr3_x86_64,
301302
lldb_dr4_x86_64,
302303
lldb_dr5_x86_64,
303304
lldb_dr6_x86_64,
304305
lldb_dr7_x86_64,
306+
k_last_dbr_x86_64 = lldb_dr7_x86_64,
305307

306308
k_num_registers_x86_64,
307309
k_num_gpr_registers_x86_64 = k_last_gpr_x86_64 - k_first_gpr_x86_64 + 1,
@@ -312,6 +314,7 @@ enum {
312314
k_num_fpr_registers_x86_64 +
313315
k_num_avx_registers_x86_64 +
314316
k_num_mpx_registers_x86_64,
317+
k_num_dbr_registers_x86_64 = k_last_dbr_x86_64 - k_first_dbr_x86_64 + 1,
315318
};
316319
}
317320

0 commit comments

Comments
 (0)