diff options
| author | Jim Ingham <jingham@apple.com> | 2014-01-15 03:32:42 +0000 |
|---|---|---|
| committer | Jim Ingham <jingham@apple.com> | 2014-01-15 03:32:42 +0000 |
| commit | 39fdae7f6a59a63e64977fe42350141928e8ac6b (patch) | |
| tree | 8224883bc323c02d2217828e86fae639ef6fe6f4 /lldb/test | |
| parent | a8b99ca4bb299bd0191983dfd36e6349fdec5fb3 (diff) | |
| download | bcm5719-llvm-39fdae7f6a59a63e64977fe42350141928e8ac6b.tar.gz bcm5719-llvm-39fdae7f6a59a63e64977fe42350141928e8ac6b.zip | |
Fix a bug where if we stop but nobody says there was a reason for the stop, we would return
control to the user anyway. This was put in to handle monitors that would say there was no
stop reason when you first attached to them. But it broke the case where you hit a thread specific
breakpoint on many threads, but NOT the one specified in the breakpoint. I work around this
by only doing the junky override when the StopID is 0 - i.e. on first attach.
This commit also adds a test for thread specific breakpoints.
llvm-svn: 199290
Diffstat (limited to 'lldb/test')
3 files changed, 120 insertions, 0 deletions
diff --git a/lldb/test/functionalities/thread/thread_specific_break/Makefile b/lldb/test/functionalities/thread/thread_specific_break/Makefile new file mode 100644 index 00000000000..b09a579159d --- /dev/null +++ b/lldb/test/functionalities/thread/thread_specific_break/Makefile @@ -0,0 +1,5 @@ +LEVEL = ../../../make + +C_SOURCES := main.c + +include $(LEVEL)/Makefile.rules diff --git a/lldb/test/functionalities/thread/thread_specific_break/TestThreadSpecificBreakpoint.py b/lldb/test/functionalities/thread/thread_specific_break/TestThreadSpecificBreakpoint.py new file mode 100644 index 00000000000..f89c2f2ef42 --- /dev/null +++ b/lldb/test/functionalities/thread/thread_specific_break/TestThreadSpecificBreakpoint.py @@ -0,0 +1,77 @@ +""" +Test that we obey thread conditioned breakpoints. +""" + +import os, time +import re +import unittest2 +import lldb, lldbutil +from lldbtest import * + +class ThreadSpecificBreakTestCase(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + @python_api_test + @dsym_test + def test_with_dsym_python(self): + """Test that we obey thread conditioned breakpoints.""" + self.buildDsym() + self.do_thread_specific_break() + + @python_api_test + @dwarf_test + def test_with_dwarf_python(self): + """Test that we obey thread conditioned breakpoints.""" + self.buildDwarf() + self.do_thread_specific_break() + + def do_thread_specific_break(self): + """Test that we obey thread conditioned breakpoints.""" + exe = os.path.join(os.getcwd(), "a.out") + + self.dbg.HandleCommand ("log enable -f /tmp/lldb-testsuite-log.txt lldb step breakpoint process") + target = self.dbg.CreateTarget(exe) + self.assertTrue(target, VALID_TARGET) + + main_source_spec = lldb.SBFileSpec ("main.c") + + # Set a breakpoint in the thread body, and make it active for only the first thread. + break_thread_body = target.BreakpointCreateBySourceRegex ("Break here in thread body.", main_source_spec) + self.assertTrue (break_thread_body.IsValid() and break_thread_body.GetNumLocations() > 0, "Failed to set thread body breakpoint.") + + process = target.LaunchSimple (None, None, self.get_process_working_directory()) + + self.assertTrue(process, PROCESS_IS_VALID) + + threads = lldbutil.get_threads_stopped_at_breakpoint (process, break_thread_body) + + victim_thread = threads[0] + + # Pick one of the threads, and change the breakpoint so it ONLY stops for this thread, + # but add a condition that it won't stop for this thread's my_value. The other threads + # pass the condition, so they should stop, but if the thread-specification is working + # they should not stop. So nobody should hit the breakpoint anymore, and we should + # just exit cleanly. + + frame = victim_thread.GetFrameAtIndex(0) + value = frame.FindVariable("my_value").GetValueAsSigned(0) + self.assertTrue (value > 0 and value < 11, "Got a reasonable value for my_value.") + + cond_string = "my_value != %d"%(value) + + break_thread_body.SetThreadID(victim_thread.GetThreadID()) + break_thread_body.SetCondition (cond_string) + + process.Continue() + + next_stop_state = process.GetState() + self.assertTrue (next_stop_state == lldb.eStateExited, "We should have not hit the breakpoint again.") + + +if __name__ == '__main__': + import atexit + lldb.SBDebugger.Initialize() + atexit.register(lambda: lldb.SBDebugger.Terminate()) + unittest2.main() diff --git a/lldb/test/functionalities/thread/thread_specific_break/main.c b/lldb/test/functionalities/thread/thread_specific_break/main.c new file mode 100644 index 00000000000..ea1bb7e60a6 --- /dev/null +++ b/lldb/test/functionalities/thread/thread_specific_break/main.c @@ -0,0 +1,38 @@ +#include <pthread.h> +#include <unistd.h> + +void * +thread_function (void *thread_marker) +{ + int keep_going = 1; + int my_value = *((int *)thread_marker); + int counter = 0; + + while (counter < 20) + { + counter++; // Break here in thread body. + usleep (10); + } + return NULL; +} + + +int +main () +{ + + pthread_t threads[10]; + + int thread_value = 0; + + for (int i = 0; i < 10; i++) + { + thread_value += 1; + pthread_create (&threads[i], NULL, &thread_function, &thread_value); + } + + for (int i = 0; i < 10; i++) + pthread_join (threads[i], NULL); + + return 0; +} |

