[libcxx-commits] [libcxx] [libc++] Install the GDB pretty printers under share/ (PR #181416)

via libcxx-commits libcxx-commits at lists.llvm.org
Fri Feb 13 12:23:37 PST 2026


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libcxx

Author: Louis Dionne (ldionne)

<details>
<summary>Changes</summary>

Similarly to what we want to start doing for LLDB data formatters (see [1]), this patch starts installing the existing GDB pretty printers under share/. I imagine that for the printers to be readily usable on a system, whoever builds GDB for that system would have to configure it to load printers from that directory.

As a drive-by break the RUN line of the GDB pretty-printer test into something readable.

[1]: https://discourse.llvm.org/t/rfc-lldb-moving-libc-data-formatters-out-of-lldb

---
Full diff: https://github.com/llvm/llvm-project/pull/181416.diff


4 Files Affected:

- (modified) libcxx/CMakeLists.txt (+2) 
- (modified) libcxx/test/configs/cmake-bridge.cfg.in (+1) 
- (modified) libcxx/test/libcxx/gdb/gdb_pretty_printer_test.sh.cpp (+8-1) 
- (modified) libcxx/utils/CMakeLists.txt (+8) 


``````````diff
diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt
index 0ac582cb561a8..8c00509ab81a9 100644
--- a/libcxx/CMakeLists.txt
+++ b/libcxx/CMakeLists.txt
@@ -417,6 +417,8 @@ set(LIBCXX_INSTALL_RUNTIME_DIR "${CMAKE_INSTALL_BINDIR}" CACHE STRING
     "Path where built libc++ runtime libraries should be installed.")
 set(LIBCXX_INSTALL_MODULES_DIR "share/libc++/v1" CACHE STRING
     "Path where target-agnostic libc++ module source files should be installed.")
+set(LIBCXX_INSTALL_EXTRAS_DIR "share" CACHE STRING
+    "Path where target-agnostic additional libc++ content is installed (e.g. debugging data formatters).")
 
 set(LIBCXX_SHARED_OUTPUT_NAME "c++" CACHE STRING "Output name for the shared libc++ runtime library.")
 set(LIBCXX_STATIC_OUTPUT_NAME "c++" CACHE STRING "Output name for the static libc++ runtime library.")
diff --git a/libcxx/test/configs/cmake-bridge.cfg.in b/libcxx/test/configs/cmake-bridge.cfg.in
index 20b7c1e9bc357..bf3218e29b39d 100644
--- a/libcxx/test/configs/cmake-bridge.cfg.in
+++ b/libcxx/test/configs/cmake-bridge.cfg.in
@@ -32,6 +32,7 @@ config.substitutions.append(('%{include-dir}', '@LIBCXX_TESTING_INSTALL_PREFIX@/
 config.substitutions.append(('%{target-include-dir}', '@LIBCXX_TESTING_INSTALL_PREFIX@/@LIBCXX_INSTALL_INCLUDE_TARGET_DIR@'))
 config.substitutions.append(('%{lib-dir}', '@LIBCXX_TESTING_INSTALL_PREFIX@/@LIBCXX_INSTALL_LIBRARY_DIR@'))
 config.substitutions.append(('%{module-dir}', '@LIBCXX_TESTING_INSTALL_PREFIX@/@LIBCXX_INSTALL_MODULES_DIR@'))
+config.substitutions.append(('%{extras-dir}', '@LIBCXX_TESTING_INSTALL_PREFIX@/@LIBCXX_INSTALL_EXTRAS_DIR@'))
 config.substitutions.append(('%{test-tools-dir}', '@LIBCXX_TEST_TOOLS_PATH@'))
 config.substitutions.append(('%{benchmark_flags}', '-I @LIBCXX_BINARY_DIR@/test/benchmarks/google-benchmark/include -L @LIBCXX_BINARY_DIR@/test/benchmarks/google-benchmark/lib -L @LIBCXX_BINARY_DIR@/test/benchmarks/google-benchmark/lib64 -l benchmark'))
 config.substitutions.append(("%{python}", shlex.quote(sys.executable)))
diff --git a/libcxx/test/libcxx/gdb/gdb_pretty_printer_test.sh.cpp b/libcxx/test/libcxx/gdb/gdb_pretty_printer_test.sh.cpp
index 638137f8d4c58..0f8cbf9e4448d 100644
--- a/libcxx/test/libcxx/gdb/gdb_pretty_printer_test.sh.cpp
+++ b/libcxx/test/libcxx/gdb/gdb_pretty_printer_test.sh.cpp
@@ -25,8 +25,15 @@
 // UNSUPPORTED: windows
 
 // RUN: %{cxx} %{flags} %s -o %t.exe %{compile_flags} -g %{link_flags}
+
 // Ensure locale-independence for unicode tests.
-// RUN: env LANG=en_US.UTF-8 %{gdb} -nx -batch -iex "set autoload off" -ex "source %S/../../../utils/gdb/libcxx/printers.py" -ex "python register_libcxx_printer_loader()" -ex "source %S/gdb_pretty_printer_test.py" %t.exe
+// RUN: env LANG=en_US.UTF-8                                    \
+// RUN:   %{gdb} -nx -batch                                     \
+// RUN:       -iex "set autoload off"                           \
+// RUN:       -ex "source %{extras-dir}/gdb/libcxx/printers.py" \
+// RUN:       -ex "python register_libcxx_printer_loader()"     \
+// RUN:       -ex "source %S/gdb_pretty_printer_test.py"        \
+// RUN:       %t.exe
 
 #include <bitset>
 #include <deque>
diff --git a/libcxx/utils/CMakeLists.txt b/libcxx/utils/CMakeLists.txt
index 027e485fc15ef..bf3f4d1f4f7e8 100644
--- a/libcxx/utils/CMakeLists.txt
+++ b/libcxx/utils/CMakeLists.txt
@@ -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"
+    DESTINATION "${LIBCXX_INSTALL_EXTRAS_DIR}/gdb/libcxx"
+    COMPONENT cxx-extras
+    PERMISSIONS OWNER_READ GROUP_READ WORLD_READ
+)

``````````

</details>


https://github.com/llvm/llvm-project/pull/181416


More information about the libcxx-commits mailing list