Skip to content

Commit a36b9b3

Browse files
author
Michał Górny
committed
[lldb] [test] Make AVX/MPX register tests more robust and fix on BSD
Make the AVX/MPX register tests more robust by checking for the presence of actual registers rather than register sets. Account for the option that the respective registers are defined but not available, as is the case on FreeBSD and NetBSD. This fixes test regression on these platforms. Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.llvm.org/D128041
1 parent 9407439 commit a36b9b3

1 file changed

Lines changed: 14 additions & 18 deletions

File tree

lldb/test/API/commands/register/register/register_command/TestRegisters.py

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -393,31 +393,25 @@ def fp_register_write(self):
393393
st0regname +
394394
' = 0'])
395395

396-
has_avx = False
397-
has_mpx = False
398-
# Returns an SBValueList.
396+
# Check if AVX/MPX registers are defined at all.
399397
registerSets = currentFrame.GetRegisters()
400-
for registerSet in registerSets:
401-
set_name = registerSet.GetName().lower()
402-
if 'advanced vector extensions' in set_name:
403-
has_avx = True
404-
# Darwin reports AVX registers as part of "Floating Point Registers"
405-
elif self.platformIsDarwin() and 'floating point registers' in set_name:
406-
has_avx = registerSet.GetChildMemberWithName('ymm0').IsValid()
407-
408-
# FreeBSD/NetBSD reports missing register sets differently
409-
# at the moment and triggers false positive here.
410-
# TODO: remove FreeBSD/NetBSD exception when we make unsupported
411-
# register groups correctly disappear.
412-
if ('memory protection extension' in registerSet.GetName().lower()
413-
and self.getPlatform() not in ["freebsd", "netbsd"]):
414-
has_mpx = True
398+
registers = frozenset(reg.GetName() for registerSet in registerSets
399+
for reg in registerSet)
400+
has_avx_regs = "ymm0" in registers
401+
has_mpx_regs = "bnd0" in registers
402+
# Check if they are actually present.
403+
self.runCmd("register read -a")
404+
output = self.res.GetOutput()
405+
has_avx = "ymm0 =" in output
406+
has_mpx = "bnd0 =" in output
415407

416408
if has_avx:
417409
new_value = "{0x01 0x02 0x03 0x00 0x00 0x00 0x00 0x00 0x09 0x0a 0x2f 0x2f 0x2f 0x2f 0x0e 0x0f 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x0c 0x0d 0x0e 0x0f}"
418410
self.write_and_read(currentFrame, "ymm0", new_value)
419411
self.write_and_read(currentFrame, "ymm7", new_value)
420412
self.expect("expr $ymm0", substrs=['vector_type'])
413+
elif has_avx_regs:
414+
self.expect("register read ymm0", substrs=["error: unavailable"])
421415
else:
422416
self.expect("register read ymm0", substrs=["Invalid register name 'ymm0'"],
423417
error=True)
@@ -434,6 +428,8 @@ def fp_register_write(self):
434428
new_value = "{0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08}"
435429
self.write_and_read(currentFrame, "bndstatus", new_value)
436430
self.expect("expr $bndstatus", substrs = ['vector_type'])
431+
elif has_mpx_regs:
432+
self.expect("register read bnd0", substrs=["error: unavailable"])
437433
else:
438434
self.expect("register read bnd0", substrs=["Invalid register name 'bnd0'"],
439435
error=True)

0 commit comments

Comments
 (0)