[Lldb-commits] [lldb] Read and store gnu build id from loaded core file (PR #92492)

2024-05-23 Thread Pavel Labath via lldb-commits


@@ -983,6 +1001,66 @@ llvm::Error 
ProcessElfCore::ParseThreadContextsFromNoteSegment(
   }
 }
 
+bool ProcessElfCore::IsElf(lldb::addr_t address) {
+  uint8_t buf[4];
+  Status error;
+  size_t byte_read = ReadMemory(address, buf, 4, error);
+  if (byte_read != 4)
+return false;

labath wrote:

I think you can just delete this and put the magic bytes check at on line 
~1024, after you read the full header. Reading 4 bytes is not going to be 
appreciably faster than reading 64 (sizeof(Elf64_Ehdr)), and this will make the 
code look more like the one on lines 60--70 (which essentially does the same 
thing).

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


[Lldb-commits] [lldb] Read and store gnu build id from loaded core file (PR #92492)

2024-05-23 Thread Pavel Labath via lldb-commits


@@ -271,6 +276,17 @@ Status ProcessElfCore::DoLoadCore() {
   return error;
 }
 
+void ProcessElfCore::UpdateBuildIdForNTFileEntries() {
+  if (!m_nt_file_entries.empty()) {
+for (NT_FILE_Entry &entry : m_nt_file_entries) {
+  std::optional uuid =

labath wrote:

Since UUID already has an IsValid() method I don't think wrapping it in an 
optional is not going to help (in fact, it will add ambiguity: Does returning 
an invalid UUID mean something different than std::nullopt?) Up to you, but I'd 
remove the optional here...

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


[Lldb-commits] [lldb] Read and store gnu build id from loaded core file (PR #92492)

2024-05-23 Thread Pavel Labath via lldb-commits


@@ -983,6 +1001,66 @@ llvm::Error 
ProcessElfCore::ParseThreadContextsFromNoteSegment(
   }
 }
 
+bool ProcessElfCore::IsElf(lldb::addr_t address) {
+  uint8_t buf[4];
+  Status error;
+  size_t byte_read = ReadMemory(address, buf, 4, error);
+  if (byte_read != 4)
+return false;
+  return elf::ELFHeader::MagicBytesMatch(buf);
+}
+
+std::optional ProcessElfCore::FindNoteInCoreMemory(lldb::addr_t address,
+ uint32_t type) {

labath wrote:

I don't think this `type` argument is useful, as this function already a UUID, 
and so it can't be used to parse any other kind of a note. I'd recommend 
inlining NT_GNU_BUILD_ID into the function (and renaming it to something like 
FindBuidIdInCoreMemory).

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


[Lldb-commits] [lldb] Read and store gnu build id from loaded core file (PR #92492)

2024-05-23 Thread Pavel Labath via lldb-commits


@@ -271,6 +282,17 @@ Status ProcessElfCore::DoLoadCore() {
   return error;
 }
 
+void ProcessElfCore::UpdateBuildIdForNTFileEntries() {
+  if (!m_nt_file_entries.empty()) {

labath wrote:

Makes sense. I though something like this might be the case.

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


[Lldb-commits] [lldb] Read and store gnu build id from loaded core file (PR #92492)

2024-05-23 Thread Pavel Labath via lldb-commits

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


[Lldb-commits] [lldb] Improve performance of .debug_names lookups when DW_IDX_parent attributes are used (PR #91808)

2024-05-23 Thread Pavel Labath via lldb-commits

labath wrote:

> Using example above, with a fix by @dwblaikie
> 
> I see:
> 
> ```
>  Hash: 0xE0CDC6A2
>   String: 0x0018 "InnerState"
>   Entry @ 0x10b {
> Abbrev: 0x3
> Tag: DW_TAG_class_type
> DW_IDX_type_unit: 0x01
> DW_IDX_die_offset: 0x0030
>   }
> ```
> 
> Since clang no longer emits entry for:
> 
> ```
> 0x0057:   DW_TAG_structure_type
> DW_AT_declaration (true)
> DW_AT_signature (0xe742f49eeadc2244)
> ```
> 
> Is this the right behavior? 

I would say "yes", because the spec is pretty explicit about excluding 
DW_AT_declaration entries.

I can see a case being made that DW_AT_signature should be treated the same way 
as DW_AT_specification and DW_AT_abstract_origin (i.e., transparently), but 
that's definitely not what the spec says right now.

> Current BOLT behavior is to skip that DIE and reference it's parent:
> 
> ```
> Hash: 0xE0CDC6A2
>   String: 0x0018 "InnerState"
>   Entry @ 0x109 {
> Abbrev: 0x3
> Tag: DW_TAG_class_type
> DW_IDX_type_unit: 0x01
> DW_IDX_die_offset: 0x0030
> DW_IDX_parent: Entry @ 0x147
>   }
> Entry @ 0x147 {
> Abbrev: 0x7
> Tag: DW_TAG_namespace
> DW_IDX_type_unit: 0x01
> DW_IDX_die_offset: 0x0025
> DW_IDX_parent: Entry @ 0x126
>   }
> ```
> 
> ```
> 0x0055: DW_TAG_namespace
>   DW_AT_name  ("B")
> 
> 0x0057:   DW_TAG_structure_type
> DW_AT_declaration (true)
> DW_AT_signature (0xe742f49eeadc2244)
> 
> 0x0060: DW_TAG_class_type
>   DW_AT_calling_convention  (DW_CC_pass_by_value)
>   DW_AT_name  ("InnerState")
>   DW_AT_byte_size (0x01)
>   DW_AT_decl_file ("/main.cpp")
>   DW_AT_decl_line (1)
> ```
> 
> It doesn't emit entry for this because there is no name attribute
> 
> ```
> 0x0057:   DW_TAG_structure_type
> DW_AT_declaration (true)
> DW_AT_signature (0xe742f49eeadc2244)
> ```

This gets a bit fuzzy, I think. The spec appears to allow this behavior (_In 
such a
case, a parent attribute may point to a nameless index entry (...), or it may 
point to the
**nearest ancestor that does have an index entry**._), but I don't think this 
is particularly useful. I think it would be better to have the parent point to 
the definition in the type unit (streching the meaning of "parent" in the 
spec), or use one of those nameless entries to point to the physical 
(declaration) parent)

(IANAL YMMV)

https://github.com/llvm/llvm-project/pull/91808
___
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 (Reland #70392) (PR #93149)

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

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

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.

>From 5191bf9a08394991f8ed14792f48451f3cb4805f Mon Sep 17 00:00:00 2001
From: Med Ismail Bennani 
Date: Thu, 23 May 2024 01:18:37 -0700
Subject: [PATCH] [lldb] Make use of Scripted{Python,}Interface for
 ScriptedThreadPlan (#70392)

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 |  17 +-
 lldb/bindings/python/python-wrapper.swig  | 157 +++---
 lldb/include/lldb/API/SBEvent.h   |   4 +-
 lldb/include/lldb/API/SBStream.h  |   6 +
 .../Interfaces/ScriptedInterface.h|   4 +-
 .../Interfaces/ScriptedThreadPlanInterface.h  |  38 +
 .../lldb/Interpreter/ScriptInterpreter.h  |  55 ++
 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 +
 .../ScriptedProcessPythonInterface.cpp|  27 ++-
 .../Interfaces/ScriptedPythonInterface.cpp|  34 +++-
 .../Interfaces/ScriptedPythonInterface.h  |  29 +++-
 .../ScriptedThreadPlanPythonInterface.cpp | 105 
 .../ScriptedThreadPlanPythonInterface.h   |  48 ++
 .../ScriptedThreadPythonInterface.cpp |  28 +++-
 .../Python/SWIGPythonBridge.h |  22 +--
 .../Python/ScriptInterpreterPython.cpp| 122 +-
 .../Python/ScriptInterpreterPythonImpl.h  |  28 +---
 lldb/source/Target/ThreadPlanPython.cpp   |  98 ++-
 .../functionalities/step_scripted/Steps.py|   4 +-
 .../thread_plan/wrap_step_over.py |   2 +-
 .../Python/PythonTestSuite.cpp|  50 +++---
 25 files changed, 468 insertions(+), 431 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 d5ea514872713..34f8c6f0ff8d3 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,16 @@ 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(std::shared_ptr 
stream_sb) {
+  return ToSWIGHelper(stream_sb.get(), 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 1370afc885d43..28ab58f8ce495 100644
--- a/lldb/bindings/python/python-wrappe

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

2024-05-23 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Med Ismail Bennani (medismailben)


Changes

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.

---

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


25 Files Affected:

- (modified) lldb/bindings/python/python-swigsafecast.swig (+10-7) 
- (modified) lldb/bindings/python/python-wrapper.swig (+27-130) 
- (modified) lldb/include/lldb/API/SBEvent.h (+3-1) 
- (modified) lldb/include/lldb/API/SBStream.h (+6) 
- (modified) lldb/include/lldb/Interpreter/Interfaces/ScriptedInterface.h 
(+2-2) 
- (added) 
lldb/include/lldb/Interpreter/Interfaces/ScriptedThreadPlanInterface.h (+38) 
- (modified) lldb/include/lldb/Interpreter/ScriptInterpreter.h (+11-44) 
- (modified) lldb/include/lldb/Target/ThreadPlanPython.h (+2) 
- (modified) lldb/include/lldb/lldb-forward.h (+3) 
- (modified) lldb/source/Interpreter/ScriptInterpreter.cpp (+13) 
- (modified) 
lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/CMakeLists.txt (+1) 
- (modified) 
lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPlatformPythonInterface.cpp
 (+2) 
- (modified) 
lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface.cpp
 (+18-9) 
- (modified) 
lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.cpp
 (+32-2) 
- (modified) 
lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h
 (+26-3) 
- (added) 
lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPlanPythonInterface.cpp
 (+105) 
- (added) 
lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPlanPythonInterface.h
 (+48) 
- (modified) 
lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPythonInterface.cpp
 (+19-9) 
- (modified) lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h 
(+5-17) 
- (modified) 
lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp 
(+6-116) 
- (modified) 
lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h 
(+3-25) 
- (modified) lldb/source/Target/ThreadPlanPython.cpp (+55-43) 
- (modified) lldb/test/API/functionalities/step_scripted/Steps.py (+2-2) 
- (modified) lldb/test/API/functionalities/thread_plan/wrap_step_over.py (+1-1) 
- (modified) lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp 
(+30-20) 


``diff
diff --git a/lldb/bindings/python/python-swigsafecast.swig 
b/lldb/bindings/python/python-swigsafecast.swig
index d5ea514872713..34f8c6f0ff8d3 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,16 @@ 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(std::shared_ptr 
stream_sb) {
+  return ToSWIGHelper(stream_sb.get(), 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 1370afc885d43..28ab58f8ce495 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 *ses

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

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

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

>From d3f819b19437645199f735c8e376c0f5041e65b1 Mon Sep 17 00:00:00 2001
From: Med Ismail Bennani 
Date: Thu, 23 May 2024 01:21:31 -0700
Subject: [PATCH] [lldb] Make use of Scripted{Python,}Interface for
 ScriptedThreadPlan (#70392)

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 |  17 +-
 lldb/bindings/python/python-wrapper.swig  | 157 +++---
 lldb/include/lldb/API/SBEvent.h   |   4 +-
 lldb/include/lldb/API/SBStream.h  |   6 +
 .../Interfaces/ScriptedInterface.h|   4 +-
 .../Interfaces/ScriptedThreadPlanInterface.h  |  38 +
 .../lldb/Interpreter/ScriptInterpreter.h  |  55 ++
 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 +
 .../ScriptedProcessPythonInterface.cpp|  27 ++-
 .../Interfaces/ScriptedPythonInterface.cpp|  34 +++-
 .../Interfaces/ScriptedPythonInterface.h  |  29 +++-
 .../ScriptedThreadPlanPythonInterface.cpp | 105 
 .../ScriptedThreadPlanPythonInterface.h   |  48 ++
 .../ScriptedThreadPythonInterface.cpp |  28 +++-
 .../Python/SWIGPythonBridge.h |  22 +--
 .../Python/ScriptInterpreterPython.cpp| 122 +-
 .../Python/ScriptInterpreterPythonImpl.h  |  28 +---
 lldb/source/Target/ThreadPlanPython.cpp   |  98 ++-
 .../functionalities/step_scripted/Steps.py|   4 +-
 .../thread_plan/wrap_step_over.py |   2 +-
 .../Python/PythonTestSuite.cpp|  50 +++---
 25 files changed, 468 insertions(+), 431 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 d5ea514872713..34f8c6f0ff8d3 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,16 @@ 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(std::shared_ptr 
stream_sb) {
+  return ToSWIGHelper(stream_sb.get(), 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 1370afc885d43..28ab58f8ce495 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 == NU

[Lldb-commits] [lldb] [lldb] Fixed the TestExitDuringExpression test in case of a remote target (PR #93119)

2024-05-23 Thread Pavel Labath via lldb-commits

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


https://github.com/llvm/llvm-project/pull/93119
___
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 (Reland #70392) (PR #93149)

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

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


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

2024-05-23 Thread via lldb-commits

Author: Med Ismail Bennani
Date: 2024-05-23T01:25:48-07:00
New Revision: 4cc6d0f4dfb26deb9863901c70258d6d7f0c8ba4

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

LOG: [lldb] Make use of Scripted{Python,}Interface for ScriptedThreadPlan 
(Reland #70392) (#93149)

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.

This just re-lands #70392 after fixing test failures.

Signed-off-by: Med Ismail Bennani 

Added: 
lldb/include/lldb/Interpreter/Interfaces/ScriptedThreadPlanInterface.h

lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPlanPythonInterface.cpp

lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPlanPythonInterface.h

Modified: 
lldb/bindings/python/python-swigsafecast.swig
lldb/bindings/python/python-wrapper.swig
lldb/include/lldb/API/SBEvent.h
lldb/include/lldb/API/SBStream.h
lldb/include/lldb/Interpreter/Interfaces/ScriptedInterface.h
lldb/include/lldb/Interpreter/ScriptInterpreter.h
lldb/include/lldb/Target/ThreadPlanPython.h
lldb/include/lldb/lldb-forward.h
lldb/source/Interpreter/ScriptInterpreter.cpp
lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/CMakeLists.txt

lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPlatformPythonInterface.cpp

lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface.cpp

lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.cpp

lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h

lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPythonInterface.cpp
lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h
lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
lldb/source/Target/ThreadPlanPython.cpp
lldb/test/API/functionalities/step_scripted/Steps.py
lldb/test/API/functionalities/thread_plan/wrap_step_over.py
lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp

Removed: 




diff  --git a/lldb/bindings/python/python-swigsafecast.swig 
b/lldb/bindings/python/python-swigsafecast.swig
index d5ea514872713..34f8c6f0ff8d3 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,16 @@ 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(std::shared_ptr 
stream_sb) {
+  return ToSWIGHelper(stream_sb.get(), 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 1370afc885d43..28ab58f8ce495 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

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

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

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


[Lldb-commits] [lldb] [lldb][Windows] Fixed the TestBreakpointCommand test (PR #93122)

2024-05-23 Thread Pavel Labath via lldb-commits

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

Nice find.

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


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

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

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

Reverts llvm/llvm-project#93149 since it breaks 
https://lab.llvm.org/buildbot/#/builders/68/builds/74799

>From 788e65c8171e233d399f3f1df645d6f9fb8f66bc Mon Sep 17 00:00:00 2001
From: Med Ismail Bennani 
Date: Thu, 23 May 2024 01:45:18 -0700
Subject: [PATCH] =?UTF-8?q?Revert=20"[lldb]=20Make=20use=20of=20Scripted{P?=
 =?UTF-8?q?ython,}Interface=20for=20ScriptedThreadPlan=20=E2=80=A6"?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This reverts commit 4cc6d0f4dfb26deb9863901c70258d6d7f0c8ba4.
---
 lldb/bindings/python/python-swigsafecast.swig |  17 +-
 lldb/bindings/python/python-wrapper.swig  | 157 +++---
 lldb/include/lldb/API/SBEvent.h   |   4 +-
 lldb/include/lldb/API/SBStream.h  |   6 -
 .../Interfaces/ScriptedInterface.h|   4 +-
 .../Interfaces/ScriptedThreadPlanInterface.h  |  38 -
 .../lldb/Interpreter/ScriptInterpreter.h  |  55 --
 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 -
 .../ScriptedProcessPythonInterface.cpp|  27 +--
 .../Interfaces/ScriptedPythonInterface.cpp|  34 +---
 .../Interfaces/ScriptedPythonInterface.h  |  29 +---
 .../ScriptedThreadPlanPythonInterface.cpp | 105 
 .../ScriptedThreadPlanPythonInterface.h   |  48 --
 .../ScriptedThreadPythonInterface.cpp |  28 +---
 .../Python/SWIGPythonBridge.h |  22 ++-
 .../Python/ScriptInterpreterPython.cpp| 122 +-
 .../Python/ScriptInterpreterPythonImpl.h  |  28 +++-
 lldb/source/Target/ThreadPlanPython.cpp   |  98 +--
 .../functionalities/step_scripted/Steps.py|   4 +-
 .../thread_plan/wrap_step_over.py |   2 +-
 .../Python/PythonTestSuite.cpp|  50 +++---
 25 files changed, 431 insertions(+), 468 deletions(-)
 delete mode 100644 
lldb/include/lldb/Interpreter/Interfaces/ScriptedThreadPlanInterface.h
 delete mode 100644 
lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPlanPythonInterface.cpp
 delete 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 34f8c6f0ff8d3..d5ea514872713 100644
--- a/lldb/bindings/python/python-swigsafecast.swig
+++ b/lldb/bindings/python/python-swigsafecast.swig
@@ -37,6 +37,10 @@ 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);
 }
@@ -111,16 +115,9 @@ SWIGBridge::ToSWIGWrapper(CommandReturnObject &cmd_retobj) 
{
   SWIGTYPE_p_lldb__SBCommandReturnObject);
 }
 
-PythonObject SWIGBridge::ToSWIGWrapper(const Stream *s) {
-  return ToSWIGHelper(new lldb::SBStream(), SWIGTYPE_p_lldb__SBStream);
-}
-
-PythonObject SWIGBridge::ToSWIGWrapper(std::shared_ptr 
stream_sb) {
-  return ToSWIGHelper(stream_sb.get(), SWIGTYPE_p_lldb__SBStream);
-}
-
-PythonObject SWIGBridge::ToSWIGWrapper(Event *event) {
-  return ToSWIGHelper(new lldb::SBEvent(event), SWIGTYPE_p_lldb__SBEvent);
+ScopedPythonObject SWIGBridge::ToSWIGWrapper(Event *event) {
+  return ScopedPythonObject(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 28ab58f8ce495..1370afc885d43 100644
--- a/lldb/bindings/python/python-wrapper.swig
+++ b/lldb/bindings/python/python-wrapper.swig
@@ -229,6 +229,133 @@ 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::ResolveNameWithDicti

[Lldb-commits] [lldb] ae3f680 - Revert "[lldb] Make use of Scripted{Python, }Interface for ScriptedThreadPlan (Reland #70392)" (#93153)

2024-05-23 Thread via lldb-commits

Author: Med Ismail Bennani
Date: 2024-05-23T01:46:29-07:00
New Revision: ae3f68066c8f282145435880107c1d3dc26ec3b8

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

LOG: Revert "[lldb] Make use of Scripted{Python,}Interface for 
ScriptedThreadPlan (Reland #70392)" (#93153)

Reverts llvm/llvm-project#93149 since it breaks
https://lab.llvm.org/buildbot/#/builders/68/builds/74799

Added: 


Modified: 
lldb/bindings/python/python-swigsafecast.swig
lldb/bindings/python/python-wrapper.swig
lldb/include/lldb/API/SBEvent.h
lldb/include/lldb/API/SBStream.h
lldb/include/lldb/Interpreter/Interfaces/ScriptedInterface.h
lldb/include/lldb/Interpreter/ScriptInterpreter.h
lldb/include/lldb/Target/ThreadPlanPython.h
lldb/include/lldb/lldb-forward.h
lldb/source/Interpreter/ScriptInterpreter.cpp
lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/CMakeLists.txt

lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPlatformPythonInterface.cpp

lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface.cpp

lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.cpp

lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h

lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPythonInterface.cpp
lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h
lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
lldb/source/Target/ThreadPlanPython.cpp
lldb/test/API/functionalities/step_scripted/Steps.py
lldb/test/API/functionalities/thread_plan/wrap_step_over.py
lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp

Removed: 
lldb/include/lldb/Interpreter/Interfaces/ScriptedThreadPlanInterface.h

lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPlanPythonInterface.cpp

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 34f8c6f0ff8d3..d5ea514872713 100644
--- a/lldb/bindings/python/python-swigsafecast.swig
+++ b/lldb/bindings/python/python-swigsafecast.swig
@@ -37,6 +37,10 @@ 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);
 }
@@ -111,16 +115,9 @@ SWIGBridge::ToSWIGWrapper(CommandReturnObject &cmd_retobj) 
{
   SWIGTYPE_p_lldb__SBCommandReturnObject);
 }
 
-PythonObject SWIGBridge::ToSWIGWrapper(const Stream *s) {
-  return ToSWIGHelper(new lldb::SBStream(), SWIGTYPE_p_lldb__SBStream);
-}
-
-PythonObject SWIGBridge::ToSWIGWrapper(std::shared_ptr 
stream_sb) {
-  return ToSWIGHelper(stream_sb.get(), SWIGTYPE_p_lldb__SBStream);
-}
-
-PythonObject SWIGBridge::ToSWIGWrapper(Event *event) {
-  return ToSWIGHelper(new lldb::SBEvent(event), SWIGTYPE_p_lldb__SBEvent);
+ScopedPythonObject SWIGBridge::ToSWIGWrapper(Event *event) {
+  return ScopedPythonObject(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 28ab58f8ce495..1370afc885d43 100644
--- a/lldb/bindings/python/python-wrapper.swig
+++ b/lldb/bindings/python/python-wrapper.swig
@@ -229,6 +229,133 @@ 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::ResolveNameWithDictionary(
+  python_class_name, dict);
+
+  if (!pfunc.IsAllocated()) {
+error_string.append("could not find script class: ");
+error_string.app

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

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

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


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

2024-05-23 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Med Ismail Bennani (medismailben)


Changes

Reverts llvm/llvm-project#93149 since it breaks 
https://lab.llvm.org/buildbot/#/builders/68/builds/74799

---

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


25 Files Affected:

- (modified) lldb/bindings/python/python-swigsafecast.swig (+7-10) 
- (modified) lldb/bindings/python/python-wrapper.swig (+130-27) 
- (modified) lldb/include/lldb/API/SBEvent.h (+1-3) 
- (modified) lldb/include/lldb/API/SBStream.h (-6) 
- (modified) lldb/include/lldb/Interpreter/Interfaces/ScriptedInterface.h 
(+2-2) 
- (removed) 
lldb/include/lldb/Interpreter/Interfaces/ScriptedThreadPlanInterface.h (-38) 
- (modified) lldb/include/lldb/Interpreter/ScriptInterpreter.h (+44-11) 
- (modified) lldb/include/lldb/Target/ThreadPlanPython.h (-2) 
- (modified) lldb/include/lldb/lldb-forward.h (-3) 
- (modified) lldb/source/Interpreter/ScriptInterpreter.cpp (-13) 
- (modified) 
lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/CMakeLists.txt (-1) 
- (modified) 
lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPlatformPythonInterface.cpp
 (-2) 
- (modified) 
lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface.cpp
 (+9-18) 
- (modified) 
lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.cpp
 (+2-32) 
- (modified) 
lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h
 (+3-26) 
- (removed) 
lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPlanPythonInterface.cpp
 (-105) 
- (removed) 
lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPlanPythonInterface.h
 (-48) 
- (modified) 
lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPythonInterface.cpp
 (+9-19) 
- (modified) lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h 
(+17-5) 
- (modified) 
lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp 
(+116-6) 
- (modified) 
lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h 
(+25-3) 
- (modified) lldb/source/Target/ThreadPlanPython.cpp (+43-55) 
- (modified) lldb/test/API/functionalities/step_scripted/Steps.py (+2-2) 
- (modified) lldb/test/API/functionalities/thread_plan/wrap_step_over.py (+1-1) 
- (modified) lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp 
(+20-30) 


``diff
diff --git a/lldb/bindings/python/python-swigsafecast.swig 
b/lldb/bindings/python/python-swigsafecast.swig
index 34f8c6f0ff8d3..d5ea514872713 100644
--- a/lldb/bindings/python/python-swigsafecast.swig
+++ b/lldb/bindings/python/python-swigsafecast.swig
@@ -37,6 +37,10 @@ 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);
 }
@@ -111,16 +115,9 @@ SWIGBridge::ToSWIGWrapper(CommandReturnObject &cmd_retobj) 
{
   SWIGTYPE_p_lldb__SBCommandReturnObject);
 }
 
-PythonObject SWIGBridge::ToSWIGWrapper(const Stream *s) {
-  return ToSWIGHelper(new lldb::SBStream(), SWIGTYPE_p_lldb__SBStream);
-}
-
-PythonObject SWIGBridge::ToSWIGWrapper(std::shared_ptr 
stream_sb) {
-  return ToSWIGHelper(stream_sb.get(), SWIGTYPE_p_lldb__SBStream);
-}
-
-PythonObject SWIGBridge::ToSWIGWrapper(Event *event) {
-  return ToSWIGHelper(new lldb::SBEvent(event), SWIGTYPE_p_lldb__SBEvent);
+ScopedPythonObject SWIGBridge::ToSWIGWrapper(Event *event) {
+  return ScopedPythonObject(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 28ab58f8ce495..1370afc885d43 100644
--- a/lldb/bindings/python/python-wrapper.swig
+++ b/lldb/bindings/python/python-wrapper.swig
@@ -229,6 +229,133 @@ 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::Reso

[Lldb-commits] [lldb] [lldb] Remove DWARFDebugInfo DIERef footguns (PR #92894)

2024-05-23 Thread Pavel Labath via lldb-commits


@@ -195,17 +195,17 @@ void DebugNamesDWARFIndex::GetCompleteObjCClass(
 if (!ref)
   continue;
 
-DWARFUnit *cu = m_debug_info.GetUnit(*ref);
-if (!cu || !cu->Supports_DW_AT_APPLE_objc_complete_type()) {
-  incomplete_types.push_back(*ref);
-  continue;
-}
-
-DWARFDIE die = m_debug_info.GetDIE(*ref);
+SymbolFileDWARF &dwarf = *llvm::cast(
+m_module.GetSymbolFile()->GetBackingSymbolFile());

labath wrote:

I was going to say that these can't be null, because then we wouldn't exist 
(the index is created by the symbol file, which is created by the module), but 
then I realized that the SymbolFile of a module can change during its lifetime 
(it rarely does, but it can), which would wreak havoc here (and elsewhere). So 
I'm going to do something even better instead. Hang on..

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


[Lldb-commits] [lldb] [llvm] [lldb][FreeBSD][AArch64] Enable register field detection (PR #85058)

2024-05-23 Thread David Spickett via lldb-commits

DavidSpickett wrote:

I'm currently assuming that the process classes will check those HWCAPs and 
only add those registers to the register info if they exist. This code only 
patches registers that are already in the info, it doesn't add any new ones.

That said, explicit is better than implicit, and I already have the HWCAP 
values to hand, so I will try checking them to see what should exist or not.

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


[Lldb-commits] [lldb] [lldb/DWARF] Make sure bad abbreviation codes do not crash lldb (PR #93006)

2024-05-23 Thread Pavel Labath via lldb-commits


@@ -44,10 +45,20 @@ bool DWARFDebugInfoEntry::Extract(const DWARFDataExtractor 
&data,
   const DWARFUnit *cu,
   lldb::offset_t *offset_ptr) {
   m_offset = *offset_ptr;
+  auto report_error = [&](const char *fmt, const auto &...vals) {
+cu->GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(

labath wrote:

All of the callers are in DWARFUnit (passing `this`), but I'm not going to pass 
up an opportunity to add more references. :P

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


[Lldb-commits] [lldb] [lldb/DWARF] Make sure bad abbreviation codes do not crash lldb (PR #93006)

2024-05-23 Thread Pavel Labath via lldb-commits

labath wrote:

> We have to back out the PeekDieName() patch locally at Meta because it was 
> crashing us due to this assertion due to .debug_names tables having incorrect 
> values for type units. Only one type unit will appear in the final file and 
> type units can have differing contents for the same type. This means 
> accelerator table entries from .o file that had a type unit, but its type 
> unit didn't end up in the final output file, can be bogus and not point to 
> valid DIE offsets which can cause PeekDieName to parse at random offsets in a 
> type unit and crash or report an error now. So we might need an extra bool to 
> be passed to the `DWARFDebugInfoEntry::Extract(...)` function that says to 
> report an error and have PeekDieName call this with "report_errors = false". 
> Right now many of these entries will cause a large numver of errors to be 
> reported. This is being fixed by verifying that type unit accelerator table 
> entries are matched to the right type unit, but that PR isn't in yet.

I think that is orthogonal to this patch, but it is troubling nonetheless 
(thank you for bringing it to my attention). If you want to go down this path, 
you might want to consider something like call_once (or call_once_every_N_sec) 
to make sure there is some record of the issue somewhere. If not, I might get 
around to this at some point.

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


[Lldb-commits] [lldb] [lldb/DWARF] Make sure bad abbreviation codes do not crash lldb (PR #93006)

2024-05-23 Thread Pavel Labath via lldb-commits

https://github.com/labath updated 
https://github.com/llvm/llvm-project/pull/93006

>From 03ab6febc0f40d0f39f533a5b4fd7c33a6728ae1 Mon Sep 17 00:00:00 2001
From: Pavel Labath 
Date: Tue, 21 May 2024 15:31:23 +
Subject: [PATCH 1/2] [lldb/DWARF] Make sure bad abbreviation codes do not
 crash lldb

We currently cannot represent abbreviation codes with more than 16 bits,
and we were lldb-asserting if we ever ran into one. While I haven't seen
any real DWARF with these kinds of abbreviations, it is possible to hit
this with handcrafted evil dwarf, due some sort of corruptions, or just
bugs (the addition of PeekDIEName makes these bugs more likely, as the
function blindly dereferences offsets within the debug info section) .

Missing abbreviations were already reporting an error. This patch turns
sure that large abbreviations into an error as well, and adds a test for
both cases.
---
 .../SymbolFile/DWARF/DWARFDebugInfoEntry.cpp  | 34 +++---
 .../DWARF/x86/invalid_abbreviation.s  | 47 +++
 2 files changed, 63 insertions(+), 18 deletions(-)
 create mode 100644 lldb/test/Shell/SymbolFile/DWARF/x86/invalid_abbreviation.s

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
index 1b0fefedf9836..4357ccb2f5c9f 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
@@ -11,6 +11,7 @@
 #include 
 
 #include 
+#include 
 #include 
 
 #include "llvm/Support/LEB128.h"
@@ -44,10 +45,20 @@ bool DWARFDebugInfoEntry::Extract(const DWARFDataExtractor 
&data,
   const DWARFUnit *cu,
   lldb::offset_t *offset_ptr) {
   m_offset = *offset_ptr;
+  auto report_error = [&](const char *fmt, const auto &...vals) {
+cu->GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
+"[{0:x16}]: {1}, please file a bug and "
+"attach the file at the start of this error message",
+static_cast(m_offset), llvm::formatv(fmt, vals...));
+*offset_ptr = std::numeric_limits::max();
+return false;
+  };
+
   m_parent_idx = 0;
   m_sibling_idx = 0;
   const uint64_t abbr_idx = data.GetULEB128(offset_ptr);
-  lldbassert(abbr_idx <= UINT16_MAX);
+  if (abbr_idx > std::numeric_limits::max())
+return report_error("abbreviation code {0} too big", abbr_idx);
   m_abbr_idx = abbr_idx;
 
   if (m_abbr_idx == 0) {
@@ -57,16 +68,9 @@ bool DWARFDebugInfoEntry::Extract(const DWARFDataExtractor 
&data,
   }
 
   const auto *abbrevDecl = GetAbbreviationDeclarationPtr(cu);
-  if (abbrevDecl == nullptr) {
-cu->GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
-"[{0:x16}]: invalid abbreviation code {1}, "
-"please file a bug and "
-"attach the file at the start of this error message",
-(uint64_t)m_offset, (unsigned)abbr_idx);
-// WE can't parse anymore if the DWARF is borked...
-*offset_ptr = UINT32_MAX;
-return false;
-  }
+  if (abbrevDecl == nullptr)
+return report_error("invalid abbreviation code {0}", abbr_idx);
+
   m_tag = abbrevDecl->getTag();
   m_has_children = abbrevDecl->hasChildren();
   // Skip all data in the .debug_info or .debug_types for the attributes
@@ -74,13 +78,7 @@ bool DWARFDebugInfoEntry::Extract(const DWARFDataExtractor 
&data,
 if (DWARFFormValue::SkipValue(attribute.Form, data, offset_ptr, cu))
   continue;
 
-cu->GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
-"[{0:x16}]: Unsupported DW_FORM_{1:x}, please file a bug "
-"and "
-"attach the file at the start of this error message",
-(uint64_t)m_offset, (unsigned)attribute.Form);
-*offset_ptr = m_offset;
-return false;
+return report_error("Unsupported DW_FORM_{1:x}", attribute.Form);
   }
   return true;
 }
diff --git a/lldb/test/Shell/SymbolFile/DWARF/x86/invalid_abbreviation.s 
b/lldb/test/Shell/SymbolFile/DWARF/x86/invalid_abbreviation.s
new file mode 100644
index 0..3f32c037aeb20
--- /dev/null
+++ b/lldb/test/Shell/SymbolFile/DWARF/x86/invalid_abbreviation.s
@@ -0,0 +1,47 @@
+# REQUIRES: x86
+
+# RUN: llvm-mc -triple=x86_64-pc-linux -filetype=obj %s > %t
+# RUN: %lldb %t \
+# RUN:   -o exit 2>&1 | FileCheck %s
+
+# CHECK-DAG: error: {{.*}} [0x0022]: abbreviation code 65536 too 
big, please file a bug and attach the file at the start of this error message
+# CHECK-DAG: error: {{.*}} [0x0048]: invalid abbreviation code 47, 
please file a bug and attach the file at the start of this error message
+
+
+.section.debug_abbrev,"",@progbits
+.uleb128 65535  # Largest representable Abbreviation 
Code
+.byte   17  # DW_TAG_compile_unit
+.byte   1   # DW_CHILDREN_yes
+.byte   37  # DW_AT_produc

[Lldb-commits] [lldb] a282463 - [lldb/DWARF] Make sure bad abbreviation codes do not crash lldb (#93006)

2024-05-23 Thread via lldb-commits

Author: Pavel Labath
Date: 2024-05-23T11:23:07+02:00
New Revision: a2824632cba8e7d98a5cbf9acb3ca5d9960c95cb

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

LOG: [lldb/DWARF] Make sure bad abbreviation codes do not crash lldb (#93006)

We currently cannot represent abbreviation codes with more than 16 bits,
and we were lldb-asserting if we ever ran into one. While I haven't seen
any real DWARF with these kinds of abbreviations, it is possible to hit
this with handcrafted evil dwarf, due some sort of corruptions, or just
bugs (the addition of PeekDIEName makes these bugs more likely, as the
function blindly dereferences offsets within the debug info section) .

Missing abbreviations were already reporting an error. This patch turns
sure that large abbreviations into an error as well, and adds a test for
both cases.

Added: 
lldb/test/Shell/SymbolFile/DWARF/x86/invalid_abbreviation.s

Modified: 
lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
index 1b0fefedf9836..688a287a06500 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
@@ -11,6 +11,7 @@
 #include 
 
 #include 
+#include 
 #include 
 
 #include "llvm/Support/LEB128.h"
@@ -41,13 +42,23 @@ extern int g_verbose;
 // Extract a debug info entry for a given DWARFUnit from the data
 // starting at the offset in offset_ptr
 bool DWARFDebugInfoEntry::Extract(const DWARFDataExtractor &data,
-  const DWARFUnit *cu,
+  const DWARFUnit &unit,
   lldb::offset_t *offset_ptr) {
   m_offset = *offset_ptr;
+  auto report_error = [&](const char *fmt, const auto &...vals) {
+unit.GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
+"[{0:x16}]: {1}, please file a bug and "
+"attach the file at the start of this error message",
+static_cast(m_offset), llvm::formatv(fmt, vals...));
+*offset_ptr = std::numeric_limits::max();
+return false;
+  };
+
   m_parent_idx = 0;
   m_sibling_idx = 0;
   const uint64_t abbr_idx = data.GetULEB128(offset_ptr);
-  lldbassert(abbr_idx <= UINT16_MAX);
+  if (abbr_idx > std::numeric_limits::max())
+return report_error("abbreviation code {0} too big", abbr_idx);
   m_abbr_idx = abbr_idx;
 
   if (m_abbr_idx == 0) {
@@ -56,31 +67,18 @@ bool DWARFDebugInfoEntry::Extract(const DWARFDataExtractor 
&data,
 return true; // NULL debug tag entry
   }
 
-  const auto *abbrevDecl = GetAbbreviationDeclarationPtr(cu);
-  if (abbrevDecl == nullptr) {
-cu->GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
-"[{0:x16}]: invalid abbreviation code {1}, "
-"please file a bug and "
-"attach the file at the start of this error message",
-(uint64_t)m_offset, (unsigned)abbr_idx);
-// WE can't parse anymore if the DWARF is borked...
-*offset_ptr = UINT32_MAX;
-return false;
-  }
+  const auto *abbrevDecl = GetAbbreviationDeclarationPtr(&unit);
+  if (abbrevDecl == nullptr)
+return report_error("invalid abbreviation code {0}", abbr_idx);
+
   m_tag = abbrevDecl->getTag();
   m_has_children = abbrevDecl->hasChildren();
   // Skip all data in the .debug_info or .debug_types for the attributes
   for (const auto &attribute : abbrevDecl->attributes()) {
-if (DWARFFormValue::SkipValue(attribute.Form, data, offset_ptr, cu))
+if (DWARFFormValue::SkipValue(attribute.Form, data, offset_ptr, &unit))
   continue;
 
-cu->GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
-"[{0:x16}]: Unsupported DW_FORM_{1:x}, please file a bug "
-"and "
-"attach the file at the start of this error message",
-(uint64_t)m_offset, (unsigned)attribute.Form);
-*offset_ptr = m_offset;
-return false;
+return report_error("Unsupported DW_FORM_{1:x}", attribute.Form);
   }
   return true;
 }

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
index c19fa74285490..6773b00e82069 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
@@ -49,7 +49,7 @@ class DWARFDebugInfoEntry {
   void BuildFunctionAddressRangeTable(DWARFUnit *cu,
   DWARFDebugAranges *debug_aranges) const;
 
-  bool Extract(const DWARFDataExtractor &data, co

[Lldb-commits] [lldb] [lldb/DWARF] Make sure bad abbreviation codes do not crash lldb (PR #93006)

2024-05-23 Thread Pavel Labath via lldb-commits

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


[Lldb-commits] [lldb] [lldb][Test] Add C++ tests for DumpValueObjectOptions and enums (PR #93158)

2024-05-23 Thread David Spickett via lldb-commits

https://github.com/DavidSpickett created 
https://github.com/llvm/llvm-project/pull/93158

DumpValueObjectOptions can only be created and modified from C++. This means 
it's currently only testable from Python by calling some command that happens 
to use one, and even so, you can't pick which options get chosen.

So we have decent coverage for the major options that way, but I want to add 
more niche options that will be harder to test from Python (register field 
options).

So this change adds some "unit tests", though it's stretching the definition to 
the point it's more "test written in C++". So we can test future options in 
isolation.

Since I want to add options specific to enums, that's all it covers. There is a 
test class that sets up the type system so it will be easy to test other types 
in future (e.g. structs, which register fields also use).

>From aff2acafd911b9eb07405beb5500a487f5d4fc4e Mon Sep 17 00:00:00 2001
From: David Spickett 
Date: Wed, 1 May 2024 13:08:54 +
Subject: [PATCH] [lldb][Test] Add C++ tests for DumpValueObjectOptions and
 enums

DumpValueObjectOptions can only be created and modified from C++.
This means it's currently only testable from Python by calling some
command that happens to use one, and even so, you can't pick
which options get chosen.

So we have decent coverage for the major options that way, but I
want to add more niche options that will be harder to test from
Python (register field options).

So this change adds some "unit tests", though it's stretching the
definition to the point it's more "test written in C++". So
we can test future options in isolation.

Since I want to add options specific to enums, that's all it covers.
There is a test class that sets up the type system so it will be
easy to test other types in future (e.g. structs, which register
fields also use).
---
 lldb/unittests/CMakeLists.txt |   1 +
 lldb/unittests/ValueObject/CMakeLists.txt |  10 ++
 .../DumpValueObjectOptionsTests.cpp   | 136 ++
 3 files changed, 147 insertions(+)
 create mode 100644 lldb/unittests/ValueObject/CMakeLists.txt
 create mode 100644 lldb/unittests/ValueObject/DumpValueObjectOptionsTests.cpp

diff --git a/lldb/unittests/CMakeLists.txt b/lldb/unittests/CMakeLists.txt
index c084fa5cca92b..dc1d8b69f0036 100644
--- a/lldb/unittests/CMakeLists.txt
+++ b/lldb/unittests/CMakeLists.txt
@@ -73,6 +73,7 @@ add_subdirectory(tools)
 add_subdirectory(UnwindAssembly)
 add_subdirectory(Utility)
 add_subdirectory(Thread)
+add_subdirectory(ValueObject)
 
 if(LLDB_CAN_USE_DEBUGSERVER AND LLDB_TOOL_DEBUGSERVER_BUILD AND NOT 
LLDB_USE_SYSTEM_DEBUGSERVER)
   add_subdirectory(debugserver)
diff --git a/lldb/unittests/ValueObject/CMakeLists.txt 
b/lldb/unittests/ValueObject/CMakeLists.txt
new file mode 100644
index 0..fb31f76506286
--- /dev/null
+++ b/lldb/unittests/ValueObject/CMakeLists.txt
@@ -0,0 +1,10 @@
+add_lldb_unittest(LLDBValueObjectTests
+  DumpValueObjectOptionsTests.cpp
+
+  LINK_LIBS
+lldbPluginPlatformLinux
+lldbPluginScriptInterpreterNone
+
+  LINK_COMPONENTS
+Support
+  )
diff --git a/lldb/unittests/ValueObject/DumpValueObjectOptionsTests.cpp 
b/lldb/unittests/ValueObject/DumpValueObjectOptionsTests.cpp
new file mode 100644
index 0..e89ec4508f6d8
--- /dev/null
+++ b/lldb/unittests/ValueObject/DumpValueObjectOptionsTests.cpp
@@ -0,0 +1,136 @@
+//===-- DumpValueObjectOptionsTests.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 "Plugins/Platform/Linux/PlatformLinux.h"
+#include "Plugins/ScriptInterpreter/None/ScriptInterpreterNone.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
+#include "TestingSupport/SubsystemRAII.h"
+#include "TestingSupport/Symbol/ClangTestUtils.h"
+#include "lldb/Core/Debugger.h"
+#include "lldb/Core/ValueObject.h"
+#include "lldb/Core/ValueObjectConstResult.h"
+#include "lldb/DataFormatters/DumpValueObjectOptions.h"
+
+#include "gtest/gtest.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+struct MockProcess : Process {
+  MockProcess(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp)
+  : Process(target_sp, listener_sp) {}
+
+  llvm::StringRef GetPluginName() override { return "mock process"; }
+
+  bool CanDebug(lldb::TargetSP target, bool plugin_specified_by_name) override 
{
+return false;
+  };
+
+  Status DoDestroy() override { return {}; }
+
+  void RefreshStateAfterStop() override {}
+
+  bool DoUpdateThreadList(ThreadList &old_thread_list,
+  ThreadList &new_thread_list) override {
+return false;
+  };
+
+  size_t DoReadMemory(lldb::addr_t vm_addr, void *buf, size_t size,
+  Statu

[Lldb-commits] [lldb] [lldb][Test] Add C++ tests for DumpValueObjectOptions and enums (PR #93158)

2024-05-23 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: David Spickett (DavidSpickett)


Changes

DumpValueObjectOptions can only be created and modified from C++. This means 
it's currently only testable from Python by calling some command that happens 
to use one, and even so, you can't pick which options get chosen.

So we have decent coverage for the major options that way, but I want to add 
more niche options that will be harder to test from Python (register field 
options).

So this change adds some "unit tests", though it's stretching the definition to 
the point it's more "test written in C++". So we can test future options in 
isolation.

Since I want to add options specific to enums, that's all it covers. There is a 
test class that sets up the type system so it will be easy to test other types 
in future (e.g. structs, which register fields also use).

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


3 Files Affected:

- (modified) lldb/unittests/CMakeLists.txt (+1) 
- (added) lldb/unittests/ValueObject/CMakeLists.txt (+10) 
- (added) lldb/unittests/ValueObject/DumpValueObjectOptionsTests.cpp (+136) 


``diff
diff --git a/lldb/unittests/CMakeLists.txt b/lldb/unittests/CMakeLists.txt
index c084fa5cca92b..dc1d8b69f0036 100644
--- a/lldb/unittests/CMakeLists.txt
+++ b/lldb/unittests/CMakeLists.txt
@@ -73,6 +73,7 @@ add_subdirectory(tools)
 add_subdirectory(UnwindAssembly)
 add_subdirectory(Utility)
 add_subdirectory(Thread)
+add_subdirectory(ValueObject)
 
 if(LLDB_CAN_USE_DEBUGSERVER AND LLDB_TOOL_DEBUGSERVER_BUILD AND NOT 
LLDB_USE_SYSTEM_DEBUGSERVER)
   add_subdirectory(debugserver)
diff --git a/lldb/unittests/ValueObject/CMakeLists.txt 
b/lldb/unittests/ValueObject/CMakeLists.txt
new file mode 100644
index 0..fb31f76506286
--- /dev/null
+++ b/lldb/unittests/ValueObject/CMakeLists.txt
@@ -0,0 +1,10 @@
+add_lldb_unittest(LLDBValueObjectTests
+  DumpValueObjectOptionsTests.cpp
+
+  LINK_LIBS
+lldbPluginPlatformLinux
+lldbPluginScriptInterpreterNone
+
+  LINK_COMPONENTS
+Support
+  )
diff --git a/lldb/unittests/ValueObject/DumpValueObjectOptionsTests.cpp 
b/lldb/unittests/ValueObject/DumpValueObjectOptionsTests.cpp
new file mode 100644
index 0..e89ec4508f6d8
--- /dev/null
+++ b/lldb/unittests/ValueObject/DumpValueObjectOptionsTests.cpp
@@ -0,0 +1,136 @@
+//===-- DumpValueObjectOptionsTests.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 "Plugins/Platform/Linux/PlatformLinux.h"
+#include "Plugins/ScriptInterpreter/None/ScriptInterpreterNone.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
+#include "TestingSupport/SubsystemRAII.h"
+#include "TestingSupport/Symbol/ClangTestUtils.h"
+#include "lldb/Core/Debugger.h"
+#include "lldb/Core/ValueObject.h"
+#include "lldb/Core/ValueObjectConstResult.h"
+#include "lldb/DataFormatters/DumpValueObjectOptions.h"
+
+#include "gtest/gtest.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+struct MockProcess : Process {
+  MockProcess(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp)
+  : Process(target_sp, listener_sp) {}
+
+  llvm::StringRef GetPluginName() override { return "mock process"; }
+
+  bool CanDebug(lldb::TargetSP target, bool plugin_specified_by_name) override 
{
+return false;
+  };
+
+  Status DoDestroy() override { return {}; }
+
+  void RefreshStateAfterStop() override {}
+
+  bool DoUpdateThreadList(ThreadList &old_thread_list,
+  ThreadList &new_thread_list) override {
+return false;
+  };
+
+  size_t DoReadMemory(lldb::addr_t vm_addr, void *buf, size_t size,
+  Status &error) override {
+// No need to read memory in these tests.
+return size;
+  }
+};
+
+class ValueObjectMockProcessTest : public ::testing::Test {
+public:
+  void SetUp() override {
+ArchSpec arch("i386-pc-linux");
+Platform::SetHostPlatform(
+platform_linux::PlatformLinux::CreateInstance(true, &arch));
+m_debugger_sp = Debugger::CreateInstance();
+ASSERT_TRUE(m_debugger_sp);
+m_debugger_sp->GetTargetList().CreateTarget(*m_debugger_sp, "", arch,
+eLoadDependentsNo,
+m_platform_sp, m_target_sp);
+ASSERT_TRUE(m_target_sp);
+ASSERT_TRUE(m_target_sp->GetArchitecture().IsValid());
+ASSERT_TRUE(m_platform_sp);
+m_listener_sp = Listener::MakeListener("dummy");
+m_process_sp = std::make_shared(m_target_sp, m_listener_sp);
+ASSERT_TRUE(m_process_sp);
+m_exe_ctx = ExecutionContext(m_process_sp);
+
+m_holder = std::make_unique("test");
+m_type_system = m_holder->GetAST();
+  }
+

[Lldb-commits] [lldb] [lldb][Test] Add C++ tests for DumpValueObjectOptions and enums (PR #93158)

2024-05-23 Thread David Spickett via lldb-commits


@@ -0,0 +1,136 @@
+//===-- DumpValueObjectOptionsTests.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 "Plugins/Platform/Linux/PlatformLinux.h"
+#include "Plugins/ScriptInterpreter/None/ScriptInterpreterNone.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
+#include "TestingSupport/SubsystemRAII.h"
+#include "TestingSupport/Symbol/ClangTestUtils.h"
+#include "lldb/Core/Debugger.h"
+#include "lldb/Core/ValueObject.h"
+#include "lldb/Core/ValueObjectConstResult.h"
+#include "lldb/DataFormatters/DumpValueObjectOptions.h"
+
+#include "gtest/gtest.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+struct MockProcess : Process {
+  MockProcess(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp)
+  : Process(target_sp, listener_sp) {}
+
+  llvm::StringRef GetPluginName() override { return "mock process"; }
+
+  bool CanDebug(lldb::TargetSP target, bool plugin_specified_by_name) override 
{
+return false;
+  };
+
+  Status DoDestroy() override { return {}; }
+
+  void RefreshStateAfterStop() override {}
+
+  bool DoUpdateThreadList(ThreadList &old_thread_list,
+  ThreadList &new_thread_list) override {
+return false;
+  };
+
+  size_t DoReadMemory(lldb::addr_t vm_addr, void *buf, size_t size,
+  Status &error) override {
+// No need to read memory in these tests.
+return size;
+  }
+};
+
+class ValueObjectMockProcessTest : public ::testing::Test {
+public:
+  void SetUp() override {
+ArchSpec arch("i386-pc-linux");
+Platform::SetHostPlatform(
+platform_linux::PlatformLinux::CreateInstance(true, &arch));
+m_debugger_sp = Debugger::CreateInstance();
+ASSERT_TRUE(m_debugger_sp);
+m_debugger_sp->GetTargetList().CreateTarget(*m_debugger_sp, "", arch,
+eLoadDependentsNo,
+m_platform_sp, m_target_sp);
+ASSERT_TRUE(m_target_sp);
+ASSERT_TRUE(m_target_sp->GetArchitecture().IsValid());
+ASSERT_TRUE(m_platform_sp);
+m_listener_sp = Listener::MakeListener("dummy");
+m_process_sp = std::make_shared(m_target_sp, m_listener_sp);
+ASSERT_TRUE(m_process_sp);
+m_exe_ctx = ExecutionContext(m_process_sp);
+
+m_holder = std::make_unique("test");
+m_type_system = m_holder->GetAST();
+  }
+
+  ExecutionContext m_exe_ctx;
+  TypeSystemClang *m_type_system;
+
+private:
+  SubsystemRAII
+  m_subsystems;
+
+  std::unique_ptr m_holder;
+  lldb::DebuggerSP m_debugger_sp;
+  lldb::TargetSP m_target_sp;
+  lldb::PlatformSP m_platform_sp;
+  lldb::ListenerSP m_listener_sp;
+  lldb::ProcessSP m_process_sp;
+};
+
+TEST_F(ValueObjectMockProcessTest, Enum) {
+  CompilerType uint_type = m_type_system->GetBuiltinTypeForEncodingAndBitSize(
+  lldb::eEncodingUint, 32);
+  CompilerType enum_type = m_type_system->CreateEnumerationType(
+  "test_enum", m_type_system->GetTranslationUnitDecl(),
+  OptionalClangModuleID(), Declaration(), uint_type, false);
+
+  m_type_system->StartTagDeclarationDefinition(enum_type);
+  Declaration decl;
+  // Each value sets one bit in the enum, to make this a "bitfield like enum".
+  m_type_system->AddEnumerationValueToEnumerationType(enum_type, decl, 
"test_2",
+  2, 32);
+  m_type_system->AddEnumerationValueToEnumerationType(enum_type, decl, 
"test_4",
+  4, 32);
+  m_type_system->CompleteTagDeclarationDefinition(enum_type);
+
+  std::vector> 
enums{
+  {0, {}, "(test_enum) test_var =\n"},

DavidSpickett wrote:

I'm looking into why this one prints no value at all, but I'm not trying to 
change any behaviour in this patch, just document what exists.

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


[Lldb-commits] [lldb] [lldb][Test] Add C++ tests for DumpValueObjectOptions and enums (PR #93158)

2024-05-23 Thread David Spickett via lldb-commits


@@ -0,0 +1,136 @@
+//===-- DumpValueObjectOptionsTests.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 "Plugins/Platform/Linux/PlatformLinux.h"
+#include "Plugins/ScriptInterpreter/None/ScriptInterpreterNone.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
+#include "TestingSupport/SubsystemRAII.h"
+#include "TestingSupport/Symbol/ClangTestUtils.h"
+#include "lldb/Core/Debugger.h"
+#include "lldb/Core/ValueObject.h"
+#include "lldb/Core/ValueObjectConstResult.h"
+#include "lldb/DataFormatters/DumpValueObjectOptions.h"
+
+#include "gtest/gtest.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+struct MockProcess : Process {
+  MockProcess(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp)
+  : Process(target_sp, listener_sp) {}
+
+  llvm::StringRef GetPluginName() override { return "mock process"; }
+
+  bool CanDebug(lldb::TargetSP target, bool plugin_specified_by_name) override 
{
+return false;
+  };
+
+  Status DoDestroy() override { return {}; }
+
+  void RefreshStateAfterStop() override {}
+
+  bool DoUpdateThreadList(ThreadList &old_thread_list,
+  ThreadList &new_thread_list) override {
+return false;
+  };
+
+  size_t DoReadMemory(lldb::addr_t vm_addr, void *buf, size_t size,
+  Status &error) override {
+// No need to read memory in these tests.
+return size;
+  }
+};
+
+class ValueObjectMockProcessTest : public ::testing::Test {
+public:
+  void SetUp() override {
+ArchSpec arch("i386-pc-linux");
+Platform::SetHostPlatform(
+platform_linux::PlatformLinux::CreateInstance(true, &arch));
+m_debugger_sp = Debugger::CreateInstance();
+ASSERT_TRUE(m_debugger_sp);
+m_debugger_sp->GetTargetList().CreateTarget(*m_debugger_sp, "", arch,
+eLoadDependentsNo,
+m_platform_sp, m_target_sp);
+ASSERT_TRUE(m_target_sp);
+ASSERT_TRUE(m_target_sp->GetArchitecture().IsValid());
+ASSERT_TRUE(m_platform_sp);
+m_listener_sp = Listener::MakeListener("dummy");
+m_process_sp = std::make_shared(m_target_sp, m_listener_sp);
+ASSERT_TRUE(m_process_sp);
+m_exe_ctx = ExecutionContext(m_process_sp);
+
+m_holder = std::make_unique("test");
+m_type_system = m_holder->GetAST();
+  }
+
+  ExecutionContext m_exe_ctx;
+  TypeSystemClang *m_type_system;
+
+private:
+  SubsystemRAII
+  m_subsystems;
+
+  std::unique_ptr m_holder;
+  lldb::DebuggerSP m_debugger_sp;
+  lldb::TargetSP m_target_sp;
+  lldb::PlatformSP m_platform_sp;
+  lldb::ListenerSP m_listener_sp;
+  lldb::ProcessSP m_process_sp;
+};
+
+TEST_F(ValueObjectMockProcessTest, Enum) {
+  CompilerType uint_type = m_type_system->GetBuiltinTypeForEncodingAndBitSize(
+  lldb::eEncodingUint, 32);
+  CompilerType enum_type = m_type_system->CreateEnumerationType(
+  "test_enum", m_type_system->GetTranslationUnitDecl(),
+  OptionalClangModuleID(), Declaration(), uint_type, false);
+
+  m_type_system->StartTagDeclarationDefinition(enum_type);
+  Declaration decl;
+  // Each value sets one bit in the enum, to make this a "bitfield like enum".
+  m_type_system->AddEnumerationValueToEnumerationType(enum_type, decl, 
"test_2",
+  2, 32);
+  m_type_system->AddEnumerationValueToEnumerationType(enum_type, decl, 
"test_4",
+  4, 32);
+  m_type_system->CompleteTagDeclarationDefinition(enum_type);
+
+  std::vector> 
enums{
+  {0, {}, "(test_enum) test_var =\n"},

DavidSpickett wrote:

It's because I used a bitfield like enum here.
```
  // enumerators. Also 0 doesn't make sense when the enumerators are used as
  // flags.
```
I'll add some tests for a normal enum as well.

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


[Lldb-commits] [lldb] 4d9e7b1 - [lldb][Windows] Fixed the TestBreakpointCommand test (#93122)

2024-05-23 Thread via lldb-commits

Author: Dmitry Vasilyev
Date: 2024-05-23T13:59:02+04:00
New Revision: 4d9e7b14e45120557e57da2f00f6d23cf122dd95

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

LOG: [lldb][Windows] Fixed the TestBreakpointCommand test (#93122)

The TestBreakpointCommand test is incorrectly disabled for Windows
target. We can disable it for Windows host instead or just fix the
issue. This patch fixes the path separator in
BreakpointResolverFileLine::DeduceSourceMapping() and the Windows
specific absolute path in the test in case of the Windows host.

Added: 


Modified: 
lldb/source/Breakpoint/BreakpointResolverFileLine.cpp

lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py

Removed: 




diff  --git a/lldb/source/Breakpoint/BreakpointResolverFileLine.cpp 
b/lldb/source/Breakpoint/BreakpointResolverFileLine.cpp
index d7d8c714867e3..16c4ee1b88d16 100644
--- a/lldb/source/Breakpoint/BreakpointResolverFileLine.cpp
+++ b/lldb/source/Breakpoint/BreakpointResolverFileLine.cpp
@@ -198,16 +198,16 @@ void BreakpointResolverFileLine::DeduceSourceMapping(
 return;
 
   Log *log = GetLog(LLDBLog::Breakpoints);
-  const llvm::StringRef path_separator = llvm::sys::path::get_separator(
-  m_location_spec.GetFileSpec().GetPathStyle());
   // Check if "b" is a suffix of "a".
   // And return std::nullopt if not or the new path
   // of "a" after consuming "b" from the back.
   auto check_suffix =
-  [path_separator](llvm::StringRef a, llvm::StringRef b,
-   bool case_sensitive) -> std::optional {
+  [](llvm::StringRef a, llvm::StringRef b,
+ bool case_sensitive) -> std::optional {
 if (case_sensitive ? a.consume_back(b) : a.consume_back_insensitive(b)) {
-  if (a.empty() || a.ends_with(path_separator)) {
+  // Note sc_file_dir and request_file_dir below are normalized
+  // and always contain the path separator '/'.
+  if (a.empty() || a.ends_with("/")) {
 return a;
   }
 }

diff  --git 
a/lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py
 
b/lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py
index c219a4ee5bd9c..605561c757372 100644
--- 
a/lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py
+++ 
b/lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py
@@ -6,7 +6,7 @@
 import lldb
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
-from lldbsuite.test import lldbutil
+from lldbsuite.test import lldbutil, lldbplatformutil
 import json
 import os
 import side_effect
@@ -581,7 +581,6 @@ def verify_source_map_deduce_statistics(self, target, 
expected_count):
 self.assertNotEqual(target_stats, None)
 self.assertEqual(target_stats["sourceMapDeduceCount"], expected_count)
 
-@skipIf(oslist=["windows"])
 @no_debug_info_test
 def test_breakpoints_auto_source_map_relative(self):
 """
@@ -612,8 +611,13 @@ def test_breakpoints_auto_source_map_relative(self):
 self.verify_source_map_deduce_statistics(target, 0)
 
 # Verify auto deduced source map when file path in debug info
-# is a suffix of request breakpoint file path
-path = "/x/y/a/b/c/main.cpp"
+# is a suffix of request breakpoint file path.
+# Note the path must be absolute.
+path = (
+"/x/y/a/b/c/main.cpp"
+if lldbplatformutil.getHostPlatform() != "windows"
+else r"C:\x\y\a\b\c\main.cpp"
+)
 bp = target.BreakpointCreateByLocation(path, 2)
 self.assertGreater(
 bp.GetNumLocations(),
@@ -625,7 +629,11 @@ def test_breakpoints_auto_source_map_relative(self):
 
 source_map_json = self.get_source_map_json()
 self.assertEqual(len(source_map_json), 1, "source map should not be 
empty")
-self.verify_source_map_entry_pair(source_map_json[0], ".", "/x/y")
+self.verify_source_map_entry_pair(
+source_map_json[0],
+".",
+"/x/y" if lldbplatformutil.getHostPlatform() != "windows" else 
r"C:\x\y",
+)
 self.verify_source_map_deduce_statistics(target, 1)
 
 # Reset source map.



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


[Lldb-commits] [lldb] [lldb][Windows] Fixed the TestBreakpointCommand test (PR #93122)

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

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


[Lldb-commits] [lldb] e37da2c - [lldb] Fixed the TestExitDuringExpression test in case of a remote target (#93119)

2024-05-23 Thread via lldb-commits

Author: Dmitry Vasilyev
Date: 2024-05-23T14:01:10+04:00
New Revision: e37da2cef7ea44f6aa52dd37978b287a0741c39f

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

LOG: [lldb] Fixed the TestExitDuringExpression test in case of a remote target 
(#93119)

Sometimes this test failed on the assert `The thread exited` in case of
a remote target. Increase the timeout to 1 second to avoid a racing
condition.

Added: 


Modified: 
lldb/test/API/functionalities/thread/exit_during_expression/main.c

Removed: 




diff  --git 
a/lldb/test/API/functionalities/thread/exit_during_expression/main.c 
b/lldb/test/API/functionalities/thread/exit_during_expression/main.c
index eb6d17520986c..f633632e96cc4 100644
--- a/lldb/test/API/functionalities/thread/exit_during_expression/main.c
+++ b/lldb/test/API/functionalities/thread/exit_during_expression/main.c
@@ -3,7 +3,7 @@
 #include 
 #include 
 
-static unsigned int g_timeout = 10;
+static unsigned int g_timeout = 100;
 
 extern int usleep(unsigned int);
 



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


[Lldb-commits] [lldb] [lldb] Fixed the TestExitDuringExpression test in case of a remote target (PR #93119)

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

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


[Lldb-commits] [lldb] [lldb][Test] Add C++ tests for DumpValueObjectOptions and enums (PR #93158)

2024-05-23 Thread David Spickett via lldb-commits

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

>From aff2acafd911b9eb07405beb5500a487f5d4fc4e Mon Sep 17 00:00:00 2001
From: David Spickett 
Date: Wed, 1 May 2024 13:08:54 +
Subject: [PATCH 1/2] [lldb][Test] Add C++ tests for DumpValueObjectOptions and
 enums

DumpValueObjectOptions can only be created and modified from C++.
This means it's currently only testable from Python by calling some
command that happens to use one, and even so, you can't pick
which options get chosen.

So we have decent coverage for the major options that way, but I
want to add more niche options that will be harder to test from
Python (register field options).

So this change adds some "unit tests", though it's stretching the
definition to the point it's more "test written in C++". So
we can test future options in isolation.

Since I want to add options specific to enums, that's all it covers.
There is a test class that sets up the type system so it will be
easy to test other types in future (e.g. structs, which register
fields also use).
---
 lldb/unittests/CMakeLists.txt |   1 +
 lldb/unittests/ValueObject/CMakeLists.txt |  10 ++
 .../DumpValueObjectOptionsTests.cpp   | 136 ++
 3 files changed, 147 insertions(+)
 create mode 100644 lldb/unittests/ValueObject/CMakeLists.txt
 create mode 100644 lldb/unittests/ValueObject/DumpValueObjectOptionsTests.cpp

diff --git a/lldb/unittests/CMakeLists.txt b/lldb/unittests/CMakeLists.txt
index c084fa5cca92b..dc1d8b69f0036 100644
--- a/lldb/unittests/CMakeLists.txt
+++ b/lldb/unittests/CMakeLists.txt
@@ -73,6 +73,7 @@ add_subdirectory(tools)
 add_subdirectory(UnwindAssembly)
 add_subdirectory(Utility)
 add_subdirectory(Thread)
+add_subdirectory(ValueObject)
 
 if(LLDB_CAN_USE_DEBUGSERVER AND LLDB_TOOL_DEBUGSERVER_BUILD AND NOT 
LLDB_USE_SYSTEM_DEBUGSERVER)
   add_subdirectory(debugserver)
diff --git a/lldb/unittests/ValueObject/CMakeLists.txt 
b/lldb/unittests/ValueObject/CMakeLists.txt
new file mode 100644
index 0..fb31f76506286
--- /dev/null
+++ b/lldb/unittests/ValueObject/CMakeLists.txt
@@ -0,0 +1,10 @@
+add_lldb_unittest(LLDBValueObjectTests
+  DumpValueObjectOptionsTests.cpp
+
+  LINK_LIBS
+lldbPluginPlatformLinux
+lldbPluginScriptInterpreterNone
+
+  LINK_COMPONENTS
+Support
+  )
diff --git a/lldb/unittests/ValueObject/DumpValueObjectOptionsTests.cpp 
b/lldb/unittests/ValueObject/DumpValueObjectOptionsTests.cpp
new file mode 100644
index 0..e89ec4508f6d8
--- /dev/null
+++ b/lldb/unittests/ValueObject/DumpValueObjectOptionsTests.cpp
@@ -0,0 +1,136 @@
+//===-- DumpValueObjectOptionsTests.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 "Plugins/Platform/Linux/PlatformLinux.h"
+#include "Plugins/ScriptInterpreter/None/ScriptInterpreterNone.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
+#include "TestingSupport/SubsystemRAII.h"
+#include "TestingSupport/Symbol/ClangTestUtils.h"
+#include "lldb/Core/Debugger.h"
+#include "lldb/Core/ValueObject.h"
+#include "lldb/Core/ValueObjectConstResult.h"
+#include "lldb/DataFormatters/DumpValueObjectOptions.h"
+
+#include "gtest/gtest.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+struct MockProcess : Process {
+  MockProcess(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp)
+  : Process(target_sp, listener_sp) {}
+
+  llvm::StringRef GetPluginName() override { return "mock process"; }
+
+  bool CanDebug(lldb::TargetSP target, bool plugin_specified_by_name) override 
{
+return false;
+  };
+
+  Status DoDestroy() override { return {}; }
+
+  void RefreshStateAfterStop() override {}
+
+  bool DoUpdateThreadList(ThreadList &old_thread_list,
+  ThreadList &new_thread_list) override {
+return false;
+  };
+
+  size_t DoReadMemory(lldb::addr_t vm_addr, void *buf, size_t size,
+  Status &error) override {
+// No need to read memory in these tests.
+return size;
+  }
+};
+
+class ValueObjectMockProcessTest : public ::testing::Test {
+public:
+  void SetUp() override {
+ArchSpec arch("i386-pc-linux");
+Platform::SetHostPlatform(
+platform_linux::PlatformLinux::CreateInstance(true, &arch));
+m_debugger_sp = Debugger::CreateInstance();
+ASSERT_TRUE(m_debugger_sp);
+m_debugger_sp->GetTargetList().CreateTarget(*m_debugger_sp, "", arch,
+eLoadDependentsNo,
+m_platform_sp, m_target_sp);
+ASSERT_TRUE(m_target_sp);
+ASSERT_TRUE(m_target_sp->GetArchitecture().IsValid());
+ASSERT_TRUE(m_platform_sp);
+m_listener

[Lldb-commits] [lldb] [lldb][Test] Add C++ tests for DumpValueObjectOptions and enums (PR #93158)

2024-05-23 Thread David Spickett via lldb-commits


@@ -0,0 +1,136 @@
+//===-- DumpValueObjectOptionsTests.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 "Plugins/Platform/Linux/PlatformLinux.h"
+#include "Plugins/ScriptInterpreter/None/ScriptInterpreterNone.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
+#include "TestingSupport/SubsystemRAII.h"
+#include "TestingSupport/Symbol/ClangTestUtils.h"
+#include "lldb/Core/Debugger.h"
+#include "lldb/Core/ValueObject.h"
+#include "lldb/Core/ValueObjectConstResult.h"
+#include "lldb/DataFormatters/DumpValueObjectOptions.h"
+
+#include "gtest/gtest.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+struct MockProcess : Process {
+  MockProcess(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp)
+  : Process(target_sp, listener_sp) {}
+
+  llvm::StringRef GetPluginName() override { return "mock process"; }
+
+  bool CanDebug(lldb::TargetSP target, bool plugin_specified_by_name) override 
{
+return false;
+  };
+
+  Status DoDestroy() override { return {}; }
+
+  void RefreshStateAfterStop() override {}
+
+  bool DoUpdateThreadList(ThreadList &old_thread_list,
+  ThreadList &new_thread_list) override {
+return false;
+  };
+
+  size_t DoReadMemory(lldb::addr_t vm_addr, void *buf, size_t size,
+  Status &error) override {
+// No need to read memory in these tests.
+return size;
+  }
+};
+
+class ValueObjectMockProcessTest : public ::testing::Test {
+public:
+  void SetUp() override {
+ArchSpec arch("i386-pc-linux");
+Platform::SetHostPlatform(
+platform_linux::PlatformLinux::CreateInstance(true, &arch));
+m_debugger_sp = Debugger::CreateInstance();
+ASSERT_TRUE(m_debugger_sp);
+m_debugger_sp->GetTargetList().CreateTarget(*m_debugger_sp, "", arch,
+eLoadDependentsNo,
+m_platform_sp, m_target_sp);
+ASSERT_TRUE(m_target_sp);
+ASSERT_TRUE(m_target_sp->GetArchitecture().IsValid());
+ASSERT_TRUE(m_platform_sp);
+m_listener_sp = Listener::MakeListener("dummy");
+m_process_sp = std::make_shared(m_target_sp, m_listener_sp);
+ASSERT_TRUE(m_process_sp);
+m_exe_ctx = ExecutionContext(m_process_sp);
+
+m_holder = std::make_unique("test");
+m_type_system = m_holder->GetAST();
+  }
+
+  ExecutionContext m_exe_ctx;
+  TypeSystemClang *m_type_system;
+
+private:
+  SubsystemRAII
+  m_subsystems;
+
+  std::unique_ptr m_holder;
+  lldb::DebuggerSP m_debugger_sp;
+  lldb::TargetSP m_target_sp;
+  lldb::PlatformSP m_platform_sp;
+  lldb::ListenerSP m_listener_sp;
+  lldb::ProcessSP m_process_sp;
+};
+
+TEST_F(ValueObjectMockProcessTest, Enum) {
+  CompilerType uint_type = m_type_system->GetBuiltinTypeForEncodingAndBitSize(
+  lldb::eEncodingUint, 32);
+  CompilerType enum_type = m_type_system->CreateEnumerationType(
+  "test_enum", m_type_system->GetTranslationUnitDecl(),
+  OptionalClangModuleID(), Declaration(), uint_type, false);
+
+  m_type_system->StartTagDeclarationDefinition(enum_type);
+  Declaration decl;
+  // Each value sets one bit in the enum, to make this a "bitfield like enum".
+  m_type_system->AddEnumerationValueToEnumerationType(enum_type, decl, 
"test_2",
+  2, 32);
+  m_type_system->AddEnumerationValueToEnumerationType(enum_type, decl, 
"test_4",
+  4, 32);
+  m_type_system->CompleteTagDeclarationDefinition(enum_type);
+
+  std::vector> 
enums{
+  {0, {}, "(test_enum) test_var =\n"},

DavidSpickett wrote:

Done.

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


[Lldb-commits] [lldb] [lldb] Fixed the TestDAP_repl_mode_detection test in case of a remote target (PR #93165)

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

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

This test is based on dap_server which runs locally. This test failed in case 
of Windows host and Linux target.

>From 2243749477714852ada7a00bb849514283655464 Mon Sep 17 00:00:00 2001
From: Dmitry Vasilyev 
Date: Thu, 23 May 2024 14:21:23 +0400
Subject: [PATCH] [lldb] Fixed the TestDAP_repl_mode_detection test in case of
 a remote target

This test is based on dap_server which runs locally. This test failed in case 
of Windows host and Linux target.
---
 .../API/tools/lldb-dap/repl-mode/TestDAP_repl_mode_detection.py  | 1 +
 1 file changed, 1 insertion(+)

diff --git 
a/lldb/test/API/tools/lldb-dap/repl-mode/TestDAP_repl_mode_detection.py 
b/lldb/test/API/tools/lldb-dap/repl-mode/TestDAP_repl_mode_detection.py
index 7c77fc8541b93..705ae13e349dc 100644
--- a/lldb/test/API/tools/lldb-dap/repl-mode/TestDAP_repl_mode_detection.py
+++ b/lldb/test/API/tools/lldb-dap/repl-mode/TestDAP_repl_mode_detection.py
@@ -18,6 +18,7 @@ def assertEvaluate(self, expression, regex):
 regex,
 )
 
+@skipIfRemote
 def test_completions(self):
 program = self.getBuildArtifact("a.out")
 self.build_and_launch(program)

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


[Lldb-commits] [lldb] [lldb] Fixed the TestDAP_repl_mode_detection test in case of a remote target (PR #93165)

2024-05-23 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Dmitry Vasilyev (slydiman)


Changes

This test is based on dap_server which runs locally. This test failed in case 
of Windows host and Linux target.

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


1 Files Affected:

- (modified) 
lldb/test/API/tools/lldb-dap/repl-mode/TestDAP_repl_mode_detection.py (+1) 


``diff
diff --git 
a/lldb/test/API/tools/lldb-dap/repl-mode/TestDAP_repl_mode_detection.py 
b/lldb/test/API/tools/lldb-dap/repl-mode/TestDAP_repl_mode_detection.py
index 7c77fc8541b93..705ae13e349dc 100644
--- a/lldb/test/API/tools/lldb-dap/repl-mode/TestDAP_repl_mode_detection.py
+++ b/lldb/test/API/tools/lldb-dap/repl-mode/TestDAP_repl_mode_detection.py
@@ -18,6 +18,7 @@ def assertEvaluate(self, expression, regex):
 regex,
 )
 
+@skipIfRemote
 def test_completions(self):
 program = self.getBuildArtifact("a.out")
 self.build_and_launch(program)

``




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


[Lldb-commits] [lldb] [lldb] Fixed the TestDAP_repl_mode_detection test in case of a remote target (PR #93165)

2024-05-23 Thread Pavel Labath via lldb-commits

https://github.com/labath requested changes to this pull request.

I'm knee-deep in lldb-dap right now. Lemme just send you a PR to skip all tests 
at once.

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


[Lldb-commits] [lldb] [lldb-dap] Automatically skip lldb-dap tests for remote platforms (PR #93169)

2024-05-23 Thread Pavel Labath via lldb-commits

https://github.com/labath created 
https://github.com/llvm/llvm-project/pull/93169

The don't currently work (and they're also not particularly useful, since all 
of the remote stuff happens inside lldb).

This saves us from annotating tests one by one.

>From 0b29674bdedee83336047a3a8de8b35980853e4d Mon Sep 17 00:00:00 2001
From: Pavel Labath 
Date: Thu, 23 May 2024 10:56:48 +
Subject: [PATCH] [lldb-dap] Automatically skip lldb-dap tests for remote
 platforms

The don't currently work (and they're also not particularly useful,
since all of the remote stuff happens inside lldb).

This saves us from annotating tests one by one.
---
 lldb/packages/Python/lldbsuite/test/dotest.py | 24 ++-
 .../tools/lldb-dap/attach/TestDAP_attach.py   |  2 --
 .../lldb-dap/breakpoint/TestDAP_logpoints.py  |  4 
 .../breakpoint/TestDAP_setBreakpoints.py  |  4 
 .../TestDAP_setExceptionBreakpoints.py|  1 -
 .../TestDAP_setFunctionBreakpoints.py |  2 --
 .../lldb-dap/commands/TestDAP_commands.py |  2 --
 .../completions/TestDAP_completions.py|  1 -
 .../tools/lldb-dap/console/TestDAP_console.py |  5 
 .../console/TestDAP_redirection_to_console.py |  1 -
 .../lldb-dap/coreFile/TestDAP_coreFile.py |  2 --
 .../TestDAP_setDataBreakpoints.py |  3 ---
 .../disassemble/TestDAP_disassemble.py|  1 -
 .../lldb-dap/disconnect/TestDAP_disconnect.py |  2 --
 .../lldb-dap/evaluate/TestDAP_evaluate.py |  5 
 .../lldb-dap/exception/TestDAP_exception.py   |  1 -
 .../tools/lldb-dap/launch/TestDAP_launch.py   | 14 ---
 .../tools/lldb-dap/module/TestDAP_module.py   |  3 ---
 .../lldb-dap/optimized/TestDAP_optimized.py   |  2 --
 .../tools/lldb-dap/restart/TestDAP_restart.py |  3 ---
 .../restart/TestDAP_restart_runInTerminal.py  |  2 --
 .../runInTerminal/TestDAP_runInTerminal.py|  7 --
 .../lldb-dap/stackTrace/TestDAP_stackTrace.py |  2 --
 .../TestDAP_stackTraceMissingFunctionName.py  |  1 -
 .../startDebugging/TestDAP_startDebugging.py  |  1 -
 .../API/tools/lldb-dap/step/TestDAP_step.py   |  1 -
 .../lldb-dap/stop-hooks/TestDAP_stop_hooks.py |  1 -
 .../TestDAP_terminatedEvent.py|  1 -
 .../tools/lldb-dap/threads/TestDAP_threads.py |  2 --
 .../lldb-dap/variables/TestDAP_variables.py   |  8 ---
 30 files changed, 18 insertions(+), 90 deletions(-)

diff --git a/lldb/packages/Python/lldbsuite/test/dotest.py 
b/lldb/packages/Python/lldbsuite/test/dotest.py
index ebabf348643ef..cab14eda62c94 100644
--- a/lldb/packages/Python/lldbsuite/test/dotest.py
+++ b/lldb/packages/Python/lldbsuite/test/dotest.py
@@ -542,12 +542,6 @@ def setupSysPath():
 lldbDAPExec = os.path.join(lldbDir, "lldb-dap")
 if is_exe(lldbDAPExec):
 os.environ["LLDBDAP_EXEC"] = lldbDAPExec
-else:
-if not configuration.shouldSkipBecauseOfCategories(["lldb-dap"]):
-print(
-"The 'lldb-dap' executable cannot be located.  The lldb-dap 
tests can not be run as a result."
-)
-configuration.skip_categories.append("lldb-dap")
 
 lldbPythonDir = None  # The directory that contains 'lldb/__init__.py'
 
@@ -929,6 +923,23 @@ def checkPexpectSupport():
 configuration.skip_categories.append("pexpect")
 
 
+def checkDAPSupport():
+import lldb
+
+if "LLDBDAP_EXEC" not in os.environ:
+msg = "The 'lldb-dap' executable cannot be located and its tests will 
not be run."
+elif lldb.remote_platform:
+msg = "lldb-dap tests are not compatible with remote platforms and 
will not be run."
+else:
+msg = None
+
+if msg:
+if configuration.verbose:
+print(msg)
+configuration.skip_categories.append("lldb-dap")
+
+
+
 def run_suite():
 # On MacOS X, check to make sure that domain for com.apple.DebugSymbols 
defaults
 # does not exist before proceeding to running the test suite.
@@ -1029,6 +1040,7 @@ def run_suite():
 checkObjcSupport()
 checkForkVForkSupport()
 checkPexpectSupport()
+checkDAPSupport()
 
 skipped_categories_list = ", ".join(configuration.skip_categories)
 print(
diff --git a/lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py 
b/lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py
index cab0067382caf..b3ba69749f673 100644
--- a/lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py
+++ b/lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py
@@ -41,7 +41,6 @@ def set_and_hit_breakpoint(self, continueToExit=True):
 
 @skipIfWindows
 @skipIfNetBSD  # Hangs on NetBSD as well
-@skipIfRemote
 def test_by_pid(self):
 """
 Tests attaching to a process by process ID.
@@ -59,7 +58,6 @@ def test_by_pid(self):
 
 @skipIfWindows
 @skipIfNetBSD  # Hangs on NetBSD as well
-@skipIfRemote
 def test_by_name(self):
 """
 Tests attaching to a process by process name.
diff --git a/lldb/test/API/tools/lldb-dap/breakpoint/TestDAP_log

[Lldb-commits] [lldb] [lldb-dap] Automatically skip lldb-dap tests for remote platforms (PR #93169)

2024-05-23 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Pavel Labath (labath)


Changes

The don't currently work (and they're also not particularly useful, since all 
of the remote stuff happens inside lldb).

This saves us from annotating tests one by one.

---

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


30 Files Affected:

- (modified) lldb/packages/Python/lldbsuite/test/dotest.py (+18-6) 
- (modified) lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py (-2) 
- (modified) lldb/test/API/tools/lldb-dap/breakpoint/TestDAP_logpoints.py (-4) 
- (modified) lldb/test/API/tools/lldb-dap/breakpoint/TestDAP_setBreakpoints.py 
(-4) 
- (modified) 
lldb/test/API/tools/lldb-dap/breakpoint/TestDAP_setExceptionBreakpoints.py (-1) 
- (modified) 
lldb/test/API/tools/lldb-dap/breakpoint/TestDAP_setFunctionBreakpoints.py (-2) 
- (modified) lldb/test/API/tools/lldb-dap/commands/TestDAP_commands.py (-2) 
- (modified) lldb/test/API/tools/lldb-dap/completions/TestDAP_completions.py 
(-1) 
- (modified) lldb/test/API/tools/lldb-dap/console/TestDAP_console.py (-5) 
- (modified) 
lldb/test/API/tools/lldb-dap/console/TestDAP_redirection_to_console.py (-1) 
- (modified) lldb/test/API/tools/lldb-dap/coreFile/TestDAP_coreFile.py (-2) 
- (modified) 
lldb/test/API/tools/lldb-dap/databreakpoint/TestDAP_setDataBreakpoints.py (-3) 
- (modified) lldb/test/API/tools/lldb-dap/disassemble/TestDAP_disassemble.py 
(-1) 
- (modified) lldb/test/API/tools/lldb-dap/disconnect/TestDAP_disconnect.py (-2) 
- (modified) lldb/test/API/tools/lldb-dap/evaluate/TestDAP_evaluate.py (-5) 
- (modified) lldb/test/API/tools/lldb-dap/exception/TestDAP_exception.py (-1) 
- (modified) lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py (-14) 
- (modified) lldb/test/API/tools/lldb-dap/module/TestDAP_module.py (-3) 
- (modified) lldb/test/API/tools/lldb-dap/optimized/TestDAP_optimized.py (-2) 
- (modified) lldb/test/API/tools/lldb-dap/restart/TestDAP_restart.py (-3) 
- (modified) 
lldb/test/API/tools/lldb-dap/restart/TestDAP_restart_runInTerminal.py (-2) 
- (modified) 
lldb/test/API/tools/lldb-dap/runInTerminal/TestDAP_runInTerminal.py (-7) 
- (modified) lldb/test/API/tools/lldb-dap/stackTrace/TestDAP_stackTrace.py (-2) 
- (modified) 
lldb/test/API/tools/lldb-dap/stackTraceMissingFunctionName/TestDAP_stackTraceMissingFunctionName.py
 (-1) 
- (modified) 
lldb/test/API/tools/lldb-dap/startDebugging/TestDAP_startDebugging.py (-1) 
- (modified) lldb/test/API/tools/lldb-dap/step/TestDAP_step.py (-1) 
- (modified) lldb/test/API/tools/lldb-dap/stop-hooks/TestDAP_stop_hooks.py (-1) 
- (modified) 
lldb/test/API/tools/lldb-dap/terminated-event/TestDAP_terminatedEvent.py (-1) 
- (modified) lldb/test/API/tools/lldb-dap/threads/TestDAP_threads.py (-2) 
- (modified) lldb/test/API/tools/lldb-dap/variables/TestDAP_variables.py (-8) 


``diff
diff --git a/lldb/packages/Python/lldbsuite/test/dotest.py 
b/lldb/packages/Python/lldbsuite/test/dotest.py
index ebabf348643ef..cab14eda62c94 100644
--- a/lldb/packages/Python/lldbsuite/test/dotest.py
+++ b/lldb/packages/Python/lldbsuite/test/dotest.py
@@ -542,12 +542,6 @@ def setupSysPath():
 lldbDAPExec = os.path.join(lldbDir, "lldb-dap")
 if is_exe(lldbDAPExec):
 os.environ["LLDBDAP_EXEC"] = lldbDAPExec
-else:
-if not configuration.shouldSkipBecauseOfCategories(["lldb-dap"]):
-print(
-"The 'lldb-dap' executable cannot be located.  The lldb-dap 
tests can not be run as a result."
-)
-configuration.skip_categories.append("lldb-dap")
 
 lldbPythonDir = None  # The directory that contains 'lldb/__init__.py'
 
@@ -929,6 +923,23 @@ def checkPexpectSupport():
 configuration.skip_categories.append("pexpect")
 
 
+def checkDAPSupport():
+import lldb
+
+if "LLDBDAP_EXEC" not in os.environ:
+msg = "The 'lldb-dap' executable cannot be located and its tests will 
not be run."
+elif lldb.remote_platform:
+msg = "lldb-dap tests are not compatible with remote platforms and 
will not be run."
+else:
+msg = None
+
+if msg:
+if configuration.verbose:
+print(msg)
+configuration.skip_categories.append("lldb-dap")
+
+
+
 def run_suite():
 # On MacOS X, check to make sure that domain for com.apple.DebugSymbols 
defaults
 # does not exist before proceeding to running the test suite.
@@ -1029,6 +1040,7 @@ def run_suite():
 checkObjcSupport()
 checkForkVForkSupport()
 checkPexpectSupport()
+checkDAPSupport()
 
 skipped_categories_list = ", ".join(configuration.skip_categories)
 print(
diff --git a/lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py 
b/lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py
index cab0067382caf..b3ba69749f673 100644
--- a/lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py
+++ b/lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py
@@ -41,7 +41,6 @@ def s

[Lldb-commits] [lldb] [lldb-dap] Automatically skip lldb-dap tests for remote platforms (PR #93169)

2024-05-23 Thread Pavel Labath via lldb-commits

https://github.com/labath updated 
https://github.com/llvm/llvm-project/pull/93169

>From 7f3ed4661375ca61f4ac0fedafb57c628eca3bd0 Mon Sep 17 00:00:00 2001
From: Pavel Labath 
Date: Thu, 23 May 2024 10:56:48 +
Subject: [PATCH] [lldb-dap] Automatically skip lldb-dap tests for remote
 platforms

The don't currently work (and they're also not particularly useful,
since all of the remote stuff happens inside lldb).

This saves us from annotating tests one by one.
---
 lldb/packages/Python/lldbsuite/test/dotest.py | 25 ++-
 .../tools/lldb-dap/attach/TestDAP_attach.py   |  2 --
 .../lldb-dap/breakpoint/TestDAP_logpoints.py  |  4 ---
 .../breakpoint/TestDAP_setBreakpoints.py  |  4 ---
 .../TestDAP_setExceptionBreakpoints.py|  1 -
 .../TestDAP_setFunctionBreakpoints.py |  2 --
 .../lldb-dap/commands/TestDAP_commands.py |  2 --
 .../completions/TestDAP_completions.py|  1 -
 .../tools/lldb-dap/console/TestDAP_console.py |  5 
 .../console/TestDAP_redirection_to_console.py |  1 -
 .../lldb-dap/coreFile/TestDAP_coreFile.py |  2 --
 .../TestDAP_setDataBreakpoints.py |  3 ---
 .../disassemble/TestDAP_disassemble.py|  1 -
 .../lldb-dap/disconnect/TestDAP_disconnect.py |  2 --
 .../lldb-dap/evaluate/TestDAP_evaluate.py |  5 
 .../lldb-dap/exception/TestDAP_exception.py   |  1 -
 .../tools/lldb-dap/launch/TestDAP_launch.py   | 14 ---
 .../tools/lldb-dap/module/TestDAP_module.py   |  3 ---
 .../lldb-dap/optimized/TestDAP_optimized.py   |  2 --
 .../tools/lldb-dap/restart/TestDAP_restart.py |  3 ---
 .../restart/TestDAP_restart_runInTerminal.py  |  2 --
 .../runInTerminal/TestDAP_runInTerminal.py|  7 --
 .../lldb-dap/stackTrace/TestDAP_stackTrace.py |  2 --
 .../TestDAP_stackTraceMissingFunctionName.py  |  1 -
 .../startDebugging/TestDAP_startDebugging.py  |  1 -
 .../API/tools/lldb-dap/step/TestDAP_step.py   |  1 -
 .../lldb-dap/stop-hooks/TestDAP_stop_hooks.py |  1 -
 .../TestDAP_terminatedEvent.py|  1 -
 .../tools/lldb-dap/threads/TestDAP_threads.py |  2 --
 .../lldb-dap/variables/TestDAP_variables.py   |  8 --
 30 files changed, 19 insertions(+), 90 deletions(-)

diff --git a/lldb/packages/Python/lldbsuite/test/dotest.py 
b/lldb/packages/Python/lldbsuite/test/dotest.py
index ebabf348643ef..2e537e3fd3ce0 100644
--- a/lldb/packages/Python/lldbsuite/test/dotest.py
+++ b/lldb/packages/Python/lldbsuite/test/dotest.py
@@ -542,12 +542,6 @@ def setupSysPath():
 lldbDAPExec = os.path.join(lldbDir, "lldb-dap")
 if is_exe(lldbDAPExec):
 os.environ["LLDBDAP_EXEC"] = lldbDAPExec
-else:
-if not configuration.shouldSkipBecauseOfCategories(["lldb-dap"]):
-print(
-"The 'lldb-dap' executable cannot be located.  The lldb-dap 
tests can not be run as a result."
-)
-configuration.skip_categories.append("lldb-dap")
 
 lldbPythonDir = None  # The directory that contains 'lldb/__init__.py'
 
@@ -929,6 +923,24 @@ def checkPexpectSupport():
 configuration.skip_categories.append("pexpect")
 
 
+def checkDAPSupport():
+import lldb
+
+if "LLDBDAP_EXEC" not in os.environ:
+msg = (
+"The 'lldb-dap' executable cannot be located and its tests will 
not be run."
+)
+elif lldb.remote_platform:
+msg = "lldb-dap tests are not compatible with remote platforms and 
will not be run."
+else:
+msg = None
+
+if msg:
+if configuration.verbose:
+print(msg)
+configuration.skip_categories.append("lldb-dap")
+
+
 def run_suite():
 # On MacOS X, check to make sure that domain for com.apple.DebugSymbols 
defaults
 # does not exist before proceeding to running the test suite.
@@ -1029,6 +1041,7 @@ def run_suite():
 checkObjcSupport()
 checkForkVForkSupport()
 checkPexpectSupport()
+checkDAPSupport()
 
 skipped_categories_list = ", ".join(configuration.skip_categories)
 print(
diff --git a/lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py 
b/lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py
index cab0067382caf..b3ba69749f673 100644
--- a/lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py
+++ b/lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py
@@ -41,7 +41,6 @@ def set_and_hit_breakpoint(self, continueToExit=True):
 
 @skipIfWindows
 @skipIfNetBSD  # Hangs on NetBSD as well
-@skipIfRemote
 def test_by_pid(self):
 """
 Tests attaching to a process by process ID.
@@ -59,7 +58,6 @@ def test_by_pid(self):
 
 @skipIfWindows
 @skipIfNetBSD  # Hangs on NetBSD as well
-@skipIfRemote
 def test_by_name(self):
 """
 Tests attaching to a process by process name.
diff --git a/lldb/test/API/tools/lldb-dap/breakpoint/TestDAP_logpoints.py 
b/lldb/test/API/tools/lldb-dap/breakpoint/TestDAP_logpoints.py
index cbf190f2b2bfc..78ceb7971112e 100644
--- a/lldb/test/API/tools/lldb-dap

[Lldb-commits] [lldb] [lldb-dap] Send terminated event only once (PR #93172)

2024-05-23 Thread Pavel Labath via lldb-commits

https://github.com/labath created 
https://github.com/llvm/llvm-project/pull/93172

This is a regression from #91591. Turns out std::mutex does not prevent code 
from running twice. :facepalm:

>From 26611411308c9a916bc3ffdac0f38e95f8aa8c89 Mon Sep 17 00:00:00 2001
From: Pavel Labath 
Date: Thu, 23 May 2024 13:02:30 +0200
Subject: [PATCH] [lldb-dap] Send terminated event only once

This is a regression from #91591. Turns out std::mutex does not prevent
code from running twice :facepalm:.
---
 lldb/tools/lldb-dap/DAP.h|  2 ++
 lldb/tools/lldb-dap/lldb-dap.cpp | 13 ++---
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/lldb/tools/lldb-dap/DAP.h b/lldb/tools/lldb-dap/DAP.h
index bbd9d46ba3a04..a88ee3e1dec6b 100644
--- a/lldb/tools/lldb-dap/DAP.h
+++ b/lldb/tools/lldb-dap/DAP.h
@@ -26,6 +26,7 @@
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/JSON.h"
+#include "llvm/Support/Threading.h"
 #include "llvm/Support/raw_ostream.h"
 
 #include "lldb/API/SBAttachInfo.h"
@@ -169,6 +170,7 @@ struct DAP {
   std::optional last_launch_or_attach_request;
   lldb::tid_t focus_tid;
   bool disconnecting = false;
+  llvm::once_flag terminated_event_flag;
   bool stop_at_entry;
   bool is_attach;
   bool enable_auto_variable_summaries;
diff --git a/lldb/tools/lldb-dap/lldb-dap.cpp b/lldb/tools/lldb-dap/lldb-dap.cpp
index 170fa88f1e8b8..7746afb6cbbf3 100644
--- a/lldb/tools/lldb-dap/lldb-dap.cpp
+++ b/lldb/tools/lldb-dap/lldb-dap.cpp
@@ -227,13 +227,12 @@ void SendContinuedEvent() {
 // debugged.
 void SendTerminatedEvent() {
   // Prevent races if the process exits while we're being asked to disconnect.
-  static std::mutex mutex;
-  std::lock_guard locker(mutex);
-
-  g_dap.RunTerminateCommands();
-  // Send a "terminated" event
-  llvm::json::Object event(CreateTerminatedEventObject());
-  g_dap.SendJSON(llvm::json::Value(std::move(event)));
+  llvm::call_once(g_dap.terminated_event_flag, [&] {
+g_dap.RunTerminateCommands();
+// Send a "terminated" event
+llvm::json::Object event(CreateTerminatedEventObject());
+g_dap.SendJSON(llvm::json::Value(std::move(event)));
+  });
 }
 
 // Send a thread stopped event for all threads as long as the process

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


[Lldb-commits] [lldb] [lldb-dap] Send terminated event only once (PR #93172)

2024-05-23 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Pavel Labath (labath)


Changes

This is a regression from #91591. Turns out std::mutex does not prevent 
code from running twice. :facepalm:

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


2 Files Affected:

- (modified) lldb/tools/lldb-dap/DAP.h (+2) 
- (modified) lldb/tools/lldb-dap/lldb-dap.cpp (+6-7) 


``diff
diff --git a/lldb/tools/lldb-dap/DAP.h b/lldb/tools/lldb-dap/DAP.h
index bbd9d46ba3a04..a88ee3e1dec6b 100644
--- a/lldb/tools/lldb-dap/DAP.h
+++ b/lldb/tools/lldb-dap/DAP.h
@@ -26,6 +26,7 @@
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/JSON.h"
+#include "llvm/Support/Threading.h"
 #include "llvm/Support/raw_ostream.h"
 
 #include "lldb/API/SBAttachInfo.h"
@@ -169,6 +170,7 @@ struct DAP {
   std::optional last_launch_or_attach_request;
   lldb::tid_t focus_tid;
   bool disconnecting = false;
+  llvm::once_flag terminated_event_flag;
   bool stop_at_entry;
   bool is_attach;
   bool enable_auto_variable_summaries;
diff --git a/lldb/tools/lldb-dap/lldb-dap.cpp b/lldb/tools/lldb-dap/lldb-dap.cpp
index 170fa88f1e8b8..7746afb6cbbf3 100644
--- a/lldb/tools/lldb-dap/lldb-dap.cpp
+++ b/lldb/tools/lldb-dap/lldb-dap.cpp
@@ -227,13 +227,12 @@ void SendContinuedEvent() {
 // debugged.
 void SendTerminatedEvent() {
   // Prevent races if the process exits while we're being asked to disconnect.
-  static std::mutex mutex;
-  std::lock_guard locker(mutex);
-
-  g_dap.RunTerminateCommands();
-  // Send a "terminated" event
-  llvm::json::Object event(CreateTerminatedEventObject());
-  g_dap.SendJSON(llvm::json::Value(std::move(event)));
+  llvm::call_once(g_dap.terminated_event_flag, [&] {
+g_dap.RunTerminateCommands();
+// Send a "terminated" event
+llvm::json::Object event(CreateTerminatedEventObject());
+g_dap.SendJSON(llvm::json::Value(std::move(event)));
+  });
 }
 
 // Send a thread stopped event for all threads as long as the process

``




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


[Lldb-commits] [lldb] [lldb-dap] Automatically skip lldb-dap tests for remote platforms (PR #93169)

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

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

LGTM, thanks!

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


[Lldb-commits] [lldb] 32c3561 - [lldb][Test] Escape | chars in enum tests

2024-05-23 Thread David Spickett via lldb-commits

Author: David Spickett
Date: 2024-05-23T12:28:26Z
New Revision: 32c3561d44aa792ef08d72b5a4c342c9965bc4c2

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

LOG: [lldb][Test] Escape | chars in enum tests

| is a reserved character in regex.

Added: 


Modified: 
lldb/test/API/lang/c/enum_types/TestEnumTypes.py

Removed: 




diff  --git a/lldb/test/API/lang/c/enum_types/TestEnumTypes.py 
b/lldb/test/API/lang/c/enum_types/TestEnumTypes.py
index 33a846c50d7de..0015c8f478578 100644
--- a/lldb/test/API/lang/c/enum_types/TestEnumTypes.py
+++ b/lldb/test/API/lang/c/enum_types/TestEnumTypes.py
@@ -26,7 +26,9 @@ def test_command_line(self):
 self.expect("fr var b", DATA_TYPES_DISPLAYED_CORRECTLY, patterns=[" = 
B$"])
 self.expect("fr var c", DATA_TYPES_DISPLAYED_CORRECTLY, patterns=[" = 
C$"])
 self.expect("fr var ab", DATA_TYPES_DISPLAYED_CORRECTLY, patterns=[" = 
AB$"])
-self.expect("fr var ac", DATA_TYPES_DISPLAYED_CORRECTLY, patterns=[" = 
A | C$"])
+self.expect(
+"fr var ac", DATA_TYPES_DISPLAYED_CORRECTLY, patterns=[" = A \| 
C$"]
+)
 self.expect("fr var all", DATA_TYPES_DISPLAYED_CORRECTLY, patterns=[" 
= ALL$"])
 # Test that an enum that doesn't match the heuristic we use in
 # TypeSystemClang::DumpEnumValue, gets printed as a raw integer.
@@ -37,7 +39,7 @@ def test_command_line(self):
 self.expect(
 "expression (enum bitfield)nonsense",
 DATA_TYPES_DISPLAYED_CORRECTLY,
-patterns=[" = B | C | 0x10$"],
+patterns=[" = B \| C \| 0x10$"],
 )
 
 # Break inside the main.



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


[Lldb-commits] [clang] [lldb] [llvm] Remove some `try_compile` CMake checks for compiler flags (PR #92953)

2024-05-23 Thread Vlad Serebrennikov via lldb-commits

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


[Lldb-commits] [lldb] 4feae05 - Remove some `try_compile` CMake checks for compiler flags (#92953)

2024-05-23 Thread via lldb-commits

Author: Vlad Serebrennikov
Date: 2024-05-23T17:05:41+04:00
New Revision: 4feae05c6abda364a9295aecfa600d7d4e7dfeb6

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

LOG: Remove some `try_compile` CMake checks for compiler flags (#92953)

This patch remove 36 checks for compiler flags that are done via
invoking the compiler across LLVM, Clang, and LLDB. It's was made
possible by raising the bar for supported compilers that has been
happening over the years since the checks were added.

This is going to improve CMake configuration times. This topic was
highlighted in
https://discourse.llvm.org/t/cmake-compiler-flag-checks-are-really-slow-ideas-to-speed-them-up/78882.

Added: 


Modified: 
clang/CMakeLists.txt
clang/tools/scan-build-py/tests/functional/exec/CMakeLists.txt
lldb/cmake/modules/LLDBConfig.cmake
llvm/cmake/config-ix.cmake
llvm/cmake/modules/AddLLVM.cmake
llvm/cmake/modules/HandleLLVMOptions.cmake

Removed: 




diff  --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index c20ce47a12abb..a6bcb853a464c 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -349,10 +349,7 @@ if (LLVM_COMPILER_IS_GCC_COMPATIBLE)
 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wno-long-long")
   endif ()
 
-  check_cxx_compiler_flag("-Werror -Wnested-anon-types" 
CXX_SUPPORTS_NO_NESTED_ANON_TYPES_FLAG)
-  if( CXX_SUPPORTS_NO_NESTED_ANON_TYPES_FLAG )
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-nested-anon-types" )
-  endif()
+  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-nested-anon-types" )
 endif ()
 
 # Determine HOST_LINK_VERSION on Darwin.

diff  --git a/clang/tools/scan-build-py/tests/functional/exec/CMakeLists.txt 
b/clang/tools/scan-build-py/tests/functional/exec/CMakeLists.txt
index 95c6fdb610e0f..cb6ebda183725 100644
--- a/clang/tools/scan-build-py/tests/functional/exec/CMakeLists.txt
+++ b/clang/tools/scan-build-py/tests/functional/exec/CMakeLists.txt
@@ -2,11 +2,7 @@ project(exec C)
 
 cmake_minimum_required(VERSION 3.20.0)
 
-include(CheckCCompilerFlag)
-check_c_compiler_flag("-std=c99" C99_SUPPORTED)
-if (C99_SUPPORTED)
-set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")
-endif()
+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")
 
 include(CheckFunctionExists)
 include(CheckSymbolExists)

diff  --git a/lldb/cmake/modules/LLDBConfig.cmake 
b/lldb/cmake/modules/LLDBConfig.cmake
index 3c6223b015bb1..6458f2e174643 100644
--- a/lldb/cmake/modules/LLDBConfig.cmake
+++ b/lldb/cmake/modules/LLDBConfig.cmake
@@ -187,24 +187,18 @@ 
include_directories("${CMAKE_CURRENT_BINARY_DIR}/../clang/include")
 # form -W, and if supported, add the corresponding -Wno- option.
 
 # Disable GCC warnings
-check_cxx_compiler_flag("-Wdeprecated-declarations" 
CXX_SUPPORTS_DEPRECATED_DECLARATIONS)
-append_if(CXX_SUPPORTS_DEPRECATED_DECLARATIONS "-Wno-deprecated-declarations" 
CMAKE_CXX_FLAGS)
-
-check_cxx_compiler_flag("-Wunknown-pragmas" CXX_SUPPORTS_UNKNOWN_PRAGMAS)
-append_if(CXX_SUPPORTS_UNKNOWN_PRAGMAS "-Wno-unknown-pragmas" CMAKE_CXX_FLAGS)
-
-check_cxx_compiler_flag("-Wstrict-aliasing" CXX_SUPPORTS_STRICT_ALIASING)
-append_if(CXX_SUPPORTS_STRICT_ALIASING "-Wno-strict-aliasing" CMAKE_CXX_FLAGS)
+append("-Wno-deprecated-declarations" CMAKE_CXX_FLAGS)
+append("-Wno-unknown-pragmas" CMAKE_CXX_FLAGS)
+append("-Wno-strict-aliasing" CMAKE_CXX_FLAGS)
 
 check_cxx_compiler_flag("-Wstringop-truncation" 
CXX_SUPPORTS_STRINGOP_TRUNCATION)
 append_if(CXX_SUPPORTS_STRINGOP_TRUNCATION "-Wno-stringop-truncation" 
CMAKE_CXX_FLAGS)
 
 # Disable Clang warnings
-check_cxx_compiler_flag("-Wdeprecated-register" 
CXX_SUPPORTS_DEPRECATED_REGISTER)
-append_if(CXX_SUPPORTS_DEPRECATED_REGISTER "-Wno-deprecated-register" 
CMAKE_CXX_FLAGS)
-
-check_cxx_compiler_flag("-Wvla-extension" CXX_SUPPORTS_VLA_EXTENSION)
-append_if(CXX_SUPPORTS_VLA_EXTENSION "-Wno-vla-extension" CMAKE_CXX_FLAGS)
+if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
+  append("-Wno-deprecated-register" CMAKE_CXX_FLAGS)
+  append("-Wno-vla-extension" CMAKE_CXX_FLAGS)
+endif()
 
 # Disable MSVC warnings
 if( MSVC )

diff  --git a/llvm/cmake/config-ix.cmake b/llvm/cmake/config-ix.cmake
index bf1b110245bb2..5a884a5b0a0c0 100644
--- a/llvm/cmake/config-ix.cmake
+++ b/llvm/cmake/config-ix.cmake
@@ -415,15 +415,18 @@ if( LLVM_ENABLE_PIC )
   set(ENABLE_PIC 1)
 else()
   set(ENABLE_PIC 0)
-  check_cxx_compiler_flag("-fno-pie" SUPPORTS_NO_PIE_FLAG)
-  if(SUPPORTS_NO_PIE_FLAG)
-set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fno-pie")
-  endif()
+  set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fno-pie")
 endif()
 
-check_cxx_compiler_flag("-Wvariadic-macros" SUPPORTS_VARIADIC_MACROS_FLAG)
-check_cxx_compiler_flag("-Wgnu-zero-variadic-macro-arguments"
-SUPPORTS_GNU_ZERO_VARIADIC_MACRO_ARGUM

[Lldb-commits] [lldb] [lldb][Test] Add C++ tests for DumpValueObjectOptions and enums (PR #93158)

2024-05-23 Thread David Spickett via lldb-commits

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

>From 0c6fe37563d7e7ee338a308b32cbea01d1f3808c Mon Sep 17 00:00:00 2001
From: David Spickett 
Date: Wed, 1 May 2024 13:08:54 +
Subject: [PATCH 1/2] [lldb][Test] Add C++ tests for DumpValueObjectOptions and
 enums

DumpValueObjectOptions can only be created and modified from C++.
This means it's currently only testable from Python by calling some
command that happens to use one, and even so, you can't pick
which options get chosen.

So we have decent coverage for the major options that way, but I
want to add more niche options that will be harder to test from
Python (register field options).

So this change adds some "unit tests", though it's stretching the
definition to the point it's more "test written in C++". So
we can test future options in isolation.

Since I want to add options specific to enums, that's all it covers.
There is a test class that sets up the type system so it will be
easy to test other types in future (e.g. structs, which register
fields also use).
---
 lldb/unittests/CMakeLists.txt |   1 +
 lldb/unittests/ValueObject/CMakeLists.txt |  10 ++
 .../DumpValueObjectOptionsTests.cpp   | 136 ++
 3 files changed, 147 insertions(+)
 create mode 100644 lldb/unittests/ValueObject/CMakeLists.txt
 create mode 100644 lldb/unittests/ValueObject/DumpValueObjectOptionsTests.cpp

diff --git a/lldb/unittests/CMakeLists.txt b/lldb/unittests/CMakeLists.txt
index c084fa5cca92b..dc1d8b69f0036 100644
--- a/lldb/unittests/CMakeLists.txt
+++ b/lldb/unittests/CMakeLists.txt
@@ -73,6 +73,7 @@ add_subdirectory(tools)
 add_subdirectory(UnwindAssembly)
 add_subdirectory(Utility)
 add_subdirectory(Thread)
+add_subdirectory(ValueObject)
 
 if(LLDB_CAN_USE_DEBUGSERVER AND LLDB_TOOL_DEBUGSERVER_BUILD AND NOT 
LLDB_USE_SYSTEM_DEBUGSERVER)
   add_subdirectory(debugserver)
diff --git a/lldb/unittests/ValueObject/CMakeLists.txt 
b/lldb/unittests/ValueObject/CMakeLists.txt
new file mode 100644
index 0..fb31f76506286
--- /dev/null
+++ b/lldb/unittests/ValueObject/CMakeLists.txt
@@ -0,0 +1,10 @@
+add_lldb_unittest(LLDBValueObjectTests
+  DumpValueObjectOptionsTests.cpp
+
+  LINK_LIBS
+lldbPluginPlatformLinux
+lldbPluginScriptInterpreterNone
+
+  LINK_COMPONENTS
+Support
+  )
diff --git a/lldb/unittests/ValueObject/DumpValueObjectOptionsTests.cpp 
b/lldb/unittests/ValueObject/DumpValueObjectOptionsTests.cpp
new file mode 100644
index 0..e89ec4508f6d8
--- /dev/null
+++ b/lldb/unittests/ValueObject/DumpValueObjectOptionsTests.cpp
@@ -0,0 +1,136 @@
+//===-- DumpValueObjectOptionsTests.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 "Plugins/Platform/Linux/PlatformLinux.h"
+#include "Plugins/ScriptInterpreter/None/ScriptInterpreterNone.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
+#include "TestingSupport/SubsystemRAII.h"
+#include "TestingSupport/Symbol/ClangTestUtils.h"
+#include "lldb/Core/Debugger.h"
+#include "lldb/Core/ValueObject.h"
+#include "lldb/Core/ValueObjectConstResult.h"
+#include "lldb/DataFormatters/DumpValueObjectOptions.h"
+
+#include "gtest/gtest.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+struct MockProcess : Process {
+  MockProcess(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp)
+  : Process(target_sp, listener_sp) {}
+
+  llvm::StringRef GetPluginName() override { return "mock process"; }
+
+  bool CanDebug(lldb::TargetSP target, bool plugin_specified_by_name) override 
{
+return false;
+  };
+
+  Status DoDestroy() override { return {}; }
+
+  void RefreshStateAfterStop() override {}
+
+  bool DoUpdateThreadList(ThreadList &old_thread_list,
+  ThreadList &new_thread_list) override {
+return false;
+  };
+
+  size_t DoReadMemory(lldb::addr_t vm_addr, void *buf, size_t size,
+  Status &error) override {
+// No need to read memory in these tests.
+return size;
+  }
+};
+
+class ValueObjectMockProcessTest : public ::testing::Test {
+public:
+  void SetUp() override {
+ArchSpec arch("i386-pc-linux");
+Platform::SetHostPlatform(
+platform_linux::PlatformLinux::CreateInstance(true, &arch));
+m_debugger_sp = Debugger::CreateInstance();
+ASSERT_TRUE(m_debugger_sp);
+m_debugger_sp->GetTargetList().CreateTarget(*m_debugger_sp, "", arch,
+eLoadDependentsNo,
+m_platform_sp, m_target_sp);
+ASSERT_TRUE(m_target_sp);
+ASSERT_TRUE(m_target_sp->GetArchitecture().IsValid());
+ASSERT_TRUE(m_platform_sp);
+m_listener

[Lldb-commits] [clang] [lldb] [llvm] Remove some `try_compile` CMake checks for compiler flags (PR #92953)

2024-05-23 Thread Vlad Serebrennikov via lldb-commits

Endilll wrote:

Quite expectedly, I see buildbot failures. Working on them.
https://lab.llvm.org/buildbot/#/builders/36/builds/45836
https://lab.llvm.org/buildbot/#/builders/57/builds/35200

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


[Lldb-commits] [lldb] Summarize std::string's when created from data. (PR #89110)

2024-05-23 Thread Jacob Lalonde via lldb-commits

https://github.com/Jlalond updated 
https://github.com/llvm/llvm-project/pull/89110

>From 5955863f22d5048cad91f089e96b10ea15c05446 Mon Sep 17 00:00:00 2001
From: Jacob John Lalonde 
Date: Wed, 10 Apr 2024 14:33:40 -0700
Subject: [PATCH 1/7] Fix bug where an sbvalue containing a std::string created
 from data would not use the built in summary provider, but default to the
 valueobjectprinter

std::string children are normally formatted as their summary [my_string_prop] = 
"hello world".
Sbvalues created from data do not follow the same summary formatter path and 
instead hit the value object printer.
This change fixes that and adds tests for the future.

Added tests in TestDataFormatterStdString.py and a formatter for a custom 
struct.
---
 .../Plugins/Language/CPlusPlus/LibStdcpp.cpp  | 31 ++--
 .../string/ConvertToDataFormatter.py  | 50 +++
 .../string/TestDataFormatterStdString.py  | 28 +++
 .../libstdcpp/string/main.cpp | 13 +
 4 files changed, 118 insertions(+), 4 deletions(-)
 create mode 100644 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/ConvertToDataFormatter.py

diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp
index 86bb575af5ca3..0da01e9ca07fb 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp
@@ -254,13 +254,13 @@ bool 
lldb_private::formatters::LibStdcppStringSummaryProvider(
   } else
 addr_of_string =
 valobj.GetAddressOf(scalar_is_load_addr, &addr_type);
-  if (addr_of_string != LLDB_INVALID_ADDRESS) {
+  if (addr_of_string != LLDB_INVALID_ADDRESS ||
+addr_type == eAddressTypeHost) {
 switch (addr_type) {
 case eAddressTypeLoad: {
   ProcessSP process_sp(valobj.GetProcessSP());
   if (!process_sp)
 return false;
-
   StringPrinter::ReadStringAndDumpToStreamOptions options(valobj);
   Status error;
   lldb::addr_t addr_of_data =
@@ -287,8 +287,31 @@ bool 
lldb_private::formatters::LibStdcppStringSummaryProvider(
   } else
 return true;
 } break;
-case eAddressTypeHost:
-  break;
+case eAddressTypeHost: {
+  // We have the host address of our std::string
+  // But we need to read the pointee data from the debugged process.
+  ProcessSP process_sp(valobj.GetProcessSP());
+  DataExtractor data;
+  Status error;
+  valobj.GetData(data, error);
+  if (error.Fail())
+return false;
+  // We want to read the address from std::string, which is the first 8 
bytes.
+  lldb::offset_t offset = 0;
+  lldb::addr_t addr = data.GetAddress(&offset);
+  if (!addr)
+  {
+stream.Printf("nullptr");
+return true;
+  }
+
+  std::string contents;
+  process_sp->ReadCStringFromMemory(addr, contents, error);
+  if (error.Fail())
+return false;
+  stream.Printf("%s", contents.c_str());
+  return true;
+} break;
 case eAddressTypeInvalid:
 case eAddressTypeFile:
   break;
diff --git 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/ConvertToDataFormatter.py
 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/ConvertToDataFormatter.py
new file mode 100644
index 0..57e42c920f829
--- /dev/null
+++ 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/ConvertToDataFormatter.py
@@ -0,0 +1,50 @@
+# coding=utf8
+"""
+Helper formmater to verify Std::String by created via SBData
+"""
+
+import lldb
+
+class SyntheticFormatter:
+def __init__(self, valobj, dict):
+self.valobj = valobj
+
+def num_children(self):
+return 6
+
+def has_children(self):
+return True
+
+def get_child_at_index(self, index):
+name = None
+match index:
+case 0:
+name = "short_string"
+case 1:
+name = "long_string"
+case 2:
+name = "short_string_ptr"
+case 3:
+name = "long_string_ptr"
+case 4:
+name = "short_string_ref"
+case 5:
+name = "long_string_ref"
+case _:
+return None
+
+child = self.valobj.GetChildMemberWithName(name)
+valType = child.GetType()
+return self.valobj.CreateValueFromData(name,
+child.GetData(),
+valType)
+
+
+def __lldb_init_module(debugger, dict):
+typeName = "string_container"
+debugger.HandleCommand(
+'type synthetic add -x "'
++ typeName
++ '" --python-class '
++ f"{__name__}.SyntheticFormatter"
+)
diff --git 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/TestDataFormatterStdString.py
 
b/lldb/test/A

[Lldb-commits] [lldb] Summarize std::string's when created from data. (PR #89110)

2024-05-23 Thread Jacob Lalonde via lldb-commits

Jlalond wrote:

@jimingham it turned out when created by data, the value object's address 
points to it's buffer which itself contains the char* of the string.

I'm not sure how we can support the small string optimization if this is the 
case, my testing was against a small string "test2", and it was always saved as 
a char* for the value object. I think for this PR we can probably ignore it and 
open an issue to support the small string optimization.

Please review when you have time

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


[Lldb-commits] [lldb] Improve performance of .debug_names lookups when DW_IDX_parent attributes are used (PR #91808)

2024-05-23 Thread Felipe de Azevedo Piovezan via lldb-commits

felipepiovezan wrote:

>Since clang no longer emits entry for:

But  what does the `debug_info` section look like? In particular, what is the 
_parent_ of the class DIE?
If the parent of `InnerState` is not some kind of entry for `State` (either a 
declaration or a definition), IMO Clang is generating incorrect information for 
the type.  What caused Clang to stop emitting these entries?

> This gets a bit fuzzy, I think. The spec appears to allow this behavior (_In 
> such a case, a parent attribute may point to a nameless index entry (...), or 
> it may point to the **nearest ancestor that does have an index entry**._), 
> but I don't think this is particularly useful. I think it would be better to 
> have the parent point to the definition in the type unit (streching the 
> meaning of "parent" in the spec), or use one of those nameless entries to 
> point to the physical (declaration) parent)
> 
> (IANAL YMMV)


We can discuss this, but I think the point is going to be moot given what I 
mentioned about. The debug_names section is reflecting the state of 
`debug_info`. If the `debug_info` is saying that `State` is not a parent of 
`InnerState`, the `debug_names` section is correct in the literal sense, but 
will produce incorrect results for the query: "find A::B::State::InnerState".

In the case where the declaration is there, debug_names will have correct info 
for `InnerState`: it will just say the parent is not indexed and things work 
out just fine.

> have the parent point to the definition in the type unit (streching the 
> meaning of "parent" in the spec),

Why do you say this is stretching the meaning of parent? This looks fine to me, 
but it seems impossible to emit such debug_names section if the compiler  is no 
longer emitting the declaration with the type signature. (we'd need to check if 
the emitter code has some way of finding the definition, but also how could it 
possibly know there is a type between any two Parent-Child nodes? It really 
feels like we can't just elide the definition).

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


[Lldb-commits] [lldb] Improve performance of .debug_names lookups when DW_IDX_parent attributes are used (PR #91808)

2024-05-23 Thread Alexander Yermolovich via lldb-commits

ayermolo wrote:

> > Using example above, with a fix by @dwblaikie
> > I see:
> > ```
> >  Hash: 0xE0CDC6A2
> >   String: 0x0018 "InnerState"
> >   Entry @ 0x10b {
> > Abbrev: 0x3
> > Tag: DW_TAG_class_type
> > DW_IDX_type_unit: 0x01
> > DW_IDX_die_offset: 0x0030
> >   }
> > ```
> > 
> > 
> > 
> >   
> > 
> > 
> >   
> > 
> > 
> > 
> >   
> > Since clang no longer emits entry for:
> > ```
> > 0x0057:   DW_TAG_structure_type
> > DW_AT_declaration (true)
> > DW_AT_signature (0xe742f49eeadc2244)
> > ```
> > 
> > 
> > 
> >   
> > 
> > 
> >   
> > 
> > 
> > 
> >   
> > Is this the right behavior?
> 
> I would say "yes", because the spec is pretty explicit about excluding 
> DW_AT_declaration entries.
> 
> I can see a case being made that DW_AT_signature should be treated the same 
> way as DW_AT_specification and DW_AT_abstract_origin (i.e., transparently), 
> but that's definitely not what the spec says right now.
> 
> > Current BOLT behavior is to skip that DIE and reference it's parent:
> > ```
> > Hash: 0xE0CDC6A2
> >   String: 0x0018 "InnerState"
> >   Entry @ 0x109 {
> > Abbrev: 0x3
> > Tag: DW_TAG_class_type
> > DW_IDX_type_unit: 0x01
> > DW_IDX_die_offset: 0x0030
> > DW_IDX_parent: Entry @ 0x147
> >   }
> > Entry @ 0x147 {
> > Abbrev: 0x7
> > Tag: DW_TAG_namespace
> > DW_IDX_type_unit: 0x01
> > DW_IDX_die_offset: 0x0025
> > DW_IDX_parent: Entry @ 0x126
> >   }
> > ```
> > 
> > 
> > 
> >   
> > 
> > 
> >   
> > 
> > 
> > 
> >   
> > ```
> > 0x0055: DW_TAG_namespace
> >   DW_AT_name  ("B")
> > 
> > 0x0057:   DW_TAG_structure_type
> > DW_AT_declaration (true)
> > DW_AT_signature (0xe742f49eeadc2244)
> > 
> > 0x0060: DW_TAG_class_type
> >   DW_AT_calling_convention  (DW_CC_pass_by_value)
> >   DW_AT_name  ("InnerState")
> >   DW_AT_byte_size (0x01)
> >   DW_AT_decl_file ("/main.cpp")
> >   DW_AT_decl_line (1)
> > ```
> > 
> > 
> > 
> >   
> > 
> > 
> >   
> > 
> > 
> > 
> >   
> > It doesn't emit entry for this because there is no name attribute
> > ```
> > 0x0057:   DW_TAG_structure_type
> > DW_AT_declaration (true)
> > DW_AT_signature (0xe742f49eeadc2244)
> > ```
> 
> This gets a bit fuzzy, I think. The spec appears to allow this behavior (_In 
> such a case, a parent attribute may point to a nameless index entry (...), or 
> it may point to the **nearest ancestor that does have an index entry**._), 
> but I don't think this is particularly useful. I think it would be better to 
> have the parent point to the definition in the type unit (streching the 
> meaning of "parent" in the spec), or use one of those nameless entries to 
> point to the physical (declaration) parent)
> 
> (IANAL YMMV)

For "parent point to the definition in the type unit". That definition will be 
in a different type unit, correct? Is that allowed? For one entry 
DW_IDX_type_unit will have one index, and it's parent will have another index. 
There is also DWP scenario.  Where we don't know which TU will be picked. So 
chain might be pointing to "discarded" TU from a different CU.

So in this particular case what would the nameless entry look like?


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


[Lldb-commits] [lldb] Improve performance of .debug_names lookups when DW_IDX_parent attributes are used (PR #91808)

2024-05-23 Thread Alexander Yermolovich via lldb-commits

ayermolo wrote:

> > Since clang no longer emits entry for:
> 
> But what does the `debug_info` section look like? In particular, what is the 
> _parent_ of the class DIE? If the parent of `InnerState` is not some kind of 
> entry for `State` (either a declaration or a definition), IMO Clang is 
> generating incorrect information for the type. What caused Clang to stop 
> emitting these entries?
> 
> > This gets a bit fuzzy, I think. The spec appears to allow this behavior 
> > (_In such a case, a parent attribute may point to a nameless index entry 
> > (...), or it may point to the **nearest ancestor that does have an index 
> > entry**._), but I don't think this is particularly useful. I think it would 
> > be better to have the parent point to the definition in the type unit 
> > (streching the meaning of "parent" in the spec), or use one of those 
> > nameless entries to point to the physical (declaration) parent)
> > (IANAL YMMV)
> 
> We can discuss this, but I think the point is going to be moot given what I 
> mentioned above. The debug_names section is reflecting the state of 
> `debug_info`. If the `debug_info` is saying that `State` is not a parent of 
> `InnerState`, the `debug_names` section is correct in the literal sense, but 
> will produce incorrect results for the query: "find A::B::State::InnerState".
> 
> In the case where the declaration is there, debug_names will have correct 
> info for `InnerState`: it will just say the parent is not indexed and things 
> work out just fine.
> 
> > have the parent point to the definition in the type unit (streching the 
> > meaning of "parent" in the spec),
> 
> Why do you say this is stretching the meaning of parent? This looks fine to 
> me, but it seems impossible to emit such debug_names section if the compiler 
> is no longer emitting the declaration with the type signature. (we'd need to 
> check if the emitter code has some way of finding the definition, but also 
> how could it possibly know there is a type between any two Parent-Child 
> nodes? It really feels like we can't just elide the definition).

For clang I used example here with TOT clang. Which included this change: 
https://github.com/llvm/llvm-project/commit/bd5c6367bd79c01665ff8ab9848afbf5b1249ce6

```
namespace A { namespace B { struct State { class InnerState{}; }; } }
A::B::State::InnerState get_state() { return A::B::State::InnerState(); }

int main() {
  return 0;
}
```

clang++ main.cpp -fuse-ld=lld -g2 -O0 -fdebug-types-section -gpubnames -o 
main.exe


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


[Lldb-commits] [lldb] Improve performance of .debug_names lookups when DW_IDX_parent attributes are used (PR #91808)

2024-05-23 Thread Felipe de Azevedo Piovezan via lldb-commits

felipepiovezan wrote:


Ohhh ok,  I just inspected the debug_names/debug_info sections; there is no 
parent at all for the InnerState debug_names entry. In this case, the 
debug_names section is valid. Unfortunate, as this may cause entire CUs/TUs to 
be parsed (because of all the calls to ProcessEntry, which is what  the 
idx_parent project was addressing), but still valid.

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


[Lldb-commits] [lldb] Improve performance of .debug_names lookups when DW_IDX_parent attributes are used (PR #91808)

2024-05-23 Thread Felipe de Azevedo Piovezan via lldb-commits

felipepiovezan wrote:

> Current BOLT behavior is to skip that DIE and reference it's parent:

This, on the other hand, is concerning. It needs to reflect the debug_info 
section, otherwise we can't use debug_names to answer queries like "find 
A::B::C::D".
It would be better if the BOLT compiler produced either a "parent_not_indexed" 
entry, or  no parent at all, or implement the nameless parent. All of these 
allow LLDB to correctly answer the query above, but what BOLT is currently 
doing does not

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


[Lldb-commits] [lldb] [llvm] Add a createError variant without error code (NFC) (PR #93209)

2024-05-23 Thread Adrian Prantl via lldb-commits

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

For the significant amount of call sites that want to create an 
incontrovertible error, such a wrapper function creates a significant 
readability improvement and lowers the cost of entry to add error handling in 
more places.

>From c5797986a4739f58c3f506860de313fb8a7a7413 Mon Sep 17 00:00:00 2001
From: Adrian Prantl 
Date: Thu, 23 May 2024 08:36:48 -0700
Subject: [PATCH] Add a createError variant without error code (NFC)

For the significant amount of call sites that want to create an
incontrovertible error, such a wrapper function creates a significant
readability improvement and lowers the cost of entry to add error
handling in more places.
---
 lldb/source/Host/common/Socket.cpp|  4 +--
 lldb/source/Interpreter/Options.cpp   | 29 ++-
 .../Plugins/ABI/PowerPC/ABISysV_ppc64.cpp |  8 ++---
 .../Python/ScriptInterpreterPython.cpp|  9 ++---
 .../SymbolFile/Breakpad/SymbolFileBreakpad.h  |  5 ++-
 .../TypeSystem/Clang/TypeSystemClang.cpp  | 15 +++-
 lldb/source/Symbol/CompilerType.cpp   |  3 +-
 lldb/source/Symbol/Symbol.cpp | 18 --
 lldb/source/Symbol/SymbolFileOnDemand.cpp |  5 ++-
 lldb/source/Symbol/TypeSystem.cpp | 32 +++--
 lldb/source/Target/Target.cpp | 36 ---
 lldb/source/Utility/Status.cpp|  3 +-
 llvm/include/llvm/Support/Error.h |  4 +++
 13 files changed, 68 insertions(+), 103 deletions(-)

diff --git a/lldb/source/Host/common/Socket.cpp 
b/lldb/source/Host/common/Socket.cpp
index bd0c127a08956..e060c174326b8 100644
--- a/lldb/source/Host/common/Socket.cpp
+++ b/lldb/source/Host/common/Socket.cpp
@@ -87,8 +87,8 @@ llvm::Error Socket::Initialize() {
   if (err == 0) {
 if (wsaData.wVersion < wVersion) {
   WSACleanup();
-  return llvm::make_error(
-  "WSASock version is not expected.", llvm::inconvertibleErrorCode());
+  return llvm::createStringError("WSASock version is not expected.",
+ llvm::inconvertibleErrorCode());
 }
   } else {
 return llvm::errorCodeToError(llvm::mapWindowsError(::WSAGetLastError()));
diff --git a/lldb/source/Interpreter/Options.cpp 
b/lldb/source/Interpreter/Options.cpp
index 51b7e6b26b6ef..4e7d074ace1b8 100644
--- a/lldb/source/Interpreter/Options.cpp
+++ b/lldb/source/Interpreter/Options.cpp
@@ -931,8 +931,7 @@ llvm::Expected Options::ParseAlias(const Args &args,
   Option *long_options = GetLongOptions();
 
   if (long_options == nullptr) {
-return llvm::make_error("Invalid long options",
-   llvm::inconvertibleErrorCode());
+return llvm::createStringError("Invalid long options");
   }
 
   std::string short_options = BuildShortOptions(long_options);
@@ -957,8 +956,7 @@ llvm::Expected Options::ParseAlias(const Args &args,
   break;
 
 if (val == '?') {
-  return llvm::make_error(
-  "Unknown or ambiguous option", llvm::inconvertibleErrorCode());
+  return llvm::createStringError("Unknown or ambiguous option");
 }
 
 if (val == 0)
@@ -980,9 +978,8 @@ llvm::Expected Options::ParseAlias(const Args &args,
 
 // See if the option takes an argument, and see if one was supplied.
 if (long_options_index == -1) {
-  return llvm::make_error(
-  llvm::formatv("Invalid option with value '{0}'.", char(val)).str(),
-  llvm::inconvertibleErrorCode());
+  return llvm::createStringError(
+  llvm::formatv("Invalid option with value '{0}'.", char(val)).str());
 }
 
 StreamString option_str;
@@ -995,11 +992,10 @@ llvm::Expected Options::ParseAlias(const Args &args,
 switch (has_arg) {
 case OptionParser::eRequiredArgument:
   if (OptionParser::GetOptionArgument() == nullptr) {
-return llvm::make_error(
+return llvm::createStringError(
 llvm::formatv("Option '{0}' is missing argument specifier.",
   option_str.GetString())
-.str(),
-llvm::inconvertibleErrorCode());
+.str());
   }
   [[fallthrough]];
 case OptionParser::eOptionalArgument:
@@ -1008,12 +1004,11 @@ llvm::Expected Options::ParseAlias(const Args 
&args,
 case OptionParser::eNoArgument:
   break;
 default:
-  return llvm::make_error(
+  return llvm::createStringError(
   llvm::formatv("error with options table; invalid value in has_arg "
 "field for option '{0}'.",
 char(val))
-  .str(),
-  llvm::inconvertibleErrorCode());
+  .str());
 }
 // Find option in the argument list; also see if it was supposed to take an
 // argument and if one was supplied.  Remove option (and argument, if
@@ -1261,8 +1256,7 @@ llvm::Expected Options::Parse(c

[Lldb-commits] [lldb] [llvm] Add a createError variant without error code (NFC) (PR #93209)

2024-05-23 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-llvm-support

Author: Adrian Prantl (adrian-prantl)


Changes

For the significant amount of call sites that want to create an 
incontrovertible error, such a wrapper function creates a significant 
readability improvement and lowers the cost of entry to add error handling in 
more places.

---

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


13 Files Affected:

- (modified) lldb/source/Host/common/Socket.cpp (+2-2) 
- (modified) lldb/source/Interpreter/Options.cpp (+11-18) 
- (modified) lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc64.cpp (+3-5) 
- (modified) 
lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp (+3-6) 
- (modified) lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h 
(+2-3) 
- (modified) lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp (+5-10) 
- (modified) lldb/source/Symbol/CompilerType.cpp (+1-2) 
- (modified) lldb/source/Symbol/Symbol.cpp (+7-11) 
- (modified) lldb/source/Symbol/SymbolFileOnDemand.cpp (+2-3) 
- (modified) lldb/source/Symbol/TypeSystem.cpp (+13-19) 
- (modified) lldb/source/Target/Target.cpp (+14-22) 
- (modified) lldb/source/Utility/Status.cpp (+1-2) 
- (modified) llvm/include/llvm/Support/Error.h (+4) 


``diff
diff --git a/lldb/source/Host/common/Socket.cpp 
b/lldb/source/Host/common/Socket.cpp
index bd0c127a08956..e060c174326b8 100644
--- a/lldb/source/Host/common/Socket.cpp
+++ b/lldb/source/Host/common/Socket.cpp
@@ -87,8 +87,8 @@ llvm::Error Socket::Initialize() {
   if (err == 0) {
 if (wsaData.wVersion < wVersion) {
   WSACleanup();
-  return llvm::make_error(
-  "WSASock version is not expected.", llvm::inconvertibleErrorCode());
+  return llvm::createStringError("WSASock version is not expected.",
+ llvm::inconvertibleErrorCode());
 }
   } else {
 return llvm::errorCodeToError(llvm::mapWindowsError(::WSAGetLastError()));
diff --git a/lldb/source/Interpreter/Options.cpp 
b/lldb/source/Interpreter/Options.cpp
index 51b7e6b26b6ef..4e7d074ace1b8 100644
--- a/lldb/source/Interpreter/Options.cpp
+++ b/lldb/source/Interpreter/Options.cpp
@@ -931,8 +931,7 @@ llvm::Expected Options::ParseAlias(const Args &args,
   Option *long_options = GetLongOptions();
 
   if (long_options == nullptr) {
-return llvm::make_error("Invalid long options",
-   llvm::inconvertibleErrorCode());
+return llvm::createStringError("Invalid long options");
   }
 
   std::string short_options = BuildShortOptions(long_options);
@@ -957,8 +956,7 @@ llvm::Expected Options::ParseAlias(const Args &args,
   break;
 
 if (val == '?') {
-  return llvm::make_error(
-  "Unknown or ambiguous option", llvm::inconvertibleErrorCode());
+  return llvm::createStringError("Unknown or ambiguous option");
 }
 
 if (val == 0)
@@ -980,9 +978,8 @@ llvm::Expected Options::ParseAlias(const Args &args,
 
 // See if the option takes an argument, and see if one was supplied.
 if (long_options_index == -1) {
-  return llvm::make_error(
-  llvm::formatv("Invalid option with value '{0}'.", char(val)).str(),
-  llvm::inconvertibleErrorCode());
+  return llvm::createStringError(
+  llvm::formatv("Invalid option with value '{0}'.", char(val)).str());
 }
 
 StreamString option_str;
@@ -995,11 +992,10 @@ llvm::Expected Options::ParseAlias(const Args &args,
 switch (has_arg) {
 case OptionParser::eRequiredArgument:
   if (OptionParser::GetOptionArgument() == nullptr) {
-return llvm::make_error(
+return llvm::createStringError(
 llvm::formatv("Option '{0}' is missing argument specifier.",
   option_str.GetString())
-.str(),
-llvm::inconvertibleErrorCode());
+.str());
   }
   [[fallthrough]];
 case OptionParser::eOptionalArgument:
@@ -1008,12 +1004,11 @@ llvm::Expected Options::ParseAlias(const Args 
&args,
 case OptionParser::eNoArgument:
   break;
 default:
-  return llvm::make_error(
+  return llvm::createStringError(
   llvm::formatv("error with options table; invalid value in has_arg "
 "field for option '{0}'.",
 char(val))
-  .str(),
-  llvm::inconvertibleErrorCode());
+  .str());
 }
 // Find option in the argument list; also see if it was supposed to take an
 // argument and if one was supplied.  Remove option (and argument, if
@@ -1261,8 +1256,7 @@ llvm::Expected Options::Parse(const Args &args,
   Status error;
   Option *long_options = GetLongOptions();
   if (long_options == nullptr) {
-return llvm::make_error("Invalid long options.",
-   llvm::inconvertibleErrorCode());
+return llvm:

[Lldb-commits] [lldb] [llvm] Add a createError variant without error code (NFC) (PR #93209)

2024-05-23 Thread Adrian Prantl via lldb-commits

adrian-prantl wrote:

The obvious downside is that it makes it easier to not even try to find a 
matching error code, but it looks like most incontrovertible errors are caught 
before the get reported as an exit status.

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


[Lldb-commits] [lldb] [lldb-dap] Automatically skip lldb-dap tests for remote platforms (PR #93169)

2024-05-23 Thread Jonas Devlieghere via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb-dap] Send terminated event only once (PR #93172)

2024-05-23 Thread via lldb-commits

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

Thanks for fixing it :)
Just tested this patch from my side, worked well!

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


[Lldb-commits] [lldb] [lldb-dap] Send terminated event only once (PR #93172)

2024-05-23 Thread via lldb-commits

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


[Lldb-commits] [clang] [lldb] [llvm] Remove some `try_compile` CMake checks for compiler flags (PR #92953)

2024-05-23 Thread Nikita Popov via lldb-commits

nikic wrote:

FYI this causes a minor compile-time improvement in stage1 builds using gcc: 
https://llvm-compile-time-tracker.com/compare.php?from=32c3561d44aa792ef08d72b5a4c342c9965bc4c2&to=4feae05c6abda364a9295aecfa600d7d4e7dfeb6&stat=instructions:u
 While that's nice, it does suggest that the flags are not the same as before.

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


[Lldb-commits] [clang] [lldb] [llvm] Remove some `try_compile` CMake checks for compiler flags (PR #92953)

2024-05-23 Thread Felipe de Azevedo Piovezan via lldb-commits

felipepiovezan wrote:

These types of changes touching a lot of projects at once can benefit from 
multiple PRs, one per project, as it makes partial reverts a lot easier and 
doesn't cause as much churn downstream (plus we can get more targeted comments 
from individual project owners)

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


[Lldb-commits] [lldb] Improve performance of .debug_names lookups when DW_IDX_parent attributes are used (PR #91808)

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

dwblaikie wrote:

Sorry I can't quite figure out who/where to reply to, so perhaps by summarizing 
the situation (though it's going to be verbose, and I'm going to add some other 
examples/complications) I can get a grip on all this/clarify where we're at.

So, history. 

* minimum spec-compliant .debug_names (DWARFv5, 6.1.1 Lookup by Name) 
implementation contains a name entry for each unqualified name which contains 
index entries for each definition DIE with that unqualified name (I'm glossing 
over all the pedantic language in the spec - can read that if anyone's 
interested)

* the original [Apple 
names](https://llvm.org/docs/SourceLevelDebugging.html#name-accelerator-tables) 
also included a hash of the qualified name to check that the exact name is 
found, but that relies on textually identical names, which isn't 
portable/wouldn't work for humans writing names in a variety of ways - so the 
standardized version allowed producers to include a DW_IDX_parent link up to 
the (hmm, I can't find any mention of the "hash of the fully qualified name" 
part in the llvm.org docs, so perhaps they're out of date -  yeah, it's in the 
code, DW_ATOM_qual_name_hash but now I just have further question (it seems 
this data's only generated for dsyms, not tables in .o files))

* having only unqualified names in the index with no further context requires a 
fair bit of DWARF deserialization to do fully or partially qualified name 
lookup - got to walk the whole DIE tree of the CU to find the unqualified DIEs 
parents to check them against the qualified name

* so @felipepiovezan and others worked on adding DW_IDX_parent support to 
LLVM's .debug_names emission code, so that qualified names could be compared 
using the parent chain - deserializing just the specifically targeted 
DIEs/basically allowing quick access to the parent chain of the unqualified DIE

* One complication of DW_IDX_parent implementation is how to detect the 
difference between an index name entry that describes an entity in the global 
namespace (ie: truly has no qualifying name needed to reach/identify it) and 
another entry that a producer didn't choose to emit DW_IDX_parent for.

* The way this was addressed was to use `DW_IDX_parent` with 
`DW_FORM_flag_present` to indicate that this DIE's qualified and unqualified 
name are identical, it has no qualifying parent

* The DWARF spec does allow unnamed entries in the index - not in the name 
index (because that's the list of non-empty names), but in the index entry list

* The DWARF spec does say that if a named entity's parent isn't indexed, 
perhaps because it's unnamed (unnamed entities don't go in the /name/ index) 
then a producer might reference an unnamed index entry, or might skip the 
entity and reference its named parent.

* The /intent/ of this wording I think is clear, to allow consumers to still do 
qualified name lookup directly from an index-with-parents even if there are 
some unnamed scopes present - but the language is too loose because there can 
be named entities that aren't present in the index (because they aren't 
definitions) that, if skipped, would make the index basically unusable - the 
consumer wouldn't know they were skipped and would treat those name components 
as not-present, so "foo::bar::baz" would appear to a consumer reading the index 
as "foo::baz" and a query for "foo::bar::baz" would be rejected.

I think the cases where these missing parents come up are most likely not 
present for Apple, the two places I can think of are the one we're currently 
discussing, type units - and `-fno-standalone-debug` situations.

The latter might be more informative as an example to consider?

```
struct t1 {
  virtual void f1();
  struct t2 { };
};
t1::t2 v1;
```
```
$ llvm-dwarfdump-tot missing_parent.o | grep 
"DW_TAG\|DW_AT_name\|DW_AT_declaration" | sed -e "s/^.{12}//"
0x000c: DW_TAG_compile_unit
  DW_AT_name("missing_parent.cpp")
0x001e:   DW_TAG_variable
DW_AT_name  ("v1")
0x0029:   DW_TAG_structure_type
DW_AT_name  ("t1")
DW_AT_declaration   (true)
0x002b: DW_TAG_structure_type
  DW_AT_name("t2")
```
```
$ llvm-dwarfdump-tot missing_parent.o -debug-names
"v1"
Tag: DW_TAG_variable
DW_IDX_die_offset: 0x001e
DW_IDX_parent: 
"t2"
Tag: DW_TAG_structure_type
DW_IDX_die_offset: 0x002b

```
In this case I think we currently can't do qualified lookup of `t1::t2` using 
just the index. We'd have to go and at least quick-parse the whole CU to find 
`t2`'s parent(s) and check them.

In the case where `t1` is defined in the same translation unit/CU (and we put 
`DW_IDX_parent` on the `t2` entry) we still /probably/ have to parse the `t1` 
DIE, because the entry offset we'd emit wouldn't tell us the name of `t1`. 
Unless we reverse the name entry->index entry mapping to find the name? 
(@felipepiovezan can you co

[Lldb-commits] [lldb] [llvm] Add a createError variant without error code (NFC) (PR #93209)

2024-05-23 Thread Jonas Devlieghere via lldb-commits

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


[Lldb-commits] [lldb] [llvm] Add a createError variant without error code (NFC) (PR #93209)

2024-05-23 Thread Jonas Devlieghere via lldb-commits

https://github.com/JDevlieghere commented:

I'm in favor of this. I rarely have a meaningful error code and it makes the 
code needlessly verbose. 

I was going to ask if we wanted to make an overload of the existing 
`createStringError` but without the error code. But then I noticed that it uses 
the printf-style formatters (and not the llvm one). I think @bulbazord tried to 
add a `formatv` overload but that slowed down compilation of LLVM itself. Long 
story short, I think having this function take an `llvm::Twine` is fine. 

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


[Lldb-commits] [lldb] [llvm] Add a createError variant without error code (NFC) (PR #93209)

2024-05-23 Thread Jonas Devlieghere via lldb-commits


@@ -87,8 +87,8 @@ llvm::Error Socket::Initialize() {
   if (err == 0) {
 if (wsaData.wVersion < wVersion) {
   WSACleanup();
-  return llvm::make_error(
-  "WSASock version is not expected.", llvm::inconvertibleErrorCode());
+  return llvm::createStringError("WSASock version is not expected.",
+ llvm::inconvertibleErrorCode());

JDevlieghere wrote:

This doesn't need the `inconvertibleErrorCode` anymore, right?

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


[Lldb-commits] [lldb] [llvm] Add a createError variant without error code (NFC) (PR #93209)

2024-05-23 Thread Adrian Prantl via lldb-commits


@@ -87,8 +87,8 @@ llvm::Error Socket::Initialize() {
   if (err == 0) {
 if (wsaData.wVersion < wVersion) {
   WSACleanup();
-  return llvm::make_error(
-  "WSASock version is not expected.", llvm::inconvertibleErrorCode());
+  return llvm::createStringError("WSASock version is not expected.",
+ llvm::inconvertibleErrorCode());

adrian-prantl wrote:

Yes, that's an oversight. I also didn't try to exhaustively convert everything, 
just give a sample of the kinds of expected improvements.

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


[Lldb-commits] [clang] [lldb] [llvm] Remove some `try_compile` CMake checks for compiler flags (PR #92953)

2024-05-23 Thread Vlad Serebrennikov via lldb-commits

Endilll wrote:

> FYI this causes a minor compile-time improvement in stage1 builds using gcc: 
> https://llvm-compile-time-tracker.com/compare.php?from=32c3561d44aa792ef08d72b5a4c342c9965bc4c2&to=4feae05c6abda364a9295aecfa600d7d4e7dfeb6&stat=instructions:u
>  While that's nice, it does suggest that the flags are not the same as before.

@nikic Can you elaborate on those numbers? Do you say that Clang (compiled with 
GCC) which compiles those tests works faster now?

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


[Lldb-commits] [clang] [compiler-rt] [lldb] [llvm] [Support] Remove terminfo dependency (PR #92865)

2024-05-23 Thread Petr Hosek via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb][Test] Add C++ tests for DumpValueObjectOptions and enums (PR #93158)

2024-05-23 Thread via lldb-commits

jimingham wrote:

LGTM.  

We do offer SBValue::GetDescription, which uses a default 
DumpValueObjectOptions.  So it would be entirely reasonable to make an 
SBValueObjectDescriptionOptions (or maybe a shorter name?) and add 
SBValue::GetDescription(SBValueObjectDescriptionOptions) API.

But people can also cons up an equivalent Dump on their own using the other 
SBValue API's, so leaving the GetDescription as it is and doing the testing on 
the side like this is also fine.

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


[Lldb-commits] [lldb] Improve performance of .debug_names lookups when DW_IDX_parent attributes are used (PR #91808)

2024-05-23 Thread Alexander Yermolovich via lldb-commits

ayermolo wrote:

OK, thanks for detailed explanation. 
Will re-read few more time to fully process it. :)
I'll change BOLT behavior to reflect the new clang behavior. If there is a 
forward delcaration (skeleton die), the parent chain won't skip it, but instead 
won't emit parent for it's children.

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


[Lldb-commits] [lldb] Summarize std::string's when created from data. (PR #89110)

2024-05-23 Thread via lldb-commits


@@ -16,9 +16,12 @@
 #include "lldb/DataFormatters/VectorIterator.h"
 #include "lldb/Target/Target.h"
 #include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/DataExtractor.h"
 #include "lldb/Utility/Endian.h"
 #include "lldb/Utility/Status.h"
 #include "lldb/Utility/Stream.h"
+#include "lldb/lldb-types.h"

jimingham wrote:

We usually put the top level lldb includes first in the lldb includes list.

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


[Lldb-commits] [lldb] Summarize std::string's when created from data. (PR #89110)

2024-05-23 Thread via lldb-commits


@@ -2763,10 +2763,10 @@ ValueObjectSP ValueObject::Cast(const CompilerType 
&compiler_type) {
   ExecutionContextScope *exe_scope
   = ExecutionContext(GetExecutionContextRef())
   .GetBestExecutionContextScope();
-  if (compiler_type.GetByteSize(exe_scope)
-  <= GetCompilerType().GetByteSize(exe_scope) 
-  || m_value.GetValueType() == Value::ValueType::LoadAddress)
-return DoCast(compiler_type);
+  if (compiler_type.GetByteSize(exe_scope) <=

jimingham wrote:

This is just a reformatting, right?  We try to only clang-format the code the 
PR actually changes, (using git-clang-format) as it makes reviews easier.  Also 
clang-format changes its mind about how to format over time, and so doing other 
code introduces spurious diffs that make archeology harder. 

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


[Lldb-commits] [lldb] Summarize std::string's when created from data. (PR #89110)

2024-05-23 Thread via lldb-commits


@@ -0,0 +1,49 @@
+# coding=utf8
+"""
+Helper formmater to verify Std::String by created via SBData

jimingham wrote:

formmater -> formatter

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


[Lldb-commits] [lldb] Summarize std::string's when created from data. (PR #89110)

2024-05-23 Thread via lldb-commits


@@ -17,6 +17,15 @@ def setUp(self):
 # Find the line number to break at.
 self.line = line_number("main.cpp", "// Set break point at this line.")
 
+# This is the function to remove the custom formats in order to have a

jimingham wrote:

If you make all your custom summaries in a category (e.g. pass `-w 
SOME_UNIQUE_NAME` then you can delete just the category with `type category 
delete`.  That way you know you are only deleting what you added.

Categories come into being disabled, so if you do it this way, you need to add:

`type category enable SOME_UNIQUE_NAME`

to your `__lldb_init_module`

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


[Lldb-commits] [lldb] Summarize std::string's when created from data. (PR #89110)

2024-05-23 Thread via lldb-commits


@@ -17,6 +17,15 @@ def setUp(self):
 # Find the line number to break at.
 self.line = line_number("main.cpp", "// Set break point at this line.")
 
+# This is the function to remove the custom formats in order to have a

jimingham wrote:

Ah, I see you didn't originally do that, so don't feel required to do that, but 
it's still the better way to do it...

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


[Lldb-commits] [lldb] Summarize std::string's when created from data. (PR #89110)

2024-05-23 Thread via lldb-commits

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


[Lldb-commits] [lldb] Summarize std::string's when created from data. (PR #89110)

2024-05-23 Thread Jacob Lalonde via lldb-commits


@@ -2763,10 +2763,10 @@ ValueObjectSP ValueObject::Cast(const CompilerType 
&compiler_type) {
   ExecutionContextScope *exe_scope
   = ExecutionContext(GetExecutionContextRef())
   .GetBestExecutionContextScope();
-  if (compiler_type.GetByteSize(exe_scope)
-  <= GetCompilerType().GetByteSize(exe_scope) 
-  || m_value.GetValueType() == Value::ValueType::LoadAddress)
-return DoCast(compiler_type);
+  if (compiler_type.GetByteSize(exe_scope) <=

Jlalond wrote:

Hmm, yeah I ran `git-clang-format` against this. 
Specifically, `git fetch upstream; git-clang-format upstream/main` and it 
produced this. I'll manually revert this one

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


[Lldb-commits] [lldb] [llvm] Add a createError variant without error code (NFC) (PR #93209)

2024-05-23 Thread Adrian Prantl via lldb-commits

https://github.com/adrian-prantl updated 
https://github.com/llvm/llvm-project/pull/93209

>From bece445681b0f810927c799cea53686cd000339b Mon Sep 17 00:00:00 2001
From: Adrian Prantl 
Date: Thu, 23 May 2024 08:36:48 -0700
Subject: [PATCH] Add a createError variant without error code (NFC)

For the significant amount of call sites that want to create an
incontrovertible error, such a wrapper function creates a significant
readability improvement and lowers the cost of entry to add error
handling in more places.
---
 lldb/source/Host/common/Socket.cpp|  3 +-
 lldb/source/Interpreter/Options.cpp   | 29 ++-
 .../Plugins/ABI/PowerPC/ABISysV_ppc64.cpp |  8 ++---
 .../Python/ScriptInterpreterPython.cpp|  9 ++---
 .../SymbolFile/Breakpad/SymbolFileBreakpad.h  |  5 ++-
 .../TypeSystem/Clang/TypeSystemClang.cpp  | 15 +++-
 lldb/source/Symbol/CompilerType.cpp   |  3 +-
 lldb/source/Symbol/Symbol.cpp | 18 --
 lldb/source/Symbol/SymbolFileOnDemand.cpp |  5 ++-
 lldb/source/Symbol/TypeSystem.cpp | 32 +++--
 lldb/source/Target/Target.cpp | 36 ---
 lldb/source/Utility/Status.cpp|  3 +-
 llvm/include/llvm/Support/Error.h |  4 +++
 13 files changed, 67 insertions(+), 103 deletions(-)

diff --git a/lldb/source/Host/common/Socket.cpp 
b/lldb/source/Host/common/Socket.cpp
index bd0c127a08956..f9911cf136cbd 100644
--- a/lldb/source/Host/common/Socket.cpp
+++ b/lldb/source/Host/common/Socket.cpp
@@ -87,8 +87,7 @@ llvm::Error Socket::Initialize() {
   if (err == 0) {
 if (wsaData.wVersion < wVersion) {
   WSACleanup();
-  return llvm::make_error(
-  "WSASock version is not expected.", llvm::inconvertibleErrorCode());
+  return llvm::createStringError("WSASock version is not expected.");
 }
   } else {
 return llvm::errorCodeToError(llvm::mapWindowsError(::WSAGetLastError()));
diff --git a/lldb/source/Interpreter/Options.cpp 
b/lldb/source/Interpreter/Options.cpp
index 51b7e6b26b6ef..4e7d074ace1b8 100644
--- a/lldb/source/Interpreter/Options.cpp
+++ b/lldb/source/Interpreter/Options.cpp
@@ -931,8 +931,7 @@ llvm::Expected Options::ParseAlias(const Args &args,
   Option *long_options = GetLongOptions();
 
   if (long_options == nullptr) {
-return llvm::make_error("Invalid long options",
-   llvm::inconvertibleErrorCode());
+return llvm::createStringError("Invalid long options");
   }
 
   std::string short_options = BuildShortOptions(long_options);
@@ -957,8 +956,7 @@ llvm::Expected Options::ParseAlias(const Args &args,
   break;
 
 if (val == '?') {
-  return llvm::make_error(
-  "Unknown or ambiguous option", llvm::inconvertibleErrorCode());
+  return llvm::createStringError("Unknown or ambiguous option");
 }
 
 if (val == 0)
@@ -980,9 +978,8 @@ llvm::Expected Options::ParseAlias(const Args &args,
 
 // See if the option takes an argument, and see if one was supplied.
 if (long_options_index == -1) {
-  return llvm::make_error(
-  llvm::formatv("Invalid option with value '{0}'.", char(val)).str(),
-  llvm::inconvertibleErrorCode());
+  return llvm::createStringError(
+  llvm::formatv("Invalid option with value '{0}'.", char(val)).str());
 }
 
 StreamString option_str;
@@ -995,11 +992,10 @@ llvm::Expected Options::ParseAlias(const Args &args,
 switch (has_arg) {
 case OptionParser::eRequiredArgument:
   if (OptionParser::GetOptionArgument() == nullptr) {
-return llvm::make_error(
+return llvm::createStringError(
 llvm::formatv("Option '{0}' is missing argument specifier.",
   option_str.GetString())
-.str(),
-llvm::inconvertibleErrorCode());
+.str());
   }
   [[fallthrough]];
 case OptionParser::eOptionalArgument:
@@ -1008,12 +1004,11 @@ llvm::Expected Options::ParseAlias(const Args 
&args,
 case OptionParser::eNoArgument:
   break;
 default:
-  return llvm::make_error(
+  return llvm::createStringError(
   llvm::formatv("error with options table; invalid value in has_arg "
 "field for option '{0}'.",
 char(val))
-  .str(),
-  llvm::inconvertibleErrorCode());
+  .str());
 }
 // Find option in the argument list; also see if it was supposed to take an
 // argument and if one was supplied.  Remove option (and argument, if
@@ -1261,8 +1256,7 @@ llvm::Expected Options::Parse(const Args &args,
   Status error;
   Option *long_options = GetLongOptions();
   if (long_options == nullptr) {
-return llvm::make_error("Invalid long options.",
-   llvm::inconvertibleErrorCode());
+return llvm::createStringError("Invalid long opt

[Lldb-commits] [lldb] [llvm] Add a createError variant without error code (NFC) (PR #93209)

2024-05-23 Thread Adrian Prantl via lldb-commits

https://github.com/adrian-prantl updated 
https://github.com/llvm/llvm-project/pull/93209

>From c5738598436c7a9e1ba38ba8ffd6f67a2e524785 Mon Sep 17 00:00:00 2001
From: Adrian Prantl 
Date: Thu, 23 May 2024 08:36:48 -0700
Subject: [PATCH] Add a createError variant without error code (NFC)

For the significant amount of call sites that want to create an
incontrovertible error, such a wrapper function creates a significant
readability improvement and lowers the cost of entry to add error
handling in more places.
---
 lldb/source/Host/common/Socket.cpp|  3 +-
 lldb/source/Interpreter/Options.cpp   | 29 ++-
 .../Plugins/ABI/PowerPC/ABISysV_ppc64.cpp |  8 ++---
 .../Python/ScriptInterpreterPython.cpp|  9 ++---
 .../SymbolFile/Breakpad/SymbolFileBreakpad.h  |  5 ++-
 .../TypeSystem/Clang/TypeSystemClang.cpp  | 15 +++-
 lldb/source/Symbol/CompilerType.cpp   |  3 +-
 lldb/source/Symbol/Symbol.cpp | 18 --
 lldb/source/Symbol/SymbolFileOnDemand.cpp |  5 ++-
 lldb/source/Symbol/TypeSystem.cpp | 32 +++--
 lldb/source/Target/Target.cpp | 36 ---
 lldb/source/Utility/Status.cpp|  3 +-
 llvm/include/llvm/Support/Error.h |  5 +++
 13 files changed, 68 insertions(+), 103 deletions(-)

diff --git a/lldb/source/Host/common/Socket.cpp 
b/lldb/source/Host/common/Socket.cpp
index bd0c127a08956..f9911cf136cbd 100644
--- a/lldb/source/Host/common/Socket.cpp
+++ b/lldb/source/Host/common/Socket.cpp
@@ -87,8 +87,7 @@ llvm::Error Socket::Initialize() {
   if (err == 0) {
 if (wsaData.wVersion < wVersion) {
   WSACleanup();
-  return llvm::make_error(
-  "WSASock version is not expected.", llvm::inconvertibleErrorCode());
+  return llvm::createStringError("WSASock version is not expected.");
 }
   } else {
 return llvm::errorCodeToError(llvm::mapWindowsError(::WSAGetLastError()));
diff --git a/lldb/source/Interpreter/Options.cpp 
b/lldb/source/Interpreter/Options.cpp
index 51b7e6b26b6ef..4e7d074ace1b8 100644
--- a/lldb/source/Interpreter/Options.cpp
+++ b/lldb/source/Interpreter/Options.cpp
@@ -931,8 +931,7 @@ llvm::Expected Options::ParseAlias(const Args &args,
   Option *long_options = GetLongOptions();
 
   if (long_options == nullptr) {
-return llvm::make_error("Invalid long options",
-   llvm::inconvertibleErrorCode());
+return llvm::createStringError("Invalid long options");
   }
 
   std::string short_options = BuildShortOptions(long_options);
@@ -957,8 +956,7 @@ llvm::Expected Options::ParseAlias(const Args &args,
   break;
 
 if (val == '?') {
-  return llvm::make_error(
-  "Unknown or ambiguous option", llvm::inconvertibleErrorCode());
+  return llvm::createStringError("Unknown or ambiguous option");
 }
 
 if (val == 0)
@@ -980,9 +978,8 @@ llvm::Expected Options::ParseAlias(const Args &args,
 
 // See if the option takes an argument, and see if one was supplied.
 if (long_options_index == -1) {
-  return llvm::make_error(
-  llvm::formatv("Invalid option with value '{0}'.", char(val)).str(),
-  llvm::inconvertibleErrorCode());
+  return llvm::createStringError(
+  llvm::formatv("Invalid option with value '{0}'.", char(val)).str());
 }
 
 StreamString option_str;
@@ -995,11 +992,10 @@ llvm::Expected Options::ParseAlias(const Args &args,
 switch (has_arg) {
 case OptionParser::eRequiredArgument:
   if (OptionParser::GetOptionArgument() == nullptr) {
-return llvm::make_error(
+return llvm::createStringError(
 llvm::formatv("Option '{0}' is missing argument specifier.",
   option_str.GetString())
-.str(),
-llvm::inconvertibleErrorCode());
+.str());
   }
   [[fallthrough]];
 case OptionParser::eOptionalArgument:
@@ -1008,12 +1004,11 @@ llvm::Expected Options::ParseAlias(const Args 
&args,
 case OptionParser::eNoArgument:
   break;
 default:
-  return llvm::make_error(
+  return llvm::createStringError(
   llvm::formatv("error with options table; invalid value in has_arg "
 "field for option '{0}'.",
 char(val))
-  .str(),
-  llvm::inconvertibleErrorCode());
+  .str());
 }
 // Find option in the argument list; also see if it was supposed to take an
 // argument and if one was supplied.  Remove option (and argument, if
@@ -1261,8 +1256,7 @@ llvm::Expected Options::Parse(const Args &args,
   Status error;
   Option *long_options = GetLongOptions();
   if (long_options == nullptr) {
-return llvm::make_error("Invalid long options.",
-   llvm::inconvertibleErrorCode());
+return llvm::createStringError("Invalid long opt

[Lldb-commits] [lldb] Summarize std::string's when created from data. (PR #89110)

2024-05-23 Thread via lldb-commits


@@ -254,13 +254,17 @@ bool 
lldb_private::formatters::LibStdcppStringSummaryProvider(
   } else
 addr_of_string =
 valobj.GetAddressOf(scalar_is_load_addr, &addr_type);
-  if (addr_of_string != LLDB_INVALID_ADDRESS) {
+
+  // We have to check for host address here
+  // because GetAddressOf returns INVALID for all non load addresses.
+  // But we can still format strings in host memory.
+  if (addr_of_string != LLDB_INVALID_ADDRESS ||
+addr_type == eAddressTypeHost) {

jimingham wrote:

I think we need to be more careful here.  GetAddressOf is really meant to do 
"can you find an address in the target for this object".  We use it that way in 
a whole bunch of places, e.g.:

```
  cstr_address = GetAddressOf(true, &cstr_address_type);
} else {
  // We have a pointer
  cstr_address = GetPointerValue(&cstr_address_type);
}

if (cstr_address == 0 || cstr_address == LLDB_INVALID_ADDRESS) {
  if (cstr_address_type == eAddressTypeHost && is_array) {
const char *cstr = GetDataExtractor().PeekCStr(0);

```

So in that case we are expecting a host address type to return an invalid 
address from GetAddressOf.

This change worries me, I don't think it will be what other code expects?  
Maybe you can get the value you need like the code above does instead?

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


[Lldb-commits] [lldb] Read and store gnu build id from loaded core file (PR #92492)

2024-05-23 Thread via lldb-commits

https://github.com/GeorgeHuyubo updated 
https://github.com/llvm/llvm-project/pull/92492

>From a9714b155a116e9b1d18434c0485ea2ad35680f3 Mon Sep 17 00:00:00 2001
From: George Hu 
Date: Tue, 14 May 2024 16:18:20 -0700
Subject: [PATCH] Read and store gnu build id from loaded core file

---
 .../Process/elf-core/ProcessElfCore.cpp   | 74 ++-
 .../Plugins/Process/elf-core/ProcessElfCore.h | 10 +++
 2 files changed, 83 insertions(+), 1 deletion(-)

diff --git a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp 
b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
index 36812c27a5b6d..0e0937b77f4b4 100644
--- a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
+++ b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
@@ -250,6 +250,9 @@ Status ProcessElfCore::DoLoadCore() {
 }
   }
 
+  // Try to find gnu build id before we load the executable.
+  UpdateBuildIdForNTFileEntries();
+
   // Core files are useless without the main executable. See if we can locate
   // the main executable using data we found in the core file notes.
   lldb::ModuleSP exe_module_sp = GetTarget().GetExecutableModule();
@@ -258,6 +261,7 @@ Status ProcessElfCore::DoLoadCore() {
 if (!m_nt_file_entries.empty()) {
   ModuleSpec exe_module_spec;
   exe_module_spec.GetArchitecture() = arch;
+  exe_module_spec.GetUUID() = m_nt_file_entries[0].uuid;
   exe_module_spec.GetFileSpec().SetFile(m_nt_file_entries[0].path,
 FileSpec::Style::native);
   if (exe_module_spec.GetFileSpec()) {
@@ -271,6 +275,14 @@ Status ProcessElfCore::DoLoadCore() {
   return error;
 }
 
+void ProcessElfCore::UpdateBuildIdForNTFileEntries() {
+  if (!m_nt_file_entries.empty()) {
+for (NT_FILE_Entry &entry : m_nt_file_entries) {
+  entry.uuid = FindBuidIdInCoreMemory(entry.start);
+}
+  }
+}
+
 lldb_private::DynamicLoader *ProcessElfCore::GetDynamicLoader() {
   if (m_dyld_up.get() == nullptr)
 m_dyld_up.reset(DynamicLoader::FindPlugin(
@@ -573,7 +585,6 @@ llvm::Expected>
 ProcessElfCore::parseSegment(const DataExtractor &segment) {
   lldb::offset_t offset = 0;
   std::vector result;
-
   while (offset < segment.GetByteSize()) {
 ELFNote note = ELFNote();
 if (!note.Parse(segment, &offset))
@@ -983,6 +994,67 @@ llvm::Error 
ProcessElfCore::ParseThreadContextsFromNoteSegment(
   }
 }
 
+UUID ProcessElfCore::FindBuidIdInCoreMemory(lldb::addr_t address) {
+  UUID invalid_uuid;
+  const uint32_t addr_size = GetAddressByteSize();
+  const size_t elf_header_size = addr_size == 4 ? sizeof(llvm::ELF::Elf32_Ehdr)
+: 
sizeof(llvm::ELF::Elf64_Ehdr);
+
+  // 80 bytes buffer is larger enough for the ELF header or program headers
+  unsigned char buf[80];
+  Status error;
+  size_t byte_read = ReadMemory(address, buf, elf_header_size, error);
+  if (byte_read != elf_header_size || !elf::ELFHeader::MagicBytesMatch(buf))
+return invalid_uuid;
+  assert(sizeof(buf) >= elf_header_size);
+  DataExtractor elf_header_data(buf, elf_header_size, GetByteOrder(),
+addr_size);
+  lldb::offset_t offset = 0;
+
+  elf::ELFHeader elf_header;
+  elf_header.Parse(elf_header_data, &offset);
+
+  const lldb::addr_t ph_addr = address + elf_header.e_phoff;
+
+  for (unsigned int i = 0; i < elf_header.e_phnum; ++i) {
+byte_read = ReadMemory(ph_addr + i * elf_header.e_phentsize, buf,
+   elf_header.e_phentsize, error);
+if (byte_read != elf_header.e_phentsize)
+  break;
+assert(sizeof(buf) >= elf_header.e_phentsize);
+DataExtractor program_header_data(buf, elf_header.e_phentsize,
+  GetByteOrder(), addr_size);
+offset = 0;
+elf::ELFProgramHeader program_header;
+program_header.Parse(program_header_data, &offset);
+if (program_header.p_type != llvm::ELF::PT_NOTE)
+  continue;
+
+std::vector note_bytes;
+note_bytes.resize(program_header.p_memsz);
+
+byte_read = ReadMemory(program_header.p_vaddr, note_bytes.data(),
+   program_header.p_memsz, error);
+if (byte_read != program_header.p_memsz)
+  continue;
+assert(sizeof(buf) >= program_header.p_memsz);
+DataExtractor segment_data(note_bytes.data(), note_bytes.size(),
+   GetByteOrder(), addr_size);
+auto notes_or_error = parseSegment(segment_data);
+if (!notes_or_error)
+  return invalid_uuid;
+for (const CoreNote ¬e : *notes_or_error) {
+  if (note.info.n_namesz == 4 &&
+  note.info.n_type == llvm::ELF::NT_GNU_BUILD_ID) {
+if ("GNU" == note.info.n_name)
+  return UUID(llvm::ArrayRef(
+  note.data.GetDataStart(), note.info.n_descsz /*byte size*/));
+  }
+}
+  }
+  return invalid_uuid;
+}
+
 uint32_t ProcessElfCore::GetNumThreadContexts() {
   if (!m_thread_data_valid)
 DoLoadCore();
diff --git a/lldb

[Lldb-commits] [lldb] [llvm] Add a createError variant without error code (NFC) (PR #93209)

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

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

This will be very useful. LGTM!

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


[Lldb-commits] [lldb] Summarize std::string's when created from data. (PR #89110)

2024-05-23 Thread Jacob Lalonde via lldb-commits


@@ -17,6 +17,15 @@ def setUp(self):
 # Find the line number to break at.
 self.line = line_number("main.cpp", "// Set break point at this line.")
 
+# This is the function to remove the custom formats in order to have a

Jlalond wrote:

This PR is already old enough that we can lump it in!

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


[Lldb-commits] [lldb] Summarize std::string's when created from data. (PR #89110)

2024-05-23 Thread Jacob Lalonde via lldb-commits


@@ -254,13 +254,17 @@ bool 
lldb_private::formatters::LibStdcppStringSummaryProvider(
   } else
 addr_of_string =
 valobj.GetAddressOf(scalar_is_load_addr, &addr_type);
-  if (addr_of_string != LLDB_INVALID_ADDRESS) {
+
+  // We have to check for host address here
+  // because GetAddressOf returns INVALID for all non load addresses.
+  // But we can still format strings in host memory.
+  if (addr_of_string != LLDB_INVALID_ADDRESS ||
+addr_type == eAddressTypeHost) {

Jlalond wrote:

We could take the approach you provided. Greg and I originally talked and 
mentioned how `GetAddressOf` will return the pointer within a buffer in certain 
cases. I'm not enough of an expert here to have strong opinions but I think 
we're in a confusing middleground, where GetAddressOf works for Load addresses, 
but fails for a host address even if we have a pointer internally to a data 
buffer. 

I think solving that is more fundamental to my (2nd?) PR in lldb, but if we can 
all agree on the returning invaild for host addresses. I'm okay with that, as 
long as we also add a comment/documentation to the call that HostAddress 
addresses are invalid and to instead use a data extractor. My only opinion on 
that as a new contributor is the API to work with ValueObject's data is clunky, 
because I can seemingly only construct a copy via `GetData`.

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


[Lldb-commits] [lldb] Improve performance of .debug_names lookups when DW_IDX_parent attributes are used (PR #91808)

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

dwblaikie wrote:

> "std::ios_base" is forward declared and it contains typedefs whose entries in 
> the .debug_names table will point to the DIE at offset 0x0090cdd5. These 
> entries cause our type lookups to try and parse a TON of forward declarations 
> and waste time and resources.
> 
> This fix makes sure when/if we find an entry in the .debug_names table, we 
> don't process it if it has a DW_AT_declaration(true) attribute.

To come back to this - the table consists of buckets, buckets (a list of 
indexes into a hash table, one hash per string), then a string table (string 
offsets into .debug_str and entry offsets). The entry offsets point into the 
entry pool which is where the tag and DW_IDX values are. Each string entry 
points to a sequence of index entries, terminated by a zero abbrev code.

But there can be index entries that aren't referenced by string entries - they 
could appear anywhere in the entry pool, just not in a sequence pointed to by a 
name entry (because if they were there, they'd be included in that string's 
entries).

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


[Lldb-commits] [lldb] Add AddressRange to SB API (PR #92014)

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


@@ -0,0 +1,65 @@
+//===-- SBAddressRange.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_API_SBADDRESSRANGE_H
+#define LLDB_API_SBADDRESSRANGE_H
+
+#include "lldb/API/SBDefines.h"
+
+namespace lldb {
+
+class LLDB_API SBAddressRange {
+public:
+  SBAddressRange();
+
+  SBAddressRange(const lldb::SBAddressRange &rhs);
+
+  SBAddressRange(lldb::SBAddress addr, lldb::addr_t byte_size);
+
+  ~SBAddressRange();
+
+  const lldb::SBAddressRange &operator=(const lldb::SBAddressRange &rhs);
+
+  void Clear();
+
+  /// Check the address range refers to a valid base address and has a byte
+  /// size greater than zero.
+  ///
+  /// \return
+  /// True if the address range is valid, false otherwise.
+  bool IsValid() const;
+
+  /// Get the base address of the range.
+  ///
+  /// \return
+  /// Base address object.
+  lldb::SBAddress GetBaseAddress() const;
+
+  /// Get the byte size of this range.
+  ///
+  /// \return
+  /// The size in bytes of this address range.
+  lldb::addr_t GetByteSize() const;
+
+  bool operator==(const SBAddressRange &rhs);
+
+  bool operator!=(const SBAddressRange &rhs);
+
+  bool GetDescription(lldb::SBStream &description, SBTarget *target);

clayborg wrote:

We should still either pass in a `SBTarget &` or a `SBTarget`. If we use a 
`SBTarget &` it makes it harder to pass in a temporary unless it is `const 
SBTarget &`, maybe that is what works better with tooling @bulbazord?

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


[Lldb-commits] [lldb] Add AddressRange to SB API (PR #92014)

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


@@ -0,0 +1,28 @@
+%extend lldb::SBAddressRangeList {
+#ifdef SWIGPYTHON
+%pythoncode%{
+def __len__(self):
+  '''Return the number of address ranges in a lldb.SBAddressRangeList 
object.'''
+  return self.GetSize()
+
+def __iter__(self):
+  '''Iterate over all the address ranges in a lldb.SBAddressRangeList 
object.'''
+  return lldb_iter(self, 'GetSize', 'GetAddressRangeAtIndex')
+
+def __getitem__(self, idx):
+  '''Get the address range at a given index in an lldb.SBAddressRangeList 
object.'''
+  if type(idx) == int:
+if idx >= self.GetSize():
+  raise IndexError("list index out of range")
+return self.GetAddressRangeAtIndex(idx)
+  else:
+print("error: unsupported idx type: %s" % type(key))
+return None

clayborg wrote:

```
>>> a = []
>>> a[12]
Traceback (most recent call last):
  File "", line 1, in 
IndexError: list index out of range
```
We should throw an `IndexError` just like a normal array

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


[Lldb-commits] [lldb] Add AddressRange to SB API (PR #92014)

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


@@ -0,0 +1,65 @@
+//===-- SBAddressRange.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_API_SBADDRESSRANGE_H
+#define LLDB_API_SBADDRESSRANGE_H
+
+#include "lldb/API/SBDefines.h"
+
+namespace lldb {
+
+class LLDB_API SBAddressRange {
+public:
+  SBAddressRange();
+
+  SBAddressRange(const lldb::SBAddressRange &rhs);
+
+  SBAddressRange(lldb::SBAddress addr, lldb::addr_t byte_size);
+
+  ~SBAddressRange();
+
+  const lldb::SBAddressRange &operator=(const lldb::SBAddressRange &rhs);
+
+  void Clear();
+
+  /// Check the address range refers to a valid base address and has a byte
+  /// size greater than zero.
+  ///
+  /// \return
+  /// True if the address range is valid, false otherwise.
+  bool IsValid() const;
+
+  /// Get the base address of the range.
+  ///
+  /// \return
+  /// Base address object.
+  lldb::SBAddress GetBaseAddress() const;
+
+  /// Get the byte size of this range.
+  ///
+  /// \return
+  /// The size in bytes of this address range.
+  lldb::addr_t GetByteSize() const;
+
+  bool operator==(const SBAddressRange &rhs);
+
+  bool operator!=(const SBAddressRange &rhs);
+
+  bool GetDescription(lldb::SBStream &description, SBTarget *target);

clayborg wrote:

@bulbazord: `const` doesn't do anything useful, it protects the 
std::shared_ptr<> from changing, but not the shared pointer from calling a non 
const method. What tooling works better with this? And how can it work better 
if `const` does nothing useful?

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


[Lldb-commits] [lldb] Improve performance of .debug_names lookups when DW_IDX_parent attributes are used (PR #91808)

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

dwblaikie wrote:

As for the original issue this patch is meant to address - I'd still like to 
see an example of the problem, as I'm not sure what the issue is. (but, 
equally, I'm not a decider in lldb - so don't have to wait on my for approval 
if other lldb devs reckon this is the right direction)

> "std::ios_base" is forward declared and it contains typedefs whose entries in 
> the .debug_names table will point to the DIE at offset 0x0090cdd5. These 
> entries cause our type lookups to try and parse a TON of forward declarations 
> and waste time and resources.

Yeah, so far as I know if the parent of the typedef isn't indexed (because it's 
a declaration that isn't a definition) we don't put a DW_IDX_parent on the 
typedef.

It wouldn't be totally wrong for a producer to do this, though they shouldn't 
put the declaration of the enclosing/outer type in a /named/ entry, just in an 
unnamed index entry.

But if they did, why would that cause bad performance? The name lookup should 
check the referenced parent DIE to see what its name is - why would there be a 
lookup of everything with that name?

Or you mean all these declarations end up in the table, and any lookup for the 
name is inefficient because it finds lots of declarations so there's just loads 
more results than we want?

Yeah - if some producer did mistakenly put declarations in named entries in the 
debug_names table, that'd be bad - filtering them out in the debugger's not the 
worst thing, or just erroring out & saying the table's bogus (maybe ignoring 
the table entirely). Not sure.

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


[Lldb-commits] [lldb] Improve performance of .debug_names lookups when DW_IDX_parent attributes are used (PR #91808)

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

dwblaikie wrote:

But seems like this isn't a DW_IDX_parent issue, then (other than as /maybe/ an 
artifact of the producer) - so the description seems misleading. "ignore 
invalid named entries that refer to declarations"

A test case/demonstration this is a real problem would be nice, though... 

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


[Lldb-commits] [lldb] Add AddressRange to SB API (PR #92014)

2024-05-23 Thread Alex Langford via lldb-commits


@@ -0,0 +1,65 @@
+//===-- SBAddressRange.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_API_SBADDRESSRANGE_H
+#define LLDB_API_SBADDRESSRANGE_H
+
+#include "lldb/API/SBDefines.h"
+
+namespace lldb {
+
+class LLDB_API SBAddressRange {
+public:
+  SBAddressRange();
+
+  SBAddressRange(const lldb::SBAddressRange &rhs);
+
+  SBAddressRange(lldb::SBAddress addr, lldb::addr_t byte_size);
+
+  ~SBAddressRange();
+
+  const lldb::SBAddressRange &operator=(const lldb::SBAddressRange &rhs);
+
+  void Clear();
+
+  /// Check the address range refers to a valid base address and has a byte
+  /// size greater than zero.
+  ///
+  /// \return
+  /// True if the address range is valid, false otherwise.
+  bool IsValid() const;
+
+  /// Get the base address of the range.
+  ///
+  /// \return
+  /// Base address object.
+  lldb::SBAddress GetBaseAddress() const;
+
+  /// Get the byte size of this range.
+  ///
+  /// \return
+  /// The size in bytes of this address range.
+  lldb::addr_t GetByteSize() const;
+
+  bool operator==(const SBAddressRange &rhs);
+
+  bool operator!=(const SBAddressRange &rhs);
+
+  bool GetDescription(lldb::SBStream &description, SBTarget *target);

bulbazord wrote:

We have some tooling downstream that generates some C++ code from the API 
headers. Specifically, it generates the sources for lldb-rpc-server and the 
necessary code to support that. const-ness of the argument helps us reliably 
determine how parameters can be used in RPC contexts. Specifically, if we see a 
`const SBFoo &`, we can generate code differently than if we see `SBFoo &`.

Why might be the target parameter be null here? I'm fine with it being a 
pointer, but I would strongly prefer a reference if possible. :)

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


[Lldb-commits] [lldb] af31883 - Add a createError variant without error code (NFC) (#93209)

2024-05-23 Thread via lldb-commits

Author: Adrian Prantl
Date: 2024-05-23T14:22:07-07:00
New Revision: af31883341a122a7285e9b4f0a034470024021eb

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

LOG: Add a createError variant without error code (NFC) (#93209)

For the significant amount of call sites that want to create an
incontrovertible error, such a wrapper function creates a significant
readability improvement and lowers the cost of entry to add error
handling in more places.

Added: 


Modified: 
lldb/source/Host/common/Socket.cpp
lldb/source/Interpreter/Options.cpp
lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc64.cpp
lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
lldb/source/Symbol/CompilerType.cpp
lldb/source/Symbol/Symbol.cpp
lldb/source/Symbol/SymbolFileOnDemand.cpp
lldb/source/Symbol/TypeSystem.cpp
lldb/source/Target/Target.cpp
lldb/source/Utility/Status.cpp
llvm/include/llvm/Support/Error.h

Removed: 




diff  --git a/lldb/source/Host/common/Socket.cpp 
b/lldb/source/Host/common/Socket.cpp
index bd0c127a08956..f9911cf136cbd 100644
--- a/lldb/source/Host/common/Socket.cpp
+++ b/lldb/source/Host/common/Socket.cpp
@@ -87,8 +87,7 @@ llvm::Error Socket::Initialize() {
   if (err == 0) {
 if (wsaData.wVersion < wVersion) {
   WSACleanup();
-  return llvm::make_error(
-  "WSASock version is not expected.", llvm::inconvertibleErrorCode());
+  return llvm::createStringError("WSASock version is not expected.");
 }
   } else {
 return llvm::errorCodeToError(llvm::mapWindowsError(::WSAGetLastError()));

diff  --git a/lldb/source/Interpreter/Options.cpp 
b/lldb/source/Interpreter/Options.cpp
index 51b7e6b26b6ef..4e7d074ace1b8 100644
--- a/lldb/source/Interpreter/Options.cpp
+++ b/lldb/source/Interpreter/Options.cpp
@@ -931,8 +931,7 @@ llvm::Expected Options::ParseAlias(const Args &args,
   Option *long_options = GetLongOptions();
 
   if (long_options == nullptr) {
-return llvm::make_error("Invalid long options",
-   llvm::inconvertibleErrorCode());
+return llvm::createStringError("Invalid long options");
   }
 
   std::string short_options = BuildShortOptions(long_options);
@@ -957,8 +956,7 @@ llvm::Expected Options::ParseAlias(const Args &args,
   break;
 
 if (val == '?') {
-  return llvm::make_error(
-  "Unknown or ambiguous option", llvm::inconvertibleErrorCode());
+  return llvm::createStringError("Unknown or ambiguous option");
 }
 
 if (val == 0)
@@ -980,9 +978,8 @@ llvm::Expected Options::ParseAlias(const Args &args,
 
 // See if the option takes an argument, and see if one was supplied.
 if (long_options_index == -1) {
-  return llvm::make_error(
-  llvm::formatv("Invalid option with value '{0}'.", char(val)).str(),
-  llvm::inconvertibleErrorCode());
+  return llvm::createStringError(
+  llvm::formatv("Invalid option with value '{0}'.", char(val)).str());
 }
 
 StreamString option_str;
@@ -995,11 +992,10 @@ llvm::Expected Options::ParseAlias(const Args &args,
 switch (has_arg) {
 case OptionParser::eRequiredArgument:
   if (OptionParser::GetOptionArgument() == nullptr) {
-return llvm::make_error(
+return llvm::createStringError(
 llvm::formatv("Option '{0}' is missing argument specifier.",
   option_str.GetString())
-.str(),
-llvm::inconvertibleErrorCode());
+.str());
   }
   [[fallthrough]];
 case OptionParser::eOptionalArgument:
@@ -1008,12 +1004,11 @@ llvm::Expected Options::ParseAlias(const Args 
&args,
 case OptionParser::eNoArgument:
   break;
 default:
-  return llvm::make_error(
+  return llvm::createStringError(
   llvm::formatv("error with options table; invalid value in has_arg "
 "field for option '{0}'.",
 char(val))
-  .str(),
-  llvm::inconvertibleErrorCode());
+  .str());
 }
 // Find option in the argument list; also see if it was supposed to take an
 // argument and if one was supplied.  Remove option (and argument, if
@@ -1261,8 +1256,7 @@ llvm::Expected Options::Parse(const Args &args,
   Status error;
   Option *long_options = GetLongOptions();
   if (long_options == nullptr) {
-return llvm::make_error("Invalid long options.",
-   llvm::inconvertibleErrorCode());
+return llvm::createStringError("Invalid long options.");
   }
 
   std::string short_op

[Lldb-commits] [lldb] [llvm] Add a createError variant without error code (NFC) (PR #93209)

2024-05-23 Thread Adrian Prantl via lldb-commits

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


[Lldb-commits] [lldb] Reapply "[lldb/aarch64] Fix unwinding when signal interrupts a leaf f… (PR #92503)

2024-05-23 Thread Jason Molenda via lldb-commits

jasonmolenda wrote:

> The way I see it, this check (at least the part about the RA register(*)) is 
> heuristic that's impossible to get always right. Like, I could construct a 
> test case using functions with non-standard ABIs where a non-leaf function 
> legitimately has a `lr=` rule. Such code would execute correctly but 
> lldb would refuse to unwind it due to the `lr=` restriction.

This would be an interesting idea.  I don't think there's any unwind format 
which allows you to specify that a different register holds the return address, 
and lr is IsSame.  You could say that lr=x9 to say that the return address is 
in x9, but you can't express that the return address is stored in a non-lr 
register.  You could add an unwind rule for pc=x9 to say that the return 
address is in x9, and depend on the unwinder to not look for lr, but to try 
retrieving pc first.

> 
> All of this is to say that I don't think there is a way to change this piece 
> of code to be correct all the time -- we'd just be trading one set of edge 
> cases for the other. I think that the most correct solution would be to 
> remove this check altogether. I'm not sure why it exists, but I expect it has 
> something to do with preventing looping stacks. 

The original goal was that if we're on frame 1, we don't want to surface a 
register value from frame 0 and use it in frame 1 unless it's a callee-spilled 
register.   e.g. x0 on frame 1 may have been overwritten while frame 0 was 
executing, there is no unwind rule for x0 and the unwinder can't show frame 0's 
x0 value in frame 1.   But if we're above a sigtramp etc frame which has the 
entire register context from when a function was interrupted, we can retrieve 
all the registers and want to show them.

> (*) I'm only talking about the `lr` rule everywhere. I _think_ that a 
> `pc=` rule would always be an error (even in signal handlers), so we 
> should be able to keep that here. OTOH, if our loop detection code is robust 
> enough, then there should be no harm in letting this through either...


Yeah I think there's improvements that can be made here for sure.


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


[Lldb-commits] [lldb] Summarize std::string's when created from data. (PR #89110)

2024-05-23 Thread via lldb-commits

jimingham wrote:

We should definitely put more comments in the ValueObject.h header, a lot of 
those interfaces are mysterious.

GetAddressOf is solving a very particular problem, which is that if someone 
does:

(lldb) expr MakeMeAFooObject()
$0= {whatever}
(lldb) expr CallAFunctionTakingAFooPointer(&$0)

People really want that to work, but $0 is a "constant result" so where it 
lives is not clear.  It's also important for data formatters that want to use a 
pointer to some ValueObject or ValueObject child.  For expr results we make a 
shadow copy in the target so we can resolve this issue (this is one of the jobs 
of the `m_live_address` ivar).

So it is really for finding addresses in the target, and should fail if we 
can't realize that.

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


[Lldb-commits] [flang] [lldb] [llvm] [flang] [lldb] [llvm] Fix 'destory' comment typos [NFC] (PR #93260)

2024-05-23 Thread Stephan T. Lavavej via lldb-commits

https://github.com/StephanTLavavej created 
https://github.com/llvm/llvm-project/pull/93260

After fixing a test name typo in #93259, I noticed these comment typos.

(This is a separate "nice to have" PR, so that it doesn't get mixed up with the 
test changes that I need.)

>From 77ddab4fafd481ac58452bfc744525a14665 Mon Sep 17 00:00:00 2001
From: "Stephan T. Lavavej" 
Date: Mon, 20 May 2024 15:12:53 -0700
Subject: [PATCH] Fix 'destory' typos.

---
 flang/lib/Optimizer/HLFIR/IR/HLFIROps.cpp | 2 +-
 flang/lib/Optimizer/HLFIR/Transforms/InlineElementals.cpp | 2 +-
 lldb/include/lldb/Target/Process.h| 4 ++--
 .../Orc/TargetProcess/SimpleExecutorMemoryManager.cpp | 4 ++--
 llvm/test/Transforms/Coroutines/no-suspend.ll | 2 +-
 5 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/flang/lib/Optimizer/HLFIR/IR/HLFIROps.cpp 
b/flang/lib/Optimizer/HLFIR/IR/HLFIROps.cpp
index 11196353b07c7..218b38e9ba79d 100644
--- a/flang/lib/Optimizer/HLFIR/IR/HLFIROps.cpp
+++ b/flang/lib/Optimizer/HLFIR/IR/HLFIROps.cpp
@@ -1115,7 +1115,7 @@ mlir::LogicalResult
 hlfir::MatmulOp::canonicalize(MatmulOp matmulOp,
   mlir::PatternRewriter &rewriter) {
   // the only two uses of the transposed matrix should be for the hlfir.matmul
-  // and hlfir.destory
+  // and hlfir.destroy
   auto isOtherwiseUnused = [&](hlfir::TransposeOp transposeOp) -> bool {
 std::size_t numUses = 0;
 for (mlir::Operation *user : transposeOp.getResult().getUsers()) {
diff --git a/flang/lib/Optimizer/HLFIR/Transforms/InlineElementals.cpp 
b/flang/lib/Optimizer/HLFIR/Transforms/InlineElementals.cpp
index 06d0518763848..6c8e3e1193747 100644
--- a/flang/lib/Optimizer/HLFIR/Transforms/InlineElementals.cpp
+++ b/flang/lib/Optimizer/HLFIR/Transforms/InlineElementals.cpp
@@ -32,7 +32,7 @@ namespace hlfir {
 } // namespace hlfir
 
 /// If the elemental has only two uses and those two are an apply operation and
-/// a destory operation, return those two, otherwise return {}
+/// a destroy operation, return those two, otherwise return {}
 static std::optional>
 getTwoUses(hlfir::ElementalOp elemental) {
   mlir::Operation::user_range users = elemental->getUsers();
diff --git a/lldb/include/lldb/Target/Process.h 
b/lldb/include/lldb/Target/Process.h
index aac0cf51680a9..637d34c29715c 100644
--- a/lldb/include/lldb/Target/Process.h
+++ b/lldb/include/lldb/Target/Process.h
@@ -915,8 +915,8 @@ class Process : public 
std::enable_shared_from_this,
   /// \param[in] force_kill
   /// Whether lldb should force a kill (instead of a detach) from
   /// the inferior process.  Normally if lldb launched a binary and
-  /// Destory is called, lldb kills it.  If lldb attached to a
-  /// running process and Destory is called, lldb detaches.  If
+  /// Destroy is called, lldb kills it.  If lldb attached to a
+  /// running process and Destroy is called, lldb detaches.  If
   /// this behavior needs to be over-ridden, this is the bool that
   /// can be used.
   ///
diff --git 
a/llvm/lib/ExecutionEngine/Orc/TargetProcess/SimpleExecutorMemoryManager.cpp 
b/llvm/lib/ExecutionEngine/Orc/TargetProcess/SimpleExecutorMemoryManager.cpp
index 4da031716e32a..3cdffb8cd0615 100644
--- a/llvm/lib/ExecutionEngine/Orc/TargetProcess/SimpleExecutorMemoryManager.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/TargetProcess/SimpleExecutorMemoryManager.cpp
@@ -75,7 +75,7 @@ Error 
SimpleExecutorMemoryManager::finalize(tpctypes::FinalizeRequest &FR) {
   auto BailOut = [&](Error Err) {
 std::pair AllocToDestroy;
 
-// Get allocation to destory.
+// Get allocation to destroy.
 {
   std::lock_guard Lock(M);
   auto I = Allocations.find(Base.toPtr());
@@ -153,7 +153,7 @@ Error SimpleExecutorMemoryManager::deallocate(
   std::vector> AllocPairs;
   AllocPairs.reserve(Bases.size());
 
-  // Get allocation to destory.
+  // Get allocation to destroy.
   Error Err = Error::success();
   {
 std::lock_guard Lock(M);
diff --git a/llvm/test/Transforms/Coroutines/no-suspend.ll 
b/llvm/test/Transforms/Coroutines/no-suspend.ll
index 53eb98f1273a9..fd8c5ac990958 100644
--- a/llvm/test/Transforms/Coroutines/no-suspend.ll
+++ b/llvm/test/Transforms/Coroutines/no-suspend.ll
@@ -325,7 +325,7 @@ body:
   %save = call token @llvm.coro.save(ptr %hdl)
   %subfn = call ptr @llvm.coro.subfn.addr(ptr %hdl, i8 1)
   call fastcc void %subfn(ptr %hdl)
-  ; memcpy separates destory from suspend, therefore cannot simplify.
+  ; memcpy separates destroy from suspend, therefore cannot simplify.
   call void @llvm.memcpy.p0.p0.i64(ptr %dst, ptr %src, i64 1, i1 false)
   %0 = call i8 @llvm.coro.suspend(token %save, i1 false)
   switch i8 %0, label %suspend [i8 0, label %resume

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


[Lldb-commits] [flang] [lldb] [llvm] [flang] [lldb] [llvm] Fix 'destory' comment typos [NFC] (PR #93260)

2024-05-23 Thread via lldb-commits

llvmbot wrote:



@llvm/pr-subscribers-lldb
@llvm/pr-subscribers-coroutines

@llvm/pr-subscribers-flang-fir-hlfir

Author: Stephan T. Lavavej (StephanTLavavej)


Changes

After fixing a test name typo in #93259, I noticed these comment typos.

(This is a separate "nice to have" PR, so that it doesn't get mixed up with the 
test changes that I need.)

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


5 Files Affected:

- (modified) flang/lib/Optimizer/HLFIR/IR/HLFIROps.cpp (+1-1) 
- (modified) flang/lib/Optimizer/HLFIR/Transforms/InlineElementals.cpp (+1-1) 
- (modified) lldb/include/lldb/Target/Process.h (+2-2) 
- (modified) 
llvm/lib/ExecutionEngine/Orc/TargetProcess/SimpleExecutorMemoryManager.cpp 
(+2-2) 
- (modified) llvm/test/Transforms/Coroutines/no-suspend.ll (+1-1) 


``diff
diff --git a/flang/lib/Optimizer/HLFIR/IR/HLFIROps.cpp 
b/flang/lib/Optimizer/HLFIR/IR/HLFIROps.cpp
index 11196353b07c7..218b38e9ba79d 100644
--- a/flang/lib/Optimizer/HLFIR/IR/HLFIROps.cpp
+++ b/flang/lib/Optimizer/HLFIR/IR/HLFIROps.cpp
@@ -1115,7 +1115,7 @@ mlir::LogicalResult
 hlfir::MatmulOp::canonicalize(MatmulOp matmulOp,
   mlir::PatternRewriter &rewriter) {
   // the only two uses of the transposed matrix should be for the hlfir.matmul
-  // and hlfir.destory
+  // and hlfir.destroy
   auto isOtherwiseUnused = [&](hlfir::TransposeOp transposeOp) -> bool {
 std::size_t numUses = 0;
 for (mlir::Operation *user : transposeOp.getResult().getUsers()) {
diff --git a/flang/lib/Optimizer/HLFIR/Transforms/InlineElementals.cpp 
b/flang/lib/Optimizer/HLFIR/Transforms/InlineElementals.cpp
index 06d0518763848..6c8e3e1193747 100644
--- a/flang/lib/Optimizer/HLFIR/Transforms/InlineElementals.cpp
+++ b/flang/lib/Optimizer/HLFIR/Transforms/InlineElementals.cpp
@@ -32,7 +32,7 @@ namespace hlfir {
 } // namespace hlfir
 
 /// If the elemental has only two uses and those two are an apply operation and
-/// a destory operation, return those two, otherwise return {}
+/// a destroy operation, return those two, otherwise return {}
 static std::optional>
 getTwoUses(hlfir::ElementalOp elemental) {
   mlir::Operation::user_range users = elemental->getUsers();
diff --git a/lldb/include/lldb/Target/Process.h 
b/lldb/include/lldb/Target/Process.h
index aac0cf51680a9..637d34c29715c 100644
--- a/lldb/include/lldb/Target/Process.h
+++ b/lldb/include/lldb/Target/Process.h
@@ -915,8 +915,8 @@ class Process : public 
std::enable_shared_from_this,
   /// \param[in] force_kill
   /// Whether lldb should force a kill (instead of a detach) from
   /// the inferior process.  Normally if lldb launched a binary and
-  /// Destory is called, lldb kills it.  If lldb attached to a
-  /// running process and Destory is called, lldb detaches.  If
+  /// Destroy is called, lldb kills it.  If lldb attached to a
+  /// running process and Destroy is called, lldb detaches.  If
   /// this behavior needs to be over-ridden, this is the bool that
   /// can be used.
   ///
diff --git 
a/llvm/lib/ExecutionEngine/Orc/TargetProcess/SimpleExecutorMemoryManager.cpp 
b/llvm/lib/ExecutionEngine/Orc/TargetProcess/SimpleExecutorMemoryManager.cpp
index 4da031716e32a..3cdffb8cd0615 100644
--- a/llvm/lib/ExecutionEngine/Orc/TargetProcess/SimpleExecutorMemoryManager.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/TargetProcess/SimpleExecutorMemoryManager.cpp
@@ -75,7 +75,7 @@ Error 
SimpleExecutorMemoryManager::finalize(tpctypes::FinalizeRequest &FR) {
   auto BailOut = [&](Error Err) {
 std::pair AllocToDestroy;
 
-// Get allocation to destory.
+// Get allocation to destroy.
 {
   std::lock_guard Lock(M);
   auto I = Allocations.find(Base.toPtr());
@@ -153,7 +153,7 @@ Error SimpleExecutorMemoryManager::deallocate(
   std::vector> AllocPairs;
   AllocPairs.reserve(Bases.size());
 
-  // Get allocation to destory.
+  // Get allocation to destroy.
   Error Err = Error::success();
   {
 std::lock_guard Lock(M);
diff --git a/llvm/test/Transforms/Coroutines/no-suspend.ll 
b/llvm/test/Transforms/Coroutines/no-suspend.ll
index 53eb98f1273a9..fd8c5ac990958 100644
--- a/llvm/test/Transforms/Coroutines/no-suspend.ll
+++ b/llvm/test/Transforms/Coroutines/no-suspend.ll
@@ -325,7 +325,7 @@ body:
   %save = call token @llvm.coro.save(ptr %hdl)
   %subfn = call ptr @llvm.coro.subfn.addr(ptr %hdl, i8 1)
   call fastcc void %subfn(ptr %hdl)
-  ; memcpy separates destory from suspend, therefore cannot simplify.
+  ; memcpy separates destroy from suspend, therefore cannot simplify.
   call void @llvm.memcpy.p0.p0.i64(ptr %dst, ptr %src, i64 1, i1 false)
   %0 = call i8 @llvm.coro.suspend(token %save, i1 false)
   switch i8 %0, label %suspend [i8 0, label %resume

``




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


  1   2   >