public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Gdb didnot step into the break point in class constructor in RH 8.0
@ 2004-12-17  8:00 kaiduan xie
  2004-12-17 12:05 ` Serge Fukanchik
  0 siblings, 1 reply; 6+ messages in thread
From: kaiduan xie @ 2004-12-17  8:00 UTC (permalink / raw)
  To: gcc-help

Hi, all,

I came across a very weird problem on RH 8.0, gdb
didnot step into the breakpoint set in class
constructor. The program test3.cpp is very very
simple:

      1 #include <stdlib.h>
      2
      3 class TranMessage
      4 {
      5 public:
      6         TranMessage(int age);
      7 private:
      8         int mAge;
      9 };
     10
     11 TranMessage::TranMessage(int age)
     12 {
     13         mAge = age;
     14 }
     15 int main()
     16 {
     17      TranMessage* tran = new TranMessage(200);
     18      return 0;
     19 }

[kaiduanx@localhost test3]$ /usr/bin/g++ --version
g++ (GCC) 3.2 20020903 (Red Hat Linux 8.0 3.2-7)
Copyright (C) 2002 Free Software Foundation, Inc.
This is free software; see the source for copying
conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.

/usr/bin/g++ -o test3 -g test3.cpp
[kaiduanx@localhost test3]$ gdb ./test3
GNU gdb Red Hat Linux (5.2.1-4)
Copyright 2002 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 conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show
warranty" for details.
This GDB was configured as "i386-redhat-linux"...
(gdb) b 17
Breakpoint 1 at 0x8048484: file test3.cpp, line 17.
(gdb) run
Starting program: /home/kaiduanx/test/test3/test3

Breakpoint 1, main () at test3.cpp:17
17              TranMessage* tran = new
TranMessage(200);
(gdb) s
operator new(unsigned) (sz=4)
    at ../../../../libstdc++-v3/libsupc++/new_op.cc:46
46      ../../../../libstdc++-v3/libsupc++/new_op.cc:
No such file or directory.        in
../../../../libstdc++-v3/libsupc++/new_op.cc
(gdb)

what is the problem? 

I also downloaded the latest gcc version 3.4.3 source
code and build it (configure; make; make install; and
installed in /usr/local/bin). The result is a little
different.

[kaiduanx@localhost test3]$ /usr/local/bin/g++ -o
test3 -g test3.cpp
[kaiduanx@localhost test3]$ gdb ./test3
GNU gdb Red Hat Linux (5.2.1-4)
Copyright 2002 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 conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show
warranty" for details.
This GDB was configured as "i386-redhat-linux"...
(gdb) b 17
Breakpoint 1 at 0x80484fd: file test3.cpp, line 17.
(gdb) run
Starting program: /home/kaiduanx/test/test3/test3

Breakpoint 1, main () at test3.cpp:17
17              TranMessage* tran = new
TranMessage(200);
(gdb) s
operator new(unsigned) (sz=4)
    at
../../../../gcc-3.4.3/libstdc++-v3/libsupc++/new_op.cc:46
46        if (sz == 0)

Now it can enter into the new_op.cc, but if I set
breakpoint in the Constructor (line number 13),

(gdb) b 13
Breakpoint 1 at 0x80484c7: file test3.cpp, line 13.
(gdb) run
Starting program: /home/kaiduanx/test/test3/test3

Program exited normally.

GDB did NOT step into the constructor!!!

Can anyone tell me what is wrong? I tested the program
on RH 9.0, gdb can step into the constructor. But due
to other reasons, I donot want to upgrade my system to
RH 9.0.

Thank your patience for reading so long, :)

Best regards,

kaiduan


______________________________________________________________________ 
Post your free ad now! http://personals.yahoo.ca

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

* Re: Gdb didnot step into the break point in class constructor in RH 8.0
  2004-12-17  8:00 Gdb didnot step into the break point in class constructor in RH 8.0 kaiduan xie
@ 2004-12-17 12:05 ` Serge Fukanchik
  2004-12-17 17:26   ` kaiduan xie
  0 siblings, 1 reply; 6+ messages in thread
From: Serge Fukanchik @ 2004-12-17 12:05 UTC (permalink / raw)
  To: kaiduan xie; +Cc: gcc-help

Try to compile with -O0 and -ggdb3 options:
-----
/usr/bin/g++ -o test3 -O0 -ggdb3 test3.cpp
-----
it is possible compiler optimized out your
constructor.
---
Serge


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

* Re: Gdb didnot step into the break point in class constructor in RH 8.0
  2004-12-17 12:05 ` Serge Fukanchik
@ 2004-12-17 17:26   ` kaiduan xie
  2004-12-17 17:31     ` Serge Fukanchik
  0 siblings, 1 reply; 6+ messages in thread
From: kaiduan xie @ 2004-12-17 17:26 UTC (permalink / raw)
  To: Serge Fukanchik; +Cc: gcc-help

Serge,

Many thanks for your help. But with this method, the
gdb still did not step into the constructor. 

kaiduan
 --- Serge Fukanchik <fuxx@mail.ru> wrote: 
> Try to compile with -O0 and -ggdb3 options:
> -----
> /usr/bin/g++ -o test3 -O0 -ggdb3 test3.cpp
> -----
> it is possible compiler optimized out your
> constructor.
> ---
> Serge
> 
> 
>  

______________________________________________________________________ 
Post your free ad now! http://personals.yahoo.ca

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

* Re: Gdb didnot step into the break point in class constructor in RH 8.0
  2004-12-17 17:26   ` kaiduan xie
@ 2004-12-17 17:31     ` Serge Fukanchik
  2004-12-17 17:43       ` kaiduan xie
  0 siblings, 1 reply; 6+ messages in thread
From: Serge Fukanchik @ 2004-12-17 17:31 UTC (permalink / raw)
  To: kaiduan xie; +Cc: gcc-help

Have you tried to explicitly put breakpoint at your constructor
instead of just single-stepping into it?

b 'TranMessage::TranMessage(int age)'

This helps sometimes... :-(

kaiduan xie wrote:

> Many thanks for your help. But with this method, the
> gdb still did not step into the constructor. 
---
Serge


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

* Re: Gdb didnot step into the break point in class constructor in RH 8.0
  2004-12-17 17:31     ` Serge Fukanchik
@ 2004-12-17 17:43       ` kaiduan xie
  0 siblings, 0 replies; 6+ messages in thread
From: kaiduan xie @ 2004-12-17 17:43 UTC (permalink / raw)
  To: Serge Fukanchik; +Cc: gcc-help

Serge,

Nope. Thanks.

kaiduan
 --- Serge Fukanchik <fuxx@mail.ru> wrote: 
> Have you tried to explicitly put breakpoint at your
> constructor
> instead of just single-stepping into it?
> 
> b 'TranMessage::TranMessage(int age)'
> 
> This helps sometimes... :-(
> 
> kaiduan xie wrote:
> 
> > Many thanks for your help. But with this method,
> the
> > gdb still did not step into the constructor. 
> ---
> Serge
> 
> 
>  

______________________________________________________________________ 
Post your free ad now! http://personals.yahoo.ca

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

* RE: Gdb didnot step into the break point in class constructor in RH 8.0
@ 2004-12-17 19:59 Ramadass, Ramanathan
  0 siblings, 0 replies; 6+ messages in thread
From: Ramadass, Ramanathan @ 2004-12-17 19:59 UTC (permalink / raw)
  To: kaiduan xie, Serge Fukanchik; +Cc: gcc-help

I think this is your problem;

According to http://www.gnu.org/software/gdb/download/ANNOUNCEMENT

"When gcc 3.x compiles a C++ constructor or C++ destructor, it generates
2 or 3 different versions of the object code.  These versions have
unique mangled names (they have to, in order for linking to work), but
they have identical source code names, which leads to a great deal of
confusion.  Specifically, if you set a breakpoint in a constructor or a
destructor, gdb will put a breakpoint in one of the versions, but your
program may execute the other version.  This makes it impossible to set
breakpoints reliably in constructors or destructors."

Ram

-----Original Message-----
From: kaiduan xie [mailto:kaiduanx@yahoo.ca]
Sent: Friday, December 17, 2004 9:44 AM
To: Serge Fukanchik
Cc: gcc-help@gcc.gnu.org
Subject: Re: Gdb didnot step into the break point in class constructor
in RH 8.0


Serge,

Nope. Thanks.

kaiduan
 --- Serge Fukanchik <fuxx@mail.ru> wrote: 
> Have you tried to explicitly put breakpoint at your
> constructor
> instead of just single-stepping into it?
> 
> b 'TranMessage::TranMessage(int age)'
> 
> This helps sometimes... :-(
> 
> kaiduan xie wrote:
> 
> > Many thanks for your help. But with this method,
> the
> > gdb still did not step into the constructor. 
> ---
> Serge
> 
> 
>  

______________________________________________________________________ 
Post your free ad now! http://personals.yahoo.ca

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

end of thread, other threads:[~2004-12-17 19:59 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-12-17  8:00 Gdb didnot step into the break point in class constructor in RH 8.0 kaiduan xie
2004-12-17 12:05 ` Serge Fukanchik
2004-12-17 17:26   ` kaiduan xie
2004-12-17 17:31     ` Serge Fukanchik
2004-12-17 17:43       ` kaiduan xie
2004-12-17 19:59 Ramadass, Ramanathan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).