Skip to content

Conversation

royitaqi
Copy link
Contributor

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 [lldb] Add/change options in statistics dump to control what sections are dumped #95075
  2. After [lldb] Add/change options in statistics dump to control what sections are dumped #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)

Summary:

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:
@royitaqi royitaqi requested a review from JDevlieghere as a code owner June 28, 2024 05:18
@llvmbot llvmbot added the lldb label Jun 28, 2024
@llvmbot
Copy link
Member

llvmbot commented Jun 28, 2024

@llvm/pr-subscribers-lldb

Author: None (royitaqi)

Changes

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 [lldb] Add/change options in statistics dump to control what sections are dumped #95075
  2. After [lldb] Add/change options in statistics dump to control what sections are dumped #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)

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

3 Files Affected:

  • (modified) lldb/include/lldb/Target/Statistics.h (+2-3)
  • (modified) lldb/source/Commands/Options.td (+3-4)
  • (modified) lldb/test/API/commands/statistics/basic/TestStats.py (+28-4)
diff --git a/lldb/include/lldb/Target/Statistics.h b/lldb/include/lldb/Target/Statistics.h
index 122eb3ddd711f..35bd7f8a66e05 100644
--- a/lldb/include/lldb/Target/Statistics.h
+++ b/lldb/include/lldb/Target/Statistics.h
@@ -144,9 +144,8 @@ struct StatisticsOptions {
   bool GetIncludeTargets() const {
     if (m_include_targets.has_value())
       return m_include_targets.value();
-    // `m_include_targets` has no value set, so return a value based on
-    // `m_summary_only`.
-    return !GetSummaryOnly();
+    // Default to true in both default mode and summary mode.
+    return true;
   }
 
   void SetIncludeModules(bool value) { m_include_modules = value; }
diff --git a/lldb/source/Commands/Options.td b/lldb/source/Commands/Options.td
index ba256e5ab917a..fa8af7cb3d762 100644
--- a/lldb/source/Commands/Options.td
+++ b/lldb/source/Commands/Options.td
@@ -1429,9 +1429,8 @@ let Command = "statistics dump" in {
     Arg<"Boolean">,
     Desc<"Dump statistics for the targets, including breakpoints, expression "
     "evaluations, frame variables, etc. "
-    "Defaults to true, unless the '--summary' mode is enabled, in which case "
-    "this is turned off unless specified. "
-    "If both the '--targets' and the '--modules' options are 'true', a list "
+    "Defaults to true in both default mode and summary mode. "
+    "In default mode, if both '--targets' and '--modules' are 'true', a list "
     "of module identifiers will be added to the 'targets' section.">;
   def statistics_dump_modules: Option<"modules", "m">, Group<1>,
     Arg<"Boolean">,
@@ -1439,7 +1438,7 @@ let Command = "statistics dump" in {
     "aspects of the module and debug information, type system, path, etc. "
     "Defaults to true, unless the '--summary' mode is enabled, in which case "
     "this is turned off unless specified. "
-    "If both the '--targets' and the '--modules' options are 'true', a list "
+    "In default mode, if both '--targets' and '--modules' are 'true', a list "
     "of module identifiers will be added to the 'targets' section.">;
   def statistics_dump_transcript: Option<"transcript", "t">, Group<1>,
     Arg<"Boolean">,
diff --git a/lldb/test/API/commands/statistics/basic/TestStats.py b/lldb/test/API/commands/statistics/basic/TestStats.py
index 136c44e17c645..a8ac60090a760 100644
--- a/lldb/test/API/commands/statistics/basic/TestStats.py
+++ b/lldb/test/API/commands/statistics/basic/TestStats.py
@@ -702,6 +702,8 @@ def get_test_cases_for_sections_existence(self):
                     "targets.moduleIdentifiers": True,
                     "targets.breakpoints": True,
                     "targets.expressionEvaluation": True,
+                    "targets.frameVariable": True,
+                    "targets.totalSharedLibraryEventHitCount": True,
                     "modules": True,
                     "transcript": True,
                 },
@@ -713,10 +715,12 @@ def get_test_cases_for_sections_existence(self):
                 },
                 "expect": {
                     "commands": False,
-                    "targets": False,
+                    "targets": True,
                     "targets.moduleIdentifiers": False,
                     "targets.breakpoints": False,
                     "targets.expressionEvaluation": False,
+                    "targets.frameVariable": False,
+                    "targets.totalSharedLibraryEventHitCount": True,
                     "modules": False,
                     "transcript": False,
                 },
@@ -733,11 +737,25 @@ def get_test_cases_for_sections_existence(self):
                     "targets.moduleIdentifiers": False,
                     "targets.breakpoints": False,
                     "targets.expressionEvaluation": False,
+                    "targets.frameVariable": False,
                     "targets.totalSharedLibraryEventHitCount": True,
                     "modules": False,
                     "transcript": False,
                 },
             },
+            {  # Summary mode without targets
+                "command_options": " --summary --targets=false",
+                "api_options": {
+                    "SetSummaryOnly": True,
+                    "SetIncludeTargets": False,
+                },
+                "expect": {
+                    "commands": False,
+                    "targets": False,
+                    "modules": False,
+                    "transcript": False,
+                },
+            },
             {  # Summary mode with modules
                 "command_options": " --summary --modules=true",
                 "api_options": {
@@ -746,15 +764,17 @@ def get_test_cases_for_sections_existence(self):
                 },
                 "expect": {
                     "commands": False,
-                    "targets": False,
+                    "targets": True,
                     "targets.moduleIdentifiers": False,
                     "targets.breakpoints": False,
                     "targets.expressionEvaluation": False,
+                    "targets.frameVariable": False,
+                    "targets.totalSharedLibraryEventHitCount": True,
                     "modules": True,
                     "transcript": False,
                 },
             },
-            {  # Everything mode but without modules and transcript
+            {  # Default mode without modules and transcript
                 "command_options": " --modules=false --transcript=false",
                 "api_options": {
                     "SetIncludeModules": False,
@@ -766,11 +786,13 @@ def get_test_cases_for_sections_existence(self):
                     "targets.moduleIdentifiers": False,
                     "targets.breakpoints": True,
                     "targets.expressionEvaluation": True,
+                    "targets.frameVariable": True,
+                    "targets.totalSharedLibraryEventHitCount": True,
                     "modules": False,
                     "transcript": False,
                 },
             },
-            {  # Everything mode but without modules
+            {  # Default mode without modules
                 "command_options": " --modules=false",
                 "api_options": {
                     "SetIncludeModules": False,
@@ -781,6 +803,8 @@ def get_test_cases_for_sections_existence(self):
                     "targets.moduleIdentifiers": False,
                     "targets.breakpoints": True,
                     "targets.expressionEvaluation": True,
+                    "targets.frameVariable": True,
+                    "targets.totalSharedLibraryEventHitCount": True,
                     "modules": False,
                     "transcript": True,
                 },

Copy link
Contributor

@kusmour kusmour left a comment

Choose a reason for hiding this comment

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

LGTM

@zhyty zhyty self-requested a review June 28, 2024 16:10
@kusmour kusmour merged commit f65a52a into llvm:main Jun 28, 2024
cpiaseque pushed a commit to cpiaseque/llvm-project that referenced this pull request Jul 3, 2024
…97004)

# Change

llvm#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 llvm#95075
2. After llvm#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 <royshi@meta.com>
kevinfrei pushed a commit to kevinfrei/llvm that referenced this pull request Sep 25, 2024
Summary:
This is to temporarily fix the test `TestVSCode`, before [PR llvm#97004](llvm#97004) can be upstreamed and pulled into `toolchain/llvm-sand/main`.

The bug was that a previous PR ([llvm#95075](llvm#95075)) accidentally removed the `targets` section from `statistics dump --summary`, which this test relies on.

The fix in [PR llvm#97004](llvm#97004) reverts that behavior, while the temporary fix in this diff just explicitly adds an option to make sure that the `targets` section is generated.

This diff *can (but doesn't have to)* be reverted after [PR llvm#97004](llvm#97004) has been merged and pulled into `llvm-sand`.

Test Plan: Manually tested after applying this diff on top of the release candidate that I'm working on.

Reviewers: jeffreytan, #lldb_team

Subscribers: gclayton, #lldb_team

Differential Revision: https://phabricator.intern.facebook.com/D59139567
@royitaqi royitaqi deleted the recover_statistics_summary_mode_behavior branch October 24, 2024 21:49
imyixinw pushed a commit to imyixinw/llvm-project that referenced this pull request Sep 5, 2025
Summary:
This is to temporarily fix the test `TestVSCode`, before [PR llvm#97004](llvm#97004) can be upstreamed and pulled into `toolchain/llvm-sand/main`.

The bug was that a previous PR ([llvm#95075](llvm#95075)) accidentally removed the `targets` section from `statistics dump --summary`, which this test relies on.

The fix in [PR llvm#97004](llvm#97004) reverts that behavior, while the temporary fix in this diff just explicitly adds an option to make sure that the `targets` section is generated.

This diff *can (but doesn't have to)* be reverted after [PR llvm#97004](llvm#97004) has been merged and pulled into `llvm-sand`.

Test Plan: Manually tested after applying this diff on top of the release candidate that I'm working on.

Reviewers: jeffreytan, #lldb_team

Subscribers: gclayton, #lldb_team

Differential Revision: https://phabricator.intern.facebook.com/D59139567
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants