diff options
| author | jimingham <jingham@apple.com> | 2026-02-05 15:03:52 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-02-05 15:03:52 -0800 |
| commit | 124c8b4054fd4fe8234611a367d50b5a62f5903e (patch) | |
| tree | 1d9e15b6e41668d005b903b57963c3def11439ec /lldb/test/API/functionalities | |
| parent | e3a09dd13b6ef8f386fbfa83289b759536f5ccfc (diff) | |
| download | llvm-124c8b4054fd4fe8234611a367d50b5a62f5903e.tar.gz llvm-124c8b4054fd4fe8234611a367d50b5a62f5903e.tar.bz2 llvm-124c8b4054fd4fe8234611a367d50b5a62f5903e.zip | |
Fix the modal private state thread we use for running expressions on the private state thread (#179799)
We have a problem when some code on the private state thread needs to
run an expression. The private state thread is the one that fetches
"raw" events from the Process Plugin and decides how to handle them. But
if the private state thread needs to fetch the processed events to drive
running an expression, it can't also be the thread processing the raw
events.
We solve this by swapping in a modal private state thread just to handle
the events from the expression evaluation. That worked until you could
cause the expression evaluation to happen from Python, because then it
wasn't just the fetching of events that matter, but also the state of
the process and the state of the runlocks. The modal private state
thread is really a modal version of the thread and its associated state.
This patch gathers all the relevant control parameters into a structure
which we can swap in and out when needed.
It also adds a test using the new "was_hit" breakpoint resolver
affordance, which, since it acts as an asynchronous breakpoint callback,
gets run on the private state thread, showing that with the change we
can call expressions in the `was_hit` callback without problems.
Diffstat (limited to 'lldb/test/API/functionalities')
3 files changed, 27 insertions, 0 deletions
diff --git a/lldb/test/API/functionalities/breakpoint/scripted_bkpt/was_hit/TestWasHit.py b/lldb/test/API/functionalities/breakpoint/scripted_bkpt/was_hit/TestWasHit.py index 2e176239facf..ac820b8d65be 100644 --- a/lldb/test/API/functionalities/breakpoint/scripted_bkpt/was_hit/TestWasHit.py +++ b/lldb/test/API/functionalities/breakpoint/scripted_bkpt/was_hit/TestWasHit.py @@ -65,6 +65,15 @@ class TestWasHit(TestBase): ) self.assertEqual(thread.stop_reason_data[1], 1, "First location hit is 1") + # Check that we did increment our global: + values = target.FindGlobalVariables("g_change_me", 2, lldb.eSymbolTypeCode) + self.assertEqual(values.GetSize(), 1, "Got the change me global") + change_me = values.GetValueAtIndex(0) + change_me_value = 1 + self.assertEqual( + change_me.signed, change_me_value, "g_change_me had the right value" + ) + for loc in [3, 4]: process.Continue() self.assertEqual( @@ -76,6 +85,10 @@ class TestWasHit(TestBase): self.assertEqual( thread.stop_reason_data[1], loc, f"Hit the right location: {loc}" ) + change_me_value += 1 + self.assertEqual( + change_me.signed, change_me_value, "g_change_me was updated correctly" + ) # At this point we should have hit three of the four locations, and not location 1.2. # Check that that is true, and that the descriptions for the location are the ones diff --git a/lldb/test/API/functionalities/breakpoint/scripted_bkpt/was_hit/bkpt_resolver.py b/lldb/test/API/functionalities/breakpoint/scripted_bkpt/was_hit/bkpt_resolver.py index acc8513e3e3e..0ddbf832c37c 100644 --- a/lldb/test/API/functionalities/breakpoint/scripted_bkpt/was_hit/bkpt_resolver.py +++ b/lldb/test/API/functionalities/breakpoint/scripted_bkpt/was_hit/bkpt_resolver.py @@ -43,6 +43,15 @@ class FacadeExample: if tmp_loc == self.loc_to_miss: return None + # Make sure we can call a function here as well: + options = lldb.SBExpressionOptions() + options.SetStopOthers(True) + options.SetTryAllThreads(False) + + result = frame.EvaluateExpression("change_him()", options) + if not result.error.success: + return lldb.LLDB_INVALID_BREAK_ID + return self.facade_locs[tmp_loc] def get_location_description(self, bp_loc, desc_level): diff --git a/lldb/test/API/functionalities/breakpoint/scripted_bkpt/was_hit/main.c b/lldb/test/API/functionalities/breakpoint/scripted_bkpt/was_hit/main.c index b8f977e49351..7fe5480f8623 100644 --- a/lldb/test/API/functionalities/breakpoint/scripted_bkpt/was_hit/main.c +++ b/lldb/test/API/functionalities/breakpoint/scripted_bkpt/was_hit/main.c @@ -1,5 +1,9 @@ #include <stdio.h> +int g_change_me = 0; + +int change_him() { return ++g_change_me; } + int stop_symbol() { static int s_cnt = 0; printf("I am in the stop symbol: %d\n", s_cnt++); @@ -10,5 +14,6 @@ int main() { for (int i = 0; i < 100; i++) { stop_symbol(); } + change_him(); return 0; } |
