[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: gdb and iterators
From: |
llewelly |
Subject: |
Re: gdb and iterators |
Date: |
Mon, 10 May 2004 15:02:23 -0600 |
User-agent: |
Gnus/5.1002 (Gnus v5.10.2) Emacs/21.3.50 (berkeley-unix) |
glen_stark <stark@ifh.ee.ethz.ch> writes:
> Hi.
>
> I hope I'm posting in the correct forum. I'm debugging some code
> using iterators, and having trouble getting info on where the iterator
> is pointing to, and what.
>
> i get:
>
> 1: spli = (t_shapePtrListIter &) @0x226b00: {<_List_iterator_base> = {
> _M_node = 0xa042980}, <No data fields>}
>
> When I type "print spli"
>
> and
> Attempt to take contents of a non-pointer value.
>
> for "print *spli". spli should be an list iterator pointing to
> pointer to a Shape (my own class). Can someone tell me what's going
> on? is there a trick to getting iterator info?
I'm using gdb 6.1 and g++ 3.3.3 . for me, print *i where i is
list<int>::iterator reports something like:
(gdb) print *i
$1 = (int &) @0x804b018: 1
which is nice, but print *l.begin() dies horribly:
(gdb) print *l.begin()
Program received signal SIGBUS, Bus error.
0x08048b42 in std::list<int, std::allocator<int> >::begin
(this=0x281099ee) at /usr/include/c++/3.3/bits/stl_list.h:569
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 (std::list<int,
std::allocator<int> >::begin()) will be abandoned.
Personally, I almost never use gdb for debugging C++ code;
cerr << "my message" ; seems less painful.