public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Kamil Rytarowski <n54@gmx.com>
To: gdb-patches@sourceware.org
Cc: tom@tromey.com, Kamil Rytarowski <n54@gmx.com>
Subject: [PATCH v2] Add support for "info auxv" on NetBSD
Date: Mon, 16 Mar 2020 19:17:10 +0100	[thread overview]
Message-ID: <20200316181710.7542-1-n54@gmx.com> (raw)
In-Reply-To: <20200314182258.4277-1-n54@gmx.com>

Register nbsd_auxv_parse() that overloads the default (Linux-style)
AUXV parsing. On NetBSD the type parameter is defined as int32_t
for all architectures.

Register nbsd_init_abi() that sets set_gdbarch_auxv_parse().

Call nbsd_init_abi() from all CPU-specific NetBSD tdep files.

gdb/ChangeLog:

	* nbsd-tdep.c: Include "gdbarch.h".
	* nbsd-tdep.c (nbsd_auxv_parse, nbsd_init_abi): New.
	* alpha-nbsd-tdep.c (alphanbsd_init_abi): Call nbsd_init_abi().
	* amd64-nbsd-tdep.c (amd64nbsd_init_abi): Likewise.
	* arm-nbsd-tdep.c (arm_netbsd_elf_init_abi): Likewise.
	* hppa-nbsd-tdep.c (hppanbsd_init_abi): Likewise.
	* i386-nbsd-tdep.c (i386nbsd_init_abi): Likewise.
	* mips-nbsd-tdep.c (nbsd_init_abi): Likewise.
	* ppc-nbsd-tdep.c (ppcnbsd_init_abi): Likewise.
	* sh-nbsd-tdep.c (shnbsd_init_abi): Likewise.
	* sparc-nbsd-tdep.c (sparc32nbsd_init_abi): Likewise.
	* sparc64-nbsd-tdep.c (sparc64nbsd_init_abi): Likewise.
	* vax-nbsd-tdep.c (vaxnbsd_elf_init_abi): Likewise.
---
 gdb/ChangeLog           | 16 ++++++++++++++++
 gdb/alpha-nbsd-tdep.c   |  2 ++
 gdb/amd64-nbsd-tdep.c   |  1 +
 gdb/arm-nbsd-tdep.c     |  3 +++
 gdb/hppa-nbsd-tdep.c    |  2 ++
 gdb/i386-nbsd-tdep.c    |  2 ++
 gdb/mips-nbsd-tdep.c    |  2 ++
 gdb/nbsd-tdep.c         | 33 +++++++++++++++++++++++++++++++++
 gdb/nbsd-tdep.h         |  2 ++
 gdb/ppc-nbsd-tdep.c     |  2 ++
 gdb/sh-nbsd-tdep.c      |  1 +
 gdb/sparc-nbsd-tdep.c   |  2 ++
 gdb/sparc64-nbsd-tdep.c |  2 ++
 gdb/vax-nbsd-tdep.c     |  2 ++
 14 files changed, 72 insertions(+)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index a0d97584189..42b2129d104 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,19 @@
+2020-03-16  Kamil Rytarowski  <n54@gmx.com>
+
+	* nbsd-tdep.c: Include "gdbarch.h".
+	* nbsd-tdep.c (nbsd_auxv_parse, nbsd_init_abi): New.
+	* alpha-nbsd-tdep.c (alphanbsd_init_abi): Call nbsd_init_abi().
+	* amd64-nbsd-tdep.c (amd64nbsd_init_abi): Likewise.
+	* arm-nbsd-tdep.c (arm_netbsd_elf_init_abi): Likewise.
+	* hppa-nbsd-tdep.c (hppanbsd_init_abi): Likewise.
+	* i386-nbsd-tdep.c (i386nbsd_init_abi): Likewise.
+	* mips-nbsd-tdep.c (nbsd_init_abi): Likewise.
+	* ppc-nbsd-tdep.c (ppcnbsd_init_abi): Likewise.
+	* sh-nbsd-tdep.c (shnbsd_init_abi): Likewise.
+	* sparc-nbsd-tdep.c (sparc32nbsd_init_abi): Likewise.
+	* sparc64-nbsd-tdep.c (sparc64nbsd_init_abi): Likewise.
+	* vax-nbsd-tdep.c (vaxnbsd_elf_init_abi): Likewise.
+
 2020-03-14  Tom Tromey  <tom@tromey.com>

 	* c-typeprint.c (cp_type_print_method_args): Print "__restrict__"
diff --git a/gdb/alpha-nbsd-tdep.c b/gdb/alpha-nbsd-tdep.c
index ab9240e35da..58294edb3f6 100644
--- a/gdb/alpha-nbsd-tdep.c
+++ b/gdb/alpha-nbsd-tdep.c
@@ -258,6 +258,8 @@ alphanbsd_init_abi (struct gdbarch_info info,
   /* Hook into the MDEBUG frame unwinder.  */
   alpha_mdebug_init_abi (info, gdbarch);

+  nbsd_init_abi (info, gdbarch);
+
   /* NetBSD/alpha does not provide single step support via ptrace(2); we
      must use software single-stepping.  */
   set_gdbarch_software_single_step (gdbarch, alpha_software_single_step);
diff --git a/gdb/amd64-nbsd-tdep.c b/gdb/amd64-nbsd-tdep.c
index 89d07236b85..59071488ed7 100644
--- a/gdb/amd64-nbsd-tdep.c
+++ b/gdb/amd64-nbsd-tdep.c
@@ -106,6 +106,7 @@ amd64nbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)

   amd64_init_abi (info, gdbarch,
 		  amd64_target_description (X86_XSTATE_SSE_MASK, true));
+  nbsd_init_abi (info, gdbarch);

   tdep->jb_pc_offset = 7 * 8;

diff --git a/gdb/arm-nbsd-tdep.c b/gdb/arm-nbsd-tdep.c
index e01df50bc25..a6104f760b3 100644
--- a/gdb/arm-nbsd-tdep.c
+++ b/gdb/arm-nbsd-tdep.c
@@ -150,6 +150,9 @@ arm_netbsd_elf_init_abi (struct gdbarch_info info,
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);

   arm_netbsd_init_abi_common (info, gdbarch);
+
+  nbsd_init_abi (info, gdbarch);
+
   if (tdep->fp_model == ARM_FLOAT_AUTO)
     tdep->fp_model = ARM_FLOAT_SOFT_VFP;

diff --git a/gdb/hppa-nbsd-tdep.c b/gdb/hppa-nbsd-tdep.c
index b532ab1d5cc..d601aa96f3f 100644
--- a/gdb/hppa-nbsd-tdep.c
+++ b/gdb/hppa-nbsd-tdep.c
@@ -201,6 +201,8 @@ hppanbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
   /* Obviously NetBSD is BSD-based.  */
   hppabsd_init_abi (info, gdbarch);

+  nbsd_init_abi (info, gdbarch);
+
   /* Core file support.  */
   set_gdbarch_iterate_over_regset_sections
     (gdbarch, hppanbsd_iterate_over_regset_sections);
diff --git a/gdb/i386-nbsd-tdep.c b/gdb/i386-nbsd-tdep.c
index 3157451e08f..f350412d9bd 100644
--- a/gdb/i386-nbsd-tdep.c
+++ b/gdb/i386-nbsd-tdep.c
@@ -377,6 +377,8 @@ i386nbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
   /* Obviously NetBSD is BSD-based.  */
   i386bsd_init_abi (info, gdbarch);

+  nbsd_init_abi (info, gdbarch);
+
   /* NetBSD has a different `struct reg'.  */
   tdep->gregset_reg_offset = i386nbsd_r_reg_offset;
   tdep->gregset_num_regs = ARRAY_SIZE (i386nbsd_r_reg_offset);
diff --git a/gdb/mips-nbsd-tdep.c b/gdb/mips-nbsd-tdep.c
index 38bc7ce636b..6f4d22b24fb 100644
--- a/gdb/mips-nbsd-tdep.c
+++ b/gdb/mips-nbsd-tdep.c
@@ -354,6 +354,8 @@ static void
 mipsnbsd_init_abi (struct gdbarch_info info,
                    struct gdbarch *gdbarch)
 {
+  nbsd_init_abi (info, gdbarch)
+
   set_gdbarch_iterate_over_regset_sections
     (gdbarch, mipsnbsd_iterate_over_regset_sections);

diff --git a/gdb/nbsd-tdep.c b/gdb/nbsd-tdep.c
index 49bb2b706bd..a9207e16625 100644
--- a/gdb/nbsd-tdep.c
+++ b/gdb/nbsd-tdep.c
@@ -22,6 +22,7 @@
 #include "defs.h"
 #include "solib-svr4.h"
 #include "nbsd-tdep.h"
+#include "gdbarch.h"

 /* FIXME: kettenis/20060115: We should really eliminate the next two
    functions completely.  */
@@ -47,3 +48,35 @@ nbsd_pc_in_sigtramp (CORE_ADDR pc, const char *func_name)
   return (func_name != NULL
 	  && startswith (func_name, "__sigtramp"));
 }
+
+static int
+nbsd_auxv_parse (struct gdbarch *gdbarch, gdb_byte **readptr,
+		 gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp)
+{
+  struct type *int_type = builtin_type (gdbarch)->builtin_int;
+  struct type *ptr_type = builtin_type (gdbarch)->builtin_data_ptr;
+  const int sizeof_auxv_type = TYPE_LENGTH (int_type);
+  const int sizeof_auxv_val = TYPE_LENGTH (ptr_type);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+  gdb_byte *ptr = *readptr;
+
+  if (endptr == ptr)
+    return 0;
+
+  if (endptr - ptr < 2 * sizeof_auxv_val)
+    return -1;
+
+  *typep = extract_unsigned_integer (ptr, sizeof_auxv_type, byte_order);
+  ptr += sizeof_auxv_val;	/* Alignment.  */
+  *valp = extract_unsigned_integer (ptr, sizeof_auxv_val, byte_order);
+  ptr += sizeof_auxv_val;
+
+  *readptr = ptr;
+  return 1;
+}
+
+void
+nbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
+{
+  set_gdbarch_auxv_parse (gdbarch, nbsd_auxv_parse);
+}
diff --git a/gdb/nbsd-tdep.h b/gdb/nbsd-tdep.h
index c99a8b537b6..9301ff7a69a 100644
--- a/gdb/nbsd-tdep.h
+++ b/gdb/nbsd-tdep.h
@@ -25,4 +25,6 @@ struct link_map_offsets *nbsd_lp64_solib_svr4_fetch_link_map_offsets (void);

 int nbsd_pc_in_sigtramp (CORE_ADDR, const char *);

+void nbsd_init_abi (struct gdbarch_info, struct gdbarch *);
+
 #endif /* NBSD_TDEP_H */
diff --git a/gdb/ppc-nbsd-tdep.c b/gdb/ppc-nbsd-tdep.c
index d75930c9f8d..81492deaccd 100644
--- a/gdb/ppc-nbsd-tdep.c
+++ b/gdb/ppc-nbsd-tdep.c
@@ -173,6 +173,8 @@ static void
 ppcnbsd_init_abi (struct gdbarch_info info,
                   struct gdbarch *gdbarch)
 {
+  nbsd_init_abi (info, gdbarch);
+
   /* For NetBSD, this is an on again, off again thing.  Some systems
      do use the broken struct convention, and some don't.  */
   set_gdbarch_return_value (gdbarch, ppcnbsd_return_value);
diff --git a/gdb/sh-nbsd-tdep.c b/gdb/sh-nbsd-tdep.c
index aa319261684..2b2a7e3fd4a 100644
--- a/gdb/sh-nbsd-tdep.c
+++ b/gdb/sh-nbsd-tdep.c
@@ -63,6 +63,7 @@ shnbsd_init_abi (struct gdbarch_info info,
                   struct gdbarch *gdbarch)
 {
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+  nbsd_init_abi (info, gdbarch);

   tdep->core_gregmap = (struct sh_corefile_regmap *)regmap;
   tdep->sizeof_gregset = 84;
diff --git a/gdb/sparc-nbsd-tdep.c b/gdb/sparc-nbsd-tdep.c
index 7aba6020d27..ab1b557c57c 100644
--- a/gdb/sparc-nbsd-tdep.c
+++ b/gdb/sparc-nbsd-tdep.c
@@ -296,6 +296,8 @@ sparc32nbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 {
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);

+  nbsd_init_abi (info, gdbarch);
+
   /* NetBSD doesn't support the 128-bit `long double' from the psABI.  */
   set_gdbarch_long_double_bit (gdbarch, 64);
   set_gdbarch_long_double_format (gdbarch, floatformats_ieee_double);
diff --git a/gdb/sparc64-nbsd-tdep.c b/gdb/sparc64-nbsd-tdep.c
index cd5bfe89410..dac7fa78b9b 100644
--- a/gdb/sparc64-nbsd-tdep.c
+++ b/gdb/sparc64-nbsd-tdep.c
@@ -249,6 +249,8 @@ sparc64nbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 {
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);

+  nbsd_init_abi (info, gdbarch);
+
   tdep->gregset = &sparc64nbsd_gregset;
   tdep->sizeof_gregset = 160;

diff --git a/gdb/vax-nbsd-tdep.c b/gdb/vax-nbsd-tdep.c
index c2c08cc1603..7630ac5ab94 100644
--- a/gdb/vax-nbsd-tdep.c
+++ b/gdb/vax-nbsd-tdep.c
@@ -29,6 +29,8 @@
 static void
 vaxnbsd_elf_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 {
+  nbsd_init_abi (info, gdbarch);
+
   /* NetBSD ELF uses SVR4-style shared libraries.  */
   set_solib_svr4_fetch_link_map_offsets
     (gdbarch, svr4_ilp32_fetch_link_map_offsets);
--
2.25.0


  parent reply	other threads:[~2020-03-16 18:18 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-14 18:22 [PATCH] Correct decoding AUXV " Kamil Rytarowski
2020-03-16 13:25 ` Tom Tromey
2020-03-16 18:17   ` Kamil Rytarowski
2020-03-16 18:17 ` Kamil Rytarowski [this message]
2020-03-19 13:11   ` [PATCH v2] Add support for "info auxv" " Kamil Rytarowski
2020-03-20 15:43   ` Tom Tromey
2020-03-20 17:27     ` Kamil Rytarowski
2020-03-20 17:27   ` [PATCH v3] " Kamil Rytarowski
2020-03-26 23:26     ` Kamil Rytarowski
2020-03-27 16:31       ` John Baldwin
2020-03-27 17:04         ` Kamil Rytarowski
2020-03-27 19:22           ` John Baldwin
2020-03-29 20:35             ` Kamil Rytarowski
2020-03-29 22:10     ` Simon Marchi

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=20200316181710.7542-1-n54@gmx.com \
    --to=n54@gmx.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tom@tromey.com \
    /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).