[Lldb-commits] [lldb] Add new Python API `SBCommandInterpreter::GetTranscript()` (PR #90703)

2024-05-05 Thread via lldb-commits


@@ -85,3 +86,84 @@ def test_command_output(self):
 self.assertEqual(res.GetOutput(), "")
 self.assertIsNotNone(res.GetError())
 self.assertEqual(res.GetError(), "")
+
+def test_structured_transcript(self):
+"""Test structured transcript generation and retrieval."""
+# Get command interpreter and create a target
+self.build()
+exe = self.getBuildArtifact("a.out")
+
+target = self.dbg.CreateTarget(exe)
+self.assertTrue(target, VALID_TARGET)
+
+ci = self.dbg.GetCommandInterpreter()
+self.assertTrue(ci, VALID_COMMAND_INTERPRETER)
+
+# Send a few commands through the command interpreter
+res = lldb.SBCommandReturnObject()
+ci.HandleCommand("version", res)
+ci.HandleCommand("an-unknown-command", res)
+ci.HandleCommand("breakpoint set -f main.c -l %d" % self.line, res)
+ci.HandleCommand("r", res)
+ci.HandleCommand("p a", res)
+total_number_of_commands = 5
+
+# Retrieve the transcript and convert it into a Python object
+transcript = ci.GetTranscript()
+self.assertTrue(transcript.IsValid())
+
+stream = lldb.SBStream()
+self.assertTrue(stream)
+
+error = transcript.GetAsJSON(stream)
+self.assertSuccess(error)
+
+transcript = json.loads(stream.GetData())
+
+# The transcript will contain a bunch of commands that are run
+# automatically. We only want to validate for the ones that are
+# listed above, hence trimming to the last parts.
+transcript = transcript[-total_number_of_commands:]

royitaqi wrote:

*There is a lot more*. I am not sure entirely sure if it's from the set up code 
in the above. It seems they contain alias or custom command setup. I don't have 
a completely list. If you want I can print you one here in comment.

The point is that the unit test shouldn't care about any extra command that was 
ran that is irrelevant to this test. So trim makes sense to me.

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


[Lldb-commits] [lldb] Add new Python API `SBCommandInterpreter::GetTranscript()` (PR #90703)

2024-05-05 Thread via lldb-commits

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


[Lldb-commits] [lldb] lldb create API folder if it does not exist, before creating SBLangua… (PR #91128)

2024-05-05 Thread Nicklas Boman via lldb-commits

https://github.com/smurfd created 
https://github.com/llvm/llvm-project/pull/91128

Create API folder if it does not exist, before creating SBLanguages.h

>From afc16cb8b3c2e5e804287f7cf5f2be1b2a8b3c46 Mon Sep 17 00:00:00 2001
From: Nicklas Boman 
Date: Sun, 5 May 2024 17:40:51 +0200
Subject: [PATCH] lldb create API folder if it does not exist, before creating
 SBLanguages.h

---
 lldb/scripts/generate-sbapi-dwarf-enum.py | 5 +
 1 file changed, 5 insertions(+)

diff --git a/lldb/scripts/generate-sbapi-dwarf-enum.py 
b/lldb/scripts/generate-sbapi-dwarf-enum.py
index 464eb2afff7d6f..162f76e77ec24a 100755
--- a/lldb/scripts/generate-sbapi-dwarf-enum.py
+++ b/lldb/scripts/generate-sbapi-dwarf-enum.py
@@ -2,6 +2,7 @@
 
 import argparse
 import re
+import os
 
 HEADER = """\
 //===-- SBLanguages.h -*- C++ -*-===//
@@ -37,6 +38,10 @@ def emit_enum(input, output):
 with open(input, "r") as f:
 lines = f.readlines()
 
+# Create output folder if it does not exist
+if not os.path.isdir(os.path.dirname(output)):
+os.makedirs(os.path.dirname(output))
+
 # Write the output.
 with open(output, "w") as f:
 # Emit the header.

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


[Lldb-commits] [lldb] lldb create API folder if it does not exist, before creating SBLangua… (PR #91128)

2024-05-05 Thread via lldb-commits

github-actions[bot] wrote:



Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be
notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this 
page.

If this is not working for you, it is probably because you do not have write
permissions for the repository. In which case you can instead tag reviewers by
name in a comment by using `@` followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a review
by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate
is once a week. Please remember that you are asking for valuable time from 
other developers.

If you have further questions, they may be answered by the [LLVM GitHub User 
Guide](https://llvm.org/docs/GitHub.html).

You can also ask questions in a comment on this PR, on the [LLVM 
Discord](https://discord.com/invite/xS7Z362) or on the 
[forums](https://discourse.llvm.org/).

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


[Lldb-commits] [lldb] lldb create API folder if it does not exist, before creating SBLangua… (PR #91128)

2024-05-05 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Nicklas Boman (smurfd)


Changes

Create API folder if it does not exist, before creating SBLanguages.h

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


1 Files Affected:

- (modified) lldb/scripts/generate-sbapi-dwarf-enum.py (+5) 


``diff
diff --git a/lldb/scripts/generate-sbapi-dwarf-enum.py 
b/lldb/scripts/generate-sbapi-dwarf-enum.py
index 464eb2afff7d6f..162f76e77ec24a 100755
--- a/lldb/scripts/generate-sbapi-dwarf-enum.py
+++ b/lldb/scripts/generate-sbapi-dwarf-enum.py
@@ -2,6 +2,7 @@
 
 import argparse
 import re
+import os
 
 HEADER = """\
 //===-- SBLanguages.h -*- C++ -*-===//
@@ -37,6 +38,10 @@ def emit_enum(input, output):
 with open(input, "r") as f:
 lines = f.readlines()
 
+# Create output folder if it does not exist
+if not os.path.isdir(os.path.dirname(output)):
+os.makedirs(os.path.dirname(output))
+
 # Write the output.
 with open(output, "w") as f:
 # Emit the header.

``




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


[Lldb-commits] [lldb] lldb create API folder if it does not exist, before creating SBLangua… (PR #91128)

2024-05-05 Thread Nicklas Boman via lldb-commits

smurfd wrote:

related to #90753 

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


[Lldb-commits] [lldb] [lldb][NFC] Handle UnresolvedTemplate type in TypeSystemClang.cpp after 7a484d3 (PR #91132)

2024-05-05 Thread Younan Zhang via lldb-commits

https://github.com/zyn0217 created 
https://github.com/llvm/llvm-project/pull/91132

The fix per se seems trivial (given the nature of the new built-in type), and 
hence I don't think we need extra tests.

>From e28f8b007e86d10c3649f8e4635c9bb52627302b Mon Sep 17 00:00:00 2001
From: Younan Zhang 
Date: Mon, 6 May 2024 00:20:14 +0800
Subject: [PATCH] [lldb][NFC] Handle UnresolvedTemplate type in
 TypeSystemClang.cpp after 7a484d3

---
 lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index 2621f682011b41..08d32e71c7fd32 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -3983,6 +3983,7 @@ 
TypeSystemClang::GetMinimumLanguage(lldb::opaque_compiler_type_t type) {
 
   case clang::BuiltinType::Dependent:
   case clang::BuiltinType::Overload:
+  case clang::BuiltinType::UnresolvedTemplate:
   case clang::BuiltinType::BoundMember:
   case clang::BuiltinType::UnknownAny:
 break;
@@ -5962,6 +5963,7 @@ uint32_t 
TypeSystemClang::GetNumPointeeChildren(clang::QualType type) {
 case clang::BuiltinType::LongDouble:
 case clang::BuiltinType::Dependent:
 case clang::BuiltinType::Overload:
+case clang::BuiltinType::UnresolvedTemplate:
 case clang::BuiltinType::ObjCId:
 case clang::BuiltinType::ObjCClass:
 case clang::BuiltinType::ObjCSel:

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


[Lldb-commits] [lldb] [lldb][NFC] Handle UnresolvedTemplate type in TypeSystemClang.cpp after 7a484d3 (PR #91132)

2024-05-05 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Younan Zhang (zyn0217)


Changes

The fix per se seems trivial (given the nature of the new built-in type), and 
hence I don't think we need extra tests.

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


1 Files Affected:

- (modified) lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp (+2) 


``diff
diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index 2621f682011b41e..08d32e71c7fd32e 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -3983,6 +3983,7 @@ 
TypeSystemClang::GetMinimumLanguage(lldb::opaque_compiler_type_t type) {
 
   case clang::BuiltinType::Dependent:
   case clang::BuiltinType::Overload:
+  case clang::BuiltinType::UnresolvedTemplate:
   case clang::BuiltinType::BoundMember:
   case clang::BuiltinType::UnknownAny:
 break;
@@ -5962,6 +5963,7 @@ uint32_t 
TypeSystemClang::GetNumPointeeChildren(clang::QualType type) {
 case clang::BuiltinType::LongDouble:
 case clang::BuiltinType::Dependent:
 case clang::BuiltinType::Overload:
+case clang::BuiltinType::UnresolvedTemplate:
 case clang::BuiltinType::ObjCId:
 case clang::BuiltinType::ObjCClass:
 case clang::BuiltinType::ObjCSel:

``




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


[Lldb-commits] [lldb] [llvm] Add support for using foreign type units in .debug_names. (PR #87740)

2024-05-05 Thread Greg Clayton via lldb-commits

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

>From d69497fc66ce092fd75fcbe7c64460a49a6e2172 Mon Sep 17 00:00:00 2001
From: Greg Clayton 
Date: Sat, 30 Mar 2024 10:50:34 -0700
Subject: [PATCH 1/2] Add support for using foreign type units in .debug_names.

This patch adds support for the new foreign type unit support in .debug_names. 
Features include:
- don't manually index foreign TUs if we have info for them
- only use the type unit entries that match the .dwo files when we have a .dwp 
file
- fix crashers that happen due to PeekDIEName() using wrong offsets
---
 .../SymbolFile/DWARF/DWARFDebugInfo.cpp   | 16 +++-
 .../Plugins/SymbolFile/DWARF/DWARFDebugInfo.h |  2 +
 .../SymbolFile/DWARF/DebugNamesDWARFIndex.cpp | 68 +-
 .../SymbolFile/DWARF/DebugNamesDWARFIndex.h   |  5 +-
 .../SymbolFile/DWARF/ManualDWARFIndex.cpp |  6 +-
 .../SymbolFile/DWARF/ManualDWARFIndex.h   |  7 +-
 .../SymbolFile/DWARF/SymbolFileDWARF.cpp  | 65 +++--
 .../SymbolFile/DWARF/SymbolFileDWARF.h|  9 ++
 .../DWARF/x86/dwp-foreign-type-units.cpp  | 91 +++
 .../DebugInfo/DWARF/DWARFAcceleratorTable.h   | 11 +++
 .../DebugInfo/DWARF/DWARFAcceleratorTable.cpp | 13 +++
 11 files changed, 260 insertions(+), 33 deletions(-)
 create mode 100644 
lldb/test/Shell/SymbolFile/DWARF/x86/dwp-foreign-type-units.cpp

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
index 44febcfac3b000..0e111c8ec47f45 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
@@ -223,7 +223,17 @@ DWARFUnit *DWARFDebugInfo::GetUnitAtOffset(DIERef::Section 
section,
 }
 
 DWARFUnit *DWARFDebugInfo::GetUnit(const DIERef &die_ref) {
-  return GetUnitContainingDIEOffset(die_ref.section(), die_ref.die_offset());
+  // Make sure we get the correct SymbolFileDWARF from the DIERef before
+  // asking for information from a debug info object. We might start with the
+  // DWARFDebugInfo for the main executable in a split DWARF and the DIERef
+  // might be pointing to a specific .dwo file or to the .dwp file. So this
+  // makes sure we get the right SymbolFileDWARF instance before finding the
+  // DWARFUnit that contains the offset. If we just use this object to do the
+  // search, we might be using the wrong .debug_info section from the wrong
+  // file with an offset meant for a different section.
+  SymbolFileDWARF *dwarf = m_dwarf.GetDIERefSymbolFile(die_ref);
+  return dwarf->DebugInfo().GetUnitContainingDIEOffset(die_ref.section(),
+   die_ref.die_offset());
 }
 
 DWARFUnit *
@@ -236,6 +246,10 @@ DWARFDebugInfo::GetUnitContainingDIEOffset(DIERef::Section 
section,
   return result;
 }
 
+const std::shared_ptr DWARFDebugInfo::GetDwpSymbolFile() {
+  return m_dwarf.GetDwpSymbolFile();
+}
+
 DWARFTypeUnit *DWARFDebugInfo::GetTypeUnitForHash(uint64_t hash) {
   auto pos = llvm::lower_bound(m_type_hash_to_unit_index,
std::make_pair(hash, 0u), llvm::less_first());
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h
index c1f0cb0203fb76..b7f99ce6282b1f 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h
@@ -58,6 +58,8 @@ class DWARFDebugInfo {
 
   const DWARFDebugAranges &GetCompileUnitAranges();
 
+  const std::shared_ptr GetDwpSymbolFile();
+
 protected:
   typedef std::vector UnitColl;
 
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
index 4da0d56fdcacb4..ba35b3b872e6c6 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
@@ -34,6 +34,18 @@ DebugNamesDWARFIndex::Create(Module &module, 
DWARFDataExtractor debug_names,
   module, std::move(index_up), debug_names, debug_str, dwarf));
 }
 
+
+llvm::DenseSet
+DebugNamesDWARFIndex::GetTypeUnitSigs(const DebugNames &debug_names) {
+  llvm::DenseSet result;
+  for (const DebugNames::NameIndex &ni : debug_names) {
+const uint32_t num_tus = ni.getForeignTUCount();
+for (uint32_t tu = 0; tu < num_tus; ++tu)
+  result.insert(ni.getForeignTUSignature(tu));
+  }
+  return result;
+}
+
 llvm::DenseSet
 DebugNamesDWARFIndex::GetUnits(const DebugNames &debug_names) {
   llvm::DenseSet result;
@@ -48,6 +60,15 @@ DebugNamesDWARFIndex::GetUnits(const DebugNames 
&debug_names) {
   return result;
 }
 
+DWARFTypeUnit *
+DebugNamesDWARFIndex::GetForeignTypeUnit(const DebugNames::Entry &entry) const 
{
+  std::optional type_sig = entry.getForeignTUTypeSignature();
+  if (type_sig)
+if (auto dwp_sp = m_debug_info.GetDwpSymbolFile())
+  return dwp_sp->DebugInfo().G

[Lldb-commits] [lldb] [lldb][NFC] Handle UnresolvedTemplate type in TypeSystemClang.cpp after 7a484d3 (PR #91132)

2024-05-05 Thread Younan Zhang via lldb-commits

zyn0217 wrote:

@aganea Feel free to commit this PR yourself if this works - It's midnight and 
I'm not going to sit here. Thanks!

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


[Lldb-commits] [lldb] 41574f5 - Add new BuiltinType introduced in 7a484d3a1f630ba9ce7b22e744818be974971470

2024-05-05 Thread David Blaikie via lldb-commits

Author: David Blaikie
Date: 2024-05-05T17:59:54Z
New Revision: 41574f5a6e2d961f398d3c671c34ac3c8e417464

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

LOG: Add new BuiltinType introduced in 7a484d3a1f630ba9ce7b22e744818be974971470

I don't think this is one lldb would encounter when building ASTs from
DWARF.

Added: 


Modified: 
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Removed: 




diff  --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index 3bdb288e97dd6a..a771016039e851 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -4996,6 +4996,9 @@ lldb::Encoding 
TypeSystemClang::GetEncoding(lldb::opaque_compiler_type_t type,
 
 case clang::BuiltinType::IncompleteMatrixIdx:
   break;
+
+case clang::BuiltinType::UnresolvedTemplate:
+  break;
 }
 break;
   // All pointer types are represented as unsigned integer encodings. We may



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


[Lldb-commits] [lldb] [lldb] Fixed SyntaxWarning: invalid escape sequence \[ \d \s (PR #91146)

2024-05-05 Thread Dmitry Vasilyev via lldb-commits

https://github.com/slydiman created 
https://github.com/llvm/llvm-project/pull/91146

None

>From 30e2ebea462561d87947fc133a3b6d287bce34d5 Mon Sep 17 00:00:00 2001
From: Dmitry Vasilyev 
Date: Mon, 6 May 2024 01:10:03 +0400
Subject: [PATCH] [lldb] Fixed SyntaxWarning: invalid escape sequence \[ \d \s

---
 .../lldbsuite/test/tools/lldb-server/gdbremote_testcase.py| 4 ++--
 .../lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py| 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
index 75522158b32210..8c8e4abed0b454 100644
--- 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
+++ 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
@@ -130,9 +130,9 @@ def setUp(self):
 self.stub_sends_two_stop_notifications_on_kill = False
 if configuration.lldb_platform_url:
 if configuration.lldb_platform_url.startswith("unix-"):
-url_pattern = "(.+)://\[?(.+?)\]?/.*"
+url_pattern = r"(.+)://\[?(.+?)\]?/.*"
 else:
-url_pattern = "(.+)://(.+):\d+"
+url_pattern = r"(.+)://(.+):\d+"
 scheme, host = re.match(
 url_pattern, configuration.lldb_platform_url
 ).groups()
diff --git 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py
index 61c5c3a7c865a2..d1a4119bac7815 100644
--- 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py
+++ 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py
@@ -50,7 +50,7 @@ def get_debugserver_exe():
 
 
 _LOG_LINE_REGEX = re.compile(
-r"^(lldb-server|debugserver)\s+<\s*(\d+)>" + 
"\s+(read|send)\s+packet:\s+(.+)$"
+r"^(lldb-server|debugserver)\s+<\s*(\d+)>\s+(read|send)\s+packet:\s+(.+)$"
 )
 
 

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


[Lldb-commits] [lldb] [lldb] Fixed SyntaxWarning: invalid escape sequence \[ \d \s (PR #91146)

2024-05-05 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Dmitry Vasilyev (slydiman)


Changes



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


2 Files Affected:

- (modified) 
lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py 
(+2-2) 
- (modified) 
lldb/packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py 
(+1-1) 


``diff
diff --git 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
index 75522158b32210..8c8e4abed0b454 100644
--- 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
+++ 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
@@ -130,9 +130,9 @@ def setUp(self):
 self.stub_sends_two_stop_notifications_on_kill = False
 if configuration.lldb_platform_url:
 if configuration.lldb_platform_url.startswith("unix-"):
-url_pattern = "(.+)://\[?(.+?)\]?/.*"
+url_pattern = r"(.+)://\[?(.+?)\]?/.*"
 else:
-url_pattern = "(.+)://(.+):\d+"
+url_pattern = r"(.+)://(.+):\d+"
 scheme, host = re.match(
 url_pattern, configuration.lldb_platform_url
 ).groups()
diff --git 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py
index 61c5c3a7c865a2..d1a4119bac7815 100644
--- 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py
+++ 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py
@@ -50,7 +50,7 @@ def get_debugserver_exe():
 
 
 _LOG_LINE_REGEX = re.compile(
-r"^(lldb-server|debugserver)\s+<\s*(\d+)>" + 
"\s+(read|send)\s+packet:\s+(.+)$"
+r"^(lldb-server|debugserver)\s+<\s*(\d+)>\s+(read|send)\s+packet:\s+(.+)$"
 )
 
 

``




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


[Lldb-commits] [lldb] [lldb/crashlog] Enforce image loading policy (PR #91109)

2024-05-05 Thread Med Ismail Bennani via lldb-commits

https://github.com/medismailben updated 
https://github.com/llvm/llvm-project/pull/91109

>From d732da2c059657e2f0acca402e24788bc40a57ef Mon Sep 17 00:00:00 2001
From: Med Ismail Bennani 
Date: Sun, 5 May 2024 20:18:22 -0700
Subject: [PATCH] [lldb/crashlog] Enforce image loading policy

In `27f27d1`, we changed the image loading logic to conform to the
various options (`-a|--load-all` & `-c|--crashed-only`) and loaded them
concurrently.

However, instead of the subset of images that matched the user option,
the thread pool would always run on all the crashlog images, causing
them to be all loaded in the target everytime.

This matches the `-a|--load-all` option behaviour but depending on the
report, it can cause lldb to load thousands of images, which can take a
very long time if the images are downloaded over the network.

This patch fixes that issue by keeping a list of `images_to_load` based of
the user-provided option. This list will be used with our executor
thread pool to load the images according to the user selection, and reinstates
the expected default behaviour, by only loading the crashed thread images and
skipping all the others.

This patch also unifies the way we load images into a single method
that's shared by both the batch mode & the interactive scripted process.

rdar://123694062

Signed-off-by: Med Ismail Bennani 
---
 lldb/examples/python/crashlog.py  | 78 +++
 .../python/crashlog_scripted_process.py   | 38 -
 2 files changed, 60 insertions(+), 56 deletions(-)

diff --git a/lldb/examples/python/crashlog.py b/lldb/examples/python/crashlog.py
index c992348b24be17..976d5bf43455b4 100755
--- a/lldb/examples/python/crashlog.py
+++ b/lldb/examples/python/crashlog.py
@@ -526,6 +526,47 @@ def create_target(self):
 def get_target(self):
 return self.target
 
+def load_images(self, options, loaded_images=[]):
+images_to_load = self.images
+if options.load_all_images:
+for image in self.images:
+image.resolve = True
+elif options.crashed_only:
+for thread in self.threads:
+if thread.did_crash():
+images_to_load = []
+for ident in thread.idents:
+for image in self.find_images_with_identifier(ident):
+image.resolve = True
+images_to_load.append(image)
+
+futures = []
+with tempfile.TemporaryDirectory() as obj_dir:
+with concurrent.futures.ThreadPoolExecutor() as executor:
+
+def add_module(image, target, obj_dir):
+return image, image.add_module(target, obj_dir)
+
+for image in images_to_load:
+if image not in loaded_images:
+if image.uuid == uuid.UUID(int=0):
+continue
+futures.append(
+executor.submit(
+add_module,
+image=image,
+target=self.target,
+obj_dir=obj_dir,
+)
+)
+
+for future in concurrent.futures.as_completed(futures):
+image, err = future.result()
+if err:
+print(err)
+else:
+loaded_images.append(image)
+
 
 class CrashLogFormatException(Exception):
 pass
@@ -1408,36 +1449,7 @@ def SymbolicateCrashLog(crash_log, options):
 if not target:
 return
 
-if options.load_all_images:
-for image in crash_log.images:
-image.resolve = True
-elif options.crashed_only:
-for thread in crash_log.threads:
-if thread.did_crash():
-for ident in thread.idents:
-for image in crash_log.find_images_with_identifier(ident):
-image.resolve = True
-
-futures = []
-loaded_images = []
-with tempfile.TemporaryDirectory() as obj_dir:
-with concurrent.futures.ThreadPoolExecutor() as executor:
-
-def add_module(image, target, obj_dir):
-return image, image.add_module(target, obj_dir)
-
-for image in crash_log.images:
-futures.append(
-executor.submit(
-add_module, image=image, target=target, obj_dir=obj_dir
-)
-)
-for future in concurrent.futures.as_completed(futures):
-image, err = future.result()
-if err:
-print(err)
-else:
-loaded_images.append(image)
+crash_log.load_images(options)
 
 if crash_log.backtraces:
 for thread in crash_log.backtraces:
@@ -1498,7 +1510,11 @@ def 

[Lldb-commits] [lldb] [lldb/crashlog] Enforce image loading policy (PR #91109)

2024-05-05 Thread Med Ismail Bennani via lldb-commits

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


[Lldb-commits] [lldb] [lldb/crashlog] Update incorrect help message for `--no-crashed-only` option (PR #91162)

2024-05-05 Thread Med Ismail Bennani via lldb-commits

https://github.com/medismailben created 
https://github.com/llvm/llvm-project/pull/91162

This patch rephrases the crashlog `--no-crashed-only` option help message. This 
option is mainly used in batch mode to symbolicate and dump all the threads 
backtraces, instead of only doing it for the crashed thread which is the 
default behavior.

rdar://127391524

>From 1ac66026f6ce495a63360eeb14dd5f57d38e650f Mon Sep 17 00:00:00 2001
From: Med Ismail Bennani 
Date: Sun, 5 May 2024 20:04:19 -0700
Subject: [PATCH] [lldb/crashlog] Update incorrect help message for
 `--no-crashed-only` option

This patch rephrases the crashlog `--no-crashed-only` option help
message. This option is mainly used in batch mode to symbolicate and
dump all the threads backtraces, instead of only doing it for the
crashed thread which is the default behavior.

rdar://127391524

Signed-off-by: Med Ismail Bennani 
---
 lldb/examples/python/crashlog.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lldb/examples/python/crashlog.py b/lldb/examples/python/crashlog.py
index c992348b24be17..cdcf6ffc593daf 100755
--- a/lldb/examples/python/crashlog.py
+++ b/lldb/examples/python/crashlog.py
@@ -1631,7 +1631,8 @@ def CreateSymbolicateCrashLogOptions(
 "--no-crashed-only",
 action="store_false",
 dest="crashed_only",
-help="do not symbolicate the crashed thread",
+help="in batch mode, symbolicate all threads, not only the crashed 
one",
+default=False,
 )
 arg_parser.add_argument(
 "--disasm-depth",

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


[Lldb-commits] [lldb] [lldb/crashlog] Update incorrect help message for `--no-crashed-only` option (PR #91162)

2024-05-05 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Med Ismail Bennani (medismailben)


Changes

This patch rephrases the crashlog `--no-crashed-only` option help message. This 
option is mainly used in batch mode to symbolicate and dump all the threads 
backtraces, instead of only doing it for the crashed thread which is the 
default behavior.

rdar://127391524

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


1 Files Affected:

- (modified) lldb/examples/python/crashlog.py (+2-1) 


``diff
diff --git a/lldb/examples/python/crashlog.py b/lldb/examples/python/crashlog.py
index c992348b24be17..cdcf6ffc593daf 100755
--- a/lldb/examples/python/crashlog.py
+++ b/lldb/examples/python/crashlog.py
@@ -1631,7 +1631,8 @@ def CreateSymbolicateCrashLogOptions(
 "--no-crashed-only",
 action="store_false",
 dest="crashed_only",
-help="do not symbolicate the crashed thread",
+help="in batch mode, symbolicate all threads, not only the crashed 
one",
+default=False,
 )
 arg_parser.add_argument(
 "--disasm-depth",

``




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


[Lldb-commits] [lldb] [lldb/crashlog] Enforce image loading policy (PR #91109)

2024-05-05 Thread Med Ismail Bennani via lldb-commits

https://github.com/medismailben updated 
https://github.com/llvm/llvm-project/pull/91109

>From 7b85cc474b55db9394fd9353e5cb0c7b32cd821c Mon Sep 17 00:00:00 2001
From: Med Ismail Bennani 
Date: Sun, 5 May 2024 22:14:42 -0700
Subject: [PATCH] [lldb/crashlog] Enforce image loading policy

In `27f27d1`, we changed the image loading logic to conform to the
various options (`-a|--load-all` & `-c|--crashed-only`) and loaded them
concurrently.

However, instead of the subset of images that matched the user option,
the thread pool would always run on all the crashlog images, causing
them to be all loaded in the target everytime.

This matches the `-a|--load-all` option behaviour but depending on the
report, it can cause lldb to load thousands of images, which can take a
very long time if the images are downloaded over the network.

This patch fixes that issue by keeping a list of `images_to_load` based of
the user-provided option. This list will be used with our executor
thread pool to load the images according to the user selection, and reinstates
the expected default behaviour, by only loading the crashed thread images and
skipping all the others.

This patch also unifies the way we load images into a single method
that's shared by both the batch mode & the interactive scripted process.

rdar://123694062

Signed-off-by: Med Ismail Bennani 
---
 lldb/examples/python/crashlog.py  | 80 +++
 .../python/crashlog_scripted_process.py   | 38 +++--
 2 files changed, 61 insertions(+), 57 deletions(-)

diff --git a/lldb/examples/python/crashlog.py b/lldb/examples/python/crashlog.py
index c992348b24be17..dccdcb2c8b77c7 100755
--- a/lldb/examples/python/crashlog.py
+++ b/lldb/examples/python/crashlog.py
@@ -252,7 +252,7 @@ def add_ident(self, ident):
 self.idents.append(ident)
 
 def did_crash(self):
-return self.reason is not None
+return self.crashed
 
 def __str__(self):
 if self.app_specific_backtrace:
@@ -526,6 +526,47 @@ def create_target(self):
 def get_target(self):
 return self.target
 
+def load_images(self, options, loaded_images=[]):
+images_to_load = self.images
+if options.load_all_images:
+for image in self.images:
+image.resolve = True
+elif options.crashed_only:
+for thread in self.threads:
+if thread.did_crash():
+images_to_load = []
+for ident in thread.idents:
+for image in self.find_images_with_identifier(ident):
+image.resolve = True
+images_to_load.append(image)
+
+futures = []
+with tempfile.TemporaryDirectory() as obj_dir:
+with concurrent.futures.ThreadPoolExecutor() as executor:
+
+def add_module(image, target, obj_dir):
+return image, image.add_module(target, obj_dir)
+
+for image in images_to_load:
+if image not in loaded_images:
+if image.uuid == uuid.UUID(int=0):
+continue
+futures.append(
+executor.submit(
+add_module,
+image=image,
+target=self.target,
+obj_dir=obj_dir,
+)
+)
+
+for future in concurrent.futures.as_completed(futures):
+image, err = future.result()
+if err:
+print(err)
+else:
+loaded_images.append(image)
+
 
 class CrashLogFormatException(Exception):
 pass
@@ -1408,36 +1449,7 @@ def SymbolicateCrashLog(crash_log, options):
 if not target:
 return
 
-if options.load_all_images:
-for image in crash_log.images:
-image.resolve = True
-elif options.crashed_only:
-for thread in crash_log.threads:
-if thread.did_crash():
-for ident in thread.idents:
-for image in crash_log.find_images_with_identifier(ident):
-image.resolve = True
-
-futures = []
-loaded_images = []
-with tempfile.TemporaryDirectory() as obj_dir:
-with concurrent.futures.ThreadPoolExecutor() as executor:
-
-def add_module(image, target, obj_dir):
-return image, image.add_module(target, obj_dir)
-
-for image in crash_log.images:
-futures.append(
-executor.submit(
-add_module, image=image, target=target, obj_dir=obj_dir
-)
-)
-for future in concurrent.futures.as_completed(futures):
-image, err = future.res