[Lldb-commits] [lldb] [lldb-dap] Do not write over the existing error if launchCommands fail during debugger launch. (PR #82051)

2024-02-17 Thread Greg Clayton via lldb-commits

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

Looks good. Always good to have a test.

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


[Lldb-commits] [lldb] Centralize the handling of completion for simple argument lists. (PR #82085)

2024-02-17 Thread Greg Clayton via lldb-commits


@@ -305,6 +305,42 @@ void CommandObject::HandleCompletion(CompletionRequest 
&request) {
   }
 }
 
+void
+CommandObject::HandleArgumentCompletion(CompletionRequest &request,
+   OptionElementVector &opt_element_vector) {
+  size_t num_arg_entries = GetNumArgumentEntries();
+  if (num_arg_entries != 1)
+return;
+
+  CommandArgumentEntry *entry_ptr = GetArgumentEntryAtIndex(0);
+  if (!entry_ptr)
+return; // Maybe this should be an assert, this shouldn't be possible.
+  
+  CommandArgumentEntry &entry = *entry_ptr;
+  // For now, we only handle the simple case of one homogenous argument type.
+  if (entry.size() != 1)
+return;

clayborg wrote:

Is it really that hard to add multiple? Can't we handle `N` completion types as 
long as they are not custom?

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


[Lldb-commits] [lldb] Centralize the handling of completion for simple argument lists. (PR #82085)

2024-02-17 Thread Greg Clayton via lldb-commits

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


[Lldb-commits] [lldb] Centralize the handling of completion for simple argument lists. (PR #82085)

2024-02-17 Thread Greg Clayton via lldb-commits


@@ -305,6 +305,42 @@ void CommandObject::HandleCompletion(CompletionRequest 
&request) {
   }
 }
 
+void
+CommandObject::HandleArgumentCompletion(CompletionRequest &request,
+   OptionElementVector &opt_element_vector) {
+  size_t num_arg_entries = GetNumArgumentEntries();
+  if (num_arg_entries != 1)
+return;
+
+  CommandArgumentEntry *entry_ptr = GetArgumentEntryAtIndex(0);
+  if (!entry_ptr)
+return; // Maybe this should be an assert, this shouldn't be possible.

clayborg wrote:

assert is fine, but please leave the `if (!entry_ptr) return;` in just in case. 
We don't want to crash if we can help it, but the assert will let us know 
something is wrong during testing.

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


[Lldb-commits] [lldb] Centralize the handling of completion for simple argument lists. (PR #82085)

2024-02-17 Thread Greg Clayton via lldb-commits

https://github.com/clayborg commented:

Good fix. Just a few comments

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


[Lldb-commits] [lldb] Centralize the handling of completion for simple argument lists. (PR #82085)

2024-02-17 Thread Greg Clayton via lldb-commits


@@ -305,6 +305,42 @@ void CommandObject::HandleCompletion(CompletionRequest 
&request) {
   }
 }
 
+void
+CommandObject::HandleArgumentCompletion(CompletionRequest &request,
+   OptionElementVector &opt_element_vector) {
+  size_t num_arg_entries = GetNumArgumentEntries();
+  if (num_arg_entries != 1)
+return;
+
+  CommandArgumentEntry *entry_ptr = GetArgumentEntryAtIndex(0);
+  if (!entry_ptr)
+return; // Maybe this should be an assert, this shouldn't be possible.
+  
+  CommandArgumentEntry &entry = *entry_ptr;
+  // For now, we only handle the simple case of one homogenous argument type.
+  if (entry.size() != 1)
+return;
+
+  // Look up the completion type, and if it has one, invoke it:
+  const CommandObject::ArgumentTableEntry *arg_entry 
+  = FindArgumentDataByType(entry[0].arg_type);
+  const ArgumentRepetitionType repeat = entry[0].arg_repetition;
+  
+  if (arg_entry == nullptr || arg_entry->completion_type == 
lldb::eNoCompletion)
+return;
+  
+  // FIXME: This should be handled higher in the Command Parser.
+  // Check the case where this command only takes one argument, and don't do
+  // the completion if we aren't on the first entry:
+  if (repeat == eArgRepeatPlain && request.GetCursorIndex() != 0)
+return;
+  
+  lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks(
+GetCommandInterpreter(), arg_entry->completion_type, request, 
nullptr);
+

clayborg wrote:

If we can handle `N` completion types, this code could be put into a function 
and run multiple times with a different index, or we can just make a loop

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


[Lldb-commits] [lldb] [lldb] Use PyBytes and PyByteArray in Python Data Objects unittest (PR #82098)

2024-02-17 Thread Greg Clayton via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb] Add more ways to find the .dwp file. (PR #81067)

2024-02-17 Thread Greg Clayton via lldb-commits

https://github.com/clayborg updated 
https://github.com/llvm/llvm-project/pull/81067

>From 3c2f6039cf0e253d78b5193098b311028daaea72 Mon Sep 17 00:00:00 2001
From: Greg Clayton 
Date: Wed, 7 Feb 2024 16:43:50 -0800
Subject: [PATCH 1/6] Add more ways to find the .dwp file.

When using split DWARF we can run into many different ways to store debug info:
- lldb loads "" which contains skeleton DWARF and needs to find ".dwp"
- lldb loads "" which is stripped but has .gnu_debuglink pointing to 
".debug" with skeleton DWARF and needs to find ".dwp"
- lldb loads "" which is stripped but has .gnu_debuglink pointing to 
".debug" with skeleton DWARF and needs to find ".debug.dwp"
- lldb loads ".debug" and needs to find ".dwp

Previously we only handled the first two cases. This patch adds support for the 
latter two.
---
 lldb/include/lldb/Utility/FileSpecList.h  |  4 ++
 .../SymbolFile/DWARF/SymbolFileDWARF.cpp  | 61 +--
 .../DWARF/x86/dwp-separate-debug-file.cpp | 30 +
 3 files changed, 78 insertions(+), 17 deletions(-)

diff --git a/lldb/include/lldb/Utility/FileSpecList.h 
b/lldb/include/lldb/Utility/FileSpecList.h
index 49edc667ddd5b6..6eb3bb9971f13a 100644
--- a/lldb/include/lldb/Utility/FileSpecList.h
+++ b/lldb/include/lldb/Utility/FileSpecList.h
@@ -238,6 +238,10 @@ class FileSpecList {
   const_iterator begin() const { return m_files.begin(); }
   const_iterator end() const { return m_files.end(); }
 
+  llvm::iterator_range files() const {
+return llvm::make_range(begin(), end());
+  }
+
 protected:
   collection m_files; ///< A collection of FileSpec objects.
 };
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index 781f5c5a436778..487961fa7437fb 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -4349,26 +4349,53 @@ SymbolFileDWARFDebugMap 
*SymbolFileDWARF::GetDebugMapSymfile() {
 
 const std::shared_ptr &SymbolFileDWARF::GetDwpSymbolFile() 
{
   llvm::call_once(m_dwp_symfile_once_flag, [this]() {
+// Create a list of files to try and append .dwp to
+FileSpecList symfiles;
+// Append the module's object file path.
+const FileSpec module_fspec = m_objfile_sp->GetModule()->GetFileSpec();
+symfiles.Append(module_fspec);
+// Append the object file for this SymbolFile only if it is different from
+// the module's file path. Our main module could be "a.out", our symbol 
file
+// could be "a.debug" and our ".dwp" file might be "a.debug.dwp" instead of
+// "a.out.dwp".
+const FileSpec symfile_fspec(m_objfile_sp->GetFileSpec());
+if (symfile_fspec != module_fspec) {
+  symfiles.Append(symfile_fspec);
+} else {
+  // If we don't have a separate debug info file, then try stripping the
+  // extension. We main module could be "a.debug" and the .dwp file could 
be
+  // "a.dwp" instead of "a.debug.dwp".
+  ConstString filename_no_ext =
+  module_fspec.GetFileNameStrippingExtension();
+  if (filename_no_ext != module_fspec.GetFilename()) {
+FileSpec module_spec_no_ext(module_fspec);
+module_spec_no_ext.SetFilename(filename_no_ext);
+symfiles.Append(module_spec_no_ext);
+  }
+}
+
+FileSpecList search_paths = Target::GetDefaultDebugFileSearchPaths();
 ModuleSpec module_spec;
 module_spec.GetFileSpec() = m_objfile_sp->GetFileSpec();
-module_spec.GetSymbolFileSpec() =
-FileSpec(m_objfile_sp->GetModule()->GetFileSpec().GetPath() + ".dwp");
-
 module_spec.GetUUID() = m_objfile_sp->GetUUID();
-FileSpecList search_paths = Target::GetDefaultDebugFileSearchPaths();
-FileSpec dwp_filespec =
-PluginManager::LocateExecutableSymbolFile(module_spec, search_paths);
-if (FileSystem::Instance().Exists(dwp_filespec)) {
-  DataBufferSP dwp_file_data_sp;
-  lldb::offset_t dwp_file_data_offset = 0;
-  ObjectFileSP dwp_obj_file = ObjectFile::FindPlugin(
-  GetObjectFile()->GetModule(), &dwp_filespec, 0,
-  FileSystem::Instance().GetByteSize(dwp_filespec), dwp_file_data_sp,
-  dwp_file_data_offset);
-  if (!dwp_obj_file)
-return;
-  m_dwp_symfile = std::make_shared(
-  *this, dwp_obj_file, DIERef::k_file_index_mask);
+for (const auto &symfile : symfiles.files()) {
+  module_spec.GetSymbolFileSpec() =
+  FileSpec(symfile.GetPath() + ".dwp", symfile.GetPathStyle());
+  FileSpec dwp_filespec =
+  PluginManager::LocateExecutableSymbolFile(module_spec, search_paths);
+  if (FileSystem::Instance().Exists(dwp_filespec)) {
+DataBufferSP dwp_file_data_sp;
+lldb::offset_t dwp_file_data_offset = 0;
+ObjectFileSP dwp_obj_file = ObjectFile::FindPlugin(
+GetObjectFile()->GetModule(), &dwp_filespec, 0,
+FileSystem::Instance().GetByteSize(dwp_filespec), dwp

[Lldb-commits] [lldb] 27f2908 - [lldb] Use PyBytes and PyByteArray in Python Data Objects unittest (#82098)

2024-02-17 Thread via lldb-commits

Author: Jonas Devlieghere
Date: 2024-02-17T11:37:26-08:00
New Revision: 27f2908fbc8092f3567385a63676d623523b318b

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

LOG: [lldb] Use PyBytes and PyByteArray in Python Data Objects unittest (#82098)

Use a Python Bytes and ByteArray object instead of Integers for
TestOwnedReferences and TestBorrowedReferences. These two tests were
failing when building against Python 3.12 because these Integer objects
had a refcount of 4294967296 (-1). I didn't dig into it, but I suspect
the Python runtime has adopted an optimization to decrease refcounting
traffic for these simple objects.

Added: 


Modified: 
lldb/unittests/ScriptInterpreter/Python/PythonDataObjectsTests.cpp

Removed: 




diff  --git 
a/lldb/unittests/ScriptInterpreter/Python/PythonDataObjectsTests.cpp 
b/lldb/unittests/ScriptInterpreter/Python/PythonDataObjectsTests.cpp
index efb8f725f6739a..a4db4627f935b4 100644
--- a/lldb/unittests/ScriptInterpreter/Python/PythonDataObjectsTests.cpp
+++ b/lldb/unittests/ScriptInterpreter/Python/PythonDataObjectsTests.cpp
@@ -51,21 +51,24 @@ class PythonDataObjectsTest : public PythonTestSuite {
 
 TEST_F(PythonDataObjectsTest, TestOwnedReferences) {
   // After creating a new object, the refcount should be >= 1
-  PyObject *obj = PyLong_FromLong(3);
-  Py_ssize_t original_refcnt = obj->ob_refcnt;
+  PyObject *obj = PyBytes_FromString("foo");
+  Py_ssize_t original_refcnt = Py_REFCNT(obj);
   EXPECT_LE(1, original_refcnt);
 
   // If we take an owned reference, the refcount should be the same
-  PythonObject owned_long(PyRefType::Owned, obj);
-  EXPECT_EQ(original_refcnt, owned_long.get()->ob_refcnt);
+  PythonObject owned(PyRefType::Owned, obj);
+  Py_ssize_t owned_refcnt = Py_REFCNT(owned.get());
+  EXPECT_EQ(original_refcnt, owned_refcnt);
 
   // Take another reference and verify that the refcount increases by 1
-  PythonObject strong_ref(owned_long);
-  EXPECT_EQ(original_refcnt + 1, strong_ref.get()->ob_refcnt);
+  PythonObject strong_ref(owned);
+  Py_ssize_t strong_refcnt = Py_REFCNT(strong_ref.get());
+  EXPECT_EQ(original_refcnt + 1, strong_refcnt);
 
   // If we reset the first one, the refcount should be the original value.
-  owned_long.Reset();
-  EXPECT_EQ(original_refcnt, strong_ref.get()->ob_refcnt);
+  owned.Reset();
+  strong_refcnt = Py_REFCNT(strong_ref.get());
+  EXPECT_EQ(original_refcnt, strong_refcnt);
 }
 
 TEST_F(PythonDataObjectsTest, TestResetting) {
@@ -82,12 +85,15 @@ TEST_F(PythonDataObjectsTest, TestResetting) {
 }
 
 TEST_F(PythonDataObjectsTest, TestBorrowedReferences) {
-  PythonInteger long_value(PyRefType::Owned, PyLong_FromLong(3));
-  Py_ssize_t original_refcnt = long_value.get()->ob_refcnt;
+  PythonByteArray byte_value(PyRefType::Owned,
+ PyByteArray_FromStringAndSize("foo", 3));
+  Py_ssize_t original_refcnt = Py_REFCNT(byte_value.get());
   EXPECT_LE(1, original_refcnt);
 
-  PythonInteger borrowed_long(PyRefType::Borrowed, long_value.get());
-  EXPECT_EQ(original_refcnt + 1, borrowed_long.get()->ob_refcnt);
+  PythonByteArray borrowed_byte(PyRefType::Borrowed, byte_value.get());
+  Py_ssize_t borrowed_refcnt = Py_REFCNT(borrowed_byte.get());
+
+  EXPECT_EQ(original_refcnt + 1, borrowed_refcnt);
 }
 
 TEST_F(PythonDataObjectsTest, TestGlobalNameResolutionNoDot) {



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Use PyBytes and PyByteArray in Python Data Objects unittest (PR #82098)

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

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


[Lldb-commits] [lldb] 21ddd7f - Report only loaded debug info in statistics dump (#81706)

2024-02-17 Thread via lldb-commits

Author: Wanyi
Date: 2024-02-17T14:38:18-05:00
New Revision: 21ddd7ff2b166c5e133b460b1a09ee8adb786ccd

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

LOG: 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.

Added: 
lldb/test/API/functionalities/stats_api/main.dwo.yaml
lldb/test/API/functionalities/stats_api/main.o.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/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 
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;
+  ///
+  /// \param load_all_debug_info
+  ///   If true, force loading any symbol files if they are not yet loaded and
+  ///   add to the

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

2024-02-17 Thread via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Call Import_AppendInittab before Py_Initialize (PR #82095)

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

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


[Lldb-commits] [lldb] fbce244 - [lldb] Call Import_AppendInittab before Py_Initialize (#82095)

2024-02-17 Thread via lldb-commits

Author: Jonas Devlieghere
Date: 2024-02-17T15:10:09-08:00
New Revision: fbce244299524fc3d736cce9d25b4262303b45d5

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

LOG: [lldb] Call Import_AppendInittab before Py_Initialize (#82095)

The Python documentation [1] says that `PyImport_AppendInittab` should
be called before `Py_Initialize()`. Starting with Python 3.12, this is
enforced with a fatal error:

  Fatal Python error: PyImport_AppendInittab: PyImport_AppendInittab()
  may not be called after Py_Initialize()

This commit ensures we only modify the table of built-in modules if
Python hasn't been initialized. For Python embedded in LLDB, that means
this happen exactly once, before the first call to `Py_Initialize`,
which becomes a NO-OP after. However, when lldb is imported in an
existing Python interpreter, Python will have already been initialized,
but by definition, the lldb module will already have been loaded, so
it's safe to skip adding it (again).

This fixes #70453.

[1] https://docs.python.org/3.12/c-api/import.html#c.PyImport_AppendInittab

Added: 


Modified: 
lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp

Removed: 




diff  --git 
a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp 
b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
index dadcde612614ba..a1ad3f569ec71a 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -97,24 +97,28 @@ struct InitializePythonRAII {
   InitializePythonRAII() {
 InitializePythonHome();
 
+// The table of built-in modules can only be extended before Python is
+// initialized.
+if (!Py_IsInitialized()) {
 #ifdef LLDB_USE_LIBEDIT_READLINE_COMPAT_MODULE
-// Python's readline is incompatible with libedit being linked into lldb.
-// Provide a patched version local to the embedded interpreter.
-bool ReadlinePatched = false;
-for (auto *p = PyImport_Inittab; p->name != nullptr; p++) {
-  if (strcmp(p->name, "readline") == 0) {
-p->initfunc = initlldb_readline;
-break;
+  // Python's readline is incompatible with libedit being linked into lldb.
+  // Provide a patched version local to the embedded interpreter.
+  bool ReadlinePatched = false;
+  for (auto *p = PyImport_Inittab; p->name != nullptr; p++) {
+if (strcmp(p->name, "readline") == 0) {
+  p->initfunc = initlldb_readline;
+  break;
+}
+  }
+  if (!ReadlinePatched) {
+PyImport_AppendInittab("readline", initlldb_readline);
+ReadlinePatched = true;
   }
-}
-if (!ReadlinePatched) {
-  PyImport_AppendInittab("readline", initlldb_readline);
-  ReadlinePatched = true;
-}
 #endif
 
-// Register _lldb as a built-in module.
-PyImport_AppendInittab("_lldb", LLDBSwigPyInit);
+  // Register _lldb as a built-in module.
+  PyImport_AppendInittab("_lldb", LLDBSwigPyInit);
+}
 
 // Python < 3.2 and Python >= 3.2 reversed the ordering requirements for
 // calling `Py_Initialize` and `PyEval_InitThreads`.  < 3.2 requires that you



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Call Import_AppendInittab before Py_Initialize (PR #82095)

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

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


[Lldb-commits] [lldb] [lldb] Don't rely on ScriptInterpreterPythonImpl::Initialize in the unit tests (PR #82096)

2024-02-17 Thread Alex Langford via lldb-commits

bulbazord wrote:

> The downside of doing the initialization manually is that we do lose a bit of 
> test coverage. For example, issue #70453 also manifested itself in the unit 
> tests.

I think this is an acceptable tradeoff. The unit tests are for testing LLDB's 
python internals, not for testing LLDB's python interface and integration.

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


[Lldb-commits] [lldb] [lldb] Don't rely on ScriptInterpreterPythonImpl::Initialize in the unit tests (PR #82096)

2024-02-17 Thread Alex Langford via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb] Don't rely on ScriptInterpreterPythonImpl::Initialize in the unit tests (PR #82096)

2024-02-17 Thread Med Ismail Bennani via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb] Use PyBytes and PyByteArray in Python Data Objects unittest (PR #82098)

2024-02-17 Thread Will Hawkins via lldb-commits

hawkinsw wrote:

> Use a Python Bytes and ByteArray object instead of Integers for 
> TestOwnedReferences and TestBorrowedReferences. These two tests were failing 
> when building against Python 3.12 because these Integer objects had a 
> refcount of 4294967296 (-1). I didn't dig into it, but I suspect the Python 
> runtime has adopted an optimization to decrease refcounting traffic for these 
> simple objects.

Perhaps related to ...

https://github.com/python/cpython/pull/30872/files#diff-1a6e70e2beeecad88840c67284ac4d54a36998029244771fcc820e801390726a

I was curious and investigated. Whether that is the *exact* change, it seems to 
confirm your hypothesis that there is special refcounting code for certain 
types of Python objects. Would you agree with that?

I hope that helps!

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


[Lldb-commits] [lldb] [lldb] Migrate distutils.version.LooseVersion to packaging (PR #82066)

2024-02-17 Thread Med Ismail Bennani via lldb-commits

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

LGTM!

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


[Lldb-commits] [lldb] 5c96e71 - [lldb] Don't rely on ScriptInterpreterPythonImpl::Initialize in the unit tests (#82096)

2024-02-17 Thread via lldb-commits

Author: Jonas Devlieghere
Date: 2024-02-17T20:55:33-08:00
New Revision: 5c96e71d0d49dd55711ccdb57a22d033fe7a8fae

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

LOG: [lldb] Don't rely on ScriptInterpreterPythonImpl::Initialize in the unit 
tests (#82096)

The unit tests only test the Python objects and don't actually use
anything from the LLDB module. That means that all the additional
complexity in ScriptInterpreterPythonImpl::Initialize is overkill.

By doing the initialization by hand, we avoid the annoying
ModuleNotFoundError.

  Traceback (most recent call last):
File "", line 1, in 
  ModuleNotFoundError: No module named 'lldb'

The error is the result of us stubbing out the SWIG (specifically
`PyInit__lldb`) because we cannot link against libLLDB from the unit
tests.

The downside of doing the initialization manually is that we do lose a
bit of test coverage. For example, issue #70453 also manifested itself
in the unit tests.

Added: 


Modified: 
lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp

Removed: 




diff  --git a/lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp 
b/lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp
index 5f0cc4c23db7b2..23162436d42c94 100644
--- a/lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp
+++ b/lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp
@@ -9,43 +9,27 @@
 #include "gtest/gtest.h"
 
 #include "Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h"
-#include "Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h"
-#include "Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h"
 #include "Plugins/ScriptInterpreter/Python/lldb-python.h"
 
-#include "lldb/Host/FileSystem.h"
-#include "lldb/Host/HostInfo.h"
-
 #include "PythonTestSuite.h"
 #include 
 
-using namespace lldb_private;
-class TestScriptInterpreterPython : public ScriptInterpreterPythonImpl {
-public:
-  using ScriptInterpreterPythonImpl::Initialize;
-};
-
 void PythonTestSuite::SetUp() {
-  FileSystem::Initialize();
-  HostInfoBase::Initialize();
-  // ScriptInterpreterPython::Initialize() depends on HostInfo being
-  // initializedso it can compute the python directory etc.
-  TestScriptInterpreterPython::Initialize();
-
   // Although we don't care about concurrency for the purposes of running
   // this test suite, Python requires the GIL to be locked even for
   // deallocating memory, which can happen when you call Py_DECREF or
   // Py_INCREF.  So acquire the GIL for the entire duration of this
   // test suite.
+  Py_InitializeEx(0);
   m_gil_state = PyGILState_Ensure();
+  PyRun_SimpleString("import sys");
 }
 
 void PythonTestSuite::TearDown() {
   PyGILState_Release(m_gil_state);
 
-  TestScriptInterpreterPython::Terminate();
-  HostInfoBase::Terminate();
-  FileSystem::Terminate();
+  // We could call Py_FinalizeEx here, but initializing and finalizing Python 
is
+  // pretty slow, so just keep Python initialized across tests.
 }
 
 // The following functions are the Pythonic implementations of the required
@@ -219,7 +203,7 @@ bool 
lldb_private::python::SWIGBridge::LLDBSwigPythonCallCommandObject(
 }
 
 bool lldb_private::python::SWIGBridge::LLDBSwigPythonCallParsedCommandObject(
-PyObject *implementor, lldb::DebuggerSP debugger, 
+PyObject *implementor, lldb::DebuggerSP debugger,
 StructuredDataImpl &args_impl,
 lldb_private::CommandReturnObject &cmd_retobj,
 lldb::ExecutionContextRefSP exe_ctx_ref_sp) {



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Don't rely on ScriptInterpreterPythonImpl::Initialize in the unit tests (PR #82096)

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

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


[Lldb-commits] [lldb] Revert "Report only loaded debug info in statistics dump (#81706)" (PR #82150)

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

https://github.com/JDevlieghere created 
https://github.com/llvm/llvm-project/pull/82150

This reverts commit 21ddd7ff2b166c5e133b460b1a09ee8adb786ccd because it breaks 
a bunch of tests:

https://lab.llvm.org/buildbot/#/builders/68/builds/69018
https://green.lab.llvm.org/green/view/LLDB/job/as-lldb-cmake/16273

>From a147a6b5d8b26c644b8efd5a99ab7c6727079a9a Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Sat, 17 Feb 2024 21:32:08 -0800
Subject: [PATCH] Revert "Report only loaded debug info in statistics dump
 (#81706)"

This reverts commit 21ddd7ff2b166c5e133b460b1a09ee8adb786ccd.
---
 .../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 +-
 .../stats_api/TestStatisticsAPI.py|  35 ---
 .../functionalities/stats_api/main.dwo.yaml   |  37 ---
 .../API/functionalities/stats_api/main.o.yaml | 212 --
 24 files changed, 21 insertions(+), 346 deletions(-)
 delete mode 100644 lldb/test/API/functionalities/stats_api/main.dwo.yaml
 delete mode 100644 lldb/test/API/functionalities/stats_api/main.o.yaml

diff --git a/lldb/bindings/interface/SBStatisticsOptionsDocstrings.i 
b/lldb/bindings/interface/SBStatisticsOptionsDocstrings.i
index 087f6ab8786630..f72cf84319e19b 100644
--- a/lldb/bindings/interface/SBStatisticsOptionsDocstrings.i
+++ b/lldb/bindings/interface/SBStatisticsOptionsDocstrings.i
@@ -6,9 +6,3 @@
 ) 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 a0055135e36c2a..8019ed4315ca21 100644
--- a/lldb/include/lldb/API/SBStatisticsOptions.h
+++ b/lldb/include/lldb/API/SBStatisticsOptions.h
@@ -25,14 +25,6 @@ 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 d20766788192f7..f356f7b789fa38 100644
--- a/lldb/include/lldb/Symbol/SymbolFile.h
+++ b/lldb/include/lldb/Symbol/SymbolFile.h
@@ -381,8 +381,7 @@ class SymbolFile : public PluginInterface {
 
   /// Metrics gathering functions
 
-  /// Return the size in bytes of all loaded debug information or total 
possible
-  /// debug info in the symbol file.
+  /// Return the size in bytes of all debug information 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
@@ -392,14 +391,7 @@ 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.
-  ///
-  /// \param load_all_debug_info
-  ///   If true, force loading any symbol files if they are not yet loaded and
-  ///   add to the total size. Default 

[Lldb-commits] [lldb] 339baae - Revert "Report only loaded debug info in statistics dump (#81706)" (#82150)

2024-02-17 Thread via lldb-commits

Author: Jonas Devlieghere
Date: 2024-02-17T21:38:11-08:00
New Revision: 339baae3e223693a98f0f25e06147e4e6dde1254

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

LOG: Revert "Report only loaded debug info in statistics dump (#81706)" (#82150)

This reverts commit 21ddd7ff2b166c5e133b460b1a09ee8adb786ccd because it
breaks a bunch of tests:

https://lab.llvm.org/buildbot/#/builders/68/builds/69018
https://green.lab.llvm.org/green/view/LLDB/job/as-lldb-cmake/16273

Added: 


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/functionalities/stats_api/TestStatisticsAPI.py

Removed: 
lldb/test/API/functionalities/stats_api/main.dwo.yaml
lldb/test/API/functionalities/stats_api/main.o.yaml



diff  --git a/lldb/bindings/interface/SBStatisticsOptionsDocstrings.i 
b/lldb/bindings/interface/SBStatisticsOptionsDocstrings.i
index 087f6ab8786630..f72cf84319e19b 100644
--- a/lldb/bindings/interface/SBStatisticsOptionsDocstrings.i
+++ b/lldb/bindings/interface/SBStatisticsOptionsDocstrings.i
@@ -6,9 +6,3 @@
 ) 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 a0055135e36c2a..8019ed4315ca21 100644
--- a/lldb/include/lldb/API/SBStatisticsOptions.h
+++ b/lldb/include/lldb/API/SBStatisticsOptions.h
@@ -25,14 +25,6 @@ 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 d20766788192f7..f356f7b789fa38 100644
--- a/lldb/include/lldb/Symbol/SymbolFile.h
+++ b/lldb/include/lldb/Symbol/SymbolFile.h
@@ -381,8 +381,7 @@ class SymbolFile : public PluginInterface {
 
   /// Metrics gathering functions
 
-  /// Return the size in bytes of all loaded debug information or total 
possible
-  /// debug info in the symbol file.
+  /// Return the size in bytes of all debug information 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
@@ -392,14 +391,7 @@ 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.
-  ///
-  /// \param load_all_debug_info
-  ///   If true, force loading any symbol files if they are not yet loaded and
-  ///   add to the total size. Default to false.
-  ///
-  /// \returns
-  ///   Total currently loaded debug info size in bytes
-  virtual uint64_t GetDebugInfoSize(bool lo

[Lldb-commits] [lldb] Revert "Report only loaded debug info in statistics dump (#81706)" (PR #82150)

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

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


[Lldb-commits] [lldb] Revert "Report only loaded debug info in statistics dump (#81706)" (PR #82150)

2024-02-17 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Jonas Devlieghere (JDevlieghere)


Changes

This reverts commit 21ddd7ff2b166c5e133b460b1a09ee8adb786ccd because it breaks 
a bunch of tests:

https://lab.llvm.org/buildbot/#/builders/68/builds/69018
https://green.lab.llvm.org/green/view/LLDB/job/as-lldb-cmake/16273

---

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


24 Files Affected:

- (modified) lldb/bindings/interface/SBStatisticsOptionsDocstrings.i (-6) 
- (modified) lldb/include/lldb/API/SBStatisticsOptions.h (-8) 
- (modified) lldb/include/lldb/Symbol/SymbolFile.h (+3-11) 
- (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 (+1-5) 
- (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 (+2-3) 
- (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 (+1-3) 
- (modified) lldb/test/API/functionalities/stats_api/TestStatisticsAPI.py (-35) 
- (removed) lldb/test/API/functionalities/stats_api/main.dwo.yaml (-37) 
- (removed) lldb/test/API/functionalities/stats_api/main.o.yaml (-212) 


``diff
diff --git a/lldb/bindings/interface/SBStatisticsOptionsDocstrings.i 
b/lldb/bindings/interface/SBStatisticsOptionsDocstrings.i
index 087f6ab8786630..f72cf84319e19b 100644
--- a/lldb/bindings/interface/SBStatisticsOptionsDocstrings.i
+++ b/lldb/bindings/interface/SBStatisticsOptionsDocstrings.i
@@ -6,9 +6,3 @@
 ) 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 a0055135e36c2a..8019ed4315ca21 100644
--- a/lldb/include/lldb/API/SBStatisticsOptions.h
+++ b/lldb/include/lldb/API/SBStatisticsOptions.h
@@ -25,14 +25,6 @@ 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 d20766788192f7..f356f7b789fa38 100644
--- a/lldb/include/lldb/Symbol/SymbolFile.h
+++ b/lldb/include/lldb/Symbol/SymbolFile.h
@@ -381,8 +381,7 @@ class SymbolFile : public PluginInterface {
 
   /// Metrics gathering functions
 
-  /// Return the size in bytes of all loaded debug information or total 
possible
-  /// debug info in the symbol file.
+  /// Return the size in bytes of all debug information 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
@@ -392,14 +391,7 @@ 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.
-  ///
-  /// \param load_all_debug_info
-  ///   If true, force loading any symbol files if they are not yet loaded and
-  ///   add to the tot

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

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

JDevlieghere wrote:

I've reverted this because it breaks a bunch of tests:

https://lab.llvm.org/buildbot/#/builders/68/builds/69018
https://green.lab.llvm.org/green/view/LLDB/job/as-lldb-cmake/16273

Please keep an eye on the bots when relanding this. 

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