help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Why gdb inside emacs cannot print out c++ object?


From: Kevin Gao
Subject: Re: Why gdb inside emacs cannot print out c++ object?
Date: Sat, 16 Mar 2019 17:48:36 -0700

Thanks, the original problem has gone away.

About the link you shared:

etc this code.

*#include <map>*
*#include <string>*
*int main() {*
*    std::map<std::string, std::string> m = {{"aaa", "bbb"}};*
*    auto p = m.begin();*
*    return 0;*
*}*

gdb in emacs can print the value which "p" points. gdb prints out "*$1 =
{first = "aaa", second = "bbb"}*"

Emacs speedbar can show the value correctly. Speedbar shows "*p {first =
"aaa", second = "bbb"}*'

The issue is: gud -> locals window cannot show the value correctly. It shows
*std::_Rb_tree_iterator<std::pair<std::__cxx11::basic_string<char,
std::char_traits<char>, std::allocator<char> > const,
std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char> > > >   p <complex data type>*

Do you know if it is possible for locals window to show correct value which
p points to? locals windows is more handy than gdb command and emacs
speedbar.

Thanks,
Kevin


On Sat, Mar 16, 2019 at 1:17 AM Eli Zaretskii <address@hidden> wrote:

> > From: Kevin Gao <address@hidden>
> > Date: Fri, 15 Mar 2019 16:46:30 -0700
> > Cc: address@hidden
> >
> > Seems sth wrong with my machine. Sorry for the false report.
>
> So the problem went away somehow?
>
> > May I ask a related question? In the local windows, instead of showing
> the value, it shows "<complex data
> > type>". Is it possible to show the value of c++ object? (eg a std::map's
> value)
>
> I think in these cases you need to provide your own pretty-printer.
> See the node "Pretty Printing" in the GDB manual.  Looks like the GCC
> folks already wrote such pretty-printers, see this stackoverflow
> discussion:
>
>
> https://stackoverflow.com/questions/11606048/how-to-pretty-print-stl-containers-in-gdb
>
>


reply via email to

[Prev in Thread] Current Thread [Next in Thread]