https://github.com/jimingham created 
https://github.com/llvm/llvm-project/pull/181414

Don't use variables after a std::move...

We didn't have a test asserting that changing the condition actually works, so 
I also added that.

>From f7e6d224b22ee9eb6bbc2df7f4a2f4a835690496 Mon Sep 17 00:00:00 2001
From: Jim Ingham <[email protected]>
Date: Fri, 13 Feb 2026 12:17:40 -0800
Subject: [PATCH] Fix a thinko in calculating the hash for a StopCondition.

---
 lldb/include/lldb/Breakpoint/StopCondition.h  |  2 +-
 .../TestBreakpointConditions.py               | 33 +++++++++++++++++++
 2 files changed, 34 insertions(+), 1 deletion(-)

diff --git a/lldb/include/lldb/Breakpoint/StopCondition.h 
b/lldb/include/lldb/Breakpoint/StopCondition.h
index 485a615368400..9106d57435af5 100644
--- a/lldb/include/lldb/Breakpoint/StopCondition.h
+++ b/lldb/include/lldb/Breakpoint/StopCondition.h
@@ -30,7 +30,7 @@ class StopCondition {
   void SetText(std::string text) {
     static std::hash<std::string> hasher;
     m_text = std::move(text);
-    m_hash = hasher(text);
+    m_hash = hasher(m_text);
   }
 
   size_t GetHash() const { return m_hash; }
diff --git 
a/lldb/test/API/functionalities/breakpoint/breakpoint_conditions/TestBreakpointConditions.py
 
b/lldb/test/API/functionalities/breakpoint/breakpoint_conditions/TestBreakpointConditions.py
index a4c9c49bc89b6..324b38602cf88 100644
--- 
a/lldb/test/API/functionalities/breakpoint/breakpoint_conditions/TestBreakpointConditions.py
+++ 
b/lldb/test/API/functionalities/breakpoint/breakpoint_conditions/TestBreakpointConditions.py
@@ -41,6 +41,12 @@ def test_breakpoint_invalid_condition_and_python_api(self):
         self.build()
         self.breakpoint_invalid_conditions_python()
 
+    @add_test_categories(["pyapi"])
+    def test_breakpoint_condition_changes(self):
+        """Use Python APIs to set breakpoint conditions."""
+        self.build()
+        self.breakpoint_condition_changes()
+
     def setUp(self):
         # Call super's setUp().
         TestBase.setUp(self)
@@ -259,3 +265,30 @@ def breakpoint_invalid_conditions_python(self):
 
         # The hit count for the breakpoint should be 1.
         self.assertEqual(breakpoint.GetHitCount(), 1)
+
+    def breakpoint_condition_changes(self):
+        target, process, thread, bkpt = lldbutil.run_to_source_breakpoint(
+            self,
+            "// a.1. -> b.1. -> c.1.",
+            lldb.SBFileSpec("main.c"))
+
+        cond_bp = target.BreakpointCreateByName("a")
+        cond_bp.SetCondition("val == 1")
+        threads = lldbutil.continue_to_breakpoint(process, cond_bp)
+        self.assertEqual(len(threads), 1, "Hit one thread")
+        self.assertEqual(threads[0].id, thread.id,"Hit our thread")
+
+        val = thread.frames[0].FindVariable("val")
+        self.assertEqual(val.GetValueAsSigned(), 1, "val is right")
+
+        # Now change the condition, continue and make sure we hit it again:
+
+        cond_bp.SetCondition("val == 3")
+
+        threads = lldbutil.continue_to_breakpoint(process, cond_bp)
+        self.assertEqual(len(threads), 1, "Hit one thread")
+        self.assertEqual(threads[0].id, thread.id,"Hit our thread")
+
+        val = thread.frames[0].FindVariable("val")
+        self.assertEqual(val.GetValueAsSigned(), 3, "val is right")
+        

_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to