-
Notifications
You must be signed in to change notification settings - Fork 15.1k
Added --report=debugger option to llvm-debuginfo-analyzer #159853
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
base: main
Are you sure you want to change the base?
Changes from all commits
a85243d
25793b4
76efd65
8b0d172
0752ef8
6a0edef
bf7848e
5d0f679
ceee148
dbc8d36
431ec62
936e9f6
6ad0daa
dbc62cd
0f5a6a9
9f2beca
cf5c3ef
efc481e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -391,6 +391,8 @@ to make the output easier to understand. | |||||
| .. code-block:: text | ||||||
|
|
||||||
| =children: Elements and children are displayed in a tree format. | ||||||
| =debugger: Lines, and optionally variables and instructions are | ||||||
| displayed in a way to simulate stepping through a debugger. | ||||||
| =list: Elements are displayed in a tabular format. | ||||||
| =parents: Elements and parents are displayed in a tree format. | ||||||
| =view: Elements, parents and children are displayed in a tree format. | ||||||
|
|
@@ -410,6 +412,10 @@ child (level 1). | |||||
| The **children** layout includes the elements that match any given | ||||||
| criteria (:option:`--select`) or (:option:`--compare`) and its children. | ||||||
|
|
||||||
| The **debugger** layout prints each statement line in order and variables | ||||||
| live at each line (if `--print=symbols` given), as well as instructions | ||||||
| (if `--print=instructions` given). | ||||||
|
|
||||||
| The **parents** layout includes the elements that match any given | ||||||
| criteria (:option:`--select`) or (:option:`--compare`) and its parents. | ||||||
|
|
||||||
|
|
@@ -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 | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For consistency with the another general printing layouts, include: |
||||||
|
|
||||||
| 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 | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| 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) | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The format looks good, but I have some questions/suggestions. As you are using indentation to describe the lexical scope, to keep consistency, the 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: |
||||||
| {Line} test.cpp:5 [foo] | ||||||
| {Parameter} ParamBool: bool : fbreg -21 (line 2) | ||||||
| {Parameter} ParamPtr: INTPTR : fbreg -16 (line 2) | ||||||
| {Parameter} ParamUnsigned: unsigned int : fbreg -20 (line 2) | ||||||
| {Variable} CONSTANT: const INTEGER : fbreg -28 (line 5) | ||||||
| {Line} test.cpp:6 [foo] | ||||||
| {Parameter} ParamBool: bool : fbreg -21 (line 2) | ||||||
| {Parameter} ParamPtr: INTPTR : fbreg -16 (line 2) | ||||||
| {Parameter} ParamUnsigned: unsigned int : fbreg -20 (line 2) | ||||||
| {Variable} CONSTANT: const INTEGER : fbreg -28 (line 5) | ||||||
| {Line} test.cpp:8 [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:9 [foo] | ||||||
| {Parameter} ParamBool: bool : fbreg -21 (line 2) | ||||||
| {Parameter} ParamPtr: INTPTR : fbreg -16 (line 2) | ||||||
| {Parameter} ParamUnsigned: unsigned int : fbreg -20 (line 2) | ||||||
|
|
||||||
| Optionally, `--print=instructions`, the lines are interleaved with the | ||||||
| instructions. Combined with the output of `--print=symbols`, tests can | ||||||
| verify specific expressions for live variables. | ||||||
|
|
||||||
| Additionally, `--attribute` can be used to include things such as | ||||||
| offsets and scope levels for {Line} and {Instruction}. | ||||||
|
|
||||||
| COMPARISON MODE | ||||||
| ^^^^^^^^^^^^^^^ | ||||||
| In this mode :program:`llvm-debuginfo-analyzer` compares logical views | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -648,6 +648,19 @@ void LVLocation::print(LVLocations *Locations, raw_ostream &OS, bool Full) { | |
| Location->print(OS, Full); | ||
| } | ||
|
|
||
| void LVLocationSymbol::printLocations(raw_ostream &OS) const { | ||
| if (Entries) { | ||
| bool CodeViewLocation = getParentSymbol()->getHasCodeViewLocation(); | ||
| std::string Leading; | ||
| for (LVOperation *Operation : *Entries) { | ||
| OS << Leading | ||
| << (CodeViewLocation ? Operation->getOperandsCodeViewInfo() | ||
| : Operation->getOperandsDWARFInfo()); | ||
| Leading = ", "; | ||
| } | ||
|
Comment on lines
+654
to
+660
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: I see that this code was moved from this original location, but perhaps we could take the chance to adopt |
||
| } | ||
| } | ||
|
|
||
| void LVLocationSymbol::printExtra(raw_ostream &OS, bool Full) const { | ||
| OS << "{Location}"; | ||
| if (getIsCallSite()) | ||
|
|
@@ -657,18 +670,21 @@ void LVLocationSymbol::printExtra(raw_ostream &OS, bool Full) const { | |
|
|
||
| // Print location entries. | ||
| if (Full && Entries) { | ||
| bool CodeViewLocation = getParentSymbol()->getHasCodeViewLocation(); | ||
| std::stringstream Stream; | ||
| std::string Leading; | ||
| for (LVOperation *Operation : *Entries) { | ||
| Stream << Leading | ||
| << (CodeViewLocation ? Operation->getOperandsCodeViewInfo() | ||
| : Operation->getOperandsDWARFInfo()); | ||
| Leading = ", "; | ||
| } | ||
| std::string Str; | ||
| raw_string_ostream Stream(Str); | ||
| printLocations(Stream); | ||
| printAttributes(OS, Full, "{Entry} ", const_cast<LVLocationSymbol *>(this), | ||
| StringRef(Stream.str()), | ||
| /*UseQuotes=*/false, | ||
| /*PrintRef=*/false); | ||
| } | ||
| } | ||
|
|
||
| void LVLocationSymbol::printDebugger(raw_ostream &OS, LVLevel Indent) const { | ||
| LVSymbol *Sym = getParentSymbol(); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For consistency: Instead of |
||
| OS << indentAsString(Indent) << formattedKind(Sym->kind()); | ||
| OS << " " << Sym->getName() << ": " << Sym->getType()->getName() << " : "; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IIRC, |
||
| printLocations(OS); | ||
| OS << " (line " << Sym->getLineNumber() << ")"; | ||
| OS << "\n"; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -132,6 +132,14 @@ void LVOptions::resolveDependencies() { | |
| setPrintWarnings(); | ||
| } | ||
|
|
||
| if (getReportDebugger()) { | ||
| // Must include at least the lines, otherwise there's nothing to print | ||
| setPrintLines(); | ||
| // Printing symbols in debugger report requires the symbol ranges | ||
| if (getPrintSymbols()) | ||
| setAttributeRange(); | ||
| } | ||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just a very minor points. Missing full stops in the comments. |
||
| // '--warning=all' settings. | ||
| if (getWarningAll()) { | ||
| setWarningCoverages(); | ||
|
|
@@ -186,6 +194,7 @@ void LVOptions::resolveDependencies() { | |
| // '--reports=all' settings. | ||
| if (getReportAll()) { | ||
| setReportChildren(); | ||
| setReportDebugger(); | ||
| setReportList(); | ||
| setReportParents(); | ||
| setReportView(); | ||
|
|
@@ -202,7 +211,7 @@ void LVOptions::resolveDependencies() { | |
| setReportAnyView(); | ||
|
|
||
| // The report will include: List or Parents or Children. | ||
| if (getReportList() || getReportAnyView()) | ||
| if (getReportList() || getReportAnyView() || getReportDebugger()) | ||
| setReportExecute(); | ||
|
|
||
| // If a view or element comparison has been requested, the following options | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For consistency with other
View layouts, theDebugger Viewshould support additional attributes such as--attribute=offset,level.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added support for them. In fact the offsets and levels are controlled by the same mechanism for printing them as the other options.