-
Notifications
You must be signed in to change notification settings - Fork 12.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Missing rust-gdb pretty printer for cdylib shared objects #96365
Comments
@tromey, I noticed you have experience in this area. Any thoughts on this, or who might be the right person? |
It seems to be the linker arg Do check this, first create these two files: // lib.rs
pub extern "C" fn yep() -> bool {
true
}
// main.rs
#![feature(start)]
#[start]
fn start(_: isize, _: *const *const u8) -> isize {
return 0;
} Then build a $ rustc +nightly \
-C save-temps \
-C debuginfo=2 \
-C codegen-units=1 \
--print link-args \
--out-dir /tmp/bin-out \
--crate-type bin \
main.rs
LC_ALL="C" PATH="/home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin:/home/martin/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/wsl/lib:/mnt/c/Windows/system32:/mnt/c/Windows:/mnt/c/Windows/System32/Wbem:/mnt/c/Windows/System32/WindowsPowerShell/v1.0/:/mnt/c/Windows/System32/OpenSSH/:/mnt/c/Program Files/Git/cmd:/mnt/c/Program Files/Docker/Docker/resources/bin:/mnt/c/Users/ensel/.cargo/bin:/mnt/c/Users/ensel/AppData/Local/Microsoft/WindowsApps:/mnt/c/Users/ensel/AppData/Local/Programs/Microsoft VS Code/bin" VSLANG="1033" "cc" "-m64" "/tmp/rustcVhABaM/symbols.o" "/tmp/bin-out/main.main.bb53c12c-cgu.0.rcgu.o" "/tmp/bin-out/main.149e45n1nrd5pscg.rcgu.o" "-Wl,--as-needed" "-L" "/home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "/home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-67e0fe4bfa018a5e.rlib" "/home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-6e25273444177929.rlib" "/home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libobject-05da49d3cca73bff.rlib" "/home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libmemchr-616c9bd2710f0982.rlib" "/home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libaddr2line-d9df84ec1a8a7a8f.rlib" "/home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libgimli-0242ef3eea1e9db2.rlib" "/home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_demangle-127f477a16f3f8f8.rlib" "/home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd_detect-eb235cc34134320b.rlib" "/home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libhashbrown-c5f20f2274212453.rlib" "/home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libminiz_oxide-4483c8bc4648568f.rlib" "/home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libadler-94da6a76998341a3.rlib" "/home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_alloc-22a9646e8f27a6e4.rlib" "/home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-eb91273024ac0258.rlib" "/home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcfg_if-323da837c64ef472.rlib" "/home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-6d46d38f739892fe.rlib" "/home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-8212dcd77adfe144.rlib" "/home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_core-522518611024dce5.rlib" "/home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-05898138a596088a.rlib" "/home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-b78d27aa9e5e005b.rlib" "-Wl,-Bdynamic" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-Wl,--eh-frame-hdr" "-Wl,-znoexecstack" "-L" "/home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "/tmp/bin-out/main" "-Wl,--gc-sections" "-pie" "-Wl,-zrelro,-znow" "-nodefaultlibs"
$ rustc +nightly \
-C save-temps \
-C debuginfo=2 \
-C codegen-units=1 \
--print link-args \
--out-dir /tmp/lib-out \
--crate-type cdylib \
lib.rs
LC_ALL="C" PATH="/home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin:/home/martin/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/wsl/lib:/mnt/c/Windows/system32:/mnt/c/Windows:/mnt/c/Windows/System32/Wbem:/mnt/c/Windows/System32/WindowsPowerShell/v1.0/:/mnt/c/Windows/System32/OpenSSH/:/mnt/c/Program Files/Git/cmd:/mnt/c/Program Files/Docker/Docker/resources/bin:/mnt/c/Users/ensel/.cargo/bin:/mnt/c/Users/ensel/AppData/Local/Microsoft/WindowsApps:/mnt/c/Users/ensel/AppData/Local/Programs/Microsoft VS Code/bin" VSLANG="1033" "cc" "-Wl,--version-script=/tmp/rustc0bhGIi/list" "-m64" "/tmp/rustc0bhGIi/symbols.o" "/tmp/lib-out/lib.lib.447e930b-cgu.0.rcgu.o" "/tmp/lib-out/lib.23es8ilvqvufl30n.rcgu.o" "-Wl,--as-needed" "-L" "/home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "/home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-67e0fe4bfa018a5e.rlib" "/home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-6e25273444177929.rlib" "/home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libobject-05da49d3cca73bff.rlib" "/home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libmemchr-616c9bd2710f0982.rlib" "/home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libaddr2line-d9df84ec1a8a7a8f.rlib" "/home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libgimli-0242ef3eea1e9db2.rlib" "/home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_demangle-127f477a16f3f8f8.rlib" "/home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd_detect-eb235cc34134320b.rlib" "/home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libhashbrown-c5f20f2274212453.rlib" "/home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libminiz_oxide-4483c8bc4648568f.rlib" "/home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libadler-94da6a76998341a3.rlib" "/home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_alloc-22a9646e8f27a6e4.rlib" "/home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-eb91273024ac0258.rlib" "/home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcfg_if-323da837c64ef472.rlib" "/home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-6d46d38f739892fe.rlib" "/home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-8212dcd77adfe144.rlib" "/home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_core-522518611024dce5.rlib" "/home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-05898138a596088a.rlib" "/home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-b78d27aa9e5e005b.rlib" "-Wl,-Bdynamic" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-Wl,--eh-frame-hdr" "-Wl,-znoexecstack" "-L" "/home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "/tmp/lib-out/liblib.so" "-Wl,--gc-sections" "-shared" "-Wl,-zrelro,-znow" "-nodefaultlibs" We can see that the $ readelf -x .debug_gdb_scripts /tmp/bin-out/main /tmp/lib-out/liblib.so
File: /tmp/bin-out/main
Hex dump of section '.debug_gdb_scripts':
0x00002000 01676462 5f6c6f61 645f7275 73745f70 .gdb_load_rust_p
0x00002010 72657474 795f7072 696e7465 72732e70 retty_printers.p
0x00002020 7900 y.
File: /tmp/lib-out/liblib.so
readelf: Warning: Section '.debug_gdb_scripts' was not dumped because it does not exist However, if we remove the $ LC_ALL="C" PATH="/home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin:/home/martin/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/wsl/lib:/mnt/c/Windows/system32:/mnt/c/Windows:/mnt/c/Windows/System32/Wbem:/mnt/c/Windows/System32/WindowsPowerShell/v1.0/:/mnt/c/Windows/System32/OpenSSH/:/mnt/c/Program Files/Git/cmd:/mnt/c/Program Files/Docker/Docker/resources/bin:/mnt/c/Users/ensel/.cargo/bin:/mnt/c/Users/ensel/AppData/Local/Microsoft/WindowsApps:/mnt/c/Users/ensel/AppData/Local/Programs/Microsoft VS Code/bin" VSLANG="1033" "cc" "-m64" "/tmp/rustcVhABaM/symbols.o" "/tmp/bin-out/main.main.bb53c12c-cgu.0.rcgu.o" "/tmp/bin-out/main.149e45n1nrd5pscg.rcgu.o" "-Wl,--as-needed" "-L" "/home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "/home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-67e0fe4bfa018a5e.rlib" "/home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-6e25273444177929.rlib" "/home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libobject-05da49d3cca73bff.rlib" "/home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libmemchr-616c9bd2710f0982.rlib" "/home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libaddr2line-d9df84ec1a8a7a8f.rlib" "/home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libgimli-0242ef3eea1e9db2.rlib" "/home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_demangle-127f477a16f3f8f8.rlib" "/home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd_detect-eb235cc34134320b.rlib" "/home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libhashbrown-c5f20f2274212453.rlib" "/home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libminiz_oxide-4483c8bc4648568f.rlib" "/home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libadler-94da6a76998341a3.rlib" "/home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_alloc-22a9646e8f27a6e4.rlib" "/home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-eb91273024ac0258.rlib" "/home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcfg_if-323da837c64ef472.rlib" "/home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-6d46d38f739892fe.rlib" "/home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-8212dcd77adfe144.rlib" "/home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_core-522518611024dce5.rlib" "/home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-05898138a596088a.rlib" "/home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-b78d27aa9e5e005b.rlib" "-Wl,-Bdynamic" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-Wl,--eh-frame-hdr" "-Wl,-znoexecstack" "-L" "/home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "/tmp/bin-out/main" "-pie" "-Wl,-zrelro,-znow" "-nodefaultlibs"
$ LC_ALL="C" PATH="/home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin:/home/martin/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/wsl/lib:/mnt/c/Windows/system32:/mnt/c/Windows:/mnt/c/Windows/System32/Wbem:/mnt/c/Windows/System32/WindowsPowerShell/v1.0/:/mnt/c/Windows/System32/OpenSSH/:/mnt/c/Program Files/Git/cmd:/mnt/c/Program Files/Docker/Docker/resources/bin:/mnt/c/Users/ensel/.cargo/bin:/mnt/c/Users/ensel/AppData/Local/Microsoft/WindowsApps:/mnt/c/Users/ensel/AppData/Local/Programs/Microsoft VS Code/bin" VSLANG="1033" "cc" "-Wl,--version-script=/tmp/rustc0bhGIi/list" "-m64" "/tmp/rustc0bhGIi/symbols.o" "/tmp/lib-out/lib.lib.447e930b-cgu.0.rcgu.o" "/tmp/lib-out/lib.23es8ilvqvufl30n.rcgu.o" "-Wl,--as-needed" "-L" "/home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "/home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-67e0fe4bfa018a5e.rlib" "/home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-6e25273444177929.rlib" "/home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libobject-05da49d3cca73bff.rlib" "/home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libmemchr-616c9bd2710f0982.rlib" "/home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libaddr2line-d9df84ec1a8a7a8f.rlib" "/home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libgimli-0242ef3eea1e9db2.rlib" "/home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_demangle-127f477a16f3f8f8.rlib" "/home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd_detect-eb235cc34134320b.rlib" "/home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libhashbrown-c5f20f2274212453.rlib" "/home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libminiz_oxide-4483c8bc4648568f.rlib" "/home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libadler-94da6a76998341a3.rlib" "/home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_alloc-22a9646e8f27a6e4.rlib" "/home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-eb91273024ac0258.rlib" "/home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcfg_if-323da837c64ef472.rlib" "/home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-6d46d38f739892fe.rlib" "/home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-8212dcd77adfe144.rlib" "/home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_core-522518611024dce5.rlib" "/home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-05898138a596088a.rlib" "/home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-b78d27aa9e5e005b.rlib" "-Wl,-Bdynamic" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-Wl,--eh-frame-hdr" "-Wl,-znoexecstack" "-L" "/home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "/tmp/lib-out/liblib.so" "-shared" "-Wl,-zrelro,-znow" "-nodefaultlibs"
$ readelf -x .debug_gdb_scripts /tmp/bin-out/main /tmp/lib-out/liblib.so
File: /tmp/bin-out/main
Hex dump of section '.debug_gdb_scripts':
0x000f9e80 01676462 5f6c6f61 645f7275 73745f70 .gdb_load_rust_p
0x000f9e90 72657474 795f7072 696e7465 72732e70 retty_printers.p
0x000f9ea0 7900 y.
File: /tmp/lib-out/liblib.so
Hex dump of section '.debug_gdb_scripts':
0x000f9e70 01676462 5f6c6f61 645f7275 73745f70 .gdb_load_rust_p
0x000f9e80 72657474 795f7072 696e7465 72732e70 retty_printers.p
0x000f9e90 7900 y. In other words, the object files emitted by WorkaroundAs a workaround it seems to work to pass
but be aware of unintended consequences, especially for release builds. |
Adding |
Problem
Debugging in
rust-gdb
with a shared object library does not activate pretty-printers supplied byrustup
.Running
cargo build
withcrate-type
ofbin
orlib
results in a.debug_gdb_scripts
section on the target or library, allowingrust-gdb
to auto-load the Python pretty printers dynamically during debugging. The pretty printers are great!rust/compiler/rustc_codegen_llvm/src/debuginfo/gdb.rs
Lines 39 to 40 in 91a0600
However, for
crate-type
ofcdylib
, the.debug_gdb_scripts
section is not written. This results in a lack of pretty printing inrust-gdb
, and makes it more challenging to userust-gdb
to best effect. I'm seeing this when working with Python bindings of Rust code with pyo3. Is there a reasoncdylib
did not receive this pretty-printer support?Workaround
I've confirmed that manually adding the
.debug_gdb_scripts
section to a.so
library generated withcrate-type=cdylib
activates the pretty printers. I did noticed some Python exceptions in the pretty printers, but have not investigated further.$ objcopy --add-section .debug_gdb_scripts=<(echo -ne "\x01gdb_load_rust_pretty_printers.py\0") ./libmytest_lib.so $ objdump -sj .debug_gdb_scripts libmytest_lib.so libmytest_lib.so: file format elf64-x86-64 Contents of section .debug_gdb_scripts: 0000 01676462 5f6c6f61 645f7275 73745f70 .gdb_load_rust_p 0010 72657474 795f7072 696e7465 72732e70 retty_printers.p 0020 7900 y.
Version information
rustc 1.60.0 (7737e0b 2022-04-04)
cargo 1.60.0 (d1fd9fe 2022-03-01)
The text was updated successfully, but these errors were encountered: