This is the mail archive of the
gdb@sources.redhat.com
mailing list for the GDB project.
Redefining n on Solaris
- From: "Allen Hopkins" <allenh at eecs dot berkeley dot edu>
- To: gdb <gdb at sources dot redhat dot com>
- Date: Wed, 18 Aug 2004 12:13:01 -0700
- Subject: Redefining n on Solaris
I'm trying to redefine "next" (to create a debugger for code
from which
C++ code is generated), and I find that I also have to
redefine "n",
to be able to use it as a shortcut for "next" (or else I get
a segmentation
fault when I type "n").
That's fine, and it works OK w/ gdb 6.0 on an Intel/Linux
system, but
not on a Sun/Solaris 2.8 system.
Here's a successful example on the Linux system:
------
linux% uname -a
Linux fortytwo.eecs.berkeley.edu 2.4.20-28.8smp #1 SMP Thu
Dec 18 12:25:21 EST 2003 i686 i686 i386 GNU/Linux
linux% cat foo.ini
define next
printf "Boo!\n"
end
define n
next
end
break main
linux% gdb -x foo.ini s
GNU gdb 6.0
Copyright 2003 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 "i586-suse-linux"...
Breakpoint 1 at 0x8048354: file s.cpp, line 4.
(gdb) run
Starting program:
/users/allenh/projects/metropolis/testing/foodir/s
Breakpoint 1, main (argc=1, argv=0xbfffe6c4) at s.cpp:4
4 int i = 0;
(gdb) n
Boo!
------
Now here's the same thing on the Sun:
sun% uname -a
SunOS markov.eecs.berkeley.edu 5.8 Generic_117350-02 sun4u
sparc SUNW,Ultra-60
sun% cat foo.ini
define next
printf "Boo!\n"
end
define n
next
end
break main
sun% gdb -x foo.ini s
GNU gdb 6.0
Copyright 2003 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 "sparc-sun-solaris2.8"...
Segmentation Fault
sun% gdb -x foo.ini
GNU gdb 6.0
Copyright 2003 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 "sparc-sun-solaris2.8".
Segmentation Fault
sun%
------
I did the second gdb on the Sun, without the executable
argument, to show
that it has nothing to do with the executable being
debugged, which is this:
main(int argc, char* argv[]) {
int i = 0;
return(i);
}
Interestingly, it works OK on the Sun if I enter the
commands from the
initialization file by hand:
------
sun% gdb s
GNU gdb 6.0
Copyright 2003 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 "sparc-sun-solaris2.8"...
(gdb) define next
Really redefine built-in command "next"? (y or n) y
Type commands for definition of "next".
End with a line saying just "end".
>printf "Boo!\n"
>end
(gdb) define n
Type commands for definition of "n".
End with a line saying just "end".
>next
>end
(gdb) break main
Breakpoint 1 at 0x106c8: file s.cpp, line 4.
(gdb) run
Starting program:
/export/home/allenh/projects/metropolis/testing/foodir/s
Breakpoint 1, main (argc=1, argv=0xffbeecac) at s.cpp:4
4 int i = 0;
(gdb) n
Boo!
(gdb)
------
Any help? Thanks.
-Allen