c++ - How to use Gdb debugger to find value of ZZ object from Number Theory Library? -
i use gdb debugger print values of variable of type zz. data type defined in number theory library or ntl. when use "print x" find out variable's value obtain this:
print x $1 = {rep=0xab2cc54}. i guess address of zz object. how can print value ? should mention don't know internal representation of class.
can use ntl compiler eclipse debug easier application ?
… zz object. how can print value ?
this bit ugly, works:
(gdb) call ntl::operator<<(std::ostream&, ntl::zz const&)(cerr, x) 42$1 = (std::ostream &) @0x620020: <incomplete type> (in example, variable x has value 42).
if don't want garbage after value, can cast void:
(gdb) call (void)ntl::operator<<(std::ostream&, ntl::zz const&)(cerr, x) 42(gdb) (but note there's no newline after value).
if you're not using namespace std, may have write
(gdb) call ntl::operator<<(std::ostream&, ntl::zz const&)('std::cerr', x) sometimes cerr may not in scope:
(gdb) call ntl::operator<<(std::ostream&, ntl::zz const&)(cerr, x) no symbol "cerr" in current context. - can try cout, gets uglier, because buffered output has flushed:
(gdb) call ntl::operator<<(std::ostream&, ntl::zz const&)(cout, x) (gdb) call 'std::basic_ostream<char, std::char_traits<char>>& std::operator<< <std::char_traits<char>>(std::basic_ostream<char, std::char_traits<char>>&, char const*)'(&cout, "\n") 42
Comments
Post a Comment