[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.
This commit is contained in:
Tom de Vries
2021-11-15 22:55:02 +01:00
parent d029b54d9c
commit 636ae5bb4b
2 changed files with 14 additions and 26 deletions

View File

@ -455,8 +455,7 @@ 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"),
printf_filtered (_("[Detaching after %s from child %s]\n"),
has_vforked ? "vfork" : "fork",
target_pid_to_str (process_ptid).c_str ());
}
@ -522,8 +521,7 @@ 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"),
printf_filtered (_("[Attaching after %s %s to child %s]\n"),
parent_pid.c_str (),
has_vforked ? "vfork" : "fork",
child_pid.c_str ());
@ -634,8 +632,7 @@ 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 "
printf_filtered (_("[Detaching after fork from "
"parent %s]\n"),
target_pid_to_str (process_ptid).c_str ());
}
@ -957,14 +954,12 @@ handle_vfork_child_exec_or_exit (int exec)
if (exec)
{
fprintf_filtered (gdb_stdlog,
_("[Detaching vfork parent %s "
printf_filtered (_("[Detaching vfork parent %s "
"after child exec]\n"), pidstr.c_str ());
}
else
{
fprintf_filtered (gdb_stdlog,
_("[Detaching vfork parent %s "
printf_filtered (_("[Detaching vfork parent %s "
"after child exit]\n"), pidstr.c_str ());
}
}

View File

@ -25,13 +25,6 @@ if {![istarget "*-linux*"]} then {
continue
}
# Test relies on checking follow-fork output. Do not run if gdb debug is
# enabled as it will be redirected to the log.
if [gdb_debug_enabled] {
untested "debug is enabled"
return 0
}
standard_testfile
set compile_options debug