1 /* Native-dependent code for FreeBSD.
3 Copyright (C) 2002-2021 Free Software Foundation, Inc.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
21 #include "gdbsupport/byte-vector.h"
28 #include "gdbthread.h"
29 #include "gdbsupport/gdb_wait.h"
30 #include "inf-ptrace.h"
31 #include <sys/types.h>
32 #ifdef HAVE_SYS_PROCCTL_H
33 #include <sys/procctl.h>
35 #include <sys/procfs.h>
36 #include <sys/ptrace.h>
37 #include <sys/signal.h>
38 #include <sys/sysctl.h>
44 #include "fbsd-tdep.h"
48 /* Return the name of a file that can be opened to get the symbols for
49 the child process identified by PID. */
52 fbsd_nat_target::pid_to_exec_file (int pid
)
54 static char buf
[PATH_MAX
];
60 mib
[2] = KERN_PROC_PATHNAME
;
63 if (sysctl (mib
, 4, buf
, &buflen
, NULL
, 0) == 0)
64 /* The kern.proc.pathname.<pid> sysctl returns a length of zero
65 for processes without an associated executable such as kernel
67 return buflen
== 0 ? NULL
: buf
;
72 /* Iterate over all the memory regions in the current inferior,
73 calling FUNC for each memory region. DATA is passed as the last
77 fbsd_nat_target::find_memory_regions (find_memory_region_ftype func
,
80 pid_t pid
= inferior_ptid
.pid ();
81 struct kinfo_vmentry
*kve
;
85 gdb::unique_xmalloc_ptr
<struct kinfo_vmentry
>
86 vmentl (kinfo_getvmmap (pid
, &nitems
));
88 perror_with_name (_("Couldn't fetch VM map entries."));
90 for (i
= 0, kve
= vmentl
.get (); i
< nitems
; i
++, kve
++)
92 /* Skip unreadable segments and those where MAP_NOCORE has been set. */
93 if (!(kve
->kve_protection
& KVME_PROT_READ
)
94 || kve
->kve_flags
& KVME_FLAG_NOCOREDUMP
)
97 /* Skip segments with an invalid type. */
98 if (kve
->kve_type
!= KVME_TYPE_DEFAULT
99 && kve
->kve_type
!= KVME_TYPE_VNODE
100 && kve
->kve_type
!= KVME_TYPE_SWAP
101 && kve
->kve_type
!= KVME_TYPE_PHYS
)
104 size
= kve
->kve_end
- kve
->kve_start
;
107 fprintf_filtered (gdb_stdout
,
108 "Save segment, %ld bytes at %s (%c%c%c)\n",
110 paddress (target_gdbarch (), kve
->kve_start
),
111 kve
->kve_protection
& KVME_PROT_READ
? 'r' : '-',
112 kve
->kve_protection
& KVME_PROT_WRITE
? 'w' : '-',
113 kve
->kve_protection
& KVME_PROT_EXEC
? 'x' : '-');
116 /* Invoke the callback function to create the corefile segment.
117 Pass MODIFIED as true, we do not know the real modification state. */
118 func (kve
->kve_start
, size
, kve
->kve_protection
& KVME_PROT_READ
,
119 kve
->kve_protection
& KVME_PROT_WRITE
,
120 kve
->kve_protection
& KVME_PROT_EXEC
, 1, data
);
125 /* Fetch the command line for a running process. */
127 static gdb::unique_xmalloc_ptr
<char>
128 fbsd_fetch_cmdline (pid_t pid
)
136 mib
[2] = KERN_PROC_ARGS
;
138 if (sysctl (mib
, 4, NULL
, &len
, NULL
, 0) == -1)
144 gdb::unique_xmalloc_ptr
<char> cmdline ((char *) xmalloc (len
));
145 if (sysctl (mib
, 4, cmdline
.get (), &len
, NULL
, 0) == -1)
148 /* Join the arguments with spaces to form a single string. */
149 char *cp
= cmdline
.get ();
150 for (size_t i
= 0; i
< len
- 1; i
++)
158 /* Fetch the external variant of the kernel's internal process
159 structure for the process PID into KP. */
162 fbsd_fetch_kinfo_proc (pid_t pid
, struct kinfo_proc
*kp
)
170 mib
[2] = KERN_PROC_PID
;
172 return (sysctl (mib
, 4, kp
, &len
, NULL
, 0) == 0);
175 /* Implement the "info_proc" target_ops method. */
178 fbsd_nat_target::info_proc (const char *args
, enum info_proc_what what
)
180 gdb::unique_xmalloc_ptr
<struct kinfo_file
> fdtbl
;
182 struct kinfo_proc kp
;
184 bool do_cmdline
= false;
187 bool do_files
= false;
188 bool do_mappings
= false;
189 bool do_status
= false;
226 error (_("Not supported on this target."));
229 gdb_argv
built_argv (args
);
230 if (built_argv
.count () == 0)
232 pid
= inferior_ptid
.pid ();
234 error (_("No current process: you must name one."));
236 else if (built_argv
.count () == 1 && isdigit (built_argv
[0][0]))
237 pid
= strtol (built_argv
[0], NULL
, 10);
239 error (_("Invalid arguments."));
241 printf_filtered (_("process %d\n"), pid
);
242 if (do_cwd
|| do_exe
|| do_files
)
243 fdtbl
.reset (kinfo_getfile (pid
, &nfd
));
247 gdb::unique_xmalloc_ptr
<char> cmdline
= fbsd_fetch_cmdline (pid
);
248 if (cmdline
!= nullptr)
249 printf_filtered ("cmdline = '%s'\n", cmdline
.get ());
251 warning (_("unable to fetch command line"));
255 const char *cwd
= NULL
;
256 struct kinfo_file
*kf
= fdtbl
.get ();
257 for (int i
= 0; i
< nfd
; i
++, kf
++)
259 if (kf
->kf_type
== KF_TYPE_VNODE
&& kf
->kf_fd
== KF_FD_TYPE_CWD
)
266 printf_filtered ("cwd = '%s'\n", cwd
);
268 warning (_("unable to fetch current working directory"));
272 const char *exe
= NULL
;
273 struct kinfo_file
*kf
= fdtbl
.get ();
274 for (int i
= 0; i
< nfd
; i
++, kf
++)
276 if (kf
->kf_type
== KF_TYPE_VNODE
&& kf
->kf_fd
== KF_FD_TYPE_TEXT
)
283 exe
= pid_to_exec_file (pid
);
285 printf_filtered ("exe = '%s'\n", exe
);
287 warning (_("unable to fetch executable path name"));
291 struct kinfo_file
*kf
= fdtbl
.get ();
295 fbsd_info_proc_files_header ();
296 for (int i
= 0; i
< nfd
; i
++, kf
++)
297 fbsd_info_proc_files_entry (kf
->kf_type
, kf
->kf_fd
, kf
->kf_flags
,
298 kf
->kf_offset
, kf
->kf_vnode_type
,
299 kf
->kf_sock_domain
, kf
->kf_sock_type
,
300 kf
->kf_sock_protocol
, &kf
->kf_sa_local
,
301 &kf
->kf_sa_peer
, kf
->kf_path
);
304 warning (_("unable to fetch list of open files"));
309 gdb::unique_xmalloc_ptr
<struct kinfo_vmentry
>
310 vmentl (kinfo_getvmmap (pid
, &nvment
));
312 if (vmentl
!= nullptr)
314 int addr_bit
= TARGET_CHAR_BIT
* sizeof (void *);
315 fbsd_info_proc_mappings_header (addr_bit
);
317 struct kinfo_vmentry
*kve
= vmentl
.get ();
318 for (int i
= 0; i
< nvment
; i
++, kve
++)
319 fbsd_info_proc_mappings_entry (addr_bit
, kve
->kve_start
,
320 kve
->kve_end
, kve
->kve_offset
,
321 kve
->kve_flags
, kve
->kve_protection
,
325 warning (_("unable to fetch virtual memory map"));
329 if (!fbsd_fetch_kinfo_proc (pid
, &kp
))
330 warning (_("Failed to fetch process information"));
336 printf_filtered ("Name: %s\n", kp
.ki_comm
);
343 state
= "R (running)";
346 state
= "T (stopped)";
349 state
= "Z (zombie)";
352 state
= "S (sleeping)";
355 state
= "W (interrupt wait)";
358 state
= "L (blocked on lock)";
361 state
= "? (unknown)";
364 printf_filtered ("State: %s\n", state
);
365 printf_filtered ("Parent process: %d\n", kp
.ki_ppid
);
366 printf_filtered ("Process group: %d\n", kp
.ki_pgid
);
367 printf_filtered ("Session id: %d\n", kp
.ki_sid
);
368 printf_filtered ("TTY: %s\n", pulongest (kp
.ki_tdev
));
369 printf_filtered ("TTY owner process group: %d\n", kp
.ki_tpgid
);
370 printf_filtered ("User IDs (real, effective, saved): %d %d %d\n",
371 kp
.ki_ruid
, kp
.ki_uid
, kp
.ki_svuid
);
372 printf_filtered ("Group IDs (real, effective, saved): %d %d %d\n",
373 kp
.ki_rgid
, kp
.ki_groups
[0], kp
.ki_svgid
);
374 printf_filtered ("Groups: ");
375 for (int i
= 0; i
< kp
.ki_ngroups
; i
++)
376 printf_filtered ("%d ", kp
.ki_groups
[i
]);
377 printf_filtered ("\n");
378 printf_filtered ("Minor faults (no memory page): %ld\n",
379 kp
.ki_rusage
.ru_minflt
);
380 printf_filtered ("Minor faults, children: %ld\n",
381 kp
.ki_rusage_ch
.ru_minflt
);
382 printf_filtered ("Major faults (memory page faults): %ld\n",
383 kp
.ki_rusage
.ru_majflt
);
384 printf_filtered ("Major faults, children: %ld\n",
385 kp
.ki_rusage_ch
.ru_majflt
);
386 printf_filtered ("utime: %s.%06ld\n",
387 plongest (kp
.ki_rusage
.ru_utime
.tv_sec
),
388 kp
.ki_rusage
.ru_utime
.tv_usec
);
389 printf_filtered ("stime: %s.%06ld\n",
390 plongest (kp
.ki_rusage
.ru_stime
.tv_sec
),
391 kp
.ki_rusage
.ru_stime
.tv_usec
);
392 printf_filtered ("utime, children: %s.%06ld\n",
393 plongest (kp
.ki_rusage_ch
.ru_utime
.tv_sec
),
394 kp
.ki_rusage_ch
.ru_utime
.tv_usec
);
395 printf_filtered ("stime, children: %s.%06ld\n",
396 plongest (kp
.ki_rusage_ch
.ru_stime
.tv_sec
),
397 kp
.ki_rusage_ch
.ru_stime
.tv_usec
);
398 printf_filtered ("'nice' value: %d\n", kp
.ki_nice
);
399 printf_filtered ("Start time: %s.%06ld\n",
400 plongest (kp
.ki_start
.tv_sec
),
401 kp
.ki_start
.tv_usec
);
402 pgtok
= getpagesize () / 1024;
403 printf_filtered ("Virtual memory size: %s kB\n",
404 pulongest (kp
.ki_size
/ 1024));
405 printf_filtered ("Data size: %s kB\n",
406 pulongest (kp
.ki_dsize
* pgtok
));
407 printf_filtered ("Stack size: %s kB\n",
408 pulongest (kp
.ki_ssize
* pgtok
));
409 printf_filtered ("Text size: %s kB\n",
410 pulongest (kp
.ki_tsize
* pgtok
));
411 printf_filtered ("Resident set size: %s kB\n",
412 pulongest (kp
.ki_rssize
* pgtok
));
413 printf_filtered ("Maximum RSS: %s kB\n",
414 pulongest (kp
.ki_rusage
.ru_maxrss
));
415 printf_filtered ("Pending Signals: ");
416 for (int i
= 0; i
< _SIG_WORDS
; i
++)
417 printf_filtered ("%08x ", kp
.ki_siglist
.__bits
[i
]);
418 printf_filtered ("\n");
419 printf_filtered ("Ignored Signals: ");
420 for (int i
= 0; i
< _SIG_WORDS
; i
++)
421 printf_filtered ("%08x ", kp
.ki_sigignore
.__bits
[i
]);
422 printf_filtered ("\n");
423 printf_filtered ("Caught Signals: ");
424 for (int i
= 0; i
< _SIG_WORDS
; i
++)
425 printf_filtered ("%08x ", kp
.ki_sigcatch
.__bits
[i
]);
426 printf_filtered ("\n");
433 /* Return the size of siginfo for the current inferior. */
441 /* This structure matches the naming and layout of `siginfo_t' in
442 <sys/signal.h>. In particular, the `si_foo' macros defined in that
443 header can be used with both types to copy fields in the `_reason'
455 union sigval32 si_value
;
488 struct gdbarch
*gdbarch
= get_frame_arch (get_current_frame ());
490 /* Is the inferior 32-bit? If so, use the 32-bit siginfo size. */
491 if (gdbarch_long_bit (gdbarch
) == 32)
492 return sizeof (struct siginfo32
);
494 return sizeof (siginfo_t
);
497 /* Convert a native 64-bit siginfo object to a 32-bit object. Note
498 that FreeBSD doesn't support writing to $_siginfo, so this only
499 needs to convert one way. */
502 fbsd_convert_siginfo (siginfo_t
*si
)
505 struct gdbarch
*gdbarch
= get_frame_arch (get_current_frame ());
507 /* Is the inferior 32-bit? If not, nothing to do. */
508 if (gdbarch_long_bit (gdbarch
) != 32)
511 struct siginfo32 si32
;
513 si32
.si_signo
= si
->si_signo
;
514 si32
.si_errno
= si
->si_errno
;
515 si32
.si_code
= si
->si_code
;
516 si32
.si_pid
= si
->si_pid
;
517 si32
.si_uid
= si
->si_uid
;
518 si32
.si_status
= si
->si_status
;
519 si32
.si_addr
= (uintptr_t) si
->si_addr
;
521 /* If sival_ptr is being used instead of sival_int on a big-endian
522 platform, then sival_int will be zero since it holds the upper
523 32-bits of the pointer value. */
524 #if _BYTE_ORDER == _BIG_ENDIAN
525 if (si
->si_value
.sival_int
== 0)
526 si32
.si_value
.sival_ptr
= (uintptr_t) si
->si_value
.sival_ptr
;
528 si32
.si_value
.sival_int
= si
->si_value
.sival_int
;
530 si32
.si_value
.sival_int
= si
->si_value
.sival_int
;
533 /* Always copy the spare fields and then possibly overwrite them for
534 signal-specific or code-specific fields. */
535 si32
._reason
.__spare__
.__spare1__
= si
->_reason
.__spare__
.__spare1__
;
536 for (int i
= 0; i
< 7; i
++)
537 si32
._reason
.__spare__
.__spare2__
[i
] = si
->_reason
.__spare__
.__spare2__
[i
];
538 switch (si
->si_signo
) {
543 si32
.si_trapno
= si
->si_trapno
;
546 switch (si
->si_code
) {
548 si32
.si_timerid
= si
->si_timerid
;
549 si32
.si_overrun
= si
->si_overrun
;
552 si32
.si_mqd
= si
->si_mqd
;
556 memcpy(si
, &si32
, sizeof (si32
));
560 /* Implement the "xfer_partial" target_ops method. */
562 enum target_xfer_status
563 fbsd_nat_target::xfer_partial (enum target_object object
,
564 const char *annex
, gdb_byte
*readbuf
,
565 const gdb_byte
*writebuf
,
566 ULONGEST offset
, ULONGEST len
,
567 ULONGEST
*xfered_len
)
569 pid_t pid
= inferior_ptid
.pid ();
573 case TARGET_OBJECT_SIGNAL_INFO
:
575 struct ptrace_lwpinfo pl
;
578 /* FreeBSD doesn't support writing to $_siginfo. */
579 if (writebuf
!= NULL
)
580 return TARGET_XFER_E_IO
;
582 if (inferior_ptid
.lwp_p ())
583 pid
= inferior_ptid
.lwp ();
585 siginfo_size
= fbsd_siginfo_size ();
586 if (offset
> siginfo_size
)
587 return TARGET_XFER_E_IO
;
589 if (ptrace (PT_LWPINFO
, pid
, (PTRACE_TYPE_ARG3
) &pl
, sizeof (pl
)) == -1)
590 return TARGET_XFER_E_IO
;
592 if (!(pl
.pl_flags
& PL_FLAG_SI
))
593 return TARGET_XFER_E_IO
;
595 fbsd_convert_siginfo (&pl
.pl_siginfo
);
596 if (offset
+ len
> siginfo_size
)
597 len
= siginfo_size
- offset
;
599 memcpy (readbuf
, ((gdb_byte
*) &pl
.pl_siginfo
) + offset
, len
);
601 return TARGET_XFER_OK
;
603 #ifdef KERN_PROC_AUXV
604 case TARGET_OBJECT_AUXV
:
606 gdb::byte_vector buf_storage
;
611 if (writebuf
!= NULL
)
612 return TARGET_XFER_E_IO
;
615 mib
[2] = KERN_PROC_AUXV
;
624 buflen
= offset
+ len
;
625 buf_storage
.resize (buflen
);
626 buf
= buf_storage
.data ();
628 if (sysctl (mib
, 4, buf
, &buflen
, NULL
, 0) == 0)
635 memcpy (readbuf
, buf
+ offset
, buflen
);
640 *xfered_len
= buflen
;
641 return (buflen
== 0) ? TARGET_XFER_EOF
: TARGET_XFER_OK
;
643 return TARGET_XFER_E_IO
;
646 #if defined(KERN_PROC_VMMAP) && defined(KERN_PROC_PS_STRINGS)
647 case TARGET_OBJECT_FREEBSD_VMMAP
:
648 case TARGET_OBJECT_FREEBSD_PS_STRINGS
:
650 gdb::byte_vector buf_storage
;
656 uint32_t struct_size
;
659 case TARGET_OBJECT_FREEBSD_VMMAP
:
660 proc_target
= KERN_PROC_VMMAP
;
661 struct_size
= sizeof (struct kinfo_vmentry
);
663 case TARGET_OBJECT_FREEBSD_PS_STRINGS
:
664 proc_target
= KERN_PROC_PS_STRINGS
;
665 struct_size
= sizeof (void *);
669 if (writebuf
!= NULL
)
670 return TARGET_XFER_E_IO
;
674 mib
[2] = proc_target
;
677 if (sysctl (mib
, 4, NULL
, &buflen
, NULL
, 0) != 0)
678 return TARGET_XFER_E_IO
;
679 buflen
+= sizeof (struct_size
);
681 if (offset
>= buflen
)
684 return TARGET_XFER_EOF
;
687 buf_storage
.resize (buflen
);
688 buf
= buf_storage
.data ();
690 memcpy (buf
, &struct_size
, sizeof (struct_size
));
691 buflen
-= sizeof (struct_size
);
692 if (sysctl (mib
, 4, buf
+ sizeof (struct_size
), &buflen
, NULL
, 0) != 0)
693 return TARGET_XFER_E_IO
;
694 buflen
+= sizeof (struct_size
);
696 if (buflen
- offset
< len
)
697 len
= buflen
- offset
;
698 memcpy (readbuf
, buf
+ offset
, len
);
700 return TARGET_XFER_OK
;
704 return inf_ptrace_target::xfer_partial (object
, annex
,
705 readbuf
, writebuf
, offset
,
710 static bool debug_fbsd_lwp
;
711 static bool debug_fbsd_nat
;
714 show_fbsd_lwp_debug (struct ui_file
*file
, int from_tty
,
715 struct cmd_list_element
*c
, const char *value
)
717 fprintf_filtered (file
, _("Debugging of FreeBSD lwp module is %s.\n"), value
);
721 show_fbsd_nat_debug (struct ui_file
*file
, int from_tty
,
722 struct cmd_list_element
*c
, const char *value
)
724 fprintf_filtered (file
, _("Debugging of FreeBSD native target is %s.\n"),
728 #define fbsd_lwp_debug_printf(fmt, ...) \
729 debug_prefixed_printf_cond (debug_fbsd_lwp, "fbsd-lwp", fmt, ##__VA_ARGS__)
731 #define fbsd_nat_debug_printf(fmt, ...) \
732 debug_prefixed_printf_cond (debug_fbsd_nat, "fbsd-nat", fmt, ##__VA_ARGS__)
736 FreeBSD's first thread support was via a "reentrant" version of libc
737 (libc_r) that first shipped in 2.2.7. This library multiplexed all
738 of the threads in a process onto a single kernel thread. This
739 library was supported via the bsd-uthread target.
741 FreeBSD 5.1 introduced two new threading libraries that made use of
742 multiple kernel threads. The first (libkse) scheduled M user
743 threads onto N (<= M) kernel threads (LWPs). The second (libthr)
744 bound each user thread to a dedicated kernel thread. libkse shipped
745 as the default threading library (libpthread).
747 FreeBSD 5.3 added a libthread_db to abstract the interface across
748 the various thread libraries (libc_r, libkse, and libthr).
750 FreeBSD 7.0 switched the default threading library from from libkse
751 to libpthread and removed libc_r.
753 FreeBSD 8.0 removed libkse and the in-kernel support for it. The
754 only threading library supported by 8.0 and later is libthr which
755 ties each user thread directly to an LWP. To simplify the
756 implementation, this target only supports LWP-backed threads using
757 ptrace directly rather than libthread_db.
759 FreeBSD 11.0 introduced LWP event reporting via PT_LWP_EVENTS.
762 /* Return true if PTID is still active in the inferior. */
765 fbsd_nat_target::thread_alive (ptid_t ptid
)
769 struct ptrace_lwpinfo pl
;
771 if (ptrace (PT_LWPINFO
, ptid
.lwp (), (caddr_t
) &pl
, sizeof pl
)
774 #ifdef PL_FLAG_EXITED
775 if (pl
.pl_flags
& PL_FLAG_EXITED
)
783 /* Convert PTID to a string. */
786 fbsd_nat_target::pid_to_str (ptid_t ptid
)
793 int pid
= ptid
.pid ();
795 return string_printf ("LWP %d of process %d", lwp
, pid
);
798 return normal_pid_to_str (ptid
);
801 #ifdef HAVE_STRUCT_PTRACE_LWPINFO_PL_TDNAME
802 /* Return the name assigned to a thread by an application. Returns
803 the string in a static buffer. */
806 fbsd_nat_target::thread_name (struct thread_info
*thr
)
808 struct ptrace_lwpinfo pl
;
809 struct kinfo_proc kp
;
810 int pid
= thr
->ptid
.pid ();
811 long lwp
= thr
->ptid
.lwp ();
812 static char buf
[sizeof pl
.pl_tdname
+ 1];
814 /* Note that ptrace_lwpinfo returns the process command in pl_tdname
815 if a name has not been set explicitly. Return a NULL name in
817 if (!fbsd_fetch_kinfo_proc (pid
, &kp
))
818 perror_with_name (_("Failed to fetch process information"));
819 if (ptrace (PT_LWPINFO
, lwp
, (caddr_t
) &pl
, sizeof pl
) == -1)
820 perror_with_name (("ptrace"));
821 if (strcmp (kp
.ki_comm
, pl
.pl_tdname
) == 0)
823 xsnprintf (buf
, sizeof buf
, "%s", pl
.pl_tdname
);
828 /* Enable additional event reporting on new processes.
830 To catch fork events, PTRACE_FORK is set on every traced process
831 to enable stops on returns from fork or vfork. Note that both the
832 parent and child will always stop, even if system call stops are
835 To catch LWP events, PTRACE_EVENTS is set on every traced process.
836 This enables stops on the birth for new LWPs (excluding the "main" LWP)
837 and the death of LWPs (excluding the last LWP in a process). Note
838 that unlike fork events, the LWP that creates a new LWP does not
842 fbsd_enable_proc_events (pid_t pid
)
844 #ifdef PT_GET_EVENT_MASK
847 if (ptrace (PT_GET_EVENT_MASK
, pid
, (PTRACE_TYPE_ARG3
)&events
,
848 sizeof (events
)) == -1)
849 perror_with_name (("ptrace"));
850 events
|= PTRACE_FORK
| PTRACE_LWP
;
852 events
|= PTRACE_VFORK
;
854 if (ptrace (PT_SET_EVENT_MASK
, pid
, (PTRACE_TYPE_ARG3
)&events
,
855 sizeof (events
)) == -1)
856 perror_with_name (("ptrace"));
859 if (ptrace (PT_FOLLOW_FORK
, pid
, (PTRACE_TYPE_ARG3
)0, 1) == -1)
860 perror_with_name (("ptrace"));
863 if (ptrace (PT_LWP_EVENTS
, pid
, (PTRACE_TYPE_ARG3
)0, 1) == -1)
864 perror_with_name (("ptrace"));
869 /* Add threads for any new LWPs in a process.
871 When LWP events are used, this function is only used to detect existing
872 threads when attaching to a process. On older systems, this function is
873 called to discover new threads each time the thread list is updated. */
876 fbsd_add_threads (fbsd_nat_target
*target
, pid_t pid
)
880 gdb_assert (!in_thread_list (target
, ptid_t (pid
)));
881 nlwps
= ptrace (PT_GETNUMLWPS
, pid
, NULL
, 0);
883 perror_with_name (("ptrace"));
885 gdb::unique_xmalloc_ptr
<lwpid_t
[]> lwps (XCNEWVEC (lwpid_t
, nlwps
));
887 nlwps
= ptrace (PT_GETLWPLIST
, pid
, (caddr_t
) lwps
.get (), nlwps
);
889 perror_with_name (("ptrace"));
891 for (i
= 0; i
< nlwps
; i
++)
893 ptid_t ptid
= ptid_t (pid
, lwps
[i
]);
895 if (!in_thread_list (target
, ptid
))
898 struct ptrace_lwpinfo pl
;
900 /* Don't add exited threads. Note that this is only called
901 when attaching to a multi-threaded process. */
902 if (ptrace (PT_LWPINFO
, lwps
[i
], (caddr_t
) &pl
, sizeof pl
) == -1)
903 perror_with_name (("ptrace"));
904 if (pl
.pl_flags
& PL_FLAG_EXITED
)
907 fbsd_lwp_debug_printf ("adding thread for LWP %u", lwps
[i
]);
908 add_thread (target
, ptid
);
913 /* Implement the "update_thread_list" target_ops method. */
916 fbsd_nat_target::update_thread_list ()
919 /* With support for thread events, threads are added/deleted from the
920 list as events are reported, so just try deleting exited threads. */
921 delete_exited_threads ();
925 fbsd_add_threads (this, inferior_ptid
.pid ());
931 To catch fork events, PT_FOLLOW_FORK is set on every traced process
932 to enable stops on returns from fork or vfork. Note that both the
933 parent and child will always stop, even if system call stops are not
936 After a fork, both the child and parent process will stop and report
937 an event. However, there is no guarantee of order. If the parent
938 reports its stop first, then fbsd_wait explicitly waits for the new
939 child before returning. If the child reports its stop first, then
940 the event is saved on a list and ignored until the parent's stop is
941 reported. fbsd_wait could have been changed to fetch the parent PID
942 of the new child and used that to wait for the parent explicitly.
943 However, if two threads in the parent fork at the same time, then
944 the wait on the parent might return the "wrong" fork event.
946 The initial version of PT_FOLLOW_FORK did not set PL_FLAG_CHILD for
947 the new child process. This flag could be inferred by treating any
948 events for an unknown pid as a new child.
950 In addition, the initial version of PT_FOLLOW_FORK did not report a
951 stop event for the parent process of a vfork until after the child
952 process executed a new program or exited. The kernel was changed to
953 defer the wait for exit or exec of the child until after posting the
954 stop event shortly after the change to introduce PL_FLAG_CHILD.
955 This could be worked around by reporting a vfork event when the
956 child event posted and ignoring the subsequent event from the
959 This implementation requires both of these fixes for simplicity's
960 sake. FreeBSD versions newer than 9.1 contain both fixes.
963 static std::list
<ptid_t
> fbsd_pending_children
;
965 /* Record a new child process event that is reported before the
966 corresponding fork event in the parent. */
969 fbsd_remember_child (ptid_t pid
)
971 fbsd_pending_children
.push_front (pid
);
974 /* Check for a previously-recorded new child process event for PID.
975 If one is found, remove it from the list and return the PTID. */
978 fbsd_is_child_pending (pid_t pid
)
980 for (auto it
= fbsd_pending_children
.begin ();
981 it
!= fbsd_pending_children
.end (); it
++)
982 if (it
->pid () == pid
)
985 fbsd_pending_children
.erase (it
);
992 static std::forward_list
<ptid_t
> fbsd_pending_vfork_done
;
994 /* Record a pending vfork done event. */
997 fbsd_add_vfork_done (ptid_t pid
)
999 fbsd_pending_vfork_done
.push_front (pid
);
1002 /* Check for a pending vfork done event for a specific PID. */
1005 fbsd_is_vfork_done_pending (pid_t pid
)
1007 for (auto it
= fbsd_pending_vfork_done
.begin ();
1008 it
!= fbsd_pending_vfork_done
.end (); it
++)
1009 if (it
->pid () == pid
)
1014 /* Check for a pending vfork done event. If one is found, remove it
1015 from the list and return the PTID. */
1018 fbsd_next_vfork_done (void)
1020 if (!fbsd_pending_vfork_done
.empty ())
1022 ptid_t ptid
= fbsd_pending_vfork_done
.front ();
1023 fbsd_pending_vfork_done
.pop_front ();
1031 /* Implement the "resume" target_ops method. */
1034 fbsd_nat_target::resume (ptid_t ptid
, int step
, enum gdb_signal signo
)
1036 #if defined(TDP_RFPPWAIT) && !defined(PTRACE_VFORK)
1039 /* Don't PT_CONTINUE a process which has a pending vfork done event. */
1040 if (minus_one_ptid
== ptid
)
1041 pid
= inferior_ptid
.pid ();
1044 if (fbsd_is_vfork_done_pending (pid
))
1048 fbsd_lwp_debug_printf ("ptid (%d, %ld, %s)", ptid
.pid (), ptid
.lwp (),
1049 pulongest (ptid
.tid ()));
1052 /* If ptid is a specific LWP, suspend all other LWPs in the process. */
1053 inferior
*inf
= find_inferior_ptid (this, ptid
);
1055 for (thread_info
*tp
: inf
->non_exited_threads ())
1059 if (tp
->ptid
.lwp () == ptid
.lwp ())
1060 request
= PT_RESUME
;
1062 request
= PT_SUSPEND
;
1064 if (ptrace (request
, tp
->ptid
.lwp (), NULL
, 0) == -1)
1065 perror_with_name (("ptrace"));
1070 /* If ptid is a wildcard, resume all matching threads (they won't run
1071 until the process is continued however). */
1072 for (thread_info
*tp
: all_non_exited_threads (this, ptid
))
1073 if (ptrace (PT_RESUME
, tp
->ptid
.lwp (), NULL
, 0) == -1)
1074 perror_with_name (("ptrace"));
1075 ptid
= inferior_ptid
;
1078 #if __FreeBSD_version < 1200052
1079 /* When multiple threads within a process wish to report STOPPED
1080 events from wait(), the kernel picks one thread event as the
1081 thread event to report. The chosen thread event is retrieved via
1082 PT_LWPINFO by passing the process ID as the request pid. If
1083 multiple events are pending, then the subsequent wait() after
1084 resuming a process will report another STOPPED event after
1085 resuming the process to handle the next thread event and so on.
1087 A single thread event is cleared as a side effect of resuming the
1088 process with PT_CONTINUE, PT_STEP, etc. In older kernels,
1089 however, the request pid was used to select which thread's event
1090 was cleared rather than always clearing the event that was just
1091 reported. To avoid clearing the event of the wrong LWP, always
1092 pass the process ID instead of an LWP ID to PT_CONTINUE or
1095 In the case of stepping, the process ID cannot be used with
1096 PT_STEP since it would step the thread that reported an event
1097 which may not be the thread indicated by PTID. For stepping, use
1098 PT_SETSTEP to enable stepping on the desired thread before
1099 resuming the process via PT_CONTINUE instead of using
1103 if (ptrace (PT_SETSTEP
, get_ptrace_pid (ptid
), NULL
, 0) == -1)
1104 perror_with_name (("ptrace"));
1107 ptid
= ptid_t (ptid
.pid ());
1109 inf_ptrace_target::resume (ptid
, step
, signo
);
1112 #ifdef USE_SIGTRAP_SIGINFO
1113 /* Handle breakpoint and trace traps reported via SIGTRAP. If the
1114 trap was a breakpoint or trace trap that should be reported to the
1115 core, return true. */
1118 fbsd_handle_debug_trap (fbsd_nat_target
*target
, ptid_t ptid
,
1119 const struct ptrace_lwpinfo
&pl
)
1122 /* Ignore traps without valid siginfo or for signals other than
1125 FreeBSD kernels prior to r341800 can return stale siginfo for at
1126 least some events, but those events can be identified by
1127 additional flags set in pl_flags. True breakpoint and
1128 single-step traps should not have other flags set in
1130 if (pl
.pl_flags
!= PL_FLAG_SI
|| pl
.pl_siginfo
.si_signo
!= SIGTRAP
)
1133 /* Trace traps are either a single step or a hardware watchpoint or
1135 if (pl
.pl_siginfo
.si_code
== TRAP_TRACE
)
1137 fbsd_nat_debug_printf ("trace trap for LWP %ld", ptid
.lwp ());
1141 if (pl
.pl_siginfo
.si_code
== TRAP_BRKPT
)
1143 /* Fixup PC for the software breakpoint. */
1144 struct regcache
*regcache
= get_thread_regcache (target
, ptid
);
1145 struct gdbarch
*gdbarch
= regcache
->arch ();
1146 int decr_pc
= gdbarch_decr_pc_after_break (gdbarch
);
1148 fbsd_nat_debug_printf ("sw breakpoint trap for LWP %ld", ptid
.lwp ());
1153 pc
= regcache_read_pc (regcache
);
1154 regcache_write_pc (regcache
, pc
- decr_pc
);
1163 /* Wait for the child specified by PTID to do something. Return the
1164 process ID of the child, or MINUS_ONE_PTID in case of error; store
1165 the status in *OURSTATUS. */
1168 fbsd_nat_target::wait (ptid_t ptid
, struct target_waitstatus
*ourstatus
,
1169 target_wait_flags target_options
)
1175 #ifndef PTRACE_VFORK
1176 wptid
= fbsd_next_vfork_done ();
1177 if (wptid
!= null_ptid
)
1179 ourstatus
->kind
= TARGET_WAITKIND_VFORK_DONE
;
1183 wptid
= inf_ptrace_target::wait (ptid
, ourstatus
, target_options
);
1184 if (ourstatus
->kind () == TARGET_WAITKIND_STOPPED
)
1186 struct ptrace_lwpinfo pl
;
1191 if (ptrace (PT_LWPINFO
, pid
, (caddr_t
) &pl
, sizeof pl
) == -1)
1192 perror_with_name (("ptrace"));
1194 wptid
= ptid_t (pid
, pl
.pl_lwpid
);
1198 fbsd_nat_debug_printf ("stop for LWP %u event %d flags %#x",
1199 pl
.pl_lwpid
, pl
.pl_event
, pl
.pl_flags
);
1200 if (pl
.pl_flags
& PL_FLAG_SI
)
1201 fbsd_nat_debug_printf ("si_signo %u si_code %u",
1202 pl
.pl_siginfo
.si_signo
,
1203 pl
.pl_siginfo
.si_code
);
1206 #ifdef PT_LWP_EVENTS
1207 if (pl
.pl_flags
& PL_FLAG_EXITED
)
1209 /* If GDB attaches to a multi-threaded process, exiting
1210 threads might be skipped during post_attach that
1211 have not yet reported their PL_FLAG_EXITED event.
1212 Ignore EXITED events for an unknown LWP. */
1213 thread_info
*thr
= find_thread_ptid (this, wptid
);
1216 fbsd_lwp_debug_printf ("deleting thread for LWP %u",
1218 if (print_thread_events
)
1219 printf_unfiltered (_("[%s exited]\n"),
1220 target_pid_to_str (wptid
).c_str ());
1221 delete_thread (thr
);
1223 if (ptrace (PT_CONTINUE
, pid
, (caddr_t
) 1, 0) == -1)
1224 perror_with_name (("ptrace"));
1229 /* Switch to an LWP PTID on the first stop in a new process.
1230 This is done after handling PL_FLAG_EXITED to avoid
1231 switching to an exited LWP. It is done before checking
1232 PL_FLAG_BORN in case the first stop reported after
1233 attaching to an existing process is a PL_FLAG_BORN
1235 if (in_thread_list (this, ptid_t (pid
)))
1237 fbsd_lwp_debug_printf ("using LWP %u for first thread",
1239 thread_change_ptid (this, ptid_t (pid
), wptid
);
1242 #ifdef PT_LWP_EVENTS
1243 if (pl
.pl_flags
& PL_FLAG_BORN
)
1245 /* If GDB attaches to a multi-threaded process, newborn
1246 threads might be added by fbsd_add_threads that have
1247 not yet reported their PL_FLAG_BORN event. Ignore
1248 BORN events for an already-known LWP. */
1249 if (!in_thread_list (this, wptid
))
1251 fbsd_lwp_debug_printf ("adding thread for LWP %u",
1253 add_thread (this, wptid
);
1255 ourstatus
->set_spurious ();
1261 if (pl
.pl_flags
& PL_FLAG_FORKED
)
1263 #ifndef PTRACE_VFORK
1264 struct kinfo_proc kp
;
1266 bool is_vfork
= false;
1270 child
= pl
.pl_child_pid
;
1272 if (pl
.pl_flags
& PL_FLAG_VFORKED
)
1276 /* Make sure the other end of the fork is stopped too. */
1277 child_ptid
= fbsd_is_child_pending (child
);
1278 if (child_ptid
== null_ptid
)
1280 pid
= waitpid (child
, &status
, 0);
1282 perror_with_name (("waitpid"));
1284 gdb_assert (pid
== child
);
1286 if (ptrace (PT_LWPINFO
, child
, (caddr_t
)&pl
, sizeof pl
) == -1)
1287 perror_with_name (("ptrace"));
1289 gdb_assert (pl
.pl_flags
& PL_FLAG_CHILD
);
1290 child_ptid
= ptid_t (child
, pl
.pl_lwpid
);
1293 /* Enable additional events on the child process. */
1294 fbsd_enable_proc_events (child_ptid
.pid ());
1296 #ifndef PTRACE_VFORK
1297 /* For vfork, the child process will have the P_PPWAIT
1299 if (fbsd_fetch_kinfo_proc (child
, &kp
))
1301 if (kp
.ki_flag
& P_PPWAIT
)
1305 warning (_("Failed to fetch process information"));
1309 ourstatus
->set_vforked (child_ptid
);
1311 ourstatus
->set_forked (child_ptid
);
1316 if (pl
.pl_flags
& PL_FLAG_CHILD
)
1318 /* Remember that this child forked, but do not report it
1319 until the parent reports its corresponding fork
1321 fbsd_remember_child (wptid
);
1326 if (pl
.pl_flags
& PL_FLAG_VFORK_DONE
)
1328 ourstatus
->set_vfork_done ();
1334 if (pl
.pl_flags
& PL_FLAG_EXEC
)
1336 ourstatus
->set_execd
1337 (make_unique_xstrdup (pid_to_exec_file (pid
)));
1341 #ifdef USE_SIGTRAP_SIGINFO
1342 if (fbsd_handle_debug_trap (this, wptid
, pl
))
1346 /* Note that PL_FLAG_SCE is set for any event reported while
1347 a thread is executing a system call in the kernel. In
1348 particular, signals that interrupt a sleep in a system
1349 call will report this flag as part of their event. Stops
1350 explicitly for system call entry and exit always use
1351 SIGTRAP, so only treat SIGTRAP events as system call
1352 entry/exit events. */
1353 if (pl
.pl_flags
& (PL_FLAG_SCE
| PL_FLAG_SCX
)
1354 && ourstatus
->sig () == SIGTRAP
)
1356 #ifdef HAVE_STRUCT_PTRACE_LWPINFO_PL_SYSCALL_CODE
1357 if (catch_syscall_enabled ())
1359 if (catching_syscall_number (pl
.pl_syscall_code
))
1361 if (pl
.pl_flags
& PL_FLAG_SCE
)
1362 ourstatus
->set_syscall_entry (pl
.pl_syscall_code
);
1364 ourstatus
->set_syscall_return (pl
.pl_syscall_code
);
1370 /* If the core isn't interested in this event, just
1371 continue the process explicitly and wait for another
1372 event. Note that PT_SYSCALL is "sticky" on FreeBSD
1373 and once system call stops are enabled on a process
1374 it stops for all system call entries and exits. */
1375 if (ptrace (PT_CONTINUE
, pid
, (caddr_t
) 1, 0) == -1)
1376 perror_with_name (("ptrace"));
1384 #ifdef USE_SIGTRAP_SIGINFO
1385 /* Implement the "stopped_by_sw_breakpoint" target_ops method. */
1388 fbsd_nat_target::stopped_by_sw_breakpoint ()
1390 struct ptrace_lwpinfo pl
;
1392 if (ptrace (PT_LWPINFO
, get_ptrace_pid (inferior_ptid
), (caddr_t
) &pl
,
1396 return (pl
.pl_flags
== PL_FLAG_SI
1397 && pl
.pl_siginfo
.si_signo
== SIGTRAP
1398 && pl
.pl_siginfo
.si_code
== TRAP_BRKPT
);
1401 /* Implement the "supports_stopped_by_sw_breakpoint" target_ops
1405 fbsd_nat_target::supports_stopped_by_sw_breakpoint ()
1411 #ifdef PROC_ASLR_CTL
1412 class maybe_disable_address_space_randomization
1415 explicit maybe_disable_address_space_randomization (bool disable_randomization
)
1417 if (disable_randomization
)
1419 if (procctl (P_PID
, getpid (), PROC_ASLR_STATUS
, &m_aslr_ctl
) == -1)
1421 warning (_("Failed to fetch current address space randomization "
1422 "status: %s"), safe_strerror (errno
));
1426 m_aslr_ctl
&= ~PROC_ASLR_ACTIVE
;
1427 if (m_aslr_ctl
== PROC_ASLR_FORCE_DISABLE
)
1430 int ctl
= PROC_ASLR_FORCE_DISABLE
;
1431 if (procctl (P_PID
, getpid (), PROC_ASLR_CTL
, &ctl
) == -1)
1433 warning (_("Error disabling address space randomization: %s"),
1434 safe_strerror (errno
));
1438 m_aslr_ctl_set
= true;
1442 ~maybe_disable_address_space_randomization ()
1446 if (procctl (P_PID
, getpid (), PROC_ASLR_CTL
, &m_aslr_ctl
) == -1)
1447 warning (_("Error restoring address space randomization: %s"),
1448 safe_strerror (errno
));
1452 DISABLE_COPY_AND_ASSIGN (maybe_disable_address_space_randomization
);
1455 bool m_aslr_ctl_set
= false;
1461 fbsd_nat_target::create_inferior (const char *exec_file
,
1462 const std::string
&allargs
,
1463 char **env
, int from_tty
)
1465 #ifdef PROC_ASLR_CTL
1466 maybe_disable_address_space_randomization restore_aslr_ctl
1467 (disable_randomization
);
1470 inf_ptrace_target::create_inferior (exec_file
, allargs
, env
, from_tty
);
1474 /* Target hook for follow_fork. On entry and at return inferior_ptid is
1475 the ptid of the followed inferior. */
1478 fbsd_nat_target::follow_fork (inferior
*child_inf
, ptid_t child_ptid
,
1479 target_waitkind fork_kind
, bool follow_child
,
1482 inf_ptrace_target::follow_fork (child_inf
, child_ptid
, fork_kind
,
1483 follow_child
, detach_fork
);
1485 if (!follow_child
&& detach_fork
)
1487 pid_t child_pid
= child_ptid
.pid ();
1489 /* Breakpoints have already been detached from the child by
1492 if (ptrace (PT_DETACH
, child_pid
, (PTRACE_TYPE_ARG3
)1, 0) == -1)
1493 perror_with_name (("ptrace"));
1495 #ifndef PTRACE_VFORK
1496 if (fork_kind () == TARGET_WAITKIND_VFORKED
)
1498 /* We can't insert breakpoints until the child process has
1499 finished with the shared memory region. The parent
1500 process doesn't wait for the child process to exit or
1501 exec until after it has been resumed from the ptrace stop
1502 to report the fork. Once it has been resumed it doesn't
1503 stop again before returning to userland, so there is no
1504 reliable way to wait on the parent.
1506 We can't stay attached to the child to wait for an exec
1507 or exit because it may invoke ptrace(PT_TRACE_ME)
1508 (e.g. if the parent process is a debugger forking a new
1511 In the end, the best we can do is to make sure it runs
1512 for a little while. Hopefully it will be out of range of
1513 any breakpoints we reinsert. Usually this is only the
1514 single-step breakpoint at vfork's return point. */
1518 /* Schedule a fake VFORK_DONE event to report on the next
1520 fbsd_add_vfork_done (inferior_ptid
);
1527 fbsd_nat_target::insert_fork_catchpoint (int pid
)
1533 fbsd_nat_target::remove_fork_catchpoint (int pid
)
1539 fbsd_nat_target::insert_vfork_catchpoint (int pid
)
1545 fbsd_nat_target::remove_vfork_catchpoint (int pid
)
1551 /* Implement the virtual inf_ptrace_target::post_startup_inferior method. */
1554 fbsd_nat_target::post_startup_inferior (ptid_t pid
)
1556 fbsd_enable_proc_events (pid
.pid ());
1559 /* Implement the "post_attach" target_ops method. */
1562 fbsd_nat_target::post_attach (int pid
)
1564 fbsd_enable_proc_events (pid
);
1565 fbsd_add_threads (this, pid
);
1568 /* Traced processes always stop after exec. */
1571 fbsd_nat_target::insert_exec_catchpoint (int pid
)
1577 fbsd_nat_target::remove_exec_catchpoint (int pid
)
1582 #ifdef HAVE_STRUCT_PTRACE_LWPINFO_PL_SYSCALL_CODE
1584 fbsd_nat_target::set_syscall_catchpoint (int pid
, bool needed
,
1586 gdb::array_view
<const int> syscall_counts
)
1589 /* Ignore the arguments. inf-ptrace.c will use PT_SYSCALL which
1590 will catch all system call entries and exits. The system calls
1591 are filtered by GDB rather than the kernel. */
1597 fbsd_nat_target::supports_multi_process ()
1603 fbsd_nat_target::supports_disable_randomization ()
1605 #ifdef PROC_ASLR_CTL
1612 /* See fbsd-nat.h. */
1615 fbsd_nat_target::fetch_register_set (struct regcache
*regcache
, int regnum
,
1616 int fetch_op
, const struct regset
*regset
,
1617 void *regs
, size_t size
)
1619 const struct regcache_map_entry
*map
1620 = (const struct regcache_map_entry
*) regset
->regmap
;
1621 pid_t pid
= get_ptrace_pid (regcache
->ptid ());
1623 if (regnum
== -1 || regcache_map_supplies (map
, regnum
, regcache
->arch(),
1626 if (ptrace (fetch_op
, pid
, (PTRACE_TYPE_ARG3
) regs
, 0) == -1)
1627 perror_with_name (_("Couldn't get registers"));
1629 regcache
->supply_regset (regset
, regnum
, regs
, size
);
1633 /* See fbsd-nat.h. */
1636 fbsd_nat_target::store_register_set (struct regcache
*regcache
, int regnum
,
1637 int fetch_op
, int store_op
,
1638 const struct regset
*regset
, void *regs
,
1641 const struct regcache_map_entry
*map
1642 = (const struct regcache_map_entry
*) regset
->regmap
;
1643 pid_t pid
= get_ptrace_pid (regcache
->ptid ());
1645 if (regnum
== -1 || regcache_map_supplies (map
, regnum
, regcache
->arch(),
1648 if (ptrace (fetch_op
, pid
, (PTRACE_TYPE_ARG3
) regs
, 0) == -1)
1649 perror_with_name (_("Couldn't get registers"));
1651 regcache
->collect_regset (regset
, regnum
, regs
, size
);
1653 if (ptrace (store_op
, pid
, (PTRACE_TYPE_ARG3
) regs
, 0) == -1)
1654 perror_with_name (_("Couldn't write registers"));
1658 void _initialize_fbsd_nat ();
1660 _initialize_fbsd_nat ()
1662 add_setshow_boolean_cmd ("fbsd-lwp", class_maintenance
,
1663 &debug_fbsd_lwp
, _("\
1664 Set debugging of FreeBSD lwp module."), _("\
1665 Show debugging of FreeBSD lwp module."), _("\
1666 Enables printf debugging output."),
1668 &show_fbsd_lwp_debug
,
1669 &setdebuglist
, &showdebuglist
);
1670 add_setshow_boolean_cmd ("fbsd-nat", class_maintenance
,
1671 &debug_fbsd_nat
, _("\
1672 Set debugging of FreeBSD native target."), _("\
1673 Show debugging of FreeBSD native target."), _("\
1674 Enables printf debugging output."),
1676 &show_fbsd_nat_debug
,
1677 &setdebuglist
, &showdebuglist
);