diff options
author | Tom de Vries <tdevries@suse.de> | 2021-11-15 22:55:02 +0100 |
---|---|---|
committer | Tom de Vries <tdevries@suse.de> | 2021-11-15 22:55:02 +0100 |
commit | 636ae5bb4b6b801f8bda05041f600cbf3945c147 (patch) | |
tree | 6fd2ce7e13b3613033bd15bf46273e05fce1a8a2 /gdb/infrun.c | |
parent | d029b54d9c57232b812a32889b445f0db8958e0a (diff) | |
download | binutils-636ae5bb4b6b801f8bda05041f600cbf3945c147.zip binutils-636ae5bb4b6b801f8bda05041f600cbf3945c147.tar.gz binutils-636ae5bb4b6b801f8bda05041f600cbf3945c147.tar.bz2 |
[gdb] Don't use gdb_stdlog for inferior-events
The test-case gdb.base/foll-vfork.exp contains:
...
if [gdb_debug_enabled] {
untested "debug is enabled"
return 0
}
...
To understand what it does, I disabled this bit and ran with GDB_DEBUG=infrun,
like so:
...
$ cd $build/gdb/testsuite
$ make check GDB_DEBUG=infrun RUNTESTFLAGS=gdb.base/foll-vfork.exp
...
and ran into:
...
(gdb) PASS: gdb.base/foll-vfork.exp: exec: \
vfork parent follow, through step: set follow-fork parent
next^M
33 if (pid == 0) {^M
(gdb) FAIL: gdb.base/foll-vfork.exp: exec: \
vfork parent follow, through step: step
...
The problem is that the test-case expects:
...
(gdb) PASS: gdb.base/foll-vfork.exp: exec: \
vfork parent follow, through step: set follow-fork parent
next^M
[Detaching after vfork from child process 28169]^M
33 if (pid == 0) {^M
(gdb) PASS: gdb.base/foll-vfork.exp: exec: \
vfork parent follow, through step: step
...
but the "Detaching" line has been redirected to
$outputs/gdb.base/foll-vfork/gdb.debug.
I looked at the documentation of "set logging debugredirect [on|off]":
...
By default, GDB debug output will go to both the terminal and the logfile.
Set debugredirect if you want debug output to go only to the log file.
...
and my interpretation of it was that "debug output" did not match the
"messages" description of inferior-events:
...
The set print inferior-events command allows you to enable or disable printing
of messages when GDB notices that new inferiors have started or that inferiors
have exited or have been detached.
...
Fix the discrepancy by not using gdb_stdlog for inferior-events.
Update the gdb.base/foll-vfork.exp test-case to not require
gdb_debug_enabled == 0.
Tested on x86_64-linux.
Tested test-case gdb.base/foll-vfork.exp with and without GDB_DEBUG=infrun.
Diffstat (limited to 'gdb/infrun.c')
-rw-r--r-- | gdb/infrun.c | 33 |
1 files changed, 14 insertions, 19 deletions
diff --git a/gdb/infrun.c b/gdb/infrun.c index 95c8bfb..64e535a 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -455,10 +455,9 @@ holding the child stopped. Try \"set detach-on-fork\" or \ ptid_t process_ptid = ptid_t (child_ptid.pid ()); target_terminal::ours_for_output (); - fprintf_filtered (gdb_stdlog, - _("[Detaching after %s from child %s]\n"), - has_vforked ? "vfork" : "fork", - target_pid_to_str (process_ptid).c_str ()); + printf_filtered (_("[Detaching after %s from child %s]\n"), + has_vforked ? "vfork" : "fork", + target_pid_to_str (process_ptid).c_str ()); } } else @@ -522,11 +521,10 @@ holding the child stopped. Try \"set detach-on-fork\" or \ std::string child_pid = target_pid_to_str (child_ptid); target_terminal::ours_for_output (); - fprintf_filtered (gdb_stdlog, - _("[Attaching after %s %s to child %s]\n"), - parent_pid.c_str (), - has_vforked ? "vfork" : "fork", - child_pid.c_str ()); + printf_filtered (_("[Attaching after %s %s to child %s]\n"), + parent_pid.c_str (), + has_vforked ? "vfork" : "fork", + child_pid.c_str ()); } /* Add the new inferior first, so that the target_detach below @@ -634,10 +632,9 @@ holding the child stopped. Try \"set detach-on-fork\" or \ ptid_t process_ptid = ptid_t (parent_ptid.pid ()); target_terminal::ours_for_output (); - fprintf_filtered (gdb_stdlog, - _("[Detaching after fork from " - "parent %s]\n"), - target_pid_to_str (process_ptid).c_str ()); + printf_filtered (_("[Detaching after fork from " + "parent %s]\n"), + target_pid_to_str (process_ptid).c_str ()); } target_detach (parent_inf, 0); @@ -957,15 +954,13 @@ handle_vfork_child_exec_or_exit (int exec) if (exec) { - fprintf_filtered (gdb_stdlog, - _("[Detaching vfork parent %s " - "after child exec]\n"), pidstr.c_str ()); + printf_filtered (_("[Detaching vfork parent %s " + "after child exec]\n"), pidstr.c_str ()); } else { - fprintf_filtered (gdb_stdlog, - _("[Detaching vfork parent %s " - "after child exit]\n"), pidstr.c_str ()); + printf_filtered (_("[Detaching vfork parent %s " + "after child exit]\n"), pidstr.c_str ()); } } |