From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18166 invoked by alias); 18 Oct 2005 11:28:34 -0000 Mailing-List: contact gdb-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sources.redhat.com Received: (qmail 18154 invoked by uid 22791); 18 Oct 2005 11:28:30 -0000 Received: from fra-del-01.spheriq.net (HELO fra-del-01.spheriq.net) (195.46.51.97) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Tue, 18 Oct 2005 11:28:30 +0000 Received: from fra-out-01.spheriq.net (fra-out-01.spheriq.net [195.46.51.129]) by fra-del-01.spheriq.net with ESMTP id j9IBSREk025690 for ; Tue, 18 Oct 2005 11:28:27 GMT Received: from fra-cus-01.spheriq.net (fra-cus-01.spheriq.net [195.46.51.37]) by fra-out-01.spheriq.net with ESMTP id j9IBSNbI004692 for ; Tue, 18 Oct 2005 11:28:24 GMT Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by fra-cus-01.spheriq.net with ESMTP id j9IBSM1I018481 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=OK) for ; Tue, 18 Oct 2005 11:28:23 GMT Received: from zeta.dmz-eu.st.com (ns2.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id B3327DA42 for ; Tue, 18 Oct 2005 11:28:21 +0000 (GMT) Received: by zeta.dmz-eu.st.com (STMicroelectronics, from userid 60012) id 2B455473CF; Tue, 18 Oct 2005 11:31:07 +0000 (GMT) Received: from zeta.dmz-eu.st.com (localhost [127.0.0.1]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id D3E87759B4 for ; Tue, 18 Oct 2005 11:31:06 +0000 (UTC) Received: from mail1.bri.st.com (mail1.bri.st.com [164.129.8.218]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 36EC8473D5 for ; Tue, 18 Oct 2005 11:31:06 +0000 (GMT) Received: from [164.129.15.13] (terrorhawk.bri.st.com [164.129.15.13]) by mail1.bri.st.com (MOS 3.5.8-GR) with ESMTP id CDA01401 (AUTH "andrew stubbs"); Tue, 18 Oct 2005 12:28:19 +0100 (BST) Message-ID: <4354DBFF.7000601@st.com> Date: Tue, 18 Oct 2005 11:28:00 -0000 From: Andrew STUBBS User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) MIME-Version: 1.0 To: gdb@sources.redhat.com Subject: RFC: GDB as a loader 1/3: silent batch mode Content-Type: multipart/mixed; boundary="------------060607090907080007020603" X-O-Spoofed: Not Scanned X-O-General-Status: No X-O-Spam1-Status: Not Scanned X-O-Spam2-Status: Not Scanned X-O-URL-Status: Not Scanned X-O-Virus1-Status: No X-O-Virus2-Status: Not Scanned X-O-Virus3-Status: No X-O-Virus4-Status: No X-O-Virus5-Status: Not Scanned X-O-Image-Status: Not Scanned X-O-Attach-Status: Not Scanned X-SpheriQ-Ver: 2.3.0 X-SW-Source: 2005-10/txt/msg00095.txt.bz2 This is a multi-part message in MIME format. --------------060607090907080007020603 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 1693 Hi all, It is my experience that GDB is often used, by means of the --batch and --command options, as a mechanism for downloading and running programs on remote targets (development boards and the like). This may be using a sledgehammer to crack a nut, but given that a debugger is always required in these cases and that creating an additional specific loader requires effort, it is not surprising that it is used for this purpose. I have therefore created a number of features to make this process a little more comfortable. I have split them into separate posts so that they may be discussed separately. All have been regression tested for both i686-pc-linux-gnu and sh-elf an have produced no new failures. I have not attempted to produce any new test cases. Probably there should be some, but where and how? Silent Batch Mode The attached patch implements a new option --batch-silent. This does much the same a --batch, except that it also disables gdb_stdout. This means that all GDB outputs, other than errors, are hidden. The advantage of this is that I no longer have to create dodgy scripts to filter out all the various GDB messages from my program output (Loading section ..., Process exited successfully, etc.). Obviously this is not particularly useful with targets such as the GDB simulator that give their output through the GDB print mechanisms. However, all targets which print via regular stdout (as our custom target interface here at ST does) work fine. Perhaps somebody could suggest a solution for those targets with which it does not work. This patch does not affect the behaviour of stderr or gdb_stderr - an error is still an error. Thanks Andrew Stubbs --------------060607090907080007020603 Content-Type: text/plain; name="batch-silent.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="batch-silent.patch" Content-length: 2483 2005-10-18 Andrew Stubbs * event-top.c (gdb_setup_readline): Don't set gdb_stdout when --batch-silent option was given. * main.c (batch_silent): New variable. (captured_main): Add new option --batch-silent. (print_gdb_help): Likewise. Index: src/gdb/event-top.c =================================================================== --- src.orig/gdb/event-top.c 2005-03-16 17:05:31.000000000 +0000 +++ src/gdb/event-top.c 2005-10-17 17:38:27.000000000 +0100 @@ -1110,8 +1110,10 @@ gdb_setup_readline (void) that the sync setup is ALL done in gdb_init, and we would only mess it up here. The sync stuff should really go away over time. */ + extern batch_silent; - gdb_stdout = stdio_fileopen (stdout); + if (!batch_silent) + gdb_stdout = stdio_fileopen (stdout); gdb_stderr = stdio_fileopen (stderr); gdb_stdlog = gdb_stderr; /* for moment */ gdb_stdtarg = gdb_stderr; /* for moment */ Index: src/gdb/main.c =================================================================== --- src.orig/gdb/main.c 2005-10-17 15:29:40.000000000 +0100 +++ src/gdb/main.c 2005-10-17 17:44:35.000000000 +0100 @@ -73,6 +73,9 @@ struct ui_file *gdb_stdtargin; struct ui_file *gdb_stdtarg; struct ui_file *gdb_stdtargerr; +/* Support for the --batch-silent option. */ +int batch_silent = 0; + /* Whether to enable writing into executable and core files */ extern int write_files; @@ -254,6 +257,7 @@ captured_main (void *data) {"silent", no_argument, &quiet, 1}, {"nx", no_argument, &inhibit_gdbinit, 1}, {"n", no_argument, &inhibit_gdbinit, 1}, + {"batch-silent", no_argument, 0, 'B'}, {"batch", no_argument, &batch, 1}, {"epoch", no_argument, &epoch_interface, 1}, @@ -384,6 +388,10 @@ captured_main (void *data) cmdsize * sizeof (*cmdarg)); } break; + case 'B': + batch = batch_silent = 1; + gdb_stdout = ui_file_new(); + break; #ifdef GDBTK case 'z': { @@ -834,6 +842,7 @@ Options:\n\n\ fputs_unfiltered (_("\ -b BAUDRATE Set serial port baud rate used for remote debugging.\n\ --batch Exit after processing options.\n\ + --batch-silent As for --batch, but suppress all gdb stdout output.\n\ --cd=DIR Change current directory to DIR.\n\ --command=FILE Execute GDB commands from FILE.\n\ --core=COREFILE Analyze the core dump COREFILE.\n\ --------------060607090907080007020603--