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     [EMAIL PROTECTED]:/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




_______________________________________________
Bug-gdb mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/bug-gdb

Reply via email to