From: Tom de Vries Date: Mon, 15 Nov 2021 21:55:02 +0000 (+0100) Subject: [gdb] Don't use gdb_stdlog for inferior-events X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=636ae5bb4b6b801f8bda05041f600cbf3945c147;p=binutils-gdb.git [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. --- diff --git a/gdb/infrun.c b/gdb/infrun.c index 95c8bfb2e7d..64e535a3477 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 ()); } } diff --git a/gdb/testsuite/gdb.base/foll-vfork.exp b/gdb/testsuite/gdb.base/foll-vfork.exp index a781a5c2087..5de0795d60a 100644 --- a/gdb/testsuite/gdb.base/foll-vfork.exp +++ b/gdb/testsuite/gdb.base/foll-vfork.exp @@ -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