From 76bb7596056d815b03290f40979eecba47355141 Mon Sep 17 00:00:00 2001 From: Jim Ingham Date: Fri, 23 Sep 2011 21:24:57 +0000 Subject: [PATCH] Added a test for problems caused when Clang errantly makes the line range for one line too long, so that the jump from the line above the bad line to the line after ends up in the middle of the bad line instead. Added a workaround to lldb to just continue to the end if we find ourselves stopped in the middle of some other line. llvm-svn: 140419 --- .../functionalities/stop-hook/TestStopHookMechanism.py | 8 ++++++++ lldb/test/functionalities/stop-hook/main.cpp | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lldb/test/functionalities/stop-hook/TestStopHookMechanism.py b/lldb/test/functionalities/stop-hook/TestStopHookMechanism.py index db722d52a3ea..d04aaa88213b 100644 --- a/lldb/test/functionalities/stop-hook/TestStopHookMechanism.py +++ b/lldb/test/functionalities/stop-hook/TestStopHookMechanism.py @@ -29,6 +29,7 @@ class StopHookMechanismTestCase(TestBase): # Find the line numbers inside main.cpp. self.begl = line_number('main.cpp', '// Set breakpoint here to test target stop-hook.') self.endl = line_number('main.cpp', '// End of the line range for which stop-hook is to be run.') + self.correct_step_line = line_number ('main.cpp', '// We should stop here after stepping.') self.line = line_number('main.cpp', '// Another breakpoint which is outside of the stop-hook range.') def stop_hook_firing(self): @@ -66,6 +67,13 @@ class StopHookMechanismTestCase(TestBase): child.sendline('thread step-over') # Expecting to find the output emitted by the firing of our stop hook. child.expect_exact('(void *) $') + # This is orthogonal to the main stop hook test, but this example shows a bug in + # CLANG where the line table entry for the "return -1" actually includes some code + # from the other branch of the if/else, so we incorrectly stop at the "return -1" line. + # I fixed that in lldb and I'm sticking in a test here because I don't want to have to + # make up a whole nother test case for it. + child.sendline('frame info') + child.expect_exact('at main.cpp:%d'%self.correct_step_line) # Now continue the inferior, we'll stop at another breakpoint which is outside the stop-hook range. child.sendline('process continue') diff --git a/lldb/test/functionalities/stop-hook/main.cpp b/lldb/test/functionalities/stop-hook/main.cpp index ee68c34feb88..c10c1e5ef0d2 100644 --- a/lldb/test/functionalities/stop-hook/main.cpp +++ b/lldb/test/functionalities/stop-hook/main.cpp @@ -30,7 +30,7 @@ int b(int val) if (!ptr) // Set breakpoint here to test target stop-hook. return -1; else - printf("ptr=%p\n", ptr); + printf("ptr=%p\n", ptr); // We should stop here after stepping. return rc; // End of the line range for which stop-hook is to be run. }