Article View: gnu.gdb.bug
Article #1257gdb 6.3 problem
From: JosĂ© MarĂa González
Date: Fri, 18 Mar 2005 06:58
Date: Fri, 18 Mar 2005 06:58
172 lines
5983 bytes
5983 bytes
Hi,
I'm having a problem with gdb. Maybe somebody knows what's going on.
BTW, I'm not in the list, so I'd appreciate direct answers.
Thanks in advance for any help.
-Chema
PS: Comments are prefixed with a hash sign.
> uname -a
FreeBSD myhostname 4.10-RELEASE FreeBSD 4.10-RELEASE #1: Tue Feb 15 18:16:00 PST 2005 root@myhostname:/usr/obj/usr/src/sys/gnu-4.10 i386
> gcc --version
2.95.4
> gdb --version
GNU gdb 6.3
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 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-unknown-freebsd4.10".
# this is the file I'm trying to debug
> cat test.cpp
namespace test_ns1
{
class Test
{
public:
static int i;
};
}
int test_ns1::Test::i = 0;
class A {
public:
int n;
};
int main(int argc, char* argv)
{
test_ns1::Test::i = 1;
A* a = new A;
a->n = 5;
}
> gcc -g -O0 -o test test.cpp
# TEST 1: breaking in main
> gdb ./test
GNU gdb 6.3
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 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-unknown-freebsd4.10"...
(gdb) break main
Breakpoint 1 at 0x80485fe: file test.cpp, line 19.
(gdb) r
Starting program: /tmp/test
Breakpoint 1, main (argc=1, argv=0xbfbfe9b4 " ëżż") at test.cpp:19
19 test_ns1::Test::i = 1;
(gdb) n
20 A* a = new A;
(gdb)
21 a->n = 5;
(gdb) p a
$1 = (A *) 0x8050030
(gdb) q
The program is running. Exit anyway? (y or n) y
# so far, so good.
# TEST 2: breaking in line 17
> gdb ./test
GNU gdb 6.3
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 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-unknown-freebsd4.10"...
(gdb) break 17
Breakpoint 1 at 0x80485f8: file test.cpp, line 17.
(gdb) r
Starting program: /tmp/test
Breakpoint 1, main (argc=1, argv=0xbfbfe9b4 " ëżż") at test.cpp:18
18 {
(gdb) n
main (argc=-1077941836, argv=0x0) at test.cpp:19
19 test_ns1::Test::i = 1;
(gdb)
20 A* a = new A;
(gdb)
0x0804862c in __builtin_new ()
(gdb)
Single stepping until exit from function __builtin_new,
which has no line number information.
main (argc=-1077941836, argv=0x0) at test.cpp:21
21 a->n = 5;
(gdb) p a
$1 = (A *) 0x1
(gdb) n
0x08048628 22 }
(gdb)
0x0804855e in _start ()
(gdb) c
Continuing.
Program exited normally.
(gdb) q
# This makes no sense, definitely. First, it goes into __builtin_new()
# when I'm doing "n". Second, the variable a is returned as "(A *) 0x1",
# which is absurd (the program never crashes)
#
#Any ideas?
#
#Interestingly enough, if I add "-ggdb" to gcc, thinks work fine.
# TEST 3: breaking in line 17
> gcc -g -O0 -ggdb -o test test.cpp
> gdb ./test
GNU gdb 6.3
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 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-unknown-freebsd4.10"...
(gdb) break 17
Breakpoint 1 at 0x80485f8: file test.cpp, line 17.
(gdb) r
Starting program: /tmp/test
Breakpoint 1, main (argc=-1077941472, argv=0x0) at test.cpp:18
18 {
(gdb) n
19 test_ns1::Test::i = 1;
(gdb)
20 A* a = new A;
(gdb)
21 a->n = 5;
(gdb) p a
$1 = (A *) 0x8050030
(gdb) q
The program is running. Exit anyway? (y or n) y
Technical Details
Message-ID:
<mailman.4367.1111212684.32256.bug-gdb@gnu.org>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!newsfeed.stanford.edu!shelby.stanford.edu!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: f5053,2336027b2447a1fd,start X-Google-Attributes: gidf5053,public X-Google-Language: ENGLISH,UTF8 Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!newsfeed.stanford.edu!shelby.stanford.edu!not-for-mail From: JosĂ© MarĂa González <chema@cs.berkeley.edu> Newsgroups: gnu.gdb.bug Subject: gdb 6.3 problem Date: Thu, 17 Mar 2005 22:58:27 -0800 Lines: 176 Approved: bug-gdb@gnu.org Message-ID: <mailman.4367.1111212684.32256.bug-gdb@gnu.org> NNTP-Posting-Host: lists.gnu.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: news.Stanford.EDU 1111211759 23041 199.232.76.165 (19 Mar 2005 05:55:59 GMT) X-Complaints-To: news@news.stanford.edu To: bug-gdb@gnu.org Envelope-to: bug-gdb@gnu.org Content-Disposition: inline User-Agent: Mutt/1.4.2.1i X-MIME-Autoconverted: from 8bit to quoted-printable by apu.bmrc.berkeley.edu id j2I6wRmE034779 X-Mailman-Approved-At: Sat, 19 Mar 2005 01:11:21 -0500 X-BeenThere: bug-gdb@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for GDB, the GNU debugger" <bug-gdb.gnu.org> List-Unsubscribe: <http://lists.gnu.org/mailman/listinfo/bug-gdb>, <mailto:bug-gdb-request@gnu.org?subject=unsubscribe> List-Archive: <http://lists.gnu.org/pipermail/bug-gdb> List-Post: <mailto:bug-gdb@gnu.org> List-Help: <mailto:bug-gdb-request@gnu.org?subject=help> List-Subscribe: <http://lists.gnu.org/mailman/listinfo/bug-gdb>, <mailto:bug-gdb-request@gnu.org?subject=subscribe>