From: Eli Zaretskii <eliz@gnu.org>
To: Simon Marchi <simon.marchi@polymtl.ca>
Cc: asmwarrior@gmail.com, gdb@sourceware.org
Subject: Re: How to load C++ pretty-printers
Date: Sat, 16 Mar 2019 16:00:00 -0000 [thread overview]
Message-ID: <83o96ayfky.fsf@gnu.org> (raw)
In-Reply-To: <b269529b205165ae1260b8a27954e46c@polymtl.ca> (message from Simon Marchi on Sat, 16 Mar 2019 10:25:43 -0400)
> Date: Sat, 16 Mar 2019 10:25:43 -0400
> From: Simon Marchi <simon.marchi@polymtl.ca>
> Cc: asmwarrior <asmwarrior@gmail.com>, gdb@sourceware.org
>
> If it can help, I have something similar to that in my .gdbinit (whereas
> asmwarrior has put the same content in a separate file, my.gdb, which
> they then source by hand).
>
> When libstdc++ is linked dynamically with a program and you debug that
> program, GDB will "auto-load" the file corresponding to the libstdc++
> shared library. In my case, it's at
> "/usr/share/gdb/auto-load/usr/lib/libstdc++.so.6.0.25-gdb.py". This
> file tries to find where the GCC-provided libstdc++ pretty printers are
> installed, and adds this path to the Python import path. It then calls
> register_libstdcxx_printers, a function provided by the libstdc++ pretty
> printers.
>
> When libstdc++ is linked statically, the auto-load does not happen, as
> you mentioned. So the idea here is to replicate what the auto-load
> script does, but by hand.
>
> In my case, I have these lines to adjust the Python import path to add
> GCC's pretty printers directory:
>
> python import sys
> python sys.path.insert(0, '/usr/share/gcc-8.2.1/python')
>
> And then I manually trigger the GDB auto-load script, that would
> normally be sourced automatically when loading the libstdc++ shared lib:
>
> source /usr/share/gdb/auto-load/usr/lib/libstdc++.so.6.0.25-gdb.py
Ah, thanks, this script was the missing piece. In the MinGW GCC
distribution it installs into lib/gcc/mingw32/VERSION/, where VERSION
is the GCC version. The script is also named differently, due to the
MS-Windows .dll.a import library.
So, for the record, I now have this in my ~/.gdbinit
python import sys
python sys.path.insert(0, 'd:/usr/share/gcc-7.3.0/python')
source d:/usr/lib/gcc/mingw32/7.3.0/libstdc++.dll.a-gdb.py
(The last line both imports the function register_libstdcxx_printers,
and calls that function.)
> The "set auto-load safe-path" line is to define it is safe to auto-load
> things from. If you are missing something, you should know quickly
> enough, as GDB will print you a warning, saying it didn't auto-load X,
> because X is not in a safe path (as well as information about how to
> adjust it).
Yes, I already have auto-load safe-path set to not get in the way.
Thanks.
next prev parent reply other threads:[~2019-03-16 16:00 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-16 8:30 Eli Zaretskii
2019-03-16 12:41 ` asmwarrior
2019-03-16 12:58 ` Eli Zaretskii
2019-03-16 13:21 ` asmwarrior
2019-03-16 14:25 ` Simon Marchi
2019-03-16 16:00 ` Eli Zaretskii [this message]
2019-03-17 1:47 ` asmwarrior
2019-03-17 11:03 ` Joel Brobecker
2019-03-17 12:39 ` Philippe Waroquiers
2019-03-17 15:31 ` Eli Zaretskii
2019-03-17 17:17 ` Philippe Waroquiers
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=83o96ayfky.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=asmwarrior@gmail.com \
--cc=gdb@sourceware.org \
--cc=simon.marchi@polymtl.ca \
/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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox