* Can't set bkpt at throw statement
@ 2004-08-12 1:13 Allen Hopkins
2004-08-12 8:59 ` Ramana Radhakrishnan
2004-08-12 12:16 ` Michael Chastain
0 siblings, 2 replies; 6+ messages in thread
From: Allen Hopkins @ 2004-08-12 1:13 UTC (permalink / raw)
To: gdb
I have two essentially identical C++ classes with essentially identical
methods that both throw the same exception. In gdb, I'm able to set a
breakpoint at the "throw" statement in one class, but not in the other.
Here are the break commands, first on the one that succeeds, then on
the one that fails:
(gdb) break Ethel.cpp:12
Breakpoint 1 at 0x80488b5: file Ethel.cpp, line 12.
(gdb) break Fred.cpp:12
Note: breakpoint -1 (disabled) also set at pc 0x0.
Breakpoint 2 at 0x0: file Fred.cpp, line 12.
(gdb) run
Starting program: /tmp/allenh/metro_dev/examples/stuck/run.x
Warning:
Cannot insert breakpoint 2.
Error accessing memory address 0x0: Input/output error.
Here is a shar of a simple demo of the problem. You can also find these
files at http://www.eecs.berkeley.edu/~allenh/stuck.
Any advice may help save my sanity. Thanks.
-Allen Hopkins
# This is a shell archive. Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file". Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
# DaBomb.h
# demo
# Ethel.cpp
# Ethel.h
# Fred.cpp
# Fred.h
# gdbrc
# main.cpp
# makefile
#
echo x - DaBomb.h
sed 's/^X//' >DaBomb.h << 'END-of-DaBomb.h'
X#ifndef DABOMB_H
X#define DABOMB_H
X
Xclass DaBomb {};
X
X#endif
END-of-DaBomb.h
echo x - demo
sed 's/^X//' >demo << 'END-of-demo'
X#!/bin/sh
X
Xmake
Xrun.x
Xgdb -x gdbrc run.x
X
END-of-demo
echo x - Ethel.cpp
sed 's/^X//' >Ethel.cpp << 'END-of-Ethel.cpp'
X#include "Ethel.h"
X#include "DaBomb.h"
X#include <iostream.h>
X
XEthel::Ethel(int i) {
X trigger = i;
X};
X
Xvoid Ethel::myFunc(int i)
X{
X if (i == trigger) {
X throw DaBomb();
X } else {
X cout << "Ethel says " << i << endl;
X }
X};
END-of-Ethel.cpp
echo x - Ethel.h
sed 's/^X//' >Ethel.h << 'END-of-Ethel.h'
X#ifndef ETHEL_H
X#define ETHEL_H
X
Xclass Ethel;
X
Xclass Ethel {
X public:
X int trigger;
X Ethel(int i);
X void myFunc(int i);
X};
X
X#endif
END-of-Ethel.h
echo x - Fred.cpp
sed 's/^X//' >Fred.cpp << 'END-of-Fred.cpp'
X#include "Fred.h"
X#include "DaBomb.h"
X#include <iostream.h>
X
XFred::Fred(int i) {
X trigger = i;
X};
X
Xvoid Fred::myFunc(int i)
X{
X if (i == trigger) {
X throw DaBomb();
X } else {
X cout << "Fred says " << i << endl;
X }
X};
END-of-Fred.cpp
echo x - Fred.h
sed 's/^X//' >Fred.h << 'END-of-Fred.h'
X#ifndef FRED_H
X#define FRED_H
X
Xclass Fred;
X
Xclass Fred {
X public:
X int trigger;
X Fred(int i);
X void myFunc(int i);
X};
X
X#endif
END-of-Fred.h
echo x - gdbrc
sed 's/^X//' >gdbrc << 'END-of-gdbrc'
Xbreak Fred.cpp:12
Xbreak Ethel.cpp:12
Xrun
END-of-gdbrc
echo x - main.cpp
sed 's/^X//' >main.cpp << 'END-of-main.cpp'
X#include "Fred.h"
X#include "Ethel.h"
X#include "DaBomb.h"
X#include <iostream.h>
X
Xint main(int argc, char* argv[])
X{
X Fred* fred = new Fred(3);
X Ethel* ethel = new Ethel(7);
X
X for (int i = 0; i < 10; i++) {
X
X try {
X fred->myFunc(i);
X } catch (DaBomb) {
X cout << "FRED threw DaBomb." << endl;
X }
X
X try {
X ethel->myFunc(i);
X } catch (DaBomb) {
X cout << "ETHEL threw DaBomb." << endl;
X }
X }
X}
END-of-main.cpp
echo x - makefile
sed 's/^X//' >makefile << 'END-of-makefile'
XOPTS = -ggdb -Wno-deprecated
X
Xall: Ethel.o Fred.o main.o
X g++ $(OPTS) -o run.x \
X Ethel.o Fred.o main.o
X
XEthel.o: Ethel.cpp Ethel.h
X g++ $(OPTS) -c Ethel.cpp
X
XFred.o: Fred.cpp Fred.h
X g++ $(OPTS) -c Fred.cpp
X
Xmain.o: ./main.cpp
X g++ $(OPTS) -c ./main.cpp
X
Xclean:
X rm -f *.o run.x
END-of-makefile
exit
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Can't set bkpt at throw statement
2004-08-12 1:13 Can't set bkpt at throw statement Allen Hopkins
@ 2004-08-12 8:59 ` Ramana Radhakrishnan
2004-08-12 12:16 ` Michael Chastain
1 sibling, 0 replies; 6+ messages in thread
From: Ramana Radhakrishnan @ 2004-08-12 8:59 UTC (permalink / raw)
To: Allen Hopkins; +Cc: gdb
Hey Allen ,
> I have two essentially identical C++ classes with essentially identical
> methods that both throw the same exception. In gdb, I'm able to set a
> breakpoint at the "throw" statement in one class, but not in the other.
> Here are the break commands, first on the one that succeeds, then on
> the one that fails:
What are the versions of g++, binutils and gdb that you are using. I
tried your case on a 686 with g++ -3.3.4 debian , gdb - 6.1 and binutils
2.14.90 and had no problems with inserting breakpoint #2 . If you could
tell the versions of the tools, maybe someone can help you and also
check if this is a problem with gdb.
regards
Ramana
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Can't set bkpt at throw statement
2004-08-12 1:13 Can't set bkpt at throw statement Allen Hopkins
2004-08-12 8:59 ` Ramana Radhakrishnan
@ 2004-08-12 12:16 ` Michael Chastain
2004-08-12 15:31 ` Allen Hopkins
1 sibling, 1 reply; 6+ messages in thread
From: Michael Chastain @ 2004-08-12 12:16 UTC (permalink / raw)
To: gdb, allenh
Your program works fine for me on:
native i686-pc-linux-gnu
red hat 8.0
gcc 3.3.4
binutils 2.15
gdb 6.2
I also tested with gcc 3.4.1 and gcc 3.5.0 20040811 (experimental).
All worked fine.
However I see the bad breakpoint on Fred.cpp:12 with
native i686-pc-linux-gnu
red hat 8.0
gcc 3.2-7-rh
binutils 2.13.90.0.2-2-rh
gdb 6.2
(gdb) break Ethel.cpp:12
Breakpoint 1 at 0x80488b5: file Ethel.cpp, line 12.
(gdb) break Fred.cpp:12
Note: breakpoint -1 (disabled) also set at pc 0x0.
Breakpoint 2 at 0x0: file Fred.cpp, line 12.
Can you report:
output of "gdb --version"
output of "gcc -v"
(or if the C++ compiler is not gcc, the equivalent)
your os name and version number
I think you will have to install a newer gcc.
It's not hard, if you use the "--prefix" option to build gcc.
Michael C
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Can't set bkpt at throw statement
2004-08-12 12:16 ` Michael Chastain
@ 2004-08-12 15:31 ` Allen Hopkins
2004-08-12 15:41 ` Michael Chastain
0 siblings, 1 reply; 6+ messages in thread
From: Allen Hopkins @ 2004-08-12 15:31 UTC (permalink / raw)
To: Michael Chastain; +Cc: gdb
Thanks. I'll try updating gcc. Here are the versions of gdb, gcc, o/s:
fortytwo[1001]$ gdb --version
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".
fortytwo[1002]$ gcc -v
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.2/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--disable-checking --host=i386-redhat-linux --with-system-zlib
--enable-__cxa_atexit
Thread model: posix
gcc version 3.2 20020903 (Red Hat Linux 8.0 3.2-7)
fortytwo[1004]$ 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
-Allen
Michael Chastain wrote:
> Your program works fine for me on:
>
> native i686-pc-linux-gnu
> red hat 8.0
> gcc 3.3.4
> binutils 2.15
> gdb 6.2
>
> I also tested with gcc 3.4.1 and gcc 3.5.0 20040811 (experimental).
> All worked fine.
>
> However I see the bad breakpoint on Fred.cpp:12 with
>
> native i686-pc-linux-gnu
> red hat 8.0
> gcc 3.2-7-rh
> binutils 2.13.90.0.2-2-rh
> gdb 6.2
>
> (gdb) break Ethel.cpp:12
> Breakpoint 1 at 0x80488b5: file Ethel.cpp, line 12.
> (gdb) break Fred.cpp:12
> Note: breakpoint -1 (disabled) also set at pc 0x0.
> Breakpoint 2 at 0x0: file Fred.cpp, line 12.
>
> Can you report:
>
> output of "gdb --version"
> output of "gcc -v"
> (or if the C++ compiler is not gcc, the equivalent)
> your os name and version number
>
> I think you will have to install a newer gcc.
> It's not hard, if you use the "--prefix" option to build gcc.
>
> Michael C
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Can't set bkpt at throw statement
2004-08-12 15:31 ` Allen Hopkins
@ 2004-08-12 15:41 ` Michael Chastain
2004-08-12 15:48 ` Allen Hopkins
0 siblings, 1 reply; 6+ messages in thread
From: Michael Chastain @ 2004-08-12 15:41 UTC (permalink / raw)
To: allenh; +Cc: gdb
Ah, we both have red hat linux 8.
Upgrading gdb didn't help: gcc 3.2-7 + gdb 6.2, bug appears.
Upgrading gcc did help: gcc 3.3.4 + gdb 6.0, no bug.
Even gcc 3.3.4 + gdb 5.2.1-4, the gdb that shipped with rhl8, works.
Unfortunately there's still a lot of gcc 3.2 in the world.
It looks like people with gcc 3.2 using c++ would be wise to upgrade.
Michael C
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Can't set bkpt at throw statement
2004-08-12 15:41 ` Michael Chastain
@ 2004-08-12 15:48 ` Allen Hopkins
0 siblings, 0 replies; 6+ messages in thread
From: Allen Hopkins @ 2004-08-12 15:48 UTC (permalink / raw)
To: Michael Chastain; +Cc: gdb
I just tried it on a Sun Sparc maching running SunOS 5.8, gdb 6.0
and gcc 3.2.2. No bug.
-Allen
Michael Chastain wrote:
> Ah, we both have red hat linux 8.
>
> Upgrading gdb didn't help: gcc 3.2-7 + gdb 6.2, bug appears.
> Upgrading gcc did help: gcc 3.3.4 + gdb 6.0, no bug.
> Even gcc 3.3.4 + gdb 5.2.1-4, the gdb that shipped with rhl8, works.
>
> Unfortunately there's still a lot of gcc 3.2 in the world.
> It looks like people with gcc 3.2 using c++ would be wise to upgrade.
>
> Michael C
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2004-08-12 15:48 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-08-12 1:13 Can't set bkpt at throw statement Allen Hopkins
2004-08-12 8:59 ` Ramana Radhakrishnan
2004-08-12 12:16 ` Michael Chastain
2004-08-12 15:31 ` Allen Hopkins
2004-08-12 15:41 ` Michael Chastain
2004-08-12 15:48 ` Allen Hopkins
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).