Fix build failure for gdbserver's raw_compare self test

Commit 5c89e5539a addressed a SVE/SME gdbserver
crash on gdbserver and added a gdbserver-side self test for a register cache
raw_compare function.

For the GDB 16 branch though, gdbserver's regcache doesn't yet have a
constructor taking a target description, so we need to explicitly initialize
the register cache before the self test can take place.

Also, the self tests are only built if we explicitly pass --enable-unit-tests
to configure. This build error should not manifest on a default build that
doesn't enable self tests.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32775

Reviewed-By: Keith Seitz <keiths@redhat.com>
Approved-By: Andrew Burgess <aburgess@redhat.com>
This commit is contained in:
Luis Machado
2025-04-07 09:24:57 +01:00
parent 0a363b10a1
commit 4ffff8e30b

View File

@@ -4107,9 +4107,14 @@ static void test_registers_raw_compare_zero_length ()
dummy_tdesc.reg_defs.emplace_back ("r0", 0, 32);
dummy_tdesc.reg_defs.emplace_back ("r1", 32, 32);
/* Create a dummy buffer that will serve as the register buffer for our
dummy regcache. */
gdb_byte dummy_register_buffer[8];
/* Create our dummy register cache so we can invoke the raw_compare method
we want to validate. */
regcache dummy_regcache (&dummy_tdesc);
regcache dummy_regcache;
init_register_cache (&dummy_regcache, &dummy_tdesc, dummy_register_buffer);
/* Create a dummy byte buffer we can pass to the raw_compare method. */
gdb_byte dummy_buffer[8];