Fix thread's gdbarch when SVE vector length changes

When the inferior program changes the SVE length, GDB can stop tracking
some registers as it obtains the new gdbarch that corresponds to the
updated length:

  Breakpoint 1, do_sve_ioctl_test () at sve-ioctls.c:44
  44              res = prctl(PR_SVE_SET_VL, i, 0, 0, 0, 0);
  (gdb) print i
  $2 = 32
  (gdb) info registers
          ⋮
  [ snip registers x0 to x30 ]
          ⋮
  sp             0xffffffffeff0      0xffffffffeff0
  pc             0xaaaaaaaaa8ac      0xaaaaaaaaa8ac <do_sve_ioctl_test+112>
  cpsr           0x60000000          [ EL=0 BTYPE=0 C Z ]
  fpsr           0x0                 0
  fpcr           0x0                 0
  vg             0x8                 8
  tpidr          0xfffff7fcb320      0xfffff7fcb320
  (gdb) next
  45              if (res < 0) {
  (gdb) info registers
          ⋮
  [ snip registers x0 to x30 ]
          ⋮
  sp             0xffffffffeff0      0xffffffffeff0
  pc             0xaaaaaaaaa8cc      0xaaaaaaaaa8cc <do_sve_ioctl_test+144>
  cpsr           0x200000            [ EL=0 BTYPE=0 SS ]
  fpsr           0x0                 0
  fpcr           0x0                 0
  vg             0x4                 4
  (gdb)

Notice that register tpidr disappeared when vg (which holds the vector
length) changed from 8 to 4.  The tpidr register is provided by the
org.gnu.gdb.aarch64.tls feature.

This happens because the code that searches for a new gdbarch to match the
new vector length in aarch64_linux_nat_target::thread_architecture doesn't
take into account the features present in the target description associated
with the previous gdbarch.  This patch makes it do that.

Since the id member of struct gdbarch_info is now unused, it's removed.
This commit is contained in:
Thiago Jung Bauermann
2022-08-18 13:42:55 +01:00
committed by Luis Machado
parent f082165361
commit 4f3681cc33
4 changed files with 36 additions and 31 deletions

View File

@@ -251,17 +251,8 @@ struct gdbarch_info
bfd *abfd = nullptr;
union
{
/* Architecture-specific target description data. Numerous targets
need only this, so give them an easy way to hold it. */
struct tdesc_arch_data *tdesc_data;
/* SPU file system ID. This is a single integer, so using the
generic form would only complicate code. Other targets may
reuse this member if suitable. */
int *id;
};
/* Architecture-specific target description data. */
struct tdesc_arch_data *tdesc_data;
enum gdb_osabi osabi = GDB_OSABI_UNKNOWN;