This is an archive of the discontinued LLVM Phabricator instance.

Anonymous namespaces are missing import DW_TAG_imported_module.
AbandonedPublic

Authored by kromanova on Feb 24 2015, 9:22 PM.

Details

Reviewers
dblaikie
echristo
Summary

DW_TAG_imported_module is missing from the compile unit's root scope. Without this tag, anonymous namespace is not imported into the module scope.

Consider the following testcase. Lack of DW_TAG_imported_module prevents our debugger from displaying the value of ‘a’.
It looks like GDB imports the anonymous namespace automatically, so it does not have this problem.
If necessary, I could add an option to control generation of DW_TAG_imported_module for anonymous namespaces.

#include <stdio.h>

namespace
{

int a = 5;

}

int main()
{

printf("%d\n", a);

return 0;

}

Diff Detail

Event Timeline

kromanova updated this revision to Diff 20644.Feb 24 2015, 9:22 PM
kromanova retitled this revision from to Anonymous namespaces are missing import DW_TAG_imported_module..
kromanova updated this object.
kromanova edited the test plan for this revision. (Show Details)
kromanova added reviewers: ygao, probinson.
kromanova updated this object.Feb 24 2015, 9:34 PM
kromanova updated this object.Feb 25 2015, 12:00 PM
kromanova updated this revision to Diff 20693.Feb 25 2015, 12:27 PM

cleaned up the testcase a little.

kromanova edited reviewers, added: echristo, dblaikie; removed: probinson, ygao.Feb 25 2015, 12:31 PM
kromanova added a subscriber: Unknown Object (MLST).
ygao added a subscriber: ygao.Feb 25 2015, 1:17 PM

Dummy comment to make the patch visible on the mailing list.

dblaikie edited edge metadata.Feb 25 2015, 1:21 PM

(usually it works better to just trash the code review & create a new one
if you forget to add the mailing list/cc's when creating it - because it'll
never send the intro mail again, but anyway)

I'm not sure if this is really a bug in the debug info - seems like it
might be reasonably treated as a bug in the debugger?

Our debugger guys get pretty pedantic about interpreting the DWARF spec. I know GDB will auto-import info from an anonymous namespace, but:

  • the size cost here is really minimal (what, 5 or 6 bytes per anonymous namespace scope);
  • they claimed that deciding whether to skip the namespace based on the name would be a problem for them;
  • the compiler implementation is obviously trivial;

so I didn't really feel motivated to argue the point.

David, I will re-post the review to LLVM-dev and abandon this one, if it's OK with you. You are right, it didn't reach LLVM-dev.
BTW, do you know how could I abandon Phabricator review?

kromanova abandoned this revision.Feb 25 2015, 7:46 PM

Hi,

Our debugger guys argument is that the debugger just follows the rules laid out by the debug information. If there is no import, the debugger will not import it. There is nothing in the DWARF spec that clearly states an empty name is a magic import.

Personally I don't have a strong opinion about this issue. It was very simple to do in the compiler and it hardly increased size of the DWARF info. Apparently, it was much tougher to fix this in the debugger.

If it is such a nuisance, maybe I could add an option and set it to false to all of the platforms, except PS4?
Or I could follow Fred's suggestion and add DW_AT_artificial attribute?

However I don’t think the patch will break any debugger (although that might be worth testing).

I could manually test GDB.
Fred, which other debuggers do you suggest to test to make sure that this patch didn't break them? Are there any existing debugger tests in LLVM?

Thanks!
Katya