public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: kewarken@qnx.com
To: gcc-gnats@gcc.gnu.org
Subject: debug/4913: "gcc -gstabs" behaves differently than "gcc -g" for c++
Date: Thu, 15 Nov 2001 12:40:00 -0000	[thread overview]
Message-ID: <20011120162622.9674.qmail@sourceware.cygnus.com> (raw)


>Number:         4913
>Category:       debug
>Synopsis:       "gcc -gstabs" behaves differently than "gcc -g" for c++
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Nov 20 08:35:59 PST 2001
>Closed-Date:
>Last-Modified:
>Originator:     Kris Warkentin
>Release:        gcc-2.95.4
>Organization:
>Environment:
Debian Gnu/Linux testing
Linux stimpy 2.2.17 #1 Sun Jun 25 09:24:41 EST 2000 i686 unknown
>Description:
Here is a script that shows the problem.  Basically examining a class which inherits from a parent class looks different depending on how it was compiled.  Since gcc uses stabs by default (on a linux box anyway), then gcc -g should give the same results as gcc -gstabs.  This test case shows that it does not.

Script started on Tue Nov 20 11:10:59 2001
marcind@stimpy:~$ cat testit.cc
#include <stdio.h>


class A {

public:
        int a;
        int b;
        int c;
    virtual void foo(int arg) = 0;

private:
        int d;
        int e;
};

class B : public A {

public:
        void foo(int arg);

};

void B::foo(int arg)
{
        a = arg;
        b = arg;
        c = arg;
}


void main( )
{
        B* pA = new(B);

        pA->foo(55);

        pA->a = 1;
	pA->b = 2;
        pA->c = 3;

}
marcind@stimpy:~$ g++ -g -o testit testit.cc
marcind@stimpy:~$ gdb testit
GNU gdb 5.0.90-cvs (MI_OUT)
Copyright 2001 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-linux"...
(gdb) b main
Breakpoint 1 at 0x804873c: file testit.cc, line 34.
(gdb) r
Starting program: /home/marcind/testit

Breakpoint 1, main () at testit.cc:34
34              B* pA = new(B);
(gdb) n
36              pA->foo(55);
(gdb) print *pA
$1 = {<A> = {a = 0, b = 0, c = 0, d = 0, e = 0, _vptr. = 0x804997c}, <No data fields>}
(gdb) print pA->a
$2 = 0
(gdb) info source
Current source file is testit.cc
Compilation directory is /home/marcind/
Located in /home/marcind/testit.cc
Contains 42 lines.
Source language is c++.
Compiled with stabs debugging format.
(gdb) The program is running.  Exit anyway? (y or n) y
marcind@stimpy:~$ gcc -gstabs -o testit testit.cc
marcind@stimpy:~$ gdb testit
GNU gdb 5.0.90-cvs (MI_OUT)
Copyright 2001 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-linux"...
(gdb) b main
Breakpoint 1 at 0x804936c: file testit.cc, line 34.
(gdb) r
Starting program: /home/marcind/testit 

Breakpoint 1, main () at testit.cc:34
34              B* pA = new(B);
(gdb) n
36              pA->foo(55);
(gdb) print pA
$1 = (B *) 0x8050470
(gdb) print *pA
$2 = {A = {a = 0, b = 0, c = 0, d = 0, e = 0, _vptr.A = 0x804e3c8}}
(gdb) print pA->a
There is no member named a.
(gdb) print pA->A->a
$3 = 0
(gdb) info source
Current source file is testit.cc
Located in /home/marcind/testit.cc
Contains 42 lines.
Source language is c++.
Compiled with stabs debugging format.
(gdb) The program is running.  Exit anyway? (y or n) y
marcind@stimpy:~$ exit

Script done on Tue Nov 20 11:13:39 2001
>How-To-Repeat:
see above
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: unknown; name="testit.cc"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="testit.cc"

I2luY2x1ZGUgPHN0ZGlvLmg+CgoKY2xhc3MgQSB7CgpwdWJsaWM6CglpbnQgYTsKCWludCBiOwoJ
aW50IGM7CiAgICB2aXJ0dWFsIHZvaWQgZm9vKGludCBhcmcpID0gMDsKCnByaXZhdGU6CglpbnQg
ZDsKCWludCBlOwp9OwoKY2xhc3MgQiA6IHB1YmxpYyBBIHsKCnB1YmxpYzoKCXZvaWQgZm9vKGlu
dCBhcmcpOwoKfTsKCnZvaWQgQjo6Zm9vKGludCBhcmcpCnsKCWEgPSBhcmc7CgliID0gYXJnOwoJ
YyA9IGFyZzsKfQoKCnZvaWQgbWFpbiggKQp7CglCKiBwQSA9IG5ldyhCKTsKCglwQS0+Zm9vKDU1
KTsKCglwQS0+YSA9IDE7CglwQS0+YiA9IDI7CglwQS0+YyA9IDM7Cgp9Cg==


             reply	other threads:[~2001-11-20 16:36 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-11-15 12:40 kewarken [this message]
2001-11-21 23:15 dje
2001-11-21 23:15 dje

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20011120162622.9674.qmail@sourceware.cygnus.com \
    --to=kewarken@qnx.com \
    --cc=gcc-gnats@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).