Boost logo

Boost Users :

Subject: Re: [Boost-users] newbie: debugging programs with boost
From: Annamalai Gurusami (annamalai.gurusami_at_[hidden])
Date: 2008-09-05 14:46:33


On Thu, Sep 4, 2008 at 11:31 PM, <p_at_[hidden]> wrote:
> Hi all,
>
> I'm having trouble using GDB with my program that uses boost. In GDB (bra
> is a vector<double>):
>
> (gdb) print bra(j)
> Invalid data type for function to be called.
>
> I've compiled my program with -g3. How can I peek at boost datatypes?

I don't think this has got anything to do with boost library. If bra
is a vector<double> then you cannot print it like that. The following
seems to work.

(gdb) print bra
$1 = {<_Vector_base<double,std::allocator<double> >> = {
    _M_impl = {<allocator<double>> = {<new_allocator<double>> = {<No
data fields>}, <No data fields>}, _M_start = 0x631b58, _M_finish =
0x631b80,
      _M_end_of_storage = 0x631b98}}, <No data fields>}
(gdb) print {double}(0x631b58+0*sizeof(double))
$2 = 33.329999999999998
(gdb) print {double}(0x631b58+1*sizeof(double))
$3 = 34.439999999999998
(gdb) print {double}(0x631b58+2*sizeof(double))
$4 = 35.549999999999997
(gdb)

After printing the vector object, I obtain the start address of the
data. Then I access the elements using the offsets. But this
approach seems to be tedious. Is there any better approach? Ideally
speaking, gdb should be able to work with "print bra.at(0)" or "print
bra[0]". But currently that is not working. Maybe newer versions of
gdb will improve C++ support!

$ gdb --version
GNU gdb 6.8.0.20080328-cvs (cygwin-special)
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-pc-cygwin".
$

Rgds,
anna

-- 
Abusive Language on Internet
http://missingrainbow.blogspot.com/2008/08/abusive-language-on-internet.html

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net