Skip to content

[DebugInfo] Use human-friendly printing for DWARF column attributes #71062

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

Merged
merged 3 commits into from
Nov 4, 2023

Conversation

jryans
Copy link
Member

@jryans jryans commented Nov 2, 2023

This prints DWARF attributes that describes source columns as base 10 integers for easier comprehension (via llvm-dwarfdump and similar tools) and matches the behaviour for source line attributes.

This prints DWARF attributes that describes source columns as base 10 integers
for easier comprehension (via `llvm-dwarfdump` and similar tools) and matches
the behaviour for source line attributes.
@llvmbot
Copy link
Member

llvmbot commented Nov 2, 2023

@llvm/pr-subscribers-debuginfo

Author: J. Ryan Stinnett (jryans)

Changes

This prints DWARF attributes that describes source columns as base 10 integers for easier comprehension (via llvm-dwarfdump and similar tools) and matches the behaviour for source line attributes.


Full diff: https://github.com/llvm/llvm-project/pull/71062.diff

1 Files Affected:

  • (modified) llvm/lib/DebugInfo/DWARF/DWARFDie.cpp (+2-1)
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
index 7af7ed8be7b4aff..fcedef8db82185c 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
@@ -147,7 +147,8 @@ static void dumpAttribute(raw_ostream &OS, const DWARFDie &Die,
 
   if (!Name.empty())
     WithColor(OS, Color) << Name;
-  else if (Attr == DW_AT_decl_line || Attr == DW_AT_call_line) {
+  else if (Attr == DW_AT_decl_line || Attr == DW_AT_decl_column ||
+           Attr == DW_AT_call_line || Attr == DW_AT_call_column) {
     if (std::optional<uint64_t> Val = FormValue.getAsUnsignedConstant())
       OS << *Val;
     else

@OCHyams
Copy link
Contributor

OCHyams commented Nov 2, 2023

LGTM. It looks like the test coverage for DW_AT_call_line printing is incidental (i.e., testing other things, such as in test/tools/llvm-dwarfdump/X86/verify_attr_file_indexes_no_files.yaml). Even so, if its easy to hijack or copy a test touching DW_AT_call_line so that DW_AT_{decl/call}_column output can be tested too then we should probably do so.

@jryans
Copy link
Member Author

jryans commented Nov 2, 2023

Thanks for taking a look @OCHyams!

I have updated existing tests to match the new output and also added a new test specifically for checking this kind of source coordinate output.

Copy link
Collaborator

@adrian-prantl adrian-prantl left a comment

Choose a reason for hiding this comment

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

I'm sure this is going to break somebody's perl script, but I think that's a very reasonable change!

@jryans jryans merged commit d5e33cc into llvm:main Nov 4, 2023
@jryans jryans deleted the dwarf-output-tweaks branch November 4, 2023 17:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants