[2/3] Add a new debug knob for the FreeBSD native target.
Commit Message
For now this just logs information about the state of the current LWP
for each STOPPED event in fbsd_wait().
gdb/ChangeLog:
* NEWS (Changes since GDB 8.1): Add "set/show debug fbsd-nat".
* fbsd-nat.c (debug_fbsd_nat): New variable.
(show_fbsd_nat_debug): New function.
(fbsd_wait): Log LWP info if "debug_fbsd_nat" is enabled.
(_initialize_fbsd_nat): Add "fbsd-nat" debug boolean command.
gdb/doc/ChangeLog:
* gdb.texinfo (Debugging Output): Document "set/show debug
fbsd-nat".
---
gdb/ChangeLog | 8 ++++++++
gdb/NEWS | 6 ++++++
gdb/doc/ChangeLog | 5 +++++
gdb/doc/gdb.texinfo | 5 +++++
gdb/fbsd-nat.c | 29 +++++++++++++++++++++++++++++
5 files changed, 53 insertions(+)
Comments
> From: John Baldwin <jhb@FreeBSD.org>
> Date: Tue, 27 Feb 2018 17:46:55 -0800
>
> For now this just logs information about the state of the current LWP
> for each STOPPED event in fbsd_wait().
>
> gdb/ChangeLog:
>
> * NEWS (Changes since GDB 8.1): Add "set/show debug fbsd-nat".
> * fbsd-nat.c (debug_fbsd_nat): New variable.
> (show_fbsd_nat_debug): New function.
> (fbsd_wait): Log LWP info if "debug_fbsd_nat" is enabled.
> (_initialize_fbsd_nat): Add "fbsd-nat" debug boolean command.
>
> gdb/doc/ChangeLog:
>
> * gdb.texinfo (Debugging Output): Document "set/show debug
> fbsd-nat".
The documentation parts of this are approved.
Thanks.
LGTM, but one small question below.
On 02/28/2018 01:46 AM, John Baldwin wrote:
> @@ -765,6 +765,7 @@ fbsd_xfer_partial (struct target_ops *ops, enum target_object object,
>
> #ifdef PT_LWPINFO
> static int debug_fbsd_lwp;
> +static int debug_fbsd_nat;
Should this be guarded by PT_LWPINFO? Wouldn't you want to
enable fbsd-nat debugging on FreeBSD systems without PT_LWPINFO?
(Hmm, does GDB actually build today if PT_LWPINFO is not defined?)
Thanks,
Pedro Alves
On Friday, March 02, 2018 08:19:33 PM Pedro Alves wrote:
> LGTM, but one small question below.
>
> On 02/28/2018 01:46 AM, John Baldwin wrote:
> > @@ -765,6 +765,7 @@ fbsd_xfer_partial (struct target_ops *ops, enum target_object object,
> >
> > #ifdef PT_LWPINFO
> > static int debug_fbsd_lwp;
> > +static int debug_fbsd_nat;
>
> Should this be guarded by PT_LWPINFO? Wouldn't you want to
> enable fbsd-nat debugging on FreeBSD systems without PT_LWPINFO?
So fbsd-nat omits a lot of functionality including custom to_wait/to_resume
methods where debug_fbsd_nat is used both in this patch and the next one for
systems without PT_LWPINFO. There isn't a way to fetch the siginfo to parse
the trap code without PT_LWPINFO for example. I don't expect to be adding
any new features that would use this debugging on systems without PT_LWPINFO
at this point. For reference, PT_LWPINFO was added to FreeBSD in 5.0 release
which was released back in 2003. The last release which didn't support it
was 4.11 released in January 2005.
> (Hmm, does GDB actually build today if PT_LWPINFO is not defined?)
I believe it should, but given how old of a FreeBSD version you'd need for
this to matter, I should perhaps require it to simplify the #ifdef forest
in the FreeBSD native target a bit.
@@ -1,3 +1,11 @@
+2018-02-28 John Baldwin <jhb@FreeBSD.org>
+
+ * NEWS (Changes since GDB 8.1): Add "set/show debug fbsd-nat".
+ * fbsd-nat.c (debug_fbsd_nat): New variable.
+ (show_fbsd_nat_debug): New function.
+ (fbsd_wait): Log LWP info if "debug_fbsd_nat" is enabled.
+ (_initialize_fbsd_nat): Add "fbsd-nat" debug boolean command.
+
2018-02-28 John Baldwin <jhb@FreeBSD.org>
* nat/x86-dregs.c (x86_dr_stopped_by_breakpoint): New function.
@@ -6,6 +6,12 @@
* 'info proc' now works on running processes on FreeBSD systems and core
files created on FreeBSD systems.
+* New commands
+
+set debug fbsd-nat
+show debug fbsd-nat
+ Control display of debugging info regarding the FreeBSD native target.
+
*** Changes in GDB 8.1
* GDB now supports dynamically creating arbitrary register groups specified
@@ -1,3 +1,8 @@
+2018-02-28 John Baldwin <jhb@FreeBSD.org>
+
+ * gdb.texinfo (Debugging Output): Document "set/show debug
+ fbsd-nat".
+
2018-02-19 Andrew Burgess <andrew.burgess@embecosm.com>
* gdb.texinfo (Machine Code): Additional information about "info
@@ -24554,6 +24554,11 @@ Displays the current state of displaying debugging info about
Turns on or off debugging messages from the FreeBSD LWP debug support.
@item show debug fbsd-lwp
Show the current state of FreeBSD LWP debugging messages.
+@item set debug fbsd-nat
+@cindex FreeBSD native target debug messages
+Turns on or off debugging messages from the FreeBSD native target.
+@item show debug fbsd-nat
+Show the current state of FreeBSD native target debugging messages.
@item set debug frame
@cindex frame debugging info
Turns on or off display of @value{GDBN} frame debugging info. The
@@ -765,6 +765,7 @@ fbsd_xfer_partial (struct target_ops *ops, enum target_object object,
#ifdef PT_LWPINFO
static int debug_fbsd_lwp;
+static int debug_fbsd_nat;
static void (*super_resume) (struct target_ops *,
ptid_t,
@@ -782,6 +783,14 @@ show_fbsd_lwp_debug (struct ui_file *file, int from_tty,
fprintf_filtered (file, _("Debugging of FreeBSD lwp module is %s.\n"), value);
}
+static void
+show_fbsd_nat_debug (struct ui_file *file, int from_tty,
+ struct cmd_list_element *c, const char *value)
+{
+ fprintf_filtered (file, _("Debugging of FreeBSD native target is %s.\n"),
+ value);
+}
+
/*
FreeBSD's first thread support was via a "reentrant" version of libc
(libc_r) that first shipped in 2.2.7. This library multiplexed all
@@ -1212,6 +1221,18 @@ fbsd_wait (struct target_ops *ops,
wptid = ptid_build (pid, pl.pl_lwpid, 0);
+ if (debug_fbsd_nat)
+ {
+ fprintf_unfiltered (gdb_stdlog,
+ "FNAT: stop for LWP %u event %d flags %#x\n",
+ pl.pl_lwpid, pl.pl_event, pl.pl_flags);
+ if (pl.pl_flags & PL_FLAG_SI)
+ fprintf_unfiltered (gdb_stdlog,
+ "FNAT: si_signo %u si_code %u\n",
+ pl.pl_siginfo.si_signo,
+ pl.pl_siginfo.si_code);
+ }
+
#ifdef PT_LWP_EVENTS
if (pl.pl_flags & PL_FLAG_EXITED)
{
@@ -1569,5 +1590,13 @@ Enables printf debugging output."),
NULL,
&show_fbsd_lwp_debug,
&setdebuglist, &showdebuglist);
+ add_setshow_boolean_cmd ("fbsd-nat", class_maintenance,
+ &debug_fbsd_nat, _("\
+Set debugging of FreeBSD native target."), _("\
+Show debugging of FreeBSD native target."), _("\
+Enables printf debugging output."),
+ NULL,
+ &show_fbsd_nat_debug,
+ &setdebuglist, &showdebuglist);
#endif
}