Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] Prevent source file errors in --batch-silent mode
@ 2008-04-21 19:34 Andrew STUBBS
  2008-04-28 19:02 ` Andrew STUBBS
  2008-05-01 20:34 ` Daniel Jacobowitz
  0 siblings, 2 replies; 13+ messages in thread
From: Andrew STUBBS @ 2008-04-21 19:34 UTC (permalink / raw)
  To: GDB Patches

[-- Attachment #1: Type: text/plain, Size: 1134 bytes --]

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

[-- Attachment #2: batch-silent-interrupt.patch --]
[-- Type: text/plain, Size: 1091 bytes --]

2008-04-21  Andrew Stubbs  <andrew.stubbs@st.com>

	* 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;

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2008-05-03 20:56 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-04-21 19:34 [PATCH] Prevent source file errors in --batch-silent mode Andrew STUBBS
2008-04-28 19:02 ` Andrew STUBBS
2008-05-01 20:34 ` Daniel Jacobowitz
2008-05-02 11:35   ` Andrew STUBBS
2008-05-02 13:46     ` Daniel Jacobowitz
2008-05-02 14:03       ` Andrew STUBBS
2008-05-02 14:10         ` Daniel Jacobowitz
2008-05-03  6:23           ` Thiago Jung Bauermann
2008-05-03 14:26             ` Christopher Faylor
2008-05-03 20:56               ` Thiago Jung Bauermann
2008-05-03 15:33             ` Daniel Jacobowitz
2008-05-03 20:54               ` Thiago Jung Bauermann
2008-05-03 21:48                 ` Daniel Jacobowitz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox