[Lldb-commits] [lldb] [LLDB] DebugInfoD tests: attempt to fix Fuchsia build (PR #96802)

2024-06-27 Thread Petr Hosek via lldb-commits

petrhosek wrote:

> > What do you mean by "normal" location?
> 
> "normal" as defined by whoever wrote Makefile.rules originally and thought 
> that was the correct place to file tools like ar and objcopy, I guess? So, on 
> your build machine, do you know where the llvm-dwp file might be installed? 
> Because honestly, I'd rather just use that thing instead of assuming the GNU 
> dwp tool is around.

It'd be right next to `clang` in the same directory.

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


[Lldb-commits] [lldb] 0ae2370 - [lldb] Do not produce field information for registers known not to exist (#95125)

2024-06-27 Thread via lldb-commits

Author: David Spickett
Date: 2024-06-27T09:26:54+01:00
New Revision: 0ae23708ef4345f0832ba4443ce7b184248b4784

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

LOG: [lldb] Do not produce field information for registers known not to exist 
(#95125)

Currently the logic is generate field information for all registers in
LinuxArm64RegisterFlags and then as we walk the existing register info,
only those that are in that existing info will get the new fields
patched in.

This works fine but on a review for FreeBSD support it was pointed out
that this is not obvious from the source code.

So instead I've allowed the construction of empty lists of fields, and
field detection methods can return an empty field list if they think
that the register will never exist.

Then the pre-existing code will see the empty field list, and never look
for that register in the register info.

I think removing the assert is ok because the GDB classes filter out
empty field lists at runtime, and anyone updating the built in field
information would presumably notice if none of the fields they intended
to add were displayed.

mte_ctrl and svcr are the only registers that need this so far.

There is no extra testing here as the behaviour is the same, it doesn't
add field information to regiters that don't exist. The mechanism is
just clearer now.

Added: 


Modified: 
lldb/source/Plugins/Process/Utility/RegisterFlagsLinux_arm64.cpp
lldb/source/Plugins/Process/Utility/RegisterFlagsLinux_arm64.h
lldb/source/Target/RegisterFlags.cpp

Removed: 




diff  --git a/lldb/source/Plugins/Process/Utility/RegisterFlagsLinux_arm64.cpp 
b/lldb/source/Plugins/Process/Utility/RegisterFlagsLinux_arm64.cpp
index 51553817921f3..8ed75d700f225 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterFlagsLinux_arm64.cpp
+++ b/lldb/source/Plugins/Process/Utility/RegisterFlagsLinux_arm64.cpp
@@ -20,6 +20,7 @@
 #define HWCAP2_BTI (1ULL << 17)
 #define HWCAP2_MTE (1ULL << 18)
 #define HWCAP2_AFP (1ULL << 20)
+#define HWCAP2_SME (1ULL << 23)
 #define HWCAP2_EBF16 (1ULL << 32)
 
 using namespace lldb_private;
@@ -27,7 +28,10 @@ using namespace lldb_private;
 LinuxArm64RegisterFlags::Fields
 LinuxArm64RegisterFlags::DetectSVCRFields(uint64_t hwcap, uint64_t hwcap2) {
   (void)hwcap;
-  (void)hwcap2;
+
+  if (!(hwcap2 & HWCAP2_SME))
+return {};
+
   // Represents the pseudo register that lldb-server builds, which itself
   // matches the architectural register SCVR. The fields match SVCR in the Arm
   // manual.
@@ -40,7 +44,10 @@ LinuxArm64RegisterFlags::DetectSVCRFields(uint64_t hwcap, 
uint64_t hwcap2) {
 LinuxArm64RegisterFlags::Fields
 LinuxArm64RegisterFlags::DetectMTECtrlFields(uint64_t hwcap, uint64_t hwcap2) {
   (void)hwcap;
-  (void)hwcap2;
+
+  if (!(hwcap2 & HWCAP2_MTE))
+return {};
+
   // Represents the contents of NT_ARM_TAGGED_ADDR_CTRL and the value passed
   // to prctl(PR_TAGGED_ADDR_CTRL...). Fields are derived from the defines
   // used to build the value.

diff  --git a/lldb/source/Plugins/Process/Utility/RegisterFlagsLinux_arm64.h 
b/lldb/source/Plugins/Process/Utility/RegisterFlagsLinux_arm64.h
index 660bef08700f4..49b1d90db64f6 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterFlagsLinux_arm64.h
+++ b/lldb/source/Plugins/Process/Utility/RegisterFlagsLinux_arm64.h
@@ -38,8 +38,8 @@ class LinuxArm64RegisterFlags {
   /// For the registers listed in this class, detect which fields are
   /// present. Must be called before UpdateRegisterInfos.
   /// If called more than once, fields will be redetected each time from
-  /// scratch. If you do not have access to hwcap, just pass 0 for each one, 
you
-  /// will only get unconditional fields.
+  /// scratch. If the target would not have this register at all, the list of
+  /// fields will be left empty.
   void DetectFields(uint64_t hwcap, uint64_t hwcap2);
 
   /// Add the field information of any registers named in this class,
@@ -63,7 +63,7 @@ class LinuxArm64RegisterFlags {
 
   struct RegisterEntry {
 RegisterEntry(llvm::StringRef name, unsigned size, DetectorFn detector)
-: m_name(name), m_flags(std::string(name) + "_flags", size, {{"", 0}}),
+: m_name(name), m_flags(std::string(name) + "_flags", size, {}),
   m_detector(detector) {}
 
 llvm::StringRef m_name;

diff  --git a/lldb/source/Target/RegisterFlags.cpp 
b/lldb/source/Target/RegisterFlags.cpp
index d2fc5392f1a76..476150251221a 100644
--- a/lldb/source/Target/RegisterFlags.cpp
+++ b/lldb/source/Target/RegisterFlags.cpp
@@ -108,10 +108,6 @@ uint64_t RegisterFlags::Field::GetMask() const {
 }
 
 void RegisterFlags::SetFields(const std::vector &fields) {
-  // We expect that the XML processor will discard anything describing flags 
but
-  // with no fi

[Lldb-commits] [lldb] [lldb] Do not produce field information for registers known not to exist (PR #95125)

2024-06-27 Thread David Spickett via lldb-commits

https://github.com/DavidSpickett closed 
https://github.com/llvm/llvm-project/pull/95125
___
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 (#70392) (PR #96868)

2024-06-27 Thread Med Ismail Bennani via lldb-commits

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

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.

>From 10b0387a1d0413c280b4a9ab779c838769d058d1 Mon Sep 17 00:00:00 2001
From: Med Ismail Bennani 
Date: Thu, 27 Jun 2024 01:29:24 -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.

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

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   | 101 ++-
 .../functionalities/step_scripted/Steps.py|   4 +-
 .../thread_plan/wrap_step_over.py |   2 +-
 .../Python/PythonTestSuite.cpp|  50 +++---
 25 files changed, 471 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

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

2024-06-27 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.

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

---

Patch is 60.58 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/96868.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 (+58-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 bd3de8ce5d46c..7915f7c4b2076 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::LLDBSwigPythonCreateScriptedThreadPl

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

2024-06-27 Thread via lldb-commits

Author: Med Ismail Bennani
Date: 2024-06-27T01:45:30-07:00
New Revision: 9a9ec228cdcf75d01be82be5be13e1542f0fc75d

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

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

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 bd3de8ce5d46c..7915f7c4b2076 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::strin

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

2024-06-27 Thread Med Ismail Bennani via lldb-commits

https://github.com/medismailben closed 
https://github.com/llvm/llvm-project/pull/96868
___
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 (#70392) (PR #96868)

2024-06-27 Thread LLVM Continuous Integration via lldb-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `lldb-x86_64-debian` 
running on `lldb-x86_64-debian` while building `lldb` at step 6 "test".

Full details are available at: 
https://lab.llvm.org/buildbot/#/builders/162/builds/851

Here is the relevant piece of the build log for the reference:
```
Step 6 (test) failure: build (failure)
...
PASS: lldb-api :: functionalities/postmortem/mach-core/TestMachCore.py (578 of 
2617)
PASS: lldb-api :: 
functionalities/thread/concurrent_events/TestConcurrentNWatchNBreak.py (579 of 
2617)
PASS: lldb-api :: 
functionalities/tail_call_frames/unambiguous_sequence/TestUnambiguousTailCalls.py
 (580 of 2617)
PASS: lldb-api :: 
functionalities/thread/concurrent_events/TestConcurrentBreakpointDelayBreakpointOneSignal.py
 (581 of 2617)
PASS: lldb-api :: 
functionalities/thread/concurrent_events/TestConcurrentBreakpointsDelayedBreakpointOneWatchpoint.py
 (582 of 2617)
PASS: lldb-api :: 
functionalities/thread/concurrent_events/TestConcurrentBreakpointOneDelayBreakpointThreads.py
 (583 of 2617)
XFAIL: lldb-api :: 
functionalities/thread/break_after_join/TestBreakAfterJoin.py (584 of 2617)
PASS: lldb-api :: functionalities/inline-stepping/TestInlineStepping.py (585 of 
2617)
PASS: lldb-api :: functionalities/step-avoids-no-debug/TestStepNoDebug.py (586 
of 2617)
PASS: lldb-api :: functionalities/inferior-assert/TestInferiorAssert.py (587 of 
2617)
FAIL: lldb-api :: functionalities/step_scripted/TestStepScripted.py (588 of 
2617)
 TEST 'lldb-api :: 
functionalities/step_scripted/TestStepScripted.py' FAILED 
Script:
--
/usr/bin/python3 
/home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/test/API/dotest.py -u 
CXXFLAGS -u CFLAGS --env ARCHIVER=/usr/bin/ar --env OBJCOPY=/usr/bin/objcopy 
--env LLVM_LIBS_DIR=/home/worker/2.0.1/lldb-x86_64-debian/build/./lib --env 
LLVM_INCLUDE_DIR=/home/worker/2.0.1/lldb-x86_64-debian/build/include --env 
LLVM_TOOLS_DIR=/home/worker/2.0.1/lldb-x86_64-debian/build/./bin --arch x86_64 
--build-dir /home/worker/2.0.1/lldb-x86_64-debian/build/lldb-test-build.noindex 
--lldb-module-cache-dir 
/home/worker/2.0.1/lldb-x86_64-debian/build/lldb-test-build.noindex/module-cache-lldb/lldb-api
 --clang-module-cache-dir 
/home/worker/2.0.1/lldb-x86_64-debian/build/lldb-test-build.noindex/module-cache-clang/lldb-api
 --executable /home/worker/2.0.1/lldb-x86_64-debian/build/./bin/lldb --compiler 
/home/worker/2.0.1/lldb-x86_64-debian/build/./bin/clang --dsymutil 
/home/worker/2.0.1/lldb-x86_64-debian/build/./bin/dsymutil --llvm-tools-dir 
/home/worker/2.0.1/lldb-x86_64-debian/build/./bin --lldb-obj-root 
/home/worker/2.0.1/lldb-x86_64-debian/build/tools/lldb --lldb-libs-dir 
/home/worker/2.0.1/lldb-x86_64-debian/build/./lib -t 
/home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/test/API/functionalities/step_scripted
 -p TestStepScripted.py
--
Exit Code: 1

Command Output (stdout):
--
lldb version 19.0.0git (https://github.com/llvm/llvm-project.git revision 
9a9ec228cdcf75d01be82be5be13e1542f0fc75d)
  clang revision 9a9ec228cdcf75d01be82be5be13e1542f0fc75d
  llvm revision 9a9ec228cdcf75d01be82be5be13e1542f0fc75d
Skipping the following test categories: ['libc++', 'dsym', 'gmodules', 
'debugserver', 'objc']
thread step-scripted -C Steps.StepReportsStopOthers -k token -v 140471925396160 
--run-mode all-threads
{'140471925396160': False}
thread step-scripted -C Steps.StepReportsStopOthers -k token -v 140471925396160 
--run-mode this-thread
{'140471925396160': True}
thread step-scripted -C Steps.StepReportsStopOthers -k token -v 140471925396160
{'140471925396160': True}
thread step-scripted -C Steps.StepReportsStopOthers -k token -v 140471925396160
{'140471925396160': False}

--
Command Output (stderr):
--
Change dir to: 
/home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/test/API/functionalities/step_scripted
runCmd: settings clear -all

output: 

runCmd: settings set symbols.enable-external-lookup false

output: 

runCmd: settings set target.inherit-tcc true

output: 


```

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


[Lldb-commits] [lldb] [lldb] Parse and display register field enums (PR #95768)

2024-06-27 Thread David Spickett via lldb-commits

DavidSpickett wrote:

I'm going to land this now but I can fix up the map type later.

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


[Lldb-commits] [lldb] ba60d8a - [lldb] Parse and display register field enums (#95768)

2024-06-27 Thread via lldb-commits

Author: David Spickett
Date: 2024-06-27T10:03:06+01:00
New Revision: ba60d8a11af2cdd7e80e2fd968cdf52adcabf5a1

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

LOG: [lldb] Parse and display register field enums (#95768)

This teaches lldb to parse the enum XML elements sent by lldb-server,
and make use of the information in `register read` and `register info`.

The format is described in

https://sourceware.org/gdb/current/onlinedocs/gdb.html/Enum-Target-Types.html.

The target XML parser will drop any invalid enum or evalue. If we find
multiple evalue for the same value, we will use the last one we find.

The order of evalues from the XML is preserved as there may be good
reason they are not in numerical order.

Added: 


Modified: 
lldb/include/lldb/Target/RegisterFlags.h
lldb/source/Core/DumpRegisterInfo.cpp
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
lldb/source/Plugins/RegisterTypeBuilder/RegisterTypeBuilderClang.cpp
lldb/source/Target/RegisterFlags.cpp
lldb/test/API/functionalities/gdb_remote_client/TestXMLRegisterFlags.py
lldb/unittests/Core/DumpRegisterInfoTest.cpp

Removed: 




diff  --git a/lldb/include/lldb/Target/RegisterFlags.h 
b/lldb/include/lldb/Target/RegisterFlags.h
index 1112972cf72e1..1250fd0330958 100644
--- a/lldb/include/lldb/Target/RegisterFlags.h
+++ b/lldb/include/lldb/Target/RegisterFlags.h
@@ -32,10 +32,15 @@ class FieldEnum {
 : m_value(value), m_name(std::move(name)) {}
 
 void ToXML(Stream &strm) const;
+
+void DumpToLog(Log *log) const;
   };
 
   typedef std::vector Enumerators;
 
+  // GDB also includes a "size" that is the size of the underlying register.
+  // We will not store that here but instead use the size of the register
+  // this gets attached to when emitting XML.
   FieldEnum(std::string id, const Enumerators &enumerators);
 
   const Enumerators &GetEnumerators() const { return m_enumerators; }
@@ -44,6 +49,8 @@ class FieldEnum {
 
   void ToXML(Stream &strm, unsigned size) const;
 
+  void DumpToLog(Log *log) const;
+
 private:
   std::string m_id;
   Enumerators m_enumerators;

diff  --git a/lldb/source/Core/DumpRegisterInfo.cpp 
b/lldb/source/Core/DumpRegisterInfo.cpp
index 8334795416902..eccc6784cd497 100644
--- a/lldb/source/Core/DumpRegisterInfo.cpp
+++ b/lldb/source/Core/DumpRegisterInfo.cpp
@@ -111,6 +111,11 @@ void lldb_private::DoDumpRegisterInfo(
   };
   DumpList(strm, "In sets: ", in_sets, emit_set);
 
-  if (flags_type)
+  if (flags_type) {
 strm.Printf("\n\n%s", flags_type->AsTable(terminal_width).c_str());
+
+std::string enumerators = flags_type->DumpEnums(terminal_width);
+if (enumerators.size())
+  strm << "\n\n" << enumerators;
+  }
 }

diff  --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp 
b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index 43c61fc9df6e4..3195587eb5676 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -4179,21 +4179,134 @@ struct GdbServerTargetInfo {
   RegisterSetMap reg_set_map;
 };
 
-static std::vector ParseFlagsFields(XMLNode flags_node,
-  unsigned size) {
+static FieldEnum::Enumerators ParseEnumEvalues(const XMLNode &enum_node) {
+  Log *log(GetLog(GDBRLog::Process));
+  // We will use the last instance of each value. Also we preserve the order
+  // of declaration in the XML, as it may not be numerical.
+  // For example, hardware may intially release with two states that softwware
+  // can read from a register field:
+  // 0 = startup, 1 = running
+  // If in a future hardware release, the designers added a pre-startup state:
+  // 0 = startup, 1 = running, 2 = pre-startup
+  // Now it makes more sense to list them in this logical order as opposed to
+  // numerical order:
+  // 2 = pre-startup, 1 = startup, 0 = startup
+  // This only matters for "register info" but let's trust what the server
+  // chose regardless.
+  std::map enumerators;
+
+  enum_node.ForEachChildElementWithName(
+  "evalue", [&enumerators, &log](const XMLNode &enumerator_node) {
+std::optional name;
+std::optional value;
+
+enumerator_node.ForEachAttribute(
+[&name, &value, &log](const llvm::StringRef &attr_name,
+  const llvm::StringRef &attr_value) {
+  if (attr_name == "name") {
+if (attr_value.size())
+  name = attr_value;
+else
+  LLDB_LOG(log, "ProcessGDBRemote::ParseEnumEvalues "
+"Ignoring empty name in evalu

[Lldb-commits] [lldb] [lldb] Parse and display register field enums (PR #95768)

2024-06-27 Thread David Spickett via lldb-commits

https://github.com/DavidSpickett closed 
https://github.com/llvm/llvm-project/pull/95768
___
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-06-27 Thread David Spickett via lldb-commits

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

>From 33b750696a5958ae13420796e82fb9f5b2ea8fa9 Mon Sep 17 00:00:00 2001
From: David Spickett 
Date: Mon, 4 Mar 2024 14:31:40 +
Subject: [PATCH] [lldb][FreeBSD][AArch64] Enable register field detection

This extends the existing register fields support from AArch64 Linux
to AArch64 FreeBSD. So you will now see output like this:
```
(lldb) register read cpsr
cpsr = 0x6200
 = (N = 0, Z = 1, C = 1, V = 0, DIT = 0, SS = 0, IL = 0, SSBS = 0, D = 
1, A = 0, I = 0, F = 0, nRW = 0, EL = 0, SP = 0)
```

Linux and FreeBSD both have HWCAP/HWCAP2 so the detection mechanism
is the same and I've renamed the detector class to reflect that.

I have confirmed that FreeBSD's treatment of CPSR (spsr as the kernel
calls it) is similair enough that we can use the same field information.

(see `sys/arm64/include/armreg.h` and `PSR_SETTABLE_64`)

For testing I've enabled the same live process test as Linux
and added a shell test using an existing FreeBSD core file.

Note that the latter does not need XML support because when reading
a core file we are not sending the information via target.xml,
it's just internal to LLDB.
---
 .../FreeBSD/NativeRegisterContextFreeBSD.h|  5 ++-
 .../NativeRegisterContextFreeBSD_arm.cpp  |  4 +--
 .../NativeRegisterContextFreeBSD_arm64.cpp| 24 +++--
 .../NativeRegisterContextFreeBSD_arm64.h  |  2 +-
 .../NativeRegisterContextFreeBSD_mips64.cpp   |  4 +--
 .../NativeRegisterContextFreeBSD_powerpc.cpp  |  4 +--
 .../NativeRegisterContextFreeBSD_x86_64.cpp   |  4 +--
 .../Process/FreeBSD/NativeThreadFreeBSD.cpp   |  4 +++
 .../Process/FreeBSD/NativeThreadFreeBSD.h |  2 ++
 .../NativeRegisterContextLinux_arm64.cpp  | 16 -
 .../Plugins/Process/Utility/CMakeLists.txt|  2 +-
 ...64.cpp => RegisterFlagsDetector_arm64.cpp} | 36 ++-
 ..._arm64.h => RegisterFlagsDetector_arm64.h} | 16 -
 .../RegisterContextPOSIXCore_arm64.cpp| 18 +-
 .../elf-core/RegisterContextPOSIXCore_arm64.h |  4 +--
 .../register_command/TestRegisters.py |  2 +-
 .../Core/aarch64-freebsd-register-fields.test | 15 
 llvm/docs/ReleaseNotes.rst|  3 ++
 .../source/Plugins/Process/Utility/BUILD.gn   |  2 +-
 19 files changed, 107 insertions(+), 60 deletions(-)
 rename lldb/source/Plugins/Process/Utility/{RegisterFlagsLinux_arm64.cpp => 
RegisterFlagsDetector_arm64.cpp} (85%)
 rename lldb/source/Plugins/Process/Utility/{RegisterFlagsLinux_arm64.h => 
RegisterFlagsDetector_arm64.h} (85%)
 create mode 100644 
lldb/test/Shell/Register/Core/aarch64-freebsd-register-fields.test

diff --git a/lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD.h 
b/lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD.h
index 484beac999..b7f659ef24de2c 100644
--- a/lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD.h
+++ b/lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD.h
@@ -9,14 +9,13 @@
 #ifndef lldb_NativeRegisterContextFreeBSD_h
 #define lldb_NativeRegisterContextFreeBSD_h
 
-#include "lldb/Host/common/NativeThreadProtocol.h"
-
 #include "Plugins/Process/Utility/NativeRegisterContextRegisterInfo.h"
 
 namespace lldb_private {
 namespace process_freebsd {
 
 class NativeProcessFreeBSD;
+class NativeThreadFreeBSD;
 
 class NativeRegisterContextFreeBSD
 : public virtual NativeRegisterContextRegisterInfo {
@@ -28,7 +27,7 @@ class NativeRegisterContextFreeBSD
   // executable.
   static NativeRegisterContextFreeBSD *
   CreateHostNativeRegisterContextFreeBSD(const ArchSpec &target_arch,
- NativeThreadProtocol &native_thread);
+ NativeThreadFreeBSD &native_thread);
   virtual llvm::Error
   CopyHardwareWatchpointsFrom(NativeRegisterContextFreeBSD &source) = 0;
 
diff --git 
a/lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_arm.cpp 
b/lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_arm.cpp
index 2c50176643878d..f19085600d6c93 100644
--- a/lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_arm.cpp
+++ b/lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_arm.cpp
@@ -29,12 +29,12 @@ using namespace lldb_private::process_freebsd;
 
 NativeRegisterContextFreeBSD *
 NativeRegisterContextFreeBSD::CreateHostNativeRegisterContextFreeBSD(
-const ArchSpec &target_arch, NativeThreadProtocol &native_thread) {
+const ArchSpec &target_arch, NativeThreadFreeBSD &native_thread) {
   return new NativeRegisterContextFreeBSD_arm(target_arch, native_thread);
 }
 
 NativeRegisterContextFreeBSD_arm::NativeRegisterContextFreeBSD_arm(
-const ArchSpec &target_arch, NativeThreadProtocol &native_thread)
+const ArchSpec &target_arch, NativeThreadFreeBSD &native_thread)
 : NativeRegisterContextRegisterInfo(
   native_thread, new RegisterInfo

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

2024-06-27 Thread David Spickett via lldb-commits

DavidSpickett wrote:

https://github.com/llvm/llvm-project/pull/95125 has now landed, so this PR is 
just the new changes.

@zxombie we now check the HWCAP to see if the register exists at all, and only 
if it does, generate field information. What do you think to the changes as 
they are now?

Anyone want to review from a general lldb point of view? Perhaps @bulbazord ?

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][AArch64] Add register field enum information (PR #96887)

2024-06-27 Thread David Spickett via lldb-commits

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

This enables XML output for enums and adds enums for 2 fields on AArch64:
* mte_ctrl.tcf, which controls how tag faults are delivered.
* fpcr.rmode, which sets the rounding mode for floating point operations.

The other one we could do is cpsr.btype, but it is not clear what would be 
useful here so I'm not including it in this change.

>From 9d0eae62a8977a2c6be1250dac1f2533ba27ce48 Mon Sep 17 00:00:00 2001
From: David Spickett 
Date: Mon, 11 Mar 2024 10:56:50 +
Subject: [PATCH] [lldb][AArch64] Add register field enum information

This enables XML output for enums and adds enums for 2 fields
on AArch64:
* mte_ctrl.tcf, which controls how tag faults are delivered.
* fpcr.rmode, which sets the rounding mode for floating point operations.

The other one we could do is cpsr.btype, but it is not
clear what would be useful here so I'm not including it
in this change.
---
 .../Process/Utility/RegisterFlagsLinux_arm64.cpp| 13 ++---
 .../gdb-remote/GDBRemoteCommunicationServerLLGS.cpp |  2 ++
 .../register/register_command/TestRegisters.py  |  8 +++-
 .../postmortem/elf-core/TestLinuxCore.py|  7 ++-
 .../TestAArch64LinuxMTEMemoryTagCoreFile.py | 13 ++---
 5 files changed, 35 insertions(+), 8 deletions(-)

diff --git a/lldb/source/Plugins/Process/Utility/RegisterFlagsLinux_arm64.cpp 
b/lldb/source/Plugins/Process/Utility/RegisterFlagsLinux_arm64.cpp
index 8ed75d700f225..1242948bcb89e 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterFlagsLinux_arm64.cpp
+++ b/lldb/source/Plugins/Process/Utility/RegisterFlagsLinux_arm64.cpp
@@ -51,16 +51,23 @@ LinuxArm64RegisterFlags::DetectMTECtrlFields(uint64_t 
hwcap, uint64_t hwcap2) {
   // Represents the contents of NT_ARM_TAGGED_ADDR_CTRL and the value passed
   // to prctl(PR_TAGGED_ADDR_CTRL...). Fields are derived from the defines
   // used to build the value.
+
+  static const FieldEnum tcf_enum(
+  "tcf_enum",
+  {{0, "TCF_NONE"}, {1, "TCF_SYNC"}, {2, "TCF_ASYNC"}, {3, "TCF_ASYMM"}});
   return {{"TAGS", 3, 18}, // 16 bit bitfield shifted up by PR_MTE_TAG_SHIFT.
-  {"TCF_ASYNC", 2},
-  {"TCF_SYNC", 1},
+  {"TCF", 1, 2, &tcf_enum},
   {"TAGGED_ADDR_ENABLE", 0}};
 }
 
 LinuxArm64RegisterFlags::Fields
 LinuxArm64RegisterFlags::DetectFPCRFields(uint64_t hwcap, uint64_t hwcap2) {
+
+  static const FieldEnum rmode_enum(
+  "rmode_enum", {{0, "RN"}, {1, "RP"}, {2, "RM"}, {3, "RZ"}});
+
   std::vector fpcr_fields{
-  {"AHP", 26}, {"DN", 25}, {"FZ", 24}, {"RMode", 22, 23},
+  {"AHP", 26}, {"DN", 25}, {"FZ", 24}, {"RMode", 22, 23, &rmode_enum},
   // Bits 21-20 are "Stride" which is unused in AArch64 state.
   };
 
diff --git 
a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
index ae1a77e5be832..08d5f5039d516 100644
--- 
a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
+++ 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
@@ -3083,6 +3083,7 @@ GDBRemoteCommunicationServerLLGS::BuildTargetXml() {
   if (registers_count)
 response.IndentMore();
 
+  llvm::StringSet<> field_enums_seen;
   for (int reg_index = 0; reg_index < registers_count; reg_index++) {
 const RegisterInfo *reg_info =
 reg_context.GetRegisterInfoAtIndex(reg_index);
@@ -3096,6 +3097,7 @@ GDBRemoteCommunicationServerLLGS::BuildTargetXml() {
 
 if (reg_info->flags_type) {
   response.IndentMore();
+  reg_info->flags_type->EnumsToXML(response, field_enums_seen);
   reg_info->flags_type->ToXML(response);
   response.IndentLess();
 }
diff --git 
a/lldb/test/API/commands/register/register/register_command/TestRegisters.py 
b/lldb/test/API/commands/register/register/register_command/TestRegisters.py
index 5c4f3a4bb374c..921fed1082980 100644
--- a/lldb/test/API/commands/register/register/register_command/TestRegisters.py
+++ b/lldb/test/API/commands/register/register/register_command/TestRegisters.py
@@ -632,7 +632,13 @@ def test_register_read_fields(self):
 self.expect("register read fpsr", substrs=["= (QC = 0, IDC = 0, IXC = 
0"])
 # AHP/DN/FZ/RMode always present, others may vary.
 self.expect(
-"register read fpcr", substrs=["= (AHP = 0, DN = 0, FZ = 0, RMode 
= 0"]
+"register read fpcr", substrs=["= (AHP = 0, DN = 0, FZ = 0, RMode 
= RN"]
+)
+
+# Should get enumerator descriptions for RMode.
+self.expect(
+"register info fpcr",
+substrs=["RMode: 0 = RN, 1 = RP, 2 = RM, 3 = RZ"],
 )
 
 @skipUnlessPlatform(["linux"])
diff --git a/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py 
b/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py
index 1eaaa87d3b87d..0afac26367de0 100644

[Lldb-commits] [lldb] [lldb][AArch64] Add register field enum information (PR #96887)

2024-06-27 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: David Spickett (DavidSpickett)


Changes

This enables XML output for enums and adds enums for 2 fields on AArch64:
* mte_ctrl.tcf, which controls how tag faults are delivered.
* fpcr.rmode, which sets the rounding mode for floating point operations.

The other one we could do is cpsr.btype, but it is not clear what would be 
useful here so I'm not including it in this change.

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


5 Files Affected:

- (modified) lldb/source/Plugins/Process/Utility/RegisterFlagsLinux_arm64.cpp 
(+10-3) 
- (modified) 
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp 
(+2) 
- (modified) 
lldb/test/API/commands/register/register/register_command/TestRegisters.py 
(+7-1) 
- (modified) lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py 
(+6-1) 
- (modified) 
lldb/test/API/linux/aarch64/mte_core_file/TestAArch64LinuxMTEMemoryTagCoreFile.py
 (+10-3) 


``diff
diff --git a/lldb/source/Plugins/Process/Utility/RegisterFlagsLinux_arm64.cpp 
b/lldb/source/Plugins/Process/Utility/RegisterFlagsLinux_arm64.cpp
index 8ed75d700f225..1242948bcb89e 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterFlagsLinux_arm64.cpp
+++ b/lldb/source/Plugins/Process/Utility/RegisterFlagsLinux_arm64.cpp
@@ -51,16 +51,23 @@ LinuxArm64RegisterFlags::DetectMTECtrlFields(uint64_t 
hwcap, uint64_t hwcap2) {
   // Represents the contents of NT_ARM_TAGGED_ADDR_CTRL and the value passed
   // to prctl(PR_TAGGED_ADDR_CTRL...). Fields are derived from the defines
   // used to build the value.
+
+  static const FieldEnum tcf_enum(
+  "tcf_enum",
+  {{0, "TCF_NONE"}, {1, "TCF_SYNC"}, {2, "TCF_ASYNC"}, {3, "TCF_ASYMM"}});
   return {{"TAGS", 3, 18}, // 16 bit bitfield shifted up by PR_MTE_TAG_SHIFT.
-  {"TCF_ASYNC", 2},
-  {"TCF_SYNC", 1},
+  {"TCF", 1, 2, &tcf_enum},
   {"TAGGED_ADDR_ENABLE", 0}};
 }
 
 LinuxArm64RegisterFlags::Fields
 LinuxArm64RegisterFlags::DetectFPCRFields(uint64_t hwcap, uint64_t hwcap2) {
+
+  static const FieldEnum rmode_enum(
+  "rmode_enum", {{0, "RN"}, {1, "RP"}, {2, "RM"}, {3, "RZ"}});
+
   std::vector fpcr_fields{
-  {"AHP", 26}, {"DN", 25}, {"FZ", 24}, {"RMode", 22, 23},
+  {"AHP", 26}, {"DN", 25}, {"FZ", 24}, {"RMode", 22, 23, &rmode_enum},
   // Bits 21-20 are "Stride" which is unused in AArch64 state.
   };
 
diff --git 
a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
index ae1a77e5be832..08d5f5039d516 100644
--- 
a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
+++ 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
@@ -3083,6 +3083,7 @@ GDBRemoteCommunicationServerLLGS::BuildTargetXml() {
   if (registers_count)
 response.IndentMore();
 
+  llvm::StringSet<> field_enums_seen;
   for (int reg_index = 0; reg_index < registers_count; reg_index++) {
 const RegisterInfo *reg_info =
 reg_context.GetRegisterInfoAtIndex(reg_index);
@@ -3096,6 +3097,7 @@ GDBRemoteCommunicationServerLLGS::BuildTargetXml() {
 
 if (reg_info->flags_type) {
   response.IndentMore();
+  reg_info->flags_type->EnumsToXML(response, field_enums_seen);
   reg_info->flags_type->ToXML(response);
   response.IndentLess();
 }
diff --git 
a/lldb/test/API/commands/register/register/register_command/TestRegisters.py 
b/lldb/test/API/commands/register/register/register_command/TestRegisters.py
index 5c4f3a4bb374c..921fed1082980 100644
--- a/lldb/test/API/commands/register/register/register_command/TestRegisters.py
+++ b/lldb/test/API/commands/register/register/register_command/TestRegisters.py
@@ -632,7 +632,13 @@ def test_register_read_fields(self):
 self.expect("register read fpsr", substrs=["= (QC = 0, IDC = 0, IXC = 
0"])
 # AHP/DN/FZ/RMode always present, others may vary.
 self.expect(
-"register read fpcr", substrs=["= (AHP = 0, DN = 0, FZ = 0, RMode 
= 0"]
+"register read fpcr", substrs=["= (AHP = 0, DN = 0, FZ = 0, RMode 
= RN"]
+)
+
+# Should get enumerator descriptions for RMode.
+self.expect(
+"register info fpcr",
+substrs=["RMode: 0 = RN, 1 = RP, 2 = RM, 3 = RZ"],
 )
 
 @skipUnlessPlatform(["linux"])
diff --git a/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py 
b/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py
index 1eaaa87d3b87d..0afac26367de0 100644
--- a/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py
+++ b/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py
@@ -583,7 +583,12 @@ def test_aarch64_sve_regs_full(self):
 self.expect("register read fpsr", substrs=["= (QC = 0, IDC = 0, IXC = 
0"])
 # AHP/DN/FZ/RMode always present, others may 

[Lldb-commits] [clang] [lldb] [clang][lldb] Don't assert structure layout correctness for layouts provided by LLDB (PR #93809)

2024-06-27 Thread Michael Buch via lldb-commits

Michael137 wrote:

> Here's the smallest patch that would put explicit alignment on any packed 
> structure:
> 
> ```
> diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
> b/clang/lib/CodeGen/CGDebugInfo.cpp
> index a072475ba770..bbb13ddd593b 100644
> --- a/clang/lib/CodeGen/CGDebugInfo.cpp
> +++ b/clang/lib/CodeGen/CGDebugInfo.cpp
> @@ -64,7 +64,7 @@ static uint32_t getTypeAlignIfRequired(const Type *Ty, 
> const ASTContext &Ctx) {
>// MaxFieldAlignmentAttr is the attribute added to types
>// declared after #pragma pack(n).
>if (auto *Decl = Ty->getAsRecordDecl())
> -if (Decl->hasAttr())
> +if (Decl->hasAttr() || 
> Decl->hasAttr())
>return TI.Align;
>  
>return 0;
> ```
> 
> But I don't think that's the right approach - I think what we should do is 
> compute the natural alignment of the structure, then compare that to the 
> actual alignment - and if they differ, we should put an explicit alignment on 
> the structure. This avoids the risk that other alignment-influencing effects 
> might be missed (and avoids the case of putting alignment on a structure 
> that, when packed, just has the same alignment anyway - which is a minor 
> issue, but nice to get right (eg: packed struct of a single char probably 
> shouldn't have an explicit alignment - since it's the same as the implicit 
> alignment anyway))

Thanks for the analysis! If we can emit alignment for packed attributes 
consistently then we probably can get rid of most of the `InferAlignment` logic 
in the `RecordLayoutBuilder` (it seems to me most of that logic was put 
introduced there for the purpose of packed structs), which would address the 
issue I saw with laying out `[[no_unique_address]]` fields. Trying this now

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


[Lldb-commits] [lldb] [lldb][AArch64] Add register field enum information (PR #96887)

2024-06-27 Thread David Spickett via lldb-commits

DavidSpickett wrote:

This is in theory the last patch for this series, but depending on 
https://github.com/llvm/llvm-project/pull/90059 the format might change 
slightly. So I'm going to add a release note after that's sorted.

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


[Lldb-commits] [lldb] [lldb][AArch64] Add register field enum information (PR #96887)

2024-06-27 Thread David Spickett via lldb-commits

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


[Lldb-commits] [lldb] 0cb748b - [lldb][test] Refactor no target XML test

2024-06-27 Thread David Spickett via lldb-commits

Author: David Spickett
Date: 2024-06-27T10:39:56Z
New Revision: 0cb748b9ba7cea72bee1bcf7c94f26c646053bb1

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

LOG: [lldb][test] Refactor no target XML test

To make it more easy to check a bug later.

Added: 


Modified: 
lldb/test/API/functionalities/gdb_remote_client/TestGDBServerNoTargetXML.py

Removed: 




diff  --git 
a/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerNoTargetXML.py 
b/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerNoTargetXML.py
index 5f6ed7d537af1..8c5bad007f569 100644
--- 
a/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerNoTargetXML.py
+++ 
b/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerNoTargetXML.py
@@ -1,3 +1,12 @@
+"""
+Check that lldb falls back to default register layouts when the remote provides
+no target XML.
+
+GPRS are passed to the responder to create register data to send back to lldb.
+Registers in SUPPL are virtual registers based on those general ones. The tests
+pass __file__ to FileCheck so any prefixes in this Python file will be checked.
+"""
+
 import lldb
 from lldbsuite.test.lldbtest import *
 from lldbsuite.test.decorators import *
@@ -6,14 +15,29 @@
 
 import binascii
 
-
-class TestGDBServerTargetXML(GDBRemoteTestBase):
+class MyResponder(MockGDBServerResponder):
 @staticmethod
 def filecheck_to_blob(fc):
 for l in fc.strip().splitlines():
 val = l.split("0x")[1]
 yield 
binascii.b2a_hex(bytes(reversed(binascii.a2b_hex(val.decode()
 
+def __init__(self, reg_data, halt_reason):
+super().__init__()
+self.reg_data = "".join(self.filecheck_to_blob(reg_data))
+self.halt_reason = halt_reason
+
+def readRegister(self, regnum):
+return ""
+
+def readRegisters(self):
+return self.reg_data
+
+def haltReason(self):
+return self.halt_reason
+
+
+class TestGDBServerTargetXML(GDBRemoteTestBase):
 @skipIfRemote
 @skipIfLLVMTargetMissing("X86")
 def test_x86_64_regs(self):
@@ -100,19 +124,10 @@ def test_x86_64_regs(self):
 CHECK-AMD64-DAG: r15l = 0xf1
 """
 
-class MyResponder(MockGDBServerResponder):
-reg_data = "".join(self.filecheck_to_blob(GPRS))
-
-def readRegister(self, regnum):
-return ""
-
-def readRegisters(self):
-return self.reg_data
-
-def haltReason(self):
-return 
"T02thread:1ff0d;threads:1ff0d;thread-pcs:00010001bc00;07:0102030405060708;10:1112131415161718;"
-
-self.server.responder = MyResponder()
+self.server.responder = MyResponder(
+GPRS,
+
"T02thread:1ff0d;threads:1ff0d;thread-pcs:00010001bc00;07:0102030405060708;10:1112131415161718;",
+)
 
 target = self.createTarget("basic_eh_frame.yaml")
 process = self.connect(target)
@@ -216,19 +231,10 @@ def test_aarch64_regs(self):
 CHECK-AARCH64-DAG: w31 = 0x23242526
 """
 
-class MyResponder(MockGDBServerResponder):
-reg_data = "".join(self.filecheck_to_blob(GPRS))
-
-def readRegister(self, regnum):
-return ""
-
-def readRegisters(self):
-return self.reg_data
-
-def haltReason(self):
-return 
"T02thread:1ff0d;threads:1ff0d;thread-pcs:00010001bc00;07:0102030405060708;10:1112131415161718;"
-
-self.server.responder = MyResponder()
+self.server.responder = MyResponder(
+GPRS,
+
"T02thread:1ff0d;threads:1ff0d;thread-pcs:00010001bc00;07:0102030405060708;10:1112131415161718;",
+)
 
 target = self.createTarget("basic_eh_frame-aarch64.yaml")
 process = self.connect(target)
@@ -300,19 +306,10 @@ def test_i386_regs(self):
 CHECK-I386-DAG: dil = 0x71
 """
 
-class MyResponder(MockGDBServerResponder):
-reg_data = "".join(self.filecheck_to_blob(GPRS))
-
-def readRegister(self, regnum):
-return ""
-
-def readRegisters(self):
-return self.reg_data
-
-def haltReason(self):
-return 
"T02thread:1ff0d;threads:1ff0d;thread-pcs:00010001bc00;07:0102030405060708;10:1112131415161718;"
-
-self.server.responder = MyResponder()
+self.server.responder = MyResponder(
+GPRS,
+
"T02thread:1ff0d;threads:1ff0d;thread-pcs:00010001bc00;07:0102030405060708;10:1112131415161718;",
+)
 
 target = self.createTarget("basic_eh_frame-i386.yaml")
 process = self.connect(target)



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
h

[Lldb-commits] [lldb] [lldb/test] Mark TestStepScripted.py as XFAIL temporarily (PR #96894)

2024-06-27 Thread Med Ismail Bennani via lldb-commits

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

After landing 9a9ec228cdcf, some of the `TestStepScripted.py` methods started 
failing on various bots:

- https://lab.llvm.org/buildbot/#/builders/162/builds/851
- https://lab.llvm.org/buildbot/#/builders/59/builds/650
- https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/as-lldb-cmake/6546/
- https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/lldb-cmake/3359/

Since I'm not able to reproduce the test failure locally (tested on darwin 
x86_64/arm64 & linux arm64), I'll mark these as XFAIL until I can reproduce the 
failure or attach to a bot to investigate the issue there directly.

>From 64cb1fc5f5f4fc3ec0a1b8a7e1e51877e938b7ef Mon Sep 17 00:00:00 2001
From: Med Ismail Bennani 
Date: Thu, 27 Jun 2024 03:38:52 -0700
Subject: [PATCH] [lldb/test] Mark TestStepScripted.py as XFAIL temporarily

After landing 9a9ec228cdcf, some of the `TestStepScripted.py` methods
started failing on various bots.

Since I'm not able to reproduce the test failure locally (tested on
darwin x86_64/arm64 & linux arm64), I'll mark these as XFAIL until I can
reproduce the failure or attach to a bot to investigate the issue there
directly.

Signed-off-by: Med Ismail Bennani 
---
 .../API/functionalities/step_scripted/TestStepScripted.py   | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/lldb/test/API/functionalities/step_scripted/TestStepScripted.py 
b/lldb/test/API/functionalities/step_scripted/TestStepScripted.py
index 53901718019f9..7a4992abd8fcb 100644
--- a/lldb/test/API/functionalities/step_scripted/TestStepScripted.py
+++ b/lldb/test/API/functionalities/step_scripted/TestStepScripted.py
@@ -7,7 +7,6 @@
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
 
-
 class StepScriptedTestCase(TestBase):
 NO_DEBUG_INFO_TESTCASE = True
 
@@ -16,12 +15,14 @@ def setUp(self):
 self.main_source_file = lldb.SBFileSpec("main.c")
 self.runCmd("command script import Steps.py")
 
+@expectedFailureAll()
 def test_standard_step_out(self):
 """Tests stepping with the scripted thread plan laying over a standard
 thread plan for stepping out."""
 self.build()
 self.step_out_with_scripted_plan("Steps.StepOut")
 
+@expectedFailureAll()
 def test_scripted_step_out(self):
 """Tests stepping with the scripted thread plan laying over an another
 scripted thread plan for stepping out."""
@@ -44,6 +45,7 @@ def step_out_with_scripted_plan(self, name):
 stop_desc = thread.GetStopDescription(1000)
 self.assertIn("Stepping out from", stop_desc, "Got right description")
 
+@expectedFailureAll()
 def test_misspelled_plan_name(self):
 """Test that we get a useful error if we misspell the plan class 
name"""
 self.build()
@@ -62,10 +64,12 @@ def test_misspelled_plan_name(self):
 # Make sure we didn't let the process run:
 self.assertEqual(stop_id, process.GetStopID(), "Process didn't run")
 
+@expectedFailureAll()
 def test_checking_variable(self):
 """Test that we can call SBValue API's from a scripted thread plan - 
using SBAPI's to step"""
 self.do_test_checking_variable(False)
 
+@expectedFailureAll()
 def test_checking_variable_cli(self):
 """Test that we can call SBValue API's from a scripted thread plan - 
using cli to step"""
 self.do_test_checking_variable(True)

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


[Lldb-commits] [lldb] [lldb/test] Mark TestStepScripted.py as XFAIL temporarily (PR #96894)

2024-06-27 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Med Ismail Bennani (medismailben)


Changes

After landing 9a9ec228cdcf, some of the `TestStepScripted.py` methods started 
failing on various bots:

- https://lab.llvm.org/buildbot/#/builders/162/builds/851
- https://lab.llvm.org/buildbot/#/builders/59/builds/650
- https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/as-lldb-cmake/6546/
- https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/lldb-cmake/3359/

Since I'm not able to reproduce the test failure locally (tested on darwin 
x86_64/arm64 & linux arm64), I'll mark these as XFAIL until I can reproduce 
the failure or attach to a bot to investigate the issue there directly.

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


1 Files Affected:

- (modified) lldb/test/API/functionalities/step_scripted/TestStepScripted.py 
(+5-1) 


``diff
diff --git a/lldb/test/API/functionalities/step_scripted/TestStepScripted.py 
b/lldb/test/API/functionalities/step_scripted/TestStepScripted.py
index 53901718019f9..7a4992abd8fcb 100644
--- a/lldb/test/API/functionalities/step_scripted/TestStepScripted.py
+++ b/lldb/test/API/functionalities/step_scripted/TestStepScripted.py
@@ -7,7 +7,6 @@
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
 
-
 class StepScriptedTestCase(TestBase):
 NO_DEBUG_INFO_TESTCASE = True
 
@@ -16,12 +15,14 @@ def setUp(self):
 self.main_source_file = lldb.SBFileSpec("main.c")
 self.runCmd("command script import Steps.py")
 
+@expectedFailureAll()
 def test_standard_step_out(self):
 """Tests stepping with the scripted thread plan laying over a standard
 thread plan for stepping out."""
 self.build()
 self.step_out_with_scripted_plan("Steps.StepOut")
 
+@expectedFailureAll()
 def test_scripted_step_out(self):
 """Tests stepping with the scripted thread plan laying over an another
 scripted thread plan for stepping out."""
@@ -44,6 +45,7 @@ def step_out_with_scripted_plan(self, name):
 stop_desc = thread.GetStopDescription(1000)
 self.assertIn("Stepping out from", stop_desc, "Got right description")
 
+@expectedFailureAll()
 def test_misspelled_plan_name(self):
 """Test that we get a useful error if we misspell the plan class 
name"""
 self.build()
@@ -62,10 +64,12 @@ def test_misspelled_plan_name(self):
 # Make sure we didn't let the process run:
 self.assertEqual(stop_id, process.GetStopID(), "Process didn't run")
 
+@expectedFailureAll()
 def test_checking_variable(self):
 """Test that we can call SBValue API's from a scripted thread plan - 
using SBAPI's to step"""
 self.do_test_checking_variable(False)
 
+@expectedFailureAll()
 def test_checking_variable_cli(self):
 """Test that we can call SBValue API's from a scripted thread plan - 
using cli to step"""
 self.do_test_checking_variable(True)

``




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


[Lldb-commits] [lldb] [lldb/test] Mark TestStepScripted.py as XFAIL temporarily (PR #96894)

2024-06-27 Thread Med Ismail Bennani via lldb-commits

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


[Lldb-commits] [lldb] 204c403 - [lldb/test] Mark TestStepScripted.py as XFAIL temporarily (#96894)

2024-06-27 Thread via lldb-commits

Author: Med Ismail Bennani
Date: 2024-06-27T03:45:38-07:00
New Revision: 204c403b5215197ecdbdb68ca7f11402d6d9892b

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

LOG: [lldb/test] Mark TestStepScripted.py as XFAIL temporarily (#96894)

After landing 9a9ec228cdcf, some of the `TestStepScripted.py` methods
started failing on various bots:

- https://lab.llvm.org/buildbot/#/builders/162/builds/851
- https://lab.llvm.org/buildbot/#/builders/59/builds/650
-
https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/as-lldb-cmake/6546/
- https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/lldb-cmake/3359/

Since I'm not able to reproduce the test failure locally (tested on
darwin x86_64/arm64 & linux arm64), I'll mark these as XFAIL until I can
reproduce it or attach to a bot to investigate the issue on it directly.

Signed-off-by: Med Ismail Bennani 

Added: 


Modified: 
lldb/test/API/functionalities/step_scripted/TestStepScripted.py

Removed: 




diff  --git a/lldb/test/API/functionalities/step_scripted/TestStepScripted.py 
b/lldb/test/API/functionalities/step_scripted/TestStepScripted.py
index 53901718019f9..7a4992abd8fcb 100644
--- a/lldb/test/API/functionalities/step_scripted/TestStepScripted.py
+++ b/lldb/test/API/functionalities/step_scripted/TestStepScripted.py
@@ -7,7 +7,6 @@
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
 
-
 class StepScriptedTestCase(TestBase):
 NO_DEBUG_INFO_TESTCASE = True
 
@@ -16,12 +15,14 @@ def setUp(self):
 self.main_source_file = lldb.SBFileSpec("main.c")
 self.runCmd("command script import Steps.py")
 
+@expectedFailureAll()
 def test_standard_step_out(self):
 """Tests stepping with the scripted thread plan laying over a standard
 thread plan for stepping out."""
 self.build()
 self.step_out_with_scripted_plan("Steps.StepOut")
 
+@expectedFailureAll()
 def test_scripted_step_out(self):
 """Tests stepping with the scripted thread plan laying over an another
 scripted thread plan for stepping out."""
@@ -44,6 +45,7 @@ def step_out_with_scripted_plan(self, name):
 stop_desc = thread.GetStopDescription(1000)
 self.assertIn("Stepping out from", stop_desc, "Got right description")
 
+@expectedFailureAll()
 def test_misspelled_plan_name(self):
 """Test that we get a useful error if we misspell the plan class 
name"""
 self.build()
@@ -62,10 +64,12 @@ def test_misspelled_plan_name(self):
 # Make sure we didn't let the process run:
 self.assertEqual(stop_id, process.GetStopID(), "Process didn't run")
 
+@expectedFailureAll()
 def test_checking_variable(self):
 """Test that we can call SBValue API's from a scripted thread plan - 
using SBAPI's to step"""
 self.do_test_checking_variable(False)
 
+@expectedFailureAll()
 def test_checking_variable_cli(self):
 """Test that we can call SBValue API's from a scripted thread plan - 
using cli to step"""
 self.do_test_checking_variable(True)



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


[Lldb-commits] [lldb] [lldb/test] Mark TestStepScripted.py as XFAIL temporarily (PR #96894)

2024-06-27 Thread Med Ismail Bennani via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Support new libc++ __compressed_pair layout (PR #96538)

2024-06-27 Thread Michael Buch via lldb-commits

https://github.com/Michael137 updated 
https://github.com/llvm/llvm-project/pull/96538

>From 3b4d9629a68c9e75dfd139ee2745bf00db979ecd Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Mon, 29 Jan 2024 16:23:16 +
Subject: [PATCH 1/2] [lldb] Support new libc++ __compressed_pair layout

This patch is in preparation for the `__compressed_pair`
refactor in https://github.com/llvm/llvm-project/pull/76756.

This gets the formatter tests to at least pass.

Currently in draft because there's still some cleanup to be done.
---
 lldb/examples/synthetic/libcxx.py | 26 --
 .../Plugins/Language/CPlusPlus/LibCxx.cpp | 61 ++
 .../Plugins/Language/CPlusPlus/LibCxxList.cpp | 83 ---
 .../Plugins/Language/CPlusPlus/LibCxxMap.cpp  | 68 +++
 .../Language/CPlusPlus/LibCxxUnorderedMap.cpp | 73 +++-
 .../Language/CPlusPlus/LibCxxVector.cpp   | 40 +
 .../list/TestDataFormatterGenericList.py  |  3 +-
 .../libcxx/string/simulator/main.cpp  |  1 +
 .../TestDataFormatterLibcxxUniquePtr.py   |  7 +-
 9 files changed, 256 insertions(+), 106 deletions(-)

diff --git a/lldb/examples/synthetic/libcxx.py 
b/lldb/examples/synthetic/libcxx.py
index 474aaa428fa23..060ff90100849 100644
--- a/lldb/examples/synthetic/libcxx.py
+++ b/lldb/examples/synthetic/libcxx.py
@@ -721,6 +721,12 @@ def _get_value_of_compressed_pair(self, pair):
 def update(self):
 logger = lldb.formatters.Logger.Logger()
 try:
+has_compressed_pair_layout = True
+alloc_valobj = self.valobj.GetChildMemberWithName("__alloc_")
+size_valobj = self.valobj.GetChildMemberWithName("__size_")
+if alloc_valobj.IsValid() and size_valobj.IsValid():
+has_compressed_pair_layout = False
+
 # A deque is effectively a two-dim array, with fixed width.
 # 'map' contains pointers to the rows of this array. The
 # full memory area allocated by the deque is delimited
@@ -734,9 +740,13 @@ def update(self):
 # variable tells which element in this NxM array is the 0th
 # one, and the 'size' element gives the number of elements
 # in the deque.
-count = self._get_value_of_compressed_pair(
-self.valobj.GetChildMemberWithName("__size_")
-)
+if has_compressed_pair_layout:
+count = self._get_value_of_compressed_pair(
+self.valobj.GetChildMemberWithName("__size_")
+)
+else:
+count = size_valobj.GetValueAsUnsigned(0)
+
 # give up now if we cant access memory reliably
 if self.block_size < 0:
 logger.write("block_size < 0")
@@ -748,9 +758,13 @@ def update(self):
 self.map_begin = map_.GetChildMemberWithName("__begin_")
 map_begin = self.map_begin.GetValueAsUnsigned(0)
 map_end = 
map_.GetChildMemberWithName("__end_").GetValueAsUnsigned(0)
-map_endcap = self._get_value_of_compressed_pair(
-map_.GetChildMemberWithName("__end_cap_")
-)
+
+if has_compressed_pair_layout:
+map_endcap = self._get_value_of_compressed_pair(
+map_.GetChildMemberWithName("__end_cap_")
+)
+else:
+map_endcap = 
map_.GetChildMemberWithName("__end_cap_").GetValueAsUnsigned(0)
 
 # check consistency
 if not map_first <= map_begin <= map_end <= map_endcap:
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
index b0e6fb7d6f5af..928b790317b6e 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
@@ -27,6 +27,7 @@
 #include "Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.h"
 #include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
 #include "lldb/lldb-enumerations.h"
+#include "lldb/lldb-forward.h"
 #include 
 #include 
 
@@ -176,9 +177,9 @@ bool 
lldb_private::formatters::LibcxxUniquePointerSummaryProvider(
   if (!ptr_sp)
 return false;
 
-  ptr_sp = GetFirstValueOfLibCXXCompressedPair(*ptr_sp);
-  if (!ptr_sp)
-return false;
+  if (ValueObjectSP compressed_pair_value__sp =
+  GetFirstValueOfLibCXXCompressedPair(*ptr_sp))
+ptr_sp = std::move(compressed_pair_value__sp);
 
   if (ptr_sp->GetValueAsUnsigned(0) == 0) {
 stream.Printf("nullptr");
@@ -701,15 +702,28 @@ 
lldb_private::formatters::LibcxxUniquePtrSyntheticFrontEnd::Update() {
   if (!ptr_sp)
 return lldb::ChildCacheState::eRefetch;
 
+  bool has_compressed_pair_layout = true;
+  ValueObjectSP deleter_sp(valobj_sp->GetChildMemberWithName("__deleter_"));
+  if (deleter_sp)
+has_compressed_pair_layout = false;
+
   // Retrieve the actual pointer and the deleter, and clone them to give them
   // user-friendly na

[Lldb-commits] [lldb] [lldb] Don't call AddRemoteRegisters if the target XML did not include any registers (PR #96907)

2024-06-27 Thread David Spickett via lldb-commits

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

Fixes #92541

When e69a3d18f48bc0d81b5dd12e735a2ec898ce64d added fallback register layouts, 
it assumed that the choices were target XML with registers, or no target XML at 
all.

In the linked issue, a user has a debug stub that does have target XML, but 
it's missing register information.

This caused us to finalize the register information using an empty set of 
registers got from target XML, then fail an assert when we attempted to add the 
fallback set. Since we think we've already completed the register information.

This change adds a check to prevent that first call and expands the existing 
tests to check each architecture without target XML and with target XML missing 
register information.

>From 25905a0f01c126dbebc854affd30d9ff838f259b Mon Sep 17 00:00:00 2001
From: David Spickett 
Date: Thu, 27 Jun 2024 10:55:28 +
Subject: [PATCH] [lldb] Don't call AddRemoteRegisters if the target XML did
 not include any registers

Fixes #92541

When e69a3d18f48bc0d81b5dd12e735a2ec898ce64d added fallback register layouts,
it assumed that the choices were target XML with registers, or no target XML
at all.

In the linked issue, a user has a debug stub that does have target XML,
but it's missing register information.

This caused us to finalize the register information using an empty set
of registers got from target XML, then fail an assert when we attempted to add
the fallback set. Since we think we've already completed the register
information.

This change adds a check to prevent that first call and expands the
existing tests to check each archictecture without target XML and
with target XML missing register information.
---
 .../Process/gdb-remote/ProcessGDBRemote.cpp   |  4 +-
 lldb/source/Target/DynamicRegisterInfo.cpp|  1 +
 ...y => TestGDBServerNoTargetXMLRegisters.py} | 78 +++
 3 files changed, 69 insertions(+), 14 deletions(-)
 rename 
lldb/test/API/functionalities/gdb_remote_client/{TestGDBServerNoTargetXML.py => 
TestGDBServerNoTargetXMLRegisters.py} (82%)

diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp 
b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index 3195587eb5676..7f1ce2303cde6 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -4879,7 +4879,9 @@ bool ProcessGDBRemote::GetGDBServerRegisterInfo(ArchSpec 
&arch_to_use) {
   m_registers_enum_types.clear();
   std::vector registers;
   if (GetGDBServerRegisterInfoXMLAndProcess(arch_to_use, "target.xml",
-registers))
+registers) &&
+  // Target XML is not required to include register information.
+  (!registers.empty()))
 AddRemoteRegisters(registers, arch_to_use);
 
   return m_register_info_sp->GetNumRegisters() > 0;
diff --git a/lldb/source/Target/DynamicRegisterInfo.cpp 
b/lldb/source/Target/DynamicRegisterInfo.cpp
index 1a817449fa958..48f9a49f8d45a 100644
--- a/lldb/source/Target/DynamicRegisterInfo.cpp
+++ b/lldb/source/Target/DynamicRegisterInfo.cpp
@@ -437,6 +437,7 @@ size_t DynamicRegisterInfo::SetRegisterInfo(
 }
 
 void DynamicRegisterInfo::Finalize(const ArchSpec &arch) {
+  printf("DynamicRegisterInfo::Finalize\n");
   if (m_finalized)
 return;
 
diff --git 
a/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerNoTargetXML.py 
b/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerNoTargetXMLRegisters.py
similarity index 82%
rename from 
lldb/test/API/functionalities/gdb_remote_client/TestGDBServerNoTargetXML.py
rename to 
lldb/test/API/functionalities/gdb_remote_client/TestGDBServerNoTargetXMLRegisters.py
index 8c5bad007f569..7557c8108439f 100644
--- 
a/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerNoTargetXML.py
+++ 
b/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerNoTargetXMLRegisters.py
@@ -1,6 +1,6 @@
 """
 Check that lldb falls back to default register layouts when the remote provides
-no target XML.
+no target XML or does not include registers in the target XML.
 
 GPRS are passed to the responder to create register data to send back to lldb.
 Registers in SUPPL are virtual registers based on those general ones. The tests
@@ -14,6 +14,7 @@
 from lldbsuite.test.lldbgdbclient import GDBRemoteTestBase
 
 import binascii
+from textwrap import dedent
 
 class MyResponder(MockGDBServerResponder):
 @staticmethod
@@ -22,8 +23,10 @@ def filecheck_to_blob(fc):
 val = l.split("0x")[1]
 yield 
binascii.b2a_hex(bytes(reversed(binascii.a2b_hex(val.decode()
 
-def __init__(self, reg_data, halt_reason):
+def __init__(self, architecture, has_target_xml, reg_data, halt_reason):
 super().__init__()
+self.architecture = architecture
+self.has_target_xml = has_target_xml
 self.reg_data =

[Lldb-commits] [lldb] [lldb] Don't call AddRemoteRegisters if the target XML did not include any registers (PR #96907)

2024-06-27 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: David Spickett (DavidSpickett)


Changes

Fixes #92541

When e69a3d18f48bc0d81b5dd12e735a2ec898ce64d added fallback register layouts, 
it assumed that the choices were target XML with registers, or no target XML at 
all.

In the linked issue, a user has a debug stub that does have target XML, but 
it's missing register information.

This caused us to finalize the register information using an empty set of 
registers got from target XML, then fail an assert when we attempted to add the 
fallback set. Since we think we've already completed the register information.

This change adds a check to prevent that first call and expands the existing 
tests to check each architecture without target XML and with target XML missing 
register information.

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


3 Files Affected:

- (modified) lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (+3-1) 
- (modified) lldb/source/Target/DynamicRegisterInfo.cpp (+1) 
- (renamed) 
lldb/test/API/functionalities/gdb_remote_client/TestGDBServerNoTargetXMLRegisters.py
 (+65-13) 


``diff
diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp 
b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index 3195587eb5676..7f1ce2303cde6 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -4879,7 +4879,9 @@ bool ProcessGDBRemote::GetGDBServerRegisterInfo(ArchSpec 
&arch_to_use) {
   m_registers_enum_types.clear();
   std::vector registers;
   if (GetGDBServerRegisterInfoXMLAndProcess(arch_to_use, "target.xml",
-registers))
+registers) &&
+  // Target XML is not required to include register information.
+  (!registers.empty()))
 AddRemoteRegisters(registers, arch_to_use);
 
   return m_register_info_sp->GetNumRegisters() > 0;
diff --git a/lldb/source/Target/DynamicRegisterInfo.cpp 
b/lldb/source/Target/DynamicRegisterInfo.cpp
index 1a817449fa958..48f9a49f8d45a 100644
--- a/lldb/source/Target/DynamicRegisterInfo.cpp
+++ b/lldb/source/Target/DynamicRegisterInfo.cpp
@@ -437,6 +437,7 @@ size_t DynamicRegisterInfo::SetRegisterInfo(
 }
 
 void DynamicRegisterInfo::Finalize(const ArchSpec &arch) {
+  printf("DynamicRegisterInfo::Finalize\n");
   if (m_finalized)
 return;
 
diff --git 
a/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerNoTargetXML.py 
b/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerNoTargetXMLRegisters.py
similarity index 82%
rename from 
lldb/test/API/functionalities/gdb_remote_client/TestGDBServerNoTargetXML.py
rename to 
lldb/test/API/functionalities/gdb_remote_client/TestGDBServerNoTargetXMLRegisters.py
index 8c5bad007f569..7557c8108439f 100644
--- 
a/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerNoTargetXML.py
+++ 
b/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerNoTargetXMLRegisters.py
@@ -1,6 +1,6 @@
 """
 Check that lldb falls back to default register layouts when the remote provides
-no target XML.
+no target XML or does not include registers in the target XML.
 
 GPRS are passed to the responder to create register data to send back to lldb.
 Registers in SUPPL are virtual registers based on those general ones. The tests
@@ -14,6 +14,7 @@
 from lldbsuite.test.lldbgdbclient import GDBRemoteTestBase
 
 import binascii
+from textwrap import dedent
 
 class MyResponder(MockGDBServerResponder):
 @staticmethod
@@ -22,8 +23,10 @@ def filecheck_to_blob(fc):
 val = l.split("0x")[1]
 yield 
binascii.b2a_hex(bytes(reversed(binascii.a2b_hex(val.decode()
 
-def __init__(self, reg_data, halt_reason):
+def __init__(self, architecture, has_target_xml, reg_data, halt_reason):
 super().__init__()
+self.architecture = architecture
+self.has_target_xml = has_target_xml
 self.reg_data = "".join(self.filecheck_to_blob(reg_data))
 self.halt_reason = halt_reason
 
@@ -36,13 +39,19 @@ def readRegisters(self):
 def haltReason(self):
 return self.halt_reason
 
+def qXferRead(self, obj, annex, offset, length):
+if self.has_target_xml and annex == "target.xml":
+return dedent(f"""\
+  
+  
+{self.architecture}
+  """), False
+
+return None, False
 
-class TestGDBServerTargetXML(GDBRemoteTestBase):
-@skipIfRemote
-@skipIfLLVMTargetMissing("X86")
-def test_x86_64_regs(self):
-"""Test grabbing various x86_64 registers from gdbserver."""
 
+class TestGDBServerTargetXML(GDBRemoteTestBase):
+def check_x86_64_regs(self, has_target_xml):
 GPRS = """
 CHECK-AMD64-DAG: rax = 0x0807060504030201
 CHECK-AMD64-DAG: rbx = 0x1817161514131211
@@ -125,6 +134,8 @@ def test_x86_64_regs(self):
 """
 
 self.serve

[Lldb-commits] [lldb] [lldb] Don't call AddRemoteRegisters if the target XML did not include any registers (PR #96907)

2024-06-27 Thread via lldb-commits

github-actions[bot] wrote:




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



You can test this locally with the following command:


``bash
darker --check --diff -r 
e9b8cd0c806db00f0981fb36717077c941426302...25905a0f01c126dbebc854affd30d9ff838f259b
 
lldb/test/API/functionalities/gdb_remote_client/TestGDBServerNoTargetXMLRegisters.py
``





View the diff from darker here.


``diff
--- TestGDBServerNoTargetXMLRegisters.py2024-06-27 13:12:32.00 +
+++ TestGDBServerNoTargetXMLRegisters.py2024-06-27 13:39:18.296302 +
@@ -13,10 +13,11 @@
 from lldbsuite.test.gdbclientutils import *
 from lldbsuite.test.lldbgdbclient import GDBRemoteTestBase
 
 import binascii
 from textwrap import dedent
+
 
 class MyResponder(MockGDBServerResponder):
 @staticmethod
 def filecheck_to_blob(fc):
 for l in fc.strip().splitlines():
@@ -39,16 +40,21 @@
 def haltReason(self):
 return self.halt_reason
 
 def qXferRead(self, obj, annex, offset, length):
 if self.has_target_xml and annex == "target.xml":
-return dedent(f"""\
+return (
+dedent(
+f"""\
   
   
 {self.architecture}
-  """), False
-
+  """
+),
+False,
+)
+
 return None, False
 
 
 class TestGDBServerTargetXML(GDBRemoteTestBase):
 def check_x86_64_regs(self, has_target_xml):
@@ -369,15 +375,15 @@
 
 @skipIfRemote
 @skipIfLLVMTargetMissing("X86")
 def test_i386_regs_no_target_xml(self):
 """Test grabbing various i386 registers from gdbserver when there is
-   no target XML."""
+no target XML."""
 self.check_i386_regs(False)
 
 @skipIfXmlSupportMissing
 @skipIfRemote
 @skipIfLLVMTargetMissing("X86")
 def test_i386_regs_no_register_info(self):
 """Test grabbing various i386 registers from gdbserver when there is
-   target XML but it does not include register info."""
+target XML but it does not include register info."""
 self.check_i386_regs(True)

``




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


[Lldb-commits] [lldb] [lldb] Don't call AddRemoteRegisters if the target XML did not include any registers (PR #96907)

2024-06-27 Thread David Spickett via lldb-commits

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

>From 25905a0f01c126dbebc854affd30d9ff838f259b Mon Sep 17 00:00:00 2001
From: David Spickett 
Date: Thu, 27 Jun 2024 10:55:28 +
Subject: [PATCH 1/2] [lldb] Don't call AddRemoteRegisters if the target XML
 did not include any registers

Fixes #92541

When e69a3d18f48bc0d81b5dd12e735a2ec898ce64d added fallback register layouts,
it assumed that the choices were target XML with registers, or no target XML
at all.

In the linked issue, a user has a debug stub that does have target XML,
but it's missing register information.

This caused us to finalize the register information using an empty set
of registers got from target XML, then fail an assert when we attempted to add
the fallback set. Since we think we've already completed the register
information.

This change adds a check to prevent that first call and expands the
existing tests to check each archictecture without target XML and
with target XML missing register information.
---
 .../Process/gdb-remote/ProcessGDBRemote.cpp   |  4 +-
 lldb/source/Target/DynamicRegisterInfo.cpp|  1 +
 ...y => TestGDBServerNoTargetXMLRegisters.py} | 78 +++
 3 files changed, 69 insertions(+), 14 deletions(-)
 rename 
lldb/test/API/functionalities/gdb_remote_client/{TestGDBServerNoTargetXML.py => 
TestGDBServerNoTargetXMLRegisters.py} (82%)

diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp 
b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index 3195587eb5676..7f1ce2303cde6 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -4879,7 +4879,9 @@ bool ProcessGDBRemote::GetGDBServerRegisterInfo(ArchSpec 
&arch_to_use) {
   m_registers_enum_types.clear();
   std::vector registers;
   if (GetGDBServerRegisterInfoXMLAndProcess(arch_to_use, "target.xml",
-registers))
+registers) &&
+  // Target XML is not required to include register information.
+  (!registers.empty()))
 AddRemoteRegisters(registers, arch_to_use);
 
   return m_register_info_sp->GetNumRegisters() > 0;
diff --git a/lldb/source/Target/DynamicRegisterInfo.cpp 
b/lldb/source/Target/DynamicRegisterInfo.cpp
index 1a817449fa958..48f9a49f8d45a 100644
--- a/lldb/source/Target/DynamicRegisterInfo.cpp
+++ b/lldb/source/Target/DynamicRegisterInfo.cpp
@@ -437,6 +437,7 @@ size_t DynamicRegisterInfo::SetRegisterInfo(
 }
 
 void DynamicRegisterInfo::Finalize(const ArchSpec &arch) {
+  printf("DynamicRegisterInfo::Finalize\n");
   if (m_finalized)
 return;
 
diff --git 
a/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerNoTargetXML.py 
b/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerNoTargetXMLRegisters.py
similarity index 82%
rename from 
lldb/test/API/functionalities/gdb_remote_client/TestGDBServerNoTargetXML.py
rename to 
lldb/test/API/functionalities/gdb_remote_client/TestGDBServerNoTargetXMLRegisters.py
index 8c5bad007f569..7557c8108439f 100644
--- 
a/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerNoTargetXML.py
+++ 
b/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerNoTargetXMLRegisters.py
@@ -1,6 +1,6 @@
 """
 Check that lldb falls back to default register layouts when the remote provides
-no target XML.
+no target XML or does not include registers in the target XML.
 
 GPRS are passed to the responder to create register data to send back to lldb.
 Registers in SUPPL are virtual registers based on those general ones. The tests
@@ -14,6 +14,7 @@
 from lldbsuite.test.lldbgdbclient import GDBRemoteTestBase
 
 import binascii
+from textwrap import dedent
 
 class MyResponder(MockGDBServerResponder):
 @staticmethod
@@ -22,8 +23,10 @@ def filecheck_to_blob(fc):
 val = l.split("0x")[1]
 yield 
binascii.b2a_hex(bytes(reversed(binascii.a2b_hex(val.decode()
 
-def __init__(self, reg_data, halt_reason):
+def __init__(self, architecture, has_target_xml, reg_data, halt_reason):
 super().__init__()
+self.architecture = architecture
+self.has_target_xml = has_target_xml
 self.reg_data = "".join(self.filecheck_to_blob(reg_data))
 self.halt_reason = halt_reason
 
@@ -36,13 +39,19 @@ def readRegisters(self):
 def haltReason(self):
 return self.halt_reason
 
+def qXferRead(self, obj, annex, offset, length):
+if self.has_target_xml and annex == "target.xml":
+return dedent(f"""\
+  
+  
+{self.architecture}
+  """), False
+
+return None, False
 
-class TestGDBServerTargetXML(GDBRemoteTestBase):
-@skipIfRemote
-@skipIfLLVMTargetMissing("X86")
-def test_x86_64_regs(self):
-"""Test grabbing various x86_64 registers from gdbserver."""
 
+class TestGDBServerTargetXML(GDBRemot

[Lldb-commits] [lldb] [lldb] Don't call AddRemoteRegisters if the target XML did not include any registers (PR #96907)

2024-06-27 Thread David Spickett via lldb-commits

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

>From 25905a0f01c126dbebc854affd30d9ff838f259b Mon Sep 17 00:00:00 2001
From: David Spickett 
Date: Thu, 27 Jun 2024 10:55:28 +
Subject: [PATCH 1/3] [lldb] Don't call AddRemoteRegisters if the target XML
 did not include any registers

Fixes #92541

When e69a3d18f48bc0d81b5dd12e735a2ec898ce64d added fallback register layouts,
it assumed that the choices were target XML with registers, or no target XML
at all.

In the linked issue, a user has a debug stub that does have target XML,
but it's missing register information.

This caused us to finalize the register information using an empty set
of registers got from target XML, then fail an assert when we attempted to add
the fallback set. Since we think we've already completed the register
information.

This change adds a check to prevent that first call and expands the
existing tests to check each archictecture without target XML and
with target XML missing register information.
---
 .../Process/gdb-remote/ProcessGDBRemote.cpp   |  4 +-
 lldb/source/Target/DynamicRegisterInfo.cpp|  1 +
 ...y => TestGDBServerNoTargetXMLRegisters.py} | 78 +++
 3 files changed, 69 insertions(+), 14 deletions(-)
 rename 
lldb/test/API/functionalities/gdb_remote_client/{TestGDBServerNoTargetXML.py => 
TestGDBServerNoTargetXMLRegisters.py} (82%)

diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp 
b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index 3195587eb5676..7f1ce2303cde6 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -4879,7 +4879,9 @@ bool ProcessGDBRemote::GetGDBServerRegisterInfo(ArchSpec 
&arch_to_use) {
   m_registers_enum_types.clear();
   std::vector registers;
   if (GetGDBServerRegisterInfoXMLAndProcess(arch_to_use, "target.xml",
-registers))
+registers) &&
+  // Target XML is not required to include register information.
+  (!registers.empty()))
 AddRemoteRegisters(registers, arch_to_use);
 
   return m_register_info_sp->GetNumRegisters() > 0;
diff --git a/lldb/source/Target/DynamicRegisterInfo.cpp 
b/lldb/source/Target/DynamicRegisterInfo.cpp
index 1a817449fa958..48f9a49f8d45a 100644
--- a/lldb/source/Target/DynamicRegisterInfo.cpp
+++ b/lldb/source/Target/DynamicRegisterInfo.cpp
@@ -437,6 +437,7 @@ size_t DynamicRegisterInfo::SetRegisterInfo(
 }
 
 void DynamicRegisterInfo::Finalize(const ArchSpec &arch) {
+  printf("DynamicRegisterInfo::Finalize\n");
   if (m_finalized)
 return;
 
diff --git 
a/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerNoTargetXML.py 
b/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerNoTargetXMLRegisters.py
similarity index 82%
rename from 
lldb/test/API/functionalities/gdb_remote_client/TestGDBServerNoTargetXML.py
rename to 
lldb/test/API/functionalities/gdb_remote_client/TestGDBServerNoTargetXMLRegisters.py
index 8c5bad007f569..7557c8108439f 100644
--- 
a/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerNoTargetXML.py
+++ 
b/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerNoTargetXMLRegisters.py
@@ -1,6 +1,6 @@
 """
 Check that lldb falls back to default register layouts when the remote provides
-no target XML.
+no target XML or does not include registers in the target XML.
 
 GPRS are passed to the responder to create register data to send back to lldb.
 Registers in SUPPL are virtual registers based on those general ones. The tests
@@ -14,6 +14,7 @@
 from lldbsuite.test.lldbgdbclient import GDBRemoteTestBase
 
 import binascii
+from textwrap import dedent
 
 class MyResponder(MockGDBServerResponder):
 @staticmethod
@@ -22,8 +23,10 @@ def filecheck_to_blob(fc):
 val = l.split("0x")[1]
 yield 
binascii.b2a_hex(bytes(reversed(binascii.a2b_hex(val.decode()
 
-def __init__(self, reg_data, halt_reason):
+def __init__(self, architecture, has_target_xml, reg_data, halt_reason):
 super().__init__()
+self.architecture = architecture
+self.has_target_xml = has_target_xml
 self.reg_data = "".join(self.filecheck_to_blob(reg_data))
 self.halt_reason = halt_reason
 
@@ -36,13 +39,19 @@ def readRegisters(self):
 def haltReason(self):
 return self.halt_reason
 
+def qXferRead(self, obj, annex, offset, length):
+if self.has_target_xml and annex == "target.xml":
+return dedent(f"""\
+  
+  
+{self.architecture}
+  """), False
+
+return None, False
 
-class TestGDBServerTargetXML(GDBRemoteTestBase):
-@skipIfRemote
-@skipIfLLVMTargetMissing("X86")
-def test_x86_64_regs(self):
-"""Test grabbing various x86_64 registers from gdbserver."""
 
+class TestGDBServerTargetXML(GDBRemot

[Lldb-commits] [lldb] [lldb] Don't call AddRemoteRegisters if the target XML did not include any registers (PR #96907)

2024-06-27 Thread David Spickett via lldb-commits

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

>From 25905a0f01c126dbebc854affd30d9ff838f259b Mon Sep 17 00:00:00 2001
From: David Spickett 
Date: Thu, 27 Jun 2024 10:55:28 +
Subject: [PATCH 1/4] [lldb] Don't call AddRemoteRegisters if the target XML
 did not include any registers

Fixes #92541

When e69a3d18f48bc0d81b5dd12e735a2ec898ce64d added fallback register layouts,
it assumed that the choices were target XML with registers, or no target XML
at all.

In the linked issue, a user has a debug stub that does have target XML,
but it's missing register information.

This caused us to finalize the register information using an empty set
of registers got from target XML, then fail an assert when we attempted to add
the fallback set. Since we think we've already completed the register
information.

This change adds a check to prevent that first call and expands the
existing tests to check each archictecture without target XML and
with target XML missing register information.
---
 .../Process/gdb-remote/ProcessGDBRemote.cpp   |  4 +-
 lldb/source/Target/DynamicRegisterInfo.cpp|  1 +
 ...y => TestGDBServerNoTargetXMLRegisters.py} | 78 +++
 3 files changed, 69 insertions(+), 14 deletions(-)
 rename 
lldb/test/API/functionalities/gdb_remote_client/{TestGDBServerNoTargetXML.py => 
TestGDBServerNoTargetXMLRegisters.py} (82%)

diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp 
b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index 3195587eb5676..7f1ce2303cde6 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -4879,7 +4879,9 @@ bool ProcessGDBRemote::GetGDBServerRegisterInfo(ArchSpec 
&arch_to_use) {
   m_registers_enum_types.clear();
   std::vector registers;
   if (GetGDBServerRegisterInfoXMLAndProcess(arch_to_use, "target.xml",
-registers))
+registers) &&
+  // Target XML is not required to include register information.
+  (!registers.empty()))
 AddRemoteRegisters(registers, arch_to_use);
 
   return m_register_info_sp->GetNumRegisters() > 0;
diff --git a/lldb/source/Target/DynamicRegisterInfo.cpp 
b/lldb/source/Target/DynamicRegisterInfo.cpp
index 1a817449fa958..48f9a49f8d45a 100644
--- a/lldb/source/Target/DynamicRegisterInfo.cpp
+++ b/lldb/source/Target/DynamicRegisterInfo.cpp
@@ -437,6 +437,7 @@ size_t DynamicRegisterInfo::SetRegisterInfo(
 }
 
 void DynamicRegisterInfo::Finalize(const ArchSpec &arch) {
+  printf("DynamicRegisterInfo::Finalize\n");
   if (m_finalized)
 return;
 
diff --git 
a/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerNoTargetXML.py 
b/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerNoTargetXMLRegisters.py
similarity index 82%
rename from 
lldb/test/API/functionalities/gdb_remote_client/TestGDBServerNoTargetXML.py
rename to 
lldb/test/API/functionalities/gdb_remote_client/TestGDBServerNoTargetXMLRegisters.py
index 8c5bad007f569..7557c8108439f 100644
--- 
a/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerNoTargetXML.py
+++ 
b/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerNoTargetXMLRegisters.py
@@ -1,6 +1,6 @@
 """
 Check that lldb falls back to default register layouts when the remote provides
-no target XML.
+no target XML or does not include registers in the target XML.
 
 GPRS are passed to the responder to create register data to send back to lldb.
 Registers in SUPPL are virtual registers based on those general ones. The tests
@@ -14,6 +14,7 @@
 from lldbsuite.test.lldbgdbclient import GDBRemoteTestBase
 
 import binascii
+from textwrap import dedent
 
 class MyResponder(MockGDBServerResponder):
 @staticmethod
@@ -22,8 +23,10 @@ def filecheck_to_blob(fc):
 val = l.split("0x")[1]
 yield 
binascii.b2a_hex(bytes(reversed(binascii.a2b_hex(val.decode()
 
-def __init__(self, reg_data, halt_reason):
+def __init__(self, architecture, has_target_xml, reg_data, halt_reason):
 super().__init__()
+self.architecture = architecture
+self.has_target_xml = has_target_xml
 self.reg_data = "".join(self.filecheck_to_blob(reg_data))
 self.halt_reason = halt_reason
 
@@ -36,13 +39,19 @@ def readRegisters(self):
 def haltReason(self):
 return self.halt_reason
 
+def qXferRead(self, obj, annex, offset, length):
+if self.has_target_xml and annex == "target.xml":
+return dedent(f"""\
+  
+  
+{self.architecture}
+  """), False
+
+return None, False
 
-class TestGDBServerTargetXML(GDBRemoteTestBase):
-@skipIfRemote
-@skipIfLLVMTargetMissing("X86")
-def test_x86_64_regs(self):
-"""Test grabbing various x86_64 registers from gdbserver."""
 
+class TestGDBServerTargetXML(GDBRemot

[Lldb-commits] [lldb] 5da6f64 - [lldb] Un-XFAIL TestStepScripted.test_misspelled_plan_name

2024-06-27 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2024-06-27T16:00:34+02:00
New Revision: 5da6f64db3184be89ee8b7cca4e5e055baaef964

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

LOG: [lldb] Un-XFAIL TestStepScripted.test_misspelled_plan_name

XFAIL in #96894 was too wide. This one actually passes.

Added: 


Modified: 
lldb/test/API/functionalities/step_scripted/TestStepScripted.py

Removed: 




diff  --git a/lldb/test/API/functionalities/step_scripted/TestStepScripted.py 
b/lldb/test/API/functionalities/step_scripted/TestStepScripted.py
index 7a4992abd8fcb..bb7479414dbbb 100644
--- a/lldb/test/API/functionalities/step_scripted/TestStepScripted.py
+++ b/lldb/test/API/functionalities/step_scripted/TestStepScripted.py
@@ -45,7 +45,6 @@ def step_out_with_scripted_plan(self, name):
 stop_desc = thread.GetStopDescription(1000)
 self.assertIn("Stepping out from", stop_desc, "Got right description")
 
-@expectedFailureAll()
 def test_misspelled_plan_name(self):
 """Test that we get a useful error if we misspell the plan class 
name"""
 self.build()



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


[Lldb-commits] [lldb] [API] add GetSyntheticValue (PR #95959)

2024-06-27 Thread Pavel Labath via lldb-commits

labath wrote:

> Would it make more sense to make the ValueImpl that's going to represent the 
> synthetic value then check whether that really is synthetic, and return an 
> empty SBValue if it is not?

Sounds like a good idea to me.


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


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

2024-06-27 Thread Pavel Labath via lldb-commits

labath wrote:

> > It looks like the test is flaky: 
> > https://lab.llvm.org/buildbot/#/builders/59/builds/535
> > It looks like the order of the types is nondeterministic. I think you 
> > should be able to use CHECK-DAG along with [this trick to match 
> > newlines](https://llvm.org/docs/CommandGuide/FileCheck.html#matching-newline-characters)
> >  to make the test accept both orderings.
> 
> What are lldb's guarantees in this regard? Clang/LLVM/etc require 
> nondeterministic output - presumably the same would be valuable to lldb, but 
> I don't know what lldb's precedents are in this regard.

It would be useful, but we've never made a serious effort to try to achieve 
that.

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


[Lldb-commits] [lldb] 2641975 - [lldb/DWARF] Unique enums parsed from declarations (#96751)

2024-06-27 Thread via lldb-commits

Author: Pavel Labath
Date: 2024-06-27T16:36:52+02:00
New Revision: 264197516495910588d19fb19b6793e9be1bd6a3

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

LOG: [lldb/DWARF] Unique enums parsed from declarations (#96751)

This is a regression from #96484 caught by @ZequanWu.

Note that we will still create separate enum types for types parsed from
two definitions. This is different from how we handle classes, but it is
not a regression.

I'm also adding the DieToType check to the class type parsing code,
although in this case, the type uniqueness should be enforced by the
UniqueDWARFASTType map.

Added: 
lldb/test/Shell/SymbolFile/DWARF/enum-declaration-uniqueness.cpp

Modified: 
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index f36e2af9589b8..c4a3b432ba949 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -870,6 +870,13 @@ TypeSP DWARFASTParserClang::ParseEnum(const SymbolContext 
&sc,
 }
   }
   if (def_die) {
+if (auto [it, inserted] = dwarf->GetDIEToType().try_emplace(
+def_die.GetDIE(), DIE_IS_BEING_PARSED);
+!inserted) {
+  if (it->getSecond() == nullptr || it->getSecond() == DIE_IS_BEING_PARSED)
+return nullptr;
+  return it->getSecond()->shared_from_this();
+}
 attrs = ParsedDWARFTypeAttributes(def_die);
   } else {
 // No definition found. Proceed with the declaration die. We can use it to
@@ -1798,6 +1805,13 @@ DWARFASTParserClang::ParseStructureLikeDIE(const 
SymbolContext &sc,
   }
 
   if (def_die) {
+if (auto [it, inserted] = dwarf->GetDIEToType().try_emplace(
+def_die.GetDIE(), DIE_IS_BEING_PARSED);
+!inserted) {
+  if (it->getSecond() == nullptr || it->getSecond() == DIE_IS_BEING_PARSED)
+return nullptr;
+  return it->getSecond()->shared_from_this();
+}
 attrs = ParsedDWARFTypeAttributes(def_die);
   } else {
 // No definition found. Proceed with the declaration die. We can use it to

diff  --git a/lldb/test/Shell/SymbolFile/DWARF/enum-declaration-uniqueness.cpp 
b/lldb/test/Shell/SymbolFile/DWARF/enum-declaration-uniqueness.cpp
new file mode 100644
index 0..6fc47d7e4b53a
--- /dev/null
+++ b/lldb/test/Shell/SymbolFile/DWARF/enum-declaration-uniqueness.cpp
@@ -0,0 +1,32 @@
+// RUN: %clangxx_host -gdwarf -c -o %t_a.o %s -DFILE_A
+// RUN: %clangxx_host -gdwarf -c -o %t_b.o %s -DFILE_B
+// RUN: %clangxx_host -o %t %t_a.o %t_b.o
+// RUN: %lldb %t \
+// RUN:   -o "target variable my_enum my_enum_ref" -o "image dump ast" \
+// RUN:   -o exit | FileCheck %s
+
+
+// CHECK: (lldb) target variable
+// CHECK: (MyEnum) my_enum = MyEnum_A
+// CHECK: (MyEnum &) my_enum_ref =
+// CHECK-SAME: &::my_enum_ref = MyEnum_A
+
+// CHECK: (lldb) image dump ast
+// CHECK: EnumDecl {{.*}} MyEnum
+// CHECK-NEXT: EnumConstantDecl {{.*}} MyEnum_A 'MyEnum'
+// CHECK-NOT: MyEnum
+
+enum MyEnum : int;
+
+extern MyEnum my_enum;
+
+#ifdef FILE_A
+enum MyEnum : int { MyEnum_A };
+
+MyEnum my_enum = MyEnum_A;
+
+int main() {}
+#endif
+#ifdef FILE_B
+MyEnum &my_enum_ref = my_enum;
+#endif



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


[Lldb-commits] [lldb] [lldb/DWARF] Unique enums parsed from declarations (PR #96751)

2024-06-27 Thread Pavel Labath via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Don't call AddRemoteRegisters if the target XML did not include any registers (PR #96907)

2024-06-27 Thread Michał Górny via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Don't call AddRemoteRegisters if the target XML did not include any registers (PR #96907)

2024-06-27 Thread Michał Górny via lldb-commits


@@ -4879,7 +4879,9 @@ bool ProcessGDBRemote::GetGDBServerRegisterInfo(ArchSpec 
&arch_to_use) {
   m_registers_enum_types.clear();
   std::vector registers;
   if (GetGDBServerRegisterInfoXMLAndProcess(arch_to_use, "target.xml",
-registers))
+registers) &&
+  // Target XML is not required to include register information.
+  (!registers.empty()))

mgorny wrote:

I'm a bit confused about the extra parentheses here.

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


[Lldb-commits] [lldb] [lldb] Don't call AddRemoteRegisters if the target XML did not include any registers (PR #96907)

2024-06-27 Thread Michał Górny via lldb-commits

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

Good catch, thanks!

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


[Lldb-commits] [lldb] [lldb] Don't call AddRemoteRegisters if the target XML did not include any registers (PR #96907)

2024-06-27 Thread David Spickett via lldb-commits

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

>From 25905a0f01c126dbebc854affd30d9ff838f259b Mon Sep 17 00:00:00 2001
From: David Spickett 
Date: Thu, 27 Jun 2024 10:55:28 +
Subject: [PATCH 1/5] [lldb] Don't call AddRemoteRegisters if the target XML
 did not include any registers

Fixes #92541

When e69a3d18f48bc0d81b5dd12e735a2ec898ce64d added fallback register layouts,
it assumed that the choices were target XML with registers, or no target XML
at all.

In the linked issue, a user has a debug stub that does have target XML,
but it's missing register information.

This caused us to finalize the register information using an empty set
of registers got from target XML, then fail an assert when we attempted to add
the fallback set. Since we think we've already completed the register
information.

This change adds a check to prevent that first call and expands the
existing tests to check each archictecture without target XML and
with target XML missing register information.
---
 .../Process/gdb-remote/ProcessGDBRemote.cpp   |  4 +-
 lldb/source/Target/DynamicRegisterInfo.cpp|  1 +
 ...y => TestGDBServerNoTargetXMLRegisters.py} | 78 +++
 3 files changed, 69 insertions(+), 14 deletions(-)
 rename 
lldb/test/API/functionalities/gdb_remote_client/{TestGDBServerNoTargetXML.py => 
TestGDBServerNoTargetXMLRegisters.py} (82%)

diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp 
b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index 3195587eb5676..7f1ce2303cde6 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -4879,7 +4879,9 @@ bool ProcessGDBRemote::GetGDBServerRegisterInfo(ArchSpec 
&arch_to_use) {
   m_registers_enum_types.clear();
   std::vector registers;
   if (GetGDBServerRegisterInfoXMLAndProcess(arch_to_use, "target.xml",
-registers))
+registers) &&
+  // Target XML is not required to include register information.
+  (!registers.empty()))
 AddRemoteRegisters(registers, arch_to_use);
 
   return m_register_info_sp->GetNumRegisters() > 0;
diff --git a/lldb/source/Target/DynamicRegisterInfo.cpp 
b/lldb/source/Target/DynamicRegisterInfo.cpp
index 1a817449fa958..48f9a49f8d45a 100644
--- a/lldb/source/Target/DynamicRegisterInfo.cpp
+++ b/lldb/source/Target/DynamicRegisterInfo.cpp
@@ -437,6 +437,7 @@ size_t DynamicRegisterInfo::SetRegisterInfo(
 }
 
 void DynamicRegisterInfo::Finalize(const ArchSpec &arch) {
+  printf("DynamicRegisterInfo::Finalize\n");
   if (m_finalized)
 return;
 
diff --git 
a/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerNoTargetXML.py 
b/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerNoTargetXMLRegisters.py
similarity index 82%
rename from 
lldb/test/API/functionalities/gdb_remote_client/TestGDBServerNoTargetXML.py
rename to 
lldb/test/API/functionalities/gdb_remote_client/TestGDBServerNoTargetXMLRegisters.py
index 8c5bad007f569..7557c8108439f 100644
--- 
a/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerNoTargetXML.py
+++ 
b/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerNoTargetXMLRegisters.py
@@ -1,6 +1,6 @@
 """
 Check that lldb falls back to default register layouts when the remote provides
-no target XML.
+no target XML or does not include registers in the target XML.
 
 GPRS are passed to the responder to create register data to send back to lldb.
 Registers in SUPPL are virtual registers based on those general ones. The tests
@@ -14,6 +14,7 @@
 from lldbsuite.test.lldbgdbclient import GDBRemoteTestBase
 
 import binascii
+from textwrap import dedent
 
 class MyResponder(MockGDBServerResponder):
 @staticmethod
@@ -22,8 +23,10 @@ def filecheck_to_blob(fc):
 val = l.split("0x")[1]
 yield 
binascii.b2a_hex(bytes(reversed(binascii.a2b_hex(val.decode()
 
-def __init__(self, reg_data, halt_reason):
+def __init__(self, architecture, has_target_xml, reg_data, halt_reason):
 super().__init__()
+self.architecture = architecture
+self.has_target_xml = has_target_xml
 self.reg_data = "".join(self.filecheck_to_blob(reg_data))
 self.halt_reason = halt_reason
 
@@ -36,13 +39,19 @@ def readRegisters(self):
 def haltReason(self):
 return self.halt_reason
 
+def qXferRead(self, obj, annex, offset, length):
+if self.has_target_xml and annex == "target.xml":
+return dedent(f"""\
+  
+  
+{self.architecture}
+  """), False
+
+return None, False
 
-class TestGDBServerTargetXML(GDBRemoteTestBase):
-@skipIfRemote
-@skipIfLLVMTargetMissing("X86")
-def test_x86_64_regs(self):
-"""Test grabbing various x86_64 registers from gdbserver."""
 
+class TestGDBServerTargetXML(GDBRemot

[Lldb-commits] [lldb] [lldb] Don't call AddRemoteRegisters if the target XML did not include any registers (PR #96907)

2024-06-27 Thread David Spickett via lldb-commits


@@ -4879,7 +4879,9 @@ bool ProcessGDBRemote::GetGDBServerRegisterInfo(ArchSpec 
&arch_to_use) {
   m_registers_enum_types.clear();
   std::vector registers;
   if (GetGDBServerRegisterInfoXMLAndProcess(arch_to_use, "target.xml",
-registers))
+registers) &&
+  // Target XML is not required to include register information.
+  (!registers.empty()))

DavidSpickett wrote:

Just paranoia :) I've removed them.

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


[Lldb-commits] [lldb] [lldb/DWARF] Don't start class definitions in ParseStructureLikeDIE (PR #96755)

2024-06-27 Thread Pavel Labath via lldb-commits


@@ -1893,72 +1849,21 @@ DWARFASTParserClang::ParseStructureLikeDIE(const 
SymbolContext &sc,
   dwarf->GetUniqueDWARFASTTypeMap().Insert(unique_typename,
*unique_ast_entry_up);
 
-  if (!attrs.is_forward_declaration) {
-// Always start the definition for a class type so that if the class
-// has child classes or types that require the class to be created
-// for use as their decl contexts the class will be ready to accept
-// these child definitions.
-if (!def_die.HasChildren()) {
-  // No children for this struct/union/class, lets finish it
-  if (TypeSystemClang::StartTagDeclarationDefinition(clang_type)) {
-TypeSystemClang::CompleteTagDeclarationDefinition(clang_type);
-  } else {
-dwarf->GetObjectFile()->GetModule()->ReportError(
-
-"DWARF DIE {0:x16} named \"{1}\" was not able to start its "
-"definition.\nPlease file a bug and attach the file at the "
-"start of this error message",
-def_die.GetID(), attrs.name.GetCString());
-  }
-
-  // Setting authority byte size and alignment for empty structures.
-  //
-  // If the byte size or alignmenet of the record is specified then
-  // overwrite the ones that would be computed by Clang.
-  // This is only needed as LLDB's TypeSystemClang is always in C++ mode,
-  // but some compilers such as GCC and Clang give empty structs a size of 0
-  // in C mode (in contrast to the size of 1 for empty structs that would 
be
-  // computed in C++ mode).
-  if (attrs.byte_size || attrs.alignment) {
-clang::RecordDecl *record_decl =
-TypeSystemClang::GetAsRecordDecl(clang_type);
-if (record_decl) {
-  ClangASTImporter::LayoutInfo layout;
-  layout.bit_size = attrs.byte_size.value_or(0) * 8;
-  layout.alignment = attrs.alignment.value_or(0) * 8;
-  GetClangASTImporter().SetRecordLayout(record_decl, layout);
-}
-  }
-} else if (clang_type_was_created) {
-  // Start the definition if the class is not objective C since the
-  // underlying decls respond to isCompleteDefinition(). Objective
-  // C decls don't respond to isCompleteDefinition() so we can't
-  // start the declaration definition right away. For C++
-  // class/union/structs we want to start the definition in case the
-  // class is needed as the declaration context for a contained class
-  // or type without the need to complete that type..
-
-  if (attrs.class_language != eLanguageTypeObjC &&
-  attrs.class_language != eLanguageTypeObjC_plus_plus)
-TypeSystemClang::StartTagDeclarationDefinition(clang_type);
-
-  // Leave this as a forward declaration until we need to know the
-  // details of the type. lldb_private::Type will automatically call
-  // the SymbolFile virtual function
-  // "SymbolFileDWARF::CompleteType(Type *)" When the definition
-  // needs to be defined.
-  assert(!dwarf->GetForwardDeclCompilerTypeToDIE().count(
- ClangUtil::RemoveFastQualifiers(clang_type)
- .GetOpaqueQualType()) &&
- "Type already in the forward declaration map!");
-  // Can't assume m_ast.GetSymbolFile() is actually a
-  // SymbolFileDWARF, it can be a SymbolFileDWARFDebugMap for Apple
-  // binaries.
-  dwarf->GetForwardDeclCompilerTypeToDIE().try_emplace(
-  ClangUtil::RemoveFastQualifiers(clang_type).GetOpaqueQualType(),
-  *def_die.GetDIERef());
-  m_ast.SetHasExternalStorage(clang_type.GetOpaqueQualType(), true);
-}
+  if (clang_type_was_created) {

labath wrote:

I don't think so, or rather like, if it does, I would say that's a bug 
somewhere else, as an empty class should be just a special case of "a class". 
You could think of this as an optimization, but I'd be surprised if it made a 
difference -- our performance problems are coming from classes that in fact 
have members. (Also, die.HasChildren() is not a very reliable indicator of an 
empty class, as e.g. an empty template class will still have children)

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


[Lldb-commits] [lldb] 8a7730f - [lldb] Don't call AddRemoteRegisters if the target XML did not include any registers (#96907)

2024-06-27 Thread via lldb-commits

Author: David Spickett
Date: 2024-06-27T16:00:07+01:00
New Revision: 8a7730fb88445a019fe150d5db4f6642e43afd04

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

LOG: [lldb] Don't call AddRemoteRegisters if the target XML did not include any 
registers (#96907)

Fixes #92541

When e69a3d18f48bc0d81b5dd12e735a2ec898ce64d added fallback register
layouts, it assumed that the choices were target XML with registers, or
no target XML at all.

In the linked issue, a user has a debug stub that does have target XML,
but it's missing register information.

This caused us to finalize the register information using an empty set
of registers got from target XML, then fail an assert when we attempted
to add the fallback set. Since we think we've already completed the
register information.

This change adds a check to prevent that first call and expands the
existing tests to check each architecture without target XML and with
target XML missing register information.

Added: 

lldb/test/API/functionalities/gdb_remote_client/TestGDBServerNoTargetXMLRegisters.py

Modified: 
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp

Removed: 
lldb/test/API/functionalities/gdb_remote_client/TestGDBServerNoTargetXML.py



diff  --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp 
b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index 3195587eb5676..604c92369e9a2 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -4879,7 +4879,9 @@ bool ProcessGDBRemote::GetGDBServerRegisterInfo(ArchSpec 
&arch_to_use) {
   m_registers_enum_types.clear();
   std::vector registers;
   if (GetGDBServerRegisterInfoXMLAndProcess(arch_to_use, "target.xml",
-registers))
+registers) &&
+  // Target XML is not required to include register information.
+  !registers.empty())
 AddRemoteRegisters(registers, arch_to_use);
 
   return m_register_info_sp->GetNumRegisters() > 0;

diff  --git 
a/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerNoTargetXML.py 
b/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerNoTargetXMLRegisters.py
similarity index 82%
rename from 
lldb/test/API/functionalities/gdb_remote_client/TestGDBServerNoTargetXML.py
rename to 
lldb/test/API/functionalities/gdb_remote_client/TestGDBServerNoTargetXMLRegisters.py
index 8c5bad007f569..118f46f9974a8 100644
--- 
a/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerNoTargetXML.py
+++ 
b/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerNoTargetXMLRegisters.py
@@ -1,6 +1,6 @@
 """
 Check that lldb falls back to default register layouts when the remote provides
-no target XML.
+no target XML or does not include registers in the target XML.
 
 GPRS are passed to the responder to create register data to send back to lldb.
 Registers in SUPPL are virtual registers based on those general ones. The tests
@@ -14,6 +14,8 @@
 from lldbsuite.test.lldbgdbclient import GDBRemoteTestBase
 
 import binascii
+from textwrap import dedent
+
 
 class MyResponder(MockGDBServerResponder):
 @staticmethod
@@ -22,8 +24,10 @@ def filecheck_to_blob(fc):
 val = l.split("0x")[1]
 yield 
binascii.b2a_hex(bytes(reversed(binascii.a2b_hex(val.decode()
 
-def __init__(self, reg_data, halt_reason):
+def __init__(self, architecture, has_target_xml, reg_data, halt_reason):
 super().__init__()
+self.architecture = architecture
+self.has_target_xml = has_target_xml
 self.reg_data = "".join(self.filecheck_to_blob(reg_data))
 self.halt_reason = halt_reason
 
@@ -36,13 +40,24 @@ def readRegisters(self):
 def haltReason(self):
 return self.halt_reason
 
+def qXferRead(self, obj, annex, offset, length):
+if self.has_target_xml and annex == "target.xml":
+return (
+dedent(
+f"""\
+
+
+  {self.architecture}
+"""
+),
+False,
+)
+
+return None, False
 
-class TestGDBServerTargetXML(GDBRemoteTestBase):
-@skipIfRemote
-@skipIfLLVMTargetMissing("X86")
-def test_x86_64_regs(self):
-"""Test grabbing various x86_64 registers from gdbserver."""
 
+class TestGDBServerTargetXML(GDBRemoteTestBase):
+def check_x86_64_regs(self, has_target_xml):
 GPRS = """
 CHECK-AMD64-DAG: rax = 0x0807060504030201
 CHECK-AMD64-DAG: rbx = 0x1817161514131211
@@ -125,6 +140,8 @@ def test_x86_64_regs(self):
 """
 
 self.server.responder = MyResponder(
+  

[Lldb-commits] [lldb] [lldb/DWARF] Don't start class definitions in ParseStructureLikeDIE (PR #96755)

2024-06-27 Thread Pavel Labath via lldb-commits

labath wrote:

> This is a really nice cleanup! It actually aligns almost exactly with [our 
> in-progress version of 
> this](https://github.com/llvm/llvm-project/blob/caacb57a46f34bf663fa5ab2190b361ce29b255b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp).
> 
> LGTM
> 
> Agree with your point about `PrepareContextToReceiveMembers`. We can add 
> those as needed. In our version of this I had to only add it in 
> `ParseSubroutine`, as you've also effectively done.

Thanks. It's very nice when things fit together.

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


[Lldb-commits] [lldb] [lldb] Don't call AddRemoteRegisters if the target XML did not include any registers (PR #96907)

2024-06-27 Thread David Spickett via lldb-commits

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


[Lldb-commits] [lldb] [LLDB] DebugInfoD tests: attempt to fix Fuchsia build (PR #96802)

2024-06-27 Thread Kevin Frei via lldb-commits

https://github.com/kevinfrei updated 
https://github.com/llvm/llvm-project/pull/96802

>From 4f0477c3ab3bbd6dcd83e755ad484031301b6a82 Mon Sep 17 00:00:00 2001
From: Kevin Frei 
Date: Mon, 25 Mar 2024 08:23:47 -0700
Subject: [PATCH 01/13] Trying to deal with Linux AArch64 test failures :/

---
 .../SymbolVendor/ELF/SymbolVendorELF.cpp  |  18 ++
 .../API/debuginfod/Normal/TestDebuginfod.py   | 187 +
 .../SplitDWARF/TestDebuginfodDWP.py   | 196 ++
 3 files changed, 401 insertions(+)
 create mode 100644 lldb/test/API/debuginfod/Normal/TestDebuginfod.py
 create mode 100644 lldb/test/API/debuginfod/SplitDWARF/TestDebuginfodDWP.py

diff --git a/lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp 
b/lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp
index b5fe35d71032a..a881218a56cef 100644
--- a/lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp
+++ b/lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp
@@ -44,6 +44,24 @@ llvm::StringRef 
SymbolVendorELF::GetPluginDescriptionStatic() {
  "executables.";
 }
 
+// If this is needed elsewhere, it can be exported/moved.
+static bool IsDwpSymbolFile(const lldb::ModuleSP &module_sp,
+const FileSpec &file_spec) {
+  DataBufferSP dwp_file_data_sp;
+  lldb::offset_t dwp_file_data_offset = 0;
+  // Try to create an ObjectFile from the file_spec.
+  ObjectFileSP dwp_obj_file = ObjectFile::FindPlugin(
+  module_sp, &file_spec, 0, FileSystem::Instance().GetByteSize(file_spec),
+  dwp_file_data_sp, dwp_file_data_offset);
+  // The presence of a debug_cu_index section is the key identifying feature of
+  // a DWP file. Make sure we don't fill in the section list on dwp_obj_file
+  // (by calling GetSectionList(false)) as this is invoked before we may have
+  // all the symbol files collected and available.
+  return dwp_obj_file && ObjectFileELF::classof(dwp_obj_file.get()) &&
+ dwp_obj_file->GetSectionList(false)->FindSectionByType(
+ eSectionTypeDWARFDebugCuIndex, false);
+}
+
 // CreateInstance
 //
 // Platforms can register a callback to use when creating symbol vendors to
diff --git a/lldb/test/API/debuginfod/Normal/TestDebuginfod.py 
b/lldb/test/API/debuginfod/Normal/TestDebuginfod.py
new file mode 100644
index 0..a662fb9fc6e68
--- /dev/null
+++ b/lldb/test/API/debuginfod/Normal/TestDebuginfod.py
@@ -0,0 +1,187 @@
+import os
+import shutil
+import tempfile
+import struct
+
+import lldb
+from lldbsuite.test.decorators import *
+import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.lldbtest import *
+
+
+def getUUID(aoutuuid):
+"""
+Pull the 20 byte UUID out of the .note.gnu.build-id section that was dumped
+to a file already, as part of the build.
+"""
+with open(aoutuuid, "rb") as f:
+data = f.read(36)
+if len(data) != 36:
+return None
+header = struct.unpack_from("<4I", data)
+if len(header) != 4:
+return None
+# 4 element 'prefix', 20 bytes of uuid, 3 byte long string: 'GNU':
+if header[0] != 4 or header[1] != 20 or header[2] != 3 or header[3] != 
0x554E47:
+return None
+return data[16:].hex()
+
+
+"""
+Test support for the DebugInfoD network symbol acquisition protocol.
+This one is for simple / no split-dwarf scenarios.
+
+For no-split-dwarf scenarios, there are 2 variations:
+1 - A stripped binary with it's corresponding unstripped binary:
+2 - A stripped binary with a corresponding --only-keep-debug symbols file
+"""
+
+
+@skipUnlessPlatform(["linux", "freebsd"])
+class DebugInfodTests(TestBase):
+# No need to try every flavor of debug inf.
+NO_DEBUG_INFO_TESTCASE = True
+
+def test_normal_no_symbols(self):
+"""
+Validate behavior with no symbols or symbol locator.
+('baseline negative' behavior)
+"""
+test_root = self.config_test(["a.out"])
+self.try_breakpoint(False)
+
+def test_normal_default(self):
+"""
+Validate behavior with symbols, but no symbol locator.
+('baseline positive' behavior)
+"""
+test_root = self.config_test(["a.out", "a.out.debug"])
+self.try_breakpoint(True)
+
+def test_debuginfod_symbols(self):
+"""
+Test behavior with the full binary available from Debuginfod as
+'debuginfo' from the plug-in.
+"""
+test_root = self.config_test(["a.out"], "a.out.full")
+self.try_breakpoint(True)
+
+def test_debuginfod_executable(self):
+"""
+Test behavior with the full binary available from Debuginfod as
+'executable' from the plug-in.
+"""
+test_root = self.config_test(["a.out"], None, "a.out.full")
+self.try_breakpoint(True)
+
+def test_debuginfod_okd_symbols(self):
+"""
+Test behavior with the 'only-keep-debug' symbols available from 
Debuginfod.
+"""
+  

[Lldb-commits] [lldb] 2fefc04 - [lldb/test] Fix enum-declaration-uniqueness.cpp

2024-06-27 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2024-06-27T17:46:27+02:00
New Revision: 2fefc042ce8faf8516ae66e1529d87c7130094a1

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

LOG: [lldb/test] Fix enum-declaration-uniqueness.cpp

Dereferencing a pointer variable without a running process does not work
on every arch/os. Fix the test to x86-linux, where it is known to work.

Added: 
lldb/test/Shell/SymbolFile/DWARF/x86/enum-declaration-uniqueness.cpp

Modified: 


Removed: 
lldb/test/Shell/SymbolFile/DWARF/enum-declaration-uniqueness.cpp



diff  --git a/lldb/test/Shell/SymbolFile/DWARF/enum-declaration-uniqueness.cpp 
b/lldb/test/Shell/SymbolFile/DWARF/x86/enum-declaration-uniqueness.cpp
similarity index 75%
rename from lldb/test/Shell/SymbolFile/DWARF/enum-declaration-uniqueness.cpp
rename to lldb/test/Shell/SymbolFile/DWARF/x86/enum-declaration-uniqueness.cpp
index 6fc47d7e4b53a..20322f1ccc37b 100644
--- a/lldb/test/Shell/SymbolFile/DWARF/enum-declaration-uniqueness.cpp
+++ b/lldb/test/Shell/SymbolFile/DWARF/x86/enum-declaration-uniqueness.cpp
@@ -1,6 +1,8 @@
-// RUN: %clangxx_host -gdwarf -c -o %t_a.o %s -DFILE_A
-// RUN: %clangxx_host -gdwarf -c -o %t_b.o %s -DFILE_B
-// RUN: %clangxx_host -o %t %t_a.o %t_b.o
+// REQUIRES: lld
+//
+// RUN: %clangxx --target=x86_64-pc-linux -g -c -o %t_a.o %s -DFILE_A
+// RUN: %clangxx --target=x86_64-pc-linux -g -c -o %t_b.o %s -DFILE_B
+// RUN: ld.lld -o %t %t_a.o %t_b.o
 // RUN: %lldb %t \
 // RUN:   -o "target variable my_enum my_enum_ref" -o "image dump ast" \
 // RUN:   -o exit | FileCheck %s
@@ -24,8 +26,6 @@ extern MyEnum my_enum;
 enum MyEnum : int { MyEnum_A };
 
 MyEnum my_enum = MyEnum_A;
-
-int main() {}
 #endif
 #ifdef FILE_B
 MyEnum &my_enum_ref = my_enum;



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


[Lldb-commits] [lldb] [LLDB] DebugInfoD tests: attempt to fix Fuchsia build (PR #96802)

2024-06-27 Thread Kevin Frei via lldb-commits

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


[Lldb-commits] [lldb] [LLDB] DebugInfoD tests: attempt to fix Fuchsia build (PR #96802)

2024-06-27 Thread Kevin Frei via lldb-commits

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


[Lldb-commits] [lldb] [LLDB] DebugInfoD tests: attempt to fix Fuchsia build (PR #96802)

2024-06-27 Thread Kevin Frei via lldb-commits

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


[Lldb-commits] [lldb] [LLDB] DebugInfoD tests: attempt to fix Fuchsia build (PR #96802)

2024-06-27 Thread Kevin Frei via lldb-commits

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


[Lldb-commits] [lldb] [LLDB] DebugInfoD tests: attempt to fix Fuchsia build (PR #96802)

2024-06-27 Thread Kevin Frei via lldb-commits

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


[Lldb-commits] [lldb] Fix flake in TestZerothFrame.py (PR #96685)

2024-06-27 Thread Kendal Harland via lldb-commits

https://github.com/kendalharland updated 
https://github.com/llvm/llvm-project/pull/96685

>From 1ca25a240cf459e16fb762f750e84260610c1077 Mon Sep 17 00:00:00 2001
From: kendal 
Date: Mon, 24 Jun 2024 13:42:20 -0700
Subject: [PATCH] Fix flake in TestZerothFrame.py

This test is relying on the order of `process.threads` which is
nondeterministic. By switching from `process.GetThreadAtIndex` to
`process.GetThreadByIndex` we consistently retrieve the correct thread.

Adds a helper function to find thread executing a file
---
 .../unwind/zeroth_frame/TestZerothFrame.py| 20 ---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git 
a/lldb/test/API/functionalities/unwind/zeroth_frame/TestZerothFrame.py 
b/lldb/test/API/functionalities/unwind/zeroth_frame/TestZerothFrame.py
index f4e883d314644..892522f5cc63e 100644
--- a/lldb/test/API/functionalities/unwind/zeroth_frame/TestZerothFrame.py
+++ b/lldb/test/API/functionalities/unwind/zeroth_frame/TestZerothFrame.py
@@ -28,6 +28,12 @@
 
 
 class ZerothFrame(TestBase):
+def _is_thread_executing_file(self, thread, file_basename):
+frame = thread.GetSelectedFrame()
+module = frame.GetModule()
+filename = module.GetFileSpec().GetFilename()
+return os.path.basename(filename) == file_basename
+
 def test(self):
 """
 Test that line information is recalculated properly for a frame when 
it moves
@@ -53,14 +59,23 @@ def test(self):
 process = target.LaunchSimple(None, None, 
self.get_process_working_directory())
 self.assertTrue(process, VALID_PROCESS)
 
-thread = process.GetThreadAtIndex(0)
+# Find the thread that is running a.out.
+thread = None
+for i in range(len(process.thread)):
+if self._is_thread_executing_file(process.thread[i], "a.out"):
+thread = process.thread[i]
+break
+
+self.assertTrue(thread != None, "failed to find thread executing 
a.out")
+
 if self.TraceOn():
 print("Backtrace at the first breakpoint:")
 for f in thread.frames:
 print(f)
+
 # Check that we have stopped at correct breakpoint.
 self.assertEqual(
-process.GetThreadAtIndex(0).frame[0].GetLineEntry().GetLine(),
+thread.frame[0].GetLineEntry().GetLine(),
 bp1_line,
 "LLDB reported incorrect line number.",
 )
@@ -70,7 +85,6 @@ def test(self):
 # 'continue' command.
 process.Continue()
 
-thread = process.GetThreadAtIndex(0)
 if self.TraceOn():
 print("Backtrace at the second breakpoint:")
 for f in thread.frames:

___
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 test-cases for packed/aligned structures (PR #96932)

2024-06-27 Thread Michael Buch via lldb-commits

https://github.com/Michael137 created 
https://github.com/llvm/llvm-project/pull/96932

Adds test that checks that LLDB correctly infers the alignment of packed 
structures. Specifically, the
`InferAlignment` code-path of the `ItaniumRecordLayoutBuilder` where it assumes 
that overlapping field offsets imply a packed structure and thus sets alignment 
to `1`. See discussion in https://github.com/llvm/llvm-project/pull/93809.

Also adds two XFAIL-ed tests:
1. where LLDB doesn't correctly infer the alignment of a derived class whose 
base has an explicit `DW_AT_alignment. See 
https://github.com/llvm/llvm-project/issues/73623.
2. where the aforementioned `InferAlignment` kicks in for overlapping fields 
(but in this case incorrectly since the structure isn't actually packed).

>From 2113f052dd69cc1773f642e06339e5a13599090c Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Thu, 27 Jun 2024 17:16:50 +0100
Subject: [PATCH] [lldb][test] Add test-cases for packed structures

Adds test that checks that LLDB correctly infers the
alignment of packed structures. Specifically, the
`InferAlignment` code-path of the `ItaniumRecordLayoutBuilder`
where it assumes that overlapping field offsets imply a
packed structure and thus sets alignment to `1`. See discussion
in https://github.com/llvm/llvm-project/pull/93809.

Also adds two XFAIL-ed tests:
1. where LLDB doesn't correctly infer the alignment of a derived class whose 
base has
an explicit `DW_AT_alignment. See 
https://github.com/llvm/llvm-project/issues/73623.
2. where the aforementioned `InferAlignment` kicks in for
   overlapping fields (but in this case incorrectly since
   the structure isn't actually packed).
---
 .../TestAlignAsBaseClass.py   |  8 +
 .../API/lang/cpp/alignas_base_class/main.cpp  |  6 
 .../DWARF/no_unique_address-alignment.cpp | 25 +
 lldb/test/Shell/SymbolFile/DWARF/packed.cpp   | 36 +++
 4 files changed, 75 insertions(+)
 create mode 100644 
lldb/test/Shell/SymbolFile/DWARF/no_unique_address-alignment.cpp
 create mode 100644 lldb/test/Shell/SymbolFile/DWARF/packed.cpp

diff --git a/lldb/test/API/lang/cpp/alignas_base_class/TestAlignAsBaseClass.py 
b/lldb/test/API/lang/cpp/alignas_base_class/TestAlignAsBaseClass.py
index 7d97b0c42b7e1..f9c99d15e5891 100644
--- a/lldb/test/API/lang/cpp/alignas_base_class/TestAlignAsBaseClass.py
+++ b/lldb/test/API/lang/cpp/alignas_base_class/TestAlignAsBaseClass.py
@@ -16,3 +16,11 @@ def test(self):
 # Verify specified class alignments.
 self.expect_expr("alignof(B2)", result_value="8")
 self.expect_expr("alignof(EmptyClassAlign8)", result_value="8")
+
+@no_debug_info_test
+
@expectedFailureAll(bugnumber="https://github.com/llvm/llvm-project/issues/73623";)
+def test(self):
+self.build()
+self.dbg.CreateTarget(self.getBuildArtifact("a.out"))
+
+self.expect_expr("alignof(Derived)", result_value="8")
diff --git a/lldb/test/API/lang/cpp/alignas_base_class/main.cpp 
b/lldb/test/API/lang/cpp/alignas_base_class/main.cpp
index 9d37554957ba3..fb922c42edfc3 100644
--- a/lldb/test/API/lang/cpp/alignas_base_class/main.cpp
+++ b/lldb/test/API/lang/cpp/alignas_base_class/main.cpp
@@ -13,4 +13,10 @@ D d3g;
 struct alignas(8) EmptyClassAlign8 {
 } t;
 
+struct alignas(8) __attribute__((packed)) AlignedAndPackedBase {} foo;
+
+struct Derived : AlignedAndPackedBase {
+} bar;
+static_assert(alignof(Derived) == 8);
+
 int main() {}
diff --git a/lldb/test/Shell/SymbolFile/DWARF/no_unique_address-alignment.cpp 
b/lldb/test/Shell/SymbolFile/DWARF/no_unique_address-alignment.cpp
new file mode 100644
index 0..79199a9237a63
--- /dev/null
+++ b/lldb/test/Shell/SymbolFile/DWARF/no_unique_address-alignment.cpp
@@ -0,0 +1,25 @@
+// XFAIL: *
+
+// RUN: %clangxx_host -gdwarf -o %t %s
+// RUN: %lldb %t \
+// RUN:   -o "b main" \
+// RUN:   -o "expr alignof(OverlappingFields)" \
+// RUN:   -o "expr sizeof(OverlappingFields)" \
+// RUN:   -o exit | FileCheck %s
+
+// CHECK:  (lldb) expr alignof(OverlappingFields)
+// CHECK-NEXT: ${{.*}} = 4
+// CHECK:  (lldb) expr sizeof(OverlappingFields)
+// CHECK-NEXT: ${{.*}} = 8
+
+struct Empty {};
+
+struct OverlappingFields {
+char y;
+[[no_unique_address]] Empty e;
+int z;
+} g_packed_struct;
+static_assert(alignof(OverlappingFields) == 4);
+static_assert(sizeof(OverlappingFields) == 8);
+
+int main() {}
diff --git a/lldb/test/Shell/SymbolFile/DWARF/packed.cpp 
b/lldb/test/Shell/SymbolFile/DWARF/packed.cpp
new file mode 100644
index 0..53b5ee624472c
--- /dev/null
+++ b/lldb/test/Shell/SymbolFile/DWARF/packed.cpp
@@ -0,0 +1,36 @@
+// RUN: %clangxx_host -gdwarf -o %t %s
+// RUN: %lldb %t \
+// RUN:   -o "b main" \
+// RUN:   -o "expr alignof(packed)" \
+// RUN:   -o "expr sizeof(packed)" \
+// RUN:   -o "expr alignof(packed_and_aligned)" \
+// RUN:   -o "expr sizeof(packed_and_aligned)" \
+// RUN:   -o exit | FileCheck %s
+
+// CHECK:  (lldb)

[Lldb-commits] [lldb] [lldb][test] Add test-cases for packed/aligned structures (PR #96932)

2024-06-27 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Michael Buch (Michael137)


Changes

Adds test that checks that LLDB correctly infers the alignment of packed 
structures. Specifically, the
`InferAlignment` code-path of the `ItaniumRecordLayoutBuilder` where it assumes 
that overlapping field offsets imply a packed structure and thus sets alignment 
to `1`. See discussion in https://github.com/llvm/llvm-project/pull/93809.

Also adds two XFAIL-ed tests:
1. where LLDB doesn't correctly infer the alignment of a derived class whose 
base has an explicit `DW_AT_alignment. See 
https://github.com/llvm/llvm-project/issues/73623.
2. where the aforementioned `InferAlignment` kicks in for overlapping fields 
(but in this case incorrectly since the structure isn't actually packed).

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


4 Files Affected:

- (modified) lldb/test/API/lang/cpp/alignas_base_class/TestAlignAsBaseClass.py 
(+8) 
- (modified) lldb/test/API/lang/cpp/alignas_base_class/main.cpp (+6) 
- (added) lldb/test/Shell/SymbolFile/DWARF/no_unique_address-alignment.cpp 
(+25) 
- (added) lldb/test/Shell/SymbolFile/DWARF/packed.cpp (+36) 


``diff
diff --git a/lldb/test/API/lang/cpp/alignas_base_class/TestAlignAsBaseClass.py 
b/lldb/test/API/lang/cpp/alignas_base_class/TestAlignAsBaseClass.py
index 7d97b0c42b7e1..f9c99d15e5891 100644
--- a/lldb/test/API/lang/cpp/alignas_base_class/TestAlignAsBaseClass.py
+++ b/lldb/test/API/lang/cpp/alignas_base_class/TestAlignAsBaseClass.py
@@ -16,3 +16,11 @@ def test(self):
 # Verify specified class alignments.
 self.expect_expr("alignof(B2)", result_value="8")
 self.expect_expr("alignof(EmptyClassAlign8)", result_value="8")
+
+@no_debug_info_test
+
@expectedFailureAll(bugnumber="https://github.com/llvm/llvm-project/issues/73623";)
+def test(self):
+self.build()
+self.dbg.CreateTarget(self.getBuildArtifact("a.out"))
+
+self.expect_expr("alignof(Derived)", result_value="8")
diff --git a/lldb/test/API/lang/cpp/alignas_base_class/main.cpp 
b/lldb/test/API/lang/cpp/alignas_base_class/main.cpp
index 9d37554957ba3..fb922c42edfc3 100644
--- a/lldb/test/API/lang/cpp/alignas_base_class/main.cpp
+++ b/lldb/test/API/lang/cpp/alignas_base_class/main.cpp
@@ -13,4 +13,10 @@ D d3g;
 struct alignas(8) EmptyClassAlign8 {
 } t;
 
+struct alignas(8) __attribute__((packed)) AlignedAndPackedBase {} foo;
+
+struct Derived : AlignedAndPackedBase {
+} bar;
+static_assert(alignof(Derived) == 8);
+
 int main() {}
diff --git a/lldb/test/Shell/SymbolFile/DWARF/no_unique_address-alignment.cpp 
b/lldb/test/Shell/SymbolFile/DWARF/no_unique_address-alignment.cpp
new file mode 100644
index 0..79199a9237a63
--- /dev/null
+++ b/lldb/test/Shell/SymbolFile/DWARF/no_unique_address-alignment.cpp
@@ -0,0 +1,25 @@
+// XFAIL: *
+
+// RUN: %clangxx_host -gdwarf -o %t %s
+// RUN: %lldb %t \
+// RUN:   -o "b main" \
+// RUN:   -o "expr alignof(OverlappingFields)" \
+// RUN:   -o "expr sizeof(OverlappingFields)" \
+// RUN:   -o exit | FileCheck %s
+
+// CHECK:  (lldb) expr alignof(OverlappingFields)
+// CHECK-NEXT: ${{.*}} = 4
+// CHECK:  (lldb) expr sizeof(OverlappingFields)
+// CHECK-NEXT: ${{.*}} = 8
+
+struct Empty {};
+
+struct OverlappingFields {
+char y;
+[[no_unique_address]] Empty e;
+int z;
+} g_packed_struct;
+static_assert(alignof(OverlappingFields) == 4);
+static_assert(sizeof(OverlappingFields) == 8);
+
+int main() {}
diff --git a/lldb/test/Shell/SymbolFile/DWARF/packed.cpp 
b/lldb/test/Shell/SymbolFile/DWARF/packed.cpp
new file mode 100644
index 0..53b5ee624472c
--- /dev/null
+++ b/lldb/test/Shell/SymbolFile/DWARF/packed.cpp
@@ -0,0 +1,36 @@
+// RUN: %clangxx_host -gdwarf -o %t %s
+// RUN: %lldb %t \
+// RUN:   -o "b main" \
+// RUN:   -o "expr alignof(packed)" \
+// RUN:   -o "expr sizeof(packed)" \
+// RUN:   -o "expr alignof(packed_and_aligned)" \
+// RUN:   -o "expr sizeof(packed_and_aligned)" \
+// RUN:   -o exit | FileCheck %s
+
+// CHECK:  (lldb) expr alignof(packed)
+// CHECK-NEXT: ${{.*}} = 1
+// CHECK:  (lldb) expr sizeof(packed)
+// CHECK-NEXT: ${{.*}} = 9
+
+// CHECK:  (lldb) expr alignof(packed_and_aligned)
+// CHECK-NEXT: ${{.*}} = 16
+// CHECK:  (lldb) expr sizeof(packed_and_aligned)
+// CHECK-NEXT: ${{.*}} = 16
+
+struct __attribute__((packed)) packed {
+int x;
+char y;
+int z;
+} g_packed_struct;
+static_assert(alignof(packed) == 1);
+static_assert(sizeof(packed) == 9);
+
+struct __attribute__((packed, aligned(16))) packed_and_aligned {
+int x;
+char y;
+int z;
+} g_packed_and_aligned_struct;
+static_assert(alignof(packed_and_aligned) == 16);
+static_assert(sizeof(packed_and_aligned) == 16);
+
+int main() {}

``




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

[Lldb-commits] [lldb] Fix flake in TestZerothFrame.py (PR #96685)

2024-06-27 Thread Kendal Harland via lldb-commits

https://github.com/kendalharland updated 
https://github.com/llvm/llvm-project/pull/96685

>From 836b5ee62a5e1e31fe973e1f4ff6cd47f10eca84 Mon Sep 17 00:00:00 2001
From: kendal 
Date: Mon, 24 Jun 2024 13:42:20 -0700
Subject: [PATCH] Fix flake in TestZerothFrame.py

This test is relying on the order of `process.threads` which is
nondeterministic. By selecting the thread based on whether it is
stopped at our breakpoint we can reliably select the correct one.
---
 .../unwind/zeroth_frame/TestZerothFrame.py| 32 +++
 1 file changed, 18 insertions(+), 14 deletions(-)

diff --git 
a/lldb/test/API/functionalities/unwind/zeroth_frame/TestZerothFrame.py 
b/lldb/test/API/functionalities/unwind/zeroth_frame/TestZerothFrame.py
index f4e883d314644..d6a1be8052995 100644
--- a/lldb/test/API/functionalities/unwind/zeroth_frame/TestZerothFrame.py
+++ b/lldb/test/API/functionalities/unwind/zeroth_frame/TestZerothFrame.py
@@ -28,6 +28,12 @@
 
 
 class ZerothFrame(TestBase):
+def _is_thread_executing_file(self, thread, file_basename):
+frame = thread.GetSelectedFrame()
+module = frame.GetModule()
+filename = module.GetFileSpec().GetFilename()
+return os.path.basename(filename) == file_basename
+
 def test(self):
 """
 Test that line information is recalculated properly for a frame when 
it moves
@@ -40,28 +46,27 @@ def test(self):
 target = self.dbg.CreateTarget(exe)
 self.assertTrue(target, VALID_TARGET)
 
-bp1_line = line_number("main.c", "// Set breakpoint 1 here")
-bp2_line = line_number("main.c", "// Set breakpoint 2 here")
-
-lldbutil.run_break_set_by_file_and_line(
-self, "main.c", bp1_line, num_expected_locations=1
-)
-lldbutil.run_break_set_by_file_and_line(
-self, "main.c", bp2_line, num_expected_locations=1
-)
+main_dot_c = lldb.SBFileSpec("main.c")
+bp1 = target.BreakpointCreateBySourceRegex("// Set breakpoint 1 here", 
main_dot_c)
+bp2 = target.BreakpointCreateBySourceRegex("// Set breakpoint 2 here", 
main_dot_c)
 
 process = target.LaunchSimple(None, None, 
self.get_process_working_directory())
 self.assertTrue(process, VALID_PROCESS)
 
-thread = process.GetThreadAtIndex(0)
+# Get the thread executing a.out.
+threads = lldbutil.get_threads_stopped_at_breakpoint(process, bp1)
+self.assertEqual(len(threads), 1)
+thread = threads[0]
+
 if self.TraceOn():
 print("Backtrace at the first breakpoint:")
 for f in thread.frames:
 print(f)
+
 # Check that we have stopped at correct breakpoint.
 self.assertEqual(
-process.GetThreadAtIndex(0).frame[0].GetLineEntry().GetLine(),
-bp1_line,
+thread.frame[0].GetLineEntry().GetLine(),
+bp1.GetLocationAtIndex(0).GetAddress().GetLineEntry().GetLine(),
 "LLDB reported incorrect line number.",
 )
 
@@ -70,7 +75,6 @@ def test(self):
 # 'continue' command.
 process.Continue()
 
-thread = process.GetThreadAtIndex(0)
 if self.TraceOn():
 print("Backtrace at the second breakpoint:")
 for f in thread.frames:
@@ -78,7 +82,7 @@ def test(self):
 # Check that we have stopped at the breakpoint
 self.assertEqual(
 thread.frame[0].GetLineEntry().GetLine(),
-bp2_line,
+bp2.GetLocationAtIndex(0).GetAddress().GetLineEntry().GetLine(),
 "LLDB reported incorrect line number.",
 )
 # Double-check with GetPCAddress()

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


[Lldb-commits] [lldb] Fix flake in TestZerothFrame.py (PR #96685)

2024-06-27 Thread Kendal Harland via lldb-commits

kendalharland wrote:

> The thread that you care about is stopped at a breakpoint, right? If so, then 
> you can use the lldbutil.get_threads_stopped_at_breakpoint utility to find 
> it...

Thanks, this eventually led to me what I think is the most obvious solution: We 
can just set the breakpoints in this test while holding onto to the 
`SBBreakpoint` objects, and then fetch the associated thread from those 
breakpoints later, and compare the thread's frames' currently line numbers.

Thanks @JDevlieghere and @bulbazord for the additional suggestions!

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


[Lldb-commits] [lldb] Fix flake in TestZerothFrame.py (PR #96685)

2024-06-27 Thread Kendal Harland via lldb-commits

https://github.com/kendalharland updated 
https://github.com/llvm/llvm-project/pull/96685

>From abc87f3cbadc47f7f0bfaf01fcdf7f7c6d4bfeb5 Mon Sep 17 00:00:00 2001
From: kendal 
Date: Mon, 24 Jun 2024 13:42:20 -0700
Subject: [PATCH] Fix flake in TestZerothFrame.py

This test is relying on the order of `process.threads` which is
nondeterministic. By selecting the thread based on whether it is
stopped at our breakpoint we can reliably select the correct one.
---
 .../unwind/zeroth_frame/TestZerothFrame.py| 26 +--
 1 file changed, 12 insertions(+), 14 deletions(-)

diff --git 
a/lldb/test/API/functionalities/unwind/zeroth_frame/TestZerothFrame.py 
b/lldb/test/API/functionalities/unwind/zeroth_frame/TestZerothFrame.py
index f4e883d314644..7ccd85e5b1044 100644
--- a/lldb/test/API/functionalities/unwind/zeroth_frame/TestZerothFrame.py
+++ b/lldb/test/API/functionalities/unwind/zeroth_frame/TestZerothFrame.py
@@ -40,28 +40,27 @@ def test(self):
 target = self.dbg.CreateTarget(exe)
 self.assertTrue(target, VALID_TARGET)
 
-bp1_line = line_number("main.c", "// Set breakpoint 1 here")
-bp2_line = line_number("main.c", "// Set breakpoint 2 here")
-
-lldbutil.run_break_set_by_file_and_line(
-self, "main.c", bp1_line, num_expected_locations=1
-)
-lldbutil.run_break_set_by_file_and_line(
-self, "main.c", bp2_line, num_expected_locations=1
-)
+main_dot_c = lldb.SBFileSpec("main.c")
+bp1 = target.BreakpointCreateBySourceRegex("// Set breakpoint 1 here", 
main_dot_c)
+bp2 = target.BreakpointCreateBySourceRegex("// Set breakpoint 2 here", 
main_dot_c)
 
 process = target.LaunchSimple(None, None, 
self.get_process_working_directory())
 self.assertTrue(process, VALID_PROCESS)
 
-thread = process.GetThreadAtIndex(0)
+# Get the thread executing a.out.
+threads = lldbutil.get_threads_stopped_at_breakpoint(process, bp1)
+self.assertEqual(len(threads), 1)
+thread = threads[0]
+
 if self.TraceOn():
 print("Backtrace at the first breakpoint:")
 for f in thread.frames:
 print(f)
+
 # Check that we have stopped at correct breakpoint.
 self.assertEqual(
-process.GetThreadAtIndex(0).frame[0].GetLineEntry().GetLine(),
-bp1_line,
+thread.frame[0].GetLineEntry().GetLine(),
+bp1.GetLocationAtIndex(0).GetAddress().GetLineEntry().GetLine(),
 "LLDB reported incorrect line number.",
 )
 
@@ -70,7 +69,6 @@ def test(self):
 # 'continue' command.
 process.Continue()
 
-thread = process.GetThreadAtIndex(0)
 if self.TraceOn():
 print("Backtrace at the second breakpoint:")
 for f in thread.frames:
@@ -78,7 +76,7 @@ def test(self):
 # Check that we have stopped at the breakpoint
 self.assertEqual(
 thread.frame[0].GetLineEntry().GetLine(),
-bp2_line,
+bp2.GetLocationAtIndex(0).GetAddress().GetLineEntry().GetLine(),
 "LLDB reported incorrect line number.",
 )
 # Double-check with GetPCAddress()

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


[Lldb-commits] [lldb] Fix flake in TestZerothFrame.py (PR #96685)

2024-06-27 Thread Kendal Harland via lldb-commits

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


[Lldb-commits] [lldb] Fix flake in TestZerothFrame.py (PR #96685)

2024-06-27 Thread Kendal Harland via lldb-commits

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


[Lldb-commits] [lldb] Revert "[lldb/test] Mark TestStepScripted.py as XFAIL temporarily (#96894)" (PR #96942)

2024-06-27 Thread Med Ismail Bennani via lldb-commits

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

This tentatively reverts commit 204c403b5215197ecdbdb68ca7f11402d6d9892b to 
remove the XFAIL from the tests while also trying to fix them at the same time.

>From 56392162f1a573570d280bebe905347069d9ea54 Mon Sep 17 00:00:00 2001
From: Med Ismail Bennani 
Date: Thu, 27 Jun 2024 10:53:24 -0700
Subject: [PATCH] Revert "[lldb/test] Mark TestStepScripted.py as XFAIL
 temporarily (#96894)"

This tentatively reverts commit 204c403b5215197ecdbdb68ca7f11402d6d9892b to
remove the XFAIL from the tests while also trying to fix them at the same time.

Signed-off-by: Med Ismail Bennani 
---
 lldb/test/API/functionalities/step_scripted/Steps.py | 1 +
 .../API/functionalities/step_scripted/TestStepScripted.py| 5 +
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/lldb/test/API/functionalities/step_scripted/Steps.py 
b/lldb/test/API/functionalities/step_scripted/Steps.py
index 3325dba753657..b121f71538ce4 100644
--- a/lldb/test/API/functionalities/step_scripted/Steps.py
+++ b/lldb/test/API/functionalities/step_scripted/Steps.py
@@ -92,6 +92,7 @@ def should_stop(self, event):
 
 def stop_description(self, stream):
 stream.Print(f"Stepped until {self.var_name} changed.")
+return True
 
 
 # This plan does nothing, but sets stop_mode to the
diff --git a/lldb/test/API/functionalities/step_scripted/TestStepScripted.py 
b/lldb/test/API/functionalities/step_scripted/TestStepScripted.py
index bb7479414dbbb..53901718019f9 100644
--- a/lldb/test/API/functionalities/step_scripted/TestStepScripted.py
+++ b/lldb/test/API/functionalities/step_scripted/TestStepScripted.py
@@ -7,6 +7,7 @@
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
 
+
 class StepScriptedTestCase(TestBase):
 NO_DEBUG_INFO_TESTCASE = True
 
@@ -15,14 +16,12 @@ def setUp(self):
 self.main_source_file = lldb.SBFileSpec("main.c")
 self.runCmd("command script import Steps.py")
 
-@expectedFailureAll()
 def test_standard_step_out(self):
 """Tests stepping with the scripted thread plan laying over a standard
 thread plan for stepping out."""
 self.build()
 self.step_out_with_scripted_plan("Steps.StepOut")
 
-@expectedFailureAll()
 def test_scripted_step_out(self):
 """Tests stepping with the scripted thread plan laying over an another
 scripted thread plan for stepping out."""
@@ -63,12 +62,10 @@ def test_misspelled_plan_name(self):
 # Make sure we didn't let the process run:
 self.assertEqual(stop_id, process.GetStopID(), "Process didn't run")
 
-@expectedFailureAll()
 def test_checking_variable(self):
 """Test that we can call SBValue API's from a scripted thread plan - 
using SBAPI's to step"""
 self.do_test_checking_variable(False)
 
-@expectedFailureAll()
 def test_checking_variable_cli(self):
 """Test that we can call SBValue API's from a scripted thread plan - 
using cli to step"""
 self.do_test_checking_variable(True)

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


[Lldb-commits] [lldb] Revert "[lldb/test] Mark TestStepScripted.py as XFAIL temporarily (#96894)" (PR #96942)

2024-06-27 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Med Ismail Bennani (medismailben)


Changes

This tentatively reverts commit 204c403b5215197ecdbdb68ca7f11402d6d9892b to 
remove the XFAIL from the tests while also trying to fix them at the same time.

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


2 Files Affected:

- (modified) lldb/test/API/functionalities/step_scripted/Steps.py (+1) 
- (modified) lldb/test/API/functionalities/step_scripted/TestStepScripted.py 
(+1-4) 


``diff
diff --git a/lldb/test/API/functionalities/step_scripted/Steps.py 
b/lldb/test/API/functionalities/step_scripted/Steps.py
index 3325dba753657..b121f71538ce4 100644
--- a/lldb/test/API/functionalities/step_scripted/Steps.py
+++ b/lldb/test/API/functionalities/step_scripted/Steps.py
@@ -92,6 +92,7 @@ def should_stop(self, event):
 
 def stop_description(self, stream):
 stream.Print(f"Stepped until {self.var_name} changed.")
+return True
 
 
 # This plan does nothing, but sets stop_mode to the
diff --git a/lldb/test/API/functionalities/step_scripted/TestStepScripted.py 
b/lldb/test/API/functionalities/step_scripted/TestStepScripted.py
index bb7479414dbbb..53901718019f9 100644
--- a/lldb/test/API/functionalities/step_scripted/TestStepScripted.py
+++ b/lldb/test/API/functionalities/step_scripted/TestStepScripted.py
@@ -7,6 +7,7 @@
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
 
+
 class StepScriptedTestCase(TestBase):
 NO_DEBUG_INFO_TESTCASE = True
 
@@ -15,14 +16,12 @@ def setUp(self):
 self.main_source_file = lldb.SBFileSpec("main.c")
 self.runCmd("command script import Steps.py")
 
-@expectedFailureAll()
 def test_standard_step_out(self):
 """Tests stepping with the scripted thread plan laying over a standard
 thread plan for stepping out."""
 self.build()
 self.step_out_with_scripted_plan("Steps.StepOut")
 
-@expectedFailureAll()
 def test_scripted_step_out(self):
 """Tests stepping with the scripted thread plan laying over an another
 scripted thread plan for stepping out."""
@@ -63,12 +62,10 @@ def test_misspelled_plan_name(self):
 # Make sure we didn't let the process run:
 self.assertEqual(stop_id, process.GetStopID(), "Process didn't run")
 
-@expectedFailureAll()
 def test_checking_variable(self):
 """Test that we can call SBValue API's from a scripted thread plan - 
using SBAPI's to step"""
 self.do_test_checking_variable(False)
 
-@expectedFailureAll()
 def test_checking_variable_cli(self):
 """Test that we can call SBValue API's from a scripted thread plan - 
using cli to step"""
 self.do_test_checking_variable(True)

``




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


[Lldb-commits] [lldb] b949b64 - Revert "[lldb/test] Mark TestStepScripted.py as XFAIL temporarily (#96894)" (#96942)

2024-06-27 Thread via lldb-commits

Author: Med Ismail Bennani
Date: 2024-06-27T11:28:37-07:00
New Revision: b949b6420775fe3466dc5a5bf34eab1d14e39e8f

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

LOG: Revert "[lldb/test] Mark TestStepScripted.py as XFAIL temporarily 
(#96894)" (#96942)

This tentatively reverts commit 204c403b5215197ecdbdb68ca7f11402d6d9892b
to remove the XFAIL from the tests while also trying to fix them at the
same time.

Signed-off-by: Med Ismail Bennani 

Added: 


Modified: 
lldb/test/API/functionalities/step_scripted/Steps.py
lldb/test/API/functionalities/step_scripted/TestStepScripted.py

Removed: 




diff  --git a/lldb/test/API/functionalities/step_scripted/Steps.py 
b/lldb/test/API/functionalities/step_scripted/Steps.py
index 3325dba753657..b121f71538ce4 100644
--- a/lldb/test/API/functionalities/step_scripted/Steps.py
+++ b/lldb/test/API/functionalities/step_scripted/Steps.py
@@ -92,6 +92,7 @@ def should_stop(self, event):
 
 def stop_description(self, stream):
 stream.Print(f"Stepped until {self.var_name} changed.")
+return True
 
 
 # This plan does nothing, but sets stop_mode to the

diff  --git a/lldb/test/API/functionalities/step_scripted/TestStepScripted.py 
b/lldb/test/API/functionalities/step_scripted/TestStepScripted.py
index bb7479414dbbb..53901718019f9 100644
--- a/lldb/test/API/functionalities/step_scripted/TestStepScripted.py
+++ b/lldb/test/API/functionalities/step_scripted/TestStepScripted.py
@@ -7,6 +7,7 @@
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
 
+
 class StepScriptedTestCase(TestBase):
 NO_DEBUG_INFO_TESTCASE = True
 
@@ -15,14 +16,12 @@ def setUp(self):
 self.main_source_file = lldb.SBFileSpec("main.c")
 self.runCmd("command script import Steps.py")
 
-@expectedFailureAll()
 def test_standard_step_out(self):
 """Tests stepping with the scripted thread plan laying over a standard
 thread plan for stepping out."""
 self.build()
 self.step_out_with_scripted_plan("Steps.StepOut")
 
-@expectedFailureAll()
 def test_scripted_step_out(self):
 """Tests stepping with the scripted thread plan laying over an another
 scripted thread plan for stepping out."""
@@ -63,12 +62,10 @@ def test_misspelled_plan_name(self):
 # Make sure we didn't let the process run:
 self.assertEqual(stop_id, process.GetStopID(), "Process didn't run")
 
-@expectedFailureAll()
 def test_checking_variable(self):
 """Test that we can call SBValue API's from a scripted thread plan - 
using SBAPI's to step"""
 self.do_test_checking_variable(False)
 
-@expectedFailureAll()
 def test_checking_variable_cli(self):
 """Test that we can call SBValue API's from a scripted thread plan - 
using cli to step"""
 self.do_test_checking_variable(True)



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


[Lldb-commits] [lldb] Revert "[lldb/test] Mark TestStepScripted.py as XFAIL temporarily (#96894)" (PR #96942)

2024-06-27 Thread Med Ismail Bennani via lldb-commits

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


[Lldb-commits] [lldb] Revert "[lldb/test] Mark TestStepScripted.py as XFAIL temporarily (#96894)" (PR #96942)

2024-06-27 Thread LLVM Continuous Integration via lldb-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `lldb-x86_64-debian` 
running on `lldb-x86_64-debian` while building `lldb` at step 6 "test".

Full details are available at: 
https://lab.llvm.org/buildbot/#/builders/162/builds/899

Here is the relevant piece of the build log for the reference:
```
Step 6 (test) failure: build (failure)
...
PASS: lldb-api :: 
functionalities/thread/concurrent_events/TestConcurrentSignalDelayWatch.py (145 
of 2619)
PASS: lldb-api :: 
functionalities/plugins/python_os_plugin/stepping_plugin_threads/TestOSPluginStepping.py
 (146 of 2619)
PASS: lldb-api :: 
functionalities/tail_call_frames/ambiguous_tail_call_seq2/TestAmbiguousTailCallSeq2.py
 (147 of 2619)
PASS: lldb-api :: 
functionalities/data-formatter/data-formatter-stl/generic/bitset/TestDataFormatterGenericBitset.py
 (148 of 2619)
PASS: lldb-shell :: Subprocess/vfork-follow-child-wp.test (149 of 2619)
PASS: lldb-shell :: SymbolFile/DWARF/x86/dwp-separate-debug-file.cpp (150 of 
2619)
PASS: lldb-api :: python_api/file_handle/TestFileHandle.py (151 of 2619)
PASS: lldb-api :: lang/cpp/static_members/TestCPPStaticMembers.py (152 of 2619)
PASS: lldb-api :: 
functionalities/thread/concurrent_events/TestConcurrentWatchBreakDelay.py (153 
of 2619)
XFAIL: lldb-api :: functionalities/longjmp/TestLongjmp.py (154 of 2619)
FAIL: lldb-api :: functionalities/step_scripted/TestStepScripted.py (155 of 
2619)
 TEST 'lldb-api :: 
functionalities/step_scripted/TestStepScripted.py' FAILED 
Script:
--
/usr/bin/python3 
/home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/test/API/dotest.py -u 
CXXFLAGS -u CFLAGS --env ARCHIVER=/usr/bin/ar --env OBJCOPY=/usr/bin/objcopy 
--env LLVM_LIBS_DIR=/home/worker/2.0.1/lldb-x86_64-debian/build/./lib --env 
LLVM_INCLUDE_DIR=/home/worker/2.0.1/lldb-x86_64-debian/build/include --env 
LLVM_TOOLS_DIR=/home/worker/2.0.1/lldb-x86_64-debian/build/./bin --arch x86_64 
--build-dir /home/worker/2.0.1/lldb-x86_64-debian/build/lldb-test-build.noindex 
--lldb-module-cache-dir 
/home/worker/2.0.1/lldb-x86_64-debian/build/lldb-test-build.noindex/module-cache-lldb/lldb-api
 --clang-module-cache-dir 
/home/worker/2.0.1/lldb-x86_64-debian/build/lldb-test-build.noindex/module-cache-clang/lldb-api
 --executable /home/worker/2.0.1/lldb-x86_64-debian/build/./bin/lldb --compiler 
/home/worker/2.0.1/lldb-x86_64-debian/build/./bin/clang --dsymutil 
/home/worker/2.0.1/lldb-x86_64-debian/build/./bin/dsymutil --llvm-tools-dir 
/home/worker/2.0.1/lldb-x86_64-debian/build/./bin --lldb-obj-root 
/home/worker/2.0.1/lldb-x86_64-debian/build/tools/lldb --lldb-libs-dir 
/home/worker/2.0.1/lldb-x86_64-debian/build/./lib -t 
/home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/test/API/functionalities/step_scripted
 -p TestStepScripted.py
--
Exit Code: 1

Command Output (stdout):
--
lldb version 19.0.0git (https://github.com/llvm/llvm-project.git revision 
b949b6420775fe3466dc5a5bf34eab1d14e39e8f)
  clang revision b949b6420775fe3466dc5a5bf34eab1d14e39e8f
  llvm revision b949b6420775fe3466dc5a5bf34eab1d14e39e8f
Skipping the following test categories: ['libc++', 'dsym', 'gmodules', 
'debugserver', 'objc']
thread step-scripted -C Steps.StepReportsStopOthers -k token -v 140691819938496 
--run-mode all-threads
{'140691819938496': False}
thread step-scripted -C Steps.StepReportsStopOthers -k token -v 140691819938496 
--run-mode this-thread
{'140691819938496': True}
thread step-scripted -C Steps.StepReportsStopOthers -k token -v 140691819938496
{'140691819938496': True}
thread step-scripted -C Steps.StepReportsStopOthers -k token -v 140691819938496
{'140691819938496': False}

--
Command Output (stderr):
--
Change dir to: 
/home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/test/API/functionalities/step_scripted
runCmd: settings clear -all

output: 

runCmd: settings set symbols.enable-external-lookup false

output: 

runCmd: settings set target.inherit-tcc true

output: 


```

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


[Lldb-commits] [lldb] [clang] Fix incomplete umbrella warnings when building clang modules (NFC) (PR #96939)

2024-06-27 Thread Med Ismail Bennani via lldb-commits

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

>From 56392162f1a573570d280bebe905347069d9ea54 Mon Sep 17 00:00:00 2001
From: Med Ismail Bennani 
Date: Thu, 27 Jun 2024 10:53:24 -0700
Subject: [PATCH] Revert "[lldb/test] Mark TestStepScripted.py as XFAIL
 temporarily (#96894)"

This tentatively reverts commit 204c403b5215197ecdbdb68ca7f11402d6d9892b to
remove the XFAIL from the tests while also trying to fix them at the same time.

Signed-off-by: Med Ismail Bennani 
---
 lldb/test/API/functionalities/step_scripted/Steps.py | 1 +
 .../API/functionalities/step_scripted/TestStepScripted.py| 5 +
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/lldb/test/API/functionalities/step_scripted/Steps.py 
b/lldb/test/API/functionalities/step_scripted/Steps.py
index 3325dba753657..b121f71538ce4 100644
--- a/lldb/test/API/functionalities/step_scripted/Steps.py
+++ b/lldb/test/API/functionalities/step_scripted/Steps.py
@@ -92,6 +92,7 @@ def should_stop(self, event):
 
 def stop_description(self, stream):
 stream.Print(f"Stepped until {self.var_name} changed.")
+return True
 
 
 # This plan does nothing, but sets stop_mode to the
diff --git a/lldb/test/API/functionalities/step_scripted/TestStepScripted.py 
b/lldb/test/API/functionalities/step_scripted/TestStepScripted.py
index bb7479414dbbb..53901718019f9 100644
--- a/lldb/test/API/functionalities/step_scripted/TestStepScripted.py
+++ b/lldb/test/API/functionalities/step_scripted/TestStepScripted.py
@@ -7,6 +7,7 @@
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
 
+
 class StepScriptedTestCase(TestBase):
 NO_DEBUG_INFO_TESTCASE = True
 
@@ -15,14 +16,12 @@ def setUp(self):
 self.main_source_file = lldb.SBFileSpec("main.c")
 self.runCmd("command script import Steps.py")
 
-@expectedFailureAll()
 def test_standard_step_out(self):
 """Tests stepping with the scripted thread plan laying over a standard
 thread plan for stepping out."""
 self.build()
 self.step_out_with_scripted_plan("Steps.StepOut")
 
-@expectedFailureAll()
 def test_scripted_step_out(self):
 """Tests stepping with the scripted thread plan laying over an another
 scripted thread plan for stepping out."""
@@ -63,12 +62,10 @@ def test_misspelled_plan_name(self):
 # Make sure we didn't let the process run:
 self.assertEqual(stop_id, process.GetStopID(), "Process didn't run")
 
-@expectedFailureAll()
 def test_checking_variable(self):
 """Test that we can call SBValue API's from a scripted thread plan - 
using SBAPI's to step"""
 self.do_test_checking_variable(False)
 
-@expectedFailureAll()
 def test_checking_variable_cli(self):
 """Test that we can call SBValue API's from a scripted thread plan - 
using cli to step"""
 self.do_test_checking_variable(True)

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


[Lldb-commits] [lldb] New ThreadPlanSingleThreadTimeout to resolve potential deadlock in single thread stepping (PR #90930)

2024-06-27 Thread via lldb-commits


@@ -2838,6 +2844,14 @@ void PruneThreadPlans();
 return std::nullopt;
   }
 
+  /// Handle thread specific async interrupt and return the original thread
+  /// that requested the async interrupt. It can be null if original thread
+  /// has exited.

jimingham wrote:

You should say what the `description` string is for.

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


[Lldb-commits] [lldb] Revert "Revert "[lldb/test] Mark TestStepScripted.py as XFAIL temporarily (#96894)"" (PR #96946)

2024-06-27 Thread Med Ismail Bennani via lldb-commits

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

Reverts llvm/llvm-project#96942 since the test failures are still happening:

https://lab.llvm.org/buildbot/#/builders/162/builds/899/

>From 148a109bcd1592032bdda31694717bbeef5a976d Mon Sep 17 00:00:00 2001
From: Med Ismail Bennani 
Date: Thu, 27 Jun 2024 11:34:19 -0700
Subject: [PATCH] =?UTF-8?q?Revert=20"Revert=20"[lldb/test]=20Mark=20TestSt?=
 =?UTF-8?q?epScripted.py=20as=20XFAIL=20temporarily=20(#9=E2=80=A6"?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This reverts commit b949b6420775fe3466dc5a5bf34eab1d14e39e8f.
---
 lldb/test/API/functionalities/step_scripted/Steps.py | 1 -
 .../API/functionalities/step_scripted/TestStepScripted.py| 5 -
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/lldb/test/API/functionalities/step_scripted/Steps.py 
b/lldb/test/API/functionalities/step_scripted/Steps.py
index b121f71538ce4..3325dba753657 100644
--- a/lldb/test/API/functionalities/step_scripted/Steps.py
+++ b/lldb/test/API/functionalities/step_scripted/Steps.py
@@ -92,7 +92,6 @@ def should_stop(self, event):
 
 def stop_description(self, stream):
 stream.Print(f"Stepped until {self.var_name} changed.")
-return True
 
 
 # This plan does nothing, but sets stop_mode to the
diff --git a/lldb/test/API/functionalities/step_scripted/TestStepScripted.py 
b/lldb/test/API/functionalities/step_scripted/TestStepScripted.py
index 53901718019f9..bb7479414dbbb 100644
--- a/lldb/test/API/functionalities/step_scripted/TestStepScripted.py
+++ b/lldb/test/API/functionalities/step_scripted/TestStepScripted.py
@@ -7,7 +7,6 @@
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
 
-
 class StepScriptedTestCase(TestBase):
 NO_DEBUG_INFO_TESTCASE = True
 
@@ -16,12 +15,14 @@ def setUp(self):
 self.main_source_file = lldb.SBFileSpec("main.c")
 self.runCmd("command script import Steps.py")
 
+@expectedFailureAll()
 def test_standard_step_out(self):
 """Tests stepping with the scripted thread plan laying over a standard
 thread plan for stepping out."""
 self.build()
 self.step_out_with_scripted_plan("Steps.StepOut")
 
+@expectedFailureAll()
 def test_scripted_step_out(self):
 """Tests stepping with the scripted thread plan laying over an another
 scripted thread plan for stepping out."""
@@ -62,10 +63,12 @@ def test_misspelled_plan_name(self):
 # Make sure we didn't let the process run:
 self.assertEqual(stop_id, process.GetStopID(), "Process didn't run")
 
+@expectedFailureAll()
 def test_checking_variable(self):
 """Test that we can call SBValue API's from a scripted thread plan - 
using SBAPI's to step"""
 self.do_test_checking_variable(False)
 
+@expectedFailureAll()
 def test_checking_variable_cli(self):
 """Test that we can call SBValue API's from a scripted thread plan - 
using cli to step"""
 self.do_test_checking_variable(True)

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


[Lldb-commits] [lldb] 37fe152 - Revert "Revert "[lldb/test] Mark TestStepScripted.py as XFAIL temporarily (#96894)"" (#96946)

2024-06-27 Thread via lldb-commits

Author: Med Ismail Bennani
Date: 2024-06-27T11:34:47-07:00
New Revision: 37fe152e0c9f47b0a9ef9663df1ddecffef6f338

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

LOG: Revert "Revert "[lldb/test] Mark TestStepScripted.py as XFAIL temporarily 
(#96894)"" (#96946)

Reverts llvm/llvm-project#96942 since the test failures are still
happening:

https://lab.llvm.org/buildbot/#/builders/162/builds/899/

Added: 


Modified: 
lldb/test/API/functionalities/step_scripted/Steps.py
lldb/test/API/functionalities/step_scripted/TestStepScripted.py

Removed: 




diff  --git a/lldb/test/API/functionalities/step_scripted/Steps.py 
b/lldb/test/API/functionalities/step_scripted/Steps.py
index b121f71538ce4..3325dba753657 100644
--- a/lldb/test/API/functionalities/step_scripted/Steps.py
+++ b/lldb/test/API/functionalities/step_scripted/Steps.py
@@ -92,7 +92,6 @@ def should_stop(self, event):
 
 def stop_description(self, stream):
 stream.Print(f"Stepped until {self.var_name} changed.")
-return True
 
 
 # This plan does nothing, but sets stop_mode to the

diff  --git a/lldb/test/API/functionalities/step_scripted/TestStepScripted.py 
b/lldb/test/API/functionalities/step_scripted/TestStepScripted.py
index 53901718019f9..bb7479414dbbb 100644
--- a/lldb/test/API/functionalities/step_scripted/TestStepScripted.py
+++ b/lldb/test/API/functionalities/step_scripted/TestStepScripted.py
@@ -7,7 +7,6 @@
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
 
-
 class StepScriptedTestCase(TestBase):
 NO_DEBUG_INFO_TESTCASE = True
 
@@ -16,12 +15,14 @@ def setUp(self):
 self.main_source_file = lldb.SBFileSpec("main.c")
 self.runCmd("command script import Steps.py")
 
+@expectedFailureAll()
 def test_standard_step_out(self):
 """Tests stepping with the scripted thread plan laying over a standard
 thread plan for stepping out."""
 self.build()
 self.step_out_with_scripted_plan("Steps.StepOut")
 
+@expectedFailureAll()
 def test_scripted_step_out(self):
 """Tests stepping with the scripted thread plan laying over an another
 scripted thread plan for stepping out."""
@@ -62,10 +63,12 @@ def test_misspelled_plan_name(self):
 # Make sure we didn't let the process run:
 self.assertEqual(stop_id, process.GetStopID(), "Process didn't run")
 
+@expectedFailureAll()
 def test_checking_variable(self):
 """Test that we can call SBValue API's from a scripted thread plan - 
using SBAPI's to step"""
 self.do_test_checking_variable(False)
 
+@expectedFailureAll()
 def test_checking_variable_cli(self):
 """Test that we can call SBValue API's from a scripted thread plan - 
using cli to step"""
 self.do_test_checking_variable(True)



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


[Lldb-commits] [lldb] Revert "Revert "[lldb/test] Mark TestStepScripted.py as XFAIL temporarily (#96894)"" (PR #96946)

2024-06-27 Thread Med Ismail Bennani via lldb-commits

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


[Lldb-commits] [lldb] Revert "Revert "[lldb/test] Mark TestStepScripted.py as XFAIL temporarily (#96894)"" (PR #96946)

2024-06-27 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Med Ismail Bennani (medismailben)


Changes

Reverts llvm/llvm-project#96942 since the test failures are still 
happening:

https://lab.llvm.org/buildbot/#/builders/162/builds/899/

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


2 Files Affected:

- (modified) lldb/test/API/functionalities/step_scripted/Steps.py (-1) 
- (modified) lldb/test/API/functionalities/step_scripted/TestStepScripted.py 
(+4-1) 


``diff
diff --git a/lldb/test/API/functionalities/step_scripted/Steps.py 
b/lldb/test/API/functionalities/step_scripted/Steps.py
index b121f71538ce4..3325dba753657 100644
--- a/lldb/test/API/functionalities/step_scripted/Steps.py
+++ b/lldb/test/API/functionalities/step_scripted/Steps.py
@@ -92,7 +92,6 @@ def should_stop(self, event):
 
 def stop_description(self, stream):
 stream.Print(f"Stepped until {self.var_name} changed.")
-return True
 
 
 # This plan does nothing, but sets stop_mode to the
diff --git a/lldb/test/API/functionalities/step_scripted/TestStepScripted.py 
b/lldb/test/API/functionalities/step_scripted/TestStepScripted.py
index 53901718019f9..bb7479414dbbb 100644
--- a/lldb/test/API/functionalities/step_scripted/TestStepScripted.py
+++ b/lldb/test/API/functionalities/step_scripted/TestStepScripted.py
@@ -7,7 +7,6 @@
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
 
-
 class StepScriptedTestCase(TestBase):
 NO_DEBUG_INFO_TESTCASE = True
 
@@ -16,12 +15,14 @@ def setUp(self):
 self.main_source_file = lldb.SBFileSpec("main.c")
 self.runCmd("command script import Steps.py")
 
+@expectedFailureAll()
 def test_standard_step_out(self):
 """Tests stepping with the scripted thread plan laying over a standard
 thread plan for stepping out."""
 self.build()
 self.step_out_with_scripted_plan("Steps.StepOut")
 
+@expectedFailureAll()
 def test_scripted_step_out(self):
 """Tests stepping with the scripted thread plan laying over an another
 scripted thread plan for stepping out."""
@@ -62,10 +63,12 @@ def test_misspelled_plan_name(self):
 # Make sure we didn't let the process run:
 self.assertEqual(stop_id, process.GetStopID(), "Process didn't run")
 
+@expectedFailureAll()
 def test_checking_variable(self):
 """Test that we can call SBValue API's from a scripted thread plan - 
using SBAPI's to step"""
 self.do_test_checking_variable(False)
 
+@expectedFailureAll()
 def test_checking_variable_cli(self):
 """Test that we can call SBValue API's from a scripted thread plan - 
using cli to step"""
 self.do_test_checking_variable(True)

``




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


[Lldb-commits] [lldb] Revert "[lldb/test] Mark TestStepScripted.py as XFAIL temporarily (#96894)" (PR #96942)

2024-06-27 Thread LLVM Continuous Integration via lldb-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `lldb-aarch64-ubuntu` 
running on `linaro-lldb-aarch64-ubuntu` while building `lldb` at step 6 "test".

Full details are available at: 
https://lab.llvm.org/buildbot/#/builders/59/builds/678

Here is the relevant piece of the build log for the reference:
```
Step 6 (test) failure: build (failure)
...
PASS: lldb-api :: functionalities/signal/handle-abrt/TestHandleAbort.py (567 of 
1981)
PASS: lldb-api :: functionalities/source-map/TestTargetSourceMap.py (568 of 
1981)
PASS: lldb-api :: functionalities/signal/TestSendSignal.py (569 of 1981)
PASS: lldb-api :: functionalities/signal/handle-segv/TestHandleSegv.py (570 of 
1981)
PASS: lldb-api :: functionalities/stats_api/TestStatisticsAPI.py (571 of 1981)
PASS: lldb-api :: functionalities/step-avoids-regexp/TestStepAvoidsRegexp.py 
(572 of 1981)
PASS: lldb-api :: commands/process/attach/TestProcessAttach.py (573 of 1981)
PASS: lldb-api :: functionalities/signal/raise/TestRaise.py (574 of 1981)
PASS: lldb-api :: functionalities/gdb_remote_client/TestPlatformClient.py (575 
of 1981)
PASS: lldb-api :: functionalities/step-avoids-no-debug/TestStepNoDebug.py (576 
of 1981)
FAIL: lldb-api :: functionalities/step_scripted/TestStepScripted.py (577 of 
1981)
 TEST 'lldb-api :: 
functionalities/step_scripted/TestStepScripted.py' FAILED 
Script:
--
/usr/bin/python3.8 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/API/dotest.py
 -u CXXFLAGS -u CFLAGS --env ARCHIVER=/usr/local/bin/llvm-ar --env 
OBJCOPY=/usr/bin/llvm-objcopy --env 
LLVM_LIBS_DIR=/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./lib --env 
LLVM_INCLUDE_DIR=/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/include 
--env LLVM_TOOLS_DIR=/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin 
--arch aarch64 --build-dir 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/lldb-test-build.noindex 
--lldb-module-cache-dir 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/lldb-test-build.noindex/module-cache-lldb/lldb-api
 --clang-module-cache-dir 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/lldb-test-build.noindex/module-cache-clang/lldb-api
 --executable /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin/lldb 
--compiler /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin/clang 
--dsymutil /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin/dsymutil 
--llvm-tools-dir /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin 
--lldb-obj-root /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/tools/lldb 
--lldb-libs-dir /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./lib 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/API/functionalities/step_scripted
 -p TestStepScripted.py
--
Exit Code: 1

Command Output (stdout):
--
lldb version 19.0.0git (https://github.com/llvm/llvm-project.git revision 
b949b6420775fe3466dc5a5bf34eab1d14e39e8f)
  clang revision b949b6420775fe3466dc5a5bf34eab1d14e39e8f
  llvm revision b949b6420775fe3466dc5a5bf34eab1d14e39e8f
Skipping the following test categories: ['libc++', 'dsym', 'gmodules', 
'debugserver', 'objc']

--
Command Output (stderr):
--
FAIL: LLDB 
(/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: 
test_checking_variable (TestStepScripted.StepScriptedTestCase)
FAIL: LLDB 
(/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: 
test_checking_variable_cli (TestStepScripted.StepScriptedTestCase)
PASS: LLDB 
(/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: 
test_misspelled_plan_name (TestStepScripted.StepScriptedTestCase)
FAIL: LLDB 
(/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: 
test_scripted_step_out (TestStepScripted.StepScriptedTestCase)
FAIL: LLDB 
(/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: 
test_standard_step_out (TestStepScripted.StepScriptedTestCase)
PASS: LLDB 
(/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: 
test_stop_others_from_command (TestStepScripted.StepScriptedTestCase)
==
FAIL: test_checking_variable (TestStepScripted.StepScriptedTestCase)
   Test that we can call SBValue API's from a scripted thread plan - using 
SBAPI's to step
--
Traceback (most recent call last):
  File 
"/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/API/functionalities/step_scripted/TestStepScripted.py",
 line 67, in test_checking_variable
self.do_test_checking_variable(False)
  File 
"/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/API/functionalities/step_scripted/TestStepScripted.py",
 line 113, in do_test_checking_variable
self.assertIn("Stepped until foo changed", desc, "Got right stop 
description")
AssertionError: 'Stepped until f

[Lldb-commits] [lldb] [LLDB] Add AST node classes, functions, etc. for Data Inspection Lang… (PR #95738)

2024-06-27 Thread Andy Hippo via lldb-commits


@@ -0,0 +1,165 @@
+(* LLDB Debug Expressions, a subset of C++ *)
+(* Insired by https://www.nongnu.org/hcb *)
+
+expression = assignment_expression ;
+
+assignment_expression = conditional_expression
+logical_or_expression assignment_operator 
assignment_expression ;
+
+assignment_operator = "="
+| "*="
+| "/="
+| "%="
+| "+="
+| "-="
+| ">>="
+| "<<="
+| "&="
+| "^="
+| "|=" ;
+
+conditional_expression = logical_or_expression
+   | logical_or_expression "?" expression ":" 
assignment_expression ;
+
+logical_or_expression = logical_and_expression {"||" logical_and_expression} ;
+
+logical_and_expression = inclusive_or_expression {"&&" 
inclusive_or_expression} ;
+
+inclusive_or_expression = exclusive_or_expression {"|" 
exclusive_or_expression} ;
+
+exclusive_or_expression = and_expression {"^" and_expression} ;
+
+and_expression = equality_expression {"&" equality_expression} ;
+
+equality_expression = relational_expression {"==" relational_expression}
+| relational_expression {"!=" relational_expression} ;
+
+relational_expression = shift_expression {"<" shift_expression}
+  | shift_expression {">" shift_expression}
+  | shift_expression {"<=" shift_expression}
+  | shift_expression {">=" shift_expression} ;
+
+shift_expression = additive_expression {"<<" additive_expression}
+ | additive_expression {">>" additive_expression} ;
+
+additive_expression = multiplicative_expression {"+" multiplicative_expression}
+| multiplicative_expression {"-" 
multiplicative_expression} ;
+
+multiplicative_expression = cast_expression {"*" cast_expression}
+  | cast_expression {"/" cast_expression}
+  | cast_expression {"%" cast_expression} ;
+
+cast_expression = unary_expression
+| "(" type_id ")" cast_expression ;
+
+unary_expression = postfix_expression

werat wrote:

It is pretty useful to be able to easily change the program state and afaik 
it's already possible with `expr` command. Generally other debugger allow this 
as well (e.g. Visual Studio), so I think it's a reasonable thing to do. 
However, for increments specifically there's a deeper reason here (and I would 
agree that they probably shouldn't be available for general use). See my big 
comment below for justification.

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


[Lldb-commits] [lldb] [LLDB] Add AST node classes, functions, etc. for Data Inspection Lang… (PR #95738)

2024-06-27 Thread Andy Hippo via lldb-commits


@@ -0,0 +1,165 @@
+(* LLDB Debug Expressions, a subset of C++ *)
+(* Insired by https://www.nongnu.org/hcb *)
+
+expression = assignment_expression ;
+
+assignment_expression = conditional_expression
+logical_or_expression assignment_operator 
assignment_expression ;
+
+assignment_operator = "="
+| "*="
+| "/="
+| "%="
+| "+="
+| "-="
+| ">>="
+| "<<="
+| "&="
+| "^="
+| "|=" ;
+
+conditional_expression = logical_or_expression
+   | logical_or_expression "?" expression ":" 
assignment_expression ;
+
+logical_or_expression = logical_and_expression {"||" logical_and_expression} ;
+
+logical_and_expression = inclusive_or_expression {"&&" 
inclusive_or_expression} ;
+
+inclusive_or_expression = exclusive_or_expression {"|" 
exclusive_or_expression} ;
+
+exclusive_or_expression = and_expression {"^" and_expression} ;
+
+and_expression = equality_expression {"&" equality_expression} ;
+
+equality_expression = relational_expression {"==" relational_expression}
+| relational_expression {"!=" relational_expression} ;
+
+relational_expression = shift_expression {"<" shift_expression}
+  | shift_expression {">" shift_expression}
+  | shift_expression {"<=" shift_expression}
+  | shift_expression {">=" shift_expression} ;
+
+shift_expression = additive_expression {"<<" additive_expression}
+ | additive_expression {">>" additive_expression} ;
+
+additive_expression = multiplicative_expression {"+" multiplicative_expression}
+| multiplicative_expression {"-" 
multiplicative_expression} ;
+
+multiplicative_expression = cast_expression {"*" cast_expression}
+  | cast_expression {"/" cast_expression}
+  | cast_expression {"%" cast_expression} ;
+
+cast_expression = unary_expression
+| "(" type_id ")" cast_expression ;
+
+unary_expression = postfix_expression
+ | "++" cast_expression
+ | "--" cast_expression
+ | unary_operator cast_expression
+ | "sizeof" unary_expression
+ | "sizeof" "(" type_id ")" ;
+
+unary_operator = "*" | "&" | "+" | "-" | "!" | "~" ;
+
+postfix_expression = primary_expression
+   | postfix_expression "[" expression "]"
+   | postfix_expression "." id_expression
+   | postfix_expression "->" id_expression
+   | postfix_expression "++"
+   | postfix_expression "--"
+   | static_cast "<" type_id ">" "(" expression ")"
+   | dynamic_cast "<" type_id ">" "(" expression ")"
+   | reinterpret_cast "<" type_id ">" "(" expression ")" ;
+
+primary_expression = numeric_literal
+   | boolean_literal
+   | pointer_literal
+   | id_expression
+   | "this"
+   | "(" expression ")"
+   | builtin_func ;
+
+type_id = type_specifier_seq [abstract_declarator] ;
+
+type_specifier_seq = type_specifier [type_specifier_seq] ;
+
+type_specifier = simple_type_specifier
+   | cv_qualifier ;
+
+simple_type_specifier = ["::"] [nested_name_specifier] type_name
+  | "char"
+  | "char16_t"
+  | "char32_t"
+  | "wchar_t"
+  | "bool"
+  | "short"
+  | "int"
+  | "long"
+  | "signed"
+  | "unsigned"
+  | "float"
+  | "double"
+  | "void" ;
+
+nested_name_specifier = type_name "::"
+  | namespace_name '::'
+  | nested_name_specifier identifier "::"
+  | nested_name_specifier simple_template_id "::";
+
+type_name = class_name
+  | enum_name
+  | typedef_name
+  | simple_template_id ;
+
+class_name = identifier ;
+
+enum_name = identifier ;
+
+typedef_name = identifier ;
+
+simple_template_id = template_name "<" [template_argument_list] ">" ;
+
+template_name = identifier ;
+
+template_argument_list = template_argument
+   | template_argument_list "," template_argument ;
+
+template_argument = type_id
+  | numeric_literal
+  | id_expression ;
+
+namespace_name = identifier ;
+
+cv_qualifier = "const" | "volatile" ;
+
+cv_qualifier_seq = cv_qualifier [cv_qualifier_seq] ;
+
+abstract_declarator = ptr_operator [abstract_declarator] ;
+
+ptr_operator = "*" [cv_qualifier_seq]
+ | "&" ;
+
+id_express

[Lldb-commits] [lldb] [LLDB] Add AST node classes, functions, etc. for Data Inspection Lang… (PR #95738)

2024-06-27 Thread Andy Hippo via lldb-commits


@@ -0,0 +1,165 @@
+(* LLDB Debug Expressions, a subset of C++ *)
+(* Insired by https://www.nongnu.org/hcb *)
+
+expression = assignment_expression ;
+
+assignment_expression = conditional_expression
+logical_or_expression assignment_operator 
assignment_expression ;
+
+assignment_operator = "="
+| "*="
+| "/="
+| "%="
+| "+="
+| "-="
+| ">>="
+| "<<="
+| "&="
+| "^="
+| "|=" ;
+
+conditional_expression = logical_or_expression
+   | logical_or_expression "?" expression ":" 
assignment_expression ;
+
+logical_or_expression = logical_and_expression {"||" logical_and_expression} ;
+
+logical_and_expression = inclusive_or_expression {"&&" 
inclusive_or_expression} ;
+
+inclusive_or_expression = exclusive_or_expression {"|" 
exclusive_or_expression} ;
+
+exclusive_or_expression = and_expression {"^" and_expression} ;
+
+and_expression = equality_expression {"&" equality_expression} ;
+
+equality_expression = relational_expression {"==" relational_expression}
+| relational_expression {"!=" relational_expression} ;
+
+relational_expression = shift_expression {"<" shift_expression}
+  | shift_expression {">" shift_expression}
+  | shift_expression {"<=" shift_expression}
+  | shift_expression {">=" shift_expression} ;
+
+shift_expression = additive_expression {"<<" additive_expression}
+ | additive_expression {">>" additive_expression} ;
+
+additive_expression = multiplicative_expression {"+" multiplicative_expression}
+| multiplicative_expression {"-" 
multiplicative_expression} ;
+
+multiplicative_expression = cast_expression {"*" cast_expression}
+  | cast_expression {"/" cast_expression}
+  | cast_expression {"%" cast_expression} ;
+
+cast_expression = unary_expression
+| "(" type_id ")" cast_expression ;
+
+unary_expression = postfix_expression
+ | "++" cast_expression
+ | "--" cast_expression
+ | unary_operator cast_expression
+ | "sizeof" unary_expression
+ | "sizeof" "(" type_id ")" ;
+
+unary_operator = "*" | "&" | "+" | "-" | "!" | "~" ;
+
+postfix_expression = primary_expression
+   | postfix_expression "[" expression "]"
+   | postfix_expression "." id_expression
+   | postfix_expression "->" id_expression
+   | postfix_expression "++"
+   | postfix_expression "--"
+   | static_cast "<" type_id ">" "(" expression ")"
+   | dynamic_cast "<" type_id ">" "(" expression ")"
+   | reinterpret_cast "<" type_id ">" "(" expression ")" ;
+
+primary_expression = numeric_literal
+   | boolean_literal
+   | pointer_literal
+   | id_expression
+   | "this"
+   | "(" expression ")"
+   | builtin_func ;
+
+type_id = type_specifier_seq [abstract_declarator] ;
+
+type_specifier_seq = type_specifier [type_specifier_seq] ;
+
+type_specifier = simple_type_specifier
+   | cv_qualifier ;
+
+simple_type_specifier = ["::"] [nested_name_specifier] type_name
+  | "char"
+  | "char16_t"
+  | "char32_t"
+  | "wchar_t"
+  | "bool"
+  | "short"
+  | "int"
+  | "long"
+  | "signed"
+  | "unsigned"
+  | "float"
+  | "double"
+  | "void" ;
+
+nested_name_specifier = type_name "::"
+  | namespace_name '::'
+  | nested_name_specifier identifier "::"
+  | nested_name_specifier simple_template_id "::";
+
+type_name = class_name
+  | enum_name
+  | typedef_name
+  | simple_template_id ;
+
+class_name = identifier ;
+
+enum_name = identifier ;
+
+typedef_name = identifier ;
+
+simple_template_id = template_name "<" [template_argument_list] ">" ;

werat wrote:

Typically this is used in casts like `((Foo)some_ptr)->field`. In the 
world of dynamic typing this is not necessary, however VisualStudio debugger 
doesn't support dynamic typing like this, so everyone is casting things.

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


[Lldb-commits] [lldb] [LLDB] Add AST node classes, functions, etc. for Data Inspection Lang… (PR #95738)

2024-06-27 Thread Andy Hippo via lldb-commits


@@ -0,0 +1,165 @@
+(* LLDB Debug Expressions, a subset of C++ *)
+(* Insired by https://www.nongnu.org/hcb *)
+
+expression = assignment_expression ;
+
+assignment_expression = conditional_expression
+logical_or_expression assignment_operator 
assignment_expression ;
+
+assignment_operator = "="
+| "*="
+| "/="
+| "%="
+| "+="
+| "-="
+| ">>="
+| "<<="
+| "&="
+| "^="
+| "|=" ;
+
+conditional_expression = logical_or_expression
+   | logical_or_expression "?" expression ":" 
assignment_expression ;
+
+logical_or_expression = logical_and_expression {"||" logical_and_expression} ;
+
+logical_and_expression = inclusive_or_expression {"&&" 
inclusive_or_expression} ;
+
+inclusive_or_expression = exclusive_or_expression {"|" 
exclusive_or_expression} ;
+
+exclusive_or_expression = and_expression {"^" and_expression} ;
+
+and_expression = equality_expression {"&" equality_expression} ;
+
+equality_expression = relational_expression {"==" relational_expression}
+| relational_expression {"!=" relational_expression} ;
+
+relational_expression = shift_expression {"<" shift_expression}
+  | shift_expression {">" shift_expression}
+  | shift_expression {"<=" shift_expression}
+  | shift_expression {">=" shift_expression} ;
+
+shift_expression = additive_expression {"<<" additive_expression}
+ | additive_expression {">>" additive_expression} ;
+
+additive_expression = multiplicative_expression {"+" multiplicative_expression}
+| multiplicative_expression {"-" 
multiplicative_expression} ;
+
+multiplicative_expression = cast_expression {"*" cast_expression}
+  | cast_expression {"/" cast_expression}
+  | cast_expression {"%" cast_expression} ;
+
+cast_expression = unary_expression
+| "(" type_id ")" cast_expression ;
+
+unary_expression = postfix_expression
+ | "++" cast_expression
+ | "--" cast_expression
+ | unary_operator cast_expression
+ | "sizeof" unary_expression
+ | "sizeof" "(" type_id ")" ;
+
+unary_operator = "*" | "&" | "+" | "-" | "!" | "~" ;
+
+postfix_expression = primary_expression
+   | postfix_expression "[" expression "]"
+   | postfix_expression "." id_expression
+   | postfix_expression "->" id_expression
+   | postfix_expression "++"
+   | postfix_expression "--"
+   | static_cast "<" type_id ">" "(" expression ")"
+   | dynamic_cast "<" type_id ">" "(" expression ")"
+   | reinterpret_cast "<" type_id ">" "(" expression ")" ;

werat wrote:

See the reply above, C++-style casts are often used in NatVis (visual studio 
debugger), which `lldb-eval` originally aimed to support.

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


[Lldb-commits] [lldb] [LLDB] Add AST node classes, functions, etc. for Data Inspection Lang… (PR #95738)

2024-06-27 Thread Andy Hippo via lldb-commits

werat wrote:

Providing more context for answers to Michael's questions.

The original motivation for `lldb-eval` (https://github.com/google/lldb-eval, 
which is a predecessor for DIL) was to support the evaluation of expressions 
used in NatVis rules. 
[NatVis](https://learn.microsoft.com/en-us/visualstudio/debugger/create-custom-views-of-native-objects?view=vs-2022)
 visualizers support complex logic, including C++-like casts, restricted 
function calls and state-changing operations like increment/decrement.

To be able to evaluate those expressions as is, lldb-eval had to support all of 
the commonly used features, hence the extensive and somewhat selective list of 
supported features :)

For example, `reinterpret_cast<>` is commonly used to cast pointers to 
structs/classes in order to access their fields (example -- 
https://github.com/godotengine/godot/blob/cae2f853dcd1ecc26ca68de08cec62089dee1f26/platform/windows/godot.natvis#L146).
 Visual Studio NatVis evaluator doesn't support dynamic typing (e.g. resolving 
`foo->bar`, if `bar` is defined in a subclass), therefore the casts are 
necessary. In the world of dynamic typing this may be not necessary.

State altering operations like increment/decrement are used in advanced 
visualizers like `` for control flow -- e.g. you can define a 
loop variable, then increment it and break out of the loop under some 
condition. A real life example -- 
https://github.com/GaijinEntertainment/DagorEngine/blob/8b340d10814f06aa364e75769d406ec7373c5574/prog/_jBuild/_natvis/dagor_types.natvis#L746.
 It's not visible in the grammar, but `lldb-eval` has additional knobs for 
controlling when state changing is allowed. If I recall correctly, this can be 
done in two cases:
1) the variable being incremented is a "context variable", e.g. an artificial 
SBValue passed to the expression as context, which doesn't exist in the 
program. See some explanation and example here -- 
https://werat.dev/blog/blazing-fast-expression-evaluation-for-c-in-lldb/#maintaning-state
2) when side effects are explecitely allowed via options -- 
https://github.com/google/lldb-eval/blob/323d48f0b06d7dcf6ed70cdde17b42285450a32a/lldb-eval/api.h#L77.
 In our debugger this was disabled for all visualizer-related evaluations and 
enabled for one-off interactive evaluations, basically mimicking the behaviour 
of Visual Studio debugger.



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


[Lldb-commits] [lldb] New ThreadPlanSingleThreadTimeout to resolve potential deadlock in single thread stepping (PR #90930)

2024-06-27 Thread via lldb-commits


@@ -0,0 +1,40 @@
+//===-- TimeoutResumeAll.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_TARGET_TIMEOUTRESUMEALL_H
+#define LLDB_TARGET_TIMEOUTRESUMEALL_H
+
+#include "lldb/Target/ThreadPlanSingleThreadTimeout.h"
+
+namespace lldb_private {
+
+// Mixin class that provides capability for ThreadPlan that supports single

jimingham wrote:

Grammar:

// Mixin class that provides the capability for ThreadPlan to support single
// thread execution that resumes all threads after a timeout.



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


[Lldb-commits] [lldb] [lldb] Use `Address` to setup breakpoint (PR #94794)

2024-06-27 Thread Julian Lettner via lldb-commits


@@ -90,17 +90,9 @@ void InstrumentationRuntimeASanLibsanitizers::Activate() {
   if (!process_sp)
 return;
 
-  lldb::ModuleSP module_sp = GetRuntimeModuleSP();
-
   Breakpoint *breakpoint = ReportRetriever::SetupBreakpoint(
-  module_sp, process_sp, ConstString("sanitizers_address_on_report"));
-
-  if (!breakpoint) {
-breakpoint = ReportRetriever::SetupBreakpoint(
-module_sp, process_sp,
-ConstString("_Z22raise_sanitizers_error23sanitizer_error_context"));
-  }
-
+  GetRuntimeModuleSP(), process_sp,
+  ConstString("sanitizers_address_on_report"));

yln wrote:

Hi @clayborg, I don't follow.  Can you elaborate?

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


[Lldb-commits] [lldb] [lldb] Use `Address` to setup breakpoint (PR #94794)

2024-06-27 Thread Usama Hameed via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb] [ObjectFileMachO] BSS segments are loadable segments (PR #96983)

2024-06-27 Thread Jason Molenda via lldb-commits

https://github.com/jasonmolenda created 
https://github.com/llvm/llvm-project/pull/96983

ObjectFileMachO::SetLoadAddress sets the address of each segment in a binary in 
a Target, but it ignores segments that are not loaded in the virtual address 
space.  It was marking segments that were purely BSS -- having no content in 
the file, but in zero-initialized memory when running in the virtual address 
space -- as not-loadable, unless they were named "DATA".  This works pretty 
well for typical userland binaries, but in less Darwin environments, there may 
be BSS segments with other names, that ARE loadable.

I looked at the origin of SectionIsLoadable's check for this, and it was a 
cleanup by Greg in 2018 where we had three different implementations of the 
idea in ObjectFileMachO and one of them skipped zero-file-size segments (BSS), 
which made it into the centralized SectionIsLoadable method.

Also add some logging to the DynamicLoader log channel when loading a binary - 
it's the first place I look when debugging segment address setting bugs, and it 
wasn't emitting anything.

rdar://129870649

>From 6bd566504355e8d50b9c922df9ebce18e07a726f Mon Sep 17 00:00:00 2001
From: Jason Molenda 
Date: Thu, 27 Jun 2024 15:34:48 -0700
Subject: [PATCH] [lldb] [ObjectFileMachO] BSS segments are loadable segments

ObjectFileMachO::SetLoadAddress sets the address of each segment
in a binary in a Target, but it ignores segments that are not loaded
in the virtual address space.  It was marking segments that were
purely BSS -- having no content in the file, but in zero-initialized
memory when running in the virtual address space -- as not-loadable,
unless they were named "DATA".  This works pretty well for typical
userland binaries, but in less Darwin environments, there may be
BSS segments with other names, that ARE loadable.

I looked at the origin of SectionIsLoadable's check for this, and
it was a cleanup by Greg in 2018 where we had three different
implementations of the idea in ObjectFileMachO and one of them
skipped zero-file-size segments (BSS), which made it into the
centralized SectionIsLoadable method.

Also add some logging to the DynamicLoader log channel when loading
a binary - it's the first place I look when debugging segment address
setting bugs, and it wasn't emitting anything.

rdar://129870649
---
 .../ObjectFile/Mach-O/ObjectFileMachO.cpp | 31 ---
 1 file changed, 26 insertions(+), 5 deletions(-)

diff --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp 
b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
index 2979bf69bf762..164c4409747e0 100644
--- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -6159,10 +6159,6 @@ Section *ObjectFileMachO::GetMachHeaderSection() {
 bool ObjectFileMachO::SectionIsLoadable(const Section *section) {
   if (!section)
 return false;
-  const bool is_dsym = (m_header.filetype == MH_DSYM);
-  if (section->GetFileSize() == 0 && !is_dsym &&
-  section->GetName() != GetSegmentNameDATA())
-return false;
   if (section->IsThreadSpecific())
 return false;
   if (GetModule().get() != section->GetModule().get())
@@ -6202,6 +6198,7 @@ lldb::addr_t 
ObjectFileMachO::CalculateSectionLoadAddressForMemoryImage(
 
 bool ObjectFileMachO::SetLoadAddress(Target &target, lldb::addr_t value,
  bool value_is_offset) {
+  Log *log(GetLog(LLDBLog::DynamicLoader));
   ModuleSP module_sp = GetModule();
   if (!module_sp)
 return false;
@@ -6217,17 +6214,37 @@ bool ObjectFileMachO::SetLoadAddress(Target &target, 
lldb::addr_t value,
   // malformed.
   const bool warn_multiple = true;
 
+  if (log) {
+std::string binary_description;
+if (GetFileSpec()) {
+  binary_description += "path='";
+  binary_description += GetFileSpec().GetPath();
+  binary_description += "' ";
+}
+if (GetUUID()) {
+  binary_description += "uuid=";
+  binary_description += GetUUID().GetAsString();
+}
+LLDB_LOGF(log, "ObjectFileMachO::SetLoadAddress %s",
+  binary_description.c_str());
+  }
   if (value_is_offset) {
 // "value" is an offset to apply to each top level segment
 for (size_t sect_idx = 0; sect_idx < num_sections; ++sect_idx) {
   // Iterate through the object file sections to find all of the
   // sections that size on disk (to avoid __PAGEZERO) and load them
   SectionSP section_sp(section_list->GetSectionAtIndex(sect_idx));
-  if (SectionIsLoadable(section_sp.get()))
+  if (SectionIsLoadable(section_sp.get())) {
+LLDB_LOGF(log,
+  "ObjectFileMachO::SetLoadAddress segment '%s' load addr is "
+  "0x%" PRIx64,
+  section_sp->GetName().AsCString(),
+  section_sp->GetFileAddress() + value);
 if (target.GetSectionLoadList().SetSectionLoadAddress(
 section_sp, se

[Lldb-commits] [lldb] [lldb] [ObjectFileMachO] BSS segments are loadable segments (PR #96983)

2024-06-27 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Jason Molenda (jasonmolenda)


Changes

ObjectFileMachO::SetLoadAddress sets the address of each segment in a binary in 
a Target, but it ignores segments that are not loaded in the virtual address 
space.  It was marking segments that were purely BSS -- having no content in 
the file, but in zero-initialized memory when running in the virtual address 
space -- as not-loadable, unless they were named "DATA".  This works pretty 
well for typical userland binaries, but in less Darwin environments, there may 
be BSS segments with other names, that ARE loadable.

I looked at the origin of SectionIsLoadable's check for this, and it was a 
cleanup by Greg in 2018 where we had three different implementations of the 
idea in ObjectFileMachO and one of them skipped zero-file-size segments (BSS), 
which made it into the centralized SectionIsLoadable method.

Also add some logging to the DynamicLoader log channel when loading a binary - 
it's the first place I look when debugging segment address setting bugs, and it 
wasn't emitting anything.

rdar://129870649

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


1 Files Affected:

- (modified) lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp (+26-5) 


``diff
diff --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp 
b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
index 2979bf69bf762..164c4409747e0 100644
--- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -6159,10 +6159,6 @@ Section *ObjectFileMachO::GetMachHeaderSection() {
 bool ObjectFileMachO::SectionIsLoadable(const Section *section) {
   if (!section)
 return false;
-  const bool is_dsym = (m_header.filetype == MH_DSYM);
-  if (section->GetFileSize() == 0 && !is_dsym &&
-  section->GetName() != GetSegmentNameDATA())
-return false;
   if (section->IsThreadSpecific())
 return false;
   if (GetModule().get() != section->GetModule().get())
@@ -6202,6 +6198,7 @@ lldb::addr_t 
ObjectFileMachO::CalculateSectionLoadAddressForMemoryImage(
 
 bool ObjectFileMachO::SetLoadAddress(Target &target, lldb::addr_t value,
  bool value_is_offset) {
+  Log *log(GetLog(LLDBLog::DynamicLoader));
   ModuleSP module_sp = GetModule();
   if (!module_sp)
 return false;
@@ -6217,17 +6214,37 @@ bool ObjectFileMachO::SetLoadAddress(Target &target, 
lldb::addr_t value,
   // malformed.
   const bool warn_multiple = true;
 
+  if (log) {
+std::string binary_description;
+if (GetFileSpec()) {
+  binary_description += "path='";
+  binary_description += GetFileSpec().GetPath();
+  binary_description += "' ";
+}
+if (GetUUID()) {
+  binary_description += "uuid=";
+  binary_description += GetUUID().GetAsString();
+}
+LLDB_LOGF(log, "ObjectFileMachO::SetLoadAddress %s",
+  binary_description.c_str());
+  }
   if (value_is_offset) {
 // "value" is an offset to apply to each top level segment
 for (size_t sect_idx = 0; sect_idx < num_sections; ++sect_idx) {
   // Iterate through the object file sections to find all of the
   // sections that size on disk (to avoid __PAGEZERO) and load them
   SectionSP section_sp(section_list->GetSectionAtIndex(sect_idx));
-  if (SectionIsLoadable(section_sp.get()))
+  if (SectionIsLoadable(section_sp.get())) {
+LLDB_LOGF(log,
+  "ObjectFileMachO::SetLoadAddress segment '%s' load addr is "
+  "0x%" PRIx64,
+  section_sp->GetName().AsCString(),
+  section_sp->GetFileAddress() + value);
 if (target.GetSectionLoadList().SetSectionLoadAddress(
 section_sp, section_sp->GetFileAddress() + value,
 warn_multiple))
   ++num_loaded_sections;
+  }
 }
   } else {
 // "value" is the new base address of the mach_header, adjust each
@@ -6242,6 +6259,10 @@ bool ObjectFileMachO::SetLoadAddress(Target &target, 
lldb::addr_t value,
 CalculateSectionLoadAddressForMemoryImage(
 value, mach_header_section, section_sp.get());
 if (section_load_addr != LLDB_INVALID_ADDRESS) {
+  LLDB_LOGF(log,
+"ObjectFileMachO::SetLoadAddress segment '%s' load addr is 
"
+"0x%" PRIx64,
+section_sp->GetName().AsCString(), section_load_addr);
   if (target.GetSectionLoadList().SetSectionLoadAddress(
   section_sp, section_load_addr, warn_multiple))
 ++num_loaded_sections;

``




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


[Lldb-commits] [clang] [lldb] [llvm] [BOLT][NFC] Move CallGraph from Passes to Core (PR #96922)

2024-06-27 Thread shaw young via lldb-commits

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


[Lldb-commits] [lldb] [lldb/Interpreter] Discard ScriptedThreadPlan::GetStopDescription return value (PR #96985)

2024-06-27 Thread Med Ismail Bennani via lldb-commits

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

This patch changes `ScriptedThreadPlan::GetStopDescription` behaviour by 
discarding its return value since it is optional in the first place (i.e. the 
user doesn't need to provide a return value in their implementation).

This patch also re-enables the tests that were XFAIL'd previously.

>From 5636039087cccad8cddcb2ea48d048a669c80ed7 Mon Sep 17 00:00:00 2001
From: Med Ismail Bennani 
Date: Thu, 27 Jun 2024 16:30:58 -0700
Subject: [PATCH] [lldb/Interpreter] Discard
 ScriptedThreadPlan::GetStopDescription return value

This patch changes `ScriptedThreadPlan::GetStopDescription` behaviour by
discarding its return value since it is optional in the first place
(i.e. the user doesn't need to provide a return value in their implementation).

This patch also re-enables the tests that were XFAIL'd previously.

Signed-off-by: Med Ismail Bennani 
---
 .../Interpreter/Interfaces/ScriptedThreadPlanInterface.h| 4 ++--
 .../Python/Interfaces/ScriptedThreadPlanPythonInterface.cpp | 4 ++--
 .../Python/Interfaces/ScriptedThreadPlanPythonInterface.h   | 2 +-
 lldb/source/Target/ThreadPlanPython.cpp | 6 +++---
 .../API/functionalities/step_scripted/TestStepScripted.py   | 5 +
 5 files changed, 9 insertions(+), 12 deletions(-)

diff --git 
a/lldb/include/lldb/Interpreter/Interfaces/ScriptedThreadPlanInterface.h 
b/lldb/include/lldb/Interpreter/Interfaces/ScriptedThreadPlanInterface.h
index 9130f9412cb0b..0f832b3b2029f 100644
--- a/lldb/include/lldb/Interpreter/Interfaces/ScriptedThreadPlanInterface.h
+++ b/lldb/include/lldb/Interpreter/Interfaces/ScriptedThreadPlanInterface.h
@@ -29,8 +29,8 @@ class ScriptedThreadPlanInterface : public ScriptedInterface {
 
   virtual lldb::StateType GetRunState() { return lldb::eStateStepping; }
 
-  virtual llvm::Expected GetStopDescription(lldb_private::Stream *s) {
-return true;
+  virtual llvm::Error GetStopDescription(lldb_private::Stream *s) {
+return llvm::Error::success();
   }
 };
 } // namespace lldb_private
diff --git 
a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPlanPythonInterface.cpp
 
b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPlanPythonInterface.cpp
index b7e475812f22b..8148e138ae564 100644
--- 
a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPlanPythonInterface.cpp
+++ 
b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPlanPythonInterface.cpp
@@ -91,7 +91,7 @@ lldb::StateType 
ScriptedThreadPlanPythonInterface::GetRunState() {
   static_cast(lldb::eStateStepping)));
 }
 
-llvm::Expected
+llvm::Error
 ScriptedThreadPlanPythonInterface::GetStopDescription(lldb_private::Stream *s) 
{
   Status error;
   Dispatch("stop_description", error, s);
@@ -99,7 +99,7 @@ 
ScriptedThreadPlanPythonInterface::GetStopDescription(lldb_private::Stream *s) {
   if (error.Fail())
 return error.ToError();
 
-  return true;
+  return llvm::Error::success();
 }
 
 #endif
diff --git 
a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPlanPythonInterface.h
 
b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPlanPythonInterface.h
index 33f086786c47b..563874a590794 100644
--- 
a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPlanPythonInterface.h
+++ 
b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPlanPythonInterface.h
@@ -40,7 +40,7 @@ class ScriptedThreadPlanPythonInterface : public 
ScriptedThreadPlanInterface,
 
   lldb::StateType GetRunState() override;
 
-  llvm::Expected GetStopDescription(lldb_private::Stream *s) override;
+  llvm::Error GetStopDescription(lldb_private::Stream *s) override;
 };
 } // namespace lldb_private
 
diff --git a/lldb/source/Target/ThreadPlanPython.cpp 
b/lldb/source/Target/ThreadPlanPython.cpp
index 373555324ba6e..5c0beb6409b90 100644
--- a/lldb/source/Target/ThreadPlanPython.cpp
+++ b/lldb/source/Target/ThreadPlanPython.cpp
@@ -182,9 +182,9 @@ void ThreadPlanPython::GetDescription(Stream *s, 
lldb::DescriptionLevel level) {
   if (m_implementation_sp) {
 ScriptInterpreter *script_interp = GetScriptInterpreter();
 if (script_interp) {
-  auto desc_or_err = m_interface->GetStopDescription(s);
-  if (!desc_or_err || !*desc_or_err) {
-LLDB_LOG_ERROR(GetLog(LLDBLog::Thread), desc_or_err.takeError(),
+  llvm::Error err = m_interface->GetStopDescription(s);
+  if (err) {
+LLDB_LOG_ERROR(GetLog(LLDBLog::Thread), std::move(err),
"Can't call ScriptedThreadPlan::GetStopDescription.");
 s->Printf("Python thread plan implemented by class %s.",
 m_class_name.c_str());
diff --git a/lldb/test/API/functionalities/step_scripted/TestStepScripted.py 
b/lldb/test/API/functionalities/step_scripted/TestStepScripted.py
index bb7479414dbbb..53901718019f9 100644
--- a/lldb/test/API/functi

[Lldb-commits] [lldb] [lldb/Interpreter] Discard ScriptedThreadPlan::GetStopDescription return value (PR #96985)

2024-06-27 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Med Ismail Bennani (medismailben)


Changes

This patch changes `ScriptedThreadPlan::GetStopDescription` behaviour by 
discarding its return value since it is optional in the first place (i.e. the 
user doesn't need to provide a return value in their implementation).

This patch also re-enables the tests that were XFAIL'd previously.

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


5 Files Affected:

- (modified) 
lldb/include/lldb/Interpreter/Interfaces/ScriptedThreadPlanInterface.h (+2-2) 
- (modified) 
lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPlanPythonInterface.cpp
 (+2-2) 
- (modified) 
lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPlanPythonInterface.h
 (+1-1) 
- (modified) lldb/source/Target/ThreadPlanPython.cpp (+3-3) 
- (modified) lldb/test/API/functionalities/step_scripted/TestStepScripted.py 
(+1-4) 


``diff
diff --git 
a/lldb/include/lldb/Interpreter/Interfaces/ScriptedThreadPlanInterface.h 
b/lldb/include/lldb/Interpreter/Interfaces/ScriptedThreadPlanInterface.h
index 9130f9412cb0b..0f832b3b2029f 100644
--- a/lldb/include/lldb/Interpreter/Interfaces/ScriptedThreadPlanInterface.h
+++ b/lldb/include/lldb/Interpreter/Interfaces/ScriptedThreadPlanInterface.h
@@ -29,8 +29,8 @@ class ScriptedThreadPlanInterface : public ScriptedInterface {
 
   virtual lldb::StateType GetRunState() { return lldb::eStateStepping; }
 
-  virtual llvm::Expected GetStopDescription(lldb_private::Stream *s) {
-return true;
+  virtual llvm::Error GetStopDescription(lldb_private::Stream *s) {
+return llvm::Error::success();
   }
 };
 } // namespace lldb_private
diff --git 
a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPlanPythonInterface.cpp
 
b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPlanPythonInterface.cpp
index b7e475812f22b..8148e138ae564 100644
--- 
a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPlanPythonInterface.cpp
+++ 
b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPlanPythonInterface.cpp
@@ -91,7 +91,7 @@ lldb::StateType 
ScriptedThreadPlanPythonInterface::GetRunState() {
   static_cast(lldb::eStateStepping)));
 }
 
-llvm::Expected
+llvm::Error
 ScriptedThreadPlanPythonInterface::GetStopDescription(lldb_private::Stream *s) 
{
   Status error;
   Dispatch("stop_description", error, s);
@@ -99,7 +99,7 @@ 
ScriptedThreadPlanPythonInterface::GetStopDescription(lldb_private::Stream *s) {
   if (error.Fail())
 return error.ToError();
 
-  return true;
+  return llvm::Error::success();
 }
 
 #endif
diff --git 
a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPlanPythonInterface.h
 
b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPlanPythonInterface.h
index 33f086786c47b..563874a590794 100644
--- 
a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPlanPythonInterface.h
+++ 
b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPlanPythonInterface.h
@@ -40,7 +40,7 @@ class ScriptedThreadPlanPythonInterface : public 
ScriptedThreadPlanInterface,
 
   lldb::StateType GetRunState() override;
 
-  llvm::Expected GetStopDescription(lldb_private::Stream *s) override;
+  llvm::Error GetStopDescription(lldb_private::Stream *s) override;
 };
 } // namespace lldb_private
 
diff --git a/lldb/source/Target/ThreadPlanPython.cpp 
b/lldb/source/Target/ThreadPlanPython.cpp
index 373555324ba6e..5c0beb6409b90 100644
--- a/lldb/source/Target/ThreadPlanPython.cpp
+++ b/lldb/source/Target/ThreadPlanPython.cpp
@@ -182,9 +182,9 @@ void ThreadPlanPython::GetDescription(Stream *s, 
lldb::DescriptionLevel level) {
   if (m_implementation_sp) {
 ScriptInterpreter *script_interp = GetScriptInterpreter();
 if (script_interp) {
-  auto desc_or_err = m_interface->GetStopDescription(s);
-  if (!desc_or_err || !*desc_or_err) {
-LLDB_LOG_ERROR(GetLog(LLDBLog::Thread), desc_or_err.takeError(),
+  llvm::Error err = m_interface->GetStopDescription(s);
+  if (err) {
+LLDB_LOG_ERROR(GetLog(LLDBLog::Thread), std::move(err),
"Can't call ScriptedThreadPlan::GetStopDescription.");
 s->Printf("Python thread plan implemented by class %s.",
 m_class_name.c_str());
diff --git a/lldb/test/API/functionalities/step_scripted/TestStepScripted.py 
b/lldb/test/API/functionalities/step_scripted/TestStepScripted.py
index bb7479414dbbb..53901718019f9 100644
--- a/lldb/test/API/functionalities/step_scripted/TestStepScripted.py
+++ b/lldb/test/API/functionalities/step_scripted/TestStepScripted.py
@@ -7,6 +7,7 @@
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
 
+
 class StepScriptedTestCase(TestBase):
 NO_DEBUG_INFO_TESTCASE = True
 
@@ -15,14 +16,12 @@ def setUp(self):
 self.main_source_file = lldb.SBFileSpec("ma

[Lldb-commits] [clang] [lldb] [llvm] [BOLT][NFC] Move CallGraph from Passes to Core (PR #96922)

2024-06-27 Thread shaw young via lldb-commits

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


[Lldb-commits] [lldb] Fix test assertions in TestDAP_stepInTargets.py (PR #96687)

2024-06-27 Thread Kendal Harland via lldb-commits

kendalharland wrote:

> I'm not sure if these names come from the demangler or debug info, but 
> windows has different implementations for both, so it not surprising they're 
> different. Assuming we don't care about the precise formatting of the names, 
> we could just check whether the name of the function is in the string (and 
> change the name to something more unique): assertIn("my_first_step_target", 
> step_in_targets[0]["label"])

Sorry for the late follow up, I got pulled into fixing something else. I think 
this is a simple enough solution. I'll reupload and reping for review.

https://github.com/llvm/llvm-project/pull/96687
___
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 test-cases for packed/aligned structures (PR #96932)

2024-06-27 Thread Michael Buch via lldb-commits

https://github.com/Michael137 updated 
https://github.com/llvm/llvm-project/pull/96932

>From d2c28706769f89bf9f0b53071726bb59c6205ce8 Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Thu, 27 Jun 2024 17:16:50 +0100
Subject: [PATCH] [lldb][test] Add test-cases for packed structures

Adds test that checks whether LLDB correctly infers the
alignment of packed structures. Specifically, the
`InferAlignment` code-path of the `ItaniumRecordLayoutBuilder`
where it assumes that overlapping field offsets imply a
packed structure and thus sets alignment to `1`. See discussion
in https://github.com/llvm/llvm-project/pull/93809.

While here, also added a test-case where we check alignment of
a class whose base has an explicit `DW_AT_alignment
(those don't get transitively propagated in DWARF, but don't seem
like a problem for LLDB).

Lastly, also added an XFAIL-ed tests where the aforementioned
`InferAlignment` kicks in for overlapping fields (but in this
case incorrectly since the structure isn't actually packed).
---
 .../TestAlignAsBaseClass.py   |  1 +
 .../API/lang/cpp/alignas_base_class/main.cpp  |  7 
 .../DWARF/no_unique_address-alignment.cpp | 25 +
 lldb/test/Shell/SymbolFile/DWARF/packed.cpp   | 36 +++
 4 files changed, 69 insertions(+)
 create mode 100644 
lldb/test/Shell/SymbolFile/DWARF/no_unique_address-alignment.cpp
 create mode 100644 lldb/test/Shell/SymbolFile/DWARF/packed.cpp

diff --git a/lldb/test/API/lang/cpp/alignas_base_class/TestAlignAsBaseClass.py 
b/lldb/test/API/lang/cpp/alignas_base_class/TestAlignAsBaseClass.py
index 7d97b0c42b7e1..362fc2740bf52 100644
--- a/lldb/test/API/lang/cpp/alignas_base_class/TestAlignAsBaseClass.py
+++ b/lldb/test/API/lang/cpp/alignas_base_class/TestAlignAsBaseClass.py
@@ -16,3 +16,4 @@ def test(self):
 # Verify specified class alignments.
 self.expect_expr("alignof(B2)", result_value="8")
 self.expect_expr("alignof(EmptyClassAlign8)", result_value="8")
+self.expect_expr("alignof(Derived)", result_value="8")
diff --git a/lldb/test/API/lang/cpp/alignas_base_class/main.cpp 
b/lldb/test/API/lang/cpp/alignas_base_class/main.cpp
index 9d37554957ba3..a37919deaebdc 100644
--- a/lldb/test/API/lang/cpp/alignas_base_class/main.cpp
+++ b/lldb/test/API/lang/cpp/alignas_base_class/main.cpp
@@ -13,4 +13,11 @@ D d3g;
 struct alignas(8) EmptyClassAlign8 {
 } t;
 
+struct alignas(8) __attribute__((packed)) AlignedAndPackedBase {
+} foo;
+
+struct Derived : AlignedAndPackedBase {
+} bar;
+static_assert(alignof(Derived) == 8);
+
 int main() {}
diff --git a/lldb/test/Shell/SymbolFile/DWARF/no_unique_address-alignment.cpp 
b/lldb/test/Shell/SymbolFile/DWARF/no_unique_address-alignment.cpp
new file mode 100644
index 0..6e544f40625df
--- /dev/null
+++ b/lldb/test/Shell/SymbolFile/DWARF/no_unique_address-alignment.cpp
@@ -0,0 +1,25 @@
+// XFAIL: *
+
+// RUN: %clangxx_host -gdwarf -o %t %s
+// RUN: %lldb %t \
+// RUN:   -o "b main" \
+// RUN:   -o "expr alignof(OverlappingFields)" \
+// RUN:   -o "expr sizeof(OverlappingFields)" \
+// RUN:   -o exit | FileCheck %s
+
+// CHECK:  (lldb) expr alignof(OverlappingFields)
+// CHECK-NEXT: ${{.*}} = 4
+// CHECK:  (lldb) expr sizeof(OverlappingFields)
+// CHECK-NEXT: ${{.*}} = 8
+
+struct Empty {};
+
+struct OverlappingFields {
+  char y;
+  [[no_unique_address]] Empty e;
+  int z;
+} g_packed_struct;
+static_assert(alignof(OverlappingFields) == 4);
+static_assert(sizeof(OverlappingFields) == 8);
+
+int main() {}
diff --git a/lldb/test/Shell/SymbolFile/DWARF/packed.cpp 
b/lldb/test/Shell/SymbolFile/DWARF/packed.cpp
new file mode 100644
index 0..fb94a834d48a6
--- /dev/null
+++ b/lldb/test/Shell/SymbolFile/DWARF/packed.cpp
@@ -0,0 +1,36 @@
+// RUN: %clangxx_host -gdwarf -o %t %s
+// RUN: %lldb %t \
+// RUN:   -o "b main" \
+// RUN:   -o "expr alignof(packed)" \
+// RUN:   -o "expr sizeof(packed)" \
+// RUN:   -o "expr alignof(packed_and_aligned)" \
+// RUN:   -o "expr sizeof(packed_and_aligned)" \
+// RUN:   -o exit | FileCheck %s
+
+// CHECK:  (lldb) expr alignof(packed)
+// CHECK-NEXT: ${{.*}} = 1
+// CHECK:  (lldb) expr sizeof(packed)
+// CHECK-NEXT: ${{.*}} = 9
+
+// CHECK:  (lldb) expr alignof(packed_and_aligned)
+// CHECK-NEXT: ${{.*}} = 16
+// CHECK:  (lldb) expr sizeof(packed_and_aligned)
+// CHECK-NEXT: ${{.*}} = 16
+
+struct __attribute__((packed)) packed {
+  int x;
+  char y;
+  int z;
+} g_packed_struct;
+static_assert(alignof(packed) == 1);
+static_assert(sizeof(packed) == 9);
+
+struct __attribute__((packed, aligned(16))) packed_and_aligned {
+  int x;
+  char y;
+  int z;
+} g_packed_and_aligned_struct;
+static_assert(alignof(packed_and_aligned) == 16);
+static_assert(sizeof(packed_and_aligned) == 16);
+
+int main() {}

___
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 test-cases for packed/aligned structures (PR #96932)

2024-06-27 Thread Michael Buch via lldb-commits

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


[Lldb-commits] [lldb] In `statistics dump --summary`, add back the `targets` section (PR #97004)

2024-06-27 Thread via lldb-commits

https://github.com/royitaqi created 
https://github.com/llvm/llvm-project/pull/97004

# Change

https://github.com/llvm/llvm-project/pull/95075 accidentally removed the 
`targets` section from `statistics dump --summary`. Adding it back, by setting 
the default value to `true` in `StatisticsOptions::GetIncludeTargets()`.

Updated the description for the options.
Updated tests.


# Verification

Manually verified the fix by running `statist dump --summary` and comparing 
three versions of LLDB (in commit order):
1. Before https://github.com/llvm/llvm-project/pull/95075
2. After https://github.com/llvm/llvm-project/pull/95075
3. After this fix

The expected result is that 1 and 3 give the same sections, while 2 is missing 
the `targets` section when in summary mode. The output (see Appendix) matches 
the expectation.


# Appendix: Manual Test Output

## `statistics dump --summary` of 1

```
(lldb) statistics dump --summary
{
  "memory": {
"strings": {
  "bytesTotal": 724992,
  "bytesUnused": 714547,
  "bytesUsed": 10445
}
  },
  "targets": [
{
  "sourceMapDeduceCount": 0,
  "totalSharedLibraryEventHitCount": 0
}
  ],
  "totalDebugInfoByteSize": 597,
  "totalDebugInfoEnabled": 1,
  "totalDebugInfoIndexLoadedFromCache": 0,
  "totalDebugInfoIndexSavedToCache": 0,
  "totalDebugInfoIndexTime": 0.00070695,
  "totalDebugInfoParseTime": 2.5998e-05,
  "totalModuleCount": 1,
  "totalModuleCountHasDebugInfo": 1,
  "totalModuleCountWithIncompleteTypes": 0,
  "totalModuleCountWithVariableErrors": 0,
  "totalSymbolTableIndexTime": 0.000223,
  "totalSymbolTableParseTime": 0.00025798,
  "totalSymbolTableStripped": 0,
  "totalSymbolTablesLoadedFromCache": 0,
  "totalSymbolTablesSavedToCache": 0
}
(lldb)
```

## `statistics dump --summary` of 3

Should be the same as above.

```
(lldb) statistics dump --summary
{
  "memory": {
"strings": {
  "bytesTotal": 516096,
  "bytesUnused": 510353,
  "bytesUsed": 5743
}
  },
  "targets": [
{
  "sourceMapDeduceCount": 0,
  "totalSharedLibraryEventHitCount": 0
}
  ],
  "totalDebugInfoByteSize": 597,
  "totalDebugInfoEnabled": 1,
  "totalDebugInfoIndexLoadedFromCache": 0,
  "totalDebugInfoIndexSavedToCache": 0,
  "totalDebugInfoIndexTime": 0.0022138,
  "totalDebugInfoParseTime": 0.00031701,
  "totalModuleCount": 1,
  "totalModuleCountHasDebugInfo": 1,
  "totalModuleCountWithIncompleteTypes": 0,
  "totalModuleCountWithVariableErrors": 0,
  "totalSymbolTableIndexTime": 0.0014499,
  "totalSymbolTableParseTime": 0.001848,
  "totalSymbolTableStripped": 0,
  "totalSymbolTablesLoadedFromCache": 0,
  "totalSymbolTablesSavedToCache": 0
}
(lldb)
```

## `statistics dump --summary` of 2

Should be missing the `targets` section.

```
(lldb) statistics dump --summary
{
  "memory": {
"strings": {
  "bytesTotal": 716800,
  "bytesUnused": 705887,
  "bytesUsed": 10913
}
  },
  "totalDebugInfoByteSize": 597,
  "totalDebugInfoEnabled": 1,
  "totalDebugInfoIndexLoadedFromCache": 0,
  "totalDebugInfoIndexSavedToCache": 0,
  "totalDebugInfoIndexTime": 0.001374,
  "totalDebugInfoParseTime": 0.000174,
  "totalModuleCount": 1,
  "totalModuleCountHasDebugInfo": 1,
  "totalModuleCountWithIncompleteTypes": 0,
  "totalModuleCountWithVariableErrors": 0,
  "totalSymbolTableIndexTime": 0.00068301,
  "totalSymbolTableParseTime": 0.0010139,
  "totalSymbolTableStripped": 0,
  "totalSymbolTablesLoadedFromCache": 0,
  "totalSymbolTablesSavedToCache": 0
}
(lldb)
```

>From 629282a7ce68c3dc2d6e2bf491870b71a1435cee Mon Sep 17 00:00:00 2001
From: royshi 
Date: Thu, 27 Jun 2024 21:17:45 -0700
Subject: [PATCH] Add `targets` back into `statistics dump --summary`

Summary:

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:
---
 lldb/include/lldb/Target/Statistics.h |  5 ++-
 lldb/source/Commands/Options.td   |  7 ++--
 .../commands/statistics/basic/TestStats.py| 32 ---
 3 files changed, 33 insertions(+), 11 deletions(-)

diff --git a/lldb/include/lldb/Target/Statistics.h 
b/lldb/include/lldb/Target/Statistics.h
index 122eb3ddd711f..35bd7f8a66e05 100644
--- a/lldb/include/lldb/Target/Statistics.h
+++ b/lldb/include/lldb/Target/Statistics.h
@@ -144,9 +144,8 @@ struct StatisticsOptions {
   bool GetIncludeTargets() const {
 if (m_include_targets.has_value())
   return m_include_targets.value();
-// `m_include_targets` has no value set, so return a value based on
-// `m_summary_only`.
-return !GetSummaryOnly();
+// Default to true in both default mode and summary mode.
+return true;
   }
 
   void SetIncludeModules(bool value) { m_include_modules = value; }
diff --git a/lldb/source/Commands/Options.td b/lldb/source/Commands/Options.td
index ba256e5ab917a..fa8af7cb3d762 100644
--- a/lldb/source/Commands/Options.td
+++ b/lldb/source/Commands/Options.td
@@ -1429,9 +1429,8 @@ let Command

[Lldb-commits] [lldb] In `statistics dump --summary`, add back the `targets` section (PR #97004)

2024-06-27 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: None (royitaqi)


Changes

# Change

https://github.com/llvm/llvm-project/pull/95075 accidentally removed the 
`targets` section from `statistics dump --summary`. Adding it back, by setting 
the default value to `true` in `StatisticsOptions::GetIncludeTargets()`.

Updated the description for the options.
Updated tests.


# Verification

Manually verified the fix by running `statist dump --summary` and comparing 
three versions of LLDB (in commit order):
1. Before https://github.com/llvm/llvm-project/pull/95075
2. After https://github.com/llvm/llvm-project/pull/95075
3. After this fix

The expected result is that 1 and 3 give the same sections, while 2 is missing 
the `targets` section when in summary mode. The output (see Appendix) matches 
the expectation.


# Appendix: Manual Test Output

## `statistics dump --summary` of 1

```
(lldb) statistics dump --summary
{
  "memory": {
"strings": {
  "bytesTotal": 724992,
  "bytesUnused": 714547,
  "bytesUsed": 10445
}
  },
  "targets": [
{
  "sourceMapDeduceCount": 0,
  "totalSharedLibraryEventHitCount": 0
}
  ],
  "totalDebugInfoByteSize": 597,
  "totalDebugInfoEnabled": 1,
  "totalDebugInfoIndexLoadedFromCache": 0,
  "totalDebugInfoIndexSavedToCache": 0,
  "totalDebugInfoIndexTime": 0.00070695,
  "totalDebugInfoParseTime": 2.5998e-05,
  "totalModuleCount": 1,
  "totalModuleCountHasDebugInfo": 1,
  "totalModuleCountWithIncompleteTypes": 0,
  "totalModuleCountWithVariableErrors": 0,
  "totalSymbolTableIndexTime": 0.000223,
  "totalSymbolTableParseTime": 0.00025798,
  "totalSymbolTableStripped": 0,
  "totalSymbolTablesLoadedFromCache": 0,
  "totalSymbolTablesSavedToCache": 0
}
(lldb)
```

## `statistics dump --summary` of 3

Should be the same as above.

```
(lldb) statistics dump --summary
{
  "memory": {
"strings": {
  "bytesTotal": 516096,
  "bytesUnused": 510353,
  "bytesUsed": 5743
}
  },
  "targets": [
{
  "sourceMapDeduceCount": 0,
  "totalSharedLibraryEventHitCount": 0
}
  ],
  "totalDebugInfoByteSize": 597,
  "totalDebugInfoEnabled": 1,
  "totalDebugInfoIndexLoadedFromCache": 0,
  "totalDebugInfoIndexSavedToCache": 0,
  "totalDebugInfoIndexTime": 0.0022138,
  "totalDebugInfoParseTime": 0.00031701,
  "totalModuleCount": 1,
  "totalModuleCountHasDebugInfo": 1,
  "totalModuleCountWithIncompleteTypes": 0,
  "totalModuleCountWithVariableErrors": 0,
  "totalSymbolTableIndexTime": 0.0014499,
  "totalSymbolTableParseTime": 0.001848,
  "totalSymbolTableStripped": 0,
  "totalSymbolTablesLoadedFromCache": 0,
  "totalSymbolTablesSavedToCache": 0
}
(lldb)
```

## `statistics dump --summary` of 2

Should be missing the `targets` section.

```
(lldb) statistics dump --summary
{
  "memory": {
"strings": {
  "bytesTotal": 716800,
  "bytesUnused": 705887,
  "bytesUsed": 10913
}
  },
  "totalDebugInfoByteSize": 597,
  "totalDebugInfoEnabled": 1,
  "totalDebugInfoIndexLoadedFromCache": 0,
  "totalDebugInfoIndexSavedToCache": 0,
  "totalDebugInfoIndexTime": 0.001374,
  "totalDebugInfoParseTime": 0.000174,
  "totalModuleCount": 1,
  "totalModuleCountHasDebugInfo": 1,
  "totalModuleCountWithIncompleteTypes": 0,
  "totalModuleCountWithVariableErrors": 0,
  "totalSymbolTableIndexTime": 0.00068301,
  "totalSymbolTableParseTime": 0.0010139,
  "totalSymbolTableStripped": 0,
  "totalSymbolTablesLoadedFromCache": 0,
  "totalSymbolTablesSavedToCache": 0
}
(lldb)
```

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


3 Files Affected:

- (modified) lldb/include/lldb/Target/Statistics.h (+2-3) 
- (modified) lldb/source/Commands/Options.td (+3-4) 
- (modified) lldb/test/API/commands/statistics/basic/TestStats.py (+28-4) 


``diff
diff --git a/lldb/include/lldb/Target/Statistics.h 
b/lldb/include/lldb/Target/Statistics.h
index 122eb3ddd711f..35bd7f8a66e05 100644
--- a/lldb/include/lldb/Target/Statistics.h
+++ b/lldb/include/lldb/Target/Statistics.h
@@ -144,9 +144,8 @@ struct StatisticsOptions {
   bool GetIncludeTargets() const {
 if (m_include_targets.has_value())
   return m_include_targets.value();
-// `m_include_targets` has no value set, so return a value based on
-// `m_summary_only`.
-return !GetSummaryOnly();
+// Default to true in both default mode and summary mode.
+return true;
   }
 
   void SetIncludeModules(bool value) { m_include_modules = value; }
diff --git a/lldb/source/Commands/Options.td b/lldb/source/Commands/Options.td
index ba256e5ab917a..fa8af7cb3d762 100644
--- a/lldb/source/Commands/Options.td
+++ b/lldb/source/Commands/Options.td
@@ -1429,9 +1429,8 @@ let Command = "statistics dump" in {
 Arg<"Boolean">,
 Desc<"Dump statistics for the targets, including breakpoints, expression "
 "evaluations, frame variables, etc. "
-"Defaults to true, unless the '--su