-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
no_mangle static symbols have improper debug info #33172
Comments
This is issue #32574. Note that gdb supports a second, improved interface to detecting shared library events. I don't remember exactly when this went in but here's one of the series; if you're interested this should help find the final patches: http://www.cygwin.com/ml/gdb-patches/2012-07/msg00157.html There's a Rust crate for making stap-style probes. |
I'm going to close in favor of #32574. Thanks for the issue, though. |
I believe that we should re-open this issue in light of #46453 |
Doesn't #46453 already cover the problem listed here? Or is it different? If it's different I'm happy to reopen. |
I think that this is actually an extra bug, in that the Even if #46453 is fixed, I believe this issue will persist, because it would still be given a mangled Does that make sense? |
To illustrate, here is the rust
and the C++ unmangled static:
Iiuc, everything is perfectly correct, except we just have to not emit the |
I believe that a "principled" fix for #46453 would also automatically solve this issue. There's already code in the compiler that computes the real symbol name of all the functions and statics we emit. Using that code for the DWARF linkage_name would give the right linkage_name to all symbols, no_mangle ones included. That would set a linkage_name identical to the DWARF name, which would differ from C++, but I can't imagine that would cause harm? |
It should be fine, but in cases where the two are equal, it is fine to omit the linkage name, and this uses less space. This is what C compilers do. |
Regardless, that's just a small |
Visited during the wg-debugging triage meeting and this seems to have been resolved. @rylev is going to add a regression test. |
Add a test for issue rust-lang#33172 Adds a test confirming that rust-lang#33172 has been fixed. CDB has some surprising results as it looks like the supposedly unmangled static's symbol name is prefixed when it shouldn't be. r? ``@wesleywiser`` Closes rust-lang#33172
Add a test for issue rust-lang#33172 Adds a test confirming that rust-lang#33172 has been fixed. CDB has some surprising results as it looks like the supposedly unmangled static's symbol name is prefixed when it shouldn't be. r? `@wesleywiser` Closes rust-lang#33172
Add a test for issue rust-lang#33172 Adds a test confirming that rust-lang#33172 has been fixed. CDB has some surprising results as it looks like the supposedly unmangled static's symbol name is prefixed when it shouldn't be. r? ``@wesleywiser`` Closes rust-lang#33172
Add a test for issue rust-lang#33172 Adds a test confirming that rust-lang#33172 has been fixed. CDB has some surprising results as it looks like the supposedly unmangled static's symbol name is prefixed when it shouldn't be. r? ```@wesleywiser``` Closes rust-lang#33172
Repro
cargo new --bin static
cd static
add the following code to
main.rs
:cargo build
gdb target/debug/static
break static::main
r
whatis TEST
output:
type = <data variable, no debug info>
frown
When
TEST
is arepr(C)
struct, etc., this makes debugging extraordinarily difficult and laborious.Actual Use Case
I'm implementing the gdb debugger interface specified in
/usr/include/link.h
, which requires a single symbol,_r_debug
to be present in the_DYNAMIC
array.(The symbol is actually not exported either, roughly GLOBAL and in the
_DYNAMIC
array, which I get around by using a--dynamic-list
flag to the linker.)I don't get around the lack of debug symbols at all, which vexes me.
The text was updated successfully, but these errors were encountered: