Subject: 24.3; gdb -mi: breakpoint with in non-existent source file spams terminal incessantly

From: Ryan Johnson <[email-masked]>
Date: Thu, 08 Aug 2013 09:47:06 -0400

Setting a breakpoint whose target is in a source file that gdb can't
find spams the terminal with failed source listings after every
command. This makes gdb-mode significantly less pleasant to use,
especially since important library functions like abort(),
__cxa_throw(), etc. usually don't have sources available.

To reproduce:

1. Create the following two files:

/* <<<--- foo.c --->>> */
#include <stdio.h>
extern void bar();
int main() {
puts("Thinking about calling bar");;
puts("Planning to call bar");
puts("About to call bar");
bar();
puts("Called bar");
return 0;
};
/* <<<--- end foo.c --->>> */

/* <<<--- bar.c --->>> */
void bar() { }
/* <<<--- end bar.c --->>> */

2. Compile them: `gcc -g foo.c bar.c -o bug'

3. Delete or move bar.c: `rm bar.c'

4. Invoke emacs: `emacs -Q'

5. M-x gdb (giving `bug' as the executable to debug)

6. Execute the following commands in gdb:
b bar
start
n
n
fin
n
n
n
quit

The output looks something like the typescript below. Note how gdb
attempts to list bar.c after every command:

<<<--- begin emacs gdb session --->>>
Current directory is ~/experiments/
GNU gdb (GDB) 7.6.50.20130728-cvs (cygwin-special)
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later 
<http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-pc-cygwin".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
..
Reading symbols from /home/Ryan/experiments/bug...done.
(gdb) b bar
Breakpoint 1 at 0x100401114: file bar.c, line 1.
(gdb) list bar.c:1
1       bar.c: No such file or directory.
start
Temporary breakpoint 2 at 0x1004010dd: file foo.c, line 4.
Starting program: /home/Ryan/experiments/bug
[New Thread 4308.0x1038]
[New Thread 4308.0x108c]

Temporary breakpoint 2, main () at foo.c:4
4           puts("About to call bar");
(gdb) list bar.c:1
1       bar.c: No such file or directory.
n
5           bar();
(gdb) list bar.c:1
1       bar.c: No such file or directory.
n

Breakpoint 1, bar () at bar.c:1
1       in bar.c
(gdb) list bar.c:1
1       in bar.c
fin
Run till exit from #0  bar () at bar.c:1
main () at foo.c:6
6           puts("Called bar");
(gdb) list bar.c:1
1       bar.c: No such file or directory.
n
7           return 0;
(gdb) list bar.c:1
1       bar.c: No such file or directory.
n
8       };
(gdb) list bar.c:1
1       bar.c: No such file or directory.
n
[Inferior 1 (process 4308) exited normally]
(gdb) list bar.c:1
1       in bar.c
quit

Debugger finished
<<<--- end emacs gdb session --->>>

By way of comparison, here is what happens if I run gdb outside emacs 
(gdb startup message removed for brevity):

<<<--- begin standalone gdb session --->>>
Reading symbols from /home/Ryan/experiments/bug...done.
(gdb) b bar
Breakpoint 1 at 0x100401114: file bar.c, line 1.
(gdb) start
Temporary breakpoint 2 at 0x1004010dd: file foo.c, line 4.
Starting program: /home/Ryan/experiments/bug
[New Thread 4676.0x1250]
[New Thread 4676.0x13d0]

Temporary breakpoint 2, main () at foo.c:4
4           puts("About to call bar");
(gdb) n
About to call bar
5           bar();
(gdb) n

Breakpoint 1, bar () at bar.c:1
1       bar.c: No such file or directory.
(gdb) fin
Run till exit from #0  bar () at bar.c:1
main () at foo.c:6
6           puts("Called bar");
(gdb) n
Called bar
7           return 0;
(gdb) n
8       };
(gdb) n
[Thread 4676.0x13d0 exited with code 0]
[Inferior 1 (process 4676) exited normally]
(gdb) quit
<<<--- end standalone gdb session --->>>

In GNU Emacs 24.3.1 (x86_64-unknown-cygwin)
  of 2013-07-05 on desktop-new
Configured using:
  `configure
  '--srcdir=/home/kbrown/src/cygemacs/emacs-24.3-4/src/emacs-24.3'
  '--prefix=/usr' '--exec-prefix=/usr' '--bindir=/usr/bin'
  '--sbindir=/usr/sbin' '--libexecdir=/usr/lib' '--datadir=/usr/share'
  '--localstatedir=/var' '--sysconfdir=/etc' '--datarootdir=/usr/share'
  '--docdir=/usr/share/doc/emacs' '-C' '--with-x=no' 'CC=gcc'
  'CFLAGS=-ggdb -O2 -pipe
  -fdebug-prefix-map=/home/kbrown/src/cygemacs/emacs-24.3-4/build=/usr/src/debug/emacs-24.3-4
  -fdebug-prefix-map=/home/kbrown/src/cygemacs/emacs-24.3-4/src/emacs-24.3=/usr/src/debug/emacs-24.3-4'
  'LDFLAGS=' 'LIBS=' 'CPPFLAGS=''

Important settings:
   value of $LANG: en_US.UTF-8
   locale-coding-system: utf-8-unix
   default enable-multibyte-characters: t

Major mode: Debugger

Minor modes in effect:
   menu-bar-mode: t
   file-name-shadow-mode: t
   global-font-lock-mode: t
   font-lock-mode: t
   auto-composition-mode: t
   auto-encryption-mode: t
   auto-compression-mode: t
   line-number-mode: t
   transient-mark-mode: t

Recent input:
ESC [ > 7 7 ; 1 0 2 0 0 ; 0 c ESC x g d b RET C-g C-x
C-f C-g ESC x g d b RET DEL DEL DEL DEL . t e DEL e
DEL DEL e x DEL C-z DEL DEL DEL b u g RET b SPC b a
r RET s t a r t RET j x o C-x u C-x o C-x 2 C-x o C-x
o s t DEL DEL n RET n RET n RET n RET f i n RET n RET
n RET n RET ESC x r e p o r t - b u g RET

Recent messages:
("emacs")
For information about GNU Emacs and the GNU system, type C-h C-a.
Quit [2 times]
Target doesn't support non-stop mode.  Turning it off.
(New file)
Loading cc-langs...done
Switched to thread 1
Undo!

Load-path shadows:
None found.

Features:
(shadow sort gnus-util mail-extr emacsbug message cl-macs gv format-spec
rfc822 mml mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231
mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums
mm-util mail-prsvr mail-utils cc-langs cl cl-lib cc-mode cc-fonts
easymenu cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars
cc-defs gdb-mi bindat json gud tool-bar easy-mmode comint regexp-opt
ansi-color ring time-date ediff-hook vc-hooks lisp-float-type
tabulated-list newcomment lisp-mode register page menu-bar rfn-eshadow
timer select mouse jit-lock font-lock syntax facemenu font-core frame
cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao
korean japanese hebrew greek romanian slovak czech european ethiopic
indian cyrillic chinese case-table epa-hook jka-cmpr-hook help simple
abbrev minibuffer loaddefs button faces cus-face macroexp files
text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget hashtable-print-readable backquote make-network-process
dbusbind multi-tty emacs)