[Lldb-commits] [lldb] 4cf458c - Fix help doc for 'enable-background-lookup' obsolete setting

2024-02-15 Thread Jason Molenda via lldb-commits

Author: Jason Molenda
Date: 2024-02-15T23:53:14-08:00
New Revision: 4cf458c696047d6d2991c121da7a5c165ff747ce

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

LOG: Fix help doc for 'enable-background-lookup' obsolete setting

The setting name that was settled on is symbols.auto-download.

Added: 


Modified: 
lldb/source/Core/CoreProperties.td

Removed: 




diff  --git a/lldb/source/Core/CoreProperties.td 
b/lldb/source/Core/CoreProperties.td
index 9c4aa2de3d7b73..4cfff805688c56 100644
--- a/lldb/source/Core/CoreProperties.td
+++ b/lldb/source/Core/CoreProperties.td
@@ -8,7 +8,7 @@ let Definition = "modulelist" in {
   def EnableBackgroundLookup: Property<"enable-background-lookup", "Boolean">,
 Global,
 DefaultFalse,
-Desc<"Alias for backward compatibility: when enabled this is the 
equivalent to 'symbols.download background'.">;
+Desc<"Alias for backward compatibility: when enabled this is the 
equivalent to 'symbols.auto-download background'.">;
   def AutoDownload: Property<"auto-download", "Enum">,
 Global,
 DefaultEnumValue<"eSymbolDownloadOff">,



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


[Lldb-commits] [lldb] 266bbc2 - [lldb] Re-enable TestStepOverWatchpoint on macOS 14.4 and later

2024-02-15 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2024-02-15T22:54:00-08:00
New Revision: 266bbc203da2d0bc880e643560fb48aff4830478

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

LOG: [lldb] Re-enable TestStepOverWatchpoint on macOS 14.4 and later

Added: 


Modified: 

lldb/test/API/commands/watchpoints/step_over_watchpoint/TestStepOverWatchpoint.py

Removed: 




diff  --git 
a/lldb/test/API/commands/watchpoints/step_over_watchpoint/TestStepOverWatchpoint.py
 
b/lldb/test/API/commands/watchpoints/step_over_watchpoint/TestStepOverWatchpoint.py
index aac31088907544..02f0592f40de6d 100644
--- 
a/lldb/test/API/commands/watchpoints/step_over_watchpoint/TestStepOverWatchpoint.py
+++ 
b/lldb/test/API/commands/watchpoints/step_over_watchpoint/TestStepOverWatchpoint.py
@@ -20,7 +20,7 @@ def get_to_start(self, bkpt_text):
 
 @add_test_categories(["basic_process"])
 @expectedFailureAll(
-oslist=["ios", "watchos", "tvos", "bridgeos", "macosx"],
+macos_version=["<", "14.4"],
 archs=["aarch64", "arm"],
 bugnumber="",
 )
@@ -63,7 +63,7 @@ def test_step_over_read_watchpoint(self):
 
 @add_test_categories(["basic_process"])
 @expectedFailureAll(
-oslist=["ios", "watchos", "tvos", "bridgeos", "macosx"],
+macos_version=["<", "14.4"],
 archs=["aarch64", "arm"],
 bugnumber="",
 )



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


[Lldb-commits] [lldb] 096c530 - [lldb] Fix Python test formatting (NFC)

2024-02-15 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2024-02-15T22:54:00-08:00
New Revision: 096c530ab3ea5c96526451181117f30db17b4b1d

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

LOG: [lldb] Fix Python test formatting (NFC)

Added: 


Modified: 
lldb/test/API/commands/command/script/add/TestAddParsedCommand.py
lldb/test/API/commands/command/script/add/test_commands.py
lldb/test/API/commands/expression/nested/TestNestedExpressions.py
lldb/test/API/commands/process/attach/TestProcessAttach.py

lldb/test/API/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py
lldb/test/API/functionalities/executable_first/TestExecutableFirst.py
lldb/test/API/functionalities/inline-sourcefile/TestInlineSourceFiles.py

lldb/test/API/functionalities/process_save_core_minidump/TestProcessSaveCoreMinidump.py
lldb/test/API/functionalities/type_find_first/TestFindFirstType.py
lldb/test/API/functionalities/vtable/TestVTableValue.py

lldb/test/API/lang/cpp/union-static-data-members/TestCppUnionStaticMembers.py
lldb/test/API/lang/cpp/unique-types4/TestUniqueTypes4.py
lldb/test/API/lang/objc/charstar_dyntype/TestCharStarDynType.py
lldb/test/API/python_api/global_module_cache/TestGlobalModuleCache.py
lldb/test/API/python_api/process/cancel_attach/TestCancelAttach.py
lldb/test/API/python_api/value/TestValueAPI.py
lldb/test/API/tools/lldb-dap/breakpoint/TestDAP_logpoints.py

Removed: 




diff  --git a/lldb/test/API/commands/command/script/add/TestAddParsedCommand.py 
b/lldb/test/API/commands/command/script/add/TestAddParsedCommand.py
index 7dba9c6937f211..d30b0b67124ed2 100644
--- a/lldb/test/API/commands/command/script/add/TestAddParsedCommand.py
+++ b/lldb/test/API/commands/command/script/add/TestAddParsedCommand.py
@@ -16,7 +16,7 @@ class ParsedCommandTestCase(TestBase):
 def test(self):
 self.pycmd_tests()
 
-def check_help_options(self, cmd_name, opt_list, substrs = []):
+def check_help_options(self, cmd_name, opt_list, substrs=[]):
 """
 Pass the command name in cmd_name and a vector of the short option, 
type & long option.
 This will append the checks for all the options and test "help 
command".
@@ -30,78 +30,108 @@ def check_help_options(self, cmd_name, opt_list, substrs = 
[]):
 (short_opt, type, long_opt) = elem
 substrs.append(f"-{short_opt} <{type}> ( --{long_opt} <{type}> 
)")
 print(f"Opt Vec\n{substrs}")
-self.expect("help " + cmd_name, substrs = substrs)
+self.expect("help " + cmd_name, substrs=substrs)
 
 def pycmd_tests(self):
 source_dir = self.getSourceDir()
 test_file_path = os.path.join(source_dir, "test_commands.py")
 self.runCmd("command script import " + test_file_path)
-self.expect("help", substrs = ["no-args", "one-arg-no-opt", 
"two-args"])
+self.expect("help", substrs=["no-args", "one-arg-no-opt", "two-args"])
 
 # Test that we did indeed add these commands as user commands:
 
 # This is the function to remove the custom commands in order to have a
 # clean slate for the next test case.
 def cleanup():
-self.runCmd("command script delete no-args one-arg-no-opt 
two-args", check=False)
+self.runCmd(
+"command script delete no-args one-arg-no-opt two-args", 
check=False
+)
 
 # Execute the cleanup function during test case tear down.
 self.addTearDownHook(cleanup)
 
 # First test the no arguments command.  Make sure the help is right:
-no_arg_opts = [["b", "boolean", "bool-arg"],
-   "+a boolean arg, defaults to True",
-   ["d", "filename", "disk-file-name"],
-   "+An on disk filename",
-   ["e", "none", "enum-option"],
-   "+An enum, doesn't actually do anything",
-   "+Values: foo | bar | baz",
-   ["l", "linenum", "line-num"],
-   "+A line number",
-   ["s", "shlib-name", "shlib-name"],
-   "+A shared library name"]
-substrs = ["Example command for use in debugging",
-   "Syntax: no-args "]
-
+no_arg_opts = [
+["b", "boolean", "bool-arg"],
+"+a boolean arg, defaults to True",
+["d", "filename", "disk-file-name"],
+"+An on disk filename",
+["e", "none", "enum-option"],
+"+An enum, doesn't actually do anything",
+"+Values: foo | bar | baz",
+["l", "linenum", "line-num"],
+"+A line number",
+["s", "s

[Lldb-commits] [lldb] Report only loaded debug info in statistics dump (PR #81706)

2024-02-15 Thread Greg Clayton via lldb-commits

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

You can remove the headerdoc in the SymbolFileDWARF.h file and this is good to 
go.

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


[Lldb-commits] [lldb] Report only loaded debug info in statistics dump (PR #81706)

2024-02-15 Thread Greg Clayton via lldb-commits

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


[Lldb-commits] [lldb] Report only loaded debug info in statistics dump (PR #81706)

2024-02-15 Thread Greg Clayton via lldb-commits


@@ -186,7 +186,19 @@ class SymbolFileDWARF : public SymbolFileCommon {
   GetMangledNamesForFunction(const std::string &scope_qualified_name,
  std::vector &mangled_names) override;
 
-  uint64_t GetDebugInfoSize() override;
+  /// Get total currently loaded debug info size or total possible debug info
+  /// size.
+  ///
+  /// For cases like .dwo files, the debug info = skeleton debug info +
+  /// all dwo debug info where .dwo files might not be loaded yet. Calling this
+  /// function by default will NOT force the loading of any .dwo files.
+  ///
+  /// \param load_all_debug_info
+  ///   If true, force loading any .dwo files associated and add to the size
+  ///
+  /// \return
+  /// Returns total currently loaded debug info size

clayborg wrote:

We don't need headerdoc on overridden functions. You can remove this.

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


[Lldb-commits] [lldb] [lldb][progress] Add progress manager class (PR #81319)

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

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


[Lldb-commits] [lldb] 327d2f8 - [lldb][progress] Add progress manager class (#81319)

2024-02-15 Thread via lldb-commits

Author: Chelsea Cassanova
Date: 2024-02-15T15:46:47-08:00
New Revision: 327d2f8c6cee019d4f915036f40041b5369b61e5

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

LOG: [lldb][progress] Add progress manager class (#81319)

Per discussions from https://github.com/llvm/llvm-project/pull/81026, it
was decided that having a class that manages a map of progress reports
would be beneficial in order to categorize them. This class is a part of
the overall `Progress` class and utilizes a map that keeps a count of
how many times a progress report category has been sent. This would be
used with the new debugger broadcast bit added in
https://github.com/llvm/llvm-project/pull/81169 so that a user listening
with that bit will receive grouped progress reports.

Added: 


Modified: 
lldb/include/lldb/Core/Progress.h
lldb/source/Core/Progress.cpp

Removed: 




diff  --git a/lldb/include/lldb/Core/Progress.h 
b/lldb/include/lldb/Core/Progress.h
index 5d882910246054..eb4d9f9d7af08e 100644
--- a/lldb/include/lldb/Core/Progress.h
+++ b/lldb/include/lldb/Core/Progress.h
@@ -11,6 +11,7 @@
 
 #include "lldb/Utility/ConstString.h"
 #include "lldb/lldb-types.h"
+#include "llvm/ADT/StringMap.h"
 #include 
 #include 
 #include 
@@ -119,6 +120,26 @@ class Progress {
   bool m_complete = false;
 };
 
+/// A class used to group progress reports by category. This is done by using a
+/// map that maintains a refcount of each category of progress reports that 
have
+/// come in. Keeping track of progress reports this way will be done if a
+/// debugger is listening to the eBroadcastBitProgressByCategory broadcast bit.
+class ProgressManager {
+public:
+  ProgressManager();
+  ~ProgressManager();
+
+  /// Control the refcount of the progress report category as needed.
+  void Increment(std::string category);
+  void Decrement(std::string category);
+
+  static ProgressManager &Instance();
+
+private:
+  llvm::StringMap m_progress_category_map;
+  std::mutex m_progress_map_mutex;
+};
+
 } // namespace lldb_private
 
 #endif // LLDB_CORE_PROGRESS_H

diff  --git a/lldb/source/Core/Progress.cpp b/lldb/source/Core/Progress.cpp
index 732efbc342b450..9e8deb1ad4e731 100644
--- a/lldb/source/Core/Progress.cpp
+++ b/lldb/source/Core/Progress.cpp
@@ -11,6 +11,7 @@
 #include "lldb/Core/Debugger.h"
 #include "lldb/Utility/StreamString.h"
 
+#include 
 #include 
 
 using namespace lldb;
@@ -66,3 +67,35 @@ void Progress::ReportProgress() {
  m_debugger_id);
   }
 }
+
+ProgressManager::ProgressManager() : m_progress_category_map() {}
+
+ProgressManager::~ProgressManager() {}
+
+ProgressManager &ProgressManager::Instance() {
+  static std::once_flag g_once_flag;
+  static ProgressManager *g_progress_manager = nullptr;
+  std::call_once(g_once_flag, []() {
+// NOTE: known leak to avoid global destructor chain issues.
+g_progress_manager = new ProgressManager();
+  });
+  return *g_progress_manager;
+}
+
+void ProgressManager::Increment(std::string title) {
+  std::lock_guard lock(m_progress_map_mutex);
+  m_progress_category_map[title]++;
+}
+
+void ProgressManager::Decrement(std::string title) {
+  std::lock_guard lock(m_progress_map_mutex);
+  auto pos = m_progress_category_map.find(title);
+
+  if (pos == m_progress_category_map.end())
+return;
+
+  if (pos->second <= 1)
+m_progress_category_map.erase(title);
+  else
+--pos->second;
+}



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


[Lldb-commits] [lldb] Re-land [lldb-dap] Add support for data breakpoint. (PR #81909)

2024-02-15 Thread Zequan Wu via lldb-commits

https://github.com/ZequanWu updated 
https://github.com/llvm/llvm-project/pull/81909

>From d95a420ef100d0e73f8ff829926fc3f3d0708386 Mon Sep 17 00:00:00 2001
From: Zequan Wu 
Date: Thu, 15 Feb 2024 14:29:18 -0500
Subject: [PATCH 1/2] [lldb-dap] Add support for data breakpoint.

This implements functionality to handle DataBreakpointInfo request and 
SetDataBreakpoints request.
---
 .../test/tools/lldb-dap/dap_server.py |  47 +++
 .../tools/lldb-dap/databreakpoint/Makefile|   3 +
 .../TestDAP_setDataBreakpoints.py | 131 +++
 .../tools/lldb-dap/databreakpoint/main.cpp|  17 +
 lldb/tools/lldb-dap/CMakeLists.txt|   1 +
 lldb/tools/lldb-dap/DAPForward.h  |   2 +
 lldb/tools/lldb-dap/Watchpoint.cpp|  48 +++
 lldb/tools/lldb-dap/Watchpoint.h  |  34 ++
 lldb/tools/lldb-dap/lldb-dap.cpp  | 336 --
 9 files changed, 585 insertions(+), 34 deletions(-)
 create mode 100644 lldb/test/API/tools/lldb-dap/databreakpoint/Makefile
 create mode 100644 
lldb/test/API/tools/lldb-dap/databreakpoint/TestDAP_setDataBreakpoints.py
 create mode 100644 lldb/test/API/tools/lldb-dap/databreakpoint/main.cpp
 create mode 100644 lldb/tools/lldb-dap/Watchpoint.cpp
 create mode 100644 lldb/tools/lldb-dap/Watchpoint.h

diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
index bb863bb8719176..27a76a652f4063 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
@@ -501,6 +501,18 @@ def get_local_variable_value(self, name, frameIndex=0, 
threadId=None):
 return variable["value"]
 return None
 
+def get_local_variable_child(self, name, child_name, frameIndex=0, 
threadId=None):
+local = self.get_local_variable(name, frameIndex, threadId)
+if local["variablesReference"] == 0:
+return None
+children = self.request_variables(local["variablesReference"])["body"][
+"variables"
+]
+for child in children:
+if child["name"] == child_name:
+return child
+return None
+
 def replay_packets(self, replay_file_path):
 f = open(replay_file_path, "r")
 mode = "invalid"
@@ -895,6 +907,41 @@ def request_setFunctionBreakpoints(self, names, 
condition=None, hitCondition=Non
 }
 return self.send_recv(command_dict)
 
+def request_dataBreakpointInfo(
+self, variablesReference, name, frameIndex=0, threadId=None
+):
+stackFrame = self.get_stackFrame(frameIndex=frameIndex, 
threadId=threadId)
+if stackFrame is None:
+return []
+args_dict = {
+"variablesReference": variablesReference,
+"name": name,
+"frameId": stackFrame["id"],
+}
+command_dict = {
+"command": "dataBreakpointInfo",
+"type": "request",
+"arguments": args_dict,
+}
+return self.send_recv(command_dict)
+
+def request_setDataBreakpoint(self, dataBreakpoints):
+"""dataBreakpoints is a list of dictionary with following fields:
+{
+dataId: (address in hex)/(size in bytes)
+accessType: read/write/readWrite
+[condition]: string
+[hitCondition]: string
+}
+"""
+args_dict = {"breakpoints": dataBreakpoints}
+command_dict = {
+"command": "setDataBreakpoints",
+"type": "request",
+"arguments": args_dict,
+}
+return self.send_recv(command_dict)
+
 def request_compileUnits(self, moduleId):
 args_dict = {"moduleId": moduleId}
 command_dict = {
diff --git a/lldb/test/API/tools/lldb-dap/databreakpoint/Makefile 
b/lldb/test/API/tools/lldb-dap/databreakpoint/Makefile
new file mode 100644
index 00..8b20bcb050
--- /dev/null
+++ b/lldb/test/API/tools/lldb-dap/databreakpoint/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules
diff --git 
a/lldb/test/API/tools/lldb-dap/databreakpoint/TestDAP_setDataBreakpoints.py 
b/lldb/test/API/tools/lldb-dap/databreakpoint/TestDAP_setDataBreakpoints.py
new file mode 100644
index 00..8b4f07a9054d74
--- /dev/null
+++ b/lldb/test/API/tools/lldb-dap/databreakpoint/TestDAP_setDataBreakpoints.py
@@ -0,0 +1,131 @@
+"""
+Test lldb-dap dataBreakpointInfo and setDataBreakpoints requests
+"""
+
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+import lldbdap_testcase
+
+
+class TestDAP_setDataBreakpoints(lldbdap_testcase.DAPTestCaseBase):
+def setUp(self):
+lldbdap_testcase.DAPTestCaseBase.setUp(self)
+self.accessTypes = ["read", "write", "readWrite"]
+
+@skipIfWindows
+@skipIfRemote
+def test_expression(self):
+"""

[Lldb-commits] [lldb] [lldb][progress] Add progress manager class (PR #81319)

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

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

>From f5ef07849c61ee9387f92376d5e1bd13bedc43e5 Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova 
Date: Thu, 8 Feb 2024 15:31:33 -0800
Subject: [PATCH 1/4] [lldb][progress] Add progress manager class

Per discussions from https://github.com/llvm/llvm-project/pull/81026,
it was decided that having a class that manages a map of progress
reports would be beneficial in order to categorize them. This class is a
part of the overall `Progress` class and utilizes a map that keeps a
count of how many times a progress report category has been sent. This
would be used with the new debugger broadcast bit added in
https://github.com/llvm/llvm-project/pull/81169 so that a user listening
with that bit will receive grouped progress reports.
---
 lldb/include/lldb/Core/Progress.h | 27 +++
 lldb/source/Core/Progress.cpp | 44 +++
 2 files changed, 71 insertions(+)

diff --git a/lldb/include/lldb/Core/Progress.h 
b/lldb/include/lldb/Core/Progress.h
index 5d882910246054..5e07789b0e5337 100644
--- a/lldb/include/lldb/Core/Progress.h
+++ b/lldb/include/lldb/Core/Progress.h
@@ -11,6 +11,7 @@
 
 #include "lldb/Utility/ConstString.h"
 #include "lldb/lldb-types.h"
+#include "llvm/ADT/StringMap.h"
 #include 
 #include 
 #include 
@@ -119,6 +120,32 @@ class Progress {
   bool m_complete = false;
 };
 
+/// A class used to group progress reports by category. This is done by using a
+/// map that maintains a refcount of each category of progress reports that 
have
+/// come in. Keeping track of progress reports this way will be done if a
+/// debugger is listening to the eBroadcastBitProgressByCategory broadcast bit.
+class ProgressManager {
+public:
+  ProgressManager();
+  ~ProgressManager();
+
+  static void Initialize();
+  static void Terminate();
+  // Control the refcount of the progress report category as needed
+  void Increment(std::string category);
+  void Decrement(std::string category);
+
+  // Public accessor for the class instance
+  static ProgressManager &Instance();
+
+private:
+  // Manage the class instance internally using a std::optional
+  static std::optional &InstanceImpl();
+
+  llvm::StringMap m_progress_category_map;
+  std::mutex m_progress_map_mutex;
+};
+
 } // namespace lldb_private
 
 #endif // LLDB_CORE_PROGRESS_H
diff --git a/lldb/source/Core/Progress.cpp b/lldb/source/Core/Progress.cpp
index 732efbc342b450..063e64a0ef499c 100644
--- a/lldb/source/Core/Progress.cpp
+++ b/lldb/source/Core/Progress.cpp
@@ -66,3 +66,47 @@ void Progress::ReportProgress() {
  m_debugger_id);
   }
 }
+
+void ProgressManager::Initialize() {
+  lldbassert(!InstanceImpl() && "A progress report manager already exists.");
+  InstanceImpl().emplace();
+}
+
+void ProgressManager::Terminate() {
+  lldbassert(InstanceImpl() &&
+ "A progress report manager has already been terminated.");
+  InstanceImpl().reset();
+}
+
+std::optional &ProgressManager::InstanceImpl() {
+  static std::optional g_progress_manager;
+  return g_progress_manager;
+}
+
+ProgressManager::ProgressManager() : m_progress_category_map() {}
+
+ProgressManager::~ProgressManager() {}
+
+ProgressManager &ProgressManager::Instance() { return *InstanceImpl(); }
+
+void ProgressManager::Increment(std::string title) {
+  std::lock_guard lock(m_progress_map_mutex);
+  auto pair = m_progress_category_map.insert(std::pair(title, 1));
+
+  // If pair.first is not empty after insertion it means that that
+  // category was entered for the first time and should not be incremented
+  if (!pair.second)
+++pair.first->second;
+}
+
+void ProgressManager::Decrement(std::string title) {
+  std::lock_guard lock(m_progress_map_mutex);
+  auto pos = m_progress_category_map.find(title);
+
+  if (pos == m_progress_category_map.end())
+return;
+
+  // Remove the category from the map if the refcount reaches 0
+  if (--pos->second == 0)
+m_progress_category_map.erase(title);
+}

>From 5a045966224a809b8a5726411e406f3526c0332c Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova 
Date: Tue, 13 Feb 2024 15:19:41 -0800
Subject: [PATCH 2/4] Use call_once in InstanceImpl(), leak progress manager
 object

In order to prevent potential crashes when LLDB is terminated,
this commit instead creates the instance for the progress manager in a
`call_once` within its initializer.
---
 lldb/include/lldb/Core/Progress.h |  9 +++--
 lldb/source/Core/Progress.cpp | 31 +--
 2 files changed, 16 insertions(+), 24 deletions(-)

diff --git a/lldb/include/lldb/Core/Progress.h 
b/lldb/include/lldb/Core/Progress.h
index 5e07789b0e5337..1f2d48c27d63d3 100644
--- a/lldb/include/lldb/Core/Progress.h
+++ b/lldb/include/lldb/Core/Progress.h
@@ -129,18 +129,15 @@ class ProgressManager {
   ProgressManager();
   ~ProgressManager();
 
-  static void Initialize();
-  static void Terminate();
-  // Control

[Lldb-commits] [lldb] [lldb][progress] Add progress manager class (PR #81319)

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


@@ -66,3 +67,41 @@ void Progress::ReportProgress() {
  m_debugger_id);
   }
 }
+
+ProgressManager &ProgressManager::InstanceImpl() {
+  static std::once_flag g_once_flag;
+  static ProgressManager *g_progress_manager = nullptr;
+  std::call_once(g_once_flag, []() {
+// NOTE: known leak to avoid global destructor chain issues.
+g_progress_manager = new ProgressManager();
+  });
+  return *g_progress_manager;
+}

chelcassanova wrote:

I was actually going to ask if `Instance()` was still necessary given that all 
functionality was in `InstanceImpl()` (or if `InstanceImpl()` now needed to be 
public or something along those lines). If we're going to keep the 
implementation of the instance accessor this way then to my understanding we 
can inline `Instance()`.

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


[Lldb-commits] [lldb] [lldb][test] Remove expectedFailureIfFn (PR #81703)

2024-02-15 Thread Jordan Rupprecht via lldb-commits

rupprecht wrote:

Skipped the test in 65c25a4c40865a0e460c0fecb1b33f7cf7455573

Tear down behavior was patched for LLDB back in 
b1490b6172c48cf802b24bd738c90eeb019436fe. I'm guessing that explains why we 
weren't noticing those errors -- they get logged as cleanup_errors, not as 
errors. (Maybe I'm missing something). By switching to standard unittest and 
dropping that patch, we're going to catch more tear down issues.

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


[Lldb-commits] [lldb] [lldb][progress] Add progress manager class (PR #81319)

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


@@ -119,6 +120,32 @@ class Progress {
   bool m_complete = false;
 };
 
+/// A class used to group progress reports by category. This is done by using a
+/// map that maintains a refcount of each category of progress reports that 
have
+/// come in. Keeping track of progress reports this way will be done if a
+/// debugger is listening to the eBroadcastBitProgressByCategory broadcast bit.
+class ProgressManager {
+public:
+  ProgressManager();
+  ~ProgressManager();
+
+  static void Initialize();
+  static void Terminate();
+  // Control the refcount of the progress report category as needed
+  void Increment(std::string category);
+  void Decrement(std::string category);
+
+  // Public accessor for the class instance
+  static ProgressManager &Instance();
+
+private:
+  // Manage the class instance internally using a std::optional

chelcassanova wrote:

I should've changed this comment in a more recent push that removes the 
reference to the `std::optional`.

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


[Lldb-commits] [lldb] 65c25a4 - [lldb][test] Skip TestDAP_commands.py test due to flakiness

2024-02-15 Thread Jordan Rupprecht via lldb-commits

Author: Jordan Rupprecht
Date: 2024-02-15T11:51:44-08:00
New Revision: 65c25a4c40865a0e460c0fecb1b33f7cf7455573

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

LOG: [lldb][test] Skip TestDAP_commands.py test due to flakiness

Added: 


Modified: 
lldb/test/API/tools/lldb-dap/commands/TestDAP_commands.py

Removed: 




diff  --git a/lldb/test/API/tools/lldb-dap/commands/TestDAP_commands.py 
b/lldb/test/API/tools/lldb-dap/commands/TestDAP_commands.py
index 226b9385fe719a..8dcda75d0a4520 100644
--- a/lldb/test/API/tools/lldb-dap/commands/TestDAP_commands.py
+++ b/lldb/test/API/tools/lldb-dap/commands/TestDAP_commands.py
@@ -1,4 +1,5 @@
 import os
+import unittest
 
 import dap_server
 import lldbdap_testcase
@@ -6,6 +7,7 @@
 from lldbsuite.test.decorators import *
 
 
+@unittest.skip("https://llvm.org/PR81686";)
 class TestDAP_commands(lldbdap_testcase.DAPTestCaseBase):
 def test_command_directive_quiet_on_success(self):
 program = self.getBuildArtifact("a.out")



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


[Lldb-commits] [lldb] Re-land [lldb-dap] Add support for data breakpoint. (PR #81909)

2024-02-15 Thread Zequan Wu via lldb-commits

https://github.com/ZequanWu updated 
https://github.com/llvm/llvm-project/pull/81909

>From d95a420ef100d0e73f8ff829926fc3f3d0708386 Mon Sep 17 00:00:00 2001
From: Zequan Wu 
Date: Thu, 15 Feb 2024 14:29:18 -0500
Subject: [PATCH] [lldb-dap] Add support for data breakpoint.

This implements functionality to handle DataBreakpointInfo request and 
SetDataBreakpoints request.
---
 .../test/tools/lldb-dap/dap_server.py |  47 +++
 .../tools/lldb-dap/databreakpoint/Makefile|   3 +
 .../TestDAP_setDataBreakpoints.py | 131 +++
 .../tools/lldb-dap/databreakpoint/main.cpp|  17 +
 lldb/tools/lldb-dap/CMakeLists.txt|   1 +
 lldb/tools/lldb-dap/DAPForward.h  |   2 +
 lldb/tools/lldb-dap/Watchpoint.cpp|  48 +++
 lldb/tools/lldb-dap/Watchpoint.h  |  34 ++
 lldb/tools/lldb-dap/lldb-dap.cpp  | 336 --
 9 files changed, 585 insertions(+), 34 deletions(-)
 create mode 100644 lldb/test/API/tools/lldb-dap/databreakpoint/Makefile
 create mode 100644 
lldb/test/API/tools/lldb-dap/databreakpoint/TestDAP_setDataBreakpoints.py
 create mode 100644 lldb/test/API/tools/lldb-dap/databreakpoint/main.cpp
 create mode 100644 lldb/tools/lldb-dap/Watchpoint.cpp
 create mode 100644 lldb/tools/lldb-dap/Watchpoint.h

diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
index bb863bb8719176..27a76a652f4063 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
@@ -501,6 +501,18 @@ def get_local_variable_value(self, name, frameIndex=0, 
threadId=None):
 return variable["value"]
 return None
 
+def get_local_variable_child(self, name, child_name, frameIndex=0, 
threadId=None):
+local = self.get_local_variable(name, frameIndex, threadId)
+if local["variablesReference"] == 0:
+return None
+children = self.request_variables(local["variablesReference"])["body"][
+"variables"
+]
+for child in children:
+if child["name"] == child_name:
+return child
+return None
+
 def replay_packets(self, replay_file_path):
 f = open(replay_file_path, "r")
 mode = "invalid"
@@ -895,6 +907,41 @@ def request_setFunctionBreakpoints(self, names, 
condition=None, hitCondition=Non
 }
 return self.send_recv(command_dict)
 
+def request_dataBreakpointInfo(
+self, variablesReference, name, frameIndex=0, threadId=None
+):
+stackFrame = self.get_stackFrame(frameIndex=frameIndex, 
threadId=threadId)
+if stackFrame is None:
+return []
+args_dict = {
+"variablesReference": variablesReference,
+"name": name,
+"frameId": stackFrame["id"],
+}
+command_dict = {
+"command": "dataBreakpointInfo",
+"type": "request",
+"arguments": args_dict,
+}
+return self.send_recv(command_dict)
+
+def request_setDataBreakpoint(self, dataBreakpoints):
+"""dataBreakpoints is a list of dictionary with following fields:
+{
+dataId: (address in hex)/(size in bytes)
+accessType: read/write/readWrite
+[condition]: string
+[hitCondition]: string
+}
+"""
+args_dict = {"breakpoints": dataBreakpoints}
+command_dict = {
+"command": "setDataBreakpoints",
+"type": "request",
+"arguments": args_dict,
+}
+return self.send_recv(command_dict)
+
 def request_compileUnits(self, moduleId):
 args_dict = {"moduleId": moduleId}
 command_dict = {
diff --git a/lldb/test/API/tools/lldb-dap/databreakpoint/Makefile 
b/lldb/test/API/tools/lldb-dap/databreakpoint/Makefile
new file mode 100644
index 00..8b20bcb050
--- /dev/null
+++ b/lldb/test/API/tools/lldb-dap/databreakpoint/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules
diff --git 
a/lldb/test/API/tools/lldb-dap/databreakpoint/TestDAP_setDataBreakpoints.py 
b/lldb/test/API/tools/lldb-dap/databreakpoint/TestDAP_setDataBreakpoints.py
new file mode 100644
index 00..8b4f07a9054d74
--- /dev/null
+++ b/lldb/test/API/tools/lldb-dap/databreakpoint/TestDAP_setDataBreakpoints.py
@@ -0,0 +1,131 @@
+"""
+Test lldb-dap dataBreakpointInfo and setDataBreakpoints requests
+"""
+
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+import lldbdap_testcase
+
+
+class TestDAP_setDataBreakpoints(lldbdap_testcase.DAPTestCaseBase):
+def setUp(self):
+lldbdap_testcase.DAPTestCaseBase.setUp(self)
+self.accessTypes = ["read", "write", "readWrite"]
+
+@skipIfWindows
+@skipIfRemote
+def test_expression(self):
+"""Test

[Lldb-commits] [lldb] Re-land [lldb-dap] Add support for data breakpoint. (PR #81909)

2024-02-15 Thread Zequan Wu via lldb-commits

ZequanWu wrote:

DAP adds a new request `DataAddressBreakpointInfo` at 
https://github.com/microsoft/debug-adapter-protocol/pull/461 with  the 
following format to allow setting watchpoints at given address and size:
```
interface DataAddressBreakpointInfoRequest extends Request {
  command: 'DataAddressBreakpointInfo';

  arguments: DataAddressBreakpointInfoArguments;
}
interface DataAddressBreakpointInfoArguments {
  /**
   * The address of the data for which to obtain breakpoint information.
   * Treated as a hex value if prefixed with `0x`, or as a decimal value
   * otherwise.
   */
  address?: string;

  /**
   * If passed, requests breakpoint information for an exclusive byte range
   * rather than a single address. The range extends the given number of `bytes`
   * from the start `address`.
   * Treated as a hex value if prefixed with `0x`, or as a decimal value
   * otherwise.
   */
  bytes?: string;
}
```

This is kind of overlap with the existing made-up `${number of 
bytes}@${expression}`. If we choose to use the made-up, the new request seems 
not necessary to add because expression could be an address as well.

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


[Lldb-commits] [lldb] Re-land [lldb-dap] Add support for data breakpoint. (PR #81909)

2024-02-15 Thread via lldb-commits

github-actions[bot] wrote:




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



You can test this locally with the following command:


``bash
darker --check --diff -r 
e82659fff2f07b5ea1d94e0d8bcb9c540d6bede1...757013af5361f5bf0f486d7ac0ee2f6980248f15
 lldb/test/API/tools/lldb-dap/databreakpoint/TestDAP_setDataBreakpoints.py 
lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
``





View the diff from darker here.


``diff
--- test/API/tools/lldb-dap/databreakpoint/TestDAP_setDataBreakpoints.py
2024-02-15 19:31:01.00 +
+++ test/API/tools/lldb-dap/databreakpoint/TestDAP_setDataBreakpoints.py
2024-02-15 19:39:15.384210 +
@@ -33,14 +33,15 @@
 self.assertEquals(response_arr_2["body"]["accessTypes"], 
self.accessTypes)
 dataBreakpoints = [
 {"dataId": response_x["body"]["dataId"], "accessType": "write"},
 {"dataId": response_arr_2["body"]["dataId"], "accessType": 
"write"},
 ]
-set_response = self.dap_server.request_setDataBreakpoint(
-dataBreakpoints)
-self.assertEquals(set_response["body"]["breakpoints"], [
-  {"verified": True}, {"verified": True}])
+set_response = 
self.dap_server.request_setDataBreakpoint(dataBreakpoints)
+self.assertEquals(
+set_response["body"]["breakpoints"],
+[{"verified": True}, {"verified": True}],
+)
 
 self.continue_to_next_stop()
 x_val = self.dap_server.get_local_variable_value("x")
 i_val = self.dap_server.get_local_variable_value("i")
 self.assertEquals(x_val, "2")
@@ -77,14 +78,15 @@
 self.assertEquals(response_arr_2["body"]["accessTypes"], 
self.accessTypes)
 dataBreakpoints = [
 {"dataId": response_x["body"]["dataId"], "accessType": "write"},
 {"dataId": response_arr_2["body"]["dataId"], "accessType": 
"write"},
 ]
-set_response = self.dap_server.request_setDataBreakpoint(
-dataBreakpoints)
-self.assertEquals(set_response["body"]["breakpoints"], [
-  {"verified": True}, {"verified": True}])
+set_response = 
self.dap_server.request_setDataBreakpoint(dataBreakpoints)
+self.assertEquals(
+set_response["body"]["breakpoints"],
+[{"verified": True}, {"verified": True}],
+)
 
 self.continue_to_next_stop()
 x_val = self.dap_server.get_local_variable_value("x")
 i_val = self.dap_server.get_local_variable_value("i")
 self.assertEquals(x_val, "2")
@@ -106,14 +108,12 @@
 "dataId": response_x["body"]["dataId"],
 "accessType": "write",
 "hitCondition": "2",
 }
 ]
-set_response = self.dap_server.request_setDataBreakpoint(
-dataBreakpoints)
-self.assertEquals(set_response["body"]["breakpoints"], [
-  {"verified": True}])
+set_response = 
self.dap_server.request_setDataBreakpoint(dataBreakpoints)
+self.assertEquals(set_response["body"]["breakpoints"], [{"verified": 
True}])
 self.continue_to_next_stop()
 x_val = self.dap_server.get_local_variable_value("x")
 self.assertEquals(x_val, "3")
 
 # Test condition
@@ -122,12 +122,10 @@
 "dataId": response_x["body"]["dataId"],
 "accessType": "write",
 "condition": "x==10",
 }
 ]
-set_response = self.dap_server.request_setDataBreakpoint(
-dataBreakpoints)
-self.assertEquals(set_response["body"]["breakpoints"], [
-  {"verified": True}])
+set_response = 
self.dap_server.request_setDataBreakpoint(dataBreakpoints)
+self.assertEquals(set_response["body"]["breakpoints"], [{"verified": 
True}])
 self.continue_to_next_stop()
 x_val = self.dap_server.get_local_variable_value("x")
 self.assertEquals(x_val, "10")

``




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


[Lldb-commits] [lldb] Re-land [lldb-dap] Add support for data breakpoint. (PR #81909)

2024-02-15 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Zequan Wu (ZequanWu)


Changes

This implements functionality to handle DataBreakpointInfo request and 
SetDataBreakpoints request.

Previous commit 
https://github.com/llvm/llvm-project/commit/8c56e78ec531f0e2460213c20fff869b6b7add99
 was reverted because setting 1 byte watchpoint failed in the new test on 
ARM64. So, I changed the test to setting 4 byte watchpoint instead, and hope 
this won't break it again. It also adds the fixes from 
https://github.com/llvm/llvm-project/pull/81680.

---

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


9 Files Affected:

- (modified) lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py 
(+47) 
- (added) lldb/test/API/tools/lldb-dap/databreakpoint/Makefile (+3) 
- (added) 
lldb/test/API/tools/lldb-dap/databreakpoint/TestDAP_setDataBreakpoints.py 
(+133) 
- (added) lldb/test/API/tools/lldb-dap/databreakpoint/main.cpp (+17) 
- (modified) lldb/tools/lldb-dap/CMakeLists.txt (+1) 
- (modified) lldb/tools/lldb-dap/DAPForward.h (+2) 
- (added) lldb/tools/lldb-dap/Watchpoint.cpp (+48) 
- (added) lldb/tools/lldb-dap/Watchpoint.h (+34) 
- (modified) lldb/tools/lldb-dap/lldb-dap.cpp (+302-34) 


``diff
diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
index bb863bb8719176..27a76a652f4063 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
@@ -501,6 +501,18 @@ def get_local_variable_value(self, name, frameIndex=0, 
threadId=None):
 return variable["value"]
 return None
 
+def get_local_variable_child(self, name, child_name, frameIndex=0, 
threadId=None):
+local = self.get_local_variable(name, frameIndex, threadId)
+if local["variablesReference"] == 0:
+return None
+children = self.request_variables(local["variablesReference"])["body"][
+"variables"
+]
+for child in children:
+if child["name"] == child_name:
+return child
+return None
+
 def replay_packets(self, replay_file_path):
 f = open(replay_file_path, "r")
 mode = "invalid"
@@ -895,6 +907,41 @@ def request_setFunctionBreakpoints(self, names, 
condition=None, hitCondition=Non
 }
 return self.send_recv(command_dict)
 
+def request_dataBreakpointInfo(
+self, variablesReference, name, frameIndex=0, threadId=None
+):
+stackFrame = self.get_stackFrame(frameIndex=frameIndex, 
threadId=threadId)
+if stackFrame is None:
+return []
+args_dict = {
+"variablesReference": variablesReference,
+"name": name,
+"frameId": stackFrame["id"],
+}
+command_dict = {
+"command": "dataBreakpointInfo",
+"type": "request",
+"arguments": args_dict,
+}
+return self.send_recv(command_dict)
+
+def request_setDataBreakpoint(self, dataBreakpoints):
+"""dataBreakpoints is a list of dictionary with following fields:
+{
+dataId: (address in hex)/(size in bytes)
+accessType: read/write/readWrite
+[condition]: string
+[hitCondition]: string
+}
+"""
+args_dict = {"breakpoints": dataBreakpoints}
+command_dict = {
+"command": "setDataBreakpoints",
+"type": "request",
+"arguments": args_dict,
+}
+return self.send_recv(command_dict)
+
 def request_compileUnits(self, moduleId):
 args_dict = {"moduleId": moduleId}
 command_dict = {
diff --git a/lldb/test/API/tools/lldb-dap/databreakpoint/Makefile 
b/lldb/test/API/tools/lldb-dap/databreakpoint/Makefile
new file mode 100644
index 00..8b20bcb050
--- /dev/null
+++ b/lldb/test/API/tools/lldb-dap/databreakpoint/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules
diff --git 
a/lldb/test/API/tools/lldb-dap/databreakpoint/TestDAP_setDataBreakpoints.py 
b/lldb/test/API/tools/lldb-dap/databreakpoint/TestDAP_setDataBreakpoints.py
new file mode 100644
index 00..02afbe4180378d
--- /dev/null
+++ b/lldb/test/API/tools/lldb-dap/databreakpoint/TestDAP_setDataBreakpoints.py
@@ -0,0 +1,133 @@
+"""
+Test lldb-dap dataBreakpointInfo and setDataBreakpoints requests
+"""
+
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+import lldbdap_testcase
+
+
+class TestDAP_setDataBreakpoints(lldbdap_testcase.DAPTestCaseBase):
+def setUp(self):
+lldbdap_testcase.DAPTestCaseBase.setUp(self)
+self.accessTypes = ["read", "write", "readWrite"]
+
+@skipIfWindows
+@skipIfRemote
+def test_expression(self):
+"""Tests setting da

[Lldb-commits] [lldb] Re-land [lldb-dap] Add support for data breakpoint. (PR #81909)

2024-02-15 Thread Zequan Wu via lldb-commits

https://github.com/ZequanWu created 
https://github.com/llvm/llvm-project/pull/81909

This implements functionality to handle DataBreakpointInfo request and 
SetDataBreakpoints request.

Previous commit 
https://github.com/llvm/llvm-project/commit/8c56e78ec531f0e2460213c20fff869b6b7add99
 was reverted because setting 1 byte watchpoint failed in the new test on 
ARM64. So, I changed the test to setting 4 byte watchpoint instead, and hope 
this won't break it again. It also adds the fixes from 
https://github.com/llvm/llvm-project/pull/81680.

>From 757013af5361f5bf0f486d7ac0ee2f6980248f15 Mon Sep 17 00:00:00 2001
From: Zequan Wu 
Date: Thu, 15 Feb 2024 14:29:18 -0500
Subject: [PATCH] [lldb-dap] Add support for data breakpoint.

This implements functionality to handle DataBreakpointInfo request and 
SetDataBreakpoints request.
---
 .../test/tools/lldb-dap/dap_server.py |  47 +++
 .../tools/lldb-dap/databreakpoint/Makefile|   3 +
 .../TestDAP_setDataBreakpoints.py | 133 +++
 .../tools/lldb-dap/databreakpoint/main.cpp|  17 +
 lldb/tools/lldb-dap/CMakeLists.txt|   1 +
 lldb/tools/lldb-dap/DAPForward.h  |   2 +
 lldb/tools/lldb-dap/Watchpoint.cpp|  48 +++
 lldb/tools/lldb-dap/Watchpoint.h  |  34 ++
 lldb/tools/lldb-dap/lldb-dap.cpp  | 336 --
 9 files changed, 587 insertions(+), 34 deletions(-)
 create mode 100644 lldb/test/API/tools/lldb-dap/databreakpoint/Makefile
 create mode 100644 
lldb/test/API/tools/lldb-dap/databreakpoint/TestDAP_setDataBreakpoints.py
 create mode 100644 lldb/test/API/tools/lldb-dap/databreakpoint/main.cpp
 create mode 100644 lldb/tools/lldb-dap/Watchpoint.cpp
 create mode 100644 lldb/tools/lldb-dap/Watchpoint.h

diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
index bb863bb8719176..27a76a652f4063 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
@@ -501,6 +501,18 @@ def get_local_variable_value(self, name, frameIndex=0, 
threadId=None):
 return variable["value"]
 return None
 
+def get_local_variable_child(self, name, child_name, frameIndex=0, 
threadId=None):
+local = self.get_local_variable(name, frameIndex, threadId)
+if local["variablesReference"] == 0:
+return None
+children = self.request_variables(local["variablesReference"])["body"][
+"variables"
+]
+for child in children:
+if child["name"] == child_name:
+return child
+return None
+
 def replay_packets(self, replay_file_path):
 f = open(replay_file_path, "r")
 mode = "invalid"
@@ -895,6 +907,41 @@ def request_setFunctionBreakpoints(self, names, 
condition=None, hitCondition=Non
 }
 return self.send_recv(command_dict)
 
+def request_dataBreakpointInfo(
+self, variablesReference, name, frameIndex=0, threadId=None
+):
+stackFrame = self.get_stackFrame(frameIndex=frameIndex, 
threadId=threadId)
+if stackFrame is None:
+return []
+args_dict = {
+"variablesReference": variablesReference,
+"name": name,
+"frameId": stackFrame["id"],
+}
+command_dict = {
+"command": "dataBreakpointInfo",
+"type": "request",
+"arguments": args_dict,
+}
+return self.send_recv(command_dict)
+
+def request_setDataBreakpoint(self, dataBreakpoints):
+"""dataBreakpoints is a list of dictionary with following fields:
+{
+dataId: (address in hex)/(size in bytes)
+accessType: read/write/readWrite
+[condition]: string
+[hitCondition]: string
+}
+"""
+args_dict = {"breakpoints": dataBreakpoints}
+command_dict = {
+"command": "setDataBreakpoints",
+"type": "request",
+"arguments": args_dict,
+}
+return self.send_recv(command_dict)
+
 def request_compileUnits(self, moduleId):
 args_dict = {"moduleId": moduleId}
 command_dict = {
diff --git a/lldb/test/API/tools/lldb-dap/databreakpoint/Makefile 
b/lldb/test/API/tools/lldb-dap/databreakpoint/Makefile
new file mode 100644
index 00..8b20bcb050
--- /dev/null
+++ b/lldb/test/API/tools/lldb-dap/databreakpoint/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules
diff --git 
a/lldb/test/API/tools/lldb-dap/databreakpoint/TestDAP_setDataBreakpoints.py 
b/lldb/test/API/tools/lldb-dap/databreakpoint/TestDAP_setDataBreakpoints.py
new file mode 100644
index 00..02afbe4180378d
--- /dev/null
+++ b/lldb/test/API/tools/lldb-dap/databreakpoint/TestDAP_setDataBreakpoints.py
@@ -0,0 +1,133 @@
+"""
+Test lldb-da

[Lldb-commits] [lldb] [lldb][progress] Add progress manager class (PR #81319)

2024-02-15 Thread Greg Clayton via lldb-commits

https://github.com/clayborg commented:

Just remove `static ProgressManager &InstanceImpl();` and inline the code into 
`static ProgressManager &Instance();` and this is good to go.

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


[Lldb-commits] [lldb] [lldb][progress] Add progress manager class (PR #81319)

2024-02-15 Thread Greg Clayton via lldb-commits


@@ -66,3 +67,41 @@ void Progress::ReportProgress() {
  m_debugger_id);
   }
 }
+
+ProgressManager &ProgressManager::InstanceImpl() {
+  static std::once_flag g_once_flag;
+  static ProgressManager *g_progress_manager = nullptr;
+  std::call_once(g_once_flag, []() {
+// NOTE: known leak to avoid global destructor chain issues.
+g_progress_manager = new ProgressManager();
+  });
+  return *g_progress_manager;
+}

clayborg wrote:

We probably don't need this function and we can just inline the contents into 
the `static ProgressManager &ProgressManager::Instance()` right?

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


[Lldb-commits] [lldb] [lldb][progress] Add progress manager class (PR #81319)

2024-02-15 Thread Greg Clayton via lldb-commits


@@ -66,3 +67,37 @@ void Progress::ReportProgress() {
  m_debugger_id);
   }
 }
+
+ProgressManager &ProgressManager::InstanceImpl() {
+  static std::once_flag g_once_flag;
+  static ProgressManager *g_progress_manager = nullptr;
+  std::call_once(g_once_flag, []() {
+// NOTE: known leak to avoid global destructor chain issues.
+g_progress_manager = new ProgressManager();
+  });
+  return *g_progress_manager;
+}
+
+ProgressManager::ProgressManager() : m_progress_category_map() {}
+
+ProgressManager::~ProgressManager() {}
+
+ProgressManager &ProgressManager::Instance() { return InstanceImpl(); }

clayborg wrote:

Remove `ProgressManager &ProgressManager::InstanceImpl()` and inline the code 
from that function in this function.

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


[Lldb-commits] [lldb] [lldb][progress] Add progress manager class (PR #81319)

2024-02-15 Thread Greg Clayton via lldb-commits


@@ -119,6 +120,32 @@ class Progress {
   bool m_complete = false;
 };
 
+/// A class used to group progress reports by category. This is done by using a
+/// map that maintains a refcount of each category of progress reports that 
have
+/// come in. Keeping track of progress reports this way will be done if a
+/// debugger is listening to the eBroadcastBitProgressByCategory broadcast bit.
+class ProgressManager {
+public:
+  ProgressManager();
+  ~ProgressManager();
+
+  static void Initialize();
+  static void Terminate();
+  // Control the refcount of the progress report category as needed
+  void Increment(std::string category);
+  void Decrement(std::string category);
+
+  // Public accessor for the class instance
+  static ProgressManager &Instance();
+
+private:
+  // Manage the class instance internally using a std::optional

clayborg wrote:

Is this comment out of date? I don't think we are using `std::optional` 
anymore

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


[Lldb-commits] [lldb] [lldb][progress] Add progress manager class (PR #81319)

2024-02-15 Thread Greg Clayton via lldb-commits

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


[Lldb-commits] [lldb] [lldb][progress] Add progress manager class (PR #81319)

2024-02-15 Thread Jonas Devlieghere via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb][progress] Add progress manager class (PR #81319)

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

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

>From f5ef07849c61ee9387f92376d5e1bd13bedc43e5 Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova 
Date: Thu, 8 Feb 2024 15:31:33 -0800
Subject: [PATCH 1/3] [lldb][progress] Add progress manager class

Per discussions from https://github.com/llvm/llvm-project/pull/81026,
it was decided that having a class that manages a map of progress
reports would be beneficial in order to categorize them. This class is a
part of the overall `Progress` class and utilizes a map that keeps a
count of how many times a progress report category has been sent. This
would be used with the new debugger broadcast bit added in
https://github.com/llvm/llvm-project/pull/81169 so that a user listening
with that bit will receive grouped progress reports.
---
 lldb/include/lldb/Core/Progress.h | 27 +++
 lldb/source/Core/Progress.cpp | 44 +++
 2 files changed, 71 insertions(+)

diff --git a/lldb/include/lldb/Core/Progress.h 
b/lldb/include/lldb/Core/Progress.h
index 5d882910246054..5e07789b0e5337 100644
--- a/lldb/include/lldb/Core/Progress.h
+++ b/lldb/include/lldb/Core/Progress.h
@@ -11,6 +11,7 @@
 
 #include "lldb/Utility/ConstString.h"
 #include "lldb/lldb-types.h"
+#include "llvm/ADT/StringMap.h"
 #include 
 #include 
 #include 
@@ -119,6 +120,32 @@ class Progress {
   bool m_complete = false;
 };
 
+/// A class used to group progress reports by category. This is done by using a
+/// map that maintains a refcount of each category of progress reports that 
have
+/// come in. Keeping track of progress reports this way will be done if a
+/// debugger is listening to the eBroadcastBitProgressByCategory broadcast bit.
+class ProgressManager {
+public:
+  ProgressManager();
+  ~ProgressManager();
+
+  static void Initialize();
+  static void Terminate();
+  // Control the refcount of the progress report category as needed
+  void Increment(std::string category);
+  void Decrement(std::string category);
+
+  // Public accessor for the class instance
+  static ProgressManager &Instance();
+
+private:
+  // Manage the class instance internally using a std::optional
+  static std::optional &InstanceImpl();
+
+  llvm::StringMap m_progress_category_map;
+  std::mutex m_progress_map_mutex;
+};
+
 } // namespace lldb_private
 
 #endif // LLDB_CORE_PROGRESS_H
diff --git a/lldb/source/Core/Progress.cpp b/lldb/source/Core/Progress.cpp
index 732efbc342b450..063e64a0ef499c 100644
--- a/lldb/source/Core/Progress.cpp
+++ b/lldb/source/Core/Progress.cpp
@@ -66,3 +66,47 @@ void Progress::ReportProgress() {
  m_debugger_id);
   }
 }
+
+void ProgressManager::Initialize() {
+  lldbassert(!InstanceImpl() && "A progress report manager already exists.");
+  InstanceImpl().emplace();
+}
+
+void ProgressManager::Terminate() {
+  lldbassert(InstanceImpl() &&
+ "A progress report manager has already been terminated.");
+  InstanceImpl().reset();
+}
+
+std::optional &ProgressManager::InstanceImpl() {
+  static std::optional g_progress_manager;
+  return g_progress_manager;
+}
+
+ProgressManager::ProgressManager() : m_progress_category_map() {}
+
+ProgressManager::~ProgressManager() {}
+
+ProgressManager &ProgressManager::Instance() { return *InstanceImpl(); }
+
+void ProgressManager::Increment(std::string title) {
+  std::lock_guard lock(m_progress_map_mutex);
+  auto pair = m_progress_category_map.insert(std::pair(title, 1));
+
+  // If pair.first is not empty after insertion it means that that
+  // category was entered for the first time and should not be incremented
+  if (!pair.second)
+++pair.first->second;
+}
+
+void ProgressManager::Decrement(std::string title) {
+  std::lock_guard lock(m_progress_map_mutex);
+  auto pos = m_progress_category_map.find(title);
+
+  if (pos == m_progress_category_map.end())
+return;
+
+  // Remove the category from the map if the refcount reaches 0
+  if (--pos->second == 0)
+m_progress_category_map.erase(title);
+}

>From 5a045966224a809b8a5726411e406f3526c0332c Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova 
Date: Tue, 13 Feb 2024 15:19:41 -0800
Subject: [PATCH 2/3] Use call_once in InstanceImpl(), leak progress manager
 object

In order to prevent potential crashes when LLDB is terminated,
this commit instead creates the instance for the progress manager in a
`call_once` within its initializer.
---
 lldb/include/lldb/Core/Progress.h |  9 +++--
 lldb/source/Core/Progress.cpp | 31 +--
 2 files changed, 16 insertions(+), 24 deletions(-)

diff --git a/lldb/include/lldb/Core/Progress.h 
b/lldb/include/lldb/Core/Progress.h
index 5e07789b0e5337..1f2d48c27d63d3 100644
--- a/lldb/include/lldb/Core/Progress.h
+++ b/lldb/include/lldb/Core/Progress.h
@@ -129,18 +129,15 @@ class ProgressManager {
   ProgressManager();
   ~ProgressManager();
 
-  static void Initialize();
-  static void Terminate();
-  // Control

[Lldb-commits] [lldb] [lldb][test] Remove expectedFailureIfFn (PR #81703)

2024-02-15 Thread Jordan Rupprecht via lldb-commits

rupprecht wrote:

I believe the old unittest framework may have been ignoring failures that 
happen during teardown.

I have started looking at https://github.com/llvm/llvm-project/issues/81686 a 
bit, but +1 to suppressing this temporarily -- I should be able to land that in 
a bit.

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


[Lldb-commits] [lldb] [lldb][test] Remove expectedFailureIfFn (PR #81703)

2024-02-15 Thread Jonas Devlieghere via lldb-commits

JDevlieghere wrote:

I can't imagine how the unit test framework could have made this flaky. It's 
more likely the test was flakey before and it went unnoticed. Can we 
(temporarily) disable the DAP test? 

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


[Lldb-commits] [lldb] [lldb][test] Remove expectedFailureIfFn (PR #81703)

2024-02-15 Thread Shubham Sandeep Rastogi via lldb-commits

rastogishubham wrote:

Hi @rupprecht,

It seems like this patch has still not fixed the issue in greendragon and the 
test is still flaky

https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/
https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake-matrix/
https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake-sanitized/

@JDevlieghere Do you have any idea as to why that is still happening?

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


[Lldb-commits] [lldb] [lldb][test] Remove expectedFailureIfFn (PR #81703)

2024-02-15 Thread David Spickett via lldb-commits

DavidSpickett wrote:

> @DavidSpickett what's the benefit of waiting for the arm bots to come back up?

If you give me the choice of more potential chaos or less, I'm always going to 
choose less :)

But yes this shouldn't be too difficult to pick out if it does fail.

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