-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Missing auto-load script in gdb #33159
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
Looking into GDB's source code, GDB uses the function As an experiment, I added this to my
This did help GDB find
CC @tromey |
|
This super hacky patch will let GDB load the files correctly, at least on my machine diff --git a/src/etc/gdb_load_rust_pretty_printers.py b/src/etc/gdb_load_rust_pretty_printers.py
index 755cac153d..48eba096fc 100644
--- a/src/etc/gdb_load_rust_pretty_printers.py
+++ b/src/etc/gdb_load_rust_pretty_printers.py
@@ -8,5 +8,12 @@
# option. This file may not be copied, modified, or distributed
# except according to those terms.
+# Hacky fix for paths being annoying
+import sys
+from os import path
+self_dir = path.dirname(path.realpath(__file__))
+sys.path.append(self_dir)
+
import gdb_rust_pretty_printing
gdb_rust_pretty_printing.register_printers(gdb.current_objfile()) |
For info, I've been experimenting debugging Rust programs using https://github.com/cs01/gdbgui Just got the basic setup working, I can confirm that the two hacks here (edit the py file, create .gdbinit) suppressed the warning. I'm not sure what the pretty printers are capable of though, is there documentation anywhere? |
I had the same problem and found out that you can also just set the PYTHONPATH environment variable instead of changin the python script.
|
I have this problem when I debug rust programs directly with But when I use |
The warning auto-load script is gone, and gdb_load_rust_pretty_printers.py is loaded from ~/.rustup directory, but a lot of commands I wrote in my gdbinit print errors or don't work as expected like when I debug C/C++ binaries. For example, when you try to |
In addition to setting
|
I've hit a similar issue while running rust-gdb on Ubuntu 20.04 (I have version 1.59.0+dfsg1
My issue, however, seems to be related to packaging, since the rust-gdb script applies the 2 workarounds mentioned above (setting PYTHONPATH and running the 2 gdb commands). It seems that in my case, the packager forgot to put rust_types.py in the deb package. Manually copying the file from a local install of the toolchain to /usr/lib/rustlib/etc/ made the error go away. |
When compiled with
-g
, we produce binaries which contain agdb_load_rust_pretty_printers.py
in.debug_gdb_scripts
section. This makes gdb complain about missing scripts when run under plain gdb as opposed to the rust-gdb wrapper script.Distribution puts this script into
$INSTALL_ROOT/lib/rustlib/etc
, which is someplace gdb wouldn’t ever look at by default. Some experimentation suggests that placing the scripts at gdb’sDATA-DIRECTORY/python/gdb/printer/
will at least make gdb detect the presence of the script, but then it fails to load the module due to import errors.The text was updated successfully, but these errors were encountered: