[llvm] Added --report=debugger option to llvm-debuginfo-analyzer (PR #159853)
Carlos Alberto Enciso via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 29 08:38:47 PDT 2025
================
@@ -855,6 +861,87 @@ layout and given the number of matches.
-----------------------------
Total 26 8
+DEBUGGER VIEW
+"""""""""""""
+In debugger view, :program:`llvm-debuginfo-analyzer` prints out
+debug-info in a manner that emulates a debugger. For each function, each
+statement line is printed out in order, complete with the inlined
+callstack. This is useful to verify the specific orders of lines, as
+well as verifying inline callstacks.
+
+.. code-block:: none
+
+ llvm-debuginfo-analyzer --report=debugger
+ test-dwarf-clang.o test-dwarf-gcc.o
+
+ Logical View:
+ {File} test-dwarf-clang.o
+ {CompileUnit} test.cpp
+ {Function} foo
+ {Line} test.cpp:2 [foo]
+ {Line} test.cpp:3 [foo]
+ {Line} test.cpp:5 [foo]
+ {Line} test.cpp:6 [foo]
+ {Line} test.cpp:8 [foo]
+ {Line} test.cpp:9 [foo]
+
+ Logical View:
+ {File} test-dwarf-gcc.o
+ {CompileUnit} test.cpp
+ {Function} foo
+ {Line} test.cpp:2 [foo]
+ {Line} test.cpp:3 [foo]
+ {Line} test.cpp:5 [foo]
+ {Line} test.cpp:6 [foo]
+ {Line} test.cpp:8 [foo]
+ {Line} test.cpp:9 [foo]
+
+Optionally, by adding `--print=symbols`, live variables for each line is
+printed out.
+
+.. code-block:: none
+
+ llvm-debuginfo-analyzer --report=debugger
+ test-dwarf-clang.o
+
+ Logical View:
+ {File} test-dwarf-clang.o
+ {CompileUnit} test.cpp
+ {Function} foo
+ {Line} test.cpp:2 [foo]
+ {Parameter} ParamBool: bool : fbreg -21 (line 2)
+ {Parameter} ParamPtr: INTPTR : fbreg -16 (line 2)
+ {Parameter} ParamUnsigned: unsigned int : fbreg -20 (line 2)
+ {Line} test.cpp:3 [foo]
+ {Parameter} ParamBool: bool : fbreg -21 (line 2)
+ {Parameter} ParamPtr: INTPTR : fbreg -16 (line 2)
+ {Parameter} ParamUnsigned: unsigned int : fbreg -20 (line 2)
----------------
CarlosAlbertoEnciso wrote:
The format looks good, but I have some questions/suggestions.
```
Logical View:
{File} test-dwarf-clang.o
{CompileUnit} test.cpp
{Function} foo
{Line} test.cpp:2 [foo]
{Parameter} ParamBool: bool : fbreg -21 (line 2)
{Parameter} ParamPtr: INTPTR : fbreg -16 (line 2)
{Parameter} ParamUnsigned: unsigned int : fbreg -20 (line 2)
{Line} test.cpp:3 [foo]
{Parameter} ParamBool: bool : fbreg -21 (line 2)
{Parameter} ParamPtr: INTPTR : fbreg -16 (line 2)
{Parameter} ParamUnsigned: unsigned int : fbreg -20 (line 2)
```
As you are using indentation to describe the lexical scope, to keep consistency, the `{CompileUnit}` and `{Function}` should have different indentation as the `{File}`.
Also, any string (type name, symbol name) are enclosed by single quotes.
```
Logical View:
{File} 'test-dwarf-clang.o'
<-- blank line
{CompileUnit} 'test.cpp'
{Function} 'foo' -> 'int' <-- type
```
```
{Parameter} ParamBool: bool : fbreg -21 (line 2)
```
Maybe
```
{Parameter} 'ParamBool' -> 'bool' : fbreg -21 (line 2)
```
Any specific reasons for the symbol location to be on the same line as the symbol information.
For optimized code, you can have multiple location entries. That is why we print the locations in a different lexical scope:
```
{Variable} 'CONSTANT' -> 'const INTEGER'
{Coverage} 100.00%
{Location}
{Entry} ....
{Entry} ....
```
https://github.com/llvm/llvm-project/pull/159853
More information about the llvm-commits
mailing list