From ca1285d17534cff3041c07ac7841288e1b3ba19c Mon Sep 17 00:00:00 2001 From: Alan Hayward Date: Fri, 17 May 2019 14:15:01 +0100 Subject: Add debug redirect option Currently, when logging is enabled, output will be sent to both a logfile and standard terminal output. The redirect option sends output only to the logfile. This includes all debug output. Add the option to redirect debug output seperately to normal output, using the cli command: set logging debugredirect on By setting this and enabling logging, all output and debug will be sent to the logfile. The user will still see all output but no debug output. This causes a change in behaviour for anyone currently using logging redirect, as now only output will be redirected. Users will have to issue the additional command above to also redirect debug. Expand ui-redirect.exp cover the changes. gdb/ChangeLog: * cli/cli-interp.c (struct saved_output_files): Add saved entry. (cli_interp_base::set_logging): Check debug_redirect. * cli/cli-interp.h (set_logging): Add debug_redirect parameter. * cli/cli-logging.c (debug_redirect): Add static variable. (pop_output_files): Add default param. (handle_redirections): Print debug setting. (show_logging_command): Likewise. (_initialize_cli_logging): Add debugredirect command. * interps.c (current_interp_set_logging): Add debug_redirect parameter. * interps.h (set_logging): Add debug_redirect parameter. (current_interp_set_logging): Likewise. * mi/mi-common.h: Likewise. * mi/mi-interp.c (mi_interp::set_logging): Likewise. gdb/testsuite/ChangeLog: * gdb.base/ui-redirect.exp: Add debug redirect tests. --- gdb/testsuite/gdb.base/ui-redirect.exp | 38 +++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) (limited to 'gdb/testsuite/gdb.base') diff --git a/gdb/testsuite/gdb.base/ui-redirect.exp b/gdb/testsuite/gdb.base/ui-redirect.exp index f1d00b9..e62d5e8 100644 --- a/gdb/testsuite/gdb.base/ui-redirect.exp +++ b/gdb/testsuite/gdb.base/ui-redirect.exp @@ -34,9 +34,17 @@ gdb_test_multiple $test $test { } gdb_test_no_output "end" +if ![runto_main] { + fail "can't run to main" + return -1 +} +gdb_breakpoint "foo" +gdb_breakpoint "bar" + with_test_prefix "logging" { gdb_test_no_output "set logging file /dev/null" - gdb_test "set logging on" "Copying output to /dev/null\\." + gdb_test "set logging on" \ + "Copying output to /dev/null.*Copying debug output to /dev/null\\." gdb_test "save breakpoints /dev/null" "Saved to file '/dev/null'\\." gdb_test "set logging off" "Done logging to /dev/null\\." gdb_test "help" "List of classes of commands:.*" @@ -44,7 +52,8 @@ with_test_prefix "logging" { with_test_prefix "redirect" { gdb_test "set logging redirect on" - gdb_test "set logging on" "Redirecting output to /dev/null\\." + gdb_test "set logging on" \ + "Redirecting output to /dev/null.*Copying debug output to /dev/null\\." gdb_test_no_output "save breakpoints /dev/null" gdb_test "set logging off" "Done logging to /dev/null\\." gdb_test "help" "List of classes of commands:.*" @@ -52,10 +61,33 @@ with_test_prefix "redirect" { with_test_prefix "redirect while already logging" { gdb_test_no_output "set logging redirect off" - gdb_test "set logging on" "Copying output to /dev/null\\." + gdb_test "set logging on" \ + "Copying output to /dev/null.*Copying debug output to /dev/null\\." gdb_test "set logging redirect on" \ ".*warning: Currently logging .*Turn the logging off and on to make the new setting effective.*" gdb_test "save breakpoints /dev/null" "Saved to file '/dev/null'\\." gdb_test "set logging off" "Done logging to /dev/null\\." gdb_test "help" "List of classes of commands:.*" + gdb_test_no_output "set logging redirect off" +} + +with_test_prefix "debugging" { + gdb_test "set debug infrun 1" + gdb_test "set logging on" \ + "Copying output to /dev/null.*Copying debug output to /dev/null\\." + gdb_test "continue" "Continuing.*infrun:.*infrun:.*Breakpoint \[0-9\]+, foo.*" + gdb_test "set debug infrun 0" + gdb_test "set logging off" "Done logging to /dev/null\\." + gdb_test "help" "List of classes of commands:.*" +} + +with_test_prefix "redirect debugging" { + gdb_test_no_output "set logging debugredirect on" + gdb_test "set debug infrun 1" + gdb_test "set logging on" \ + "Copying output to /dev/null.*Redirecting debug output to /dev/null\\." + gdb_test "continue" "Continuing.*((?!infrun).).*Breakpoint \[0-9\]+, bar.*" + gdb_test "set debug infrun 0" + gdb_test "set logging off" "Done logging to /dev/null\\." + gdb_test "help" "List of classes of commands:.*" } -- cgit v1.1