Skip to content
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

demangled characters like { make debugging annoying #37646

Open
m4b opened this issue Nov 8, 2016 · 7 comments
Open

demangled characters like { make debugging annoying #37646

m4b opened this issue Nov 8, 2016 · 7 comments
Labels
A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@m4b
Copy link
Contributor

m4b commented Nov 8, 2016

(in gdb at least)

I think I complained to @tromey about this already and he proposed a solution, but I'm finding this more and more annoying when debugging that the '{' was chosen demangle to, for closures and impls, e.g.:

_ZN4clap4args3arg3Arg5short28_$u7b$$u7b$closure$u7d$$u7d$17h7c4595ce99cae01bE

demangles to:

clap::args::arg::Arg::short::{{closure}}::h7c4595ce99cae01b

as it breaks gdb's symbol auto-complete, it's hard to set a breakpoint, print the type, etc.

As I mentioned, I think @tromey suggested how to fix this with certain gdb expressions, or some work around, but I've already forgotten and maybe we should just make it demangle to something different ? 👼

@sfackler sfackler added the A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) label Nov 8, 2016
@tromey
Copy link
Contributor

tromey commented Nov 8, 2016

See also issue #32925. In some cases the linkage name in the debuginfo disagrees with the actual linkage name.

For impls I think a more comprehensive DWARF emission approach is needed. A few of us have a google doc on this topic but most of it hasn't been turned into bugs or an RFC or whatever yet.

I haven't given the naming of closures any thought. It's important, though, to separate what is put into the mangled name and what sort of information is emitted in the debuginfo.

For breakpoints, break file:line is the usual workaround. For printing types and whatnot, I'm not sure, I think it's just a pain.

@michaelwoerister
Copy link
Member

I think we could switch from {{closure}} to something like ___closure without breaking anything.

Is there a character that cannot be part of a valid Rust identifier but works with GDB's about-completion? $ or # maybe?

@m4b
Copy link
Contributor Author

m4b commented Nov 8, 2016

@tromey would know better than me.

Just to be clear, I like the brackets around closures, it's just they don't play nice. __ seems ugly to me, but will do if all else fails. I like idea of different char for bracket that plays nice. I wonder if | will work (also it evokes closures, but I digress)?

@mark-i-m
Copy link
Member

Can square brackets or angle brackets be used?

@tromey
Copy link
Contributor

tromey commented Dec 12, 2018

FWIW I now tend to think this is just a bug in gdb (and lldb) and should be filed there instead. (The bugs about things like { appearing in the linkage name, though, are rustc bugs.)

In gdb there are two ways to refer to items.

One is "linespecs", which is the syntax you use for break and some other commands like that. If linespecs don't support the {{closure}} syntax, then we can fix that. There's already a gdb bug open to remind me to look into this someday. Putting quotes around the name should already work.

The other way to refer to items is via expressions. It's normal in gdb to add a language extension to let one refer to unusual names this way -- for C this is done using single quotes. Perhaps that would work ok for rust as well.

For lldb I'm less sure about the linespec equivalent, but we do completely control the expression parser at least, and can make it work however we like.

@m4b
Copy link
Contributor Author

m4b commented Dec 13, 2018

This is still an issue and I’m still not able to print things or break on them with {{ with quotes, single quotes, without, etc.

Alternatively quoting demangled cpp names works as expected.

Since I filed this 2 years ago and no action has been taken to fix it in gdb can we just not emit these symbols in rustc ?

@pnkfelix
Copy link
Member

Discussed in wg-debugging triage

We propose that a community member should file a compiler MCP here, suggesting that we change the choice of symbol name to better accommodate this scenario.

@wesleywiser says that *-windows-msvc targets already adopt $ for similar reasons. (But they also say that users complain about symbols being ugly on windows, so those people might see $ as a step in the wrong direction here.)

@Nilstrieb Nilstrieb added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Apr 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

8 participants