From patchwork Sat Mar 21 02:34:25 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cleber Rosa X-Patchwork-Id: 5747 Received: (qmail 47665 invoked by alias); 21 Mar 2015 02:35:27 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 47598 invoked by uid 89); 21 Mar 2015 02:35:26 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL, BAYES_00, SPF_HELO_PASS, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Sat, 21 Mar 2015 02:35:24 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t2L2ZNX9011816 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Fri, 20 Mar 2015 22:35:23 -0400 Received: from x220.homelab.tallawa.org.com ([10.3.112.4]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t2L2YppP029072; Fri, 20 Mar 2015 22:35:19 -0400 From: Cleber Rosa To: gdb-patches@sourceware.org Cc: crosa@redhat.com, areis@redhat.com Subject: [PATCH 4/4] GDBServer: add 'monitor set server-stderr' command Date: Fri, 20 Mar 2015 23:34:25 -0300 Message-Id: <1426905265-8495-5-git-send-email-crosa@redhat.com> In-Reply-To: <1426905265-8495-1-git-send-email-crosa@redhat.com> References: <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 * gdb.texinfo (info): Add documentation about the 'monitor set server-stderr' command gdb/gdbserver/Changelog: 2015-03-20 Cleber Rosa * 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 * 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 \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'"