Skip to content

Commit f65a52a

Browse files
authored
In statistics dump --summary, add back the targets section (#97004)
# Change #95075 accidentally removed the `targets` section from `statistics dump --summary`. Adding it back, by setting the default value to `true` in `StatisticsOptions::GetIncludeTargets()`. Updated the description for the options. Updated tests. # Verification Manually verified the fix by running `statist dump --summary` and comparing three versions of LLDB (in commit order): 1. Before #95075 2. After #95075 3. After this fix The expected result is that 1 and 3 give the same sections, while 2 is missing the `targets` section when in summary mode. The output (see Appendix) matches the expectation. # Appendix: Manual Test Output ## `statistics dump --summary` of 1 ``` (lldb) statistics dump --summary { "memory": { "strings": { "bytesTotal": 724992, "bytesUnused": 714547, "bytesUsed": 10445 } }, "targets": [ { "sourceMapDeduceCount": 0, "totalSharedLibraryEventHitCount": 0 } ], "totalDebugInfoByteSize": 597, "totalDebugInfoEnabled": 1, "totalDebugInfoIndexLoadedFromCache": 0, "totalDebugInfoIndexSavedToCache": 0, "totalDebugInfoIndexTime": 0.00070699999999999995, "totalDebugInfoParseTime": 2.5999999999999998e-05, "totalModuleCount": 1, "totalModuleCountHasDebugInfo": 1, "totalModuleCountWithIncompleteTypes": 0, "totalModuleCountWithVariableErrors": 0, "totalSymbolTableIndexTime": 0.000223, "totalSymbolTableParseTime": 0.00025799999999999998, "totalSymbolTableStripped": 0, "totalSymbolTablesLoadedFromCache": 0, "totalSymbolTablesSavedToCache": 0 } (lldb) ``` ## `statistics dump --summary` of 3 Should be the same as above. ``` (lldb) statistics dump --summary { "memory": { "strings": { "bytesTotal": 516096, "bytesUnused": 510353, "bytesUsed": 5743 } }, "targets": [ { "sourceMapDeduceCount": 0, "totalSharedLibraryEventHitCount": 0 } ], "totalDebugInfoByteSize": 597, "totalDebugInfoEnabled": 1, "totalDebugInfoIndexLoadedFromCache": 0, "totalDebugInfoIndexSavedToCache": 0, "totalDebugInfoIndexTime": 0.0022139999999999998, "totalDebugInfoParseTime": 0.00031700000000000001, "totalModuleCount": 1, "totalModuleCountHasDebugInfo": 1, "totalModuleCountWithIncompleteTypes": 0, "totalModuleCountWithVariableErrors": 0, "totalSymbolTableIndexTime": 0.0014499999999999999, "totalSymbolTableParseTime": 0.001848, "totalSymbolTableStripped": 0, "totalSymbolTablesLoadedFromCache": 0, "totalSymbolTablesSavedToCache": 0 } (lldb) ``` ## `statistics dump --summary` of 2 Should be missing the `targets` section. ``` (lldb) statistics dump --summary { "memory": { "strings": { "bytesTotal": 716800, "bytesUnused": 705887, "bytesUsed": 10913 } }, "totalDebugInfoByteSize": 597, "totalDebugInfoEnabled": 1, "totalDebugInfoIndexLoadedFromCache": 0, "totalDebugInfoIndexSavedToCache": 0, "totalDebugInfoIndexTime": 0.001374, "totalDebugInfoParseTime": 0.000174, "totalModuleCount": 1, "totalModuleCountHasDebugInfo": 1, "totalModuleCountWithIncompleteTypes": 0, "totalModuleCountWithVariableErrors": 0, "totalSymbolTableIndexTime": 0.00068300000000000001, "totalSymbolTableParseTime": 0.0010139999999999999, "totalSymbolTableStripped": 0, "totalSymbolTablesLoadedFromCache": 0, "totalSymbolTablesSavedToCache": 0 } (lldb) ``` Co-authored-by: royshi <[email protected]>
1 parent e17b17d commit f65a52a

File tree

3 files changed

+33
-11
lines changed

3 files changed

+33
-11
lines changed

lldb/include/lldb/Target/Statistics.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,8 @@ struct StatisticsOptions {
144144
bool GetIncludeTargets() const {
145145
if (m_include_targets.has_value())
146146
return m_include_targets.value();
147-
// `m_include_targets` has no value set, so return a value based on
148-
// `m_summary_only`.
149-
return !GetSummaryOnly();
147+
// Default to true in both default mode and summary mode.
148+
return true;
150149
}
151150

152151
void SetIncludeModules(bool value) { m_include_modules = value; }

lldb/source/Commands/Options.td

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1429,17 +1429,16 @@ let Command = "statistics dump" in {
14291429
Arg<"Boolean">,
14301430
Desc<"Dump statistics for the targets, including breakpoints, expression "
14311431
"evaluations, frame variables, etc. "
1432-
"Defaults to true, unless the '--summary' mode is enabled, in which case "
1433-
"this is turned off unless specified. "
1434-
"If both the '--targets' and the '--modules' options are 'true', a list "
1432+
"Defaults to true in both default mode and summary mode. "
1433+
"In default mode, if both '--targets' and '--modules' are 'true', a list "
14351434
"of module identifiers will be added to the 'targets' section.">;
14361435
def statistics_dump_modules: Option<"modules", "m">, Group<1>,
14371436
Arg<"Boolean">,
14381437
Desc<"Dump statistics for the modules, including time and size of various "
14391438
"aspects of the module and debug information, type system, path, etc. "
14401439
"Defaults to true, unless the '--summary' mode is enabled, in which case "
14411440
"this is turned off unless specified. "
1442-
"If both the '--targets' and the '--modules' options are 'true', a list "
1441+
"In default mode, if both '--targets' and '--modules' are 'true', a list "
14431442
"of module identifiers will be added to the 'targets' section.">;
14441443
def statistics_dump_transcript: Option<"transcript", "t">, Group<1>,
14451444
Arg<"Boolean">,

lldb/test/API/commands/statistics/basic/TestStats.py

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -702,6 +702,8 @@ def get_test_cases_for_sections_existence(self):
702702
"targets.moduleIdentifiers": True,
703703
"targets.breakpoints": True,
704704
"targets.expressionEvaluation": True,
705+
"targets.frameVariable": True,
706+
"targets.totalSharedLibraryEventHitCount": True,
705707
"modules": True,
706708
"transcript": True,
707709
},
@@ -713,10 +715,12 @@ def get_test_cases_for_sections_existence(self):
713715
},
714716
"expect": {
715717
"commands": False,
716-
"targets": False,
718+
"targets": True,
717719
"targets.moduleIdentifiers": False,
718720
"targets.breakpoints": False,
719721
"targets.expressionEvaluation": False,
722+
"targets.frameVariable": False,
723+
"targets.totalSharedLibraryEventHitCount": True,
720724
"modules": False,
721725
"transcript": False,
722726
},
@@ -733,11 +737,25 @@ def get_test_cases_for_sections_existence(self):
733737
"targets.moduleIdentifiers": False,
734738
"targets.breakpoints": False,
735739
"targets.expressionEvaluation": False,
740+
"targets.frameVariable": False,
736741
"targets.totalSharedLibraryEventHitCount": True,
737742
"modules": False,
738743
"transcript": False,
739744
},
740745
},
746+
{ # Summary mode without targets
747+
"command_options": " --summary --targets=false",
748+
"api_options": {
749+
"SetSummaryOnly": True,
750+
"SetIncludeTargets": False,
751+
},
752+
"expect": {
753+
"commands": False,
754+
"targets": False,
755+
"modules": False,
756+
"transcript": False,
757+
},
758+
},
741759
{ # Summary mode with modules
742760
"command_options": " --summary --modules=true",
743761
"api_options": {
@@ -746,15 +764,17 @@ def get_test_cases_for_sections_existence(self):
746764
},
747765
"expect": {
748766
"commands": False,
749-
"targets": False,
767+
"targets": True,
750768
"targets.moduleIdentifiers": False,
751769
"targets.breakpoints": False,
752770
"targets.expressionEvaluation": False,
771+
"targets.frameVariable": False,
772+
"targets.totalSharedLibraryEventHitCount": True,
753773
"modules": True,
754774
"transcript": False,
755775
},
756776
},
757-
{ # Everything mode but without modules and transcript
777+
{ # Default mode without modules and transcript
758778
"command_options": " --modules=false --transcript=false",
759779
"api_options": {
760780
"SetIncludeModules": False,
@@ -766,11 +786,13 @@ def get_test_cases_for_sections_existence(self):
766786
"targets.moduleIdentifiers": False,
767787
"targets.breakpoints": True,
768788
"targets.expressionEvaluation": True,
789+
"targets.frameVariable": True,
790+
"targets.totalSharedLibraryEventHitCount": True,
769791
"modules": False,
770792
"transcript": False,
771793
},
772794
},
773-
{ # Everything mode but without modules
795+
{ # Default mode without modules
774796
"command_options": " --modules=false",
775797
"api_options": {
776798
"SetIncludeModules": False,
@@ -781,6 +803,8 @@ def get_test_cases_for_sections_existence(self):
781803
"targets.moduleIdentifiers": False,
782804
"targets.breakpoints": True,
783805
"targets.expressionEvaluation": True,
806+
"targets.frameVariable": True,
807+
"targets.totalSharedLibraryEventHitCount": True,
784808
"modules": False,
785809
"transcript": True,
786810
},

0 commit comments

Comments
 (0)