public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
From: "Allen Hopkins" <allenh@eecs.berkeley.edu>
To: gdb@sources.redhat.com
Subject: Can't set bkpt at throw statement
Date: Thu, 12 Aug 2004 01:13:00 -0000	[thread overview]
Message-ID: <411AC515.4080002@eecs.berkeley.edu> (raw)

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



             reply	other threads:[~2004-08-12  1:13 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-08-12  1:13 Allen Hopkins [this message]
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

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=411AC515.4080002@eecs.berkeley.edu \
    --to=allenh@eecs.berkeley.edu \
    --cc=gdb@sources.redhat.com \
    /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).