public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Andrew Burgess <aburgess@redhat.com>
To: gdb-patches@sourceware.org
Cc: Andrew Burgess <aburgess@redhat.com>
Subject: [PATCH 1/3] gdb: have mips_nbsd_nat_target inherit from nbsd_nat_target
Date: Fri,  3 Dec 2021 10:28:43 +0000	[thread overview]
Message-ID: <e950ad5e7bf77276205280b8564d17804973e886.1638527080.git.aburgess@redhat.com> (raw)
In-Reply-To: <cover.1638527080.git.aburgess@redhat.com>

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.
---
 gdb/mips-netbsd-nat.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

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;
-- 
2.25.4


  reply	other threads:[~2021-12-03 10:28 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-03 10:28 [PATCH 0/3] Refactor target_ops::post_startup_inferior Andrew Burgess
2021-12-03 10:28 ` Andrew Burgess [this message]
2021-12-03 16:23   ` [PATCH 1/3] gdb: have mips_nbsd_nat_target inherit from nbsd_nat_target John Baldwin
2021-12-03 10:28 ` [PATCH 2/3] gdb: rename gdb_startup_inferior to inf_child_target::startup_inferior Andrew Burgess
2021-12-07 18:58   ` Tom Tromey
2021-12-09 18:45   ` Andrew Burgess
2021-12-03 10:28 ` [PATCH 3/3] gdb: make post_startup_inferior a virtual method on inf_ptrace_target Andrew Burgess
2021-12-03 16:39   ` John Baldwin
2021-12-07 19:10     ` Tom Tromey
2021-12-08 11:46     ` Andrew Burgess
2021-12-08 18:11       ` John Baldwin
2021-12-13 11:21 ` [PATCH 0/3] Refactor target_ops::post_startup_inferior Andrew Burgess

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e950ad5e7bf77276205280b8564d17804973e886.1638527080.git.aburgess@redhat.com \
    --to=aburgess@redhat.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).