[Lldb-commits] [lldb] [lldb][AArch64][Linux] Rename IsEnabled to IsPresent (PR #70303)

2023-10-27 Thread David Spickett via lldb-commits

https://github.com/DavidSpickett updated 
https://github.com/llvm/llvm-project/pull/70303

>From bbcdfa3bb4844f609efabbb819444bbab02b02f8 Mon Sep 17 00:00:00 2001
From: David Spickett 
Date: Thu, 26 Oct 2023 08:28:02 +
Subject: [PATCH] [lldb][AArch64][Linux] Reanme IsEnabled to
 IsPresent

For most register sets, if it was enabled this meant you could use it,
it was present in the process. There was no present but turned off state.

So "enabled" made sense.

Then ZA came along (and soon to be ZT0) where ZA can be present in the
hardware when you have SME, but ZA itself can be made inactive.

This means that "IsZAEnabled()" doesn't mean is it active, it means
do you have SME. Which is very confusing when we actually want to know
if ZA is active.

So instead say "IsZAPresent", to make these checks more specific.
For things that can't be made inactive, present will imply "active"
as they're never inactive.
---
 .../NativeRegisterContextLinux_arm64.cpp  | 21 +--
 .../Process/Utility/RegisterInfoPOSIX_arm64.h | 12 +--
 .../RegisterContextPOSIXCore_arm64.cpp| 12 +--
 3 files changed, 22 insertions(+), 23 deletions(-)

diff --git 
a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp 
b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
index b5210c368144206..22aa2f3a920945d 100644
--- a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
+++ b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
@@ -166,10 +166,10 @@ 
NativeRegisterContextLinux_arm64::NativeRegisterContextLinux_arm64(
   m_tls_is_valid = false;
 
   // SME adds the tpidr2 register
-  m_tls_size = GetRegisterInfo().IsSSVEEnabled() ? sizeof(m_tls_regs)
+  m_tls_size = GetRegisterInfo().IsSSVEPresent() ? sizeof(m_tls_regs)
  : 
sizeof(m_tls_regs.tpidr_reg);
 
-  if (GetRegisterInfo().IsSVEEnabled() || GetRegisterInfo().IsSSVEEnabled())
+  if (GetRegisterInfo().IsSVEPresent() || GetRegisterInfo().IsSSVEPresent())
 m_sve_state = SVEState::Unknown;
   else
 m_sve_state = SVEState::Disabled;
@@ -609,8 +609,7 @@ 
NativeRegisterContextLinux_arm64::CacheAllRegisters(uint32_t &cached_size) {
   if (error.Fail())
 return error;
 
-  // Here this means, does the system have ZA, not whether it is active.
-  if (GetRegisterInfo().IsZAEnabled()) {
+  if (GetRegisterInfo().IsZAPresent()) {
 error = ReadZAHeader();
 if (error.Fail())
   return error;
@@ -628,7 +627,7 @@ 
NativeRegisterContextLinux_arm64::CacheAllRegisters(uint32_t &cached_size) {
   }
 
   // If SVE is enabled we need not copy FPR separately.
-  if (GetRegisterInfo().IsSVEEnabled() || GetRegisterInfo().IsSSVEEnabled()) {
+  if (GetRegisterInfo().IsSVEPresent() || GetRegisterInfo().IsSSVEPresent()) {
 // Store mode and register data.
 cached_size +=
 sizeof(RegisterSetType) + sizeof(m_sve_state) + GetSVEBufferSize();
@@ -640,7 +639,7 @@ 
NativeRegisterContextLinux_arm64::CacheAllRegisters(uint32_t &cached_size) {
   if (error.Fail())
 return error;
 
-  if (GetRegisterInfo().IsMTEEnabled()) {
+  if (GetRegisterInfo().IsMTEPresent()) {
 cached_size += sizeof(RegisterSetType) + GetMTEControlSize();
 error = ReadMTEControl();
 if (error.Fail())
@@ -708,7 +707,7 @@ Status 
NativeRegisterContextLinux_arm64::ReadAllRegisterValues(
   // constants and the functions vec_set_vector_length, sve_set_common and
   // za_set in the Linux Kernel.
 
-  if ((m_sve_state != SVEState::Streaming) && GetRegisterInfo().IsZAEnabled()) 
{
+  if ((m_sve_state != SVEState::Streaming) && GetRegisterInfo().IsZAPresent()) 
{
 // Use the header size not the buffer size, as we may be using the buffer
 // for fake data, which we do not want to write out.
 assert(m_za_header.size <= GetZABufferSize());
@@ -716,7 +715,7 @@ Status 
NativeRegisterContextLinux_arm64::ReadAllRegisterValues(
 m_za_header.size);
   }
 
-  if (GetRegisterInfo().IsSVEEnabled() || GetRegisterInfo().IsSSVEEnabled()) {
+  if (GetRegisterInfo().IsSVEPresent() || GetRegisterInfo().IsSSVEPresent()) {
 dst = AddRegisterSetType(dst, RegisterSetType::SVE);
 *(reinterpret_cast(dst)) = m_sve_state;
 dst += sizeof(m_sve_state);
@@ -726,13 +725,13 @@ Status 
NativeRegisterContextLinux_arm64::ReadAllRegisterValues(
 GetFPRSize());
   }
 
-  if ((m_sve_state == SVEState::Streaming) && GetRegisterInfo().IsZAEnabled()) 
{
+  if ((m_sve_state == SVEState::Streaming) && GetRegisterInfo().IsZAPresent()) 
{
 assert(m_za_header.size <= GetZABufferSize());
 dst = AddSavedRegisters(dst, RegisterSetType::SME, GetZABuffer(),
 m_za_header.size);
   }
 
-  if (GetRegisterInfo().IsMTEEnabled()) {
+  if (GetRegisterInfo().IsMTEPresent()) {
 dst = AddSavedRegisters(dst, RegisterSetType::MTE, GetMTEControl(),
 GetMT

[Lldb-commits] [lldb] [lldb][AArch64][Linux] Rename IsEnabled to IsPresent (PR #70303)

2023-10-27 Thread David Spickett via lldb-commits

DavidSpickett wrote:

@omjavaid Any objections?

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


[Lldb-commits] [lldb] [lldb][AArch64][Linux] Add field information for the CPSR register (PR #70300)

2023-10-27 Thread David Spickett via lldb-commits

https://github.com/DavidSpickett updated 
https://github.com/llvm/llvm-project/pull/70300

>From 45a9d131ce6c9fb31355519cd810ceff32c05ee7 Mon Sep 17 00:00:00 2001
From: David Spickett 
Date: Wed, 11 Oct 2023 14:54:07 +0100
Subject: [PATCH 1/3] [lldb][AArch64][Linux] Add field information for the CPSR
 register

The contents of which are mostly SPSR_EL1 as shown in the Arm manual,
with a few adjustments for things Linux says userspace shouldn't concern
itself with.

```
(lldb) register read cpsr
cpsr = 0x80001000
 = (N = 1, Z = 0, C = 0, V = 0, SS = 0, IL = 0, ...
```

Some fields are always present, some depend on extensions. I've checked
for those extensions using HWCAP and HWCAP2.

To provide this for core files and live processes I've added a new class
LinuxArm64RegisterFlags. This is a container for all the registers we'll want
to have fields and handles detecting fields and updating register info.

This is used by the native process as follows:
* There is a global LinuxArm64RegisterFlags object.
* The first thread takes a mutex on it, and updates the fields.
* Subsequent threads see that detection is already done, and skip it.
* All threads then update their own copy of the register information
  with pointers to the field information contained in the global object.

This means that even though every thread will have the same fields,
we only detect them once and have one copy of the information.

Core files instead have a LinuxArm64RegisterFlags as a member, because
each core file could have different saved capabilities. The logic from
there is the same but we get HWACP values from the corefile note.

This handler class is Linux specific right now, but it can easily be made
more generic if needed. For example by using LLVM's FeatureBitset
instead of HWCAPs.

Updating register info is done with string comparison, which isn't ideal.
For CPSR, we do know the register number ahead of time but we do not for
other registers in dynamic register sets. So in the interest of
consistency, I'm going to use string comparison for all registers including 
cpsr.

I've added tests with a core file and live process. Only checking for
fields that are always present to account for CPU variance.
---
 lldb/include/lldb/Target/RegisterFlags.h  |   5 +
 lldb/include/lldb/lldb-private-types.h|   5 +-
 .../NativeRegisterContextLinux_arm64.cpp  |  18 
 .../Plugins/Process/Utility/CMakeLists.txt|   1 +
 .../Utility/RegisterFlagsLinux_arm64.cpp  | 100 ++
 .../Utility/RegisterFlagsLinux_arm64.h|  75 +
 .../RegisterContextPOSIXCore_arm64.cpp|  17 +++
 .../elf-core/RegisterContextPOSIXCore_arm64.h |   3 +
 lldb/source/Target/RegisterFlags.cpp  |  14 ++-
 .../register_command/TestRegisters.py |  12 +++
 .../postmortem/elf-core/TestLinuxCore.py  |   4 +
 11 files changed, 249 insertions(+), 5 deletions(-)
 create mode 100644 
lldb/source/Plugins/Process/Utility/RegisterFlagsLinux_arm64.cpp
 create mode 100644 
lldb/source/Plugins/Process/Utility/RegisterFlagsLinux_arm64.h

diff --git a/lldb/include/lldb/Target/RegisterFlags.h 
b/lldb/include/lldb/Target/RegisterFlags.h
index 7c5b97c2265fda3..1d8c8e943813e77 100644
--- a/lldb/include/lldb/Target/RegisterFlags.h
+++ b/lldb/include/lldb/Target/RegisterFlags.h
@@ -83,6 +83,11 @@ class RegisterFlags {
   RegisterFlags(std::string id, unsigned size,
 const std::vector &fields);
 
+  /// Replace all the fields with the new set of fields. All the assumptions
+  /// and checks apply as when you use the constructor. Intended to only be 
used
+  /// when runtime field detection is needed.
+  void SetFields(const std::vector &fields);
+
   // Reverse the order of the fields, keeping their values the same.
   // For example a field from bit 31 to 30 with value 0b10 will become bits
   // 1 to 0, with the same 0b10 value.
diff --git a/lldb/include/lldb/lldb-private-types.h 
b/lldb/include/lldb/lldb-private-types.h
index e6717836331f590..f2ced61b7cc315b 100644
--- a/lldb/include/lldb/lldb-private-types.h
+++ b/lldb/include/lldb/lldb-private-types.h
@@ -62,7 +62,10 @@ struct RegisterInfo {
   /// rax ax, ah, and al.
   uint32_t *invalidate_regs;
   /// If not nullptr, a type defined by XML descriptions.
-  const RegisterFlags *flags_type;
+  /// This is mutable so that it may be updated after the register info tables
+  /// have been constructed. For example a specific target OS may have a
+  /// different layout.
+  mutable const RegisterFlags *flags_type;
 
   llvm::ArrayRef data(const uint8_t *context_base) const {
 return llvm::ArrayRef(context_base + byte_offset, byte_size);
diff --git 
a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp 
b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
index b5210c368144206..b55d60f3d9bbd13 100644
--- a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
+++ b/lldb/source/Plu

[Lldb-commits] [lldb] [lldb][AArch64][Linux] Add field information for the CPSR register (PR #70300)

2023-10-27 Thread David Spickett via lldb-commits

https://github.com/DavidSpickett updated 
https://github.com/llvm/llvm-project/pull/70300

>From 45a9d131ce6c9fb31355519cd810ceff32c05ee7 Mon Sep 17 00:00:00 2001
From: David Spickett 
Date: Wed, 11 Oct 2023 14:54:07 +0100
Subject: [PATCH 1/4] [lldb][AArch64][Linux] Add field information for the CPSR
 register

The contents of which are mostly SPSR_EL1 as shown in the Arm manual,
with a few adjustments for things Linux says userspace shouldn't concern
itself with.

```
(lldb) register read cpsr
cpsr = 0x80001000
 = (N = 1, Z = 0, C = 0, V = 0, SS = 0, IL = 0, ...
```

Some fields are always present, some depend on extensions. I've checked
for those extensions using HWCAP and HWCAP2.

To provide this for core files and live processes I've added a new class
LinuxArm64RegisterFlags. This is a container for all the registers we'll want
to have fields and handles detecting fields and updating register info.

This is used by the native process as follows:
* There is a global LinuxArm64RegisterFlags object.
* The first thread takes a mutex on it, and updates the fields.
* Subsequent threads see that detection is already done, and skip it.
* All threads then update their own copy of the register information
  with pointers to the field information contained in the global object.

This means that even though every thread will have the same fields,
we only detect them once and have one copy of the information.

Core files instead have a LinuxArm64RegisterFlags as a member, because
each core file could have different saved capabilities. The logic from
there is the same but we get HWACP values from the corefile note.

This handler class is Linux specific right now, but it can easily be made
more generic if needed. For example by using LLVM's FeatureBitset
instead of HWCAPs.

Updating register info is done with string comparison, which isn't ideal.
For CPSR, we do know the register number ahead of time but we do not for
other registers in dynamic register sets. So in the interest of
consistency, I'm going to use string comparison for all registers including 
cpsr.

I've added tests with a core file and live process. Only checking for
fields that are always present to account for CPU variance.
---
 lldb/include/lldb/Target/RegisterFlags.h  |   5 +
 lldb/include/lldb/lldb-private-types.h|   5 +-
 .../NativeRegisterContextLinux_arm64.cpp  |  18 
 .../Plugins/Process/Utility/CMakeLists.txt|   1 +
 .../Utility/RegisterFlagsLinux_arm64.cpp  | 100 ++
 .../Utility/RegisterFlagsLinux_arm64.h|  75 +
 .../RegisterContextPOSIXCore_arm64.cpp|  17 +++
 .../elf-core/RegisterContextPOSIXCore_arm64.h |   3 +
 lldb/source/Target/RegisterFlags.cpp  |  14 ++-
 .../register_command/TestRegisters.py |  12 +++
 .../postmortem/elf-core/TestLinuxCore.py  |   4 +
 11 files changed, 249 insertions(+), 5 deletions(-)
 create mode 100644 
lldb/source/Plugins/Process/Utility/RegisterFlagsLinux_arm64.cpp
 create mode 100644 
lldb/source/Plugins/Process/Utility/RegisterFlagsLinux_arm64.h

diff --git a/lldb/include/lldb/Target/RegisterFlags.h 
b/lldb/include/lldb/Target/RegisterFlags.h
index 7c5b97c2265fda3..1d8c8e943813e77 100644
--- a/lldb/include/lldb/Target/RegisterFlags.h
+++ b/lldb/include/lldb/Target/RegisterFlags.h
@@ -83,6 +83,11 @@ class RegisterFlags {
   RegisterFlags(std::string id, unsigned size,
 const std::vector &fields);
 
+  /// Replace all the fields with the new set of fields. All the assumptions
+  /// and checks apply as when you use the constructor. Intended to only be 
used
+  /// when runtime field detection is needed.
+  void SetFields(const std::vector &fields);
+
   // Reverse the order of the fields, keeping their values the same.
   // For example a field from bit 31 to 30 with value 0b10 will become bits
   // 1 to 0, with the same 0b10 value.
diff --git a/lldb/include/lldb/lldb-private-types.h 
b/lldb/include/lldb/lldb-private-types.h
index e6717836331f590..f2ced61b7cc315b 100644
--- a/lldb/include/lldb/lldb-private-types.h
+++ b/lldb/include/lldb/lldb-private-types.h
@@ -62,7 +62,10 @@ struct RegisterInfo {
   /// rax ax, ah, and al.
   uint32_t *invalidate_regs;
   /// If not nullptr, a type defined by XML descriptions.
-  const RegisterFlags *flags_type;
+  /// This is mutable so that it may be updated after the register info tables
+  /// have been constructed. For example a specific target OS may have a
+  /// different layout.
+  mutable const RegisterFlags *flags_type;
 
   llvm::ArrayRef data(const uint8_t *context_base) const {
 return llvm::ArrayRef(context_base + byte_offset, byte_size);
diff --git 
a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp 
b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
index b5210c368144206..b55d60f3d9bbd13 100644
--- a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
+++ b/lldb/source/Plu

[Lldb-commits] [lldb] 02ef12d - [lldb] Return unimplemented error from ScriptedProcessInterface::CreatePluginObject

2023-10-27 Thread David Spickett via lldb-commits

Author: David Spickett
Date: 2023-10-27T11:24:03Z
New Revision: 02ef12dd808f19191a4d0a9f511c4e5a5dda59b5

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

LOG: [lldb] Return unimplemented error from 
ScriptedProcessInterface::CreatePluginObject

After https://github.com/llvm/llvm-project/pull/68052 this function changed 
from returning
a nullptr with `return {};` to returning Expected and hitting 
`llvm_unreachable` before it could
do so.

I gather that we're never supposed to call this function, but on Windows we 
actually do call
this function because `interpreter->CreateScriptedProcessInterface()` returns
`ScriptedProcessInterface` not `ScriptedProcessPythonInterface`. Likely because
`target_sp->GetDebugger().GetScriptInterpreter()` also does not return a Python 
related class.

The previously XFAILed test crashed with:
```
 # .---command stderr
 # | PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ 
and include the crash backtrace.
 # | Stack dump:
 # | 0.  Program arguments: 
c:\\users\\tcwg\\david.spickett\\build-llvm\\bin\\lldb-test.exe ir-memory-map 
C:\\Users\\tcwg\\david.spickett\\build-llvm\\tools\\lldb\\test\\Shell\\Expr\\Output\\TestIRMemoryMapWindows.test.tmp
 
C:\\Users\\tcwg\\david.spickett\\llvm-project\\lldb\\test\\Shell\\Expr/Inputs/ir-memory-map-basic
 # | 1.  HandleCommand(command = "run")
 # | Exception Code: 0xC01D
 # | #0 0x7ff696b5f588 
lldb_private::ScriptedProcessInterface::CreatePluginObject(class 
llvm::StringRef, class lldb_private::ExecutionContext &, class 
std::shared_ptr, class 
lldb_private::StructuredData::Generic *) 
C:\Users\tcwg\david.spickett\llvm-project\lldb\include\lldb\Interpreter\Interfaces\ScriptedProcessInterface.h:28:0
 # | #1 0x7ff696b1d808 
llvm::Expected 
>::operator bool 
C:\Users\tcwg\david.spickett\llvm-project\llvm\include\llvm\Support\Error.h:567:0
 # | #2 0x7ff696b1d808 lldb_private::ScriptedProcess::ScriptedProcess(class 
std::shared_ptr, class std::shared_ptr, class lldb_private::ScriptedMetadata const &, class 
lldb_private::Status &) 
C:\Users\tcwg\david.spickett\llvm-project\lldb\source\Plugins\Process\scripted\ScriptedProcess.cpp:115:0
 # | #3 0x7ff696b1d124 
std::shared_ptr::shared_ptr C:\Program 
Files\Microsoft Visual 
Studio\2022\Preview\VC\Tools\MSVC\14.35.32124\include\memory:1478:0
 # | #4 0x7ff696b1d124 lldb_private::ScriptedProcess::CreateInstance(class 
std::shared_ptr, class std::shared_ptr, class lldb_private::FileSpec const *, bool) 
C:\Users\tcwg\david.spickett\llvm-project\lldb\source\Plugins\Process\scripted\ScriptedProcess.cpp:61:0
 # | #5 0x7ff69699c8f4 
std::_Ptr_base::_Move_construct_from C:\Program 
Files\Microsoft Visual 
Studio\2022\Preview\VC\Tools\MSVC\14.35.32124\include\memory:1237:0
 # | #6 0x7ff69699c8f4 std::shared_ptr::shared_ptr 
C:\Program Files\Microsoft Visual 
Studio\2022\Preview\VC\Tools\MSVC\14.35.32124\include\memory:1534:0
 # | #7 0x7ff69699c8f4 std::shared_ptr::operator= 
C:\Program Files\Microsoft Visual 
Studio\2022\Preview\VC\Tools\MSVC\14.35.32124\include\memory:1594:0
 # | #8 0x7ff69699c8f4 lldb_private::Process::FindPlugin(class 
std::shared_ptr, class llvm::StringRef, class 
std::shared_ptr, class lldb_private::FileSpec 
const *, bool) 
C:\Users\tcwg\david.spickett\llvm-project\lldb\source\Target\Process.cpp:396:0
 # | #9 0x7ff6969bd708 
std::_Ptr_base::_Move_construct_from C:\Program 
Files\Microsoft Visual 
Studio\2022\Preview\VC\Tools\MSVC\14.35.32124\include\memory:1237:0
 # | #10 0x7ff6969bd708 std::shared_ptr::shared_ptr 
C:\Program Files\Microsoft Visual 
Studio\2022\Preview\VC\Tools\MSVC\14.35.32124\include\memory:1534:0
 # | #11 0x7ff6969bd708 std::shared_ptr::operator= 
C:\Program Files\Microsoft Visual 
Studio\2022\Preview\VC\Tools\MSVC\14.35.32124\include\memory:1594:0
 # | #12 0x7ff6969bd708 lldb_private::Target::CreateProcess(class 
std::shared_ptr, class llvm::StringRef, class 
lldb_private::FileSpec const *, bool) 
C:\Users\tcwg\david.spickett\llvm-project\lldb\source\Target\Target.cpp:215:0
 # | #13 0x7ff696b13af0 std::_Ptr_base::_Ptr_base 
C:\Program Files\Microsoft Visual 
Studio\2022\Preview\VC\Tools\MSVC\14.35.32124\include\memory:1230:0
 # | #14 0x7ff696b13af0 std::shared_ptr::shared_ptr 
C:\Program Files\Microsoft Visual 
Studio\2022\Preview\VC\Tools\MSVC\14.35.32124\include\memory:1524:0
 # | #15 0x7ff696b13af0 lldb_private::PlatformWindows::DebugProcess(class 
lldb_private::ProcessLaunchInfo &, class lldb_private::Debugger &, class 
lldb_private::Target &, class lldb_private::Status &) 
C:\Users\tcwg\david.spickett\llvm-project\lldb\source\Plugins\Platform\Windows\PlatformWindows.cpp:495:0
 # | #16 0x7ff6969cf590 
std::_Ptr_base::_Move_construct_from C:\Program 
Files\Microsoft Visual 
Studio\2022\Preview\VC\Tools\MSVC\14.35.32

[Lldb-commits] [lldb] [lldb/Interpreter] Make ScriptedInterface Object creation more generic (PR #68052)

2023-10-27 Thread David Spickett via lldb-commits

DavidSpickett wrote:

https://github.com/llvm/llvm-project/commit/02ef12dd808f19191a4d0a9f511c4e5a5dda59b5
 fixes the Windows test. If the behaviour seems suspicious to you, I can check 
more details of the build but I don't know anything about `Scripted...` so I'll 
need you to tell me what to look for.

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


[Lldb-commits] [lldb] [lldb] Replace the usage of module imp with module importlib (PR #70443)

2023-10-27 Thread Tulio Magno Quites Machado Filho via lldb-commits

https://github.com/tuliom created 
https://github.com/llvm/llvm-project/pull/70443

imp got removed in Python 3.12 [1] and the community recommends using importlib 
in newer Python versions.

[1] https://docs.python.org/3.12/whatsnew/3.12.html#imp

>From 16fd09f102eff20825847e32f225715960d1c082 Mon Sep 17 00:00:00 2001
From: Tulio Magno Quites Machado Filho 
Date: Wed, 25 Oct 2023 10:48:53 -0300
Subject: [PATCH] [lldb] Replace the usage of module imp with module importlib

imp got removed in Python 3.12 [1] and the community recommends using
importlib in newer Python versions.

[1] https://docs.python.org/3.12/whatsnew/3.12.html#imp
---
 lldb/scripts/use_lldb_suite.py  | 30 ++
 lldb/test/API/use_lldb_suite.py | 29 +
 2 files changed, 43 insertions(+), 16 deletions(-)

diff --git a/lldb/scripts/use_lldb_suite.py b/lldb/scripts/use_lldb_suite.py
index 6388d87b181ce03..4cedfa532cf972d 100644
--- a/lldb/scripts/use_lldb_suite.py
+++ b/lldb/scripts/use_lldb_suite.py
@@ -17,11 +17,25 @@ def find_lldb_root():
 
 
 lldb_root = find_lldb_root()
-import imp
-
-fp, pathname, desc = imp.find_module("use_lldb_suite_root", [lldb_root])
-try:
-imp.load_module("use_lldb_suite_root", fp, pathname, desc)
-finally:
-if fp:
-fp.close()
+
+# Module imp got removed in Python 3.12.
+if (
+sys.version_info.major == 3 and sys.version_info.minor >= 12
+) or sys.version_info.major > 3:
+import importlib.machinery
+import importlib.util
+
+path = os.path.join(lldb_root, "use_lldb_suite_root.py")
+loader = importlib.machinery.SourceFileLoader("use_lldb_suite_root", path)
+spec = importlib.util.spec_from_loader("use_lldb_suite_root", 
loader=loader)
+module = importlib.util.module_from_spec(spec)
+loader.exec_module(module)
+else:
+import imp
+
+fp, pathname, desc = imp.find_module("use_lldb_suite_root", [lldb_root])
+try:
+imp.load_module("use_lldb_suite_root", fp, pathname, desc)
+finally:
+if fp:
+fp.close()
diff --git a/lldb/test/API/use_lldb_suite.py b/lldb/test/API/use_lldb_suite.py
index e237dd4b8a5607c..c9332d9921b4eb3 100644
--- a/lldb/test/API/use_lldb_suite.py
+++ b/lldb/test/API/use_lldb_suite.py
@@ -20,11 +20,24 @@ def find_lldb_root():
 
 lldb_root = find_lldb_root()
 
-import imp
-
-fp, pathname, desc = imp.find_module("use_lldb_suite_root", [lldb_root])
-try:
-imp.load_module("use_lldb_suite_root", fp, pathname, desc)
-finally:
-if fp:
-fp.close()
+# Module imp got removed in Python 3.12.
+if (
+sys.version_info.major == 3 and sys.version_info.minor >= 12
+) or sys.version_info.major > 3:
+import importlib.machinery
+import importlib.util
+
+path = os.path.join(lldb_root, "use_lldb_suite_root.py")
+loader = importlib.machinery.SourceFileLoader("use_lldb_suite_root", path)
+spec = importlib.util.spec_from_loader("use_lldb_suite_root", 
loader=loader)
+module = importlib.util.module_from_spec(spec)
+loader.exec_module(module)
+else:
+import imp
+
+fp, pathname, desc = imp.find_module("use_lldb_suite_root", [lldb_root])
+try:
+imp.load_module("use_lldb_suite_root", fp, pathname, desc)
+finally:
+if fp:
+fp.close()

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


[Lldb-commits] [lldb] [lldb] Replace the usage of module imp with module importlib (PR #70443)

2023-10-27 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Tulio Magno Quites Machado Filho (tuliom)


Changes

imp got removed in Python 3.12 [1] and the community recommends using importlib 
in newer Python versions.

[1] https://docs.python.org/3.12/whatsnew/3.12.html#imp

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


2 Files Affected:

- (modified) lldb/scripts/use_lldb_suite.py (+22-8) 
- (modified) lldb/test/API/use_lldb_suite.py (+21-8) 


``diff
diff --git a/lldb/scripts/use_lldb_suite.py b/lldb/scripts/use_lldb_suite.py
index 6388d87b181ce03..4cedfa532cf972d 100644
--- a/lldb/scripts/use_lldb_suite.py
+++ b/lldb/scripts/use_lldb_suite.py
@@ -17,11 +17,25 @@ def find_lldb_root():
 
 
 lldb_root = find_lldb_root()
-import imp
-
-fp, pathname, desc = imp.find_module("use_lldb_suite_root", [lldb_root])
-try:
-imp.load_module("use_lldb_suite_root", fp, pathname, desc)
-finally:
-if fp:
-fp.close()
+
+# Module imp got removed in Python 3.12.
+if (
+sys.version_info.major == 3 and sys.version_info.minor >= 12
+) or sys.version_info.major > 3:
+import importlib.machinery
+import importlib.util
+
+path = os.path.join(lldb_root, "use_lldb_suite_root.py")
+loader = importlib.machinery.SourceFileLoader("use_lldb_suite_root", path)
+spec = importlib.util.spec_from_loader("use_lldb_suite_root", 
loader=loader)
+module = importlib.util.module_from_spec(spec)
+loader.exec_module(module)
+else:
+import imp
+
+fp, pathname, desc = imp.find_module("use_lldb_suite_root", [lldb_root])
+try:
+imp.load_module("use_lldb_suite_root", fp, pathname, desc)
+finally:
+if fp:
+fp.close()
diff --git a/lldb/test/API/use_lldb_suite.py b/lldb/test/API/use_lldb_suite.py
index e237dd4b8a5607c..c9332d9921b4eb3 100644
--- a/lldb/test/API/use_lldb_suite.py
+++ b/lldb/test/API/use_lldb_suite.py
@@ -20,11 +20,24 @@ def find_lldb_root():
 
 lldb_root = find_lldb_root()
 
-import imp
-
-fp, pathname, desc = imp.find_module("use_lldb_suite_root", [lldb_root])
-try:
-imp.load_module("use_lldb_suite_root", fp, pathname, desc)
-finally:
-if fp:
-fp.close()
+# Module imp got removed in Python 3.12.
+if (
+sys.version_info.major == 3 and sys.version_info.minor >= 12
+) or sys.version_info.major > 3:
+import importlib.machinery
+import importlib.util
+
+path = os.path.join(lldb_root, "use_lldb_suite_root.py")
+loader = importlib.machinery.SourceFileLoader("use_lldb_suite_root", path)
+spec = importlib.util.spec_from_loader("use_lldb_suite_root", 
loader=loader)
+module = importlib.util.module_from_spec(spec)
+loader.exec_module(module)
+else:
+import imp
+
+fp, pathname, desc = imp.find_module("use_lldb_suite_root", [lldb_root])
+try:
+imp.load_module("use_lldb_suite_root", fp, pathname, desc)
+finally:
+if fp:
+fp.close()

``




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


[Lldb-commits] [lldb] [lldb] Adapt code to Python 3.13 (PR #70445)

2023-10-27 Thread Tulio Magno Quites Machado Filho via lldb-commits

https://github.com/tuliom created 
https://github.com/llvm/llvm-project/pull/70445

1. Remove usage of PyEval_ThreadsInitialized and PyEval_InitThreads

Both of these functions were removed in Python 3.13 [1] after being deprecated 
since Python 3.9.

According to "What's new in Python 3.13" document [1]:

Since Python 3.7, Py_Initialize() always creates the GIL: calling
PyEval_InitThreads() did nothing and PyEval_ThreadsInitialized()
always returned non-zero.

2. Replace _Py_IsFinalizing() with Py_IsFinalizing().

[1] https://docs.python.org/3.13/whatsnew/3.13.html

>From ed87035da34be675df7ea78bdf5f7631d81ab2db Mon Sep 17 00:00:00 2001
From: Tulio Magno Quites Machado Filho 
Date: Wed, 25 Oct 2023 10:48:53 -0300
Subject: [PATCH] [lldb] Adapt code to Python 3.13

1. Remove usage of PyEval_ThreadsInitialized and PyEval_InitThreads

Both of these functions were removed in Python 3.13 [1] after being
deprecated since Python 3.9.

According to "What's new in Python 3.13" document [1]:

Since Python 3.7, Py_Initialize() always creates the GIL: calling
PyEval_InitThreads() did nothing and PyEval_ThreadsInitialized()
always returned non-zero.

2. Replace _Py_IsFinalizing() with Py_IsFinalizing().

[1] https://docs.python.org/3.13/whatsnew/3.13.html
---
 .../ScriptInterpreter/Python/PythonDataObjects.cpp   | 4 +++-
 .../ScriptInterpreter/Python/ScriptInterpreterPython.cpp | 9 +
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp 
b/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
index 9ac840a4a102da3..fe3438c42471543 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
@@ -71,7 +71,9 @@ Expected 
python::As(Expected &&obj) {
 }
 
 static bool python_is_finalizing() {
-#if PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION < 7
+#if (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 13) || (PY_MAJOR_VERSION > 3)
+  return Py_IsFinalizing();
+#elif PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION < 7
   return _Py_Finalizing != nullptr;
 #else
   return _Py_IsFinalizing();
diff --git 
a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp 
b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
index a57c8e4984ad8a8..968cc8ca03001e5 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -179,18 +179,27 @@ struct InitializePythonRAII {
   return;
 #endif
 
+// `PyEval_ThreadsInitialized` was deprecated in Python 3.9 and removed in
+// Python 3.13. It has been returning `true` always since Python 3.7.
+#if (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION < 9) || (PY_MAJOR_VERSION < 3)
 if (PyEval_ThreadsInitialized()) {
+#endif
   Log *log = GetLog(LLDBLog::Script);
 
   m_was_already_initialized = true;
   m_gil_state = PyGILState_Ensure();
   LLDB_LOGV(log, "Ensured PyGILState. Previous state = {0}locked\n",
 m_gil_state == PyGILState_UNLOCKED ? "un" : "");
+
+// `PyEval_InitThreads` was deprecated in Python 3.9 and removed in
+// Python 3.13.
+#if (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION < 9) || (PY_MAJOR_VERSION < 3)
   return;
 }
 
 // InitThreads acquires the GIL if it hasn't been called before.
 PyEval_InitThreads();
+#endif
   }
 
   PyGILState_STATE m_gil_state = PyGILState_UNLOCKED;

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


[Lldb-commits] [lldb] [lldb] Adapt code to Python 3.13 (PR #70445)

2023-10-27 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Tulio Magno Quites Machado Filho (tuliom)


Changes

1. Remove usage of PyEval_ThreadsInitialized and PyEval_InitThreads

Both of these functions were removed in Python 3.13 [1] after being deprecated 
since Python 3.9.

According to "What's new in Python 3.13" document [1]:

Since Python 3.7, Py_Initialize() always creates the GIL: calling
PyEval_InitThreads() did nothing and PyEval_ThreadsInitialized()
always returned non-zero.

2. Replace _Py_IsFinalizing() with Py_IsFinalizing().

[1] https://docs.python.org/3.13/whatsnew/3.13.html

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


2 Files Affected:

- (modified) lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp 
(+3-1) 
- (modified) 
lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp (+9) 


``diff
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp 
b/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
index 9ac840a4a102da3..fe3438c42471543 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
@@ -71,7 +71,9 @@ Expected 
python::As(Expected &&obj) {
 }
 
 static bool python_is_finalizing() {
-#if PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION < 7
+#if (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 13) || (PY_MAJOR_VERSION > 3)
+  return Py_IsFinalizing();
+#elif PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION < 7
   return _Py_Finalizing != nullptr;
 #else
   return _Py_IsFinalizing();
diff --git 
a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp 
b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
index a57c8e4984ad8a8..968cc8ca03001e5 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -179,18 +179,27 @@ struct InitializePythonRAII {
   return;
 #endif
 
+// `PyEval_ThreadsInitialized` was deprecated in Python 3.9 and removed in
+// Python 3.13. It has been returning `true` always since Python 3.7.
+#if (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION < 9) || (PY_MAJOR_VERSION < 3)
 if (PyEval_ThreadsInitialized()) {
+#endif
   Log *log = GetLog(LLDBLog::Script);
 
   m_was_already_initialized = true;
   m_gil_state = PyGILState_Ensure();
   LLDB_LOGV(log, "Ensured PyGILState. Previous state = {0}locked\n",
 m_gil_state == PyGILState_UNLOCKED ? "un" : "");
+
+// `PyEval_InitThreads` was deprecated in Python 3.9 and removed in
+// Python 3.13.
+#if (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION < 9) || (PY_MAJOR_VERSION < 3)
   return;
 }
 
 // InitThreads acquires the GIL if it hasn't been called before.
 PyEval_InitThreads();
+#endif
   }
 
   PyGILState_STATE m_gil_state = PyGILState_UNLOCKED;

``




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


[Lldb-commits] [lldb] [clang]set invalid for lambda which missing capture `this` (PR #70432)

2023-10-27 Thread via lldb-commits


@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -verify -fsyntax-only -std=c++17 %s
+
+struct S {
+  int n;
+  int d = (4, []() { return n; }());  // expected-error {{'this' cannot be 
implicitly captured in this context}} \
+  // expected-note {{explicitly capture 
'this'}}
+};

cor3ntin wrote:

Can you move that test to an existing file? Maybe 
test/SemaCXX/lambda-implicit-this-capture.cpp
(in a `GH67687` namespace)

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


[Lldb-commits] [lldb] [lldb] Replace the usage of module imp with module importlib (PR #70443)

2023-10-27 Thread David Spickett via lldb-commits

DavidSpickett wrote:

Do you know when `importlib` was added? I wonder if the overlap is enough to 
not need a fallback. We appear to advertise a 3.6 or 3.7 minimum in our 
documentation, and llvm wants >=3.6 
(https://llvm.org/docs/GettingStarted.html#software).

@JDevlieghere will know for sure.

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


[Lldb-commits] [lldb] [lldb] Replace the usage of module imp with module importlib (PR #70443)

2023-10-27 Thread Tulio Magno Quites Machado Filho via lldb-commits

tuliom wrote:

[This document](https://docs.python.org/3/library/importlib.html) mentions 3.1.
Many functions were added after 3.6, but none of them are being explicitly used 
in this patch.
I'm afraid the easiest way to guarantee is by testing with Python 3.6.

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


[Lldb-commits] [lldb] [lldb] Replace the usage of module imp with module importlib (PR #70443)

2023-10-27 Thread Tulio Magno Quites Machado Filho via lldb-commits

tuliom wrote:

I believe it's also important to mention this PR does not solve issue #70453.
But it helps to solve `ModuleNotFoundError: No module named 'imp'` kind of 
issues.

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


[Lldb-commits] [lldb] [OpenACC] Initial commits to support OpenACC (PR #70234)

2023-10-27 Thread Erich Keane via lldb-commits

erichkeane wrote:

Build failures are all 1 test, and are:

`File 
/var/lib/buildkite-agent/builds/linux-56-59b8f5d88-fdgrz-1/llvm-project/clang-ci/libcxx/test/libcxx/algorithms/cpp17_iterator_concepts.verify.cpp
 Line 410: cannot find start of regex ('{{') in static assertion failed`

The patch responsible was reverted here: 
https://github.com/llvm/llvm-project/commit/fde1ecdec878be591479f508d6a373701deb137e

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


[Lldb-commits] [lldb] d8003d0 - [lldb][lldb-dap] Remove extra spaces at the end of --help examples

2023-10-27 Thread David Spickett via lldb-commits

Author: David Spickett
Date: 2023-10-27T15:35:15Z
New Revision: d8003d021b87485836a8f685b0ac6473069c229b

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

LOG: [lldb][lldb-dap] Remove extra spaces at the end of --help examples

Added: 


Modified: 
lldb/tools/lldb-dap/lldb-dap.cpp

Removed: 




diff  --git a/lldb/tools/lldb-dap/lldb-dap.cpp 
b/lldb/tools/lldb-dap/lldb-dap.cpp
index b5d06a977a449b7..e103aabb870207f 100644
--- a/lldb/tools/lldb-dap/lldb-dap.cpp
+++ b/lldb/tools/lldb-dap/lldb-dap.cpp
@@ -3591,7 +3591,7 @@ static void printHelp(LLDBDAPOptTable &table, 
llvm::StringRef tool_name) {
   debugger to attach to the process.
 
 lldb-dap -g
-  )___";
+)___";
   llvm::outs() << examples;
 }
 



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


[Lldb-commits] [lldb] [mlir] Add config for PDL (PR #69927)

2023-10-27 Thread Jacques Pienaar via lldb-commits

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


[Lldb-commits] [lldb] [mlir] Add config for PDL (PR #69927)

2023-10-27 Thread Jacques Pienaar via lldb-commits

jpienaar wrote:

> Can you expand on the motivation? Why is it a problem that PDL is always 
> included? Your description isn’t very explicit on the impact.

Done. Its not PDL specific, I think it is a problem if any dialect is always 
included even if not used :) The others just have a simple method to elide.

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


[Lldb-commits] [lldb] [OpenMP] Improve omp offload profiler (PR #68016)

2023-10-27 Thread via lldb-commits

https://github.com/fel-cab updated 
https://github.com/llvm/llvm-project/pull/68016

>From dd44de067c26ba94b6561c5ed7fa4a5d812a3d1a Mon Sep 17 00:00:00 2001
From: Felipe Cabarcas 
Date: Mon, 18 Sep 2023 12:07:12 +
Subject: [PATCH 01/13] testing Profiler features

---
 openmp/libomptarget/src/interface.cpp | 5 -
 openmp/libomptarget/src/private.h | 3 ++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/openmp/libomptarget/src/interface.cpp 
b/openmp/libomptarget/src/interface.cpp
index 5f21b16b3fbfb1e..f64e1e268a3952e 100644
--- a/openmp/libomptarget/src/interface.cpp
+++ b/openmp/libomptarget/src/interface.cpp
@@ -252,7 +252,10 @@ static inline int targetKernel(ident_t *Loc, int64_t 
DeviceId, int32_t NumTeams,
   static_assert(std::is_convertible_v,
 "Target AsyncInfoTy must be convertible to AsyncInfoTy.");
 
-  TIMESCOPE_WITH_IDENT(Loc);
+  //TIMESCOPE_WITH_IDENT(Loc);
+  TIMESCOPE();
+  //TIMESCOPE_WITH_NAME_AND_IDENT("Hello", Loc);
+  //TIMESCOPE_WITH_RTM_AND_IDENT("Hello", Loc);
 
   DP("Entering target region for device %" PRId64 " with entry point " DPxMOD
  "\n",
diff --git a/openmp/libomptarget/src/private.h 
b/openmp/libomptarget/src/private.h
index cbce15b63a3eba2..dc6cd3944233955 100644
--- a/openmp/libomptarget/src/private.h
+++ b/openmp/libomptarget/src/private.h
@@ -433,7 +433,8 @@ class ExponentialBackoff {
   SourceInfo SI(IDENT);
\
   std::string ProfileLocation = SI.getProfileLocation();   
\
   std::string RTM = RegionTypeMsg; 
\
-  llvm::TimeTraceScope TimeScope(__FUNCTION__, ProfileLocation + RTM)
+  llvm::TimeTraceScope TimeScope(ProfileLocation, ProfileLocation + RTM)
+  //llvm::TimeTraceScope TimeScope(__FUNCTION__, ProfileLocation + RTM)
 #else
 #define TIMESCOPE()
 #define TIMESCOPE_WITH_IDENT(IDENT)

>From 92586bca6364100c7511ad38a30f41b0f86dea9c Mon Sep 17 00:00:00 2001
From: Felipe Cabarcas 
Date: Tue, 19 Sep 2023 12:02:53 +
Subject: [PATCH 02/13] Improve Profiler 1

---
 llvm/lib/Support/TimeProfiler.cpp |  2 +-
 openmp/libomptarget/src/interface.cpp | 17 +
 openmp/libomptarget/src/omptarget.cpp | 10 +-
 openmp/libomptarget/src/private.h |  5 +++--
 4 files changed, 18 insertions(+), 16 deletions(-)

diff --git a/llvm/lib/Support/TimeProfiler.cpp 
b/llvm/lib/Support/TimeProfiler.cpp
index 4d625b3eb5b1709..e1458116f64ab47 100644
--- a/llvm/lib/Support/TimeProfiler.cpp
+++ b/llvm/lib/Support/TimeProfiler.cpp
@@ -227,7 +227,7 @@ struct llvm::TimeTraceProfiler {
 J.attribute("ph", "X");
 J.attribute("ts", 0);
 J.attribute("dur", DurUs);
-J.attribute("name", "Total " + Total.first);
+J.attribute("name", "Total: " + Total.first);
 J.attributeObject("args", [&] {
   J.attribute("count", int64_t(Count));
   J.attribute("avg ms", int64_t(DurUs / Count / 1000));
diff --git a/openmp/libomptarget/src/interface.cpp 
b/openmp/libomptarget/src/interface.cpp
index f64e1e268a3952e..b8892cbe689107f 100644
--- a/openmp/libomptarget/src/interface.cpp
+++ b/openmp/libomptarget/src/interface.cpp
@@ -33,14 +33,14 @@ using namespace llvm::omp::target::ompt;
 

 /// adds requires flags
 EXTERN void __tgt_register_requires(int64_t Flags) {
-  TIMESCOPE();
+  //TIMESCOPE();
   PM->RTLs.registerRequires(Flags);
 }
 
 

 /// adds a target shared library to the target execution image
 EXTERN void __tgt_register_lib(__tgt_bin_desc *Desc) {
-  TIMESCOPE();
+  //TIMESCOPE();
   if (PM->maybeDelayRegisterLib(Desc))
 return;
 
@@ -61,7 +61,7 @@ EXTERN void __tgt_init_all_rtls() { PM->RTLs.initAllRTLs(); }
 

 /// unloads a target shared library
 EXTERN void __tgt_unregister_lib(__tgt_bin_desc *Desc) {
-  TIMESCOPE();
+  //TIMESCOPE();
   PM->RTLs.unregisterLib(Desc);
   for (auto &RTL : PM->RTLs.UsedRTLs) {
 if (RTL->unregister_lib) {
@@ -82,7 +82,8 @@ targetData(ident_t *Loc, int64_t DeviceId, int32_t ArgNum, 
void **ArgsBase,
   static_assert(std::is_convertible_v,
 "TargetAsyncInfoTy must be convertible to AsyncInfoTy.");
 
-  TIMESCOPE_WITH_RTM_AND_IDENT(RegionTypeMsg, Loc);
+  //TIMESCOPE_WITH_RTM_AND_IDENT(RegionTypeMsg, Loc);
+  TIMESCOPE_WITH_RTM_AND_IDENT("targetData", Loc);
 
   DP("Entering data %s region for device %" PRId64 " with %d mappings\n",
  RegionName, DeviceId, ArgNum);
@@ -253,9 +254,9 @@ static inline int targetKernel(ident_t *Loc, int64_t 
DeviceId, int32_t NumTeams,
 "Target AsyncInfoTy must be convertible to AsyncInfoTy.");
 
   //TIMESCOPE_WITH_IDENT(Loc);
-  TIMESCOPE();
+  //TIMESCOPE();
   //TIMESCOPE_WITH_NAME_AND_IDENT("Hello", Loc);
-

[Lldb-commits] [lldb] [lldb] Replace the usage of module imp with module importlib (PR #70443)

2023-10-27 Thread Alex Langford via lldb-commits

https://github.com/bulbazord commented:

`importlib` has been around since Python 3.1, maybe we shouldn't have the 
conditional logic to use `imp` instead? I'm pretty sure the minimum supported 
version is 3.6 since that's what LLVM requires.

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


[Lldb-commits] [lldb] [lldb] Add logging to ObjectFileMachO::ParseSymtab (PR #70490)

2023-10-27 Thread Jonas Devlieghere via lldb-commits

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

I have a crash when parsing the dyld trie data and I want to ask the originator 
to send me the (possibly corrupted) binary that's causing this. This patch adds 
some logging to help pinpoint that file.

>From d2202447c895de0f18eade952353dc194971a012 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Fri, 27 Oct 2023 11:17:17 -0700
Subject: [PATCH] [lldb] Add logging to ObjectFileMachO::ParseSymtab

I have a crash when parsing the dyld trie data and I want to ask the
originator to send me the (possibly corrupted) binary that's causing
this. This patch adds some logging to help pinpoint that file.
---
 lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp 
b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
index efcfdf5ac2cd37e..db186ab95802017 100644
--- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -2220,9 +2220,12 @@ void ObjectFileMachO::ParseSymtab(Symtab &symtab) {
   if (!module_sp)
 return;
 
+  Log *log = GetLog(LLDBLog::Symbols);
+
   const FileSpec &file = m_file ? m_file : module_sp->GetFileSpec();
   const char *file_name = file.GetFilename().AsCString("");
   LLDB_SCOPED_TIMERF("ObjectFileMachO::ParseSymtab () module = %s", file_name);
+  LLDB_LOG(log, "Parsing symbol table for {0}", file_name);
   Progress progress(llvm::formatv("Parsing symbol table for {0}", file_name));
 
   llvm::MachO::symtab_command symtab_load_command = {0, 0, 0, 0, 0, 0};
@@ -2252,7 +2255,6 @@ void ObjectFileMachO::ParseSymtab(Symtab &symtab) {
   lldb::offset_t offset = MachHeaderSizeFromMagic(m_header.magic);
   uint32_t i;
   FileSpecList dylib_files;
-  Log *log = GetLog(LLDBLog::Symbols);
   llvm::StringRef g_objc_v2_prefix_class("_OBJC_CLASS_$_");
   llvm::StringRef g_objc_v2_prefix_metaclass("_OBJC_METACLASS_$_");
   llvm::StringRef g_objc_v2_prefix_ivar("_OBJC_IVAR_$_");
@@ -2652,7 +2654,9 @@ void ObjectFileMachO::ParseSymtab(Symtab &symtab) {
   std::vector external_sym_trie_entries;
   std::set resolver_addresses;
 
-  if (dyld_trie_data.GetByteSize() > 0) {
+  const size_t dyld_trie_data_size = dyld_trie_data.GetByteSize();
+  if (dyld_trie_data_size > 0) {
+LLDB_LOG(log, "Parsing {0} bytes of dyld trie data", dyld_trie_data_size);
 SectionSP text_segment_sp =
 GetSectionList()->FindSectionByName(GetSegmentNameTEXT());
 lldb::addr_t text_segment_file_addr = LLDB_INVALID_ADDRESS;

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


[Lldb-commits] [lldb] [lldb] Add logging to ObjectFileMachO::ParseSymtab (PR #70490)

2023-10-27 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Jonas Devlieghere (JDevlieghere)


Changes

I have a crash when parsing the dyld trie data and I want to ask the originator 
to send me the (possibly corrupted) binary that's causing this. This patch adds 
some logging to help pinpoint that file.

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


1 Files Affected:

- (modified) lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp (+6-2) 


``diff
diff --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp 
b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
index efcfdf5ac2cd37e..db186ab95802017 100644
--- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -2220,9 +2220,12 @@ void ObjectFileMachO::ParseSymtab(Symtab &symtab) {
   if (!module_sp)
 return;
 
+  Log *log = GetLog(LLDBLog::Symbols);
+
   const FileSpec &file = m_file ? m_file : module_sp->GetFileSpec();
   const char *file_name = file.GetFilename().AsCString("");
   LLDB_SCOPED_TIMERF("ObjectFileMachO::ParseSymtab () module = %s", file_name);
+  LLDB_LOG(log, "Parsing symbol table for {0}", file_name);
   Progress progress(llvm::formatv("Parsing symbol table for {0}", file_name));
 
   llvm::MachO::symtab_command symtab_load_command = {0, 0, 0, 0, 0, 0};
@@ -2252,7 +2255,6 @@ void ObjectFileMachO::ParseSymtab(Symtab &symtab) {
   lldb::offset_t offset = MachHeaderSizeFromMagic(m_header.magic);
   uint32_t i;
   FileSpecList dylib_files;
-  Log *log = GetLog(LLDBLog::Symbols);
   llvm::StringRef g_objc_v2_prefix_class("_OBJC_CLASS_$_");
   llvm::StringRef g_objc_v2_prefix_metaclass("_OBJC_METACLASS_$_");
   llvm::StringRef g_objc_v2_prefix_ivar("_OBJC_IVAR_$_");
@@ -2652,7 +2654,9 @@ void ObjectFileMachO::ParseSymtab(Symtab &symtab) {
   std::vector external_sym_trie_entries;
   std::set resolver_addresses;
 
-  if (dyld_trie_data.GetByteSize() > 0) {
+  const size_t dyld_trie_data_size = dyld_trie_data.GetByteSize();
+  if (dyld_trie_data_size > 0) {
+LLDB_LOG(log, "Parsing {0} bytes of dyld trie data", dyld_trie_data_size);
 SectionSP text_segment_sp =
 GetSectionList()->FindSectionByName(GetSegmentNameTEXT());
 lldb::addr_t text_segment_file_addr = LLDB_INVALID_ADDRESS;

``




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


[Lldb-commits] [lldb] [lldb] Make use of Scripted{Python, }Interface for ScriptedThreadPlan (PR #70392)

2023-10-27 Thread Alex Langford via lldb-commits


@@ -0,0 +1,92 @@
+//===-- ScriptedThreadPlanPythonInterface.cpp 
-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "lldb/Host/Config.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/lldb-enumerations.h"
+
+#if LLDB_ENABLE_PYTHON
+
+// LLDB Python header must be included first
+#include "../lldb-python.h"
+
+#include "../SWIGPythonBridge.h"
+#include "../ScriptInterpreterPythonImpl.h"
+#include "ScriptedThreadPlanPythonInterface.h"
+
+using namespace lldb;
+using namespace lldb_private;
+using namespace lldb_private::python;
+
+ScriptedThreadPlanPythonInterface::ScriptedThreadPlanPythonInterface(
+ScriptInterpreterPythonImpl &interpreter)
+: ScriptedThreadPlanInterface(), ScriptedPythonInterface(interpreter) {}
+
+llvm::Expected
+ScriptedThreadPlanPythonInterface::CreatePluginObject(
+const llvm::StringRef class_name, lldb::ThreadPlanSP thread_plan_sp,
+const StructuredDataImpl &args_sp) {
+  return ScriptedPythonInterface::CreatePluginObject(class_name, nullptr,
+ thread_plan_sp, args_sp);
+}
+
+llvm::Expected
+ScriptedThreadPlanPythonInterface::ExplainsStop(Event *event) {
+  Status error;
+  StructuredData::ObjectSP obj = Dispatch("explains_stop", error, event);
+
+  if (!CheckStructuredDataObject(LLVM_PRETTY_FUNCTION, obj, error))
+return error.ToError();
+
+  return obj->GetBooleanValue();
+}
+
+llvm::Expected
+ScriptedThreadPlanPythonInterface::ShouldStop(Event *event) {
+  Status error;
+  StructuredData::ObjectSP obj = Dispatch("should_stop", error, event);
+
+  if (!CheckStructuredDataObject(LLVM_PRETTY_FUNCTION, obj, error))
+return error.ToError();
+
+  return obj->GetBooleanValue();
+}
+
+llvm::Expected ScriptedThreadPlanPythonInterface::IsStale() {
+  Status error;
+  StructuredData::ObjectSP obj = Dispatch("is_stale", error);
+
+  if (!CheckStructuredDataObject(LLVM_PRETTY_FUNCTION, obj, error))
+return error.ToError();
+
+  return obj->GetBooleanValue();
+}
+
+lldb::StateType ScriptedThreadPlanPythonInterface::GetRunState() {
+  Status error;
+  StructuredData::ObjectSP obj = Dispatch("should_step", error);

bulbazord wrote:

You don't need to do anything but `should_step` is so close to `should_stop`... 
😱 

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


[Lldb-commits] [lldb] [lldb] Make use of Scripted{Python, }Interface for ScriptedThreadPlan (PR #70392)

2023-10-27 Thread Alex Langford via lldb-commits


@@ -0,0 +1,40 @@
+//===-- ScriptedThreadInterface.h ---*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLDB_INTERPRETER_INTERFACES_SCRIPTEDTHREADPLANINTERFACE_H
+#define LLDB_INTERPRETER_INTERFACES_SCRIPTEDTHREADPLANINTERFACE_H
+
+#include "lldb/lldb-private.h"
+
+#include "ScriptedInterface.h"
+
+namespace lldb_private {
+class ScriptedThreadPlanInterface : public ScriptedInterface {
+public:
+  virtual llvm::Expected
+  CreatePluginObject(llvm::StringRef class_name,
+ lldb::ThreadPlanSP thread_plan_sp,
+ const StructuredDataImpl &args_sp) {
+llvm_unreachable("unimplemented!");
+  }
+
+  virtual llvm::Expected ExplainsStop(Event *event) { return true; }
+
+  virtual llvm::Expected ShouldStop(Event *event) { return true; }
+
+  virtual llvm::Expected IsStale() { return true; };
+
+  virtual lldb::StateType GetRunState() { return lldb::eStateStepping; }
+
+  virtual llvm::Expected GetStopDescription(lldb_private::Stream *s) {
+return true;

bulbazord wrote:

Why not make all of these pure virtual methods?

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


[Lldb-commits] [lldb] [lldb] Make use of Scripted{Python, }Interface for ScriptedThreadPlan (PR #70392)

2023-10-27 Thread Alex Langford via lldb-commits


@@ -0,0 +1,40 @@
+//===-- ScriptedThreadInterface.h ---*- C++ 
-*-===//

bulbazord wrote:

The header is missing the world `Plan`

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


[Lldb-commits] [lldb] [lldb] Make use of Scripted{Python, }Interface for ScriptedThreadPlan (PR #70392)

2023-10-27 Thread Alex Langford via lldb-commits


@@ -104,6 +104,19 @@ ScriptInterpreter::GetStatusFromSBError(const 
lldb::SBError &error) const {
   return Status();
 }
 
+Event *
+ScriptInterpreter::GetOpaqueTypeFromSBEvent(const lldb::SBEvent &event) const {
+  return event.m_opaque_ptr;
+}
+
+Stream *ScriptInterpreter::GetOpaqueTypeFromSBStream(
+const lldb::SBStream &stream) const {
+  if (stream.m_opaque_up)
+return const_cast(stream).m_opaque_up.release();

bulbazord wrote:

This feels a little sketchy to me... `GetOpaqueTypeFromSBStream` is taking 
ownership of the underlying pointer and returning it to the caller. The 
`SBStream` that gets passed in is no longer valid. Is this intentional? That 
would mean this function -- and only this function -- has different semantics 
from the other `GetOpaqueTypeFromSBClass` functions.

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


[Lldb-commits] [lldb] [lldb] Make use of Scripted{Python, }Interface for ScriptedThreadPlan (PR #70392)

2023-10-27 Thread Alex Langford via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Add logging to ObjectFileMachO::ParseSymtab (PR #70490)

2023-10-27 Thread Alex Langford via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Add logging to ObjectFileMachO::ParseSymtab (PR #70490)

2023-10-27 Thread Alex Langford via lldb-commits

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

looks fine to me, one small question though

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


[Lldb-commits] [lldb] [lldb] Add logging to ObjectFileMachO::ParseSymtab (PR #70490)

2023-10-27 Thread Alex Langford via lldb-commits


@@ -2652,7 +2654,9 @@ void ObjectFileMachO::ParseSymtab(Symtab &symtab) {
   std::vector external_sym_trie_entries;
   std::set resolver_addresses;
 
-  if (dyld_trie_data.GetByteSize() > 0) {
+  const size_t dyld_trie_data_size = dyld_trie_data.GetByteSize();
+  if (dyld_trie_data_size > 0) {

bulbazord wrote:

Why did you pull this out?

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


[Lldb-commits] [lldb] 11b3b38 - [lldb] Make ScriptedInterface::CreateObjectPlugin less strict

2023-10-27 Thread Med Ismail Bennani via lldb-commits

Author: Med Ismail Bennani
Date: 2023-10-27T11:58:59-07:00
New Revision: 11b3b3834cfdd9183eff903ef8ac34a733af2068

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

LOG: [lldb] Make ScriptedInterface::CreateObjectPlugin less strict

This patches changes the implementation of `CreateObjectPlugin` in the
various base ScriptedInterface classes, to return an `UnimplementedError`
instead of triggering an assertion.

Signed-off-by: Med Ismail Bennani 

Added: 


Modified: 
lldb/include/lldb/Interpreter/Interfaces/ScriptedInterface.h
lldb/include/lldb/Interpreter/Interfaces/ScriptedPlatformInterface.h
lldb/include/lldb/Interpreter/Interfaces/ScriptedProcessInterface.h
lldb/include/lldb/Interpreter/Interfaces/ScriptedThreadInterface.h

Removed: 




diff  --git a/lldb/include/lldb/Interpreter/Interfaces/ScriptedInterface.h 
b/lldb/include/lldb/Interpreter/Interfaces/ScriptedInterface.h
index 2406f0f1f9aee27..e4816352daa5db6 100644
--- a/lldb/include/lldb/Interpreter/Interfaces/ScriptedInterface.h
+++ b/lldb/include/lldb/Interpreter/Interfaces/ScriptedInterface.h
@@ -13,6 +13,7 @@
 #include "lldb/Target/ExecutionContext.h"
 #include "lldb/Utility/LLDBLog.h"
 #include "lldb/Utility/Log.h"
+#include "lldb/Utility/UnimplementedError.h"
 #include "lldb/lldb-private.h"
 
 #include "llvm/Support/Compiler.h"

diff  --git 
a/lldb/include/lldb/Interpreter/Interfaces/ScriptedPlatformInterface.h 
b/lldb/include/lldb/Interpreter/Interfaces/ScriptedPlatformInterface.h
index dc3630fc75d9e1a..2dcbb47ffa6de85 100644
--- a/lldb/include/lldb/Interpreter/Interfaces/ScriptedPlatformInterface.h
+++ b/lldb/include/lldb/Interpreter/Interfaces/ScriptedPlatformInterface.h
@@ -23,8 +23,7 @@ class ScriptedPlatformInterface : virtual public 
ScriptedInterface {
   CreatePluginObject(llvm::StringRef class_name, ExecutionContext &exe_ctx,
  StructuredData::DictionarySP args_sp,
  StructuredData::Generic *script_obj = nullptr) {
-llvm_unreachable(
-"Cannot create an instance of the ScriptedPlatformInterface!");
+return {llvm::make_error()};
   }
 
   virtual StructuredData::DictionarySP ListProcesses() { return {}; }

diff  --git 
a/lldb/include/lldb/Interpreter/Interfaces/ScriptedProcessInterface.h 
b/lldb/include/lldb/Interpreter/Interfaces/ScriptedProcessInterface.h
index bedeaf25ae0cb9c..a429cacd862f121 100644
--- a/lldb/include/lldb/Interpreter/Interfaces/ScriptedProcessInterface.h
+++ b/lldb/include/lldb/Interpreter/Interfaces/ScriptedProcessInterface.h
@@ -12,7 +12,6 @@
 #include "ScriptedInterface.h"
 #include "lldb/Core/StructuredDataImpl.h"
 #include "lldb/Target/MemoryRegionInfo.h"
-#include "lldb/Utility/UnimplementedError.h"
 
 #include "lldb/lldb-private.h"
 

diff  --git 
a/lldb/include/lldb/Interpreter/Interfaces/ScriptedThreadInterface.h 
b/lldb/include/lldb/Interpreter/Interfaces/ScriptedThreadInterface.h
index 65ec2b0387df07b..107e593b5561ef7 100644
--- a/lldb/include/lldb/Interpreter/Interfaces/ScriptedThreadInterface.h
+++ b/lldb/include/lldb/Interpreter/Interfaces/ScriptedThreadInterface.h
@@ -24,8 +24,7 @@ class ScriptedThreadInterface : virtual public 
ScriptedInterface {
   CreatePluginObject(llvm::StringRef class_name, ExecutionContext &exe_ctx,
  StructuredData::DictionarySP args_sp,
  StructuredData::Generic *script_obj = nullptr) {
-llvm_unreachable(
-"Cannot create an instance of the ScriptedThreadInterface!");
+return {llvm::make_error()};
   }
 
   virtual lldb::tid_t GetThreadID() { return LLDB_INVALID_THREAD_ID; }



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


[Lldb-commits] [lldb] [lldb] Make use of Scripted{Python, }Interface for ScriptedThreadPlan (PR #70392)

2023-10-27 Thread Med Ismail Bennani via lldb-commits


@@ -0,0 +1,40 @@
+//===-- ScriptedThreadInterface.h ---*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLDB_INTERPRETER_INTERFACES_SCRIPTEDTHREADPLANINTERFACE_H
+#define LLDB_INTERPRETER_INTERFACES_SCRIPTEDTHREADPLANINTERFACE_H
+
+#include "lldb/lldb-private.h"
+
+#include "ScriptedInterface.h"
+
+namespace lldb_private {
+class ScriptedThreadPlanInterface : public ScriptedInterface {
+public:
+  virtual llvm::Expected
+  CreatePluginObject(llvm::StringRef class_name,
+ lldb::ThreadPlanSP thread_plan_sp,
+ const StructuredDataImpl &args_sp) {
+llvm_unreachable("unimplemented!");
+  }
+
+  virtual llvm::Expected ExplainsStop(Event *event) { return true; }
+
+  virtual llvm::Expected ShouldStop(Event *event) { return true; }
+
+  virtual llvm::Expected IsStale() { return true; };
+
+  virtual lldb::StateType GetRunState() { return lldb::eStateStepping; }
+
+  virtual llvm::Expected GetStopDescription(lldb_private::Stream *s) {
+return true;

medismailben wrote:

Same answer as in 
https://github.com/llvm/llvm-project/pull/68052#discussion_r1372058327.

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


[Lldb-commits] [lldb] [lldb] Make use of Scripted{Python, }Interface for ScriptedThreadPlan (PR #70392)

2023-10-27 Thread Med Ismail Bennani via lldb-commits


@@ -0,0 +1,92 @@
+//===-- ScriptedThreadPlanPythonInterface.cpp 
-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "lldb/Host/Config.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/lldb-enumerations.h"
+
+#if LLDB_ENABLE_PYTHON
+
+// LLDB Python header must be included first
+#include "../lldb-python.h"
+
+#include "../SWIGPythonBridge.h"
+#include "../ScriptInterpreterPythonImpl.h"
+#include "ScriptedThreadPlanPythonInterface.h"
+
+using namespace lldb;
+using namespace lldb_private;
+using namespace lldb_private::python;
+
+ScriptedThreadPlanPythonInterface::ScriptedThreadPlanPythonInterface(
+ScriptInterpreterPythonImpl &interpreter)
+: ScriptedThreadPlanInterface(), ScriptedPythonInterface(interpreter) {}
+
+llvm::Expected
+ScriptedThreadPlanPythonInterface::CreatePluginObject(
+const llvm::StringRef class_name, lldb::ThreadPlanSP thread_plan_sp,
+const StructuredDataImpl &args_sp) {
+  return ScriptedPythonInterface::CreatePluginObject(class_name, nullptr,
+ thread_plan_sp, args_sp);
+}
+
+llvm::Expected
+ScriptedThreadPlanPythonInterface::ExplainsStop(Event *event) {
+  Status error;
+  StructuredData::ObjectSP obj = Dispatch("explains_stop", error, event);
+
+  if (!CheckStructuredDataObject(LLVM_PRETTY_FUNCTION, obj, error))
+return error.ToError();
+
+  return obj->GetBooleanValue();
+}
+
+llvm::Expected
+ScriptedThreadPlanPythonInterface::ShouldStop(Event *event) {
+  Status error;
+  StructuredData::ObjectSP obj = Dispatch("should_stop", error, event);
+
+  if (!CheckStructuredDataObject(LLVM_PRETTY_FUNCTION, obj, error))
+return error.ToError();
+
+  return obj->GetBooleanValue();
+}
+
+llvm::Expected ScriptedThreadPlanPythonInterface::IsStale() {
+  Status error;
+  StructuredData::ObjectSP obj = Dispatch("is_stale", error);
+
+  if (!CheckStructuredDataObject(LLVM_PRETTY_FUNCTION, obj, error))
+return error.ToError();
+
+  return obj->GetBooleanValue();
+}
+
+lldb::StateType ScriptedThreadPlanPythonInterface::GetRunState() {
+  Status error;
+  StructuredData::ObjectSP obj = Dispatch("should_step", error);

medismailben wrote:

Yep, but that's stable API at this point, can't change it at this time 😭 

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


[Lldb-commits] [lldb] [lldb] Make use of Scripted{Python, }Interface for ScriptedThreadPlan (PR #70392)

2023-10-27 Thread Med Ismail Bennani via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Adapt code to Python 3.13 (PR #70445)

2023-10-27 Thread Med Ismail Bennani via lldb-commits

medismailben wrote:

LGTM!

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


[Lldb-commits] [lldb] [lldb] Adapt code to Python 3.13 (PR #70445)

2023-10-27 Thread Med Ismail Bennani via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb] Make use of Scripted{Python, }Interface for ScriptedThreadPlan (PR #70392)

2023-10-27 Thread Med Ismail Bennani via lldb-commits


@@ -104,6 +104,19 @@ ScriptInterpreter::GetStatusFromSBError(const 
lldb::SBError &error) const {
   return Status();
 }
 
+Event *
+ScriptInterpreter::GetOpaqueTypeFromSBEvent(const lldb::SBEvent &event) const {
+  return event.m_opaque_ptr;
+}
+
+Stream *ScriptInterpreter::GetOpaqueTypeFromSBStream(
+const lldb::SBStream &stream) const {
+  if (stream.m_opaque_up)
+return const_cast(stream).m_opaque_up.release();

medismailben wrote:

`lldb::SBStream` have different semantics than other classes, as it uses a 
unique_ptr to point to its opaque type and  also `lldb_private::Stream` is an 
abstract type so the only way to get the underlying object is to do this. Let 
me know if you can think of a better way of doing it.

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


[Lldb-commits] [lldb] [lldb] Make use of Scripted{Python, }Interface for ScriptedThreadPlan (PR #70392)

2023-10-27 Thread Med Ismail Bennani via lldb-commits

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

>From 086c5f8a4056f027377e490c0387f2d1344cb5db Mon Sep 17 00:00:00 2001
From: Med Ismail Bennani 
Date: Fri, 27 Oct 2023 12:13:00 -0700
Subject: [PATCH] [lldb] Make use of Scripted{Python,}Interface for
 ScriptedThreadPlan

This patch makes ScriptedThreadPlan conforming to the ScriptedInterface
& ScriptedPythonInterface facilities by introducing 2
ScriptedThreadPlanInterface & ScriptedThreadPlanPythonInterface classes.

This allows us to get rid of every ScriptedThreadPlan-specific SWIG
method and re-use the same affordances as other scripting offordances,
like Scripted{Process,Thread,Platform} & OperatingSystem.

To do so, this adds new transformer methods for `ThreadPlan`, `Stream` &
`Event`, to allow the bijection between C++ objects and their python
counterparts.

Signed-off-by: Med Ismail Bennani 
---
 lldb/bindings/python/python-swigsafecast.swig |  13 +-
 lldb/bindings/python/python-wrapper.swig  | 153 +++---
 lldb/include/lldb/API/SBEvent.h   |   4 +-
 lldb/include/lldb/API/SBStream.h  |   9 ++
 .../Interfaces/ScriptedInterface.h|   4 +-
 .../Interfaces/ScriptedThreadPlanInterface.h  |  40 +
 .../lldb/Interpreter/ScriptInterpreter.h  |  56 ++-
 lldb/include/lldb/Target/ThreadPlanPython.h   |   2 +
 lldb/include/lldb/lldb-forward.h  |   3 +
 lldb/source/Interpreter/ScriptInterpreter.cpp |  13 ++
 .../Python/Interfaces/CMakeLists.txt  |   1 +
 .../ScriptedPlatformPythonInterface.cpp   |   2 +
 .../Interfaces/ScriptedPythonInterface.cpp|  34 
 .../Interfaces/ScriptedPythonInterface.h  |  20 +++
 .../ScriptedThreadPlanPythonInterface.cpp |  92 +++
 .../ScriptedThreadPlanPythonInterface.h   |  44 +
 .../ScriptedThreadPythonInterface.cpp |   1 +
 .../Python/SWIGPythonBridge.h |  21 +--
 .../Python/ScriptInterpreterPython.cpp| 122 +-
 .../Python/ScriptInterpreterPythonImpl.h  |  28 +---
 lldb/source/Target/ThreadPlanPython.cpp   |  92 ++-
 .../functionalities/step_scripted/Steps.py|   4 +-
 .../Python/PythonTestSuite.cpp|  45 +++---
 23 files changed, 398 insertions(+), 405 deletions(-)
 create mode 100644 
lldb/include/lldb/Interpreter/Interfaces/ScriptedThreadPlanInterface.h
 create mode 100644 
lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPlanPythonInterface.cpp
 create mode 100644 
lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPlanPythonInterface.h

diff --git a/lldb/bindings/python/python-swigsafecast.swig 
b/lldb/bindings/python/python-swigsafecast.swig
index d5ea5148727134d..fba3a77d8f2df44 100644
--- a/lldb/bindings/python/python-swigsafecast.swig
+++ b/lldb/bindings/python/python-swigsafecast.swig
@@ -37,10 +37,6 @@ PythonObject SWIGBridge::ToSWIGWrapper(const Status& status) 
{
   return ToSWIGHelper(new lldb::SBError(status), SWIGTYPE_p_lldb__SBError);
 }
 
-PythonObject SWIGBridge::ToSWIGWrapper(std::unique_ptr 
stream_sb) {
-  return ToSWIGHelper(stream_sb.release(), SWIGTYPE_p_lldb__SBStream);
-}
-
 PythonObject SWIGBridge::ToSWIGWrapper(std::unique_ptr 
data_sb) {
   return ToSWIGHelper(data_sb.release(), SWIGTYPE_p_lldb__SBStructuredData);
 }
@@ -115,9 +111,12 @@ SWIGBridge::ToSWIGWrapper(CommandReturnObject &cmd_retobj) 
{
   SWIGTYPE_p_lldb__SBCommandReturnObject);
 }
 
-ScopedPythonObject SWIGBridge::ToSWIGWrapper(Event *event) {
-  return ScopedPythonObject(new lldb::SBEvent(event),
-   SWIGTYPE_p_lldb__SBEvent);
+PythonObject SWIGBridge::ToSWIGWrapper(const Stream *s) {
+  return ToSWIGHelper(new lldb::SBStream(), SWIGTYPE_p_lldb__SBStream);
+}
+
+PythonObject SWIGBridge::ToSWIGWrapper(Event *event) {
+  return ToSWIGHelper(new lldb::SBEvent(event), SWIGTYPE_p_lldb__SBEvent);
 }
 
 PythonObject SWIGBridge::ToSWIGWrapper(
diff --git a/lldb/bindings/python/python-wrapper.swig 
b/lldb/bindings/python/python-wrapper.swig
index 17bc7b1f2198709..5c28d652824073a 100644
--- a/lldb/bindings/python/python-wrapper.swig
+++ b/lldb/bindings/python/python-wrapper.swig
@@ -229,133 +229,6 @@ PythonObject 
lldb_private::python::SWIGBridge::LLDBSwigPythonCreateCommandObject
   return pfunc(SWIGBridge::ToSWIGWrapper(std::move(debugger_sp)), dict);
 }
 
-PythonObject 
lldb_private::python::SWIGBridge::LLDBSwigPythonCreateScriptedThreadPlan(
-const char *python_class_name, const char *session_dictionary_name,
-const lldb_private::StructuredDataImpl &args_impl,
-std::string &error_string, const lldb::ThreadPlanSP &thread_plan_sp) {
-  if (python_class_name == NULL || python_class_name[0] == '\0' ||
-  !session_dictionary_name)
-return PythonObject();
-
-  PyErr_Cleaner py_err_cleaner(true);
-
-  auto dict = PythonModule::MainModule().ResolveName(
-  session_dictionary_name);
-  auto pfunc = PythonObject::R

[Lldb-commits] [lldb] [lldb] Add logging to ObjectFileMachO::ParseSymtab (PR #70490)

2023-10-27 Thread Jonas Devlieghere via lldb-commits


@@ -2652,7 +2654,9 @@ void ObjectFileMachO::ParseSymtab(Symtab &symtab) {
   std::vector external_sym_trie_entries;
   std::set resolver_addresses;
 
-  if (dyld_trie_data.GetByteSize() > 0) {
+  const size_t dyld_trie_data_size = dyld_trie_data.GetByteSize();
+  if (dyld_trie_data_size > 0) {

JDevlieghere wrote:

So I can reuse the value in the log line below. 

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


[Lldb-commits] [lldb] [lldb] Make use of Scripted{Python, }Interface for ScriptedThreadPlan (PR #70392)

2023-10-27 Thread Alex Langford via lldb-commits


@@ -104,6 +104,19 @@ ScriptInterpreter::GetStatusFromSBError(const 
lldb::SBError &error) const {
   return Status();
 }
 
+Event *
+ScriptInterpreter::GetOpaqueTypeFromSBEvent(const lldb::SBEvent &event) const {
+  return event.m_opaque_ptr;
+}
+
+Stream *ScriptInterpreter::GetOpaqueTypeFromSBStream(
+const lldb::SBStream &stream) const {
+  if (stream.m_opaque_up)
+return const_cast(stream).m_opaque_up.release();

bulbazord wrote:

I'm having a hard time wrapping my head around the SBStream portion of your 
patch (everything else makes sense). So we pass in a `const SBStream &` to 
`GetOpaqueTypeFromSBStream` which that takes ownership of the underlying 
`Stream *`  and returns it. What happens to the original SBStream argument? Can 
we guarantee that nothing ever tries to use it again afterwards?
It looks like the intent in `ReverseTransform` is to take ownership of the 
original user-provided stream and write its contents to some other stream 
`original_arg` after performing some kind of copy on it. Instead of taking 
ownership of the underlying stream (and invalidating its argument), why not 
just use `.get()` instead of `.release()`? The `SBStream` passed in here won't 
be invalidated and `original_arg` in `ReverseTransform` can still get the data 
out of the Python `SBStream` object.

What am I missing?

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


[Lldb-commits] [PATCH] D159127: [lldb][libc++] Adds chrono data formatters.

2023-10-27 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added a comment.

@Mordante @Michael137  This seems to fail on older versions of compiler/libcxx 
https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake-matrix/7247/ You can 
probably fix this by just requiring a minimum clang version in the tests


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D159127/new/

https://reviews.llvm.org/D159127

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


[Lldb-commits] [lldb] d3cbf9f - [lldb] Add logging to ObjectFileMachO::ParseSymtab (#70490)

2023-10-27 Thread via lldb-commits

Author: Jonas Devlieghere
Date: 2023-10-27T14:50:21-07:00
New Revision: d3cbf9fb64399dbf8718c600d8ac63bd1afaa9d1

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

LOG: [lldb] Add logging to ObjectFileMachO::ParseSymtab (#70490)

I have a crash when parsing the dyld trie data and I want to ask the
originator to send me the (possibly corrupted) binary that's causing
this. This patch adds some logging to help pinpoint that file.

Added: 


Modified: 
lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp

Removed: 




diff  --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp 
b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
index efcfdf5ac2cd37e..db186ab95802017 100644
--- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -2220,9 +2220,12 @@ void ObjectFileMachO::ParseSymtab(Symtab &symtab) {
   if (!module_sp)
 return;
 
+  Log *log = GetLog(LLDBLog::Symbols);
+
   const FileSpec &file = m_file ? m_file : module_sp->GetFileSpec();
   const char *file_name = file.GetFilename().AsCString("");
   LLDB_SCOPED_TIMERF("ObjectFileMachO::ParseSymtab () module = %s", file_name);
+  LLDB_LOG(log, "Parsing symbol table for {0}", file_name);
   Progress progress(llvm::formatv("Parsing symbol table for {0}", file_name));
 
   llvm::MachO::symtab_command symtab_load_command = {0, 0, 0, 0, 0, 0};
@@ -2252,7 +2255,6 @@ void ObjectFileMachO::ParseSymtab(Symtab &symtab) {
   lldb::offset_t offset = MachHeaderSizeFromMagic(m_header.magic);
   uint32_t i;
   FileSpecList dylib_files;
-  Log *log = GetLog(LLDBLog::Symbols);
   llvm::StringRef g_objc_v2_prefix_class("_OBJC_CLASS_$_");
   llvm::StringRef g_objc_v2_prefix_metaclass("_OBJC_METACLASS_$_");
   llvm::StringRef g_objc_v2_prefix_ivar("_OBJC_IVAR_$_");
@@ -2652,7 +2654,9 @@ void ObjectFileMachO::ParseSymtab(Symtab &symtab) {
   std::vector external_sym_trie_entries;
   std::set resolver_addresses;
 
-  if (dyld_trie_data.GetByteSize() > 0) {
+  const size_t dyld_trie_data_size = dyld_trie_data.GetByteSize();
+  if (dyld_trie_data_size > 0) {
+LLDB_LOG(log, "Parsing {0} bytes of dyld trie data", dyld_trie_data_size);
 SectionSP text_segment_sp =
 GetSectionList()->FindSectionByName(GetSegmentNameTEXT());
 lldb::addr_t text_segment_file_addr = LLDB_INVALID_ADDRESS;



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


[Lldb-commits] [lldb] [lldb] Add logging to ObjectFileMachO::ParseSymtab (PR #70490)

2023-10-27 Thread Jonas Devlieghere via lldb-commits

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


[Lldb-commits] [lldb] [LLVM][DWARF] Add support for monolithic types in .debug_names (PR #70512)

2023-10-27 Thread Jonas Devlieghere via lldb-commits

https://github.com/JDevlieghere updated 
https://github.com/llvm/llvm-project/pull/70512

>From 1c6a604df93b833c3bb9c7d34f4f27415592dbe5 Mon Sep 17 00:00:00 2001
From: Alexander Yermolovich 
Date: Thu, 5 Oct 2023 12:39:02 -0700
Subject: [PATCH] [LLVM][DWARF] Add support for monolithic types in
 .debug_names

Enable Type Units with DWARF5 accelerator tables for monolithic DWARF.
Implementation relies on linker to tombstone offset in LocalTU list to -1 when
it deduplciates type units using COMDAT.
---
 llvm/include/llvm/CodeGen/AccelTable.h|  64 +--
 llvm/lib/CodeGen/AsmPrinter/AccelTable.cpp| 173 --
 .../lib/CodeGen/AsmPrinter/DwarfCompileUnit.h |   2 +-
 llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp|  37 +++-
 llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h  |  12 +-
 llvm/lib/CodeGen/AsmPrinter/DwarfFile.cpp |   4 +
 llvm/lib/CodeGen/AsmPrinter/DwarfFile.h   |  20 ++
 llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp |   6 +
 llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h   |  15 ++
 llvm/lib/DWARFLinker/DWARFStreamer.cpp|  18 +-
 .../DWARFLinkerParallel/DWARFEmitterImpl.cpp  |  13 +-
 .../test/DebugInfo/X86/accel-tables-dwarf5.ll |   1 -
 .../test/DebugInfo/X86/debug-names-dwarf64.ll |   8 +-
 .../X86/debug-names-types-monolithic.ll   | 163 +
 .../DebugInfo/X86/debug-names-types-split.ll  |  57 ++
 .../ARM/dwarf5-dwarf4-combination-macho.test  |  14 +-
 16 files changed, 503 insertions(+), 104 deletions(-)
 create mode 100644 llvm/test/DebugInfo/X86/debug-names-types-monolithic.ll
 create mode 100644 llvm/test/DebugInfo/X86/debug-names-types-split.ll

diff --git a/llvm/include/llvm/CodeGen/AccelTable.h 
b/llvm/include/llvm/CodeGen/AccelTable.h
index d4e21b2ac8e7ebc..d948b7d82b85979 100644
--- a/llvm/include/llvm/CodeGen/AccelTable.h
+++ b/llvm/include/llvm/CodeGen/AccelTable.h
@@ -16,7 +16,6 @@
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/MapVector.h"
 #include "llvm/ADT/STLFunctionalExtras.h"
-#include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/BinaryFormat/Dwarf.h"
 #include "llvm/CodeGen/DIE.h"
@@ -104,10 +103,13 @@
 namespace llvm {
 
 class AsmPrinter;
-class DwarfCompileUnit;
+class DwarfUnit;
 class DwarfDebug;
+class DwarfTypeUnit;
 class MCSymbol;
 class raw_ostream;
+struct TypeUnitMetaInfo;
+using TUVectorTy = SmallVector;
 
 /// Interface which the different types of accelerator table data have to
 /// conform. It serves as a base class for different values of the template
@@ -197,6 +199,9 @@ template  class AccelTable : public 
AccelTableBase {
 
   template 
   void addName(DwarfStringPoolEntryRef Name, Types &&... Args);
+  void clear() { Entries.clear(); }
+  void addEntries(AccelTable &Table);
+  const StringEntries getEntries() const { return Entries; }
 };
 
 template 
@@ -250,11 +255,21 @@ class AppleAccelTableData : public AccelTableData {
 /// emitDWARF5AccelTable function.
 class DWARF5AccelTableData : public AccelTableData {
 public:
+  struct AttributeEncoding {
+dwarf::Index Index;
+dwarf::Form Form;
+  };
   static uint32_t hash(StringRef Name) { return caseFoldingDjbHash(Name); }
 
-  DWARF5AccelTableData(const DIE &Die, const DwarfCompileUnit &CU);
-  DWARF5AccelTableData(uint64_t DieOffset, unsigned DieTag, unsigned CUIndex)
-  : OffsetVal(DieOffset), DieTag(DieTag), UnitID(CUIndex) {}
+  DWARF5AccelTableData(const DIE &Die, const DwarfUnit &CU,
+   const bool IsTU = false);
+  DWARF5AccelTableData(const uint64_t DieOffset, const unsigned DieTag,
+   const unsigned Index, const bool IsTU = false)
+  : OffsetVal(DieOffset) {
+Data.DieTag = DieTag;
+Data.UnitID = Index;
+Data.IsTU = IsTU;
+  }
 
 #ifndef NDEBUG
   void print(raw_ostream &OS) const override;
@@ -265,18 +280,25 @@ class DWARF5AccelTableData : public AccelTableData {
"Accessing DIE Offset before normalizing.");
 return std::get(OffsetVal);
   }
-  unsigned getDieTag() const { return DieTag; }
-  unsigned getUnitID() const { return UnitID; }
+  unsigned getDieTag() const { return Data.DieTag; }
+  unsigned getUnitID() const { return Data.UnitID; }
+  bool isTU() const { return Data.IsTU; }
   void normalizeDIEToOffset() {
 assert(std::holds_alternative(OffsetVal) &&
"Accessing offset after normalizing.");
 OffsetVal = std::get(OffsetVal)->getOffset();
   }
+  bool isNormalized() const {
+return std::holds_alternative(OffsetVal);
+  }
 
 protected:
   std::variant OffsetVal;
-  unsigned DieTag;
-  unsigned UnitID;
+  struct MetaData {
+uint32_t DieTag : 16;
+uint32_t UnitID : 15;
+uint32_t IsTU : 1;
+  } Data;
 
   uint64_t order() const override { return getDieOffset(); }
 };
@@ -288,7 +310,19 @@ class DWARF5AccelTable : public 
AccelTable {
   void convertDieToOffset() {
 for (auto &Entry : Entries) {
   for (AccelTableData *Value : Entry.second.Values) {
-static_cast(Value)->norma

[Lldb-commits] [lldb] [LLVM][DWARF] Add support for monolithic types in .debug_names (PR #70512)

2023-10-27 Thread Alexander Yermolovich via lldb-commits

https://github.com/ayermolo updated 
https://github.com/llvm/llvm-project/pull/70512

>From 1c6a604df93b833c3bb9c7d34f4f27415592dbe5 Mon Sep 17 00:00:00 2001
From: Alexander Yermolovich 
Date: Thu, 5 Oct 2023 12:39:02 -0700
Subject: [PATCH] [LLVM][DWARF] Add support for monolithic types in
 .debug_names

Enable Type Units with DWARF5 accelerator tables for monolithic DWARF.
Implementation relies on linker to tombstone offset in LocalTU list to -1 when
it deduplciates type units using COMDAT.
---
 llvm/include/llvm/CodeGen/AccelTable.h|  64 +--
 llvm/lib/CodeGen/AsmPrinter/AccelTable.cpp| 173 --
 .../lib/CodeGen/AsmPrinter/DwarfCompileUnit.h |   2 +-
 llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp|  37 +++-
 llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h  |  12 +-
 llvm/lib/CodeGen/AsmPrinter/DwarfFile.cpp |   4 +
 llvm/lib/CodeGen/AsmPrinter/DwarfFile.h   |  20 ++
 llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp |   6 +
 llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h   |  15 ++
 llvm/lib/DWARFLinker/DWARFStreamer.cpp|  18 +-
 .../DWARFLinkerParallel/DWARFEmitterImpl.cpp  |  13 +-
 .../test/DebugInfo/X86/accel-tables-dwarf5.ll |   1 -
 .../test/DebugInfo/X86/debug-names-dwarf64.ll |   8 +-
 .../X86/debug-names-types-monolithic.ll   | 163 +
 .../DebugInfo/X86/debug-names-types-split.ll  |  57 ++
 .../ARM/dwarf5-dwarf4-combination-macho.test  |  14 +-
 16 files changed, 503 insertions(+), 104 deletions(-)
 create mode 100644 llvm/test/DebugInfo/X86/debug-names-types-monolithic.ll
 create mode 100644 llvm/test/DebugInfo/X86/debug-names-types-split.ll

diff --git a/llvm/include/llvm/CodeGen/AccelTable.h 
b/llvm/include/llvm/CodeGen/AccelTable.h
index d4e21b2ac8e7ebc..d948b7d82b85979 100644
--- a/llvm/include/llvm/CodeGen/AccelTable.h
+++ b/llvm/include/llvm/CodeGen/AccelTable.h
@@ -16,7 +16,6 @@
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/MapVector.h"
 #include "llvm/ADT/STLFunctionalExtras.h"
-#include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/BinaryFormat/Dwarf.h"
 #include "llvm/CodeGen/DIE.h"
@@ -104,10 +103,13 @@
 namespace llvm {
 
 class AsmPrinter;
-class DwarfCompileUnit;
+class DwarfUnit;
 class DwarfDebug;
+class DwarfTypeUnit;
 class MCSymbol;
 class raw_ostream;
+struct TypeUnitMetaInfo;
+using TUVectorTy = SmallVector;
 
 /// Interface which the different types of accelerator table data have to
 /// conform. It serves as a base class for different values of the template
@@ -197,6 +199,9 @@ template  class AccelTable : public 
AccelTableBase {
 
   template 
   void addName(DwarfStringPoolEntryRef Name, Types &&... Args);
+  void clear() { Entries.clear(); }
+  void addEntries(AccelTable &Table);
+  const StringEntries getEntries() const { return Entries; }
 };
 
 template 
@@ -250,11 +255,21 @@ class AppleAccelTableData : public AccelTableData {
 /// emitDWARF5AccelTable function.
 class DWARF5AccelTableData : public AccelTableData {
 public:
+  struct AttributeEncoding {
+dwarf::Index Index;
+dwarf::Form Form;
+  };
   static uint32_t hash(StringRef Name) { return caseFoldingDjbHash(Name); }
 
-  DWARF5AccelTableData(const DIE &Die, const DwarfCompileUnit &CU);
-  DWARF5AccelTableData(uint64_t DieOffset, unsigned DieTag, unsigned CUIndex)
-  : OffsetVal(DieOffset), DieTag(DieTag), UnitID(CUIndex) {}
+  DWARF5AccelTableData(const DIE &Die, const DwarfUnit &CU,
+   const bool IsTU = false);
+  DWARF5AccelTableData(const uint64_t DieOffset, const unsigned DieTag,
+   const unsigned Index, const bool IsTU = false)
+  : OffsetVal(DieOffset) {
+Data.DieTag = DieTag;
+Data.UnitID = Index;
+Data.IsTU = IsTU;
+  }
 
 #ifndef NDEBUG
   void print(raw_ostream &OS) const override;
@@ -265,18 +280,25 @@ class DWARF5AccelTableData : public AccelTableData {
"Accessing DIE Offset before normalizing.");
 return std::get(OffsetVal);
   }
-  unsigned getDieTag() const { return DieTag; }
-  unsigned getUnitID() const { return UnitID; }
+  unsigned getDieTag() const { return Data.DieTag; }
+  unsigned getUnitID() const { return Data.UnitID; }
+  bool isTU() const { return Data.IsTU; }
   void normalizeDIEToOffset() {
 assert(std::holds_alternative(OffsetVal) &&
"Accessing offset after normalizing.");
 OffsetVal = std::get(OffsetVal)->getOffset();
   }
+  bool isNormalized() const {
+return std::holds_alternative(OffsetVal);
+  }
 
 protected:
   std::variant OffsetVal;
-  unsigned DieTag;
-  unsigned UnitID;
+  struct MetaData {
+uint32_t DieTag : 16;
+uint32_t UnitID : 15;
+uint32_t IsTU : 1;
+  } Data;
 
   uint64_t order() const override { return getDieOffset(); }
 };
@@ -288,7 +310,19 @@ class DWARF5AccelTable : public 
AccelTable {
   void convertDieToOffset() {
 for (auto &Entry : Entries) {
   for (AccelTableData *Value : Entry.second.Values) {
-static_cast(Value)->normalize

[Lldb-commits] [lldb] [lldb] Remove some declarations without definitions (PR #70514)

2023-10-27 Thread Sergei Barannikov via lldb-commits

https://github.com/s-barannikov created 
https://github.com/llvm/llvm-project/pull/70514

The corresponding definitions were removed in 7dcbe3d3 and 2a8fa2a8.
Also remove a couple of variables made dead by these changes.


>From e06880e4af9e1d8bd535d08174eb8a0fffd2e780 Mon Sep 17 00:00:00 2001
From: Sergei Barannikov 
Date: Sat, 28 Oct 2023 00:38:11 +0300
Subject: [PATCH] [lldb] Remove some declarations without definitions

The corresponding definitions were removed in 7dcbe3d3 and 2a8fa2a8.
Also remove a couple of variables made dead by these changes.
---
 .../ExpressionParser/Clang/IRForTarget.cpp|  8 --
 .../ExpressionParser/Clang/IRForTarget.h  | 74 ---
 2 files changed, 82 deletions(-)

diff --git a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
index 1b7e86bb187f230..81bb0e73e91f9f9 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
@@ -1641,14 +1641,6 @@ bool IRForTarget::runOnModule(Module &llvm_module) {
 }
   }
 
-  llvm::Type *int8_ty = Type::getInt8Ty(m_module->getContext());
-
-  m_reloc_placeholder = new llvm::GlobalVariable(
-  (*m_module), int8_ty, false /* IsConstant */,
-  GlobalVariable::InternalLinkage, Constant::getNullValue(int8_ty),
-  "reloc_placeholder", nullptr /* InsertBefore */,
-  GlobalVariable::NotThreadLocal /* ThreadLocal */, 0 /* AddressSpace */);
-
   
   // Replace $__lldb_expr_result with a persistent variable
   //
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.h 
b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.h
index eb93952e2b3c241..a924187ba04c061 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.h
+++ b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.h
@@ -111,43 +111,6 @@ class IRForTarget {
   /// True on success; false otherwise.
   bool FixFunctionLinkage(llvm::Function &llvm_function);
 
-  /// A module-level pass to replace all function pointers with their
-  /// integer equivalents.
-
-  /// The top-level pass implementation
-  ///
-  /// \param[in] llvm_function
-  /// The function currently being processed.
-  ///
-  /// \return
-  /// True on success; false otherwise.
-  bool HasSideEffects(llvm::Function &llvm_function);
-
-  /// A function-level pass to check whether the function has side
-  /// effects.
-
-  /// Get the address of a function, and a location to put the complete Value
-  /// of the function if one is available.
-  ///
-  /// \param[in] function
-  /// The function to find the location of.
-  ///
-  /// \param[out] ptr
-  /// The location of the function in the target.
-  ///
-  /// \param[out] name
-  /// The resolved name of the function (matters for intrinsics).
-  ///
-  /// \param[out] value_ptr
-  /// A variable to put the function's completed Value* in, or NULL
-  /// if the Value* shouldn't be stored anywhere.
-  ///
-  /// \return
-  /// The pointer.
-  LookupResult GetFunctionAddress(llvm::Function *function, uint64_t &ptr,
-  lldb_private::ConstString &name,
-  llvm::Constant **&value_ptr);
-
   /// A function-level pass to take the generated global value
   /// $__lldb_expr_result and make it into a persistent variable. Also see
   /// ASTResultSynthesizer.
@@ -170,30 +133,6 @@ class IRForTarget {
 private:
   clang::NamedDecl *DeclForGlobal(llvm::GlobalValue *global);
 
-  /// Set the constant result variable m_const_result to the provided
-  /// constant, assuming it can be evaluated.  The result variable will be
-  /// reset to NULL later if the expression has side effects.
-  ///
-  /// \param[in] initializer
-  /// The constant initializer for the variable.
-  ///
-  /// \param[in] name
-  /// The name of the result variable.
-  ///
-  /// \param[in] type
-  /// The Clang type of the result variable.
-  void MaybeSetConstantResult(llvm::Constant *initializer,
-  lldb_private::ConstString name,
-  lldb_private::TypeFromParser type);
-
-  /// If the IR represents a cast of a variable, set m_const_result to the
-  /// result of the cast.  The result variable will be reset to
-  /// NULL latger if the expression has side effects.
-  ///
-  /// \param[in] type
-  /// The Clang type of the result variable.
-  void MaybeSetCastResult(lldb_private::TypeFromParser type);
-
   /// The top-level pass implementation
   ///
   /// \param[in] llvm_function
@@ -409,15 +348,9 @@ class IRForTarget {
   lldb_private::Stream &m_error_stream;
   /// The execution unit containing the IR being created.
   lldb_private::IRExecutionUnit &m_execution_unit;
-  /// If non-NULL, the store instruction that writes to the result variable.  
If
-  /// m_has_side_effects

[Lldb-commits] [lldb] [lldb] Remove some declarations without definitions (PR #70514)

2023-10-27 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Sergei Barannikov (s-barannikov)


Changes

The corresponding definitions were removed in 7dcbe3d3 and 2a8fa2a8.
Also remove a couple of variables made dead by these changes.


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


2 Files Affected:

- (modified) lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp (-8) 
- (modified) lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.h (-74) 


``diff
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
index 1b7e86bb187f230..81bb0e73e91f9f9 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
@@ -1641,14 +1641,6 @@ bool IRForTarget::runOnModule(Module &llvm_module) {
 }
   }
 
-  llvm::Type *int8_ty = Type::getInt8Ty(m_module->getContext());
-
-  m_reloc_placeholder = new llvm::GlobalVariable(
-  (*m_module), int8_ty, false /* IsConstant */,
-  GlobalVariable::InternalLinkage, Constant::getNullValue(int8_ty),
-  "reloc_placeholder", nullptr /* InsertBefore */,
-  GlobalVariable::NotThreadLocal /* ThreadLocal */, 0 /* AddressSpace */);
-
   
   // Replace $__lldb_expr_result with a persistent variable
   //
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.h 
b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.h
index eb93952e2b3c241..a924187ba04c061 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.h
+++ b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.h
@@ -111,43 +111,6 @@ class IRForTarget {
   /// True on success; false otherwise.
   bool FixFunctionLinkage(llvm::Function &llvm_function);
 
-  /// A module-level pass to replace all function pointers with their
-  /// integer equivalents.
-
-  /// The top-level pass implementation
-  ///
-  /// \param[in] llvm_function
-  /// The function currently being processed.
-  ///
-  /// \return
-  /// True on success; false otherwise.
-  bool HasSideEffects(llvm::Function &llvm_function);
-
-  /// A function-level pass to check whether the function has side
-  /// effects.
-
-  /// Get the address of a function, and a location to put the complete Value
-  /// of the function if one is available.
-  ///
-  /// \param[in] function
-  /// The function to find the location of.
-  ///
-  /// \param[out] ptr
-  /// The location of the function in the target.
-  ///
-  /// \param[out] name
-  /// The resolved name of the function (matters for intrinsics).
-  ///
-  /// \param[out] value_ptr
-  /// A variable to put the function's completed Value* in, or NULL
-  /// if the Value* shouldn't be stored anywhere.
-  ///
-  /// \return
-  /// The pointer.
-  LookupResult GetFunctionAddress(llvm::Function *function, uint64_t &ptr,
-  lldb_private::ConstString &name,
-  llvm::Constant **&value_ptr);
-
   /// A function-level pass to take the generated global value
   /// $__lldb_expr_result and make it into a persistent variable. Also see
   /// ASTResultSynthesizer.
@@ -170,30 +133,6 @@ class IRForTarget {
 private:
   clang::NamedDecl *DeclForGlobal(llvm::GlobalValue *global);
 
-  /// Set the constant result variable m_const_result to the provided
-  /// constant, assuming it can be evaluated.  The result variable will be
-  /// reset to NULL later if the expression has side effects.
-  ///
-  /// \param[in] initializer
-  /// The constant initializer for the variable.
-  ///
-  /// \param[in] name
-  /// The name of the result variable.
-  ///
-  /// \param[in] type
-  /// The Clang type of the result variable.
-  void MaybeSetConstantResult(llvm::Constant *initializer,
-  lldb_private::ConstString name,
-  lldb_private::TypeFromParser type);
-
-  /// If the IR represents a cast of a variable, set m_const_result to the
-  /// result of the cast.  The result variable will be reset to
-  /// NULL latger if the expression has side effects.
-  ///
-  /// \param[in] type
-  /// The Clang type of the result variable.
-  void MaybeSetCastResult(lldb_private::TypeFromParser type);
-
   /// The top-level pass implementation
   ///
   /// \param[in] llvm_function
@@ -409,15 +348,9 @@ class IRForTarget {
   lldb_private::Stream &m_error_stream;
   /// The execution unit containing the IR being created.
   lldb_private::IRExecutionUnit &m_execution_unit;
-  /// If non-NULL, the store instruction that writes to the result variable.  
If
-  /// m_has_side_effects is true, this is NULL.
-  llvm::StoreInst *m_result_store = nullptr;
   /// True if the function's result in the AST is a pointer (see comments in
   /// ASTResultSynthesizer::SynthesizeBodyResult)
   bool m_result_is_pointer = fals

[Lldb-commits] [lldb] [LLVM][DWARF] Add support for monolithic types in .debug_names (PR #70512)

2023-10-27 Thread Alexander Yermolovich via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Make use of Scripted{Python, }Interface for ScriptedThreadPlan (PR #70392)

2023-10-27 Thread Med Ismail Bennani via lldb-commits

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

>From 56f95c1a16bc448d050865ba433e56af82dfbe2e Mon Sep 17 00:00:00 2001
From: Med Ismail Bennani 
Date: Fri, 27 Oct 2023 15:20:28 -0700
Subject: [PATCH] [lldb] Make use of Scripted{Python,}Interface for
 ScriptedThreadPlan

This patch makes ScriptedThreadPlan conforming to the ScriptedInterface
& ScriptedPythonInterface facilities by introducing 2
ScriptedThreadPlanInterface & ScriptedThreadPlanPythonInterface classes.

This allows us to get rid of every ScriptedThreadPlan-specific SWIG
method and re-use the same affordances as other scripting offordances,
like Scripted{Process,Thread,Platform} & OperatingSystem.

To do so, this adds new transformer methods for `ThreadPlan`, `Stream` &
`Event`, to allow the bijection between C++ objects and their python
counterparts.

Signed-off-by: Med Ismail Bennani 
---
 lldb/bindings/python/python-swigsafecast.swig |  13 +-
 lldb/bindings/python/python-wrapper.swig  | 153 +++---
 lldb/include/lldb/API/SBEvent.h   |   4 +-
 lldb/include/lldb/API/SBStream.h  |   9 ++
 .../Interfaces/ScriptedInterface.h|   4 +-
 .../Interfaces/ScriptedThreadPlanInterface.h  |  40 +
 .../lldb/Interpreter/ScriptInterpreter.h  |  56 ++-
 lldb/include/lldb/Target/ThreadPlanPython.h   |   2 +
 lldb/include/lldb/lldb-forward.h  |   3 +
 lldb/source/Interpreter/ScriptInterpreter.cpp |  13 ++
 .../Python/Interfaces/CMakeLists.txt  |   1 +
 .../ScriptedPlatformPythonInterface.cpp   |   2 +
 .../Interfaces/ScriptedPythonInterface.cpp|  34 
 .../Interfaces/ScriptedPythonInterface.h  |  20 +++
 .../ScriptedThreadPlanPythonInterface.cpp |  92 +++
 .../ScriptedThreadPlanPythonInterface.h   |  44 +
 .../ScriptedThreadPythonInterface.cpp |   1 +
 .../Python/SWIGPythonBridge.h |  21 +--
 .../Python/ScriptInterpreterPython.cpp| 122 +-
 .../Python/ScriptInterpreterPythonImpl.h  |  28 +---
 lldb/source/Target/ThreadPlanPython.cpp   |  92 ++-
 .../functionalities/step_scripted/Steps.py|   4 +-
 .../Python/PythonTestSuite.cpp|  45 +++---
 23 files changed, 398 insertions(+), 405 deletions(-)
 create mode 100644 
lldb/include/lldb/Interpreter/Interfaces/ScriptedThreadPlanInterface.h
 create mode 100644 
lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPlanPythonInterface.cpp
 create mode 100644 
lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPlanPythonInterface.h

diff --git a/lldb/bindings/python/python-swigsafecast.swig 
b/lldb/bindings/python/python-swigsafecast.swig
index d5ea5148727134d..fba3a77d8f2df44 100644
--- a/lldb/bindings/python/python-swigsafecast.swig
+++ b/lldb/bindings/python/python-swigsafecast.swig
@@ -37,10 +37,6 @@ PythonObject SWIGBridge::ToSWIGWrapper(const Status& status) 
{
   return ToSWIGHelper(new lldb::SBError(status), SWIGTYPE_p_lldb__SBError);
 }
 
-PythonObject SWIGBridge::ToSWIGWrapper(std::unique_ptr 
stream_sb) {
-  return ToSWIGHelper(stream_sb.release(), SWIGTYPE_p_lldb__SBStream);
-}
-
 PythonObject SWIGBridge::ToSWIGWrapper(std::unique_ptr 
data_sb) {
   return ToSWIGHelper(data_sb.release(), SWIGTYPE_p_lldb__SBStructuredData);
 }
@@ -115,9 +111,12 @@ SWIGBridge::ToSWIGWrapper(CommandReturnObject &cmd_retobj) 
{
   SWIGTYPE_p_lldb__SBCommandReturnObject);
 }
 
-ScopedPythonObject SWIGBridge::ToSWIGWrapper(Event *event) {
-  return ScopedPythonObject(new lldb::SBEvent(event),
-   SWIGTYPE_p_lldb__SBEvent);
+PythonObject SWIGBridge::ToSWIGWrapper(const Stream *s) {
+  return ToSWIGHelper(new lldb::SBStream(), SWIGTYPE_p_lldb__SBStream);
+}
+
+PythonObject SWIGBridge::ToSWIGWrapper(Event *event) {
+  return ToSWIGHelper(new lldb::SBEvent(event), SWIGTYPE_p_lldb__SBEvent);
 }
 
 PythonObject SWIGBridge::ToSWIGWrapper(
diff --git a/lldb/bindings/python/python-wrapper.swig 
b/lldb/bindings/python/python-wrapper.swig
index 17bc7b1f2198709..5c28d652824073a 100644
--- a/lldb/bindings/python/python-wrapper.swig
+++ b/lldb/bindings/python/python-wrapper.swig
@@ -229,133 +229,6 @@ PythonObject 
lldb_private::python::SWIGBridge::LLDBSwigPythonCreateCommandObject
   return pfunc(SWIGBridge::ToSWIGWrapper(std::move(debugger_sp)), dict);
 }
 
-PythonObject 
lldb_private::python::SWIGBridge::LLDBSwigPythonCreateScriptedThreadPlan(
-const char *python_class_name, const char *session_dictionary_name,
-const lldb_private::StructuredDataImpl &args_impl,
-std::string &error_string, const lldb::ThreadPlanSP &thread_plan_sp) {
-  if (python_class_name == NULL || python_class_name[0] == '\0' ||
-  !session_dictionary_name)
-return PythonObject();
-
-  PyErr_Cleaner py_err_cleaner(true);
-
-  auto dict = PythonModule::MainModule().ResolveName(
-  session_dictionary_name);
-  auto pfunc = PythonObject::R

[Lldb-commits] [lldb] [lldb] Make use of Scripted{Python, }Interface for ScriptedThreadPlan (PR #70392)

2023-10-27 Thread Med Ismail Bennani via lldb-commits


@@ -104,6 +104,19 @@ ScriptInterpreter::GetStatusFromSBError(const 
lldb::SBError &error) const {
   return Status();
 }
 
+Event *
+ScriptInterpreter::GetOpaqueTypeFromSBEvent(const lldb::SBEvent &event) const {
+  return event.m_opaque_ptr;
+}
+
+Stream *ScriptInterpreter::GetOpaqueTypeFromSBStream(
+const lldb::SBStream &stream) const {
+  if (stream.m_opaque_up)
+return const_cast(stream).m_opaque_up.release();

medismailben wrote:

Makes sense. Updated the PR.

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


[Lldb-commits] [lldb] [lldb] Make use of Scripted{Python, }Interface for ScriptedThreadPlan (PR #70392)

2023-10-27 Thread Alex Langford via lldb-commits

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

I think all of my comments have been addressed. Thanks!

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


[Lldb-commits] [lldb] [lldb] Remove some declarations without definitions (PR #70514)

2023-10-27 Thread Alex Langford via lldb-commits

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

I can't find any uses of these either.
I also checked in Apple's downstream swift fork, it doesn't look used there 
either.

LGTM

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


[Lldb-commits] [lldb] 4e4433f - [lldb] Remove some declarations without definitions (#70514)

2023-10-27 Thread via lldb-commits

Author: Sergei Barannikov
Date: 2023-10-28T02:33:50+03:00
New Revision: 4e4433f629a5ecfea538808449d513b5762a67b6

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

LOG: [lldb] Remove some declarations without definitions (#70514)

The corresponding definitions were removed in 7dcbe3d3 and 2a8fa2a8.
Also remove a couple of variables made dead by those changes.

Added: 


Modified: 
lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.h

Removed: 




diff  --git a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
index 1b7e86bb187f230..81bb0e73e91f9f9 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
@@ -1641,14 +1641,6 @@ bool IRForTarget::runOnModule(Module &llvm_module) {
 }
   }
 
-  llvm::Type *int8_ty = Type::getInt8Ty(m_module->getContext());
-
-  m_reloc_placeholder = new llvm::GlobalVariable(
-  (*m_module), int8_ty, false /* IsConstant */,
-  GlobalVariable::InternalLinkage, Constant::getNullValue(int8_ty),
-  "reloc_placeholder", nullptr /* InsertBefore */,
-  GlobalVariable::NotThreadLocal /* ThreadLocal */, 0 /* AddressSpace */);
-
   
   // Replace $__lldb_expr_result with a persistent variable
   //

diff  --git a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.h 
b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.h
index eb93952e2b3c241..a924187ba04c061 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.h
+++ b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.h
@@ -111,43 +111,6 @@ class IRForTarget {
   /// True on success; false otherwise.
   bool FixFunctionLinkage(llvm::Function &llvm_function);
 
-  /// A module-level pass to replace all function pointers with their
-  /// integer equivalents.
-
-  /// The top-level pass implementation
-  ///
-  /// \param[in] llvm_function
-  /// The function currently being processed.
-  ///
-  /// \return
-  /// True on success; false otherwise.
-  bool HasSideEffects(llvm::Function &llvm_function);
-
-  /// A function-level pass to check whether the function has side
-  /// effects.
-
-  /// Get the address of a function, and a location to put the complete Value
-  /// of the function if one is available.
-  ///
-  /// \param[in] function
-  /// The function to find the location of.
-  ///
-  /// \param[out] ptr
-  /// The location of the function in the target.
-  ///
-  /// \param[out] name
-  /// The resolved name of the function (matters for intrinsics).
-  ///
-  /// \param[out] value_ptr
-  /// A variable to put the function's completed Value* in, or NULL
-  /// if the Value* shouldn't be stored anywhere.
-  ///
-  /// \return
-  /// The pointer.
-  LookupResult GetFunctionAddress(llvm::Function *function, uint64_t &ptr,
-  lldb_private::ConstString &name,
-  llvm::Constant **&value_ptr);
-
   /// A function-level pass to take the generated global value
   /// $__lldb_expr_result and make it into a persistent variable. Also see
   /// ASTResultSynthesizer.
@@ -170,30 +133,6 @@ class IRForTarget {
 private:
   clang::NamedDecl *DeclForGlobal(llvm::GlobalValue *global);
 
-  /// Set the constant result variable m_const_result to the provided
-  /// constant, assuming it can be evaluated.  The result variable will be
-  /// reset to NULL later if the expression has side effects.
-  ///
-  /// \param[in] initializer
-  /// The constant initializer for the variable.
-  ///
-  /// \param[in] name
-  /// The name of the result variable.
-  ///
-  /// \param[in] type
-  /// The Clang type of the result variable.
-  void MaybeSetConstantResult(llvm::Constant *initializer,
-  lldb_private::ConstString name,
-  lldb_private::TypeFromParser type);
-
-  /// If the IR represents a cast of a variable, set m_const_result to the
-  /// result of the cast.  The result variable will be reset to
-  /// NULL latger if the expression has side effects.
-  ///
-  /// \param[in] type
-  /// The Clang type of the result variable.
-  void MaybeSetCastResult(lldb_private::TypeFromParser type);
-
   /// The top-level pass implementation
   ///
   /// \param[in] llvm_function
@@ -409,15 +348,9 @@ class IRForTarget {
   lldb_private::Stream &m_error_stream;
   /// The execution unit containing the IR being created.
   lldb_private::IRExecutionUnit &m_execution_unit;
-  /// If non-NULL, the store instruction that writes to the result variable.  

[Lldb-commits] [lldb] [lldb] Remove some declarations without definitions (PR #70514)

2023-10-27 Thread Sergei Barannikov via lldb-commits

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


[Lldb-commits] [lldb] Fix the DEVELOPER_DIR computation (PR #70528)

2023-10-27 Thread Adrian Prantl via lldb-commits

https://github.com/adrian-prantl created 
https://github.com/llvm/llvm-project/pull/70528

The code was incorrectly going into the wrong direction by removing one 
component instead of appendeing /Developer to it. Due to fallback mechanisms in 
xcrun this never seemed to have caused any issues.

>From d5e0dee978e75f5d623f6a96121ba277a25c40e9 Mon Sep 17 00:00:00 2001
From: Adrian Prantl 
Date: Fri, 27 Oct 2023 17:32:43 -0700
Subject: [PATCH] Fix the DEVELOPER_DIR computation

The code was incorrectly going into the wrong direction by removing
one component instead of appendeing /Developer to it. Due to fallback
mechanisms in xcrun this never seemed to have caused any issues.
---
 lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm | 12 +---
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm 
b/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
index e3506a01c606b78..33d94504fe70f8c 100644
--- a/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
+++ b/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
@@ -461,13 +461,11 @@ static void ParseOSVersion(llvm::VersionTuple &version, 
NSString *Key) {
 // Invoke xcrun with the shlib dir.
 if (FileSpec fspec = HostInfo::GetShlibDir()) {
   if (FileSystem::Instance().Exists(fspec)) {
-std::string contents_dir =
-XcodeSDK::FindXcodeContentsDirectoryInPath(fspec.GetPath());
-llvm::StringRef shlib_developer_dir =
-llvm::sys::path::parent_path(contents_dir);
-if (!shlib_developer_dir.empty()) {
-  auto sdk =
-  xcrun(sdk_name, show_sdk_path, std::move(shlib_developer_dir));
+llvm::SmallString<0> shlib_developer_dir(
+XcodeSDK::FindXcodeContentsDirectoryInPath(fspec.GetPath()));
+llvm::sys::path::append(shlib_developer_dir, "Developer");
+if (FileSystem::Instance().Exists(shlib_developer_dir)) {
+  auto sdk = xcrun(sdk_name, show_sdk_path, shlib_developer_dir);
   if (!sdk)
 return sdk.takeError();
   if (!sdk->empty())

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


[Lldb-commits] [lldb] Fix the DEVELOPER_DIR computation (PR #70528)

2023-10-27 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Adrian Prantl (adrian-prantl)


Changes

The code was incorrectly going into the wrong direction by removing one 
component instead of appendeing /Developer to it. Due to fallback mechanisms in 
xcrun this never seemed to have caused any issues.

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


1 Files Affected:

- (modified) lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm (+5-7) 


``diff
diff --git a/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm 
b/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
index e3506a01c606b78..33d94504fe70f8c 100644
--- a/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
+++ b/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
@@ -461,13 +461,11 @@ static void ParseOSVersion(llvm::VersionTuple &version, 
NSString *Key) {
 // Invoke xcrun with the shlib dir.
 if (FileSpec fspec = HostInfo::GetShlibDir()) {
   if (FileSystem::Instance().Exists(fspec)) {
-std::string contents_dir =
-XcodeSDK::FindXcodeContentsDirectoryInPath(fspec.GetPath());
-llvm::StringRef shlib_developer_dir =
-llvm::sys::path::parent_path(contents_dir);
-if (!shlib_developer_dir.empty()) {
-  auto sdk =
-  xcrun(sdk_name, show_sdk_path, std::move(shlib_developer_dir));
+llvm::SmallString<0> shlib_developer_dir(
+XcodeSDK::FindXcodeContentsDirectoryInPath(fspec.GetPath()));
+llvm::sys::path::append(shlib_developer_dir, "Developer");
+if (FileSystem::Instance().Exists(shlib_developer_dir)) {
+  auto sdk = xcrun(sdk_name, show_sdk_path, shlib_developer_dir);
   if (!sdk)
 return sdk.takeError();
   if (!sdk->empty())

``




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


[Lldb-commits] [lldb] Fix the DEVELOPER_DIR computation (PR #70528)

2023-10-27 Thread Alex Langford via lldb-commits

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

Makes sense to me

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


[Lldb-commits] [lldb] Fix the DEVELOPER_DIR computation (PR #70528)

2023-10-27 Thread Alex Langford via lldb-commits

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


[Lldb-commits] [lldb] Fix the DEVELOPER_DIR computation (PR #70528)

2023-10-27 Thread Alex Langford via lldb-commits


@@ -461,13 +461,11 @@ static void ParseOSVersion(llvm::VersionTuple &version, 
NSString *Key) {
 // Invoke xcrun with the shlib dir.
 if (FileSpec fspec = HostInfo::GetShlibDir()) {
   if (FileSystem::Instance().Exists(fspec)) {
-std::string contents_dir =
-XcodeSDK::FindXcodeContentsDirectoryInPath(fspec.GetPath());
-llvm::StringRef shlib_developer_dir =
-llvm::sys::path::parent_path(contents_dir);
-if (!shlib_developer_dir.empty()) {
-  auto sdk =
-  xcrun(sdk_name, show_sdk_path, std::move(shlib_developer_dir));
+llvm::SmallString<0> shlib_developer_dir(

bulbazord wrote:

Why 0?
I assume the switch to SmallString has to do with the 
`llvm::sys::path::append`, that part makes sense to me.

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


[Lldb-commits] [lldb] Fix the DEVELOPER_DIR computation (PR #70528)

2023-10-27 Thread Alex Langford via lldb-commits


@@ -461,13 +461,11 @@ static void ParseOSVersion(llvm::VersionTuple &version, 
NSString *Key) {
 // Invoke xcrun with the shlib dir.
 if (FileSpec fspec = HostInfo::GetShlibDir()) {
   if (FileSystem::Instance().Exists(fspec)) {
-std::string contents_dir =
-XcodeSDK::FindXcodeContentsDirectoryInPath(fspec.GetPath());
-llvm::StringRef shlib_developer_dir =
-llvm::sys::path::parent_path(contents_dir);
-if (!shlib_developer_dir.empty()) {
-  auto sdk =
-  xcrun(sdk_name, show_sdk_path, std::move(shlib_developer_dir));
+llvm::SmallString<0> shlib_developer_dir(
+XcodeSDK::FindXcodeContentsDirectoryInPath(fspec.GetPath()));
+llvm::sys::path::append(shlib_developer_dir, "Developer");
+if (FileSystem::Instance().Exists(shlib_developer_dir)) {

bulbazord wrote:

Do we actually need to check its existence or can `xcrun` take care of that for 
us?

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


[Lldb-commits] [lldb] Fix the DEVELOPER_DIR computation (PR #70528)

2023-10-27 Thread Jonas Devlieghere via lldb-commits


@@ -461,13 +461,11 @@ static void ParseOSVersion(llvm::VersionTuple &version, 
NSString *Key) {
 // Invoke xcrun with the shlib dir.
 if (FileSpec fspec = HostInfo::GetShlibDir()) {
   if (FileSystem::Instance().Exists(fspec)) {
-std::string contents_dir =
-XcodeSDK::FindXcodeContentsDirectoryInPath(fspec.GetPath());
-llvm::StringRef shlib_developer_dir =
-llvm::sys::path::parent_path(contents_dir);
-if (!shlib_developer_dir.empty()) {
-  auto sdk =
-  xcrun(sdk_name, show_sdk_path, std::move(shlib_developer_dir));
+llvm::SmallString<0> shlib_developer_dir(

JDevlieghere wrote:

The way I read that is that there's no reasonably small default so this avoids 
the stack allocation and goes directly to the heap. 

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


[Lldb-commits] [lldb] [lldb/Target] Delay image loading after corefile process creation (PR #70351)

2023-10-27 Thread Med Ismail Bennani via lldb-commits

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

>From 604a03a8be94f5a9390f39a1606bad809c939ffc Mon Sep 17 00:00:00 2001
From: Med Ismail Bennani 
Date: Fri, 27 Oct 2023 19:47:53 -0700
Subject: [PATCH] [lldb/Target] Delay image loading after corefile process
 creation

This patch is a follow-up to db223b7f01f7. Similarly to it, it changes
the timing of binary image loading for the ProcessMachCore plugin.

This issue came up after getting reports of scripting resources that
would fail to execute because they relied on data provided by the corefile
process (i.e. for reading memory). However, rior to this change, the
scripting resource loading would happen as part of the binary image
loading, which in turns happened before the process finished being created.

This patch address that issue by delaying the binary image loading phase
until we receive the corefile process stop event event, ensuring that the
process is fully formed.

Signed-off-by: Med Ismail Bennani 
---
 lldb/include/lldb/Target/Process.h|  2 +
 .../Process/mach-core/ProcessMachCore.cpp |  4 +-
 .../Process/mach-core/ProcessMachCore.h   |  2 +
 lldb/source/Target/Process.cpp| 29 +
 .../script-resource-loading/Makefile  |  5 ++
 .../TestScriptResourceLoading.py  | 63 +++
 .../script-resource-loading/main.cpp  |  5 ++
 .../my_scripting_resource.py  | 15 +
 8 files changed, 110 insertions(+), 15 deletions(-)
 create mode 100644 
lldb/test/API/functionalities/script-resource-loading/Makefile
 create mode 100644 
lldb/test/API/functionalities/script-resource-loading/TestScriptResourceLoading.py
 create mode 100644 
lldb/test/API/functionalities/script-resource-loading/main.cpp
 create mode 100644 
lldb/test/API/functionalities/script-resource-loading/my_scripting_resource.py

diff --git a/lldb/include/lldb/Target/Process.h 
b/lldb/include/lldb/Target/Process.h
index a6d3e6c2d16926e..e25e82302a56dd9 100644
--- a/lldb/include/lldb/Target/Process.h
+++ b/lldb/include/lldb/Target/Process.h
@@ -614,6 +614,8 @@ class Process : public 
std::enable_shared_from_this,
 return error;
   }
 
+  virtual void DidLoadCore() {}
+
   /// The "ShadowListener" for a process is just an ordinary Listener that 
   /// listens for all the Process event bits.  It's convenient because you can
   /// specify it in the LaunchInfo or AttachInfo, so it will get events from
diff --git a/lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp 
b/lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp
index b11062a0224abc2..9b10a0b832915d3 100644
--- a/lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp
+++ b/lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp
@@ -570,8 +570,6 @@ Status ProcessMachCore::DoLoadCore() {
 
   CreateMemoryRegions();
 
-  LoadBinariesAndSetDYLD();
-
   CleanupMemoryRegionPermissions();
 
   AddressableBits addressable_bits = core_objfile->GetAddressableBits();
@@ -580,6 +578,8 @@ Status ProcessMachCore::DoLoadCore() {
   return error;
 }
 
+void ProcessMachCore::DidLoadCore() { LoadBinariesAndSetDYLD(); }
+
 lldb_private::DynamicLoader *ProcessMachCore::GetDynamicLoader() {
   if (m_dyld_up.get() == nullptr)
 m_dyld_up.reset(DynamicLoader::FindPlugin(this, m_dyld_plugin_name));
diff --git a/lldb/source/Plugins/Process/mach-core/ProcessMachCore.h 
b/lldb/source/Plugins/Process/mach-core/ProcessMachCore.h
index c8820209e3f3830..0e61daa625b53cc 100644
--- a/lldb/source/Plugins/Process/mach-core/ProcessMachCore.h
+++ b/lldb/source/Plugins/Process/mach-core/ProcessMachCore.h
@@ -46,6 +46,8 @@ class ProcessMachCore : public 
lldb_private::PostMortemProcess {
   // Creating a new process, or attaching to an existing one
   lldb_private::Status DoLoadCore() override;
 
+  void DidLoadCore() override;
+
   lldb_private::DynamicLoader *GetDynamicLoader() override;
 
   // PluginInterface protocol
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index f82ab05362fbee9..f4bacf314dd746a 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -2639,19 +2639,6 @@ Status Process::LoadCore() {
 else
   StartPrivateStateThread();
 
-DynamicLoader *dyld = GetDynamicLoader();
-if (dyld)
-  dyld->DidAttach();
-
-GetJITLoaders().DidAttach();
-
-SystemRuntime *system_runtime = GetSystemRuntime();
-if (system_runtime)
-  system_runtime->DidAttach();
-
-if (!m_os_up)
-  LoadOperatingSystemPlugin(false);
-
 // We successfully loaded a core file, now pretend we stopped so we can
 // show all of the threads in the core file and explore the crashed state.
 SetPrivateState(eStateStopped);
@@ -2668,7 +2655,23 @@ Status Process::LoadCore() {
 StateAsCString(state));
   error.SetErrorString(
   "Did not get stopped event after loading the core file.");
+} else {
+  DidLo

[Lldb-commits] [lldb] [lldb/Target] Delay image loading after corefile process creation (PR #70351)

2023-10-27 Thread Med Ismail Bennani via lldb-commits

medismailben wrote:

Add test like @jimingham suggested.

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