Index: lldb/CMakeLists.txt =================================================================== --- lldb/CMakeLists.txt +++ lldb/CMakeLists.txt @@ -106,10 +106,6 @@ list(APPEND LLDB_TEST_DEPS lldb-server) endif() - if(TARGET lldb-mi) - list(APPEND LLDB_TEST_DEPS lldb-mi) - endif() - if(TARGET lldb-vscode) list(APPEND LLDB_TEST_DEPS lldb-vscode) endif() Index: lldb/CODE_OWNERS.txt =================================================================== --- lldb/CODE_OWNERS.txt +++ lldb/CODE_OWNERS.txt @@ -21,10 +21,6 @@ D: Expression evaluator, IR interpreter, Clang integration D: Data Formatters -N: Ilia K -E: ki.stfu@gmail.com -D: lldb-mi - N: Ed Maste E: emaste@freebsd.org D: FreeBSD @@ -34,10 +30,6 @@ D: ABI, Disassembler, Unwinding, iOS, debugserver, Platform, ObjectFile, SymbolFile, D: SymbolVendor, DWARF, gdb-remote -N: Hafiz Abid Qadeer -E: abidh.haq@gmail.com -D: lldb-mi - N: Kamil Rytarowski E: kamil@netbsd.org D: NetBSD Index: lldb/lit/helper/toolchain.py =================================================================== --- lldb/lit/helper/toolchain.py +++ lldb/lit/helper/toolchain.py @@ -16,11 +16,6 @@ dsname = 'debugserver' if platform.system() in ['Darwin'] else 'lldb-server' dsargs = [] if platform.system() in ['Darwin'] else ['gdbserver'] - lldbmi = ToolSubst('%lldbmi', - command=FindTool('lldb-mi'), - extra_args=['--synchronous'], - unresolved='ignore') - build_script = os.path.dirname(__file__) build_script = os.path.join(build_script, 'build.py') @@ -43,7 +38,6 @@ ToolSubst('%lldb-init', command=FindTool('lldb'), extra_args=['-S', lldb_init]), - lldbmi, ToolSubst('%debugserver', command=FindTool(dsname), extra_args=dsargs, @@ -61,9 +55,6 @@ llvm_config.add_tool_substitutions(primary_tools, [config.lldb_tools_dir]) - # lldb-mi always fails without Python support - if lldbmi.was_resolved and not config.lldb_disable_python: - config.available_features.add('lldb-mi') def _use_msvc_substitutions(config): # If running from a Visual Studio Command prompt (e.g. vcvars), this will Index: lldb/packages/Python/lldbsuite/test/dotest.py =================================================================== --- lldb/packages/Python/lldbsuite/test/dotest.py +++ lldb/packages/Python/lldbsuite/test/dotest.py @@ -693,16 +693,11 @@ os.environ["LLDB_SRC"] = lldbsuite.lldb_root pluginPath = os.path.join(scriptPath, 'plugins') - toolsLLDBMIPath = os.path.join(scriptPath, 'tools', 'lldb-mi') toolsLLDBVSCode = os.path.join(scriptPath, 'tools', 'lldb-vscode') toolsLLDBServerPath = os.path.join(scriptPath, 'tools', 'lldb-server') - # Insert script dir, plugin dir, lldb-mi dir and lldb-server dir to the - # sys.path. + # Insert script dir, plugin dir and lldb-server dir to the sys.path. sys.path.insert(0, pluginPath) - # Adding test/tools/lldb-mi to the path makes it easy - sys.path.insert(0, toolsLLDBMIPath) - # to "import lldbmi_testcase" from the MI tests # Adding test/tools/lldb-vscode to the path makes it easy to # "import lldb_vscode_testcase" from the VSCode tests sys.path.insert(0, toolsLLDBVSCode) @@ -761,19 +756,7 @@ print("LLDB import library dir:", os.environ["LLDB_IMPLIB_DIR"]) os.system('%s -v' % lldbtest_config.lldbExec) - # Assume lldb-mi is in same place as lldb - # If not found, disable the lldb-mi tests - # TODO: Append .exe on Windows - # - this will be in a separate commit in case the mi tests fail horribly lldbDir = os.path.dirname(lldbtest_config.lldbExec) - lldbMiExec = os.path.join(lldbDir, "lldb-mi") - if is_exe(lldbMiExec): - os.environ["LLDBMI_EXEC"] = lldbMiExec - else: - if not configuration.shouldSkipBecauseOfCategories(["lldb-mi"]): - print( - "The 'lldb-mi' executable cannot be located. The lldb-mi tests can not be run as a result.") - configuration.skipCategories.append("lldb-mi") lldbVSCodeExec = os.path.join(lldbDir, "lldb-vscode") if is_exe(lldbVSCodeExec): Index: lldb/packages/Python/lldbsuite/test/lldbtest.py =================================================================== --- lldb/packages/Python/lldbsuite/test/lldbtest.py +++ lldb/packages/Python/lldbsuite/test/lldbtest.py @@ -711,11 +711,6 @@ else: self.libcxxPath = None - if "LLDBMI_EXEC" in os.environ: - self.lldbMiExec = os.environ["LLDBMI_EXEC"] - else: - self.lldbMiExec = None - if "LLDBVSCODE_EXEC" in os.environ: self.lldbVSCodeExec = os.environ["LLDBVSCODE_EXEC"] else: Index: lldb/packages/Python/lldbsuite/test/test_categories.py =================================================================== --- lldb/packages/Python/lldbsuite/test/test_categories.py +++ lldb/packages/Python/lldbsuite/test/test_categories.py @@ -34,7 +34,6 @@ 'dyntype': 'Tests related to dynamic type support', 'stresstest': 'Tests related to stressing lldb limits', 'flakey': 'Flakey test cases, i.e. tests that do not reliably pass at each execution', - 'lldb-mi': 'lldb-mi tests', 'darwin-log': 'Darwin log tests', 'watchpoint': 'Watchpoint-related tests', } Index: lldb/packages/Python/lldbsuite/test/tools/lldb-mi/.categories =================================================================== --- lldb/packages/Python/lldbsuite/test/tools/lldb-mi/.categories +++ /dev/null @@ -1 +0,0 @@ -lldb-mi Index: lldb/packages/Python/lldbsuite/test/tools/lldb-mi/Makefile =================================================================== --- lldb/packages/Python/lldbsuite/test/tools/lldb-mi/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -LEVEL = ../../make - -CXX_SOURCES := main.cpp - -include $(LEVEL)/Makefile.rules Index: lldb/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiEnvironmentCd.py =================================================================== --- lldb/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiEnvironmentCd.py +++ /dev/null @@ -1,38 +0,0 @@ -""" -Test lldb-mi -environment-cd command. -""" - -from __future__ import print_function - - -import lldbmi_testcase -from lldbsuite.test.decorators import * -from lldbsuite.test.lldbtest import * -from lldbsuite.test import lldbutil - - -class MiEnvironmentCdTestCase(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 - @skipIfDarwin # Disabled while I investigate the failure on buildbot. - @skipIfRemote # We do not currently support remote debugging via the MI. - def test_lldbmi_environment_cd(self): - """Test that 'lldb-mi --interpreter' changes working directory for inferior.""" - - self.spawnLldbMi(args=None) - - # Load executable - self.runCmd("-file-exec-and-symbols %s" % self.myexe) - self.expect("\^done") - - # cd to a different directory - self.runCmd("-environment-cd /tmp") - self.expect("\^done") - - # Run to the end - self.runCmd("-exec-run") - self.expect("\^running") - self.expect("@\"cwd: /tmp\\r\\n\"", exactly=True) Index: lldb/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiLibraryLoaded.py =================================================================== --- lldb/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiLibraryLoaded.py +++ /dev/null @@ -1,60 +0,0 @@ -""" -Test lldb-mi =library-loaded notifications. -""" - -from __future__ import print_function - - -import lldbmi_testcase -from lldbsuite.test.decorators import * -from lldbsuite.test.lldbtest import * -from lldbsuite.test import lldbutil - - -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 - @skipIfRemote # We do not currently support remote debugging via the MI. - @skipIfDarwin - 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 = self.getBuildArtifact(self.myexe) - symbols_path = os.path.join( - path + ".dSYM", - "Contents", - "Resources", - "DWARF", - "a.out") - - 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))]) Index: lldb/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiPrompt.py =================================================================== --- lldb/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiPrompt.py +++ /dev/null @@ -1,58 +0,0 @@ -""" -Test that the lldb-mi driver prints prompt properly. -""" - -from __future__ import print_function - - -import lldbmi_testcase -from lldbsuite.test.decorators import * -from lldbsuite.test.lldbtest import * -from lldbsuite.test import lldbutil - - -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 - @skipIfRemote # We do not currently support remote debugging via the MI. - 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) Index: lldb/packages/Python/lldbsuite/test/tools/lldb-mi/breakpoint/Makefile =================================================================== --- lldb/packages/Python/lldbsuite/test/tools/lldb-mi/breakpoint/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -LEVEL = ../../../make - -CXX_SOURCES := main.cpp - -include $(LEVEL)/Makefile.rules Index: lldb/packages/Python/lldbsuite/test/tools/lldb-mi/breakpoint/TestMiBreak.py =================================================================== --- lldb/packages/Python/lldbsuite/test/tools/lldb-mi/breakpoint/TestMiBreak.py +++ /dev/null @@ -1,361 +0,0 @@ -""" -Test lldb-mi -break-xxx commands. -""" - -from __future__ import print_function - - -import unittest2 -import lldbmi_testcase -from lldbsuite.test.decorators import * -from lldbsuite.test.lldbtest import * -from lldbsuite.test import lldbutil - - -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 - @skipIfLinux # llvm.org/pr24717 - @expectedFailureNetBSD - @skipIfRemote # We do not currently support remote debugging via the MI. - 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 - @expectedFailureNetBSD - @skipIfRemote # We do not currently support remote debugging via the MI. - 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 - @skipIfRemote # We do not currently support remote debugging via the MI. - 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 - @skipIfRemote # We do not currently support remote debugging via the MI. - 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 - @skipIfRemote # We do not currently support remote debugging via the MI. - 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(self.getSourceDir(), "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 - @skipIfRemote # We do not currently support remote debugging via the MI. - 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_decl = line_number('main.cpp', '// BP_main_decl') - line_in = line_number('main.cpp', '// BP_in_main') - self.runCmd("-break-insert -f main.cpp:%d" % line_in) - 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_in) - self.expect( - "\^error,msg=\"Command 'break-insert'. Breakpoint location 'main.cpp:%d' not found\"" % - line_in) - - # Set target.move-to-nearest-code=on and target.skip-prologue=on and - # set BP #3 & #4 - 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_in) - self.expect("\^done,bkpt={number=\"3\"") - self.runCmd("-break-insert main.cpp:%d" % line_decl) - self.expect("\^done,bkpt={number=\"4\"") - - # Set target.skip-prologue=off and set BP #5 - self.runCmd( - "-interpreter-exec console \"settings set target.skip-prologue off\"") - self.expect("\^done") - self.runCmd("-break-insert main.cpp:%d" % line_decl) - self.expect("\^done,bkpt={number=\"5\"") - - # Test that BP #5 is located before BP #4 - self.runCmd("-exec-run") - self.expect("\^running") - self.expect( - "\*stopped,reason=\"breakpoint-hit\",disp=\"del\",bkptno=\"5\"") - - # Test that BP #4 is hit - self.runCmd("-exec-continue") - 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 #6 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 #7 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=\"7\"") - self.runCmd("-exec-continue") - self.expect("\^running") - self.expect( - "\*stopped,reason=\"breakpoint-hit\",disp=\"del\",bkptno=\"7\"") - - # 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\"") - - @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows - @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races - @skipIfRemote # We do not currently support remote debugging via the MI. - @skipIfNetBSD - def test_lldbmi_break_enable_disable(self): - """Test that 'lldb-mi --interpreter' works for enabling / disabling breakpoints.""" - - self.spawnLldbMi(args=None) - - self.runCmd("-file-exec-and-symbols %s" % self.myexe) - self.expect("\^done") - - self.runCmd("-break-insert main") - self.expect( - "\^done,bkpt={number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"(?!0xffffffffffffffff)0x[0-9a-f]+\",func=\"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+\",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+\",times=\"0\",original-location=\"main\"}") - self.expect( - "\*stopped,reason=\"breakpoint-hit\",disp=\"del\",bkptno=\"1\"") - - self.runCmd("-break-insert ns::foo1") - self.expect( - "\^done,bkpt={number=\"2\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"(?!0xffffffffffffffff)0x[0-9a-f]+\",func=\"ns::foo1\(\)\"") - self.expect( - "=breakpoint-modified,bkpt={number=\"2\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"(?!0xffffffffffffffff)0x[0-9a-f]+\",func=\"ns::foo1\(\)\",file=\"main\.cpp\",fullname=\".+?main\.cpp\",line=\"\d+\",times=\"0\",original-location=\"ns::foo1\"}") - - self.runCmd("-break-insert ns::foo2") - self.expect( - "\^done,bkpt={number=\"3\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"(?!0xffffffffffffffff)0x[0-9a-f]+\",func=\"ns::foo2\(\)\"") - self.expect( - "=breakpoint-modified,bkpt={number=\"3\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"(?!0xffffffffffffffff)0x[0-9a-f]+\",func=\"ns::foo2\(\)\",file=\"main\.cpp\",fullname=\".+?main\.cpp\",line=\"\d+\",times=\"0\",original-location=\"ns::foo2\"}") - - # disable the 2nd breakpoint - self.runCmd("-break-disable 2") - self.expect("\^done") - self.expect( - "=breakpoint-modified,bkpt={number=\"2\",type=\"breakpoint\",disp=\"keep\",enabled=\"n\",addr=\"(?!0xffffffffffffffff)0x[0-9a-f]+\",func=\"ns::foo1\(\)\",file=\"main\.cpp\",fullname=\".+?main\.cpp\",line=\"\d+\",times=\"0\",original-location=\"ns::foo1\"}") - - # disable the 3rd breakpoint and re-enable - self.runCmd("-break-disable 3") - self.expect("\^done") - self.expect( - "=breakpoint-modified,bkpt={number=\"3\",type=\"breakpoint\",disp=\"keep\",enabled=\"n\",addr=\"(?!0xffffffffffffffff)0x[0-9a-f]+\",func=\"ns::foo2\(\)\",file=\"main\.cpp\",fullname=\".+?main\.cpp\",line=\"\d+\",times=\"0\",original-location=\"ns::foo2\"}") - - self.runCmd("-break-enable 3") - self.expect("\^done") - self.expect( - "=breakpoint-modified,bkpt={number=\"3\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"(?!0xffffffffffffffff)0x[0-9a-f]+\",func=\"ns::foo2\(\)\",file=\"main\.cpp\",fullname=\".+?main\.cpp\",line=\"\d+\",times=\"0\",original-location=\"ns::foo2\"}") - - self.runCmd("-exec-continue") - self.expect("\^running") - self.expect( - "\*stopped,reason=\"breakpoint-hit\",disp=\"del\",bkptno=\"3\"") Index: lldb/packages/Python/lldbsuite/test/tools/lldb-mi/breakpoint/main.cpp =================================================================== --- lldb/packages/Python/lldbsuite/test/tools/lldb-mi/breakpoint/main.cpp +++ /dev/null @@ -1,29 +0,0 @@ -//===-- main.cpp ------------------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#include - -namespace ns -{ - int foo1(void) { printf("In foo1\n"); return 1; } - int foo2(void) { printf("In foo2\n"); return 2; } -} - -int x; -int main(int argc, char const *argv[]) { // BP_main_decl - printf("Print a formatted string so that GCC does not optimize this printf call: %s\n", argv[0]); - // This is a long comment with no code inside - // This is a long comment with no code inside - // This is a long comment with no code inside - // BP_in_main - // This is a long comment with no code inside - // This is a long comment with no code inside - // This is a long comment with no code inside - x = ns::foo1() + ns::foo2(); - return 0; // BP_return -} Index: lldb/packages/Python/lldbsuite/test/tools/lldb-mi/control/Makefile =================================================================== --- lldb/packages/Python/lldbsuite/test/tools/lldb-mi/control/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -LEVEL = ../../../make - -CXX_SOURCES := main.cpp - -include $(LEVEL)/Makefile.rules Index: lldb/packages/Python/lldbsuite/test/tools/lldb-mi/control/TestMiExec.py =================================================================== --- lldb/packages/Python/lldbsuite/test/tools/lldb-mi/control/TestMiExec.py +++ /dev/null @@ -1,141 +0,0 @@ -""" -Test lldb-mi -exec-xxx commands. -""" - -from __future__ import print_function - - -import lldbmi_testcase -from lldbsuite.test.decorators import * -from lldbsuite.test.lldbtest import * -from lldbsuite.test import lldbutil - - -class MiExecTestCase(lldbmi_testcase.MiTestCaseBase): - - mydir = TestBase.compute_mydir(__file__) - - @skipIfRemote # We do not currently support remote debugging via the MI. - @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\"") - - @skipIfRemote # We do not currently support remote debugging via the MI. - @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 - # Note that exactly=True is needed to avoid extra escaping for re - 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\\\"", exactly=True) - #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\\\"", exactly=True) - #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\\\"", exactly=True) - #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\\\\\\\"\\\"", exactly=True) - - @skipIfRemote # We do not currently support remote debugging via the MI. - @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\"") Index: lldb/packages/Python/lldbsuite/test/tools/lldb-mi/control/main.cpp =================================================================== --- lldb/packages/Python/lldbsuite/test/tools/lldb-mi/control/main.cpp +++ /dev/null @@ -1,32 +0,0 @@ -//===-- main.cpp ------------------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#include - -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; -} Index: lldb/packages/Python/lldbsuite/test/tools/lldb-mi/data/Makefile =================================================================== --- lldb/packages/Python/lldbsuite/test/tools/lldb-mi/data/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -LEVEL = ../../../make - -CXX_SOURCES := main.cpp - -include $(LEVEL)/Makefile.rules Index: lldb/packages/Python/lldbsuite/test/tools/lldb-mi/data/TestMiData.py =================================================================== --- lldb/packages/Python/lldbsuite/test/tools/lldb-mi/data/TestMiData.py +++ /dev/null @@ -1,365 +0,0 @@ -""" -Test lldb-mi -data-xxx commands. -""" - -from __future__ import print_function - - -import unittest2 -import lldbmi_testcase -from lldbsuite.test.decorators import * -from lldbsuite.test.lldbtest import * -from lldbsuite.test import lldbutil - - -class MiDataTestCase(lldbmi_testcase.MiTestCaseBase): - - mydir = TestBase.compute_mydir(__file__) - - @skipIfRemote # We do not currently support remote debugging via the MI. - @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows - @skipIfDarwin # pexpect is known to be unreliable on Darwin - @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) - - # Test -data-disassemble with source line information - self.runCmd("-data-disassemble -s %#x -e %#x -- 1" % (addr, addr + 0x10)) - self.expect( - '\^done,asm_insns=\[src_and_asm_line={line="\d+",file="main.cpp",' - 'line_asm_insn=\[{address="0x0*%x",func-name="main",offset="0",size="[1-9]+",inst=".+?"}\],' - 'fullname="%s"}' % - (addr, os.path.abspath("main.cpp")) ) - - # 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 - - # The MIPS and PPC64le disassemblers never print stub name - if self.isMIPS() or self.isPPC64le(): - 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=\".+?\"}"]) - else: - 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\"}"]) - - @skipIfRemote # We do not currently support remote debugging via the MI. - @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows - @skipIfDarwin # pexpect is known to be unreliable on Darwin - @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races - 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=\"1011121300\"}\]" % - (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=\"2021222300\"}\]" % - (addr, addr + size)) - - @skipIfRemote # We do not currently support remote debugging via the MI. - @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows - @skipIfDarwin # pexpect is known to be unreliable on Darwin - @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') - - @skipIfRemote # We do not currently support remote debugging via the MI. - @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows - @skipIfDarwin # pexpect is known to be unreliable on Darwin - @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=\[\".+?\"\]") - - @skipIfRemote # We do not currently support remote debugging via the MI. - @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows - @skipIfDarwin # pexpect is known to be unreliable on Darwin - @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]+\"}\]") - - @skipIfRemote # We do not currently support remote debugging via the MI. - @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows - @skipIfDarwin # pexpect is known to be unreliable on Darwin - @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\}\}\"") Index: lldb/packages/Python/lldbsuite/test/tools/lldb-mi/data/main.cpp =================================================================== --- lldb/packages/Python/lldbsuite/test/tools/lldb-mi/data/main.cpp +++ /dev/null @@ -1,60 +0,0 @@ -//===-- main.cpp ------------------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#include - -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]; - char g = g_CharArray[0]; - char s = s_CharArray[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; -} Index: lldb/packages/Python/lldbsuite/test/tools/lldb-mi/interpreter/Makefile =================================================================== --- lldb/packages/Python/lldbsuite/test/tools/lldb-mi/interpreter/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -LEVEL = ../../../make - -CXX_SOURCES := main.cpp - -include $(LEVEL)/Makefile.rules Index: lldb/packages/Python/lldbsuite/test/tools/lldb-mi/interpreter/TestMiCliSupport.py =================================================================== --- lldb/packages/Python/lldbsuite/test/tools/lldb-mi/interpreter/TestMiCliSupport.py +++ /dev/null @@ -1,240 +0,0 @@ -""" -Test lldb-mi can interpret CLI commands directly. -""" - -from __future__ import print_function - - -import lldbmi_testcase -from lldbsuite.test.decorators import * -from lldbsuite.test.lldbtest import * -from lldbsuite.test import lldbutil - - -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 - @skipIfRemote # We do not currently support remote debugging via the MI. - 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\"") - - @skipIfRemote # We do not currently support remote debugging via the MI. - @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_list(self): - """Test that 'lldb-mi --interpreter' can list targets by 'target list' command.""" - - self.spawnLldbMi(args=None) - - # Test that initially there are no targets. - self.runCmd("target list") - self.expect(r"~\"No targets.\\n\"") - self.expect("\^done") - - # Add target. - self.runCmd("-file-exec-and-symbols %s" % self.myexe) - - # Test that "target list" lists added target. - self.runCmd("target list") - self.expect(r"~\"Current targets:\\n\* target #0: %s" % self.myexe) - - @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 - @skipIfRemote # We do not currently support remote debugging via the MI. - 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 - @skipIfRemote # We do not currently support remote debugging via the MI. - 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 - @skipIfRemote # We do not currently support remote debugging via the MI. - 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 - @skipIfRemote # We do not currently support remote debugging via the MI. - 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 - @skipIfRemote # We do not currently support remote debugging via the MI. - 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 - @skipIfRemote # We do not currently support remote debugging via the MI. - 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 - @skipIfRemote # We do not currently support remote debugging via the MI. - 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\"") Index: lldb/packages/Python/lldbsuite/test/tools/lldb-mi/interpreter/TestMiInterpreterExec.py =================================================================== --- lldb/packages/Python/lldbsuite/test/tools/lldb-mi/interpreter/TestMiInterpreterExec.py +++ /dev/null @@ -1,227 +0,0 @@ -""" -Test lldb-mi -interpreter-exec command. -""" - -from __future__ import print_function - - -import lldbmi_testcase -from lldbsuite.test.decorators import * -from lldbsuite.test.lldbtest import * -from lldbsuite.test import lldbutil - - -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 - @skipIfRemote # We do not currently support remote debugging via the MI. - @skipIfDarwin - 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\"") - - @skipIfRemote # We do not currently support remote debugging via the MI. - @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows. - @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races. - @skipIfDarwin - def test_lldbmi_target_list(self): - """Test that 'lldb-mi --interpreter' can list targets by 'target list' command.""" - - self.spawnLldbMi(args=None) - - # Test that initially there are no targets. - self.runCmd("-interpreter-exec console \"target list\"") - self.expect(r"~\"No targets.\\n\"") - - # Add target. - self.runCmd("-file-exec-and-symbols %s" % self.myexe) - - # Test that "target list" lists added target. - self.runCmd("-interpreter-exec console \"target list\"") - self.expect(r"~\"Current targets:\\n\* target #0: %s" % self.myexe) - - @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows - @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races - @skipIfRemote # We do not currently support remote debugging via the MI. - @skipIfDarwin - 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 - @skipIfRemote # We do not currently support remote debugging via the MI. - @skipIfDarwin - @skipIfLinux - 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 - @skipIfRemote # We do not currently support remote debugging via the MI. - @skipIfDarwin - 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 - @skipIfRemote # We do not currently support remote debugging via the MI. - @skipIfDarwin - 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 - @skipIfRemote # We do not currently support remote debugging via the MI. - @skipIfDarwin - 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") - @skipIfRemote # We do not currently support remote debugging via the MI. - @skipIfDarwin - 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\"") Index: lldb/packages/Python/lldbsuite/test/tools/lldb-mi/interpreter/main.cpp =================================================================== --- lldb/packages/Python/lldbsuite/test/tools/lldb-mi/interpreter/main.cpp +++ /dev/null @@ -1,18 +0,0 @@ -//===-- main.cpp ------------------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#include - -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 -} Index: lldb/packages/Python/lldbsuite/test/tools/lldb-mi/lexical_scope/Makefile =================================================================== --- lldb/packages/Python/lldbsuite/test/tools/lldb-mi/lexical_scope/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -LEVEL = ../../../make - -CXX_SOURCES := main.cpp - -include $(LEVEL)/Makefile.rules Index: lldb/packages/Python/lldbsuite/test/tools/lldb-mi/lexical_scope/TestMiLexicalScope.py =================================================================== --- lldb/packages/Python/lldbsuite/test/tools/lldb-mi/lexical_scope/TestMiLexicalScope.py +++ /dev/null @@ -1,68 +0,0 @@ -""" -Test lldb-mi -stack-list-locals -stack-list-variables and -var-create commands -for variables with the same name in sibling lexical scopes. -""" - -from __future__ import print_function - - -import lldbmi_testcase -from lldbsuite.test.decorators import * -from lldbsuite.test.lldbtest import * -from lldbsuite.test import lldbutil - - -class MiLexicalScopeTestCase(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 - @skipIfRemote # We do not currently support remote debugging via the MI. - def test_lldbmi_var_create_in_sibling_scope(self): - """Test that 'lldb-mi --interpreter' works with sibling lexical scopes.""" - - self.spawnLldbMi(args=None) - - # Load executable - self.runCmd("-file-exec-and-symbols %s" % self.myexe) - self.expect("\^done") - - # Breakpoint inside first scope - line = line_number('main.cpp', '// BP_first') - self.runCmd("-break-insert --file main.cpp:%d" % line) - self.expect("\^done,bkpt={number=\"\d+\"") - - # Breakpoint inside second scope - line = line_number('main.cpp', '// BP_second') - self.runCmd("-break-insert --file main.cpp:%d" % line) - self.expect("\^done,bkpt={number=\"\d+\"") - - # Run to the first scope - self.runCmd("-exec-run") - self.expect("\^running") - self.expect("\*stopped,reason=\"breakpoint-hit\"") - - # Check that only variables a and b exist with expected values - self.runCmd("-stack-list-locals --thread 1 --frame 0 --all-values") - self.expect("\^done,locals=\[{name=\"a\",value=\"1\"},{name=\"b\",value=\"2\"}\]") - - # Create variable object for local variable b - self.runCmd("-var-create - * \"b\"") - self.expect( - "\^done,name=\"var\d+\",numchild=\"0\",value=\"2\",type=\"int\",thread-id=\"1\",has_more=\"0\"") - - # Run to the second scope - self.runCmd("-exec-continue") - self.expect("\^running") - self.expect("\*stopped,reason=\"breakpoint-hit\"") - - # Check that only variables a and b exist with expected values, - # but variable b is different from previous breakpoint - self.runCmd("-stack-list-variables --thread 1 --frame 0 --all-values") - self.expect("\^done,variables=\[{name=\"a\",value=\"1\"},{name=\"b\",value=\"3\"}\]") - - # Create variable object for local variable b - self.runCmd("-var-create - * \"b\"") - self.expect( - "\^done,name=\"var\d+\",numchild=\"0\",value=\"3\",type=\"short\",thread-id=\"1\",has_more=\"0\"") Index: lldb/packages/Python/lldbsuite/test/tools/lldb-mi/lexical_scope/main.cpp =================================================================== --- lldb/packages/Python/lldbsuite/test/tools/lldb-mi/lexical_scope/main.cpp +++ /dev/null @@ -1,32 +0,0 @@ -//===-- main.cpp ------------------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -void -some_func (void) -{ -} - -void test_sibling_scope (void) -{ - int a = 1; - { - int b = 2; - some_func(); // BP_first - } - { - short b = 3; - some_func(); // BP_second - } -} - -int -main (int argc, char **argv) -{ - test_sibling_scope(); - return 0; -} Index: lldb/packages/Python/lldbsuite/test/tools/lldb-mi/lldbmi_testcase.py =================================================================== --- lldb/packages/Python/lldbsuite/test/tools/lldb-mi/lldbmi_testcase.py +++ /dev/null @@ -1,72 +0,0 @@ -""" -Base class for lldb-mi test cases. -""" - -from __future__ import print_function - - -from lldbsuite.test.lldbtest import * - - -class MiTestCaseBase(Base): - - mydir = None - myexe = None - mylog = None - NO_DEBUG_INFO_TESTCASE = True - - @classmethod - def classCleanup(cls): - if cls.myexe: - TestBase.RemoveTempFile(cls.myexe) - if cls.mylog: - TestBase.RemoveTempFile(cls.mylog) - - def setUp(self): - if not self.mydir: - raise("mydir is empty") - - Base.setUp(self) - self.buildDefault() - self.child_prompt = "(gdb)" - self.myexe = self.getBuildArtifact("a.out") - - 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, exe=None, args=None, preconfig=True): - import pexpect - import sys - if sys.version_info.major == 3: - self.child = pexpect.spawnu("%s --interpreter %s" % ( - self.lldbMiExec, args if args else ""), cwd=self.getBuildDir()) - else: - self.child = pexpect.spawn("%s --interpreter %s" % ( - self.lldbMiExec, args if args else ""), cwd=self.getBuildDir()) - self.child.setecho(True) - self.mylog = self.getBuildArtifact("child.log") - 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) - if preconfig: - self.runCmd("settings set symbols.enable-external-lookup false") - self.expect("\^done") - self.expect(self.child_prompt, exactly=True) - if exe: - self.runCmd("-file-exec-and-symbols \"%s\"" % exe) - # Testcases expect to be able to match output of this command, - # see test_lldbmi_specialchars. - - 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) Index: lldb/packages/Python/lldbsuite/test/tools/lldb-mi/main.cpp =================================================================== --- lldb/packages/Python/lldbsuite/test/tools/lldb-mi/main.cpp +++ /dev/null @@ -1,32 +0,0 @@ -//===-- main.cpp ------------------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#include - -#ifdef _WIN32 - #include - #define getcwd _getcwd // suppress "deprecation" warning -#else - #include -#endif - -int -main(int argc, char const *argv[]) -{ - int a = 10; - - char buf[512]; - char *ans = getcwd(buf, sizeof(buf)); - if (ans) { - printf("cwd: %s\n", ans); - } - - printf("argc=%d\n", argc); // BP_printf - - return 0; -} Index: lldb/packages/Python/lldbsuite/test/tools/lldb-mi/signal/Makefile =================================================================== --- lldb/packages/Python/lldbsuite/test/tools/lldb-mi/signal/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -LEVEL = ../../../make - -CXX_SOURCES := main.cpp - -include $(LEVEL)/Makefile.rules Index: lldb/packages/Python/lldbsuite/test/tools/lldb-mi/signal/TestMiSignal.py =================================================================== --- lldb/packages/Python/lldbsuite/test/tools/lldb-mi/signal/TestMiSignal.py +++ /dev/null @@ -1,236 +0,0 @@ -""" -Test that the lldb-mi handles signals properly. -""" - -from __future__ import print_function - - -import lldbmi_testcase -from lldbsuite.test.decorators import * -from lldbsuite.test.lldbtest import * -from lldbsuite.test import lldbutil - - -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 - @expectedFailureNetBSD - @skipIfRemote # We do not currently support remote debugging via the MI. - @skipIfLinux - 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") - - # There's a chance that lldb didn't resume the process, we send an interruput but - # the process is not running yet. Give it some time to restart. 5 seconds ought to - # be enough for every modern CPU out there. - import time - time.sleep(5) - - # 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 - @expectedFailureNetBSD - @skipIfRemote # We do not currently support remote debugging via the MI. - 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 - @skipIfDarwin # pexpect is known to be unreliable on Darwin - @skipIfRemote # We do not currently support remote debugging via the MI. - 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 - # the same as GdbRemoteTestCaseBase.get_next_port - port = 12000 + random.randint(0, 3999) - 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 - @expectedFailureNetBSD - @skipIfRemote # We do not currently support remote debugging via the MI. - 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 - @skipIfRemote # We do not currently support remote debugging via the MI. - 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 - # the same as GdbRemoteTestCaseBase.get_next_port - port = 12000 + random.randint(0, 3999) - 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 - # FIXME: self.runCmd("-exec-run") - self.runCmd("-interpreter-exec command \"process launch\"") - 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") Index: lldb/packages/Python/lldbsuite/test/tools/lldb-mi/signal/main.cpp =================================================================== --- lldb/packages/Python/lldbsuite/test/tools/lldb-mi/signal/main.cpp +++ /dev/null @@ -1,32 +0,0 @@ -//===-- main.cpp ------------------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#include -#include - -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; -} Index: lldb/packages/Python/lldbsuite/test/tools/lldb-mi/stack/Makefile =================================================================== --- lldb/packages/Python/lldbsuite/test/tools/lldb-mi/stack/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -LEVEL = ../../../make - -CXX_SOURCES := main.cpp - -include $(LEVEL)/Makefile.rules Index: lldb/packages/Python/lldbsuite/test/tools/lldb-mi/stack/TestMiStack.py =================================================================== --- lldb/packages/Python/lldbsuite/test/tools/lldb-mi/stack/TestMiStack.py +++ /dev/null @@ -1,558 +0,0 @@ -""" -Test lldb-mi -stack-xxx commands. -""" - -from __future__ import print_function - - -import lldbmi_testcase -from lldbsuite.test.decorators import * -from lldbsuite.test.lldbtest import * -from lldbsuite.test import lldbutil - - -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 - @skipIfRemote # We do not currently support remote debugging via the MI. - 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 - @skipIfRemote # We do not currently support remote debugging via the MI. - 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=\".*?\"}\]") - - # Test -stack-list-locals in a function with catch clause, - # having unnamed parameter - # Run to BP_catch_unnamed - line = line_number('main.cpp', '// BP_catch_unnamed') - self.runCmd("-break-insert --file main.cpp:%d" % line) - self.expect("\^done,bkpt={number=\"6\"") - self.runCmd("-exec-continue") - self.expect("\^running") - self.expect("\*stopped,reason=\"breakpoint-hit\"") - - # Test -stack-list-locals: use --no-values - self.runCmd("-stack-list-locals --no-values") - self.expect("\^done,locals=\[name=\"i\",name=\"j\"\]") - - @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows - @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races - @skipIfRemote # We do not currently support remote debugging via the MI. - 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 - @skipIfRemote # We do not currently support remote debugging via the MI. - 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 - @skipIfRemote # We do not currently support remote debugging via the MI. - 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 - @skipIfRemote # We do not currently support remote debugging via the MI. - 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 - @skipIfRemote # We do not currently support remote debugging via the MI. - 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+\"\}") Index: lldb/packages/Python/lldbsuite/test/tools/lldb-mi/stack/main.cpp =================================================================== --- lldb/packages/Python/lldbsuite/test/tools/lldb-mi/stack/main.cpp +++ /dev/null @@ -1,141 +0,0 @@ -//===-- main.cpp ------------------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#include - -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; -} - -void catch_unnamed_test() -{ - try - { - int i = 1, j = 2; - throw std::exception(); // BP_catch_unnamed - } - catch(std::exception&) - { - } -} - -int -main(int argc, char const *argv[]) -{ - local_int_test(); - local_struct_test(); - local_array_test(); - local_pointer_test(); - catch_unnamed_test(); - - do_tests_with_args(); - return 0; -} Index: lldb/packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/Makefile =================================================================== --- lldb/packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -LEVEL = ../../../make - -CXX_SOURCES := main.cpp - -include $(LEVEL)/Makefile.rules Index: lldb/packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/TestMiStartupOptions.py =================================================================== --- lldb/packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/TestMiStartupOptions.py +++ /dev/null @@ -1,335 +0,0 @@ -""" -Test lldb-mi startup options. -""" - -from __future__ import print_function - -import lldbmi_testcase -from lldbsuite.test.decorators import * -from lldbsuite.test.lldbtest import * -from lldbsuite.test import lldbutil - -import os - -class MiStartupOptionsTestCase(lldbmi_testcase.MiTestCaseBase): - - mydir = TestBase.compute_mydir(__file__) - - @skipIfRemote # We do not currently support remote debugging via the MI. - @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows - @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races - @skipIfDarwin - @skipIfLinux - def test_lldbmi_executable_option_file(self): - """Test that 'lldb-mi --interpreter %s' loads executable file.""" - - self.spawnLldbMi(exe=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 - @skipIfDarwin - 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(exe=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) - - @skipIfRemote # We do not currently support remote debugging via the MI. - @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows - @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races - @skipIfDarwin - @skipIfLinux - 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 - self.spawnLldbMi(exe=self.myexe) - - # Test that the executable is loaded when file was specified using - # absolute path - 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\"") - - @skipIfRemote # We do not currently support remote debugging via the MI. - @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows - @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races - @skipIfDarwin - @skipIfLinux - 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 = os.path.relpath(self.myexe, self.getBuildDir()) - self.spawnLldbMi(exe=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 - @skipIfDarwin - 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" + self.myexe - - self.spawnLldbMi(exe=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) - - def copyScript(self, sourceFile): - """copy the script to builddir and replace a.out with the full path""" - destFile = os.path.join(os.path.dirname(self.myexe), - sourceFile+'.script') - with open(sourceFile, 'r') as src: - with open(destFile, 'w+') as dest: - dest.write(src.read().replace("a.out", self.myexe)) - return destFile - - @skipIfRemote # We do not currently support remote debugging via the MI. - @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 - @expectedFailureNetBSD - @skipIfDarwin - 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 = self.copyScript("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) - os.unlink(sourceFile) - - @skipIfRemote # We do not currently support remote debugging via the MI. - @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 - @expectedFailureNetBSD - @skipIfDarwin - 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 = self.copyScript("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\"") - os.unlink(sourceFile) - - @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows - @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races - @skipIfDarwin - 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 = self.copyScript("start_script_error") - self.spawnLldbMi(args="--source %s" % sourceFile, preconfig=False) - - # After 'settings set symbols.enable-external-lookup false' - self.expect("settings set symbols.enable-external-lookup false") - self.expect("\^done") - - # 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) - os.unlink(sourceFile) - - @skipIfRemote # We do not currently support remote debugging via the MI. - @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows - @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races - @skipIfDarwin - @skipIfLinux - def test_lldbmi_log_option(self): - """Test that 'lldb-mi --log' creates a log file in the current directory.""" - - logDirectory = self.getBuildDir() - self.spawnLldbMi(exe=self.myexe, args="--log") - - # 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 - import 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) - - @skipIfRemote # We do not currently support remote debugging via the MI. - @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows - @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races - @skipIfDarwin - @skipIfLinux - 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(exe=self.myexe, - args="--log --log-dir=%s" % 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 - import 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) Index: lldb/packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/main.cpp =================================================================== --- lldb/packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/main.cpp +++ /dev/null @@ -1,14 +0,0 @@ -//===-- main.cpp ------------------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -int -main(int argc, char const *argv[]) -{ - int a = 10; - return 0; //BP_return -} Index: lldb/packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/start_script =================================================================== --- lldb/packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/start_script +++ /dev/null @@ -1,5 +0,0 @@ --file-exec-and-symbols a.out --break-insert -f main --exec-run --break-insert main.cpp:14 --exec-continue Index: lldb/packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/start_script_error =================================================================== --- lldb/packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/start_script_error +++ /dev/null @@ -1,3 +0,0 @@ -settings set symbols.enable-external-lookup false --file-exec-and-symbols a.out --break-ins -f main Index: lldb/packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/start_script_exit =================================================================== --- lldb/packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/start_script_exit +++ /dev/null @@ -1,7 +0,0 @@ --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 Index: lldb/packages/Python/lldbsuite/test/tools/lldb-mi/syntax/Makefile =================================================================== --- lldb/packages/Python/lldbsuite/test/tools/lldb-mi/syntax/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -LEVEL = ../../../make - -CXX_SOURCES := main.cpp - -include $(LEVEL)/Makefile.rules Index: lldb/packages/Python/lldbsuite/test/tools/lldb-mi/syntax/TestMiSyntax.py =================================================================== --- lldb/packages/Python/lldbsuite/test/tools/lldb-mi/syntax/TestMiSyntax.py +++ /dev/null @@ -1,174 +0,0 @@ -""" -Test that the lldb-mi driver understands MI command syntax. -""" - -from __future__ import print_function - - -import lldbmi_testcase -from lldbsuite.test.decorators import * -from lldbsuite.test.lldbtest import * -from lldbsuite.test import lldbutil -from functools import reduce - - -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 - @skipIfRemote # We do not currently support remote debugging via the MI. - @skipIfDarwin - @skipIfLinux - 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 - @skipIfRemote # We do not currently support remote debugging via the MI. - @skipIfDarwin - def test_lldbmi_specialchars(self): - """Test that 'lldb-mi --interpreter' handles complicated strings.""" - - # Create an alias for myexe - complicated_myexe = self.getBuildArtifact("C--mpl-x file's`s @#$%^&*()_+-={}[]| name") - os.symlink(self.myexe, complicated_myexe) - self.addTearDownHook(lambda: os.unlink(complicated_myexe)) - - self.spawnLldbMi(exe=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 - @skipIfDarwin - @expectedFlakeyNetBSD - @skipIfRemote # We do not currently support remote debugging via the MI. - def test_lldbmi_output_grammar(self): - """Test that 'lldb-mi --interpreter' uses standard output syntax.""" - - self.spawnLldbMi(args=None) - self.child.setecho(False) - - # Run all commands simultaneously - self.runCmd("-unknown-command") - self.runCmd("-interpreter-exec command help") - self.runCmd("-file-exec-and-symbols %s" % self.myexe) - self.runCmd("-break-insert -f main") - self.runCmd("-gdb-set target-async off") - self.runCmd("-exec-run") - self.runCmd("-gdb-set target-async on") - self.runCmd("-exec-continue") - self.runCmd("-gdb-exit") - - # Test that the program's output matches to the following pattern: - # ( async-record | stream-record )* [ result-record ] "(gdb)" nl - async_record = "^[0-9]*(\*|\+|=).+?\n" # 1 - stream_record = "^(~|@|&).+?\n" # 2 - result_record = "^[0-9]*\^.+?\n" # 3 - prompt = "^\(gdb\)\r\n" # 4 - command = "^\r\n" # 5 (it looks like empty line for pexpect) - error = "^.+?\n" # 6 - import pexpect # 7 (EOF) - all_patterns = [ - async_record, - stream_record, - result_record, - prompt, - command, - error, - pexpect.EOF] - - # Routines to get a bit-mask for the specified list of patterns - def get_bit(pattern): return all_patterns.index(pattern) - def get_mask(pattern): return 1 << get_bit(pattern) - def or_op(x, y): return x | y - def get_state(*args): return reduce(or_op, map(get_mask, args)) - - next_state = get_state(command) - while True: - it = self.expect(all_patterns) - matched_pattern = all_patterns[it] - - # Check that state is acceptable - if not (next_state & get_mask(matched_pattern)): - self.fail( - "error: inconsistent pattern '%s' for state %#x (matched string: %s)" % - (repr(matched_pattern), next_state, self.child.after)) - elif matched_pattern == async_record or matched_pattern == stream_record: - next_state = get_state( - async_record, - stream_record, - result_record, - prompt) - elif matched_pattern == result_record: - # FIXME lldb-mi prints async-records out of turn - # ``` - # ^done - # (gdb) - # ^running - # =thread-group-started,id="i1",pid="13875" - # (gdb) - # ``` - # Therefore to pass that test I changed the grammar's rule: - # next_state = get_state(prompt) - # to: - next_state = get_state(async_record, prompt) - elif matched_pattern == prompt: - # FIXME lldb-mi prints the prompt out of turn - # ``` - # ^done - # (gdb) - # ^running - # (gdb) - # (gdb) - # ``` - # Therefore to pass that test I changed the grammar's rule: - # next_state = get_state(async_record, stream_record, result_record, command, pexpect.EOF) - # to: - next_state = get_state( - async_record, - stream_record, - result_record, - prompt, - command, - pexpect.EOF) - elif matched_pattern == command: - next_state = get_state( - async_record, - stream_record, - result_record) - elif matched_pattern == pexpect.EOF: - break - else: - self.fail("error: pexpect returned an unknown state") Index: lldb/packages/Python/lldbsuite/test/tools/lldb-mi/syntax/main.cpp =================================================================== --- lldb/packages/Python/lldbsuite/test/tools/lldb-mi/syntax/main.cpp +++ /dev/null @@ -1,16 +0,0 @@ -//===-- main.cpp ------------------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#include - -int -main(int argc, char const *argv[]) -{ - printf("'\n` - it's \\n\x12\"\\\""); - return 0; -} Index: lldb/packages/Python/lldbsuite/test/tools/lldb-mi/target/Makefile =================================================================== --- lldb/packages/Python/lldbsuite/test/tools/lldb-mi/target/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -LEVEL = ../../../make - -CXX_SOURCES := test_attach.cpp - -include $(LEVEL)/Makefile.rules Index: lldb/packages/Python/lldbsuite/test/tools/lldb-mi/target/TestMiTarget.py =================================================================== --- lldb/packages/Python/lldbsuite/test/tools/lldb-mi/target/TestMiTarget.py +++ /dev/null @@ -1,137 +0,0 @@ -""" -Test lldb-mi -target-xxx commands. -""" - -from __future__ import print_function - -import lldbmi_testcase -from lldbsuite.test.decorators import * -from lldbsuite.test.lldbtest import * -from lldbsuite.test import lldbutil - - -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 - @skipIfRemote # We do not currently support remote debugging via the MI. - @skipIfDarwin - @expectedFailureNetBSD - def test_lldbmi_target_attach_wait_for(self): - """Test that 'lldb-mi --interpreter' works for -target-attach -n --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" % self.getBuildArtifact(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(self.getBuildArtifact(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 - @skipIfRemote # We do not currently support remote debugging via the MI. - @skipIfDarwin - @expectedFailureNetBSD - def test_lldbmi_target_attach_name(self): - """Test that 'lldb-mi --interpreter' works for -target-attach -n .""" - - # 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(self.getBuildArtifact(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 - @skipIfRemote # We do not currently support remote debugging via the MI. - @skipIfDarwin - @expectedFailureNetBSD - def test_lldbmi_target_attach_pid(self): - """Test that 'lldb-mi --interpreter' works for -target-attach .""" - - # 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( - self.getBuildArtifact(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") Index: lldb/packages/Python/lldbsuite/test/tools/lldb-mi/target/test_attach.cpp =================================================================== --- lldb/packages/Python/lldbsuite/test/tools/lldb-mi/target/test_attach.cpp +++ /dev/null @@ -1,20 +0,0 @@ -//===-- main.cpp ------------------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#include - -int -main(int argc, char const *argv[]) -{ - int i = 0; - for (;;) - { - i++; // BP_i++ - } - return 0; -} Index: lldb/packages/Python/lldbsuite/test/tools/lldb-mi/threadinfo/Makefile =================================================================== --- lldb/packages/Python/lldbsuite/test/tools/lldb-mi/threadinfo/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -LEVEL = ../../../make - -CXX_SOURCES := test_threadinfo.cpp - -ENABLE_THREADS := YES - -include $(LEVEL)/Makefile.rules Index: lldb/packages/Python/lldbsuite/test/tools/lldb-mi/threadinfo/TestMiThreadInfo.py =================================================================== --- lldb/packages/Python/lldbsuite/test/tools/lldb-mi/threadinfo/TestMiThreadInfo.py +++ /dev/null @@ -1,42 +0,0 @@ -""" -Test lldb-mi -thread-info command. -""" - -from __future__ import print_function - -import lldbmi_testcase -from lldbsuite.test.decorators import * -from lldbsuite.test.lldbtest import * -from lldbsuite.test import lldbutil - - -class MiThreadInfoTestCase(lldbmi_testcase.MiTestCaseBase): - - mydir = TestBase.compute_mydir(__file__) - - @skipIfWindows # pthreads not supported on Windows - @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races - @expectedFailureNetBSD - @skipIfRemote # We do not currently support remote debugging via the MI. - def test_lldbmi_thread_info(self): - """Test that -thread-info prints thread info and the current-thread-id""" - - self.spawnLldbMi(args=None) - - # Load executable - self.runCmd("-file-exec-and-symbols %s" % self.myexe) - self.expect("\^done") - - self.runCmd("-break-insert ThreadProc") - self.expect("\^done") - - # Run to the breakpoint - self.runCmd("-exec-run") - self.expect("\^running") - self.expect("\*stopped,reason=\"breakpoint-hit\"") - - self.runCmd("-thread-info") - self.expect( - "\^done,threads=\[\{id=\"1\",(.*)\},\{id=\"2\",(.*)\],current-thread-id=\"2\"") - - self.runCmd("-gdb-quit") Index: lldb/packages/Python/lldbsuite/test/tools/lldb-mi/threadinfo/test_threadinfo.cpp =================================================================== --- lldb/packages/Python/lldbsuite/test/tools/lldb-mi/threadinfo/test_threadinfo.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include -#include -#include - -using namespace std; - -void -ThreadProc() -{ - int i = 0; - i++; -} - -int -main() -{ - thread t(ThreadProc); - t.join(); - - return 0; -} Index: lldb/packages/Python/lldbsuite/test/tools/lldb-mi/variable/Makefile =================================================================== --- lldb/packages/Python/lldbsuite/test/tools/lldb-mi/variable/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -LEVEL = ../../../make - -CXX_SOURCES := main.cpp - -include $(LEVEL)/Makefile.rules Index: lldb/packages/Python/lldbsuite/test/tools/lldb-mi/variable/TestMiGdbSetShowPrint.py =================================================================== --- lldb/packages/Python/lldbsuite/test/tools/lldb-mi/variable/TestMiGdbSetShowPrint.py +++ /dev/null @@ -1,247 +0,0 @@ -# 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.decorators import * -from lldbsuite.test.lldbtest import * -from lldbsuite.test import lldbutil - - -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 - @skipIfRemote # We do not currently support remote debugging via the MI. - 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 - @expectedFailureAll(compiler="gcc", bugnumber="llvm.org/pr23357") - @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races - @skipIfRemote # We do not currently support remote debugging via the MI. - 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.\"") Index: lldb/packages/Python/lldbsuite/test/tools/lldb-mi/variable/TestMiVar.py =================================================================== --- lldb/packages/Python/lldbsuite/test/tools/lldb-mi/variable/TestMiVar.py +++ /dev/null @@ -1,465 +0,0 @@ -""" -Test lldb-mi -var-xxx commands. -""" - -from __future__ import print_function - - -import lldbmi_testcase -from lldbsuite.test.decorators import * -from lldbsuite.test.lldbtest import * -from lldbsuite.test import lldbutil - - -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 - @skipIfRemote # We do not currently support remote debugging via the MI. - @skipIfDarwin - 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: use of undeclared identifier \'undef\'\\\\n\"") - self.runCmd("-data-evaluate-expression undef") - self.expect( - "\^error,msg=\"error: use of undeclared identifier \'undef\'\\\\n\"") - - # 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]". - # FIXME -var-list-children shows invalid thread-id - 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\"") - - # Print an expression with spaces and optional arguments - self.runCmd("-data-evaluate-expression \"a + b\"") - self.expect("\^done,value=\"12\"") - self.runCmd("-var-create var7 * \"a + b\" --thread 1 --frame 0") - self.expect( - "\^done,name=\"var7\",numchild=\"0\",value=\"12\",type=\"int\",thread-id=\"1\",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 - @skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots - @skipIfDarwin - @skipIfRemote # We do not currently support remote debugging via the MI. - 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 - @skipIfRemote # We do not currently support remote debugging via the MI. - @skipIfDarwin - 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 - @skipIfRemote # We do not currently support remote debugging via the MI. - @skipIfDarwin - 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 - @skipIfRemote # We do not currently support remote debugging via the MI. - @skipIfDarwin - 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 - @skipIfRemote # We do not currently support remote debugging via the MI. - @skipIfDarwin - 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"') Index: lldb/packages/Python/lldbsuite/test/tools/lldb-mi/variable/main.cpp =================================================================== --- lldb/packages/Python/lldbsuite/test/tools/lldb-mi/variable/main.cpp +++ /dev/null @@ -1,151 +0,0 @@ -//===-- main.cpp ------------------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#include -#include - -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 -}