* Why gdb inside emacs cannot print out c++ object?
@ 2019-03-14 7:04 Kevin Gao
2019-03-14 15:00 ` Eli Zaretskii
0 siblings, 1 reply; 6+ messages in thread
From: Kevin Gao @ 2019-03-14 7:04 UTC (permalink / raw)
To: help-gnu-emacs
Hello folks,
I hit an issue when debugging c++ code using gdb inside emacs.
Suppose: p is c++ iterator of an object of multimap<int, pair<string,
string>>;
inside emacs gdb (with many windows on), "p p" returns:
*$1 = {_M_node = 0x555555775fa0}*, which is meaningless to me.
As a comparison, in raw gdb (etc gdb ./a.out), "p p" returns:
*$1 = {first = 1, second = {first = "foo", second = "bar"}}*, which is what
I want to see.
Why gdb inside emacs cannot print out c++ object? Seems emacs does some
special setting which turns off c++ mode?
This is really a blocking issue for C++ debug. Please share you idea.
Thanks,
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Why gdb inside emacs cannot print out c++ object?
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
0 siblings, 1 reply; 6+ messages in thread
From: Eli Zaretskii @ 2019-03-14 15:00 UTC (permalink / raw)
To: help-gnu-emacs
> From: Kevin Gao <kkegao@gmail.com>
> Date: Thu, 14 Mar 2019 00:04:29 -0700
>
> Suppose: p is c++ iterator of an object of multimap<int, pair<string,
> string>>;
>
> inside emacs gdb (with many windows on), "p p" returns:
> *$1 = {_M_node = 0x555555775fa0}*, which is meaningless to me.
>
> As a comparison, in raw gdb (etc gdb ./a.out), "p p" returns:
> *$1 = {first = 1, second = {first = "foo", second = "bar"}}*, which is what
> I want to see.
>
> Why gdb inside emacs cannot print out c++ object? Seems emacs does some
> special setting which turns off c++ mode?
Does it work if you invoke GDB with "M-x gud-gdb" instead of "M-x gdb"?
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Why gdb inside emacs cannot print out c++ object?
2019-03-14 15:00 ` Eli Zaretskii
@ 2019-03-15 23:46 ` Kevin Gao
2019-03-16 8:02 ` Eli Zaretskii
0 siblings, 1 reply; 6+ messages in thread
From: Kevin Gao @ 2019-03-15 23:46 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: help-gnu-emacs
Seems sth wrong with my machine. Sorry for the false report.
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)
Thanks,
Kevin
On Thu, Mar 14, 2019 at 8:00 AM Eli Zaretskii <eliz@gnu.org> wrote:
> > From: Kevin Gao <kkegao@gmail.com>
> > Date: Thu, 14 Mar 2019 00:04:29 -0700
> >
> > Suppose: p is c++ iterator of an object of multimap<int, pair<string,
> > string>>;
> >
> > inside emacs gdb (with many windows on), "p p" returns:
> > *$1 = {_M_node = 0x555555775fa0}*, which is meaningless to me.
> >
> > As a comparison, in raw gdb (etc gdb ./a.out), "p p" returns:
> > *$1 = {first = 1, second = {first = "foo", second = "bar"}}*, which is
> what
> > I want to see.
> >
> > Why gdb inside emacs cannot print out c++ object? Seems emacs does some
> > special setting which turns off c++ mode?
>
> Does it work if you invoke GDB with "M-x gud-gdb" instead of "M-x gdb"?
>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Why gdb inside emacs cannot print out c++ object?
2019-03-15 23:46 ` Kevin Gao
@ 2019-03-16 8:02 ` Eli Zaretskii
2019-03-17 0:48 ` Kevin Gao
0 siblings, 1 reply; 6+ messages in thread
From: Eli Zaretskii @ 2019-03-16 8:02 UTC (permalink / raw)
To: help-gnu-emacs
> 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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Why gdb inside emacs cannot print out c++ object?
2019-03-16 8:02 ` Eli Zaretskii
@ 2019-03-17 0:48 ` Kevin Gao
2019-03-17 0:57 ` Kevin Gao
0 siblings, 1 reply; 6+ messages in thread
From: Kevin Gao @ 2019-03-17 0:48 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: help-gnu-emacs
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
>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Why gdb inside emacs cannot print out c++ object?
2019-03-17 0:48 ` Kevin Gao
@ 2019-03-17 0:57 ` Kevin Gao
0 siblings, 0 replies; 6+ messages in thread
From: Kevin Gao @ 2019-03-17 0:57 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: help-gnu-emacs
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
>>
>>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2019-03-17 0:57 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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.