[libcxx-commits] [libcxx] [libc++] Install the GDB pretty printers under share/ (PR #181416)
Braden Ganetsky via libcxx-commits
libcxx-commits at lists.llvm.org
Sat Feb 28 21:28:06 PST 2026
================
@@ -61,3 +61,11 @@ add_custom_target(libcxx-generate-files
libcxx-generate-width-estimation-table
libcxx-indic-conjunct-break-table
COMMENT "Create all the auto-generated files in libc++ and its tests.")
+
+# Install the GDB pretty printers.
+install(
+ FILES "${LIBCXX_SOURCE_DIR}/utils/gdb/libcxx/printers.py"
----------------
k3DW wrote:
> I think there's some special naming schemes that GDB requires for the formatters to get detected.
The GDB pretty-printers will be detected and auto-loaded for the binary `/path/to/libc++.so.1.0` if there is a corresponding auto-loading script at `<gdb-scripts-directory>/path/to/libc++.so.1.0-gdb.py`. On my machine, `<gdb-scripts-directory>` is `/usr/share/gdb/auto-load`, but this can be queried from GDB. The auto-loading script needs to be named identically to the canonical file path to the binary, with `-gdb.py` appended to the end.
Without including an auto-load script alongside the installation of the libc++ printers, it will be much more difficult for the users. Printers for the standard library should "just work" out of the box.
Querying GDB for the location for the auto-load script isn't too difficult. I've been using something like [this script](https://gist.github.com/k3DW/58b0968d903b703c6e52576a3aca1950). On my machine, `gdb-auto-load-dir.py | tail -1` spits out `/usr/share/gdb/auto-load`.
As for the contents of the auto-load script, I don't know. [My own libc++ GDB auto-load script](https://github.com/k3DW/debug/blob/f9f1a1a9a9a5562177265a55596e32839d684d64/gdb/install_libcxx_printers.py#L103-L117) is quick and dirty. It works for me for now, but I don't think it's distributable. [The libstdc++ GDB auto-load script](https://github.com/gcc-mirror/gcc/blob/254a858ae7ae1400452f1c80125c80de0778bde5/libstdc%2B%2B-v3/python/hook.in) is much more robust.
https://github.com/llvm/llvm-project/pull/181416
More information about the libcxx-commits
mailing list