Skip to content

Commit 29871d5

Browse files
authored
Rollup merge of #111962 - theIDinside:better-gdb, r=Mark-Simulacrum
Make GDB Python Pretty Printers loadable after spawning GDB, avoiding required `rust-gdb` Fixes #111961 Makes the Python pretty printer library source'able from within GDB after spawn, making the wrapper script `rust-gdb` become not the required approach to use the pretty printer library. Allows for integration into GUI:s that wrap GDB extremely easy. The previous design complicates this feature.
2 parents c4e11dc + c5145dc commit 29871d5

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

Diff for: src/etc/gdb_load_rust_pretty_printers.py

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
# Add this folder to the python sys path; GDB Python-interpreter will now find modules in this path
2+
import sys
3+
from os import path
4+
self_dir = path.dirname(path.realpath(__file__))
5+
sys.path.append(self_dir)
6+
17
import gdb
28
import gdb_lookup
3-
gdb_lookup.register_printers(gdb.current_objfile())
9+
10+
# current_objfile can be none; even with `gdb foo-app`; sourcing this file after gdb init now works
11+
try:
12+
gdb_lookup.register_printers(gdb.current_objfile())
13+
except Exception:
14+
gdb_lookup.register_printers(gdb.selected_inferior().progspace)

0 commit comments

Comments
 (0)