[Lldb-commits] [lldb] Revert commits that add `TestFind(Ranges)InMemory.py` (PR #96560)

2024-06-24 Thread Chelsea Cassanova via lldb-commits

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


[Lldb-commits] [lldb] Revert commits that add `TestFind(Ranges)InMemory.py` (PR #96560)

2024-06-24 Thread Chelsea Cassanova via lldb-commits

https://github.com/chelcassanova created 
https://github.com/llvm/llvm-project/pull/96560

Reverting to unblock macOS buildbots which are currently failing on these 
tests. https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/as-lldb-cmake/6377/

>From 22127178761968b01be207a1c83c7048dc3ec47d Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova 
Date: Mon, 24 Jun 2024 14:17:09 -0700
Subject: [PATCH 1/2] Revert "[lldb] Fix failing TestFind(Ranges)InMemory.py
 tests. (#96511)"

This reverts commit 33a9c57b89c3ea901a057c3fcc9c9160eaf5a625. Alongside
10bd5ad this is being reverted as these commits are blocking the macOS
buildbots: 
https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/as-lldb-cmake/6375/
---
 lldb/test/API/python_api/find_in_memory/address_ranges_helper.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lldb/test/API/python_api/find_in_memory/address_ranges_helper.py 
b/lldb/test/API/python_api/find_in_memory/address_ranges_helper.py
index 2c11fba80766f..0544100f97b29 100644
--- a/lldb/test/API/python_api/find_in_memory/address_ranges_helper.py
+++ b/lldb/test/API/python_api/find_in_memory/address_ranges_helper.py
@@ -35,6 +35,7 @@ def GetRangeFromAddrValue(test_base, addr):
 )
 
 test_base.assertTrue(region.IsReadable())
+test_base.assertFalse(region.IsExecutable())
 
 address_start = lldb.SBAddress(region.GetRegionBase(), test_base.target)
 stack_size = region.GetRegionEnd() - region.GetRegionBase()

>From 10b926cb193292252bc8df6d0ed8345dc73c30e5 Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova 
Date: Mon, 24 Jun 2024 14:18:51 -0700
Subject: [PATCH 2/2] Revert "[lldb][API] Add Find(Ranges)InMemory() to Process
 SB API (#95007)"

This reverts commit 10bd5ad0a133fe73ffc1b05e63bc3fb2d56ba79c. Alongside
33a9c57 this commit is being reverted to unblock the macOS buildbots.
---
 lldb/bindings/python/python-typemaps.swig |   3 +-
 lldb/include/lldb/API/SBProcess.h |  10 -
 lldb/include/lldb/Core/AddressRangeListImpl.h |   4 -
 lldb/include/lldb/Target/Process.h|  14 --
 lldb/source/API/SBProcess.cpp |  58 +
 lldb/source/Target/Process.cpp| 123 --
 .../API/python_api/find_in_memory/Makefile|   3 -
 .../find_in_memory/TestFindInMemory.py| 131 ---
 .../find_in_memory/TestFindRangesInMemory.py  | 221 --
 .../find_in_memory/address_ranges_helper.py   |  73 --
 .../API/python_api/find_in_memory/main.cpp|  27 ---
 11 files changed, 6 insertions(+), 661 deletions(-)
 delete mode 100644 lldb/test/API/python_api/find_in_memory/Makefile
 delete mode 100644 lldb/test/API/python_api/find_in_memory/TestFindInMemory.py
 delete mode 100644 
lldb/test/API/python_api/find_in_memory/TestFindRangesInMemory.py
 delete mode 100644 
lldb/test/API/python_api/find_in_memory/address_ranges_helper.py
 delete mode 100644 lldb/test/API/python_api/find_in_memory/main.cpp

diff --git a/lldb/bindings/python/python-typemaps.swig 
b/lldb/bindings/python/python-typemaps.swig
index f8c33e15c03e6..c39594c7df041 100644
--- a/lldb/bindings/python/python-typemaps.swig
+++ b/lldb/bindings/python/python-typemaps.swig
@@ -257,8 +257,7 @@ AND call SWIG_fail at the same time, because it will result 
in a double free.
 }
 // For SBProcess::WriteMemory, SBTarget::GetInstructions and 
SBDebugger::DispatchInput.
 %typemap(in) (const void *buf, size_t size),
- (const void *data, size_t data_len),
- (const void *buf, uint64_t size) {
+ (const void *data, size_t data_len) {
   if (PythonString::Check($input)) {
 PythonString str(PyRefType::Borrowed, $input);
 $1 = (void *)str.GetString().data();
diff --git a/lldb/include/lldb/API/SBProcess.h 
b/lldb/include/lldb/API/SBProcess.h
index a6ab7ae759918..f1b5d1fb92ce2 100644
--- a/lldb/include/lldb/API/SBProcess.h
+++ b/lldb/include/lldb/API/SBProcess.h
@@ -209,16 +209,6 @@ class LLDB_API SBProcess {
 
   lldb::addr_t ReadPointerFromMemory(addr_t addr, lldb::SBError );
 
-  lldb::SBAddressRangeList FindRangesInMemory(const void *buf, uint64_t size,
-  const SBAddressRangeList ,
-  uint32_t alignment,
-  uint32_t max_matches,
-  SBError );
-
-  lldb::addr_t FindInMemory(const void *buf, uint64_t size,
-const SBAddressRange , uint32_t alignment,
-SBError );
-
   // Events
   static lldb::StateType GetStateFromEvent(const lldb::SBEvent );
 
diff --git a/lldb/include/lldb/Core/AddressRangeListImpl.h 
b/lldb/include/lldb/Core/AddressRangeListImpl.h
index 6742e6ead87de..46ebfe73d4d92 100644
--- a/lldb/include/lldb/Core/AddressRangeListImpl.h
+++ b/lldb/include/lldb/Core/AddressRangeListImpl.h
@@ -13,9 +13,7 @@
 #include 
 
 namespace lldb {
-class SBAddressRangeList;
 class SBBlock;
-class SBProcess;
 }
 

[Lldb-commits] [lldb] Add a unit test for SBBreakpoint::SetCallback (PR #96001)

2024-06-24 Thread Chelsea Cassanova via lldb-commits

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


[Lldb-commits] [lldb] [lldb][API] Add Find(Ranges)InMemory() to Process SB API (PR #95007)

2024-06-24 Thread Chelsea Cassanova via lldb-commits

chelcassanova wrote:

Hey Miro, looks like this change broke the LLDB MacOS buildbot: 
https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/as-lldb-cmake/6353/

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


[Lldb-commits] [lldb] Add a unit test for SBBreakpoint::SetCallback (PR #96001)

2024-06-21 Thread Chelsea Cassanova via lldb-commits

https://github.com/chelcassanova updated 
https://github.com/llvm/llvm-project/pull/96001

>From a59949cc908d5216950f2530fe1455da8ad39b5f Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova 
Date: Thu, 13 Jun 2024 16:02:07 -0700
Subject: [PATCH] add unit test for breakpoint::setcallback

---
 lldb/include/lldb/lldb-private-interfaces.h   |  8 +-
 lldb/source/Breakpoint/BreakpointOptions.cpp  | 18 ++--
 lldb/unittests/CMakeLists.txt |  1 +
 lldb/unittests/Callback/CMakeLists.txt| 12 +++
 .../Callback/TestBreakpointSetCallback.cpp| 85 +++
 5 files changed, 107 insertions(+), 17 deletions(-)
 create mode 100644 lldb/unittests/Callback/CMakeLists.txt
 create mode 100644 lldb/unittests/Callback/TestBreakpointSetCallback.cpp

diff --git a/lldb/include/lldb/lldb-private-interfaces.h 
b/lldb/include/lldb/lldb-private-interfaces.h
index 53d5fbb84cc92..cdd9b51d9329c 100644
--- a/lldb/include/lldb/lldb-private-interfaces.h
+++ b/lldb/include/lldb/lldb-private-interfaces.h
@@ -99,10 +99,10 @@ typedef std::optional 
(*SymbolLocatorLocateExecutableSymbolFile)(
 typedef bool (*SymbolLocatorDownloadObjectAndSymbolFile)(
 ModuleSpec _spec, Status , bool force_lookup,
 bool copy_executable);
-typedef bool (*BreakpointHitCallback)(void *baton,
-  StoppointCallbackContext *context,
-  lldb::user_id_t break_id,
-  lldb::user_id_t break_loc_id);
+using BreakpointHitCallback =
+std::function;
+
 typedef bool (*WatchpointHitCallback)(void *baton,
   StoppointCallbackContext *context,
   lldb::user_id_t watch_id);
diff --git a/lldb/source/Breakpoint/BreakpointOptions.cpp 
b/lldb/source/Breakpoint/BreakpointOptions.cpp
index 6c6037dd9edd3..1db8401698114 100644
--- a/lldb/source/Breakpoint/BreakpointOptions.cpp
+++ b/lldb/source/Breakpoint/BreakpointOptions.cpp
@@ -102,19 +102,11 @@ const char *BreakpointOptions::g_option_names[(
 "ConditionText", "IgnoreCount", 
 "EnabledState", "OneShotState", "AutoContinue"};
 
-bool BreakpointOptions::NullCallback(void *baton,
- StoppointCallbackContext *context,
- lldb::user_id_t break_id,
- lldb::user_id_t break_loc_id) {
-  return true;
-}
-
 // BreakpointOptions constructor
 BreakpointOptions::BreakpointOptions(bool all_flags_set)
-: m_callback(BreakpointOptions::NullCallback),
-  m_baton_is_command_baton(false), m_callback_is_synchronous(false),
-  m_enabled(true), m_one_shot(false), m_ignore_count(0),
-  m_condition_text_hash(0), m_inject_condition(false),
+: m_callback(nullptr), m_baton_is_command_baton(false),
+  m_callback_is_synchronous(false), m_enabled(true), m_one_shot(false),
+  m_ignore_count(0), m_condition_text_hash(0), m_inject_condition(false),
   m_auto_continue(false), m_set_flags(0) {
   if (all_flags_set)
 m_set_flags.Set(~((Flags::ValueType)0));
@@ -420,7 +412,7 @@ void BreakpointOptions::SetCallback(
 }
 
 void BreakpointOptions::ClearCallback() {
-  m_callback = BreakpointOptions::NullCallback;
+  m_callback = nullptr;
   m_callback_is_synchronous = false;
   m_callback_baton_sp.reset();
   m_baton_is_command_baton = false;
@@ -449,7 +441,7 @@ bool 
BreakpointOptions::InvokeCallback(StoppointCallbackContext *context,
 }
 
 bool BreakpointOptions::HasCallback() const {
-  return m_callback != BreakpointOptions::NullCallback;
+  return static_cast(m_callback);
 }
 
 bool BreakpointOptions::GetCommandLineCallbacks(StringList _list) {
diff --git a/lldb/unittests/CMakeLists.txt b/lldb/unittests/CMakeLists.txt
index a2585a94b6155..cc9d45ebf981d 100644
--- a/lldb/unittests/CMakeLists.txt
+++ b/lldb/unittests/CMakeLists.txt
@@ -52,6 +52,7 @@ if (NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
   add_subdirectory(API)
 endif()
 add_subdirectory(Breakpoint)
+add_subdirectory(Callback)
 add_subdirectory(Core)
 add_subdirectory(DataFormatter)
 add_subdirectory(Disassembler)
diff --git a/lldb/unittests/Callback/CMakeLists.txt 
b/lldb/unittests/Callback/CMakeLists.txt
new file mode 100644
index 0..b9e0ef5a396e3
--- /dev/null
+++ b/lldb/unittests/Callback/CMakeLists.txt
@@ -0,0 +1,12 @@
+add_lldb_unittest(LLDBCallbackTests
+  TestBreakpointSetCallback.cpp
+
+  LINK_LIBS
+lldbBreakpoint
+lldbCore
+LLVMTestingSupport
+lldbUtilityHelpers
+lldbPluginPlatformMacOSX
+  LINK_COMPONENTS
+Support
+  )
diff --git a/lldb/unittests/Callback/TestBreakpointSetCallback.cpp 
b/lldb/unittests/Callback/TestBreakpointSetCallback.cpp
new file mode 100644
index 0..2a7070f9349c0
--- /dev/null
+++ b/lldb/unittests/Callback/TestBreakpointSetCallback.cpp
@@ -0,0 +1,85 @@
+//===-- TestBreakpointSetCallback.cpp
+//===//
+//
+// Part of the LLVM 

[Lldb-commits] [lldb] Add a unit test for SBBreakpoint::SetCallback (PR #96001)

2024-06-21 Thread Chelsea Cassanova via lldb-commits

https://github.com/chelcassanova updated 
https://github.com/llvm/llvm-project/pull/96001

>From 44ea5e0d0a319fa12463129ff072bcaef6112544 Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova 
Date: Thu, 13 Jun 2024 16:02:07 -0700
Subject: [PATCH] add unit test for breakpoint::setcallback

---
 lldb/include/lldb/lldb-private-interfaces.h   |  8 +-
 lldb/source/Breakpoint/BreakpointOptions.cpp  | 18 ++--
 lldb/unittests/CMakeLists.txt |  1 +
 lldb/unittests/Callback/CMakeLists.txt| 12 +++
 .../Callback/TestBreakpointSetCallback.cpp| 89 +++
 5 files changed, 111 insertions(+), 17 deletions(-)
 create mode 100644 lldb/unittests/Callback/CMakeLists.txt
 create mode 100644 lldb/unittests/Callback/TestBreakpointSetCallback.cpp

diff --git a/lldb/include/lldb/lldb-private-interfaces.h 
b/lldb/include/lldb/lldb-private-interfaces.h
index 53d5fbb84cc92..cdd9b51d9329c 100644
--- a/lldb/include/lldb/lldb-private-interfaces.h
+++ b/lldb/include/lldb/lldb-private-interfaces.h
@@ -99,10 +99,10 @@ typedef std::optional 
(*SymbolLocatorLocateExecutableSymbolFile)(
 typedef bool (*SymbolLocatorDownloadObjectAndSymbolFile)(
 ModuleSpec _spec, Status , bool force_lookup,
 bool copy_executable);
-typedef bool (*BreakpointHitCallback)(void *baton,
-  StoppointCallbackContext *context,
-  lldb::user_id_t break_id,
-  lldb::user_id_t break_loc_id);
+using BreakpointHitCallback =
+std::function;
+
 typedef bool (*WatchpointHitCallback)(void *baton,
   StoppointCallbackContext *context,
   lldb::user_id_t watch_id);
diff --git a/lldb/source/Breakpoint/BreakpointOptions.cpp 
b/lldb/source/Breakpoint/BreakpointOptions.cpp
index 6c6037dd9edd3..1db8401698114 100644
--- a/lldb/source/Breakpoint/BreakpointOptions.cpp
+++ b/lldb/source/Breakpoint/BreakpointOptions.cpp
@@ -102,19 +102,11 @@ const char *BreakpointOptions::g_option_names[(
 "ConditionText", "IgnoreCount", 
 "EnabledState", "OneShotState", "AutoContinue"};
 
-bool BreakpointOptions::NullCallback(void *baton,
- StoppointCallbackContext *context,
- lldb::user_id_t break_id,
- lldb::user_id_t break_loc_id) {
-  return true;
-}
-
 // BreakpointOptions constructor
 BreakpointOptions::BreakpointOptions(bool all_flags_set)
-: m_callback(BreakpointOptions::NullCallback),
-  m_baton_is_command_baton(false), m_callback_is_synchronous(false),
-  m_enabled(true), m_one_shot(false), m_ignore_count(0),
-  m_condition_text_hash(0), m_inject_condition(false),
+: m_callback(nullptr), m_baton_is_command_baton(false),
+  m_callback_is_synchronous(false), m_enabled(true), m_one_shot(false),
+  m_ignore_count(0), m_condition_text_hash(0), m_inject_condition(false),
   m_auto_continue(false), m_set_flags(0) {
   if (all_flags_set)
 m_set_flags.Set(~((Flags::ValueType)0));
@@ -420,7 +412,7 @@ void BreakpointOptions::SetCallback(
 }
 
 void BreakpointOptions::ClearCallback() {
-  m_callback = BreakpointOptions::NullCallback;
+  m_callback = nullptr;
   m_callback_is_synchronous = false;
   m_callback_baton_sp.reset();
   m_baton_is_command_baton = false;
@@ -449,7 +441,7 @@ bool 
BreakpointOptions::InvokeCallback(StoppointCallbackContext *context,
 }
 
 bool BreakpointOptions::HasCallback() const {
-  return m_callback != BreakpointOptions::NullCallback;
+  return static_cast(m_callback);
 }
 
 bool BreakpointOptions::GetCommandLineCallbacks(StringList _list) {
diff --git a/lldb/unittests/CMakeLists.txt b/lldb/unittests/CMakeLists.txt
index a2585a94b6155..cc9d45ebf981d 100644
--- a/lldb/unittests/CMakeLists.txt
+++ b/lldb/unittests/CMakeLists.txt
@@ -52,6 +52,7 @@ if (NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
   add_subdirectory(API)
 endif()
 add_subdirectory(Breakpoint)
+add_subdirectory(Callback)
 add_subdirectory(Core)
 add_subdirectory(DataFormatter)
 add_subdirectory(Disassembler)
diff --git a/lldb/unittests/Callback/CMakeLists.txt 
b/lldb/unittests/Callback/CMakeLists.txt
new file mode 100644
index 0..b9e0ef5a396e3
--- /dev/null
+++ b/lldb/unittests/Callback/CMakeLists.txt
@@ -0,0 +1,12 @@
+add_lldb_unittest(LLDBCallbackTests
+  TestBreakpointSetCallback.cpp
+
+  LINK_LIBS
+lldbBreakpoint
+lldbCore
+LLVMTestingSupport
+lldbUtilityHelpers
+lldbPluginPlatformMacOSX
+  LINK_COMPONENTS
+Support
+  )
diff --git a/lldb/unittests/Callback/TestBreakpointSetCallback.cpp 
b/lldb/unittests/Callback/TestBreakpointSetCallback.cpp
new file mode 100644
index 0..d82ca660ab73f
--- /dev/null
+++ b/lldb/unittests/Callback/TestBreakpointSetCallback.cpp
@@ -0,0 +1,89 @@
+//===-- TestBreakpointSetCallback.cpp
+//===//
+//
+// Part of the LLVM 

[Lldb-commits] [lldb] Add a unit test for SBBreakpoint::SetCallback (PR #96001)

2024-06-21 Thread Chelsea Cassanova via lldb-commits

https://github.com/chelcassanova updated 
https://github.com/llvm/llvm-project/pull/96001

>From 86dcffcc7a1820756fe8104d8239f25185a27733 Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova 
Date: Thu, 13 Jun 2024 16:02:07 -0700
Subject: [PATCH] add unit test for breakpoint::setcallback

---
 lldb/include/lldb/lldb-private-interfaces.h   |  8 +-
 lldb/source/Breakpoint/BreakpointOptions.cpp  | 18 ++--
 lldb/unittests/CMakeLists.txt |  1 +
 lldb/unittests/Callback/CMakeLists.txt| 12 +++
 .../Callback/TestBreakpointSetCallback.cpp| 89 +++
 5 files changed, 111 insertions(+), 17 deletions(-)
 create mode 100644 lldb/unittests/Callback/CMakeLists.txt
 create mode 100644 lldb/unittests/Callback/TestBreakpointSetCallback.cpp

diff --git a/lldb/include/lldb/lldb-private-interfaces.h 
b/lldb/include/lldb/lldb-private-interfaces.h
index 53d5fbb84cc92..cdd9b51d9329c 100644
--- a/lldb/include/lldb/lldb-private-interfaces.h
+++ b/lldb/include/lldb/lldb-private-interfaces.h
@@ -99,10 +99,10 @@ typedef std::optional 
(*SymbolLocatorLocateExecutableSymbolFile)(
 typedef bool (*SymbolLocatorDownloadObjectAndSymbolFile)(
 ModuleSpec _spec, Status , bool force_lookup,
 bool copy_executable);
-typedef bool (*BreakpointHitCallback)(void *baton,
-  StoppointCallbackContext *context,
-  lldb::user_id_t break_id,
-  lldb::user_id_t break_loc_id);
+using BreakpointHitCallback =
+std::function;
+
 typedef bool (*WatchpointHitCallback)(void *baton,
   StoppointCallbackContext *context,
   lldb::user_id_t watch_id);
diff --git a/lldb/source/Breakpoint/BreakpointOptions.cpp 
b/lldb/source/Breakpoint/BreakpointOptions.cpp
index 6c6037dd9edd3..1db8401698114 100644
--- a/lldb/source/Breakpoint/BreakpointOptions.cpp
+++ b/lldb/source/Breakpoint/BreakpointOptions.cpp
@@ -102,19 +102,11 @@ const char *BreakpointOptions::g_option_names[(
 "ConditionText", "IgnoreCount", 
 "EnabledState", "OneShotState", "AutoContinue"};
 
-bool BreakpointOptions::NullCallback(void *baton,
- StoppointCallbackContext *context,
- lldb::user_id_t break_id,
- lldb::user_id_t break_loc_id) {
-  return true;
-}
-
 // BreakpointOptions constructor
 BreakpointOptions::BreakpointOptions(bool all_flags_set)
-: m_callback(BreakpointOptions::NullCallback),
-  m_baton_is_command_baton(false), m_callback_is_synchronous(false),
-  m_enabled(true), m_one_shot(false), m_ignore_count(0),
-  m_condition_text_hash(0), m_inject_condition(false),
+: m_callback(nullptr), m_baton_is_command_baton(false),
+  m_callback_is_synchronous(false), m_enabled(true), m_one_shot(false),
+  m_ignore_count(0), m_condition_text_hash(0), m_inject_condition(false),
   m_auto_continue(false), m_set_flags(0) {
   if (all_flags_set)
 m_set_flags.Set(~((Flags::ValueType)0));
@@ -420,7 +412,7 @@ void BreakpointOptions::SetCallback(
 }
 
 void BreakpointOptions::ClearCallback() {
-  m_callback = BreakpointOptions::NullCallback;
+  m_callback = nullptr;
   m_callback_is_synchronous = false;
   m_callback_baton_sp.reset();
   m_baton_is_command_baton = false;
@@ -449,7 +441,7 @@ bool 
BreakpointOptions::InvokeCallback(StoppointCallbackContext *context,
 }
 
 bool BreakpointOptions::HasCallback() const {
-  return m_callback != BreakpointOptions::NullCallback;
+  return static_cast(m_callback);
 }
 
 bool BreakpointOptions::GetCommandLineCallbacks(StringList _list) {
diff --git a/lldb/unittests/CMakeLists.txt b/lldb/unittests/CMakeLists.txt
index a2585a94b6155..cc9d45ebf981d 100644
--- a/lldb/unittests/CMakeLists.txt
+++ b/lldb/unittests/CMakeLists.txt
@@ -52,6 +52,7 @@ if (NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
   add_subdirectory(API)
 endif()
 add_subdirectory(Breakpoint)
+add_subdirectory(Callback)
 add_subdirectory(Core)
 add_subdirectory(DataFormatter)
 add_subdirectory(Disassembler)
diff --git a/lldb/unittests/Callback/CMakeLists.txt 
b/lldb/unittests/Callback/CMakeLists.txt
new file mode 100644
index 0..b9e0ef5a396e3
--- /dev/null
+++ b/lldb/unittests/Callback/CMakeLists.txt
@@ -0,0 +1,12 @@
+add_lldb_unittest(LLDBCallbackTests
+  TestBreakpointSetCallback.cpp
+
+  LINK_LIBS
+lldbBreakpoint
+lldbCore
+LLVMTestingSupport
+lldbUtilityHelpers
+lldbPluginPlatformMacOSX
+  LINK_COMPONENTS
+Support
+  )
diff --git a/lldb/unittests/Callback/TestBreakpointSetCallback.cpp 
b/lldb/unittests/Callback/TestBreakpointSetCallback.cpp
new file mode 100644
index 0..998b001d400c5
--- /dev/null
+++ b/lldb/unittests/Callback/TestBreakpointSetCallback.cpp
@@ -0,0 +1,89 @@
+//===-- TestBreakpointSetCallback.cpp
+//===//
+//
+// Part of the LLVM 

[Lldb-commits] [lldb] Add a unit test for SBBreakpoint::SetCallback (PR #96001)

2024-06-20 Thread Chelsea Cassanova via lldb-commits


@@ -0,0 +1,93 @@
+//===-- TestBreakpointSetCallback.cpp
+//===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "Plugins/Platform/MacOSX/PlatformMacOSX.h"
+#include "Plugins/Platform/MacOSX/PlatformRemoteMacOSX.h"
+#include "TestingSupport/SubsystemRAII.h"
+#include "TestingSupport/TestUtilities.h"
+#include "lldb/Breakpoint/StoppointCallbackContext.h"
+#include "lldb/Core/Debugger.h"
+#include "lldb/Core/Progress.h"
+#include "lldb/Host/FileSystem.h"
+#include "lldb/Host/HostInfo.h"
+#include "lldb/Target/ExecutionContext.h"
+#include "lldb/lldb-private-enumerations.h"
+#include "lldb/lldb-types.h"
+#include "gtest/gtest.h"
+#include 
+#include 
+#include 
+
+using namespace lldb_private;
+using namespace lldb;
+
+#define EXPECTED_BREAKPOINT_ID 1
+#define EXPECTED_BREAKPOINT_LOCATION_ID 0
+
+class BreakpointSetCallbackTest : public ::testing::Test {
+public:
+  static void CheckCallbackArgs(void *baton, StoppointCallbackContext *context,
+lldb::user_id_t break_id,
+lldb::user_id_t break_loc_id,
+lldb::user_id_t expected_breakpoint_id,
+lldb::user_id_t expected_breakpoint_loc_id,
+TargetSP expected_target_sp) {
+EXPECT_EQ(context->exe_ctx_ref.GetTargetSP(), expected_target_sp);
+EXPECT_EQ(baton, "hello");
+EXPECT_EQ(break_id, expected_breakpoint_id);
+EXPECT_EQ(break_loc_id, expected_breakpoint_loc_id);
+  }
+
+protected:
+  void SetUp() override {
+std::call_once(TestUtilities::g_debugger_initialize_flag,
+   []() { Debugger::Initialize(nullptr); });
+
+// Set up the debugger, make sure that was done properly.
+ArchSpec arch("x86_64-apple-macosx-");
+Platform::SetHostPlatform(
+PlatformRemoteMacOSX::CreateInstance(true, ));
+
+m_debugger_sp = Debugger::CreateInstance();
+
+// Create target
+m_debugger_sp->GetTargetList().CreateTarget(*m_debugger_sp, "", arch,
+
lldb_private::eLoadDependentsNo,
+m_platform_sp, m_target_sp);
+// Create breakpoint
+m_breakpoint_sp = m_target_sp->CreateBreakpoint(0xDEADBEEF, false, false);
+  };
+
+  DebuggerSP m_debugger_sp;
+  PlatformSP m_platform_sp;
+  TargetSP m_target_sp;
+  BreakpointSP m_breakpoint_sp;
+  lldb::user_id_t expected_breakpoint_id;
+  lldb::user_id_t expected_breakpoint_loc_id;
+  SubsystemRAII
+  subsystems;
+};
+
+TEST_F(BreakpointSetCallbackTest, TestBreakpointSetCallback) {
+  void *baton = (void *)"hello";
+  TargetSP current_target = m_target_sp;

chelcassanova wrote:

That only works if I capture `this`, trying to capture just `m_target_sp` won't 
work (unless we move the target setup into the test body)

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


[Lldb-commits] [lldb] Add a unit test for SBBreakpoint::SetCallback (PR #96001)

2024-06-20 Thread Chelsea Cassanova via lldb-commits

https://github.com/chelcassanova updated 
https://github.com/llvm/llvm-project/pull/96001

>From 2cfcef620125ed7d0ba84acfa20de3064437282c Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova 
Date: Thu, 13 Jun 2024 16:02:07 -0700
Subject: [PATCH] add unit test for breakpoint::setcallback

---
 lldb/include/lldb/lldb-private-interfaces.h   | 13 ++-
 lldb/source/Breakpoint/BreakpointOptions.cpp  | 18 +---
 lldb/unittests/CMakeLists.txt |  1 +
 lldb/unittests/Callback/CMakeLists.txt| 12 +++
 .../Callback/TestBreakpointSetCallback.cpp| 93 +++
 5 files changed, 120 insertions(+), 17 deletions(-)
 create mode 100644 lldb/unittests/Callback/CMakeLists.txt
 create mode 100644 lldb/unittests/Callback/TestBreakpointSetCallback.cpp

diff --git a/lldb/include/lldb/lldb-private-interfaces.h 
b/lldb/include/lldb/lldb-private-interfaces.h
index 53d5fbb84cc92..136b644133d32 100644
--- a/lldb/include/lldb/lldb-private-interfaces.h
+++ b/lldb/include/lldb/lldb-private-interfaces.h
@@ -99,10 +99,15 @@ typedef std::optional 
(*SymbolLocatorLocateExecutableSymbolFile)(
 typedef bool (*SymbolLocatorDownloadObjectAndSymbolFile)(
 ModuleSpec _spec, Status , bool force_lookup,
 bool copy_executable);
-typedef bool (*BreakpointHitCallback)(void *baton,
-  StoppointCallbackContext *context,
-  lldb::user_id_t break_id,
-  lldb::user_id_t break_loc_id);
+// typedef bool (*BreakpointHitCallback)(void *baton,
+//   StoppointCallbackContext *context,
+//   lldb::user_id_t break_id,
+//   lldb::user_id_t break_loc_id);
+typedef std::function
+BreakpointHitCallback;
+
 typedef bool (*WatchpointHitCallback)(void *baton,
   StoppointCallbackContext *context,
   lldb::user_id_t watch_id);
diff --git a/lldb/source/Breakpoint/BreakpointOptions.cpp 
b/lldb/source/Breakpoint/BreakpointOptions.cpp
index 6c6037dd9edd3..1db8401698114 100644
--- a/lldb/source/Breakpoint/BreakpointOptions.cpp
+++ b/lldb/source/Breakpoint/BreakpointOptions.cpp
@@ -102,19 +102,11 @@ const char *BreakpointOptions::g_option_names[(
 "ConditionText", "IgnoreCount", 
 "EnabledState", "OneShotState", "AutoContinue"};
 
-bool BreakpointOptions::NullCallback(void *baton,
- StoppointCallbackContext *context,
- lldb::user_id_t break_id,
- lldb::user_id_t break_loc_id) {
-  return true;
-}
-
 // BreakpointOptions constructor
 BreakpointOptions::BreakpointOptions(bool all_flags_set)
-: m_callback(BreakpointOptions::NullCallback),
-  m_baton_is_command_baton(false), m_callback_is_synchronous(false),
-  m_enabled(true), m_one_shot(false), m_ignore_count(0),
-  m_condition_text_hash(0), m_inject_condition(false),
+: m_callback(nullptr), m_baton_is_command_baton(false),
+  m_callback_is_synchronous(false), m_enabled(true), m_one_shot(false),
+  m_ignore_count(0), m_condition_text_hash(0), m_inject_condition(false),
   m_auto_continue(false), m_set_flags(0) {
   if (all_flags_set)
 m_set_flags.Set(~((Flags::ValueType)0));
@@ -420,7 +412,7 @@ void BreakpointOptions::SetCallback(
 }
 
 void BreakpointOptions::ClearCallback() {
-  m_callback = BreakpointOptions::NullCallback;
+  m_callback = nullptr;
   m_callback_is_synchronous = false;
   m_callback_baton_sp.reset();
   m_baton_is_command_baton = false;
@@ -449,7 +441,7 @@ bool 
BreakpointOptions::InvokeCallback(StoppointCallbackContext *context,
 }
 
 bool BreakpointOptions::HasCallback() const {
-  return m_callback != BreakpointOptions::NullCallback;
+  return static_cast(m_callback);
 }
 
 bool BreakpointOptions::GetCommandLineCallbacks(StringList _list) {
diff --git a/lldb/unittests/CMakeLists.txt b/lldb/unittests/CMakeLists.txt
index a2585a94b6155..cc9d45ebf981d 100644
--- a/lldb/unittests/CMakeLists.txt
+++ b/lldb/unittests/CMakeLists.txt
@@ -52,6 +52,7 @@ if (NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
   add_subdirectory(API)
 endif()
 add_subdirectory(Breakpoint)
+add_subdirectory(Callback)
 add_subdirectory(Core)
 add_subdirectory(DataFormatter)
 add_subdirectory(Disassembler)
diff --git a/lldb/unittests/Callback/CMakeLists.txt 
b/lldb/unittests/Callback/CMakeLists.txt
new file mode 100644
index 0..b9e0ef5a396e3
--- /dev/null
+++ b/lldb/unittests/Callback/CMakeLists.txt
@@ -0,0 +1,12 @@
+add_lldb_unittest(LLDBCallbackTests
+  TestBreakpointSetCallback.cpp
+
+  LINK_LIBS
+lldbBreakpoint
+lldbCore
+LLVMTestingSupport
+lldbUtilityHelpers
+lldbPluginPlatformMacOSX
+  LINK_COMPONENTS
+Support
+  )
diff --git a/lldb/unittests/Callback/TestBreakpointSetCallback.cpp 

[Lldb-commits] [lldb] Add a unit test for SBBreakpoint::SetCallback (PR #96001)

2024-06-20 Thread Chelsea Cassanova via lldb-commits

https://github.com/chelcassanova updated 
https://github.com/llvm/llvm-project/pull/96001

>From aa575bbc2b91837851631cf7a14e03398e2efa48 Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova 
Date: Thu, 13 Jun 2024 16:02:07 -0700
Subject: [PATCH] add unit test for breakpoint::setcallback

---
 lldb/include/lldb/lldb-private-interfaces.h   |  9 +-
 lldb/source/Breakpoint/BreakpointOptions.cpp  | 13 +--
 lldb/unittests/CMakeLists.txt |  1 +
 lldb/unittests/Callback/CMakeLists.txt| 12 +++
 .../Callback/TestBreakpointSetCallback.cpp| 88 +++
 5 files changed, 111 insertions(+), 12 deletions(-)
 create mode 100644 lldb/unittests/Callback/CMakeLists.txt
 create mode 100644 lldb/unittests/Callback/TestBreakpointSetCallback.cpp

diff --git a/lldb/include/lldb/lldb-private-interfaces.h 
b/lldb/include/lldb/lldb-private-interfaces.h
index 53d5fbb84cc92..39ecf5f05fb85 100644
--- a/lldb/include/lldb/lldb-private-interfaces.h
+++ b/lldb/include/lldb/lldb-private-interfaces.h
@@ -99,10 +99,15 @@ typedef std::optional 
(*SymbolLocatorLocateExecutableSymbolFile)(
 typedef bool (*SymbolLocatorDownloadObjectAndSymbolFile)(
 ModuleSpec _spec, Status , bool force_lookup,
 bool copy_executable);
-typedef bool (*BreakpointHitCallback)(void *baton,
+// typedef bool (*BreakpointHitCallback)(void *baton,
+//   StoppointCallbackContext *context,
+//   lldb::user_id_t break_id,
+//   lldb::user_id_t break_loc_id);
+typedef std::function 
BreakpointHitCallback;
+
 typedef bool (*WatchpointHitCallback)(void *baton,
   StoppointCallbackContext *context,
   lldb::user_id_t watch_id);
diff --git a/lldb/source/Breakpoint/BreakpointOptions.cpp 
b/lldb/source/Breakpoint/BreakpointOptions.cpp
index 6c6037dd9edd3..f2ce40d02ffb4 100644
--- a/lldb/source/Breakpoint/BreakpointOptions.cpp
+++ b/lldb/source/Breakpoint/BreakpointOptions.cpp
@@ -102,16 +102,9 @@ const char *BreakpointOptions::g_option_names[(
 "ConditionText", "IgnoreCount", 
 "EnabledState", "OneShotState", "AutoContinue"};
 
-bool BreakpointOptions::NullCallback(void *baton,
- StoppointCallbackContext *context,
- lldb::user_id_t break_id,
- lldb::user_id_t break_loc_id) {
-  return true;
-}
-
 // BreakpointOptions constructor
 BreakpointOptions::BreakpointOptions(bool all_flags_set)
-: m_callback(BreakpointOptions::NullCallback),
+: m_callback(nullptr),
   m_baton_is_command_baton(false), m_callback_is_synchronous(false),
   m_enabled(true), m_one_shot(false), m_ignore_count(0),
   m_condition_text_hash(0), m_inject_condition(false),
@@ -420,7 +413,7 @@ void BreakpointOptions::SetCallback(
 }
 
 void BreakpointOptions::ClearCallback() {
-  m_callback = BreakpointOptions::NullCallback;
+  m_callback = nullptr;
   m_callback_is_synchronous = false;
   m_callback_baton_sp.reset();
   m_baton_is_command_baton = false;
@@ -449,7 +442,7 @@ bool 
BreakpointOptions::InvokeCallback(StoppointCallbackContext *context,
 }
 
 bool BreakpointOptions::HasCallback() const {
-  return m_callback != BreakpointOptions::NullCallback;
+  return static_cast(m_callback);
 }
 
 bool BreakpointOptions::GetCommandLineCallbacks(StringList _list) {
diff --git a/lldb/unittests/CMakeLists.txt b/lldb/unittests/CMakeLists.txt
index a2585a94b6155..cc9d45ebf981d 100644
--- a/lldb/unittests/CMakeLists.txt
+++ b/lldb/unittests/CMakeLists.txt
@@ -52,6 +52,7 @@ if (NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
   add_subdirectory(API)
 endif()
 add_subdirectory(Breakpoint)
+add_subdirectory(Callback)
 add_subdirectory(Core)
 add_subdirectory(DataFormatter)
 add_subdirectory(Disassembler)
diff --git a/lldb/unittests/Callback/CMakeLists.txt 
b/lldb/unittests/Callback/CMakeLists.txt
new file mode 100644
index 0..b9e0ef5a396e3
--- /dev/null
+++ b/lldb/unittests/Callback/CMakeLists.txt
@@ -0,0 +1,12 @@
+add_lldb_unittest(LLDBCallbackTests
+  TestBreakpointSetCallback.cpp
+
+  LINK_LIBS
+lldbBreakpoint
+lldbCore
+LLVMTestingSupport
+lldbUtilityHelpers
+lldbPluginPlatformMacOSX
+  LINK_COMPONENTS
+Support
+  )
diff --git a/lldb/unittests/Callback/TestBreakpointSetCallback.cpp 
b/lldb/unittests/Callback/TestBreakpointSetCallback.cpp
new file mode 100644
index 0..7318e524025e4
--- /dev/null
+++ b/lldb/unittests/Callback/TestBreakpointSetCallback.cpp
@@ -0,0 +1,88 @@
+//===-- TestBreakpointSetCallback.cpp
+//===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//

[Lldb-commits] [lldb] Add a unit test for SBBreakpoint::SetCallback (PR #96001)

2024-06-18 Thread Chelsea Cassanova via lldb-commits


@@ -0,0 +1,89 @@
+//===-- TestBreakpointSetCallback.cpp
+//===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "Plugins/Platform/MacOSX/PlatformMacOSX.h"
+#include "Plugins/Platform/MacOSX/PlatformRemoteMacOSX.h"
+#include "TestingSupport/SubsystemRAII.h"
+#include "TestingSupport/TestUtilities.h"
+#include "lldb/Breakpoint/StoppointCallbackContext.h"
+#include "lldb/Core/Debugger.h"
+#include "lldb/Core/Progress.h"
+#include "lldb/Host/FileSystem.h"
+#include "lldb/Host/HostInfo.h"
+#include "lldb/Target/ExecutionContext.h"
+#include "lldb/lldb-private-enumerations.h"
+#include "lldb/lldb-types.h"
+#include "gtest/gtest.h"
+#include 
+#include 
+#include 
+
+using namespace lldb_private;
+using namespace lldb;
+
+class BreakpointSetCallbackTest : public ::testing::Test {
+public:
+  static void CheckCallbackArgs(void *baton, StoppointCallbackContext *context,
+lldb::user_id_t break_id,
+lldb::user_id_t break_loc_id,
+lldb::user_id_t expected_breakpoint_id,
+lldb::user_id_t expected_breakpoint_loc_id) {
+EXPECT_TRUE(baton);
+EXPECT_TRUE(context);
+EXPECT_EQ(break_id, expected_breakpoint_id);
+EXPECT_EQ(break_loc_id, expected_breakpoint_loc_id);
+  }
+
+protected:
+  // The debugger's initialization function can't be called with no arguments
+  // so calling it using SubsystemRAII will cause the test build to fail as
+  // SubsystemRAII will call Initialize with no arguments. As such we set it up
+  // here the usual way.
+  void SetUp() override {
+std::call_once(TestUtilities::g_debugger_initialize_flag,
+   []() { Debugger::Initialize(nullptr); });
+
+// Set up the debugger, make sure that was done properly.
+ArchSpec arch("x86_64-apple-macosx-");
+Platform::SetHostPlatform(
+PlatformRemoteMacOSX::CreateInstance(true, ));
+
+m_debugger_sp = Debugger::CreateInstance();
+m_debugger_sp->GetTargetList().CreateTarget(*m_debugger_sp, "", arch,
+
lldb_private::eLoadDependentsNo,
+m_platform_sp, m_target_sp);
+m_breakpoint_sp = m_target_sp->CreateBreakpoint(0xDEADBEEF, false, false);
+  };
+
+  static bool callback(void *baton, StoppointCallbackContext *context,
+   lldb::user_id_t break_id, lldb::user_id_t break_loc_id) 
{
+BreakpointSetCallbackTest::CheckCallbackArgs(baton, context, break_id,
+ break_loc_id, 0, 0);

chelcassanova wrote:

My mistake, those should be 1  

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


[Lldb-commits] [lldb] Add a unit test for SBBreakpoint::SetCallback (PR #96001)

2024-06-18 Thread Chelsea Cassanova via lldb-commits


@@ -0,0 +1,89 @@
+//===-- TestBreakpointSetCallback.cpp
+//===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "Plugins/Platform/MacOSX/PlatformMacOSX.h"
+#include "Plugins/Platform/MacOSX/PlatformRemoteMacOSX.h"
+#include "TestingSupport/SubsystemRAII.h"
+#include "TestingSupport/TestUtilities.h"
+#include "lldb/Breakpoint/StoppointCallbackContext.h"
+#include "lldb/Core/Debugger.h"
+#include "lldb/Core/Progress.h"
+#include "lldb/Host/FileSystem.h"
+#include "lldb/Host/HostInfo.h"
+#include "lldb/Target/ExecutionContext.h"
+#include "lldb/lldb-private-enumerations.h"
+#include "lldb/lldb-types.h"
+#include "gtest/gtest.h"
+#include 
+#include 
+#include 
+
+using namespace lldb_private;
+using namespace lldb;
+
+class BreakpointSetCallbackTest : public ::testing::Test {
+public:
+  static void CheckCallbackArgs(void *baton, StoppointCallbackContext *context,
+lldb::user_id_t break_id,
+lldb::user_id_t break_loc_id,
+lldb::user_id_t expected_breakpoint_id,
+lldb::user_id_t expected_breakpoint_loc_id) {
+EXPECT_TRUE(baton);
+EXPECT_TRUE(context);

chelcassanova wrote:

An `EXPECT_EQ` for `baton` being `"hello"` right? I'll add that. Also, should I 
check anything more for the `StoppointCallbackContext` being true here?

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


[Lldb-commits] [lldb] Add a unit test for SBBreakpoint::SetCallback (PR #96001)

2024-06-18 Thread Chelsea Cassanova via lldb-commits




chelcassanova wrote:

Not anymore, I'll remove these.

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


[Lldb-commits] [lldb] [lldb][swig] Refactor callback typemaps and functions (PR #95318)

2024-06-18 Thread Chelsea Cassanova via lldb-commits

chelcassanova wrote:

Closing this PR, we wanted to be able to do this _without_ using the 
`PythonDataObjects` class in the swig wrapper that contains callback functions 
but this looks to be unfeasible for callbacks that return SB objects

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


[Lldb-commits] [lldb] [lldb][swig] Refactor callback typemaps and functions (PR #95318)

2024-06-18 Thread Chelsea Cassanova via lldb-commits

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


[Lldb-commits] [lldb] Add a unit test for SBBreakpoint::SetCallback (PR #96001)

2024-06-18 Thread Chelsea Cassanova via lldb-commits

https://github.com/chelcassanova updated 
https://github.com/llvm/llvm-project/pull/96001

>From 0dc804076d624883e966b58c94cae8dc5065f1e3 Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova 
Date: Thu, 13 Jun 2024 16:02:07 -0700
Subject: [PATCH] add unit test for breakpoint::setcallback

---
 lldb/unittests/Breakpoint/CMakeLists.txt  |  3 +
 lldb/unittests/CMakeLists.txt |  1 +
 lldb/unittests/Callback/CMakeLists.txt| 12 +++
 .../Callback/TestBreakpointSetCallback.cpp| 89 +++
 4 files changed, 105 insertions(+)
 create mode 100644 lldb/unittests/Callback/CMakeLists.txt
 create mode 100644 lldb/unittests/Callback/TestBreakpointSetCallback.cpp

diff --git a/lldb/unittests/Breakpoint/CMakeLists.txt 
b/lldb/unittests/Breakpoint/CMakeLists.txt
index 757c2da1a4d9d..629f86dfe65a7 100644
--- a/lldb/unittests/Breakpoint/CMakeLists.txt
+++ b/lldb/unittests/Breakpoint/CMakeLists.txt
@@ -5,6 +5,9 @@ add_lldb_unittest(LLDBBreakpointTests
   LINK_LIBS
 lldbBreakpoint
 lldbCore
+LLVMTestingSupport
+lldbUtilityHelpers
+lldbPluginPlatformMacOSX
   LINK_COMPONENTS
 Support
   )
diff --git a/lldb/unittests/CMakeLists.txt b/lldb/unittests/CMakeLists.txt
index a2585a94b6155..cc9d45ebf981d 100644
--- a/lldb/unittests/CMakeLists.txt
+++ b/lldb/unittests/CMakeLists.txt
@@ -52,6 +52,7 @@ if (NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
   add_subdirectory(API)
 endif()
 add_subdirectory(Breakpoint)
+add_subdirectory(Callback)
 add_subdirectory(Core)
 add_subdirectory(DataFormatter)
 add_subdirectory(Disassembler)
diff --git a/lldb/unittests/Callback/CMakeLists.txt 
b/lldb/unittests/Callback/CMakeLists.txt
new file mode 100644
index 0..bb8797c513256
--- /dev/null
+++ b/lldb/unittests/Callback/CMakeLists.txt
@@ -0,0 +1,12 @@
+add_lldb_unittest(LLDBCallbackTests
+  TestBreakpointSetCallback.cpp
+
+   LINK_LIBS
+lldbBreakpoint
+lldbCore
+LLVMTestingSupport
+lldbUtilityHelpers
+lldbPluginPlatformMacOSX
+  LINK_COMPONENTS
+Support
+  )
diff --git a/lldb/unittests/Callback/TestBreakpointSetCallback.cpp 
b/lldb/unittests/Callback/TestBreakpointSetCallback.cpp
new file mode 100644
index 0..7eea9c42bfad3
--- /dev/null
+++ b/lldb/unittests/Callback/TestBreakpointSetCallback.cpp
@@ -0,0 +1,89 @@
+//===-- TestBreakpointSetCallback.cpp
+//===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "Plugins/Platform/MacOSX/PlatformMacOSX.h"
+#include "Plugins/Platform/MacOSX/PlatformRemoteMacOSX.h"
+#include "TestingSupport/SubsystemRAII.h"
+#include "TestingSupport/TestUtilities.h"
+#include "lldb/Breakpoint/StoppointCallbackContext.h"
+#include "lldb/Core/Debugger.h"
+#include "lldb/Core/Progress.h"
+#include "lldb/Host/FileSystem.h"
+#include "lldb/Host/HostInfo.h"
+#include "lldb/Target/ExecutionContext.h"
+#include "lldb/lldb-private-enumerations.h"
+#include "lldb/lldb-types.h"
+#include "gtest/gtest.h"
+#include 
+#include 
+#include 
+
+using namespace lldb_private;
+using namespace lldb;
+
+class BreakpointSetCallbackTest : public ::testing::Test {
+public:
+  static void CheckCallbackArgs(void *baton, StoppointCallbackContext *context,
+lldb::user_id_t break_id,
+lldb::user_id_t break_loc_id,
+lldb::user_id_t expected_breakpoint_id,
+lldb::user_id_t expected_breakpoint_loc_id) {
+EXPECT_TRUE(baton);
+EXPECT_TRUE(context);
+EXPECT_EQ(break_id, expected_breakpoint_id);
+EXPECT_EQ(break_loc_id, expected_breakpoint_loc_id);
+  }
+
+protected:
+  // The debugger's initialization function can't be called with no arguments
+  // so calling it using SubsystemRAII will cause the test build to fail as
+  // SubsystemRAII will call Initialize with no arguments. As such we set it up
+  // here the usual way.
+  void SetUp() override {
+std::call_once(TestUtilities::g_debugger_initialize_flag,
+   []() { Debugger::Initialize(nullptr); });
+
+// Set up the debugger, make sure that was done properly.
+ArchSpec arch("x86_64-apple-macosx-");
+Platform::SetHostPlatform(
+PlatformRemoteMacOSX::CreateInstance(true, ));
+
+m_debugger_sp = Debugger::CreateInstance();
+m_debugger_sp->GetTargetList().CreateTarget(*m_debugger_sp, "", arch,
+
lldb_private::eLoadDependentsNo,
+m_platform_sp, m_target_sp);
+m_breakpoint_sp = m_target_sp->CreateBreakpoint(0xDEADBEEF, false, false);
+  };
+
+  static bool callback(void *baton, StoppointCallbackContext *context,
+ 

[Lldb-commits] [lldb] Add a unit test for SBBreakpoint::SetCallback (PR #96001)

2024-06-18 Thread Chelsea Cassanova via lldb-commits

https://github.com/chelcassanova created 
https://github.com/llvm/llvm-project/pull/96001

This commit adds a unit test for SBBreakpoint::SetCallback as it wasn't being 
tested before.

>From dc51494a84d6b0dac1d4c6b106eeb6e625a09b58 Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova 
Date: Thu, 13 Jun 2024 16:02:07 -0700
Subject: [PATCH] add unit test for breakpoint::setcallback

---
 lldb/unittests/Breakpoint/CMakeLists.txt  |  4 +
 .../Breakpoint/TestBreakpointSetCallback.cpp  | 90 +++
 2 files changed, 94 insertions(+)
 create mode 100644 lldb/unittests/Breakpoint/TestBreakpointSetCallback.cpp

diff --git a/lldb/unittests/Breakpoint/CMakeLists.txt 
b/lldb/unittests/Breakpoint/CMakeLists.txt
index 757c2da1a4d9d..858a2151c503b 100644
--- a/lldb/unittests/Breakpoint/CMakeLists.txt
+++ b/lldb/unittests/Breakpoint/CMakeLists.txt
@@ -1,10 +1,14 @@
 add_lldb_unittest(LLDBBreakpointTests
   BreakpointIDTest.cpp
   WatchpointAlgorithmsTests.cpp
+  TestBreakpointSetCallback.cpp
 
   LINK_LIBS
 lldbBreakpoint
 lldbCore
+LLVMTestingSupport
+lldbUtilityHelpers
+lldbPluginPlatformMacOSX
   LINK_COMPONENTS
 Support
   )
diff --git a/lldb/unittests/Breakpoint/TestBreakpointSetCallback.cpp 
b/lldb/unittests/Breakpoint/TestBreakpointSetCallback.cpp
new file mode 100644
index 0..351384230f15f
--- /dev/null
+++ b/lldb/unittests/Breakpoint/TestBreakpointSetCallback.cpp
@@ -0,0 +1,90 @@
+//===-- TestBreakpointSetCallback.cpp
+//===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "Plugins/Platform/MacOSX/PlatformMacOSX.h"
+#include "Plugins/Platform/MacOSX/PlatformRemoteMacOSX.h"
+#include "TestingSupport/SubsystemRAII.h"
+#include "TestingSupport/TestUtilities.h"
+#include "lldb/Breakpoint/StoppointCallbackContext.h"
+#include "lldb/Core/Debugger.h"
+#include "lldb/Core/Progress.h"
+#include "lldb/Host/FileSystem.h"
+#include "lldb/Host/HostInfo.h"
+#include "lldb/Target/ExecutionContext.h"
+#include "lldb/lldb-private-enumerations.h"
+#include "lldb/lldb-types.h"
+#include "gtest/gtest.h"
+#include 
+#include 
+#include 
+
+using namespace lldb_private;
+using namespace lldb;
+
+class BreakpointSetCallbackTest : public ::testing::Test {
+public:
+  static void CheckCallbackArgs(void *baton, StoppointCallbackContext *context,
+lldb::user_id_t break_id,
+lldb::user_id_t break_loc_id,
+lldb::user_id_t expected_breakpoint_id,
+lldb::user_id_t expected_breakpoint_loc_id) {
+std::cout << "HELLO" << std::endl;
+EXPECT_TRUE(baton);
+EXPECT_TRUE(context);
+EXPECT_EQ(break_id, expected_breakpoint_id);
+EXPECT_EQ(break_loc_id, expected_breakpoint_loc_id);
+  }
+
+protected:
+  // The debugger's initialization function can't be called with no arguments
+  // so calling it using SubsystemRAII will cause the test build to fail as
+  // SubsystemRAII will call Initialize with no arguments. As such we set it up
+  // here the usual way.
+  void SetUp() override {
+std::call_once(TestUtilities::g_debugger_initialize_flag,
+   []() { Debugger::Initialize(nullptr); });
+
+// Set up the debugger, make sure that was done properly.
+ArchSpec arch("x86_64-apple-macosx-");
+Platform::SetHostPlatform(
+PlatformRemoteMacOSX::CreateInstance(true, ));
+
+m_debugger_sp = Debugger::CreateInstance();
+m_debugger_sp->GetTargetList().CreateTarget(*m_debugger_sp, "", arch,
+
lldb_private::eLoadDependentsNo,
+m_platform_sp, m_target_sp);
+m_breakpoint_sp = m_target_sp->CreateBreakpoint(0xDEADBEEF, false, false);
+  };
+
+  static bool callback(void *baton, StoppointCallbackContext *context,
+   lldb::user_id_t break_id, lldb::user_id_t break_loc_id) 
{
+BreakpointSetCallbackTest::CheckCallbackArgs(baton, context, break_id,
+ break_loc_id, 0, 0);
+return true;
+  }
+
+  DebuggerSP m_debugger_sp;
+  PlatformSP m_platform_sp;
+  TargetSP m_target_sp;
+  BreakpointSP m_breakpoint_sp;
+  Event *m_event;
+  const ExecutionContext m_exe_ctx;
+  lldb::user_id_t expected_breakpoint_id;
+  lldb::user_id_t expected_breakpoint_loc_id;
+  SubsystemRAII
+  subsystems;
+};
+
+TEST_F(BreakpointSetCallbackTest, TestBreakpointSetCallback) {
+  void *baton = (void *)"hello";
+  StoppointCallbackContext context(m_event, m_exe_ctx, true);
+  m_breakpoint_sp->SetCallback(BreakpointSetCallbackTest::callback, baton,
+   false);
+  

[Lldb-commits] [lldb] [lldb][breakpoint] Grey out disabled breakpoints (PR #91404)

2024-06-18 Thread Chelsea Cassanova via lldb-commits

https://github.com/chelcassanova updated 
https://github.com/llvm/llvm-project/pull/91404

>From 5724d6c77d29ad80e9ca03ce7ac1c3e6ed33afc0 Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova 
Date: Thu, 9 May 2024 11:08:29 -0700
Subject: [PATCH] [lldb][breakpoint] Grey out disabled breakpoints

This commit adds colour settings to the list of breakpoints in order to
grey out breakpoints that have been disabled.
---
 lldb/include/lldb/API/SBStream.h  |  5 +
 lldb/include/lldb/Utility/Stream.h|  8 
 lldb/source/API/SBStream.cpp  | 10 ++
 lldb/source/Breakpoint/Breakpoint.cpp |  9 +
 lldb/source/Utility/Stream.cpp|  8 
 5 files changed, 40 insertions(+)

diff --git a/lldb/include/lldb/API/SBStream.h b/lldb/include/lldb/API/SBStream.h
index 0e33f05b69916..108ddc38b4028 100644
--- a/lldb/include/lldb/API/SBStream.h
+++ b/lldb/include/lldb/API/SBStream.h
@@ -12,6 +12,7 @@
 #include 
 
 #include "lldb/API/SBDefines.h"
+#include "llvm/ADT/StringRef.h"
 
 namespace lldb {
 
@@ -43,6 +44,10 @@ class LLDB_API SBStream {
 
   void Print(const char *str);
 
+  bool HasColor();
+
+  void FormatAnsiTerminalCodes(llvm::StringRef format);
+
   void RedirectToFile(const char *path, bool append);
 
   void RedirectToFile(lldb::SBFile file);
diff --git a/lldb/include/lldb/Utility/Stream.h 
b/lldb/include/lldb/Utility/Stream.h
index 37bcdc9924171..1ab590202cd69 100644
--- a/lldb/include/lldb/Utility/Stream.h
+++ b/lldb/include/lldb/Utility/Stream.h
@@ -309,6 +309,12 @@ class Stream {
   /// The current indentation level.
   unsigned GetIndentLevel() const;
 
+  /// Whether or not the stream is using color.
+  ///
+  /// \return
+  /// The color setting of the stream.
+  bool HasColor();
+
   /// Indent the current line in the stream.
   ///
   /// Indent the current line using the current indentation level and print an
@@ -366,6 +372,8 @@ class Stream {
   /// The optional C string format that can be overridden.
   void QuotedCString(const char *cstr, const char *format = "\"%s\"");
 
+  void FormatAnsiTerminalCodes(llvm::StringRef format);
+
   /// Set the address size in bytes.
   ///
   /// \param[in] addr_size
diff --git a/lldb/source/API/SBStream.cpp b/lldb/source/API/SBStream.cpp
index fc8f09a7bb9ae..bc0f3356d4753 100644
--- a/lldb/source/API/SBStream.cpp
+++ b/lldb/source/API/SBStream.cpp
@@ -11,6 +11,7 @@
 #include "lldb/API/SBFile.h"
 #include "lldb/Host/FileSystem.h"
 #include "lldb/Host/StreamFile.h"
+#include "lldb/Utility/AnsiTerminal.h"
 #include "lldb/Utility/Instrumentation.h"
 #include "lldb/Utility/LLDBLog.h"
 #include "lldb/Utility/Status.h"
@@ -77,6 +78,15 @@ void SBStream::Printf(const char *format, ...) {
   va_end(args);
 }
 
+bool SBStream::HasColor() {
+  return m_opaque_up->AsRawOstream().colors_enabled();
+}
+
+void SBStream::FormatAnsiTerminalCodes(llvm::StringRef format) {
+  if (HasColor())
+Printf("%s", ansi::FormatAnsiTerminalCodes(format).c_str());
+}
+
 void SBStream::RedirectToFile(const char *path, bool append) {
   LLDB_INSTRUMENT_VA(this, path, append);
 
diff --git a/lldb/source/Breakpoint/Breakpoint.cpp 
b/lldb/source/Breakpoint/Breakpoint.cpp
index ae845e92762b9..95624f4ae3ad5 100644
--- a/lldb/source/Breakpoint/Breakpoint.cpp
+++ b/lldb/source/Breakpoint/Breakpoint.cpp
@@ -15,6 +15,7 @@
 #include "lldb/Breakpoint/BreakpointResolver.h"
 #include "lldb/Breakpoint/BreakpointResolverFileLine.h"
 #include "lldb/Core/Address.h"
+#include "lldb/Core/Debugger.h"
 #include "lldb/Core/Module.h"
 #include "lldb/Core/ModuleList.h"
 #include "lldb/Core/SearchFilter.h"
@@ -26,6 +27,7 @@
 #include "lldb/Target/SectionLoadList.h"
 #include "lldb/Target/Target.h"
 #include "lldb/Target/ThreadSpec.h"
+#include "lldb/Utility/AnsiTerminal.h"
 #include "lldb/Utility/LLDBLog.h"
 #include "lldb/Utility/Log.h"
 #include "lldb/Utility/Stream.h"
@@ -837,6 +839,10 @@ void Breakpoint::GetDescription(Stream *s, 
lldb::DescriptionLevel level,
 bool show_locations) {
   assert(s != nullptr);
 
+  // Grey out any disabled breakpoints in the list of breakpoints.
+  if (!IsEnabled())
+s->FormatAnsiTerminalCodes("${ansi.faint}");
+
   if (!m_kind_description.empty()) {
 if (level == eDescriptionLevelBrief) {
   s->PutCString(GetBreakpointKind());
@@ -933,6 +939,9 @@ void Breakpoint::GetDescription(Stream *s, 
lldb::DescriptionLevel level,
 }
 s->IndentLess();
   }
+
+  // Reset the colors back to normal if they were previously greyed out.
+  s->FormatAnsiTerminalCodes("${ansi.normal}");
 }
 
 void Breakpoint::GetResolverDescription(Stream *s) {
diff --git a/lldb/source/Utility/Stream.cpp b/lldb/source/Utility/Stream.cpp
index 89dce9fb0e1f7..e4ca9ad5a1f14 100644
--- a/lldb/source/Utility/Stream.cpp
+++ b/lldb/source/Utility/Stream.cpp
@@ -103,6 +103,11 @@ void Stream::QuotedCString(const char *cstr, const char 
*format) {
   Printf(format, cstr);
 }
 
+void 

[Lldb-commits] [lldb] [lldb][swig] Refactor callback typemaps and functions (PR #95318)

2024-06-12 Thread Chelsea Cassanova via lldb-commits

https://github.com/chelcassanova created 
https://github.com/llvm/llvm-project/pull/95318

This commit refactors the typemaps and static functions used in the SWIG 
typemaps and wrappers to be in their own SWIG files that are included in the 
main `python.swig` file.

>From 51ea2794e3ea5369d5197103775476819154b019 Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova 
Date: Wed, 12 Jun 2024 14:42:39 -0700
Subject: [PATCH] [lldb][swig] Refactor callback typemaps and functions

This commit refactors the typemaps and static functions used in the SWIG
typemaps and wrappers to be in their own SWIG files that are included in
the main `python.swig` file.
---
 .../python/python-callbacks-typemaps.swig | 119 ++
 .../python/python-callbacks-wrapper.swig  | 101 +++
 lldb/bindings/python/python-typemaps.swig | 116 -
 lldb/bindings/python/python-wrapper.swig  |  96 --
 lldb/bindings/python/python.swig  |   2 +
 5 files changed, 222 insertions(+), 212 deletions(-)
 create mode 100644 lldb/bindings/python/python-callbacks-typemaps.swig
 create mode 100644 lldb/bindings/python/python-callbacks-wrapper.swig

diff --git a/lldb/bindings/python/python-callbacks-typemaps.swig 
b/lldb/bindings/python/python-callbacks-typemaps.swig
new file mode 100644
index 0..71f01c1144557
--- /dev/null
+++ b/lldb/bindings/python/python-callbacks-typemaps.swig
@@ -0,0 +1,119 @@
+/*
+ Typemaps specific to callback functions in LLDB. If editing this file
+ use the Python C API to access Python objects instead of using 
PythonDataObjects.
+*/
+
+// For Log::LogOutputCallback
+%typemap(in) (lldb::LogOutputCallback log_callback, void *baton) {
+  if (!($input == Py_None ||
+PyCallable_Check(reinterpret_cast($input {
+PyErr_SetString(PyExc_TypeError, "Need a callable object or None!");
+SWIG_fail;
+  }
+
+  // FIXME (filcab): We can't currently check if our callback is already
+  // LLDBSwigPythonCallPythonLogOutputCallback (to DECREF the previous
+  // baton) nor can we just remove all traces of a callback, if we want to
+  // revert to a file logging mechanism.
+
+  // Don't lose the callback reference
+  Py_INCREF($input);
+  $1 = LLDBSwigPythonCallPythonLogOutputCallback;
+  $2 = $input;
+}
+
+%typemap(typecheck) (lldb::LogOutputCallback log_callback, void *baton) {
+  $1 = $input == Py_None;
+  $1 = $1 || PyCallable_Check(reinterpret_cast($input));
+}
+
+// For lldb::SBDebuggerDestroyCallback
+%typemap(in) (lldb::SBDebuggerDestroyCallback destroy_callback, void *baton) {
+  if (!($input == Py_None ||
+PyCallable_Check(reinterpret_cast($input {
+PyErr_SetString(PyExc_TypeError, "Need a callable object or None!");
+SWIG_fail;
+  }
+
+  // FIXME (filcab): We can't currently check if our callback is already
+  // LLDBSwigPythonCallPythonSBDebuggerTerminateCallback (to DECREF the 
previous
+  // baton) nor can we just remove all traces of a callback, if we want to
+  // revert to a file logging mechanism.
+
+  // Don't lose the callback reference
+  Py_INCREF($input);
+  $1 = LLDBSwigPythonCallPythonSBDebuggerTerminateCallback;
+  $2 = $input;
+}
+
+%typemap(typecheck) (lldb::SBDebuggerDestroyCallback destroy_callback, void 
*baton) {
+  $1 = $input == Py_None;
+  $1 = $1 || PyCallable_Check(reinterpret_cast($input));
+}
+
+%typemap(in) (lldb::CommandOverrideCallback callback, void *baton) {
+  if (!($input == Py_None ||
+PyCallable_Check(reinterpret_cast($input {
+PyErr_SetString(PyExc_TypeError, "Need a callable object or None!");
+SWIG_fail;
+  }
+
+  // Don't lose the callback reference
+  Py_INCREF($input);
+  $1 = LLDBSwigPythonCallPythonSBCommandInterpreterSetCommandOverrideCallback;
+  $2 = $input;
+}
+%typemap(typecheck) (lldb::CommandOverrideCallback callback, void *baton) {
+  $1 = $input == Py_None;
+  $1 = $1 || PyCallable_Check(reinterpret_cast($input));
+}
+// For lldb::SBPlatformLocateModuleCallback
+%typemap(in) (lldb::SBPlatformLocateModuleCallback callback,
+  void *callback_baton) {
+  if (!($input == Py_None ||
+PyCallable_Check(reinterpret_cast($input {
+PyErr_SetString(PyExc_TypeError, "Need a callable object or None!");
+SWIG_fail;
+  }
+
+  if ($input == Py_None) {
+$1 = nullptr;
+$2 = nullptr;
+  } else {
+PythonCallable callable = Retain($input);
+if (!callable.IsValid()) {
+  PyErr_SetString(PyExc_TypeError, "Need a valid callable object");
+  SWIG_fail;
+}
+
+llvm::Expected arg_info = callable.GetArgInfo();
+if (!arg_info) {
+  PyErr_SetString(PyExc_TypeError,
+  ("Could not get arguments: " +
+  llvm::toString(arg_info.takeError())).c_str());
+  SWIG_fail;
+}
+
+if (arg_info.get().max_positional_args != 3) {
+  PyErr_SetString(PyExc_TypeError, "Expected 3 argument callable object");
+  SWIG_fail;
+}
+
+// NOTE: When this is 

[Lldb-commits] [lldb] Reland "[lldb][api-test] Add API test for SBCommandInterpreter::Comm… (PR #95181)

2024-06-11 Thread Chelsea Cassanova via lldb-commits

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


[Lldb-commits] [lldb] Reland "[lldb][api-test] Add API test for SBCommandInterpreter::Comm… (PR #95181)

2024-06-11 Thread Chelsea Cassanova via lldb-commits

https://github.com/chelcassanova created 
https://github.com/llvm/llvm-project/pull/95181

…andOverrideCallback (#94518)"

This reverts commit 7cff05ada05e87408966d56b4c1675033187ff5c. The API test that 
was added erroneously imports a module that isn't needed and wouldn't be found 
which causes a test failures. This reversion removes that import.

>From 6cee5d2638b2b50bc8c4538014c2d3c77c98ecba Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova 
Date: Tue, 11 Jun 2024 15:33:55 -0700
Subject: [PATCH] Reland  "[lldb][api-test] Add API test for
 SBCommandInterpreter::CommandOverrideCallback (#94518)"

This reverts commit 7cff05ada05e87408966d56b4c1675033187ff5c.
The API test that was added erroneously imports a module that isn't
needed and wouldn't be found which causes a test failures. This
reversion removes that import.
---
 lldb/bindings/python/python-typemaps.swig | 18 ++-
 lldb/bindings/python/python-wrapper.swig  | 22 ++
 lldb/include/lldb/API/SBCommandInterpreter.h  |  2 --
 .../TestCommandOverrideCallback.py| 30 +++
 4 files changed, 69 insertions(+), 3 deletions(-)
 create mode 100644 
lldb/test/API/python_api/interpreter/TestCommandOverrideCallback.py

diff --git a/lldb/bindings/python/python-typemaps.swig 
b/lldb/bindings/python/python-typemaps.swig
index 8d4b740e5f35c..c39594c7df041 100644
--- a/lldb/bindings/python/python-typemaps.swig
+++ b/lldb/bindings/python/python-typemaps.swig
@@ -427,7 +427,6 @@ template <> bool SetNumberFromPyObject(double 
, PyObject *obj) {
   free($1);
 }
 
-
 // For Log::LogOutputCallback
 %typemap(in) (lldb::LogOutputCallback log_callback, void *baton) {
   if (!($input == Py_None ||
@@ -476,6 +475,23 @@ template <> bool SetNumberFromPyObject(double 
, PyObject *obj) {
   $1 = $1 || PyCallable_Check(reinterpret_cast($input));
 }
 
+%typemap(in) (lldb::CommandOverrideCallback callback, void *baton) {
+  if (!($input == Py_None ||
+PyCallable_Check(reinterpret_cast($input {
+PyErr_SetString(PyExc_TypeError, "Need a callable object or None!");
+SWIG_fail;
+  }
+
+  // Don't lose the callback reference.
+  Py_INCREF($input);
+  $1 = LLDBSwigPythonCallPythonSBCommandInterpreterSetCommandOverrideCallback;
+  $2 = $input;
+}
+%typemap(typecheck) (lldb::CommandOverrideCallback callback, void *baton) {
+  $1 = $input == Py_None;
+  $1 = $1 || PyCallable_Check(reinterpret_cast($input));
+}
+
 %typemap(in) lldb::FileSP {
   PythonFile py_file(PyRefType::Borrowed, $input);
   if (!py_file) {
diff --git a/lldb/bindings/python/python-wrapper.swig 
b/lldb/bindings/python/python-wrapper.swig
index 1370afc885d43..bd3de8ce5d46c 100644
--- a/lldb/bindings/python/python-wrapper.swig
+++ b/lldb/bindings/python/python-wrapper.swig
@@ -1099,6 +1099,28 @@ static void 
LLDBSwigPythonCallPythonSBDebuggerTerminateCallback(lldb::user_id_t
   }
 }
 
+static bool 
LLDBSwigPythonCallPythonSBCommandInterpreterSetCommandOverrideCallback(void 
*baton, const char **argv) {
+  bool ret_val = false;
+  if (baton != Py_None) {
+SWIG_PYTHON_THREAD_BEGIN_BLOCK;
+// Create a PyList of items since we're going to pass it to the callback 
as a tuple
+// of arguments.
+PyObject *py_argv = PyList_New(0);
+for (const char **arg = argv; arg && *arg; arg++) {
+  std::string arg_string = *arg;
+  PyObject *py_string = PyUnicode_FromStringAndSize(arg_string.c_str(), 
arg_string.size());
+  PyList_Append(py_argv, py_string);
+}
+
+PyObject *result = PyObject_CallObject(
+reinterpret_cast(baton), PyList_AsTuple(py_argv));
+ret_val = result ? PyObject_IsTrue(result) : false;
+Py_XDECREF(result);
+SWIG_PYTHON_THREAD_END_BLOCK;
+  }
+  return ret_val;
+}
+
 static SBError LLDBSwigPythonCallLocateModuleCallback(
 void *callback_baton, const SBModuleSpec _spec_sb,
 SBFileSpec _file_spec_sb, SBFileSpec _file_spec_sb) {
diff --git a/lldb/include/lldb/API/SBCommandInterpreter.h 
b/lldb/include/lldb/API/SBCommandInterpreter.h
index 639309aa32bfc..b7e39b7858616 100644
--- a/lldb/include/lldb/API/SBCommandInterpreter.h
+++ b/lldb/include/lldb/API/SBCommandInterpreter.h
@@ -265,11 +265,9 @@ class SBCommandInterpreter {
   // Catch commands before they execute by registering a callback that will get
   // called when the command gets executed. This allows GUI or command line
   // interfaces to intercept a command and stop it from happening
-#ifndef SWIG
   bool SetCommandOverrideCallback(const char *command_name,
   lldb::CommandOverrideCallback callback,
   void *baton);
-#endif
 
   /// Return true if the command interpreter is the active IO handler.
   ///
diff --git 
a/lldb/test/API/python_api/interpreter/TestCommandOverrideCallback.py 
b/lldb/test/API/python_api/interpreter/TestCommandOverrideCallback.py
new file mode 100644
index 0..a09c4a71c9948
--- /dev/null
+++ 

[Lldb-commits] [lldb] 7cff05a - Revert "[lldb][api-test] Add API test for SBCommandInterpreter::CommandOverrideCallback (#94518)"

2024-06-11 Thread Chelsea Cassanova via lldb-commits

Author: Chelsea Cassanova
Date: 2024-06-11T15:27:10-07:00
New Revision: 7cff05ada05e87408966d56b4c1675033187ff5c

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

LOG: Revert "[lldb][api-test] Add API test for 
SBCommandInterpreter::CommandOverrideCallback (#94518)"

This reverts commit 6fb6eba9304b63e86ebf039edcb9a0b32e4b39e7.
This test breaks due to an incorrect import in the test.

Added: 


Modified: 
lldb/bindings/python/python-typemaps.swig
lldb/bindings/python/python-wrapper.swig
lldb/include/lldb/API/SBCommandInterpreter.h

Removed: 
lldb/test/API/python_api/interpreter/TestCommandOverrideCallback.py



diff  --git a/lldb/bindings/python/python-typemaps.swig 
b/lldb/bindings/python/python-typemaps.swig
index c39594c7df041..8d4b740e5f35c 100644
--- a/lldb/bindings/python/python-typemaps.swig
+++ b/lldb/bindings/python/python-typemaps.swig
@@ -427,6 +427,7 @@ template <> bool SetNumberFromPyObject(double 
, PyObject *obj) {
   free($1);
 }
 
+
 // For Log::LogOutputCallback
 %typemap(in) (lldb::LogOutputCallback log_callback, void *baton) {
   if (!($input == Py_None ||
@@ -475,23 +476,6 @@ template <> bool SetNumberFromPyObject(double 
, PyObject *obj) {
   $1 = $1 || PyCallable_Check(reinterpret_cast($input));
 }
 
-%typemap(in) (lldb::CommandOverrideCallback callback, void *baton) {
-  if (!($input == Py_None ||
-PyCallable_Check(reinterpret_cast($input {
-PyErr_SetString(PyExc_TypeError, "Need a callable object or None!");
-SWIG_fail;
-  }
-
-  // Don't lose the callback reference.
-  Py_INCREF($input);
-  $1 = LLDBSwigPythonCallPythonSBCommandInterpreterSetCommandOverrideCallback;
-  $2 = $input;
-}
-%typemap(typecheck) (lldb::CommandOverrideCallback callback, void *baton) {
-  $1 = $input == Py_None;
-  $1 = $1 || PyCallable_Check(reinterpret_cast($input));
-}
-
 %typemap(in) lldb::FileSP {
   PythonFile py_file(PyRefType::Borrowed, $input);
   if (!py_file) {

diff  --git a/lldb/bindings/python/python-wrapper.swig 
b/lldb/bindings/python/python-wrapper.swig
index bd3de8ce5d46c..1370afc885d43 100644
--- a/lldb/bindings/python/python-wrapper.swig
+++ b/lldb/bindings/python/python-wrapper.swig
@@ -1099,28 +1099,6 @@ static void 
LLDBSwigPythonCallPythonSBDebuggerTerminateCallback(lldb::user_id_t
   }
 }
 
-static bool 
LLDBSwigPythonCallPythonSBCommandInterpreterSetCommandOverrideCallback(void 
*baton, const char **argv) {
-  bool ret_val = false;
-  if (baton != Py_None) {
-SWIG_PYTHON_THREAD_BEGIN_BLOCK;
-// Create a PyList of items since we're going to pass it to the callback 
as a tuple
-// of arguments.
-PyObject *py_argv = PyList_New(0);
-for (const char **arg = argv; arg && *arg; arg++) {
-  std::string arg_string = *arg;
-  PyObject *py_string = PyUnicode_FromStringAndSize(arg_string.c_str(), 
arg_string.size());
-  PyList_Append(py_argv, py_string);
-}
-
-PyObject *result = PyObject_CallObject(
-reinterpret_cast(baton), PyList_AsTuple(py_argv));
-ret_val = result ? PyObject_IsTrue(result) : false;
-Py_XDECREF(result);
-SWIG_PYTHON_THREAD_END_BLOCK;
-  }
-  return ret_val;
-}
-
 static SBError LLDBSwigPythonCallLocateModuleCallback(
 void *callback_baton, const SBModuleSpec _spec_sb,
 SBFileSpec _file_spec_sb, SBFileSpec _file_spec_sb) {

diff  --git a/lldb/include/lldb/API/SBCommandInterpreter.h 
b/lldb/include/lldb/API/SBCommandInterpreter.h
index b7e39b7858616..639309aa32bfc 100644
--- a/lldb/include/lldb/API/SBCommandInterpreter.h
+++ b/lldb/include/lldb/API/SBCommandInterpreter.h
@@ -265,9 +265,11 @@ class SBCommandInterpreter {
   // Catch commands before they execute by registering a callback that will get
   // called when the command gets executed. This allows GUI or command line
   // interfaces to intercept a command and stop it from happening
+#ifndef SWIG
   bool SetCommandOverrideCallback(const char *command_name,
   lldb::CommandOverrideCallback callback,
   void *baton);
+#endif
 
   /// Return true if the command interpreter is the active IO handler.
   ///

diff  --git 
a/lldb/test/API/python_api/interpreter/TestCommandOverrideCallback.py 
b/lldb/test/API/python_api/interpreter/TestCommandOverrideCallback.py
deleted file mode 100644
index a593feb0012d9..0
--- a/lldb/test/API/python_api/interpreter/TestCommandOverrideCallback.py
+++ /dev/null
@@ -1,31 +0,0 @@
-from typing_extensions import override
-import lldb
-from lldbsuite.test.decorators import *
-from lldbsuite.test.lldbtest import *
-from lldbsuite.test import lldbutil
-
-
-class CommandOverrideCallback(TestBase):
-def setUp(self):
-TestBase.setUp(self)
-self.line = line_number("main.c", "Hello 

[Lldb-commits] [lldb] [lldb][api-test] Add API test for SBCommandInterpreter::CommandOverrideCallback (PR #94518)

2024-06-11 Thread Chelsea Cassanova via lldb-commits

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


[Lldb-commits] [lldb] [lldb][api-test] Add API test for SBCommandInterpreter::CommandOverrideCallback (PR #94518)

2024-06-07 Thread Chelsea Cassanova via lldb-commits

https://github.com/chelcassanova updated 
https://github.com/llvm/llvm-project/pull/94518

>From 4e40f07e424458be6e44cc41d333f38763a0d0fb Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova 
Date: Wed, 5 Jun 2024 11:24:01 -0700
Subject: [PATCH] [lldb][api-test] Add API test for
 SBCommandInterpreter::CommandOverrideCallback

`SBCommandInterpreter::CommandOverrideCallback` was not being exposed to
the Python API has no coverage in the
API test suite, so this commits exposes and adds a test for it. Doing
this involves also adding a typemap for the callback used for this
function so that it matches the functionality of other callback
functions that are exposed to Python.
---
 lldb/bindings/python/python-typemaps.swig | 18 ++-
 lldb/bindings/python/python-wrapper.swig  | 22 +
 lldb/include/lldb/API/SBCommandInterpreter.h  |  2 --
 .../TestCommandOverrideCallback.py| 31 +++
 4 files changed, 70 insertions(+), 3 deletions(-)
 create mode 100644 
lldb/test/API/python_api/interpreter/TestCommandOverrideCallback.py

diff --git a/lldb/bindings/python/python-typemaps.swig 
b/lldb/bindings/python/python-typemaps.swig
index 8d4b740e5f35c..c39594c7df041 100644
--- a/lldb/bindings/python/python-typemaps.swig
+++ b/lldb/bindings/python/python-typemaps.swig
@@ -427,7 +427,6 @@ template <> bool SetNumberFromPyObject(double 
, PyObject *obj) {
   free($1);
 }
 
-
 // For Log::LogOutputCallback
 %typemap(in) (lldb::LogOutputCallback log_callback, void *baton) {
   if (!($input == Py_None ||
@@ -476,6 +475,23 @@ template <> bool SetNumberFromPyObject(double 
, PyObject *obj) {
   $1 = $1 || PyCallable_Check(reinterpret_cast($input));
 }
 
+%typemap(in) (lldb::CommandOverrideCallback callback, void *baton) {
+  if (!($input == Py_None ||
+PyCallable_Check(reinterpret_cast($input {
+PyErr_SetString(PyExc_TypeError, "Need a callable object or None!");
+SWIG_fail;
+  }
+
+  // Don't lose the callback reference.
+  Py_INCREF($input);
+  $1 = LLDBSwigPythonCallPythonSBCommandInterpreterSetCommandOverrideCallback;
+  $2 = $input;
+}
+%typemap(typecheck) (lldb::CommandOverrideCallback callback, void *baton) {
+  $1 = $input == Py_None;
+  $1 = $1 || PyCallable_Check(reinterpret_cast($input));
+}
+
 %typemap(in) lldb::FileSP {
   PythonFile py_file(PyRefType::Borrowed, $input);
   if (!py_file) {
diff --git a/lldb/bindings/python/python-wrapper.swig 
b/lldb/bindings/python/python-wrapper.swig
index 1370afc885d43..bd3de8ce5d46c 100644
--- a/lldb/bindings/python/python-wrapper.swig
+++ b/lldb/bindings/python/python-wrapper.swig
@@ -1099,6 +1099,28 @@ static void 
LLDBSwigPythonCallPythonSBDebuggerTerminateCallback(lldb::user_id_t
   }
 }
 
+static bool 
LLDBSwigPythonCallPythonSBCommandInterpreterSetCommandOverrideCallback(void 
*baton, const char **argv) {
+  bool ret_val = false;
+  if (baton != Py_None) {
+SWIG_PYTHON_THREAD_BEGIN_BLOCK;
+// Create a PyList of items since we're going to pass it to the callback 
as a tuple
+// of arguments.
+PyObject *py_argv = PyList_New(0);
+for (const char **arg = argv; arg && *arg; arg++) {
+  std::string arg_string = *arg;
+  PyObject *py_string = PyUnicode_FromStringAndSize(arg_string.c_str(), 
arg_string.size());
+  PyList_Append(py_argv, py_string);
+}
+
+PyObject *result = PyObject_CallObject(
+reinterpret_cast(baton), PyList_AsTuple(py_argv));
+ret_val = result ? PyObject_IsTrue(result) : false;
+Py_XDECREF(result);
+SWIG_PYTHON_THREAD_END_BLOCK;
+  }
+  return ret_val;
+}
+
 static SBError LLDBSwigPythonCallLocateModuleCallback(
 void *callback_baton, const SBModuleSpec _spec_sb,
 SBFileSpec _file_spec_sb, SBFileSpec _file_spec_sb) {
diff --git a/lldb/include/lldb/API/SBCommandInterpreter.h 
b/lldb/include/lldb/API/SBCommandInterpreter.h
index 8ac36344b3a79..084b6d9adb703 100644
--- a/lldb/include/lldb/API/SBCommandInterpreter.h
+++ b/lldb/include/lldb/API/SBCommandInterpreter.h
@@ -265,11 +265,9 @@ class SBCommandInterpreter {
   // Catch commands before they execute by registering a callback that will get
   // called when the command gets executed. This allows GUI or command line
   // interfaces to intercept a command and stop it from happening
-#ifndef SWIG
   bool SetCommandOverrideCallback(const char *command_name,
   lldb::CommandOverrideCallback callback,
   void *baton);
-#endif
 
   /// Return true if the command interpreter is the active IO handler.
   ///
diff --git 
a/lldb/test/API/python_api/interpreter/TestCommandOverrideCallback.py 
b/lldb/test/API/python_api/interpreter/TestCommandOverrideCallback.py
new file mode 100644
index 0..a593feb0012d9
--- /dev/null
+++ b/lldb/test/API/python_api/interpreter/TestCommandOverrideCallback.py
@@ -0,0 +1,31 @@
+from typing_extensions import override
+import lldb
+from lldbsuite.test.decorators import *
+from 

[Lldb-commits] [lldb] [lldb][api-test] Add API test for SBCommandInterpreter::CommandOverrideCallback (PR #94518)

2024-06-07 Thread Chelsea Cassanova via lldb-commits

https://github.com/chelcassanova updated 
https://github.com/llvm/llvm-project/pull/94518

>From a7215585f55617a41f7c8e566088d3f50203fe55 Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova 
Date: Wed, 5 Jun 2024 11:24:01 -0700
Subject: [PATCH] [lldb][api-test] Add API test for
 SBCommandInterpreter::CommandOverrideCallback

`SBCommandInterpreter::CommandOverrideCallback` was not being exposed to
the Python API has no coverage in the
API test suite, so this commits exposes and adds a test for it. Doing
this involves also adding a typemap for the callback used for this
function so that it matches the functionality of other callback
functions that are exposed to Python.
---
 lldb/bindings/python/python-typemaps.swig | 18 ++-
 lldb/bindings/python/python-wrapper.swig  | 22 ++
 lldb/include/lldb/API/SBCommandInterpreter.h  |  2 --
 .../TestCommandOverrideCallback.py| 30 +++
 4 files changed, 69 insertions(+), 3 deletions(-)
 create mode 100644 
lldb/test/API/python_api/interpreter/TestCommandOverrideCallback.py

diff --git a/lldb/bindings/python/python-typemaps.swig 
b/lldb/bindings/python/python-typemaps.swig
index 8d4b740e5f35c..c39594c7df041 100644
--- a/lldb/bindings/python/python-typemaps.swig
+++ b/lldb/bindings/python/python-typemaps.swig
@@ -427,7 +427,6 @@ template <> bool SetNumberFromPyObject(double 
, PyObject *obj) {
   free($1);
 }
 
-
 // For Log::LogOutputCallback
 %typemap(in) (lldb::LogOutputCallback log_callback, void *baton) {
   if (!($input == Py_None ||
@@ -476,6 +475,23 @@ template <> bool SetNumberFromPyObject(double 
, PyObject *obj) {
   $1 = $1 || PyCallable_Check(reinterpret_cast($input));
 }
 
+%typemap(in) (lldb::CommandOverrideCallback callback, void *baton) {
+  if (!($input == Py_None ||
+PyCallable_Check(reinterpret_cast($input {
+PyErr_SetString(PyExc_TypeError, "Need a callable object or None!");
+SWIG_fail;
+  }
+
+  // Don't lose the callback reference.
+  Py_INCREF($input);
+  $1 = LLDBSwigPythonCallPythonSBCommandInterpreterSetCommandOverrideCallback;
+  $2 = $input;
+}
+%typemap(typecheck) (lldb::CommandOverrideCallback callback, void *baton) {
+  $1 = $input == Py_None;
+  $1 = $1 || PyCallable_Check(reinterpret_cast($input));
+}
+
 %typemap(in) lldb::FileSP {
   PythonFile py_file(PyRefType::Borrowed, $input);
   if (!py_file) {
diff --git a/lldb/bindings/python/python-wrapper.swig 
b/lldb/bindings/python/python-wrapper.swig
index 1370afc885d43..bd3de8ce5d46c 100644
--- a/lldb/bindings/python/python-wrapper.swig
+++ b/lldb/bindings/python/python-wrapper.swig
@@ -1099,6 +1099,28 @@ static void 
LLDBSwigPythonCallPythonSBDebuggerTerminateCallback(lldb::user_id_t
   }
 }
 
+static bool 
LLDBSwigPythonCallPythonSBCommandInterpreterSetCommandOverrideCallback(void 
*baton, const char **argv) {
+  bool ret_val = false;
+  if (baton != Py_None) {
+SWIG_PYTHON_THREAD_BEGIN_BLOCK;
+// Create a PyList of items since we're going to pass it to the callback 
as a tuple
+// of arguments.
+PyObject *py_argv = PyList_New(0);
+for (const char **arg = argv; arg && *arg; arg++) {
+  std::string arg_string = *arg;
+  PyObject *py_string = PyUnicode_FromStringAndSize(arg_string.c_str(), 
arg_string.size());
+  PyList_Append(py_argv, py_string);
+}
+
+PyObject *result = PyObject_CallObject(
+reinterpret_cast(baton), PyList_AsTuple(py_argv));
+ret_val = result ? PyObject_IsTrue(result) : false;
+Py_XDECREF(result);
+SWIG_PYTHON_THREAD_END_BLOCK;
+  }
+  return ret_val;
+}
+
 static SBError LLDBSwigPythonCallLocateModuleCallback(
 void *callback_baton, const SBModuleSpec _spec_sb,
 SBFileSpec _file_spec_sb, SBFileSpec _file_spec_sb) {
diff --git a/lldb/include/lldb/API/SBCommandInterpreter.h 
b/lldb/include/lldb/API/SBCommandInterpreter.h
index 8ac36344b3a79..084b6d9adb703 100644
--- a/lldb/include/lldb/API/SBCommandInterpreter.h
+++ b/lldb/include/lldb/API/SBCommandInterpreter.h
@@ -265,11 +265,9 @@ class SBCommandInterpreter {
   // Catch commands before they execute by registering a callback that will get
   // called when the command gets executed. This allows GUI or command line
   // interfaces to intercept a command and stop it from happening
-#ifndef SWIG
   bool SetCommandOverrideCallback(const char *command_name,
   lldb::CommandOverrideCallback callback,
   void *baton);
-#endif
 
   /// Return true if the command interpreter is the active IO handler.
   ///
diff --git 
a/lldb/test/API/python_api/interpreter/TestCommandOverrideCallback.py 
b/lldb/test/API/python_api/interpreter/TestCommandOverrideCallback.py
new file mode 100644
index 0..9ff16efd82859
--- /dev/null
+++ b/lldb/test/API/python_api/interpreter/TestCommandOverrideCallback.py
@@ -0,0 +1,30 @@
+from typing_extensions import override
+import lldb
+from lldbsuite.test.decorators import *
+from 

[Lldb-commits] [lldb] [lldb][api-test] Add API test for SBCommandInterpreter::CommandOverrideCallback (PR #94518)

2024-06-07 Thread Chelsea Cassanova via lldb-commits

https://github.com/chelcassanova updated 
https://github.com/llvm/llvm-project/pull/94518

>From 44e8cab5d45a87eb1ea2076c498abe5be423eb1c Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova 
Date: Wed, 5 Jun 2024 11:24:01 -0700
Subject: [PATCH] [lldb][api-test] Add API test for
 SBCommandInterpreter::CommandOverrideCallback

`SBCommandInterpreter::CommandOverrideCallback` was not being exposed to
the Python API has no coverage in the
API test suite, so this commits exposes and adds a test for it. Doing
this involves also adding a typemap for the callback used for this
function so that it matches the functionality of other callback
functions that are exposed to Python.
---
 lldb/bindings/python/python-typemaps.swig | 18 -
 lldb/bindings/python/python-wrapper.swig  | 22 +++
 lldb/include/lldb/API/SBCommandInterpreter.h  |  2 --
 .../TestCommandOverrideCallback.py| 27 +++
 4 files changed, 66 insertions(+), 3 deletions(-)
 create mode 100644 
lldb/test/API/python_api/interpreter/TestCommandOverrideCallback.py

diff --git a/lldb/bindings/python/python-typemaps.swig 
b/lldb/bindings/python/python-typemaps.swig
index 8d4b740e5f35c..ff698907568c8 100644
--- a/lldb/bindings/python/python-typemaps.swig
+++ b/lldb/bindings/python/python-typemaps.swig
@@ -427,7 +427,6 @@ template <> bool SetNumberFromPyObject(double 
, PyObject *obj) {
   free($1);
 }
 
-
 // For Log::LogOutputCallback
 %typemap(in) (lldb::LogOutputCallback log_callback, void *baton) {
   if (!($input == Py_None ||
@@ -476,6 +475,23 @@ template <> bool SetNumberFromPyObject(double 
, PyObject *obj) {
   $1 = $1 || PyCallable_Check(reinterpret_cast($input));
 }
 
+%typemap(in) (lldb::CommandOverrideCallback callback, void *baton) {
+  if (!($input == Py_None ||
+PyCallable_Check(reinterpret_cast($input {
+PyErr_SetString(PyExc_TypeError, "Need a callable object or None!");
+SWIG_fail;
+  }
+
+  // Don't lose the callback reference
+  Py_INCREF($input);
+  $1 = LLDBSwigPythonCallPythonSBCommandInterpreterSetCommandOverrideCallback;
+  $2 = $input;
+}
+%typemap(typecheck) (lldb::CommandOverrideCallback callback, void *baton) {
+  $1 = $input == Py_None;
+  $1 = $1 || PyCallable_Check(reinterpret_cast($input));
+}
+
 %typemap(in) lldb::FileSP {
   PythonFile py_file(PyRefType::Borrowed, $input);
   if (!py_file) {
diff --git a/lldb/bindings/python/python-wrapper.swig 
b/lldb/bindings/python/python-wrapper.swig
index 1370afc885d43..bd3de8ce5d46c 100644
--- a/lldb/bindings/python/python-wrapper.swig
+++ b/lldb/bindings/python/python-wrapper.swig
@@ -1099,6 +1099,28 @@ static void 
LLDBSwigPythonCallPythonSBDebuggerTerminateCallback(lldb::user_id_t
   }
 }
 
+static bool 
LLDBSwigPythonCallPythonSBCommandInterpreterSetCommandOverrideCallback(void 
*baton, const char **argv) {
+  bool ret_val = false;
+  if (baton != Py_None) {
+SWIG_PYTHON_THREAD_BEGIN_BLOCK;
+// Create a PyList of items since we're going to pass it to the callback 
as a tuple
+// of arguments.
+PyObject *py_argv = PyList_New(0);
+for (const char **arg = argv; arg && *arg; arg++) {
+  std::string arg_string = *arg;
+  PyObject *py_string = PyUnicode_FromStringAndSize(arg_string.c_str(), 
arg_string.size());
+  PyList_Append(py_argv, py_string);
+}
+
+PyObject *result = PyObject_CallObject(
+reinterpret_cast(baton), PyList_AsTuple(py_argv));
+ret_val = result ? PyObject_IsTrue(result) : false;
+Py_XDECREF(result);
+SWIG_PYTHON_THREAD_END_BLOCK;
+  }
+  return ret_val;
+}
+
 static SBError LLDBSwigPythonCallLocateModuleCallback(
 void *callback_baton, const SBModuleSpec _spec_sb,
 SBFileSpec _file_spec_sb, SBFileSpec _file_spec_sb) {
diff --git a/lldb/include/lldb/API/SBCommandInterpreter.h 
b/lldb/include/lldb/API/SBCommandInterpreter.h
index 8ac36344b3a79..084b6d9adb703 100644
--- a/lldb/include/lldb/API/SBCommandInterpreter.h
+++ b/lldb/include/lldb/API/SBCommandInterpreter.h
@@ -265,11 +265,9 @@ class SBCommandInterpreter {
   // Catch commands before they execute by registering a callback that will get
   // called when the command gets executed. This allows GUI or command line
   // interfaces to intercept a command and stop it from happening
-#ifndef SWIG
   bool SetCommandOverrideCallback(const char *command_name,
   lldb::CommandOverrideCallback callback,
   void *baton);
-#endif
 
   /// Return true if the command interpreter is the active IO handler.
   ///
diff --git 
a/lldb/test/API/python_api/interpreter/TestCommandOverrideCallback.py 
b/lldb/test/API/python_api/interpreter/TestCommandOverrideCallback.py
new file mode 100644
index 0..e8d374987fc90
--- /dev/null
+++ b/lldb/test/API/python_api/interpreter/TestCommandOverrideCallback.py
@@ -0,0 +1,27 @@
+from typing_extensions import override
+import lldb
+from lldbsuite.test.decorators import *
+from 

[Lldb-commits] [lldb] [lldb][api-test] Add API test for SBCommandInterpreter::CommandOverrideCallback (PR #94518)

2024-06-06 Thread Chelsea Cassanova via lldb-commits


@@ -476,6 +475,32 @@ template <> bool SetNumberFromPyObject(double 
, PyObject *obj) {
   $1 = $1 || PyCallable_Check(reinterpret_cast($input));
 }
 
+%typemap(in) (lldb::CommandOverrideCallback callback, void *baton) {
+  if (!($input == Py_None ||
+PyCallable_Check(reinterpret_cast($input {
+PyErr_SetString(PyExc_TypeError, "Need a callable object or None!");
+SWIG_fail;
+  }
+
+  // FIXME (filcab): We can't currently check if our callback is already

chelcassanova wrote:

I'm not opposed to that, this same message appears for the other 2 callbacks.

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


[Lldb-commits] [lldb] [lldb][api-test] Add API test for SBCommandInterpreter::CommandOverrideCallback (PR #94518)

2024-06-06 Thread Chelsea Cassanova via lldb-commits


@@ -476,6 +475,32 @@ template <> bool SetNumberFromPyObject(double 
, PyObject *obj) {
   $1 = $1 || PyCallable_Check(reinterpret_cast($input));
 }
 
+%typemap(in) (lldb::CommandOverrideCallback callback, void *baton) {
+  if (!($input == Py_None ||
+PyCallable_Check(reinterpret_cast($input {
+PyErr_SetString(PyExc_TypeError, "Need a callable object or None!");
+SWIG_fail;
+  }
+
+  // FIXME (filcab): We can't currently check if our callback is already
+  // LLDBSwigPythonCallPythonSBDebuggerTerminateCallback (to DECREF the 
previous
+  // baton) nor can we just remove all traces of a callback, if we want to
+  // revert to a file logging mechanism.
+
+  // Don't lose the callback reference
+  Py_INCREF($input);
+  $1 = LLDBSwigPythonCallPythonSBCommandInterpreterSetCommandOverrideCallback;
+  $2 = $input;
+}
+
+%typemap(typecheck) (lldb::CommandOverrideCallback callback,
+

chelcassanova wrote:

Yup, I kind of wish that SWIG had a formatter like `clang-format`.

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


[Lldb-commits] [lldb] [lldb][api-test] Add API test for SBCommandInterpreter::CommandOverrideCallback (PR #94518)

2024-06-05 Thread Chelsea Cassanova via lldb-commits


@@ -1099,6 +1099,19 @@ static void 
LLDBSwigPythonCallPythonSBDebuggerTerminateCallback(lldb::user_id_t
   }
 }
 
+static bool 
LLDBSwigPythonCallPythonSBCommandInterpreterSetCommandOverrideCallback(void 
*baton, const char **argv) {
+  bool b = false;
+  if (baton != Py_None) {
+SWIG_PYTHON_THREAD_BEGIN_BLOCK;
+PyObject *result = PyObject_CallFunction(
+  reinterpret_cast(baton), const_cast("s"), argv); // 
WRONG!

chelcassanova wrote:

Yes, forgot to do this here when I cleaned this up and you can see the comment 
from that  

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


[Lldb-commits] [lldb] [lldb][api-test] Add API test for SBCommandInterpreter::CommandOverrideCallback (PR #94518)

2024-06-05 Thread Chelsea Cassanova via lldb-commits

https://github.com/chelcassanova updated 
https://github.com/llvm/llvm-project/pull/94518

>From e4ba69ac4983e4e2882200e7efe0e850eeefae21 Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova 
Date: Wed, 5 Jun 2024 11:24:01 -0700
Subject: [PATCH] [lldb][api-test] Add API test for
 SBCommandInterpreter::CommandOverrideCallback

`SBCommandInterpreter::CommandOverrideCallback` was not being exposed to
the Python API has no coverage in the
API test suite, so this commits exposes and adds a test for it. Doing
this involves also adding a typemap for the callback used for this
function so that it matches the functionality of other callback
functions that are exposed to Python.
---
 lldb/bindings/python/python-typemaps.swig | 27 -
 lldb/bindings/python/python-wrapper.swig  | 13 
 lldb/include/lldb/API/SBCommandInterpreter.h  |  2 --
 .../TestCommandOverrideCallback.py| 30 +++
 4 files changed, 69 insertions(+), 3 deletions(-)
 create mode 100644 
lldb/test/API/python_api/interpreter/TestCommandOverrideCallback.py

diff --git a/lldb/bindings/python/python-typemaps.swig 
b/lldb/bindings/python/python-typemaps.swig
index 8d4b740e5f35c..1bf93c59fbc7b 100644
--- a/lldb/bindings/python/python-typemaps.swig
+++ b/lldb/bindings/python/python-typemaps.swig
@@ -427,7 +427,6 @@ template <> bool SetNumberFromPyObject(double 
, PyObject *obj) {
   free($1);
 }
 
-
 // For Log::LogOutputCallback
 %typemap(in) (lldb::LogOutputCallback log_callback, void *baton) {
   if (!($input == Py_None ||
@@ -476,6 +475,32 @@ template <> bool SetNumberFromPyObject(double 
, PyObject *obj) {
   $1 = $1 || PyCallable_Check(reinterpret_cast($input));
 }
 
+%typemap(in) (lldb::CommandOverrideCallback callback, void *baton) {
+  if (!($input == Py_None ||
+PyCallable_Check(reinterpret_cast($input {
+PyErr_SetString(PyExc_TypeError, "Need a callable object or None!");
+SWIG_fail;
+  }
+
+  // FIXME (filcab): We can't currently check if our callback is already
+  // LLDBSwigPythonCallPythonSBDebuggerTerminateCallback (to DECREF the 
previous
+  // baton) nor can we just remove all traces of a callback, if we want to
+  // revert to a file logging mechanism.
+
+  // Don't lose the callback reference
+  Py_INCREF($input);
+  $1 = LLDBSwigPythonCallPythonSBCommandInterpreterSetCommandOverrideCallback;
+  $2 = $input;
+}
+
+%typemap(typecheck) (lldb::CommandOverrideCallback callback,
+
+  void *baton) {
+
+  $1 = $input == Py_None;
+  $1 = $1 || PyCallable_Check(reinterpret_cast($input));
+}
+
 %typemap(in) lldb::FileSP {
   PythonFile py_file(PyRefType::Borrowed, $input);
   if (!py_file) {
diff --git a/lldb/bindings/python/python-wrapper.swig 
b/lldb/bindings/python/python-wrapper.swig
index 1370afc885d43..0a332cb0a2ff4 100644
--- a/lldb/bindings/python/python-wrapper.swig
+++ b/lldb/bindings/python/python-wrapper.swig
@@ -1099,6 +1099,19 @@ static void 
LLDBSwigPythonCallPythonSBDebuggerTerminateCallback(lldb::user_id_t
   }
 }
 
+static bool 
LLDBSwigPythonCallPythonSBCommandInterpreterSetCommandOverrideCallback(void 
*baton, const char **argv) {
+  bool b = false;
+  if (baton != Py_None) {
+SWIG_PYTHON_THREAD_BEGIN_BLOCK;
+PyObject *result = PyObject_CallFunction(
+  reinterpret_cast(baton), const_cast("s"), argv); // 
WRONG!
+b = result ? PyObject_IsTrue(result) : false;
+Py_XDECREF(result);
+SWIG_PYTHON_THREAD_END_BLOCK;
+  }
+  return b;
+}
+
 static SBError LLDBSwigPythonCallLocateModuleCallback(
 void *callback_baton, const SBModuleSpec _spec_sb,
 SBFileSpec _file_spec_sb, SBFileSpec _file_spec_sb) {
diff --git a/lldb/include/lldb/API/SBCommandInterpreter.h 
b/lldb/include/lldb/API/SBCommandInterpreter.h
index 8ac36344b3a79..084b6d9adb703 100644
--- a/lldb/include/lldb/API/SBCommandInterpreter.h
+++ b/lldb/include/lldb/API/SBCommandInterpreter.h
@@ -265,11 +265,9 @@ class SBCommandInterpreter {
   // Catch commands before they execute by registering a callback that will get
   // called when the command gets executed. This allows GUI or command line
   // interfaces to intercept a command and stop it from happening
-#ifndef SWIG
   bool SetCommandOverrideCallback(const char *command_name,
   lldb::CommandOverrideCallback callback,
   void *baton);
-#endif
 
   /// Return true if the command interpreter is the active IO handler.
   ///
diff --git 
a/lldb/test/API/python_api/interpreter/TestCommandOverrideCallback.py 
b/lldb/test/API/python_api/interpreter/TestCommandOverrideCallback.py
new file mode 100644
index 0..067f37f88096d
--- /dev/null
+++ b/lldb/test/API/python_api/interpreter/TestCommandOverrideCallback.py
@@ -0,0 +1,30 @@
+from typing_extensions import override
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class 

[Lldb-commits] [lldb] [lldb][api-test] Add API test for SBCommandInterpreter::CommandOverrideCallback (PR #94518)

2024-06-05 Thread Chelsea Cassanova via lldb-commits

https://github.com/chelcassanova created 
https://github.com/llvm/llvm-project/pull/94518

`SBCommandInterpreter::CommandOverrideCallback` was not being exposed to the 
Python API has no coverage in the
API test suite, so this commits exposes and adds a test for it. Doing this 
involves also adding a typemap for the callback used for this function so that 
it matches the functionality of other callback functions that are exposed to 
Python.

>From 90602ed1b2f27fecb9e1fc28419587cf6bcb04bf Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova 
Date: Wed, 5 Jun 2024 11:24:01 -0700
Subject: [PATCH] [lldb][api-test] Add API test for
 SBCommandInterpreter::CommandOverrideCallback

`SBCommandInterpreter::CommandOverrideCallback` was not being exposed to
the Python API has no coverage in the
API test suite, so this commits exposes and adds a test for it. Doing
this involves also adding a typemap for the callback used for this
function so that it matches the functionality of other callback
functions that are exposed to Python.
---
 lldb/bindings/python/python-typemaps.swig | 27 -
 lldb/bindings/python/python-wrapper.swig  | 13 
 lldb/include/lldb/API/SBCommandInterpreter.h  |  2 --
 .../TestCommandOverrideCallback.py| 30 +++
 4 files changed, 69 insertions(+), 3 deletions(-)
 create mode 100644 
lldb/test/API/python_api/interpreter/TestCommandOverrideCallback.py

diff --git a/lldb/bindings/python/python-typemaps.swig 
b/lldb/bindings/python/python-typemaps.swig
index 8d4b740e5f35c..1bf93c59fbc7b 100644
--- a/lldb/bindings/python/python-typemaps.swig
+++ b/lldb/bindings/python/python-typemaps.swig
@@ -427,7 +427,6 @@ template <> bool SetNumberFromPyObject(double 
, PyObject *obj) {
   free($1);
 }
 
-
 // For Log::LogOutputCallback
 %typemap(in) (lldb::LogOutputCallback log_callback, void *baton) {
   if (!($input == Py_None ||
@@ -476,6 +475,32 @@ template <> bool SetNumberFromPyObject(double 
, PyObject *obj) {
   $1 = $1 || PyCallable_Check(reinterpret_cast($input));
 }
 
+%typemap(in) (lldb::CommandOverrideCallback callback, void *baton) {
+  if (!($input == Py_None ||
+PyCallable_Check(reinterpret_cast($input {
+PyErr_SetString(PyExc_TypeError, "Need a callable object or None!");
+SWIG_fail;
+  }
+
+  // FIXME (filcab): We can't currently check if our callback is already
+  // LLDBSwigPythonCallPythonSBDebuggerTerminateCallback (to DECREF the 
previous
+  // baton) nor can we just remove all traces of a callback, if we want to
+  // revert to a file logging mechanism.
+
+  // Don't lose the callback reference
+  Py_INCREF($input);
+  $1 = LLDBSwigPythonCallPythonSBCommandInterpreterSetCommandOverrideCallback;
+  $2 = $input;
+}
+
+%typemap(typecheck) (lldb::CommandOverrideCallback callback,
+
+  void *baton) {
+
+  $1 = $input == Py_None;
+  $1 = $1 || PyCallable_Check(reinterpret_cast($input));
+}
+
 %typemap(in) lldb::FileSP {
   PythonFile py_file(PyRefType::Borrowed, $input);
   if (!py_file) {
diff --git a/lldb/bindings/python/python-wrapper.swig 
b/lldb/bindings/python/python-wrapper.swig
index 1370afc885d43..0a332cb0a2ff4 100644
--- a/lldb/bindings/python/python-wrapper.swig
+++ b/lldb/bindings/python/python-wrapper.swig
@@ -1099,6 +1099,19 @@ static void 
LLDBSwigPythonCallPythonSBDebuggerTerminateCallback(lldb::user_id_t
   }
 }
 
+static bool 
LLDBSwigPythonCallPythonSBCommandInterpreterSetCommandOverrideCallback(void 
*baton, const char **argv) {
+  bool b = false;
+  if (baton != Py_None) {
+SWIG_PYTHON_THREAD_BEGIN_BLOCK;
+PyObject *result = PyObject_CallFunction(
+  reinterpret_cast(baton), const_cast("s"), argv); // 
WRONG!
+b = result ? PyObject_IsTrue(result) : false;
+Py_XDECREF(result);
+SWIG_PYTHON_THREAD_END_BLOCK;
+  }
+  return b;
+}
+
 static SBError LLDBSwigPythonCallLocateModuleCallback(
 void *callback_baton, const SBModuleSpec _spec_sb,
 SBFileSpec _file_spec_sb, SBFileSpec _file_spec_sb) {
diff --git a/lldb/include/lldb/API/SBCommandInterpreter.h 
b/lldb/include/lldb/API/SBCommandInterpreter.h
index 8ac36344b3a79..084b6d9adb703 100644
--- a/lldb/include/lldb/API/SBCommandInterpreter.h
+++ b/lldb/include/lldb/API/SBCommandInterpreter.h
@@ -265,11 +265,9 @@ class SBCommandInterpreter {
   // Catch commands before they execute by registering a callback that will get
   // called when the command gets executed. This allows GUI or command line
   // interfaces to intercept a command and stop it from happening
-#ifndef SWIG
   bool SetCommandOverrideCallback(const char *command_name,
   lldb::CommandOverrideCallback callback,
   void *baton);
-#endif
 
   /// Return true if the command interpreter is the active IO handler.
   ///
diff --git 
a/lldb/test/API/python_api/interpreter/TestCommandOverrideCallback.py 
b/lldb/test/API/python_api/interpreter/TestCommandOverrideCallback.py
new 

[Lldb-commits] [lldb] [lldb][breakpoint] Grey out disabled breakpoints (PR #91404)

2024-05-16 Thread Chelsea Cassanova via lldb-commits

chelcassanova wrote:

Cool, sorry for the delay but I made changes to `Stream` and `SBStream` to add 
a `GetUseColor()` accessor and to change the bool it uses in initialization to 
a `std::optional` and I'm gonna put them up in a separate PR. 

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


[Lldb-commits] [lldb] [lldb][breakpoint] Grey out disabled breakpoints (PR #91404)

2024-05-10 Thread Chelsea Cassanova via lldb-commits

chelcassanova wrote:

Hm, so in that case should we focus on adding an `SBStream::GetUseColor` so 
that the stream's colour settings can take precedence here?

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


[Lldb-commits] [lldb] [lldb][breakpoint] Grey out disabled breakpoints (PR #91404)

2024-05-09 Thread Chelsea Cassanova via lldb-commits

https://github.com/chelcassanova updated 
https://github.com/llvm/llvm-project/pull/91404

>From 0e45adeac968aa435f58dfef026ef308e56b40a5 Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova 
Date: Thu, 9 May 2024 11:08:29 -0700
Subject: [PATCH] [lldb][breakpoint] Grey out disabled breakpoints

This commit adds colour settings to the list of breakpoints in order to
grey out breakpoints that have been disabled.
---
 lldb/source/Breakpoint/Breakpoint.cpp | 12 
 1 file changed, 12 insertions(+)

diff --git a/lldb/source/Breakpoint/Breakpoint.cpp 
b/lldb/source/Breakpoint/Breakpoint.cpp
index ae845e92762b9..8d28c5f1873e1 100644
--- a/lldb/source/Breakpoint/Breakpoint.cpp
+++ b/lldb/source/Breakpoint/Breakpoint.cpp
@@ -15,6 +15,7 @@
 #include "lldb/Breakpoint/BreakpointResolver.h"
 #include "lldb/Breakpoint/BreakpointResolverFileLine.h"
 #include "lldb/Core/Address.h"
+#include "lldb/Core/Debugger.h"
 #include "lldb/Core/Module.h"
 #include "lldb/Core/ModuleList.h"
 #include "lldb/Core/SearchFilter.h"
@@ -26,6 +27,7 @@
 #include "lldb/Target/SectionLoadList.h"
 #include "lldb/Target/Target.h"
 #include "lldb/Target/ThreadSpec.h"
+#include "lldb/Utility/AnsiTerminal.h"
 #include "lldb/Utility/LLDBLog.h"
 #include "lldb/Utility/Log.h"
 #include "lldb/Utility/Stream.h"
@@ -837,6 +839,12 @@ void Breakpoint::GetDescription(Stream *s, 
lldb::DescriptionLevel level,
 bool show_locations) {
   assert(s != nullptr);
 
+  // Grey out any disabled breakpoints in the list of breakpoints.
+  const bool print_faint =
+  (!IsEnabled() && GetTarget().GetDebugger().GetUseColor());
+  if (print_faint)
+s->Printf("%s", ansi::FormatAnsiTerminalCodes("${ansi.faint}").c_str());
+
   if (!m_kind_description.empty()) {
 if (level == eDescriptionLevelBrief) {
   s->PutCString(GetBreakpointKind());
@@ -933,6 +941,10 @@ void Breakpoint::GetDescription(Stream *s, 
lldb::DescriptionLevel level,
 }
 s->IndentLess();
   }
+
+  // Reset the colors back to normal if they were previously greyed out.
+  if (print_faint)
+s->Printf("%s", ansi::FormatAnsiTerminalCodes("${ansi.normal}").c_str());
 }
 
 void Breakpoint::GetResolverDescription(Stream *s) {

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


[Lldb-commits] [lldb] [lldb][breakpoint] Grey out disabled breakpoints (PR #91404)

2024-05-09 Thread Chelsea Cassanova via lldb-commits


@@ -848,6 +850,13 @@ void Breakpoint::GetDescription(Stream *s, 
lldb::DescriptionLevel level,
   const size_t num_locations = GetNumLocations();
   const size_t num_resolved_locations = GetNumResolvedLocations();
 
+  // Grey out any disabled breakpoints in the list of breakpoints.
+  if (GetTarget().GetDebugger().GetUseColor())
+s->Printf("%s",
+  IsEnabled()
+  ? ansi::FormatAnsiTerminalCodes("${ansi.normal}").c_str()
+  : ansi::FormatAnsiTerminalCodes("${ansi.faint}").c_str());

chelcassanova wrote:

![image](https://github.com/llvm/llvm-project/assets/21184907/0a95ccc6-bf9a-4acb-b8e0-2746d5911f15)
I also thought that I'd have to reset the colours back to normal somewhere but 
when I tried this for a little the colours seemed fine without explicitly 
placing a reset somewhere.

I can still add a reset alongside this simplified logic though.

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


[Lldb-commits] [lldb] [lldb][breakpoint] Grey out disabled breakpoints (PR #91404)

2024-05-09 Thread Chelsea Cassanova via lldb-commits

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


[Lldb-commits] [lldb] [lldb][breakpoint] Grey out disabled breakpoints (PR #91404)

2024-05-09 Thread Chelsea Cassanova via lldb-commits

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


[Lldb-commits] [lldb] [lldb][breakpointoptions] Make disabled keyword red (PR #91404)

2024-05-09 Thread Chelsea Cassanova via lldb-commits

chelcassanova wrote:

I changed this PR to make disabled breakpoints greyed out (per Ismail's 
suggestion). Since this is being done at the `Breakpoint` level we have access 
to the target and its debugger to access `GetUseColor()`.

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


[Lldb-commits] [lldb] [lldb][breakpointoptions] Make disabled keyword red (PR #91404)

2024-05-09 Thread Chelsea Cassanova via lldb-commits

https://github.com/chelcassanova updated 
https://github.com/llvm/llvm-project/pull/91404

>From c334f7357aebefa3e0b7af645396e699cf3a4c8d Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova 
Date: Thu, 9 May 2024 11:08:29 -0700
Subject: [PATCH] [lldb][breakpoint] Grey out disabled breakpoints

This commit adds colour settings to the list of breakpoints in order to
grey out breakpoints that have been disabled.
---
 lldb/source/Breakpoint/Breakpoint.cpp | 9 +
 1 file changed, 9 insertions(+)

diff --git a/lldb/source/Breakpoint/Breakpoint.cpp 
b/lldb/source/Breakpoint/Breakpoint.cpp
index ae845e92762b9..3f42e9fc7df90 100644
--- a/lldb/source/Breakpoint/Breakpoint.cpp
+++ b/lldb/source/Breakpoint/Breakpoint.cpp
@@ -15,6 +15,7 @@
 #include "lldb/Breakpoint/BreakpointResolver.h"
 #include "lldb/Breakpoint/BreakpointResolverFileLine.h"
 #include "lldb/Core/Address.h"
+#include "lldb/Core/Debugger.h"
 #include "lldb/Core/Module.h"
 #include "lldb/Core/ModuleList.h"
 #include "lldb/Core/SearchFilter.h"
@@ -26,6 +27,7 @@
 #include "lldb/Target/SectionLoadList.h"
 #include "lldb/Target/Target.h"
 #include "lldb/Target/ThreadSpec.h"
+#include "lldb/Utility/AnsiTerminal.h"
 #include "lldb/Utility/LLDBLog.h"
 #include "lldb/Utility/Log.h"
 #include "lldb/Utility/Stream.h"
@@ -848,6 +850,13 @@ void Breakpoint::GetDescription(Stream *s, 
lldb::DescriptionLevel level,
   const size_t num_locations = GetNumLocations();
   const size_t num_resolved_locations = GetNumResolvedLocations();
 
+  // Grey out any disabled breakpoints in the list of breakpoints.
+  if (GetTarget().GetDebugger().GetUseColor())
+s->Printf("%s",
+  IsEnabled()
+  ? ansi::FormatAnsiTerminalCodes("${ansi.normal}").c_str()
+  : ansi::FormatAnsiTerminalCodes("${ansi.faint}").c_str());
+
   // They just made the breakpoint, they don't need to be told HOW they made
   // it... Also, we'll print the breakpoint number differently depending on
   // whether there is 1 or more locations.

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


[Lldb-commits] [lldb] [lldb][enums] Remove broadcast bits from debugger (PR #91618)

2024-05-09 Thread Chelsea Cassanova via lldb-commits

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


[Lldb-commits] [lldb] [lldb][enums] Remove broadcast bits from debugger (PR #91618)

2024-05-09 Thread Chelsea Cassanova via lldb-commits

https://github.com/chelcassanova updated 
https://github.com/llvm/llvm-project/pull/91618

>From 167850e01960175e332b9da3d95d6054102a960a Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova 
Date: Thu, 9 May 2024 09:23:02 -0700
Subject: [PATCH] [lldb][enums] Remove broadcast bits from debugger

Removes the debugger broadcast bits from `Debugger.h` and instead uses
the enum from `lldb-enumerations.h`. Also adds the
`eBroadcastSymbolChange` bit to the enum in `lldb-enumerations.h`.
---
 lldb/include/lldb/Core/Debugger.h   | 11 +--
 lldb/include/lldb/lldb-enumerations.h   |  3 ++-
 lldb/source/Core/Debugger.cpp   | 17 +
 lldb/source/Core/Progress.cpp   |  2 +-
 lldb/unittests/Core/DiagnosticEventTest.cpp | 17 +++--
 lldb/unittests/Core/ProgressReportTest.cpp  |  8 
 6 files changed, 24 insertions(+), 34 deletions(-)

diff --git a/lldb/include/lldb/Core/Debugger.h 
b/lldb/include/lldb/Core/Debugger.h
index c0f7c732ad2d4..ea994bf8c28dd 100644
--- a/lldb/include/lldb/Core/Debugger.h
+++ b/lldb/include/lldb/Core/Debugger.h
@@ -78,15 +78,6 @@ class Debugger : public 
std::enable_shared_from_this,
  public UserID,
  public Properties {
 public:
-  /// Broadcaster event bits definitions.
-  enum {
-eBroadcastBitProgress = (1 << 0),
-eBroadcastBitWarning = (1 << 1),
-eBroadcastBitError = (1 << 2),
-eBroadcastSymbolChange = (1 << 3),
-eBroadcastBitProgressCategory = (1 << 4),
-  };
-
   using DebuggerList = std::vector;
 
   static llvm::StringRef GetStaticBroadcasterClass();
@@ -628,7 +619,7 @@ class Debugger : public 
std::enable_shared_from_this,
   ReportProgress(uint64_t progress_id, std::string title, std::string details,
  uint64_t completed, uint64_t total,
  std::optional debugger_id,
- uint32_t progress_category_bit = eBroadcastBitProgress);
+ uint32_t progress_category_bit = lldb::eBroadcastBitProgress);
 
   static void ReportDiagnosticImpl(lldb::Severity severity, std::string 
message,
std::optional debugger_id,
diff --git a/lldb/include/lldb/lldb-enumerations.h 
b/lldb/include/lldb/lldb-enumerations.h
index 437971b3364cd..8e05f6ba9c876 100644
--- a/lldb/include/lldb/lldb-enumerations.h
+++ b/lldb/include/lldb/lldb-enumerations.h
@@ -1344,7 +1344,8 @@ enum DebuggerBroadcastBit {
   eBroadcastBitProgress = (1 << 0),
   eBroadcastBitWarning = (1 << 1),
   eBroadcastBitError = (1 << 2),
-  eBroadcastBitProgressCategory = (1 << 3),
+  eBroadcastSymbolChange = (1 << 3),
+  eBroadcastBitProgressCategory = (1 << 4),
 };
 
 /// Used for expressing severity in logs and diagnostics.
diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp
index 976420a434439..9951fbcd3e7c3 100644
--- a/lldb/source/Core/Debugger.cpp
+++ b/lldb/source/Core/Debugger.cpp
@@ -1485,10 +1485,10 @@ static void PrivateReportDiagnostic(Debugger , 
Severity severity,
 assert(false && "eSeverityInfo should not be broadcast");
 return;
   case eSeverityWarning:
-event_type = Debugger::eBroadcastBitWarning;
+event_type = lldb::eBroadcastBitWarning;
 break;
   case eSeverityError:
-event_type = Debugger::eBroadcastBitError;
+event_type = lldb::eBroadcastBitError;
 break;
   }
 
@@ -1572,7 +1572,7 @@ void Debugger::ReportSymbolChange(const ModuleSpec 
_spec) {
 std::lock_guard guard(*g_debugger_list_mutex_ptr);
 for (DebuggerSP debugger_sp : *g_debugger_list_ptr) {
   EventSP event_sp = std::make_shared(
-  Debugger::eBroadcastSymbolChange,
+  lldb::eBroadcastSymbolChange,
   new SymbolChangeEventData(debugger_sp, module_spec));
   debugger_sp->GetBroadcaster().BroadcastEvent(event_sp);
 }
@@ -1879,8 +1879,9 @@ lldb::thread_result_t Debugger::DefaultEventHandler() {
   CommandInterpreter::eBroadcastBitAsynchronousErrorData);
 
   listener_sp->StartListeningForEvents(
-  _broadcaster, eBroadcastBitProgress | eBroadcastBitWarning |
-  eBroadcastBitError | eBroadcastSymbolChange);
+  _broadcaster, lldb::eBroadcastBitProgress | lldb::eBroadcastBitWarning 
|
+  lldb::eBroadcastBitError |
+  lldb::eBroadcastSymbolChange);
 
   // Let the thread that spawned us know that we have started up and that we
   // are now listening to all required events so no events get missed
@@ -1932,11 +1933,11 @@ lldb::thread_result_t Debugger::DefaultEventHandler() {
   }
 }
   } else if (broadcaster == _broadcaster) {
-if (event_type & Debugger::eBroadcastBitProgress)
+if (event_type & lldb::eBroadcastBitProgress)
   HandleProgressEvent(event_sp);
-else if (event_type & Debugger::eBroadcastBitWarning)
+else if (event_type & lldb::eBroadcastBitWarning)
   

[Lldb-commits] [lldb] [lldb][enums] Remove broadcast bits from debugger (PR #91618)

2024-05-09 Thread Chelsea Cassanova via lldb-commits

https://github.com/chelcassanova created 
https://github.com/llvm/llvm-project/pull/91618

Removes the debugger broadcast bits from `Debugger.h` and instead uses the enum 
from `lldb-enumerations.h`. Also adds the `eBroadcastSymbolChange` bit to the 
enum in `lldb-enumerations.h`.

>From f338108d6b0cbb47e72663c58c1cbb17ee446cbc Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova 
Date: Thu, 9 May 2024 09:23:02 -0700
Subject: [PATCH] [lldb][enums] Remove broadcast bits from debugger

Removes the debugger broadcast bits from `Debugger.h` and instead uses
the enum from `lldb-enumerations.h`. Also adds the
`eBroadcastSymbolChange` bit to the enum in `lldb-enumerations.h`.
---
 lldb/include/lldb/Core/Debugger.h   | 11 +--
 lldb/include/lldb/lldb-enumerations.h   |  3 ++-
 lldb/source/Core/Debugger.cpp   | 16 
 lldb/source/Core/Progress.cpp   |  2 +-
 lldb/unittests/Core/DiagnosticEventTest.cpp | 14 +++---
 lldb/unittests/Core/ProgressReportTest.cpp  |  8 
 6 files changed, 23 insertions(+), 31 deletions(-)

diff --git a/lldb/include/lldb/Core/Debugger.h 
b/lldb/include/lldb/Core/Debugger.h
index c0f7c732ad2d..ea994bf8c28d 100644
--- a/lldb/include/lldb/Core/Debugger.h
+++ b/lldb/include/lldb/Core/Debugger.h
@@ -78,15 +78,6 @@ class Debugger : public 
std::enable_shared_from_this,
  public UserID,
  public Properties {
 public:
-  /// Broadcaster event bits definitions.
-  enum {
-eBroadcastBitProgress = (1 << 0),
-eBroadcastBitWarning = (1 << 1),
-eBroadcastBitError = (1 << 2),
-eBroadcastSymbolChange = (1 << 3),
-eBroadcastBitProgressCategory = (1 << 4),
-  };
-
   using DebuggerList = std::vector;
 
   static llvm::StringRef GetStaticBroadcasterClass();
@@ -628,7 +619,7 @@ class Debugger : public 
std::enable_shared_from_this,
   ReportProgress(uint64_t progress_id, std::string title, std::string details,
  uint64_t completed, uint64_t total,
  std::optional debugger_id,
- uint32_t progress_category_bit = eBroadcastBitProgress);
+ uint32_t progress_category_bit = lldb::eBroadcastBitProgress);
 
   static void ReportDiagnosticImpl(lldb::Severity severity, std::string 
message,
std::optional debugger_id,
diff --git a/lldb/include/lldb/lldb-enumerations.h 
b/lldb/include/lldb/lldb-enumerations.h
index 437971b3364c..8e05f6ba9c87 100644
--- a/lldb/include/lldb/lldb-enumerations.h
+++ b/lldb/include/lldb/lldb-enumerations.h
@@ -1344,7 +1344,8 @@ enum DebuggerBroadcastBit {
   eBroadcastBitProgress = (1 << 0),
   eBroadcastBitWarning = (1 << 1),
   eBroadcastBitError = (1 << 2),
-  eBroadcastBitProgressCategory = (1 << 3),
+  eBroadcastSymbolChange = (1 << 3),
+  eBroadcastBitProgressCategory = (1 << 4),
 };
 
 /// Used for expressing severity in logs and diagnostics.
diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp
index 976420a43443..1c2d4e378e20 100644
--- a/lldb/source/Core/Debugger.cpp
+++ b/lldb/source/Core/Debugger.cpp
@@ -1485,10 +1485,10 @@ static void PrivateReportDiagnostic(Debugger , 
Severity severity,
 assert(false && "eSeverityInfo should not be broadcast");
 return;
   case eSeverityWarning:
-event_type = Debugger::eBroadcastBitWarning;
+event_type = lldb::eBroadcastBitWarning;
 break;
   case eSeverityError:
-event_type = Debugger::eBroadcastBitError;
+event_type = lldb::eBroadcastBitError;
 break;
   }
 
@@ -1572,7 +1572,7 @@ void Debugger::ReportSymbolChange(const ModuleSpec 
_spec) {
 std::lock_guard guard(*g_debugger_list_mutex_ptr);
 for (DebuggerSP debugger_sp : *g_debugger_list_ptr) {
   EventSP event_sp = std::make_shared(
-  Debugger::eBroadcastSymbolChange,
+  lldb::eBroadcastSymbolChange,
   new SymbolChangeEventData(debugger_sp, module_spec));
   debugger_sp->GetBroadcaster().BroadcastEvent(event_sp);
 }
@@ -1879,8 +1879,8 @@ lldb::thread_result_t Debugger::DefaultEventHandler() {
   CommandInterpreter::eBroadcastBitAsynchronousErrorData);
 
   listener_sp->StartListeningForEvents(
-  _broadcaster, eBroadcastBitProgress | eBroadcastBitWarning |
-  eBroadcastBitError | eBroadcastSymbolChange);
+  _broadcaster, lldb::eBroadcastBitProgress | lldb::eBroadcastBitWarning 
|
+  lldb::eBroadcastBitError | 
lldb::eBroadcastSymbolChange);
 
   // Let the thread that spawned us know that we have started up and that we
   // are now listening to all required events so no events get missed
@@ -1932,11 +1932,11 @@ lldb::thread_result_t Debugger::DefaultEventHandler() {
   }
 }
   } else if (broadcaster == _broadcaster) {
-if (event_type & Debugger::eBroadcastBitProgress)
+if (event_type & lldb::eBroadcastBitProgress)
   

[Lldb-commits] [lldb] [lldb][breakpointoptions] Make disabled keyword red (PR #91404)

2024-05-08 Thread Chelsea Cassanova via lldb-commits


@@ -534,7 +534,8 @@ void BreakpointOptions::GetDescription(Stream *s,
 
 if (m_ignore_count > 0)
   s->Printf("ignore: %d ", m_ignore_count);
-s->Printf("%sabled ", m_enabled ? "en" : "dis");
+s->PutCStringColorHighlighted(m_enabled ? "enabled " : "disabled ",
+  m_disbaled_breakpoint_highlight_settings);

chelcassanova wrote:

I was speaking to Ismail about this and seems like it would be nice if we had a 
`Stream::GetUseColor` for this given that you can set whether or not the stream 
has colours at construction but you can't query the state of it after that.

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


[Lldb-commits] [lldb] [WIP] [lldb][Progress] Report progress when completing types from DWARF (PR #91452)

2024-05-08 Thread Chelsea Cassanova via lldb-commits


@@ -1240,7 +1241,13 @@ TypeSP 
SymbolFileDWARFDebugMap::FindCompleteObjCDefinitionTypeForDIE(
 void SymbolFileDWARFDebugMap::FindTypes(const TypeQuery ,
 TypeResults ) {
   std::lock_guard guard(GetModuleMutex());
+  Progress progress(
+  llvm::formatv("Searching for type '{0}'",
+query.GetTypeBasename().AsCString("<>")));
   ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) {
+if (auto *obj = oso_dwarf->GetObjectFile())
+  progress.Increment(1, obj->GetFileSpec().GetPath());

chelcassanova wrote:

It would probably get rendered as `Searching for type 'Foo': main.o` if that 
filename is used as the details for `Increment`.

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


[Lldb-commits] [lldb] [lldb][breakpointoptions] Make disabled keyword red (PR #91404)

2024-05-07 Thread Chelsea Cassanova via lldb-commits


@@ -534,7 +534,8 @@ void BreakpointOptions::GetDescription(Stream *s,
 
 if (m_ignore_count > 0)
   s->Printf("ignore: %d ", m_ignore_count);
-s->Printf("%sabled ", m_enabled ? "en" : "dis");
+s->PutCStringColorHighlighted(m_enabled ? "enabled " : "disabled ",
+  m_disbaled_breakpoint_highlight_settings);

chelcassanova wrote:

This means that only the debugger tells you whether or not you're using colours 
then? `BreakpointOptions::GetDescription()` doesn't seem to have a reference to 
the debugger, target or interpreter so I'm wondering what the next best options 
to determine if we're using colours is. 

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


[Lldb-commits] [lldb] [lldb][breakpointoptions] Make disabled keyword red (PR #91404)

2024-05-07 Thread Chelsea Cassanova via lldb-commits


@@ -534,7 +534,8 @@ void BreakpointOptions::GetDescription(Stream *s,
 
 if (m_ignore_count > 0)
   s->Printf("ignore: %d ", m_ignore_count);
-s->Printf("%sabled ", m_enabled ? "en" : "dis");
+s->PutCStringColorHighlighted(m_enabled ? "enabled " : "disabled ",
+  m_disbaled_breakpoint_highlight_settings);

chelcassanova wrote:

Ah, so using `Printf` with `ansi::FormatAnsiTerminalCodes` instead? And yes 
using this with `--no-use-colors` does show the colour here so it looks like 
this isn't being checked at the stream level.

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


[Lldb-commits] [lldb] [lldb][breakpointoptions] Make disabled keyword red (PR #91404)

2024-05-07 Thread Chelsea Cassanova via lldb-commits

https://github.com/chelcassanova created 
https://github.com/llvm/llvm-project/pull/91404

This commit adds colour highlighting to the `disabled` keyword in the 
breakpoint list so that it appears red (and should be easier to see in a large 
sea of breakpoints).

>From 4458e951ed4b8d226974000dae2705ad6ec6ed79 Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova 
Date: Tue, 7 May 2024 14:20:14 -0700
Subject: [PATCH] [lldb][breakpointoptions] Make disabled keyword red

This commit adds colour highlighting to the `disabled` keyword in the
breakpoint list so that it appears red (and should be easier to see in a
large sea of breakpoints).
---
 lldb/include/lldb/Breakpoint/BreakpointOptions.h | 6 ++
 lldb/source/Breakpoint/BreakpointOptions.cpp | 3 ++-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/lldb/include/lldb/Breakpoint/BreakpointOptions.h 
b/lldb/include/lldb/Breakpoint/BreakpointOptions.h
index 7bf545717422..3dc3a7190d03 100644
--- a/lldb/include/lldb/Breakpoint/BreakpointOptions.h
+++ b/lldb/include/lldb/Breakpoint/BreakpointOptions.h
@@ -400,6 +400,12 @@ friend class Breakpoint;
   /// Which options are set at this level.
   /// Drawn from BreakpointOptions::SetOptionsFlags.
   Flags m_set_flags;
+  /// Settings that allow the 'disabled' keyword to be displayed in red.
+  Stream::HighlightSettings m_disbaled_breakpoint_highlight_settings{
+  "disabled",
+  "\x1b[31m",
+  "\x1b[37m",
+  };
 };
 
 } // namespace lldb_private
diff --git a/lldb/source/Breakpoint/BreakpointOptions.cpp 
b/lldb/source/Breakpoint/BreakpointOptions.cpp
index 6c6037dd9edd..993de590b0d4 100644
--- a/lldb/source/Breakpoint/BreakpointOptions.cpp
+++ b/lldb/source/Breakpoint/BreakpointOptions.cpp
@@ -534,7 +534,8 @@ void BreakpointOptions::GetDescription(Stream *s,
 
 if (m_ignore_count > 0)
   s->Printf("ignore: %d ", m_ignore_count);
-s->Printf("%sabled ", m_enabled ? "en" : "dis");
+s->PutCStringColorHighlighted(m_enabled ? "enabled " : "disabled ",
+  m_disbaled_breakpoint_highlight_settings);
 
 if (m_one_shot)
   s->Printf("one-shot ");

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


[Lldb-commits] [lldb] [lldb][sbapi] Fix API break in SBDebugger broadcast bits (PR #90261)

2024-04-26 Thread Chelsea Cassanova via lldb-commits

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


[Lldb-commits] [lldb] [lldb][sbapi] Fix API break in SBDebugger broadcast bits (PR #90261)

2024-04-26 Thread Chelsea Cassanova via lldb-commits

https://github.com/chelcassanova updated 
https://github.com/llvm/llvm-project/pull/90261

>From 697ab926dd1139810ec7d126258f6386552cdf96 Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova 
Date: Fri, 26 Apr 2024 12:52:19 -0700
Subject: [PATCH] [lldb][sbapi] Fix API break in SBDebugger broadcast bits

https://github.com/llvm/llvm-project/pull/87409 removed the broadcast
bits from SBDebugger and placed them in `lldb-enumerations.h`. This is
API-breaking so this commits places the enum back into `SBDebugger.h`
and references the bits from `lldb-enumerations.h`.
---
 lldb/include/lldb/API/SBDebugger.h | 7 +++
 .../diagnostic_reporting/TestDiagnosticReporting.py| 2 +-
 .../progress_reporting/TestProgressReporting.py| 2 +-
 .../clang_modules/TestClangModuleBuildProgress.py  | 2 +-
 lldb/test/API/macosx/rosetta/TestRosetta.py| 2 +-
 lldb/tools/lldb-dap/lldb-dap.cpp   | 4 ++--
 6 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/lldb/include/lldb/API/SBDebugger.h 
b/lldb/include/lldb/API/SBDebugger.h
index cf5409a12a056a..7333cd57ad3129 100644
--- a/lldb/include/lldb/API/SBDebugger.h
+++ b/lldb/include/lldb/API/SBDebugger.h
@@ -42,6 +42,13 @@ class LLDB_API SBInputReader {
 
 class LLDB_API SBDebugger {
 public:
+  FLAGS_ANONYMOUS_ENUM(){
+  eBroadcastBitProgress = 
lldb::DebuggerBroadcastBit::eBroadcastBitProgress,
+  eBroadcastBitWarning = lldb::DebuggerBroadcastBit::eBroadcastBitWarning,
+  eBroadcastBitError = lldb::DebuggerBroadcastBit::eBroadcastBitError,
+  eBroadcastBitProgressCategory =
+  lldb::DebuggerBroadcastBit::eBroadcastBitProgressCategory,
+  };
   SBDebugger();
 
   SBDebugger(const lldb::SBDebugger );
diff --git 
a/lldb/test/API/functionalities/diagnostic_reporting/TestDiagnosticReporting.py 
b/lldb/test/API/functionalities/diagnostic_reporting/TestDiagnosticReporting.py
index 6353e3e8cbedbd..36a3be695628f5 100644
--- 
a/lldb/test/API/functionalities/diagnostic_reporting/TestDiagnosticReporting.py
+++ 
b/lldb/test/API/functionalities/diagnostic_reporting/TestDiagnosticReporting.py
@@ -15,7 +15,7 @@ def setUp(self):
 self.broadcaster = self.dbg.GetBroadcaster()
 self.listener = lldbutil.start_listening_from(
 self.broadcaster,
-lldb.eBroadcastBitWarning | lldb.eBroadcastBitError,
+lldb.SBDebugger.eBroadcastBitWarning | 
lldb.SBDebugger.eBroadcastBitError,
 )
 
 def test_dwarf_symbol_loading_diagnostic_report(self):
diff --git 
a/lldb/test/API/functionalities/progress_reporting/TestProgressReporting.py 
b/lldb/test/API/functionalities/progress_reporting/TestProgressReporting.py
index 98988d7624da3c..9af53845ca1b77 100644
--- a/lldb/test/API/functionalities/progress_reporting/TestProgressReporting.py
+++ b/lldb/test/API/functionalities/progress_reporting/TestProgressReporting.py
@@ -13,7 +13,7 @@ def setUp(self):
 TestBase.setUp(self)
 self.broadcaster = self.dbg.GetBroadcaster()
 self.listener = lldbutil.start_listening_from(
-self.broadcaster, lldb.eBroadcastBitProgress
+self.broadcaster, lldb.SBDebugger.eBroadcastBitProgress
 )
 
 def test_dwarf_symbol_loading_progress_report(self):
diff --git 
a/lldb/test/API/functionalities/progress_reporting/clang_modules/TestClangModuleBuildProgress.py
 
b/lldb/test/API/functionalities/progress_reporting/clang_modules/TestClangModuleBuildProgress.py
index 33c7c269c081e4..228f676aedf6ac 100644
--- 
a/lldb/test/API/functionalities/progress_reporting/clang_modules/TestClangModuleBuildProgress.py
+++ 
b/lldb/test/API/functionalities/progress_reporting/clang_modules/TestClangModuleBuildProgress.py
@@ -34,7 +34,7 @@ def test_clang_module_build_progress_report(self):
 # other unrelated progress events.
 broadcaster = self.dbg.GetBroadcaster()
 listener = lldbutil.start_listening_from(
-broadcaster, lldb.eBroadcastBitProgress
+broadcaster, lldb.SBDebugger.eBroadcastBitProgress
 )
 
 # Trigger module builds.
diff --git a/lldb/test/API/macosx/rosetta/TestRosetta.py 
b/lldb/test/API/macosx/rosetta/TestRosetta.py
index 669db95a1624c6..ce40de475ef16c 100644
--- a/lldb/test/API/macosx/rosetta/TestRosetta.py
+++ b/lldb/test/API/macosx/rosetta/TestRosetta.py
@@ -49,7 +49,7 @@ def test_rosetta(self):
 if rosetta_debugserver_installed():
 broadcaster = self.dbg.GetBroadcaster()
 listener = lldbutil.start_listening_from(
-broadcaster, lldb.eBroadcastBitWarning
+broadcaster, lldb.SBDebugger.eBroadcastBitWarning
 )
 
 target, process, thread, bkpt = lldbutil.run_to_source_breakpoint(
diff --git a/lldb/tools/lldb-dap/lldb-dap.cpp b/lldb/tools/lldb-dap/lldb-dap.cpp
index 16c50ed5791b0a..97a6df3508f4f1 100644
--- a/lldb/tools/lldb-dap/lldb-dap.cpp
+++ 

[Lldb-commits] [lldb] [lldb][sbapi] Fix API break in SBDebugger broadcast bits (PR #90261)

2024-04-26 Thread Chelsea Cassanova via lldb-commits

https://github.com/chelcassanova created 
https://github.com/llvm/llvm-project/pull/90261

https://github.com/llvm/llvm-project/pull/87409 removed the broadcast bits from 
SBDebugger and placed them in `lldb-enumerations.h`. This is API-breaking so 
this commits places the enum back into `SBDebugger.h` and references the bits 
from `lldb-enumerations.h`.

>From b0a7237da0517f59f04791d8ecef102acc84408a Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova 
Date: Fri, 26 Apr 2024 12:52:19 -0700
Subject: [PATCH] [lldb][sbapi] Fix API break in SBDebugger broadcast bits

https://github.com/llvm/llvm-project/pull/87409 removed the broadcast
bits from SBDebugger and placed them in `lldb-enumerations.h`. This is
API-breaking so this commits places the enum back into `SBDebugger.h`
and references the bits from `lldb-enumerations.h`.
---
 lldb/include/lldb/API/SBDebugger.h | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/lldb/include/lldb/API/SBDebugger.h 
b/lldb/include/lldb/API/SBDebugger.h
index cf5409a12a056a..7333cd57ad3129 100644
--- a/lldb/include/lldb/API/SBDebugger.h
+++ b/lldb/include/lldb/API/SBDebugger.h
@@ -42,6 +42,13 @@ class LLDB_API SBInputReader {
 
 class LLDB_API SBDebugger {
 public:
+  FLAGS_ANONYMOUS_ENUM(){
+  eBroadcastBitProgress = 
lldb::DebuggerBroadcastBit::eBroadcastBitProgress,
+  eBroadcastBitWarning = lldb::DebuggerBroadcastBit::eBroadcastBitWarning,
+  eBroadcastBitError = lldb::DebuggerBroadcastBit::eBroadcastBitError,
+  eBroadcastBitProgressCategory =
+  lldb::DebuggerBroadcastBit::eBroadcastBitProgressCategory,
+  };
   SBDebugger();
 
   SBDebugger(const lldb::SBDebugger );

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


[Lldb-commits] [lldb] [lldb][docs] Update instructions for debugging API tests (PR #89979)

2024-04-24 Thread Chelsea Cassanova via lldb-commits

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


[Lldb-commits] [lldb] [lldb][docs] Update instructions for debugging API tests (PR #89979)

2024-04-24 Thread Chelsea Cassanova via lldb-commits

https://github.com/chelcassanova created 
https://github.com/llvm/llvm-project/pull/89979

This adds the option to use the `breakpoint()` keyword as a way to debug the 
API tests.

>From f1a0a1bc059e133d2e00157ce58b2cbda4904fab Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova 
Date: Wed, 24 Apr 2024 12:48:29 -0700
Subject: [PATCH] [lldb][docs] Update instructions for debugging API tests

This adds the option to use the `breakpoint()` keyword as a way to debug
the API tests.
---
 lldb/docs/resources/test.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lldb/docs/resources/test.rst b/lldb/docs/resources/test.rst
index 2b0e9010fe280a..d90d7012f1c860 100644
--- a/lldb/docs/resources/test.rst
+++ b/lldb/docs/resources/test.rst
@@ -602,7 +602,7 @@ will cause the script to print out the pid of the test and 
wait for a while
 until a debugger is attached. Then run ``lldb -p `` to attach.
 
 To instead debug a test's python source, edit the test and insert
-``import pdb; pdb.set_trace()`` at the point you want to start debugging. In
+``import pdb; pdb.set_trace()`` or ``breakpoint()`` (Python 3 only) at the 
point you want to start debugging. In
 addition to pdb's debugging facilities, lldb commands can be executed with the
 help of a pdb alias. For example ``lldb bt`` and ``lldb v some_var``. Add this
 line to your ``~/.pdbrc``:

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


[Lldb-commits] [lldb] [lldb][lit] Guard MallocNanoZone envvar in shell tests (PR #88824)

2024-04-15 Thread Chelsea Cassanova via lldb-commits

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


[Lldb-commits] [lldb] [lldb][lit] Guard MallocNanoZone envvar in shell tests (PR #88824)

2024-04-15 Thread Chelsea Cassanova via lldb-commits

https://github.com/chelcassanova updated 
https://github.com/llvm/llvm-project/pull/88824

>From 7b95abd2247ca3e34985ce2c7e93c3dbe3a609c5 Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova 
Date: Mon, 15 Apr 2024 15:29:06 -0700
Subject: [PATCH] [lldb][lit] Guard MallocNanoZone envvar in shell tests

Previously the MallocNanoZone envvar would be set to 0 on Darwin for the
LLDB shell tests, but this should guarded behind ASan being enabled as
opposed to simply running the test suite behind Darwin. This required
that the LLVM_USE_SANITIZER option be added as an attribute to the lit
config for shell tests.
---
 lldb/test/Shell/lit.cfg.py | 12 
 lldb/test/Shell/lit.site.cfg.py.in |  1 +
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/lldb/test/Shell/lit.cfg.py b/lldb/test/Shell/lit.cfg.py
index 290569576ac80d..e24f3fbb4d9318 100644
--- a/lldb/test/Shell/lit.cfg.py
+++ b/lldb/test/Shell/lit.cfg.py
@@ -50,10 +50,14 @@
 )
 
 # Enable sanitizer runtime flags.
-config.environment["ASAN_OPTIONS"] = "detect_stack_use_after_return=1"
-config.environment["TSAN_OPTIONS"] = "halt_on_error=1"
-if platform.system() == "Darwin":
-config.environment["MallocNanoZone"] = "0"
+if "Address" in config.llvm_use_sanitizer:
+config.environment["ASAN_OPTIONS"] = "detect_stack_use_after_return=1"
+if platform.system() == "Darwin":
+config.environment["MallocNanoZone"] = "0"
+
+if "Thread" in config.llvm_use_sanitizer:
+config.environment["TSAN_OPTIONS"] = "halt_on_error=1"
+
 
 # Support running the test suite under the lldb-repro wrapper. This makes it
 # possible to capture a test suite run and then rerun all the test from the
diff --git a/lldb/test/Shell/lit.site.cfg.py.in 
b/lldb/test/Shell/lit.site.cfg.py.in
index 736dfc335732b5..b69e7bce1bc0be 100644
--- a/lldb/test/Shell/lit.site.cfg.py.in
+++ b/lldb/test/Shell/lit.site.cfg.py.in
@@ -26,6 +26,7 @@ config.lldb_enable_lua = @LLDB_ENABLE_LUA@
 config.lldb_build_directory = "@LLDB_TEST_BUILD_DIRECTORY@"
 config.have_lldb_server = @LLDB_TOOL_LLDB_SERVER_BUILD@
 config.lldb_system_debugserver = @LLDB_USE_SYSTEM_DEBUGSERVER@
+config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@"
 # The shell tests use their own module caches.
 config.lldb_module_cache = os.path.join("@LLDB_TEST_MODULE_CACHE_LLDB@", 
"lldb-shell")
 config.clang_module_cache = os.path.join("@LLDB_TEST_MODULE_CACHE_CLANG@", 
"lldb-shell")

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


[Lldb-commits] [lldb] [lldb][lit] Guard MallocNanoZone envvar in shell tests (PR #88824)

2024-04-15 Thread Chelsea Cassanova via lldb-commits

https://github.com/chelcassanova created 
https://github.com/llvm/llvm-project/pull/88824

Previously the MallocNanoZone envvar would be set to 0 on Darwin for the LLDB 
shell tests, but this should guarded behind ASan being enabled as opposed to 
simply running the test suite behind Darwin. This required that the 
LLVM_USE_SANITIZER option be added as an attribute to the lit config for shell 
tests.

>From 08a98fef47798998703df2b1deda0be69e2849cd Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova 
Date: Mon, 15 Apr 2024 15:29:06 -0700
Subject: [PATCH] [lldb][lit] Guard MallocNanoZone envvar in shell tests

Previously the MallocNanoZone envvar would be set to 0 on Darwin for the
LLDB shell tests, but this should guarded behind ASan being enabled as
opposed to simply running the test suite behind Darwin. This required
that the LLVM_USE_SANITIZER option be added as an attribute to the lit
config for shell tests.
---
 lldb/test/Shell/lit.cfg.py | 13 +
 lldb/test/Shell/lit.site.cfg.py.in |  1 +
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/lldb/test/Shell/lit.cfg.py b/lldb/test/Shell/lit.cfg.py
index 290569576ac80d..8379c3183cc084 100644
--- a/lldb/test/Shell/lit.cfg.py
+++ b/lldb/test/Shell/lit.cfg.py
@@ -50,10 +50,15 @@
 )
 
 # Enable sanitizer runtime flags.
-config.environment["ASAN_OPTIONS"] = "detect_stack_use_after_return=1"
-config.environment["TSAN_OPTIONS"] = "halt_on_error=1"
-if platform.system() == "Darwin":
-config.environment["MallocNanoZone"] = "0"
+if "Address" in config.llvm_use_sanitizer:
+config.environment["ASAN_OPTIONS"] = "detect_stack_use_after_return=1"
+if platform.system() == "Darwin":
+config.environment["MallocNanoZone"] = "0"
+
+if "Thread" in config.llvm_use_sanitizer:
+config.environment["TSAN_OPTIONS"] = "halt_on_error=1"
+
+
 
 # Support running the test suite under the lldb-repro wrapper. This makes it
 # possible to capture a test suite run and then rerun all the test from the
diff --git a/lldb/test/Shell/lit.site.cfg.py.in 
b/lldb/test/Shell/lit.site.cfg.py.in
index 736dfc335732b5..b69e7bce1bc0be 100644
--- a/lldb/test/Shell/lit.site.cfg.py.in
+++ b/lldb/test/Shell/lit.site.cfg.py.in
@@ -26,6 +26,7 @@ config.lldb_enable_lua = @LLDB_ENABLE_LUA@
 config.lldb_build_directory = "@LLDB_TEST_BUILD_DIRECTORY@"
 config.have_lldb_server = @LLDB_TOOL_LLDB_SERVER_BUILD@
 config.lldb_system_debugserver = @LLDB_USE_SYSTEM_DEBUGSERVER@
+config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@"
 # The shell tests use their own module caches.
 config.lldb_module_cache = os.path.join("@LLDB_TEST_MODULE_CACHE_LLDB@", 
"lldb-shell")
 config.clang_module_cache = os.path.join("@LLDB_TEST_MODULE_CACHE_CLANG@", 
"lldb-shell")

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


[Lldb-commits] [lldb] Reapply "Fix error in unrecognized register name handling for "SBFram…e.register"" (#88468)" (PR #88535)

2024-04-12 Thread Chelsea Cassanova via lldb-commits

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

LGTM!

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


[Lldb-commits] [lldb] Reland "[lldb][lit] Add MallocNanoZone envvar to Darwin ASan builds" … (PR #88442)

2024-04-11 Thread Chelsea Cassanova via lldb-commits

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


[Lldb-commits] [lldb] Revert "Fix error in unrecognized register name handling for "SBFrame.register"" (PR #88468)

2024-04-11 Thread Chelsea Cassanova via lldb-commits

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


[Lldb-commits] [lldb] Revert "Fix error in unrecognized register name handling for "SBFrame.register"" (PR #88468)

2024-04-11 Thread Chelsea Cassanova via lldb-commits

https://github.com/chelcassanova created 
https://github.com/llvm/llvm-project/pull/88468

Reverts llvm/llvm-project#88047. TestFrames.py is failing on x86_64 
GreenDragon: 
https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/lldb-cmake/983/

>From 069d90a500ed02067f3f1a5d01c7827623353b85 Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova 
Date: Thu, 11 Apr 2024 20:12:43 -0700
Subject: [PATCH] =?UTF-8?q?Revert=20"Fix=20error=20in=20unrecognized=20reg?=
 =?UTF-8?q?ister=20name=20handling=20for=20"SBFrame.registe=E2=80=A6"?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This reverts commit 9a36077e4db30c7da603620762036d4a430e4e62.
---
 lldb/bindings/interface/SBFrameExtensions.i  | 12 +---
 lldb/test/API/python_api/frame/TestFrames.py | 12 
 2 files changed, 1 insertion(+), 23 deletions(-)

diff --git a/lldb/bindings/interface/SBFrameExtensions.i 
b/lldb/bindings/interface/SBFrameExtensions.i
index e0472280666ab9..43b22ed7a6b325 100644
--- a/lldb/bindings/interface/SBFrameExtensions.i
+++ b/lldb/bindings/interface/SBFrameExtensions.i
@@ -44,16 +44,6 @@ STRING_EXTENSION_OUTSIDE(SBFrame)
 def __init__(self, regs):
 self.regs = regs
 
-def __iter__(self):
-return self.get_registers()
-
-def get_registers(self):
-for i in range(0,len(self.regs)):
-rs = self.regs[i]
-for j in range (0,rs.num_children):
-reg = rs.GetChildAtIndex(j)
-yield reg
-  
 def __getitem__(self, key):
 if type(key) is str:
 for i in range(0,len(self.regs)):
@@ -62,7 +52,7 @@ STRING_EXTENSION_OUTSIDE(SBFrame)
 reg = rs.GetChildAtIndex(j)
 if reg.name == key: return reg
 else:
-return SBValue()
+return lldb.SBValue()
 
 return registers_access(self.registers)
 
diff --git a/lldb/test/API/python_api/frame/TestFrames.py 
b/lldb/test/API/python_api/frame/TestFrames.py
index dfa96d51830bae..a82b129bc8099d 100644
--- a/lldb/test/API/python_api/frame/TestFrames.py
+++ b/lldb/test/API/python_api/frame/TestFrames.py
@@ -73,19 +73,7 @@ def test_get_arg_vals_for_call_stack(self):
 gpr_reg_set = lldbutil.get_GPRs(frame)
 pc_value = gpr_reg_set.GetChildMemberWithName("pc")
 self.assertTrue(pc_value, "We should have a valid PC.")
-# Make sure we can also get this from the "register" property:
-iterator_pc_value = 0
-found_pc = False
-for reg in frame.register:
-if reg.name == "pc":
-found_pc = True
-iterator_pc_value = int(reg.GetValue(), 0)
-break
-
 pc_value_int = int(pc_value.GetValue(), 0)
-self.assertTrue(found_pc, "Found the PC value in the register 
list")
-self.assertEqual(iterator_pc_value, pc_value_int, "The methods 
of finding pc match")
-
 # Make sure on arm targets we dont mismatch PC value on the 
basis of thumb bit.
 # Frame PC will not have thumb bit set in case of a thumb
 # instruction as PC.

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


[Lldb-commits] [lldb] Reland "[lldb][lit] Add MallocNanoZone envvar to Darwin ASan builds" … (PR #88442)

2024-04-11 Thread Chelsea Cassanova via lldb-commits

https://github.com/chelcassanova created 
https://github.com/llvm/llvm-project/pull/88442

…(#88436)"

This reverts commit 1f5d130df85c2d0550dc8687ad0fa1d96856c318. The original 
commit checks that the host system is "Darwin" before setting the 
`MallocNanoZone` envvar, but on the Shell lit config this attribute does not 
exist at the point where it is being checked which leads to a build failure.

This commit checks the host OS correctly.

>From dc964330c1409a2089c54114d1efea43cc835599 Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova 
Date: Thu, 11 Apr 2024 14:18:22 -0700
Subject: [PATCH] Reland "[lldb][lit] Add MallocNanoZone envvar to Darwin ASan
 builds" (#88436)"

This reverts commit 1f5d130df85c2d0550dc8687ad0fa1d96856c318. The
original commit checks that the host system is "Darwin" before setting
the `MallocNanoZone` envvar, but on the Shell lit config this attribute
does not exist at the point where it is being checked which leads to a
build failure.

This commit checks the host OS correctly.
---
 lldb/test/API/lit.cfg.py   | 1 +
 lldb/test/Shell/lit.cfg.py | 2 ++
 2 files changed, 3 insertions(+)

diff --git a/lldb/test/API/lit.cfg.py b/lldb/test/API/lit.cfg.py
index f9497b632fc504..9ea389c639a013 100644
--- a/lldb/test/API/lit.cfg.py
+++ b/lldb/test/API/lit.cfg.py
@@ -121,6 +121,7 @@ def delete_module_cache(path):
 config.environment["DYLD_INSERT_LIBRARIES"] = 
find_sanitizer_runtime(
 "libclang_rt.asan_osx_dynamic.dylib"
 )
+config.environment["MallocNanoZone"] = "0"
 
 if "Thread" in config.llvm_use_sanitizer:
 config.environment["TSAN_OPTIONS"] = "halt_on_error=1"
diff --git a/lldb/test/Shell/lit.cfg.py b/lldb/test/Shell/lit.cfg.py
index 31afe5151c0661..290569576ac80d 100644
--- a/lldb/test/Shell/lit.cfg.py
+++ b/lldb/test/Shell/lit.cfg.py
@@ -52,6 +52,8 @@
 # Enable sanitizer runtime flags.
 config.environment["ASAN_OPTIONS"] = "detect_stack_use_after_return=1"
 config.environment["TSAN_OPTIONS"] = "halt_on_error=1"
+if platform.system() == "Darwin":
+config.environment["MallocNanoZone"] = "0"
 
 # Support running the test suite under the lldb-repro wrapper. This makes it
 # possible to capture a test suite run and then rerun all the test from the

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


[Lldb-commits] [lldb] Revert "[lldb][lit] Add MallocNanoZone envvar to Darwin ASan builds" (PR #88436)

2024-04-11 Thread Chelsea Cassanova via lldb-commits

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


[Lldb-commits] [lldb] Revert "[lldb][lit] Add MallocNanoZone envvar to Darwin ASan builds" (PR #88436)

2024-04-11 Thread Chelsea Cassanova via lldb-commits

https://github.com/chelcassanova created 
https://github.com/llvm/llvm-project/pull/88436

Reverts llvm/llvm-project#88431. A config variable for the host OS is 
unrecognized on the Linux builds and is causing a build failure.

>From 79a4eb5047d8c90568b04ad5fb90e6421e1aba69 Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova 
Date: Thu, 11 Apr 2024 13:41:48 -0700
Subject: [PATCH] Revert "[lldb][lit] Add MallocNanoZone envvar to Darwin ASan
 builds (#88431)"

This reverts commit 4df854e1a98ed47c955838d2c94bf2913c50041f.
---
 lldb/test/API/lit.cfg.py   | 1 -
 lldb/test/Shell/lit.cfg.py | 2 --
 2 files changed, 3 deletions(-)

diff --git a/lldb/test/API/lit.cfg.py b/lldb/test/API/lit.cfg.py
index 9ea389c639a013..f9497b632fc504 100644
--- a/lldb/test/API/lit.cfg.py
+++ b/lldb/test/API/lit.cfg.py
@@ -121,7 +121,6 @@ def delete_module_cache(path):
 config.environment["DYLD_INSERT_LIBRARIES"] = 
find_sanitizer_runtime(
 "libclang_rt.asan_osx_dynamic.dylib"
 )
-config.environment["MallocNanoZone"] = "0"
 
 if "Thread" in config.llvm_use_sanitizer:
 config.environment["TSAN_OPTIONS"] = "halt_on_error=1"
diff --git a/lldb/test/Shell/lit.cfg.py b/lldb/test/Shell/lit.cfg.py
index 345627835d2bf2..31afe5151c0661 100644
--- a/lldb/test/Shell/lit.cfg.py
+++ b/lldb/test/Shell/lit.cfg.py
@@ -52,8 +52,6 @@
 # Enable sanitizer runtime flags.
 config.environment["ASAN_OPTIONS"] = "detect_stack_use_after_return=1"
 config.environment["TSAN_OPTIONS"] = "halt_on_error=1"
-if "Darwin" in config.host_os:
-config.environment["MallocNanoZone"] = "0"
 
 # Support running the test suite under the lldb-repro wrapper. This makes it
 # possible to capture a test suite run and then rerun all the test from the

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


[Lldb-commits] [lldb] [lldb][lit] Add MallocNanoZone envvar to Darwin ASan builds (PR #88431)

2024-04-11 Thread Chelsea Cassanova via lldb-commits

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


[Lldb-commits] [lldb] [lldb][lit] Add MallocNanoZone envvar to Darwin ASan builds (PR #88431)

2024-04-11 Thread Chelsea Cassanova via lldb-commits

chelcassanova wrote:

If that's the case then I'll just merge this in.

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


[Lldb-commits] [lldb] [lldb][lit] Add MallocNanoZone envvar to Darwin ASan builds (PR #88431)

2024-04-11 Thread Chelsea Cassanova via lldb-commits

https://github.com/chelcassanova created 
https://github.com/llvm/llvm-project/pull/88431

When builds on Darwin are configured with ASan, running tests will emit a 
warning about malloc's nano zone that can interfere with the test output and 
cause failures. Setting the environment variable `MallocNanoZone` to 0 will 
remove this warning and allow the tests to run as normal.

>From 13184a3e7da4972feb6fc73878303301b8aa739d Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova 
Date: Thu, 11 Apr 2024 11:06:52 -0700
Subject: [PATCH] [lldb][lit] Add MallocNanoZone envvar to Darwin ASan builds

When builds are Darwin are configured with ASan, running tests will emit
a warning that can interfere with the test output and cause failures.
Setting the environment variable `MallocNanoZone` to 0 will remove this
warning and allow the tests to run as normal.
---
 lldb/test/API/lit.cfg.py   | 1 +
 lldb/test/Shell/lit.cfg.py | 2 ++
 2 files changed, 3 insertions(+)

diff --git a/lldb/test/API/lit.cfg.py b/lldb/test/API/lit.cfg.py
index f9497b632fc504..9ea389c639a013 100644
--- a/lldb/test/API/lit.cfg.py
+++ b/lldb/test/API/lit.cfg.py
@@ -121,6 +121,7 @@ def delete_module_cache(path):
 config.environment["DYLD_INSERT_LIBRARIES"] = 
find_sanitizer_runtime(
 "libclang_rt.asan_osx_dynamic.dylib"
 )
+config.environment["MallocNanoZone"] = "0"
 
 if "Thread" in config.llvm_use_sanitizer:
 config.environment["TSAN_OPTIONS"] = "halt_on_error=1"
diff --git a/lldb/test/Shell/lit.cfg.py b/lldb/test/Shell/lit.cfg.py
index 31afe5151c0661..345627835d2bf2 100644
--- a/lldb/test/Shell/lit.cfg.py
+++ b/lldb/test/Shell/lit.cfg.py
@@ -52,6 +52,8 @@
 # Enable sanitizer runtime flags.
 config.environment["ASAN_OPTIONS"] = "detect_stack_use_after_return=1"
 config.environment["TSAN_OPTIONS"] = "halt_on_error=1"
+if "Darwin" in config.host_os:
+config.environment["MallocNanoZone"] = "0"
 
 # Support running the test suite under the lldb-repro wrapper. This makes it
 # possible to capture a test suite run and then rerun all the test from the

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


[Lldb-commits] [lldb] Reland "[lldb][sbdebugger] Move SBDebugger Broadcast bit enum into ll… (PR #88331)

2024-04-11 Thread Chelsea Cassanova via lldb-commits

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


[Lldb-commits] [lldb] Reland "[lldb][sbdebugger] Move SBDebugger Broadcast bit enum into ll… (PR #88331)

2024-04-10 Thread Chelsea Cassanova via lldb-commits

https://github.com/chelcassanova created 
https://github.com/llvm/llvm-project/pull/88331

…db-enumerations.h" (#88324)"

This reverts commit 9f6d08f2566a26144ea1753f80aebb1f2ecfdc63. This broke the 
build because of a usage of one of the original SBDebugger broadcast bits that 
wasn't updated in the original commit.

>From 535923f710c61ab1273ac527099691e32e08a2df Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova 
Date: Wed, 10 Apr 2024 16:22:44 -0700
Subject: [PATCH] Reland "[lldb][sbdebugger] Move SBDebugger Broadcast bit enum
 into lldb-enumerations.h" (#88324)"

This reverts commit 9f6d08f2566a26144ea1753f80aebb1f2ecfdc63. This broke
the build because of a usage of one of the original SBDebugger broadcast
bits that wasn't updated in the original commit.
---
 lldb/include/lldb/API/SBDebugger.h| 7 ---
 lldb/include/lldb/lldb-enumerations.h | 8 
 .../diagnostic_reporting/TestDiagnosticReporting.py   | 2 +-
 .../progress_reporting/TestProgressReporting.py   | 2 +-
 .../clang_modules/TestClangModuleBuildProgress.py | 2 +-
 lldb/test/API/macosx/rosetta/TestRosetta.py   | 2 +-
 lldb/tools/lldb-dap/lldb-dap.cpp  | 4 ++--
 7 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/lldb/include/lldb/API/SBDebugger.h 
b/lldb/include/lldb/API/SBDebugger.h
index 62b2f91f5076d5..cf5409a12a056a 100644
--- a/lldb/include/lldb/API/SBDebugger.h
+++ b/lldb/include/lldb/API/SBDebugger.h
@@ -42,13 +42,6 @@ class LLDB_API SBInputReader {
 
 class LLDB_API SBDebugger {
 public:
-  FLAGS_ANONYMOUS_ENUM(){
-  eBroadcastBitProgress = (1 << 0),
-  eBroadcastBitWarning = (1 << 1),
-  eBroadcastBitError = (1 << 2),
-  eBroadcastBitProgressCategory = (1 << 3),
-  };
-
   SBDebugger();
 
   SBDebugger(const lldb::SBDebugger );
diff --git a/lldb/include/lldb/lldb-enumerations.h 
b/lldb/include/lldb/lldb-enumerations.h
index 646f7bfda98475..f3b07ea6d20395 100644
--- a/lldb/include/lldb/lldb-enumerations.h
+++ b/lldb/include/lldb/lldb-enumerations.h
@@ -1339,6 +1339,14 @@ enum AddressMaskRange {
   eAddressMaskRangeAll = eAddressMaskRangeAny,
 };
 
+/// Used by the debugger to indicate which events are being broadcasted.
+enum DebuggerBroadcastBit {
+  eBroadcastBitProgress = (1 << 0),
+  eBroadcastBitWarning = (1 << 1),
+  eBroadcastBitError = (1 << 2),
+  eBroadcastBitProgressCategory = (1 << 3),
+};
+
 } // namespace lldb
 
 #endif // LLDB_LLDB_ENUMERATIONS_H
diff --git 
a/lldb/test/API/functionalities/diagnostic_reporting/TestDiagnosticReporting.py 
b/lldb/test/API/functionalities/diagnostic_reporting/TestDiagnosticReporting.py
index 36a3be695628f5..6353e3e8cbedbd 100644
--- 
a/lldb/test/API/functionalities/diagnostic_reporting/TestDiagnosticReporting.py
+++ 
b/lldb/test/API/functionalities/diagnostic_reporting/TestDiagnosticReporting.py
@@ -15,7 +15,7 @@ def setUp(self):
 self.broadcaster = self.dbg.GetBroadcaster()
 self.listener = lldbutil.start_listening_from(
 self.broadcaster,
-lldb.SBDebugger.eBroadcastBitWarning | 
lldb.SBDebugger.eBroadcastBitError,
+lldb.eBroadcastBitWarning | lldb.eBroadcastBitError,
 )
 
 def test_dwarf_symbol_loading_diagnostic_report(self):
diff --git 
a/lldb/test/API/functionalities/progress_reporting/TestProgressReporting.py 
b/lldb/test/API/functionalities/progress_reporting/TestProgressReporting.py
index 9af53845ca1b77..98988d7624da3c 100644
--- a/lldb/test/API/functionalities/progress_reporting/TestProgressReporting.py
+++ b/lldb/test/API/functionalities/progress_reporting/TestProgressReporting.py
@@ -13,7 +13,7 @@ def setUp(self):
 TestBase.setUp(self)
 self.broadcaster = self.dbg.GetBroadcaster()
 self.listener = lldbutil.start_listening_from(
-self.broadcaster, lldb.SBDebugger.eBroadcastBitProgress
+self.broadcaster, lldb.eBroadcastBitProgress
 )
 
 def test_dwarf_symbol_loading_progress_report(self):
diff --git 
a/lldb/test/API/functionalities/progress_reporting/clang_modules/TestClangModuleBuildProgress.py
 
b/lldb/test/API/functionalities/progress_reporting/clang_modules/TestClangModuleBuildProgress.py
index 228f676aedf6ac..33c7c269c081e4 100644
--- 
a/lldb/test/API/functionalities/progress_reporting/clang_modules/TestClangModuleBuildProgress.py
+++ 
b/lldb/test/API/functionalities/progress_reporting/clang_modules/TestClangModuleBuildProgress.py
@@ -34,7 +34,7 @@ def test_clang_module_build_progress_report(self):
 # other unrelated progress events.
 broadcaster = self.dbg.GetBroadcaster()
 listener = lldbutil.start_listening_from(
-broadcaster, lldb.SBDebugger.eBroadcastBitProgress
+broadcaster, lldb.eBroadcastBitProgress
 )
 
 # Trigger module builds.
diff --git a/lldb/test/API/macosx/rosetta/TestRosetta.py 
b/lldb/test/API/macosx/rosetta/TestRosetta.py
index 

[Lldb-commits] [lldb] Revert "[lldb][sbdebugger] Move SBDebugger Broadcast bit enum into lldb-enumerations.h" (PR #88324)

2024-04-10 Thread Chelsea Cassanova via lldb-commits

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


[Lldb-commits] [lldb] Revert "[lldb][sbdebugger] Move SBDebugger Broadcast bit enum into lldb-enumerations.h" (PR #88324)

2024-04-10 Thread Chelsea Cassanova via lldb-commits

https://github.com/chelcassanova created 
https://github.com/llvm/llvm-project/pull/88324

Reverts llvm/llvm-project#87409 due a missed update to the broadcast bit 
causing a build failure on the x86_64 Debian buildbot.

>From 27a49dc1d37f3e7ffa855ed7a536a796fa2e1642 Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova 
Date: Wed, 10 Apr 2024 14:50:39 -0700
Subject: [PATCH] =?UTF-8?q?Revert=20"[lldb][sbdebugger]=20Move=20SBDebugge?=
 =?UTF-8?q?r=20Broadcast=20bit=20enum=20into=20lldb-enume=E2=80=A6"?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This reverts commit af7c196fb8d10f58a704b5a8d142feacf2f0236d.
---
 lldb/include/lldb/API/SBDebugger.h| 7 +++
 lldb/include/lldb/lldb-enumerations.h | 8 
 .../diagnostic_reporting/TestDiagnosticReporting.py   | 2 +-
 .../progress_reporting/TestProgressReporting.py   | 2 +-
 .../clang_modules/TestClangModuleBuildProgress.py | 2 +-
 lldb/test/API/macosx/rosetta/TestRosetta.py   | 2 +-
 6 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/lldb/include/lldb/API/SBDebugger.h 
b/lldb/include/lldb/API/SBDebugger.h
index cf5409a12a056a..62b2f91f5076d5 100644
--- a/lldb/include/lldb/API/SBDebugger.h
+++ b/lldb/include/lldb/API/SBDebugger.h
@@ -42,6 +42,13 @@ class LLDB_API SBInputReader {
 
 class LLDB_API SBDebugger {
 public:
+  FLAGS_ANONYMOUS_ENUM(){
+  eBroadcastBitProgress = (1 << 0),
+  eBroadcastBitWarning = (1 << 1),
+  eBroadcastBitError = (1 << 2),
+  eBroadcastBitProgressCategory = (1 << 3),
+  };
+
   SBDebugger();
 
   SBDebugger(const lldb::SBDebugger );
diff --git a/lldb/include/lldb/lldb-enumerations.h 
b/lldb/include/lldb/lldb-enumerations.h
index f3b07ea6d20395..646f7bfda98475 100644
--- a/lldb/include/lldb/lldb-enumerations.h
+++ b/lldb/include/lldb/lldb-enumerations.h
@@ -1339,14 +1339,6 @@ enum AddressMaskRange {
   eAddressMaskRangeAll = eAddressMaskRangeAny,
 };
 
-/// Used by the debugger to indicate which events are being broadcasted.
-enum DebuggerBroadcastBit {
-  eBroadcastBitProgress = (1 << 0),
-  eBroadcastBitWarning = (1 << 1),
-  eBroadcastBitError = (1 << 2),
-  eBroadcastBitProgressCategory = (1 << 3),
-};
-
 } // namespace lldb
 
 #endif // LLDB_LLDB_ENUMERATIONS_H
diff --git 
a/lldb/test/API/functionalities/diagnostic_reporting/TestDiagnosticReporting.py 
b/lldb/test/API/functionalities/diagnostic_reporting/TestDiagnosticReporting.py
index 6353e3e8cbedbd..36a3be695628f5 100644
--- 
a/lldb/test/API/functionalities/diagnostic_reporting/TestDiagnosticReporting.py
+++ 
b/lldb/test/API/functionalities/diagnostic_reporting/TestDiagnosticReporting.py
@@ -15,7 +15,7 @@ def setUp(self):
 self.broadcaster = self.dbg.GetBroadcaster()
 self.listener = lldbutil.start_listening_from(
 self.broadcaster,
-lldb.eBroadcastBitWarning | lldb.eBroadcastBitError,
+lldb.SBDebugger.eBroadcastBitWarning | 
lldb.SBDebugger.eBroadcastBitError,
 )
 
 def test_dwarf_symbol_loading_diagnostic_report(self):
diff --git 
a/lldb/test/API/functionalities/progress_reporting/TestProgressReporting.py 
b/lldb/test/API/functionalities/progress_reporting/TestProgressReporting.py
index 98988d7624da3c..9af53845ca1b77 100644
--- a/lldb/test/API/functionalities/progress_reporting/TestProgressReporting.py
+++ b/lldb/test/API/functionalities/progress_reporting/TestProgressReporting.py
@@ -13,7 +13,7 @@ def setUp(self):
 TestBase.setUp(self)
 self.broadcaster = self.dbg.GetBroadcaster()
 self.listener = lldbutil.start_listening_from(
-self.broadcaster, lldb.eBroadcastBitProgress
+self.broadcaster, lldb.SBDebugger.eBroadcastBitProgress
 )
 
 def test_dwarf_symbol_loading_progress_report(self):
diff --git 
a/lldb/test/API/functionalities/progress_reporting/clang_modules/TestClangModuleBuildProgress.py
 
b/lldb/test/API/functionalities/progress_reporting/clang_modules/TestClangModuleBuildProgress.py
index 33c7c269c081e4..228f676aedf6ac 100644
--- 
a/lldb/test/API/functionalities/progress_reporting/clang_modules/TestClangModuleBuildProgress.py
+++ 
b/lldb/test/API/functionalities/progress_reporting/clang_modules/TestClangModuleBuildProgress.py
@@ -34,7 +34,7 @@ def test_clang_module_build_progress_report(self):
 # other unrelated progress events.
 broadcaster = self.dbg.GetBroadcaster()
 listener = lldbutil.start_listening_from(
-broadcaster, lldb.eBroadcastBitProgress
+broadcaster, lldb.SBDebugger.eBroadcastBitProgress
 )
 
 # Trigger module builds.
diff --git a/lldb/test/API/macosx/rosetta/TestRosetta.py 
b/lldb/test/API/macosx/rosetta/TestRosetta.py
index 669db95a1624c6..ce40de475ef16c 100644
--- a/lldb/test/API/macosx/rosetta/TestRosetta.py
+++ b/lldb/test/API/macosx/rosetta/TestRosetta.py
@@ -49,7 +49,7 @@ def test_rosetta(self):
 if 

[Lldb-commits] [lldb] [lldb][sbdebugger] Move SBDebugger Broadcast bit enum into lldb-enumerations.h (PR #87409)

2024-04-10 Thread Chelsea Cassanova via lldb-commits

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


[Lldb-commits] [lldb] [lldb][sbdebugger] Move SBDebugger Broadcast bit enum into lldb-enumerations.h (PR #87409)

2024-04-10 Thread Chelsea Cassanova via lldb-commits

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


[Lldb-commits] [lldb] [lldb][sbdebugger] Move SBDebugger Broadcast bit enum into lldb-enumerations.h (PR #87409)

2024-04-10 Thread Chelsea Cassanova via lldb-commits

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


[Lldb-commits] [lldb] [lldb][sbdebugger] Match progress category enum bit in Debugger.h (PR #87409)

2024-04-10 Thread Chelsea Cassanova via lldb-commits

https://github.com/chelcassanova updated 
https://github.com/llvm/llvm-project/pull/87409

>From 7561d03d775822f789a61a5b827dfa04b29b57b2 Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova 
Date: Tue, 2 Apr 2024 13:22:15 -0700
Subject: [PATCH 1/3] [lldb][sbdebugger] Match progress category enum bit in
 Debugger.h

When the `eBroadcastBitProgressCategory` bit was originally added to
Debugger.h and SBDebugger.h, each corresponding bit was added in order
of the other bits that were previously there. Since `Debugger.h` has an
enum bit that `SBDebugger.h` does not, this meant that their offsets did
not match. This commit changes it so that the bit offsets match each other.
---
 lldb/include/lldb/API/SBDebugger.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lldb/include/lldb/API/SBDebugger.h 
b/lldb/include/lldb/API/SBDebugger.h
index 62b2f91f5076d5..a994874dde6d4a 100644
--- a/lldb/include/lldb/API/SBDebugger.h
+++ b/lldb/include/lldb/API/SBDebugger.h
@@ -42,11 +42,13 @@ class LLDB_API SBInputReader {
 
 class LLDB_API SBDebugger {
 public:
+  // The enum values here need to match their corresponding values in
+  // Debugger.h.
   FLAGS_ANONYMOUS_ENUM(){
   eBroadcastBitProgress = (1 << 0),
   eBroadcastBitWarning = (1 << 1),
   eBroadcastBitError = (1 << 2),
-  eBroadcastBitProgressCategory = (1 << 3),
+  eBroadcastBitProgressCategory = (1 << 4),
   };
 
   SBDebugger();

>From a37c65dea5794e474e554f4b1762f0f630965afe Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova 
Date: Mon, 8 Apr 2024 16:39:41 -0700
Subject: [PATCH 2/3] Add SBDebugger broadcast bits to lldb-enumerations

Per Alex's suggestions, adds the broadcast bits from SBDebugger
into lldb-enumerations.
---
 lldb/include/lldb/lldb-enumerations.h | 8 
 1 file changed, 8 insertions(+)

diff --git a/lldb/include/lldb/lldb-enumerations.h 
b/lldb/include/lldb/lldb-enumerations.h
index 646f7bfda98475..17f4125c50cced 100644
--- a/lldb/include/lldb/lldb-enumerations.h
+++ b/lldb/include/lldb/lldb-enumerations.h
@@ -1339,6 +1339,14 @@ enum AddressMaskRange {
   eAddressMaskRangeAll = eAddressMaskRangeAny,
 };
 
+/// Used by the debugger to indicate which events are being broadcasted.
+enum DebuggerBroadcast {
+  eBroadcastBitProgress = (1 << 0),
+  eBroadcastBitWarning = (1 << 1),
+  eBroadcastBitError = (1 << 2),
+  eBroadcastBitProgressCategory = (1 << 4),
+};
+
 } // namespace lldb
 
 #endif // LLDB_LLDB_ENUMERATIONS_H

>From 39b05ffc015476e854b301a84f1bdd3c46257448 Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova 
Date: Wed, 10 Apr 2024 10:22:55 -0700
Subject: [PATCH 3/3] Remove broadcast enum from SBDebugger

Removes the enum for broadcast bits from SBDebugger as they're now in
lldb-enumerations.h. This also requires uses of these bits to be updated
in some API tests.
---
 lldb/include/lldb/API/SBDebugger.h   | 9 -
 lldb/include/lldb/lldb-enumerations.h| 4 ++--
 .../diagnostic_reporting/TestDiagnosticReporting.py  | 2 +-
 .../progress_reporting/TestProgressReporting.py  | 2 +-
 .../clang_modules/TestClangModuleBuildProgress.py| 2 +-
 lldb/test/API/macosx/rosetta/TestRosetta.py  | 2 +-
 6 files changed, 6 insertions(+), 15 deletions(-)

diff --git a/lldb/include/lldb/API/SBDebugger.h 
b/lldb/include/lldb/API/SBDebugger.h
index a994874dde6d4a..cf5409a12a056a 100644
--- a/lldb/include/lldb/API/SBDebugger.h
+++ b/lldb/include/lldb/API/SBDebugger.h
@@ -42,15 +42,6 @@ class LLDB_API SBInputReader {
 
 class LLDB_API SBDebugger {
 public:
-  // The enum values here need to match their corresponding values in
-  // Debugger.h.
-  FLAGS_ANONYMOUS_ENUM(){
-  eBroadcastBitProgress = (1 << 0),
-  eBroadcastBitWarning = (1 << 1),
-  eBroadcastBitError = (1 << 2),
-  eBroadcastBitProgressCategory = (1 << 4),
-  };
-
   SBDebugger();
 
   SBDebugger(const lldb::SBDebugger );
diff --git a/lldb/include/lldb/lldb-enumerations.h 
b/lldb/include/lldb/lldb-enumerations.h
index 17f4125c50cced..f3b07ea6d20395 100644
--- a/lldb/include/lldb/lldb-enumerations.h
+++ b/lldb/include/lldb/lldb-enumerations.h
@@ -1340,11 +1340,11 @@ enum AddressMaskRange {
 };
 
 /// Used by the debugger to indicate which events are being broadcasted.
-enum DebuggerBroadcast {
+enum DebuggerBroadcastBit {
   eBroadcastBitProgress = (1 << 0),
   eBroadcastBitWarning = (1 << 1),
   eBroadcastBitError = (1 << 2),
-  eBroadcastBitProgressCategory = (1 << 4),
+  eBroadcastBitProgressCategory = (1 << 3),
 };
 
 } // namespace lldb
diff --git 
a/lldb/test/API/functionalities/diagnostic_reporting/TestDiagnosticReporting.py 
b/lldb/test/API/functionalities/diagnostic_reporting/TestDiagnosticReporting.py
index 36a3be695628f5..6353e3e8cbedbd 100644
--- 
a/lldb/test/API/functionalities/diagnostic_reporting/TestDiagnosticReporting.py
+++ 
b/lldb/test/API/functionalities/diagnostic_reporting/TestDiagnosticReporting.py
@@ -15,7 +15,7 @@ def setUp(self):
 

[Lldb-commits] [lldb] [lldb][sbdebugger] Match progress category enum bit in Debugger.h (PR #87409)

2024-04-10 Thread Chelsea Cassanova via lldb-commits


@@ -1339,6 +1339,14 @@ enum AddressMaskRange {
   eAddressMaskRangeAll = eAddressMaskRangeAny,
 };
 
+/// Used by the debugger to indicate which events are being broadcasted.
+enum DebuggerBroadcastBit {
+  eBroadcastBitProgress = (1 << 0),
+  eBroadcastBitWarning = (1 << 1),
+  eBroadcastBitError = (1 << 2),
+  eBroadcastBitProgressCategory = (1 << 4),

chelcassanova wrote:

Oh yeah, I guess since this is in `lldb-enumerations` it doesn't have to match 
the ones in Debugger.h anymore.

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


[Lldb-commits] [lldb] [lldb][sbdebugger] Match progress category enum bit in Debugger.h (PR #87409)

2024-04-10 Thread Chelsea Cassanova via lldb-commits

https://github.com/chelcassanova updated 
https://github.com/llvm/llvm-project/pull/87409

>From 7561d03d775822f789a61a5b827dfa04b29b57b2 Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova 
Date: Tue, 2 Apr 2024 13:22:15 -0700
Subject: [PATCH 1/3] [lldb][sbdebugger] Match progress category enum bit in
 Debugger.h

When the `eBroadcastBitProgressCategory` bit was originally added to
Debugger.h and SBDebugger.h, each corresponding bit was added in order
of the other bits that were previously there. Since `Debugger.h` has an
enum bit that `SBDebugger.h` does not, this meant that their offsets did
not match. This commit changes it so that the bit offsets match each other.
---
 lldb/include/lldb/API/SBDebugger.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lldb/include/lldb/API/SBDebugger.h 
b/lldb/include/lldb/API/SBDebugger.h
index 62b2f91f5076d5..a994874dde6d4a 100644
--- a/lldb/include/lldb/API/SBDebugger.h
+++ b/lldb/include/lldb/API/SBDebugger.h
@@ -42,11 +42,13 @@ class LLDB_API SBInputReader {
 
 class LLDB_API SBDebugger {
 public:
+  // The enum values here need to match their corresponding values in
+  // Debugger.h.
   FLAGS_ANONYMOUS_ENUM(){
   eBroadcastBitProgress = (1 << 0),
   eBroadcastBitWarning = (1 << 1),
   eBroadcastBitError = (1 << 2),
-  eBroadcastBitProgressCategory = (1 << 3),
+  eBroadcastBitProgressCategory = (1 << 4),
   };
 
   SBDebugger();

>From a37c65dea5794e474e554f4b1762f0f630965afe Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova 
Date: Mon, 8 Apr 2024 16:39:41 -0700
Subject: [PATCH 2/3] Add SBDebugger broadcast bits to lldb-enumerations

Per Alex's suggestions, adds the broadcast bits from SBDebugger
into lldb-enumerations.
---
 lldb/include/lldb/lldb-enumerations.h | 8 
 1 file changed, 8 insertions(+)

diff --git a/lldb/include/lldb/lldb-enumerations.h 
b/lldb/include/lldb/lldb-enumerations.h
index 646f7bfda98475..17f4125c50cced 100644
--- a/lldb/include/lldb/lldb-enumerations.h
+++ b/lldb/include/lldb/lldb-enumerations.h
@@ -1339,6 +1339,14 @@ enum AddressMaskRange {
   eAddressMaskRangeAll = eAddressMaskRangeAny,
 };
 
+/// Used by the debugger to indicate which events are being broadcasted.
+enum DebuggerBroadcast {
+  eBroadcastBitProgress = (1 << 0),
+  eBroadcastBitWarning = (1 << 1),
+  eBroadcastBitError = (1 << 2),
+  eBroadcastBitProgressCategory = (1 << 4),
+};
+
 } // namespace lldb
 
 #endif // LLDB_LLDB_ENUMERATIONS_H

>From 3dc9c9fe56be78ece6f3702719d9f61a1a7bf965 Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova 
Date: Wed, 10 Apr 2024 10:22:55 -0700
Subject: [PATCH 3/3] Remove broadcast enum from SBDebugger

Removes the enum for broadcast bits from SBDebugger as they're now in
lldb-enumerations.h. This also requires uses of these bits to be updated
in some API tests.
---
 lldb/include/lldb/API/SBDebugger.h   | 9 -
 lldb/include/lldb/lldb-enumerations.h| 2 +-
 .../diagnostic_reporting/TestDiagnosticReporting.py  | 2 +-
 .../progress_reporting/TestProgressReporting.py  | 2 +-
 .../clang_modules/TestClangModuleBuildProgress.py| 2 +-
 lldb/test/API/macosx/rosetta/TestRosetta.py  | 2 +-
 6 files changed, 5 insertions(+), 14 deletions(-)

diff --git a/lldb/include/lldb/API/SBDebugger.h 
b/lldb/include/lldb/API/SBDebugger.h
index a994874dde6d4a..cf5409a12a056a 100644
--- a/lldb/include/lldb/API/SBDebugger.h
+++ b/lldb/include/lldb/API/SBDebugger.h
@@ -42,15 +42,6 @@ class LLDB_API SBInputReader {
 
 class LLDB_API SBDebugger {
 public:
-  // The enum values here need to match their corresponding values in
-  // Debugger.h.
-  FLAGS_ANONYMOUS_ENUM(){
-  eBroadcastBitProgress = (1 << 0),
-  eBroadcastBitWarning = (1 << 1),
-  eBroadcastBitError = (1 << 2),
-  eBroadcastBitProgressCategory = (1 << 4),
-  };
-
   SBDebugger();
 
   SBDebugger(const lldb::SBDebugger );
diff --git a/lldb/include/lldb/lldb-enumerations.h 
b/lldb/include/lldb/lldb-enumerations.h
index 17f4125c50cced..fb262503272e80 100644
--- a/lldb/include/lldb/lldb-enumerations.h
+++ b/lldb/include/lldb/lldb-enumerations.h
@@ -1340,7 +1340,7 @@ enum AddressMaskRange {
 };
 
 /// Used by the debugger to indicate which events are being broadcasted.
-enum DebuggerBroadcast {
+enum DebuggerBroadcastBit {
   eBroadcastBitProgress = (1 << 0),
   eBroadcastBitWarning = (1 << 1),
   eBroadcastBitError = (1 << 2),
diff --git 
a/lldb/test/API/functionalities/diagnostic_reporting/TestDiagnosticReporting.py 
b/lldb/test/API/functionalities/diagnostic_reporting/TestDiagnosticReporting.py
index 36a3be695628f5..6353e3e8cbedbd 100644
--- 
a/lldb/test/API/functionalities/diagnostic_reporting/TestDiagnosticReporting.py
+++ 
b/lldb/test/API/functionalities/diagnostic_reporting/TestDiagnosticReporting.py
@@ -15,7 +15,7 @@ def setUp(self):
 self.broadcaster = self.dbg.GetBroadcaster()
 self.listener = lldbutil.start_listening_from(
 

[Lldb-commits] [lldb] [lldb][sbdebugger] Match progress category enum bit in Debugger.h (PR #87409)

2024-04-10 Thread Chelsea Cassanova via lldb-commits


@@ -42,11 +42,13 @@ class LLDB_API SBInputReader {
 
 class LLDB_API SBDebugger {
 public:
+  // The enum values here need to match their corresponding values in
+  // Debugger.h.
   FLAGS_ANONYMOUS_ENUM(){
   eBroadcastBitProgress = (1 << 0),
   eBroadcastBitWarning = (1 << 1),
   eBroadcastBitError = (1 << 2),
-  eBroadcastBitProgressCategory = (1 << 3),
+  eBroadcastBitProgressCategory = (1 << 4),

chelcassanova wrote:

Yup, will remove.

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


[Lldb-commits] [lldb] [lldb][sbdebugger] Match progress category enum bit in Debugger.h (PR #87409)

2024-04-08 Thread Chelsea Cassanova via lldb-commits

https://github.com/chelcassanova updated 
https://github.com/llvm/llvm-project/pull/87409

>From 7561d03d775822f789a61a5b827dfa04b29b57b2 Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova 
Date: Tue, 2 Apr 2024 13:22:15 -0700
Subject: [PATCH 1/2] [lldb][sbdebugger] Match progress category enum bit in
 Debugger.h

When the `eBroadcastBitProgressCategory` bit was originally added to
Debugger.h and SBDebugger.h, each corresponding bit was added in order
of the other bits that were previously there. Since `Debugger.h` has an
enum bit that `SBDebugger.h` does not, this meant that their offsets did
not match. This commit changes it so that the bit offsets match each other.
---
 lldb/include/lldb/API/SBDebugger.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lldb/include/lldb/API/SBDebugger.h 
b/lldb/include/lldb/API/SBDebugger.h
index 62b2f91f5076d5..a994874dde6d4a 100644
--- a/lldb/include/lldb/API/SBDebugger.h
+++ b/lldb/include/lldb/API/SBDebugger.h
@@ -42,11 +42,13 @@ class LLDB_API SBInputReader {
 
 class LLDB_API SBDebugger {
 public:
+  // The enum values here need to match their corresponding values in
+  // Debugger.h.
   FLAGS_ANONYMOUS_ENUM(){
   eBroadcastBitProgress = (1 << 0),
   eBroadcastBitWarning = (1 << 1),
   eBroadcastBitError = (1 << 2),
-  eBroadcastBitProgressCategory = (1 << 3),
+  eBroadcastBitProgressCategory = (1 << 4),
   };
 
   SBDebugger();

>From a37c65dea5794e474e554f4b1762f0f630965afe Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova 
Date: Mon, 8 Apr 2024 16:39:41 -0700
Subject: [PATCH 2/2] Add SBDebugger broadcast bits to lldb-enumerations

Per Alex's suggestions, adds the broadcast bits from SBDebugger
into lldb-enumerations.
---
 lldb/include/lldb/lldb-enumerations.h | 8 
 1 file changed, 8 insertions(+)

diff --git a/lldb/include/lldb/lldb-enumerations.h 
b/lldb/include/lldb/lldb-enumerations.h
index 646f7bfda98475..17f4125c50cced 100644
--- a/lldb/include/lldb/lldb-enumerations.h
+++ b/lldb/include/lldb/lldb-enumerations.h
@@ -1339,6 +1339,14 @@ enum AddressMaskRange {
   eAddressMaskRangeAll = eAddressMaskRangeAny,
 };
 
+/// Used by the debugger to indicate which events are being broadcasted.
+enum DebuggerBroadcast {
+  eBroadcastBitProgress = (1 << 0),
+  eBroadcastBitWarning = (1 << 1),
+  eBroadcastBitError = (1 << 2),
+  eBroadcastBitProgressCategory = (1 << 4),
+};
+
 } // namespace lldb
 
 #endif // LLDB_LLDB_ENUMERATIONS_H

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


[Lldb-commits] [lldb] Make the correct (5 argument) form of the command definition be the primary one suggested in the docs (PR #86593)

2024-03-25 Thread Chelsea Cassanova via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb][progress][NFC] Clarify Doxygen comments for `details` field (PR #86002)

2024-03-21 Thread Chelsea Cassanova via lldb-commits

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


[Lldb-commits] [lldb] [lldb][progress][NFC] Clarify Doxygen comments for `details` field (PR #86002)

2024-03-20 Thread Chelsea Cassanova via lldb-commits

https://github.com/chelcassanova created 
https://github.com/llvm/llvm-project/pull/86002

The Doxygen comments for the `details` field of a progress report currently 
does not specify that this field will act as the initial set of details for a 
progress report that gets updated with `Progress::Increment()`. This commit 
clarifies this.

>From f651cc7367d30a0718a37cdbd55e9f2718febb68 Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova 
Date: Wed, 20 Mar 2024 13:17:42 -0700
Subject: [PATCH] [lldb][progress][NFC] Clarify Doxygen comments for `details`
 field

The Doxygen comments for the `details` field of a progress report
currently does not specify that this field will act as the initial set
of details for a progress report that gets updated with
`Progress::Increment()`. This commit clarifies this.
---
 lldb/include/lldb/Core/Progress.h | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/lldb/include/lldb/Core/Progress.h 
b/lldb/include/lldb/Core/Progress.h
index c38f6dd0a140ed..eb3af9816dc6ca 100644
--- a/lldb/include/lldb/Core/Progress.h
+++ b/lldb/include/lldb/Core/Progress.h
@@ -66,7 +66,11 @@ class Progress {
   /// @param [in] title The title of this progress activity.
   ///
   /// @param [in] details Specific information about what the progress report
-  /// is currently working on.
+  /// is currently working on. Although not required, if the progress report is
+  /// updated with Progress::Increment() then this field will be overwritten
+  /// with the new set of details passed into that function, and the details
+  /// passed initially will act as an "item 0" for the total set of
+  /// items being reported on.
   ///
   /// @param [in] total The total units of work to be done if specified, if
   /// set to std::nullopt then an indeterminate progress indicator should be

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


[Lldb-commits] [lldb] [lldb] Show module name in progress update for downloading symbols (PR #85342)

2024-03-14 Thread Chelsea Cassanova via lldb-commits

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

LGTM!

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


[Lldb-commits] [lldb] [lldb] Implement coalescing of disjoint progress events (PR #84854)

2024-03-14 Thread Chelsea Cassanova via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb] Implement coalescing of disjoint progress events (PR #84854)

2024-03-11 Thread Chelsea Cassanova via lldb-commits


@@ -0,0 +1,164 @@
+//===-- AlarmTest.cpp 
-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "lldb/Host/Alarm.h"
+#include "gtest/gtest.h"
+
+#include 
+#include 
+
+using namespace lldb_private;
+using namespace std::chrono_literals;
+
+static constexpr auto ALARM_TIMEOUT = 500ms;
+static constexpr auto TEST_TIMEOUT = 1000ms;
+static constexpr bool RUN_CALLBACKS_ON_EXIT = true;
+
+// Enable strict checking of the ALARM_TIMEOUTs. This should only be enabled 
for
+// development and never during automated testing where scheduling and
+// ALARM_TIMEOUTs are unpredictable.
+#define STRICT_ALARM_TIMEOUT 1
+
+#if STRICT_ALARM_TIMEOUT
+static constexpr auto EPSILON = 10ms;
+#endif
+
+TEST(AlarmTest, Create) {
+  std::mutex m;
+
+  std::vector callbacks_actual;
+  std::vector callbacks_expected;
+
+  Alarm alarm(ALARM_TIMEOUT, RUN_CALLBACKS_ON_EXIT);
+
+  // Create 5 alarms some time apart.
+  for (size_t i = 0; i < 5; ++i) {
+callbacks_actual.emplace_back();
+callbacks_expected.emplace_back(std::chrono::system_clock::now() +
+ALARM_TIMEOUT);
+
+alarm.Create([_actual, , i]() {
+  std::lock_guard guard(m);
+  callbacks_actual[i] = std::chrono::system_clock::now();
+});
+
+std::this_thread::sleep_for(ALARM_TIMEOUT / 5);
+  }
+
+  // Leave plenty of time for all the alarms to fire.
+  std::this_thread::sleep_for(TEST_TIMEOUT);
+
+  // Make sure all the alarms around the expected time.
+  for (size_t i = 0; i < 5; ++i) {
+EXPECT_GE(callbacks_actual[i], callbacks_expected[i]);
+#if STRICT_ALARM_TIMEOUT
+EXPECT_LE(callbacks_actual[i], callbacks_expected[i] + EPSILON);
+#endif
+  }
+}
+
+TEST(AlarmTest, Exit) {
+  std::mutex m;
+
+  std::vector handles;
+  std::vector callbacks;
+
+  {
+Alarm alarm(ALARM_TIMEOUT, RUN_CALLBACKS_ON_EXIT);
+
+// Create 5 alarms.
+for (size_t i = 0; i < 5; ++i) {
+  callbacks.emplace_back(false);
+
+  handles.push_back(alarm.Create([, , i]() {
+std::lock_guard guard(m);
+callbacks[i] = true;
+  }));
+}
+
+// Let the alarm go out of scope before any alarm had a chance to fire.
+  }
+
+  // Make sure none of the first 4 alarms fired.
+  for (bool callback : callbacks)
+EXPECT_TRUE(callback);

chelcassanova wrote:

Just wondering, why do we check that the first 4 alarms didn't fire but not the 
final one here?

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


[Lldb-commits] [lldb] [lldb] Implement coalescing of disjoint progress events (PR #84854)

2024-03-11 Thread Chelsea Cassanova via lldb-commits


@@ -0,0 +1,164 @@
+//===-- AlarmTest.cpp 
-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "lldb/Host/Alarm.h"
+#include "gtest/gtest.h"
+
+#include 
+#include 
+
+using namespace lldb_private;
+using namespace std::chrono_literals;
+
+static constexpr auto ALARM_TIMEOUT = 500ms;
+static constexpr auto TEST_TIMEOUT = 1000ms;
+static constexpr bool RUN_CALLBACKS_ON_EXIT = true;
+
+// Enable strict checking of the ALARM_TIMEOUTs. This should only be enabled 
for
+// development and never during automated testing where scheduling and
+// ALARM_TIMEOUTs are unpredictable.
+#define STRICT_ALARM_TIMEOUT 1
+
+#if STRICT_ALARM_TIMEOUT
+static constexpr auto EPSILON = 10ms;
+#endif
+
+TEST(AlarmTest, Create) {
+  std::mutex m;
+
+  std::vector callbacks_actual;
+  std::vector callbacks_expected;
+
+  Alarm alarm(ALARM_TIMEOUT, RUN_CALLBACKS_ON_EXIT);
+
+  // Create 5 alarms some time apart.
+  for (size_t i = 0; i < 5; ++i) {
+callbacks_actual.emplace_back();
+callbacks_expected.emplace_back(std::chrono::system_clock::now() +
+ALARM_TIMEOUT);
+
+alarm.Create([_actual, , i]() {
+  std::lock_guard guard(m);
+  callbacks_actual[i] = std::chrono::system_clock::now();
+});
+
+std::this_thread::sleep_for(ALARM_TIMEOUT / 5);
+  }
+
+  // Leave plenty of time for all the alarms to fire.
+  std::this_thread::sleep_for(TEST_TIMEOUT);
+
+  // Make sure all the alarms around the expected time.

chelcassanova wrote:

nit: Missing word or am I just reading this wrong?

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


[Lldb-commits] [lldb] [lldb] Implement coalescing of disjoint progress events (PR #84854)

2024-03-11 Thread Chelsea Cassanova via lldb-commits


@@ -210,3 +211,37 @@ TEST_F(ProgressReportTest, TestOverlappingEvents) {
   // initial report.
   EXPECT_EQ(data->GetID(), expected_progress_id);
 }
+
+TEST_F(ProgressReportTest, TestProgressManagerDisjointReports) {
+  ListenerSP listener_sp =
+  CreateListenerFor(Debugger::eBroadcastBitProgressCategory);
+  EventSP event_sp;
+  const ProgressEventData *data;
+  uint64_t expected_progress_id;
+
+  { Progress progress("Coalesced report 1", "Starting report 1"); }
+  { Progress progress("Coalesced report 1", "Starting report 2"); }
+  { Progress progress("Coalesced report 1", "Starting report 3"); }
+
+  ASSERT_TRUE(listener_sp->GetEvent(event_sp, TIMEOUT));
+  data = ProgressEventData::GetEventDataFromEvent(event_sp.get());
+  expected_progress_id = data->GetID();
+
+  EXPECT_EQ(data->GetDetails(), "");
+  EXPECT_FALSE(data->IsFinite());
+  EXPECT_FALSE(data->GetCompleted());
+  EXPECT_EQ(data->GetTotal(), Progress::kNonDeterministicTotal);
+  EXPECT_EQ(data->GetMessage(), "Coalesced report 1");
+
+  ASSERT_TRUE(listener_sp->GetEvent(event_sp, TIMEOUT));
+  data = ProgressEventData::GetEventDataFromEvent(event_sp.get());
+
+  EXPECT_EQ(data->GetID(), expected_progress_id);
+  EXPECT_EQ(data->GetDetails(), "");
+  EXPECT_FALSE(data->IsFinite());
+  EXPECT_TRUE(data->GetCompleted());
+  EXPECT_EQ(data->GetTotal(), Progress::kNonDeterministicTotal);
+  EXPECT_EQ(data->GetMessage(), "Coalesced report 1");
+
+  ASSERT_FALSE(listener_sp->GetEvent(event_sp, TIMEOUT));

chelcassanova wrote:

Good point to try popping another event from the stack and expect that to not 
work, this was something I was going to add to the original progress manager 
test but I thought would be overkill  .

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


[Lldb-commits] [lldb] [lldb] Implement coalescing of disjoint progress events (PR #84854)

2024-03-11 Thread Chelsea Cassanova via lldb-commits


@@ -0,0 +1,88 @@
+//===-- Alarm.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_HOST_ALARM_H
+#define LLDB_HOST_ALARM_H
+
+#include "lldb/Host/HostThread.h"
+#include "lldb/lldb-types.h"
+#include "llvm/Support/Chrono.h"
+
+namespace lldb_private {
+
+class Alarm {
+public:
+  using Handle = uint64_t;
+  using Callback = std::function;
+  using TimePoint = llvm::sys::TimePoint<>;
+  using Duration = std::chrono::milliseconds;
+
+  Alarm(Duration timeout, bool run_callback_on_exit = false);
+  ~Alarm();
+
+  Handle Create(Callback callback);
+  bool Restart(Handle handle);
+  bool Cancel(Handle handle);
+
+  static constexpr Handle INVALID_HANDLE = 0;
+
+private:
+  /// Helper functions to start, stop and check the status of the alarm thread.
+  /// @{
+  void StartAlarmThread();
+  void StopAlarmThread();
+  bool AlarmThreadRunning();
+  /// @}
+
+  /// Return an unique, monotonically increasing handle.
+  static Handle GetNextUniqueHandle();
+
+  TimePoint GetNextExpiration() const;
+
+  /// Alarm entry.
+  struct Entry {
+Handle handle;
+Callback callback;
+TimePoint expiration;
+
+Entry(Callback callback, TimePoint expiration);
+bool operator==(const Entry ) { return handle == rhs.handle; }
+  };
+
+  /// List of alarm entries.
+  std::vector m_entries;
+
+  /// Timeout between when an alarm is created and when it fires.
+  Duration m_timeout;
+
+  /// The alarm thread.
+  /// @{
+  HostThread m_alarm_thread;
+  lldb::thread_result_t AlarmThread();
+  /// @}
+
+  /// Synchronize access between the alarm thread and the main thread.
+  std::mutex m_alarm_mutex;
+
+  /// Condition variable used to wake up the alarm thread.
+  std::condition_variable m_alarm_cv;
+
+  /// Flag to signal the alarm thread that something changed and we need to
+  // recompute the next alarm.

chelcassanova wrote:

nit: missing third slash for doxygen?

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


[Lldb-commits] [lldb] [lldb] Do some gardening in ProgressReportTest (NFC) (PR #84278)

2024-03-07 Thread Chelsea Cassanova via lldb-commits

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

LGTM!

https://github.com/llvm/llvm-project/pull/84278
___
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 report all progress event as completed. (PR #84281)

2024-03-07 Thread Chelsea Cassanova via lldb-commits

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

LGTM!

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


[Lldb-commits] [lldb] [lldb][progress] Hook up new broadcast bit and progress manager (PR #83069)

2024-03-01 Thread Chelsea Cassanova via lldb-commits

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


[Lldb-commits] [lldb] [lldb][progress][NFC] Fix Doxygen information (PR #83502)

2024-02-29 Thread Chelsea Cassanova via lldb-commits

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


[Lldb-commits] [lldb] [lldb][progress][NFC] Fix Doxygen information (PR #83502)

2024-02-29 Thread Chelsea Cassanova via lldb-commits

https://github.com/chelcassanova created 
https://github.com/llvm/llvm-project/pull/83502

The `details` field in the constructor for `Progress` is missing Doxygen 
documentation, this commit adds this.

>From 7b26213416e45853514e98d5043255ccd42153a9 Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova 
Date: Thu, 29 Feb 2024 15:15:27 -0800
Subject: [PATCH] [lldb][progress][NFC] Fix Doxygen information

The `details` field in the constructor for `Progress` is missing Doxygen
documentation, this commit adds this.
---
 lldb/include/lldb/Core/Progress.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lldb/include/lldb/Core/Progress.h 
b/lldb/include/lldb/Core/Progress.h
index eb4d9f9d7af08e..9549e3b5aea950 100644
--- a/lldb/include/lldb/Core/Progress.h
+++ b/lldb/include/lldb/Core/Progress.h
@@ -64,6 +64,9 @@ class Progress {
   ///
   /// @param [in] title The title of this progress activity.
   ///
+  /// @param [in] details Specific information about what the progress report
+  /// is currently working on.
+  ///
   /// @param [in] total The total units of work to be done if specified, if
   /// set to std::nullopt then an indeterminate progress indicator should be
   /// displayed.

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


[Lldb-commits] [lldb] [lldb][progress] Hook up new broadcast bit and progress manager (PR #83069)

2024-02-29 Thread Chelsea Cassanova via lldb-commits

https://github.com/chelcassanova updated 
https://github.com/llvm/llvm-project/pull/83069

>From 5fcab5d9b7af70861bbc46f096032dce7de41517 Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova 
Date: Tue, 20 Feb 2024 13:56:53 -0800
Subject: [PATCH] [lldb][progress] Hook up new broadcast bit and progress
 manager

This commit adds the functionality to broadcast events using the
`Debugger::eBroadcastProgressCategory`
bit (https://github.com/llvm/llvm-project/pull/81169) by keeping track of these
reports with the `ProgressManager`
class (https://github.com/llvm/llvm-project/pull/81319). The new bit is
used in such a way that it will only broadcast the initial and final
progress reports for specific progress categories that are managed by
the progress manager.

This commit also adds a new test to the progress report unit test that
checks that only the initial/final reports are broadcasted when using
the new bit.
---
 lldb/include/lldb/Core/Debugger.h  | 10 ++-
 lldb/include/lldb/Core/Progress.h  | 37 ++---
 lldb/source/Core/Debugger.cpp  | 19 +++--
 lldb/source/Core/Progress.cpp  | 56 +
 lldb/unittests/Core/ProgressReportTest.cpp | 93 +-
 5 files changed, 177 insertions(+), 38 deletions(-)

diff --git a/lldb/include/lldb/Core/Debugger.h 
b/lldb/include/lldb/Core/Debugger.h
index 6ba90eb6ed8fdf..b65ec1029ab24b 100644
--- a/lldb/include/lldb/Core/Debugger.h
+++ b/lldb/include/lldb/Core/Debugger.h
@@ -593,6 +593,7 @@ class Debugger : public 
std::enable_shared_from_this,
   friend class CommandInterpreter;
   friend class REPL;
   friend class Progress;
+  friend class ProgressManager;
 
   /// Report progress events.
   ///
@@ -623,10 +624,11 @@ class Debugger : public 
std::enable_shared_from_this,
   ///   debugger identifier that this progress should be delivered to. If this
   ///   optional parameter does not have a value, the progress will be
   ///   delivered to all debuggers.
-  static void ReportProgress(uint64_t progress_id, std::string title,
- std::string details, uint64_t completed,
- uint64_t total,
- std::optional debugger_id);
+  static void
+  ReportProgress(uint64_t progress_id, std::string title, std::string details,
+ uint64_t completed, uint64_t total,
+ std::optional debugger_id,
+ uint32_t progress_category_bit = eBroadcastBitProgress);
 
   static void ReportDiagnosticImpl(DiagnosticEventData::Type type,
std::string message,
diff --git a/lldb/include/lldb/Core/Progress.h 
b/lldb/include/lldb/Core/Progress.h
index eb4d9f9d7af08e..766bda0cf1c5e5 100644
--- a/lldb/include/lldb/Core/Progress.h
+++ b/lldb/include/lldb/Core/Progress.h
@@ -9,10 +9,11 @@
 #ifndef LLDB_CORE_PROGRESS_H
 #define LLDB_CORE_PROGRESS_H
 
-#include "lldb/Utility/ConstString.h"
+#include "lldb/lldb-forward.h"
 #include "lldb/lldb-types.h"
 #include "llvm/ADT/StringMap.h"
 #include 
+#include 
 #include 
 #include 
 
@@ -97,27 +98,36 @@ class Progress {
   /// Used to indicate a non-deterministic progress report
   static constexpr uint64_t kNonDeterministicTotal = UINT64_MAX;
 
+  /// Data belonging to this Progress event that is used for bookkeeping by
+  /// ProgressManager.
+  struct ProgressData {
+/// The title of the progress activity, also used as a category.
+std::string title;
+/// A unique integer identifier for progress reporting.
+uint64_t progress_id;
+/// The optional debugger ID to report progress to. If this has no value
+/// then all debuggers will receive this event.
+std::optional debugger_id;
+  };
+
 private:
   void ReportProgress();
   static std::atomic g_id;
-  /// The title of the progress activity.
-  std::string m_title;
+  /// More specific information about the current file being displayed in the
+  /// report.
   std::string m_details;
-  std::mutex m_mutex;
-  /// A unique integer identifier for progress reporting.
-  const uint64_t m_id;
   /// How much work ([0...m_total]) that has been completed.
   uint64_t m_completed;
   /// Total amount of work, use a std::nullopt in the constructor for non
   /// deterministic progress.
   uint64_t m_total;
-  /// The optional debugger ID to report progress to. If this has no value then
-  /// all debuggers will receive this event.
-  std::optional m_debugger_id;
+  std::mutex m_mutex;
   /// Set to true when progress has been reported where m_completed == m_total
   /// to ensure that we don't send progress updates after progress has
   /// completed.
   bool m_complete = false;
+  /// Data needed by the debugger to broadcast a progress event.
+  ProgressData m_progress_data;
 };
 
 /// A class used to group progress reports by category. This is done by using a
@@ -130,13 +140,16 @@ class ProgressManager {
   ~ProgressManager();
 
   /// Control the refcount of the progress report 

[Lldb-commits] [lldb] [lldb][progress] Hook up new broadcast bit and progress manager (PR #83069)

2024-02-29 Thread Chelsea Cassanova via lldb-commits

https://github.com/chelcassanova updated 
https://github.com/llvm/llvm-project/pull/83069

>From 59e3b1da1335261badeace24d6136d924cda6949 Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova 
Date: Tue, 20 Feb 2024 13:56:53 -0800
Subject: [PATCH] [lldb][progress] Hook up new broadcast bit and progress
 manager

This commit adds the functionality to broadcast events using the
`Debugger::eBroadcastProgressCategory`
bit (https://github.com/llvm/llvm-project/pull/81169) by keeping track of these
reports with the `ProgressManager`
class (https://github.com/llvm/llvm-project/pull/81319). The new bit is
used in such a way that it will only broadcast the initial and final
progress reports for specific progress categories that are managed by
the progress manager.

This commit also adds a new test to the progress report unit test that
checks that only the initial/final reports are broadcasted when using
the new bit.
---
 lldb/include/lldb/Core/Debugger.h  | 10 ++-
 lldb/include/lldb/Core/Progress.h  | 47 +++
 lldb/source/Core/Debugger.cpp  | 19 +++--
 lldb/source/Core/Progress.cpp  | 77 +-
 lldb/unittests/Core/ProgressReportTest.cpp | 93 +-
 5 files changed, 195 insertions(+), 51 deletions(-)

diff --git a/lldb/include/lldb/Core/Debugger.h 
b/lldb/include/lldb/Core/Debugger.h
index 6ba90eb6ed8fdf..b65ec1029ab24b 100644
--- a/lldb/include/lldb/Core/Debugger.h
+++ b/lldb/include/lldb/Core/Debugger.h
@@ -593,6 +593,7 @@ class Debugger : public 
std::enable_shared_from_this,
   friend class CommandInterpreter;
   friend class REPL;
   friend class Progress;
+  friend class ProgressManager;
 
   /// Report progress events.
   ///
@@ -623,10 +624,11 @@ class Debugger : public 
std::enable_shared_from_this,
   ///   debugger identifier that this progress should be delivered to. If this
   ///   optional parameter does not have a value, the progress will be
   ///   delivered to all debuggers.
-  static void ReportProgress(uint64_t progress_id, std::string title,
- std::string details, uint64_t completed,
- uint64_t total,
- std::optional debugger_id);
+  static void
+  ReportProgress(uint64_t progress_id, std::string title, std::string details,
+ uint64_t completed, uint64_t total,
+ std::optional debugger_id,
+ uint32_t progress_category_bit = eBroadcastBitProgress);
 
   static void ReportDiagnosticImpl(DiagnosticEventData::Type type,
std::string message,
diff --git a/lldb/include/lldb/Core/Progress.h 
b/lldb/include/lldb/Core/Progress.h
index eb4d9f9d7af08e..450c0b439910f2 100644
--- a/lldb/include/lldb/Core/Progress.h
+++ b/lldb/include/lldb/Core/Progress.h
@@ -9,10 +9,11 @@
 #ifndef LLDB_CORE_PROGRESS_H
 #define LLDB_CORE_PROGRESS_H
 
-#include "lldb/Utility/ConstString.h"
+#include "lldb/lldb-forward.h"
 #include "lldb/lldb-types.h"
 #include "llvm/ADT/StringMap.h"
 #include 
+#include 
 #include 
 #include 
 
@@ -97,27 +98,36 @@ class Progress {
   /// Used to indicate a non-deterministic progress report
   static constexpr uint64_t kNonDeterministicTotal = UINT64_MAX;
 
+  /// Data belonging to this Progress event. This data is used by the Debugger
+  /// to broadcast the event and by the ProgressManager for bookkeeping.
+  struct ProgressData {
+/// The title of the progress activity, also used as a category.
+std::string title;
+/// More specific information about the current file being displayed in the
+/// report.
+std::string details;
+/// A unique integer identifier for progress reporting.
+uint64_t progress_id;
+/// How much work ([0...m_total]) that has been completed.
+uint64_t completed;
+/// Total amount of work, use a std::nullopt in the constructor for non
+/// deterministic progress.
+uint64_t total;
+/// The optional debugger ID to report progress to. If this has no value
+/// then all debuggers will receive this event.
+std::optional debugger_id;
+  };
+
 private:
   void ReportProgress();
   static std::atomic g_id;
-  /// The title of the progress activity.
-  std::string m_title;
-  std::string m_details;
   std::mutex m_mutex;
-  /// A unique integer identifier for progress reporting.
-  const uint64_t m_id;
-  /// How much work ([0...m_total]) that has been completed.
-  uint64_t m_completed;
-  /// Total amount of work, use a std::nullopt in the constructor for non
-  /// deterministic progress.
-  uint64_t m_total;
-  /// The optional debugger ID to report progress to. If this has no value then
-  /// all debuggers will receive this event.
-  std::optional m_debugger_id;
   /// Set to true when progress has been reported where m_completed == m_total
   /// to ensure that we don't send progress updates after progress has
   /// completed.
   bool m_complete = false;
+  /// Data needed by 

[Lldb-commits] [lldb] [lldb][progress] Hook up new broadcast bit and progress manager (PR #83069)

2024-02-28 Thread Chelsea Cassanova via lldb-commits

https://github.com/chelcassanova updated 
https://github.com/llvm/llvm-project/pull/83069

>From f38204941062691bf3e3f6e57d8171a5c0258f77 Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova 
Date: Tue, 20 Feb 2024 13:56:53 -0800
Subject: [PATCH] [lldb][progress] Hook up new broadcast bit and progress
 manager

This commit adds the functionality to broadcast events using the
`Debugger::eBroadcastProgressCategory`
bit (https://github.com/llvm/llvm-project/pull/81169) by keeping track of these
reports with the `ProgressManager`
class (https://github.com/llvm/llvm-project/pull/81319). The new bit is
used in such a way that it will only broadcast the initial and final
progress reports for specific progress categories that are managed by
the progress manager.

This commit also adds a new test to the progress report unit test that
checks that only the initial/final reports are broadcasted when using
the new bit.
---
 lldb/include/lldb/Core/Debugger.h  | 10 +--
 lldb/include/lldb/Core/Progress.h  | 47 +-
 lldb/source/Core/Debugger.cpp  | 19 +++---
 lldb/source/Core/Progress.cpp  | 73 +++---
 lldb/unittests/Core/ProgressReportTest.cpp | 57 +
 5 files changed, 156 insertions(+), 50 deletions(-)

diff --git a/lldb/include/lldb/Core/Debugger.h 
b/lldb/include/lldb/Core/Debugger.h
index 6ba90eb6ed8fdf..b65ec1029ab24b 100644
--- a/lldb/include/lldb/Core/Debugger.h
+++ b/lldb/include/lldb/Core/Debugger.h
@@ -593,6 +593,7 @@ class Debugger : public 
std::enable_shared_from_this,
   friend class CommandInterpreter;
   friend class REPL;
   friend class Progress;
+  friend class ProgressManager;
 
   /// Report progress events.
   ///
@@ -623,10 +624,11 @@ class Debugger : public 
std::enable_shared_from_this,
   ///   debugger identifier that this progress should be delivered to. If this
   ///   optional parameter does not have a value, the progress will be
   ///   delivered to all debuggers.
-  static void ReportProgress(uint64_t progress_id, std::string title,
- std::string details, uint64_t completed,
- uint64_t total,
- std::optional debugger_id);
+  static void
+  ReportProgress(uint64_t progress_id, std::string title, std::string details,
+ uint64_t completed, uint64_t total,
+ std::optional debugger_id,
+ uint32_t progress_category_bit = eBroadcastBitProgress);
 
   static void ReportDiagnosticImpl(DiagnosticEventData::Type type,
std::string message,
diff --git a/lldb/include/lldb/Core/Progress.h 
b/lldb/include/lldb/Core/Progress.h
index eb4d9f9d7af08e..450c0b439910f2 100644
--- a/lldb/include/lldb/Core/Progress.h
+++ b/lldb/include/lldb/Core/Progress.h
@@ -9,10 +9,11 @@
 #ifndef LLDB_CORE_PROGRESS_H
 #define LLDB_CORE_PROGRESS_H
 
-#include "lldb/Utility/ConstString.h"
+#include "lldb/lldb-forward.h"
 #include "lldb/lldb-types.h"
 #include "llvm/ADT/StringMap.h"
 #include 
+#include 
 #include 
 #include 
 
@@ -97,27 +98,36 @@ class Progress {
   /// Used to indicate a non-deterministic progress report
   static constexpr uint64_t kNonDeterministicTotal = UINT64_MAX;
 
+  /// Data belonging to this Progress event. This data is used by the Debugger
+  /// to broadcast the event and by the ProgressManager for bookkeeping.
+  struct ProgressData {
+/// The title of the progress activity, also used as a category.
+std::string title;
+/// More specific information about the current file being displayed in the
+/// report.
+std::string details;
+/// A unique integer identifier for progress reporting.
+uint64_t progress_id;
+/// How much work ([0...m_total]) that has been completed.
+uint64_t completed;
+/// Total amount of work, use a std::nullopt in the constructor for non
+/// deterministic progress.
+uint64_t total;
+/// The optional debugger ID to report progress to. If this has no value
+/// then all debuggers will receive this event.
+std::optional debugger_id;
+  };
+
 private:
   void ReportProgress();
   static std::atomic g_id;
-  /// The title of the progress activity.
-  std::string m_title;
-  std::string m_details;
   std::mutex m_mutex;
-  /// A unique integer identifier for progress reporting.
-  const uint64_t m_id;
-  /// How much work ([0...m_total]) that has been completed.
-  uint64_t m_completed;
-  /// Total amount of work, use a std::nullopt in the constructor for non
-  /// deterministic progress.
-  uint64_t m_total;
-  /// The optional debugger ID to report progress to. If this has no value then
-  /// all debuggers will receive this event.
-  std::optional m_debugger_id;
   /// Set to true when progress has been reported where m_completed == m_total
   /// to ensure that we don't send progress updates after progress has
   /// completed.
   bool m_complete = false;
+  /// Data needed 

[Lldb-commits] [lldb] [lldb][progress] Hook up new broadcast bit and progress manager (PR #83069)

2024-02-28 Thread Chelsea Cassanova via lldb-commits

https://github.com/chelcassanova updated 
https://github.com/llvm/llvm-project/pull/83069

>From 40caaa80180d4845393fc4b80ee2dc09b7c87a7e Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova 
Date: Tue, 20 Feb 2024 13:56:53 -0800
Subject: [PATCH] [lldb][progress] Hook up new broadcast bit and progress
 manager

This commit adds the functionality to broadcast events using the
`Debugger::eBroadcastProgressCategory`
bit (https://github.com/llvm/llvm-project/pull/81169) by keeping track of these
reports with the `ProgressManager`
class (https://github.com/llvm/llvm-project/pull/81319). The new bit is
used in such a way that it will only broadcast the initial and final
progress reports for specific progress categories that are managed by
the progress manager.

This commit also adds a new test to the progress report unit test that
checks that only the initial/final reports are broadcasted when using
the new bit.
---
 lldb/include/lldb/Core/Debugger.h  | 10 +--
 lldb/include/lldb/Core/Progress.h  | 47 +-
 lldb/source/Core/Debugger.cpp  | 19 +++---
 lldb/source/Core/Progress.cpp  | 73 +++---
 lldb/unittests/Core/ProgressReportTest.cpp | 57 +
 5 files changed, 156 insertions(+), 50 deletions(-)

diff --git a/lldb/include/lldb/Core/Debugger.h 
b/lldb/include/lldb/Core/Debugger.h
index 6ba90eb6ed8fdf..b65ec1029ab24b 100644
--- a/lldb/include/lldb/Core/Debugger.h
+++ b/lldb/include/lldb/Core/Debugger.h
@@ -593,6 +593,7 @@ class Debugger : public 
std::enable_shared_from_this,
   friend class CommandInterpreter;
   friend class REPL;
   friend class Progress;
+  friend class ProgressManager;
 
   /// Report progress events.
   ///
@@ -623,10 +624,11 @@ class Debugger : public 
std::enable_shared_from_this,
   ///   debugger identifier that this progress should be delivered to. If this
   ///   optional parameter does not have a value, the progress will be
   ///   delivered to all debuggers.
-  static void ReportProgress(uint64_t progress_id, std::string title,
- std::string details, uint64_t completed,
- uint64_t total,
- std::optional debugger_id);
+  static void
+  ReportProgress(uint64_t progress_id, std::string title, std::string details,
+ uint64_t completed, uint64_t total,
+ std::optional debugger_id,
+ uint32_t progress_category_bit = eBroadcastBitProgress);
 
   static void ReportDiagnosticImpl(DiagnosticEventData::Type type,
std::string message,
diff --git a/lldb/include/lldb/Core/Progress.h 
b/lldb/include/lldb/Core/Progress.h
index eb4d9f9d7af08e..b2038a9ffd9317 100644
--- a/lldb/include/lldb/Core/Progress.h
+++ b/lldb/include/lldb/Core/Progress.h
@@ -9,10 +9,11 @@
 #ifndef LLDB_CORE_PROGRESS_H
 #define LLDB_CORE_PROGRESS_H
 
-#include "lldb/Utility/ConstString.h"
+#include "lldb/lldb-forward.h"
 #include "lldb/lldb-types.h"
 #include "llvm/ADT/StringMap.h"
 #include 
+#include 
 #include 
 #include 
 
@@ -97,27 +98,36 @@ class Progress {
   /// Used to indicate a non-deterministic progress report
   static constexpr uint64_t kNonDeterministicTotal = UINT64_MAX;
 
+/// Data belonging to this Progress event. This data is used by the 
Debugger
+/// to broadcast the event and by the ProgressManager for bookkeeping.
+  struct ProgressData {
+/// The title of the progress activity, also used as a category.
+std::string title;
+/// More specific information about the current file being displayed in the
+/// report.
+std::string details;
+/// A unique integer identifier for progress reporting.
+uint64_t progress_id;
+/// How much work ([0...m_total]) that has been completed.
+uint64_t completed;
+/// Total amount of work, use a std::nullopt in the constructor for non
+/// deterministic progress.
+uint64_t total;
+/// The optional debugger ID to report progress to. If this has no value
+/// then all debuggers will receive this event.
+std::optional debugger_id;
+  };
+
 private:
   void ReportProgress();
   static std::atomic g_id;
-  /// The title of the progress activity.
-  std::string m_title;
-  std::string m_details;
   std::mutex m_mutex;
-  /// A unique integer identifier for progress reporting.
-  const uint64_t m_id;
-  /// How much work ([0...m_total]) that has been completed.
-  uint64_t m_completed;
-  /// Total amount of work, use a std::nullopt in the constructor for non
-  /// deterministic progress.
-  uint64_t m_total;
-  /// The optional debugger ID to report progress to. If this has no value then
-  /// all debuggers will receive this event.
-  std::optional m_debugger_id;
   /// Set to true when progress has been reported where m_completed == m_total
   /// to ensure that we don't send progress updates after progress has
   /// completed.
   bool m_complete = false;
+  /// Data 

[Lldb-commits] [lldb] [lldb][progress] Hook up new broadcast bit and progress manager (PR #83069)

2024-02-28 Thread Chelsea Cassanova via lldb-commits

https://github.com/chelcassanova updated 
https://github.com/llvm/llvm-project/pull/83069

>From 03268312834c61a16c4bc28efc442fcd027ec0a9 Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova 
Date: Tue, 20 Feb 2024 13:56:53 -0800
Subject: [PATCH] [lldb][progress] Hook up new broadcast bit and progress
 manager

This commit adds the functionality to broadcast events using the
`Debugger::eBroadcastProgressCategory`
bit (https://github.com/llvm/llvm-project/pull/81169) by keeping track of these
reports with the `ProgressManager`
class (https://github.com/llvm/llvm-project/pull/81319). The new bit is
used in such a way that it will only broadcast the initial and final
progress reports for specific progress categories that are managed by
the progress manager.

This commit also adds a new test to the progress report unit test that
checks that only the initial/final reports are broadcasted when using
the new bit.
---
 lldb/include/lldb/Core/Debugger.h  | 10 +--
 lldb/include/lldb/Core/Progress.h  | 48 +-
 lldb/source/Core/Debugger.cpp  | 19 +++---
 lldb/source/Core/Progress.cpp  | 73 +++---
 lldb/unittests/Core/ProgressReportTest.cpp | 57 +
 5 files changed, 157 insertions(+), 50 deletions(-)

diff --git a/lldb/include/lldb/Core/Debugger.h 
b/lldb/include/lldb/Core/Debugger.h
index 6ba90eb6ed8fdf..b65ec1029ab24b 100644
--- a/lldb/include/lldb/Core/Debugger.h
+++ b/lldb/include/lldb/Core/Debugger.h
@@ -593,6 +593,7 @@ class Debugger : public 
std::enable_shared_from_this,
   friend class CommandInterpreter;
   friend class REPL;
   friend class Progress;
+  friend class ProgressManager;
 
   /// Report progress events.
   ///
@@ -623,10 +624,11 @@ class Debugger : public 
std::enable_shared_from_this,
   ///   debugger identifier that this progress should be delivered to. If this
   ///   optional parameter does not have a value, the progress will be
   ///   delivered to all debuggers.
-  static void ReportProgress(uint64_t progress_id, std::string title,
- std::string details, uint64_t completed,
- uint64_t total,
- std::optional debugger_id);
+  static void
+  ReportProgress(uint64_t progress_id, std::string title, std::string details,
+ uint64_t completed, uint64_t total,
+ std::optional debugger_id,
+ uint32_t progress_category_bit = eBroadcastBitProgress);
 
   static void ReportDiagnosticImpl(DiagnosticEventData::Type type,
std::string message,
diff --git a/lldb/include/lldb/Core/Progress.h 
b/lldb/include/lldb/Core/Progress.h
index eb4d9f9d7af08e..d3077ef4823eac 100644
--- a/lldb/include/lldb/Core/Progress.h
+++ b/lldb/include/lldb/Core/Progress.h
@@ -9,10 +9,11 @@
 #ifndef LLDB_CORE_PROGRESS_H
 #define LLDB_CORE_PROGRESS_H
 
-#include "lldb/Utility/ConstString.h"
+#include "lldb/lldb-forward.h"
 #include "lldb/lldb-types.h"
 #include "llvm/ADT/StringMap.h"
 #include 
+#include 
 #include 
 #include 
 
@@ -97,27 +98,37 @@ class Progress {
   /// Used to indicate a non-deterministic progress report
   static constexpr uint64_t kNonDeterministicTotal = UINT64_MAX;
 
+  /// Use a struct to send data from a Progress object to
+  /// the progress manager.
+  struct ProgressData {
+/// Data belonging to this Progress event. This data is used by the 
Debugger
+/// to broadcast the event and by the ProgressManager for bookkeeping.
+std::string title;
+/// More specific information about the current file being displayed in the
+/// report.
+std::string details;
+/// A unique integer identifier for progress reporting.
+uint64_t progress_id;
+/// How much work ([0...m_total]) that has been completed.
+uint64_t completed;
+/// Total amount of work, use a std::nullopt in the constructor for non
+/// deterministic progress.
+uint64_t total;
+/// The optional debugger ID to report progress to. If this has no value
+/// then all debuggers will receive this event.
+std::optional debugger_id;
+  };
+
 private:
   void ReportProgress();
   static std::atomic g_id;
-  /// The title of the progress activity.
-  std::string m_title;
-  std::string m_details;
   std::mutex m_mutex;
-  /// A unique integer identifier for progress reporting.
-  const uint64_t m_id;
-  /// How much work ([0...m_total]) that has been completed.
-  uint64_t m_completed;
-  /// Total amount of work, use a std::nullopt in the constructor for non
-  /// deterministic progress.
-  uint64_t m_total;
-  /// The optional debugger ID to report progress to. If this has no value then
-  /// all debuggers will receive this event.
-  std::optional m_debugger_id;
   /// Set to true when progress has been reported where m_completed == m_total
   /// to ensure that we don't send progress updates after progress has
   /// completed.
   bool m_complete = 

[Lldb-commits] [lldb] [lldb][progress] Hook up new broadcast bit and progress manager (PR #83069)

2024-02-28 Thread Chelsea Cassanova via lldb-commits


@@ -82,20 +94,37 @@ ProgressManager ::Instance() {
   return *g_progress_manager;
 }
 
-void ProgressManager::Increment(std::string title) {
+void ProgressManager::Increment(Progress::ProgressData progress_data) {

chelcassanova wrote:

Yeah, the title is used for map queries but the data itself isn't stored in the 
map, it's passed on to `ProgressManager::ReportProgress`.  If we change it to a 
const ref (`const Progress::ProgressData& progress_data`) here then we probably 
also want to do this for `Decrement` since it uses the map in a similar way.

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


[Lldb-commits] [lldb] [lldb][progress] Hook up new broadcast bit and progress manager (PR #83069)

2024-02-28 Thread Chelsea Cassanova via lldb-commits

https://github.com/chelcassanova updated 
https://github.com/llvm/llvm-project/pull/83069

>From 63dded34a47dd161fa918e45aaeecf966ba08476 Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova 
Date: Tue, 20 Feb 2024 13:56:53 -0800
Subject: [PATCH] [lldb][progress] Hook up new broadcast bit and progress
 manager

This commit adds the functionality to broadcast events using the
`Debugger::eBroadcastProgressCategory`
bit (https://github.com/llvm/llvm-project/pull/81169) by keeping track of these
reports with the `ProgressManager`
class (https://github.com/llvm/llvm-project/pull/81319). The new bit is
used in such a way that it will only broadcast the initial and final
progress reports for specific progress categories that are managed by
the progress manager.

This commit also adds a new test to the progress report unit test that
checks that only the initial/final reports are broadcasted when using
the new bit.
---
 lldb/include/lldb/Core/Debugger.h  | 10 +--
 lldb/include/lldb/Core/Progress.h  | 48 +-
 lldb/source/Core/Debugger.cpp  | 19 +++---
 lldb/source/Core/Progress.cpp  | 73 +++---
 lldb/unittests/Core/ProgressReportTest.cpp | 57 +
 5 files changed, 157 insertions(+), 50 deletions(-)

diff --git a/lldb/include/lldb/Core/Debugger.h 
b/lldb/include/lldb/Core/Debugger.h
index 6ba90eb6ed8fdf..b65ec1029ab24b 100644
--- a/lldb/include/lldb/Core/Debugger.h
+++ b/lldb/include/lldb/Core/Debugger.h
@@ -593,6 +593,7 @@ class Debugger : public 
std::enable_shared_from_this,
   friend class CommandInterpreter;
   friend class REPL;
   friend class Progress;
+  friend class ProgressManager;
 
   /// Report progress events.
   ///
@@ -623,10 +624,11 @@ class Debugger : public 
std::enable_shared_from_this,
   ///   debugger identifier that this progress should be delivered to. If this
   ///   optional parameter does not have a value, the progress will be
   ///   delivered to all debuggers.
-  static void ReportProgress(uint64_t progress_id, std::string title,
- std::string details, uint64_t completed,
- uint64_t total,
- std::optional debugger_id);
+  static void
+  ReportProgress(uint64_t progress_id, std::string title, std::string details,
+ uint64_t completed, uint64_t total,
+ std::optional debugger_id,
+ uint32_t progress_category_bit = eBroadcastBitProgress);
 
   static void ReportDiagnosticImpl(DiagnosticEventData::Type type,
std::string message,
diff --git a/lldb/include/lldb/Core/Progress.h 
b/lldb/include/lldb/Core/Progress.h
index eb4d9f9d7af08e..1dad11a73429ba 100644
--- a/lldb/include/lldb/Core/Progress.h
+++ b/lldb/include/lldb/Core/Progress.h
@@ -9,10 +9,11 @@
 #ifndef LLDB_CORE_PROGRESS_H
 #define LLDB_CORE_PROGRESS_H
 
-#include "lldb/Utility/ConstString.h"
+#include "lldb/lldb-forward.h"
 #include "lldb/lldb-types.h"
 #include "llvm/ADT/StringMap.h"
 #include 
+#include 
 #include 
 #include 
 
@@ -97,27 +98,37 @@ class Progress {
   /// Used to indicate a non-deterministic progress report
   static constexpr uint64_t kNonDeterministicTotal = UINT64_MAX;
 
+  /// Use a struct to send data from a Progress object to
+  /// the progress manager.
+  struct ProgressData {
+/// The title of the progress activity, also used as a category to group
+/// reports.
+std::string title;
+/// More specific information about the current file being displayed in the
+/// report.
+std::string details;
+/// A unique integer identifier for progress reporting.
+uint64_t progress_id;
+/// How much work ([0...m_total]) that has been completed.
+uint64_t completed;
+/// Total amount of work, use a std::nullopt in the constructor for non
+/// deterministic progress.
+uint64_t total;
+/// The optional debugger ID to report progress to. If this has no value
+/// then all debuggers will receive this event.
+std::optional debugger_id;
+  };
+
 private:
   void ReportProgress();
   static std::atomic g_id;
-  /// The title of the progress activity.
-  std::string m_title;
-  std::string m_details;
   std::mutex m_mutex;
-  /// A unique integer identifier for progress reporting.
-  const uint64_t m_id;
-  /// How much work ([0...m_total]) that has been completed.
-  uint64_t m_completed;
-  /// Total amount of work, use a std::nullopt in the constructor for non
-  /// deterministic progress.
-  uint64_t m_total;
-  /// The optional debugger ID to report progress to. If this has no value then
-  /// all debuggers will receive this event.
-  std::optional m_debugger_id;
   /// Set to true when progress has been reported where m_completed == m_total
   /// to ensure that we don't send progress updates after progress has
   /// completed.
   bool m_complete = false;
+  /// Data needed by the debugger to broadcast a progress 

[Lldb-commits] [lldb] [lldb][progress] Hook up new broadcast bit and progress manager (PR #83069)

2024-02-27 Thread Chelsea Cassanova via lldb-commits


@@ -29,8 +30,12 @@ Progress::Progress(std::string title, std::string details,
 
   if (debugger)
 m_debugger_id = debugger->GetID();
+
+  m_progress_data = {m_title, m_details, m_id,
+ m_completed, m_total,   m_debugger_id};

chelcassanova wrote:

I'm removing this anyways but yeah not sure what `clang-format` was thinking 
here.

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


[Lldb-commits] [lldb] [lldb][progress] Hook up new broadcast bit and progress manager (PR #83069)

2024-02-27 Thread Chelsea Cassanova via lldb-commits

https://github.com/chelcassanova updated 
https://github.com/llvm/llvm-project/pull/83069

>From 2cef4a29f0105847fa11b7f6a6ee063184fb838a Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova 
Date: Tue, 20 Feb 2024 13:56:53 -0800
Subject: [PATCH] [lldb][progress] Hook up new broadcast bit and progress
 manager

This commit adds the functionality to broadcast events using the
`Debugger::eBroadcastProgressCategory`
bit (https://github.com/llvm/llvm-project/pull/81169) by keeping track of these
reports with the `ProgressManager`
class (https://github.com/llvm/llvm-project/pull/81319). The new bit is
used in such a way that it will only broadcast the initial and final
progress reports for specific progress categories that are managed by
the progress manager.

This commit also adds a new test to the progress report unit test that
checks that only the initial/final reports are broadcasted when using
the new bit.
---
 lldb/include/lldb/Core/Debugger.h  | 10 ++--
 lldb/include/lldb/Core/Progress.h  | 43 +++-
 lldb/source/Core/Debugger.cpp  | 25 +++---
 lldb/source/Core/Progress.cpp  | 40 ---
 lldb/unittests/Core/ProgressReportTest.cpp | 57 ++
 5 files changed, 145 insertions(+), 30 deletions(-)

diff --git a/lldb/include/lldb/Core/Debugger.h 
b/lldb/include/lldb/Core/Debugger.h
index 6ba90eb6ed8fdf..b65ec1029ab24b 100644
--- a/lldb/include/lldb/Core/Debugger.h
+++ b/lldb/include/lldb/Core/Debugger.h
@@ -593,6 +593,7 @@ class Debugger : public 
std::enable_shared_from_this,
   friend class CommandInterpreter;
   friend class REPL;
   friend class Progress;
+  friend class ProgressManager;
 
   /// Report progress events.
   ///
@@ -623,10 +624,11 @@ class Debugger : public 
std::enable_shared_from_this,
   ///   debugger identifier that this progress should be delivered to. If this
   ///   optional parameter does not have a value, the progress will be
   ///   delivered to all debuggers.
-  static void ReportProgress(uint64_t progress_id, std::string title,
- std::string details, uint64_t completed,
- uint64_t total,
- std::optional debugger_id);
+  static void
+  ReportProgress(uint64_t progress_id, std::string title, std::string details,
+ uint64_t completed, uint64_t total,
+ std::optional debugger_id,
+ uint32_t progress_category_bit = eBroadcastBitProgress);
 
   static void ReportDiagnosticImpl(DiagnosticEventData::Type type,
std::string message,
diff --git a/lldb/include/lldb/Core/Progress.h 
b/lldb/include/lldb/Core/Progress.h
index eb4d9f9d7af08e..7554d4fe2b77e9 100644
--- a/lldb/include/lldb/Core/Progress.h
+++ b/lldb/include/lldb/Core/Progress.h
@@ -9,10 +9,11 @@
 #ifndef LLDB_CORE_PROGRESS_H
 #define LLDB_CORE_PROGRESS_H
 
-#include "lldb/Utility/ConstString.h"
+#include "lldb/lldb-forward.h"
 #include "lldb/lldb-types.h"
 #include "llvm/ADT/StringMap.h"
 #include 
+#include 
 #include 
 #include 
 
@@ -97,27 +98,44 @@ class Progress {
   /// Used to indicate a non-deterministic progress report
   static constexpr uint64_t kNonDeterministicTotal = UINT64_MAX;
 
+  /// Use a struct to send data from a Progress object to
+  /// the progress manager.
+  struct ProgressData {
+/// The title of the progress activity, also used as a category to group
+/// reports.
+std::string title;
+/// More specific information about the current file being displayed in the
+/// report.
+std::string details;
+/// A unique integer identifier for progress reporting.
+uint64_t progress_id;
+/// How much work ([0...m_total]) that has been completed.
+uint64_t completed;
+/// Total amount of work, use a std::nullopt in the constructor for non
+/// deterministic progress.
+uint64_t total;
+/// The optional debugger ID to report progress to. If this has no value
+/// then all debuggers will receive this event.
+std::optional debugger_id;
+  };
+
 private:
+  friend class Debugger;
   void ReportProgress();
   static std::atomic g_id;
-  /// The title of the progress activity.
   std::string m_title;
   std::string m_details;
   std::mutex m_mutex;
-  /// A unique integer identifier for progress reporting.
   const uint64_t m_id;
-  /// How much work ([0...m_total]) that has been completed.
   uint64_t m_completed;
-  /// Total amount of work, use a std::nullopt in the constructor for non
-  /// deterministic progress.
   uint64_t m_total;
-  /// The optional debugger ID to report progress to. If this has no value then
-  /// all debuggers will receive this event.
   std::optional m_debugger_id;
   /// Set to true when progress has been reported where m_completed == m_total
   /// to ensure that we don't send progress updates after progress has
   /// completed.
   bool m_complete = false;
+  /// Data needed by the 

  1   2   3   >