1 /* Native-dependent code for FreeBSD.
3 Copyright (C) 2002-2020 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 #include <sys/procfs.h>
33 #include <sys/ptrace.h>
34 #include <sys/signal.h>
35 #include <sys/sysctl.h>
37 #if defined(HAVE_KINFO_GETFILE) || defined(HAVE_KINFO_GETVMMAP)
40 #if !defined(HAVE_KINFO_GETVMMAP)
41 #include "gdbsupport/filestuff.h"
46 #include "fbsd-tdep.h"
50 /* Return the name of a file that can be opened to get the symbols for
51 the child process identified by PID. */
54 fbsd_nat_target::pid_to_exec_file (int pid
)
56 static char buf
[PATH_MAX
];
62 mib
[2] = KERN_PROC_PATHNAME
;
65 if (sysctl (mib
, 4, buf
, &buflen
, NULL
, 0) == 0)
66 /* The kern.proc.pathname.<pid> sysctl returns a length of zero
67 for processes without an associated executable such as kernel
69 return buflen
== 0 ? NULL
: buf
;
74 #ifdef HAVE_KINFO_GETVMMAP
75 /* Iterate over all the memory regions in the current inferior,
76 calling FUNC for each memory region. DATA is passed as the last
80 fbsd_nat_target::find_memory_regions (find_memory_region_ftype func
,
83 pid_t pid
= inferior_ptid
.pid ();
84 struct kinfo_vmentry
*kve
;
88 gdb::unique_xmalloc_ptr
<struct kinfo_vmentry
>
89 vmentl (kinfo_getvmmap (pid
, &nitems
));
91 perror_with_name (_("Couldn't fetch VM map entries."));
93 for (i
= 0, kve
= vmentl
.get (); i
< nitems
; i
++, kve
++)
95 /* Skip unreadable segments and those where MAP_NOCORE has been set. */
96 if (!(kve
->kve_protection
& KVME_PROT_READ
)
97 || kve
->kve_flags
& KVME_FLAG_NOCOREDUMP
)
100 /* Skip segments with an invalid type. */
101 if (kve
->kve_type
!= KVME_TYPE_DEFAULT
102 && kve
->kve_type
!= KVME_TYPE_VNODE
103 && kve
->kve_type
!= KVME_TYPE_SWAP
104 && kve
->kve_type
!= KVME_TYPE_PHYS
)
107 size
= kve
->kve_end
- kve
->kve_start
;
110 fprintf_filtered (gdb_stdout
,
111 "Save segment, %ld bytes at %s (%c%c%c)\n",
113 paddress (target_gdbarch (), kve
->kve_start
),
114 kve
->kve_protection
& KVME_PROT_READ
? 'r' : '-',
115 kve
->kve_protection
& KVME_PROT_WRITE
? 'w' : '-',
116 kve
->kve_protection
& KVME_PROT_EXEC
? 'x' : '-');
119 /* Invoke the callback function to create the corefile segment.
120 Pass MODIFIED as true, we do not know the real modification state. */
121 func (kve
->kve_start
, size
, kve
->kve_protection
& KVME_PROT_READ
,
122 kve
->kve_protection
& KVME_PROT_WRITE
,
123 kve
->kve_protection
& KVME_PROT_EXEC
, 1, data
);
129 fbsd_read_mapping (FILE *mapfile
, unsigned long *start
, unsigned long *end
,
132 /* FreeBSD 5.1-RELEASE uses a 256-byte buffer. */
134 int resident
, privateresident
;
138 /* As of FreeBSD 5.0-RELEASE, the layout is described in
139 /usr/src/sys/fs/procfs/procfs_map.c. Somewhere in 5.1-CURRENT a
140 new column was added to the procfs map. Therefore we can't use
141 fscanf since we need to support older releases too. */
142 if (fgets (buf
, sizeof buf
, mapfile
) != NULL
)
143 ret
= sscanf (buf
, "%lx %lx %d %d %lx %s", start
, end
,
144 &resident
, &privateresident
, &obj
, protection
);
146 return (ret
!= 0 && ret
!= EOF
);
149 /* Iterate over all the memory regions in the current inferior,
150 calling FUNC for each memory region. DATA is passed as the last
154 fbsd_nat_target::find_memory_regions (find_memory_region_ftype func
,
157 pid_t pid
= inferior_ptid
.pid ();
158 unsigned long start
, end
, size
;
160 int read
, write
, exec
;
162 std::string mapfilename
= string_printf ("/proc/%ld/map", (long) pid
);
163 gdb_file_up
mapfile (fopen (mapfilename
.c_str (), "r"));
165 error (_("Couldn't open %s."), mapfilename
.c_str ());
168 fprintf_filtered (gdb_stdout
,
169 "Reading memory regions from %s\n", mapfilename
.c_str ());
171 /* Now iterate until end-of-file. */
172 while (fbsd_read_mapping (mapfile
.get (), &start
, &end
, &protection
[0]))
176 read
= (strchr (protection
, 'r') != 0);
177 write
= (strchr (protection
, 'w') != 0);
178 exec
= (strchr (protection
, 'x') != 0);
182 fprintf_filtered (gdb_stdout
,
183 "Save segment, %ld bytes at %s (%c%c%c)\n",
184 size
, paddress (target_gdbarch (), start
),
190 /* Invoke the callback function to create the corefile segment.
191 Pass MODIFIED as true, we do not know the real modification state. */
192 func (start
, size
, read
, write
, exec
, 1, data
);
199 /* Fetch the command line for a running process. */
201 static gdb::unique_xmalloc_ptr
<char>
202 fbsd_fetch_cmdline (pid_t pid
)
210 mib
[2] = KERN_PROC_ARGS
;
212 if (sysctl (mib
, 4, NULL
, &len
, NULL
, 0) == -1)
218 gdb::unique_xmalloc_ptr
<char> cmdline ((char *) xmalloc (len
));
219 if (sysctl (mib
, 4, cmdline
.get (), &len
, NULL
, 0) == -1)
222 /* Join the arguments with spaces to form a single string. */
223 char *cp
= cmdline
.get ();
224 for (size_t i
= 0; i
< len
- 1; i
++)
232 /* Fetch the external variant of the kernel's internal process
233 structure for the process PID into KP. */
236 fbsd_fetch_kinfo_proc (pid_t pid
, struct kinfo_proc
*kp
)
244 mib
[2] = KERN_PROC_PID
;
246 return (sysctl (mib
, 4, kp
, &len
, NULL
, 0) == 0);
249 /* Implement the "info_proc" target_ops method. */
252 fbsd_nat_target::info_proc (const char *args
, enum info_proc_what what
)
254 #ifdef HAVE_KINFO_GETFILE
255 gdb::unique_xmalloc_ptr
<struct kinfo_file
> fdtbl
;
258 struct kinfo_proc kp
;
260 bool do_cmdline
= false;
263 #ifdef HAVE_KINFO_GETFILE
264 bool do_files
= false;
266 #ifdef HAVE_KINFO_GETVMMAP
267 bool do_mappings
= false;
269 bool do_status
= false;
278 #ifdef HAVE_KINFO_GETVMMAP
296 #ifdef HAVE_KINFO_GETFILE
305 #ifdef HAVE_KINFO_GETFILE
308 #ifdef HAVE_KINFO_GETVMMAP
314 error (_("Not supported on this target."));
317 gdb_argv
built_argv (args
);
318 if (built_argv
.count () == 0)
320 pid
= inferior_ptid
.pid ();
322 error (_("No current process: you must name one."));
324 else if (built_argv
.count () == 1 && isdigit (built_argv
[0][0]))
325 pid
= strtol (built_argv
[0], NULL
, 10);
327 error (_("Invalid arguments."));
329 printf_filtered (_("process %d\n"), pid
);
330 #ifdef HAVE_KINFO_GETFILE
331 if (do_cwd
|| do_exe
|| do_files
)
332 fdtbl
.reset (kinfo_getfile (pid
, &nfd
));
337 gdb::unique_xmalloc_ptr
<char> cmdline
= fbsd_fetch_cmdline (pid
);
338 if (cmdline
!= nullptr)
339 printf_filtered ("cmdline = '%s'\n", cmdline
.get ());
341 warning (_("unable to fetch command line"));
345 const char *cwd
= NULL
;
346 #ifdef HAVE_KINFO_GETFILE
347 struct kinfo_file
*kf
= fdtbl
.get ();
348 for (int i
= 0; i
< nfd
; i
++, kf
++)
350 if (kf
->kf_type
== KF_TYPE_VNODE
&& kf
->kf_fd
== KF_FD_TYPE_CWD
)
358 printf_filtered ("cwd = '%s'\n", cwd
);
360 warning (_("unable to fetch current working directory"));
364 const char *exe
= NULL
;
365 #ifdef HAVE_KINFO_GETFILE
366 struct kinfo_file
*kf
= fdtbl
.get ();
367 for (int i
= 0; i
< nfd
; i
++, kf
++)
369 if (kf
->kf_type
== KF_TYPE_VNODE
&& kf
->kf_fd
== KF_FD_TYPE_TEXT
)
377 exe
= pid_to_exec_file (pid
);
379 printf_filtered ("exe = '%s'\n", exe
);
381 warning (_("unable to fetch executable path name"));
383 #ifdef HAVE_KINFO_GETFILE
386 struct kinfo_file
*kf
= fdtbl
.get ();
390 fbsd_info_proc_files_header ();
391 for (int i
= 0; i
< nfd
; i
++, kf
++)
392 fbsd_info_proc_files_entry (kf
->kf_type
, kf
->kf_fd
, kf
->kf_flags
,
393 kf
->kf_offset
, kf
->kf_vnode_type
,
394 kf
->kf_sock_domain
, kf
->kf_sock_type
,
395 kf
->kf_sock_protocol
, &kf
->kf_sa_local
,
396 &kf
->kf_sa_peer
, kf
->kf_path
);
399 warning (_("unable to fetch list of open files"));
402 #ifdef HAVE_KINFO_GETVMMAP
406 gdb::unique_xmalloc_ptr
<struct kinfo_vmentry
>
407 vmentl (kinfo_getvmmap (pid
, &nvment
));
409 if (vmentl
!= nullptr)
411 int addr_bit
= TARGET_CHAR_BIT
* sizeof (void *);
412 fbsd_info_proc_mappings_header (addr_bit
);
414 struct kinfo_vmentry
*kve
= vmentl
.get ();
415 for (int i
= 0; i
< nvment
; i
++, kve
++)
416 fbsd_info_proc_mappings_entry (addr_bit
, kve
->kve_start
,
417 kve
->kve_end
, kve
->kve_offset
,
418 kve
->kve_flags
, kve
->kve_protection
,
422 warning (_("unable to fetch virtual memory map"));
427 if (!fbsd_fetch_kinfo_proc (pid
, &kp
))
428 warning (_("Failed to fetch process information"));
434 printf_filtered ("Name: %s\n", kp
.ki_comm
);
441 state
= "R (running)";
444 state
= "T (stopped)";
447 state
= "Z (zombie)";
450 state
= "S (sleeping)";
453 state
= "W (interrupt wait)";
456 state
= "L (blocked on lock)";
459 state
= "? (unknown)";
462 printf_filtered ("State: %s\n", state
);
463 printf_filtered ("Parent process: %d\n", kp
.ki_ppid
);
464 printf_filtered ("Process group: %d\n", kp
.ki_pgid
);
465 printf_filtered ("Session id: %d\n", kp
.ki_sid
);
466 printf_filtered ("TTY: %ju\n", (uintmax_t) kp
.ki_tdev
);
467 printf_filtered ("TTY owner process group: %d\n", kp
.ki_tpgid
);
468 printf_filtered ("User IDs (real, effective, saved): %d %d %d\n",
469 kp
.ki_ruid
, kp
.ki_uid
, kp
.ki_svuid
);
470 printf_filtered ("Group IDs (real, effective, saved): %d %d %d\n",
471 kp
.ki_rgid
, kp
.ki_groups
[0], kp
.ki_svgid
);
472 printf_filtered ("Groups: ");
473 for (int i
= 0; i
< kp
.ki_ngroups
; i
++)
474 printf_filtered ("%d ", kp
.ki_groups
[i
]);
475 printf_filtered ("\n");
476 printf_filtered ("Minor faults (no memory page): %ld\n",
477 kp
.ki_rusage
.ru_minflt
);
478 printf_filtered ("Minor faults, children: %ld\n",
479 kp
.ki_rusage_ch
.ru_minflt
);
480 printf_filtered ("Major faults (memory page faults): %ld\n",
481 kp
.ki_rusage
.ru_majflt
);
482 printf_filtered ("Major faults, children: %ld\n",
483 kp
.ki_rusage_ch
.ru_majflt
);
484 printf_filtered ("utime: %jd.%06ld\n",
485 (intmax_t) kp
.ki_rusage
.ru_utime
.tv_sec
,
486 kp
.ki_rusage
.ru_utime
.tv_usec
);
487 printf_filtered ("stime: %jd.%06ld\n",
488 (intmax_t) kp
.ki_rusage
.ru_stime
.tv_sec
,
489 kp
.ki_rusage
.ru_stime
.tv_usec
);
490 printf_filtered ("utime, children: %jd.%06ld\n",
491 (intmax_t) kp
.ki_rusage_ch
.ru_utime
.tv_sec
,
492 kp
.ki_rusage_ch
.ru_utime
.tv_usec
);
493 printf_filtered ("stime, children: %jd.%06ld\n",
494 (intmax_t) kp
.ki_rusage_ch
.ru_stime
.tv_sec
,
495 kp
.ki_rusage_ch
.ru_stime
.tv_usec
);
496 printf_filtered ("'nice' value: %d\n", kp
.ki_nice
);
497 printf_filtered ("Start time: %jd.%06ld\n", kp
.ki_start
.tv_sec
,
498 kp
.ki_start
.tv_usec
);
499 pgtok
= getpagesize () / 1024;
500 printf_filtered ("Virtual memory size: %ju kB\n",
501 (uintmax_t) kp
.ki_size
/ 1024);
502 printf_filtered ("Data size: %ju kB\n",
503 (uintmax_t) kp
.ki_dsize
* pgtok
);
504 printf_filtered ("Stack size: %ju kB\n",
505 (uintmax_t) kp
.ki_ssize
* pgtok
);
506 printf_filtered ("Text size: %ju kB\n",
507 (uintmax_t) kp
.ki_tsize
* pgtok
);
508 printf_filtered ("Resident set size: %ju kB\n",
509 (uintmax_t) kp
.ki_rssize
* pgtok
);
510 printf_filtered ("Maximum RSS: %ju kB\n",
511 (uintmax_t) kp
.ki_rusage
.ru_maxrss
);
512 printf_filtered ("Pending Signals: ");
513 for (int i
= 0; i
< _SIG_WORDS
; i
++)
514 printf_filtered ("%08x ", kp
.ki_siglist
.__bits
[i
]);
515 printf_filtered ("\n");
516 printf_filtered ("Ignored Signals: ");
517 for (int i
= 0; i
< _SIG_WORDS
; i
++)
518 printf_filtered ("%08x ", kp
.ki_sigignore
.__bits
[i
]);
519 printf_filtered ("\n");
520 printf_filtered ("Caught Signals: ");
521 for (int i
= 0; i
< _SIG_WORDS
; i
++)
522 printf_filtered ("%08x ", kp
.ki_sigcatch
.__bits
[i
]);
523 printf_filtered ("\n");
531 * The current layout of siginfo_t on FreeBSD was adopted in SVN
532 * revision 153154 which shipped in FreeBSD versions 7.0 and later.
533 * Don't bother supporting the older layout on older kernels. The
534 * older format was also never used in core dump notes.
536 #if __FreeBSD_version >= 700009
541 /* Return the size of siginfo for the current inferior. */
549 /* This structure matches the naming and layout of `siginfo_t' in
550 <sys/signal.h>. In particular, the `si_foo' macros defined in that
551 header can be used with both types to copy fields in the `_reason'
563 union sigval32 si_value
;
596 struct gdbarch
*gdbarch
= get_frame_arch (get_current_frame ());
598 /* Is the inferior 32-bit? If so, use the 32-bit siginfo size. */
599 if (gdbarch_long_bit (gdbarch
) == 32)
600 return sizeof (struct siginfo32
);
602 return sizeof (siginfo_t
);
605 /* Convert a native 64-bit siginfo object to a 32-bit object. Note
606 that FreeBSD doesn't support writing to $_siginfo, so this only
607 needs to convert one way. */
610 fbsd_convert_siginfo (siginfo_t
*si
)
613 struct gdbarch
*gdbarch
= get_frame_arch (get_current_frame ());
615 /* Is the inferior 32-bit? If not, nothing to do. */
616 if (gdbarch_long_bit (gdbarch
) != 32)
619 struct siginfo32 si32
;
621 si32
.si_signo
= si
->si_signo
;
622 si32
.si_errno
= si
->si_errno
;
623 si32
.si_code
= si
->si_code
;
624 si32
.si_pid
= si
->si_pid
;
625 si32
.si_uid
= si
->si_uid
;
626 si32
.si_status
= si
->si_status
;
627 si32
.si_addr
= (uintptr_t) si
->si_addr
;
629 /* If sival_ptr is being used instead of sival_int on a big-endian
630 platform, then sival_int will be zero since it holds the upper
631 32-bits of the pointer value. */
632 #if _BYTE_ORDER == _BIG_ENDIAN
633 if (si
->si_value
.sival_int
== 0)
634 si32
.si_value
.sival_ptr
= (uintptr_t) si
->si_value
.sival_ptr
;
636 si32
.si_value
.sival_int
= si
->si_value
.sival_int
;
638 si32
.si_value
.sival_int
= si
->si_value
.sival_int
;
641 /* Always copy the spare fields and then possibly overwrite them for
642 signal-specific or code-specific fields. */
643 si32
._reason
.__spare__
.__spare1__
= si
->_reason
.__spare__
.__spare1__
;
644 for (int i
= 0; i
< 7; i
++)
645 si32
._reason
.__spare__
.__spare2__
[i
] = si
->_reason
.__spare__
.__spare2__
[i
];
646 switch (si
->si_signo
) {
651 si32
.si_trapno
= si
->si_trapno
;
654 switch (si
->si_code
) {
656 si32
.si_timerid
= si
->si_timerid
;
657 si32
.si_overrun
= si
->si_overrun
;
660 si32
.si_mqd
= si
->si_mqd
;
664 memcpy(si
, &si32
, sizeof (si32
));
669 /* Implement the "xfer_partial" target_ops method. */
671 enum target_xfer_status
672 fbsd_nat_target::xfer_partial (enum target_object object
,
673 const char *annex
, gdb_byte
*readbuf
,
674 const gdb_byte
*writebuf
,
675 ULONGEST offset
, ULONGEST len
,
676 ULONGEST
*xfered_len
)
678 pid_t pid
= inferior_ptid
.pid ();
683 case TARGET_OBJECT_SIGNAL_INFO
:
685 struct ptrace_lwpinfo pl
;
688 /* FreeBSD doesn't support writing to $_siginfo. */
689 if (writebuf
!= NULL
)
690 return TARGET_XFER_E_IO
;
692 if (inferior_ptid
.lwp_p ())
693 pid
= inferior_ptid
.lwp ();
695 siginfo_size
= fbsd_siginfo_size ();
696 if (offset
> siginfo_size
)
697 return TARGET_XFER_E_IO
;
699 if (ptrace (PT_LWPINFO
, pid
, (PTRACE_TYPE_ARG3
) &pl
, sizeof (pl
)) == -1)
700 return TARGET_XFER_E_IO
;
702 if (!(pl
.pl_flags
& PL_FLAG_SI
))
703 return TARGET_XFER_E_IO
;
705 fbsd_convert_siginfo (&pl
.pl_siginfo
);
706 if (offset
+ len
> siginfo_size
)
707 len
= siginfo_size
- offset
;
709 memcpy (readbuf
, ((gdb_byte
*) &pl
.pl_siginfo
) + offset
, len
);
711 return TARGET_XFER_OK
;
714 #ifdef KERN_PROC_AUXV
715 case TARGET_OBJECT_AUXV
:
717 gdb::byte_vector buf_storage
;
722 if (writebuf
!= NULL
)
723 return TARGET_XFER_E_IO
;
726 mib
[2] = KERN_PROC_AUXV
;
735 buflen
= offset
+ len
;
736 buf_storage
.resize (buflen
);
737 buf
= buf_storage
.data ();
739 if (sysctl (mib
, 4, buf
, &buflen
, NULL
, 0) == 0)
746 memcpy (readbuf
, buf
+ offset
, buflen
);
751 *xfered_len
= buflen
;
752 return (buflen
== 0) ? TARGET_XFER_EOF
: TARGET_XFER_OK
;
754 return TARGET_XFER_E_IO
;
757 #if defined(KERN_PROC_VMMAP) && defined(KERN_PROC_PS_STRINGS)
758 case TARGET_OBJECT_FREEBSD_VMMAP
:
759 case TARGET_OBJECT_FREEBSD_PS_STRINGS
:
761 gdb::byte_vector buf_storage
;
767 uint32_t struct_size
;
770 case TARGET_OBJECT_FREEBSD_VMMAP
:
771 proc_target
= KERN_PROC_VMMAP
;
772 struct_size
= sizeof (struct kinfo_vmentry
);
774 case TARGET_OBJECT_FREEBSD_PS_STRINGS
:
775 proc_target
= KERN_PROC_PS_STRINGS
;
776 struct_size
= sizeof (void *);
780 if (writebuf
!= NULL
)
781 return TARGET_XFER_E_IO
;
785 mib
[2] = proc_target
;
788 if (sysctl (mib
, 4, NULL
, &buflen
, NULL
, 0) != 0)
789 return TARGET_XFER_E_IO
;
790 buflen
+= sizeof (struct_size
);
792 if (offset
>= buflen
)
795 return TARGET_XFER_EOF
;
798 buf_storage
.resize (buflen
);
799 buf
= buf_storage
.data ();
801 memcpy (buf
, &struct_size
, sizeof (struct_size
));
802 buflen
-= sizeof (struct_size
);
803 if (sysctl (mib
, 4, buf
+ sizeof (struct_size
), &buflen
, NULL
, 0) != 0)
804 return TARGET_XFER_E_IO
;
805 buflen
+= sizeof (struct_size
);
807 if (buflen
- offset
< len
)
808 len
= buflen
- offset
;
809 memcpy (readbuf
, buf
+ offset
, len
);
811 return TARGET_XFER_OK
;
815 return inf_ptrace_target::xfer_partial (object
, annex
,
816 readbuf
, writebuf
, offset
,
821 static bool debug_fbsd_lwp
;
822 static bool debug_fbsd_nat
;
825 show_fbsd_lwp_debug (struct ui_file
*file
, int from_tty
,
826 struct cmd_list_element
*c
, const char *value
)
828 fprintf_filtered (file
, _("Debugging of FreeBSD lwp module is %s.\n"), value
);
832 show_fbsd_nat_debug (struct ui_file
*file
, int from_tty
,
833 struct cmd_list_element
*c
, const char *value
)
835 fprintf_filtered (file
, _("Debugging of FreeBSD native target is %s.\n"),
840 FreeBSD's first thread support was via a "reentrant" version of libc
841 (libc_r) that first shipped in 2.2.7. This library multiplexed all
842 of the threads in a process onto a single kernel thread. This
843 library was supported via the bsd-uthread target.
845 FreeBSD 5.1 introduced two new threading libraries that made use of
846 multiple kernel threads. The first (libkse) scheduled M user
847 threads onto N (<= M) kernel threads (LWPs). The second (libthr)
848 bound each user thread to a dedicated kernel thread. libkse shipped
849 as the default threading library (libpthread).
851 FreeBSD 5.3 added a libthread_db to abstract the interface across
852 the various thread libraries (libc_r, libkse, and libthr).
854 FreeBSD 7.0 switched the default threading library from from libkse
855 to libpthread and removed libc_r.
857 FreeBSD 8.0 removed libkse and the in-kernel support for it. The
858 only threading library supported by 8.0 and later is libthr which
859 ties each user thread directly to an LWP. To simplify the
860 implementation, this target only supports LWP-backed threads using
861 ptrace directly rather than libthread_db.
863 FreeBSD 11.0 introduced LWP event reporting via PT_LWP_EVENTS.
866 /* Return true if PTID is still active in the inferior. */
869 fbsd_nat_target::thread_alive (ptid_t ptid
)
873 struct ptrace_lwpinfo pl
;
875 if (ptrace (PT_LWPINFO
, ptid
.lwp (), (caddr_t
) &pl
, sizeof pl
)
878 #ifdef PL_FLAG_EXITED
879 if (pl
.pl_flags
& PL_FLAG_EXITED
)
887 /* Convert PTID to a string. */
890 fbsd_nat_target::pid_to_str (ptid_t ptid
)
897 int pid
= ptid
.pid ();
899 return string_printf ("LWP %d of process %d", lwp
, pid
);
902 return normal_pid_to_str (ptid
);
905 #ifdef HAVE_STRUCT_PTRACE_LWPINFO_PL_TDNAME
906 /* Return the name assigned to a thread by an application. Returns
907 the string in a static buffer. */
910 fbsd_nat_target::thread_name (struct thread_info
*thr
)
912 struct ptrace_lwpinfo pl
;
913 struct kinfo_proc kp
;
914 int pid
= thr
->ptid
.pid ();
915 long lwp
= thr
->ptid
.lwp ();
916 static char buf
[sizeof pl
.pl_tdname
+ 1];
918 /* Note that ptrace_lwpinfo returns the process command in pl_tdname
919 if a name has not been set explicitly. Return a NULL name in
921 if (!fbsd_fetch_kinfo_proc (pid
, &kp
))
922 perror_with_name (_("Failed to fetch process information"));
923 if (ptrace (PT_LWPINFO
, lwp
, (caddr_t
) &pl
, sizeof pl
) == -1)
924 perror_with_name (("ptrace"));
925 if (strcmp (kp
.ki_comm
, pl
.pl_tdname
) == 0)
927 xsnprintf (buf
, sizeof buf
, "%s", pl
.pl_tdname
);
932 /* Enable additional event reporting on new processes.
934 To catch fork events, PTRACE_FORK is set on every traced process
935 to enable stops on returns from fork or vfork. Note that both the
936 parent and child will always stop, even if system call stops are
939 To catch LWP events, PTRACE_EVENTS is set on every traced process.
940 This enables stops on the birth for new LWPs (excluding the "main" LWP)
941 and the death of LWPs (excluding the last LWP in a process). Note
942 that unlike fork events, the LWP that creates a new LWP does not
946 fbsd_enable_proc_events (pid_t pid
)
948 #ifdef PT_GET_EVENT_MASK
951 if (ptrace (PT_GET_EVENT_MASK
, pid
, (PTRACE_TYPE_ARG3
)&events
,
952 sizeof (events
)) == -1)
953 perror_with_name (("ptrace"));
954 events
|= PTRACE_FORK
| PTRACE_LWP
;
956 events
|= PTRACE_VFORK
;
958 if (ptrace (PT_SET_EVENT_MASK
, pid
, (PTRACE_TYPE_ARG3
)&events
,
959 sizeof (events
)) == -1)
960 perror_with_name (("ptrace"));
963 if (ptrace (PT_FOLLOW_FORK
, pid
, (PTRACE_TYPE_ARG3
)0, 1) == -1)
964 perror_with_name (("ptrace"));
967 if (ptrace (PT_LWP_EVENTS
, pid
, (PTRACE_TYPE_ARG3
)0, 1) == -1)
968 perror_with_name (("ptrace"));
973 /* Add threads for any new LWPs in a process.
975 When LWP events are used, this function is only used to detect existing
976 threads when attaching to a process. On older systems, this function is
977 called to discover new threads each time the thread list is updated. */
980 fbsd_add_threads (fbsd_nat_target
*target
, pid_t pid
)
984 gdb_assert (!in_thread_list (target
, ptid_t (pid
)));
985 nlwps
= ptrace (PT_GETNUMLWPS
, pid
, NULL
, 0);
987 perror_with_name (("ptrace"));
989 gdb::unique_xmalloc_ptr
<lwpid_t
[]> lwps (XCNEWVEC (lwpid_t
, nlwps
));
991 nlwps
= ptrace (PT_GETLWPLIST
, pid
, (caddr_t
) lwps
.get (), nlwps
);
993 perror_with_name (("ptrace"));
995 for (i
= 0; i
< nlwps
; i
++)
997 ptid_t ptid
= ptid_t (pid
, lwps
[i
], 0);
999 if (!in_thread_list (target
, ptid
))
1001 #ifdef PT_LWP_EVENTS
1002 struct ptrace_lwpinfo pl
;
1004 /* Don't add exited threads. Note that this is only called
1005 when attaching to a multi-threaded process. */
1006 if (ptrace (PT_LWPINFO
, lwps
[i
], (caddr_t
) &pl
, sizeof pl
) == -1)
1007 perror_with_name (("ptrace"));
1008 if (pl
.pl_flags
& PL_FLAG_EXITED
)
1012 fprintf_unfiltered (gdb_stdlog
,
1013 "FLWP: adding thread for LWP %u\n",
1015 add_thread (target
, ptid
);
1020 /* Implement the "update_thread_list" target_ops method. */
1023 fbsd_nat_target::update_thread_list ()
1025 #ifdef PT_LWP_EVENTS
1026 /* With support for thread events, threads are added/deleted from the
1027 list as events are reported, so just try deleting exited threads. */
1028 delete_exited_threads ();
1032 fbsd_add_threads (this, inferior_ptid
.pid ());
1038 To catch fork events, PT_FOLLOW_FORK is set on every traced process
1039 to enable stops on returns from fork or vfork. Note that both the
1040 parent and child will always stop, even if system call stops are not
1043 After a fork, both the child and parent process will stop and report
1044 an event. However, there is no guarantee of order. If the parent
1045 reports its stop first, then fbsd_wait explicitly waits for the new
1046 child before returning. If the child reports its stop first, then
1047 the event is saved on a list and ignored until the parent's stop is
1048 reported. fbsd_wait could have been changed to fetch the parent PID
1049 of the new child and used that to wait for the parent explicitly.
1050 However, if two threads in the parent fork at the same time, then
1051 the wait on the parent might return the "wrong" fork event.
1053 The initial version of PT_FOLLOW_FORK did not set PL_FLAG_CHILD for
1054 the new child process. This flag could be inferred by treating any
1055 events for an unknown pid as a new child.
1057 In addition, the initial version of PT_FOLLOW_FORK did not report a
1058 stop event for the parent process of a vfork until after the child
1059 process executed a new program or exited. The kernel was changed to
1060 defer the wait for exit or exec of the child until after posting the
1061 stop event shortly after the change to introduce PL_FLAG_CHILD.
1062 This could be worked around by reporting a vfork event when the
1063 child event posted and ignoring the subsequent event from the
1066 This implementation requires both of these fixes for simplicity's
1067 sake. FreeBSD versions newer than 9.1 contain both fixes.
1070 static std::list
<ptid_t
> fbsd_pending_children
;
1072 /* Record a new child process event that is reported before the
1073 corresponding fork event in the parent. */
1076 fbsd_remember_child (ptid_t pid
)
1078 fbsd_pending_children
.push_front (pid
);
1081 /* Check for a previously-recorded new child process event for PID.
1082 If one is found, remove it from the list and return the PTID. */
1085 fbsd_is_child_pending (pid_t pid
)
1087 for (auto it
= fbsd_pending_children
.begin ();
1088 it
!= fbsd_pending_children
.end (); it
++)
1089 if (it
->pid () == pid
)
1092 fbsd_pending_children
.erase (it
);
1098 #ifndef PTRACE_VFORK
1099 static std::forward_list
<ptid_t
> fbsd_pending_vfork_done
;
1101 /* Record a pending vfork done event. */
1104 fbsd_add_vfork_done (ptid_t pid
)
1106 fbsd_pending_vfork_done
.push_front (pid
);
1109 /* Check for a pending vfork done event for a specific PID. */
1112 fbsd_is_vfork_done_pending (pid_t pid
)
1114 for (auto it
= fbsd_pending_vfork_done
.begin ();
1115 it
!= fbsd_pending_vfork_done
.end (); it
++)
1116 if (it
->pid () == pid
)
1121 /* Check for a pending vfork done event. If one is found, remove it
1122 from the list and return the PTID. */
1125 fbsd_next_vfork_done (void)
1127 if (!fbsd_pending_vfork_done
.empty ())
1129 ptid_t ptid
= fbsd_pending_vfork_done
.front ();
1130 fbsd_pending_vfork_done
.pop_front ();
1138 /* Implement the "resume" target_ops method. */
1141 fbsd_nat_target::resume (ptid_t ptid
, int step
, enum gdb_signal signo
)
1143 #if defined(TDP_RFPPWAIT) && !defined(PTRACE_VFORK)
1146 /* Don't PT_CONTINUE a process which has a pending vfork done event. */
1147 if (minus_one_ptid
== ptid
)
1148 pid
= inferior_ptid
.pid ();
1151 if (fbsd_is_vfork_done_pending (pid
))
1156 fprintf_unfiltered (gdb_stdlog
,
1157 "FLWP: fbsd_resume for ptid (%d, %ld, %ld)\n",
1158 ptid
.pid (), ptid
.lwp (),
1162 /* If ptid is a specific LWP, suspend all other LWPs in the process. */
1163 inferior
*inf
= find_inferior_ptid (this, ptid
);
1165 for (thread_info
*tp
: inf
->non_exited_threads ())
1169 if (tp
->ptid
.lwp () == ptid
.lwp ())
1170 request
= PT_RESUME
;
1172 request
= PT_SUSPEND
;
1174 if (ptrace (request
, tp
->ptid
.lwp (), NULL
, 0) == -1)
1175 perror_with_name (("ptrace"));
1180 /* If ptid is a wildcard, resume all matching threads (they won't run
1181 until the process is continued however). */
1182 for (thread_info
*tp
: all_non_exited_threads (this, ptid
))
1183 if (ptrace (PT_RESUME
, tp
->ptid
.lwp (), NULL
, 0) == -1)
1184 perror_with_name (("ptrace"));
1185 ptid
= inferior_ptid
;
1188 #if __FreeBSD_version < 1200052
1189 /* When multiple threads within a process wish to report STOPPED
1190 events from wait(), the kernel picks one thread event as the
1191 thread event to report. The chosen thread event is retrieved via
1192 PT_LWPINFO by passing the process ID as the request pid. If
1193 multiple events are pending, then the subsequent wait() after
1194 resuming a process will report another STOPPED event after
1195 resuming the process to handle the next thread event and so on.
1197 A single thread event is cleared as a side effect of resuming the
1198 process with PT_CONTINUE, PT_STEP, etc. In older kernels,
1199 however, the request pid was used to select which thread's event
1200 was cleared rather than always clearing the event that was just
1201 reported. To avoid clearing the event of the wrong LWP, always
1202 pass the process ID instead of an LWP ID to PT_CONTINUE or
1205 In the case of stepping, the process ID cannot be used with
1206 PT_STEP since it would step the thread that reported an event
1207 which may not be the thread indicated by PTID. For stepping, use
1208 PT_SETSTEP to enable stepping on the desired thread before
1209 resuming the process via PT_CONTINUE instead of using
1213 if (ptrace (PT_SETSTEP
, get_ptrace_pid (ptid
), NULL
, 0) == -1)
1214 perror_with_name (("ptrace"));
1217 ptid
= ptid_t (ptid
.pid ());
1219 inf_ptrace_target::resume (ptid
, step
, signo
);
1222 #ifdef USE_SIGTRAP_SIGINFO
1223 /* Handle breakpoint and trace traps reported via SIGTRAP. If the
1224 trap was a breakpoint or trace trap that should be reported to the
1225 core, return true. */
1228 fbsd_handle_debug_trap (fbsd_nat_target
*target
, ptid_t ptid
,
1229 const struct ptrace_lwpinfo
&pl
)
1232 /* Ignore traps without valid siginfo or for signals other than
1235 FreeBSD kernels prior to r341800 can return stale siginfo for at
1236 least some events, but those events can be identified by
1237 additional flags set in pl_flags. True breakpoint and
1238 single-step traps should not have other flags set in
1240 if (pl
.pl_flags
!= PL_FLAG_SI
|| pl
.pl_siginfo
.si_signo
!= SIGTRAP
)
1243 /* Trace traps are either a single step or a hardware watchpoint or
1245 if (pl
.pl_siginfo
.si_code
== TRAP_TRACE
)
1248 fprintf_unfiltered (gdb_stdlog
,
1249 "FNAT: trace trap for LWP %ld\n", ptid
.lwp ());
1253 if (pl
.pl_siginfo
.si_code
== TRAP_BRKPT
)
1255 /* Fixup PC for the software breakpoint. */
1256 struct regcache
*regcache
= get_thread_regcache (target
, ptid
);
1257 struct gdbarch
*gdbarch
= regcache
->arch ();
1258 int decr_pc
= gdbarch_decr_pc_after_break (gdbarch
);
1261 fprintf_unfiltered (gdb_stdlog
,
1262 "FNAT: sw breakpoint trap for LWP %ld\n",
1268 pc
= regcache_read_pc (regcache
);
1269 regcache_write_pc (regcache
, pc
- decr_pc
);
1278 /* Wait for the child specified by PTID to do something. Return the
1279 process ID of the child, or MINUS_ONE_PTID in case of error; store
1280 the status in *OURSTATUS. */
1283 fbsd_nat_target::wait (ptid_t ptid
, struct target_waitstatus
*ourstatus
,
1290 #ifndef PTRACE_VFORK
1291 wptid
= fbsd_next_vfork_done ();
1292 if (wptid
!= null_ptid
)
1294 ourstatus
->kind
= TARGET_WAITKIND_VFORK_DONE
;
1298 wptid
= inf_ptrace_target::wait (ptid
, ourstatus
, target_options
);
1299 if (ourstatus
->kind
== TARGET_WAITKIND_STOPPED
)
1301 struct ptrace_lwpinfo pl
;
1306 if (ptrace (PT_LWPINFO
, pid
, (caddr_t
) &pl
, sizeof pl
) == -1)
1307 perror_with_name (("ptrace"));
1309 wptid
= ptid_t (pid
, pl
.pl_lwpid
, 0);
1313 fprintf_unfiltered (gdb_stdlog
,
1314 "FNAT: stop for LWP %u event %d flags %#x\n",
1315 pl
.pl_lwpid
, pl
.pl_event
, pl
.pl_flags
);
1316 if (pl
.pl_flags
& PL_FLAG_SI
)
1317 fprintf_unfiltered (gdb_stdlog
,
1318 "FNAT: si_signo %u si_code %u\n",
1319 pl
.pl_siginfo
.si_signo
,
1320 pl
.pl_siginfo
.si_code
);
1323 #ifdef PT_LWP_EVENTS
1324 if (pl
.pl_flags
& PL_FLAG_EXITED
)
1326 /* If GDB attaches to a multi-threaded process, exiting
1327 threads might be skipped during post_attach that
1328 have not yet reported their PL_FLAG_EXITED event.
1329 Ignore EXITED events for an unknown LWP. */
1330 thread_info
*thr
= find_thread_ptid (this, wptid
);
1334 fprintf_unfiltered (gdb_stdlog
,
1335 "FLWP: deleting thread for LWP %u\n",
1337 if (print_thread_events
)
1338 printf_unfiltered (_("[%s exited]\n"),
1339 target_pid_to_str (wptid
).c_str ());
1340 delete_thread (thr
);
1342 if (ptrace (PT_CONTINUE
, pid
, (caddr_t
) 1, 0) == -1)
1343 perror_with_name (("ptrace"));
1348 /* Switch to an LWP PTID on the first stop in a new process.
1349 This is done after handling PL_FLAG_EXITED to avoid
1350 switching to an exited LWP. It is done before checking
1351 PL_FLAG_BORN in case the first stop reported after
1352 attaching to an existing process is a PL_FLAG_BORN
1354 if (in_thread_list (this, ptid_t (pid
)))
1357 fprintf_unfiltered (gdb_stdlog
,
1358 "FLWP: using LWP %u for first thread\n",
1360 thread_change_ptid (this, ptid_t (pid
), wptid
);
1363 #ifdef PT_LWP_EVENTS
1364 if (pl
.pl_flags
& PL_FLAG_BORN
)
1366 /* If GDB attaches to a multi-threaded process, newborn
1367 threads might be added by fbsd_add_threads that have
1368 not yet reported their PL_FLAG_BORN event. Ignore
1369 BORN events for an already-known LWP. */
1370 if (!in_thread_list (this, wptid
))
1373 fprintf_unfiltered (gdb_stdlog
,
1374 "FLWP: adding thread for LWP %u\n",
1376 add_thread (this, wptid
);
1378 ourstatus
->kind
= TARGET_WAITKIND_SPURIOUS
;
1384 if (pl
.pl_flags
& PL_FLAG_FORKED
)
1386 #ifndef PTRACE_VFORK
1387 struct kinfo_proc kp
;
1392 child
= pl
.pl_child_pid
;
1393 ourstatus
->kind
= TARGET_WAITKIND_FORKED
;
1395 if (pl
.pl_flags
& PL_FLAG_VFORKED
)
1396 ourstatus
->kind
= TARGET_WAITKIND_VFORKED
;
1399 /* Make sure the other end of the fork is stopped too. */
1400 child_ptid
= fbsd_is_child_pending (child
);
1401 if (child_ptid
== null_ptid
)
1403 pid
= waitpid (child
, &status
, 0);
1405 perror_with_name (("waitpid"));
1407 gdb_assert (pid
== child
);
1409 if (ptrace (PT_LWPINFO
, child
, (caddr_t
)&pl
, sizeof pl
) == -1)
1410 perror_with_name (("ptrace"));
1412 gdb_assert (pl
.pl_flags
& PL_FLAG_CHILD
);
1413 child_ptid
= ptid_t (child
, pl
.pl_lwpid
, 0);
1416 /* Enable additional events on the child process. */
1417 fbsd_enable_proc_events (child_ptid
.pid ());
1419 #ifndef PTRACE_VFORK
1420 /* For vfork, the child process will have the P_PPWAIT
1422 if (fbsd_fetch_kinfo_proc (child
, &kp
))
1424 if (kp
.ki_flag
& P_PPWAIT
)
1425 ourstatus
->kind
= TARGET_WAITKIND_VFORKED
;
1428 warning (_("Failed to fetch process information"));
1430 ourstatus
->value
.related_pid
= child_ptid
;
1435 if (pl
.pl_flags
& PL_FLAG_CHILD
)
1437 /* Remember that this child forked, but do not report it
1438 until the parent reports its corresponding fork
1440 fbsd_remember_child (wptid
);
1445 if (pl
.pl_flags
& PL_FLAG_VFORK_DONE
)
1447 ourstatus
->kind
= TARGET_WAITKIND_VFORK_DONE
;
1454 if (pl
.pl_flags
& PL_FLAG_EXEC
)
1456 ourstatus
->kind
= TARGET_WAITKIND_EXECD
;
1457 ourstatus
->value
.execd_pathname
1458 = xstrdup (pid_to_exec_file (pid
));
1463 #ifdef USE_SIGTRAP_SIGINFO
1464 if (fbsd_handle_debug_trap (this, wptid
, pl
))
1468 /* Note that PL_FLAG_SCE is set for any event reported while
1469 a thread is executing a system call in the kernel. In
1470 particular, signals that interrupt a sleep in a system
1471 call will report this flag as part of their event. Stops
1472 explicitly for system call entry and exit always use
1473 SIGTRAP, so only treat SIGTRAP events as system call
1474 entry/exit events. */
1475 if (pl
.pl_flags
& (PL_FLAG_SCE
| PL_FLAG_SCX
)
1476 && ourstatus
->value
.sig
== SIGTRAP
)
1478 #ifdef HAVE_STRUCT_PTRACE_LWPINFO_PL_SYSCALL_CODE
1479 if (catch_syscall_enabled ())
1481 if (catching_syscall_number (pl
.pl_syscall_code
))
1483 if (pl
.pl_flags
& PL_FLAG_SCE
)
1484 ourstatus
->kind
= TARGET_WAITKIND_SYSCALL_ENTRY
;
1486 ourstatus
->kind
= TARGET_WAITKIND_SYSCALL_RETURN
;
1487 ourstatus
->value
.syscall_number
= pl
.pl_syscall_code
;
1492 /* If the core isn't interested in this event, just
1493 continue the process explicitly and wait for another
1494 event. Note that PT_SYSCALL is "sticky" on FreeBSD
1495 and once system call stops are enabled on a process
1496 it stops for all system call entries and exits. */
1497 if (ptrace (PT_CONTINUE
, pid
, (caddr_t
) 1, 0) == -1)
1498 perror_with_name (("ptrace"));
1506 #ifdef USE_SIGTRAP_SIGINFO
1507 /* Implement the "stopped_by_sw_breakpoint" target_ops method. */
1510 fbsd_nat_target::stopped_by_sw_breakpoint ()
1512 struct ptrace_lwpinfo pl
;
1514 if (ptrace (PT_LWPINFO
, get_ptrace_pid (inferior_ptid
), (caddr_t
) &pl
,
1518 return (pl
.pl_flags
== PL_FLAG_SI
1519 && pl
.pl_siginfo
.si_signo
== SIGTRAP
1520 && pl
.pl_siginfo
.si_code
== TRAP_BRKPT
);
1523 /* Implement the "supports_stopped_by_sw_breakpoint" target_ops
1527 fbsd_nat_target::supports_stopped_by_sw_breakpoint ()
1534 /* Target hook for follow_fork. On entry and at return inferior_ptid is
1535 the ptid of the followed inferior. */
1538 fbsd_nat_target::follow_fork (bool follow_child
, bool detach_fork
)
1540 if (!follow_child
&& detach_fork
)
1542 struct thread_info
*tp
= inferior_thread ();
1543 pid_t child_pid
= tp
->pending_follow
.value
.related_pid
.pid ();
1545 /* Breakpoints have already been detached from the child by
1548 if (ptrace (PT_DETACH
, child_pid
, (PTRACE_TYPE_ARG3
)1, 0) == -1)
1549 perror_with_name (("ptrace"));
1551 #ifndef PTRACE_VFORK
1552 if (tp
->pending_follow
.kind
== TARGET_WAITKIND_VFORKED
)
1554 /* We can't insert breakpoints until the child process has
1555 finished with the shared memory region. The parent
1556 process doesn't wait for the child process to exit or
1557 exec until after it has been resumed from the ptrace stop
1558 to report the fork. Once it has been resumed it doesn't
1559 stop again before returning to userland, so there is no
1560 reliable way to wait on the parent.
1562 We can't stay attached to the child to wait for an exec
1563 or exit because it may invoke ptrace(PT_TRACE_ME)
1564 (e.g. if the parent process is a debugger forking a new
1567 In the end, the best we can do is to make sure it runs
1568 for a little while. Hopefully it will be out of range of
1569 any breakpoints we reinsert. Usually this is only the
1570 single-step breakpoint at vfork's return point. */
1574 /* Schedule a fake VFORK_DONE event to report on the next
1576 fbsd_add_vfork_done (inferior_ptid
);
1585 fbsd_nat_target::insert_fork_catchpoint (int pid
)
1591 fbsd_nat_target::remove_fork_catchpoint (int pid
)
1597 fbsd_nat_target::insert_vfork_catchpoint (int pid
)
1603 fbsd_nat_target::remove_vfork_catchpoint (int pid
)
1609 /* Implement the "post_startup_inferior" target_ops method. */
1612 fbsd_nat_target::post_startup_inferior (ptid_t pid
)
1614 fbsd_enable_proc_events (pid
.pid ());
1617 /* Implement the "post_attach" target_ops method. */
1620 fbsd_nat_target::post_attach (int pid
)
1622 fbsd_enable_proc_events (pid
);
1623 fbsd_add_threads (this, pid
);
1627 /* If the FreeBSD kernel supports PL_FLAG_EXEC, then traced processes
1628 will always stop after exec. */
1631 fbsd_nat_target::insert_exec_catchpoint (int pid
)
1637 fbsd_nat_target::remove_exec_catchpoint (int pid
)
1643 #ifdef HAVE_STRUCT_PTRACE_LWPINFO_PL_SYSCALL_CODE
1645 fbsd_nat_target::set_syscall_catchpoint (int pid
, bool needed
,
1647 gdb::array_view
<const int> syscall_counts
)
1650 /* Ignore the arguments. inf-ptrace.c will use PT_SYSCALL which
1651 will catch all system call entries and exits. The system calls
1652 are filtered by GDB rather than the kernel. */
1658 fbsd_nat_target::supports_multi_process ()
1663 void _initialize_fbsd_nat ();
1665 _initialize_fbsd_nat ()
1667 add_setshow_boolean_cmd ("fbsd-lwp", class_maintenance
,
1668 &debug_fbsd_lwp
, _("\
1669 Set debugging of FreeBSD lwp module."), _("\
1670 Show debugging of FreeBSD lwp module."), _("\
1671 Enables printf debugging output."),
1673 &show_fbsd_lwp_debug
,
1674 &setdebuglist
, &showdebuglist
);
1675 add_setshow_boolean_cmd ("fbsd-nat", class_maintenance
,
1676 &debug_fbsd_nat
, _("\
1677 Set debugging of FreeBSD native target."), _("\
1678 Show debugging of FreeBSD native target."), _("\
1679 Enables printf debugging output."),
1681 &show_fbsd_nat_debug
,
1682 &setdebuglist
, &showdebuglist
);