Index: tools/lldb-mi/TestMiInterpreterExec.py =================================================================== --- tools/lldb-mi/TestMiInterpreterExec.py +++ tools/lldb-mi/TestMiInterpreterExec.py @@ -139,12 +139,16 @@ self.expect("\^running") self.expect("\*stopped,reason=\"breakpoint-hit\"") - # Test that "thread step-in" steps in - #FIXME: is this supposed to step into printf? + # Test that "thread step-in" steps into (or not) printf depending on debug info + # Note that message is different in Darwin and Linux: + # Darwin: ??? + # Linux: "\*stopped,reason=\"end-stepping-range\",frame=\{addr="0x[0-9a-f]+\",func=\"__printf\",args=\[\{name=\"format\",value=\"0x[0-9a-f]+\"\}\],file=\"printf.c\",fullname=\".+printf.c\",line="\d+"},thread-id=\"1\",stopped-threads=\"all\" self.runCmd("-interpreter-exec console \"thread step-in\"") self.expect("\^done") - self.expect("~\"argc=1\\\\r\\\\n\"") - self.expect("\*stopped,reason=\"end-stepping-range\"") + it = self.expect([ "~\"argc=1\\\\r\\\\n\"", + "\*stopped,reason=\"end-stepping-range\".+func=\"((?!main).)+\"" ]) + if it == 0: + self.expect("\*stopped,reason=\"end-stepping-range\".+func=\"main\"") @lldbmi_test @expectedFailureWindows("llvm.org/pr22274: need a pexpect replacement for windows") Index: tools/lldb-mi/control/TestMiExec.py =================================================================== --- tools/lldb-mi/control/TestMiExec.py +++ tools/lldb-mi/control/TestMiExec.py @@ -160,22 +160,22 @@ # Test -exec-next self.runCmd("-exec-next --thread 1 --frame 0") self.expect("\^running") - self.expect("\*stopped,reason=\"end-stepping-range\".*main.cpp\",line=\"29\"") + self.expect("\*stopped,reason=\"end-stepping-range\".+main.cpp\",line=\"29\"") # Test that --thread is optional self.runCmd("-exec-next --frame 0") self.expect("\^running") - self.expect("\*stopped,reason=\"end-stepping-range\".*main.cpp\",line=\"30\"") + self.expect("\*stopped,reason=\"end-stepping-range\".+main.cpp\",line=\"30\"") # Test that --frame is optional self.runCmd("-exec-next --thread 1") self.expect("\^running") - self.expect("\*stopped,reason=\"end-stepping-range\".*main.cpp\",line=\"31\"") + self.expect("\*stopped,reason=\"end-stepping-range\".+main.cpp\",line=\"31\"") # Test that both --thread and --frame are optional self.runCmd("-exec-next") self.expect("\^running") - self.expect("\*stopped,reason=\"end-stepping-range\".*main.cpp\",line=\"32\"") + self.expect("\*stopped,reason=\"end-stepping-range\".+main.cpp\",line=\"32\"") # Test that an invalid --thread is handled self.runCmd("-exec-next --thread 0") @@ -213,23 +213,23 @@ # Test -exec-next-instruction self.runCmd("-exec-next-instruction --thread 1 --frame 0") self.expect("\^running") - self.expect("\*stopped,reason=\"end-stepping-range\".*main.cpp\",line=\"28\"") + self.expect("\*stopped,reason=\"end-stepping-range\".+main.cpp\",line=\"28\"") # Test that --thread is optional self.runCmd("-exec-next-instruction --frame 0") self.expect("\^running") - self.expect("\*stopped,reason=\"end-stepping-range\".*main.cpp\",line=\"28\"") + self.expect("\*stopped,reason=\"end-stepping-range\".+main.cpp\",line=\"28\"") # Test that --frame is optional self.runCmd("-exec-next-instruction --thread 1") self.expect("\^running") - self.expect("\*stopped,reason=\"end-stepping-range\".*main.cpp\",line=\"29\"") + self.expect("\*stopped,reason=\"end-stepping-range\".+main.cpp\",line=\"29\"") # Test that both --thread and --frame are optional self.runCmd("-exec-next-instruction") self.expect("\^running") # Depending on compiler, it can stop at different line - self.expect("\*stopped,reason=\"end-stepping-range\".*main.cpp\",line=\"29\"") + self.expect("\*stopped,reason=\"end-stepping-range\".+main.cpp\",line=\"29\"") # Test that an invalid --thread is handled self.runCmd("-exec-next-instruction --thread 0") @@ -263,44 +263,42 @@ # Warning: the following is sensative to the lines in the source - # Test that -exec-step does not step into printf (which - # has no debug info) - #FIXME: is this supposed to step into printf? + # Test that -exec-step steps into (or not) printf depending on debug info + # Note that message is different in Darwin and Linux: + # Darwin: ??? + # Linux: "\*stopped,reason=\"end-stepping-range\",frame=\{addr="0x[0-9a-f]+\",func=\"__printf\",args=\[\{name=\"format\",value=\"0x[0-9a-f]+\"\}\],file=\"printf.c\",fullname=\".+printf.c\",line="\d+"},thread-id=\"1\",stopped-threads=\"all\" self.runCmd("-exec-step --thread 1 --frame 0") self.expect("\^running") - self.expect("\*stopped,reason=\"end-stepping-range\".*main.cpp\",line=\"29\"") + it = self.expect([ "\*stopped,reason=\"end-stepping-range\".+func=\"main\"", + "\*stopped,reason=\"end-stepping-range\".+func=\"((?!main).)+\"" ]) + # Exit from printf if needed + if it == 1: + self.runCmd("-exec-finish") + self.expect("\^running") + self.expect("\*stopped,reason=\"end-stepping-range\".+func=\"main\"") # Test that -exec-step steps into g_MyFunction and back out # (and that --thread is optional) self.runCmd("-exec-step --frame 0") self.expect("\^running") - self.expect("\*stopped,reason=\"end-stepping-range\".*func=\"g_MyFunction\(\)\"") - #FIXME: is this supposed to step into printf? - self.runCmd("-exec-step --frame 0") - self.expect("\^running") - self.expect("\*stopped,reason=\"end-stepping-range\".*func=\"g_MyFunction\(\)\"") + self.expect("\*stopped,reason=\"end-stepping-range\".+func=\"g_MyFunction\(\)\"") # Use -exec-finish here to make sure that control reaches the caller. # -exec-step can keep us in the g_MyFunction for gcc self.runCmd("-exec-finish --frame 0") self.expect("\^running") - self.expect("\*stopped,reason=\"end-stepping-range\".*main.cpp\",line=\"30\"") + self.expect("\*stopped,reason=\"end-stepping-range\".+main.cpp\",line=\"30\"") # Test that -exec-step steps into s_MyFunction - self.runCmd("-exec-step --frame 0") - self.expect("\^running") - self.expect("\*stopped,reason=\"end-stepping-range\".*func=\"s_MyFunction\(\)\"") - - # Test that -exec-step steps into g_MyFunction # (and that --frame is optional) self.runCmd("-exec-step --thread 1") self.expect("\^running") - self.expect("\*stopped,reason=\"end-stepping-range\".*func=\"g_MyFunction\(\)\"") + self.expect("\*stopped,reason=\"end-stepping-range\".+func=\"s_MyFunction\(\)\"") # Test that -exec-step steps into g_MyFunction from inside # s_MyFunction (and that both --thread and --frame are optional) self.runCmd("-exec-step") self.expect("\^running") - self.expect("\*stopped,reason=\"end-stepping-range\".*func=\"g_MyFunction\(\)\"") + self.expect("\*stopped,reason=\"end-stepping-range\".+func=\"g_MyFunction\(\)\"") # Test that an invalid --thread is handled self.runCmd("-exec-step --thread 0") @@ -315,7 +313,8 @@ @lldbmi_test @expectedFailureWindows("llvm.org/pr22274: need a pexpect replacement for windows") - @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin due to calling convention assumptions") + #@unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin due to calling convention assumptions") + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races def test_lldbmi_exec_step_instruction(self): """Test that 'lldb-mi --interpreter' works for instruction stepping into.""" @@ -338,31 +337,31 @@ # Test that -exec-next steps over printf self.runCmd("-exec-next --thread 1 --frame 0") self.expect("\^running") - self.expect("\*stopped,reason=\"end-stepping-range\".*main.cpp\",line=\"29\"") + self.expect("\*stopped,reason=\"end-stepping-range\".+main.cpp\",line=\"29\"") # Test that -exec-step-instruction steps over non branching # instruction self.runCmd("-exec-step-instruction --thread 1 --frame 0") self.expect("\^running") - self.expect("\*stopped,reason=\"end-stepping-range\".*main.cpp\",line=\"2[8-9]\"") + self.expect("\*stopped,reason=\"end-stepping-range\".+main.cpp\",line=\"2[8-9]\"") # Test that -exec-step-instruction steps into g_MyFunction # instruction (and that --thread is optional) self.runCmd("-exec-step-instruction --frame 0") self.expect("\^running") - self.expect("\*stopped,reason=\"end-stepping-range\".*func=\"g_MyFunction\(\)\"") + self.expect("\*stopped,reason=\"end-stepping-range\".+func=\"g_MyFunction\(\)\"") # Test that -exec-step-instruction steps over non branching # (and that --frame is optional) self.runCmd("-exec-step-instruction --thread 1") self.expect("\^running") - self.expect("\*stopped,reason=\"end-stepping-range\".*func=\"g_MyFunction\(\)\"") + self.expect("\*stopped,reason=\"end-stepping-range\".+func=\"g_MyFunction\(\)\"") # Test that -exec-step-instruction steps into g_MyFunction # (and that both --thread and --frame are optional) self.runCmd("-exec-step-instruction") self.expect("\^running") - self.expect("\*stopped,reason=\"end-stepping-range\".*func=\"g_MyFunction\(\)\"") + self.expect("\*stopped,reason=\"end-stepping-range\".+func=\"g_MyFunction\(\)\"") # Test that an invalid --thread is handled self.runCmd("-exec-step-instruction --thread 0") @@ -397,7 +396,7 @@ # Test that -exec-finish returns from g_MyFunction self.runCmd("-exec-finish --thread 1 --frame 0") self.expect("\^running") - self.expect("\*stopped,reason=\"end-stepping-range\".*func=\"main\"") + self.expect("\*stopped,reason=\"end-stepping-range\".+func=\"main\"") # Run to BP inside s_MyFunction call self.runCmd("-break-insert s_MyFunction") @@ -416,13 +415,13 @@ # s_MyFunction (and that --frame is optional) self.runCmd("-exec-finish --thread 1") self.expect("\^running") - self.expect("\*stopped,reason=\"end-stepping-range\".*func=\"s_MyFunction\(\)\"") + self.expect("\*stopped,reason=\"end-stepping-range\".+func=\"s_MyFunction\(\)\"") # Test that -exec-finish returns from s_MyFunction # (and that both --thread and --frame are optional) self.runCmd("-exec-finish") self.expect("\^running") - self.expect("\*stopped,reason=\"end-stepping-range\".*func=\"main\"") + self.expect("\*stopped,reason=\"end-stepping-range\".+func=\"main\"") # Test that an invalid --thread is handled self.runCmd("-exec-finish --thread 0") @@ -446,7 +445,7 @@ ## Test that -exec-finish returns from printf self.runCmd("-exec-finish --thread 1 --frame 0") self.expect("\^running") - self.expect("\*stopped,reason=\"end-stepping-range\".*func=\"main\"") + self.expect("\*stopped,reason=\"end-stepping-range\".+func=\"main\"") if __name__ == '__main__': unittest2.main() Index: tools/lldb-mi/signal/TestMiSignal.py =================================================================== --- tools/lldb-mi/signal/TestMiSignal.py +++ tools/lldb-mi/signal/TestMiSignal.py @@ -16,7 +16,7 @@ @lldbmi_test @expectedFailureWindows("llvm.org/pr22274: need a pexpect replacement for windows") - @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + @skipIfFreeBSD # llvm.org/pr22411: Fails on FreeBSD apparently due to thread race conditions def test_lldbmi_stopped_when_interrupt(self): """Test that 'lldb-mi --interpreter' interrupt and resume a looping app.""" @@ -41,7 +41,7 @@ # Test that -exec-interrupt can interrupt an execution self.runCmd("-exec-interrupt") - self.expect("\*stopped,reason=\"signal-received\",signal-name=\"SIGINT\",signal-meaning=\"Interrupt\",.*thread-id=\"1\",stopped-threads=\"all\"") + self.expect("\*stopped,reason=\"signal-received\",signal-name=\"SIGINT\",signal-meaning=\"Interrupt\".+thread-id=\"1\",stopped-threads=\"all\"") # Continue (to loop forever) self.runCmd("-exec-continue") @@ -49,7 +49,7 @@ # Test that Ctrl+C can interrupt an execution self.child.sendintr() #FIXME: here uses self.child directly - self.expect("\*stopped,reason=\"signal-received\",signal-name=\"SIGINT\",signal-meaning=\"Interrupt\",.*thread-id=\"1\",stopped-threads=\"all\"") + self.expect("\*stopped,reason=\"signal-received\",signal-name=\"SIGINT\",signal-meaning=\"Interrupt\".+thread-id=\"1\",stopped-threads=\"all\"") @lldbmi_test @expectedFailureWindows("llvm.org/pr22274: need a pexpect replacement for windows") @@ -71,7 +71,8 @@ # Note that message is different in Darwin and Linux: # Darwin: "*stopped,reason=\"signal-received\",signal-name=\"SIGINT\",signal-meaning=\"Interrupt\",frame={level=\"0\",addr=\"0x[0-9a-f]+\",func=\"_dyld_start\",file=\"??\",fullname=\"??\",line=\"-1\"},thread-id=\"1\",stopped-threads=\"all\" # Linux: "*stopped,reason=\"end-stepping-range\",frame={addr=\"0x[0-9a-f]+\",func=\"??\",args=\[\],file=\"??\",fullname=\"??\",line=\"-1\"},thread-id=\"1\",stopped-threads=\"all\" - self.expect("\*stopped,reason=\"(signal-received|end-stepping-range)\",.+,thread-id=\"1\",stopped-threads=\"all\"") + self.expect([ "\*stopped,reason=\"signal-received\",signal-name=\"SIGINT\",signal-meaning=\"Interrupt\",frame=\{level=\"0\",addr=\"0x[0-9a-f]+\",func=\"_dyld_start\",file=\"\?\?\",fullname=\"\?\?\",line=\"-1\"\},thread-id=\"1\",stopped-threads=\"all\"", + "\*stopped,reason=\"end-stepping-range\",frame={addr=\"0x[0-9a-f]+\",func=\"\?\?\",args=\[\],file=\"\?\?\",fullname=\"\?\?\",line=\"-1\"},thread-id=\"1\",stopped-threads=\"all\"" ]) # Run to main to make sure we have not exited the application self.runCmd("-break-insert -f main") @@ -114,7 +115,7 @@ self.expect("\^done") # Test that *stopped is printed - self.expect("\*stopped,reason=\"signal-received\",signal-name=\"SIGINT\",signal-meaning=\"Interrupt\",.*thread-id=\"1\",stopped-threads=\"all\"") + self.expect("\*stopped,reason=\"signal-received\",signal-name=\"SIGINT\",signal-meaning=\"Interrupt\".+thread-id=\"1\",stopped-threads=\"all\"") # Exit self.runCmd("-gdb-exit") @@ -150,7 +151,11 @@ self.expect("\^running") # Test that *stopped is printed - self.expect("\*stopped,reason=\"exception-received\",exception=\"(EXC_BAD_ACCESS \(code=1, address=0x0\)|invalid address \(fault address: 0x0\))\",thread-id=\"1\",stopped-threads=\"all\"") + # Note that message is different in Darwin and Linux: + # Darwin: "*stopped,reason=\"exception-received\",exception=\"EXC_BAD_ACCESS (code=1, address=0x0)\",thread-id=\"1\",stopped-threads=\"all\"" + # Linux: "*stopped,reason=\"exception-received\",exception=\"invalid address (fault address: 0x0)\",thread-id=\"1\",stopped-threads=\"all\"" + self.expect([ "\*stopped,reason=\"exception-received\",exception=\"EXC_BAD_ACCESS \(code=1, address=0x0\)\",thread-id=\"1\",stopped-threads=\"all\"", + "\*stopped,reason=\"exception-received\",exception=\"invalid address \(fault address: 0x0\)\",thread-id=\"1\",stopped-threads=\"all\"" ]) @lldbmi_test @expectedFailureWindows("llvm.org/pr22274: need a pexpect replacement for windows") Index: tools/lldb-mi/stack/TestMiStack.py =================================================================== --- tools/lldb-mi/stack/TestMiStack.py +++ tools/lldb-mi/stack/TestMiStack.py @@ -41,15 +41,15 @@ # Test -stack-list-arguments: use 1 or --all-values self.runCmd("-stack-list-arguments 1") - self.expect("\^done,stack-args=\[frame={level=\"0\",args=\[{name=\"argc\",value=\"1\"},{name=\"argv\",value=\".*\"}\]}") + self.expect("\^done,stack-args=\[frame={level=\"0\",args=\[{name=\"argc\",value=\"1\"},{name=\"argv\",value=\".+\"}\]}") self.runCmd("-stack-list-arguments --all-values") - self.expect("\^done,stack-args=\[frame={level=\"0\",args=\[{name=\"argc\",value=\"1\"},{name=\"argv\",value=\".*\"}\]}") + self.expect("\^done,stack-args=\[frame={level=\"0\",args=\[{name=\"argc\",value=\"1\"},{name=\"argv\",value=\".+\"}\]}") # Test -stack-list-arguments: use 2 or --simple-values self.runCmd("-stack-list-arguments 2") - self.expect("\^done,stack-args=\[frame={level=\"0\",args=\[{name=\"argc\",value=\"1\"},{name=\"argv\",value=\".*\"}\]}") + self.expect("\^done,stack-args=\[frame={level=\"0\",args=\[{name=\"argc\",value=\"1\"},{name=\"argv\",value=\".+\"}\]}") self.runCmd("-stack-list-arguments --simple-values") - self.expect("\^done,stack-args=\[frame={level=\"0\",args=\[{name=\"argc\",value=\"1\"},{name=\"argv\",value=\".*\"}\]}") + self.expect("\^done,stack-args=\[frame={level=\"0\",args=\[{name=\"argc\",value=\"1\"},{name=\"argv\",value=\".+\"}\]}") @lldbmi_test @expectedFailureWindows("llvm.org/pr22274: need a pexpect replacement for windows") @@ -168,15 +168,15 @@ # Test -stack-list-locals: use 1 or --all-values self.runCmd("-stack-list-locals 1") - self.expect("\^done,locals=\[{name=\"test_str\",value=\".*Rakaposhi.*\"},{name=\"var_e\",value=\"24\"},{name=\"ptr\",value=\".*\"}\]") + self.expect("\^done,locals=\[{name=\"test_str\",value=\".*Rakaposhi.*\"},{name=\"var_e\",value=\"24\"},{name=\"ptr\",value=\".+\"}\]") self.runCmd("-stack-list-locals --all-values") - self.expect("\^done,locals=\[{name=\"test_str\",value=\".*Rakaposhi.*\"},{name=\"var_e\",value=\"24\"},{name=\"ptr\",value=\".*\"}\]") + self.expect("\^done,locals=\[{name=\"test_str\",value=\".*Rakaposhi.*\"},{name=\"var_e\",value=\"24\"},{name=\"ptr\",value=\".+\"}\]") # Test -stack-list-locals: use 2 or --simple-values self.runCmd("-stack-list-locals 2") - self.expect("\^done,locals=\[{name=\"test_str\",value=\".*Rakaposhi.*\"},{name=\"var_e\",value=\"24\"},{name=\"ptr\",value=\".*\"}\]") + self.expect("\^done,locals=\[{name=\"test_str\",value=\".*Rakaposhi.*\"},{name=\"var_e\",value=\"24\"},{name=\"ptr\",value=\".+\"}\]") self.runCmd("-stack-list-locals --simple-values") - self.expect("\^done,locals=\[{name=\"test_str\",value=\".*Rakaposhi.*\"},{name=\"var_e\",value=\"24\"},{name=\"ptr\",value=\".*\"}\]") + self.expect("\^done,locals=\[{name=\"test_str\",value=\".*Rakaposhi.*\"},{name=\"var_e\",value=\"24\"},{name=\"ptr\",value=\".+\"}\]") @lldbmi_test @expectedFailureWindows("llvm.org/pr22274: need a pexpect replacement for windows") @@ -296,7 +296,7 @@ # Test that current frame is #1 self.runCmd("-stack-info-frame") - self.expect("\^done,frame=\{level=\"1\",addr=\".+\",func=\".+\",file=\"\?\?\",fullname=\"\?\?\",line=\"-1\"\}") + self.expect("\^done,frame=\{level=\"1\",addr=\".+\",func=\".+\",file=\".+\",fullname=\".+\",line=\"(-1|\d+)\"\}") # Test that -stack-select-frame can select frame #0 (child frame) self.runCmd("-stack-select-frame 0")