1 # Buildsheet autogenerated by ravenadm tool -- Do not edit.
7 SDESC[standard]= GNU debugger
8 HOMEPAGE= http://www.gnu.org/software/gdb/
13 DISTFILE[1]= gdb-10.1.tar.xz:main
15 SPKGS[standard]= single
17 OPTIONS_AVAILABLE= none
18 OPTIONS_STANDARD= none
22 BUILDRUN_DEPENDS= source-highlight:primary:standard
24 USES= cpe iconv gmake libtool readline pkgconfig makeinfo
27 EXTRACT_HEAD[1]= {{TAR}} -xf
28 EXTRACT_TAIL[1]= --exclude dejagnu --exclude expect --exclude sim --exclude texinfo --exclude intl --exclude readline
30 LICENSE= GPLv3+:single
31 LICENSE_TERMS= single:{{WRKDIR}}/TERMS
32 LICENSE_FILE= GPLv3+:{{WRKSRC}}/COPYING
33 LICENSE_AWK= TERMS:"^\#include"
34 LICENSE_SOURCE= TERMS:{{WRKSRC}}/gdb/gdb.c
38 FPC_EQUIVALENT= devel/gdb
41 CONFIGURE_OUTSOURCE= yes
42 CONFIGURE_ARGS= --program-suffix=101
46 --disable-build-with-cxx
47 --with-gdb-datadir={{PREFIX}}/share/gdb101
48 {{ICONV_CONFIGURE_ARG}}
49 --with-system-readline
51 --with-libexpat-prefix={{LOCALBASE}}
52 --without-libunwind-ia64
53 --with-python={{PYTHON_CMD}}
54 --with-source-highlight
55 CONFIGURE_ENV= CONFIGURED_M4=m4
56 CONFIGURED_BISON=byacc
60 CFLAGS= -DRL_NO_COMPAT
61 -D__STDC_CONSTANT_MACROS
67 ${REINPLACE_CMD} -e 's|$$| [GDB v10.1 for ${OPSYS}]|' \
68 ${WRKSRC}/gdb/version.in
69 # remove leftover readline removed garbage
70 ${REINPLACE_CMD} -e 's|..READLINE.*user.texi||' \
71 ${WRKSRC}/gdb/doc/Makefile.in
74 ${CP} ${OPSYSDIR}/dfly-tdep.* ${WRKSRC}/gdb/
75 ${CP} ${OPSYSDIR}/dfly-nat.* ${WRKSRC}/gdb/
76 ${CP} ${OPSYSDIR}/i386* ${WRKSRC}/gdb/
77 ${CP} ${OPSYSDIR}/amd64* ${WRKSRC}/gdb/
80 ${INSTALL_PROGRAM} ${INSTALL_WRKSRC}/gdb/gdb \
81 ${STAGEDIR}${PREFIX}/bin/gdb101
82 ${INSTALL_MAN} ${WRKSRC}/gdb/doc/gdb.1 \
83 ${STAGEDIR}${MAN1PREFIX}/man/man1/gdb101.1
84 (cd ${INSTALL_WRKSRC}/gdb/data-directory ; \
85 ${SETENV} ${MAKE_ENV} ${MAKE_CMD} ${MAKE_ARGS} install-syscalls )
86 ${LN} -sf gdb101 ${STAGEDIR}${PREFIX}/bin/gdbtui101
87 ${LN} -sf gdb101 ${STAGEDIR}${PREFIX}/bin/gdb
88 (cd ${INSTALL_WRKSRC}/gdb && ${SETENV} ${MAKE_ENV} \
89 ${MAKE_CMD} ${MAKE_ARGS} install-python )
90 (cd ${INSTALL_WRKSRC}/gdb/data-directory && ${SETENV} ${MAKE_ENV} \
91 ${MAKE_CMD} ${MAKE_ARGS} install-python )
92 . for f in gdb gdb/command gdb/function gdb/printer
93 (cd ${STAGEDIR}${PREFIX}/share/gdb101/python/${f} ; ${CHMOD} 644 *.py* )
96 [FILE:284:descriptions/desc.single]
97 GDB is a source-level debugger for Ada, C, C++, Objective-C, Pascal and
98 many other languages. GDB can target (i.e., debug programs running on)
99 more than a dozen different processor architectures, and GDB itself can
100 run on most popular GNU/Linux, Unix and Microsoft Windows variants.
104 f82f1eceeec14a3afa2de8d9b0d3c91d5a3820e23e0a01bbb70ef9f0276b62c0 21507112 gdb-10.1.tar.xz
107 [FILE:831:manifests/plist.single]
112 share/gdb%%VER%%/python/gdb/
122 share/gdb%%VER%%/python/gdb/command/
131 share/gdb%%VER%%/python/gdb/function/
136 share/gdb%%VER%%/python/gdb/printer/
139 share/gdb%%VER%%/syscalls/
156 share/man/man1/gdb%%VER%%.1.gz
159 [FILE:1057:patches/patch-gdb_amd64-bsd-nat.c]
160 --- gdb/amd64-bsd-nat.c.orig 2020-09-13 02:33:41 UTC
161 +++ gdb/amd64-bsd-nat.c
163 #include <sys/types.h>
164 #include <sys/ptrace.h>
165 #include <machine/reg.h>
166 +#include <machine/psl.h>
168 #include "amd64-tdep.h"
169 #include "amd64-nat.h"
170 @@ -142,12 +143,19 @@ amd64bsd_store_inferior_registers (struc
171 if (regnum == -1 || amd64_native_gregset_supplies_p (gdbarch, regnum))
174 + register_t old_rflags;
176 if (gdb_ptrace (PT_GETREGS, ptid, (PTRACE_TYPE_ARG3) ®s, 0) == -1)
177 perror_with_name (_("Couldn't get registers"));
179 + old_rflags = regs.r_rflags;
180 amd64_collect_native_gregset (regcache, ®s, regnum);
182 + /* This is a workaround about the PSL_USERCHANGE posix limitation. */
183 + if ((regs.r_rflags ^ old_rflags ) & ~PSL_USERCHANGE)
185 + regs.r_rflags ^= (regs.r_rflags ^ old_rflags ) & ~PSL_USERCHANGE;
187 if (gdb_ptrace (PT_SETREGS, ptid, (PTRACE_TYPE_ARG3) ®s, 0) == -1)
188 perror_with_name (_("Couldn't write registers"));
192 [FILE:312:patches/patch-gdb_compile_compile-loc2c.c]
193 --- gdb/compile/compile-loc2c.c.orig 2020-09-13 02:33:41 UTC
194 +++ gdb/compile/compile-loc2c.c
195 @@ -660,6 +660,7 @@ do_compile_dwarf_expr_to_c (int indent,
196 uint64_t uoffset, reg;
200 print_spaces (indent - 2, stream);
201 if (info[op_ptr - base].label)
205 [FILE:717:patches/patch-gdb_fbsd-nat.c]
206 --- gdb/fbsd-nat.c.orig 2020-10-24 04:23:02 UTC
208 @@ -1176,6 +1176,14 @@ fbsd_nat_target::resume (ptid_t ptid, in
209 /* If ptid is a specific LWP, suspend all other LWPs in the process. */
210 inferior *inf = find_inferior_ptid (this, ptid);
212 +#ifndef PT_LWP_EVENTS
213 + /* When LWP events are not supported, a new thread might already be
214 + running that has not yet reported an event when GDB wishes to
215 + only run a single thread. Force an update of the thread list
216 + to ensure that any such threads are suspended before the process
218 + fbsd_add_threads (ptid.pid ());
220 for (thread_info *tp : inf->non_exited_threads ())
225 [FILE:923:patches/patch-gdb_gdb__wchar.h]
226 diff --git gdb/gdb_wchar.h gdb/gdb_wchar.h
227 index 868fe04..1311080 100644
228 --- gdb/gdb_wchar.h.orig 2020-09-13 02:33:41 UTC
232 #if defined (HAVE_ICONV) && defined (HAVE_BTOWC) \
233 && (defined (__STDC_ISO_10646__) \
234 - || (defined (_LIBICONV_VERSION) && _LIBICONV_VERSION >= 0x108))
235 + || (!defined (LIBICONV_PLUG) && defined (_LIBICONV_VERSION) && _LIBICONV_VERSION >= 0x108))
237 typedef wchar_t gdb_wchar_t;
238 typedef wint_t gdb_wint_t;
239 @@ -82,7 +82,7 @@ typedef wint_t gdb_wint_t;
240 #define INTERMEDIATE_ENCODING intermediate_encoding ()
241 const char *intermediate_encoding (void);
243 -#elif defined (_LIBICONV_VERSION) && _LIBICONV_VERSION >= 0x108
244 +#elif !defined (LIBICONV_PLUG) && defined (_LIBICONV_VERSION) && _LIBICONV_VERSION >= 0x108
245 #define INTERMEDIATE_ENCODING "wchar_t"
247 /* This shouldn't happen, because the earlier #if should have filtered
250 [FILE:801:patches/patch-gdb_i386-fbsd-nat.c]
251 --- gdb/i386-fbsd-nat.c.orig 2020-09-13 02:33:41 UTC
252 +++ gdb/i386-fbsd-nat.c
253 @@ -43,8 +43,6 @@ public:
254 const struct target_desc *read_description () override;
257 - void resume (ptid_t, int, enum gdb_signal) override;
259 #if defined(HAVE_PT_GETDBREGS) && defined(USE_SIGTRAP_SIGINFO)
260 bool supports_stopped_by_hw_breakpoint () override;
262 @@ -52,6 +50,7 @@ public:
264 static i386_fbsd_nat_target the_i386_fbsd_nat_target;
267 /* Resume execution of the inferior process. If STEP is nonzero,
268 single-step it. If SIGNAL is nonzero, give it that signal. */
270 @@ -98,6 +97,7 @@ i386_fbsd_nat_target::resume (ptid_t pti
271 gdb_signal_to_host (signal)) == -1)
272 perror_with_name (("ptrace"));
277 /* Support for debugging kernel virtual memory images. */
280 [FILE:452:patches/patch-gdb_python_python-config.py]
281 --- gdb/python/python-config.py.orig 2020-09-13 02:33:41 UTC
282 +++ gdb/python/python-config.py
283 @@ -59,6 +59,8 @@ for opt in opt_flags:
285 elif opt in ('--libs', '--ldflags'):
286 libs = ['-lpython' + pyver + abiflags]
287 + if getvar('LDFLAGS') is not None:
288 + libs.extend(getvar('LDFLAGS').split())
289 if getvar('LIBS') is not None:
290 libs.extend(getvar('LIBS').split())
291 if getvar('SYSLIBS') is not None:
294 [FILE:247:patches/patch-gdb_s390-tdep.c]
295 --- gdb/s390-tdep.c.orig 2020-10-24 04:23:02 UTC
298 #include "trad-frame.h"
305 #include "features/s390-linux32.c"
306 #include "features/s390x-linux64.c"
310 [FILE:580:patches/patch-gdbsupport_common-defs.h]
311 --- gdbsupport/common-defs.h.orig 2020-09-13 02:33:41 UTC
312 +++ gdbsupport/common-defs.h
315 Must do this before including any system header, since other system
316 headers may include stdint.h/inttypes.h. */
317 +#ifndef __STDC_CONSTANT_MACROS
318 #define __STDC_CONSTANT_MACROS 1
320 +#ifndef __STDC_LIMIT_MACROS
321 #define __STDC_LIMIT_MACROS 1
323 +#ifndef __STDC_FORMAT_MACROS
324 #define __STDC_FORMAT_MACROS 1
327 /* Some distros enable _FORTIFY_SOURCE by default, which on occasion
328 has caused build failures with -Wunused-result when a patch is
331 [FILE:429:patches/patch-gnulib_import_stddef.in.h]
332 --- gnulib/import/stddef.in.h.orig 2020-09-13 02:33:41 UTC
333 +++ gnulib/import/stddef.in.h
335 #if defined _MSC_VER && defined __cplusplus
338 -# if ! (@HAVE_MAX_ALIGN_T@ || defined _GCC_MAX_ALIGN_T)
340 # if !GNULIB_defined_max_align_t
341 /* On the x86, the maximum storage alignment of double, long, etc. is 4,
342 but GCC's C11 ABI for x86 says that max_align_t has an alignment of 8,
345 [FILE:601:patches/patch-libiberty-basename]
346 --- include/libiberty.h.orig 2020-09-13 02:33:41 UTC
347 +++ include/libiberty.h
348 @@ -109,7 +109,7 @@ extern int countargv (char * const *);
349 || defined (__FreeBSD__) || defined (__OpenBSD__) || defined (__NetBSD__) \
350 || defined (__CYGWIN__) || defined (__CYGWIN32__) || defined (__MINGW32__) \
351 || defined (__DragonFly__) || defined (HAVE_DECL_BASENAME)
352 -extern char *basename (const char *) ATTRIBUTE_RETURNS_NONNULL ATTRIBUTE_NONNULL(1);
355 /* Do not allow basename to be used if there is no prototype seen. We
356 either need to use the above prototype or have one from
359 [FILE:505:patches/patch-unified]
360 --- gdb/gdb.c.orig 2020-09-13 02:33:41 UTC
362 @@ -28,6 +28,12 @@ main (int argc, char **argv)
363 memset (&args, 0, sizeof args);
366 - args.interpreter_p = INTERP_CONSOLE;
367 + if (strncmp(basename(argv[0]), "insight", 7) == 0) {
368 + args.interpreter_p = "insight";
369 + } else if (strncmp(basename(argv[0]), "gdbtui", 6) == 0) {
370 + args.interpreter_p = INTERP_TUI;
372 + args.interpreter_p = INTERP_CONSOLE;
374 return gdb_main (&args);
378 [FILE:9620:dragonfly/amd64-dfly-nat.c]
379 /* Native-dependent code for DragonFly/amd64.
381 Copyright (C) 2003-2019 Free Software Foundation, Inc.
383 This file is part of GDB.
385 This program is free software; you can redistribute it and/or modify
386 it under the terms of the GNU General Public License as published by
387 the Free Software Foundation; either version 3 of the License, or
388 (at your option) any later version.
390 This program is distributed in the hope that it will be useful,
391 but WITHOUT ANY WARRANTY; without even the implied warranty of
392 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
393 GNU General Public License for more details.
395 You should have received a copy of the GNU General Public License
396 along with this program. If not, see <http://www.gnu.org/licenses/>. */
399 #include "inferior.h"
400 #include "regcache.h"
406 #include <sys/types.h>
407 #include <sys/procfs.h>
408 #include <sys/ptrace.h>
409 #include <sys/sysctl.h>
410 #include <sys/user.h>
411 #include <machine/reg.h>
412 #include <machine/segments.h>
414 #include "dfly-nat.h"
415 #include "amd64-tdep.h"
416 #include "amd64-nat.h"
417 #include "amd64-bsd-nat.h"
419 #include "gdbsupport/x86-xstate.h"
422 class amd64_dfly_nat_target final
423 : public amd64_bsd_nat_target<dfly_nat_target>
426 /* Add some extra features to the common *BSD/amd64 target. */
427 const struct target_desc *read_description () override;
429 #if defined(HAVE_PT_GETDBREGS) && defined(USE_SIGTRAP_SIGINFO)
430 bool supports_stopped_by_hw_breakpoint () override;
434 static amd64_dfly_nat_target the_amd64_dfly_nat_target;
436 /* Offset in `struct reg' where MEMBER is stored. */
437 #define REG_OFFSET(member) offsetof (struct reg, member)
439 /* At amd64dfly64_r_reg_offset[REGNUM] you'll find the offset in
440 `struct reg' location where the GDB register REGNUM is stored.
441 Unsupported registers are marked with `-1'. */
442 static int amd64dfly64_r_reg_offset[] =
461 REG_OFFSET (r_rflags),
471 /* Mapping between the general-purpose registers in DragonFly/amd64
472 `struct reg' format and GDB's register cache layout for
475 Note that most DragonFly/amd64 registers are 64-bit, while the
476 DragonFly/x86 registers are all 32-bit, but since we're
477 little-endian we get away with that. */
479 /* From <machine/reg.h>. */
480 static int amd64dfly32_r_reg_offset[I386_NUM_GREGS] =
482 14 * 8, 13 * 8, /* %eax, %ecx */
483 12 * 8, 11 * 8, /* %edx, %ebx */
484 20 * 8, 10 * 8, /* %esp, %ebp */
485 9 * 8, 8 * 8, /* %esi, %edi */
486 17 * 8, 19 * 8, /* %eip, %eflags */
487 18 * 8, 21 * 8, /* %cs, %ss */
488 -1, -1, -1, -1 /* %ds, %es, %fs, %gs */
492 #ifdef DFLY_PCB_SUPPLY
493 /* Transfering the registers between GDB, inferiors and core files. */
495 /* Fill GDB's register array with the general-purpose register values
499 supply_gregset (struct regcache *regcache, const gregset_t *gregsetp)
501 amd64_supply_native_gregset (regcache, gregsetp, -1);
504 /* Fill register REGNUM (if it is a general-purpose register) in
505 *GREGSETPS with the value in GDB's register array. If REGNUM is -1,
506 do this for all registers. */
509 fill_gregset (const struct regcache *regcache, gdb_gregset_t *gregsetp, int regnum)
511 amd64_collect_native_gregset (regcache, gregsetp, regnum);
514 /* Fill GDB's register array with the floating-point register values
518 supply_fpregset (struct regcache *regcache, const fpregset_t *fpregsetp)
520 amd64_supply_fxsave (regcache, -1, fpregsetp);
523 /* Fill register REGNUM (if it is a floating-point register) in
524 *FPREGSETP with the value in GDB's register array. If REGNUM is -1,
525 do this for all registers. */
528 fill_fpregset (const struct regcache *regcache, gdb_fpregset_t *fpregsetp, int regnum)
530 amd64_collect_fxsave (regcache, regnum, fpregsetp);
533 /* Support for debugging kernel virtual memory images. */
535 #include <sys/types.h>
536 #include <machine/pcb.h>
537 #include <osreldate.h>
542 amd64dfly_supply_pcb (struct regcache *regcache, struct pcb *pcb)
544 /* The following is true for FreeBSD 5.2:
546 The pcb contains %rip, %rbx, %rsp, %rbp, %r12, %r13, %r14, %r15,
547 %ds, %es, %fs and %gs. This accounts for all callee-saved
548 registers specified by the psABI and then some. Here %esp
549 contains the stack pointer at the point just after the call to
550 cpu_switch(). From this information we reconstruct the register
551 state as it would like when we just returned from cpu_switch(). */
553 /* The stack pointer shouldn't be zero. */
554 if (pcb->pcb_rsp == 0)
558 regcache->raw_supply (AMD64_RIP_REGNUM, &pcb->pcb_rip);
559 regcache->raw_supply (AMD64_RBX_REGNUM, &pcb->pcb_rbx);
560 regcache->raw_supply (AMD64_RSP_REGNUM, &pcb->pcb_rsp);
561 regcache->raw_supply (AMD64_RBP_REGNUM, &pcb->pcb_rbp);
562 regcache->raw_supply (12, &pcb->pcb_r12);
563 regcache->raw_supply (13, &pcb->pcb_r13);
564 regcache->raw_supply (14, &pcb->pcb_r14);
565 regcache->raw_supply (15, &pcb->pcb_r15);
569 #endif /* DFLY_PCB_SUPPLY */
572 /* Implement the read_description method. */
574 const struct target_desc *
575 amd64_dfly_nat_target::read_description ()
577 #ifdef PT_GETXSTATE_INFO
578 static int xsave_probed;
579 static uint64_t xcr0;
584 if (ptrace (PT_GETREGS, inferior_ptid.pid (),
585 (PTRACE_TYPE_ARG3) ®s, 0) == -1)
586 perror_with_name (_("Couldn't get registers"));
587 is64 = (regs.r_cs == GSEL (GUCODE_SEL, SEL_UPL));
588 #ifdef PT_GETXSTATE_INFO
591 struct ptrace_xstate_info info;
593 if (ptrace (PT_GETXSTATE_INFO, inferior_ptid.pid (),
594 (PTRACE_TYPE_ARG3) &info, sizeof (info)) == 0)
596 x86bsd_xsave_len = info.xsave_len;
597 xcr0 = info.xsave_mask;
602 if (x86bsd_xsave_len != 0)
605 return amd64_target_description (xcr0, true);
607 return i386_target_description (xcr0, true);
611 return amd64_target_description (X86_XSTATE_SSE_MASK, true);
613 return i386_target_description (X86_XSTATE_SSE_MASK, true);
616 #if defined(HAVE_PT_GETDBREGS) && defined(USE_SIGTRAP_SIGINFO)
617 /* Implement the supports_stopped_by_hw_breakpoints method. */
620 amd64_dfly_nat_target::supports_stopped_by_hw_breakpoint ()
627 _initialize_amd64dfly_nat (void)
631 amd64_native_gregset32_reg_offset = amd64dfly32_r_reg_offset;
632 amd64_native_gregset64_reg_offset = amd64dfly64_r_reg_offset;
634 add_inf_child_target (&the_amd64_dfly_nat_target);
636 #ifdef DFLY_PCB_SUPPLY
637 /* Support debugging kernel virtual memory images. */
638 bsd_kvm_add_target (amd64dfly_supply_pcb);
641 /* To support the recognition of signal handlers, i386-bsd-tdep.c
642 hardcodes some constants. Inclusion of this file means that we
643 are compiling a native debugger, which means that we can use the
644 system header files and sysctl(3) to get at the relevant
647 #define SC_REG_OFFSET amd64dfly_sc_reg_offset
649 /* We only check the program counter, stack pointer and frame
650 pointer since these members of `struct sigcontext' are essential
651 for providing backtraces. */
653 #define SC_RIP_OFFSET SC_REG_OFFSET[AMD64_RIP_REGNUM]
654 #define SC_RSP_OFFSET SC_REG_OFFSET[AMD64_RSP_REGNUM]
655 #define SC_RBP_OFFSET SC_REG_OFFSET[AMD64_RBP_REGNUM]
657 /* Override the default value for the offset of the program counter
658 in the sigcontext structure. */
659 offset = offsetof (struct sigcontext, sc_rip);
661 if (SC_RIP_OFFSET != offset)
664 offsetof (struct sigcontext, sc_rip) yields %d instead of %d.\n\
665 Please report this to <bug-gdb@gnu.org>."),
666 offset, SC_RIP_OFFSET);
669 SC_RIP_OFFSET = offset;
671 /* Likewise for the stack pointer. */
672 offset = offsetof (struct sigcontext, sc_rsp);
674 if (SC_RSP_OFFSET != offset)
677 offsetof (struct sigcontext, sc_rsp) yields %d instead of %d.\n\
678 Please report this to <bug-gdb@gnu.org>."),
679 offset, SC_RSP_OFFSET);
682 SC_RSP_OFFSET = offset;
684 /* And the frame pointer. */
685 offset = offsetof (struct sigcontext, sc_rbp);
687 if (SC_RBP_OFFSET != offset)
690 offsetof (struct sigcontext, sc_rbp) yields %d instead of %d.\n\
691 Please report this to <bug-gdb@gnu.org>."),
692 offset, SC_RBP_OFFSET);
695 SC_RBP_OFFSET = offset;
697 #ifdef KERN_PROC_SIGTRAMP
699 struct kinfo_sigtramp kst = {0};
700 size_t len = sizeof (kst);
701 int mib[3] = { CTL_KERN, KERN_PROC, KERN_PROC_SIGTRAMP };
702 if (sysctl (mib, 3, &kst, &len, NULL, 0) == 0)
704 amd64dfly_sigtramp_start_addr = (uintptr_t) kst.ksigtramp_start;
705 amd64dfly_sigtramp_end_addr = (uintptr_t) kst.ksigtramp_end;
715 mib[1] = KERN_PS_STRINGS;
716 len = sizeof (ps_strings);
717 if (sysctl (mib, 2, &ps_strings, &len, NULL, 0) == 0)
719 amd64dfly_sigtramp_start_addr = ps_strings - 32;
720 amd64dfly_sigtramp_end_addr = ps_strings;
727 [FILE:6089:dragonfly/amd64-dfly-tdep.c]
728 /* Target-dependent code for DragonFly/amd64.
730 Copyright (C) 2003-2019 Free Software Foundation, Inc.
732 This file is part of GDB.
734 This program is free software; you can redistribute it and/or modify
735 it under the terms of the GNU General Public License as published by
736 the Free Software Foundation; either version 3 of the License, or
737 (at your option) any later version.
739 This program is distributed in the hope that it will be useful,
740 but WITHOUT ANY WARRANTY; without even the implied warranty of
741 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
742 GNU General Public License for more details.
744 You should have received a copy of the GNU General Public License
745 along with this program. If not, see <http://www.gnu.org/licenses/>. */
748 #include "arch-utils.h"
751 #include "regcache.h"
754 #include "gdbsupport/x86-xstate.h"
758 #include "amd64-tdep.h"
759 #include "dfly-tdep.h"
760 #include "solib-svr4.h"
762 /* Support for signal handlers. */
765 /* Return whether THIS_FRAME corresponds to a FreeBSD sigtramp
768 static const gdb_byte amd64fbsd_sigtramp_code[] =
770 0x48, 0x8d, 0x7c, 0x24, 0x10, /* lea SIGF_UC(%rsp),%rdi */
771 0x6a, 0x00, /* pushq $0 */
772 0x48, 0xc7, 0xc0, 0xa1, 0x01, 0x00, 0x00,
773 /* movq $SYS_sigreturn,%rax */
774 0x0f, 0x05 /* syscall */
778 amd64fbsd_sigtramp_p (struct frame_info *this_frame)
780 CORE_ADDR pc = get_frame_pc (this_frame);
781 gdb_byte buf[sizeof amd64fbsd_sigtramp_code];
783 if (!safe_frame_unwind_memory (this_frame, pc, buf, sizeof buf))
785 if (memcmp (buf, amd64fbsd_sigtramp_code, sizeof amd64fbsd_sigtramp_code)
793 /* Assuming THIS_FRAME is for a BSD sigtramp routine, return the
794 address of the associated sigcontext structure. */
797 amd64dfly_sigcontext_addr (struct frame_info *this_frame)
799 struct gdbarch *gdbarch = get_frame_arch (this_frame);
800 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
804 /* The `struct sigcontext' (which really is an `ucontext_t' on
805 DragonFly/amd64) lives at a fixed offset in the signal frame. See
806 <machine/sigframe.h>. */
807 get_frame_register (this_frame, AMD64_RSP_REGNUM, buf);
808 sp = extract_unsigned_integer (buf, 8, byte_order);
812 /* Mapping between the general-purpose registers in `struct reg'
813 format and GDB's register cache layout.
815 Note that some registers are 32-bit, but since we're little-endian
816 we get away with that. */
818 /* From <machine/reg.h>. */
819 static int amd64dfly_r_reg_offset[] =
836 14 * 8, /* ... %r15 */
838 22 * 8, /* %eflags */
847 /* Location of the signal trampoline. */
848 CORE_ADDR amd64dfly_sigtramp_start_addr = 0x7fffffffffc0ULL;
849 CORE_ADDR amd64dfly_sigtramp_end_addr = 0x7fffffffffe0ULL;
851 /* From <machine/signal.h>. */
852 int amd64dfly_sc_reg_offset[] =
854 24 + 6 * 8, /* %rax */
855 24 + 7 * 8, /* %rbx */
856 24 + 3 * 8, /* %rcx */
857 24 + 2 * 8, /* %rdx */
858 24 + 1 * 8, /* %rsi */
859 24 + 0 * 8, /* %rdi */
860 24 + 8 * 8, /* %rbp */
861 24 + 23 * 8, /* %rsp */
862 24 + 4 * 8, /* %r8 ... */
869 24 + 14 * 8, /* ... %r15 */
870 24 + 20 * 8, /* %rip */
871 24 + 22 * 8, /* %eflags */
872 24 + 21 * 8, /* %cs */
873 24 + 24 * 8, /* %ss */
880 /* From /usr/src/lib/libc/amd64/gen/_setjmp.S. */
881 static int amd64dfly_jmp_buf_reg_offset[] =
895 4 * 8, /* %r12 ... */
898 7 * 8, /* ... %r15 */
903 amd64dfly_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
905 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
907 /* Generic DragonFly support. */
908 dfly_init_abi (info, gdbarch);
910 /* Obviously DragonFly is BSD-based. */
911 i386bsd_init_abi (info, gdbarch);
913 tdep->gregset_reg_offset = amd64dfly_r_reg_offset;
914 tdep->gregset_num_regs = ARRAY_SIZE (amd64dfly_r_reg_offset);
915 tdep->sizeof_gregset = 25 * 8;
917 amd64_init_abi (info, gdbarch,
918 amd64_target_description (X86_XSTATE_SSE_MASK, true));
921 tdep->sigtramp_p = amd64dfly_sigtramp_p;
923 tdep->sigtramp_start = amd64dfly_sigtramp_start_addr;
924 tdep->sigtramp_end = amd64dfly_sigtramp_end_addr;
925 tdep->sigcontext_addr = amd64dfly_sigcontext_addr;
926 tdep->sc_reg_offset = amd64dfly_sc_reg_offset;
927 tdep->sc_num_regs = ARRAY_SIZE (amd64dfly_sc_reg_offset);
930 tdep->xsave_xcr0_offset = I386_DFLY_XSAVE_XCR0_OFFSET;
932 /* Iterate over core file register note sections. */
933 set_gdbarch_iterate_over_regset_sections
934 (gdbarch, amd64dfly_iterate_over_regset_sections);
936 set_gdbarch_core_read_description (gdbarch,
937 amd64dfly_core_read_description);
940 /* FreeBSD uses SVR4-style shared libraries. */
941 set_solib_svr4_fetch_link_map_offsets
942 (gdbarch, svr4_lp64_fetch_link_map_offsets);
944 set_gdbarch_fetch_tls_load_module_address (gdbarch,
945 svr4_fetch_objfile_link_map);
947 set_gdbarch_get_thread_local_address (gdbarch,
948 amd64fbsd_get_thread_local_address);
953 _initialize_amd64dfly_tdep (void)
955 gdbarch_register_osabi (bfd_arch_i386, bfd_mach_x86_64,
956 GDB_OSABI_DRAGONFLY, amd64dfly_init_abi);
960 [FILE:4794:dragonfly/dfly-nat.c]
961 /* Native-dependent code for DragonFly.
963 Copyright (C) 2002-2016 Free Software Foundation, Inc.
965 This file is part of GDB.
967 This program is free software; you can redistribute it and/or modify
968 it under the terms of the GNU General Public License as published by
969 the Free Software Foundation; either version 3 of the License, or
970 (at your option) any later version.
972 This program is distributed in the hope that it will be useful,
973 but WITHOUT ANY WARRANTY; without even the implied warranty of
974 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
975 GNU General Public License for more details.
977 You should have received a copy of the GNU General Public License
978 along with this program. If not, see <http://www.gnu.org/licenses/>. */
981 #include "gdbsupport/byte-vector.h"
983 #include "inferior.h"
984 #include "regcache.h"
988 #include "gdbthread.h"
989 #include "gdbsupport/gdb_wait.h"
990 #include "inf-ptrace.h"
991 #include <sys/types.h>
992 #include <sys/procfs.h>
993 #include <sys/ptrace.h>
994 #include <sys/signal.h>
995 #include <sys/sysctl.h>
996 #include <sys/user.h>
997 #ifdef HAVE_KINFO_GETVMMAP
1000 #include "gdbsupport/filestuff.h"
1002 #include "elf-bfd.h"
1003 #include "dfly-nat.h"
1004 #include "dfly-tdep.h"
1008 /* Return the name of a file that can be opened to get the symbols for
1009 the child process identified by PID. */
1012 dfly_nat_target::pid_to_exec_file (int pid)
1015 static char buf[PATH_MAX];
1016 char name[PATH_MAX];
1018 #ifdef KERN_PROC_PATHNAME
1024 mib[2] = KERN_PROC_PATHNAME;
1026 buflen = sizeof buf;
1027 if (sysctl (mib, 4, buf, &buflen, NULL, 0) == 0)
1028 /* The kern.proc.pathname.<pid> sysctl returns a length of zero
1029 for processes without an associated executable such as kernel
1031 return buflen == 0 ? NULL : buf;
1034 xsnprintf (name, PATH_MAX, "/proc/%d/exe", pid);
1035 len = readlink (name, buf, PATH_MAX - 1);
1046 dfly_read_mapping (FILE *mapfile, unsigned long *start, unsigned long *end,
1049 /* FreeBSD 5.1-RELEASE uses a 256-byte buffer. */
1051 int resident, privateresident;
1055 /* As of FreeBSD 5.0-RELEASE, the layout is described in
1056 /usr/src/sys/fs/procfs/procfs_map.c. Somewhere in 5.1-CURRENT a
1057 new column was added to the procfs map. Therefore we can't use
1058 fscanf since we need to support older releases too. */
1059 if (fgets (buf, sizeof buf, mapfile) != NULL)
1060 ret = sscanf (buf, "%lx %lx %d %d %lx %s", start, end,
1061 &resident, &privateresident, &obj, protection);
1063 return (ret != 0 && ret != EOF);
1066 /* Iterate over all the memory regions in the current inferior,
1067 calling FUNC for each memory region. OBFD is passed as the last
1068 argument to FUNC. */
1071 dfly_nat_target::find_memory_regions (find_memory_region_ftype func,
1074 pid_t pid = inferior_ptid.pid ();
1075 unsigned long start, end, size;
1077 int read, write, exec;
1079 std::string mapfilename = string_printf ("/proc/%ld/map", (long) pid);
1080 gdb_file_up mapfile (fopen (mapfilename.c_str (), "r"));
1081 if (mapfile == NULL)
1082 error (_("Couldn't open %s."), mapfilename.c_str ());
1085 fprintf_filtered (gdb_stdout,
1086 "Reading memory regions from %s\n", mapfilename.c_str ());
1088 /* Now iterate until end-of-file. */
1089 while (dfly_read_mapping (mapfile.get (), &start, &end, &protection[0]))
1093 read = (strchr (protection, 'r') != 0);
1094 write = (strchr (protection, 'w') != 0);
1095 exec = (strchr (protection, 'x') != 0);
1099 fprintf_filtered (gdb_stdout,
1100 "Save segment, %ld bytes at %s (%c%c%c)\n",
1101 size, paddress (target_gdbarch (), start),
1107 /* Invoke the callback function to create the corefile segment.
1108 Pass MODIFIED as true, we do not know the real modification state. */
1109 func (start, size, read, write, exec, 1, obfd);
1117 dfly_nat_add_target (struct target_ops *t)
1119 t->to_pid_to_exec_file = dfly_pid_to_exec_file;
1120 t->to_find_memory_regions = dfly_find_memory_regions;
1121 /* XXX: thread vfork support */
1126 /* Provide a prototype to silence -Wmissing-prototypes. */
1127 extern initialize_file_ftype _initialize_dfly_nat;
1130 _initialize_dfly_nat (void)
1132 /* XXX: todo add_setshow_boolean_cmd() */
1136 [FILE:1305:dragonfly/dfly-nat.h]
1137 /* Native-dependent code for DragonFly.
1139 Copyright (C) 2004-2019 Free Software Foundation, Inc.
1141 This file is part of GDB.
1143 This program is free software; you can redistribute it and/or modify
1144 it under the terms of the GNU General Public License as published by
1145 the Free Software Foundation; either version 3 of the License, or
1146 (at your option) any later version.
1148 This program is distributed in the hope that it will be useful,
1149 but WITHOUT ANY WARRANTY; without even the implied warranty of
1150 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1151 GNU General Public License for more details.
1153 You should have received a copy of the GNU General Public License
1154 along with this program. If not, see <http://www.gnu.org/licenses/>. */
1159 #include "inf-ptrace.h"
1160 #include <sys/user.h>
1162 /* A prototype DragonFly target. */
1164 class dfly_nat_target : public inf_ptrace_target
1167 char *pid_to_exec_file (int pid) override;
1169 int find_memory_regions (find_memory_region_ftype func, void *data) override;
1174 /* Register the customized DragonFly target. This should be used
1175 instead of calling add_target directly. */
1176 extern void dfly_nat_add_target (struct target_ops *);
1179 #endif /* dfly-nat.h */
1182 [FILE:59356:dragonfly/dfly-tdep.c]
1183 /* Target-dependent code for DragonFly, architecture-independent.
1185 Copyright (C) 2002-2019 Free Software Foundation, Inc.
1187 This file is part of GDB.
1189 This program is free software; you can redistribute it and/or modify
1190 it under the terms of the GNU General Public License as published by
1191 the Free Software Foundation; either version 3 of the License, or
1192 (at your option) any later version.
1194 This program is distributed in the hope that it will be useful,
1195 but WITHOUT ANY WARRANTY; without even the implied warranty of
1196 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1197 GNU General Public License for more details.
1199 You should have received a copy of the GNU General Public License
1200 along with this program. If not, see <http://www.gnu.org/licenses/>. */
1204 #include "gdbcore.h"
1205 #include "inferior.h"
1206 #include "regcache.h"
1208 #include "gdbthread.h"
1209 #include "objfiles.h"
1210 #include "xml-syscall.h"
1211 #include <sys/socket.h>
1212 #include <arpa/inet.h>
1214 #include "elf-bfd.h"
1215 #include "dfly-tdep.h"
1217 /* This enum is derived from FreeBSD's <sys/signal.h>. */
1221 DRAGONFLY_SIGHUP = 1,
1222 DRAGONFLY_SIGINT = 2,
1223 DRAGONFLY_SIGQUIT = 3,
1224 DRAGONFLY_SIGILL = 4,
1225 DRAGONFLY_SIGTRAP = 5,
1226 DRAGONFLY_SIGABRT = 6,
1227 DRAGONFLY_SIGEMT = 7,
1228 DRAGONFLY_SIGFPE = 8,
1229 DRAGONFLY_SIGKILL = 9,
1230 DRAGONFLY_SIGBUS = 10,
1231 DRAGONFLY_SIGSEGV = 11,
1232 DRAGONFLY_SIGSYS = 12,
1233 DRAGONFLY_SIGPIPE = 13,
1234 DRAGONFLY_SIGALRM = 14,
1235 DRAGONFLY_SIGTERM = 15,
1236 DRAGONFLY_SIGURG = 16,
1237 DRAGONFLY_SIGSTOP = 17,
1238 DRAGONFLY_SIGTSTP = 18,
1239 DRAGONFLY_SIGCONT = 19,
1240 DRAGONFLY_SIGCHLD = 20,
1241 DRAGONFLY_SIGTTIN = 21,
1242 DRAGONFLY_SIGTTOU = 22,
1243 DRAGONFLY_SIGIO = 23,
1244 DRAGONFLY_SIGXCPU = 24,
1245 DRAGONFLY_SIGXFSZ = 25,
1246 DRAGONFLY_SIGVTALRM = 26,
1247 DRAGONFLY_SIGPROF = 27,
1248 DRAGONFLY_SIGWINCH = 28,
1249 DRAGONFLY_SIGINFO = 29,
1250 DRAGONFLY_SIGUSR1 = 30,
1251 DRAGONFLY_SIGUSR2 = 31,
1252 DRAGONFLY_SIGTHR = 32,
1253 DRAGONFLY_SIGCKPT = 33,
1254 DRAGONFLY_SIGCKPTEXIT = 34,
1258 /* Flags in pl_flags. */
1259 #define PL_FLAG_SI 0x20 /* siginfo is valid */
1261 /* Sizes of siginfo_t. */
1262 #define SIZE64_SIGINFO_T 80
1263 #define SIZE32_SIGINFO_T 64
1265 /* Offsets in data structure used in NT_FREEBSD_PROCSTAT_VMMAP core
1266 dump notes. See <sys/user.h> for the definition of struct
1267 kinfo_vmentry. This data structure should have the same layout on
1270 Note that FreeBSD 7.0 used an older version of this structure
1271 (struct kinfo_ovmentry), but the NT_FREEBSD_PROCSTAT_VMMAP core
1272 dump note wasn't introduced until FreeBSD 9.2. As a result, the
1273 core dump note has always used the 7.1 and later structure
1276 #define KVE_STRUCTSIZE 0x0
1277 #define KVE_START 0x8
1278 #define KVE_END 0x10
1279 #define KVE_OFFSET 0x18
1280 #define KVE_FLAGS 0x2c
1281 #define KVE_PROTECTION 0x38
1282 #define KVE_PATH 0x88
1284 /* Flags in the 'kve_protection' field in struct kinfo_vmentry. These
1285 match the KVME_PROT_* constants in <sys/user.h>. */
1287 #define KINFO_VME_PROT_READ 0x00000001
1288 #define KINFO_VME_PROT_WRITE 0x00000002
1289 #define KINFO_VME_PROT_EXEC 0x00000004
1291 /* Flags in the 'kve_flags' field in struct kinfo_vmentry. These
1292 match the KVME_FLAG_* constants in <sys/user.h>. */
1294 #define KINFO_VME_FLAG_COW 0x00000001
1295 #define KINFO_VME_FLAG_NEEDS_COPY 0x00000002
1296 #define KINFO_VME_FLAG_NOCOREDUMP 0x00000004
1297 #define KINFO_VME_FLAG_SUPER 0x00000008
1298 #define KINFO_VME_FLAG_GROWS_UP 0x00000010
1299 #define KINFO_VME_FLAG_GROWS_DOWN 0x00000020
1301 /* Offsets in data structure used in NT_FREEBSD_PROCSTAT_FILES core
1302 dump notes. See <sys/user.h> for the definition of struct
1303 kinfo_file. This data structure should have the same layout on all
1306 Note that FreeBSD 7.0 used an older version of this structure
1307 (struct kinfo_ofile), but the NT_FREEBSD_PROCSTAT_FILES core dump
1308 note wasn't introduced until FreeBSD 9.2. As a result, the core
1309 dump note has always used the 7.1 and later structure format. */
1311 #define KF_STRUCTSIZE 0x0
1314 #define KF_FLAGS 0x10
1315 #define KF_OFFSET 0x18
1316 #define KF_VNODE_TYPE 0x20
1317 #define KF_SOCK_DOMAIN 0x24
1318 #define KF_SOCK_TYPE 0x28
1319 #define KF_SOCK_PROTOCOL 0x2c
1320 #define KF_SA_LOCAL 0x30
1321 #define KF_SA_PEER 0xb0
1322 #define KF_PATH 0x170
1324 /* Constants for the 'kf_type' field in struct kinfo_file. These
1325 match the KF_TYPE_* constants in <sys/user.h>. */
1327 #define KINFO_FILE_TYPE_VNODE 1
1328 #define KINFO_FILE_TYPE_SOCKET 2
1329 #define KINFO_FILE_TYPE_PIPE 3
1330 #define KINFO_FILE_TYPE_FIFO 4
1331 #define KINFO_FILE_TYPE_KQUEUE 5
1332 #define KINFO_FILE_TYPE_CRYPTO 6
1333 #define KINFO_FILE_TYPE_MQUEUE 7
1334 #define KINFO_FILE_TYPE_SHM 8
1335 #define KINFO_FILE_TYPE_SEM 9
1336 #define KINFO_FILE_TYPE_PTS 10
1337 #define KINFO_FILE_TYPE_PROCDESC 11
1339 /* Special values for the 'kf_fd' field in struct kinfo_file. These
1340 match the KF_FD_TYPE_* constants in <sys/user.h>. */
1342 #define KINFO_FILE_FD_TYPE_CWD -1
1343 #define KINFO_FILE_FD_TYPE_ROOT -2
1344 #define KINFO_FILE_FD_TYPE_JAIL -3
1345 #define KINFO_FILE_FD_TYPE_TRACE -4
1346 #define KINFO_FILE_FD_TYPE_TEXT -5
1347 #define KINFO_FILE_FD_TYPE_CTTY -6
1349 /* Flags in the 'kf_flags' field in struct kinfo_file. These match
1350 the KF_FLAG_* constants in <sys/user.h>. */
1352 #define KINFO_FILE_FLAG_READ 0x00000001
1353 #define KINFO_FILE_FLAG_WRITE 0x00000002
1354 #define KINFO_FILE_FLAG_APPEND 0x00000004
1355 #define KINFO_FILE_FLAG_ASYNC 0x00000008
1356 #define KINFO_FILE_FLAG_FSYNC 0x00000010
1357 #define KINFO_FILE_FLAG_NONBLOCK 0x00000020
1358 #define KINFO_FILE_FLAG_DIRECT 0x00000040
1359 #define KINFO_FILE_FLAG_HASLOCK 0x00000080
1360 #define KINFO_FILE_FLAG_EXEC 0x00004000
1362 /* Constants for the 'kf_vnode_type' field in struct kinfo_file.
1363 These match the KF_VTYPE_* constants in <sys/user.h>. */
1365 #define KINFO_FILE_VTYPE_VREG 1
1366 #define KINFO_FILE_VTYPE_VDIR 2
1367 #define KINFO_FILE_VTYPE_VCHR 4
1368 #define KINFO_FILE_VTYPE_VLNK 5
1369 #define KINFO_FILE_VTYPE_VSOCK 6
1370 #define KINFO_FILE_VTYPE_VFIFO 7
1373 /* Constants for socket address families. These match AF_* constants
1374 in <sys/socket.h>. */
1376 #define DFLY_AF_UNIX 1
1377 #define DFLY_AF_INET 2
1378 #define DFLY_AF_INET6 28
1380 /* Constants for socket types. These match SOCK_* constants in
1383 #define DFLY_SOCK_STREAM 1
1384 #define DFLY_SOCK_DGRAM 2
1385 #define DFLY_SOCK_SEQPACKET 5
1387 /* Constants for IP protocols. These match IPPROTO_* constants in
1390 #define DFLY_IPPROTO_ICMP 1
1391 #define DFLY_IPPROTO_TCP 6
1392 #define DFLY_IPPROTO_UDP 17
1394 /* Socket address structures. These have the same layout on all
1395 DragonFly architectures. In addition, multibyte fields such as IP
1396 addresses are always stored in network byte order. */
1398 struct dfly_sockaddr_in
1402 uint8_t sin_port[2];
1403 uint8_t sin_addr[4];
1407 struct dfly_sockaddr_in6
1410 uint8_t sin6_family;
1411 uint8_t sin6_port[2];
1412 uint32_t sin6_flowinfo;
1413 uint8_t sin6_addr[16];
1414 uint32_t sin6_scope_id;
1417 struct dfly_sockaddr_un
1425 /* Number of 32-bit words in a signal set. This matches _SIG_WORDS in
1426 <sys/_sigset.h> and is the same value on all architectures. */
1430 /* Offsets in data structure used in NT_FREEBSD_PROCSTAT_PROC core
1431 dump notes. See <sys/user.h> for the definition of struct
1432 kinfo_proc. This data structure has different layouts on different
1433 architectures mostly due to ILP32 vs LP64. However, FreeBSD/i386
1434 uses a 32-bit time_t while all other architectures use a 64-bit
1437 The core dump note actually contains one kinfo_proc structure for
1438 each thread, but all of the process-wide data can be obtained from
1439 the first structure. One result of this note's format is that some
1440 of the process-wide status available in the native target method
1441 from the kern.proc.pid.<pid> sysctl such as ki_stat and ki_siglist
1442 is not available from a core dump. Instead, the per-thread data
1443 structures contain the value of these fields for individual
1446 struct kinfo_proc_layout
1448 /* Offsets of struct kinfo_proc members. */
1455 int ki_tdev_freebsd11;
1477 /* Offsets of struct rusage members. */
1485 const struct kinfo_proc_layout kinfo_proc_layout_64 =
1493 .ki_tdev_freebsd11 = 0x64,
1494 .ki_sigignore = 0x88,
1495 .ki_sigcatch = 0x98,
1513 .ki_rusage_ch = 0x2f0,
1523 static struct gdbarch_data *dfly_gdbarch_data_handle;
1525 struct dfly_gdbarch_data
1527 struct type *siginfo_type;
1531 init_dfly_gdbarch_data (struct gdbarch *gdbarch)
1533 return GDBARCH_OBSTACK_ZALLOC (gdbarch, struct dfly_gdbarch_data);
1536 static struct dfly_gdbarch_data *
1537 get_dfly_gdbarch_data (struct gdbarch *gdbarch)
1539 return ((struct dfly_gdbarch_data *)
1540 gdbarch_data (gdbarch, dfly_gdbarch_data_handle));
1543 /* Per-program-space data for DragonFly architectures. */
1544 static const struct program_space_data *dfly_pspace_data_handle;
1546 struct dfly_pspace_data
1548 /* Offsets in the runtime linker's 'Obj_Entry' structure. */
1549 LONGEST off_linkmap;
1550 LONGEST off_tlsindex;
1551 bool rtld_offsets_valid;
1554 static struct dfly_pspace_data *
1555 get_dfly_pspace_data (struct program_space *pspace)
1557 struct dfly_pspace_data *data;
1559 data = ((struct dfly_pspace_data *)
1560 program_space_data (pspace, dfly_pspace_data_handle));
1563 data = XCNEW (struct dfly_pspace_data);
1564 set_program_space_data (pspace, dfly_pspace_data_handle, data);
1570 /* The cleanup callback for DragonFly architecture per-program-space data. */
1573 dfly_pspace_data_cleanup (struct program_space *pspace, void *data)
1578 /* This is how we want PTIDs from core files to be printed. */
1581 dfly_core_pid_to_str (struct gdbarch *gdbarch, ptid_t ptid)
1583 static char buf[80];
1585 if (ptid.lwp () != 0)
1587 xsnprintf (buf, sizeof buf, "LWP %ld", ptid.lwp ());
1591 return normal_pid_to_str (ptid);
1594 /* Extract the name assigned to a thread from a core. Returns the
1595 string in a static buffer. */
1599 dfly_core_thread_name (struct gdbarch *gdbarch, struct thread_info *thr)
1601 static char buf[80];
1602 struct bfd_section *section;
1605 if (thr->ptid.lwp () != 0)
1607 /* FreeBSD includes a NT_FREEBSD_THRMISC note for each thread
1608 whose contents are defined by a "struct thrmisc" declared in
1609 <sys/procfs.h> on FreeBSD. The per-thread name is stored as
1610 a null-terminated string as the first member of the
1611 structure. Rather than define the full structure here, just
1612 extract the null-terminated name from the start of the
1614 thread_section_name section_name (".thrmisc", thr->ptid);
1616 section = bfd_get_section_by_name (core_bfd, section_name.c_str ());
1617 if (section != NULL && bfd_section_size (core_bfd, section) > 0)
1619 /* Truncate the name if it is longer than "buf". */
1620 size = bfd_section_size (core_bfd, section);
1621 if (size > sizeof buf - 1)
1622 size = sizeof buf - 1;
1623 if (bfd_get_section_contents (core_bfd, section, buf, (file_ptr) 0,
1629 /* Note that each thread will report the process command
1630 as its thread name instead of an empty name if a name
1631 has not been set explicitly. Return a NULL name in
1633 if (strcmp (buf, elf_tdata (core_bfd)->core->program) != 0)
1643 /* Implement the "core_xfer_siginfo" gdbarch method. */
1647 dfly_core_xfer_siginfo (struct gdbarch *gdbarch, gdb_byte *readbuf,
1648 ULONGEST offset, ULONGEST len)
1650 size_t siginfo_size;
1652 if (gdbarch_long_bit (gdbarch) == 32)
1653 siginfo_size = SIZE32_SIGINFO_T;
1655 siginfo_size = SIZE64_SIGINFO_T;
1656 if (offset > siginfo_size)
1659 thread_section_name section_name (".note.freebsdcore.lwpinfo", inferior_ptid);
1660 asection *section = bfd_get_section_by_name (core_bfd, section_name.c_str ());
1661 if (section == NULL)
1665 if (!bfd_get_section_contents (core_bfd, section, buf,
1666 LWPINFO_OFFSET + LWPINFO_PL_FLAGS, 4))
1669 int pl_flags = extract_signed_integer (buf, 4, gdbarch_byte_order (gdbarch));
1670 if (!(pl_flags & PL_FLAG_SI))
1673 if (offset + len > siginfo_size)
1674 len = siginfo_size - offset;
1676 ULONGEST siginfo_offset;
1677 if (gdbarch_long_bit (gdbarch) == 32)
1678 siginfo_offset = LWPINFO_OFFSET + LWPINFO32_PL_SIGINFO;
1680 siginfo_offset = LWPINFO_OFFSET + LWPINFO64_PL_SIGINFO;
1682 if (!bfd_get_section_contents (core_bfd, section, readbuf,
1683 siginfo_offset + offset, len))
1692 find_signalled_thread (struct thread_info *info, void *data)
1694 if (info->suspend.stop_signal != GDB_SIGNAL_0
1695 && info->ptid.pid () == inferior_ptid.pid ())
1702 /* Structure for passing information from
1703 dfly_collect_thread_registers via an iterator to
1704 dfly_collect_regset_section_cb. */
1707 struct dfly_collect_regset_section_cb_data
1709 const struct regcache *regcache;
1714 enum gdb_signal stop_signal;
1715 int abort_iteration;
1721 dfly_collect_regset_section_cb (const char *sect_name, int supply_size,
1722 int collect_size, const struct regset *regset,
1723 const char *human_name, void *cb_data)
1726 struct dfly_collect_regset_section_cb_data *data
1727 = (struct dfly_collect_regset_section_cb_data *) cb_data;
1729 if (data->abort_iteration)
1732 gdb_assert (regset->collect_regset);
1734 buf = (char *) xmalloc (collect_size);
1735 regset->collect_regset (regset, data->regcache, -1, buf, collect_size);
1737 /* PRSTATUS still needs to be treated specially. */
1738 if (strcmp (sect_name, ".reg") == 0)
1739 data->note_data = (char *) elfcore_write_prstatus
1740 (data->obfd, data->note_data, data->note_size, data->lwp,
1741 gdb_signal_to_host (data->stop_signal), buf);
1743 data->note_data = (char *) elfcore_write_register_note
1744 (data->obfd, data->note_data, data->note_size,
1745 sect_name, buf, collect_size);
1748 if (data->note_data == NULL)
1749 data->abort_iteration = 1;
1753 /* Records the thread's register state for the corefile note
1758 dfly_collect_thread_registers (const struct regcache *regcache,
1759 ptid_t ptid, bfd *obfd,
1760 char *note_data, int *note_size,
1761 enum gdb_signal stop_signal)
1763 struct gdbarch *gdbarch = regcache->arch ();
1764 struct dfly_collect_regset_section_cb_data data;
1766 data.regcache = regcache;
1768 data.note_data = note_data;
1769 data.note_size = note_size;
1770 data.stop_signal = stop_signal;
1771 data.abort_iteration = 0;
1772 data.lwp = ptid.lwp ();
1774 gdbarch_iterate_over_regset_sections (gdbarch,
1775 dfly_collect_regset_section_cb,
1777 return data.note_data;
1782 struct dfly_corefile_thread_data
1784 struct gdbarch *gdbarch;
1788 enum gdb_signal stop_signal;
1792 /* Records the thread's register state for the corefile note
1797 dfly_corefile_thread (struct thread_info *info,
1798 struct dfly_corefile_thread_data *args)
1800 struct regcache *regcache;
1802 regcache = get_thread_arch_regcache (info->ptid, args->gdbarch);
1804 target_fetch_registers (regcache, -1);
1806 args->note_data = dfly_collect_thread_registers
1807 (regcache, info->ptid, args->obfd, args->note_data,
1808 args->note_size, args->stop_signal);
1812 /* Return a byte_vector containing the contents of a core dump note
1813 for the target object of type OBJECT. If STRUCTSIZE is non-zero,
1814 the data is prefixed with a 32-bit integer size to match the format
1815 used in FreeBSD NT_PROCSTAT_* notes. */
1818 static gdb::optional<gdb::byte_vector>
1819 dfly_make_note_desc (enum target_object object, uint32_t structsize)
1821 gdb::optional<gdb::byte_vector> buf =
1822 target_read_alloc (current_top_target (), object, NULL);
1823 if (!buf || buf->empty ())
1826 if (structsize == 0)
1829 gdb::byte_vector desc (sizeof (structsize) + buf->size ());
1830 memcpy (desc.data (), &structsize, sizeof (structsize));
1831 memcpy (desc.data () + sizeof (structsize), buf->data (), buf->size ());
1836 /* Create appropriate note sections for a corefile, returning them in
1837 allocated memory. */
1841 dfly_make_corefile_notes (struct gdbarch *gdbarch, bfd *obfd, int *note_size)
1843 struct dfly_corefile_thread_data thread_args;
1844 char *note_data = NULL;
1845 Elf_Internal_Ehdr *i_ehdrp;
1846 struct thread_info *curr_thr, *signalled_thr;
1848 gdb_assert (gdbarch_iterate_over_regset_sections_p (gdbarch));
1850 if (get_exec_file (0))
1852 const char *fname = lbasename (get_exec_file (0));
1853 char *psargs = xstrdup (fname);
1855 if (get_inferior_args ())
1856 psargs = reconcat (psargs, psargs, " ", get_inferior_args (),
1859 note_data = elfcore_write_prpsinfo (obfd, note_data, note_size,
1863 /* Thread register information. */
1866 update_thread_list ();
1868 CATCH (e, RETURN_MASK_ERROR)
1870 exception_print (gdb_stderr, e);
1874 /* Like the kernel, prefer dumping the signalled thread first.
1875 "First thread" is what tools use to infer the signalled thread.
1876 In case there's more than one signalled thread, prefer the
1877 current thread, if it is signalled. */
1878 curr_thr = inferior_thread ();
1879 if (curr_thr->suspend.stop_signal != GDB_SIGNAL_0)
1880 signalled_thr = curr_thr;
1883 signalled_thr = iterate_over_threads (find_signalled_thread, NULL);
1884 if (signalled_thr == NULL)
1885 signalled_thr = curr_thr;
1888 thread_args.gdbarch = gdbarch;
1889 thread_args.obfd = obfd;
1890 thread_args.note_data = note_data;
1891 thread_args.note_size = note_size;
1892 thread_args.stop_signal = signalled_thr->suspend.stop_signal;
1894 dfly_corefile_thread (signalled_thr, &thread_args);
1895 for (thread_info *thr : current_inferior ()->non_exited_threads ())
1897 if (thr == signalled_thr)
1900 dfly_corefile_thread (thr, &thread_args);
1903 note_data = thread_args.note_data;
1905 /* Auxiliary vector. */
1906 uint32_t structsize = gdbarch_ptr_bit (gdbarch) / 4; /* Elf_Auxinfo */
1907 gdb::optional<gdb::byte_vector> note_desc =
1908 dfly_make_note_desc (TARGET_OBJECT_AUXV, structsize);
1909 if (note_desc && !note_desc->empty ())
1911 note_data = elfcore_write_note (obfd, note_data, note_size, "FreeBSD",
1912 NT_FREEBSD_PROCSTAT_AUXV,
1913 note_desc->data (), note_desc->size ());
1918 /* Virtual memory mappings. */
1919 note_desc = dfly_make_note_desc (TARGET_OBJECT_FREEBSD_VMMAP, 0);
1920 if (note_desc && !note_desc->empty ())
1922 note_data = elfcore_write_note (obfd, note_data, note_size, "FreeBSD",
1923 NT_FREEBSD_PROCSTAT_VMMAP,
1924 note_desc->data (), note_desc->size ());
1929 note_desc = dfly_make_note_desc (TARGET_OBJECT_FREEBSD_PS_STRINGS, 0);
1930 if (note_desc && !note_desc->empty ())
1932 note_data = elfcore_write_note (obfd, note_data, note_size, "FreeBSD",
1933 NT_FREEBSD_PROCSTAT_PSSTRINGS,
1934 note_desc->data (), note_desc->size ());
1943 /* Helper function to generate the file descriptor description for a
1944 single open file in 'info proc files'. */
1948 dfly_file_fd (int kf_fd)
1952 case KINFO_FILE_FD_TYPE_CWD:
1954 case KINFO_FILE_FD_TYPE_ROOT:
1956 case KINFO_FILE_FD_TYPE_JAIL:
1958 case KINFO_FILE_FD_TYPE_TRACE:
1960 case KINFO_FILE_FD_TYPE_TEXT:
1962 case KINFO_FILE_FD_TYPE_CTTY:
1965 return int_string (kf_fd, 10, 1, 0, 0);
1970 /* Helper function to generate the file type for a single open file in
1971 'info proc files'. */
1975 dfly_file_type (int kf_type, int kf_vnode_type)
1979 case KINFO_FILE_TYPE_VNODE:
1980 switch (kf_vnode_type)
1982 case KINFO_FILE_VTYPE_VREG:
1984 case KINFO_FILE_VTYPE_VDIR:
1986 case KINFO_FILE_VTYPE_VCHR:
1988 case KINFO_FILE_VTYPE_VLNK:
1990 case KINFO_FILE_VTYPE_VSOCK:
1992 case KINFO_FILE_VTYPE_VFIFO:
1996 char *str = get_print_cell ();
1998 xsnprintf (str, PRINT_CELL_SIZE, "vn:%d", kf_vnode_type);
2002 case KINFO_FILE_TYPE_SOCKET:
2004 case KINFO_FILE_TYPE_PIPE:
2006 case KINFO_FILE_TYPE_FIFO:
2008 case KINFO_FILE_TYPE_KQUEUE:
2010 case KINFO_FILE_TYPE_CRYPTO:
2012 case KINFO_FILE_TYPE_MQUEUE:
2014 case KINFO_FILE_TYPE_SHM:
2016 case KINFO_FILE_TYPE_SEM:
2018 case KINFO_FILE_TYPE_PTS:
2020 case KINFO_FILE_TYPE_PROCDESC:
2023 return int_string (kf_type, 10, 1, 0, 0);
2028 /* Helper function to generate the file flags for a single open file in
2029 'info proc files'. */
2033 dfly_file_flags (int kf_flags)
2035 static char file_flags[10];
2037 file_flags[0] = (kf_flags & KINFO_FILE_FLAG_READ) ? 'r' : '-';
2038 file_flags[1] = (kf_flags & KINFO_FILE_FLAG_WRITE) ? 'w' : '-';
2039 file_flags[2] = (kf_flags & KINFO_FILE_FLAG_EXEC) ? 'x' : '-';
2040 file_flags[3] = (kf_flags & KINFO_FILE_FLAG_APPEND) ? 'a' : '-';
2041 file_flags[4] = (kf_flags & KINFO_FILE_FLAG_ASYNC) ? 's' : '-';
2042 file_flags[5] = (kf_flags & KINFO_FILE_FLAG_FSYNC) ? 'f' : '-';
2043 file_flags[6] = (kf_flags & KINFO_FILE_FLAG_NONBLOCK) ? 'n' : '-';
2044 file_flags[7] = (kf_flags & KINFO_FILE_FLAG_DIRECT) ? 'd' : '-';
2045 file_flags[8] = (kf_flags & KINFO_FILE_FLAG_HASLOCK) ? 'l' : '-';
2046 file_flags[9] = '\0';
2052 /* Helper function to generate the name of an IP protocol. */
2055 dfly_ipproto (int protocol)
2059 case DFLY_IPPROTO_ICMP:
2061 case DFLY_IPPROTO_TCP:
2063 case DFLY_IPPROTO_UDP:
2067 char *str = get_print_cell ();
2069 xsnprintf (str, PRINT_CELL_SIZE, "ip<%d>", protocol);
2075 /* Helper function to print out an IPv4 socket address. */
2078 dfly_print_sockaddr_in (const void *sockaddr)
2080 const struct dfly_sockaddr_in *sin =
2081 reinterpret_cast<const struct dfly_sockaddr_in *> (sockaddr);
2082 char buf[INET_ADDRSTRLEN];
2084 if (inet_ntop (AF_INET, sin->sin_addr, buf, sizeof buf) == nullptr)
2085 error (_("Failed to format IPv4 address"));
2086 printf_filtered ("%s:%u", buf,
2087 (sin->sin_port[0] << 8) | sin->sin_port[1]);
2090 /* Helper function to print out an IPv6 socket address. */
2093 dfly_print_sockaddr_in6 (const void *sockaddr)
2095 const struct dfly_sockaddr_in6 *sin6 =
2096 reinterpret_cast<const struct dfly_sockaddr_in6 *> (sockaddr);
2097 char buf[INET6_ADDRSTRLEN];
2099 if (inet_ntop (AF_INET6, sin6->sin6_addr, buf, sizeof buf) == nullptr)
2100 error (_("Failed to format IPv6 address"));
2101 printf_filtered ("%s.%u", buf,
2102 (sin6->sin6_port[0] << 8) | sin6->sin6_port[1]);
2105 /* See dfly-tdep.h. */
2109 dfly_info_proc_files_header ()
2111 printf_filtered (_("Open files:\n\n"));
2112 printf_filtered (" %6s %6s %10s %9s %s\n",
2113 "FD", "Type", "Offset", "Flags ", "Name");
2117 /* See dfly-tdep.h. */
2121 dfly_info_proc_files_entry (int kf_type, int kf_fd, int kf_flags,
2122 LONGEST kf_offset, int kf_vnode_type,
2123 int kf_sock_domain, int kf_sock_type,
2124 int kf_sock_protocol, const void *kf_sa_local,
2125 const void *kf_sa_peer, const void *kf_path)
2127 printf_filtered (" %6s %6s %10s %8s ",
2128 dfly_file_fd (kf_fd),
2129 dfly_file_type (kf_type, kf_vnode_type),
2130 kf_offset > -1 ? hex_string (kf_offset) : "-",
2131 dfly_file_flags (kf_flags));
2132 if (kf_type == KINFO_FILE_TYPE_SOCKET)
2134 switch (kf_sock_domain)
2138 switch (kf_sock_type)
2140 case DFLY_SOCK_STREAM:
2141 printf_filtered ("unix stream:");
2143 case DFLY_SOCK_DGRAM:
2144 printf_filtered ("unix dgram:");
2146 case DFLY_SOCK_SEQPACKET:
2147 printf_filtered ("unix seqpacket:");
2150 printf_filtered ("unix <%d>:", kf_sock_type);
2154 /* For local sockets, print out the first non-nul path
2155 rather than both paths. */
2156 const struct dfly_sockaddr_un *sun
2157 = reinterpret_cast<const struct dfly_sockaddr_un *> (kf_sa_local);
2158 if (sun->sun_path[0] == 0)
2159 sun = reinterpret_cast<const struct dfly_sockaddr_un *>
2161 printf_filtered ("%s", sun->sun_path);
2165 printf_filtered ("%s4 ", dfly_ipproto (kf_sock_protocol));
2166 dfly_print_sockaddr_in (kf_sa_local);
2167 printf_filtered (" -> ");
2168 dfly_print_sockaddr_in (kf_sa_peer);
2171 printf_filtered ("%s6 ", dfly_ipproto (kf_sock_protocol));
2172 dfly_print_sockaddr_in6 (kf_sa_local);
2173 printf_filtered (" -> ");
2174 dfly_print_sockaddr_in6 (kf_sa_peer);
2179 printf_filtered ("%s", reinterpret_cast<const char *> (kf_path));
2180 printf_filtered ("\n");
2184 /* Implement "info proc files" for a corefile. */
2188 dfly_core_info_proc_files (struct gdbarch *gdbarch)
2191 = bfd_get_section_by_name (core_bfd, ".note.freebsdcore.files");
2192 if (section == NULL)
2194 warning (_("unable to find open files in core file"));
2198 size_t note_size = bfd_get_section_size (section);
2200 error (_("malformed core note - too short for header"));
2202 gdb::def_vector<unsigned char> contents (note_size);
2203 if (!bfd_get_section_contents (core_bfd, section, contents.data (),
2205 error (_("could not get core note contents"));
2207 unsigned char *descdata = contents.data ();
2208 unsigned char *descend = descdata + note_size;
2210 /* Skip over the structure size. */
2213 dfly_info_proc_files_header ();
2215 while (descdata + KF_PATH < descend)
2217 ULONGEST structsize = bfd_get_32 (core_bfd, descdata + KF_STRUCTSIZE);
2218 if (structsize < KF_PATH)
2219 error (_("malformed core note - file structure too small"));
2221 LONGEST type = bfd_get_signed_32 (core_bfd, descdata + KF_TYPE);
2222 LONGEST fd = bfd_get_signed_32 (core_bfd, descdata + KF_FD);
2223 LONGEST flags = bfd_get_signed_32 (core_bfd, descdata + KF_FLAGS);
2224 LONGEST offset = bfd_get_signed_64 (core_bfd, descdata + KF_OFFSET);
2225 LONGEST vnode_type = bfd_get_signed_32 (core_bfd,
2226 descdata + KF_VNODE_TYPE);
2227 LONGEST sock_domain = bfd_get_signed_32 (core_bfd,
2228 descdata + KF_SOCK_DOMAIN);
2229 LONGEST sock_type = bfd_get_signed_32 (core_bfd, descdata + KF_SOCK_TYPE);
2230 LONGEST sock_protocol = bfd_get_signed_32 (core_bfd,
2231 descdata + KF_SOCK_PROTOCOL);
2232 dfly_info_proc_files_entry (type, fd, flags, offset, vnode_type,
2233 sock_domain, sock_type, sock_protocol,
2234 descdata + KF_SA_LOCAL, descdata + KF_SA_PEER,
2235 descdata + KF_PATH);
2237 descdata += structsize;
2242 /* Helper function to generate mappings flags for a single VM map
2243 entry in 'info proc mappings'. */
2247 dfly_vm_map_entry_flags (int kve_flags, int kve_protection)
2249 static char vm_flags[9];
2251 vm_flags[0] = (kve_protection & KINFO_VME_PROT_READ) ? 'r' : '-';
2252 vm_flags[1] = (kve_protection & KINFO_VME_PROT_WRITE) ? 'w' : '-';
2253 vm_flags[2] = (kve_protection & KINFO_VME_PROT_EXEC) ? 'x' : '-';
2255 vm_flags[4] = (kve_flags & KINFO_VME_FLAG_COW) ? 'C' : '-';
2256 vm_flags[5] = (kve_flags & KINFO_VME_FLAG_NEEDS_COPY) ? 'N' : '-';
2257 vm_flags[6] = (kve_flags & KINFO_VME_FLAG_SUPER) ? 'S' : '-';
2258 vm_flags[7] = (kve_flags & KINFO_VME_FLAG_GROWS_UP) ? 'U'
2259 : (kve_flags & KINFO_VME_FLAG_GROWS_DOWN) ? 'D' : '-';
2266 /* See dfly-tdep.h. */
2270 dfly_info_proc_mappings_header (int addr_bit)
2272 printf_filtered (_("Mapped address spaces:\n\n"));
2275 printf_filtered (" %18s %18s %10s %10s %9s %s\n",
2278 " Size", " Offset", "Flags ", "File");
2282 printf_filtered ("\t%10s %10s %10s %10s %9s %s\n",
2285 " Size", " Offset", "Flags ", "File");
2290 /* See dfly-tdep.h. */
2294 dfly_info_proc_mappings_entry (int addr_bit, ULONGEST kve_start,
2295 ULONGEST kve_end, ULONGEST kve_offset,
2296 int kve_flags, int kve_protection,
2297 const void *kve_path)
2301 printf_filtered (" %18s %18s %10s %10s %9s %s\n",
2302 hex_string (kve_start),
2303 hex_string (kve_end),
2304 hex_string (kve_end - kve_start),
2305 hex_string (kve_offset),
2306 dfly_vm_map_entry_flags (kve_flags, kve_protection),
2307 reinterpret_cast<const char *> (kve_path));
2311 printf_filtered ("\t%10s %10s %10s %10s %9s %s\n",
2312 hex_string (kve_start),
2313 hex_string (kve_end),
2314 hex_string (kve_end - kve_start),
2315 hex_string (kve_offset),
2316 dfly_vm_map_entry_flags (kve_flags, kve_protection),
2317 reinterpret_cast<const char *> (kve_path));
2322 /* Implement "info proc mappings" for a corefile. */
2326 dfly_core_info_proc_mappings (struct gdbarch *gdbarch)
2329 unsigned char *descdata, *descend;
2332 section = bfd_get_section_by_name (core_bfd, ".note.freebsdcore.vmmap");
2333 if (section == NULL)
2335 warning (_("unable to find mappings in core file"));
2339 note_size = bfd_get_section_size (section);
2341 error (_("malformed core note - too short for header"));
2343 gdb::def_vector<unsigned char> contents (note_size);
2344 if (!bfd_get_section_contents (core_bfd, section, contents.data (),
2346 error (_("could not get core note contents"));
2348 descdata = contents.data ();
2349 descend = descdata + note_size;
2351 /* Skip over the structure size. */
2354 dfly_info_proc_mappings_header (gdbarch_addr_bit (gdbarch));
2355 while (descdata + KVE_PATH < descend)
2357 ULONGEST structsize = bfd_get_32 (core_bfd, descdata + KVE_STRUCTSIZE);
2358 if (structsize < KVE_PATH)
2359 error (_("malformed core note - vmmap entry too small"));
2361 ULONGEST start = bfd_get_64 (core_bfd, descdata + KVE_START);
2362 ULONGEST end = bfd_get_64 (core_bfd, descdata + KVE_END);
2363 ULONGEST offset = bfd_get_64 (core_bfd, descdata + KVE_OFFSET);
2364 LONGEST flags = bfd_get_signed_32 (core_bfd, descdata + KVE_FLAGS);
2365 LONGEST prot = bfd_get_signed_32 (core_bfd, descdata + KVE_PROTECTION);
2366 dfly_info_proc_mappings_entry (gdbarch_addr_bit (gdbarch), start, end,
2367 offset, flags, prot, descdata + KVE_PATH);
2369 descdata += structsize;
2374 /* Fetch the pathname of a vnode for a single file descriptor from the
2375 file table core note. */
2378 static gdb::unique_xmalloc_ptr<char>
2379 dfly_core_vnode_path (struct gdbarch *gdbarch, int fd)
2382 unsigned char *descdata, *descend;
2385 section = bfd_get_section_by_name (core_bfd, ".note.freebsdcore.files");
2386 if (section == NULL)
2389 note_size = bfd_get_section_size (section);
2391 error (_("malformed core note - too short for header"));
2393 gdb::def_vector<unsigned char> contents (note_size);
2394 if (!bfd_get_section_contents (core_bfd, section, contents.data (),
2396 error (_("could not get core note contents"));
2398 descdata = contents.data ();
2399 descend = descdata + note_size;
2401 /* Skip over the structure size. */
2404 while (descdata + KF_PATH < descend)
2406 ULONGEST structsize;
2408 structsize = bfd_get_32 (core_bfd, descdata + KF_STRUCTSIZE);
2409 if (structsize < KF_PATH)
2410 error (_("malformed core note - file structure too small"));
2412 if (bfd_get_32 (core_bfd, descdata + KF_TYPE) == KINFO_FILE_TYPE_VNODE
2413 && bfd_get_signed_32 (core_bfd, descdata + KF_FD) == fd)
2415 char *path = (char *) descdata + KF_PATH;
2416 return gdb::unique_xmalloc_ptr<char> (xstrdup (path));
2419 descdata += structsize;
2425 /* Helper function to read a struct timeval. */
2429 dfly_core_fetch_timeval (struct gdbarch *gdbarch, unsigned char *data,
2430 LONGEST &sec, ULONGEST &usec)
2432 if (gdbarch_addr_bit (gdbarch) == 64)
2434 sec = bfd_get_signed_64 (core_bfd, data);
2435 usec = bfd_get_64 (core_bfd, data + 8);
2437 else if (bfd_get_arch (core_bfd) == bfd_arch_i386)
2439 sec = bfd_get_signed_32 (core_bfd, data);
2440 usec = bfd_get_32 (core_bfd, data + 4);
2444 sec = bfd_get_signed_64 (core_bfd, data);
2445 usec = bfd_get_32 (core_bfd, data + 8);
2450 /* Print out the contents of a signal set. */
2454 dfly_print_sigset (const char *descr, unsigned char *sigset)
2456 printf_filtered ("%s: ", descr);
2457 for (int i = 0; i < SIG_WORDS; i++)
2458 printf_filtered ("%08x ",
2459 (unsigned int) bfd_get_32 (core_bfd, sigset + i * 4));
2460 printf_filtered ("\n");
2464 /* Implement "info proc status" for a corefile. */
2468 dfly_core_info_proc_status (struct gdbarch *gdbarch)
2470 const struct kinfo_proc_layout *kp;
2472 unsigned char *descdata;
2473 int addr_bit, long_bit;
2478 section = bfd_get_section_by_name (core_bfd, ".note.freebsdcore.proc");
2479 if (section == NULL)
2481 warning (_("unable to find process info in core file"));
2485 addr_bit = gdbarch_addr_bit (gdbarch);
2487 kp = &kinfo_proc_layout_64;
2488 else if (bfd_get_arch (core_bfd) == bfd_arch_i386)
2489 kp = &kinfo_proc_layout_i386;
2491 kp = &kinfo_proc_layout_32;
2492 long_bit = gdbarch_long_bit (gdbarch);
2495 * Ensure that the note is large enough for all of the fields fetched
2496 * by this function. In particular, the note must contain the 32-bit
2497 * structure size, then it must be long enough to access the last
2498 * field used (ki_rusage_ch.ru_majflt) which is the size of a long.
2500 note_size = bfd_get_section_size (section);
2501 if (note_size < (4 + kp->ki_rusage_ch + kp->ru_majflt
2502 + long_bit / TARGET_CHAR_BIT))
2503 error (_("malformed core note - too short"));
2505 gdb::def_vector<unsigned char> contents (note_size);
2506 if (!bfd_get_section_contents (core_bfd, section, contents.data (),
2508 error (_("could not get core note contents"));
2510 descdata = contents.data ();
2512 /* Skip over the structure size. */
2515 /* Verify 'ki_layout' is 0. */
2516 if (bfd_get_32 (core_bfd, descdata + kp->ki_layout) != 0)
2518 warning (_("unsupported process information in core file"));
2522 printf_filtered ("Name: %.19s\n", descdata + kp->ki_comm);
2523 printf_filtered ("Process ID: %s\n",
2524 pulongest (bfd_get_32 (core_bfd, descdata + kp->ki_pid)));
2525 printf_filtered ("Parent process: %s\n",
2526 pulongest (bfd_get_32 (core_bfd, descdata + kp->ki_ppid)));
2527 printf_filtered ("Process group: %s\n",
2528 pulongest (bfd_get_32 (core_bfd, descdata + kp->ki_pgid)));
2529 printf_filtered ("Session id: %s\n",
2530 pulongest (bfd_get_32 (core_bfd, descdata + kp->ki_sid)));
2532 /* FreeBSD 12.0 and later store a 64-bit dev_t at 'ki_tdev'. Older
2533 kernels store a 32-bit dev_t at 'ki_tdev_freebsd11'. In older
2534 kernels the 64-bit 'ki_tdev' field is in a reserved section of
2535 the structure that is cleared to zero. Assume that a zero value
2536 in ki_tdev indicates a core dump from an older kernel and use the
2537 value in 'ki_tdev_freebsd11' instead. */
2538 value = bfd_get_64 (core_bfd, descdata + kp->ki_tdev);
2540 value = bfd_get_32 (core_bfd, descdata + kp->ki_tdev_freebsd11);
2541 printf_filtered ("TTY: %s\n", pulongest (value));
2542 printf_filtered ("TTY owner process group: %s\n",
2543 pulongest (bfd_get_32 (core_bfd, descdata + kp->ki_tpgid)));
2544 printf_filtered ("User IDs (real, effective, saved): %s %s %s\n",
2545 pulongest (bfd_get_32 (core_bfd, descdata + kp->ki_ruid)),
2546 pulongest (bfd_get_32 (core_bfd, descdata + kp->ki_uid)),
2547 pulongest (bfd_get_32 (core_bfd, descdata + kp->ki_svuid)));
2548 printf_filtered ("Group IDs (real, effective, saved): %s %s %s\n",
2549 pulongest (bfd_get_32 (core_bfd, descdata + kp->ki_rgid)),
2550 pulongest (bfd_get_32 (core_bfd, descdata + kp->ki_groups)),
2551 pulongest (bfd_get_32 (core_bfd, descdata + kp->ki_svgid)));
2552 printf_filtered ("Groups: ");
2553 uint16_t ngroups = bfd_get_16 (core_bfd, descdata + kp->ki_ngroups);
2554 for (int i = 0; i < ngroups; i++)
2555 printf_filtered ("%s ",
2556 pulongest (bfd_get_32 (core_bfd,
2557 descdata + kp->ki_groups + i * 4)));
2558 printf_filtered ("\n");
2559 value = bfd_get (long_bit, core_bfd,
2560 descdata + kp->ki_rusage + kp->ru_minflt);
2561 printf_filtered ("Minor faults (no memory page): %s\n", pulongest (value));
2562 value = bfd_get (long_bit, core_bfd,
2563 descdata + kp->ki_rusage_ch + kp->ru_minflt);
2564 printf_filtered ("Minor faults, children: %s\n", pulongest (value));
2565 value = bfd_get (long_bit, core_bfd,
2566 descdata + kp->ki_rusage + kp->ru_majflt);
2567 printf_filtered ("Major faults (memory page faults): %s\n",
2569 value = bfd_get (long_bit, core_bfd,
2570 descdata + kp->ki_rusage_ch + kp->ru_majflt);
2571 printf_filtered ("Major faults, children: %s\n", pulongest (value));
2572 dfly_core_fetch_timeval (gdbarch,
2573 descdata + kp->ki_rusage + kp->ru_utime,
2575 printf_filtered ("utime: %s.%06d\n", plongest (sec), (int) value);
2576 dfly_core_fetch_timeval (gdbarch,
2577 descdata + kp->ki_rusage + kp->ru_stime,
2579 printf_filtered ("stime: %s.%06d\n", plongest (sec), (int) value);
2580 dfly_core_fetch_timeval (gdbarch,
2581 descdata + kp->ki_rusage_ch + kp->ru_utime,
2583 printf_filtered ("utime, children: %s.%06d\n", plongest (sec), (int) value);
2584 dfly_core_fetch_timeval (gdbarch,
2585 descdata + kp->ki_rusage_ch + kp->ru_stime,
2587 printf_filtered ("stime, children: %s.%06d\n", plongest (sec), (int) value);
2588 printf_filtered ("'nice' value: %d\n",
2589 bfd_get_signed_8 (core_bfd, descdata + kp->ki_nice));
2590 dfly_core_fetch_timeval (gdbarch, descdata + kp->ki_start, sec, value);
2591 printf_filtered ("Start time: %s.%06d\n", plongest (sec), (int) value);
2592 printf_filtered ("Virtual memory size: %s kB\n",
2593 pulongest (bfd_get (addr_bit, core_bfd,
2594 descdata + kp->ki_size) / 1024));
2595 printf_filtered ("Data size: %s pages\n",
2596 pulongest (bfd_get (addr_bit, core_bfd,
2597 descdata + kp->ki_dsize)));
2598 printf_filtered ("Stack size: %s pages\n",
2599 pulongest (bfd_get (addr_bit, core_bfd,
2600 descdata + kp->ki_ssize)));
2601 printf_filtered ("Text size: %s pages\n",
2602 pulongest (bfd_get (addr_bit, core_bfd,
2603 descdata + kp->ki_tsize)));
2604 printf_filtered ("Resident set size: %s pages\n",
2605 pulongest (bfd_get (addr_bit, core_bfd,
2606 descdata + kp->ki_rssize)));
2607 printf_filtered ("Maximum RSS: %s pages\n",
2608 pulongest (bfd_get (long_bit, core_bfd,
2609 descdata + kp->ki_rusage
2611 dfly_print_sigset ("Ignored Signals", descdata + kp->ki_sigignore);
2612 dfly_print_sigset ("Caught Signals", descdata + kp->ki_sigcatch);
2616 /* Implement the "core_info_proc" gdbarch method. */
2620 dfly_core_info_proc (struct gdbarch *gdbarch, const char *args,
2621 enum info_proc_what what)
2623 bool do_cmdline = false;
2624 bool do_cwd = false;
2625 bool do_exe = false;
2626 bool do_files = false;
2627 bool do_mappings = false;
2628 bool do_status = false;
2669 pid = bfd_core_file_pid (core_bfd);
2671 printf_filtered (_("process %d\n"), pid);
2675 const char *cmdline;
2677 cmdline = bfd_core_file_failing_command (core_bfd);
2679 printf_filtered ("cmdline = '%s'\n", cmdline);
2681 warning (_("Command line unavailable"));
2685 gdb::unique_xmalloc_ptr<char> cwd =
2686 dfly_core_vnode_path (gdbarch, KINFO_FILE_FD_TYPE_CWD);
2688 printf_filtered ("cwd = '%s'\n", cwd.get ());
2690 warning (_("unable to read current working directory"));
2694 gdb::unique_xmalloc_ptr<char> exe =
2695 dfly_core_vnode_path (gdbarch, KINFO_FILE_FD_TYPE_TEXT);
2697 printf_filtered ("exe = '%s'\n", exe.get ());
2699 warning (_("unable to read executable path name"));
2702 dfly_core_info_proc_files (gdbarch);
2704 dfly_core_info_proc_mappings (gdbarch);
2706 dfly_core_info_proc_status (gdbarch);
2710 /* Print descriptions of FreeBSD-specific AUXV entries to FILE. */
2714 dfly_print_auxv_entry (struct gdbarch *gdbarch, struct ui_file *file,
2715 CORE_ADDR type, CORE_ADDR val)
2717 const char *name = "???";
2718 const char *description = "";
2719 enum auxv_format format = AUXV_FORMAT_HEX;
2738 default_print_auxv_entry (gdbarch, file, type, val);
2740 #define _TAGNAME(tag) #tag
2741 #define TAGNAME(tag) _TAGNAME(AT_##tag)
2742 #define TAG(tag, text, kind) \
2743 case AT_FREEBSD_##tag: name = TAGNAME(tag); description = text; format = kind; break
2744 TAG (EXECPATH, _("Executable path"), AUXV_FORMAT_STR);
2745 TAG (CANARY, _("Canary for SSP"), AUXV_FORMAT_HEX);
2746 TAG (CANARYLEN, ("Length of the SSP canary"), AUXV_FORMAT_DEC);
2747 TAG (OSRELDATE, _("OSRELDATE"), AUXV_FORMAT_DEC);
2748 TAG (NCPUS, _("Number of CPUs"), AUXV_FORMAT_DEC);
2749 TAG (PAGESIZES, _("Pagesizes"), AUXV_FORMAT_HEX);
2750 TAG (PAGESIZESLEN, _("Number of pagesizes"), AUXV_FORMAT_DEC);
2751 TAG (TIMEKEEP, _("Pointer to timehands"), AUXV_FORMAT_HEX);
2752 TAG (STACKPROT, _("Initial stack protection"), AUXV_FORMAT_HEX);
2753 TAG (EHDRFLAGS, _("ELF header e_flags"), AUXV_FORMAT_HEX);
2754 TAG (HWCAP, _("Machine-dependent CPU capability hints"), AUXV_FORMAT_HEX);
2755 TAG (HWCAP2, _("Extension of AT_HWCAP"), AUXV_FORMAT_HEX);
2758 fprint_auxv_entry (file, name, description, format, type, val);
2762 /* Implement the "get_siginfo_type" gdbarch method. */
2765 static struct type *
2766 dfly_get_siginfo_type (struct gdbarch *gdbarch)
2768 struct dfly_gdbarch_data *dfly_gdbarch_data;
2769 struct type *int_type, *int32_type, *uint32_type, *long_type, *void_ptr_type;
2770 struct type *uid_type, *pid_type;
2771 struct type *sigval_type, *reason_type;
2772 struct type *siginfo_type;
2775 dfly_gdbarch_data = get_dfly_gdbarch_data (gdbarch);
2776 if (dfly_gdbarch_data->siginfo_type != NULL)
2777 return dfly_gdbarch_data->siginfo_type;
2779 int_type = arch_integer_type (gdbarch, gdbarch_int_bit (gdbarch),
2781 int32_type = arch_integer_type (gdbarch, 32, 0, "int32_t");
2782 uint32_type = arch_integer_type (gdbarch, 32, 1, "uint32_t");
2783 long_type = arch_integer_type (gdbarch, gdbarch_long_bit (gdbarch),
2785 void_ptr_type = lookup_pointer_type (builtin_type (gdbarch)->builtin_void);
2788 sigval_type = arch_composite_type (gdbarch, NULL, TYPE_CODE_UNION);
2789 TYPE_NAME (sigval_type) = xstrdup ("sigval");
2790 append_composite_type_field (sigval_type, "sival_int", int_type);
2791 append_composite_type_field (sigval_type, "sival_ptr", void_ptr_type);
2794 pid_type = arch_type (gdbarch, TYPE_CODE_TYPEDEF,
2795 TYPE_LENGTH (int32_type) * TARGET_CHAR_BIT, "__pid_t");
2796 TYPE_TARGET_TYPE (pid_type) = int32_type;
2797 TYPE_TARGET_STUB (pid_type) = 1;
2800 uid_type = arch_type (gdbarch, TYPE_CODE_TYPEDEF,
2801 TYPE_LENGTH (uint32_type) * TARGET_CHAR_BIT,
2803 TYPE_TARGET_TYPE (uid_type) = uint32_type;
2804 TYPE_TARGET_STUB (uid_type) = 1;
2807 reason_type = arch_composite_type (gdbarch, NULL, TYPE_CODE_UNION);
2810 type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT);
2811 append_composite_type_field (type, "si_trapno", int_type);
2812 append_composite_type_field (reason_type, "_fault", type);
2815 type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT);
2816 append_composite_type_field (type, "si_timerid", int_type);
2817 append_composite_type_field (type, "si_overrun", int_type);
2818 append_composite_type_field (reason_type, "_timer", type);
2821 type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT);
2822 append_composite_type_field (type, "si_mqd", int_type);
2823 append_composite_type_field (reason_type, "_mesgq", type);
2826 type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT);
2827 append_composite_type_field (type, "si_band", long_type);
2828 append_composite_type_field (reason_type, "_poll", type);
2831 type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT);
2832 append_composite_type_field (type, "__spare1__", long_type);
2833 append_composite_type_field (type, "__spare2__",
2834 init_vector_type (int_type, 7));
2835 append_composite_type_field (reason_type, "__spare__", type);
2837 /* struct siginfo */
2838 siginfo_type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT);
2839 TYPE_NAME (siginfo_type) = xstrdup ("siginfo");
2840 append_composite_type_field (siginfo_type, "si_signo", int_type);
2841 append_composite_type_field (siginfo_type, "si_errno", int_type);
2842 append_composite_type_field (siginfo_type, "si_code", int_type);
2843 append_composite_type_field (siginfo_type, "si_pid", pid_type);
2844 append_composite_type_field (siginfo_type, "si_uid", uid_type);
2845 append_composite_type_field (siginfo_type, "si_status", int_type);
2846 append_composite_type_field (siginfo_type, "si_addr", void_ptr_type);
2847 append_composite_type_field (siginfo_type, "si_value", sigval_type);
2848 append_composite_type_field (siginfo_type, "_reason", reason_type);
2850 dfly_gdbarch_data->siginfo_type = siginfo_type;
2852 return siginfo_type;
2856 /* Implement the "gdb_signal_from_target" gdbarch method. */
2858 static enum gdb_signal
2859 dfly_gdb_signal_from_target (struct gdbarch *gdbarch, int signal)
2864 return GDB_SIGNAL_0;
2866 case DRAGONFLY_SIGHUP:
2867 return GDB_SIGNAL_HUP;
2869 case DRAGONFLY_SIGINT:
2870 return GDB_SIGNAL_INT;
2872 case DRAGONFLY_SIGQUIT:
2873 return GDB_SIGNAL_QUIT;
2875 case DRAGONFLY_SIGILL:
2876 return GDB_SIGNAL_ILL;
2878 case DRAGONFLY_SIGTRAP:
2879 return GDB_SIGNAL_TRAP;
2881 case DRAGONFLY_SIGABRT:
2882 return GDB_SIGNAL_ABRT;
2884 case DRAGONFLY_SIGEMT:
2885 return GDB_SIGNAL_EMT;
2887 case DRAGONFLY_SIGFPE:
2888 return GDB_SIGNAL_FPE;
2890 case DRAGONFLY_SIGKILL:
2891 return GDB_SIGNAL_KILL;
2893 case DRAGONFLY_SIGBUS:
2894 return GDB_SIGNAL_BUS;
2896 case DRAGONFLY_SIGSEGV:
2897 return GDB_SIGNAL_SEGV;
2899 case DRAGONFLY_SIGSYS:
2900 return GDB_SIGNAL_SYS;
2902 case DRAGONFLY_SIGPIPE:
2903 return GDB_SIGNAL_PIPE;
2905 case DRAGONFLY_SIGALRM:
2906 return GDB_SIGNAL_ALRM;
2908 case DRAGONFLY_SIGTERM:
2909 return GDB_SIGNAL_TERM;
2911 case DRAGONFLY_SIGURG:
2912 return GDB_SIGNAL_URG;
2914 case DRAGONFLY_SIGSTOP:
2915 return GDB_SIGNAL_STOP;
2917 case DRAGONFLY_SIGTSTP:
2918 return GDB_SIGNAL_TSTP;
2920 case DRAGONFLY_SIGCONT:
2921 return GDB_SIGNAL_CONT;
2923 case DRAGONFLY_SIGCHLD:
2924 return GDB_SIGNAL_CHLD;
2926 case DRAGONFLY_SIGTTIN:
2927 return GDB_SIGNAL_TTIN;
2929 case DRAGONFLY_SIGTTOU:
2930 return GDB_SIGNAL_TTOU;
2932 case DRAGONFLY_SIGIO:
2933 return GDB_SIGNAL_IO;
2935 case DRAGONFLY_SIGXCPU:
2936 return GDB_SIGNAL_XCPU;
2938 case DRAGONFLY_SIGXFSZ:
2939 return GDB_SIGNAL_XFSZ;
2941 case DRAGONFLY_SIGVTALRM:
2942 return GDB_SIGNAL_VTALRM;
2944 case DRAGONFLY_SIGPROF:
2945 return GDB_SIGNAL_PROF;
2947 case DRAGONFLY_SIGWINCH:
2948 return GDB_SIGNAL_WINCH;
2950 case DRAGONFLY_SIGINFO:
2951 return GDB_SIGNAL_INFO;
2953 case DRAGONFLY_SIGUSR1:
2954 return GDB_SIGNAL_USR1;
2956 case DRAGONFLY_SIGUSR2:
2957 return GDB_SIGNAL_USR2;
2960 /* SIGTHR is the same as SIGLWP on FreeBSD. */
2961 case FREEBSD_SIGTHR:
2962 return GDB_SIGNAL_LWP;
2964 case FREEBSD_SIGLIBRT:
2965 return GDB_SIGNAL_LIBRT;
2970 if (signal >= FREEBSD_SIGRTMIN && signal <= FREEBSD_SIGRTMAX)
2972 int offset = signal - FREEBSD_SIGRTMIN;
2974 return (enum gdb_signal) ((int) GDB_SIGNAL_REALTIME_65 + offset);
2978 return GDB_SIGNAL_UNKNOWN;
2981 /* Implement the "gdb_signal_to_target" gdbarch method. */
2984 dfly_gdb_signal_to_target (struct gdbarch *gdbarch,
2985 enum gdb_signal signal)
2992 case GDB_SIGNAL_HUP:
2993 return DRAGONFLY_SIGHUP;
2995 case GDB_SIGNAL_INT:
2996 return DRAGONFLY_SIGINT;
2998 case GDB_SIGNAL_QUIT:
2999 return DRAGONFLY_SIGQUIT;
3001 case GDB_SIGNAL_ILL:
3002 return DRAGONFLY_SIGILL;
3004 case GDB_SIGNAL_TRAP:
3005 return DRAGONFLY_SIGTRAP;
3007 case GDB_SIGNAL_ABRT:
3008 return DRAGONFLY_SIGABRT;
3010 case GDB_SIGNAL_EMT:
3011 return DRAGONFLY_SIGEMT;
3013 case GDB_SIGNAL_FPE:
3014 return DRAGONFLY_SIGFPE;
3016 case GDB_SIGNAL_KILL:
3017 return DRAGONFLY_SIGKILL;
3019 case GDB_SIGNAL_BUS:
3020 return DRAGONFLY_SIGBUS;
3022 case GDB_SIGNAL_SEGV:
3023 return DRAGONFLY_SIGSEGV;
3025 case GDB_SIGNAL_SYS:
3026 return DRAGONFLY_SIGSYS;
3028 case GDB_SIGNAL_PIPE:
3029 return DRAGONFLY_SIGPIPE;
3031 case GDB_SIGNAL_ALRM:
3032 return DRAGONFLY_SIGALRM;
3034 case GDB_SIGNAL_TERM:
3035 return DRAGONFLY_SIGTERM;
3037 case GDB_SIGNAL_URG:
3038 return DRAGONFLY_SIGURG;
3040 case GDB_SIGNAL_STOP:
3041 return DRAGONFLY_SIGSTOP;
3043 case GDB_SIGNAL_TSTP:
3044 return DRAGONFLY_SIGTSTP;
3046 case GDB_SIGNAL_CONT:
3047 return DRAGONFLY_SIGCONT;
3049 case GDB_SIGNAL_CHLD:
3050 return DRAGONFLY_SIGCHLD;
3052 case GDB_SIGNAL_TTIN:
3053 return DRAGONFLY_SIGTTIN;
3055 case GDB_SIGNAL_TTOU:
3056 return DRAGONFLY_SIGTTOU;
3059 return DRAGONFLY_SIGIO;
3061 case GDB_SIGNAL_XCPU:
3062 return DRAGONFLY_SIGXCPU;
3064 case GDB_SIGNAL_XFSZ:
3065 return DRAGONFLY_SIGXFSZ;
3067 case GDB_SIGNAL_VTALRM:
3068 return DRAGONFLY_SIGVTALRM;
3070 case GDB_SIGNAL_PROF:
3071 return DRAGONFLY_SIGPROF;
3073 case GDB_SIGNAL_WINCH:
3074 return DRAGONFLY_SIGWINCH;
3076 case GDB_SIGNAL_INFO:
3077 return DRAGONFLY_SIGINFO;
3079 case GDB_SIGNAL_USR1:
3080 return DRAGONFLY_SIGUSR1;
3082 case GDB_SIGNAL_USR2:
3083 return DRAGONFLY_SIGUSR2;
3086 case GDB_SIGNAL_LWP:
3087 return FREEBSD_SIGTHR;
3089 case GDB_SIGNAL_LIBRT:
3090 return FREEBSD_SIGLIBRT;
3095 if (signal >= GDB_SIGNAL_REALTIME_65
3096 && signal <= GDB_SIGNAL_REALTIME_126)
3098 int offset = signal - GDB_SIGNAL_REALTIME_65;
3100 return FREEBSD_SIGRTMIN + offset;
3108 /* Implement the "get_syscall_number" gdbarch method. */
3111 dfly_get_syscall_number (struct gdbarch *gdbarch, thread_info *thread)
3114 /* FreeBSD doesn't use gdbarch_get_syscall_number since FreeBSD
3115 native targets fetch the system call number from the
3116 'pl_syscall_code' member of struct ptrace_lwpinfo in dfly_wait.
3117 However, system call catching requires this function to be
3120 internal_error (__FILE__, __LINE__, _("dfly_get_sycall_number called"));
3124 /* Read an integer symbol value from the current target. */
3128 dfly_read_integer_by_name (struct gdbarch *gdbarch, const char *name)
3130 bound_minimal_symbol ms = lookup_minimal_symbol (name, NULL, NULL);
3131 if (ms.minsym == NULL)
3132 error (_("Unable to resolve symbol '%s'"), name);
3135 if (target_read_memory (BMSYMBOL_VALUE_ADDRESS (ms), buf, sizeof buf) != 0)
3136 error (_("Unable to read value of '%s'"), name);
3138 return extract_signed_integer (buf, sizeof buf, gdbarch_byte_order (gdbarch));
3142 /* Lookup offsets of fields in the runtime linker's 'Obj_Entry'
3143 structure needed to determine the TLS index of an object file. */
3147 dfly_fetch_rtld_offsets (struct gdbarch *gdbarch, struct dfly_pspace_data *data)
3151 /* Fetch offsets from debug symbols in rtld. */
3152 struct symbol *obj_entry_sym
3153 = lookup_symbol_in_language ("Struct_Obj_Entry", NULL, STRUCT_DOMAIN,
3154 language_c, NULL).symbol;
3155 if (obj_entry_sym == NULL)
3156 error (_("Unable to find Struct_Obj_Entry symbol"));
3157 data->off_linkmap = lookup_struct_elt (SYMBOL_TYPE(obj_entry_sym),
3158 "linkmap", 0).offset / 8;
3159 data->off_tlsindex = lookup_struct_elt (SYMBOL_TYPE(obj_entry_sym),
3160 "tlsindex", 0).offset / 8;
3161 data->rtld_offsets_valid = true;
3164 CATCH (e, RETURN_MASK_ERROR)
3166 data->off_linkmap = -1;
3172 /* Fetch offsets from global variables in libthr. Note that
3173 this does not work for single-threaded processes that are not
3174 linked against libthr. */
3175 data->off_linkmap = dfly_read_integer_by_name (gdbarch,
3176 "_thread_off_linkmap");
3177 data->off_tlsindex = dfly_read_integer_by_name (gdbarch,
3178 "_thread_off_tlsindex");
3179 data->rtld_offsets_valid = true;
3182 CATCH (e, RETURN_MASK_ERROR)
3184 data->off_linkmap = -1;
3190 /* Helper function to read the TLS index of an object file associated
3191 with a link map entry at LM_ADDR. */
3195 dfly_get_tls_index (struct gdbarch *gdbarch, CORE_ADDR lm_addr)
3197 struct dfly_pspace_data *data = get_dfly_pspace_data (current_program_space);
3199 if (!data->rtld_offsets_valid)
3200 dfly_fetch_rtld_offsets (gdbarch, data);
3202 if (data->off_linkmap == -1)
3203 throw_error (TLS_GENERIC_ERROR,
3204 _("Cannot fetch runtime linker structure offsets"));
3206 /* Simulate container_of to convert from LM_ADDR to the Obj_Entry
3207 pointer and then compute the offset of the tlsindex member. */
3208 CORE_ADDR tlsindex_addr = lm_addr - data->off_linkmap + data->off_tlsindex;
3211 if (target_read_memory (tlsindex_addr, buf, sizeof buf) != 0)
3212 throw_error (TLS_GENERIC_ERROR,
3213 _("Cannot find thread-local variables on this target"));
3215 return extract_signed_integer (buf, sizeof buf, gdbarch_byte_order (gdbarch));
3219 /* See dfly-tdep.h. */
3223 dfly_get_thread_local_address (struct gdbarch *gdbarch, CORE_ADDR dtv_addr,
3224 CORE_ADDR lm_addr, CORE_ADDR offset)
3226 LONGEST tls_index = dfly_get_tls_index (gdbarch, lm_addr);
3228 gdb_byte buf[gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT];
3229 if (target_read_memory (dtv_addr, buf, sizeof buf) != 0)
3230 throw_error (TLS_GENERIC_ERROR,
3231 _("Cannot find thread-local variables on this target"));
3233 const struct builtin_type *builtin = builtin_type (gdbarch);
3234 CORE_ADDR addr = gdbarch_pointer_to_address (gdbarch,
3235 builtin->builtin_data_ptr, buf);
3237 addr += (tls_index + 1) * TYPE_LENGTH (builtin->builtin_data_ptr);
3238 if (target_read_memory (addr, buf, sizeof buf) != 0)
3239 throw_error (TLS_GENERIC_ERROR,
3240 _("Cannot find thread-local variables on this target"));
3242 addr = gdbarch_pointer_to_address (gdbarch, builtin->builtin_data_ptr, buf);
3243 return addr + offset;
3247 /* To be called from GDB_OSABI_DRAGONFLY handlers. */
3250 dfly_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
3253 set_gdbarch_core_pid_to_str (gdbarch, dfly_core_pid_to_str);
3254 set_gdbarch_core_thread_name (gdbarch, dfly_core_thread_name);
3255 set_gdbarch_core_xfer_siginfo (gdbarch, dfly_core_xfer_siginfo);
3256 set_gdbarch_make_corefile_notes (gdbarch, dfly_make_corefile_notes);
3257 set_gdbarch_core_info_proc (gdbarch, dfly_core_info_proc);
3258 set_gdbarch_print_auxv_entry (gdbarch, dfly_print_auxv_entry);
3259 set_gdbarch_get_siginfo_type (gdbarch, dfly_get_siginfo_type);
3261 set_gdbarch_gdb_signal_from_target (gdbarch, dfly_gdb_signal_from_target);
3262 set_gdbarch_gdb_signal_to_target (gdbarch, dfly_gdb_signal_to_target);
3265 /* `catch syscall' */
3266 set_xml_syscall_file_name (gdbarch, "syscalls/dragonfly.xml");
3267 set_gdbarch_get_syscall_number (gdbarch, dfly_get_syscall_number);
3272 _initialize_dfly_tdep (void)
3274 dfly_gdbarch_data_handle =
3275 gdbarch_data_register_post_init (init_dfly_gdbarch_data);
3276 dfly_pspace_data_handle
3277 = register_program_space_data_with_cleanup (NULL, dfly_pspace_data_cleanup);
3281 [FILE:2986:dragonfly/dfly-tdep.h]
3282 /* Target-dependent code for DragonFly, architecture independent.
3284 Copyright (C) 2009-2019 Free Software Foundation, Inc.
3286 This file is part of GDB.
3288 This program is free software; you can redistribute it and/or modify
3289 it under the terms of the GNU General Public License as published by
3290 the Free Software Foundation; either version 3 of the License, or
3291 (at your option) any later version.
3293 This program is distributed in the hope that it will be useful,
3294 but WITHOUT ANY WARRANTY; without even the implied warranty of
3295 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3296 GNU General Public License for more details.
3298 You should have received a copy of the GNU General Public License
3299 along with this program. If not, see <http://www.gnu.org/licenses/>. */
3304 extern void dfly_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch);
3306 /* Output the header for "info proc files". */
3308 extern void dfly_info_proc_files_header ();
3310 /* Output description of a single file descriptor for "info proc
3311 files". The KF_TYPE, KF_FD, KF_FLAGS, KF_OFFSET, KF_VNODE_TYPE,
3312 KF_SOCK_DOMAIN, KF_SOCK_TYPE, and KF_SOCK_PROTOCOL parameters
3313 should contain the value of the corresponding fields in a 'struct
3314 kinfo_file'. The KF_SA_LOCAL, KF_SA_PEER, and KF_PATH parameters
3315 should contain pointers to the corresponding fields in a 'struct
3318 extern void dfly_info_proc_files_entry (int kf_type, int kf_fd, int kf_flags,
3319 LONGEST kf_offset, int kf_vnode_type,
3320 int kf_sock_domain, int kf_sock_type,
3321 int kf_sock_protocol,
3322 const void *kf_sa_local,
3323 const void *kf_sa_peer,
3324 const void *kf_path);
3326 /* Output the header for "info proc mappings". ADDR_BIT is the size
3327 of a virtual address in bits. */
3329 extern void dfly_info_proc_mappings_header (int addr_bit);
3331 /* Output description of a single memory range for "info proc
3332 mappings". ADDR_BIT is the size of a virtual address in bits. The
3333 KVE_START, KVE_END, KVE_OFFSET, KVE_FLAGS, and KVE_PROTECTION
3334 parameters should contain the value of the corresponding fields in
3335 a 'struct kinfo_vmentry'. The KVE_PATH parameter should contain a
3336 pointer to the 'kve_path' field in a 'struct kinfo_vmentry'. */
3338 extern void dfly_info_proc_mappings_entry (int addr_bit, ULONGEST kve_start,
3340 ULONGEST kve_offset,
3341 int kve_flags, int kve_protection,
3342 const void *kve_path);
3344 /* Helper function to fetch the address of a thread-local variable.
3345 DTV_ADDR is the base address of the thread's dtv array. LM_ADDR is
3346 the address of the link_map structure for the associated object
3347 file. OFFSET is the offset of the variable in the object file's
3348 thread-local variable block. */
3350 extern CORE_ADDR dfly_get_thread_local_address (struct gdbarch *gdbarch,
3355 #endif /* dfly-tdep.h */
3358 [FILE:2546:dragonfly/i386-dfly-tdep.c]
3359 /* Target-dependent code for DragonFly/i386.
3361 Copyright (C) 2003-2013 Free Software Foundation, Inc.
3363 This file is part of GDB.
3365 This program is free software; you can redistribute it and/or modify
3366 it under the terms of the GNU General Public License as published by
3367 the Free Software Foundation; either version 3 of the License, or
3368 (at your option) any later version.
3370 This program is distributed in the hope that it will be useful,
3371 but WITHOUT ANY WARRANTY; without even the implied warranty of
3372 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3373 GNU General Public License for more details.
3375 You should have received a copy of the GNU General Public License
3376 along with this program. If not, see <http://www.gnu.org/licenses/>. */
3379 #include "arch-utils.h"
3380 #include "gdbcore.h"
3382 #include "regcache.h"
3384 #include "gdbsupport/x86-xstate.h"
3386 #include "i386-tdep.h"
3387 #include "i387-tdep.h"
3388 #include "dfly-tdep.h"
3389 #include "solib-svr4.h"
3391 static int i386dfly_r_reg_offset[] =
3411 /* Sigtramp routine location. */
3412 CORE_ADDR i386dfly_sigtramp_start_addr = 0xbfbfdf20;
3413 CORE_ADDR i386dfly_sigtramp_end_addr = 0xbfbfdff0;
3415 int i386dfly_sc_reg_offset[] =
3436 i386dfly_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
3438 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
3440 i386_elf_init_abi(info, gdbarch);
3442 tdep->gregset_reg_offset = i386dfly_r_reg_offset;
3443 tdep->gregset_num_regs = ARRAY_SIZE (i386dfly_r_reg_offset);
3444 tdep->sizeof_gregset = 80;
3446 tdep->sc_reg_offset = i386dfly_sc_reg_offset;
3447 tdep->sc_num_regs = ARRAY_SIZE (i386dfly_sc_reg_offset);
3449 set_solib_svr4_fetch_link_map_offsets
3450 (gdbarch, svr4_ilp32_fetch_link_map_offsets);
3454 /* Provide a prototype to silence -Wmissing-prototypes. */
3455 void _initialize_i386dfly_tdep (void);
3458 _initialize_i386dfly_tdep (void)
3460 gdbarch_register_osabi (bfd_arch_i386, 0, GDB_OSABI_DRAGONFLY,
3465 [FILE:420:dragonfly/patch-bfd_config.bfd]
3466 --- bfd/config.bfd.orig 2020-10-24 04:23:01 UTC
3468 @@ -666,7 +666,7 @@ case "${targ}" in
3470 x86_64-*-dragonfly*)
3471 targ_defvec=x86_64_elf64_vec
3472 - targ_selvecs="i386_elf32_vec iamcu_elf32_vec l1om_elf64_vec k1om_elf64_vec"
3473 + targ_selvecs="i386_elf32_vec iamcu_elf32_vec l1om_elf64_vec k1om_elf64_vec x86_64_pei_vec"
3476 x86_64-*-freebsd* | x86_64-*-kfreebsd*-gnu)
3479 [FILE:785:dragonfly/patch-gdb_Makefile.in]
3480 --- gdb/Makefile.in.orig 2020-10-24 04:23:02 UTC
3482 @@ -678,6 +678,7 @@ ALL_64_TARGET_OBS = \
3484 amd64-darwin-tdep.o \
3485 amd64-dicos-tdep.o \
3486 + amd64-dfly-tdep.o \
3488 amd64-linux-tdep.o \
3490 @@ -731,6 +732,7 @@ ALL_TARGET_OBS = \
3498 @@ -745,6 +747,7 @@ ALL_TARGET_OBS = \
3500 i386-darwin-tdep.o \
3502 + i386-dfly-tdep.o \
3506 @@ -1269,6 +1272,8 @@ HFILES_NO_SRCDIR = \
3517 [FILE:518:dragonfly/patch-gdb_amd64-tdep.h]
3518 --- gdb/amd64-tdep.h.orig 2020-10-24 04:23:02 UTC
3519 +++ gdb/amd64-tdep.h
3520 @@ -146,8 +146,8 @@ extern int amd64nbsd_r_reg_offset[];
3521 extern int amd64obsd_r_reg_offset[];
3523 /* Variables exported from amd64-fbsd-tdep.c. */
3524 -extern CORE_ADDR amd64fbsd_sigtramp_start_addr;
3525 -extern CORE_ADDR amd64fbsd_sigtramp_end_addr;
3526 -extern int amd64fbsd_sc_reg_offset[];
3527 +extern CORE_ADDR amd64dfly_sigtramp_start_addr;
3528 +extern CORE_ADDR amd64dfly_sigtramp_end_addr;
3529 +extern int amd64dfly_sc_reg_offset[];
3531 #endif /* amd64-tdep.h */
3534 [FILE:644:dragonfly/patch-gdb_bsd-kvm.c]
3535 --- gdb/bsd-kvm.c.orig 2020-09-13 02:33:41 UTC
3539 #include "readline/readline.h"
3540 #include <sys/param.h>
3541 -#include <sys/proc.h>
3542 #ifdef HAVE_SYS_USER_H
3543 #include <sys/user.h>
3545 +#include <sys/proc.h>
3547 #include "bsd-kvm.h"
3549 @@ -330,8 +330,10 @@ bsd_kvm_proc_cmd (const char *arg, int f
3550 #ifdef HAVE_STRUCT_LWP
3551 addr += offsetof (struct lwp, l_addr);
3553 +#ifndef __DragonFly__ /* XXX FIXME */
3554 addr += offsetof (struct proc, p_addr);
3558 if (kvm_read (core_kd, addr, &bsd_kvm_paddr, sizeof bsd_kvm_paddr) == -1)
3559 error (("%s"), kvm_geterr (core_kd));
3562 [FILE:361:dragonfly/patch-gdb_configure.host]
3563 --- gdb/configure.host.orig 2020-09-13 02:33:41 UTC
3564 +++ gdb/configure.host
3565 @@ -173,6 +173,7 @@ vax-*-netbsdelf* | vax-*-knetbsd*-gnu)
3566 vax-*-openbsd*) gdb_host=obsd ;;
3568 x86_64-*-linux*) gdb_host=linux64 ;;
3569 +x86_64-*-dragonfly*) gdb_host=dfly64 ;;
3570 x86_64-*-freebsd* | x86_64-*-kfreebsd*-gnu)
3572 x86_64-*-netbsd* | x86_64-*-knetbsd*-gnu)
3575 [FILE:786:dragonfly/patch-gdb_configure.nat]
3576 --- gdb/configure.nat.orig 2020-10-24 04:23:02 UTC
3577 +++ gdb/configure.nat
3578 @@ -62,6 +62,11 @@ case ${gdb_host} in
3579 NAT_CDEPS='$(srcdir)/proc-service.list'
3580 LOADLIBES='-ldl $(RDYNAMIC)'
3583 + NATDEPFILES='fork-child.o nat/fork-inferior.o inf-ptrace.o dfly-nat.o'
3584 + HAVE_NATIVE_GCORE_HOST=1
3588 NATDEPFILES='fork-child.o nat/fork-inferior.o inf-ptrace.o fbsd-nat.o'
3589 HAVE_NATIVE_GCORE_HOST=1
3590 @@ -197,6 +202,16 @@ case ${gdb_host} in
3596 + case ${gdb_host_cpu} in
3598 + # Host: DragonFly/amd64
3599 + NATDEPFILES="${NATDEPFILES} amd64-nat.o amd64-bsd-nat.o \
3600 + amd64-dfly-nat.o bsd-kvm.o x86-nat.o nat/x86-dregs.o \
3606 case ${gdb_host_cpu} in
3609 [FILE:993:dragonfly/patch-gdb_configure.tgt]
3610 --- gdb/configure.tgt.orig 2020-10-24 04:23:02 UTC
3611 +++ gdb/configure.tgt
3612 @@ -100,6 +100,8 @@ esac
3613 # 2. Get the objects per os in $TARG.
3617 + os_obs="dfly-tdep.o solib-svr4.o";;
3618 *-*-freebsd* | *-*-kfreebsd*-gnu)
3619 os_obs="fbsd-tdep.o solib-svr4.o";;
3620 *-*-netbsd* | *-*-knetbsd*-gnu)
3621 @@ -733,6 +735,11 @@ x86_64-*-linux*)
3622 i386-linux-tdep.o glibc-tdep.o \
3623 solib-svr4.o symfile-mem.o linux-tdep.o linux-record.o"
3625 +x86_64-*-dragonfly*)
3626 + # Target: DragonFly/amd64
3627 + gdb_target_obs="amd64-dfly-tdep.o ${i386_tobjs} \
3628 + i386-bsd-tdep.o i386-dfly-tdep.o"
3630 x86_64-*-freebsd* | x86_64-*-kfreebsd*-gnu)
3631 # Target: FreeBSD/amd64
3632 gdb_target_obs="amd64-fbsd-tdep.o ${i386_tobjs} \
3633 @@ -771,6 +778,8 @@ gdb_target_obs="${cpu_obs} ${os_obs} ${g
3634 # map target onto default OS ABI
3638 + gdb_osabi=GDB_OSABI_DRAGONFLY ;;
3639 *-*-freebsd* | *-*-kfreebsd*-gnu)
3640 gdb_osabi=GDB_OSABI_FREEBSD ;;
3641 *-*-linux* | *-*-uclinux*)
3644 [FILE:344:dragonfly/patch-gdb_i386-bsd-nat.c]
3645 --- gdb/i386-bsd-nat.c.orig 2020-10-24 04:23:02 UTC
3646 +++ gdb/i386-bsd-nat.c
3647 @@ -360,6 +360,8 @@ _initialize_i386bsd_nat ()
3648 #define SC_REG_OFFSET i386nbsd_sc_reg_offset
3649 #elif defined (OpenBSD)
3650 #define SC_REG_OFFSET i386obsd_sc_reg_offset
3651 +#elif defined (DragonFly)
3652 +#define SC_REG_OFFSET i386dfly_sc_reg_offset
3655 #ifdef SC_REG_OFFSET
3658 [FILE:773:dragonfly/patch-gdb_i386-tdep.h]
3659 --- gdb/i386-tdep.h.orig 2020-10-24 04:23:02 UTC
3661 @@ -471,12 +471,11 @@ extern int i386_mpx_enabled (void);
3662 /* Functions and variables exported from i386-bsd-tdep.c. */
3664 extern void i386bsd_init_abi (struct gdbarch_info, struct gdbarch *);
3665 -extern CORE_ADDR i386fbsd_sigtramp_start_addr;
3666 -extern CORE_ADDR i386fbsd_sigtramp_end_addr;
3667 +extern CORE_ADDR i386dfly_sigtramp_start_addr;
3668 +extern CORE_ADDR i386dfly_sigtramp_end_addr;
3669 extern CORE_ADDR i386obsd_sigtramp_start_addr;
3670 extern CORE_ADDR i386obsd_sigtramp_end_addr;
3671 -extern int i386fbsd4_sc_reg_offset[];
3672 -extern int i386fbsd_sc_reg_offset[];
3673 +extern int i386dfly_sc_reg_offset[];
3674 extern int i386nbsd_sc_reg_offset[];
3675 extern int i386obsd_sc_reg_offset[];
3676 extern int i386bsd_sc_reg_offset[];
3679 [FILE:728:dragonfly/patch-gdb_osabi.c]
3680 --- gdb/osabi.c.orig 2020-10-24 04:23:02 UTC
3682 @@ -68,6 +68,7 @@ static const struct osabi_names gdb_osab
3683 { "FreeBSD", NULL },
3685 { "OpenBSD", NULL },
3686 + { "DragonFly", NULL },
3687 { "WindowsCE", NULL },
3689 { "QNX-Neutrino", NULL },
3690 @@ -497,6 +498,15 @@ generic_elf_osabi_sniff_abi_tag_sections
3695 + if (check_note (abfd, sect, note, §size, "DragonFly", 4,
3696 + NT_DRAGONFLY_ABI_TAG))
3698 + /* There is no need to check the version yet. */
3699 + *osabi = GDB_OSABI_DRAGONFLY;
3704 if (check_note (abfd, sect, note, §size, "FreeBSD", 4,
3705 NT_FREEBSD_ABI_TAG))
3708 [FILE:243:dragonfly/patch-gdb_osabi.h]
3709 --- gdb/osabi.h.orig 2020-10-24 04:23:02 UTC
3711 @@ -33,6 +33,7 @@ enum gdb_osabi
3715 + GDB_OSABI_DRAGONFLY,
3721 [FILE:390:dragonfly/patch-include_elf_common.h]
3722 --- include/elf/common.h.orig 2020-10-24 04:23:02 UTC
3723 +++ include/elf/common.h
3725 /* Values for FreeBSD .note.ABI-tag notes. Note name is "FreeBSD". */
3727 #define NT_FREEBSD_ABI_TAG 1
3728 +#define NT_DRAGONFLY_ABI_TAG 1
3730 /* These three macros disassemble and assemble a symbol table st_info field,
3731 which contains the symbol binding and symbol type. The STB_ and STT_
3734 [FILE:740:sunos/patch-gdb_fbsd-tdep.c]
3735 --- gdb/fbsd-tdep.c.orig 2020-05-23 21:10:29 UTC
3737 @@ -1018,12 +1018,12 @@ fbsd_info_proc_files_entry (int kf_type,
3739 /* For local sockets, print out the first non-nul path
3740 rather than both paths. */
3741 - const struct fbsd_sockaddr_un *sun
3742 + const struct fbsd_sockaddr_un *xsunx
3743 = reinterpret_cast<const struct fbsd_sockaddr_un *> (kf_sa_local);
3744 - if (sun->sun_path[0] == 0)
3745 - sun = reinterpret_cast<const struct fbsd_sockaddr_un *>
3746 + if (xsunx->sun_path[0] == 0)
3747 + xsunx = reinterpret_cast<const struct fbsd_sockaddr_un *>
3749 - printf_filtered ("%s", sun->sun_path);
3750 + printf_filtered ("%s", xsunx->sun_path);