This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH v3 3/3] GDBServer: add 'monitor set server-output' command
- From: Cleber Rosa <crosa at redhat dot com>
- To: gdb-patches at sourceware dot org
- Cc: areis at redhat dot com, Cleber Rosa <crosa at redhat dot com>
- Date: Tue, 31 Mar 2015 12:49:07 -0300
- Subject: [PATCH v3 3/3] GDBServer: add 'monitor set server-output' command
- Authentication-results: sourceware.org; auth=none
- References: <1427816947-25750-1-git-send-email-crosa at redhat dot com>
This monitor command, just like the command line option --server-output,
will redirect all of the gdbserver's own output (always sent to stderr)
to a separate file.
gdb/Changelog:
2015-03-31 Cleber Rosa <crosa@redhat.com>
* NEWS: New feature in the GDBserver: monitor set server-output.
gdb/doc/Changelog:
2015-03-31 Cleber Rosa <crosa@redhat.com>
* gdb.texinfo (info): Add documentation about the 'monitor set
server-output' command.
gdb/gdbserver/Changelog:
2015-03-31 Cleber Rosa <crosa@redhat.com>
* server.c (monitor_show_help): Add help message about the
'monitor set server-output' command.
(handle_monitor_command): Respond to 'set server-output' command.
gdb/testsuite/ChangeLog:
2015-03-31 Cleber Rosa <crosa@redhat.com>
* gdb.server/server-mon.exp: Add tests with the 'monitor set
server-output' command succeeding and failing.
---
gdb/NEWS | 2 ++
gdb/doc/gdb.texinfo | 3 +++
gdb/gdbserver/server.c | 24 +++++++++++++++++++++---
gdb/testsuite/gdb.server/server-mon.exp | 8 ++++++++
4 files changed, 34 insertions(+), 3 deletions(-)
diff --git a/gdb/NEWS b/gdb/NEWS
index 737aacf..763154b 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -104,6 +104,8 @@ Itanium running HP-UX ia64-*-hpux*
** New option --server-output=file allows users to send the
server output to a separate file.
+ ** New monitor command "monitor set server-output", the monitor
+ command counterpart of command line option --server-output.
*** Changes in GDB 7.9
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 1cfabd4..aaec295 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -19329,6 +19329,9 @@ Include a timestamp in each line of debugging output.
Options are processed in order. Thus, for example, if @option{none}
appears last then no additional information is added to debugging output.
+@item monitor set server-output @var{output_filename}
+Redirect the server output to a file given by @var{output_filename}.
+
@item monitor set libthread-db-search-path [PATH]
@cindex gdbserver, search path for @code{libthread_db}
When this command is issued, @var{path} is a colon-separated list of
diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c
index b4a715f..51251f9 100644
--- a/gdb/gdbserver/server.c
+++ b/gdb/gdbserver/server.c
@@ -754,9 +754,9 @@ monitor_show_help (void)
monitor_output (" Enable remote protocol debugging messages\n");
monitor_output (" set debug-format option1[,option2,...]\n");
monitor_output (" Add additional information to debugging messages\n");
- monitor_output (" Options: all, none");
- monitor_output (", timestamp");
- monitor_output ("\n");
+ monitor_output (" Options: all, none, timestamp\n");
+ monitor_output (" set server-output output_filename\n");
+ monitor_output (" Redirects the server output to output_filename\n");
monitor_output (" exit\n");
monitor_output (" Quit GDBserver\n");
}
@@ -1105,6 +1105,24 @@ handle_monitor_command (char *mon, char *own_buf)
xfree (error_msg);
}
}
+ else if (strncmp (mon, "set server-output ",
+ sizeof ("set server-output ") -1) == 0)
+ {
+ char *out_filename = mon + (sizeof ("set server-output ") - 1);
+ if (set_server_output (out_filename) == 0) {
+ char *monitor_msg = xstrprintf ("Redirected server output to '%s'\n",
+ out_filename);
+ monitor_output (monitor_msg);
+ xfree (monitor_msg);
+ }
+ else
+ {
+ char *monitor_msg = xstrprintf ("Failed to set server output to '%s'\n",
+ out_filename);
+ monitor_output (monitor_msg);
+ xfree (monitor_msg);
+ }
+ }
else if (strcmp (mon, "help") == 0)
monitor_show_help ();
else if (strcmp (mon, "exit") == 0)
diff --git a/gdb/testsuite/gdb.server/server-mon.exp b/gdb/testsuite/gdb.server/server-mon.exp
index a4c03ee..a19bc11 100644
--- a/gdb/testsuite/gdb.server/server-mon.exp
+++ b/gdb/testsuite/gdb.server/server-mon.exp
@@ -54,3 +54,11 @@ gdb_test "monitor set debug-format all" \
"All extra debug format options enabled\\."
gdb_test "monitor set debug-format none" \
"All extra debug format options disabled\\."
+
+# Tests the monitor command that sends stderr output to another file
+gdb_test "monitor set server-output /dev/null" \
+ "Redirected server output to '/dev/null'"
+
+# Tests the monitor command that sends stderr output to another file
+gdb_test "monitor set server-output /im/pro/ba/ble/pa/th" \
+ "Failed to set server output to '/im/pro/ba/ble/pa/th'"
--
1.9.3