Skip to content

Commit c5145dc

Browse files
committed
Fix #111961 r=Mark-Simulacrum
Makes the Python pretty printer library source'able from within GDB after spawn. This makes `rust-gdb` not the required approach. It also provides the possibility for GUI:s that wrap GDB, to debug Rust using the pretty printer library; as well as other projects such as for instance Pernosco, which previously was not possible. This won't introduce any new unexpected behaviors for users of `rust-gdb`
1 parent cade266 commit c5145dc

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed
+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)