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

From: [email-masked] (Nick Roberts)
Date: Wed, 2 Dec 2009 20:07:05 +1300

> 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

Yes.  I think it will also happen with a more simple program/recipe too.
By default Emacs uses GDB's non-stop mode but I think it has some bugs.
Look at this:

#include <stdio.h>

int main() {
  printf ("Hello World\n");
}

...
This GDB was configured as "x86_64-unknown-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/nickrob/bar...done.
(gdb) set target-async 1
(gdb) set pagination off
(gdb) set non-stop on
(gdb) r
Starting program: /home/nickrob/bar 
Hello World

Program exited with code 014.
(gdb) start
Temporary breakpoint 1 at 0x400514: file bar.c, line 4.
Starting program: /home/nickrob/bar 

Temporary breakpoint 1, main () at bar.c:4
4	  printf ("Hello World\n");
(gdb) n
Hello World
5	}
(gdb) n

Program received signal SIGSEGV, Segmentation fault.
main () at bar.c:5
5	}

-- 
Nick                                           http://users.snap.net.nz/~nickrob