diff options
author | Jim Ingham <jingham@apple.com> | 2019-02-23 00:13:25 +0000 |
---|---|---|
committer | Jim Ingham <jingham@apple.com> | 2019-02-23 00:13:25 +0000 |
commit | ff8c7a0947663ce7515f0b8ee52b9d0fe8883bc3 (patch) | |
tree | aa2c285e2f294cc7b0620c84c9f4f726677c8a21 /lldb/lit/ExecControl | |
parent | 275d15ecf3476b7f884174e1c85f4894fb815bf1 (diff) | |
download | bcm5719-llvm-ff8c7a0947663ce7515f0b8ee52b9d0fe8883bc3.tar.gz bcm5719-llvm-ff8c7a0947663ce7515f0b8ee52b9d0fe8883bc3.zip |
Make sure that stop-hooks run asynchronously.
They aren't designed to nest recursively, so this will prevent that.
Also add a --auto-continue flag, putting "continue" in the stop hook makes
the stop hooks fight one another in multi-threaded programs.
Also allow more than one -o options so you can make more complex stop hooks w/o
having to go into the editor.
<rdar://problem/48115661>
Differential Revision: https://reviews.llvm.org/D58394
llvm-svn: 354706
Diffstat (limited to 'lldb/lit/ExecControl')
7 files changed, 22 insertions, 18 deletions
diff --git a/lldb/lit/ExecControl/StopHook/Inputs/stop-hook-2.lldbinit b/lldb/lit/ExecControl/StopHook/Inputs/stop-hook-2.lldbinit index 13de5fb60bc..31817bdaaa5 100644 --- a/lldb/lit/ExecControl/StopHook/Inputs/stop-hook-2.lldbinit +++ b/lldb/lit/ExecControl/StopHook/Inputs/stop-hook-2.lldbinit @@ -1 +1 @@ -target stop-hook add -f stop-hook.c -l 29 -e 34 -o "expr ptr"
\ No newline at end of file +target stop-hook add -f stop-hook.c -l 29 -e 34 -o "expr ptr" diff --git a/lldb/lit/ExecControl/StopHook/Inputs/stop-hook-3.lldbinit b/lldb/lit/ExecControl/StopHook/Inputs/stop-hook-3.lldbinit index b4dcda2f88f..36e144deecc 100644 --- a/lldb/lit/ExecControl/StopHook/Inputs/stop-hook-3.lldbinit +++ b/lldb/lit/ExecControl/StopHook/Inputs/stop-hook-3.lldbinit @@ -1,3 +1,3 @@ target stop-hook add -f stop-hook.c -l 29 -e 34 expr ptr -DONE
\ No newline at end of file +DONE diff --git a/lldb/lit/ExecControl/StopHook/Inputs/stop-hook-threads-1.lldbinit b/lldb/lit/ExecControl/StopHook/Inputs/stop-hook-threads-1.lldbinit index f192d9952e9..004bd34abfb 100644 --- a/lldb/lit/ExecControl/StopHook/Inputs/stop-hook-threads-1.lldbinit +++ b/lldb/lit/ExecControl/StopHook/Inputs/stop-hook-threads-1.lldbinit @@ -1,7 +1,7 @@ +break set -f stop-hook-threads.cpp -p "Break here to set up the stop hook" break set -f stop-hook-threads.cpp -p "Break here to test that the stop-hook" run -target stop-hook add -frame variable --show-globals g_val +target stop-hook add -G true +expr lldb_val += 1 thread list -continue DONE diff --git a/lldb/lit/ExecControl/StopHook/Inputs/stop-hook-threads-2.lldbinit b/lldb/lit/ExecControl/StopHook/Inputs/stop-hook-threads-2.lldbinit index 467f60b1e1e..3b7d23953c3 100644 --- a/lldb/lit/ExecControl/StopHook/Inputs/stop-hook-threads-2.lldbinit +++ b/lldb/lit/ExecControl/StopHook/Inputs/stop-hook-threads-2.lldbinit @@ -1,4 +1,5 @@ +break set -f stop-hook-threads.cpp -p "Break here to set up the stop hook" break set -f stop-hook-threads.cpp -p "Break here to test that the stop-hook" run -target stop-hook add -x 2 -o "frame variable thread_index" -target stop-hook add -o continue +target stop-hook add -x 2 -o "expr lldb_val += 1" -o "thread list" +target stop-hook add -G true -o "script print('Hit stop hook') diff --git a/lldb/lit/ExecControl/StopHook/Inputs/stop-hook-threads.cpp b/lldb/lit/ExecControl/StopHook/Inputs/stop-hook-threads.cpp index 5b6f31edd1b..e653f5ff518 100644 --- a/lldb/lit/ExecControl/StopHook/Inputs/stop-hook-threads.cpp +++ b/lldb/lit/ExecControl/StopHook/Inputs/stop-hook-threads.cpp @@ -16,6 +16,7 @@ std::default_random_engine g_random_engine{std::random_device{}()}; std::uniform_int_distribution<> g_distribution{0, 3000}; uint32_t g_val = 0; +uint32_t lldb_val = 0; uint32_t access_pool (bool flag = false) @@ -62,7 +63,8 @@ thread_func (uint32_t thread_index) int main (int argc, char const *argv[]) { std::thread threads[3]; - + // Break here to set up the stop hook + printf("Stop hooks engaged.\n"); // Create 3 threads for (auto &thread : threads) thread = std::thread{thread_func, std::distance(threads, &thread)}; @@ -71,5 +73,7 @@ int main (int argc, char const *argv[]) for (auto &thread : threads) thread.join(); + // print lldb_val so we can check it here. + printf ("lldb_val was set to: %d.\n", lldb_val); return 0; } diff --git a/lldb/lit/ExecControl/StopHook/stop-hook-threads.test b/lldb/lit/ExecControl/StopHook/stop-hook-threads.test index c761bdc1d14..134357535cd 100644 --- a/lldb/lit/ExecControl/StopHook/stop-hook-threads.test +++ b/lldb/lit/ExecControl/StopHook/stop-hook-threads.test @@ -4,7 +4,6 @@ # RUN: %lldb -b -s %p/Inputs/stop-hook-threads-2.lldbinit -s %s -f %t \ # RUN: | FileCheck --check-prefix=CHECK --check-prefix=CHECK-FILTER %s # XFAIL: system-windows -# UNSUPPORTED: linux thread list break set -f stop-hook-threads.cpp -p "Set break point at this line" @@ -12,23 +11,22 @@ target stop-hook list # CHECK: Hook: 1 # CHECK-NEXT: State: enabled +# CHECK-NO-FILTER-NEXT: AutoContinue on # CHECK-FILTER-NEXT: Thread # CHECK-FILTER-NEXT: index: 2 # CHECK-NEXT: Commands: -# CHECK-NEXT: frame variable +# CHECK-NEXT: expr lldb_val += 1 +# CHECK-NEXT: thread list # CHECK-FILTER: Hook: 2 # CHECK-FILTER-NEXT: State: enabled +# CHECK-FILTER-NEXT: AutoContinue on # CHECK-FILTER-NEXT: Commands: -# CHECK-FILTER-NEXT: continue +# CHECK-FILTER-NEXT: script print('Hit stop hook') # Get the threads going continue -# When we filter per thread, we expect exactly 4 identical "frame var" results -# CHECK-FILTER: (uint32_t) thread_index = [[THREAD_INDEX:[0-9]*]] -# CHECK-FILTER-COUNT-3: (uint32_t) thread_index = [[THREAD_INDEX]] -# CHECK-FILTER-NOT: thread_index - -# When we don't filter, we expect to count 12 stopped threads in the thread list output -# CHECK-NO-FILTER-COUNT-12: at stop-hook-threads.cpp{{.*}} stop reason = breakpoint
\ No newline at end of file +# Now make sure we hit the command the right number of times: +# CHECK-NO-FILTER: lldb_val was set to: 15. +# CHECK-FILTER: lldb_val was set to: 5. diff --git a/lldb/lit/ExecControl/StopHook/stop-hook.test b/lldb/lit/ExecControl/StopHook/stop-hook.test index ca6495ef14a..dbf2b975809 100644 --- a/lldb/lit/ExecControl/StopHook/stop-hook.test +++ b/lldb/lit/ExecControl/StopHook/stop-hook.test @@ -11,6 +11,7 @@ # string, so the test "passes" despite the fact that the commands failed # llvm.org/pr40119 # UNSUPPORTED: system-windows +# XFAIL: system-linux break set -f stop-hook.c -p "// Set breakpoint here to test target stop-hook" break set -f stop-hook.c -p "// Another breakpoint which is outside of the stop-hook range" |