[Rd] C++ debugging help needed
Ross Boylan
ross at biostat.ucsf.edu
Wed Oct 2 22:01:18 CEST 2013
On Wed, Oct 02, 2013 at 11:05:19AM -0400, Duncan Murdoch wrote:
....
>> Up to entry #4 this all looks normal. If I go into that stack frame, I
>> see this:
>>
>>
>> (gdb) up
>> #4 Shape::~Shape (this=0x15f8760, __in_chrg=<optimized out>) at
>> Shape.cpp:13
>> warning: Source file is more recent than executable.
That warning looks suspicious. Are your sure gdb is finding the right
source files, and that the object code has been built from them?
>> 13 blended(in_material.isTransparent())
>> (gdb) p this
>> $9 = (Shape * const) 0x15f8760
>> (gdb) p *this
>> $10 = {_vptr.Shape = 0x7ffff2d8e290, mName = 6, mType = {
>> static npos = <optimized out>,
>> _M_dataplus = {<std::allocator<char>> =
>> {<__gnu_cxx::new_allocator<char>> =
>> {<No data fields>}, <No data fields>},
>> _M_p = 0x7f7fffff7f7fffff <Address 0x7f7fffff7f7fffff out of
>> bounds>}},
>> mShapeColor = {mRed = -1.4044474254567505e+306,
>> mGreen = -1.4044477603031902e+306, mBlue = 4.24399170841135e-314,
>> mTransparent = 0}, mSpecularReflectivity = 0.0078125,
>> mSpecularSize = 1065353216, mDiffuseReflectivity = 0.007812501848093234,
>> mAmbientReflectivity = 0}
>>
>> The things displayed in *this are all wrong. Those field names come
>> from the Shape object in the igraph package, not the Shape object in the
>> rgl package. The mixOmics package uses both.
>>
>> My questions:
>>
>> - Has my code somehow got mixed up with the igraph code, so I really do
>> have a call out to igraph's Shape::~Shape instead of rgl's
>> Shape::~Shape, or is this just bad info being given to me by gdb?
>>
I don't know, but I think it's possible to give fully qualified type
names to gdb to force it to use the right definition. That's assuming
that both Shape's are in different namespaces. If they aren't, that's
likely the problem.
>> - If I really do have calls to the wrong destructor in there, how do I
>> avoid this?
Are you invoking the destructor explicitly? An object should know
it's type, which should result in the right call without much effort.
>>
>> Duncan Murdoch
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
More information about the R-devel
mailing list