-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Avoid volatile loads to preserve the gdb pretty printer section #44993
Comments
This comment has some more informaton on this. Apparently we should also make sure that this isn't an allocated section in the final executable, no need to have this actually be resident in memory! |
Yes, I'd love to get rid of this hack. |
This approach (read: hack) doesn't work with LLD 6.0, the LLD version that's shipped with the Rust toolchain. This means that if we want to default to LLD as the ARM Cortex-M linker (good because the user won't have to install arm-none-eabi-binutils, or worse arm-none-eabi-gcc, to link Rust programs) we'll have a regression in binary size (bad) because .debug_gdb_scripts will be allocated in the final binary. @michaelwoerister @tromey is there any chance we could (eventually) get rid of .debug_gdb_scripts and rust-gdb altogether? GDB 7.12+ has official support for Rust and can pretty print Rust stuff so I'm not even sure what rust-gdb buys you at this point. The standard in Cortex-M land is to use vanilla arm-none-eabi-gdb so we'd rather not have to pay for / deal with this .gdb_debug_script hack which we don't even use! |
It has printers for things from the standard library -- which is something gdb itself should not really know about; and it arranges for these printers to be installed (gdb by default won't load random python code, something has to set the "auto load safe path"). However, I don't think the hook code necessarily has to be in |
One option which may be the easiest to take in the meantime is to make generation of this section a boolean in custom target specs. That way presumably the embedded targets could all disable it (and it'd be left on for Linux and such). Although if someone gets to @tromey's solution first then that'd obviate the need for this route of course! |
That must be why I never noticed anything amiss -- ARM Cortex-M doesn't have access to the standard library. One always uses core and (very) ocassionally the alloc crate for stuff like Vec.
off-topic: I'd love to see GDB use the |
Normally I discourage this kind of thing, because pretty-printers are invoked by One wacky option would be to translate the |
That would be a quick short-term fix to avoid problems with certain targets. |
Wild idea: can we make gdb somehow interpret the Rust code in |
…xcrichton add emit_debug_gdb_scripts target option and .. set it to false for no-std targets like ARM Cortex-M and MSP430. For the rationale of this change see the comment in thumb_base.rs this is a temporary workaround until rust-lang#44993 is implemented r? @alexcrichton or @michaelwoerister
Same as the other embedded targets, see: rust-lang#49728 This is a temporary workaround for rust-lang#44993.
…ochenkov set emit_debug_gdb_scripts: false for riscv32imac-unknown-none target Same as the other embedded targets, see: rust-lang#49728 This is a temporary workaround for rust-lang#44993.
Related: #65564 (proposes running code on the inferior to obtain a debugger view) |
This option was added in `rustc` in order to disable GDB scripts for some no-`std` targets, see rust-lang/rust#44993. Therefore, even though the default in the compiler for targets is `true`, we leave it as `false`. If, in the future, it gets enabled, then we should take into account the `CONFIG_GDB_SCRIPTS` option. Signed-off-by: Miguel Ojeda <[email protected]>
This option was added in `rustc` in order to disable GDB scripts for some no-`std` targets, see rust-lang/rust#44993. Therefore, even though the default in the compiler for targets is `true`, we leave it as `false`. If, in the future, it gets enabled, then we should take into account the `CONFIG_GDB_SCRIPTS` option. Signed-off-by: Miguel Ojeda <[email protected]>
Visted during wg-debugging triage. At this time, a target option is available to completely disable the inclusion of gdb pretty printers in the executable. That seems to mitigate the original issue but it would still be good to solve this in a more elegant way. |
Right now when you compile a program with debuginfo on Linux we'll emit a volatile load of a gdb pretty printer section which is intended on ensuring that the linker forces a section in the executable.
Apparently, though, this has caused some problems for embedded work (cc @japaric) where the section doesn't always make it to the final image that's flashed to devices, meaning that this stray load near the beginning of the program can sometimes cause problems.
We should look into other solutions to force the linker to keep this symbol I think. Right now we're passing a version script on Linux to preserve symbols in cdylibs and I think the same would work for this? Worth trying out!
cc @michaelwoerister
The text was updated successfully, but these errors were encountered: