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

[dwarf] Emit all symbols as children of the given module #4746

Closed
wants to merge 1 commit into from

Conversation

ibuclaw
Copy link
Member

@ibuclaw ibuclaw commented Jun 16, 2015

This allows gdb to correctly build a scope map of all modules, which can be used in conjunction with the D-specific name lookup routines in my fork (works by looking up the current enclosed module, and then seeing if the given name is part of it).

Though perhaps this shouldn't be merged until gdb catches up.
Also, will need to emit struct/class/enum names in the same way.

@MartinNowak - FYI, this implements half of my propsosal (the other half is implementing DW_TAG_imported_declaration)

if (global.params.isWindows)
s->prettyIdent = fd->toPrettyChars(true);
else
s->prettyIdent = fd->toChars();
s->Sclass = SCglobal;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So you want to parse the human readable function type, e.g. void function() foo(int arg)? Sounds like it would require half of a D parser.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't fd->toChars print something like the original function declaration?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should just be the base identifier name, I've never seen strange things coming from gdc when using this, can check instantiated functions just to be sure though. Why do you think it would require half of a D parser to do it this way though?
If dmd is emitting children correctly in debug, gdb can build up a list of qualified names just by looking up the names of all parents, joining them together using the appropriate separator.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I confused this with FunctionType::toChars, FuncDeclaration::toChars uses Dsymbol::toChars and should be fine.

@MartinNowak
Copy link
Member

This breaks test/runnable/gdb14313.d, and maybe you can come up with some sort of gdb test already.

@ibuclaw
Copy link
Member Author

ibuclaw commented Jun 30, 2015

This breaks test/runnable/gdb14313.d, and maybe you can come up with some sort of gdb test already.

I think it's just a problem with the version of gdb the autotester has installed. Older gdb versions don't know how to correctly handle what I described.

@MartinNowak
Copy link
Member

Well, that would mean we break debugging for some user with that gdb version.

@ibuclaw
Copy link
Member Author

ibuclaw commented Jun 30, 2015

If you are using gdb-7.6 or 7.7, you'll have D2 demangling support, in which case getting the value by the full qualified name will match the demangled symbol and start working again.

I don't consider it unreasonable to break older versions of gdb. You for sure cannot use gdb-7.5 with gcc-4.9, for instance.

@MartinNowak
Copy link
Member

Well, gdb-7.4 is what you get on Ubuntu 12.04LTS.
http://packages.ubuntu.com/precise/gdb
It would be bad to break already working D debugging. Think of all the disappointed, let-me-tryout-d users.
Do you actually know what the problem is? The failing test already uses qualified but unmangled names (https://github.com/D-Programming-Language/dmd/blob/971b319e45c4e81825265fdb04363806a76bd4a0/test/runnable/gdb14313.d#L9).

@ibuclaw
Copy link
Member Author

ibuclaw commented Jul 10, 2015

Do you actually know what the problem is? The failing test already uses qualified but unmangled names

A mixture between two things:

  1. Anything old than gdb-7.8 does not demangle mangled symbols (the demangler has been broken in gdb for a long time)
  2. When building up names dynamically by reading dwarf, typenames_concat encounters a namespace-style tag, but knows nothing about how to handle language_d - so it falls back to using :: as a separator.

I think that this PR, and the other two should probably be merged together under one umbrella in a way, as it's looking like the latter two PRs are not trivial (this change just lacks any controls).

But I've still not heard back from anyone who knows better the dmd backend.

FYI gdb-7.10 has been frozen, so I'm going to start submitting a new batch of patches in to further push D support. If you're lucky, you won't notice anything when you switch to gdb-7.11. However, you'll be missing out on quite a lot. :)

@ibuclaw
Copy link
Member Author

ibuclaw commented Apr 6, 2017

My opinion is that the compiler should not be backwards compatible with older debuggers. But no one seems to think that here so in that case debug support will never improve for dmd, alienating most features I have trained gdb to do.

@ibuclaw ibuclaw closed this Apr 6, 2017
@ibuclaw ibuclaw deleted the dwarfmod branch April 6, 2017 08:37
@WalterBright
Copy link
Member

It's been a while since 2015. The backwards compatibility issue may no longer be relevant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants