Subject: bug#5076: 23.1.50; gdb weird breakpoint problem

From: Michael Welsh Duggan <[email-masked]>
Date: Sun, 29 Nov 2009 23:16:31 -0500

Please describe exactly what actions triggered the bug
and the precise symptoms of the bug.  If you can, give
a recipe starting from `emacs -Q':

Compile the following program using 
gcc -g -o bar bar.c

int main() {
    int a = 4;
    int b = 5;

    int c = a++ * b;
    int d = ++a * b;

    return d;
}

Start gdb on the resulting progam bar.  An example (modify to suit
location):

M-x gdb RET C-a C-k gdb -i=mi bar RET

Use the following gdb session:
start
n
n
n
n
n
n
n
n
start

Here is what the output is for me:

Current directory is /usr/local/home/md5i/
GNU gdb (GDB) 7.0-debian
Copyright (C) 2009 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 "i486-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /usr/local/home/md5i/bar...done.
(gdb) start
Temporary breakpoint 1 at 0x80483a5: file bar.c, line 2.
Starting program: /usr/local/home/md5i/bar 
(gdb) n
(gdb) n
(gdb) n
(gdb) n
(gdb) n
(gdb) n
(gdb) n
(gdb) n
The program is not being run.
(gdb) start
Temporary breakpoint 2 at 0x80483a5: file bar.c, line 2.
Starting program: /usr/local/home/md5i/bar 
Error in re-setting breakpoint 2: Warning:
Cannot insert breakpoint -44.
Error accessing memory address 0xb7ea56c0: Input/output error.

Warning:
Cannot insert breakpoint -44.
Error accessing memory address 0xb7ea56c0: Input/output error.

Here is the gdb-debug-log for this session:

 (send-item "42-break-list"
	    (lambda
	      (&rest args)
	      (with-current-buffer #<buffer *breakpoints of bar*>
				   (apply 'gdb-breakpoints-list-handler args))))
 (send-item "41-stack-info-frame" gdb-frame-handler)
 (recv . "&\"Error in re-setting breakpoint 2: Warning:\\n\"\n&\"Cannot insert breakpoint -44.\\n\"\n&\"Error accessing memory address 0xb7ea56c0: Input/output error.\\n\"\n&\"\\n\"\n&\"Warning:\\n\"\n&\"Cannot insert breakpoint -44.\\n\"\n&\"Error accessing memory address 0xb7ea56c0: Input/output error.\\n\"\n&\"\\n\"\n^error,msg=\"Warning:\\nCannot insert breakpoint -44.\\nError accessing memory address 0xb7ea56c0: Input/output error.\\n\"\n(gdb) \n")
 (send-item "40-thread-info"
	    (lambda
	      (&rest args)
	      (with-current-buffer #<buffer *threads of bar*>
				   (apply 'gdb-thread-list-handler args))))
 (mi-send .
	  #("start\n" 0 5
	    (fontified t)))
 (send-item "39-break-list"
	    (lambda
	      (&rest args)
	      (with-current-buffer #<buffer *breakpoints of bar*>
				   (apply 'gdb-breakpoints-list-handler args))))
 (send-item "38-thread-info"
	    (lambda
	      (&rest args)
	      (with-current-buffer #<buffer *threads of bar*>
				   (apply 'gdb-thread-list-handler args))))
 (send-item "37-stack-info-frame" gdb-frame-handler)
 (recv . "&\"The program is not being run.\\n\"\n^error,msg=\"The program is not being run.\"\n(gdb) \n")
 (mi-send .
	  #("n\n" 0 1
	    (fontified t)))
 (send-item "36-break-list"
	    (lambda
	      (&rest args)
	      (with-current-buffer #<buffer *breakpoints of bar*>
				   (apply 'gdb-breakpoints-list-handler args))))
 (send-item "35-stack-info-frame" gdb-frame-handler)
 (send-item "34-thread-info --thread 1"
	    (lambda
	      (&rest args)
	      (with-current-buffer #<buffer *threads of bar*>
				   (apply 'gdb-thread-list-handler args))))
 (recv . "^running\n*running,thread-id=\"1\"\n(gdb) \n=thread-exited,id=\"1\",group-id=\"22163\"\n=thread-group-exited,id=\"22163\"\n*stopped,reason=\"exited\",exit-code=\"036\"\n")
 (mi-send .
	  #("n\n" 0 1
	    (fontified t)))
 (send-item "33-break-list"
	    (lambda
	      (&rest args)
	      (with-current-buffer #<buffer *breakpoints of bar*>
				   (apply 'gdb-breakpoints-list-handler args))))
 (send-item "32-stack-info-frame --thread 1" gdb-frame-handler)
 (send-item "31-thread-info --thread 1"
	    (lambda
	      (&rest args)
	      (with-current-buffer #<buffer *threads of bar*>
				   (apply 'gdb-thread-list-handler args))))
 (recv . "^running\n*running,thread-id=\"1\"\n(gdb) \n")
 (mi-send .
	  #("n\n" 0 1
	    (fontified t)))
 (send-item "30-break-list"
	    (lambda
	      (&rest args)
	      (with-current-buffer #<buffer *breakpoints of bar*>
				   (apply 'gdb-breakpoints-list-handler args))))
 (send-item "29-stack-info-frame --thread 1" gdb-frame-handler)
 (send-item "28-thread-info --thread 1"
	    (lambda
	      (&rest args)
	      (with-current-buffer #<buffer *threads of bar*>
				   (apply 'gdb-thread-list-handler args))))
 (recv . "^running\n*running,thread-id=\"1\"\n(gdb) \n*stopped,reason=\"end-stepping-range\",frame={addr=\"0x080483d2\",func=\"main\",args=[],file=\"bar.c\",fullname=\"/usr/local/home/md5i/bar.c\",line=\"9\"},thread-id=\"1\",stopped-threads=[\"1\"]\n")
 (mi-send .
	  #("n\n" 0 1
	    (fontified t)))
 (send-item "27-break-list"
	    (lambda
	      (&rest args)
	      (with-current-buffer #<buffer *breakpoints of bar*>
				   (apply 'gdb-breakpoints-list-handler args))))
 (send-item "26-stack-info-frame --thread 1" gdb-frame-handler)
 (send-item "25-thread-info --thread 1"
	    (lambda
	      (&rest args)
	      (with-current-buffer #<buffer *threads of bar*>
				   (apply 'gdb-thread-list-handler args))))
 (recv . "^running\n*running,thread-id=\"1\"\n(gdb) \n*stopped,reason=\"end-stepping-range\",frame={addr=\"0x080483cf\",func=\"main\",args=[],file=\"bar.c\",fullname=\"/usr/local/home/md5i/bar.c\",line=\"8\"},thread-id=\"1\",stopped-threads=[\"1\"]\n")
 (mi-send .
	  #("n\n" 0 1
	    (fontified t)))
 (send-item "24-break-list"
	    (lambda
	      (&rest args)
	      (with-current-buffer #<buffer *breakpoints of bar*>
				   (apply 'gdb-breakpoints-list-handler args))))
 (send-item "23-stack-info-frame --thread 1" gdb-frame-handler)
 (send-item "22-thread-info --thread 1"
	    (lambda
	      (&rest args)
	      (with-current-buffer #<buffer *threads of bar*>
				   (apply 'gdb-thread-list-handler args))))
 (recv . "^running\n*running,thread-id=\"1\"\n(gdb) \n*stopped,reason=\"end-stepping-range\",frame={addr=\"0x080483c1\",func=\"main\",args=[],file=\"bar.c\",fullname=\"/usr/local/home/md5i/bar.c\",line=\"6\"},thread-id=\"1\",stopped-threads=[\"1\"]\n")
 (mi-send .
	  #("n\n" 0 1
	    (fontified t)))
 (send-item "21-break-list"
	    (lambda
	      (&rest args)
	      (with-current-buffer #<buffer *breakpoints of bar*>
				   (apply 'gdb-breakpoints-list-handler args))))
 (send-item "20-stack-info-frame --thread 1" gdb-frame-handler)
 (send-item "19-thread-info --thread 1"
	    (lambda
	      (&rest args)
	      (with-current-buffer #<buffer *threads of bar*>
				   (apply 'gdb-thread-list-handler args))))
 (recv . "^running\n*running,thread-id=\"1\"\n(gdb) \n*stopped,reason=\"end-stepping-range\",frame={addr=\"0x080483b3\",func=\"main\",args=[],file=\"bar.c\",fullname=\"/usr/local/home/md5i/bar.c\",line=\"5\"},thread-id=\"1\",stopped-threads=[\"1\"]\n")
 (mi-send .
	  #("n\n" 0 1
	    (fontified t)))
 (send-item "18-break-list"
	    (lambda
	      (&rest args)
	      (with-current-buffer #<buffer *breakpoints of bar*>
				   (apply 'gdb-breakpoints-list-handler args))))
 (send-item "17-stack-info-frame --thread 1" gdb-frame-handler)
 (send-item "16-thread-info --thread 1"
	    (lambda
	      (&rest args)
	      (with-current-buffer #<buffer *threads of bar*>
				   (apply 'gdb-thread-list-handler args))))
 (recv . "^running\n*running,thread-id=\"1\"\n(gdb) \n*stopped,reason=\"end-stepping-range\",frame={addr=\"0x080483ac\",func=\"main\",args=[],file=\"bar.c\",fullname=\"/usr/local/home/md5i/bar.c\",line=\"3\"},thread-id=\"1\",stopped-threads=[\"1\"]\n")
 (mi-send .
	  #("n\n" 0 1
	    (fontified t)))
 (recv . "12^done,threads=[{id=\"1\",target-id=\"process 22163\",frame={level=\"0\",addr=\"0x080483a5\",func=\"main\",args=[],file=\"bar.c\",fullname=\"/usr/local/home/md5i/bar.c\",line=\"2\"},state=\"stopped\"}],current-thread-id=\"1\"\n(gdb) \n")
 (send-item "15-break-list"
	    (lambda
	      (&rest args)
	      (with-current-buffer #<buffer *breakpoints of bar*>
				   (apply 'gdb-breakpoints-list-handler args))))
 (send-item "14-stack-info-frame --thread 1" gdb-frame-handler)
 (send-item "13-data-list-register-names --thread 1" gdb-register-names-handler)
 (recv . "*stopped,reason=\"breakpoint-hit\",disp=\"del\",bkptno=\"1\",frame={addr=\"0x080483a5\",func=\"main\",args=[],file=\"bar.c\",fullname=\"/usr/local/home/md5i/bar.c\",line=\"2\"},thread-id=\"1\",stopped-threads=[\"1\"]\n")
 (recv . "(gdb) \n=library-loaded,id=\"/lib/i686/cmov/libc.so.6\",target-name=\"/lib/i686/cmov/libc.so.6\",host-name=\"/lib/i686/cmov/libc.so.6\",symbols-loaded=\"0\"\n")
 (recv . "=library-loaded,id=\"/lib/ld-linux.so.2\",target-name=\"/lib/ld-linux.so.2\",host-name=\"/lib/ld-linux.so.2\",symbols-loaded=\"0\"\n")
 (send-item "12-thread-info"
	    (lambda
	      (&rest args)
	      (with-current-buffer #<buffer *threads of bar*>
				   (apply 'gdb-thread-list-handler args))))
 (recv . "~\"Temporary breakpoint 1 at 0x80483a5: file bar.c, line 2.\\n\"\n~\"Starting program: /usr/local/home/md5i/bar \\n\"\n=thread-group-created,id=\"22163\"\n=thread-created,id=\"1\",group-id=\"22163\"\n^running\n*running,thread-id=\"all\"\n")
 (mi-send .
	  #("start\n" 0 5
	    (fontified t)))
 (recv . "10^done\n(gdb) \n11^done\n(gdb) \n")
 (send-item "11-enable-pretty-printing" ignore)
 (send-item "10-gdb-set target-async 1" ignore)
 (recv . "~\"GNU gdb (GDB) 7.0-debian\\n\"\n~\"Copyright (C) 2009 Free Software Foundation, Inc.\\n\"\n~\"License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\\n\"\n~\"This is free software: you are free to change and redistribute it.\\n\"\n~\"There is NO WARRANTY, to the extent permitted by law.  Type \\\"show copying\\\"\\n\"\n~\"and \\\"show warranty\\\" for details.\\n\"\n~\"This GDB was configured as \\\"i486-linux-gnu\\\".\\n\"\n~\"For bug reporting instructions, please see:\\n\"\n~\"<http://www.gnu.org/software/gdb/bugs/>...\\n\"\n~\"Reading symbols from /usr/local/home/md5i/bar...\"\n")
 (send-item "9-break-list"
	    (lambda
	      (&rest args)
	      (with-current-buffer #<buffer *breakpoints of bar*>
				   (apply 'gdb-breakpoints-list-handler args))))
 (send-item "8-thread-info"
	    (lambda
	      (&rest args)
	      (with-current-buffer #<buffer *threads of bar*>
				   (apply 'gdb-thread-list-handler args))))
 (send-item "7-stack-info-frame" gdb-frame-handler)
 (send-item "6-gdb-show prompt" gdb-get-prompt)
 (send-item "5-file-list-exec-source-file" gdb-get-source-file)
 (send-item "4-file-list-exec-source-files" gdb-get-source-file-list)
 (send-item "3-gdb-set non-stop 1" gdb-non-stop-handler)
 (send-item "2-gdb-set height 0" ignore)
 (send-item "1-inferior-tty-set /dev/pts/14" ignore))

In GNU Emacs 23.1.50.1 (i686-pc-linux-gnu, GTK+ Version 2.18.3)
 of 2009-11-27 on maru
Windowing system distributor `The X.Org Foundation', version 11.0.10605000
configured using `configure  '--without-toolkit-scroll-bars''

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: en_US.utf8
  value of $XMODIFIERS: nil
  locale-coding-system: utf-8-unix
  default enable-multibyte-characters: t

Major mode: Summary

Minor modes in effect:
  display-time-mode: t
  diff-auto-refine-mode: t
  shell-dirtrack-mode: t
  tooltip-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  global-auto-composition-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t

Recent input:
C-n C-n C-f C-f C-f C-f C-f C-f C-f C-f C-f C-f C-f 
C-f M-b M-b M-f C-f M-d C-d C-M-f C-k C-k ) C-n M-b 
M-f <M-backspace> g d b - s e l M-/ M-/ C-e C-M-b C-M-f 
C-n C-a C-k C-k C-x C-s <M-return> <return> C-x 1 C-M-x 
M-x g d b <return> / u s <tab> l o c <tab> M-p M-n 
C-e b i <tab> l i l y p o n d <return> b SPC m a i 
n _ w i <tab> C-_ C-x 4 b <return> C-r ( w i t h - 
c u t r <backspace> r r t <backspace> <backspace> <backspace> 
<backspace> r r e t <backspace> C-s C-s C-s C-s C-s 
C-a C-x C-f g u d <tab> <return> C-s C-s C-s C-s C-s 
C-s C-s C-s C-s C-s C-s C-s C-a C-M-x <M-return> <return> 
C-x o C-e <tab> <return> r u n SPC <return> C-c C-n 
C-c C-n C-c C-n C-c C-n C-c C-n C-c C-s C-c C-n <return> 
<help-echo> <switch-frame> f C-c C-y C-x 1 <escape> 
> C-p C-p C-p C-p C-p C-p M-q C-n C-n C-n <return> 
C-p <return> I t SPC d o e s SPC w o r k . SPC SPC 
I SPC w i l l SPC b e SPC s u b m i t t i n g SPC a 
SPC f o l l o w u p SPC m i s f e a t u r e <M-backspace> 
b u g <M-backspace> m i s f e a t u r e SPC a SPC <backspace> 
s SPC a SPC s e p a r a t e SPC b u g . SPC <backspace> 
C-c C-c M-x r e p o r t <tab> <return>

Recent messages:
Command: -exec-next --thread 1 1
Mark set [2 times]
Auto-saving...done
Sending...
Sending via mail...
nnimap: Updating info for nnimap+localimap:archive.mail...done
Sending...done
Starting new Ispell process [default] ...
Checking spelling of DISAPPEARS...
DISAPPEARS is correct

Load-path shadows:
/usr/local/share/emacs/site-lisp/lilypond-words hides /usr/share/emacs/site-lisp/lilypond-words
/usr/local/share/emacs/site-lisp/lilypond-indent hides /usr/share/emacs/site-lisp/lilypond-indent
/usr/local/share/emacs/site-lisp/lilypond-mode hides /usr/share/emacs/site-lisp/lilypond-mode
/home/md5i/src/elisp/psvn hides /usr/share/emacs/site-lisp/psvn
/usr/local/share/emacs/site-lisp/lilypond-song hides /usr/share/emacs/site-lisp/lilypond-song
/usr/local/share/emacs/site-lisp/lilypond-what-beat hides /usr/share/emacs/site-lisp/lilypond-what-beat
/usr/local/share/emacs/site-lisp/lilypond-font-lock hides /usr/share/emacs/site-lisp/lilypond-font-lock
/usr/local/share/emacs/site-lisp/lilypond-init hides /usr/share/emacs/site-lisp/lilypond-init

Features:
(shadow ispell emacsbug newcomment speedbar sb-image ezimage dframe
gdb-mi warnings bindat json gud dabbrev jka-compr find-func grep
lilypond-mode scheme etags vc-git cc-mode cc-fonts cc-menus cc-cmds
cc-styles cc-align cc-engine cc-vars cc-defs multi-isearch mule-util
vc-dispatcher vc-svn gnus-cite ansi-color flow-fill gnus-async
gnus-bcklg parse-time sort byte-opt bytecomp byte-compile gnus-ml
disp-table gnus-topic nnfolder utf-7 utf7 rfc2104 nnimap nndraft nnmh
bbdb-gnus bbdb-snarf mail-extr bbdb-com nnml gnus-agent gnus-srvr
gnus-score score-mode nnvirtual gnus-msg gnus-art mm-uu mml2015 mm-view
smime dig gnus-cache edmacro kmacro gnus-demon nntp nnir gnus-sum
gnus-group gnus-undo nnmail mail-source nnoo gnus-start gnus-spec
gnus-int gnus-range gnus-win gnus gnus-ems server uptimes pp uniquify
descr-text help-mode view tramp-imap epa epg epg-config imap-hash imap
assoc tramp-gw tramp-fish tramp-smb tramp-cache tramp-ftp tramp-cmds
tramp auth-source format-spec tramp-compat trampver time rng-loc rng-uri
rng-parse rng-match rng-dt rng-util rng-pttrn nxml-parse nxml-ns
nxml-enc xmltok nxml-util sgml-mode psvn log-edit pcvs-util add-log
diff-mode easy-mmode inf-caml camldebug thingatpt derived shell
caml-types caml-emacs caml-font caml advice help-fns advice-preload
compile imenu message sendmail ecomplete rfc822 mml easymenu mml-sec
password-cache mm-decode mm-bodies mm-encode mailcap mail-parse rfc2231
rfc2047 rfc2045 qp ietf-drums mailabbrev nnheader gnus-util netrc
time-date mm-util mail-prsvr gmm-utils wid-edit mailheader canlock sha1
hex-util hashcash mail-utils generic-x debian-el debian-el-loaddefs
dired-x dired-aux dired bbdb-autoloads bbdb timezone ange-ftp regexp-opt
comint ring cl cl-19 tooltip ediff-hook vc-hooks lisp-float-type mwheel
x-win x-dnd font-setting tool-bar dnd fontset image fringe lisp-mode
register page menu-bar rfn-eshadow timer select scroll-bar mldrag 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
loaddefs button minibuffer faces cus-face text-properties overlay md5
base64 format env code-pages mule custom widget hashtable-print-readable
backquote make-network-process dbusbind system-font-setting
font-render-setting gtk x-toolkit x multi-tty emacs)

-- 
Michael Welsh Duggan
([email-masked])