]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Fix build failure for gdbserver's raw_compare self test
authorLuis Machado <luis.machado@arm.com>
Mon, 7 Apr 2025 08:24:57 +0000 (09:24 +0100)
committerLuis Machado <luis.machado@arm.com>
Mon, 7 Apr 2025 14:18:43 +0000 (15:18 +0100)
Commit 5c89e5539aef2992a2417be55307c9071ffbe89c 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>
gdbserver/server.cc

index 2eb22f3dc8e230e2eb8a62fafeccadbf07f0b28e..fe94c56aa023159deba9eb78b75a4eac36030e18 100644 (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];