]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Add gdbserver target methods target_validate_tdesc and arch_setup
authorAlan Hayward <alan.hayward@arm.com>
Wed, 7 Nov 2018 15:15:24 +0000 (15:15 +0000)
committerAlan Hayward <alan.hayward@arm.com>
Wed, 7 Nov 2018 15:16:30 +0000 (15:16 +0000)
target_validate_tdesc () is added as a new target function.
This function checks current target description is still valid for the
current inferior, returning false if not. On SVE, we need to check if the
vector length has changed - if it has then the current target descriptor
will need to be switched to a valid one.

The existing arch_setup () is extended to be a target function.
This will later allow it to be called from get_thread_regcache () in
gdbserver/regcache.c. This call is required to generate a new target
descriptor if we have decided the current one is no longer valid.

2018-11-07  Alan Hayward  <alan.hayward@arm.com>

gdbserver/
* linux-aarch64-low.c (int aarch64_validate_tdesc): New function.
(struct linux_target_ops): Add aarch64_validate_tdesc.
* linux-low.c (linux_validate_tdesc): New function.
(linux_target_ops): Add linux_arch_setup and linux_validate_tdesc.
* linux-low.h (linux_target_ops): Add validate_tdesc.
* target.h (struct target_ops): Likewise.
(target_arch_setup) New macro.
(target_validate_tdesc) New macro.

gdb/gdbserver/linux-aarch64-low.c
gdb/gdbserver/linux-low.c
gdb/gdbserver/linux-low.h
gdb/gdbserver/target.h

index 1d34e319dfd5f677f7587d84ed868e95c023417e..dcc19ce18c0e09a0d0729d6b6750a85443163019 100644 (file)
@@ -3037,6 +3037,14 @@ aarch64_supports_hardware_single_step (void)
   return 1;
 }
 
+/* Implementation of the linux_target_ops method "validate_tdesc ".  */
+
+static bool
+aarch64_validate_tdesc (struct thread_info *thread)
+{
+  return true;
+}
+
 struct linux_target_ops the_low_target =
 {
   aarch64_arch_setup,
@@ -3075,6 +3083,8 @@ struct linux_target_ops the_low_target =
   aarch64_breakpoint_kind_from_current_state,
   aarch64_supports_hardware_single_step,
   aarch64_get_syscall_trapinfo,
+  NULL, /* get_ipa_tdesc_idx.  */
+  aarch64_validate_tdesc,
 };
 
 void
index 701f3e863c0a665832549680a22f9bc1c80dd13f..3c33ebff053c72f84c0c7cfe7c6feed86f32deb6 100644 (file)
@@ -6576,6 +6576,15 @@ linux_get_ipa_tdesc_idx (void)
   return (*the_low_target.get_ipa_tdesc_idx) ();
 }
 
+static bool
+linux_validate_tdesc (struct thread_info *thread)
+{
+  if (the_low_target.validate_tdesc == NULL)
+    return true;
+
+  return (*the_low_target.validate_tdesc) (thread);
+}
+
 static int
 linux_supports_tracepoints (void)
 {
@@ -7526,6 +7535,8 @@ static struct target_ops linux_target_ops = {
 #else
   NULL,
 #endif
+  linux_arch_setup,
+  linux_validate_tdesc,
 };
 
 #ifdef HAVE_LINUX_REGSETS
index 79b3311f021cfb3a219d725dededbbca5261c602..a99e6fc41a5ef732c8e0b0b733128c0a7679d825 100644 (file)
@@ -256,6 +256,9 @@ struct linux_target_ops
 
   /* See target.h.  */
   int (*get_ipa_tdesc_idx) (void);
+
+  /* See target.h.  */
+  bool (*validate_tdesc) (struct thread_info *thread);
 };
 
 extern struct linux_target_ops the_low_target;
index fce54e05adbc3b6509cb2c891a067154cc72cd4f..dfa74ec94f0a8e9971108f7b3409615d8acbc840 100644 (file)
@@ -478,6 +478,16 @@ struct target_ops
      false for failure.  Return pointer to thread handle via HANDLE
      and the handle's length via HANDLE_LEN.  */
   bool (*thread_handle) (ptid_t ptid, gdb_byte **handle, int *handle_len);
+
+  /* Call the target arch_setup function on the current thread.  */
+  void (*arch_setup) (void);
+
+  /* Check that the current target description is still valid for the current
+     inferior, returning false if not.  For example, if the size of some
+     registers (see aarch64 SVE), or the number of registers, had changed.
+     This check does not include the contents of the registers.  Default
+     implementation will always return true.  */
+  bool (*validate_tdesc) (struct thread_info *thread);
 };
 
 extern struct target_ops *the_target;
@@ -565,6 +575,14 @@ int kill_inferior (process_info *proc);
   (the_target->get_min_fast_tracepoint_insn_len                \
    ? (*the_target->get_min_fast_tracepoint_insn_len) () : 0)
 
+#define target_arch_setup(thread)                      \
+  if (the_target->arch_setup)                          \
+    (*the_target->arch_setup) ();
+
+#define target_validate_tdesc(thread)                  \
+  (the_target->validate_tdesc                          \
+    ? (*the_target->validate_tdesc) (thread) : true)
+
 #define thread_stopped(thread) \
   (*the_target->thread_stopped) (thread)