Module Name:    src
Committed By:   rin
Date:           Thu Aug 17 06:54:31 UTC 2023

Modified Files:
        src/external/gpl3/gdb/dist/gdb: netbsd-tdep.c
        src/external/gpl3/gdb/dist/include/elf: common.h

Log Message:
gdb: Add support for NetBSD-specific auxv AT_STACKBASE

It was wrongly shown as AT_GID in decimal format.


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.1 -r1.2 src/external/gpl3/gdb/dist/gdb/netbsd-tdep.c
cvs rdiff -u -r1.7 -r1.8 src/external/gpl3/gdb/dist/include/elf/common.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/gpl3/gdb/dist/gdb/netbsd-tdep.c
diff -u src/external/gpl3/gdb/dist/gdb/netbsd-tdep.c:1.1.1.1 src/external/gpl3/gdb/dist/gdb/netbsd-tdep.c:1.2
--- src/external/gpl3/gdb/dist/gdb/netbsd-tdep.c:1.1.1.1	Sun Jul 30 22:44:53 2023
+++ src/external/gpl3/gdb/dist/gdb/netbsd-tdep.c	Thu Aug 17 06:54:31 2023
@@ -27,6 +27,8 @@
 #include "objfiles.h"
 #include "xml-syscall.h"
 
+#include "elf/common.h"
+
 /* Flags in the 'kve_protection' field in struct kinfo_vmentry.  These
    match the KVME_PROT_* constants in <sys/sysctl.h>.  */
 
@@ -390,6 +392,31 @@ get_nbsd_gdbarch_data (struct gdbarch *g
   return result;
 }
 
+/* Print descriptions of NetBSD-specific AUXV entries to FILE.  */
+
+static void
+nbsd_print_auxv_entry (struct gdbarch *gdbarch, struct ui_file *file,
+		       CORE_ADDR type, CORE_ADDR val)
+{
+  const char *name = "???";
+  const char *description = "";
+  enum auxv_format format = AUXV_FORMAT_HEX;
+
+  switch (type)
+    {
+    default:
+      default_print_auxv_entry (gdbarch, file, type, val);
+      return;
+#define _TAGNAME(tag) #tag
+#define TAGNAME(tag) _TAGNAME(AT_##tag)
+#define TAG(tag, text, kind) \
+      case AT_NETBSD_##tag: name = TAGNAME(tag); description = text; format = kind; break
+      TAG (STACKBASE, _("Base address of main thread"), AUXV_FORMAT_HEX);
+    }
+
+  fprint_auxv_entry (file, name, description, format, type, val);
+}
+
 /* Implement the "get_siginfo_type" gdbarch method.  */
 
 static struct type *
@@ -613,6 +640,7 @@ nbsd_init_abi (struct gdbarch_info info,
   set_gdbarch_gdb_signal_to_target (gdbarch, nbsd_gdb_signal_to_target);
   set_gdbarch_skip_solib_resolver (gdbarch, nbsd_skip_solib_resolver);
   set_gdbarch_auxv_parse (gdbarch, svr4_auxv_parse);
+  set_gdbarch_print_auxv_entry (gdbarch, nbsd_print_auxv_entry);
   set_gdbarch_get_siginfo_type (gdbarch, nbsd_get_siginfo_type);
 
   /* `catch syscall' */

Index: src/external/gpl3/gdb/dist/include/elf/common.h
diff -u src/external/gpl3/gdb/dist/include/elf/common.h:1.7 src/external/gpl3/gdb/dist/include/elf/common.h:1.8
--- src/external/gpl3/gdb/dist/include/elf/common.h:1.7	Mon Jul 31 17:00:57 2023
+++ src/external/gpl3/gdb/dist/include/elf/common.h	Thu Aug 17 06:54:31 2023
@@ -1409,6 +1409,8 @@
 #define AT_FREEBSD_USRSTACKBASE 35      /* Top of user stack. */
 #define AT_FREEBSD_USRSTACKLIM  36      /* Grow limit of user stack. */
 
+#define AT_NETBSD_STACKBASE     13      /* Base address of the main thread. */
+
 #define AT_SUN_UID      2000    /* Effective user ID.  */
 #define AT_SUN_RUID     2001    /* Real user ID.  */
 #define AT_SUN_GID      2002    /* Effective group ID.  */

Reply via email to