c++ - How to drill down into shared_ptr [Netbeans, clang++, gdb] -
i'm using
- netbeans c++ 8.0.2
- clang++ (ubuntu clang version 3.6.0-2ubuntu1 (tags/release_360/final) (based on llvm 3.6.0))
- gdb (gnu gdb (ubuntu 7.9-1ubuntu1) 7.9)
in "c++ simple tests," whenever inspect variable shared_ptr, see value is:
std::shared_ptr (count 1, weak 0) 0x64d3a0
or similar. there no way drill down value of it's pointing to. if tree view in variables window shows 1 of expander icons, disappears when click it. when try dereferencing or calling get()
function in "expressions" window, error messages:
could not find operator*.
and
cannot evaluate function -- may inlined
respectively.
if create reference value in actual program, not allows me drill down reference, shared_ptr can drilled down (which seems fishy me). tried -g3
, -ggdb
made no difference.
is there debug version of standard library (is libcxx default?), or setting somewhere might improve situation? or maybe way list private members/raw view in variables window, dereference underlying pointer myself?
one flaw of gdb pretty-printing code printing, , can't used dig deeper. flaw affects "varobj" feature, guis use when communicating gdb value display.
there possibilities can make better.
first, bit of background. reason can't call operator*
or get
gcc not emit out-of-line copy of function has been inlined. space-saving optimization. (you can request happen uncommonly done.)
so, 1 approach fixing new-ish gdb xmethod
code. can write python code in gdb let implement things get
, gdb expressions work expected, though compiler isn't cooperating. handy! , libstdc++ ships of these, though don't know specifically; have go digging.
there 2 low-tech approaches use.
mentioned in comments -- copy-and-paste pointer value, cast proper type. works reliably, though note pain. gdb should have "varobj" support idiom ides can right thing without jumping through hoops. believe there's gdb bug open this.
bypass pretty-printers , dig object representation directly. can unpleasant -- in libstdc++ in particular object representations non-obvious -- smart pointer shouldn't bad. recipe
print/r
, , examine see. ides can , should provide way bypass pretty-printing well, "varobj" api exposes capability. don't know whether netbeans does.
Comments
Post a Comment