[Lldb-commits] [lldb] [llvm] Add AArch64 support to the premerge tests (PR #155274)

2025-10-07 Thread Tom Stellard via lldb-commits

https://github.com/tstellar updated 
https://github.com/llvm/llvm-project/pull/155274

>From 57697a66cfdddf2028c7260f1ce61ecacc550d00 Mon Sep 17 00:00:00 2001
From: Tom Stellard 
Date: Mon, 25 Aug 2025 17:15:36 +
Subject: [PATCH 01/69] Add AArch64 support to the premerge tests

---
 .github/workflows/premerge.yaml | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/.github/workflows/premerge.yaml b/.github/workflows/premerge.yaml
index 9d925517a7211..6d83573702a79 100644
--- a/.github/workflows/premerge.yaml
+++ b/.github/workflows/premerge.yaml
@@ -28,7 +28,13 @@ jobs:
 if: >-
 github.repository_owner == 'llvm' &&
 (github.event_name != 'pull_request' || github.event.action != 
'closed')
-runs-on: llvm-premerge-linux-runners
+matrix:
+  runs-on:
+- llvm-premerge-linux-runners
+- depot-ubuntu-24.04-arm-64
+runs-on: ${{ matrix.runs-on }}
+container:
+  image: ${{ (startsWith(matrix.runs-on, 'depot-ubuntu-24.04-arm') && 
"ghcr.io/$GITHUB_REPOSITORY_OWNER/arm64v8/ci-ubuntu-24.04-agent" ) || null }}
 steps:
   - name: Checkout LLVM
 uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # 
v5.0.0

>From 8ba375b2d80614f4a769af1b417bf21f1712786c Mon Sep 17 00:00:00 2001
From: Tom Stellard 
Date: Mon, 25 Aug 2025 17:20:38 +
Subject: [PATCH 02/69] Fix typo

---
 .github/workflows/premerge.yaml | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/.github/workflows/premerge.yaml b/.github/workflows/premerge.yaml
index 6d83573702a79..f88dbc6143ab4 100644
--- a/.github/workflows/premerge.yaml
+++ b/.github/workflows/premerge.yaml
@@ -28,10 +28,11 @@ jobs:
 if: >-
 github.repository_owner == 'llvm' &&
 (github.event_name != 'pull_request' || github.event.action != 
'closed')
-matrix:
-  runs-on:
-- llvm-premerge-linux-runners
-- depot-ubuntu-24.04-arm-64
+strategy:
+  matrix:
+runs-on:
+  - llvm-premerge-linux-runners
+  - depot-ubuntu-24.04-arm-64
 runs-on: ${{ matrix.runs-on }}
 container:
   image: ${{ (startsWith(matrix.runs-on, 'depot-ubuntu-24.04-arm') && 
"ghcr.io/$GITHUB_REPOSITORY_OWNER/arm64v8/ci-ubuntu-24.04-agent" ) || null }}

>From af39d1af7635196606ceaeff6a2cf1db72e142e4 Mon Sep 17 00:00:00 2001
From: Tom Stellard 
Date: Mon, 25 Aug 2025 17:21:51 +
Subject: [PATCH 03/69] Fix quotes

---
 .github/workflows/premerge.yaml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.github/workflows/premerge.yaml b/.github/workflows/premerge.yaml
index f88dbc6143ab4..914713bb4a352 100644
--- a/.github/workflows/premerge.yaml
+++ b/.github/workflows/premerge.yaml
@@ -35,7 +35,7 @@ jobs:
   - depot-ubuntu-24.04-arm-64
 runs-on: ${{ matrix.runs-on }}
 container:
-  image: ${{ (startsWith(matrix.runs-on, 'depot-ubuntu-24.04-arm') && 
"ghcr.io/$GITHUB_REPOSITORY_OWNER/arm64v8/ci-ubuntu-24.04-agent" ) || null }}
+  image: ${{ (startsWith(matrix.runs-on, 'depot-ubuntu-24.04-arm') && 
'ghcr.io/$GITHUB_REPOSITORY_OWNER/arm64v8/ci-ubuntu-24.04-agent' ) || null }}
 steps:
   - name: Checkout LLVM
 uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # 
v5.0.0

>From 0330faf41115cab59d8667dbe77bf9414ea3455c Mon Sep 17 00:00:00 2001
From: Tom Stellard 
Date: Mon, 25 Aug 2025 17:24:18 +
Subject: [PATCH 04/69] Fix container name

---
 .github/workflows/premerge.yaml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.github/workflows/premerge.yaml b/.github/workflows/premerge.yaml
index 914713bb4a352..edb7248d792fe 100644
--- a/.github/workflows/premerge.yaml
+++ b/.github/workflows/premerge.yaml
@@ -35,7 +35,7 @@ jobs:
   - depot-ubuntu-24.04-arm-64
 runs-on: ${{ matrix.runs-on }}
 container:
-  image: ${{ (startsWith(matrix.runs-on, 'depot-ubuntu-24.04-arm') && 
'ghcr.io/$GITHUB_REPOSITORY_OWNER/arm64v8/ci-ubuntu-24.04-agent' ) || null }}
+  image: ${{ (startsWith(matrix.runs-on, 'depot-ubuntu-24.04-arm') && 
format('ghcr.io/{}/arm64v8/ci-ubuntu-24.04-agent',github.repository_owner) ) || 
null }}
 steps:
   - name: Checkout LLVM
 uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # 
v5.0.0

>From 0492ee60484cd594f80b6cadcb7ebc5755b6710c Mon Sep 17 00:00:00 2001
From: Tom Stellard 
Date: Mon, 25 Aug 2025 17:29:25 +
Subject: [PATCH 05/69] Fix format string

---
 .github/workflows/premerge.yaml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.github/workflows/premerge.yaml b/.github/workflows/premerge.yaml
index edb7248d792fe..28d79518bc1df 100644
--- a/.github/workflows/premerge.yaml
+++ b/.github/workflows/premerge.yaml
@@ -35,7 +35,7 @@ jobs:
   - depot-ubuntu-24.04-arm-64
 runs-on: ${{ matrix.runs-on }}
 container:
-  image: ${{ (startsWith(matrix.runs-on, 'depot-ubuntu-24.04-arm') && 
format('ghcr.io/{}/arm64v8/ci-ub

[Lldb-commits] [lldb] [LLDB][Stats] Calculate active time to first Bt (PR #161604)

2025-10-07 Thread Jacob Lalonde via lldb-commits


@@ -513,6 +518,63 @@ llvm::json::Value DebuggerStats::ReportStatistics(
   return std::move(global_stats);
 }
 
+void TargetStats::SetFirstBtTime(lldb::ProcessSP process_sp, Thread &thread) {
+  if (m_first_bt_time_set)
+return;
+
+  // Our goal here is to calculate the total active time to get to the first bt
+  // so this will be the target creation time, or the load core time plus all
+  // the time to load and index modules and their debug info.
+  double elapsed_time = 0.0;
+  // GetStackFrameCount can be expensive, but at this point we should
+  // have completed a BT successfully, so the frames should already
+  // exist.
+  for (size_t i = 0; i < thread.GetStackFrameCount(); ++i) {
+lldb::StackFrameSP frame_sp = thread.GetStackFrameAtIndex(i);
+if (!frame_sp)
+  continue;
+
+lldb::ModuleSP module_sp =
+frame_sp->GetSymbolContext(lldb::eSymbolContextModule).module_sp;
+if (!module_sp)
+  continue;
+
+// Add the time it took to load and index the module.
+elapsed_time += module_sp->GetSymtabParseTime().get().count();
+elapsed_time += module_sp->GetSymtabParseTime().get().count();
+
+// Add the time it took to load and index the debug info. Can create
+// false is very important here. We don't want this call to have any side
+// effects.
+SymbolFile *sym_file = module_sp->GetSymbolFile(/*can_create=*/false);
+if (!sym_file)
+  continue;
+
+elapsed_time += sym_file->GetDebugInfoParseTime().count();
+elapsed_time += sym_file->GetDebugInfoIndexTime().count();
+
+// Lastly, walk over all the symbol locators and add their time.
+for (const auto &entry : module_sp->GetSymbolLocatorStatistics().map) {
+  elapsed_time += entry.second;

Jlalond wrote:

I didn't consider the symbol locator may have ran and no symbol was found.

https://github.com/llvm/llvm-project/pull/161604
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Make SBBreakpoint/SBBreakpointLocation.SetCondition(nullptr) work again. (PR #162370)

2025-10-07 Thread via lldb-commits

https://github.com/jimingham updated 
https://github.com/llvm/llvm-project/pull/162370

>From ee58ec0f67b5ef70d7c11756f5931ad08ed7c4dc Mon Sep 17 00:00:00 2001
From: Jim Ingham 
Date: Tue, 7 Oct 2025 13:44:45 -0700
Subject: [PATCH 1/5] Make
 SBBreakpoint/SBBreakpointLocation.SetCondition(nullptr) work again.

The addition of the StopCondition in the lldb_private layer meant that
clearing a breakpoint condition with:

sb_break.SetCondition(nullptr);

now crashes.  Also, GetCondition for an empty condition used to return
a nullptr, but now it returns "".

This patch fixes that crash and makes the SB GetCondition always return
nullptr for an empty condition.
---
 lldb/source/API/SBBreakpoint.cpp  | 11 ++-
 lldb/source/API/SBBreakpointLocation.cpp  | 11 ++-
 .../BreakpointClearConditionTest.cpp  | 85 +++
 lldb/unittests/Breakpoint/CMakeLists.txt  |  7 +-
 4 files changed, 109 insertions(+), 5 deletions(-)
 create mode 100644 lldb/unittests/Breakpoint/BreakpointClearConditionTest.cpp

diff --git a/lldb/source/API/SBBreakpoint.cpp b/lldb/source/API/SBBreakpoint.cpp
index 07c0a2ea907ba..23dba462478c9 100644
--- a/lldb/source/API/SBBreakpoint.cpp
+++ b/lldb/source/API/SBBreakpoint.cpp
@@ -275,7 +275,11 @@ void SBBreakpoint::SetCondition(const char *condition) {
   if (bkpt_sp) {
 std::lock_guard guard(
 bkpt_sp->GetTarget().GetAPIMutex());
-bkpt_sp->SetCondition(StopCondition(condition));
+// Treat a null pointer as resetting the condition.
+if (!condition)
+  bkpt_sp->SetCondition(StopCondition());
+else
+  bkpt_sp->SetCondition(StopCondition(condition));
   }
 }
 
@@ -288,7 +292,10 @@ const char *SBBreakpoint::GetCondition() {
 
   std::lock_guard guard(
   bkpt_sp->GetTarget().GetAPIMutex());
-  return ConstString(bkpt_sp->GetCondition().GetText()).GetCString();
+  StopCondition cond = bkpt_sp->GetCondition();
+  if (!cond)
+return nullptr;
+  return ConstString(cond.GetText()).GetCString();
 }
 
 void SBBreakpoint::SetAutoContinue(bool auto_continue) {
diff --git a/lldb/source/API/SBBreakpointLocation.cpp 
b/lldb/source/API/SBBreakpointLocation.cpp
index e786435c4f8af..2feaa5c805a15 100644
--- a/lldb/source/API/SBBreakpointLocation.cpp
+++ b/lldb/source/API/SBBreakpointLocation.cpp
@@ -160,7 +160,11 @@ void SBBreakpointLocation::SetCondition(const char 
*condition) {
   if (loc_sp) {
 std::lock_guard guard(
 loc_sp->GetTarget().GetAPIMutex());
-loc_sp->SetCondition(StopCondition(condition));
+// Treat a nullptr as clearing the condition
+if (!condition)
+  loc_sp->SetCondition(StopCondition());
+else
+  loc_sp->SetCondition(StopCondition(condition));
   }
 }
 
@@ -173,7 +177,10 @@ const char *SBBreakpointLocation::GetCondition() {
 
   std::lock_guard guard(
   loc_sp->GetTarget().GetAPIMutex());
-  return ConstString(loc_sp->GetCondition().GetText()).GetCString();
+  StopCondition cond = loc_sp->GetCondition();
+  if (!cond)
+return nullptr;
+  return ConstString(cond.GetText()).GetCString();
 }
 
 void SBBreakpointLocation::SetAutoContinue(bool auto_continue) {
diff --git a/lldb/unittests/Breakpoint/BreakpointClearConditionTest.cpp 
b/lldb/unittests/Breakpoint/BreakpointClearConditionTest.cpp
new file mode 100644
index 0..688c85a4a711f
--- /dev/null
+++ b/lldb/unittests/Breakpoint/BreakpointClearConditionTest.cpp
@@ -0,0 +1,85 @@
+//===-- BreakpointClearConditionTest.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/API/SBBreakpoint.h"
+#include "lldb/API/SBBreakpointLocation.h"
+#include "lldb/API/SBDebugger.h"
+#include "lldb/API/SBTarget.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 BreakpointClearConditionTest : public ::testing::Test {
+public:
+  void SetUp() override {
+std::call_once(TestUtilities::g_debugger_initialize_flag,
+   []() { SBDebugger::Initialize(); });
+  };
+
+  SBDebugger m_sb_debugger;
+  SubsystemRAII subsystems;
+};
+
+template
+void test_condition(T sb_object) {
+  const char *in_cond_str = "Here is a condition";
+  sb_object.SetC

[Lldb-commits] [lldb] [lldb] Fix stepping out if the return address is not allowed to stop at (PR #161982)

2025-10-07 Thread Igor Kudrin via lldb-commits

https://github.com/igorkudrin edited 
https://github.com/llvm/llvm-project/pull/161982
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Make SBBreakpoint/SBBreakpointLocation.SetCondition(nullptr) work again. (PR #162370)

2025-10-07 Thread via lldb-commits

https://github.com/jimingham updated 
https://github.com/llvm/llvm-project/pull/162370

>From ee58ec0f67b5ef70d7c11756f5931ad08ed7c4dc Mon Sep 17 00:00:00 2001
From: Jim Ingham 
Date: Tue, 7 Oct 2025 13:44:45 -0700
Subject: [PATCH 1/2] Make
 SBBreakpoint/SBBreakpointLocation.SetCondition(nullptr) work again.

The addition of the StopCondition in the lldb_private layer meant that
clearing a breakpoint condition with:

sb_break.SetCondition(nullptr);

now crashes.  Also, GetCondition for an empty condition used to return
a nullptr, but now it returns "".

This patch fixes that crash and makes the SB GetCondition always return
nullptr for an empty condition.
---
 lldb/source/API/SBBreakpoint.cpp  | 11 ++-
 lldb/source/API/SBBreakpointLocation.cpp  | 11 ++-
 .../BreakpointClearConditionTest.cpp  | 85 +++
 lldb/unittests/Breakpoint/CMakeLists.txt  |  7 +-
 4 files changed, 109 insertions(+), 5 deletions(-)
 create mode 100644 lldb/unittests/Breakpoint/BreakpointClearConditionTest.cpp

diff --git a/lldb/source/API/SBBreakpoint.cpp b/lldb/source/API/SBBreakpoint.cpp
index 07c0a2ea907ba..23dba462478c9 100644
--- a/lldb/source/API/SBBreakpoint.cpp
+++ b/lldb/source/API/SBBreakpoint.cpp
@@ -275,7 +275,11 @@ void SBBreakpoint::SetCondition(const char *condition) {
   if (bkpt_sp) {
 std::lock_guard guard(
 bkpt_sp->GetTarget().GetAPIMutex());
-bkpt_sp->SetCondition(StopCondition(condition));
+// Treat a null pointer as resetting the condition.
+if (!condition)
+  bkpt_sp->SetCondition(StopCondition());
+else
+  bkpt_sp->SetCondition(StopCondition(condition));
   }
 }
 
@@ -288,7 +292,10 @@ const char *SBBreakpoint::GetCondition() {
 
   std::lock_guard guard(
   bkpt_sp->GetTarget().GetAPIMutex());
-  return ConstString(bkpt_sp->GetCondition().GetText()).GetCString();
+  StopCondition cond = bkpt_sp->GetCondition();
+  if (!cond)
+return nullptr;
+  return ConstString(cond.GetText()).GetCString();
 }
 
 void SBBreakpoint::SetAutoContinue(bool auto_continue) {
diff --git a/lldb/source/API/SBBreakpointLocation.cpp 
b/lldb/source/API/SBBreakpointLocation.cpp
index e786435c4f8af..2feaa5c805a15 100644
--- a/lldb/source/API/SBBreakpointLocation.cpp
+++ b/lldb/source/API/SBBreakpointLocation.cpp
@@ -160,7 +160,11 @@ void SBBreakpointLocation::SetCondition(const char 
*condition) {
   if (loc_sp) {
 std::lock_guard guard(
 loc_sp->GetTarget().GetAPIMutex());
-loc_sp->SetCondition(StopCondition(condition));
+// Treat a nullptr as clearing the condition
+if (!condition)
+  loc_sp->SetCondition(StopCondition());
+else
+  loc_sp->SetCondition(StopCondition(condition));
   }
 }
 
@@ -173,7 +177,10 @@ const char *SBBreakpointLocation::GetCondition() {
 
   std::lock_guard guard(
   loc_sp->GetTarget().GetAPIMutex());
-  return ConstString(loc_sp->GetCondition().GetText()).GetCString();
+  StopCondition cond = loc_sp->GetCondition();
+  if (!cond)
+return nullptr;
+  return ConstString(cond.GetText()).GetCString();
 }
 
 void SBBreakpointLocation::SetAutoContinue(bool auto_continue) {
diff --git a/lldb/unittests/Breakpoint/BreakpointClearConditionTest.cpp 
b/lldb/unittests/Breakpoint/BreakpointClearConditionTest.cpp
new file mode 100644
index 0..688c85a4a711f
--- /dev/null
+++ b/lldb/unittests/Breakpoint/BreakpointClearConditionTest.cpp
@@ -0,0 +1,85 @@
+//===-- BreakpointClearConditionTest.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/API/SBBreakpoint.h"
+#include "lldb/API/SBBreakpointLocation.h"
+#include "lldb/API/SBDebugger.h"
+#include "lldb/API/SBTarget.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 BreakpointClearConditionTest : public ::testing::Test {
+public:
+  void SetUp() override {
+std::call_once(TestUtilities::g_debugger_initialize_flag,
+   []() { SBDebugger::Initialize(); });
+  };
+
+  SBDebugger m_sb_debugger;
+  SubsystemRAII subsystems;
+};
+
+template
+void test_condition(T sb_object) {
+  const char *in_cond_str = "Here is a condition";
+  sb_object.SetC

[Lldb-commits] [lldb] [lldb-dap] Add stdio redirection for integrated and external terminals (PR #161089)

2025-10-07 Thread Jonas Devlieghere via lldb-commits


@@ -143,6 +148,73 @@ static void PrintVersion() {
   llvm::outs() << "liblldb: " << lldb::SBDebugger::GetVersionString() << '\n';
 }
 
+#if not defined(_WIN32)
+struct FDGroup {
+  std::vector fds;
+  bool read = false;
+  bool write = false;
+};
+
+static llvm::Error RedirectToFile(const FDGroup &fdg, llvm::StringRef file) {
+  if (!fdg.read && !fdg.write)
+return llvm::Error::success();
+  int flags = 0;
+  if (fdg.read && fdg.write)
+flags = O_NOCTTY | O_CREAT | O_RDWR;
+  else if (fdg.read)
+flags = O_NOCTTY | O_RDONLY;
+  else
+flags = O_NOCTTY | O_CREAT | O_WRONLY | O_TRUNC;

JDevlieghere wrote:

Maybe consider making this `FDGroup::GetFlags()` and have some early returns to 
avoid all the else cases? Something like:

```
int GetFlags() const {
  if (fdg.read && fdg.write)
return O_NOCTTY | O_CREAT | O_RDWR;
  if (fdg.read)
return O_NOCTTY | O_RDONLY;
  return O_NOCTTY | O_CREAT | O_WRONLY | O_TRUNC;
} 
``` 

https://github.com/llvm/llvm-project/pull/161089
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Make SBBreakpoint/SBBreakpointLocation.SetCondition(nullptr) work again. (PR #162370)

2025-10-07 Thread Jonas Devlieghere via lldb-commits


@@ -0,0 +1,85 @@
+//===-- BreakpointClearConditionTest.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/API/SBBreakpoint.h"
+#include "lldb/API/SBBreakpointLocation.h"
+#include "lldb/API/SBDebugger.h"
+#include "lldb/API/SBTarget.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 BreakpointClearConditionTest : public ::testing::Test {
+public:
+  void SetUp() override {
+std::call_once(TestUtilities::g_debugger_initialize_flag,
+   []() { SBDebugger::Initialize(); });
+  };
+
+  SBDebugger m_sb_debugger;
+  SubsystemRAII subsystems;
+};
+
+template
+void test_condition(T sb_object) {
+  const char *in_cond_str = "Here is a condition";
+  sb_object.SetCondition(in_cond_str);
+  // Make sure we set the condition correctly:
+  const char *out_cond_str = sb_object.GetCondition();
+  EXPECT_STREQ(in_cond_str, out_cond_str);
+  // Now unset it by passing in nullptr and make sure that works:
+  const char *empty_tokens[2] = {nullptr, ""};
+  for (auto token : empty_tokens) {
+sb_object.SetCondition(token);
+out_cond_str = sb_object.GetCondition();
+// And make sure an unset condition returns nullptr:
+EXPECT_EQ(nullptr, out_cond_str);
+  }  
+}
+
+TEST_F(BreakpointClearConditionTest, BreakpointClearConditionTest) {
+  // Set up the debugger, make sure that was done properly.
+  m_sb_debugger = SBDebugger::Create(false);
+
+  // Create target
+  SBTarget sb_target;
+  SBError error;
+  sb_target = m_sb_debugger.CreateTarget("", "x86_64-apple-macosx-", 
"remote-macosx",
+   /*add_dependent=*/ false, error);
+
+  EXPECT_EQ(sb_target.IsValid(), true);
+
+  // Create breakpoint
+  SBBreakpoint sb_breakpoint =
+  sb_target.BreakpointCreateByAddress(0xDEADBEEF);
+  test_condition(sb_breakpoint);
+  
+  // Address breakpoints always have one location, so we can also use this
+  // to test the location:
+  SBBreakpointLocation sb_loc = sb_breakpoint.GetLocationAtIndex(0);
+  EXPECT_EQ(sb_loc.IsValid(), true);
+  test_condition(sb_loc);
+  
+}

JDevlieghere wrote:

You will have to move this test in the `unittests/API/` directory. You cannot 
have a unit test that links both the public and the private API. 

https://github.com/llvm/llvm-project/pull/162370
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [LLDB][Stats] Calculate active time to first Bt (PR #161604)

2025-10-07 Thread Greg Clayton via lldb-commits


@@ -513,6 +518,63 @@ llvm::json::Value DebuggerStats::ReportStatistics(
   return std::move(global_stats);
 }
 
+void TargetStats::SetFirstBtTime(lldb::ProcessSP process_sp, Thread &thread) {
+  if (m_first_bt_time_set)

clayborg wrote:

use `std::once` with the `std::once_flag`

https://github.com/llvm/llvm-project/pull/161604
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [LLDB][Stats] Calculate active time to first Bt (PR #161604)

2025-10-07 Thread Greg Clayton via lldb-commits


@@ -513,6 +518,63 @@ llvm::json::Value DebuggerStats::ReportStatistics(
   return std::move(global_stats);
 }
 
+void TargetStats::SetFirstBtTime(lldb::ProcessSP process_sp, Thread &thread) {

clayborg wrote:

No need to pass a process into this function, the thread has access to its 
process if it is needed.

https://github.com/llvm/llvm-project/pull/161604
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits