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
)
57 static char buf
[PATH_MAX
];
60 #ifdef KERN_PROC_PATHNAME
66 mib
[2] = KERN_PROC_PATHNAME
;
69 if (sysctl (mib
, 4, buf
, &buflen
, NULL
, 0) == 0)
70 /* The kern.proc.pathname.<pid> sysctl returns a length of zero
71 for processes without an associated executable such as kernel
73 return buflen
== 0 ? NULL
: buf
;
76 xsnprintf (name
, PATH_MAX
, "/proc/%d/exe", pid
);
77 len
= readlink (name
, buf
, PATH_MAX
- 1);
87 #ifdef HAVE_KINFO_GETVMMAP
88 /* Iterate over all the memory regions in the current inferior,
89 calling FUNC for each memory region. OBFD is passed as the last
93 fbsd_nat_target::find_memory_regions (find_memory_region_ftype func
,
96 pid_t pid
= inferior_ptid
.pid ();
97 struct kinfo_vmentry
*kve
;
101 gdb::unique_xmalloc_ptr
<struct kinfo_vmentry
>
102 vmentl (kinfo_getvmmap (pid
, &nitems
));
104 perror_with_name (_("Couldn't fetch VM map entries."));
106 for (i
= 0, kve
= vmentl
.get (); i
< nitems
; i
++, kve
++)
108 /* Skip unreadable segments and those where MAP_NOCORE has been set. */
109 if (!(kve
->kve_protection
& KVME_PROT_READ
)
110 || kve
->kve_flags
& KVME_FLAG_NOCOREDUMP
)
113 /* Skip segments with an invalid type. */
114 if (kve
->kve_type
!= KVME_TYPE_DEFAULT
115 && kve
->kve_type
!= KVME_TYPE_VNODE
116 && kve
->kve_type
!= KVME_TYPE_SWAP
117 && kve
->kve_type
!= KVME_TYPE_PHYS
)
120 size
= kve
->kve_end
- kve
->kve_start
;
123 fprintf_filtered (gdb_stdout
,
124 "Save segment, %ld bytes at %s (%c%c%c)\n",
126 paddress (target_gdbarch (), kve
->kve_start
),
127 kve
->kve_protection
& KVME_PROT_READ
? 'r' : '-',
128 kve
->kve_protection
& KVME_PROT_WRITE
? 'w' : '-',
129 kve
->kve_protection
& KVME_PROT_EXEC
? 'x' : '-');
132 /* Invoke the callback function to create the corefile segment.
133 Pass MODIFIED as true, we do not know the real modification state. */
134 func (kve
->kve_start
, size
, kve
->kve_protection
& KVME_PROT_READ
,
135 kve
->kve_protection
& KVME_PROT_WRITE
,
136 kve
->kve_protection
& KVME_PROT_EXEC
, 1, obfd
);
142 fbsd_read_mapping (FILE *mapfile
, unsigned long *start
, unsigned long *end
,
145 /* FreeBSD 5.1-RELEASE uses a 256-byte buffer. */
147 int resident
, privateresident
;
151 /* As of FreeBSD 5.0-RELEASE, the layout is described in
152 /usr/src/sys/fs/procfs/procfs_map.c. Somewhere in 5.1-CURRENT a
153 new column was added to the procfs map. Therefore we can't use
154 fscanf since we need to support older releases too. */
155 if (fgets (buf
, sizeof buf
, mapfile
) != NULL
)
156 ret
= sscanf (buf
, "%lx %lx %d %d %lx %s", start
, end
,
157 &resident
, &privateresident
, &obj
, protection
);
159 return (ret
!= 0 && ret
!= EOF
);
162 /* Iterate over all the memory regions in the current inferior,
163 calling FUNC for each memory region. OBFD is passed as the last
167 fbsd_nat_target::find_memory_regions (find_memory_region_ftype func
,
170 pid_t pid
= inferior_ptid
.pid ();
171 unsigned long start
, end
, size
;
173 int read
, write
, exec
;
175 std::string mapfilename
= string_printf ("/proc/%ld/map", (long) pid
);
176 gdb_file_up
mapfile (fopen (mapfilename
.c_str (), "r"));
178 error (_("Couldn't open %s."), mapfilename
.c_str ());
181 fprintf_filtered (gdb_stdout
,
182 "Reading memory regions from %s\n", mapfilename
.c_str ());
184 /* Now iterate until end-of-file. */
185 while (fbsd_read_mapping (mapfile
.get (), &start
, &end
, &protection
[0]))
189 read
= (strchr (protection
, 'r') != 0);
190 write
= (strchr (protection
, 'w') != 0);
191 exec
= (strchr (protection
, 'x') != 0);
195 fprintf_filtered (gdb_stdout
,
196 "Save segment, %ld bytes at %s (%c%c%c)\n",
197 size
, paddress (target_gdbarch (), start
),
203 /* Invoke the callback function to create the corefile segment.
204 Pass MODIFIED as true, we do not know the real modification state. */
205 func (start
, size
, read
, write
, exec
, 1, obfd
);
212 /* Fetch the command line for a running process. */
214 static gdb::unique_xmalloc_ptr
<char>
215 fbsd_fetch_cmdline (pid_t pid
)
223 mib
[2] = KERN_PROC_ARGS
;
225 if (sysctl (mib
, 4, NULL
, &len
, NULL
, 0) == -1)
231 gdb::unique_xmalloc_ptr
<char> cmdline ((char *) xmalloc (len
));
232 if (sysctl (mib
, 4, cmdline
.get (), &len
, NULL
, 0) == -1)
235 /* Join the arguments with spaces to form a single string. */
236 char *cp
= cmdline
.get ();
237 for (size_t i
= 0; i
< len
- 1; i
++)
245 /* Fetch the external variant of the kernel's internal process
246 structure for the process PID into KP. */
249 fbsd_fetch_kinfo_proc (pid_t pid
, struct kinfo_proc
*kp
)
257 mib
[2] = KERN_PROC_PID
;
259 return (sysctl (mib
, 4, kp
, &len
, NULL
, 0) == 0);
262 /* Implement the "info_proc" target_ops method. */
265 fbsd_nat_target::info_proc (const char *args
, enum info_proc_what what
)
267 #ifdef HAVE_KINFO_GETFILE
268 gdb::unique_xmalloc_ptr
<struct kinfo_file
> fdtbl
;
271 struct kinfo_proc kp
;
273 bool do_cmdline
= false;
276 #ifdef HAVE_KINFO_GETFILE
277 bool do_files
= false;
279 #ifdef HAVE_KINFO_GETVMMAP
280 bool do_mappings
= false;
282 bool do_status
= false;
291 #ifdef HAVE_KINFO_GETVMMAP
309 #ifdef HAVE_KINFO_GETFILE
318 #ifdef HAVE_KINFO_GETFILE
321 #ifdef HAVE_KINFO_GETVMMAP
327 error (_("Not supported on this target."));
330 gdb_argv
built_argv (args
);
331 if (built_argv
.count () == 0)
333 pid
= inferior_ptid
.pid ();
335 error (_("No current process: you must name one."));
337 else if (built_argv
.count () == 1 && isdigit (built_argv
[0][0]))
338 pid
= strtol (built_argv
[0], NULL
, 10);
340 error (_("Invalid arguments."));
342 printf_filtered (_("process %d\n"), pid
);
343 #ifdef HAVE_KINFO_GETFILE
344 if (do_cwd
|| do_exe
|| do_files
)
345 fdtbl
.reset (kinfo_getfile (pid
, &nfd
));
350 gdb::unique_xmalloc_ptr
<char> cmdline
= fbsd_fetch_cmdline (pid
);
351 if (cmdline
!= nullptr)
352 printf_filtered ("cmdline = '%s'\n", cmdline
.get ());
354 warning (_("unable to fetch command line"));
358 const char *cwd
= NULL
;
359 #ifdef HAVE_KINFO_GETFILE
360 struct kinfo_file
*kf
= fdtbl
.get ();
361 for (int i
= 0; i
< nfd
; i
++, kf
++)
363 if (kf
->kf_type
== KF_TYPE_VNODE
&& kf
->kf_fd
== KF_FD_TYPE_CWD
)
371 printf_filtered ("cwd = '%s'\n", cwd
);
373 warning (_("unable to fetch current working directory"));
377 const char *exe
= NULL
;
378 #ifdef HAVE_KINFO_GETFILE
379 struct kinfo_file
*kf
= fdtbl
.get ();
380 for (int i
= 0; i
< nfd
; i
++, kf
++)
382 if (kf
->kf_type
== KF_TYPE_VNODE
&& kf
->kf_fd
== KF_FD_TYPE_TEXT
)
390 exe
= pid_to_exec_file (pid
);
392 printf_filtered ("exe = '%s'\n", exe
);
394 warning (_("unable to fetch executable path name"));
396 #ifdef HAVE_KINFO_GETFILE
399 struct kinfo_file
*kf
= fdtbl
.get ();
403 fbsd_info_proc_files_header ();
404 for (int i
= 0; i
< nfd
; i
++, kf
++)
405 fbsd_info_proc_files_entry (kf
->kf_type
, kf
->kf_fd
, kf
->kf_flags
,
406 kf
->kf_offset
, kf
->kf_vnode_type
,
407 kf
->kf_sock_domain
, kf
->kf_sock_type
,
408 kf
->kf_sock_protocol
, &kf
->kf_sa_local
,
409 &kf
->kf_sa_peer
, kf
->kf_path
);
412 warning (_("unable to fetch list of open files"));
415 #ifdef HAVE_KINFO_GETVMMAP
419 gdb::unique_xmalloc_ptr
<struct kinfo_vmentry
>
420 vmentl (kinfo_getvmmap (pid
, &nvment
));
422 if (vmentl
!= nullptr)
424 int addr_bit
= TARGET_CHAR_BIT
* sizeof (void *);
425 fbsd_info_proc_mappings_header (addr_bit
);
427 struct kinfo_vmentry
*kve
= vmentl
.get ();
428 for (int i
= 0; i
< nvment
; i
++, kve
++)
429 fbsd_info_proc_mappings_entry (addr_bit
, kve
->kve_start
,
430 kve
->kve_end
, kve
->kve_offset
,
431 kve
->kve_flags
, kve
->kve_protection
,
435 warning (_("unable to fetch virtual memory map"));
440 if (!fbsd_fetch_kinfo_proc (pid
, &kp
))
441 warning (_("Failed to fetch process information"));
447 printf_filtered ("Name: %s\n", kp
.ki_comm
);
454 state
= "R (running)";
457 state
= "T (stopped)";
460 state
= "Z (zombie)";
463 state
= "S (sleeping)";
466 state
= "W (interrupt wait)";
469 state
= "L (blocked on lock)";
472 state
= "? (unknown)";
475 printf_filtered ("State: %s\n", state
);
476 printf_filtered ("Parent process: %d\n", kp
.ki_ppid
);
477 printf_filtered ("Process group: %d\n", kp
.ki_pgid
);
478 printf_filtered ("Session id: %d\n", kp
.ki_sid
);
479 printf_filtered ("TTY: %ju\n", (uintmax_t) kp
.ki_tdev
);
480 printf_filtered ("TTY owner process group: %d\n", kp
.ki_tpgid
);
481 printf_filtered ("User IDs (real, effective, saved): %d %d %d\n",
482 kp
.ki_ruid
, kp
.ki_uid
, kp
.ki_svuid
);
483 printf_filtered ("Group IDs (real, effective, saved): %d %d %d\n",
484 kp
.ki_rgid
, kp
.ki_groups
[0], kp
.ki_svgid
);
485 printf_filtered ("Groups: ");
486 for (int i
= 0; i
< kp
.ki_ngroups
; i
++)
487 printf_filtered ("%d ", kp
.ki_groups
[i
]);
488 printf_filtered ("\n");
489 printf_filtered ("Minor faults (no memory page): %ld\n",
490 kp
.ki_rusage
.ru_minflt
);
491 printf_filtered ("Minor faults, children: %ld\n",
492 kp
.ki_rusage_ch
.ru_minflt
);
493 printf_filtered ("Major faults (memory page faults): %ld\n",
494 kp
.ki_rusage
.ru_majflt
);
495 printf_filtered ("Major faults, children: %ld\n",
496 kp
.ki_rusage_ch
.ru_majflt
);
497 printf_filtered ("utime: %jd.%06ld\n",
498 (intmax_t) kp
.ki_rusage
.ru_utime
.tv_sec
,
499 kp
.ki_rusage
.ru_utime
.tv_usec
);
500 printf_filtered ("stime: %jd.%06ld\n",
501 (intmax_t) kp
.ki_rusage
.ru_stime
.tv_sec
,
502 kp
.ki_rusage
.ru_stime
.tv_usec
);
503 printf_filtered ("utime, children: %jd.%06ld\n",
504 (intmax_t) kp
.ki_rusage_ch
.ru_utime
.tv_sec
,
505 kp
.ki_rusage_ch
.ru_utime
.tv_usec
);
506 printf_filtered ("stime, children: %jd.%06ld\n",
507 (intmax_t) kp
.ki_rusage_ch
.ru_stime
.tv_sec
,
508 kp
.ki_rusage_ch
.ru_stime
.tv_usec
);
509 printf_filtered ("'nice' value: %d\n", kp
.ki_nice
);
510 printf_filtered ("Start time: %jd.%06ld\n", kp
.ki_start
.tv_sec
,
511 kp
.ki_start
.tv_usec
);
512 pgtok
= getpagesize () / 1024;
513 printf_filtered ("Virtual memory size: %ju kB\n",
514 (uintmax_t) kp
.ki_size
/ 1024);
515 printf_filtered ("Data size: %ju kB\n",
516 (uintmax_t) kp
.ki_dsize
* pgtok
);
517 printf_filtered ("Stack size: %ju kB\n",
518 (uintmax_t) kp
.ki_ssize
* pgtok
);
519 printf_filtered ("Text size: %ju kB\n",
520 (uintmax_t) kp
.ki_tsize
* pgtok
);
521 printf_filtered ("Resident set size: %ju kB\n",
522 (uintmax_t) kp
.ki_rssize
* pgtok
);
523 printf_filtered ("Maximum RSS: %ju kB\n",
524 (uintmax_t) kp
.ki_rusage
.ru_maxrss
);
525 printf_filtered ("Pending Signals: ");
526 for (int i
= 0; i
< _SIG_WORDS
; i
++)
527 printf_filtered ("%08x ", kp
.ki_siglist
.__bits
[i
]);
528 printf_filtered ("\n");
529 printf_filtered ("Ignored Signals: ");
530 for (int i
= 0; i
< _SIG_WORDS
; i
++)
531 printf_filtered ("%08x ", kp
.ki_sigignore
.__bits
[i
]);
532 printf_filtered ("\n");
533 printf_filtered ("Caught Signals: ");
534 for (int i
= 0; i
< _SIG_WORDS
; i
++)
535 printf_filtered ("%08x ", kp
.ki_sigcatch
.__bits
[i
]);
536 printf_filtered ("\n");
544 * The current layout of siginfo_t on FreeBSD was adopted in SVN
545 * revision 153154 which shipped in FreeBSD versions 7.0 and later.
546 * Don't bother supporting the older layout on older kernels. The
547 * older format was also never used in core dump notes.
549 #if __FreeBSD_version >= 700009
554 /* Return the size of siginfo for the current inferior. */
562 /* This structure matches the naming and layout of `siginfo_t' in
563 <sys/signal.h>. In particular, the `si_foo' macros defined in that
564 header can be used with both types to copy fields in the `_reason'
576 union sigval32 si_value
;
609 struct gdbarch
*gdbarch
= get_frame_arch (get_current_frame ());
611 /* Is the inferior 32-bit? If so, use the 32-bit siginfo size. */
612 if (gdbarch_long_bit (gdbarch
) == 32)
613 return sizeof (struct siginfo32
);
615 return sizeof (siginfo_t
);
618 /* Convert a native 64-bit siginfo object to a 32-bit object. Note
619 that FreeBSD doesn't support writing to $_siginfo, so this only
620 needs to convert one way. */
623 fbsd_convert_siginfo (siginfo_t
*si
)
626 struct gdbarch
*gdbarch
= get_frame_arch (get_current_frame ());
628 /* Is the inferior 32-bit? If not, nothing to do. */
629 if (gdbarch_long_bit (gdbarch
) != 32)
632 struct siginfo32 si32
;
634 si32
.si_signo
= si
->si_signo
;
635 si32
.si_errno
= si
->si_errno
;
636 si32
.si_code
= si
->si_code
;
637 si32
.si_pid
= si
->si_pid
;
638 si32
.si_uid
= si
->si_uid
;
639 si32
.si_status
= si
->si_status
;
640 si32
.si_addr
= (uintptr_t) si
->si_addr
;
642 /* If sival_ptr is being used instead of sival_int on a big-endian
643 platform, then sival_int will be zero since it holds the upper
644 32-bits of the pointer value. */
645 #if _BYTE_ORDER == _BIG_ENDIAN
646 if (si
->si_value
.sival_int
== 0)
647 si32
.si_value
.sival_ptr
= (uintptr_t) si
->si_value
.sival_ptr
;
649 si32
.si_value
.sival_int
= si
->si_value
.sival_int
;
651 si32
.si_value
.sival_int
= si
->si_value
.sival_int
;
654 /* Always copy the spare fields and then possibly overwrite them for
655 signal-specific or code-specific fields. */
656 si32
._reason
.__spare__
.__spare1__
= si
->_reason
.__spare__
.__spare1__
;
657 for (int i
= 0; i
< 7; i
++)
658 si32
._reason
.__spare__
.__spare2__
[i
] = si
->_reason
.__spare__
.__spare2__
[i
];
659 switch (si
->si_signo
) {
664 si32
.si_trapno
= si
->si_trapno
;
667 switch (si
->si_code
) {
669 si32
.si_timerid
= si
->si_timerid
;
670 si32
.si_overrun
= si
->si_overrun
;
673 si32
.si_mqd
= si
->si_mqd
;
677 memcpy(si
, &si32
, sizeof (si32
));
682 /* Implement the "xfer_partial" target_ops method. */
684 enum target_xfer_status
685 fbsd_nat_target::xfer_partial (enum target_object object
,
686 const char *annex
, gdb_byte
*readbuf
,
687 const gdb_byte
*writebuf
,
688 ULONGEST offset
, ULONGEST len
,
689 ULONGEST
*xfered_len
)
691 pid_t pid
= inferior_ptid
.pid ();
696 case TARGET_OBJECT_SIGNAL_INFO
:
698 struct ptrace_lwpinfo pl
;
701 /* FreeBSD doesn't support writing to $_siginfo. */
702 if (writebuf
!= NULL
)
703 return TARGET_XFER_E_IO
;
705 if (inferior_ptid
.lwp_p ())
706 pid
= inferior_ptid
.lwp ();
708 siginfo_size
= fbsd_siginfo_size ();
709 if (offset
> siginfo_size
)
710 return TARGET_XFER_E_IO
;
712 if (ptrace (PT_LWPINFO
, pid
, (PTRACE_TYPE_ARG3
) &pl
, sizeof (pl
)) == -1)
713 return TARGET_XFER_E_IO
;
715 if (!(pl
.pl_flags
& PL_FLAG_SI
))
716 return TARGET_XFER_E_IO
;
718 fbsd_convert_siginfo (&pl
.pl_siginfo
);
719 if (offset
+ len
> siginfo_size
)
720 len
= siginfo_size
- offset
;
722 memcpy (readbuf
, ((gdb_byte
*) &pl
.pl_siginfo
) + offset
, len
);
724 return TARGET_XFER_OK
;
727 #ifdef KERN_PROC_AUXV
728 case TARGET_OBJECT_AUXV
:
730 gdb::byte_vector buf_storage
;
735 if (writebuf
!= NULL
)
736 return TARGET_XFER_E_IO
;
739 mib
[2] = KERN_PROC_AUXV
;
748 buflen
= offset
+ len
;
749 buf_storage
.resize (buflen
);
750 buf
= buf_storage
.data ();
752 if (sysctl (mib
, 4, buf
, &buflen
, NULL
, 0) == 0)
759 memcpy (readbuf
, buf
+ offset
, buflen
);
764 *xfered_len
= buflen
;
765 return (buflen
== 0) ? TARGET_XFER_EOF
: TARGET_XFER_OK
;
767 return TARGET_XFER_E_IO
;
770 #if defined(KERN_PROC_VMMAP) && defined(KERN_PROC_PS_STRINGS)
771 case TARGET_OBJECT_FREEBSD_VMMAP
:
772 case TARGET_OBJECT_FREEBSD_PS_STRINGS
:
774 gdb::byte_vector buf_storage
;
780 uint32_t struct_size
;
783 case TARGET_OBJECT_FREEBSD_VMMAP
:
784 proc_target
= KERN_PROC_VMMAP
;
785 struct_size
= sizeof (struct kinfo_vmentry
);
787 case TARGET_OBJECT_FREEBSD_PS_STRINGS
:
788 proc_target
= KERN_PROC_PS_STRINGS
;
789 struct_size
= sizeof (void *);
793 if (writebuf
!= NULL
)
794 return TARGET_XFER_E_IO
;
798 mib
[2] = proc_target
;
801 if (sysctl (mib
, 4, NULL
, &buflen
, NULL
, 0) != 0)
802 return TARGET_XFER_E_IO
;
803 buflen
+= sizeof (struct_size
);
805 if (offset
>= buflen
)
808 return TARGET_XFER_EOF
;
811 buf_storage
.resize (buflen
);
812 buf
= buf_storage
.data ();
814 memcpy (buf
, &struct_size
, sizeof (struct_size
));
815 buflen
-= sizeof (struct_size
);
816 if (sysctl (mib
, 4, buf
+ sizeof (struct_size
), &buflen
, NULL
, 0) != 0)
817 return TARGET_XFER_E_IO
;
818 buflen
+= sizeof (struct_size
);
820 if (buflen
- offset
< len
)
821 len
= buflen
- offset
;
822 memcpy (readbuf
, buf
+ offset
, len
);
824 return TARGET_XFER_OK
;
828 return inf_ptrace_target::xfer_partial (object
, annex
,
829 readbuf
, writebuf
, offset
,
835 static bool debug_fbsd_lwp
;
836 static bool debug_fbsd_nat
;
839 show_fbsd_lwp_debug (struct ui_file
*file
, int from_tty
,
840 struct cmd_list_element
*c
, const char *value
)
842 fprintf_filtered (file
, _("Debugging of FreeBSD lwp module is %s.\n"), value
);
846 show_fbsd_nat_debug (struct ui_file
*file
, int from_tty
,
847 struct cmd_list_element
*c
, const char *value
)
849 fprintf_filtered (file
, _("Debugging of FreeBSD native target is %s.\n"),
854 FreeBSD's first thread support was via a "reentrant" version of libc
855 (libc_r) that first shipped in 2.2.7. This library multiplexed all
856 of the threads in a process onto a single kernel thread. This
857 library was supported via the bsd-uthread target.
859 FreeBSD 5.1 introduced two new threading libraries that made use of
860 multiple kernel threads. The first (libkse) scheduled M user
861 threads onto N (<= M) kernel threads (LWPs). The second (libthr)
862 bound each user thread to a dedicated kernel thread. libkse shipped
863 as the default threading library (libpthread).
865 FreeBSD 5.3 added a libthread_db to abstract the interface across
866 the various thread libraries (libc_r, libkse, and libthr).
868 FreeBSD 7.0 switched the default threading library from from libkse
869 to libpthread and removed libc_r.
871 FreeBSD 8.0 removed libkse and the in-kernel support for it. The
872 only threading library supported by 8.0 and later is libthr which
873 ties each user thread directly to an LWP. To simplify the
874 implementation, this target only supports LWP-backed threads using
875 ptrace directly rather than libthread_db.
877 FreeBSD 11.0 introduced LWP event reporting via PT_LWP_EVENTS.
880 /* Return true if PTID is still active in the inferior. */
883 fbsd_nat_target::thread_alive (ptid_t ptid
)
887 struct ptrace_lwpinfo pl
;
889 if (ptrace (PT_LWPINFO
, ptid
.lwp (), (caddr_t
) &pl
, sizeof pl
)
892 #ifdef PL_FLAG_EXITED
893 if (pl
.pl_flags
& PL_FLAG_EXITED
)
901 /* Convert PTID to a string. */
904 fbsd_nat_target::pid_to_str (ptid_t ptid
)
911 int pid
= ptid
.pid ();
913 return string_printf ("LWP %d of process %d", lwp
, pid
);
916 return normal_pid_to_str (ptid
);
919 #ifdef HAVE_STRUCT_PTRACE_LWPINFO_PL_TDNAME
920 /* Return the name assigned to a thread by an application. Returns
921 the string in a static buffer. */
924 fbsd_nat_target::thread_name (struct thread_info
*thr
)
926 struct ptrace_lwpinfo pl
;
927 struct kinfo_proc kp
;
928 int pid
= thr
->ptid
.pid ();
929 long lwp
= thr
->ptid
.lwp ();
930 static char buf
[sizeof pl
.pl_tdname
+ 1];
932 /* Note that ptrace_lwpinfo returns the process command in pl_tdname
933 if a name has not been set explicitly. Return a NULL name in
935 if (!fbsd_fetch_kinfo_proc (pid
, &kp
))
936 perror_with_name (_("Failed to fetch process information"));
937 if (ptrace (PT_LWPINFO
, lwp
, (caddr_t
) &pl
, sizeof pl
) == -1)
938 perror_with_name (("ptrace"));
939 if (strcmp (kp
.ki_comm
, pl
.pl_tdname
) == 0)
941 xsnprintf (buf
, sizeof buf
, "%s", pl
.pl_tdname
);
946 /* Enable additional event reporting on new processes.
948 To catch fork events, PTRACE_FORK is set on every traced process
949 to enable stops on returns from fork or vfork. Note that both the
950 parent and child will always stop, even if system call stops are
953 To catch LWP events, PTRACE_EVENTS is set on every traced process.
954 This enables stops on the birth for new LWPs (excluding the "main" LWP)
955 and the death of LWPs (excluding the last LWP in a process). Note
956 that unlike fork events, the LWP that creates a new LWP does not
960 fbsd_enable_proc_events (pid_t pid
)
962 #ifdef PT_GET_EVENT_MASK
965 if (ptrace (PT_GET_EVENT_MASK
, pid
, (PTRACE_TYPE_ARG3
)&events
,
966 sizeof (events
)) == -1)
967 perror_with_name (("ptrace"));
968 events
|= PTRACE_FORK
| PTRACE_LWP
;
970 events
|= PTRACE_VFORK
;
972 if (ptrace (PT_SET_EVENT_MASK
, pid
, (PTRACE_TYPE_ARG3
)&events
,
973 sizeof (events
)) == -1)
974 perror_with_name (("ptrace"));
977 if (ptrace (PT_FOLLOW_FORK
, pid
, (PTRACE_TYPE_ARG3
)0, 1) == -1)
978 perror_with_name (("ptrace"));
981 if (ptrace (PT_LWP_EVENTS
, pid
, (PTRACE_TYPE_ARG3
)0, 1) == -1)
982 perror_with_name (("ptrace"));
987 /* Add threads for any new LWPs in a process.
989 When LWP events are used, this function is only used to detect existing
990 threads when attaching to a process. On older systems, this function is
991 called to discover new threads each time the thread list is updated. */
994 fbsd_add_threads (fbsd_nat_target
*target
, pid_t pid
)
998 gdb_assert (!in_thread_list (target
, ptid_t (pid
)));
999 nlwps
= ptrace (PT_GETNUMLWPS
, pid
, NULL
, 0);
1001 perror_with_name (("ptrace"));
1003 gdb::unique_xmalloc_ptr
<lwpid_t
[]> lwps (XCNEWVEC (lwpid_t
, nlwps
));
1005 nlwps
= ptrace (PT_GETLWPLIST
, pid
, (caddr_t
) lwps
.get (), nlwps
);
1007 perror_with_name (("ptrace"));
1009 for (i
= 0; i
< nlwps
; i
++)
1011 ptid_t ptid
= ptid_t (pid
, lwps
[i
], 0);
1013 if (!in_thread_list (target
, ptid
))
1015 #ifdef PT_LWP_EVENTS
1016 struct ptrace_lwpinfo pl
;
1018 /* Don't add exited threads. Note that this is only called
1019 when attaching to a multi-threaded process. */
1020 if (ptrace (PT_LWPINFO
, lwps
[i
], (caddr_t
) &pl
, sizeof pl
) == -1)
1021 perror_with_name (("ptrace"));
1022 if (pl
.pl_flags
& PL_FLAG_EXITED
)
1026 fprintf_unfiltered (gdb_stdlog
,
1027 "FLWP: adding thread for LWP %u\n",
1029 add_thread (target
, ptid
);
1034 /* Implement the "update_thread_list" target_ops method. */
1037 fbsd_nat_target::update_thread_list ()
1039 #ifdef PT_LWP_EVENTS
1040 /* With support for thread events, threads are added/deleted from the
1041 list as events are reported, so just try deleting exited threads. */
1042 delete_exited_threads ();
1046 fbsd_add_threads (this, inferior_ptid
.pid ());
1052 To catch fork events, PT_FOLLOW_FORK is set on every traced process
1053 to enable stops on returns from fork or vfork. Note that both the
1054 parent and child will always stop, even if system call stops are not
1057 After a fork, both the child and parent process will stop and report
1058 an event. However, there is no guarantee of order. If the parent
1059 reports its stop first, then fbsd_wait explicitly waits for the new
1060 child before returning. If the child reports its stop first, then
1061 the event is saved on a list and ignored until the parent's stop is
1062 reported. fbsd_wait could have been changed to fetch the parent PID
1063 of the new child and used that to wait for the parent explicitly.
1064 However, if two threads in the parent fork at the same time, then
1065 the wait on the parent might return the "wrong" fork event.
1067 The initial version of PT_FOLLOW_FORK did not set PL_FLAG_CHILD for
1068 the new child process. This flag could be inferred by treating any
1069 events for an unknown pid as a new child.
1071 In addition, the initial version of PT_FOLLOW_FORK did not report a
1072 stop event for the parent process of a vfork until after the child
1073 process executed a new program or exited. The kernel was changed to
1074 defer the wait for exit or exec of the child until after posting the
1075 stop event shortly after the change to introduce PL_FLAG_CHILD.
1076 This could be worked around by reporting a vfork event when the
1077 child event posted and ignoring the subsequent event from the
1080 This implementation requires both of these fixes for simplicity's
1081 sake. FreeBSD versions newer than 9.1 contain both fixes.
1084 static std::list
<ptid_t
> fbsd_pending_children
;
1086 /* Record a new child process event that is reported before the
1087 corresponding fork event in the parent. */
1090 fbsd_remember_child (ptid_t pid
)
1092 fbsd_pending_children
.push_front (pid
);
1095 /* Check for a previously-recorded new child process event for PID.
1096 If one is found, remove it from the list and return the PTID. */
1099 fbsd_is_child_pending (pid_t pid
)
1101 for (auto it
= fbsd_pending_children
.begin ();
1102 it
!= fbsd_pending_children
.end (); it
++)
1103 if (it
->pid () == pid
)
1106 fbsd_pending_children
.erase (it
);
1112 #ifndef PTRACE_VFORK
1113 static std::forward_list
<ptid_t
> fbsd_pending_vfork_done
;
1115 /* Record a pending vfork done event. */
1118 fbsd_add_vfork_done (ptid_t pid
)
1120 fbsd_pending_vfork_done
.push_front (pid
);
1123 /* Check for a pending vfork done event for a specific PID. */
1126 fbsd_is_vfork_done_pending (pid_t pid
)
1128 for (auto it
= fbsd_pending_vfork_done
.begin ();
1129 it
!= fbsd_pending_vfork_done
.end (); it
++)
1130 if (it
->pid () == pid
)
1135 /* Check for a pending vfork done event. If one is found, remove it
1136 from the list and return the PTID. */
1139 fbsd_next_vfork_done (void)
1141 if (!fbsd_pending_vfork_done
.empty ())
1143 ptid_t ptid
= fbsd_pending_vfork_done
.front ();
1144 fbsd_pending_vfork_done
.pop_front ();
1152 /* Implement the "resume" target_ops method. */
1155 fbsd_nat_target::resume (ptid_t ptid
, int step
, enum gdb_signal signo
)
1157 #if defined(TDP_RFPPWAIT) && !defined(PTRACE_VFORK)
1160 /* Don't PT_CONTINUE a process which has a pending vfork done event. */
1161 if (minus_one_ptid
== ptid
)
1162 pid
= inferior_ptid
.pid ();
1165 if (fbsd_is_vfork_done_pending (pid
))
1170 fprintf_unfiltered (gdb_stdlog
,
1171 "FLWP: fbsd_resume for ptid (%d, %ld, %ld)\n",
1172 ptid
.pid (), ptid
.lwp (),
1176 /* If ptid is a specific LWP, suspend all other LWPs in the process. */
1177 inferior
*inf
= find_inferior_ptid (this, ptid
);
1179 for (thread_info
*tp
: inf
->non_exited_threads ())
1183 if (tp
->ptid
.lwp () == ptid
.lwp ())
1184 request
= PT_RESUME
;
1186 request
= PT_SUSPEND
;
1188 if (ptrace (request
, tp
->ptid
.lwp (), NULL
, 0) == -1)
1189 perror_with_name (("ptrace"));
1194 /* If ptid is a wildcard, resume all matching threads (they won't run
1195 until the process is continued however). */
1196 for (thread_info
*tp
: all_non_exited_threads (this, ptid
))
1197 if (ptrace (PT_RESUME
, tp
->ptid
.lwp (), NULL
, 0) == -1)
1198 perror_with_name (("ptrace"));
1199 ptid
= inferior_ptid
;
1202 #if __FreeBSD_version < 1200052
1203 /* When multiple threads within a process wish to report STOPPED
1204 events from wait(), the kernel picks one thread event as the
1205 thread event to report. The chosen thread event is retrieved via
1206 PT_LWPINFO by passing the process ID as the request pid. If
1207 multiple events are pending, then the subsequent wait() after
1208 resuming a process will report another STOPPED event after
1209 resuming the process to handle the next thread event and so on.
1211 A single thread event is cleared as a side effect of resuming the
1212 process with PT_CONTINUE, PT_STEP, etc. In older kernels,
1213 however, the request pid was used to select which thread's event
1214 was cleared rather than always clearing the event that was just
1215 reported. To avoid clearing the event of the wrong LWP, always
1216 pass the process ID instead of an LWP ID to PT_CONTINUE or
1219 In the case of stepping, the process ID cannot be used with
1220 PT_STEP since it would step the thread that reported an event
1221 which may not be the thread indicated by PTID. For stepping, use
1222 PT_SETSTEP to enable stepping on the desired thread before
1223 resuming the process via PT_CONTINUE instead of using
1227 if (ptrace (PT_SETSTEP
, get_ptrace_pid (ptid
), NULL
, 0) == -1)
1228 perror_with_name (("ptrace"));
1231 ptid
= ptid_t (ptid
.pid ());
1233 inf_ptrace_target::resume (ptid
, step
, signo
);
1236 #ifdef USE_SIGTRAP_SIGINFO
1237 /* Handle breakpoint and trace traps reported via SIGTRAP. If the
1238 trap was a breakpoint or trace trap that should be reported to the
1239 core, return true. */
1242 fbsd_handle_debug_trap (fbsd_nat_target
*target
, ptid_t ptid
,
1243 const struct ptrace_lwpinfo
&pl
)
1246 /* Ignore traps without valid siginfo or for signals other than
1249 FreeBSD kernels prior to r341800 can return stale siginfo for at
1250 least some events, but those events can be identified by
1251 additional flags set in pl_flags. True breakpoint and
1252 single-step traps should not have other flags set in
1254 if (pl
.pl_flags
!= PL_FLAG_SI
|| pl
.pl_siginfo
.si_signo
!= SIGTRAP
)
1257 /* Trace traps are either a single step or a hardware watchpoint or
1259 if (pl
.pl_siginfo
.si_code
== TRAP_TRACE
)
1262 fprintf_unfiltered (gdb_stdlog
,
1263 "FNAT: trace trap for LWP %ld\n", ptid
.lwp ());
1267 if (pl
.pl_siginfo
.si_code
== TRAP_BRKPT
)
1269 /* Fixup PC for the software breakpoint. */
1270 struct regcache
*regcache
= get_thread_regcache (target
, ptid
);
1271 struct gdbarch
*gdbarch
= regcache
->arch ();
1272 int decr_pc
= gdbarch_decr_pc_after_break (gdbarch
);
1275 fprintf_unfiltered (gdb_stdlog
,
1276 "FNAT: sw breakpoint trap for LWP %ld\n",
1282 pc
= regcache_read_pc (regcache
);
1283 regcache_write_pc (regcache
, pc
- decr_pc
);
1292 /* Wait for the child specified by PTID to do something. Return the
1293 process ID of the child, or MINUS_ONE_PTID in case of error; store
1294 the status in *OURSTATUS. */
1297 fbsd_nat_target::wait (ptid_t ptid
, struct target_waitstatus
*ourstatus
,
1304 #ifndef PTRACE_VFORK
1305 wptid
= fbsd_next_vfork_done ();
1306 if (wptid
!= null_ptid
)
1308 ourstatus
->kind
= TARGET_WAITKIND_VFORK_DONE
;
1312 wptid
= inf_ptrace_target::wait (ptid
, ourstatus
, target_options
);
1313 if (ourstatus
->kind
== TARGET_WAITKIND_STOPPED
)
1315 struct ptrace_lwpinfo pl
;
1320 if (ptrace (PT_LWPINFO
, pid
, (caddr_t
) &pl
, sizeof pl
) == -1)
1321 perror_with_name (("ptrace"));
1323 wptid
= ptid_t (pid
, pl
.pl_lwpid
, 0);
1327 fprintf_unfiltered (gdb_stdlog
,
1328 "FNAT: stop for LWP %u event %d flags %#x\n",
1329 pl
.pl_lwpid
, pl
.pl_event
, pl
.pl_flags
);
1330 if (pl
.pl_flags
& PL_FLAG_SI
)
1331 fprintf_unfiltered (gdb_stdlog
,
1332 "FNAT: si_signo %u si_code %u\n",
1333 pl
.pl_siginfo
.si_signo
,
1334 pl
.pl_siginfo
.si_code
);
1337 #ifdef PT_LWP_EVENTS
1338 if (pl
.pl_flags
& PL_FLAG_EXITED
)
1340 /* If GDB attaches to a multi-threaded process, exiting
1341 threads might be skipped during post_attach that
1342 have not yet reported their PL_FLAG_EXITED event.
1343 Ignore EXITED events for an unknown LWP. */
1344 thread_info
*thr
= find_thread_ptid (this, wptid
);
1348 fprintf_unfiltered (gdb_stdlog
,
1349 "FLWP: deleting thread for LWP %u\n",
1351 if (print_thread_events
)
1352 printf_unfiltered (_("[%s exited]\n"),
1353 target_pid_to_str (wptid
).c_str ());
1354 delete_thread (thr
);
1356 if (ptrace (PT_CONTINUE
, pid
, (caddr_t
) 1, 0) == -1)
1357 perror_with_name (("ptrace"));
1362 /* Switch to an LWP PTID on the first stop in a new process.
1363 This is done after handling PL_FLAG_EXITED to avoid
1364 switching to an exited LWP. It is done before checking
1365 PL_FLAG_BORN in case the first stop reported after
1366 attaching to an existing process is a PL_FLAG_BORN
1368 if (in_thread_list (this, ptid_t (pid
)))
1371 fprintf_unfiltered (gdb_stdlog
,
1372 "FLWP: using LWP %u for first thread\n",
1374 thread_change_ptid (this, ptid_t (pid
), wptid
);
1377 #ifdef PT_LWP_EVENTS
1378 if (pl
.pl_flags
& PL_FLAG_BORN
)
1380 /* If GDB attaches to a multi-threaded process, newborn
1381 threads might be added by fbsd_add_threads that have
1382 not yet reported their PL_FLAG_BORN event. Ignore
1383 BORN events for an already-known LWP. */
1384 if (!in_thread_list (this, wptid
))
1387 fprintf_unfiltered (gdb_stdlog
,
1388 "FLWP: adding thread for LWP %u\n",
1390 add_thread (this, wptid
);
1392 ourstatus
->kind
= TARGET_WAITKIND_SPURIOUS
;
1398 if (pl
.pl_flags
& PL_FLAG_FORKED
)
1400 #ifndef PTRACE_VFORK
1401 struct kinfo_proc kp
;
1406 child
= pl
.pl_child_pid
;
1407 ourstatus
->kind
= TARGET_WAITKIND_FORKED
;
1409 if (pl
.pl_flags
& PL_FLAG_VFORKED
)
1410 ourstatus
->kind
= TARGET_WAITKIND_VFORKED
;
1413 /* Make sure the other end of the fork is stopped too. */
1414 child_ptid
= fbsd_is_child_pending (child
);
1415 if (child_ptid
== null_ptid
)
1417 pid
= waitpid (child
, &status
, 0);
1419 perror_with_name (("waitpid"));
1421 gdb_assert (pid
== child
);
1423 if (ptrace (PT_LWPINFO
, child
, (caddr_t
)&pl
, sizeof pl
) == -1)
1424 perror_with_name (("ptrace"));
1426 gdb_assert (pl
.pl_flags
& PL_FLAG_CHILD
);
1427 child_ptid
= ptid_t (child
, pl
.pl_lwpid
, 0);
1430 /* Enable additional events on the child process. */
1431 fbsd_enable_proc_events (child_ptid
.pid ());
1433 #ifndef PTRACE_VFORK
1434 /* For vfork, the child process will have the P_PPWAIT
1436 if (fbsd_fetch_kinfo_proc (child
, &kp
))
1438 if (kp
.ki_flag
& P_PPWAIT
)
1439 ourstatus
->kind
= TARGET_WAITKIND_VFORKED
;
1442 warning (_("Failed to fetch process information"));
1444 ourstatus
->value
.related_pid
= child_ptid
;
1449 if (pl
.pl_flags
& PL_FLAG_CHILD
)
1451 /* Remember that this child forked, but do not report it
1452 until the parent reports its corresponding fork
1454 fbsd_remember_child (wptid
);
1459 if (pl
.pl_flags
& PL_FLAG_VFORK_DONE
)
1461 ourstatus
->kind
= TARGET_WAITKIND_VFORK_DONE
;
1468 if (pl
.pl_flags
& PL_FLAG_EXEC
)
1470 ourstatus
->kind
= TARGET_WAITKIND_EXECD
;
1471 ourstatus
->value
.execd_pathname
1472 = xstrdup (pid_to_exec_file (pid
));
1477 #ifdef USE_SIGTRAP_SIGINFO
1478 if (fbsd_handle_debug_trap (this, wptid
, pl
))
1482 /* Note that PL_FLAG_SCE is set for any event reported while
1483 a thread is executing a system call in the kernel. In
1484 particular, signals that interrupt a sleep in a system
1485 call will report this flag as part of their event. Stops
1486 explicitly for system call entry and exit always use
1487 SIGTRAP, so only treat SIGTRAP events as system call
1488 entry/exit events. */
1489 if (pl
.pl_flags
& (PL_FLAG_SCE
| PL_FLAG_SCX
)
1490 && ourstatus
->value
.sig
== SIGTRAP
)
1492 #ifdef HAVE_STRUCT_PTRACE_LWPINFO_PL_SYSCALL_CODE
1493 if (catch_syscall_enabled ())
1495 if (catching_syscall_number (pl
.pl_syscall_code
))
1497 if (pl
.pl_flags
& PL_FLAG_SCE
)
1498 ourstatus
->kind
= TARGET_WAITKIND_SYSCALL_ENTRY
;
1500 ourstatus
->kind
= TARGET_WAITKIND_SYSCALL_RETURN
;
1501 ourstatus
->value
.syscall_number
= pl
.pl_syscall_code
;
1506 /* If the core isn't interested in this event, just
1507 continue the process explicitly and wait for another
1508 event. Note that PT_SYSCALL is "sticky" on FreeBSD
1509 and once system call stops are enabled on a process
1510 it stops for all system call entries and exits. */
1511 if (ptrace (PT_CONTINUE
, pid
, (caddr_t
) 1, 0) == -1)
1512 perror_with_name (("ptrace"));
1520 #ifdef USE_SIGTRAP_SIGINFO
1521 /* Implement the "stopped_by_sw_breakpoint" target_ops method. */
1524 fbsd_nat_target::stopped_by_sw_breakpoint ()
1526 struct ptrace_lwpinfo pl
;
1528 if (ptrace (PT_LWPINFO
, get_ptrace_pid (inferior_ptid
), (caddr_t
) &pl
,
1532 return (pl
.pl_flags
== PL_FLAG_SI
1533 && pl
.pl_siginfo
.si_signo
== SIGTRAP
1534 && pl
.pl_siginfo
.si_code
== TRAP_BRKPT
);
1537 /* Implement the "supports_stopped_by_sw_breakpoint" target_ops
1541 fbsd_nat_target::supports_stopped_by_sw_breakpoint ()
1548 /* Target hook for follow_fork. On entry and at return inferior_ptid is
1549 the ptid of the followed inferior. */
1552 fbsd_nat_target::follow_fork (int follow_child
, int detach_fork
)
1554 if (!follow_child
&& detach_fork
)
1556 struct thread_info
*tp
= inferior_thread ();
1557 pid_t child_pid
= tp
->pending_follow
.value
.related_pid
.pid ();
1559 /* Breakpoints have already been detached from the child by
1562 if (ptrace (PT_DETACH
, child_pid
, (PTRACE_TYPE_ARG3
)1, 0) == -1)
1563 perror_with_name (("ptrace"));
1565 #ifndef PTRACE_VFORK
1566 if (tp
->pending_follow
.kind
== TARGET_WAITKIND_VFORKED
)
1568 /* We can't insert breakpoints until the child process has
1569 finished with the shared memory region. The parent
1570 process doesn't wait for the child process to exit or
1571 exec until after it has been resumed from the ptrace stop
1572 to report the fork. Once it has been resumed it doesn't
1573 stop again before returning to userland, so there is no
1574 reliable way to wait on the parent.
1576 We can't stay attached to the child to wait for an exec
1577 or exit because it may invoke ptrace(PT_TRACE_ME)
1578 (e.g. if the parent process is a debugger forking a new
1581 In the end, the best we can do is to make sure it runs
1582 for a little while. Hopefully it will be out of range of
1583 any breakpoints we reinsert. Usually this is only the
1584 single-step breakpoint at vfork's return point. */
1588 /* Schedule a fake VFORK_DONE event to report on the next
1590 fbsd_add_vfork_done (inferior_ptid
);
1599 fbsd_nat_target::insert_fork_catchpoint (int pid
)
1605 fbsd_nat_target::remove_fork_catchpoint (int pid
)
1611 fbsd_nat_target::insert_vfork_catchpoint (int pid
)
1617 fbsd_nat_target::remove_vfork_catchpoint (int pid
)
1623 /* Implement the "post_startup_inferior" target_ops method. */
1626 fbsd_nat_target::post_startup_inferior (ptid_t pid
)
1628 fbsd_enable_proc_events (pid
.pid ());
1631 /* Implement the "post_attach" target_ops method. */
1634 fbsd_nat_target::post_attach (int pid
)
1636 fbsd_enable_proc_events (pid
);
1637 fbsd_add_threads (this, pid
);
1641 /* If the FreeBSD kernel supports PL_FLAG_EXEC, then traced processes
1642 will always stop after exec. */
1645 fbsd_nat_target::insert_exec_catchpoint (int pid
)
1651 fbsd_nat_target::remove_exec_catchpoint (int pid
)
1657 #ifdef HAVE_STRUCT_PTRACE_LWPINFO_PL_SYSCALL_CODE
1659 fbsd_nat_target::set_syscall_catchpoint (int pid
, bool needed
,
1661 gdb::array_view
<const int> syscall_counts
)
1664 /* Ignore the arguments. inf-ptrace.c will use PT_SYSCALL which
1665 will catch all system call entries and exits. The system calls
1666 are filtered by GDB rather than the kernel. */
1672 void _initialize_fbsd_nat ();
1674 _initialize_fbsd_nat ()
1677 add_setshow_boolean_cmd ("fbsd-lwp", class_maintenance
,
1678 &debug_fbsd_lwp
, _("\
1679 Set debugging of FreeBSD lwp module."), _("\
1680 Show debugging of FreeBSD lwp module."), _("\
1681 Enables printf debugging output."),
1683 &show_fbsd_lwp_debug
,
1684 &setdebuglist
, &showdebuglist
);
1685 add_setshow_boolean_cmd ("fbsd-nat", class_maintenance
,
1686 &debug_fbsd_nat
, _("\
1687 Set debugging of FreeBSD native target."), _("\
1688 Show debugging of FreeBSD native target."), _("\
1689 Enables printf debugging output."),
1691 &show_fbsd_nat_debug
,
1692 &setdebuglist
, &showdebuglist
);