c++/1942: can not set breakpoint in constructor

gnatsweb@spamit.net gnatsweb@spamit.net
Wed May 11 23:08:00 GMT 2005

>Number:         1942
>Category:       c++
>Synopsis:       can not set breakpoint in constructor
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Wed May 11 23:08:01 UTC 2005
>Originator:     Eric Nadler
>Release:        GNU gdb
Red Hat Linux AS 4
Sorry, I wasn't able to add on to the older related tickets for this bug, numbers 1091 and 1193.  To address the question in those tickets, I do still find that this fails.

I've used different flavors of g++ and gdb on different Linux and Solaris platforms.  The most recent code was using Red Hat AS 4:

g++ (GCC) 3.4.3 20041212 (Red Hat 3.4.3-9.EL4)
GNU gdb

Here is my program:

#include <iostream>
#include <string>
using namespace std;

struct X {
   X(const string&, int);

X::X(const string& message, int value) {
   cout << message;

int main() {
   X h("Hello", 1);
   X w(" World", 2);
   cout << endl;

And my attempt at setting a breakpoint and running the program.  It 
seems also
that recent builds of gdb set breakpoints that die when trying to use 
Previous versions wouldn't break, but wouldn't die either.

/home/enadler/test/compilerbugs/linux $
/development/enadler/nobackup/apps/gdb- a.out
GNU gdb
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and 
you are
welcome to change it and/or distribute copies of it under certain 
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for 
This GDB was configured as "i686-pc-linux-gnu"...Using host 
library "/lib/tls/libthread_db.so.1".

(gdb) b X::X
[0] cancel
[1] all
> 1
Note: breakpoint -1 (disabled) also set at pc 0x0.
Breakpoint 1 at 0x0
Note: breakpoints -1 (disabled) and 1 also set at pc 0x0.
Breakpoint 2 at 0x0
warning: Multiple breakpoints were set.
Use the "delete" command to delete unwanted breakpoints.
(gdb) b /home/enadler/test/compilerbugs/linux/noGDBConstructor.cc:9
Breakpoint 3 at 0x8048930: file noGDBConstructor.cc, line 9.
(gdb) b /home/enadler/test/compilerbugs/linux/noGDBConstructor.cc:10
Breakpoint 4 at 0x8048936: file noGDBConstructor.cc, line 10.
(gdb) b /home/enadler/test/compilerbugs/linux/noGDBConstructor.cc:16
Breakpoint 5 at 0x8048abb: file noGDBConstructor.cc, line 16.
(gdb) run
Starting program: /home/enadler/test/compilerbugs/linux/a.out 
Cannot insert breakpoint 1.
Error accessing memory address 0x0: Input/output error.

(gdb) del 1
(gdb) del 2
(gdb) run
The program being debugged has been started already.
Start it from the beginning? (y or n) y

Starting program: /home/enadler/test/compilerbugs/linux/a.out 

Breakpoint 5, main () at noGDBConstructor.cc:16
16	   cout << endl;
(gdb) c
Hello World

Program exited normally.
(gdb) quit



More information about the Gdb-prs mailing list