diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2023-06-06 12:00:32 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-06-06 12:00:32 +0200 |
| commit | 29871d5480c887abdaf4b8b2b925a9e4aee7b521 (patch) | |
| tree | 21f478f3a1e6e9154eed2a53e28fae166d0345c1 | |
| parent | c4e11dc3277ee44d4fbfb58da5273bd00940e6d4 (diff) | |
| parent | c5145dc87a2b750a12e8f36d84ff6fb4f8edfdf4 (diff) | |
| download | rust-29871d5480c887abdaf4b8b2b925a9e4aee7b521.tar.gz rust-29871d5480c887abdaf4b8b2b925a9e4aee7b521.zip | |
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.
| -rw-r--r-- | src/etc/gdb_load_rust_pretty_printers.py | 13 |
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) |
