all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Kevin Gao <kkegao@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: help-gnu-emacs@gnu.org
Subject: Re: Why gdb inside emacs cannot print out c++ object?
Date: Sat, 16 Mar 2019 17:57:36 -0700	[thread overview]
Message-ID: <CAMX2uZgxXNg3_YtRw5-_-Gbpmdw1Yr2cXia+y6kSukn3c=wHjA@mail.gmail.com> (raw)
In-Reply-To: <CAMX2uZjYkNdvj-x40Xqcb+79oMz4evhKVbHMBjTdjVACDE=ZJw@mail.gmail.com>

For now, I use gdb command "info locals" as workaround. which is able to
print out C++ objects. etc it prints out


*m = std::map with 1 element = {["aaa"] = "bbb"}*
*p = {first = "aaa", second = "bbb"}*

I wish emacs gud window, locals cannot show the same thing.

Thanks,
Kevin


On Sat, Mar 16, 2019 at 5:48 PM Kevin Gao <kkegao@gmail.com> wrote:

> 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 <eliz@gnu.org> wrote:
>
>> > From: Kevin Gao <kkegao@gmail.com>
>> > Date: Fri, 15 Mar 2019 16:46:30 -0700
>> > Cc: help-gnu-emacs@gnu.org
>> >
>> > 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	other threads:[~2019-03-17  0:57 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-14  7:04 Why gdb inside emacs cannot print out c++ object? Kevin Gao
2019-03-14 15:00 ` Eli Zaretskii
2019-03-15 23:46   ` Kevin Gao
2019-03-16  8:02     ` Eli Zaretskii
2019-03-17  0:48       ` Kevin Gao
2019-03-17  0:57         ` Kevin Gao [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAMX2uZgxXNg3_YtRw5-_-Gbpmdw1Yr2cXia+y6kSukn3c=wHjA@mail.gmail.com' \
    --to=kkegao@gmail.com \
    --cc=eliz@gnu.org \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.