Skip to content

Default transcript dumping in "statistics dump" to false #145436

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

qxy11
Copy link
Contributor

@qxy11 qxy11 commented Jun 23, 2025

Summary

Currently, if the setting interpreter.save-transcript is enabled, whenever we call "statistics dump", it'll default to reporting a huge list of transcripts which can be a bit noisy. This is because the current check GetIncludeTranscript returns !GetSummaryOnly() by default if no specific transcript-setting option is given in the statistics dump command (ie. statistics dump --transcripts=false or statistics dump --transcripts=true). Then when interpreter.save-transcript is enabled, this saves a list of transcripts, and the transcript list ends up getting logged by default.

These changes default the option to log transcripts in the statistics dump command to "false". This can still be enabled via the --transcripts option if users want to see a transcript. Since interpreter.save-transcript is false by default, the main delta is that if interpreter.save-transcript is true and summary mode is false, we now disable saving the transcript.

This also adds a warning to 'statistics dump --transcript=true' when
interpreter.save-transcript is disabled, which should help users understand
why transcript data is empty.

Testing

Manual testing

Tested with settings set interpreter.save-transcript true enabled at startup on a toy hello-world program:

(lldb) settings set interpreter.save-transcript true
(lldb) target create "/home/qxy11/hello-world/a.out"
Current executable set to '/home/qxy11/hello-world/a.out' (x86_64).
(lldb) statistics dump
{
  /* no transcript */
}
(lldb) statistics dump --transcript=true
{
"transcript": [
    {
      "command": "statistics dump",
      "commandArguments": "",
      "commandName": "statistics dump",
      "durationInSeconds": 0.0019650000000000002,
      "error": "",
      "output": "{...
    },
    {
      "command": "statistics dump --transcript=true",
      "commandArguments": "--transcript=true",
      "commandName": "statistics dump",
      "timestampInEpochSeconds": 1750720021
    }
  ]
}

Without settings set interpreter.save-transcript true:

(lldb) target create "/home/qxy11/hello-world/a.out"
Current executable set to '/home/qxy11/hello-world/a.out' (x86_64).
(lldb) statistics dump
{
  /* no transcript */
}
(lldb) statistics dump --transcript=true
{
  /* no transcript */
}
warning: transcript requested but none was saved. Enable with 'settings set interpreter.save-transcript true'

Unit tests

Changed unit tests to account for new expected default behavior to false, and added a couple new tests around expected behavior with --transcript=true.

lldb-dotest -p TestStats ~/llvm-sand/external/llvm-project/lldb/test/API/commands/statistics/basic/

@qxy11 qxy11 requested a review from JDevlieghere as a code owner June 23, 2025 23:38
@llvmbot llvmbot added the lldb label Jun 23, 2025
@llvmbot
Copy link
Member

llvmbot commented Jun 23, 2025

@llvm/pr-subscribers-lldb

Author: None (qxy11)

Changes

Summary

Currently, if the setting interpreter.save-transcript is enabled, whenever we call "statistics dump", it'll default to reporting a huge list of transcripts which can be a bit noisy. This is because the current check GetIncludeTranscript returns !GetSummaryOnly() by default if no specific transcript-setting option is given in the statistics dump command (ie. statistics dump --transcripts=false or statistics dump --transcripts=true). Then when interpreter.save-transcript is enabled, this saves a list of transcripts, and the transcript list ends up getting logged by default.

These changes default the option to log transcripts in the statistics dump command to "false". This can still be enabled via the --transcripts option if users want to see a transcript. Since interpreter.save-transcript is false by default, the main delta is that if interpreter.save-transcript is true and summary mode is false, we now disable saving the transcript.

Testing

Manual testing

Tested with settings set interpreter.save-transcript true enabled at startup on a toy hello-world program:

(lldb) target create "/home/qxy11/hello-world/a.out"
Current executable set to '/home/qxy11/hello-world/a.out' (x86_64).
(lldb) statistics dump
{
  /* no transcript */
}
(lldb) statistics dump --transcript=true
"transcript": [
    {
      "command": "statistics dump",
      "commandArguments": "",
      "commandName": "statistics dump",
      "durationInSeconds": 0.0019650000000000002,
      "error": "",
      "output": "{...
    },
    {
      "command": "statistics dump --transcript=true",
      "commandArguments": "--transcript=true",
      "commandName": "statistics dump",
      "timestampInEpochSeconds": 1750720021
    }
  ]

Unit tests

Changed unit tests to account for new expected default behavior to false, and added a couple new tests around expected behavior with --transcript=true.

lldb-dotest -p TestStats ~/llvm-sand/external/llvm-project/lldb/test/API/commands/statistics/basic/

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

4 Files Affected:

  • (modified) lldb/include/lldb/API/SBStatisticsOptions.h (+1-2)
  • (modified) lldb/include/lldb/Target/Statistics.h (+2-3)
  • (modified) lldb/source/Commands/Options.td (+9-7)
  • (modified) lldb/test/API/commands/statistics/basic/TestStats.py (+36-1)
diff --git a/lldb/include/lldb/API/SBStatisticsOptions.h b/lldb/include/lldb/API/SBStatisticsOptions.h
index 74bea03eff9c9..bfff9dc926432 100644
--- a/lldb/include/lldb/API/SBStatisticsOptions.h
+++ b/lldb/include/lldb/API/SBStatisticsOptions.h
@@ -57,8 +57,7 @@ class LLDB_API SBStatisticsOptions {
   /// a JSON array with all commands the user and/or scripts executed during a
   /// debug session.
   ///
-  /// Defaults to true, unless the `SummaryOnly` mode is enabled, in which case
-  /// this is turned off unless specified.
+  /// Defaults to false.
   void SetIncludeTranscript(bool b);
   bool GetIncludeTranscript() const;
 
diff --git a/lldb/include/lldb/Target/Statistics.h b/lldb/include/lldb/Target/Statistics.h
index 42f03798c219e..68194cf216a1a 100644
--- a/lldb/include/lldb/Target/Statistics.h
+++ b/lldb/include/lldb/Target/Statistics.h
@@ -193,9 +193,8 @@ struct StatisticsOptions {
   bool GetIncludeTranscript() const {
     if (m_include_transcript.has_value())
       return m_include_transcript.value();
-    // `m_include_transcript` has no value set, so return a value based on
-    // `m_summary_only`.
-    return !GetSummaryOnly();
+    // Default to false in both default mode and summary mode.
+    return false;
   }
 
   void SetIncludePlugins(bool value) { m_include_plugins = value; }
diff --git a/lldb/source/Commands/Options.td b/lldb/source/Commands/Options.td
index 75bdffe16c52e..5327647d65cc4 100644
--- a/lldb/source/Commands/Options.td
+++ b/lldb/source/Commands/Options.td
@@ -1482,13 +1482,15 @@ let Command = "statistics dump" in {
     "this is turned off unless specified. "
     "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">,
-    Desc<"If the setting interpreter.save-transcript is enabled and this "
-    "option is 'true', include a JSON array with all commands the user and/or "
-    "scripts executed during a debug session. "
-    "Defaults to true, unless the '--summary' mode is enabled, in which case "
-    "this is turned off unless specified.">;
+  def statistics_dump_transcript
+      : Option<"transcript", "t">,
+        Group<1>,
+        Arg<"Boolean">,
+        Desc<"If the setting interpreter.save-transcript is enabled and this "
+             "option is 'true', include a JSON array with all commands the "
+             "user and/or "
+             "scripts executed during a debug session. "
+             "Defaults to false. ">;
   def statistics_dump_plugins
       : Option<"plugins", "p">,
         Group<1>,
diff --git a/lldb/test/API/commands/statistics/basic/TestStats.py b/lldb/test/API/commands/statistics/basic/TestStats.py
index 5281bde4c6479..890ceb1f5fd57 100644
--- a/lldb/test/API/commands/statistics/basic/TestStats.py
+++ b/lldb/test/API/commands/statistics/basic/TestStats.py
@@ -892,7 +892,7 @@ def get_test_cases_for_sections_existence(self):
                     "targets.frameVariable": True,
                     "targets.totalSharedLibraryEventHitCount": True,
                     "modules": True,
-                    "transcript": True,
+                    "transcript": False,
                 },
             },
             {  # Summary mode
@@ -979,6 +979,24 @@ def get_test_cases_for_sections_existence(self):
                     "transcript": False,
                 },
             },
+            {  # Default mode without modules and with transcript
+                "command_options": " --modules=false --transcript=true",
+                "api_options": {
+                    "SetIncludeModules": False,
+                    "SetIncludeTranscript": True,
+                },
+                "expect": {
+                    "commands": True,
+                    "targets": True,
+                    "targets.moduleIdentifiers": False,
+                    "targets.breakpoints": True,
+                    "targets.expressionEvaluation": True,
+                    "targets.frameVariable": True,
+                    "targets.totalSharedLibraryEventHitCount": True,
+                    "modules": False,
+                    "transcript": True,
+                },
+            },
             {  # Default mode without modules
                 "command_options": " --modules=false",
                 "api_options": {
@@ -993,6 +1011,23 @@ def get_test_cases_for_sections_existence(self):
                     "targets.frameVariable": True,
                     "targets.totalSharedLibraryEventHitCount": True,
                     "modules": False,
+                    "transcript": False,
+                },
+            },
+            {  # Default mode with transcript
+                "command_options": " --transcript=true",
+                "api_options": {
+                    "SetIncludeTranscript": True,
+                },
+                "expect": {
+                    "commands": True,
+                    "targets": True,
+                    "targets.moduleIdentifiers": True,
+                    "targets.breakpoints": True,
+                    "targets.expressionEvaluation": True,
+                    "targets.frameVariable": True,
+                    "targets.totalSharedLibraryEventHitCount": True,
+                    "modules": True,
                     "transcript": True,
                 },
             },

@qxy11
Copy link
Contributor Author

qxy11 commented Jun 23, 2025

cc @jeffreytan81 @clayborg @dmpots
Also cc @royitaqi on the internal use cases

Copy link
Member

@Michael137 Michael137 left a comment

Choose a reason for hiding this comment

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

Seems sensible to me. Should we issue a warning if a user runs statistics dump --transcript=true but the interpreter.save-transcript is not turned on?

Copy link
Member

@Michael137 Michael137 left a comment

Choose a reason for hiding this comment

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

LGTM

Any chance we could add a test for the warning?

@qxy11
Copy link
Contributor Author

qxy11 commented Jun 25, 2025

Added a unit test around the warning message as well. I'll probably need some help with landing this.

Copy link

github-actions bot commented Jun 25, 2025

✅ With the latest revision this PR passed the Python code formatter.

qxy11 added 5 commits June 25, 2025 11:51
Summary:
Add warning to 'statistics dump --transcript=true' when
interpreter.save-transcript is disabled, helping users understand
why transcript data is empty.

Also refactor StatisticsOptions::GetIncludeTranscript() to use
value_or(false) instead of the verbose has_value()/value() pattern
to address PR comments.
@qxy11 qxy11 force-pushed the no-dump-transcript branch from 4bd8089 to 105e48f Compare June 25, 2025 19:00
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