Skip to content

[llvm-debuginfo-analyzer] Incorrect DW_AT_call_line/DW_AT_call_file. #115701

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

Conversation

CarlosAlbertoEnciso
Copy link
Member

The code dealing with DW_AT_call_line/DW_AT_call_file is in the wrong place. The correct functions were call, but with incorrect values:
DW_AT_call_line <-- Filename Index
DW_AT_call_file <-- Line number

The code dealing with DW_AT_call_line/DW_AT_call_file is in the
wrong place. The correct functions were call, but with incorrect
values:
  DW_AT_call_line <-- Filename Index
  DW_AT_call_file <-- Line number
@llvmbot
Copy link
Member

llvmbot commented Nov 11, 2024

@llvm/pr-subscribers-llvm-binary-utilities

@llvm/pr-subscribers-debuginfo

Author: Carlos Alberto Enciso (CarlosAlbertoEnciso)

Changes

The code dealing with DW_AT_call_line/DW_AT_call_file is in the wrong place. The correct functions were call, but with incorrect values:
DW_AT_call_line <-- Filename Index
DW_AT_call_file <-- Line number


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

3 Files Affected:

  • (modified) llvm/docs/CommandGuide/llvm-debuginfo-analyzer.rst (+1-1)
  • (modified) llvm/lib/DebugInfo/LogicalView/Readers/LVDWARFReader.cpp (+4-4)
  • (modified) llvm/test/tools/llvm-debuginfo-analyzer/DWARF/05-dwarf-incorrect-lexical-scope-variable.test (+1-1)
diff --git a/llvm/docs/CommandGuide/llvm-debuginfo-analyzer.rst b/llvm/docs/CommandGuide/llvm-debuginfo-analyzer.rst
index 5b3200a4b78235..60fa024db5e991 100644
--- a/llvm/docs/CommandGuide/llvm-debuginfo-analyzer.rst
+++ b/llvm/docs/CommandGuide/llvm-debuginfo-analyzer.rst
@@ -1742,7 +1742,7 @@ DWARF - Clang (Linux)
   [003]     3           {Variable} 'Var_1' -> 'int'
   [002]    11         {Function} extern not_inlined 'test' -> 'int'
   [003]    12           {Variable} 'A' -> 'int'
-  [003]    14           {InlinedFunction} inlined 'InlineFunction' -> 'int'
+  [003]    13           {InlinedFunction} inlined 'InlineFunction' -> 'int'
   [004]                   {Block}
   [005]                     {Variable} 'Var_2' -> 'int'
   [004]                   {Parameter} 'Param' -> 'int'
diff --git a/llvm/lib/DebugInfo/LogicalView/Readers/LVDWARFReader.cpp b/llvm/lib/DebugInfo/LogicalView/Readers/LVDWARFReader.cpp
index 1c523c01314977..ce1d5619e1fa80 100644
--- a/llvm/lib/DebugInfo/LogicalView/Readers/LVDWARFReader.cpp
+++ b/llvm/lib/DebugInfo/LogicalView/Readers/LVDWARFReader.cpp
@@ -304,12 +304,12 @@ void LVDWARFReader::processOneAttribute(const DWARFDie &Die,
     CurrentElement->setBitSize(*FormValue.getAsUnsignedConstant());
     break;
   case dwarf::DW_AT_call_file:
-    CurrentElement->setCallFilenameIndex(GetAsUnsignedConstant());
+    CurrentElement->setCallFilenameIndex(IncrementFileIndex
+                                             ? GetAsUnsignedConstant() + 1
+                                             : GetAsUnsignedConstant());
     break;
   case dwarf::DW_AT_call_line:
-    CurrentElement->setCallLineNumber(IncrementFileIndex
-                                          ? GetAsUnsignedConstant() + 1
-                                          : GetAsUnsignedConstant());
+    CurrentElement->setCallLineNumber(GetAsUnsignedConstant());
     break;
   case dwarf::DW_AT_comp_dir:
     CompileUnit->setCompilationDirectory(dwarf::toStringRef(FormValue));
diff --git a/llvm/test/tools/llvm-debuginfo-analyzer/DWARF/05-dwarf-incorrect-lexical-scope-variable.test b/llvm/test/tools/llvm-debuginfo-analyzer/DWARF/05-dwarf-incorrect-lexical-scope-variable.test
index 5453a46fb542dd..e1ac7588f1d8c4 100644
--- a/llvm/test/tools/llvm-debuginfo-analyzer/DWARF/05-dwarf-incorrect-lexical-scope-variable.test
+++ b/llvm/test/tools/llvm-debuginfo-analyzer/DWARF/05-dwarf-incorrect-lexical-scope-variable.test
@@ -50,7 +50,7 @@
 ; ONE-NEXT: [003]     3           {Variable} 'Var_1' -> 'int'
 ; ONE-NEXT: [002]    11         {Function} extern not_inlined 'test' -> 'int'
 ; ONE-NEXT: [003]    12           {Variable} 'A' -> 'int'
-; ONE-NEXT: [003]    14           {InlinedFunction} not_inlined 'InlineFunction' -> 'int'
+; ONE-NEXT: [003]    13           {InlinedFunction} not_inlined 'InlineFunction' -> 'int'
 ; ONE-NEXT: [004]                   {Block}
 ; ONE-NEXT: [005]                     {Variable} 'Var_2' -> 'int'
 ; ONE-NEXT: [004]                   {Parameter} 'Param' -> 'int'

Copy link
Contributor

@OCHyams OCHyams left a comment

Choose a reason for hiding this comment

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

LGTM

@CarlosAlbertoEnciso
Copy link
Member Author

@OCHyams Many thanks for your review.

@CarlosAlbertoEnciso CarlosAlbertoEnciso merged commit 5e7662e into llvm:main Nov 11, 2024
11 of 13 checks passed
@CarlosAlbertoEnciso CarlosAlbertoEnciso deleted the mixed-call-file-call-line branch November 11, 2024 14:36
Groverkss pushed a commit to iree-org/llvm-project that referenced this pull request Nov 15, 2024
…lvm#115701)

The code dealing with DW_AT_call_line/DW_AT_call_file is in the wrong
place. The correct functions were call, but with incorrect values:
  DW_AT_call_line <-- Filename Index
  DW_AT_call_file <-- Line number
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.

3 participants