about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/etc/gdb_load_rust_pretty_printers.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/etc/gdb_load_rust_pretty_printers.py b/src/etc/gdb_load_rust_pretty_printers.py
index 856b5df2de7..491b6ba9e9e 100644
--- a/src/etc/gdb_load_rust_pretty_printers.py
+++ b/src/etc/gdb_load_rust_pretty_printers.py
@@ -1,3 +1,14 @@
+# Add this folder to the python sys path; GDB Python-interpreter will now find modules in this path
+import sys
+from os import path
+self_dir = path.dirname(path.realpath(__file__))
+sys.path.append(self_dir)
+
 import gdb
 import gdb_lookup
-gdb_lookup.register_printers(gdb.current_objfile())
+
+# current_objfile can be none; even with `gdb foo-app`; sourcing this file after gdb init now works
+try:
+    gdb_lookup.register_printers(gdb.current_objfile())
+except Exception:
+    gdb_lookup.register_printers(gdb.selected_inferior().progspace)