From 7a9abb2bce8f2f52f7f59927b18582f67a0c3208 Mon Sep 17 00:00:00 2001 From: Alan Hayward Date: Wed, 7 Nov 2018 15:15:24 +0000 Subject: [PATCH] Add gdbserver target methods target_validate_tdesc and arch_setup 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 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 | 10 ++++++++++ gdb/gdbserver/linux-low.c | 11 +++++++++++ gdb/gdbserver/linux-low.h | 3 +++ gdb/gdbserver/target.h | 18 ++++++++++++++++++ 4 files changed, 42 insertions(+) diff --git a/gdb/gdbserver/linux-aarch64-low.c b/gdb/gdbserver/linux-aarch64-low.c index 1d34e319dfd..dcc19ce18c0 100644 --- a/gdb/gdbserver/linux-aarch64-low.c +++ b/gdb/gdbserver/linux-aarch64-low.c @@ -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 diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c index 701f3e863c0..3c33ebff053 100644 --- a/gdb/gdbserver/linux-low.c +++ b/gdb/gdbserver/linux-low.c @@ -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 diff --git a/gdb/gdbserver/linux-low.h b/gdb/gdbserver/linux-low.h index 79b3311f021..a99e6fc41a5 100644 --- a/gdb/gdbserver/linux-low.h +++ b/gdb/gdbserver/linux-low.h @@ -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; diff --git a/gdb/gdbserver/target.h b/gdb/gdbserver/target.h index fce54e05adb..dfa74ec94f0 100644 --- a/gdb/gdbserver/target.h +++ b/gdb/gdbserver/target.h @@ -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) -- 2.47.2