From c98f7d6cdd74b02dcfcf12993e9a13ce851b1383 Mon Sep 17 00:00:00 2001 From: Sergey Zigachev Date: Fri, 26 Jan 2024 19:13:12 +0500 Subject: [PATCH] devel/gdb: unlock and fix port --- ports/devel/gdb/STATUS | 2 +- ports/devel/gdb/dragonfly/amd64-dfly-nat.c | 35 +++- ports/devel/gdb/dragonfly/amd64-dfly-tdep.c | 9 +- ports/devel/gdb/dragonfly/dfly-nat.c | 11 +- ports/devel/gdb/dragonfly/dfly-nat.h | 2 +- ports/devel/gdb/dragonfly/dfly-tdep.c | 166 ++++++++---------- ports/devel/gdb/dragonfly/i386-dfly-tdep.c | 13 +- .../devel/gdb/dragonfly/patch-bfd_config.bfd | 8 +- .../gdb/dragonfly/patch-gdb_amd64-tdep.h | 12 +- .../devel/gdb/dragonfly/patch-gdb_i386-tdep.h | 10 +- 10 files changed, 139 insertions(+), 129 deletions(-) diff --git a/ports/devel/gdb/STATUS b/ports/devel/gdb/STATUS index 73215ea69c3c..25d4abcd02e7 100644 --- a/ports/devel/gdb/STATUS +++ b/ports/devel/gdb/STATUS @@ -1,3 +1,3 @@ -LOCK +PORT Last attempt: 11.2 Last success: 11.2 diff --git a/ports/devel/gdb/dragonfly/amd64-dfly-nat.c b/ports/devel/gdb/dragonfly/amd64-dfly-nat.c index bd5bd5ecc76f..50efbab5a5a5 100644 --- a/ports/devel/gdb/dragonfly/amd64-dfly-nat.c +++ b/ports/devel/gdb/dragonfly/amd64-dfly-nat.c @@ -39,7 +39,6 @@ #include "amd64-bsd-nat.h" #include "x86-nat.h" #include "gdbsupport/x86-xstate.h" - class amd64_dfly_nat_target final : public amd64_bsd_nat_target @@ -51,6 +50,9 @@ class amd64_dfly_nat_target final #if defined(HAVE_PT_GETDBREGS) && defined(USE_SIGTRAP_SIGINFO) bool supports_stopped_by_hw_breakpoint () override; #endif + +protected: + void post_startup_inferior (ptid_t) override; }; static amd64_dfly_nat_target the_amd64_dfly_nat_target; @@ -246,7 +248,36 @@ amd64_dfly_nat_target::supports_stopped_by_hw_breakpoint () #endif void -_initialize_amd64dfly_nat (void) +amd64_dfly_nat_target::post_startup_inferior (ptid_t pid) +{ +#ifdef PT_GET_EVENT_MASK + int events; + + if (ptrace (PT_GET_EVENT_MASK, pid, (PTRACE_TYPE_ARG3)&events, + sizeof (events)) == -1) + perror_with_name (("ptrace (PT_GET_EVENT_MASK)")); + events |= PTRACE_FORK | PTRACE_LWP; +#ifdef PTRACE_VFORK + events |= PTRACE_VFORK; +#endif + if (ptrace (PT_SET_EVENT_MASK, pid, (PTRACE_TYPE_ARG3)&events, + sizeof (events)) == -1) + perror_with_name (("ptrace (PT_SET_EVENT_MASK)")); +#else +#ifdef TDP_RFPPWAIT + if (ptrace (PT_FOLLOW_FORK, pid, (PTRACE_TYPE_ARG3)0, 1) == -1) + perror_with_name (("ptrace (PT_FOLLOW_FORK)")); +#endif +#ifdef PT_LWP_EVENTS + if (ptrace (PT_LWP_EVENTS, pid, (PTRACE_TYPE_ARG3)0, 1) == -1) + perror_with_name (("ptrace (PT_LWP_EVENTS)")); +#endif +#endif +} + +void _initialize_amd64dfly_nat (); +void +_initialize_amd64dfly_nat () { int offset; diff --git a/ports/devel/gdb/dragonfly/amd64-dfly-tdep.c b/ports/devel/gdb/dragonfly/amd64-dfly-tdep.c index b6decd4e27c7..a3a1032e32fe 100644 --- a/ports/devel/gdb/dragonfly/amd64-dfly-tdep.c +++ b/ports/devel/gdb/dragonfly/amd64-dfly-tdep.c @@ -67,7 +67,7 @@ amd64fbsd_sigtramp_p (struct frame_info *this_frame) address of the associated sigcontext structure. */ static CORE_ADDR -amd64dfly_sigcontext_addr (struct frame_info *this_frame) +amd64dfly_sigcontext_addr (struct frame_info_ptr this_frame) { struct gdbarch *gdbarch = get_frame_arch (this_frame); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); @@ -81,7 +81,7 @@ amd64dfly_sigcontext_addr (struct frame_info *this_frame) sp = extract_unsigned_integer (buf, 8, byte_order); return sp + 16; } - + /* Mapping between the general-purpose registers in `struct reg' format and GDB's register cache layout. @@ -175,7 +175,7 @@ static int amd64dfly_jmp_buf_reg_offset[] = static void amd64dfly_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + i386_gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); /* Generic DragonFly support. */ dfly_init_abi (info, gdbarch); @@ -222,8 +222,9 @@ amd64dfly_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) #endif } +void _initialize_amd64dfly_tdep (); void -_initialize_amd64dfly_tdep (void) +_initialize_amd64dfly_tdep () { gdbarch_register_osabi (bfd_arch_i386, bfd_mach_x86_64, GDB_OSABI_DRAGONFLY, amd64dfly_init_abi); diff --git a/ports/devel/gdb/dragonfly/dfly-nat.c b/ports/devel/gdb/dragonfly/dfly-nat.c index 01d9b07d2b1d..dae4471faad7 100644 --- a/ports/devel/gdb/dragonfly/dfly-nat.c +++ b/ports/devel/gdb/dragonfly/dfly-nat.c @@ -48,7 +48,7 @@ /* Return the name of a file that can be opened to get the symbols for the child process identified by PID. */ -char * +const char * dfly_nat_target::pid_to_exec_file (int pid) { ssize_t len; @@ -122,7 +122,7 @@ dfly_nat_target::find_memory_regions (find_memory_region_ftype func, error (_("Couldn't open %s."), mapfilename.c_str ()); if (info_verbose) - fprintf_filtered (gdb_stdout, + gdb_printf (gdb_stdout, "Reading memory regions from %s\n", mapfilename.c_str ()); /* Now iterate until end-of-file. */ @@ -136,7 +136,7 @@ dfly_nat_target::find_memory_regions (find_memory_region_ftype func, if (info_verbose) { - fprintf_filtered (gdb_stdout, + gdb_printf (gdb_stdout, "Save segment, %ld bytes at %s (%c%c%c)\n", size, paddress (target_gdbarch (), start), read ? 'r' : '-', @@ -146,7 +146,7 @@ dfly_nat_target::find_memory_regions (find_memory_region_ftype func, /* Invoke the callback function to create the corefile segment. Pass MODIFIED as true, we do not know the real modification state. */ - func (start, size, read, write, exec, 1, obfd); + func (start, size, read, write, exec, 1, false, obfd); } return 0; @@ -166,8 +166,9 @@ dfly_nat_add_target (struct target_ops *t) /* Provide a prototype to silence -Wmissing-prototypes. */ extern initialize_file_ftype _initialize_dfly_nat; +void _initialize_dfly_nat (); void -_initialize_dfly_nat (void) +_initialize_dfly_nat () { /* XXX: todo add_setshow_boolean_cmd() */ } diff --git a/ports/devel/gdb/dragonfly/dfly-nat.h b/ports/devel/gdb/dragonfly/dfly-nat.h index e28f4f456f18..8cbe33d876c2 100644 --- a/ports/devel/gdb/dragonfly/dfly-nat.h +++ b/ports/devel/gdb/dragonfly/dfly-nat.h @@ -28,7 +28,7 @@ class dfly_nat_target : public inf_ptrace_target { public: - char *pid_to_exec_file (int pid) override; + const char *pid_to_exec_file (int pid) override; int find_memory_regions (find_memory_region_ftype func, void *data) override; diff --git a/ports/devel/gdb/dragonfly/dfly-tdep.c b/ports/devel/gdb/dragonfly/dfly-tdep.c index 0d1f34143b39..befd54bd8e79 100644 --- a/ports/devel/gdb/dragonfly/dfly-tdep.c +++ b/ports/devel/gdb/dragonfly/dfly-tdep.c @@ -338,61 +338,47 @@ const struct kinfo_proc_layout kinfo_proc_layout_64 = }; #endif -static struct gdbarch_data *dfly_gdbarch_data_handle; - struct dfly_gdbarch_data { - struct type *siginfo_type; + struct type *siginfo_type = nullptr; }; -static void * -init_dfly_gdbarch_data (struct gdbarch *gdbarch) -{ - return GDBARCH_OBSTACK_ZALLOC (gdbarch, struct dfly_gdbarch_data); -} +static const registry::key + dfly_gdbarch_data_handle; static struct dfly_gdbarch_data * get_dfly_gdbarch_data (struct gdbarch *gdbarch) { - return ((struct dfly_gdbarch_data *) - gdbarch_data (gdbarch, dfly_gdbarch_data_handle)); + struct dfly_gdbarch_data *result = dfly_gdbarch_data_handle.get (gdbarch); + if (result == nullptr) + result = dfly_gdbarch_data_handle.emplace (gdbarch); + return result; } -/* Per-program-space data for DragonFly architectures. */ -static const struct program_space_data *dfly_pspace_data_handle; - struct dfly_pspace_data { /* Offsets in the runtime linker's 'Obj_Entry' structure. */ - LONGEST off_linkmap; - LONGEST off_tlsindex; - bool rtld_offsets_valid; + LONGEST off_linkmap = 0; + LONGEST off_tlsindex = 0; + bool rtld_offsets_valid = false; }; +/* Per-program-space data for FreeBSD architectures. */ +static const registry::key + dfly_pspace_data_handle; + static struct dfly_pspace_data * get_dfly_pspace_data (struct program_space *pspace) { struct dfly_pspace_data *data; - data = ((struct dfly_pspace_data *) - program_space_data (pspace, dfly_pspace_data_handle)); + data = dfly_pspace_data_handle.get (pspace); if (data == NULL) - { - data = XCNEW (struct dfly_pspace_data); - set_program_space_data (pspace, dfly_pspace_data_handle, data); - } + data = dfly_pspace_data_handle.emplace (pspace); return data; } -/* The cleanup callback for DragonFly architecture per-program-space data. */ - -static void -dfly_pspace_data_cleanup (struct program_space *pspace, void *data) -{ - xfree (data); -} - /* This is how we want PTIDs from core files to be printed. */ static std::string @@ -901,7 +887,7 @@ dfly_print_sockaddr_in (const void *sockaddr) if (inet_ntop (AF_INET, sin->sin_addr, buf, sizeof buf) == nullptr) error (_("Failed to format IPv4 address")); - printf_filtered ("%s:%u", buf, + gdb_printf ("%s:%u", buf, (sin->sin_port[0] << 8) | sin->sin_port[1]); } @@ -916,7 +902,7 @@ dfly_print_sockaddr_in6 (const void *sockaddr) if (inet_ntop (AF_INET6, sin6->sin6_addr, buf, sizeof buf) == nullptr) error (_("Failed to format IPv6 address")); - printf_filtered ("%s.%u", buf, + gdb_printf ("%s.%u", buf, (sin6->sin6_port[0] << 8) | sin6->sin6_port[1]); } @@ -926,8 +912,8 @@ dfly_print_sockaddr_in6 (const void *sockaddr) void dfly_info_proc_files_header () { - printf_filtered (_("Open files:\n\n")); - printf_filtered (" %6s %6s %10s %9s %s\n", + gdb_printf (_("Open files:\n\n")); + gdb_printf (" %6s %6s %10s %9s %s\n", "FD", "Type", "Offset", "Flags ", "Name"); } #endif @@ -942,7 +928,7 @@ dfly_info_proc_files_entry (int kf_type, int kf_fd, int kf_flags, int kf_sock_protocol, const void *kf_sa_local, const void *kf_sa_peer, const void *kf_path) { - printf_filtered (" %6s %6s %10s %8s ", + gdb_printf (" %6s %6s %10s %8s ", dfly_file_fd (kf_fd), dfly_file_type (kf_type, kf_vnode_type), kf_offset > -1 ? hex_string (kf_offset) : "-", @@ -956,16 +942,16 @@ dfly_info_proc_files_entry (int kf_type, int kf_fd, int kf_flags, switch (kf_sock_type) { case DFLY_SOCK_STREAM: - printf_filtered ("unix stream:"); + gdb_printf ("unix stream:"); break; case DFLY_SOCK_DGRAM: - printf_filtered ("unix dgram:"); + gdb_printf ("unix dgram:"); break; case DFLY_SOCK_SEQPACKET: - printf_filtered ("unix seqpacket:"); + gdb_printf ("unix seqpacket:"); break; default: - printf_filtered ("unix <%d>:", kf_sock_type); + gdb_printf ("unix <%d>:", kf_sock_type); break; } @@ -976,26 +962,26 @@ dfly_info_proc_files_entry (int kf_type, int kf_fd, int kf_flags, if (sun->sun_path[0] == 0) sun = reinterpret_cast (kf_sa_peer); - printf_filtered ("%s", sun->sun_path); + gdb_printf ("%s", sun->sun_path); break; } case DFLY_AF_INET: - printf_filtered ("%s4 ", dfly_ipproto (kf_sock_protocol)); + gdb_printf ("%s4 ", dfly_ipproto (kf_sock_protocol)); dfly_print_sockaddr_in (kf_sa_local); - printf_filtered (" -> "); + gdb_printf (" -> "); dfly_print_sockaddr_in (kf_sa_peer); break; case DFLY_AF_INET6: - printf_filtered ("%s6 ", dfly_ipproto (kf_sock_protocol)); + gdb_printf ("%s6 ", dfly_ipproto (kf_sock_protocol)); dfly_print_sockaddr_in6 (kf_sa_local); - printf_filtered (" -> "); + gdb_printf (" -> "); dfly_print_sockaddr_in6 (kf_sa_peer); break; } } else - printf_filtered ("%s", reinterpret_cast (kf_path)); - printf_filtered ("\n"); + gdb_printf ("%s", reinterpret_cast (kf_path)); + gdb_printf ("\n"); } #endif @@ -1087,17 +1073,17 @@ dfly_vm_map_entry_flags (int kve_flags, int kve_protection) void dfly_info_proc_mappings_header (int addr_bit) { - printf_filtered (_("Mapped address spaces:\n\n")); + gdb_printf (_("Mapped address spaces:\n\n")); if (addr_bit == 64) { - printf_filtered (" %18s %18s %10s %10s %9s %s\n", + gdb_printf (" %18s %18s %10s %10s %9s %s\n", "Start Addr", " End Addr", " Size", " Offset", "Flags ", "File"); } else { - printf_filtered ("\t%10s %10s %10s %10s %9s %s\n", + gdb_printf ("\t%10s %10s %10s %10s %9s %s\n", "Start Addr", " End Addr", " Size", " Offset", "Flags ", "File"); @@ -1116,7 +1102,7 @@ dfly_info_proc_mappings_entry (int addr_bit, ULONGEST kve_start, { if (addr_bit == 64) { - printf_filtered (" %18s %18s %10s %10s %9s %s\n", + gdb_printf (" %18s %18s %10s %10s %9s %s\n", hex_string (kve_start), hex_string (kve_end), hex_string (kve_end - kve_start), @@ -1126,7 +1112,7 @@ dfly_info_proc_mappings_entry (int addr_bit, ULONGEST kve_start, } else { - printf_filtered ("\t%10s %10s %10s %10s %9s %s\n", + gdb_printf ("\t%10s %10s %10s %10s %9s %s\n", hex_string (kve_start), hex_string (kve_end), hex_string (kve_end - kve_start), @@ -1271,11 +1257,11 @@ dfly_core_fetch_timeval (struct gdbarch *gdbarch, unsigned char *data, static void dfly_print_sigset (const char *descr, unsigned char *sigset) { - printf_filtered ("%s: ", descr); + gdb_printf ("%s: ", descr); for (int i = 0; i < SIG_WORDS; i++) - printf_filtered ("%08x ", + gdb_printf ("%08x ", (unsigned int) bfd_get_32 (core_bfd, sigset + i * 4)); - printf_filtered ("\n"); + gdb_printf ("\n"); } #endif @@ -1337,14 +1323,14 @@ dfly_core_info_proc_status (struct gdbarch *gdbarch) return; } - printf_filtered ("Name: %.19s\n", descdata + kp->ki_comm); - printf_filtered ("Process ID: %s\n", + gdb_printf ("Name: %.19s\n", descdata + kp->ki_comm); + gdb_printf ("Process ID: %s\n", pulongest (bfd_get_32 (core_bfd, descdata + kp->ki_pid))); - printf_filtered ("Parent process: %s\n", + gdb_printf ("Parent process: %s\n", pulongest (bfd_get_32 (core_bfd, descdata + kp->ki_ppid))); - printf_filtered ("Process group: %s\n", + gdb_printf ("Process group: %s\n", pulongest (bfd_get_32 (core_bfd, descdata + kp->ki_pgid))); - printf_filtered ("Session id: %s\n", + gdb_printf ("Session id: %s\n", pulongest (bfd_get_32 (core_bfd, descdata + kp->ki_sid))); /* FreeBSD 12.0 and later store a 64-bit dev_t at 'ki_tdev'. Older @@ -1356,73 +1342,73 @@ dfly_core_info_proc_status (struct gdbarch *gdbarch) value = bfd_get_64 (core_bfd, descdata + kp->ki_tdev); if (value == 0) value = bfd_get_32 (core_bfd, descdata + kp->ki_tdev_freebsd11); - printf_filtered ("TTY: %s\n", pulongest (value)); - printf_filtered ("TTY owner process group: %s\n", + gdb_printf ("TTY: %s\n", pulongest (value)); + gdb_printf ("TTY owner process group: %s\n", pulongest (bfd_get_32 (core_bfd, descdata + kp->ki_tpgid))); - printf_filtered ("User IDs (real, effective, saved): %s %s %s\n", + gdb_printf ("User IDs (real, effective, saved): %s %s %s\n", pulongest (bfd_get_32 (core_bfd, descdata + kp->ki_ruid)), pulongest (bfd_get_32 (core_bfd, descdata + kp->ki_uid)), pulongest (bfd_get_32 (core_bfd, descdata + kp->ki_svuid))); - printf_filtered ("Group IDs (real, effective, saved): %s %s %s\n", + gdb_printf ("Group IDs (real, effective, saved): %s %s %s\n", pulongest (bfd_get_32 (core_bfd, descdata + kp->ki_rgid)), pulongest (bfd_get_32 (core_bfd, descdata + kp->ki_groups)), pulongest (bfd_get_32 (core_bfd, descdata + kp->ki_svgid))); - printf_filtered ("Groups: "); + gdb_printf ("Groups: "); uint16_t ngroups = bfd_get_16 (core_bfd, descdata + kp->ki_ngroups); for (int i = 0; i < ngroups; i++) - printf_filtered ("%s ", + gdb_printf ("%s ", pulongest (bfd_get_32 (core_bfd, descdata + kp->ki_groups + i * 4))); - printf_filtered ("\n"); + gdb_printf ("\n"); value = bfd_get (long_bit, core_bfd, descdata + kp->ki_rusage + kp->ru_minflt); - printf_filtered ("Minor faults (no memory page): %s\n", pulongest (value)); + gdb_printf ("Minor faults (no memory page): %s\n", pulongest (value)); value = bfd_get (long_bit, core_bfd, descdata + kp->ki_rusage_ch + kp->ru_minflt); - printf_filtered ("Minor faults, children: %s\n", pulongest (value)); + gdb_printf ("Minor faults, children: %s\n", pulongest (value)); value = bfd_get (long_bit, core_bfd, descdata + kp->ki_rusage + kp->ru_majflt); - printf_filtered ("Major faults (memory page faults): %s\n", + gdb_printf ("Major faults (memory page faults): %s\n", pulongest (value)); value = bfd_get (long_bit, core_bfd, descdata + kp->ki_rusage_ch + kp->ru_majflt); - printf_filtered ("Major faults, children: %s\n", pulongest (value)); + gdb_printf ("Major faults, children: %s\n", pulongest (value)); dfly_core_fetch_timeval (gdbarch, descdata + kp->ki_rusage + kp->ru_utime, sec, value); - printf_filtered ("utime: %s.%06d\n", plongest (sec), (int) value); + gdb_printf ("utime: %s.%06d\n", plongest (sec), (int) value); dfly_core_fetch_timeval (gdbarch, descdata + kp->ki_rusage + kp->ru_stime, sec, value); - printf_filtered ("stime: %s.%06d\n", plongest (sec), (int) value); + gdb_printf ("stime: %s.%06d\n", plongest (sec), (int) value); dfly_core_fetch_timeval (gdbarch, descdata + kp->ki_rusage_ch + kp->ru_utime, sec, value); - printf_filtered ("utime, children: %s.%06d\n", plongest (sec), (int) value); + gdb_printf ("utime, children: %s.%06d\n", plongest (sec), (int) value); dfly_core_fetch_timeval (gdbarch, descdata + kp->ki_rusage_ch + kp->ru_stime, sec, value); - printf_filtered ("stime, children: %s.%06d\n", plongest (sec), (int) value); - printf_filtered ("'nice' value: %d\n", + gdb_printf ("stime, children: %s.%06d\n", plongest (sec), (int) value); + gdb_printf ("'nice' value: %d\n", bfd_get_signed_8 (core_bfd, descdata + kp->ki_nice)); dfly_core_fetch_timeval (gdbarch, descdata + kp->ki_start, sec, value); - printf_filtered ("Start time: %s.%06d\n", plongest (sec), (int) value); - printf_filtered ("Virtual memory size: %s kB\n", + gdb_printf ("Start time: %s.%06d\n", plongest (sec), (int) value); + gdb_printf ("Virtual memory size: %s kB\n", pulongest (bfd_get (addr_bit, core_bfd, descdata + kp->ki_size) / 1024)); - printf_filtered ("Data size: %s pages\n", + gdb_printf ("Data size: %s pages\n", pulongest (bfd_get (addr_bit, core_bfd, descdata + kp->ki_dsize))); - printf_filtered ("Stack size: %s pages\n", + gdb_printf ("Stack size: %s pages\n", pulongest (bfd_get (addr_bit, core_bfd, descdata + kp->ki_ssize))); - printf_filtered ("Text size: %s pages\n", + gdb_printf ("Text size: %s pages\n", pulongest (bfd_get (addr_bit, core_bfd, descdata + kp->ki_tsize))); - printf_filtered ("Resident set size: %s pages\n", + gdb_printf ("Resident set size: %s pages\n", pulongest (bfd_get (addr_bit, core_bfd, descdata + kp->ki_rssize))); - printf_filtered ("Maximum RSS: %s pages\n", + gdb_printf ("Maximum RSS: %s pages\n", pulongest (bfd_get (long_bit, core_bfd, descdata + kp->ki_rusage + kp->ru_maxrss))); @@ -1486,7 +1472,7 @@ dfly_core_info_proc (struct gdbarch *gdbarch, const char *args, pid = bfd_core_file_pid (core_bfd); if (pid != 0) - printf_filtered (_("process %d\n"), pid); + gdb_printf (_("process %d\n"), pid); if (do_cmdline) { @@ -1494,7 +1480,7 @@ dfly_core_info_proc (struct gdbarch *gdbarch, const char *args, cmdline = bfd_core_file_failing_command (core_bfd); if (cmdline) - printf_filtered ("cmdline = '%s'\n", cmdline); + gdb_printf ("cmdline = '%s'\n", cmdline); else warning (_("Command line unavailable")); } @@ -1503,7 +1489,7 @@ dfly_core_info_proc (struct gdbarch *gdbarch, const char *args, gdb::unique_xmalloc_ptr cwd = dfly_core_vnode_path (gdbarch, KINFO_FILE_FD_TYPE_CWD); if (cwd) - printf_filtered ("cwd = '%s'\n", cwd.get ()); + gdb_printf ("cwd = '%s'\n", cwd.get ()); else warning (_("unable to read current working directory")); } @@ -1512,7 +1498,7 @@ dfly_core_info_proc (struct gdbarch *gdbarch, const char *args, gdb::unique_xmalloc_ptr exe = dfly_core_vnode_path (gdbarch, KINFO_FILE_FD_TYPE_TEXT); if (exe) - printf_filtered ("exe = '%s'\n", exe.get ()); + gdb_printf ("exe = '%s'\n", exe.get ()); else warning (_("unable to read executable path name")); } @@ -2086,11 +2072,3 @@ dfly_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) #endif } -void -_initialize_dfly_tdep (void) -{ - dfly_gdbarch_data_handle = - gdbarch_data_register_post_init (init_dfly_gdbarch_data); - dfly_pspace_data_handle - = register_program_space_data_with_cleanup (NULL, dfly_pspace_data_cleanup); -} diff --git a/ports/devel/gdb/dragonfly/i386-dfly-tdep.c b/ports/devel/gdb/dragonfly/i386-dfly-tdep.c index 0346153f6b1f..2878025628db 100644 --- a/ports/devel/gdb/dragonfly/i386-dfly-tdep.c +++ b/ports/devel/gdb/dragonfly/i386-dfly-tdep.c @@ -77,7 +77,13 @@ int i386dfly_sc_reg_offset[] = static void i386dfly_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + i386_gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + + /* Generic DragonFly support. */ + dfly_init_abi (info, gdbarch); + + /* Obviously DragonFly is BSD-based. */ + i386bsd_init_abi (info, gdbarch); i386_elf_init_abi(info, gdbarch); @@ -94,10 +100,9 @@ i386dfly_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) /* Provide a prototype to silence -Wmissing-prototypes. */ -void _initialize_i386dfly_tdep (void); - +void _initialize_i386dfly_tdep (); void -_initialize_i386dfly_tdep (void) +_initialize_i386dfly_tdep () { gdbarch_register_osabi (bfd_arch_i386, 0, GDB_OSABI_DRAGONFLY, i386dfly_init_abi); diff --git a/ports/devel/gdb/dragonfly/patch-bfd_config.bfd b/ports/devel/gdb/dragonfly/patch-bfd_config.bfd index fbed2020392e..03e5911bd195 100644 --- a/ports/devel/gdb/dragonfly/patch-bfd_config.bfd +++ b/ports/devel/gdb/dragonfly/patch-bfd_config.bfd @@ -1,11 +1,11 @@ ---- bfd/config.bfd.orig 2019-05-11 18:19:02 UTC +--- bfd/config.bfd.orig 2023-05-27 09:46:46 UTC +++ bfd/config.bfd -@@ -679,7 +679,7 @@ case "${targ}" in +@@ -693,7 +693,7 @@ case "${targ}" in ;; x86_64-*-dragonfly*) targ_defvec=x86_64_elf64_vec -- targ_selvecs="i386_elf32_vec iamcu_elf32_vec l1om_elf64_vec k1om_elf64_vec" -+ targ_selvecs="i386_elf32_vec iamcu_elf32_vec l1om_elf64_vec k1om_elf64_vec x86_64_pei_vec" +- targ_selvecs="i386_elf32_vec iamcu_elf32_vec" ++ targ_selvecs="i386_elf32_vec iamcu_elf32_vec x86_64_pei_vec" want64=true ;; x86_64-*-freebsd* | x86_64-*-kfreebsd*-gnu) diff --git a/ports/devel/gdb/dragonfly/patch-gdb_amd64-tdep.h b/ports/devel/gdb/dragonfly/patch-gdb_amd64-tdep.h index bd29f153eda7..af35342c6ac6 100644 --- a/ports/devel/gdb/dragonfly/patch-gdb_amd64-tdep.h +++ b/ports/devel/gdb/dragonfly/patch-gdb_amd64-tdep.h @@ -1,14 +1,12 @@ ---- gdb/amd64-tdep.h.orig 2018-09-05 07:27:13 UTC +--- gdb/amd64-tdep.h.orig 2023-05-27 09:46:46 UTC +++ gdb/amd64-tdep.h -@@ -145,8 +145,8 @@ extern int amd64nbsd_r_reg_offset[]; +@@ -144,4 +144,9 @@ extern int amd64nbsd_r_reg_offset[]; + /* Variables exported from amd64-obsd-tdep.c. */ extern int amd64obsd_r_reg_offset[]; - /* Variables exported from amd64-fbsd-tdep.c. */ --extern CORE_ADDR amd64fbsd_sigtramp_start_addr; --extern CORE_ADDR amd64fbsd_sigtramp_end_addr; --extern int amd64fbsd_sc_reg_offset[]; ++/* Variables exported from amd64-dfly-tdep.c. */ +extern CORE_ADDR amd64dfly_sigtramp_start_addr; +extern CORE_ADDR amd64dfly_sigtramp_end_addr; +extern int amd64dfly_sc_reg_offset[]; - ++ #endif /* amd64-tdep.h */ diff --git a/ports/devel/gdb/dragonfly/patch-gdb_i386-tdep.h b/ports/devel/gdb/dragonfly/patch-gdb_i386-tdep.h index 870aa02063d0..3eba19892cd4 100644 --- a/ports/devel/gdb/dragonfly/patch-gdb_i386-tdep.h +++ b/ports/devel/gdb/dragonfly/patch-gdb_i386-tdep.h @@ -1,17 +1,13 @@ ---- gdb/i386-tdep.h.orig 2021-10-29 19:54:52.227305000 +0200 -+++ gdb/i386-tdep.h 2021-10-29 19:56:13.315464000 +0200 -@@ -472,12 +472,11 @@ +--- gdb/i386-tdep.h.orig 2023-05-27 09:46:46 UTC ++++ gdb/i386-tdep.h +@@ -472,8 +472,11 @@ extern int i386_mpx_enabled (void); /* Functions and variables exported from i386-bsd-tdep.c. */ extern void i386bsd_init_abi (struct gdbarch_info, struct gdbarch *); --extern CORE_ADDR i386fbsd_sigtramp_start_addr; --extern CORE_ADDR i386fbsd_sigtramp_end_addr; +extern CORE_ADDR i386dfly_sigtramp_start_addr; +extern CORE_ADDR i386dfly_sigtramp_end_addr; extern CORE_ADDR i386obsd_sigtramp_start_addr; extern CORE_ADDR i386obsd_sigtramp_end_addr; --extern int i386fbsd4_sc_reg_offset[]; --extern int i386fbsd_sc_reg_offset[]; +extern int i386dfly_sc_reg_offset[]; extern int i386obsd_sc_reg_offset[]; extern int i386bsd_sc_reg_offset[];