From: Andrew Burgess Date: Fri, 12 Nov 2021 12:04:08 +0000 (+0000) Subject: gdb: have mips_nbsd_nat_target inherit from nbsd_nat_target X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=8b8b05a454442ee187bcb279e52701028d98afc6;p=binutils-gdb.git gdb: have mips_nbsd_nat_target inherit from nbsd_nat_target While working on another patch I had reason to look at mips-netbsd-nat.c, and noticed that the class mips_nbsd_nat_target inherits directly from inf_ptrace_target. This is a little strange as alpha_bsd_nat_target, arm_netbsd_nat_target, hppa_nbsd_nat_target, m68k_bsd_nat_target, ppc_nbsd_nat_target, sh_nbsd_nat_target, and vax_bsd_nat_target all inherit from nbsd_nat_target. Originally, in this commit: commit f6ac5f3d63e03a81c4ff3749aba234961cc9090e Date: Thu May 3 00:37:22 2018 +0100 Convert struct target_ops to C++ When the target tree was converted to C++, all of the above classes inherited from inf_ptrace_target except for hppa_nbsd_nat_target, which was the only class that originally inherited from nbsd_nat_target. Later on all the remaining targets (except mips) were converted to inherit from nbsd_nat_target, these are the commits: commit 4fed520be264b60893aa674071947890f8172915 Date: Sat Mar 14 16:05:24 2020 +0100 Inherit alpha_netbsd_nat_target from nbsd_nat_target commit 6018d381a00515933016c539d2fdc18ad0d304b8 Date: Sat Mar 14 14:50:51 2020 +0100 Inherit arm_netbsd_nat_target from nbsd_nat_target commit 01a801176ea15ddfc988cade2e3d84c3b0abfec3 Date: Sat Mar 14 16:54:42 2020 +0100 Inherit m68k_bsd_nat_target from nbsd_nat_target commit 9faa006d11a5e08264a007463435f84b77864c9c Date: Thu Mar 19 14:52:57 2020 +0100 Inherit ppc_nbsd_nat_target from nbsd_nat_target commit 9809762324491b851332ce600ae9bde8dd34f601 Date: Tue Mar 17 15:07:39 2020 +0100 Inherit sh_nbsd_nat_target from nbsd_nat_target commit d5be5fa4207da00d039a1d5a040ba316e7092cbd Date: Sat Mar 14 13:21:58 2020 +0100 Inherit vax_bsd_nat_target from nbsd_nat_target I could only find mailing list threads for ppc and sh in the archive , and unfortunately, none of the commits has any real detail that might explain why mips was missed out, the only extra context I could find was this message: https://sourceware.org/pipermail/gdb-patches/2020-March/166853.html Which says that "proper" OS support is going to be added to nbsd_nat_target, hence the need to inherit from that class. My guess is that leaving mips_nbsd_nat_target unchanged was an oversight, so, in this commit, I propose changing mips_nbsd_nat_target to inherit from nbsd_nat_target just like all the other nbsd targets. My motivation for this patch relates to the post_startup_inferior target method. In a future commit I want to change how this method is handled. Currently the mips_nbsd_nat_target will pick up the empty implementation of inf_child_target::post_startup_inferior rather than the version in netbsd-nat.c. This feels like a bug to me, as surely, enabling of proc events is something that would need to be done for all netbsd targets, regardless of architecture. In my future patch I have a choice then, either (a) add a new, empty implementation of post_startup_inferior to mips_nbsd_nat_target, or (b) this commit, have mips_nbsd_nat_target inherit from nbsd_nat_target. Option (b) seems like the right way to go, hence, this commit. I've done absolutely no testing for this change, not even building it, as that would require at least an environment in which I can x-build mips-netbsd applications, which I have no idea how to set up. --- diff --git a/gdb/mips-netbsd-nat.c b/gdb/mips-netbsd-nat.c index 349ab55b7dc..887163cccd4 100644 --- a/gdb/mips-netbsd-nat.c +++ b/gdb/mips-netbsd-nat.c @@ -30,9 +30,10 @@ #include "mips-tdep.h" #include "mips-netbsd-tdep.h" +#include "netbsd-nat.h" #include "inf-ptrace.h" -class mips_nbsd_nat_target final : public inf_ptrace_target +class mips_nbsd_nat_target final : public nbsd_nat_target { void fetch_registers (struct regcache *, int) override; void store_registers (struct regcache *, int) override;