diff options
author | dim <dim@FreeBSD.org> | 2016-01-06 20:12:03 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2016-01-06 20:12:03 +0000 |
commit | 78b9749c0a4ea980a8b934645da6ae98fcc665e8 (patch) | |
tree | dd2a1ddf0476664c2b823409c36cbccd52662ca7 /packages/Python/lldbsuite/test/tools/lldb-mi | |
parent | 60cb593f9d55fa5ca7a5372b731f2330345b4b9a (diff) | |
download | FreeBSD-src-78b9749c0a4ea980a8b934645da6ae98fcc665e8.zip FreeBSD-src-78b9749c0a4ea980a8b934645da6ae98fcc665e8.tar.gz |
Vendor import of lldb trunk r256945:
https://llvm.org/svn/llvm-project/lldb/trunk@256945
Diffstat (limited to 'packages/Python/lldbsuite/test/tools/lldb-mi')
49 files changed, 4557 insertions, 0 deletions
diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/Makefile b/packages/Python/lldbsuite/test/tools/lldb-mi/Makefile new file mode 100644 index 0000000..8a7102e --- /dev/null +++ b/packages/Python/lldbsuite/test/tools/lldb-mi/Makefile @@ -0,0 +1,5 @@ +LEVEL = ../../make + +CXX_SOURCES := main.cpp + +include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiExit.py b/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiExit.py new file mode 100644 index 0000000..86a0a65 --- /dev/null +++ b/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiExit.py @@ -0,0 +1,84 @@ +""" +Test that the lldb-mi driver exits properly. +""" + +from __future__ import print_function + + + +import lldbmi_testcase +from lldbsuite.test.lldbtest import * + +class MiExitTestCase(lldbmi_testcase.MiTestCaseBase): + + mydir = TestBase.compute_mydir(__file__) + + @expectedFailureWindows("llvm.org/pr22274: need a pexpect replacement for windows") + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + def test_lldbmi_gdb_exit(self): + """Test that '-gdb-exit' terminates local debug session and exits.""" + + self.spawnLldbMi(args = None) + + # Load executable + self.runCmd("-file-exec-and-symbols %s" % self.myexe) + self.expect("\^done") + + # Run to main + self.runCmd("-break-insert -f main") + self.expect("\^done,bkpt={number=\"1\"") + self.runCmd("-exec-run") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + # Test -gdb-exit: try to exit and check that program is finished + self.runCmd("-gdb-exit") + self.expect("\^exit") + import pexpect + self.expect(pexpect.EOF) + + @expectedFailureWindows("llvm.org/pr22274: need a pexpect replacement for windows") + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + def test_lldbmi_quit(self): + """Test that 'quit' exits immediately.""" + + self.spawnLldbMi(args = None) + + # Load executable + self.runCmd("-file-exec-and-symbols %s" % self.myexe) + self.expect("\^done") + + # Run to main + self.runCmd("-break-insert -f main") + self.expect("\^done,bkpt={number=\"1\"") + self.runCmd("-exec-run") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + # Test quit: try to exit and check that program is finished + self.runCmd("quit") + import pexpect + self.expect(pexpect.EOF) + + @expectedFailureWindows("llvm.org/pr22274: need a pexpect replacement for windows") + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + def test_lldbmi_q(self): + """Test that 'q' exits immediately.""" + + self.spawnLldbMi(args = None) + + # Load executable + self.runCmd("-file-exec-and-symbols %s" % self.myexe) + self.expect("\^done") + + # Run to main + self.runCmd("-break-insert -f main") + self.expect("\^done,bkpt={number=\"1\"") + self.runCmd("-exec-run") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + # Test q: try to exit and check that program is finished + self.runCmd("q") + import pexpect + self.expect(pexpect.EOF) diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiFile.py b/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiFile.py new file mode 100644 index 0000000..8b4eac1 --- /dev/null +++ b/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiFile.py @@ -0,0 +1,77 @@ +""" +Test lldb-mi -file-xxx commands. +""" + +from __future__ import print_function + + + +import lldbmi_testcase +from lldbsuite.test.lldbtest import * + +class MiFileTestCase(lldbmi_testcase.MiTestCaseBase): + + mydir = TestBase.compute_mydir(__file__) + + @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + def test_lldbmi_file_exec_and_symbols_file(self): + """Test that 'lldb-mi --interpreter' works for -file-exec-and-symbols exe.""" + + self.spawnLldbMi(args = None) + + # Test that -file-exec-and-symbols works for filename + self.runCmd("-file-exec-and-symbols %s" % self.myexe) + self.expect("\^done") + + # Run + self.runCmd("-exec-run") + self.expect("\^running") + self.expect("\*stopped,reason=\"exited-normally\"") + + @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + def test_lldbmi_file_exec_and_symbols_absolute_path(self): + """Test that 'lldb-mi --interpreter' works for -file-exec-and-symbols fullpath/exe.""" + + self.spawnLldbMi(args = None) + + # Test that -file-exec-and-symbols works for absolute path + import os + path = os.path.join(os.getcwd(), self.myexe) + self.runCmd("-file-exec-and-symbols \"%s\"" % path) + self.expect("\^done") + + # Run + self.runCmd("-exec-run") + self.expect("\^running") + self.expect("\*stopped,reason=\"exited-normally\"") + + @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + def test_lldbmi_file_exec_and_symbols_relative_path(self): + """Test that 'lldb-mi --interpreter' works for -file-exec-and-symbols relpath/exe.""" + + self.spawnLldbMi(args = None) + + # Test that -file-exec-and-symbols works for relative path + path = "./%s" % self.myexe + self.runCmd("-file-exec-and-symbols %s" % path) + self.expect("\^done") + + # Run + self.runCmd("-exec-run") + self.expect("\^running") + self.expect("\*stopped,reason=\"exited-normally\"") + + @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + def test_lldbmi_file_exec_and_symbols_unknown_path(self): + """Test that 'lldb-mi --interpreter' works for -file-exec-and-symbols badpath/exe.""" + + self.spawnLldbMi(args = None) + + # Test that -file-exec-and-symbols fails on unknown path + path = "unknown_dir/%s" % self.myexe + self.runCmd("-file-exec-and-symbols %s" % path) + self.expect("\^error") diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiGdbSetShow.py b/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiGdbSetShow.py new file mode 100644 index 0000000..ab3eb1f --- /dev/null +++ b/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiGdbSetShow.py @@ -0,0 +1,190 @@ +""" +Test lldb-mi -gdb-set and -gdb-show commands. +""" + +from __future__ import print_function + + + +import unittest2 +import lldbmi_testcase +from lldbsuite.test.lldbtest import * + +class MiGdbSetShowTestCase(lldbmi_testcase.MiTestCaseBase): + + mydir = TestBase.compute_mydir(__file__) + + @expectedFailureWindows("llvm.org/pr22274: need a pexpect replacement for windows") + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + def test_lldbmi_gdb_set_target_async_default(self): + """Test that 'lldb-mi --interpreter' switches to async mode by default.""" + + self.spawnLldbMi(args = None) + + # Switch to sync mode + self.runCmd("-gdb-set target-async off") + self.expect("\^done") + self.runCmd("-gdb-show target-async") + self.expect("\^done,value=\"off\"") + + # Test that -gdb-set switches to async by default + self.runCmd("-gdb-set target-async") + self.expect("\^done") + self.runCmd("-gdb-show target-async") + self.expect("\^done,value=\"on\"") + + @expectedFailureWindows("llvm.org/pr22274: need a pexpect replacement for windows") + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + @expectedFlakeyLinux("llvm.org/pr26028") # Fails in ~1% of cases + def test_lldbmi_gdb_set_target_async_on(self): + """Test that 'lldb-mi --interpreter' can execute commands in async mode.""" + + self.spawnLldbMi(args = None) + + # Switch to sync mode + self.runCmd("-gdb-set target-async off") + self.expect("\^done") + self.runCmd("-gdb-show target-async") + self.expect("\^done,value=\"off\"") + + # Test that -gdb-set can switch to async mode + self.runCmd("-gdb-set target-async on") + self.expect("\^done") + self.runCmd("-gdb-show target-async") + self.expect("\^done,value=\"on\"") + + # Load executable + self.runCmd("-file-exec-and-symbols %s" % self.myexe) + self.expect("\^done") + + # Test that program is executed in async mode + self.runCmd("-exec-run") + self.expect("\*running") + self.expect("@\"argc=1") + + @expectedFailureWindows("llvm.org/pr22274: need a pexpect replacement for windows") + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + @expectedFailureLinux # Failing in ~11/600 dosep runs (build 3120-3122) + def test_lldbmi_gdb_set_target_async_off(self): + """Test that 'lldb-mi --interpreter' can execute commands in sync mode.""" + + self.spawnLldbMi(args = None) + + # Test that -gdb-set can switch to sync mode + self.runCmd("-gdb-set target-async off") + self.expect("\^done") + self.runCmd("-gdb-show target-async") + self.expect("\^done,value=\"off\"") + + # Load executable + self.runCmd("-file-exec-and-symbols %s" % self.myexe) + self.expect("\^done") + + # Test that program is executed in async mode + self.runCmd("-exec-run") + unexpected = [ "\*running" ] # "\*running" is async notification + it = self.expect(unexpected + [ "@\"argc=1\\\\r\\\\n" ]) + if it < len(unexpected): + self.fail("unexpected found: %s" % unexpected[it]) + + @expectedFailureWindows("llvm.org/pr22274: need a pexpect replacement for windows") + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + def test_lldbmi_gdb_show_target_async(self): + """Test that 'lldb-mi --interpreter' in async mode by default.""" + + self.spawnLldbMi(args = None) + + # Test that default target-async value is "on" + self.runCmd("-gdb-show target-async") + self.expect("\^done,value=\"on\"") + + @expectedFailureWindows("llvm.org/pr22274: need a pexpect replacement for windows") + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + def test_lldbmi_gdb_show_language(self): + """Test that 'lldb-mi --interpreter' can get current language.""" + + self.spawnLldbMi(args = None) + + # Load executable + self.runCmd("-file-exec-and-symbols %s" % self.myexe) + self.expect("\^done") + + # Run to main + self.runCmd("-break-insert -f main") + self.expect("\^done,bkpt={number=\"1\"") + self.runCmd("-exec-run") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + # Test that -gdb-show language gets current language + self.runCmd("-gdb-show language") + self.expect("\^done,value=\"c\+\+\"") + + @expectedFailureWindows("llvm.org/pr22274: need a pexpect replacement for windows") + @unittest2.expectedFailure("-gdb-set ignores unknown properties") + def test_lldbmi_gdb_set_unknown(self): + """Test that 'lldb-mi --interpreter' fails when setting an unknown property.""" + + self.spawnLldbMi(args = None) + + # Test that -gdb-set fails if property is unknown + self.runCmd("-gdb-set unknown some_value") + self.expect("\^error") + + @expectedFailureWindows("llvm.org/pr22274: need a pexpect replacement for windows") + @unittest2.expectedFailure("-gdb-show ignores unknown properties") + def test_lldbmi_gdb_show_unknown(self): + """Test that 'lldb-mi --interpreter' fails when showing an unknown property.""" + + self.spawnLldbMi(args = None) + + # Test that -gdb-show fails if property is unknown + self.runCmd("-gdb-show unknown") + self.expect("\^error") + + + @expectedFailureWindows("llvm.org/pr22274: need a pexpect replacement for windows") + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + @skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots + def test_lldbmi_gdb_set_ouptut_radix(self): + """Test that 'lldb-mi --interpreter' works for -gdb-set output-radix.""" + + self.spawnLldbMi(args = None) + + # Load executable + self.runCmd("-file-exec-and-symbols %s" % self.myexe) + self.expect("\^done") + + # Run to BP_printf + line = line_number('main.cpp', '// BP_printf') + self.runCmd("-break-insert main.cpp:%d" % line) + self.expect("\^done,bkpt={number=\"1\"") + self.runCmd("-exec-run") + self.expect("\^running"); + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + # Setup variable + self.runCmd("-var-create var_a * a"); + self.expect("\^done,name=\"var_a\",numchild=\"0\",value=\"10\",type=\"int\",thread-id=\"1\",has_more=\"0\"") + + # Test default output + self.runCmd("-var-evaluate-expression var_a"); + self.expect("\^done,value=\"10\""); + + # Test hex output + self.runCmd("-gdb-set output-radix 16"); + self.expect("\^done"); + self.runCmd("-var-evaluate-expression var_a"); + self.expect("\^done,value=\"0xa\""); + + # Test octal output + self.runCmd("-gdb-set output-radix 8"); + self.expect("\^done"); + self.runCmd("-var-evaluate-expression var_a"); + self.expect("\^done,value=\"012\""); + + # Test decimal output + self.runCmd("-gdb-set output-radix 10"); + self.expect("\^done"); + self.runCmd("-var-evaluate-expression var_a"); + self.expect("\^done,value=\"10\""); diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiLibraryLoaded.py b/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiLibraryLoaded.py new file mode 100644 index 0000000..4d9c935 --- /dev/null +++ b/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiLibraryLoaded.py @@ -0,0 +1,33 @@ +""" +Test lldb-mi =library-loaded notifications. +""" + +from __future__ import print_function + + + +import lldbmi_testcase +from lldbsuite.test.lldbtest import * + +class MiLibraryLoadedTestCase(lldbmi_testcase.MiTestCaseBase): + + mydir = TestBase.compute_mydir(__file__) + + @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + def test_lldbmi_library_loaded(self): + """Test that 'lldb-mi --interpreter' shows the =library-loaded notifications.""" + + self.spawnLldbMi(args = None) + + # Load executable + self.runCmd("-file-exec-and-symbols %s" % self.myexe) + self.expect("\^done") + + # Test =library-loaded + import os + path = os.path.join(os.getcwd(), self.myexe) + symbols_path = os.path.join(path + ".dSYM", "Contents", "Resources", "DWARF", self.myexe) + def add_slashes(x): return x.replace("\\", "\\\\").replace("\"", "\\\"").replace("\'", "\\\'").replace("\0", "\\\0") + self.expect([ "=library-loaded,id=\"%s\",target-name=\"%s\",host-name=\"%s\",symbols-loaded=\"1\",symbols-path=\"%s\",loaded_addr=\"-\",size=\"[0-9]+\"" % (add_slashes(path), add_slashes(path), add_slashes(path), add_slashes(symbols_path)), + "=library-loaded,id=\"%s\",target-name=\"%s\",host-name=\"%s\",symbols-loaded=\"0\",loaded_addr=\"-\",size=\"[0-9]+\"" % (add_slashes(path), add_slashes(path), add_slashes(path)) ]) diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiPrompt.py b/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiPrompt.py new file mode 100644 index 0000000..d810267 --- /dev/null +++ b/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiPrompt.py @@ -0,0 +1,54 @@ +""" +Test that the lldb-mi driver prints prompt properly. +""" + +from __future__ import print_function + + + +import lldbmi_testcase +from lldbsuite.test.lldbtest import * + +class MiPromptTestCase(lldbmi_testcase.MiTestCaseBase): + + mydir = TestBase.compute_mydir(__file__) + + @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + def test_lldbmi_prompt(self): + """Test that 'lldb-mi --interpreter' echos '(gdb)' after commands and events.""" + + self.spawnLldbMi(args = None) + + # Test that lldb-mi is ready after unknown command + self.runCmd("-unknown-command") + self.expect("\^error,msg=\"Driver\. Received command '-unknown-command'\. It was not handled\. Command 'unknown-command' not in Command Factory\"") + self.expect(self.child_prompt, exactly = True) + + # Test that lldb-mi is ready after -file-exec-and-symbols + self.runCmd("-file-exec-and-symbols %s" % self.myexe) + self.expect("\^done") + self.expect(self.child_prompt, exactly = True) + + # Test that lldb-mi is ready after -break-insert + self.runCmd("-break-insert -f main") + self.expect("\^done,bkpt={number=\"1\"") + self.expect(self.child_prompt, exactly = True) + + # Test that lldb-mi is ready after -exec-run + self.runCmd("-exec-run") + self.expect("\*running") + self.expect(self.child_prompt, exactly = True) + + # Test that lldb-mi is ready after BP hit + self.expect("\*stopped,reason=\"breakpoint-hit\"") + self.expect(self.child_prompt, exactly = True) + + # Test that lldb-mi is ready after -exec-continue + self.runCmd("-exec-continue") + self.expect("\^running") + self.expect(self.child_prompt, exactly = True) + + # Test that lldb-mi is ready after program exited + self.expect("\*stopped,reason=\"exited-normally\"") + self.expect(self.child_prompt, exactly = True) diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/breakpoint/Makefile b/packages/Python/lldbsuite/test/tools/lldb-mi/breakpoint/Makefile new file mode 100644 index 0000000..314f1cb --- /dev/null +++ b/packages/Python/lldbsuite/test/tools/lldb-mi/breakpoint/Makefile @@ -0,0 +1,5 @@ +LEVEL = ../../../make + +CXX_SOURCES := main.cpp + +include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/breakpoint/TestMiBreak.py b/packages/Python/lldbsuite/test/tools/lldb-mi/breakpoint/TestMiBreak.py new file mode 100644 index 0000000..020954f --- /dev/null +++ b/packages/Python/lldbsuite/test/tools/lldb-mi/breakpoint/TestMiBreak.py @@ -0,0 +1,246 @@ +""" +Test lldb-mi -break-xxx commands. +""" + +from __future__ import print_function + + + +import unittest2 +import lldbmi_testcase +from lldbsuite.test.lldbtest import * + +class MiBreakTestCase(lldbmi_testcase.MiTestCaseBase): + + mydir = TestBase.compute_mydir(__file__) + + @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + def test_lldbmi_break_insert_function_pending(self): + """Test that 'lldb-mi --interpreter' works for pending function breakpoints.""" + + self.spawnLldbMi(args = None) + + self.runCmd("-file-exec-and-symbols %s" % self.myexe) + self.expect("\^done") + + self.runCmd("-break-insert -f printf") + #FIXME function name is unknown on Darwin, fullname should be ??, line is -1 + #self.expect("\^done,bkpt={number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"0xffffffffffffffff\",func=\"printf\",file=\"\?\?\",fullname=\"\?\?\",line=\"-1\",pending=\[\"printf\"\],times=\"0\",original-location=\"printf\"}") + self.expect("\^done,bkpt={number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"0xffffffffffffffff\",func=\"\?\?\",file=\"\?\?\",fullname=\"\?\?/\?\?\",line=\"0\",pending=\[\"printf\"\],times=\"0\",original-location=\"printf\"}") + #FIXME function name is unknown on Darwin, fullname should be ??, line -1 + #self.expect("=breakpoint-modified,bkpt={number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"0xffffffffffffffff\",func=\"printf\",file=\"\?\?\",fullname=\"\?\?\",line=\"-1\",pending=\[\"printf\"\],times=\"0\",original-location=\"printf\"}") + self.expect("=breakpoint-modified,bkpt={number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"0xffffffffffffffff\",func=\"\?\?\",file=\"\?\?\",fullname=\"\?\?/\?\?\",line=\"0\",pending=\[\"printf\"\],times=\"0\",original-location=\"printf\"}") + + self.runCmd("-exec-run") + self.expect("\^running") + self.expect("=breakpoint-modified,bkpt={number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"(?!0xffffffffffffffff)0x[0-9a-f]+\",func=\".+?\",file=\".+?\",fullname=\".+?\",line=\"(-1|\d+)\",pending=\[\"printf\"\],times=\"0\",original-location=\"printf\"}") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + def test_lldbmi_break_insert_function(self): + """Test that 'lldb-mi --interpreter' works for function breakpoints.""" + + self.spawnLldbMi(args = None) + + self.runCmd("-file-exec-and-symbols %s" % self.myexe) + self.expect("\^done") + + self.runCmd("-break-insert -f main") + self.expect("\^done,bkpt={number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"(?!0xffffffffffffffff)0x[0-9a-f]+\",func=\"main\",file=\"main\.cpp\",fullname=\".+?main\.cpp\",line=\"\d+\",pending=\[\"main\"\],times=\"0\",original-location=\"main\"}") + self.expect("=breakpoint-modified,bkpt={number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"(?!0xffffffffffffffff)0x[0-9a-f]+\",func=\"main\",file=\"main\.cpp\",fullname=\".+?main\.cpp\",line=\"\d+\",pending=\[\"main\"\],times=\"0\",original-location=\"main\"}") + + self.runCmd("-exec-run") + self.expect("\^running") + self.expect("=breakpoint-modified,bkpt={number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"(?!0xffffffffffffffff)0x[0-9a-f]+\",func=\"main\",file=\"main\.cpp\",fullname=\".+?main\.cpp\",line=\"\d+\",pending=\[\"main\"\],times=\"0\",original-location=\"main\"}") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + # Test that -break-insert can set non-pending BP + self.runCmd("-break-insert printf") + #FIXME function name is unknown on Darwin + #self.expect("\^done,bkpt={number=\"2\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"(?!0xffffffffffffffff)0x[0-9a-f]+\",func=\"printf\",file=\".+?\",fullname=\".+?\",line=\"(-1|\d+)\",times=\"0\",original-location=\"printf\"}") + self.expect("\^done,bkpt={number=\"2\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"(?!0xffffffffffffffff)0x[0-9a-f]+\",func=\".+?\",file=\".+?\",fullname=\".+?\",line=\"(-1|\d+)\",times=\"0\",original-location=\"printf\"}") + #FIXME function name is unknown on Darwin + #self.expect("=breakpoint-modified,bkpt={number=\"2\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"(?!0xffffffffffffffff)0x[0-9a-f]+\",func=\"printf\",file=\".+?\",fullname=\".+?\",line=\"(-1|\d+)\",times=\"0\",original-location=\"printf\"}") + self.expect("=breakpoint-modified,bkpt={number=\"2\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"(?!0xffffffffffffffff)0x[0-9a-f]+\",func=\".+?\",file=\".+?\",fullname=\".+?\",line=\"(-1|\d+)\",times=\"0\",original-location=\"printf\"}") + # FIXME function name is unknown on Darwin + #self.expect("=breakpoint-modified,bkpt={number=\"2\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"(?!0xffffffffffffffff)0x[0-9a-f]+\",func=\"printf\",file=\".+?\",fullname=\".+?\",line=\"(-1|\d+)\",times=\"0\",original-location=\"printf\"}") + self.expect("=breakpoint-modified,bkpt={number=\"2\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"(?!0xffffffffffffffff)0x[0-9a-f]+\",func=\".+?\",file=\".+?\",fullname=\".+?\",line=\"(-1|\d+)\",times=\"0\",original-location=\"printf\"}") + + # Test that -break-insert fails if non-pending BP can't be resolved + self.runCmd("-break-insert unknown_func") + self.expect("\^error,msg=\"Command 'break-insert'. Breakpoint location 'unknown_func' not found\"") + + # Test that non-pending BP was set correctly + self.runCmd("-exec-continue") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\".*bkptno=\"2\"") + + # Test that we can set a BP using the file:func syntax + self.runCmd("-break-insert main.cpp:main") + self.expect("\^done,bkpt={number=\"4\"") + self.runCmd("-break-insert main.cpp:ns::foo1") + self.expect("\^done,bkpt={number=\"5\"") + #FIXME: quotes on filenames aren't handled correctly in lldb-mi. + #self.runCmd("-break-insert \"main.cpp\":main") + #self.expect("\^done,bkpt={number=\"6\"") + + # We should hit BP #5 on 'main.cpp:ns::foo1' + self.runCmd("-exec-continue") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\".*bkptno=\"5\"") + + #FIXME: this test is disabled due to lldb bug llvm.org/pr24271. + # Test that we can set a BP using the global namespace token + #self.runCmd("-break-insert ::main") + #self.expect("\^done,bkpt={number=\"7\"") + #self.runCmd("-break-insert main.cpp:::main") + #self.expect("\^done,bkpt={number=\"8\"") + + @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + def test_lldbmi_break_insert_file_line_pending(self): + """Test that 'lldb-mi --interpreter' works for pending file:line breakpoints.""" + + self.spawnLldbMi(args = None) + + self.runCmd("-file-exec-and-symbols %s" % self.myexe) + self.expect("\^done") + + # Find the line number to break inside main() and set + # pending BP + line = line_number('main.cpp', '// BP_return') + self.runCmd("-break-insert -f main.cpp:%d" % line) + self.expect("\^done,bkpt={number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"(?!0xffffffffffffffff)0x[0-9a-f]+\",func=\"main\",file=\"main\.cpp\",fullname=\".+?main\.cpp\",line=\"%d\",pending=\[\"main.cpp:%d\"\],times=\"0\",original-location=\"main.cpp:%d\"}" % (line, line, line)) + self.expect("=breakpoint-modified,bkpt={number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"(?!0xffffffffffffffff)0x[0-9a-f]+\",func=\"main\",file=\"main\.cpp\",fullname=\".+?main\.cpp\",line=\"%d\",pending=\[\"main.cpp:%d\"\],times=\"0\",original-location=\"main.cpp:%d\"}" % (line, line, line)) + + self.runCmd("-exec-run") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + def test_lldbmi_break_insert_file_line(self): + """Test that 'lldb-mi --interpreter' works for file:line breakpoints.""" + + self.spawnLldbMi(args = None) + + self.runCmd("-file-exec-and-symbols %s" % self.myexe) + self.expect("\^done") + + self.runCmd("-break-insert -f main") + self.expect("\^done,bkpt={number=\"1\"") + + self.runCmd("-exec-run") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + # Test that -break-insert can set non-pending BP + line = line_number('main.cpp', '// BP_return') + self.runCmd("-break-insert main.cpp:%d" % line) + self.expect("\^done,bkpt={number=\"2\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"(?!0xffffffffffffffff)0x[0-9a-f]+\",func=\"main\",file=\"main\.cpp\",fullname=\".+?main\.cpp\",line=\"%d\",times=\"0\",original-location=\"main.cpp:%d\"}" % (line, line)) + self.expect("=breakpoint-modified,bkpt={number=\"2\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"(?!0xffffffffffffffff)0x[0-9a-f]+\",func=\"main\",file=\"main\.cpp\",fullname=\".+?main\.cpp\",line=\"%d\",times=\"0\",original-location=\"main.cpp:%d\"}" % (line, line)) + + # Test that -break-insert fails if non-pending BP can't be resolved + self.runCmd("-break-insert unknown_file:1") + self.expect("\^error,msg=\"Command 'break-insert'. Breakpoint location 'unknown_file:1' not found\"") + + # Test that non-pending BP was set correctly + self.runCmd("-exec-continue") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + @unittest2.expectedFailure("-break-insert doesn't work for absolute path") + def test_lldbmi_break_insert_file_line_absolute_path(self): + """Test that 'lldb-mi --interpreter' works for file:line breakpoints.""" + + self.spawnLldbMi(args = None) + + self.runCmd("-file-exec-and-symbols %s" % self.myexe) + self.expect("\^done") + + self.runCmd("-break-insert -f main") + self.expect("\^done,bkpt={number=\"1\"") + + self.runCmd("-exec-run") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + import os + path = os.path.join(os.getcwd(), "main.cpp") + line = line_number('main.cpp', '// BP_return') + self.runCmd("-break-insert %s:%d" % (path, line)) + self.expect("\^done,bkpt={number=\"2\"") + + self.runCmd("-exec-continue") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + def test_lldbmi_break_insert_settings(self): + """Test that 'lldb-mi --interpreter' can set breakpoints accoridng to global options.""" + + self.spawnLldbMi(args = None) + + # Load executable + self.runCmd("-file-exec-and-symbols %s" % self.myexe) + self.expect("\^done") + + # Set target.move-to-nearest-code=off and try to set BP #1 that shouldn't be hit + self.runCmd("-interpreter-exec console \"settings set target.move-to-nearest-code off\"") + self.expect("\^done") + line = line_number('main.cpp', '// BP_before_main') + self.runCmd("-break-insert -f main.cpp:%d" % line) + self.expect("\^done,bkpt={number=\"1\"") + + # Test that non-pending BP will not be set on non-existing line if target.move-to-nearest-code=off + # Note: this increases the BP number by 1 even though BP #2 is invalid. + self.runCmd("-break-insert main.cpp:%d" % line) + self.expect("\^error,msg=\"Command 'break-insert'. Breakpoint location 'main.cpp:%d' not found\"" % line) + + # Set target.move-to-nearest-code=on and target.skip-prologue=on and set BP #3 + self.runCmd("-interpreter-exec console \"settings set target.move-to-nearest-code on\"") + self.runCmd("-interpreter-exec console \"settings set target.skip-prologue on\"") + self.expect("\^done") + self.runCmd("-break-insert main.cpp:%d" % line) + self.expect("\^done,bkpt={number=\"3\"") + + # Set target.skip-prologue=off and set BP #4 + self.runCmd("-interpreter-exec console \"settings set target.skip-prologue off\"") + self.expect("\^done") + self.runCmd("-break-insert main.cpp:%d" % line) + self.expect("\^done,bkpt={number=\"4\"") + + # Test that BP #4 is located before BP #3 + self.runCmd("-exec-run") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\",disp=\"del\",bkptno=\"4\"") + + # Test that BP #3 is hit + self.runCmd("-exec-continue") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\",disp=\"del\",bkptno=\"3\"") + + # Test that the target.language=pascal setting works and that BP #5 is NOT set + self.runCmd("-interpreter-exec console \"settings set target.language c\"") + self.expect("\^done") + self.runCmd("-break-insert ns.foo1") + self.expect("\^error") + + # Test that the target.language=c++ setting works and that BP #6 is hit + self.runCmd("-interpreter-exec console \"settings set target.language c++\"") + self.expect("\^done") + self.runCmd("-break-insert ns::foo1") + self.expect("\^done,bkpt={number=\"6\"") + self.runCmd("-exec-continue") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\",disp=\"del\",bkptno=\"6\"") + + # Test that BP #1 and #2 weren't set by running to program exit + self.runCmd("-exec-continue") + self.expect("\^running") + self.expect("\*stopped,reason=\"exited-normally\"") diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/breakpoint/main.cpp b/packages/Python/lldbsuite/test/tools/lldb-mi/breakpoint/main.cpp new file mode 100644 index 0000000..9416a0d --- /dev/null +++ b/packages/Python/lldbsuite/test/tools/lldb-mi/breakpoint/main.cpp @@ -0,0 +1,27 @@ +//===-- main.cpp ------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include <cstdio> + +namespace ns +{ + int foo1(void) { printf("In foo1\n"); return 1; } + int foo2(void) { printf("In foo2\n"); return 2; } +} + +// BP_before_main + +int x; +int +main(int argc, char const *argv[]) +{ + printf("Print a formatted string so that GCC does not optimize this printf call: %s\n", argv[0]); + x = ns::foo1() + ns::foo2(); + return 0; // BP_return +} diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/control/Makefile b/packages/Python/lldbsuite/test/tools/lldb-mi/control/Makefile new file mode 100644 index 0000000..314f1cb --- /dev/null +++ b/packages/Python/lldbsuite/test/tools/lldb-mi/control/Makefile @@ -0,0 +1,5 @@ +LEVEL = ../../../make + +CXX_SOURCES := main.cpp + +include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/control/TestMiExec.py b/packages/Python/lldbsuite/test/tools/lldb-mi/control/TestMiExec.py new file mode 100644 index 0000000..742bbc8 --- /dev/null +++ b/packages/Python/lldbsuite/test/tools/lldb-mi/control/TestMiExec.py @@ -0,0 +1,457 @@ +""" +Test lldb-mi -exec-xxx commands. +""" + +from __future__ import print_function + + + +import lldbmi_testcase +from lldbsuite.test.lldbtest import * + +class MiExecTestCase(lldbmi_testcase.MiTestCaseBase): + + mydir = TestBase.compute_mydir(__file__) + + @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + @expectedFailureLinux # llvm.org/pr25000: lldb-mi does not receive broadcasted notification from Core/Process about process stopped + def test_lldbmi_exec_run(self): + """Test that 'lldb-mi --interpreter' can stop at entry.""" + + self.spawnLldbMi(args = None) + + # Load executable + self.runCmd("-file-exec-and-symbols %s" % self.myexe) + self.expect("\^done") + + # Test that program is stopped at entry + self.runCmd("-exec-run --start") + self.expect("\^running") + self.expect("\*stopped,reason=\"signal-received\",signal-name=\"SIGSTOP\",signal-meaning=\"Stop\",.*?thread-id=\"1\",stopped-threads=\"all\"") + # Test that lldb-mi is ready to execute next commands + self.expect(self.child_prompt, exactly = True) + + @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + def test_lldbmi_exec_abort(self): + """Test that 'lldb-mi --interpreter' works for -exec-abort.""" + + self.spawnLldbMi(args = None) + + # Test that -exec-abort fails on invalid process + self.runCmd("-exec-abort") + self.expect("\^error,msg=\"Command 'exec-abort'\. Invalid process during debug session\"") + + # Load executable + self.runCmd("-file-exec-and-symbols %s" % self.myexe) + self.expect("\^done") + + # Set arguments + self.runCmd("-exec-arguments arg1") + self.expect("\^done") + + # Run to main + self.runCmd("-break-insert -f main") + self.expect("\^done,bkpt={number=\"1\"") + self.runCmd("-exec-run") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + # Test that arguments were passed + self.runCmd("-data-evaluate-expression argc") + self.expect("\^done,value=\"2\"") + + # Test that program may be aborted + self.runCmd("-exec-abort") + self.expect("\^done") + self.expect("\*stopped,reason=\"exited-normally\"") + + # Test that program can be run again + self.runCmd("-exec-run") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + # Test that arguments were passed again + self.runCmd("-data-evaluate-expression argc") + self.expect("\^done,value=\"2\"") + + # Test that program may be aborted again + self.runCmd("-exec-abort") + self.expect("\^done") + self.expect("\*stopped,reason=\"exited-normally\"") + + @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + def test_lldbmi_exec_arguments_set(self): + """Test that 'lldb-mi --interpreter' can pass args using -exec-arguments.""" + + self.spawnLldbMi(args = None) + + # Load executable + self.runCmd("-file-exec-and-symbols %s" % self.myexe) + self.expect("\^done") + + # Set arguments + self.runCmd("-exec-arguments --arg1 \"2nd arg\" third_arg fourth=\"4th arg\"") + self.expect("\^done") + + # Run to main + self.runCmd("-break-insert -f main") + self.expect("\^done,bkpt={number=\"1\"") + self.runCmd("-exec-run") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + # Check argc and argv to see if arg passed + self.runCmd("-data-evaluate-expression argc") + self.expect("\^done,value=\"5\"") + #self.runCmd("-data-evaluate-expression argv[1]") + #self.expect("\^done,value=\"--arg1\"") + self.runCmd("-interpreter-exec command \"print argv[1]\"") + self.expect("\"--arg1\"") + #self.runCmd("-data-evaluate-expression argv[2]") + #self.expect("\^done,value=\"2nd arg\"") + self.runCmd("-interpreter-exec command \"print argv[2]\"") + self.expect("\"2nd arg\"") + #self.runCmd("-data-evaluate-expression argv[3]") + #self.expect("\^done,value=\"third_arg\"") + self.runCmd("-interpreter-exec command \"print argv[3]\"") + self.expect("\"third_arg\"") + #self.runCmd("-data-evaluate-expression argv[4]") + #self.expect("\^done,value=\"fourth=\\\\\\\"4th arg\\\\\\\"\"") + self.runCmd("-interpreter-exec command \"print argv[4]\"") + self.expect("\"fourth=\\\\\\\"4th arg\\\\\\\"\"") + + @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + def test_lldbmi_exec_arguments_reset(self): + """Test that 'lldb-mi --interpreter' can reset previously set args using -exec-arguments.""" + + self.spawnLldbMi(args = None) + + # Load executable + self.runCmd("-file-exec-and-symbols %s" % self.myexe) + self.expect("\^done") + + # Set arguments + self.runCmd("-exec-arguments arg1") + self.expect("\^done") + self.runCmd("-exec-arguments") + self.expect("\^done") + + # Run to main + self.runCmd("-break-insert -f main") + self.expect("\^done,bkpt={number=\"1\"") + self.runCmd("-exec-run") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + # Check argc to see if arg passed + self.runCmd("-data-evaluate-expression argc") + self.expect("\^done,value=\"1\"") + + @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + def test_lldbmi_exec_next(self): + """Test that 'lldb-mi --interpreter' works for stepping.""" + + self.spawnLldbMi(args = None) + + # Load executable + self.runCmd("-file-exec-and-symbols %s" % self.myexe) + self.expect("\^done") + + # Run to main + self.runCmd("-break-insert -f main") + self.expect("\^done,bkpt={number=\"1\"") + self.runCmd("-exec-run") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + # Warning: the following is sensitive to the lines in the source + + # 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\"") + + # 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\"") + + # 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\"") + + # 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\"") + + # Test that an invalid --thread is handled + self.runCmd("-exec-next --thread 0") + self.expect("\^error,message=\"error: Thread index 0 is out of range") + self.runCmd("-exec-next --thread 10") + self.expect("\^error,message=\"error: Thread index 10 is out of range") + + # Test that an invalid --frame is handled + # FIXME: no error is returned + self.runCmd("-exec-next --frame 10") + #self.expect("\^error: Frame index 10 is out of range") + + @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + @expectedFailurei386 #xfail to get buildbot green, failing config: i386 binary running on ubuntu 14.04 x86_64 + def test_lldbmi_exec_next_instruction(self): + """Test that 'lldb-mi --interpreter' works for instruction stepping.""" + + self.spawnLldbMi(args = None) + + # Load executable + self.runCmd("-file-exec-and-symbols %s" % self.myexe) + self.expect("\^done") + + # Run to main + self.runCmd("-break-insert -f main") + self.expect("\^done,bkpt={number=\"1\"") + self.runCmd("-exec-run") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + # Warning: the following is sensitive to the lines in the + # source and optimizations + + # 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\"") + + # 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\"") + + # 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\"") + + # 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|30)\"") + + # Test that an invalid --thread is handled + self.runCmd("-exec-next-instruction --thread 0") + self.expect("\^error,message=\"error: Thread index 0 is out of range") + self.runCmd("-exec-next-instruction --thread 10") + self.expect("\^error,message=\"error: Thread index 10 is out of range") + + # Test that an invalid --frame is handled + # FIXME: no error is returned + self.runCmd("-exec-next-instruction --frame 10") + #self.expect("\^error: Frame index 10 is out of range") + + @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + def test_lldbmi_exec_step(self): + """Test that 'lldb-mi --interpreter' works for stepping into.""" + + self.spawnLldbMi(args = None) + + # Load executable + self.runCmd("-file-exec-and-symbols %s" % self.myexe) + self.expect("\^done") + + # Run to main + self.runCmd("-break-insert -f main") + self.expect("\^done,bkpt={number=\"1\"") + self.runCmd("-exec-run") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + # Warning: the following is sensitive to the lines in the source + + # Test that -exec-step steps into (or not) printf depending on debug info + # Note that message is different in Darwin and Linux: + # Darwin: "*stopped,reason=\"end-stepping-range\",frame={addr=\"0x[0-9a-f]+\",func=\"main\",args=[{name=\"argc\",value=\"1\"},{name=\"argv\",value="0x[0-9a-f]+\"}],file=\"main.cpp\",fullname=\".+main.cpp\",line=\"\d\"},thread-id=\"1\",stopped-threads=\"all\" + # 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") + 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.*?\"") + # 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\"") + + # Test that -exec-step steps into s_MyFunction + # (and that --frame is optional) + self.runCmd("-exec-step --thread 1") + self.expect("\^running") + 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.*?\"") + + # Test that an invalid --thread is handled + self.runCmd("-exec-step --thread 0") + self.expect("\^error,message=\"error: Thread index 0 is out of range") + self.runCmd("-exec-step --thread 10") + self.expect("\^error,message=\"error: Thread index 10 is out of range") + + # Test that an invalid --frame is handled + # FIXME: no error is returned + self.runCmd("-exec-step --frame 10") + #self.expect("\^error: Frame index 10 is out of range") + + @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows + @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.""" + + self.spawnLldbMi(args = None) + + # Load executable + self.runCmd("-file-exec-and-symbols %s" % self.myexe) + self.expect("\^done") + + # Warning: the following is sensitive to the lines in the + # source and optimizations + + # Run to main + self.runCmd("-break-insert -f main") + self.expect("\^done,bkpt={number=\"1\"") + self.runCmd("-exec-run") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + # 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\"") + + # 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\"") + + # 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.*?\"") + + # 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.*?\"") + + # 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.*?\"") + + # Test that an invalid --thread is handled + self.runCmd("-exec-step-instruction --thread 0") + self.expect("\^error,message=\"error: Thread index 0 is out of range") + self.runCmd("-exec-step-instruction --thread 10") + self.expect("\^error,message=\"error: Thread index 10 is out of range") + + # Test that an invalid --frame is handled + # FIXME: no error is returned + self.runCmd("-exec-step-instruction --frame 10") + #self.expect("\^error: Frame index 10 is out of range") + + @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + def test_lldbmi_exec_finish(self): + """Test that 'lldb-mi --interpreter' works for -exec-finish.""" + + self.spawnLldbMi(args = None) + + # Load executable + self.runCmd("-file-exec-and-symbols %s" % self.myexe) + self.expect("\^done") + + # Set BP at g_MyFunction and run to BP + self.runCmd("-break-insert -f g_MyFunction") + self.expect("\^done,bkpt={number=\"1\"") + self.runCmd("-exec-run") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + # 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\"") + + # Run to BP inside s_MyFunction call + self.runCmd("-break-insert s_MyFunction") + self.expect("\^done,bkpt={number=\"2\"") + self.runCmd("-exec-continue") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + # Test that -exec-finish hits BP at g_MyFunction call inside + # s_MyFunction (and that --thread is optional) + self.runCmd("-exec-finish --frame 0") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + # Test that -exec-finish returns from g_MyFunction call inside + # 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.*?\"") + + # 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\"") + + # Test that an invalid --thread is handled + self.runCmd("-exec-finish --thread 0") + self.expect("\^error,message=\"error: Thread index 0 is out of range") + self.runCmd("-exec-finish --thread 10") + self.expect("\^error,message=\"error: Thread index 10 is out of range") + + # Test that an invalid --frame is handled + # FIXME: no error is returned + #self.runCmd("-exec-finish --frame 10") + #self.expect("\^error: Frame index 10 is out of range") + + # Set BP at printf and run to BP + self.runCmd("-break-insert -f printf") + self.expect("\^done,bkpt={number=\"3\"") + self.runCmd("-exec-continue") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + ## 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\"") diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/control/main.cpp b/packages/Python/lldbsuite/test/tools/lldb-mi/control/main.cpp new file mode 100644 index 0000000..ae0c3d9 --- /dev/null +++ b/packages/Python/lldbsuite/test/tools/lldb-mi/control/main.cpp @@ -0,0 +1,33 @@ +//===-- main.cpp ------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include <cstdio> + +void +g_MyFunction(void) +{ + printf("g_MyFunction"); +} + +static void +s_MyFunction(void) +{ + g_MyFunction(); + printf("s_MyFunction"); +} + +int +main(int argc, char const *argv[]) +{ + printf("start"); + g_MyFunction(); + s_MyFunction(); + printf("exit"); + return 0; +} diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/data/Makefile b/packages/Python/lldbsuite/test/tools/lldb-mi/data/Makefile new file mode 100644 index 0000000..314f1cb --- /dev/null +++ b/packages/Python/lldbsuite/test/tools/lldb-mi/data/Makefile @@ -0,0 +1,5 @@ +LEVEL = ../../../make + +CXX_SOURCES := main.cpp + +include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/data/TestMiData.py b/packages/Python/lldbsuite/test/tools/lldb-mi/data/TestMiData.py new file mode 100644 index 0000000..df9f541 --- /dev/null +++ b/packages/Python/lldbsuite/test/tools/lldb-mi/data/TestMiData.py @@ -0,0 +1,337 @@ +""" +Test lldb-mi -data-xxx commands. +""" + +from __future__ import print_function + + + +import unittest2 +import lldbmi_testcase +from lldbsuite.test.lldbtest import * + +class MiDataTestCase(lldbmi_testcase.MiTestCaseBase): + + mydir = TestBase.compute_mydir(__file__) + + @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + def test_lldbmi_data_disassemble(self): + """Test that 'lldb-mi --interpreter' works for -data-disassemble.""" + + self.spawnLldbMi(args = None) + + # Load executable + self.runCmd("-file-exec-and-symbols %s" % self.myexe) + self.expect("\^done") + + # Run to main + self.runCmd("-break-insert -f main") + self.expect("\^done,bkpt={number=\"1\"") + self.runCmd("-exec-run") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + # Get an address for disassembling: use main + self.runCmd("-data-evaluate-expression main") + self.expect("\^done,value=\"0x[0-9a-f]+ \(a.out`main at main.cpp:[0-9]+\)\"") + addr = int(self.child.after.split("\"")[1].split(" ")[0], 16) + + # Test -data-disassemble: try to disassemble some address + self.runCmd("-data-disassemble -s %#x -e %#x -- 0" % (addr, addr + 0x10)) + self.expect("\^done,asm_insns=\[{address=\"0x0*%x\",func-name=\"main\",offset=\"0\",size=\"[1-9]+\",inst=\".+?\"}," % addr) + + # Test -data-disassemble without "--" + self.runCmd("-data-disassemble -s %#x -e %#x 0" % (addr, addr + 0x10)) + self.expect("\^done,asm_insns=\[{address=\"0x0*%x\",func-name=\"main\",offset=\"0\",size=\"[1-9]+\",inst=\".+?\"}," % addr) + + # Run to hello_world + self.runCmd("-break-insert -f hello_world") + self.expect("\^done,bkpt={number=\"2\"") + self.runCmd("-exec-continue") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + # Get an address for disassembling: use hello_world + self.runCmd("-data-evaluate-expression hello_world") + self.expect("\^done,value=\"0x[0-9a-f]+ \(a.out`hello_world\(\) at main.cpp:[0-9]+\)\"") + addr = int(self.child.after.split("\"")[1].split(" ")[0], 16) + + # Test -data-disassemble: try to disassemble some address + self.runCmd("-data-disassemble -s %#x -e %#x -- 0" % (addr, addr + 0x10)) + + # This matches a line similar to: + # Darwin: {address="0x0000000100000f18",func-name="hello_world()",offset="8",size="7",inst="leaq 0x65(%rip), %rdi; \"Hello, World!\\n\""}, + # Linux: {address="0x0000000000400642",func-name="hello_world()",offset="18",size="5",inst="callq 0x4004d0; symbol stub for: printf"} + # To match the escaped characters in the ouptut, we must use four backslashes per matches backslash + # See https://docs.python.org/2/howto/regex.html#the-backslash-plague + self.expect([ "{address=\"0x[0-9a-f]+\",func-name=\"hello_world\(\)\",offset=\"[0-9]+\",size=\"[0-9]+\",inst=\".+?; \\\\\"Hello, World!\\\\\\\\n\\\\\"\"}", + "{address=\"0x[0-9a-f]+\",func-name=\"hello_world\(\)\",offset=\"[0-9]+\",size=\"[0-9]+\",inst=\".+?; symbol stub for: printf\"}" ]) + + @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + @unittest2.skip("-data-evaluate-expression doesn't work on globals") #FIXME: the global case worked before refactoring + def test_lldbmi_data_read_memory_bytes_global(self): + """Test that -data-read-memory-bytes can access global buffers.""" + + self.spawnLldbMi(args = None) + + # Load executable + self.runCmd("-file-exec-and-symbols %s" % self.myexe) + self.expect("\^done") + + # Run to main + self.runCmd("-break-insert -f main") + self.expect("\^done,bkpt={number=\"1\"") + self.runCmd("-exec-run") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + # Get address of char[] (global) + self.runCmd("-data-evaluate-expression &g_CharArray") + self.expect("\^done,value=\"0x[0-9a-f]+\"") + addr = int(self.child.after.split("\"")[1], 16) + size = 5 + + # Test that -data-read-memory-bytes works for char[] type (global) + self.runCmd("-data-read-memory-bytes %#x %d" % (addr, size)) + self.expect("\^done,memory=\[{begin=\"0x0*%x\",offset=\"0x0+\",end=\"0x0*%x\",contents=\"1112131400\"}\]" % (addr, addr + size)) + + # Get address of static char[] + self.runCmd("-data-evaluate-expression &s_CharArray") + self.expect("\^done,value=\"0x[0-9a-f]+\"") + addr = int(self.child.after.split("\"")[1], 16) + size = 5 + + # Test that -data-read-memory-bytes works for static char[] type + self.runCmd("-data-read-memory-bytes %#x %d" % (addr, size)) + self.expect("\^done,memory=\[{begin=\"0x0*%x\",offset=\"0x0+\",end=\"0x0*%x\",contents=\"1112131400\"}\]" % (addr, addr + size)) + + @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + def test_lldbmi_data_read_memory_bytes_local(self): + """Test that -data-read-memory-bytes can access local buffers.""" + + self.spawnLldbMi(args = None) + + # Load executable + self.runCmd('-file-exec-and-symbols %s' % self.myexe) + self.expect(r'\^done') + + # Run to BP_local_array_test_inner + line = line_number('main.cpp', '// BP_local_array_test_inner') + self.runCmd('-break-insert main.cpp:%d' % line) + self.expect(r'\^done,bkpt=\{number="1"') + self.runCmd('-exec-run') + self.expect(r'\^running') + self.expect(r'\*stopped,reason="breakpoint-hit"') + + # Get address of local char[] + self.runCmd('-data-evaluate-expression "(void *)&array"') + self.expect(r'\^done,value="0x[0-9a-f]+"') + addr = int(self.child.after.split('"')[1], 16) + size = 4 + + # Test that an unquoted hex literal address works + self.runCmd('-data-read-memory-bytes %#x %d' % (addr, size)) + self.expect(r'\^done,memory=\[\{begin="0x0*%x",offset="0x0+",end="0x0*%x",contents="01020304"\}\]' % (addr, addr + size)) + + # Test that a double-quoted hex literal address works + self.runCmd('-data-read-memory-bytes "%#x" %d' % (addr, size)) + self.expect(r'\^done,memory=\[\{begin="0x0*%x",offset="0x0+",end="0x0*%x",contents="01020304"\}\]' % (addr, addr + size)) + + # Test that unquoted expressions work + self.runCmd('-data-read-memory-bytes &array %d' % size) + self.expect(r'\^done,memory=\[\{begin="0x0*%x",offset="0x0+",end="0x0*%x",contents="01020304"\}\]' % (addr, addr + size)) + + # This doesn't work, and perhaps that makes sense, but it does work on GDB + self.runCmd('-data-read-memory-bytes array 4') + self.expect(r'\^error') + #self.expect(r'\^done,memory=\[\{begin="0x0*%x",offset="0x0+",end="0x0*%x",contents="01020304"\}\]' % (addr, addr + size)) + + self.runCmd('-data-read-memory-bytes &array[2] 2') + self.expect(r'\^done,memory=\[\{begin="0x0*%x",offset="0x0+",end="0x0*%x",contents="0304"\}\]' % (addr + 2, addr + size)) + + self.runCmd('-data-read-memory-bytes first_element_ptr %d' % size) + self.expect(r'\^done,memory=\[\{begin="0x0*%x",offset="0x0+",end="0x0*%x",contents="01020304"\}\]' % (addr, addr + size)) + + # Test that double-quoted expressions work + self.runCmd('-data-read-memory-bytes "&array" %d' % size) + self.expect(r'\^done,memory=\[\{begin="0x0*%x",offset="0x0+",end="0x0*%x",contents="01020304"\}\]' % (addr, addr + size)) + + self.runCmd('-data-read-memory-bytes "&array[0] + 1" 3') + self.expect(r'\^done,memory=\[\{begin="0x0*%x",offset="0x0+",end="0x0*%x",contents="020304"\}\]' % (addr + 1, addr + size)) + + self.runCmd('-data-read-memory-bytes "first_element_ptr + 1" 3') + self.expect(r'\^done,memory=\[\{begin="0x0*%x",offset="0x0+",end="0x0*%x",contents="020304"\}\]' % (addr + 1, addr + size)) + + # Test the -o (offset) option + self.runCmd('-data-read-memory-bytes -o 1 &array 3') + self.expect(r'\^done,memory=\[\{begin="0x0*%x",offset="0x0+",end="0x0*%x",contents="020304"\}\]' % (addr + 1, addr + size)) + + # Test the --thread option + self.runCmd('-data-read-memory-bytes --thread 1 &array 4') + self.expect(r'\^done,memory=\[\{begin="0x0*%x",offset="0x0+",end="0x0*%x",contents="01020304"\}\]' % (addr, addr + size)) + + # Test the --thread option with an invalid value + self.runCmd('-data-read-memory-bytes --thread 999 &array 4') + self.expect(r'\^error') + + # Test the --frame option (current frame) + self.runCmd('-data-read-memory-bytes --frame 0 &array 4') + self.expect(r'\^done,memory=\[\{begin="0x0*%x",offset="0x0+",end="0x0*%x",contents="01020304"\}\]' % (addr, addr + size)) + + # Test the --frame option (outer frame) + self.runCmd('-data-read-memory-bytes --frame 1 &array 4') + self.expect(r'\^done,memory=\[\{begin="0x[0-9a-f]+",offset="0x0+",end="0x[0-9a-f]+",contents="05060708"\}\]') + + # Test the --frame option with an invalid value + self.runCmd('-data-read-memory-bytes --frame 999 &array 4') + self.expect(r'\^error') + + # Test all the options at once + self.runCmd('-data-read-memory-bytes --thread 1 --frame 1 -o 2 &array 2') + self.expect(r'\^done,memory=\[\{begin="0x[0-9a-f]+",offset="0x0+",end="0x[0-9a-f]+",contents="0708"\}\]') + + # Test that an expression that references undeclared variables doesn't work + self.runCmd('-data-read-memory-bytes "&undeclared_array1 + undeclared_array2[1]" 2') + self.expect(r'\^error') + + # Test that the address argument is required + self.runCmd('-data-read-memory-bytes') + self.expect(r'\^error') + + # Test that the count argument is required + self.runCmd('-data-read-memory-bytes &array') + self.expect(r'\^error') + + # Test that the address and count arguments are required when other options are present + self.runCmd('-data-read-memory-bytes --thread 1') + self.expect(r'\^error') + + self.runCmd('-data-read-memory-bytes --thread 1 --frame 0') + self.expect(r'\^error') + + # Test that the count argument is required when other options are present + self.runCmd('-data-read-memory-bytes --thread 1 &array') + self.expect(r'\^error') + + @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + def test_lldbmi_data_list_register_names(self): + """Test that 'lldb-mi --interpreter' works for -data-list-register-names.""" + + self.spawnLldbMi(args = None) + + # Load executable + self.runCmd("-file-exec-and-symbols %s" % self.myexe) + self.expect("\^done") + + # Run to main + self.runCmd("-break-insert -f main") + self.expect("\^done,bkpt={number=\"1\"") + self.runCmd("-exec-run") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + # Test -data-list-register-names: try to get all registers + self.runCmd("-data-list-register-names") + self.expect("\^done,register-names=\[\".+?\",") + + # Test -data-list-register-names: try to get specified registers + self.runCmd("-data-list-register-names 0") + self.expect("\^done,register-names=\[\".+?\"\]") + + @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + def test_lldbmi_data_list_register_values(self): + """Test that 'lldb-mi --interpreter' works for -data-list-register-values.""" + + self.spawnLldbMi(args = None) + + # Load executable + self.runCmd("-file-exec-and-symbols %s" % self.myexe) + self.expect("\^done") + + # Run to main + self.runCmd("-break-insert -f main") + self.expect("\^done,bkpt={number=\"1\"") + self.runCmd("-exec-run") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + # Test -data-list-register-values: try to get all registers + self.runCmd("-data-list-register-values x") + self.expect("\^done,register-values=\[{number=\"0\",value=\"0x[0-9a-f]+\"") + + # Test -data-list-register-values: try to get specified registers + self.runCmd("-data-list-register-values x 0") + self.expect("\^done,register-values=\[{number=\"0\",value=\"0x[0-9a-f]+\"}\]") + + @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + def test_lldbmi_data_info_line(self): + """Test that 'lldb-mi --interpreter' works for -data-info-line.""" + + self.spawnLldbMi(args = None) + + # Load executable + self.runCmd("-file-exec-and-symbols %s" % self.myexe) + self.expect("\^done") + + # Run to main + self.runCmd("-break-insert -f main") + self.expect("\^done,bkpt={number=\"1\"") + self.runCmd("-exec-run") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + # Get the address of main and its line + self.runCmd("-data-evaluate-expression main") + self.expect("\^done,value=\"0x[0-9a-f]+ \(a.out`main at main.cpp:[0-9]+\)\"") + addr = int(self.child.after.split("\"")[1].split(" ")[0], 16) + line = line_number('main.cpp', '// FUNC_main') + + # Test that -data-info-line works for address + self.runCmd("-data-info-line *%#x" % addr) + self.expect("\^done,start=\"0x0*%x\",end=\"0x[0-9a-f]+\",file=\".+?main.cpp\",line=\"%d\"" % (addr, line)) + + # Test that -data-info-line works for file:line + self.runCmd("-data-info-line main.cpp:%d" % line) + self.expect("\^done,start=\"0x0*%x\",end=\"0x[0-9a-f]+\",file=\".+?main.cpp\",line=\"%d\"" % (addr, line)) + + # Test that -data-info-line fails when invalid address is specified + self.runCmd("-data-info-line *0x0") + self.expect("\^error,msg=\"Command 'data-info-line'\. Error: The LineEntry is absent or has an unknown format\.\"") + + # Test that -data-info-line fails when file is unknown + self.runCmd("-data-info-line unknown_file:1") + self.expect("\^error,msg=\"Command 'data-info-line'\. Error: The LineEntry is absent or has an unknown format\.\"") + + # Test that -data-info-line fails when line has invalid format + self.runCmd("-data-info-line main.cpp:bad_line") + self.expect("\^error,msg=\"error: invalid line number string 'bad_line'") + self.runCmd("-data-info-line main.cpp:0") + self.expect("\^error,msg=\"error: zero is an invalid line number") + + @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + def test_lldbmi_data_evaluate_expression(self): + """Test that 'lldb-mi --interpreter' works for -data-evaluate-expression.""" + + self.spawnLldbMi(args = None) + + # Load executable + self.runCmd("-file-exec-and-symbols %s" % self.myexe) + self.expect("\^done") + + line = line_number('main.cpp', '// BP_local_2d_array_test') + self.runCmd('-break-insert main.cpp:%d' % line) + self.expect("\^done,bkpt={number=\"1\"") + self.runCmd("-exec-run") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + # Check 2d array + self.runCmd("-data-evaluate-expression array2d") + self.expect("\^done,value=\"\{\[0\] = \{\[0\] = 1, \[1\] = 2, \[2\] = 3\}, \[1\] = \{\[0\] = 4, \[1\] = 5, \[2\] = 6\}\}\"") diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/data/main.cpp b/packages/Python/lldbsuite/test/tools/lldb-mi/data/main.cpp new file mode 100644 index 0000000..8030fe8 --- /dev/null +++ b/packages/Python/lldbsuite/test/tools/lldb-mi/data/main.cpp @@ -0,0 +1,59 @@ +//===-- main.cpp ------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include <stdio.h> + +const char g_CharArray[] = "\x10\x11\x12\x13"; +static const char s_CharArray[] = "\x20\x21\x22\x23"; + +void +local_array_test_inner() +{ + char array[] = { 0x01, 0x02, 0x03, 0x04 }; + char *first_element_ptr = &array[0]; + // BP_local_array_test_inner + return; +} + +void +local_array_test() +{ + char array[] = { 0x05, 0x06, 0x07, 0x08 }; + // BP_local_array_test + local_array_test_inner(); + return; +} + +void +local_2d_array_test() +{ + int array2d[2][3]; + array2d[0][0] = 1; + array2d[0][1] = 2; + array2d[0][2] = 3; + array2d[1][0] = 4; + array2d[1][1] = 5; + array2d[1][2] = 6; + return; // BP_local_2d_array_test +} + +void +hello_world() +{ + printf("Hello, World!\n"); // BP_hello_world +} + +int +main(int argc, char const *argv[]) +{ // FUNC_main + local_array_test(); + hello_world(); + local_2d_array_test(); + return 0; +} diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/interpreter/Makefile b/packages/Python/lldbsuite/test/tools/lldb-mi/interpreter/Makefile new file mode 100644 index 0000000..314f1cb --- /dev/null +++ b/packages/Python/lldbsuite/test/tools/lldb-mi/interpreter/Makefile @@ -0,0 +1,5 @@ +LEVEL = ../../../make + +CXX_SOURCES := main.cpp + +include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/interpreter/TestMiCliSupport.py b/packages/Python/lldbsuite/test/tools/lldb-mi/interpreter/TestMiCliSupport.py new file mode 100644 index 0000000..562be91 --- /dev/null +++ b/packages/Python/lldbsuite/test/tools/lldb-mi/interpreter/TestMiCliSupport.py @@ -0,0 +1,206 @@ +""" +Test lldb-mi can interpret CLI commands directly. +""" + +from __future__ import print_function + + + +import lldbmi_testcase +from lldbsuite.test.lldbtest import * + +class MiCliSupportTestCase(lldbmi_testcase.MiTestCaseBase): + + mydir = TestBase.compute_mydir(__file__) + + @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + def test_lldbmi_target_create(self): + """Test that 'lldb-mi --interpreter' can create target by 'target create' command.""" + + self.spawnLldbMi(args = None) + + # Test that "target create" loads executable + self.runCmd("target create \"%s\"" % self.myexe) + self.expect("\^done") + + # Test that executable was loaded properly + self.runCmd("-break-insert -f main") + self.expect("\^done,bkpt={number=\"1\"") + self.runCmd("-exec-run") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + @skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots + def test_lldbmi_breakpoint_set(self): + """Test that 'lldb-mi --interpreter' can set breakpoint by 'breakpoint set' command.""" + + self.spawnLldbMi(args = None) + + # Load executable + self.runCmd("-file-exec-and-symbols %s" % self.myexe) + self.expect("\^done") + + # Test that "breakpoint set" sets a breakpoint + self.runCmd("breakpoint set --name main") + self.expect("\^done") + self.expect("=breakpoint-created,bkpt={number=\"1\"") + + # Test that breakpoint was set properly + self.runCmd("-exec-run") + self.expect("\^running") + self.expect("=breakpoint-modified,bkpt={number=\"1\"") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + @skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots + def test_lldbmi_settings_set_target_run_args_before(self): + """Test that 'lldb-mi --interpreter' can set target arguments by 'setting set target.run-args' command before than target was created.""" + + self.spawnLldbMi(args = None) + + # Test that "settings set target.run-args" passes arguments to executable + #FIXME: --arg1 causes an error + self.runCmd("setting set target.run-args arg1 \"2nd arg\" third_arg fourth=\"4th arg\"") + self.expect("\^done") + + # Load executable + self.runCmd("-file-exec-and-symbols %s" % self.myexe) + self.expect("\^done") + + # Run + self.runCmd("-exec-run") + self.expect("\^running") + + # Test that arguments were passed properly + self.expect("@\"argc=5\\\\r\\\\n\"") + + @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + @skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots + def test_lldbmi_settings_set_target_run_args_after(self): + """Test that 'lldb-mi --interpreter' can set target arguments by 'setting set target.run-args' command after than target was created.""" + + self.spawnLldbMi(args = None) + + # Load executable + self.runCmd("-file-exec-and-symbols %s" % self.myexe) + self.expect("\^done") + + # Test that "settings set target.run-args" passes arguments to executable + #FIXME: --arg1 causes an error + self.runCmd("setting set target.run-args arg1 \"2nd arg\" third_arg fourth=\"4th arg\"") + self.expect("\^done") + + # Run + self.runCmd("-exec-run") + self.expect("\^running") + + # Test that arguments were passed properly + self.expect("@\"argc=5\\\\r\\\\n\"") + + @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + @skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots + def test_lldbmi_process_launch(self): + """Test that 'lldb-mi --interpreter' can launch process by "process launch" command.""" + + self.spawnLldbMi(args = None) + + # Load executable + self.runCmd("-file-exec-and-symbols %s" % self.myexe) + self.expect("\^done") + + # Set breakpoint + self.runCmd("-break-insert -f main") + self.expect("\^done,bkpt={number=\"1\"") + + # Test that "process launch" launches executable + self.runCmd("process launch") + self.expect("\^done") + + # Test that breakpoint hit + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + @skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots + def test_lldbmi_thread_step_in(self): + """Test that 'lldb-mi --interpreter' can step in by "thread step-in" command.""" + + self.spawnLldbMi(args = None) + + # Load executable + self.runCmd("-file-exec-and-symbols %s" % self.myexe) + self.expect("\^done") + + # Run to main + self.runCmd("-break-insert -f main") + self.expect("\^done,bkpt={number=\"1\"") + self.runCmd("-exec-run") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + # Test that "thread step-in" steps into (or not) printf depending on debug info + # Note that message is different in Darwin and Linux: + # Darwin: "*stopped,reason=\"end-stepping-range\",frame={addr=\"0x[0-9a-f]+\",func=\"main\",args=[{name=\"argc\",value=\"1\"},{name=\"argv\",value="0x[0-9a-f]+\"}],file=\"main.cpp\",fullname=\".+main.cpp\",line=\"\d\"},thread-id=\"1\",stopped-threads=\"all\" + # 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("thread step-in") + self.expect("\^done") + 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\"") + + @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + @skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots + def test_lldbmi_thread_step_over(self): + """Test that 'lldb-mi --interpreter' can step over by "thread step-over" command.""" + + self.spawnLldbMi(args = None) + + # Load executable + self.runCmd("-file-exec-and-symbols %s" % self.myexe) + self.expect("\^done") + + # Run to main + self.runCmd("-break-insert -f main") + self.expect("\^done,bkpt={number=\"1\"") + self.runCmd("-exec-run") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + # Test that "thread step-over" steps over + self.runCmd("thread step-over") + self.expect("\^done") + self.expect("@\"argc=1\\\\r\\\\n\"") + self.expect("\*stopped,reason=\"end-stepping-range\"") + + @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + @skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots + def test_lldbmi_thread_continue(self): + """Test that 'lldb-mi --interpreter' can continue execution by "thread continue" command.""" + + self.spawnLldbMi(args = None) + + # Load executable + self.runCmd("-file-exec-and-symbols %s" % self.myexe) + self.expect("\^done") + + # Run to main + self.runCmd("-break-insert -f main") + self.expect("\^done,bkpt={number=\"1\"") + self.runCmd("-exec-run") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + # Test that "thread continue" continues execution + self.runCmd("thread continue") + self.expect("\^done") + self.expect("@\"argc=1\\\\r\\\\n") + self.expect("\*stopped,reason=\"exited-normally\"") diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/interpreter/TestMiInterpreterExec.py b/packages/Python/lldbsuite/test/tools/lldb-mi/interpreter/TestMiInterpreterExec.py new file mode 100644 index 0000000..93d9f25 --- /dev/null +++ b/packages/Python/lldbsuite/test/tools/lldb-mi/interpreter/TestMiInterpreterExec.py @@ -0,0 +1,229 @@ +""" +Test lldb-mi -interpreter-exec command. +""" + +from __future__ import print_function + + + +import lldbmi_testcase +from lldbsuite.test.lldbtest import * + +class MiInterpreterExecTestCase(lldbmi_testcase.MiTestCaseBase): + + mydir = TestBase.compute_mydir(__file__) + + @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + def test_lldbmi_target_create(self): + """Test that 'lldb-mi --interpreter' can create target by 'target create' command.""" + + self.spawnLldbMi(args = None) + + # Test that "target create" loads executable + self.runCmd("-interpreter-exec console \"target create \\\"%s\\\"\"" % self.myexe) + self.expect("\^done") + + # Test that executable was loaded properly + self.runCmd("-break-insert -f main") + self.expect("\^done,bkpt={number=\"1\"") + self.runCmd("-exec-run") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + def test_lldbmi_breakpoint_set(self): + """Test that 'lldb-mi --interpreter' can set breakpoint by 'breakpoint set' command.""" + + self.spawnLldbMi(args = None) + + # Load executable + self.runCmd("-file-exec-and-symbols %s" % self.myexe) + self.expect("\^done") + + # Test that "breakpoint set" sets a breakpoint + self.runCmd("-interpreter-exec console \"breakpoint set --name main\"") + self.expect("\^done") + self.expect("=breakpoint-created,bkpt={number=\"1\"") + + # Test that breakpoint was set properly + self.runCmd("-exec-run") + self.expect("\^running") + self.expect("=breakpoint-modified,bkpt={number=\"1\"") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + @expectedFailureLinux # Failing in ~9/600 dosep runs (build 3120-3122) + def test_lldbmi_settings_set_target_run_args_before(self): + """Test that 'lldb-mi --interpreter' can set target arguments by 'setting set target.run-args' command before than target was created.""" + + self.spawnLldbMi(args = None) + + # Test that "settings set target.run-args" passes arguments to executable + #FIXME: --arg1 causes an error + self.runCmd("-interpreter-exec console \"setting set target.run-args arg1 \\\"2nd arg\\\" third_arg fourth=\\\"4th arg\\\"\"") + self.expect("\^done") + + # Load executable + self.runCmd("-file-exec-and-symbols %s" % self.myexe) + self.expect("\^done") + + # Run + self.runCmd("-exec-run") + self.expect("\^running") + + # Test that arguments were passed properly + self.expect("@\"argc=5\\\\r\\\\n\"") + self.expect("@\"argv.0.=.*lldb-mi") + self.expect("@\"argv.1.=arg1\\\\r\\\\n\"") + self.expect("@\"argv.2.=2nd arg\\\\r\\\\n\"") + self.expect("@\"argv.3.=third_arg\\\\r\\\\n\"") + self.expect("@\"argv.4.=fourth=4th arg\\\\r\\\\n\"") + + # Test that program exited normally + self.expect("\*stopped,reason=\"exited-normally\"") + + @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + @expectedFailureLinux # Failing in ~9/600 dosep runs (build 3120-3122) + def test_lldbmi_settings_set_target_run_args_after(self): + """Test that 'lldb-mi --interpreter' can set target arguments by 'setting set target.run-args' command after than target was created.""" + + self.spawnLldbMi(args = None) + + # Load executable + self.runCmd("-file-exec-and-symbols %s" % self.myexe) + self.expect("\^done") + + # Test that "settings set target.run-args" passes arguments to executable + #FIXME: --arg1 causes an error + self.runCmd("-interpreter-exec console \"setting set target.run-args arg1 \\\"2nd arg\\\" third_arg fourth=\\\"4th arg\\\"\"") + self.expect("\^done") + + # Run to BP_printf + line = line_number('main.cpp', '// BP_printf') + self.runCmd("-break-insert main.cpp:%d" % line) + self.expect("\^done,bkpt={number=\"1\"") + self.runCmd("-exec-run") + self.expect("\^running"); + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + # Run to BP_return + line = line_number('main.cpp', '// BP_return') + self.runCmd("-break-insert main.cpp:%d" % line) + self.expect("\^done,bkpt={number=\"2\"") + self.runCmd("-exec-continue") + self.expect("\^running"); + + # Test that arguments were passed properly + self.expect("@\"argc=5\\\\r\\\\n\"") + self.expect("@\"argv.0.=.*lldb-mi") + self.expect("@\"argv.1.=arg1\\\\r\\\\n\"") + self.expect("@\"argv.2.=2nd arg\\\\r\\\\n\"") + self.expect("@\"argv.3.=third_arg\\\\r\\\\n\"") + self.expect("@\"argv.4.=fourth=4th arg\\\\r\\\\n\"") + + # Hit BP_return + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + def test_lldbmi_process_launch(self): + """Test that 'lldb-mi --interpreter' can launch process by "process launch" command.""" + + self.spawnLldbMi(args = None) + + # Load executable + self.runCmd("-file-exec-and-symbols %s" % self.myexe) + self.expect("\^done") + + # Set breakpoint + self.runCmd("-break-insert -f main") + self.expect("\^done,bkpt={number=\"1\"") + + # Test that "process launch" launches executable + self.runCmd("-interpreter-exec console \"process launch\"") + self.expect("\^done") + + # Test that breakpoint hit + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + def test_lldbmi_thread_step_in(self): + """Test that 'lldb-mi --interpreter' can step in by "thread step-in" command.""" + + self.spawnLldbMi(args = None) + + # Load executable + self.runCmd("-file-exec-and-symbols %s" % self.myexe) + self.expect("\^done") + + # Run to main + self.runCmd("-break-insert -f main") + self.expect("\^done,bkpt={number=\"1\"") + self.runCmd("-exec-run") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + # Test that "thread step-in" steps into (or not) printf depending on debug info + # Note that message is different in Darwin and Linux: + # Darwin: "*stopped,reason=\"end-stepping-range\",frame={addr=\"0x[0-9a-f]+\",func=\"main\",args=[{name=\"argc\",value=\"1\"},{name=\"argv\",value="0x[0-9a-f]+\"}],file=\"main.cpp\",fullname=\".+main.cpp\",line=\"\d\"},thread-id=\"1\",stopped-threads=\"all\" + # 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") + 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\"") + + @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + def test_lldbmi_thread_step_over(self): + """Test that 'lldb-mi --interpreter' can step over by "thread step-over" command.""" + + self.spawnLldbMi(args = None) + + # Load executable + self.runCmd("-file-exec-and-symbols %s" % self.myexe) + self.expect("\^done") + + # Run to main + self.runCmd("-break-insert -f main") + self.expect("\^done,bkpt={number=\"1\"") + self.runCmd("-exec-run") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + # Test that "thread step-over" steps over + self.runCmd("-interpreter-exec console \"thread step-over\"") + self.expect("\^done") + self.expect("@\"argc=1\\\\r\\\\n\"") + self.expect("\*stopped,reason=\"end-stepping-range\"") + + @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + @expectedFlakeyLinux("llvm.org/pr25470") + def test_lldbmi_thread_continue(self): + """Test that 'lldb-mi --interpreter' can continue execution by "thread continue" command.""" + + self.spawnLldbMi(args = None) + + # Load executable + self.runCmd("-file-exec-and-symbols %s" % self.myexe) + self.expect("\^done") + + # Run to main + self.runCmd("-break-insert -f main") + self.expect("\^done,bkpt={number=\"1\"") + self.runCmd("-exec-run") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + # Test that "thread continue" continues execution + self.runCmd("-interpreter-exec console \"thread continue\"") + self.expect("\^done") + self.expect("@\"argc=1\\\\r\\\\n") + self.expect("\*stopped,reason=\"exited-normally\"") diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/interpreter/main.cpp b/packages/Python/lldbsuite/test/tools/lldb-mi/interpreter/main.cpp new file mode 100644 index 0000000..0c042d4 --- /dev/null +++ b/packages/Python/lldbsuite/test/tools/lldb-mi/interpreter/main.cpp @@ -0,0 +1,19 @@ +//===-- main.cpp ------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include <cstdio> + +int +main(int argc, char const *argv[]) +{ + printf("argc=%d\n", argc); // BP_printf + for (int i = 0; i < argc; ++i) + printf("argv[%d]=%s\n", i, argv[i]); + return 0; // BP_return +} diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/lldbmi_testcase.py b/packages/Python/lldbsuite/test/tools/lldb-mi/lldbmi_testcase.py new file mode 100644 index 0000000..277ffe7 --- /dev/null +++ b/packages/Python/lldbsuite/test/tools/lldb-mi/lldbmi_testcase.py @@ -0,0 +1,54 @@ +""" +Base class for lldb-mi test cases. +""" + +from __future__ import print_function + + + +from lldbsuite.test.lldbtest import * + +class MiTestCaseBase(Base): + + mydir = None + myexe = "a.out" + mylog = "child.log" + + def getCategories(self): + return ['lldb-mi'] + + @classmethod + def classCleanup(cls): + TestBase.RemoveTempFile(cls.myexe) + TestBase.RemoveTempFile(cls.mylog) + + def setUp(self): + Base.setUp(self) + self.buildDefault() + self.child_prompt = "(gdb)" + + def tearDown(self): + if self.TraceOn(): + print("\n\nContents of %s:" % self.mylog) + try: + print(open(self.mylog, "r").read()) + except IOError: + pass + Base.tearDown(self) + + def spawnLldbMi(self, args=None): + import pexpect + self.child = pexpect.spawn("%s --interpreter %s" % ( + self.lldbMiExec, args if args else "")) + self.child.setecho(True) + self.child.logfile_read = open(self.mylog, "w") + # wait until lldb-mi has started up and is ready to go + self.expect(self.child_prompt, exactly = True) + + def runCmd(self, cmd): + self.child.sendline(cmd) + + def expect(self, pattern, exactly=False, *args, **kwargs): + if exactly: + return self.child.expect_exact(pattern, *args, **kwargs) + return self.child.expect(pattern, *args, **kwargs) diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/main.cpp b/packages/Python/lldbsuite/test/tools/lldb-mi/main.cpp new file mode 100644 index 0000000..6a2079f --- /dev/null +++ b/packages/Python/lldbsuite/test/tools/lldb-mi/main.cpp @@ -0,0 +1,19 @@ +//===-- main.cpp ------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include <cstdio> + +int +main(int argc, char const *argv[]) +{ + int a = 10; + + printf("argc=%d\n", argc); // BP_printf + return 0; +} diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/signal/Makefile b/packages/Python/lldbsuite/test/tools/lldb-mi/signal/Makefile new file mode 100644 index 0000000..314f1cb --- /dev/null +++ b/packages/Python/lldbsuite/test/tools/lldb-mi/signal/Makefile @@ -0,0 +1,5 @@ +LEVEL = ../../../make + +CXX_SOURCES := main.cpp + +include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/signal/TestMiSignal.py b/packages/Python/lldbsuite/test/tools/lldb-mi/signal/TestMiSignal.py new file mode 100644 index 0000000..11e7b8a --- /dev/null +++ b/packages/Python/lldbsuite/test/tools/lldb-mi/signal/TestMiSignal.py @@ -0,0 +1,197 @@ +""" +Test that the lldb-mi handles signals properly. +""" + +from __future__ import print_function + + + +import lldbmi_testcase +from lldbsuite.test.lldbtest import * + +class MiSignalTestCase(lldbmi_testcase.MiTestCaseBase): + + mydir = TestBase.compute_mydir(__file__) + + @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows + @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.""" + + self.spawnLldbMi(args = None) + + # Load executable + self.runCmd("-file-exec-and-symbols %s" % self.myexe) + self.expect("\^done") + + # Run to main + self.runCmd("-break-insert -f main") + self.expect("\^done,bkpt={number=\"1\"") + self.runCmd("-exec-run") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + # Set doloop=1 and run (to loop forever) + self.runCmd("-data-evaluate-expression \"do_loop=1\"") + self.expect("\^done,value=\"1\"") + self.runCmd("-exec-continue") + self.expect("\^running") + + # 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\"") + + # Continue (to loop forever) + self.runCmd("-exec-continue") + self.expect("\^running") + + # 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\"") + + @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows + @skipIfFreeBSD # llvm.org/pr22411: Fails on FreeBSD apparently due to thread race conditions + @skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots + def test_lldbmi_stopped_when_stopatentry_local(self): + """Test that 'lldb-mi --interpreter' notifies after it was stopped on entry (local).""" + + self.spawnLldbMi(args = None) + + # Load executable + self.runCmd("-file-exec-and-symbols %s" % self.myexe) + self.expect("\^done") + + # Run with stop-at-entry flag + self.runCmd("-interpreter-exec command \"process launch -s\"") + self.expect("\^done") + + # Test that *stopped is printed + # Note that message is different in Darwin and Linux: + # Darwin: "*stopped,reason=\"signal-received\",signal-name=\"SIGSTOP\",signal-meaning=\"Stop\",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\",signal-name=\"SIGSTOP\",signal-meaning=\"Stop\",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") + self.expect("\^done,bkpt={number=\"1\"") + self.runCmd("-exec-continue") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows + @skipUnlessDarwin + def test_lldbmi_stopped_when_stopatentry_remote(self): + """Test that 'lldb-mi --interpreter' notifies after it was stopped on entry (remote).""" + + # Prepare debugserver + import lldbgdbserverutils + debugserver_exe = lldbgdbserverutils.get_debugserver_exe() + if not debugserver_exe: + self.skipTest("debugserver exe not found") + hostname = "localhost" + import random + port = 12000 + random.randint(0,3999) # the same as GdbRemoteTestCaseBase.get_next_port + import pexpect + debugserver_child = pexpect.spawn("%s %s:%d" % (debugserver_exe, hostname, port)) + self.addTearDownHook(lambda: debugserver_child.terminate(force = True)) + + self.spawnLldbMi(args = None) + + # Connect to debugserver + self.runCmd("-interpreter-exec command \"platform select remote-macosx --sysroot /\"") + self.expect("\^done") + self.runCmd("-file-exec-and-symbols %s" % self.myexe) + self.expect("\^done") + self.runCmd("-interpreter-exec command \"process connect connect://%s:%d\"" % (hostname, port)) + self.expect("\^done") + + # Run with stop-at-entry flag + self.runCmd("-interpreter-exec command \"process launch -s\"") + self.expect("\^done") + + # Test that *stopped is printed + self.expect("\*stopped,reason=\"signal-received\",signal-name=\"SIGSTOP\",signal-meaning=\"Stop\",.+?thread-id=\"1\",stopped-threads=\"all\"") + + # Exit + self.runCmd("-gdb-exit") + self.expect("\^exit") + + @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + @skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots + def test_lldbmi_stopped_when_segfault_local(self): + """Test that 'lldb-mi --interpreter' notifies after it was stopped when segfault occurred (local).""" + + self.spawnLldbMi(args = None) + + # Load executable + self.runCmd("-file-exec-and-symbols %s" % self.myexe) + self.expect("\^done") + + # Run to main + self.runCmd("-break-insert -f main") + self.expect("\^done,bkpt={number=\"1\"") + self.runCmd("-exec-run") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + # Set do_segfault=1 and run (to cause a segfault error) + self.runCmd("-data-evaluate-expression \"do_segfault=1\"") + self.expect("\^done,value=\"1\"") + self.runCmd("-exec-continue") + self.expect("\^running") + + # Test that *stopped is printed + # 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\"" ]) + + @skipUnlessDarwin + def test_lldbmi_stopped_when_segfault_remote(self): + """Test that 'lldb-mi --interpreter' notifies after it was stopped when segfault occurred (remote).""" + + # Prepare debugserver + import lldbgdbserverutils + debugserver_exe = lldbgdbserverutils.get_debugserver_exe() + if not debugserver_exe: + self.skipTest("debugserver exe not found") + hostname = "localhost" + import random + port = 12000 + random.randint(0,3999) # the same as GdbRemoteTestCaseBase.get_next_port + import pexpect + debugserver_child = pexpect.spawn("%s %s:%d" % (debugserver_exe, hostname, port)) + self.addTearDownHook(lambda: debugserver_child.terminate(force = True)) + + self.spawnLldbMi(args = None) + + # Connect to debugserver + self.runCmd("-interpreter-exec command \"platform select remote-macosx --sysroot /\"") + self.expect("\^done") + self.runCmd("-file-exec-and-symbols %s" % self.myexe) + self.expect("\^done") + self.runCmd("-interpreter-exec command \"process connect connect://%s:%d\"" % (hostname, port)) + self.expect("\^done") + + # Run to main + self.runCmd("-break-insert -f main") + self.expect("\^done,bkpt={number=\"1\"") + #FIXME -exec-run doesn't work + self.runCmd("-interpreter-exec command \"process launch\"") #FIXME: self.runCmd("-exec-run") + self.expect("\^done") #FIXME: self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + # Set do_segfault=1 and run (to cause a segfault error) + self.runCmd("-data-evaluate-expression \"do_segfault=1\"") + self.expect("\^done,value=\"1\"") + self.runCmd("-exec-continue") + self.expect("\^running") + + # Test that *stopped is printed + self.expect("\*stopped,reason=\"exception-received\",exception=\"EXC_BAD_ACCESS \(code=1, address=0x0\)\",thread-id=\"1\",stopped-threads=\"all\"") + + # Exit + self.runCmd("-gdb-exit") + self.expect("\^exit") diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/signal/main.cpp b/packages/Python/lldbsuite/test/tools/lldb-mi/signal/main.cpp new file mode 100644 index 0000000..7f6eeca --- /dev/null +++ b/packages/Python/lldbsuite/test/tools/lldb-mi/signal/main.cpp @@ -0,0 +1,33 @@ +//===-- main.cpp ------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include <cstddef> +#include <unistd.h> + +int do_loop; +int do_segfault; + +int +main(int argc, char const *argv[]) +{ + if (do_loop) + { + do + sleep(1); + while (do_loop); // BP_loop_condition + } + + if (do_segfault) + { + int *null_ptr = NULL; + return *null_ptr; + } + + return 0; +} diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/stack/Makefile b/packages/Python/lldbsuite/test/tools/lldb-mi/stack/Makefile new file mode 100644 index 0000000..314f1cb --- /dev/null +++ b/packages/Python/lldbsuite/test/tools/lldb-mi/stack/Makefile @@ -0,0 +1,5 @@ +LEVEL = ../../../make + +CXX_SOURCES := main.cpp + +include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/stack/TestMiStack.py b/packages/Python/lldbsuite/test/tools/lldb-mi/stack/TestMiStack.py new file mode 100644 index 0000000..14dab38 --- /dev/null +++ b/packages/Python/lldbsuite/test/tools/lldb-mi/stack/TestMiStack.py @@ -0,0 +1,479 @@ +""" +Test lldb-mi -stack-xxx commands. +""" + +from __future__ import print_function + + + +import lldbmi_testcase +from lldbsuite.test.lldbtest import * + +class MiStackTestCase(lldbmi_testcase.MiTestCaseBase): + + mydir = TestBase.compute_mydir(__file__) + + @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + def test_lldbmi_stack_list_arguments(self): + """Test that 'lldb-mi --interpreter' can shows arguments.""" + + self.spawnLldbMi(args = None) + + # Load executable + self.runCmd("-file-exec-and-symbols %s" % self.myexe) + self.expect("\^done") + + # Run to main + self.runCmd("-break-insert -f main") + self.expect("\^done,bkpt={number=\"1\"") + self.runCmd("-exec-run") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + # Test that -stack-list-arguments lists empty stack arguments if range is empty + self.runCmd("-stack-list-arguments 0 1 0") + self.expect("\^done,stack-args=\[\]") + + # Test that -stack-list-arguments lists stack arguments without values + # (and that low-frame and high-frame are optional) + self.runCmd("-stack-list-arguments 0") + self.expect("\^done,stack-args=\[frame={level=\"0\",args=\[name=\"argc\",name=\"argv\"\]}") + self.runCmd("-stack-list-arguments --no-values") + self.expect("\^done,stack-args=\[frame={level=\"0\",args=\[name=\"argc\",name=\"argv\"\]}") + + # Test that -stack-list-arguments lists stack arguments with all values + self.runCmd("-stack-list-arguments 1 0 0") + self.expect("\^done,stack-args=\[frame={level=\"0\",args=\[{name=\"argc\",value=\"1\"},{name=\"argv\",value=\".*\"}\]}\]") + self.runCmd("-stack-list-arguments --all-values 0 0") + self.expect("\^done,stack-args=\[frame={level=\"0\",args=\[{name=\"argc\",value=\"1\"},{name=\"argv\",value=\".*\"}\]}\]") + + # Test that -stack-list-arguments lists stack arguments with simple values + self.runCmd("-stack-list-arguments 2 0 1") + self.expect("\^done,stack-args=\[frame={level=\"0\",args=\[{name=\"argc\",type=\"int\",value=\"1\"},{name=\"argv\",type=\"const char \*\*\",value=\".*\"}\]}") + self.runCmd("-stack-list-arguments --simple-values 0 1") + self.expect("\^done,stack-args=\[frame={level=\"0\",args=\[{name=\"argc\",type=\"int\",value=\"1\"},{name=\"argv\",type=\"const char \*\*\",value=\".*\"}\]}") + + # Test that an invalid low-frame is handled + # FIXME: -1 is treated as unsigned int + self.runCmd("-stack-list-arguments 0 -1 0") + #self.expect("\^error") + self.runCmd("-stack-list-arguments 0 0") + self.expect("\^error,msg=\"Command 'stack-list-arguments'\. Thread frame range invalid\"") + + # Test that an invalid high-frame is handled + # FIXME: -1 is treated as unsigned int + self.runCmd("-stack-list-arguments 0 0 -1") + #self.expect("\^error") + + # Test that a missing low-frame or high-frame is handled + self.runCmd("-stack-list-arguments 0 0") + self.expect("\^error,msg=\"Command 'stack-list-arguments'\. Thread frame range invalid\"") + + # Test that an invalid low-frame is handled + self.runCmd("-stack-list-arguments 0 0") + self.expect("\^error,msg=\"Command 'stack-list-arguments'\. Thread frame range invalid\"") + + @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + def test_lldbmi_stack_list_locals(self): + """Test that 'lldb-mi --interpreter' can shows local variables.""" + + self.spawnLldbMi(args = None) + + # Load executable + self.runCmd("-file-exec-and-symbols %s" % self.myexe) + self.expect("\^done") + + # Run to main + self.runCmd("-break-insert -f main") + self.expect("\^done,bkpt={number=\"1\"") + self.runCmd("-exec-run") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + # Test int local variables: + # Run to BP_local_int_test + line = line_number('main.cpp', '// BP_local_int_test') + self.runCmd("-break-insert --file main.cpp:%d" % line) + self.expect("\^done,bkpt={number=\"2\"") + self.runCmd("-exec-continue") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + # Test -stack-list-locals: use 0 or --no-values + self.runCmd("-stack-list-locals 0") + self.expect("\^done,locals=\[name=\"a\",name=\"b\"\]") + self.runCmd("-stack-list-locals --no-values") + self.expect("\^done,locals=\[name=\"a\",name=\"b\"\]") + + # Test -stack-list-locals: use 1 or --all-values + self.runCmd("-stack-list-locals 1") + self.expect("\^done,locals=\[{name=\"a\",value=\"10\"},{name=\"b\",value=\"20\"}\]") + self.runCmd("-stack-list-locals --all-values") + self.expect("\^done,locals=\[{name=\"a\",value=\"10\"},{name=\"b\",value=\"20\"}\]") + + # Test -stack-list-locals: use 2 or --simple-values + self.runCmd("-stack-list-locals 2") + self.expect("\^done,locals=\[{name=\"a\",type=\"int\",value=\"10\"},{name=\"b\",type=\"int\",value=\"20\"}\]") + self.runCmd("-stack-list-locals --simple-values") + self.expect("\^done,locals=\[{name=\"a\",type=\"int\",value=\"10\"},{name=\"b\",type=\"int\",value=\"20\"}\]") + + # Test struct local variable: + # Run to BP_local_struct_test + line = line_number('main.cpp', '// BP_local_struct_test') + self.runCmd("-break-insert --file main.cpp:%d" % line) + self.expect("\^done,bkpt={number=\"3\"") + self.runCmd("-exec-continue") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + # Test -stack-list-locals: use 0 or --no-values + self.runCmd("-stack-list-locals 0") + self.expect("\^done,locals=\[name=\"var_c\"\]") + self.runCmd("-stack-list-locals --no-values") + self.expect("\^done,locals=\[name=\"var_c\"\]") + + # Test -stack-list-locals: use 1 or --all-values + self.runCmd("-stack-list-locals 1") + self.expect("\^done,locals=\[{name=\"var_c\",value=\"{var_a = 10, var_b = 97 'a', inner_ = {var_d = 30}}\"}\]") + self.runCmd("-stack-list-locals --all-values") + self.expect("\^done,locals=\[{name=\"var_c\",value=\"{var_a = 10, var_b = 97 'a', inner_ = {var_d = 30}}\"}\]") + + # Test -stack-list-locals: use 2 or --simple-values + self.runCmd("-stack-list-locals 2") + self.expect("\^done,locals=\[{name=\"var_c\",type=\"my_type\"}\]") + self.runCmd("-stack-list-locals --simple-values") + self.expect("\^done,locals=\[{name=\"var_c\",type=\"my_type\"}\]") + + # Test array local variable: + # Run to BP_local_array_test + line = line_number('main.cpp', '// BP_local_array_test') + self.runCmd("-break-insert --file main.cpp:%d" % line) + self.expect("\^done,bkpt={number=\"4\"") + self.runCmd("-exec-continue") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + # Test -stack-list-locals: use 0 or --no-values + self.runCmd("-stack-list-locals 0") + self.expect("\^done,locals=\[name=\"array\"\]") + self.runCmd("-stack-list-locals --no-values") + self.expect("\^done,locals=\[name=\"array\"\]") + + # Test -stack-list-locals: use 1 or --all-values + self.runCmd("-stack-list-locals 1") + self.expect("\^done,locals=\[{name=\"array\",value=\"{\[0\] = 100, \[1\] = 200, \[2\] = 300}\"}\]") + self.runCmd("-stack-list-locals --all-values") + self.expect("\^done,locals=\[{name=\"array\",value=\"{\[0\] = 100, \[1\] = 200, \[2\] = 300}\"}\]") + + # Test -stack-list-locals: use 2 or --simple-values + self.runCmd("-stack-list-locals 2") + self.expect("\^done,locals=\[{name=\"array\",type=\"int \[3\]\"}\]") + self.runCmd("-stack-list-locals --simple-values") + self.expect("\^done,locals=\[{name=\"array\",type=\"int \[3\]\"}\]") + + # Test pointers as local variable: + # Run to BP_local_pointer_test + line = line_number('main.cpp', '// BP_local_pointer_test') + self.runCmd("-break-insert --file main.cpp:%d" % line) + self.expect("\^done,bkpt={number=\"5\"") + self.runCmd("-exec-continue") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + # Test -stack-list-locals: use 0 or --no-values + self.runCmd("-stack-list-locals 0") + self.expect("\^done,locals=\[name=\"test_str\",name=\"var_e\",name=\"ptr\"\]") + self.runCmd("-stack-list-locals --no-values") + self.expect("\^done,locals=\[name=\"test_str\",name=\"var_e\",name=\"ptr\"\]") + + # 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.runCmd("-stack-list-locals --all-values") + 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\",type=\"const char \*\",value=\".*?Rakaposhi.*?\"},{name=\"var_e\",type=\"int\",value=\"24\"},{name=\"ptr\",type=\"int \*\",value=\".*?\"}\]") + self.runCmd("-stack-list-locals --simple-values") + self.expect("\^done,locals=\[{name=\"test_str\",type=\"const char \*\",value=\".*?Rakaposhi.*?\"},{name=\"var_e\",type=\"int\",value=\"24\"},{name=\"ptr\",type=\"int \*\",value=\".*?\"}\]") + + @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + def test_lldbmi_stack_list_variables(self): + """Test that 'lldb-mi --interpreter' can shows local variables and arguments.""" + + self.spawnLldbMi(args = None) + + # Load executable + self.runCmd("-file-exec-and-symbols %s" % self.myexe) + self.expect("\^done") + + # Run to main + self.runCmd("-break-insert -f main") + self.expect("\^done,bkpt={number=\"1\"") + self.runCmd("-exec-run") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + # Test int local variables: + # Run to BP_local_int_test + line = line_number('main.cpp', '// BP_local_int_test_with_args') + self.runCmd("-break-insert --file main.cpp:%d" % line) + self.expect("\^done,bkpt={number=\"2\"") + self.runCmd("-exec-continue") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + # Test -stack-list-variables: use 0 or --no-values + self.runCmd("-stack-list-variables 0") + self.expect("\^done,variables=\[{arg=\"1\",name=\"c\"},{arg=\"1\",name=\"d\"},{name=\"a\"},{name=\"b\"}\]") + self.runCmd("-stack-list-variables --no-values") + self.expect("\^done,variables=\[{arg=\"1\",name=\"c\"},{arg=\"1\",name=\"d\"},{name=\"a\"},{name=\"b\"}\]") + + # Test -stack-list-variables: use 1 or --all-values + self.runCmd("-stack-list-variables 1") + self.expect("\^done,variables=\[{arg=\"1\",name=\"c\",value=\"30\"},{arg=\"1\",name=\"d\",value=\"40\"},{name=\"a\",value=\"10\"},{name=\"b\",value=\"20\"}\]") + self.runCmd("-stack-list-variables --all-values") + self.expect("\^done,variables=\[{arg=\"1\",name=\"c\",value=\"30\"},{arg=\"1\",name=\"d\",value=\"40\"},{name=\"a\",value=\"10\"},{name=\"b\",value=\"20\"}\]") + + # Test -stack-list-variables: use 2 or --simple-values + self.runCmd("-stack-list-variables 2") + self.expect("\^done,variables=\[{arg=\"1\",name=\"c\",type=\"int\",value=\"30\"},{arg=\"1\",name=\"d\",type=\"int\",value=\"40\"},{name=\"a\",type=\"int\",value=\"10\"},{name=\"b\",type=\"int\",value=\"20\"}\]") + self.runCmd("-stack-list-variables --simple-values") + self.expect("\^done,variables=\[{arg=\"1\",name=\"c\",type=\"int\",value=\"30\"},{arg=\"1\",name=\"d\",type=\"int\",value=\"40\"},{name=\"a\",type=\"int\",value=\"10\"},{name=\"b\",type=\"int\",value=\"20\"}\]") + + # Test struct local variable: + # Run to BP_local_struct_test + line = line_number('main.cpp', '// BP_local_struct_test_with_args') + self.runCmd("-break-insert --file main.cpp:%d" % line) + self.expect("\^done,bkpt={number=\"3\"") + self.runCmd("-exec-continue") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + # Test -stack-list-variables: use 0 or --no-values + self.runCmd("-stack-list-variables 0") + self.expect("\^done,variables=\[{arg=\"1\",name=\"var_e\"},{name=\"var_c\"}\]") + self.runCmd("-stack-list-variables --no-values") + self.expect("\^done,variables=\[{arg=\"1\",name=\"var_e\"},{name=\"var_c\"}\]") + + # Test -stack-list-variables: use 1 or --all-values + self.runCmd("-stack-list-variables 1") + self.expect("\^done,variables=\[{arg=\"1\",name=\"var_e\",value=\"{var_a = 20, var_b = 98 'b', inner_ = {var_d = 40}}\"},{name=\"var_c\",value=\"{var_a = 10, var_b = 97 'a', inner_ = {var_d = 30}}\"}\]") + self.runCmd("-stack-list-variables --all-values") + self.expect("\^done,variables=\[{arg=\"1\",name=\"var_e\",value=\"{var_a = 20, var_b = 98 'b', inner_ = {var_d = 40}}\"},{name=\"var_c\",value=\"{var_a = 10, var_b = 97 'a', inner_ = {var_d = 30}}\"}\]") + + # Test -stack-list-variables: use 2 or --simple-values + self.runCmd("-stack-list-variables 2") + self.expect("\^done,variables=\[{arg=\"1\",name=\"var_e\",type=\"my_type\"},{name=\"var_c\",type=\"my_type\"}\]") + self.runCmd("-stack-list-variables --simple-values") + self.expect("\^done,variables=\[{arg=\"1\",name=\"var_e\",type=\"my_type\"},{name=\"var_c\",type=\"my_type\"}\]") + + # Test array local variable: + # Run to BP_local_array_test + line = line_number('main.cpp', '// BP_local_array_test_with_args') + self.runCmd("-break-insert --file main.cpp:%d" % line) + self.expect("\^done,bkpt={number=\"4\"") + self.runCmd("-exec-continue") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + # Test -stack-list-variables: use 0 or --no-values + self.runCmd("-stack-list-variables 0") + self.expect("\^done,variables=\[{arg=\"1\",name=\"other_array\"},{name=\"array\"}\]") + self.runCmd("-stack-list-variables --no-values") + self.expect("\^done,variables=\[{arg=\"1\",name=\"other_array\"},{name=\"array\"}\]") + + # Test -stack-list-variables: use 1 or --all-values + self.runCmd("-stack-list-variables 1") + self.expect("\^done,variables=\[{arg=\"1\",name=\"other_array\",value=\".*?\"},{name=\"array\",value=\"{\[0\] = 100, \[1\] = 200, \[2\] = 300}\"}\]") + self.runCmd("-stack-list-variables --all-values") + self.expect("\^done,variables=\[{arg=\"1\",name=\"other_array\",value=\".*?\"},{name=\"array\",value=\"{\[0\] = 100, \[1\] = 200, \[2\] = 300}\"}\]") + + # Test -stack-list-variables: use 2 or --simple-values + self.runCmd("-stack-list-variables 2") + self.expect("\^done,variables=\[{arg=\"1\",name=\"other_array\",type=\"int \*\",value=\".*?\"},{name=\"array\",type=\"int \[3\]\"}\]") + self.runCmd("-stack-list-variables --simple-values") + self.expect("\^done,variables=\[{arg=\"1\",name=\"other_array\",type=\"int \*\",value=\".*?\"},{name=\"array\",type=\"int \[3\]\"}\]") + + # Test pointers as local variable: + # Run to BP_local_pointer_test + line = line_number('main.cpp', '// BP_local_pointer_test_with_args') + self.runCmd("-break-insert --file main.cpp:%d" % line) + self.expect("\^done,bkpt={number=\"5\"") + self.runCmd("-exec-continue") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + # Test -stack-list-variables: use 0 or --no-values + self.runCmd("-stack-list-variables 0") + self.expect("\^done,variables=\[{arg=\"1\",name=\"arg_str\"},{arg=\"1\",name=\"arg_ptr\"},{name=\"test_str\"},{name=\"var_e\"},{name=\"ptr\"}\]") + self.runCmd("-stack-list-variables --no-values") + self.expect("\^done,variables=\[{arg=\"1\",name=\"arg_str\"},{arg=\"1\",name=\"arg_ptr\"},{name=\"test_str\"},{name=\"var_e\"},{name=\"ptr\"}\]") + + # Test -stack-list-variables: use 1 or --all-values + self.runCmd("-stack-list-variables 1") + self.expect("\^done,variables=\[{arg=\"1\",name=\"arg_str\",value=\".*?String.*?\"},{arg=\"1\",name=\"arg_ptr\",value=\".*?\"},{name=\"test_str\",value=\".*?Rakaposhi.*?\"},{name=\"var_e\",value=\"24\"},{name=\"ptr\",value=\".*?\"}\]") + self.runCmd("-stack-list-variables --all-values") + self.expect("\^done,variables=\[{arg=\"1\",name=\"arg_str\",value=\".*?String.*?\"},{arg=\"1\",name=\"arg_ptr\",value=\".*?\"},{name=\"test_str\",value=\".*?Rakaposhi.*?\"},{name=\"var_e\",value=\"24\"},{name=\"ptr\",value=\".*?\"}\]") + + # Test -stack-list-variables: use 2 or --simple-values + self.runCmd("-stack-list-variables 2") + self.expect("\^done,variables=\[{arg=\"1\",name=\"arg_str\",type=\"const char \*\",value=\".*?String.*?\"},{arg=\"1\",name=\"arg_ptr\",type=\"int \*\",value=\".*?\"},{name=\"test_str\",type=\"const char \*\",value=\".*?Rakaposhi.*?\"},{name=\"var_e\",type=\"int\",value=\"24\"},{name=\"ptr\",type=\"int \*\",value=\".*?\"}\]") + self.runCmd("-stack-list-variables --simple-values") + self.expect("\^done,variables=\[{arg=\"1\",name=\"arg_str\",type=\"const char \*\",value=\".*?String.*?\"},{arg=\"1\",name=\"arg_ptr\",type=\"int \*\",value=\".*?\"},{name=\"test_str\",type=\"const char \*\",value=\".*?Rakaposhi.*?\"},{name=\"var_e\",type=\"int\",value=\"24\"},{name=\"ptr\",type=\"int \*\",value=\".*?\"}\]") + + @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + def test_lldbmi_stack_info_depth(self): + """Test that 'lldb-mi --interpreter' can shows depth of the stack.""" + + self.spawnLldbMi(args = None) + + # Load executable + self.runCmd("-file-exec-and-symbols %s" % self.myexe) + self.expect("\^done") + + # Run to main + self.runCmd("-break-insert -f main") + self.expect("\^done,bkpt={number=\"1\"") + self.runCmd("-exec-run") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + # Test that -stack-info-depth works + # (and that max-depth is optional) + self.runCmd("-stack-info-depth") + self.expect("\^done,depth=\"[1-9]\"") + + # Test that max-depth restricts check of stack depth + #FIXME: max-depth argument is ignored + self.runCmd("-stack-info-depth 1") + #self.expect("\^done,depth=\"1\"") + + # Test that invalid max-depth argument is handled + #FIXME: max-depth argument is ignored + self.runCmd("-stack-info-depth -1") + #self.expect("\^error") + + @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + @skipUnlessDarwin + def test_lldbmi_stack_info_frame(self): + """Test that 'lldb-mi --interpreter' can show information about current frame.""" + + self.spawnLldbMi(args = None) + + # Test that -stack-info-frame fails when program isn't running + self.runCmd("-stack-info-frame") + self.expect("\^error,msg=\"Command 'stack-info-frame'\. Invalid process during debug session\"") + + # Load executable + self.runCmd("-file-exec-and-symbols %s" % self.myexe) + self.expect("\^done") + + # Run to main + self.runCmd("-break-insert -f main") + self.expect("\^done,bkpt={number=\"1\"") + self.runCmd("-exec-run") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + # Test that -stack-info-frame works when program was stopped on BP + self.runCmd("-stack-info-frame") + self.expect("\^done,frame=\{level=\"0\",addr=\"0x[0-9a-f]+\",func=\"main\",file=\"main\.cpp\",fullname=\".+?main\.cpp\",line=\"\d+\"\}") + + # Select frame #1 + self.runCmd("-stack-select-frame 1") + self.expect("\^done") + + # Test that -stack-info-frame works when specified frame was selected + self.runCmd("-stack-info-frame") + self.expect("\^done,frame=\{level=\"1\",addr=\"0x[0-9a-f]+\",func=\".+?\",file=\"\?\?\",fullname=\"\?\?\",line=\"-1\"\}") + + # Test that -stack-info-frame fails when an argument is specified + #FIXME: unknown argument is ignored + self.runCmd("-stack-info-frame unknown_arg") + #self.expect("\^error") + + @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + def test_lldbmi_stack_list_frames(self): + """Test that 'lldb-mi --interpreter' can lists the frames on the stack.""" + + self.spawnLldbMi(args = None) + + # Load executable + self.runCmd("-file-exec-and-symbols %s" % self.myexe) + self.expect("\^done") + + # Run to main + self.runCmd("-break-insert -f main") + self.expect("\^done,bkpt={number=\"1\"") + self.runCmd("-exec-run") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + # Test stack frame: get frame #0 info + self.runCmd("-stack-list-frames 0 0") + self.expect("\^done,stack=\[frame=\{level=\"0\",addr=\"0x[0-9a-f]+\",func=\"main\",file=\"main\.cpp\",fullname=\".+?main\.cpp\",line=\"\d+\"\}\]") + + @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + def test_lldbmi_stack_select_frame(self): + """Test that 'lldb-mi --interpreter' can choose current frame.""" + + self.spawnLldbMi(args = None) + + # Load executable + self.runCmd("-file-exec-and-symbols %s" % self.myexe) + self.expect("\^done") + + # Run to main + self.runCmd("-break-insert -f main") + self.expect("\^done,bkpt={number=\"1\"") + self.runCmd("-exec-run") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + # Test that -stack-select-frame requires 1 mandatory argument + self.runCmd("-stack-select-frame") + self.expect("\^error,msg=\"Command 'stack-select-frame'\. Command Args\. Validation failed. Mandatory args not found: frame_id\"") + + # Test that -stack-select-frame fails on invalid frame number + self.runCmd("-stack-select-frame 99") + self.expect("\^error,msg=\"Command 'stack-select-frame'\. Frame ID invalid\"") + + # Test that current frame is #0 + self.runCmd("-stack-info-frame") + self.expect("\^done,frame=\{level=\"0\",addr=\"0x[0-9a-f]+\",func=\"main\",file=\"main\.cpp\",fullname=\".+?main\.cpp\",line=\"\d+\"\}") + + # Test that -stack-select-frame can select the selected frame + self.runCmd("-stack-select-frame 0") + self.expect("\^done") + + # Test that current frame is still #0 + self.runCmd("-stack-info-frame") + self.expect("\^done,frame=\{level=\"0\",addr=\"0x[0-9a-f]+\",func=\"main\",file=\"main\.cpp\",fullname=\".+?main\.cpp\",line=\"\d+\"\}") + + # Test that -stack-select-frame can select frame #1 (parent frame) + self.runCmd("-stack-select-frame 1") + self.expect("\^done") + + # Test that current frame is #1 + # Note that message is different in Darwin and Linux: + # Darwin: "^done,frame={level=\"1\",addr=\"0x[0-9a-f]+\",func=\"start\",file=\"??\",fullname=\"??\",line=\"-1\"}" + # Linux: "^done,frame={level=\"1\",addr=\"0x[0-9a-f]+\",func=\".+\",file=\".+\",fullname=\".+\",line=\"\d+\"}" + self.runCmd("-stack-info-frame") + self.expect("\^done,frame=\{level=\"1\",addr=\"0x[0-9a-f]+\",func=\".+?\",file=\".+?\",fullname=\".+?\",line=\"(-1|\d+)\"\}") + + # Test that -stack-select-frame can select frame #0 (child frame) + self.runCmd("-stack-select-frame 0") + self.expect("\^done") + + # Test that current frame is #0 and it has the same information + self.runCmd("-stack-info-frame") + self.expect("\^done,frame=\{level=\"0\",addr=\"0x[0-9a-f]+\",func=\"main\",file=\"main\.cpp\",fullname=\".+?main\.cpp\",line=\"\d+\"\}") diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/stack/main.cpp b/packages/Python/lldbsuite/test/tools/lldb-mi/stack/main.cpp new file mode 100644 index 0000000..e11f83e --- /dev/null +++ b/packages/Python/lldbsuite/test/tools/lldb-mi/stack/main.cpp @@ -0,0 +1,127 @@ +//===-- main.cpp ------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +struct inner +{ + int var_d; +}; + +struct my_type +{ + int var_a; + char var_b; + struct inner inner_; +}; + +int +local_int_test(void) +{ + int a = 10, b = 20; + return 0; // BP_local_int_test +} + +int +local_int_test_with_args(int c, int d) +{ + int a = 10, b = 20; + return 0; // BP_local_int_test_with_args +} + +int +local_struct_test(void) +{ + struct my_type var_c; + var_c.var_a = 10; + var_c.var_b = 'a'; + var_c.inner_.var_d = 30; + return 0; // BP_local_struct_test +} + +int local_struct_test_with_args(struct my_type var_e) +{ + struct my_type var_c; + var_c.var_a = 10; + var_c.var_b = 'a'; + var_c.inner_.var_d = 30; + return 0; // BP_local_struct_test_with_args +} + +int +local_array_test(void) +{ + int array[3]; + array[0] = 100; + array[1] = 200; + array[2] = 300; + return 0; // BP_local_array_test +} + +int +local_array_test_with_args(int* other_array) +{ + int array[3]; + array[0] = 100; + array[1] = 200; + array[2] = 300; + return 0; // BP_local_array_test_with_args +} + +int +local_pointer_test(void) +{ + const char *test_str = "Rakaposhi"; + int var_e = 24; + int *ptr = &var_e; + return 0; // BP_local_pointer_test +} + +int +local_pointer_test_with_args(const char *arg_str, int *arg_ptr) +{ + const char *test_str = "Rakaposhi"; + int var_e = 24; + int *ptr = &var_e; + return 0; // BP_local_pointer_test_with_args +} + +int do_tests_with_args() +{ + local_int_test_with_args(30, 40); + + struct my_type var_e; + var_e.var_a = 20; + var_e.var_b = 'b'; + var_e.inner_.var_d = 40; + local_struct_test_with_args(var_e); + + int array[3]; + array[0] = 400; + array[1] = 500; + array[2] = 600; + local_array_test_with_args(array); + + const char *test_str = "String"; + int var_z = 25; + int *ptr = &var_z; + local_pointer_test_with_args(test_str, ptr); + + return 0; +} + +int +main(int argc, char const *argv[]) +{ + local_int_test(); + local_struct_test(); + local_array_test(); + local_pointer_test(); + + do_tests_with_args(); + return 0; +} diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/Makefile b/packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/Makefile new file mode 100644 index 0000000..314f1cb --- /dev/null +++ b/packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/Makefile @@ -0,0 +1,5 @@ +LEVEL = ../../../make + +CXX_SOURCES := main.cpp + +include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/TestMiStartupOptions.py b/packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/TestMiStartupOptions.py new file mode 100644 index 0000000..8f02f1c --- /dev/null +++ b/packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/TestMiStartupOptions.py @@ -0,0 +1,290 @@ +""" +Test lldb-mi startup options. +""" + +from __future__ import print_function + + + +import lldbmi_testcase +from lldbsuite.test.lldbtest import * + +class MiStartupOptionsTestCase(lldbmi_testcase.MiTestCaseBase): + + mydir = TestBase.compute_mydir(__file__) + + @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + def test_lldbmi_executable_option_file(self): + """Test that 'lldb-mi --interpreter %s' loads executable file.""" + + self.spawnLldbMi(args = "%s" % self.myexe) + + # Test that the executable is loaded when file was specified + self.expect("-file-exec-and-symbols \"%s\"" % self.myexe) + self.expect("\^done") + + # Test that lldb-mi is ready when executable was loaded + self.expect(self.child_prompt, exactly = True) + + # Run to main + self.runCmd("-break-insert -f main") + self.expect("\^done,bkpt={number=\"1\"") + self.runCmd("-exec-run") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + # Continue + self.runCmd("-exec-continue") + self.expect("\^running") + self.expect("\*stopped,reason=\"exited-normally\"") + + @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + def test_lldbmi_executable_option_unknown_file(self): + """Test that 'lldb-mi --interpreter %s' fails on unknown executable file.""" + + # Prepare path to executable + path = "unknown_file" + + self.spawnLldbMi(args = "%s" % path) + + # Test that the executable isn't loaded when unknown file was specified + self.expect("-file-exec-and-symbols \"%s\"" % path) + self.expect("\^error,msg=\"Command 'file-exec-and-symbols'. Target binary '%s' is invalid. error: unable to find executable for '%s'\"" % (path, path)) + + # Test that lldb-mi is ready when executable was loaded + self.expect(self.child_prompt, exactly = True) + + @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + def test_lldbmi_executable_option_absolute_path(self): + """Test that 'lldb-mi --interpreter %s' loads executable which is specified via absolute path.""" + + # Prepare path to executable + import os + path = os.path.join(os.getcwd(), self.myexe) + + self.spawnLldbMi(args = "%s" % path) + + # Test that the executable is loaded when file was specified using absolute path + self.expect("-file-exec-and-symbols \"%s\"" % path) + self.expect("\^done") + + # Test that lldb-mi is ready when executable was loaded + self.expect(self.child_prompt, exactly = True) + + # Run + self.runCmd("-exec-run") + self.expect("\^running") + self.expect("\*stopped,reason=\"exited-normally\"") + + @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + def test_lldbmi_executable_option_relative_path(self): + """Test that 'lldb-mi --interpreter %s' loads executable which is specified via relative path.""" + + # Prepare path to executable + path = "./%s" % self.myexe + + self.spawnLldbMi(args = "%s" % path) + + # Test that the executable is loaded when file was specified using relative path + self.expect("-file-exec-and-symbols \"%s\"" % path) + self.expect("\^done") + + # Test that lldb-mi is ready when executable was loaded + self.expect(self.child_prompt, exactly = True) + + # Run + self.runCmd("-exec-run") + self.expect("\^running") + self.expect("\*stopped,reason=\"exited-normally\"") + + @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + def test_lldbmi_executable_option_unknown_path(self): + """Test that 'lldb-mi --interpreter %s' fails on executable file which is specified via unknown path.""" + + # Prepare path to executable + path = "unknown_dir/%s" % self.myexe + + self.spawnLldbMi(args = "%s" % path) + + # Test that the executable isn't loaded when file was specified using unknown path + self.expect("-file-exec-and-symbols \"%s\"" % path) + self.expect("\^error,msg=\"Command 'file-exec-and-symbols'. Target binary '%s' is invalid. error: unable to find executable for '%s'\"" % (path, path)) + + # Test that lldb-mi is ready when executable was loaded + self.expect(self.child_prompt, exactly = True) + + @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + @skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots + def test_lldbmi_source_option_start_script(self): + """Test that 'lldb-mi --interpreter' can execute user's commands after initial commands were executed.""" + + # Prepared source file + sourceFile = "start_script" + + self.spawnLldbMi(args = "--source %s" % sourceFile) + + # After '-file-exec-and-symbols a.out' + self.expect("-file-exec-and-symbols %s" % self.myexe) + self.expect("\^done") + + # After '-break-insert -f main' + self.expect("-break-insert -f main") + self.expect("\^done,bkpt={number=\"1\"") + + # After '-exec-run' + self.expect("-exec-run") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + # After '-break-insert main.cpp:BP_return' + line = line_number('main.cpp', '//BP_return') + self.expect("-break-insert main.cpp:%d" % line) + self.expect("\^done,bkpt={number=\"2\"") + + # After '-exec-continue' + self.expect("-exec-continue") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + # Test that lldb-mi is ready after execution of --source start_script + self.expect(self.child_prompt, exactly = True) + + # Try to evaluate 'a' expression + self.runCmd("-data-evaluate-expression a") + self.expect("\^done,value=\"10\"") + self.expect(self.child_prompt, exactly = True) + + @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + @skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots + def test_lldbmi_source_option_start_script_exit(self): + """Test that 'lldb-mi --interpreter' can execute a prepared file which passed via --source option.""" + + # Prepared source file + sourceFile = "start_script_exit" + + self.spawnLldbMi(args = "--source %s" % sourceFile) + + # After '-file-exec-and-symbols a.out' + self.expect("-file-exec-and-symbols %s" % self.myexe) + self.expect("\^done") + + # After '-break-insert -f main' + self.expect("-break-insert -f main") + self.expect("\^done,bkpt={number=\"1\"") + + # After '-exec-run' + self.expect("-exec-run") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + # After '-break-insert main.cpp:BP_return' + line = line_number('main.cpp', '//BP_return') + self.expect("-break-insert main.cpp:%d" % line) + self.expect("\^done,bkpt={number=\"2\"") + + # After '-exec-continue' + self.expect("-exec-continue") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + # After '-data-evaluate-expression a' + self.expect("-data-evaluate-expression a") + self.expect("\^done,value=\"10\"") + + # After '-gdb-exit' + self.expect("-gdb-exit") + self.expect("\^exit") + self.expect("\*stopped,reason=\"exited-normally\"") + + @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + def test_lldbmi_source_option_start_script_error(self): + """Test that 'lldb-mi --interpreter' stops execution of initial commands in case of error.""" + + # Prepared source file + sourceFile = "start_script_error" + + self.spawnLldbMi(args = "--source %s" % sourceFile) + + # After '-file-exec-and-symbols a.out' + self.expect("-file-exec-and-symbols %s" % self.myexe) + self.expect("\^done") + + # After '-break-ins -f main' + self.expect("-break-ins -f main") + self.expect("\^error") + + # Test that lldb-mi is ready after execution of --source start_script + self.expect(self.child_prompt, exactly = True) + + @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + def test_lldbmi_log_option(self): + """Test that 'lldb-mi --log' creates a log file in the current directory.""" + + logDirectory = "." + self.spawnLldbMi(args = "%s --log" % self.myexe) + + # Test that the executable is loaded when file was specified + self.expect("-file-exec-and-symbols \"%s\"" % self.myexe) + self.expect("\^done") + + # Test that lldb-mi is ready when executable was loaded + self.expect(self.child_prompt, exactly = True) + + # Run + self.runCmd("-exec-run") + self.expect("\^running") + self.expect("\*stopped,reason=\"exited-normally\"") + + # Check log file is created + import glob,os + logFile = glob.glob(logDirectory + "/lldb-mi-*.log") + + if not logFile: + self.fail("log file not found") + + # Delete log + for f in logFile: + os.remove(f) + + @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + def test_lldbmi_log_directory_option(self): + """Test that 'lldb-mi --log --log-dir' creates a log file in the directory specified by --log-dir.""" + + # Create log in temp directory + import tempfile + logDirectory = tempfile.gettempdir() + + self.spawnLldbMi(args = "%s --log --log-dir=%s" % (self.myexe,logDirectory)) + + # Test that the executable is loaded when file was specified + self.expect("-file-exec-and-symbols \"%s\"" % self.myexe) + self.expect("\^done") + + # Test that lldb-mi is ready when executable was loaded + self.expect(self.child_prompt, exactly = True) + + # Run + self.runCmd("-exec-run") + self.expect("\^running") + self.expect("\*stopped,reason=\"exited-normally\"") + + # Check log file is created + import glob,os + logFile = glob.glob(logDirectory + "/lldb-mi-*.log") + + if not logFile: + self.fail("log file not found") + + # Delete log + for f in logFile: + os.remove(f) diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/main.cpp b/packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/main.cpp new file mode 100644 index 0000000..7f2d524 --- /dev/null +++ b/packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/main.cpp @@ -0,0 +1,15 @@ +//===-- main.cpp ------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +int +main(int argc, char const *argv[]) +{ + int a = 10; + return 0; //BP_return +} diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/start_script b/packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/start_script new file mode 100644 index 0000000..511c022 --- /dev/null +++ b/packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/start_script @@ -0,0 +1,5 @@ +-file-exec-and-symbols a.out +-break-insert -f main +-exec-run +-break-insert main.cpp:14 +-exec-continue diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/start_script_error b/packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/start_script_error new file mode 100644 index 0000000..d834e74 --- /dev/null +++ b/packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/start_script_error @@ -0,0 +1,2 @@ +-file-exec-and-symbols a.out +-break-ins -f main diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/start_script_exit b/packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/start_script_exit new file mode 100644 index 0000000..8379018 --- /dev/null +++ b/packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/start_script_exit @@ -0,0 +1,7 @@ +-file-exec-and-symbols a.out +-break-insert -f main +-exec-run +-break-insert main.cpp:14 +-exec-continue +-data-evaluate-expression a +-gdb-exit diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/symbol/Makefile b/packages/Python/lldbsuite/test/tools/lldb-mi/symbol/Makefile new file mode 100644 index 0000000..dde38f4 --- /dev/null +++ b/packages/Python/lldbsuite/test/tools/lldb-mi/symbol/Makefile @@ -0,0 +1,5 @@ +LEVEL = ../../../make + +CXX_SOURCES := main.cpp symbol_list_lines_inline_test.cpp symbol_list_lines_inline_test2.cpp + +include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/symbol/TestMiSymbol.py b/packages/Python/lldbsuite/test/tools/lldb-mi/symbol/TestMiSymbol.py new file mode 100644 index 0000000..3566b2f --- /dev/null +++ b/packages/Python/lldbsuite/test/tools/lldb-mi/symbol/TestMiSymbol.py @@ -0,0 +1,81 @@ +""" +Test lldb-mi -symbol-xxx commands. +""" + +from __future__ import print_function + + + +import lldbmi_testcase +from lldbsuite.test.lldbtest import * + +class MiSymbolTestCase(lldbmi_testcase.MiTestCaseBase): + + mydir = TestBase.compute_mydir(__file__) + + @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + @expectedFailureLinux # new failure after r256863 + def test_lldbmi_symbol_list_lines_file(self): + """Test that 'lldb-mi --interpreter' works for -symbol-list-lines when file exists.""" + + self.spawnLldbMi(args = None) + + # Load executable + self.runCmd("-file-exec-and-symbols %s" % self.myexe) + self.expect("\^done") + + # Run to main + self.runCmd("-break-insert -f main") + self.expect("\^done,bkpt={number=\"1\"") + self.runCmd("-exec-run") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + # Get address of main and its line + self.runCmd("-data-evaluate-expression main") + self.expect("\^done,value=\"0x[0-9a-f]+ \(a.out`main at main.cpp:[0-9]+\)\"") + addr = int(self.child.after.split("\"")[1].split(" ")[0], 16) + line = line_number('main.cpp', '// FUNC_main') + + # Test that -symbol-list-lines works on valid data + self.runCmd("-symbol-list-lines main.cpp") + self.expect("\^done,lines=\[\{pc=\"0x0*%x\",line=\"%d\"\}(,\{pc=\"0x[0-9a-f]+\",line=\"\d+\"\})+\]" % (addr, line)) + + # Test that -symbol-list-lines doesn't include lines from other sources + # by checking the first and last line, and making sure the other lines + # are between 30 and 39. + sline = line_number('symbol_list_lines_inline_test2.cpp', '// FUNC_gfunc2') + eline = line_number('symbol_list_lines_inline_test2.cpp', '// END_gfunc2') + self.runCmd("-symbol-list-lines symbol_list_lines_inline_test2.cpp") + self.expect("\^done,lines=\[\{pc=\"0x[0-9a-f]+\",line=\"%d\"\}(,\{pc=\"0x[0-9a-f]+\",line=\"3\d\"\})*,\{pc=\"0x[0-9a-f]+\",line=\"%d\"\}(,\{pc=\"0x[0-9a-f]+\",line=\"3\d\"\})*\]" % (sline, eline)) + ##FIXME: This doesn't work for symbol_list_lines_inline_test.cpp due to clang bug llvm.org/pr24716 (fixed in newer versions of clang) + ##sline = line_number('symbol_list_lines_inline_test.cpp', '// FUNC_gfunc') + ##eline = line_number('symbol_list_lines_inline_test.cpp', '// STRUCT_s') + ##self.runCmd("-symbol-list-lines symbol_list_lines_inline_test.cpp") + ##self.expect("\^done,lines=\[\{pc=\"0x[0-9a-f]+\",line=\"%d\"\}(,\{pc=\"0x[0-9a-f]+\",line=\"3\d\"\})*,\{pc=\"0x[0-9a-f]+\",line=\"%d\"\}\]" % (sline, eline)) + + # Test that -symbol-list-lines works on header files by checking the first + # and last line, and making sure the other lines are under 29. + sline = line_number('symbol_list_lines_inline_test.h', '// FUNC_ifunc') + eline = line_number('symbol_list_lines_inline_test.h', '// FUNC_mfunc') + self.runCmd("-symbol-list-lines symbol_list_lines_inline_test.h") + self.expect("\^done,lines=\[\{pc=\"0x[0-9a-f]+\",line=\"%d\"\}(,\{pc=\"0x[0-9a-f]+\",line=\"\d\"\})*(,\{pc=\"0x[0-9a-f]+\",line=\"1\d\"\})*,\{pc=\"0x[0-9a-f]+\",line=\"%d\"\}(,\{pc=\"0x[0-9a-f]+\",line=\"2\d\"\})*\]" % (sline, eline)) + + # Test that -symbol-list-lines fails when file doesn't exist + self.runCmd("-symbol-list-lines unknown_file") + self.expect("\^error,message=\"error: No source filenames matched 'unknown_file'\. \"") + + # Test that -symbol-list-lines fails when file is specified using relative path + self.runCmd("-symbol-list-lines ./main.cpp") + self.expect("\^error,message=\"error: No source filenames matched '\./main\.cpp'\. \"") + + # Test that -symbol-list-lines works when file is specified using absolute path + import os + path = os.path.join(os.getcwd(), "main.cpp") + self.runCmd("-symbol-list-lines \"%s\"" % path) + self.expect("\^done,lines=\[\{pc=\"0x0*%x\",line=\"%d\"\}(,\{pc=\"0x[0-9a-f]+\",line=\"\d+\"\})+\]" % (addr, line)) + + # Test that -symbol-list-lines fails when file doesn't exist + self.runCmd("-symbol-list-lines unknown_dir/main.cpp") + self.expect("\^error,message=\"error: No source filenames matched 'unknown_dir/main\.cpp'\. \"") diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/symbol/main.cpp b/packages/Python/lldbsuite/test/tools/lldb-mi/symbol/main.cpp new file mode 100644 index 0000000..6d725a5 --- /dev/null +++ b/packages/Python/lldbsuite/test/tools/lldb-mi/symbol/main.cpp @@ -0,0 +1,18 @@ +//===-- main.cpp ------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +extern int j; +extern int gfunc(int i); +extern int gfunc2(int i); +int +main() +{ // FUNC_main + int i = gfunc(j) + gfunc2(j); + return i == 0; +} diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/symbol/symbol_list_lines_inline_test.cpp b/packages/Python/lldbsuite/test/tools/lldb-mi/symbol/symbol_list_lines_inline_test.cpp new file mode 100644 index 0000000..c432ba8 --- /dev/null +++ b/packages/Python/lldbsuite/test/tools/lldb-mi/symbol/symbol_list_lines_inline_test.cpp @@ -0,0 +1,39 @@ +// Skip lines so we can make sure we're not seeing any lines from +// symbol_list_lines_inline_test.h included in -symbol-list-lines +// symbol_list_lines_inline_test.cpp, by checking that all the lines +// are between 30 and 39. +// line 5 +// line 6 +// line 7 +// line 8 +// line 9 +// line 10 +// line 11 +// line 12 +// line 13 +// line 14 +// line 15 +// line 16 +// line 17 +// line 18 +// line 19 +// line 20 +// line 21 +// line 22 +// line 23 +// line 24 +// line 25 +// line 26 +// line 27 +// line 28 +// line 29 +#include "symbol_list_lines_inline_test.h" +int +gfunc(int i) +{ // FUNC_gfunc + return ns::ifunc(i); +} +namespace ns +{ +S s; // STRUCT_s +} diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/symbol/symbol_list_lines_inline_test.h b/packages/Python/lldbsuite/test/tools/lldb-mi/symbol/symbol_list_lines_inline_test.h new file mode 100644 index 0000000..4b986dc --- /dev/null +++ b/packages/Python/lldbsuite/test/tools/lldb-mi/symbol/symbol_list_lines_inline_test.h @@ -0,0 +1,24 @@ +namespace ns +{ +inline int +ifunc(int i) +{ // FUNC_ifunc + return i; +} +struct S +{ + int a; + int b; + S() + : a(3) + , b(4) + { + } + int + mfunc() + { // FUNC_mfunc + return a + b; + } +}; +extern S s; +} diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/symbol/symbol_list_lines_inline_test2.cpp b/packages/Python/lldbsuite/test/tools/lldb-mi/symbol/symbol_list_lines_inline_test2.cpp new file mode 100644 index 0000000..cfedf47 --- /dev/null +++ b/packages/Python/lldbsuite/test/tools/lldb-mi/symbol/symbol_list_lines_inline_test2.cpp @@ -0,0 +1,38 @@ +// Skip lines so we can make sure we're not seeing any lines from +// symbol_list_lines_inline_test.h included in -symbol-list-lines +// symbol_list_lines_inline_test2.cpp, by checking that all the lines +// are between 30 and 39. +// line 5 +// line 6 +// line 7 +// line 8 +// line 9 +// line 10 +// line 11 +// line 12 +// line 13 +// line 14 +// line 15 +// line 16 +// line 17 +// line 18 +// line 19 +// line 20 +// line 21 +// line 22 +// line 23 +// line 24 +// line 25 +// line 26 +// line 27 +// line 28 +// line 29 +#include "symbol_list_lines_inline_test.h" +int j = 2; +int +gfunc2(int i) +{ // FUNC_gfunc2 + i += ns::s.mfunc(); + i += ns::ifunc(i); + return i == 0; // END_gfunc2 +} diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/syntax/Makefile b/packages/Python/lldbsuite/test/tools/lldb-mi/syntax/Makefile new file mode 100644 index 0000000..314f1cb --- /dev/null +++ b/packages/Python/lldbsuite/test/tools/lldb-mi/syntax/Makefile @@ -0,0 +1,5 @@ +LEVEL = ../../../make + +CXX_SOURCES := main.cpp + +include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/syntax/TestMiSyntax.py b/packages/Python/lldbsuite/test/tools/lldb-mi/syntax/TestMiSyntax.py new file mode 100644 index 0000000..f8a6743 --- /dev/null +++ b/packages/Python/lldbsuite/test/tools/lldb-mi/syntax/TestMiSyntax.py @@ -0,0 +1,80 @@ +""" +Test that the lldb-mi driver understands MI command syntax. +""" + +from __future__ import print_function + + + +import lldbmi_testcase +from lldbsuite.test.lldbtest import * + +class MiSyntaxTestCase(lldbmi_testcase.MiTestCaseBase): + + mydir = TestBase.compute_mydir(__file__) + + @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + def test_lldbmi_tokens(self): + """Test that 'lldb-mi --interpreter' prints command tokens.""" + + self.spawnLldbMi(args = None) + + # Load executable + self.runCmd("000-file-exec-and-symbols %s" % self.myexe) + self.expect("000\^done") + + # Run to main + self.runCmd("100000001-break-insert -f main") + self.expect("100000001\^done,bkpt={number=\"1\"") + self.runCmd("2-exec-run") + self.expect("2\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + # Exit + self.runCmd("0000000000000000000003-exec-continue") + self.expect("0000000000000000000003\^running") + self.expect("\*stopped,reason=\"exited-normally\"") + + @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + def test_lldbmi_specialchars(self): + """Test that 'lldb-mi --interpreter' handles complicated strings.""" + + # Create an alias for myexe + complicated_myexe = "C--mpl-x file's`s @#$%^&*()_+-={}[]| name" + os.symlink(self.myexe, complicated_myexe) + self.addTearDownHook(lambda: os.unlink(complicated_myexe)) + + self.spawnLldbMi(args = "\"%s\"" % complicated_myexe) + + # Test that the executable was loaded + self.expect("-file-exec-and-symbols \"%s\"" % complicated_myexe, exactly = True) + self.expect("\^done") + + # Check that it was loaded correctly + self.runCmd("-break-insert -f main") + self.expect("\^done,bkpt={number=\"1\"") + self.runCmd("-exec-run") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + @expectedFailureLinux # Failing in ~6/600 dosep runs (build 3120-3122) + def test_lldbmi_process_output(self): + """Test that 'lldb-mi --interpreter' wraps process output correctly.""" + + self.spawnLldbMi(args = None) + + # Load executable + self.runCmd("-file-exec-and-symbols %s" % self.myexe) + self.expect("\^done") + + # Run + self.runCmd("-exec-run") + self.expect("\^running") + + # Test that a process output is wrapped correctly + self.expect("\@\"'\\\\r\\\\n\"") + self.expect("\@\"` - it's \\\\\\\\n\\\\x12\\\\\"\\\\\\\\\\\\\"") diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/syntax/main.cpp b/packages/Python/lldbsuite/test/tools/lldb-mi/syntax/main.cpp new file mode 100644 index 0000000..d2935b0 --- /dev/null +++ b/packages/Python/lldbsuite/test/tools/lldb-mi/syntax/main.cpp @@ -0,0 +1,17 @@ +//===-- main.cpp ------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include <cstdio> + +int +main(int argc, char const *argv[]) +{ + printf("'\n` - it's \\n\x12\"\\\""); + return 0; +} diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/target/Makefile b/packages/Python/lldbsuite/test/tools/lldb-mi/target/Makefile new file mode 100644 index 0000000..b2550fe --- /dev/null +++ b/packages/Python/lldbsuite/test/tools/lldb-mi/target/Makefile @@ -0,0 +1,5 @@ +LEVEL = ../../../make + +CXX_SOURCES := test_attach.cpp + +include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/target/TestMiTarget.py b/packages/Python/lldbsuite/test/tools/lldb-mi/target/TestMiTarget.py new file mode 100644 index 0000000..73ef913 --- /dev/null +++ b/packages/Python/lldbsuite/test/tools/lldb-mi/target/TestMiTarget.py @@ -0,0 +1,125 @@ +""" +Test lldb-mi -target-xxx commands. +""" + +from __future__ import print_function + + + +import lldbmi_testcase +from lldbsuite.test.lldbtest import * + +class MiTargetTestCase(lldbmi_testcase.MiTestCaseBase): + + mydir = TestBase.compute_mydir(__file__) + + @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + @skipIfLinux # cannot attach to process on linux + def test_lldbmi_target_attach_wait_for(self): + """Test that 'lldb-mi --interpreter' works for -target-attach -n <name> --waitfor.""" + + # Build target executable with unique name + exeName = self.testMethodName + d = {'EXE': exeName} + self.buildProgram("test_attach.cpp", exeName) + self.addTearDownCleanup(dictionary=d) + + self.spawnLldbMi(args = None) + + # Load executable + # FIXME: -file-exec-and-sybmols is not required for target attach, but the test will not pass without this + self.runCmd("-file-exec-and-symbols %s" % exeName) + self.expect("\^done") + + # Set up attach + self.runCmd("-target-attach -n %s --waitfor" % exeName) + time.sleep(4) # Give attach time to setup + + # Start target process + self.spawnSubprocess(os.path.join(os.path.dirname(__file__), exeName)); + self.addTearDownHook(self.cleanupSubprocesses) + self.expect("\^done") + + # Set breakpoint on printf + line = line_number('test_attach.cpp', '// BP_i++') + self.runCmd("-break-insert -f test_attach.cpp:%d" % line) + self.expect("\^done,bkpt={number=\"1\"") + + # Continue to breakpoint + self.runCmd("-exec-continue") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + # Detach + self.runCmd("-target-detach") + self.expect("\^done") + + @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + @skipIfLinux # cannot attach to process on linux + def test_lldbmi_target_attach_name(self): + """Test that 'lldb-mi --interpreter' works for -target-attach -n <name>.""" + + # Build target executable with unique name + exeName = self.testMethodName + d = {'EXE': exeName} + self.buildProgram("test_attach.cpp", exeName) + self.addTearDownCleanup(dictionary=d) + + # Start target process + targetProcess = self.spawnSubprocess(os.path.join(os.path.dirname(__file__), exeName)); + self.addTearDownHook(self.cleanupSubprocesses) + + self.spawnLldbMi(args = None) + + # Set up atatch + self.runCmd("-target-attach -n %s" % exeName) + self.expect("\^done") + + # Set breakpoint on printf + line = line_number('test_attach.cpp', '// BP_i++') + self.runCmd("-break-insert -f test_attach.cpp:%d" % line) + self.expect("\^done,bkpt={number=\"1\"") + + # Continue to breakpoint + self.runCmd("-exec-continue") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + # Detach + self.runCmd("-target-detach") + self.expect("\^done") + + @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + @skipIfLinux # cannot attach to process on linux + def test_lldbmi_target_attach_pid(self): + """Test that 'lldb-mi --interpreter' works for -target-attach <pid>.""" + + # Build target executable with unique name + exeName = self.testMethodName + d = {'EXE': exeName} + self.buildProgram("test_attach.cpp", exeName) + self.addTearDownCleanup(dictionary=d) + + # Start target process + targetProcess = self.spawnSubprocess(os.path.join(os.path.dirname(__file__), exeName)); + self.addTearDownHook(self.cleanupSubprocesses) + + self.spawnLldbMi(args = None) + + # Set up atatch + self.runCmd("-target-attach %d" % targetProcess.pid) + self.expect("\^done") + + # Set breakpoint on printf + line = line_number('test_attach.cpp', '// BP_i++') + self.runCmd("-break-insert -f test_attach.cpp:%d" % line) + self.expect("\^done,bkpt={number=\"1\"") + + # Continue to breakpoint + self.runCmd("-exec-continue") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + # Detach + self.runCmd("-target-detach") + self.expect("\^done") diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/target/test_attach.cpp b/packages/Python/lldbsuite/test/tools/lldb-mi/target/test_attach.cpp new file mode 100644 index 0000000..caaf33a --- /dev/null +++ b/packages/Python/lldbsuite/test/tools/lldb-mi/target/test_attach.cpp @@ -0,0 +1,21 @@ +//===-- main.cpp ------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include <cstdio> + +int +main(int argc, char const *argv[]) +{ + int i = 0; + for (;;) + { + i++; // BP_i++ + } + return 0; +} diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/variable/Makefile b/packages/Python/lldbsuite/test/tools/lldb-mi/variable/Makefile new file mode 100644 index 0000000..314f1cb --- /dev/null +++ b/packages/Python/lldbsuite/test/tools/lldb-mi/variable/Makefile @@ -0,0 +1,5 @@ +LEVEL = ../../../make + +CXX_SOURCES := main.cpp + +include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/variable/TestMiGdbSetShowPrint.py b/packages/Python/lldbsuite/test/tools/lldb-mi/variable/TestMiGdbSetShowPrint.py new file mode 100644 index 0000000..067df64 --- /dev/null +++ b/packages/Python/lldbsuite/test/tools/lldb-mi/variable/TestMiGdbSetShowPrint.py @@ -0,0 +1,227 @@ +#coding=utf8 +""" +Test lldb-mi -gdb-set and -gdb-show commands for 'print option-name'. +""" + +from __future__ import print_function + + + +import lldbmi_testcase +from lldbsuite.test.lldbtest import * + +class MiGdbSetShowTestCase(lldbmi_testcase.MiTestCaseBase): + + mydir = TestBase.compute_mydir(__file__) + + # evaluates array when char-array-as-string is off + def eval_and_check_array(self, var, typ, length): + self.runCmd("-var-create - * %s" % var) + self.expect('\^done,name="var\d+",numchild="%d",value="\[%d\]",type="%s \[%d\]",thread-id="1",has_more="0"' % (length, length, typ, length)) + + # evaluates any type which can be represented as string of characters + def eval_and_match_string(self, var, value, typ): + value=value.replace("\\", "\\\\").replace("\"", "\\\"") + self.runCmd("-var-create - * " + var) + self.expect('\^done,name="var\d+",numchild="[0-9]+",value="%s",type="%s",thread-id="1",has_more="0"' % (value, typ)) + + @skipIfWindows #llvm.org/pr24452: Get lldb-mi working on Windows + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + @skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots + def test_lldbmi_gdb_set_show_print_char_array_as_string(self): + """Test that 'lldb-mi --interpreter' can print array of chars as string.""" + + self.spawnLldbMi(args = None) + + # Load executable + self.runCmd("-file-exec-and-symbols %s" % self.myexe) + self.expect("\^done") + + # Run to BP_gdb_set_show_print_char_array_as_string_test + line = line_number('main.cpp', '// BP_gdb_set_show_print_char_array_as_string_test') + self.runCmd("-break-insert main.cpp:%d" % line) + self.expect("\^done,bkpt={number=\"1\"") + self.runCmd("-exec-run") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + # Test that default print char-array-as-string value is "off" + self.runCmd("-gdb-show print char-array-as-string") + self.expect("\^done,value=\"off\"") + + # Test that a char* is expanded to string when print char-array-as-string is "off" + self.eval_and_match_string("cp", r'0x[0-9a-f]+ \"\\t\\\"hello\\\"\\n\"', r'const char \*') + + # Test that a char[] isn't expanded to string when print char-array-as-string is "off" + self.eval_and_check_array("ca", "const char", 10); + + # Test that a char16_t* is expanded to string when print char-array-as-string is "off" + self.eval_and_match_string("u16p", r'0x[0-9a-f]+ u\"\\t\\\"hello\\\"\\n\"', r'const char16_t \*') + + # Test that a char16_t[] isn't expanded to string when print char-array-as-string is "off" + self.eval_and_check_array("u16a", "const char16_t", 10); + + # Test that a char32_t* is expanded to string when print char-array-as-string is "off" + self.eval_and_match_string("u32p", r'0x[0-9a-f]+ U\"\\t\\\"hello\\\"\\n\"', r'const char32_t \*') + + # Test that a char32_t[] isn't expanded to string when print char-array-as-string is "off" + self.eval_and_check_array("u32a", "const char32_t", 10); + + # Test that -gdb-set can set print char-array-as-string flag + self.runCmd("-gdb-set print char-array-as-string on") + self.expect("\^done") + self.runCmd("-gdb-set print char-array-as-string 1") + self.expect("\^done") + self.runCmd("-gdb-show print char-array-as-string") + self.expect("\^done,value=\"on\"") + + # Test that a char* with escape chars is expanded to string when print char-array-as-string is "on" + self.eval_and_match_string("cp", r'0x[0-9a-f]+ \"\\t\\\"hello\\\"\\n\"', r'const char \*') + + # Test that a char[] with escape chars is expanded to string when print char-array-as-string is "on" + self.eval_and_match_string("ca", r'\"\\t\\\"hello\\\"\\n\"', r'const char \[10\]') + + # Test that a char16_t* with escape chars is expanded to string when print char-array-as-string is "on" + self.eval_and_match_string("u16p", r'0x[0-9a-f]+ u\"\\t\\\"hello\\\"\\n\"', r'const char16_t \*') + + # Test that a char16_t[] with escape chars is expanded to string when print char-array-as-string is "on" + self.eval_and_match_string("u16a", r'u\"\\t\\\"hello\\\"\\n\"', r'const char16_t \[10\]') + + # Test that a char32_t* with escape chars is expanded to string when print char-array-as-string is "on" + self.eval_and_match_string("u32p", r'0x[0-9a-f]+ U\"\\t\\\"hello\\\"\\n\"', r'const char32_t \*') + + # Test that a char32_t[] with escape chars is expanded to string when print char-array-as-string is "on" + self.eval_and_match_string("u32a", r'U\"\\t\\\"hello\\\"\\n\"', r'const char32_t \[10\]') + + # Test russian unicode strings + self.eval_and_match_string("u16p_rus", r'0x[0-9a-f]+ u\"\\\\Аламо-сквер\"', r'const char16_t \*') + self.eval_and_match_string("u16a_rus", r'u\"\\\\Бейвью\"', r'const char16_t \[8\]') + self.eval_and_match_string("u32p_rus", r'0x[0-9a-f]+ U\"\\\\Чайнатаун\"', r'const char32_t \*') + self.eval_and_match_string("u32a_rus", r'U\"\\\\Догпатч\"', r'const char32_t \[9\]') + + # Test that -gdb-set print char-array-as-string fails if "on"/"off" isn't specified + self.runCmd("-gdb-set print char-array-as-string") + self.expect("\^error,msg=\"The request ''print' expects option-name and \"on\" or \"off\"' failed.\"") + + # Test that -gdb-set print char-array-as-string fails when option is unknown + self.runCmd("-gdb-set print char-array-as-string unknown") + self.expect("\^error,msg=\"The request ''print' expects option-name and \"on\" or \"off\"' failed.\"") + + @skipIfWindows #llvm.org/pr24452: Get lldb-mi working on Windows + @expectedFailureGcc("https://llvm.org/bugs/show_bug.cgi?id=23357") + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + def test_lldbmi_gdb_set_show_print_expand_aggregates(self): + """Test that 'lldb-mi --interpreter' can expand aggregates everywhere.""" + + self.spawnLldbMi(args = None) + + # Load executable + self.runCmd("-file-exec-and-symbols %s" % self.myexe) + self.expect("\^done") + + # Run to BP_gdb_set_show_print_expand_aggregates + line = line_number('main.cpp', '// BP_gdb_set_show_print_expand_aggregates') + self.runCmd("-break-insert main.cpp:%d" % line) + self.expect("\^done,bkpt={number=\"1\"") + self.runCmd("-exec-run") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + # Test that default print expand-aggregates value is "off" + self.runCmd("-gdb-show print expand-aggregates") + self.expect("\^done,value=\"off\"") + + # Test that composite type isn't expanded when print expand-aggregates is "off" + self.runCmd("-var-create var1 * complx") + self.expect("\^done,name=\"var1\",numchild=\"3\",value=\"{\.\.\.}\",type=\"complex_type\",thread-id=\"1\",has_more=\"0\"") + + # Test that composite type[] isn't expanded when print expand-aggregates is "off" + self.eval_and_check_array("complx_array", "complex_type", 2) + + # Test that a struct with a char first element is not formatted as a string + self.runCmd("-var-create - * &nstr") + self.expect("\^done,name=\"var\d+\",numchild=\"2\",value=\"0x[0-9a-f]+\",type=\"not_str \*\",thread-id=\"1\",has_more=\"0\"") + + # Test that -gdb-set can set print expand-aggregates flag + self.runCmd("-gdb-set print expand-aggregates on") + self.expect("\^done") + self.runCmd("-gdb-set print expand-aggregates 1") + self.expect("\^done") + self.runCmd("-gdb-show print expand-aggregates") + self.expect("\^done,value=\"on\"") + + # Test that composite type is expanded when print expand-aggregates is "on" + self.runCmd("-var-create var3 * complx") + self.expect("\^done,name=\"var3\",numchild=\"3\",value=\"{i = 3, inner = {l = 3}, complex_ptr = 0x[0-9a-f]+}\",type=\"complex_type\",thread-id=\"1\",has_more=\"0\"") + + # Test that composite type[] is expanded when print expand-aggregates is "on" + self.runCmd("-var-create var4 * complx_array") + self.expect("\^done,name=\"var4\",numchild=\"2\",value=\"{\[0\] = {i = 4, inner = {l = 4}, complex_ptr = 0x[0-9a-f]+}, \[1\] = {i = 5, inner = {l = 5}, complex_ptr = 0x[0-9a-f]+}}\",type=\"complex_type \[2\]\",thread-id=\"1\",has_more=\"0\"") + + # Test that -gdb-set print expand-aggregates fails if "on"/"off" isn't specified + self.runCmd("-gdb-set print expand-aggregates") + self.expect("\^error,msg=\"The request ''print' expects option-name and \"on\" or \"off\"' failed.\"") + + # Test that -gdb-set print expand-aggregates fails when option is unknown + self.runCmd("-gdb-set print expand-aggregates unknown") + self.expect("\^error,msg=\"The request ''print' expects option-name and \"on\" or \"off\"' failed.\"") + + @skipIfWindows #llvm.org/pr24452: Get lldb-mi working on Windows + @expectedFailureGcc("https://llvm.org/bugs/show_bug.cgi?id=23357") + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + def test_lldbmi_gdb_set_show_print_aggregate_field_names(self): + """Test that 'lldb-mi --interpreter' can expand aggregates everywhere.""" + + self.spawnLldbMi(args = None) + + # Load executable + self.runCmd("-file-exec-and-symbols %s" % self.myexe) + self.expect("\^done") + + # Run to BP_gdb_set_show_print_aggregate_field_names + line = line_number('main.cpp', '// BP_gdb_set_show_print_aggregate_field_names') + self.runCmd("-break-insert main.cpp:%d" % line) + self.expect("\^done,bkpt={number=\"1\"") + self.runCmd("-exec-run") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + # Test that default print aggregatep-field-names value is "on" + self.runCmd("-gdb-show print aggregate-field-names") + self.expect("\^done,value=\"on\"") + + # Set print expand-aggregates flag to "on" + self.runCmd("-gdb-set print expand-aggregates on") + self.expect("\^done") + + # Test that composite type is expanded with field name when print aggregate-field-names is "on" + self.runCmd("-var-create var1 * complx") + self.expect("\^done,name=\"var1\",numchild=\"3\",value=\"{i = 3, inner = {l = 3}, complex_ptr = 0x[0-9a-f]+}\",type=\"complex_type\",thread-id=\"1\",has_more=\"0\"") + + # Test that composite type[] is expanded with field name when print aggregate-field-names is "on" + self.runCmd("-var-create var2 * complx_array") + self.expect("\^done,name=\"var2\",numchild=\"2\",value=\"{\[0\] = {i = 4, inner = {l = 4}, complex_ptr = 0x[0-9a-f]+}, \[1\] = {i = 5, inner = {l = 5}, complex_ptr = 0x[0-9a-f]+}}\",type=\"complex_type \[2\]\",thread-id=\"1\",has_more=\"0\"") + + # Test that -gdb-set can set print aggregate-field-names flag + self.runCmd("-gdb-set print aggregate-field-names off") + self.expect("\^done") + self.runCmd("-gdb-set print aggregate-field-names 0") + self.expect("\^done") + self.runCmd("-gdb-show print aggregate-field-names") + self.expect("\^done,value=\"off\"") + + # Test that composite type is expanded without field name when print aggregate-field-names is "off" + self.runCmd("-var-create var3 * complx") + self.expect("\^done,name=\"var3\",numchild=\"3\",value=\"{3,\{3\},0x[0-9a-f]+}\",type=\"complex_type\",thread-id=\"1\",has_more=\"0\"") + + # Test that composite type[] is expanded without field name when print aggregate-field-names is "off" + self.runCmd("-var-create var4 * complx_array") + self.expect("\^done,name=\"var4\",numchild=\"2\",value=\"{{4,\{4\},0x[0-9a-f]+},{5,\{5\},0x[0-9a-f]+}}\",type=\"complex_type \[2\]\",thread-id=\"1\",has_more=\"0\"") + + # Test that -gdb-set print aggregate-field-names fails if "on"/"off" isn't specified + self.runCmd("-gdb-set print aggregate-field-names") + self.expect("\^error,msg=\"The request ''print' expects option-name and \"on\" or \"off\"' failed.\"") + + # Test that -gdb-set print aggregate-field-names fails when option is unknown + self.runCmd("-gdb-set print aggregate-field-names unknown") + self.expect("\^error,msg=\"The request ''print' expects option-name and \"on\" or \"off\"' failed.\"") diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/variable/TestMiVar.py b/packages/Python/lldbsuite/test/tools/lldb-mi/variable/TestMiVar.py new file mode 100644 index 0000000..26f3a9c --- /dev/null +++ b/packages/Python/lldbsuite/test/tools/lldb-mi/variable/TestMiVar.py @@ -0,0 +1,396 @@ +""" +Test lldb-mi -var-xxx commands. +""" + +from __future__ import print_function + + + +import lldbmi_testcase +from lldbsuite.test.lldbtest import * + +class MiVarTestCase(lldbmi_testcase.MiTestCaseBase): + + mydir = TestBase.compute_mydir(__file__) + + @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + def test_lldbmi_eval(self): + """Test that 'lldb-mi --interpreter' works for evaluating.""" + + self.spawnLldbMi(args = None) + + # Load executable + self.runCmd("-file-exec-and-symbols %s" % self.myexe) + self.expect("\^done") + + # Run to program return + line = line_number('main.cpp', '// BP_return') + self.runCmd("-break-insert main.cpp:%d" % line) + self.expect("\^done,bkpt={number=\"1\"") + self.runCmd("-exec-run") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + # Print non-existant variable + self.runCmd("-var-create var1 * undef") + self.expect("\^error,msg=\"error: error: use of undeclared identifier \'undef\'\\\\nerror: 1 errors parsing expression\\\\n\"") + self.runCmd("-data-evaluate-expression undef") + self.expect("\^error,msg=\"Could not evaluate expression\"") + + # Print global "g_MyVar", modify, delete and create again + self.runCmd("-data-evaluate-expression g_MyVar") + self.expect("\^done,value=\"3\"") + self.runCmd("-var-create var2 * g_MyVar") + self.expect("\^done,name=\"var2\",numchild=\"0\",value=\"3\",type=\"int\",thread-id=\"1\",has_more=\"0\"") + self.runCmd("-var-evaluate-expression var2") + self.expect("\^done,value=\"3\"") + self.runCmd("-var-show-attributes var2") + self.expect("\^done,status=\"editable\"") + self.runCmd("-var-list-children var2") + self.expect("\^done,numchild=\"0\",has_more=\"0\"") + # Ensure -var-list-children also works with quotes + self.runCmd("-var-list-children \"var2\"") + self.expect("\^done,numchild=\"0\",has_more=\"0\"") + self.runCmd("-data-evaluate-expression \"g_MyVar=30\"") + self.expect("\^done,value=\"30\"") + self.runCmd("-var-update --all-values var2") + #self.expect("\^done,changelist=\[\{name=\"var2\",value=\"30\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\}\]") #FIXME -var-update doesn't work + self.runCmd("-var-delete var2") + self.expect("\^done") + self.runCmd("-var-create var2 * g_MyVar") + self.expect("\^done,name=\"var2\",numchild=\"0\",value=\"30\",type=\"int\",thread-id=\"1\",has_more=\"0\"") + + # Print static "s_MyVar", modify, delete and create again + self.runCmd("-data-evaluate-expression s_MyVar") + self.expect("\^done,value=\"30\"") + self.runCmd("-var-create var3 * s_MyVar") + self.expect("\^done,name=\"var3\",numchild=\"0\",value=\"30\",type=\"int\",thread-id=\"1\",has_more=\"0\"") + self.runCmd("-var-evaluate-expression var3") + self.expect("\^done,value=\"30\"") + self.runCmd("-var-show-attributes var3") + self.expect("\^done,status=\"editable\"") + self.runCmd("-var-list-children var3") + self.expect("\^done,numchild=\"0\",has_more=\"0\"") + self.runCmd("-data-evaluate-expression \"s_MyVar=3\"") + self.expect("\^done,value=\"3\"") + self.runCmd("-var-update --all-values var3") + #self.expect("\^done,changelist=\[\{name=\"var3\",value=\"3\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\}\]") #FIXME -var-update doesn't work + self.runCmd("-var-delete var3") + self.expect("\^done") + self.runCmd("-var-create var3 * s_MyVar") + self.expect("\^done,name=\"var3\",numchild=\"0\",value=\"3\",type=\"int\",thread-id=\"1\",has_more=\"0\"") + + # Print local "b", modify, delete and create again + self.runCmd("-data-evaluate-expression b") + self.expect("\^done,value=\"20\"") + self.runCmd("-var-create var4 * b") + self.expect("\^done,name=\"var4\",numchild=\"0\",value=\"20\",type=\"int\",thread-id=\"1\",has_more=\"0\"") + self.runCmd("-var-evaluate-expression var4") + self.expect("\^done,value=\"20\"") + self.runCmd("-var-show-attributes var4") + self.expect("\^done,status=\"editable\"") + self.runCmd("-var-list-children var4") + self.expect("\^done,numchild=\"0\",has_more=\"0\"") + self.runCmd("-data-evaluate-expression \"b=2\"") + self.expect("\^done,value=\"2\"") + self.runCmd("-var-update --all-values var4") + #self.expect("\^done,changelist=\[\{name=\"var4\",value=\"2\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\}\]") #FIXME -var-update doesn't work + self.runCmd("-var-delete var4") + self.expect("\^done") + self.runCmd("-var-create var4 * b") + self.expect("\^done,name=\"var4\",numchild=\"0\",value=\"2\",type=\"int\",thread-id=\"1\",has_more=\"0\"") + + # Print temp "a + b" + self.runCmd("-data-evaluate-expression \"a + b\"") + self.expect("\^done,value=\"12\"") + self.runCmd("-var-create var5 * \"a + b\"") + self.expect("\^done,name=\"var5\",numchild=\"0\",value=\"12\",type=\"int\",thread-id=\"1\",has_more=\"0\"") + self.runCmd("-var-evaluate-expression var5") + self.expect("\^done,value=\"12\"") + self.runCmd("-var-show-attributes var5") + self.expect("\^done,status=\"editable\"") #FIXME editable or not? + self.runCmd("-var-list-children var5") + self.expect("\^done,numchild=\"0\",has_more=\"0\"") + + # Print argument "argv[0]" + self.runCmd("-data-evaluate-expression \"argv[0]\"") + self.expect("\^done,value=\"0x[0-9a-f]+ \\\\\\\".*?%s\\\\\\\"\"" % self.myexe) + self.runCmd("-var-create var6 * \"argv[0]\"") + self.expect("\^done,name=\"var6\",numchild=\"1\",value=\"0x[0-9a-f]+ \\\\\\\".*?%s\\\\\\\"\",type=\"const char \*\",thread-id=\"1\",has_more=\"0\"" % self.myexe) + self.runCmd("-var-evaluate-expression var6") + self.expect("\^done,value=\"0x[0-9a-f]+ \\\\\\\".*?%s\\\\\\\"\"" % self.myexe) + self.runCmd("-var-show-attributes var6") + self.expect("\^done,status=\"editable\"") + self.runCmd("-var-list-children --all-values var6") + # FIXME: The name below is not correct. It should be "var.*argv[0]". + self.expect("\^done,numchild=\"1\",children=\[child=\{name=\"var6\.\*\$[0-9]+\",exp=\"\*\$[0-9]+\",numchild=\"0\",type=\"const char\",thread-id=\"4294967295\",value=\"47 '/'\",has_more=\"0\"\}\],has_more=\"0\"") #FIXME -var-list-children shows invalid thread-id + + @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + @skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots + def test_lldbmi_var_update(self): + """Test that 'lldb-mi --interpreter' works for -var-update.""" + + self.spawnLldbMi(args = None) + + # Load executable + self.runCmd("-file-exec-and-symbols %s" % self.myexe) + self.expect("\^done") + + # Run to BP_var_update_test_init + line = line_number('main.cpp', '// BP_var_update_test_init') + self.runCmd("-break-insert main.cpp:%d" % line) + self.expect("\^done,bkpt={number=\"1\"") + self.runCmd("-exec-run") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + # Setup variables + self.runCmd("-var-create var_l * l") + self.expect("\^done,name=\"var_l\",numchild=\"0\",value=\"1\",type=\"long\",thread-id=\"1\",has_more=\"0\"") + self.runCmd("-var-create var_complx * complx") + self.expect("\^done,name=\"var_complx\",numchild=\"3\",value=\"\{\.\.\.\}\",type=\"complex_type\",thread-id=\"1\",has_more=\"0\"") + self.runCmd("-var-create var_complx_array * complx_array") + self.expect("\^done,name=\"var_complx_array\",numchild=\"2\",value=\"\[2\]\",type=\"complex_type \[2\]\",thread-id=\"1\",has_more=\"0\"") + + # Go to BP_var_update_test_l + line = line_number('main.cpp', '// BP_var_update_test_l') + self.runCmd("-break-insert main.cpp:%d" % line) + self.expect("\^done,bkpt={number=\"2\"") + self.runCmd("-exec-continue") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + # Test that var_l was updated + self.runCmd("-var-update --all-values var_l") + self.expect("\^done,changelist=\[\{name=\"var_l\",value=\"0\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\}\]") + + # Go to BP_var_update_test_complx + line = line_number('main.cpp', '// BP_var_update_test_complx') + self.runCmd("-break-insert main.cpp:%d" % line) + self.expect("\^done,bkpt={number=\"3\"") + self.runCmd("-exec-continue") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + # Test that var_complx was updated + self.runCmd("-var-update --all-values var_complx") + self.expect("\^done,changelist=\[\{name=\"var_complx\",value=\"\{\.\.\.\}\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\}\]") + + # Go to BP_var_update_test_complx_array + line = line_number('main.cpp', '// BP_var_update_test_complx_array') + self.runCmd("-break-insert main.cpp:%d" % line) + self.expect("\^done,bkpt={number=\"4\"") + self.runCmd("-exec-continue") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + # Test that var_complex_array was updated + self.runCmd("-var-update --all-values var_complx_array") + self.expect("\^done,changelist=\[\{name=\"var_complx_array\",value=\"\[2\]\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\}\]") + + @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + def test_lldbmi_var_create_register(self): + """Test that 'lldb-mi --interpreter' works for -var-create $regname.""" + + self.spawnLldbMi(args = None) + + # Load executable + self.runCmd("-file-exec-and-symbols %s" % self.myexe) + self.expect("\^done") + + # Run to main + self.runCmd("-break-insert -f main") + self.expect("\^done,bkpt={number=\"1\"") + self.runCmd("-exec-run") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + # Find name of register 0 + self.runCmd("-data-list-register-names 0") + self.expect("\^done,register-names=\[\".+?\"\]") + register_name = self.child.after.split("\"")[1] + + # Create variable for register 0 + # Note that message is different in Darwin and Linux: + # Darwin: "^done,name=\"var_reg\",numchild=\"0\",value=\"0x[0-9a-f]+\",type=\"unsigned long\",thread-id=\"1\",has_more=\"0\" + # Linux: "^done,name=\"var_reg\",numchild=\"0\",value=\"0x[0-9a-f]+\",type=\"unsigned int\",thread-id=\"1\",has_more=\"0\" + self.runCmd("-var-create var_reg * $%s" % register_name) + self.expect("\^done,name=\"var_reg\",numchild=\"0\",value=\"0x[0-9a-f]+\",type=\"unsigned (long|int)\",thread-id=\"1\",has_more=\"0\"") + + # Assign value to variable + self.runCmd("-var-assign var_reg \"6\"") + #FIXME: the output has different format for 32bit and 64bit values + self.expect("\^done,value=\"0x0*?6\"") + + # Assert register 0 updated + self.runCmd("-data-list-register-values d 0") + self.expect("\^done,register-values=\[{number=\"0\",value=\"6\"") + + @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + @skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots + def test_lldbmi_var_list_children(self): + """Test that 'lldb-mi --interpreter' works for -var-list-children.""" + + self.spawnLldbMi(args = None) + + # Load executable + self.runCmd("-file-exec-and-symbols %s" % self.myexe) + self.expect("\^done") + + # Run to BP_var_list_children_test + line = line_number('main.cpp', '// BP_var_list_children_test') + self.runCmd("-break-insert main.cpp:%d" % line) + self.expect("\^done,bkpt={number=\"1\"") + self.runCmd("-exec-run") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + # Create variable + self.runCmd("-var-create var_complx * complx") + self.expect("\^done,name=\"var_complx\",numchild=\"3\",value=\"\{\.\.\.\}\",type=\"complex_type\",thread-id=\"1\",has_more=\"0\"") + self.runCmd("-var-create var_complx_array * complx_array") + self.expect("\^done,name=\"var_complx_array\",numchild=\"2\",value=\"\[2\]\",type=\"complex_type \[2\]\",thread-id=\"1\",has_more=\"0\"") + self.runCmd("-var-create var_pcomplx * pcomplx") + self.expect("\^done,name=\"var_pcomplx\",numchild=\"2\",value=\"\{\.\.\.\}\",type=\"pcomplex_type\",thread-id=\"1\",has_more=\"0\"") + + # Test that -var-evaluate-expression can evaluate the children of created varobj + self.runCmd("-var-list-children var_complx") + self.runCmd("-var-evaluate-expression var_complx.i") + self.expect("\^done,value=\"3\"") + self.runCmd("-var-list-children var_complx_array") + self.runCmd("-var-evaluate-expression var_complx_array.[0]") + self.expect("\^done,value=\"\{...\}\"") + self.runCmd("-var-list-children var_pcomplx") + self.runCmd("-var-evaluate-expression var_pcomplx.complex_type") + self.expect("\^done,value=\"\{...\}\"") + + # Test that -var-list-children lists empty children if range is empty + # (and that print-values is optional) + self.runCmd("-var-list-children var_complx 0 0") + self.expect("\^done,numchild=\"0\",has_more=\"1\"") + self.runCmd("-var-list-children var_complx 99 0") + self.expect("\^done,numchild=\"0\",has_more=\"1\"") + self.runCmd("-var-list-children var_complx 99 3") + self.expect("\^done,numchild=\"0\",has_more=\"0\"") + + # Test that -var-list-children lists all children with their values + # (and that from and to are optional) + self.runCmd("-var-list-children --all-values var_complx") + self.expect("\^done,numchild=\"3\",children=\[child=\{name=\"var_complx\.i\",exp=\"i\",numchild=\"0\",type=\"int\",thread-id=\"1\",value=\"3\",has_more=\"0\"\},child=\{name=\"var_complx\.inner\",exp=\"inner\",numchild=\"1\",type=\"complex_type::\(anonymous struct\)\",thread-id=\"1\",value=\"\{\.\.\.\}\",has_more=\"0\"\},child=\{name=\"var_complx\.complex_ptr\",exp=\"complex_ptr\",numchild=\"3\",type=\"complex_type \*\",thread-id=\"1\",value=\"0x[0-9a-f]+\",has_more=\"0\"\}\],has_more=\"0\"") + self.runCmd("-var-list-children --simple-values var_complx_array") + self.expect("\^done,numchild=\"2\",children=\[child=\{name=\"var_complx_array\.\[0\]\",exp=\"\[0\]\",numchild=\"3\",type=\"complex_type\",thread-id=\"1\",has_more=\"0\"\},child=\{name=\"var_complx_array\.\[1\]\",exp=\"\[1\]\",numchild=\"3\",type=\"complex_type\",thread-id=\"1\",has_more=\"0\"\}\],has_more=\"0\"") + self.runCmd("-var-list-children 0 var_pcomplx") + self.expect("\^done,numchild=\"2\",children=\[child=\{name=\"var_pcomplx\.complex_type\",exp=\"complex_type\",numchild=\"3\",type=\"complex_type\",thread-id=\"1\",has_more=\"0\"\},child={name=\"var_pcomplx\.complx\",exp=\"complx\",numchild=\"3\",type=\"complex_type\",thread-id=\"1\",has_more=\"0\"\}\],has_more=\"0\"") + + # Test that -var-list-children lists children without values + self.runCmd("-var-list-children 0 var_complx 0 1") + self.expect("\^done,numchild=\"1\",children=\[child=\{name=\"var_complx\.i\",exp=\"i\",numchild=\"0\",type=\"int\",thread-id=\"1\",has_more=\"0\"\}\],has_more=\"1\"") + self.runCmd("-var-list-children --no-values var_complx 0 1") + self.expect("\^done,numchild=\"1\",children=\[child=\{name=\"var_complx\.i\",exp=\"i\",numchild=\"0\",type=\"int\",thread-id=\"1\",has_more=\"0\"\}\],has_more=\"1\"") + self.runCmd("-var-list-children --no-values var_complx_array 0 1") + self.expect("\^done,numchild=\"1\",children=\[child=\{name=\"var_complx_array\.\[0\]\",exp=\"\[0\]\",numchild=\"3\",type=\"complex_type\",thread-id=\"1\",has_more=\"0\"\}\],has_more=\"1\"") + self.runCmd("-var-list-children --no-values var_pcomplx 0 1") + self.expect("\^done,numchild=\"1\",children=\[child=\{name=\"var_pcomplx\.complex_type\",exp=\"complex_type\",numchild=\"3\",type=\"complex_type\",thread-id=\"1\",has_more=\"0\"\}\],has_more=\"1\"") + + # Test that -var-list-children lists children with all values + self.runCmd("-var-list-children 1 var_complx 1 2") + self.expect("\^done,numchild=\"1\",children=\[child=\{name=\"var_complx\.inner\",exp=\"inner\",numchild=\"1\",type=\"complex_type::\(anonymous struct\)\",thread-id=\"1\",value=\"\{\.\.\.\}\",has_more=\"0\"\}\],has_more=\"1\"") + self.runCmd("-var-list-children --all-values var_complx 1 2") + self.expect("\^done,numchild=\"1\",children=\[child=\{name=\"var_complx\.inner\",exp=\"inner\",numchild=\"1\",type=\"complex_type::\(anonymous struct\)\",thread-id=\"1\",value=\"\{\.\.\.\}\",has_more=\"0\"\}\],has_more=\"1\"") + self.runCmd("-var-list-children --all-values var_complx_array 1 2") + self.expect("\^done,numchild=\"1\",children=\[child=\{name=\"var_complx_array\.\[1\]\",exp=\"\[1\]\",numchild=\"3\",type=\"complex_type\",thread-id=\"1\",value=\"\{\.\.\.\}\",has_more=\"0\"\}\],has_more=\"0\"") + self.runCmd("-var-list-children --all-values var_pcomplx 1 2") + self.expect("\^done,numchild=\"1\",children=\[child={name=\"var_pcomplx\.complx\",exp=\"complx\",numchild=\"3\",type=\"complex_type\",thread-id=\"1\",value=\"\{\.\.\.\}\",has_more=\"0\"\}\],has_more=\"0\"") + + # Test that -var-list-children lists children with simple values + self.runCmd("-var-list-children 2 var_complx 2 4") + self.expect("\^done,numchild=\"1\",children=\[child=\{name=\"var_complx\.complex_ptr\",exp=\"complex_ptr\",numchild=\"3\",type=\"complex_type \*\",thread-id=\"1\",has_more=\"0\"\}\],has_more=\"0\"") + self.runCmd("-var-list-children --simple-values var_complx 2 4") + self.expect("\^done,numchild=\"1\",children=\[child=\{name=\"var_complx\.complex_ptr\",exp=\"complex_ptr\",numchild=\"3\",type=\"complex_type \*\",thread-id=\"1\",has_more=\"0\"\}\],has_more=\"0\"") + self.runCmd("-var-list-children --simple-values var_complx_array 2 4") + self.expect("\^done,numchild=\"0\",has_more=\"0\"") + self.runCmd("-var-list-children --simple-values var_pcomplx 2 4") + self.expect("\^done,numchild=\"0\",has_more=\"0\"") + + # Test that an invalid from is handled + # FIXME: -1 is treated as unsigned int + self.runCmd("-var-list-children 0 var_complx -1 0") + #self.expect("\^error,msg=\"Command 'var-list-children'\. Variable children range invalid\"") + + # Test that an invalid to is handled + # FIXME: -1 is treated as unsigned int + self.runCmd("-var-list-children 0 var_complx 0 -1") + #self.expect("\^error,msg=\"Command 'var-list-children'\. Variable children range invalid\"") + + # Test that a missing low-frame or high-frame is handled + self.runCmd("-var-list-children 0 var_complx 0") + self.expect("\^error,msg=\"Command 'var-list-children'. Variable children range invalid\"") + + @skipIfWindows #llvm.org/pr24452: Get lldb-mi working on Windows + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + @skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots + def test_lldbmi_var_create_for_stl_types(self): + """Test that 'lldb-mi --interpreter' print summary for STL types.""" + + self.spawnLldbMi(args = None) + + # Load executable + self.runCmd("-file-exec-and-symbols %s" % self.myexe) + self.expect("\^done") + + # Run to BP_gdb_set_show_print_char_array_as_string_test + line = line_number('main.cpp', '// BP_cpp_stl_types_test') + self.runCmd("-break-insert main.cpp:%d" % line) + self.expect("\^done,bkpt={number=\"1\"") + self.runCmd("-exec-run") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + # Test for std::string + self.runCmd("-var-create - * std_string") + self.expect('\^done,name="var\d+",numchild="[0-9]+",value="\\\\"hello\\\\"",type="std::[\S]*?string",thread-id="1",has_more="0"') + + @skipIfWindows #llvm.org/pr24452: Get lldb-mi working on Windows + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + @skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots + def test_lldbmi_var_create_for_unnamed_objects(self): + """Test that 'lldb-mi --interpreter' can expand unnamed structures and unions.""" + + self.spawnLldbMi(args = None) + + # Load executable + self.runCmd("-file-exec-and-symbols %s" % self.myexe) + self.expect("\^done") + + # Run to breakpoint + line = line_number('main.cpp', '// BP_unnamed_objects_test') + self.runCmd("-break-insert main.cpp:%d" % line) + self.expect("\^done,bkpt={number=\"1\"") + self.runCmd("-exec-run") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + # Evaluate struct_with_unions type and its children + self.runCmd("-var-create v0 * swu") + self.expect('\^done,name="v0",numchild="2",value="\{\.\.\.\}",type="struct_with_unions",thread-id="1",has_more="0"') + + self.runCmd("-var-list-children v0") + + # inspect the first unnamed union + self.runCmd("-var-list-children v0.$0") + self.runCmd("-var-evaluate-expression v0.$0.u_i") + self.expect('\^done,value="1"') + + # inspect the second unnamed union + self.runCmd("-var-list-children v0.$1") + self.runCmd("-var-evaluate-expression v0.$1.u1") + self.expect('\^done,value="-1"') + # inspect unnamed structure + self.runCmd("-var-list-children v0.$1.$1") + self.runCmd("-var-evaluate-expression v0.$1.$1.s1") + self.expect('\^done,value="-1"') + diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/variable/main.cpp b/packages/Python/lldbsuite/test/tools/lldb-mi/variable/main.cpp new file mode 100644 index 0000000..8c79539 --- /dev/null +++ b/packages/Python/lldbsuite/test/tools/lldb-mi/variable/main.cpp @@ -0,0 +1,152 @@ +//===-- main.cpp ------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include <cstdint> +#include <string> + +struct complex_type +{ + int i; + struct { long l; } inner; + complex_type *complex_ptr; +}; + +struct pcomplex_type : complex_type +{ + pcomplex_type(const complex_type &complx_base, const complex_type &complx_member) + : complex_type(complx_base), complx(complx_member) { } + complex_type complx; + static int si; +}; + +int pcomplex_type::si; + +struct struct_with_unions +{ + struct_with_unions(): u_i(1), u1(-1) {} + union + { + int u_i; + int u_j; + }; + union + { + int u1; + struct + { + short s1; + short s2; + }; + }; +}; + +void +var_update_test(void) +{ + long l = 1; + complex_type complx = { 3, { 3L }, &complx }; + complex_type complx_array[2] = { { 4, { 4L }, &complx_array[1] }, { 5, { 5 }, &complx_array[0] } }; + // BP_var_update_test_init + + l = 0; + // BP_var_update_test_l + + complx.inner.l = 2; + // BP_var_update_test_complx + + complx_array[1].inner.l = 4; + // BP_var_update_test_complx_array +} + +void +var_list_children_test(void) +{ + complex_type complx = { 3, { 3L }, &complx }; + complex_type complx_array[2] = { { 4, { 4L }, &complx_array[1] }, { 5, { 5 }, &complx_array[0] } }; + pcomplex_type pcomplx({ 6, { 6L }, &pcomplx}, { 7, { 7L }, &pcomplx}); + + // BP_var_list_children_test +} + +void +gdb_set_show_print_char_array_as_string_test(void) +{ + const char *cp = "\t\"hello\"\n"; + const char ca[] = "\t\"hello\"\n"; + const char16_t *u16p = u"\t\"hello\"\n"; + const char16_t u16a[] = u"\t\"hello\"\n"; + const char32_t *u32p = U"\t\"hello\"\n"; + const char32_t u32a[] = U"\t\"hello\"\n"; + + const char16_t* u16p_rus = u"\\Аламо-сквер"; + const char16_t u16a_rus[] = u"\\Бейвью"; + const char32_t* u32p_rus = U"\\Чайнатаун"; + const char32_t u32a_rus[] = U"\\Догпатч"; + + // BP_gdb_set_show_print_char_array_as_string_test +} + +void +cpp_stl_types_test(void) +{ + std::string std_string = "hello"; + // BP_cpp_stl_types_test +} + +void +unnamed_objects_test(void) +{ + struct_with_unions swu; + // BP_unnamed_objects_test +} + +struct not_str +{ + not_str(char _c, int _f) + : c(_c), f(_f) { } + char c; + int f; +}; + +void +gdb_set_show_print_expand_aggregates(void) +{ + complex_type complx = { 3, { 3L }, &complx }; + complex_type complx_array[2] = { { 4, { 4L }, &complx_array[1] }, { 5, { 5 }, &complx_array[0] } }; + not_str nstr('a', 0); + + // BP_gdb_set_show_print_expand_aggregates +} + +void +gdb_set_show_print_aggregate_field_names(void) +{ + complex_type complx = { 3, { 3L }, &complx }; + complex_type complx_array[2] = { { 4, { 4L }, &complx_array[1] }, { 5, { 5 }, &complx_array[0] } }; + + // BP_gdb_set_show_print_aggregate_field_names +} + +int g_MyVar = 3; +static int s_MyVar = 4; + +int +main(int argc, char const *argv[]) +{ + int a = 10, b = 20; + s_MyVar = a + b; + var_update_test(); + var_list_children_test(); + gdb_set_show_print_char_array_as_string_test(); + cpp_stl_types_test(); + unnamed_objects_test(); + gdb_set_show_print_expand_aggregates(); + gdb_set_show_print_aggregate_field_names(); + return 0; // BP_return +} |