From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 53496 invoked by alias); 16 Mar 2019 16:00:51 -0000 Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org Received: (qmail 53420 invoked by uid 89); 16 Mar 2019 16:00:50 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-3.7 required=5.0 tests=AWL,BAYES_00,SPF_PASS autolearn=ham version=3.3.1 spammy=H*f:sk:b269529, HX-Languages-Length:2335, mingw32 X-HELO: eggs.gnu.org Received: from eggs.gnu.org (HELO eggs.gnu.org) (209.51.188.92) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 16 Mar 2019 16:00:49 +0000 Received: from fencepost.gnu.org ([2001:470:142:3::e]:33214) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h5Bjr-0007N9-8Z; Sat, 16 Mar 2019 12:00:47 -0400 Received: from [176.228.60.248] (port=1998 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1h5Bjq-0001oH-F7; Sat, 16 Mar 2019 12:00:47 -0400 Date: Sat, 16 Mar 2019 16:00:00 -0000 Message-Id: <83o96ayfky.fsf@gnu.org> From: Eli Zaretskii To: Simon Marchi CC: asmwarrior@gmail.com, gdb@sourceware.org In-reply-to: (message from Simon Marchi on Sat, 16 Mar 2019 10:25:43 -0400) Subject: Re: How to load C++ pretty-printers References: <835zsjz0f8.fsf@gnu.org> <83sgvnx9g1.fsf@gnu.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-IsSubscribed: yes X-SW-Source: 2019-03/txt/msg00041.txt.bz2 > Date: Sat, 16 Mar 2019 10:25:43 -0400 > From: Simon Marchi > Cc: asmwarrior , 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.