From: Faheem Mitha <faheem@email.unc.edu>
To: gdb@sources.redhat.com
Subject: setfault calling functions within gdb
Date: Mon, 09 Sep 2002 20:58:00 -0000 [thread overview]
Message-ID: <Pine.LNX.4.44.0209092345270.13388-100000@Chrestomanci> (raw)
Dear People,
I'm having problems calling functions from within gdb. Can someone tell me
what I am doing wrong? Consider the following innocuous program
---------------------------------------------------------
#include<vector>
#include <iostream>
using std::vector;
using std::cout;
typedef vector<double> Point;
void print(Point pt);
int main()
{
Point foo(3,1.0);
//print(foo);
}
void print(Point pt)
{
unsigned int i;
cout << "[";
for(i=0; i < pt.size(); i++)
{
cout << pt[i];
cout << ",";
}
cout << "]";
}
-----------------------------------------------------------
When I set a breakpoint after the definition of foo and call
print(foo) I get a segfault. There appears to be nothing wrong with
this function, since print(foo) when compiled into the function works
as expected. Also, "print foo[0]" works fine. There seem to be two
possibilities; a) I am doing something wrong, b) this is a bug in
gdb. I'm hoping it is the former. I dimly recall calling functions
successfully sometime in the past, but I can't remember whether it was
in C or C++ code.
Any help would be greatly appreciated. This is really frustrating!
Output from gdb follows. I'm using gdb, gcc-3.0 on Debian Sarge. The
respective versions are
ii gdb 5.2.cvs20020401-6 The GNU Debugger
ii g++-3.0 3.0.4-9 The GNU C++ compiler.
I locally compiled the slightly more recent version of gdb from August
which is in unstable, but I get the same behaviour.
Faheem.
(gdb) call print(foo)
[
Program received signal SIGSEGV, Segmentation fault.
0x0804a1a4 in print(std::vector<double, std::allocator<double> >)
(pt=0x804f008) at test.cc:22
The program being debugged was signaled while in a function called
from GDB.
GDB remains in the frame where the signal was received.
To change this behavior use "set unwindonsignal on"
Evaluation of the expression containing the function
(print(std::vector<double, std::allocator<double> >)) will be
abandoned.
(gdb)
next reply other threads:[~2002-09-10 3:58 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-09-09 20:58 Faheem Mitha [this message]
2002-09-09 23:49 ` Jim Blandy
2002-09-10 20:12 ` Faheem Mitha
2002-09-10 6:27 ` Daniel Jacobowitz
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=Pine.LNX.4.44.0209092345270.13388-100000@Chrestomanci \
--to=faheem@email.unc.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