From: Cleber Rosa <crosa@redhat.com>
To: gdb-patches@sourceware.org
Cc: crosa@redhat.com, areis@redhat.com
Subject: [PATCH 4/4] GDBServer: add 'monitor set server-stderr' command
Date: Sat, 21 Mar 2015 02:35:00 -0000 [thread overview]
Message-ID: <1426905265-8495-5-git-send-email-crosa@redhat.com> (raw)
In-Reply-To: <1426905265-8495-1-git-send-email-crosa@redhat.com>
This monitor command, just like the command line option --server-stderr,
will redirect all of the gdbserver's own output (always sent to stderr)
to a separate file.
gdb/doc/Changelog:
2015-03-20 Cleber Rosa <crosa@redhat.com>
* gdb.texinfo (info): Add documentation about the 'monitor set
server-stderr' command
gdb/gdbserver/Changelog:
2015-03-20 Cleber Rosa <crosa@redhat.com>
* server.c (monitor_show_help): Add help message about the
'monitor set server-stderr' command
(handle_monitor_command): Respond to 'set server-stderr' command
gdb/testsuite/ChangeLog:
2015-03-20 Cleber Rosa <crosa@redhat.com>
* gdb.server/server-mon.exp: Add tests with the 'monitor set
server-stderr' command succeeding and failing
---
gdb/doc/gdb.texinfo | 3 +++
gdb/gdbserver/server.c | 22 +++++++++++++++++++---
gdb/testsuite/gdb.server/server-mon.exp | 8 ++++++++
3 files changed, 30 insertions(+), 3 deletions(-)
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 2834794..3a6bbde 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -19314,6 +19314,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-stderr [PATH]
+Redirect the server stderr to a file given by @var{path}.
+
@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 db26f24..afa7aed 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-stderr <path>\n");
+ monitor_output (" Redirects the server stderr content to another file\n");
monitor_output (" exit\n");
monitor_output (" Quit GDBserver\n");
}
@@ -1105,6 +1105,22 @@ handle_monitor_command (char *mon, char *own_buf)
xfree (error_msg);
}
}
+ else if (strncmp (mon, "set server-stderr ",
+ sizeof ("set server-stderr ") -1) == 0)
+ {
+ char *path = mon + (sizeof ("set server-stderr ") - 1);
+ if (set_server_stderr (path) == 0) {
+ char *monitor_msg = xstrprintf ("Redirected server stderr to '%s'\n", path);
+ monitor_output (monitor_msg);
+ xfree (monitor_msg);
+ }
+ else
+ {
+ char *monitor_msg = xstrprintf ("Failed to set server stderr to '%s'\n", path);
+ 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..34cd1ce 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-stderr /dev/null" \
+ "Redirected server stderr to '/dev/null'"
+
+# Tests the monitor command that sends stderr output to another file
+gdb_test "monitor set server-stderr /im/pro/ba/ble/pa/th" \
+ "Failed to set server stderr to '/im/pro/ba/ble/pa/th'"
--
1.9.3
next prev parent reply other threads:[~2015-03-21 2:35 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-21 2:35 [PATCH 0/4] GDBServer: introduce a dedicated stderr stream Cleber Rosa
2015-03-21 2:35 ` Cleber Rosa [this message]
2015-03-21 8:29 ` [PATCH 4/4] GDBServer: add 'monitor set server-stderr' command Eli Zaretskii
2015-03-23 20:09 ` Cleber Rosa
2015-03-21 2:35 ` [PATCH 1/4] GDBServer: introduce a stderr stream dedicated to the server Cleber Rosa
2015-03-21 2:35 ` [PATCH 2/4] GDBServer: give more complete usage information Cleber Rosa
2015-03-21 17:05 ` Pedro Alves
2015-03-24 14:15 ` Cleber Rosa
2015-03-31 14:44 ` Cleber Rosa
2015-04-01 10:10 ` Pedro Alves
2015-03-21 2:35 ` [PATCH 3/4] GDBServer: introduce --server-stderr command line option Cleber Rosa
2015-03-21 8:26 ` Eli Zaretskii
2015-03-23 18:51 ` Cleber Rosa
2015-03-23 19:12 ` Eli Zaretskii
2015-03-23 20:35 ` Cleber Rosa
2015-03-23 20:43 ` Eli Zaretskii
2015-03-21 15:05 ` [PATCH 0/4] GDBServer: introduce a dedicated stderr stream Pedro Alves
2015-03-24 17:07 ` Cleber Rosa
2015-04-01 11:17 ` Pedro Alves
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1426905265-8495-5-git-send-email-crosa@redhat.com \
--to=crosa@redhat.com \
--cc=areis@redhat.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox