[llvm-commits] [PATCH] Fix emission of debug data for global variables
James.Molloy at arm.com
Mon Sep 26 11:03:49 CDT 2011
With the new debug information changes, global variables aren't emitted properly to DWARF. The DW_AT_decl_file field is incorrect.
This stems from DwarfCompileUnit.cpp:138:
unsigned FileID = DD->GetOrCreateSourceID(G.getContext().getFilename(),
G.getContext() returns a NULL metadatum for the new metadata format (it used to return the CompileUnit). This causes a new SourceID to be generated for the "null" file, and the global is assigned this incorrect SourceID.
Attached is a testcase and proposed patch. It inlines getFilename() and getDirectory() into DIGlobalVariable, returning the original getContext().getFilename() for old versions of the debug info and getFieldAs<DIFile>(6).getFilename() for new versions.
I've implemented it this way so that the old code path is identical to before. I'm not sure if this is the most perfect fix - as getFieldAs<DIFile>(6) is valid (seemingly) for all debug info versions, perhaps the best idea would be to remove the conditionalization and always return getFieldAs<DIFile>(6).getFilename/getDirectory() ?
-- IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 4836 bytes
Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110926/97849988/attachment.obj
More information about the llvm-commits