Re: *****SPAM***** casting in gdb

Jacques Le Normand
2002-12-13T19:43:25Z

here you go, thanks for lending a hand...

[countchocula@chocoland countchocula]$ g++ -ggdb test.cpp -o test.o
[countchocula@chocoland countchocula]$ gdb test.o
GNU gdb Red Hat Linux (5.2.1-4)
Copyright 2002 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 "i386-redhat-linux"...
(gdb) b 10
Breakpoint 1 at 0x80486f5: file test.cpp, line 10.
(gdb) r
Starting program: /home/countchocula/test.o

Breakpoint 1, main () at test.cpp:10
10 a.push_back(2);
(gdb) p a[0]
One of the arguments you tried to pass to operator[] could not be converted
to w
hat the function wants.
(gdb)

the code
#include <vector>
using namespace std;
int main(){
vector<int> a;
a.push_back(2);
a.push_back(2);
a.push_back(2);
a.push_back(2);
a.push_back(2);
a.push_back(2);
a.push_back(2);
a.push_back(2);
a.push_back(2);
a.push_back(2);
a.push_back(2);
a.push_back(2);
a.push_back(2);
a.push_back(2);
a.push_back(2);
a.push_back(2);
a.push_back(2);
return 0;
}

----- Original Message -----
From: "Daniel Jacobowitz" <drow@mvista.com>
To: "Daniel Berlin" <dberlin@dberlin.org>
Cc: "Jacques Le Normand" <jacqueslen@sympatico.ca>; <gdb@sources.redhat.com>
Sent: Friday, December 13, 2002 11:47 AM
Subject: Re: *****SPAM***** casting in gdb

> On Fri, Dec 13, 2002 at 10:33:02AM -0500, Daniel Berlin wrote:
> >
> > On Friday, December 13, 2002, at 01:28 AM, Jacques Le Normand wrote:
> >
> > >how do you get gdb to cast to size_t?
> > >I realize that size_t is a typedef to unsigned long long or somesuch.
> > >A little background:
> > >when I'm debugging my vector<int> v, gdb won't let me type v[0],
> > >instead =
> > >it says this: "One of the arguments you tried to pass to operator[] =
> > >could not be converted to what the funtion wants."
> > >I then looked up what operator[] took in the sgi docs and it said a =
> > >size_t. Anyone have any ideas?
> > >(I realize I can do p *(v._M_start+n) , but having a method for
> > >casting =
> > >would help me later on)
> > >--Jacques
> > >
> > While this doesn't help *you*, it should help the current C++ people
> > for GDB:
> > I've seen this with STABS debugging info when some of the operator
> > functions were left out of the debugging info, but others weren't (GCC
> > + STABS will omit unused functions from debug info), and we ommitted
> > the operator we really need to use, and in some cases when we parsed
> > the types of the arguments out of the demangled function name and come
> > up with some weird type.
>
> Yeah, something like that's my guess; I've been getting this better but
> it's taking time...
>
> Jacques, could you do me a favor? Try to create a small test case for
> the error message using vector.
>
> The problem is almost certainly that the argument 'this' to the
> operator is of the wrong type, not that the integer is of the wrong
> type.
>
> --
> Daniel Jacobowitz
> MontaVista Software Debian GNU/Linux Developer