[Lldb-commits] [lldb] [Reland] Report only loaded debug info in statistics dump (#81706) (PR #82207)

2024-02-18 Thread via lldb-commits

https://github.com/kusmour created 
https://github.com/llvm/llvm-project/pull/82207

Updates:

- The previous patch changed the default behavior to not load dwos in 
`DWARFUnit`
~~`SymbolFileDWARFDwo *GetDwoSymbolFile(bool load_all_debug_info = false);`~~
`SymbolFileDWARFDwo *GetDwoSymbolFile(bool load_all_debug_info = true);`
  - This broke some lldb-shell tests (see 
https://green.lab.llvm.org/green/view/LLDB/job/as-lldb-cmake/16273/)
- TestDebugInfoSize.py
  - with symbol on-demand, by default statistics dump only reports skeleton 
debug info size
  - `statistics dump -f` will load all dwos. debug info = skeleton debug info + 
all dwo debug info

Currently running `statistics dump` will trigger lldb to load debug info that's 
not yet loaded (eg. dwo files). Resulted in a delay in the command return, 
which, can be interrupting.

This patch also added a new option `--load-all-debug-info` asking statistics to 
dump all possible debug info, which will force loading all debug info available 
if not yet loaded.

>From bd9ea7da20587e3ad982c0e0884374d73c4d2b0e Mon Sep 17 00:00:00 2001
From: Wanyi 
Date: Sat, 17 Feb 2024 14:38:18 -0500
Subject: [PATCH] [Reland] Report only loaded debug info in statistics dump
 (#81706)

Currently running `statistics dump` will trigger lldb to load debug info
that's not yet loaded (eg. dwo files). Resulted in a delay in the
command return, which, can be interrupting.

This patch also added a new option `--load-all-debug-info` asking
statistics to dump all possible debug info, which will force loading all
debug info available if not yet loaded.
---
 .../interface/SBStatisticsOptionsDocstrings.i |   6 +
 lldb/include/lldb/API/SBStatisticsOptions.h   |   8 +
 lldb/include/lldb/Symbol/SymbolFile.h |  14 +-
 lldb/include/lldb/Symbol/SymbolFileOnDemand.h |   2 +-
 lldb/include/lldb/Target/Statistics.h |   1 +
 lldb/source/API/SBStatisticsOptions.cpp   |   8 +
 lldb/source/Commands/CommandObjectStats.cpp   |   3 +
 lldb/source/Commands/Options.td   |   6 +-
 .../Breakpad/SymbolFileBreakpad.cpp   |   2 +-
 .../SymbolFile/Breakpad/SymbolFileBreakpad.h  |   2 +-
 .../Plugins/SymbolFile/DWARF/DWARFUnit.cpp|   5 +-
 .../Plugins/SymbolFile/DWARF/DWARFUnit.h  |   2 +-
 .../SymbolFile/DWARF/SymbolFileDWARF.cpp  |   4 +-
 .../SymbolFile/DWARF/SymbolFileDWARF.h|   2 +-
 .../SymbolFile/DWARF/SymbolFileDWARFDwo.cpp   |   2 +-
 .../SymbolFile/DWARF/SymbolFileDWARFDwo.h |   2 +-
 .../NativePDB/SymbolFileNativePDB.cpp |   2 +-
 .../NativePDB/SymbolFileNativePDB.h   |   2 +-
 lldb/source/Symbol/SymbolFile.cpp |   2 +-
 lldb/source/Symbol/SymbolFileOnDemand.cpp |   4 +-
 lldb/source/Target/Statistics.cpp |   4 +-
 .../target/debuginfo/TestDebugInfoSize.py |  11 +
 .../stats_api/TestStatisticsAPI.py|  39 ++
 .../stats_api/main-main.dwo.yaml  |  37 ++
 .../API/functionalities/stats_api/main.yaml   | 543 ++
 25 files changed, 692 insertions(+), 21 deletions(-)
 create mode 100644 lldb/test/API/functionalities/stats_api/main-main.dwo.yaml
 create mode 100644 lldb/test/API/functionalities/stats_api/main.yaml

diff --git a/lldb/bindings/interface/SBStatisticsOptionsDocstrings.i 
b/lldb/bindings/interface/SBStatisticsOptionsDocstrings.i
index f72cf84319e19b..087f6ab8786630 100644
--- a/lldb/bindings/interface/SBStatisticsOptionsDocstrings.i
+++ b/lldb/bindings/interface/SBStatisticsOptionsDocstrings.i
@@ -6,3 +6,9 @@
 ) lldb::SBStatisticsOptions::SetSummaryOnly;
 %feature("docstring", "Gets whether the statistics only dump a summary."
 ) lldb::SBStatisticsOptions::GetSummaryOnly;
+%feature("docstring", "
+Sets whether the statistics will force loading all possible debug info."
+) lldb::SBStatisticsOptions::SetReportAllAvailableDebugInfo;
+%feature("docstring", "
+Gets whether the statistics will force loading all possible debug info."
+) lldb::SBStatisticsOptions::GetReportAllAvailableDebugInfo;
diff --git a/lldb/include/lldb/API/SBStatisticsOptions.h 
b/lldb/include/lldb/API/SBStatisticsOptions.h
index 8019ed4315ca21..a0055135e36c2a 100644
--- a/lldb/include/lldb/API/SBStatisticsOptions.h
+++ b/lldb/include/lldb/API/SBStatisticsOptions.h
@@ -25,6 +25,14 @@ class LLDB_API SBStatisticsOptions {
   void SetSummaryOnly(bool b);
   bool GetSummaryOnly();
 
+  /// If set to true, the debugger will load all debug info that is available
+  /// and report statistics on the total amount. If this is set to false, then
+  /// only report statistics on the currently loaded debug information.
+  /// This can avoid loading debug info from separate files just so it can
+  /// report the total size which can slow down statistics reporting.
+  void SetReportAllAvailableDebugInfo(bool b);
+  bool GetReportAllAvailableDebugInfo();
+
 protected:
   friend class SBTarget;
   const lldb_private::StatisticsOptions &ref() const;
diff --git a/lldb/include/lldb/Symbol/SymbolFi

[Lldb-commits] [lldb] [Reland] Report only loaded debug info in statistics dump (#81706) (PR #82207)

2024-02-18 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Wanyi (kusmour)


Changes

Updates:

- The previous patch changed the default behavior to not load dwos in 
`DWARFUnit`
~~`SymbolFileDWARFDwo *GetDwoSymbolFile(bool load_all_debug_info = false);`~~
`SymbolFileDWARFDwo *GetDwoSymbolFile(bool load_all_debug_info = true);`
  - This broke some lldb-shell tests (see 
https://green.lab.llvm.org/green/view/LLDB/job/as-lldb-cmake/16273/)
- TestDebugInfoSize.py
  - with symbol on-demand, by default statistics dump only reports skeleton 
debug info size
  - `statistics dump -f` will load all dwos. debug info = skeleton debug info + 
all dwo debug info

Currently running `statistics dump` will trigger lldb to load debug info that's 
not yet loaded (eg. dwo files). Resulted in a delay in the command return, 
which, can be interrupting.

This patch also added a new option `--load-all-debug-info` asking statistics to 
dump all possible debug info, which will force loading all debug info available 
if not yet loaded.

---

Patch is 41.07 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/82207.diff


25 Files Affected:

- (modified) lldb/bindings/interface/SBStatisticsOptionsDocstrings.i (+6) 
- (modified) lldb/include/lldb/API/SBStatisticsOptions.h (+8) 
- (modified) lldb/include/lldb/Symbol/SymbolFile.h (+11-3) 
- (modified) lldb/include/lldb/Symbol/SymbolFileOnDemand.h (+1-1) 
- (modified) lldb/include/lldb/Target/Statistics.h (+1) 
- (modified) lldb/source/API/SBStatisticsOptions.cpp (+8) 
- (modified) lldb/source/Commands/CommandObjectStats.cpp (+3) 
- (modified) lldb/source/Commands/Options.td (+5-1) 
- (modified) lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp 
(+1-1) 
- (modified) lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h 
(+1-1) 
- (modified) lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp (+3-2) 
- (modified) lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h (+1-1) 
- (modified) lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (+2-2) 
- (modified) lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h (+1-1) 
- (modified) lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp (+1-1) 
- (modified) lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h (+1-1) 
- (modified) lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp 
(+1-1) 
- (modified) lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h 
(+1-1) 
- (modified) lldb/source/Symbol/SymbolFile.cpp (+1-1) 
- (modified) lldb/source/Symbol/SymbolFileOnDemand.cpp (+2-2) 
- (modified) lldb/source/Target/Statistics.cpp (+3-1) 
- (modified) lldb/test/API/commands/target/debuginfo/TestDebugInfoSize.py (+11) 
- (modified) lldb/test/API/functionalities/stats_api/TestStatisticsAPI.py (+39) 
- (added) lldb/test/API/functionalities/stats_api/main-main.dwo.yaml (+37) 
- (added) lldb/test/API/functionalities/stats_api/main.yaml (+543) 


``diff
diff --git a/lldb/bindings/interface/SBStatisticsOptionsDocstrings.i 
b/lldb/bindings/interface/SBStatisticsOptionsDocstrings.i
index f72cf84319e19b..087f6ab8786630 100644
--- a/lldb/bindings/interface/SBStatisticsOptionsDocstrings.i
+++ b/lldb/bindings/interface/SBStatisticsOptionsDocstrings.i
@@ -6,3 +6,9 @@
 ) lldb::SBStatisticsOptions::SetSummaryOnly;
 %feature("docstring", "Gets whether the statistics only dump a summary."
 ) lldb::SBStatisticsOptions::GetSummaryOnly;
+%feature("docstring", "
+Sets whether the statistics will force loading all possible debug info."
+) lldb::SBStatisticsOptions::SetReportAllAvailableDebugInfo;
+%feature("docstring", "
+Gets whether the statistics will force loading all possible debug info."
+) lldb::SBStatisticsOptions::GetReportAllAvailableDebugInfo;
diff --git a/lldb/include/lldb/API/SBStatisticsOptions.h 
b/lldb/include/lldb/API/SBStatisticsOptions.h
index 8019ed4315ca21..a0055135e36c2a 100644
--- a/lldb/include/lldb/API/SBStatisticsOptions.h
+++ b/lldb/include/lldb/API/SBStatisticsOptions.h
@@ -25,6 +25,14 @@ class LLDB_API SBStatisticsOptions {
   void SetSummaryOnly(bool b);
   bool GetSummaryOnly();
 
+  /// If set to true, the debugger will load all debug info that is available
+  /// and report statistics on the total amount. If this is set to false, then
+  /// only report statistics on the currently loaded debug information.
+  /// This can avoid loading debug info from separate files just so it can
+  /// report the total size which can slow down statistics reporting.
+  void SetReportAllAvailableDebugInfo(bool b);
+  bool GetReportAllAvailableDebugInfo();
+
 protected:
   friend class SBTarget;
   const lldb_private::StatisticsOptions &ref() const;
diff --git a/lldb/include/lldb/Symbol/SymbolFile.h 
b/lldb/include/lldb/Symbol/SymbolFile.h
index f356f7b789fa38..d20766788192f7 100644
--- a/lldb/include/lldb/Symbol/SymbolFile.h
+++ b/lldb/include/lldb/Symbol/SymbolFile.h
@@ -381,7 +381,8 @@ class SymbolFile : public PluginInterface {
 
   /// Metrics g

[Lldb-commits] [lldb] [Reland] Report only loaded debug info in statistics dump (#81706) (PR #82207)

2024-02-18 Thread via lldb-commits

github-actions[bot] wrote:




:warning: Python code formatter, darker found issues in your code. :warning:



You can test this locally with the following command:


``bash
darker --check --diff -r 
79709498eaa57095a9888b882e94f6d15a244d4b...bd9ea7da20587e3ad982c0e0884374d73c4d2b0e
 lldb/test/API/commands/target/debuginfo/TestDebugInfoSize.py 
lldb/test/API/functionalities/stats_api/TestStatisticsAPI.py
``





View the diff from darker here.


``diff
--- commands/target/debuginfo/TestDebugInfoSize.py  2024-02-19 
04:12:41.00 +
+++ commands/target/debuginfo/TestDebugInfoSize.py  2024-02-19 
05:17:03.401880 +
@@ -128,13 +128,12 @@
 self.assertIn(
 "totalDebugInfoByteSize",
 debug_stats,
 'Make sure the "totalDebugInfoByteSize" key is in 
target.GetStatistics()',
 )
-self.assertEqual(
-debug_stats["totalDebugInfoByteSize"], SKELETON_DEBUGINFO_SIZE)
-
+self.assertEqual(debug_stats["totalDebugInfoByteSize"], 
SKELETON_DEBUGINFO_SIZE)
+
 # Force loading all the dwo files
 stats_options = lldb.SBStatisticsOptions()
 stats_options.SetReportAllAvailableDebugInfo(True)
 stats = target.GetStatistics(stats_options)
 stream = lldb.SBStream()

``




https://github.com/llvm/llvm-project/pull/82207
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [Reland] Report only loaded debug info in statistics dump (#81706) (PR #82207)

2024-02-18 Thread via lldb-commits

kusmour wrote:

For the 2 links of test failures in the original PR:
I've run `ninja check-lldb` on x86 linux to confirm the lldb-shell test 
failures in https://green.lab.llvm.org/green/view/LLDB/job/as-lldb-cmake/16273/ 
are fixed.
Unfortunately, I wasn't able to repro most test failures in 
https://lab.llvm.org/buildbot/#/builders/68/builds/69018 with or without my 
patch. I am assuming there're other factors causing the failures.

https://github.com/llvm/llvm-project/pull/82207
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [Reland] Report only loaded debug info in statistics dump (#81706) (PR #82207)

2024-02-18 Thread via lldb-commits

https://github.com/kusmour updated 
https://github.com/llvm/llvm-project/pull/82207

>From 8c4f6defdc14a851debbc96d56b2ec358740a3ca Mon Sep 17 00:00:00 2001
From: Wanyi 
Date: Sat, 17 Feb 2024 14:38:18 -0500
Subject: [PATCH] [Reland] Report only loaded debug info in statistics dump
 (#81706)

Currently running `statistics dump` will trigger lldb to load debug info
that's not yet loaded (eg. dwo files). Resulted in a delay in the
command return, which, can be interrupting.

This patch also added a new option `--load-all-debug-info` asking
statistics to dump all possible debug info, which will force loading all
debug info available if not yet loaded.
---
 .../interface/SBStatisticsOptionsDocstrings.i |   6 +
 lldb/include/lldb/API/SBStatisticsOptions.h   |   8 +
 lldb/include/lldb/Symbol/SymbolFile.h |  14 +-
 lldb/include/lldb/Symbol/SymbolFileOnDemand.h |   2 +-
 lldb/include/lldb/Target/Statistics.h |   1 +
 lldb/source/API/SBStatisticsOptions.cpp   |   8 +
 lldb/source/Commands/CommandObjectStats.cpp   |   3 +
 lldb/source/Commands/Options.td   |   6 +-
 .../Breakpad/SymbolFileBreakpad.cpp   |   2 +-
 .../SymbolFile/Breakpad/SymbolFileBreakpad.h  |   2 +-
 .../Plugins/SymbolFile/DWARF/DWARFUnit.cpp|   5 +-
 .../Plugins/SymbolFile/DWARF/DWARFUnit.h  |   2 +-
 .../SymbolFile/DWARF/SymbolFileDWARF.cpp  |   4 +-
 .../SymbolFile/DWARF/SymbolFileDWARF.h|   2 +-
 .../SymbolFile/DWARF/SymbolFileDWARFDwo.cpp   |   2 +-
 .../SymbolFile/DWARF/SymbolFileDWARFDwo.h |   2 +-
 .../NativePDB/SymbolFileNativePDB.cpp |   2 +-
 .../NativePDB/SymbolFileNativePDB.h   |   2 +-
 lldb/source/Symbol/SymbolFile.cpp |   2 +-
 lldb/source/Symbol/SymbolFileOnDemand.cpp |   4 +-
 lldb/source/Target/Statistics.cpp |   4 +-
 .../target/debuginfo/TestDebugInfoSize.py |  10 +
 .../stats_api/TestStatisticsAPI.py|  39 ++
 .../stats_api/main-main.dwo.yaml  |  37 ++
 .../API/functionalities/stats_api/main.yaml   | 543 ++
 25 files changed, 691 insertions(+), 21 deletions(-)
 create mode 100644 lldb/test/API/functionalities/stats_api/main-main.dwo.yaml
 create mode 100644 lldb/test/API/functionalities/stats_api/main.yaml

diff --git a/lldb/bindings/interface/SBStatisticsOptionsDocstrings.i 
b/lldb/bindings/interface/SBStatisticsOptionsDocstrings.i
index f72cf84319e19b..087f6ab8786630 100644
--- a/lldb/bindings/interface/SBStatisticsOptionsDocstrings.i
+++ b/lldb/bindings/interface/SBStatisticsOptionsDocstrings.i
@@ -6,3 +6,9 @@
 ) lldb::SBStatisticsOptions::SetSummaryOnly;
 %feature("docstring", "Gets whether the statistics only dump a summary."
 ) lldb::SBStatisticsOptions::GetSummaryOnly;
+%feature("docstring", "
+Sets whether the statistics will force loading all possible debug info."
+) lldb::SBStatisticsOptions::SetReportAllAvailableDebugInfo;
+%feature("docstring", "
+Gets whether the statistics will force loading all possible debug info."
+) lldb::SBStatisticsOptions::GetReportAllAvailableDebugInfo;
diff --git a/lldb/include/lldb/API/SBStatisticsOptions.h 
b/lldb/include/lldb/API/SBStatisticsOptions.h
index 8019ed4315ca21..a0055135e36c2a 100644
--- a/lldb/include/lldb/API/SBStatisticsOptions.h
+++ b/lldb/include/lldb/API/SBStatisticsOptions.h
@@ -25,6 +25,14 @@ class LLDB_API SBStatisticsOptions {
   void SetSummaryOnly(bool b);
   bool GetSummaryOnly();
 
+  /// If set to true, the debugger will load all debug info that is available
+  /// and report statistics on the total amount. If this is set to false, then
+  /// only report statistics on the currently loaded debug information.
+  /// This can avoid loading debug info from separate files just so it can
+  /// report the total size which can slow down statistics reporting.
+  void SetReportAllAvailableDebugInfo(bool b);
+  bool GetReportAllAvailableDebugInfo();
+
 protected:
   friend class SBTarget;
   const lldb_private::StatisticsOptions &ref() const;
diff --git a/lldb/include/lldb/Symbol/SymbolFile.h 
b/lldb/include/lldb/Symbol/SymbolFile.h
index f356f7b789fa38..d20766788192f7 100644
--- a/lldb/include/lldb/Symbol/SymbolFile.h
+++ b/lldb/include/lldb/Symbol/SymbolFile.h
@@ -381,7 +381,8 @@ class SymbolFile : public PluginInterface {
 
   /// Metrics gathering functions
 
-  /// Return the size in bytes of all debug information in the symbol file.
+  /// Return the size in bytes of all loaded debug information or total 
possible
+  /// debug info in the symbol file.
   ///
   /// If the debug information is contained in sections of an ObjectFile, then
   /// this call should add the size of all sections that contain debug
@@ -391,7 +392,14 @@ class SymbolFile : public PluginInterface {
   /// entire file should be returned. The default implementation of this
   /// function will iterate over all sections in a module and add up their
   /// debug info only section byte sizes.
-  virtual uint64_t GetDebugInfoSize() = 0;
+

[Lldb-commits] [lldb] [Reland] Report only loaded debug info in statistics dump (#81706) (PR #82207)

2024-02-18 Thread via lldb-commits

https://github.com/kusmour updated 
https://github.com/llvm/llvm-project/pull/82207

>From f71ff3b5aea6f9d1a963a331b9e58662f6ac4640 Mon Sep 17 00:00:00 2001
From: Wanyi 
Date: Sat, 17 Feb 2024 14:38:18 -0500
Subject: [PATCH] [Reland] Report only loaded debug info in statistics dump
 (#81706)

Currently running `statistics dump` will trigger lldb to load debug info
that's not yet loaded (eg. dwo files). Resulted in a delay in the
command return, which, can be interrupting.

This patch also added a new option `--load-all-debug-info` asking
statistics to dump all possible debug info, which will force loading all
debug info available if not yet loaded.
---
 .../interface/SBStatisticsOptionsDocstrings.i |   6 +
 lldb/include/lldb/API/SBStatisticsOptions.h   |   8 +
 lldb/include/lldb/Symbol/SymbolFile.h |  14 +-
 lldb/include/lldb/Symbol/SymbolFileOnDemand.h |   2 +-
 lldb/include/lldb/Target/Statistics.h |   1 +
 lldb/source/API/SBStatisticsOptions.cpp   |   8 +
 lldb/source/Commands/CommandObjectStats.cpp   |   3 +
 lldb/source/Commands/Options.td   |   6 +-
 .../Breakpad/SymbolFileBreakpad.cpp   |   2 +-
 .../SymbolFile/Breakpad/SymbolFileBreakpad.h  |   2 +-
 .../Plugins/SymbolFile/DWARF/DWARFUnit.cpp|   5 +-
 .../Plugins/SymbolFile/DWARF/DWARFUnit.h  |   2 +-
 .../SymbolFile/DWARF/SymbolFileDWARF.cpp  |   4 +-
 .../SymbolFile/DWARF/SymbolFileDWARF.h|   2 +-
 .../SymbolFile/DWARF/SymbolFileDWARFDwo.cpp   |   2 +-
 .../SymbolFile/DWARF/SymbolFileDWARFDwo.h |   2 +-
 .../NativePDB/SymbolFileNativePDB.cpp |   2 +-
 .../NativePDB/SymbolFileNativePDB.h   |   2 +-
 lldb/source/Symbol/SymbolFile.cpp |   2 +-
 lldb/source/Symbol/SymbolFileOnDemand.cpp |   4 +-
 lldb/source/Target/Statistics.cpp |   4 +-
 .../target/debuginfo/TestDebugInfoSize.py |  10 +
 .../stats_api/TestStatisticsAPI.py|  39 ++
 .../stats_api/main-main.dwo.yaml  |  37 ++
 .../API/functionalities/stats_api/main.yaml   | 543 ++
 25 files changed, 691 insertions(+), 21 deletions(-)
 create mode 100644 lldb/test/API/functionalities/stats_api/main-main.dwo.yaml
 create mode 100644 lldb/test/API/functionalities/stats_api/main.yaml

diff --git a/lldb/bindings/interface/SBStatisticsOptionsDocstrings.i 
b/lldb/bindings/interface/SBStatisticsOptionsDocstrings.i
index f72cf84319e19b..087f6ab8786630 100644
--- a/lldb/bindings/interface/SBStatisticsOptionsDocstrings.i
+++ b/lldb/bindings/interface/SBStatisticsOptionsDocstrings.i
@@ -6,3 +6,9 @@
 ) lldb::SBStatisticsOptions::SetSummaryOnly;
 %feature("docstring", "Gets whether the statistics only dump a summary."
 ) lldb::SBStatisticsOptions::GetSummaryOnly;
+%feature("docstring", "
+Sets whether the statistics will force loading all possible debug info."
+) lldb::SBStatisticsOptions::SetReportAllAvailableDebugInfo;
+%feature("docstring", "
+Gets whether the statistics will force loading all possible debug info."
+) lldb::SBStatisticsOptions::GetReportAllAvailableDebugInfo;
diff --git a/lldb/include/lldb/API/SBStatisticsOptions.h 
b/lldb/include/lldb/API/SBStatisticsOptions.h
index 8019ed4315ca21..a0055135e36c2a 100644
--- a/lldb/include/lldb/API/SBStatisticsOptions.h
+++ b/lldb/include/lldb/API/SBStatisticsOptions.h
@@ -25,6 +25,14 @@ class LLDB_API SBStatisticsOptions {
   void SetSummaryOnly(bool b);
   bool GetSummaryOnly();
 
+  /// If set to true, the debugger will load all debug info that is available
+  /// and report statistics on the total amount. If this is set to false, then
+  /// only report statistics on the currently loaded debug information.
+  /// This can avoid loading debug info from separate files just so it can
+  /// report the total size which can slow down statistics reporting.
+  void SetReportAllAvailableDebugInfo(bool b);
+  bool GetReportAllAvailableDebugInfo();
+
 protected:
   friend class SBTarget;
   const lldb_private::StatisticsOptions &ref() const;
diff --git a/lldb/include/lldb/Symbol/SymbolFile.h 
b/lldb/include/lldb/Symbol/SymbolFile.h
index f356f7b789fa38..d20766788192f7 100644
--- a/lldb/include/lldb/Symbol/SymbolFile.h
+++ b/lldb/include/lldb/Symbol/SymbolFile.h
@@ -381,7 +381,8 @@ class SymbolFile : public PluginInterface {
 
   /// Metrics gathering functions
 
-  /// Return the size in bytes of all debug information in the symbol file.
+  /// Return the size in bytes of all loaded debug information or total 
possible
+  /// debug info in the symbol file.
   ///
   /// If the debug information is contained in sections of an ObjectFile, then
   /// this call should add the size of all sections that contain debug
@@ -391,7 +392,14 @@ class SymbolFile : public PluginInterface {
   /// entire file should be returned. The default implementation of this
   /// function will iterate over all sections in a module and add up their
   /// debug info only section byte sizes.
-  virtual uint64_t GetDebugInfoSize() = 0;
+

[Lldb-commits] [lldb] [Reland] Report only loaded debug info in statistics dump (#81706) (PR #82207)

2024-02-18 Thread Jonas Devlieghere via lldb-commits

https://github.com/JDevlieghere approved this pull request.

Thanks! I applied your patch locally and the test suite passes cleanly on macOS 
as well. LGTM! 

https://github.com/llvm/llvm-project/pull/82207
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] dd7386d - [Reland] Report only loaded debug info in statistics dump (#81706) (#82207)

2024-02-18 Thread via lldb-commits

Author: Wanyi
Date: 2024-02-19T00:33:23-05:00
New Revision: dd7386d85f11cf6ad911b9827c7018fb08c6c205

URL: 
https://github.com/llvm/llvm-project/commit/dd7386d85f11cf6ad911b9827c7018fb08c6c205
DIFF: 
https://github.com/llvm/llvm-project/commit/dd7386d85f11cf6ad911b9827c7018fb08c6c205.diff

LOG: [Reland] Report only loaded debug info in statistics dump (#81706) (#82207)

Updates:

- The previous patch changed the default behavior to not load dwos in
`DWARFUnit`
~~`SymbolFileDWARFDwo *GetDwoSymbolFile(bool load_all_debug_info =
false);`~~
`SymbolFileDWARFDwo *GetDwoSymbolFile(bool load_all_debug_info = true);`
- This broke some lldb-shell tests (see
https://green.lab.llvm.org/green/view/LLDB/job/as-lldb-cmake/16273/)
- TestDebugInfoSize.py
- with symbol on-demand, by default statistics dump only reports
skeleton debug info size
- `statistics dump -f` will load all dwos. debug info = skeleton debug
info + all dwo debug info

Currently running `statistics dump` will trigger lldb to load debug info
that's not yet loaded (eg. dwo files). Resulted in a delay in the
command return, which, can be interrupting.

This patch also added a new option `--load-all-debug-info` asking
statistics to dump all possible debug info, which will force loading all
debug info available if not yet loaded.

Added: 
lldb/test/API/functionalities/stats_api/main-main.dwo.yaml
lldb/test/API/functionalities/stats_api/main.yaml

Modified: 
lldb/bindings/interface/SBStatisticsOptionsDocstrings.i
lldb/include/lldb/API/SBStatisticsOptions.h
lldb/include/lldb/Symbol/SymbolFile.h
lldb/include/lldb/Symbol/SymbolFileOnDemand.h
lldb/include/lldb/Target/Statistics.h
lldb/source/API/SBStatisticsOptions.cpp
lldb/source/Commands/CommandObjectStats.cpp
lldb/source/Commands/Options.td
lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h
lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h
lldb/source/Symbol/SymbolFile.cpp
lldb/source/Symbol/SymbolFileOnDemand.cpp
lldb/source/Target/Statistics.cpp
lldb/test/API/commands/target/debuginfo/TestDebugInfoSize.py
lldb/test/API/functionalities/stats_api/TestStatisticsAPI.py

Removed: 




diff  --git a/lldb/bindings/interface/SBStatisticsOptionsDocstrings.i 
b/lldb/bindings/interface/SBStatisticsOptionsDocstrings.i
index f72cf84319e19b..087f6ab8786630 100644
--- a/lldb/bindings/interface/SBStatisticsOptionsDocstrings.i
+++ b/lldb/bindings/interface/SBStatisticsOptionsDocstrings.i
@@ -6,3 +6,9 @@
 ) lldb::SBStatisticsOptions::SetSummaryOnly;
 %feature("docstring", "Gets whether the statistics only dump a summary."
 ) lldb::SBStatisticsOptions::GetSummaryOnly;
+%feature("docstring", "
+Sets whether the statistics will force loading all possible debug info."
+) lldb::SBStatisticsOptions::SetReportAllAvailableDebugInfo;
+%feature("docstring", "
+Gets whether the statistics will force loading all possible debug info."
+) lldb::SBStatisticsOptions::GetReportAllAvailableDebugInfo;

diff  --git a/lldb/include/lldb/API/SBStatisticsOptions.h 
b/lldb/include/lldb/API/SBStatisticsOptions.h
index 8019ed4315ca21..a0055135e36c2a 100644
--- a/lldb/include/lldb/API/SBStatisticsOptions.h
+++ b/lldb/include/lldb/API/SBStatisticsOptions.h
@@ -25,6 +25,14 @@ class LLDB_API SBStatisticsOptions {
   void SetSummaryOnly(bool b);
   bool GetSummaryOnly();
 
+  /// If set to true, the debugger will load all debug info that is available
+  /// and report statistics on the total amount. If this is set to false, then
+  /// only report statistics on the currently loaded debug information.
+  /// This can avoid loading debug info from separate files just so it can
+  /// report the total size which can slow down statistics reporting.
+  void SetReportAllAvailableDebugInfo(bool b);
+  bool GetReportAllAvailableDebugInfo();
+
 protected:
   friend class SBTarget;
   const lldb_private::StatisticsOptions &ref() const;

diff  --git a/lldb/include/lldb/Symbol/SymbolFile.h 
b/lldb/include/lldb/Symbol/SymbolFile.h
index f356f7b789fa38..d20766788192f7 100644
--- a/lldb/include/lldb/Symbol/SymbolFile.h
+++ b/lldb/include/lldb/Symbol/SymbolFile.h
@@ -381,7 +381,8 @@ class SymbolFile : public PluginInterface {
 
   /// Metrics gathering functions
 
-  /// Return the size in bytes of all debug information in the symbol file.
+  /// Return the size in bytes of all loaded debug information or total 

[Lldb-commits] [lldb] [Reland] Report only loaded debug info in statistics dump (#81706) (PR #82207)

2024-02-18 Thread via lldb-commits

https://github.com/kusmour closed 
https://github.com/llvm/llvm-project/pull/82207
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits