internal-error, or an internal-warning. This is on by default for
internal-error and off by default for internal-warning.
+set logging on|off
+ Deprecated and replaced by "set logging enabled on|off".
+
+set logging enabled on|off
+show logging enabled
+ These commands set or show whether logging is enabled or disabled.
+
* Python API
** New function gdb.add_history(), which takes a gdb.Value object
#include "ui-out.h"
#include "interps.h"
#include "cli/cli-style.h"
+#include "cli/cli-decode.h"
static char *saved_filename;
saved_filename = NULL;
}
+static bool logging_enabled;
+
+static void
+set_logging_enabled (const char *args,
+ int from_tty, struct cmd_list_element *c)
+{
+ if (logging_enabled)
+ set_logging_on (args, from_tty);
+ else
+ set_logging_off (args, from_tty);
+}
+
+static void
+show_logging_enabled (struct ui_file *file, int from_tty,
+ struct cmd_list_element *c, const char *value)
+{
+ if (logging_enabled)
+ printf_unfiltered (_("Logging is enabled.\n"));
+ else
+ printf_unfiltered (_("Logging is disabled.\n"));
+}
+
void _initialize_cli_logging ();
void
_initialize_cli_logging ()
{
static struct cmd_list_element *set_logging_cmdlist, *show_logging_cmdlist;
+ /* Set/show logging. */
add_setshow_prefix_cmd ("logging", class_support,
_("Set logging options."),
_("Show logging options."),
&set_logging_cmdlist, &show_logging_cmdlist,
&setlist, &showlist);
+ /* Set/show logging overwrite. */
add_setshow_boolean_cmd ("overwrite", class_support, &logging_overwrite, _("\
Set whether logging overwrites or appends to the log file."), _("\
Show whether logging overwrites or appends to the log file."), _("\
set_logging_overwrite,
show_logging_overwrite,
&set_logging_cmdlist, &show_logging_cmdlist);
+
+ /* Set/show logging redirect. */
add_setshow_boolean_cmd ("redirect", class_support, &logging_redirect, _("\
Set the logging output mode."), _("\
Show the logging output mode."), _("\
set_logging_redirect,
show_logging_redirect,
&set_logging_cmdlist, &show_logging_cmdlist);
+
+ /* Set/show logging debugredirect. */
add_setshow_boolean_cmd ("debugredirect", class_support,
&debug_redirect, _("\
Set the logging debug output mode."), _("\
show_logging_redirect,
&set_logging_cmdlist, &show_logging_cmdlist);
+ /* Set/show logging file. */
add_setshow_filename_cmd ("file", class_support, &logging_filename, _("\
Set the current logfile."), _("\
Show the current logfile."), _("\
NULL,
show_logging_filename,
&set_logging_cmdlist, &show_logging_cmdlist);
- add_cmd ("on", class_support, set_logging_on,
- _("Enable logging."), &set_logging_cmdlist);
- add_cmd ("off", class_support, set_logging_off,
- _("Disable logging."), &set_logging_cmdlist);
+
+ /* Set/show logging enabled. */
+ set_show_commands setshow_logging_enabled_cmds
+ = add_setshow_boolean_cmd ("enabled", class_support, &logging_enabled,
+ _("Enable logging."),
+ _("Show whether logging is enabled."),
+ _("When on, enable logging."),
+ set_logging_enabled,
+ show_logging_enabled,
+ &set_logging_cmdlist, &show_logging_cmdlist);
+
+ /* Set logging on, deprecated alias. */
+ cmd_list_element *set_logging_on_cmd
+ = add_alias_cmd ("on", setshow_logging_enabled_cmds.set, class_support,
+ false, &set_logging_cmdlist);
+ deprecate_cmd (set_logging_on_cmd, "set logging enabled on");
+ set_logging_on_cmd->default_args = "on";
+
+ /* Set logging off, deprecated alias. */
+ cmd_list_element *set_logging_off_cmd
+ = add_alias_cmd ("off", setshow_logging_enabled_cmds.set, class_support,
+ false, &set_logging_cmdlist);
+ deprecate_cmd (set_logging_off_cmd, "set logging enabled off");
+ set_logging_off_cmd->default_args = "off";
}
There are several commands to control @value{GDBN}'s logging.
@table @code
-@kindex set logging
-@item set logging on
-Enable logging.
-@item set logging off
-Disable logging.
+@kindex set logging enabled
+@item set logging enabled [on|off]
+Enable or disable logging.
@cindex logging file name
@item set logging file @var{file}
Change the name of the current logfile. The default logfile is @file{gdb.txt}.
@item set logging overwrite [on|off]
By default, @value{GDBN} will append to the logfile. Set @code{overwrite} if
-you want @code{set logging on} to overwrite the logfile instead.
+you want @code{set logging enabled on} to overwrite the logfile instead.
@item set logging redirect [on|off]
By default, @value{GDBN} output will go to both the terminal and the logfile.
Set @code{redirect} if you want output to go only to the log file.
set file [standard_output_file gdb.txt]
gdb_test_no_output "set logging file $file" "set logging file"
gdb_test_no_output "set logging redirect on"
-gdb_test "set logging on"
+gdb_test "set logging enabled on"
gdb_test_no_output "maint print symbols"
-gdb_test "set logging off"
+gdb_test "set logging enabled off"
file delete $file
set bp_location [gdb_get_line_number "BREAK" ${testdir}/foo.adb]
gdb_test_no_output "set logging file $log_name" \
"set logging filename"
gdb_test_no_output "set logging overwrite on"
- gdb_test "set logging on" "Copying output to .*"
+ gdb_test "set logging enabled on" "Copying output to .*"
set main_expr [style main function]
set base_file_expr [style ".*style\\.c" file]
gdb_test "frame" \
"$main_expr.*$arg_expr.*$arg_expr.*$file_expr.*"
- gdb_test "set logging off" "Done logging to .*"
+ gdb_test "set logging enabled off" "Done logging to .*"
set fd [open $log_name]
set data [read -nonewline $fd]
with_test_prefix "logging" {
gdb_test_no_output "set logging file /dev/null"
- gdb_test "set logging on" \
+ gdb_test "set logging enabled on" \
"Copying output to /dev/null.*Copying debug output to /dev/null\\."
gdb_test "save breakpoints $cmds_file" "Saved to file '$cmds_file'\\." \
"save breakpoints cmds.txt"
cmp_file_string "$cmds_file" "$cmds" "cmds.txt"
gdb_test "userdefined" "#0 main ().*"
- gdb_test "set logging off" "Done logging to /dev/null\\."
+ gdb_test "set logging enabled off" "Done logging to /dev/null\\."
gdb_test "help" "List of classes of commands:.*"
}
with_test_prefix "redirect" {
gdb_test "set logging redirect on"
- gdb_test "set logging on" \
+ gdb_test "set logging enabled on" \
"Redirecting output to /dev/null.*Copying debug output to /dev/null\\."
gdb_test_no_output "save breakpoints $cmds_file" "save breakpoints cmds.txt"
cmp_file_string "$cmds_file" "$cmds" "cmds.txt"
gdb_test_no_output "userdefined"
- gdb_test "set logging off" "Done logging to /dev/null\\."
+ gdb_test "set logging enabled off" "Done logging to /dev/null\\."
gdb_test "help" "List of classes of commands:.*"
}
with_test_prefix "redirect while already logging" {
gdb_test_no_output "set logging redirect off"
- gdb_test "set logging on" \
+ gdb_test "set logging enabled 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.*"
"save breakpoints cmds.txt"
cmp_file_string "$cmds_file" "$cmds" "cmds.txt"
gdb_test "userdefined" "#0 main ().*"
- gdb_test "set logging off" "Done logging to /dev/null\\."
+ gdb_test "set logging enabled 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" \
+ gdb_test "set logging enabled on" \
"Copying output to /dev/null.*Copying debug output to /dev/null\\."
set prompt "$gdb_prompt \\\[infrun\\\] fetch_inferior_event: exit\r\n$"
}
gdb_test "set debug infrun 0"
- gdb_test "set logging off" "Done logging to /dev/null\\."
+ gdb_test "set logging enabled 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" \
+ gdb_test "set logging enabled 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 "set logging enabled off" "Done logging to /dev/null\\."
gdb_test "help" "List of classes of commands:.*"
}
with_test_prefix "redirect logging and debuging" {
gdb_test_no_output "set logging redirect on"
gdb_test_no_output "set logging debugredirect on"
- gdb_test "set logging on" \
+ gdb_test "set logging enabled on" \
"Redirecting output to /dev/null.*Redirecting debug output to /dev/null\\."
- gdb_test "set logging off" "Done logging to /dev/null\\."
+ gdb_test "set logging enabled off" "Done logging to /dev/null\\."
}
mi_gdb_test "-gdb-set logging overwrite on" ".*"
-mi_gdb_test "-gdb-set logging on" ".*" "logging on"
+mi_gdb_test "-gdb-set logging enabled on" ".*" "logging on"
mi_step "logged step"
mi_next "logged next"
-mi_gdb_test "-gdb-set logging off" ".*" "logging off"
+mi_gdb_test "-gdb-set logging enabled off" ".*" "logging off"
set chan [open $milogfile]
set logcontent [read $chan]
# Since all output will be going into the file, just keep sending commands
# and don't expect anything to appear until logging is turned off.
-send_gdb "1001-gdb-set logging on\n"
+send_gdb "1001-gdb-set logging enabled on\n"
send_gdb "1002-exec-step\n"
send_gdb "1003-exec-next\n"
-mi_gdb_test "1004-gdb-set logging off" ".*" "redirect logging off"
+mi_gdb_test "1004-gdb-set logging enabled off" ".*" "redirect logging off"
set chan [open $milogfile]
set logcontent [read $chan]
with_test_prefix "redirect while already logging" {
mi_gdb_test "-gdb-set logging redirect off" ".*" \
"logging redirect off"
- mi_gdb_test "-gdb-set logging on" ".*" \
+ mi_gdb_test "-gdb-set logging enabled on" ".*" \
"logging on"
mi_gdb_test "-gdb-set logging redirect on" \
".*warning: Currently logging .*Turn the logging off and on to make the new setting effective.*" \
"logging redirect on"
- mi_gdb_test "-gdb-set logging off" ".*" \
+ mi_gdb_test "-gdb-set logging enabled off" ".*" \
"logging off"
}
}
# First ensure logging is off.
- send_gdb "set logging off\n"
+ send_gdb "set logging enabled off\n"
set debugfile [standard_output_file gdb.debug]
send_gdb "set logging file $debugfile\n"
}
# Now that everything is set, enable logging.
- send_gdb "set logging on\n"
+ send_gdb "set logging enabled on\n"
gdb_expect 10 {
-re "Copying output to $debugfile.*Redirecting debug output to $debugfile.*$gdb_prompt $" {}
timeout { warning "Couldn't set logging file" }