[PATCH] Prevent source file errors in --batch-silent mode

Andrew STUBBS andrew.stubbs@st.com
Mon Apr 21 19:34:00 GMT 2008


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
<Ctrl-C>
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.

<ADDPATCH infrun.c>

Andrew
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: batch-silent-interrupt.patch
URL: <http://sourceware.org/pipermail/gdb-patches/attachments/20080421/e01fe5b3/attachment.ksh>


More information about the Gdb-patches mailing list