From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18519 invoked by alias); 21 Apr 2008 18:18:36 -0000 Received: (qmail 18495 invoked by uid 22791); 21 Apr 2008 18:18:34 -0000 X-Spam-Check-By: sourceware.org Received: from s200aog10.obsmtp.com (HELO s200aog10.obsmtp.com) (207.126.144.124) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 21 Apr 2008 18:18:11 +0000 Received: from source ([164.129.1.35]) (using TLSv1) by eu1sys200aob010.postini.com ([207.126.147.11]) with SMTP; Mon, 21 Apr 2008 18:18:08 UTC Received: from zeta.dmz-eu.st.com (ns2.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 6C39CDAE4 for ; Mon, 21 Apr 2008 18:18:00 +0000 (GMT) Received: from mail1.bri.st.com (mail1.bri.st.com [164.129.8.218]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id DAFF24C273 for ; Mon, 21 Apr 2008 18:13:25 +0000 (GMT) Received: from [164.129.12.194] (bri0669.bri.st.com [164.129.12.194]) by mail1.bri.st.com (MOS 3.7.5a-GA) with ESMTP id CKB45659 (AUTH stubbsa); Mon, 21 Apr 2008 19:12:31 +0100 (BST) Message-ID: <480CD958.8010409@st.com> Date: Mon, 21 Apr 2008 19:34:00 -0000 From: Andrew STUBBS User-Agent: Thunderbird 2.0.0.12 (Windows/20080213) MIME-Version: 1.0 To: GDB Patches Subject: [PATCH] Prevent source file errors in --batch-silent mode Content-Type: multipart/mixed; boundary="------------000202070208050802060304" X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2008-04/txt/msg00439.txt.bz2 This is a multi-part message in MIME format. --------------000202070208050802060304 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 1134 Hi, The --batch-silent option disables all output on stdout, thus silencing GDB with no impact on the rest of the source base. However, it does *not* silence stderr. Most of the time this is the right thing to do, but it can lead to a little unnecessary noise. Specifically, given the following trivial test file: int main() { while (1) ; return 0; } Compiled with debug info, but with the source file *taken away*, the debugger will produce an irritating error message if the running program is interrupted with Ctrl-C: $ gdb -ex run a.out -batch-silent 3 t.c: No such file or directory. In this example the user is irritated, but in typical real world examples the error message refers to some OS source file they've never heard of (with a scary name like kernel.c), which may lead the user to think there is a real problem. The attached patch prevents GDB attempting to print the source reference when in --batch-silent mode. The only outward evidence of this feature was the error message, so nothing is lost. If anything it's a little more efficient now. Andrew --------------000202070208050802060304 Content-Type: text/plain; name="batch-silent-interrupt.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="batch-silent-interrupt.patch" Content-length: 1091 2008-04-21 Andrew Stubbs * infrun.c (normal_stop): Don't print source location when running in --batch-silent mode. Index: src/gdb/infrun.c =================================================================== --- src.orig/gdb/infrun.c 2008-04-21 18:47:00.000000000 +0100 +++ src/gdb/infrun.c 2008-04-21 18:48:32.000000000 +0100 @@ -3170,6 +3170,11 @@ Further execution is probably impossible if (!stop_stack_dummy) { + /* If --batch-silent is enabled then there's no need to print the current + source location, and to try risks causing an error message about + missing source files. */ + extern int batch_silent; + select_frame (get_current_frame ()); /* Print current location without a level number, if @@ -3178,7 +3183,7 @@ Further execution is probably impossible bpstat_print() contains the logic deciding in detail what to print, based on the event(s) that just occurred. */ - if (stop_print_frame) + if (stop_print_frame && !batch_silent) { int bpstat_ret; int source_flag; --------------000202070208050802060304--