summaryrefslogtreecommitdiff
path: root/packages/Python/lldbsuite/test/tools
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2018-07-28 11:09:23 +0000
committerDimitry Andric <dim@FreeBSD.org>2018-07-28 11:09:23 +0000
commitf73363f1dd94996356cefbf24388f561891acf0b (patch)
treee3c31248bdb36eaec5fd833490d4278162dba2a0 /packages/Python/lldbsuite/test/tools
parent160ee69dd7ae18978f4068116777639ea98dc951 (diff)
Notes
Diffstat (limited to 'packages/Python/lldbsuite/test/tools')
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-mi/TestMiExit.py94
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-mi/TestMiFile.py7
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-mi/TestMiGdbSetShow.py260
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-mi/TestMiLibraryLoaded.py5
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-mi/breakpoint/TestMiBreak.py2
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-mi/control/TestMiExec.py371
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-mi/data/TestMiData.py65
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-mi/interpreter/TestMiCliSupport.py20
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-mi/interpreter/TestMiInterpreterExec.py66
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-mi/lldbmi_testcase.py18
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-mi/signal/TestMiSignal.py2
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/TestMiStartupOptions.py46
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-mi/symbol/Makefile5
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-mi/symbol/TestMiSymbol.py104
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-mi/symbol/main.cpp18
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-mi/symbol/symbol_list_lines_inline_test.cpp39
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-mi/symbol/symbol_list_lines_inline_test.h24
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-mi/symbol/symbol_list_lines_inline_test2.cpp38
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-mi/syntax/TestMiSyntax.py29
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-mi/target/TestMiTarget.py12
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-mi/variable/TestMiGdbSetShowPrint.py75
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-mi/variable/TestMiVar.py7
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-server/TestAppleSimulatorOSType.py112
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteExitCode.py (renamed from packages/Python/lldbsuite/test/tools/lldb-server/exit-code/TestGdbRemoteExitCode.py)0
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteExpeditedRegisters.py2
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteGPacket.py40
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteModuleInfo.py2
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-server/TestLldbGdbServer.py9
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-server/exit-code/Makefile8
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-server/exit-code/main.cpp355
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py34
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-server/main.cpp16
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-server/platform-process-connect/TestPlatformProcessConnect.py15
33 files changed, 320 insertions, 1580 deletions
diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiExit.py b/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiExit.py
deleted file mode 100644
index 4f3562d42de8..000000000000
--- a/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiExit.py
+++ /dev/null
@@ -1,94 +0,0 @@
-"""
-Test that the lldb-mi driver exits 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 MiExitTestCase(lldbmi_testcase.MiTestCaseBase):
-
- mydir = TestBase.compute_mydir(__file__)
-
- @expectedFailureAll(
- oslist=["windows"],
- bugnumber="llvm.org/pr22274: need a pexpect replacement for 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_gdb_exit(self):
- """Test that '-gdb-exit' terminates local debug session and exits."""
-
- self.spawnLldbMi(args=None)
-
- # Load executable
- self.runCmd("-file-exec-and-symbols %s" % self.myexe)
- self.expect("\^done")
-
- # Run to main
- self.runCmd("-break-insert -f main")
- self.expect("\^done,bkpt={number=\"1\"")
- self.runCmd("-exec-run")
- self.expect("\^running")
- self.expect("\*stopped,reason=\"breakpoint-hit\"")
-
- # Test -gdb-exit: try to exit and check that program is finished
- self.runCmd("-gdb-exit")
- self.expect("\^exit")
- import pexpect
- self.expect(pexpect.EOF)
-
- @expectedFailureAll(
- oslist=["windows"],
- bugnumber="llvm.org/pr22274: need a pexpect replacement for 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_quit(self):
- """Test that 'quit' exits immediately."""
-
- self.spawnLldbMi(args=None)
-
- # Load executable
- self.runCmd("-file-exec-and-symbols %s" % self.myexe)
- self.expect("\^done")
-
- # Run to main
- self.runCmd("-break-insert -f main")
- self.expect("\^done,bkpt={number=\"1\"")
- self.runCmd("-exec-run")
- self.expect("\^running")
- self.expect("\*stopped,reason=\"breakpoint-hit\"")
-
- # Test quit: try to exit and check that program is finished
- self.runCmd("quit")
- import pexpect
- self.expect(pexpect.EOF)
-
- @expectedFailureAll(
- oslist=["windows"],
- bugnumber="llvm.org/pr22274: need a pexpect replacement for 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_q(self):
- """Test that 'q' exits immediately."""
-
- self.spawnLldbMi(args=None)
-
- # Load executable
- self.runCmd("-file-exec-and-symbols %s" % self.myexe)
- self.expect("\^done")
-
- # Run to main
- self.runCmd("-break-insert -f main")
- self.expect("\^done,bkpt={number=\"1\"")
- self.runCmd("-exec-run")
- self.expect("\^running")
- self.expect("\*stopped,reason=\"breakpoint-hit\"")
-
- # Test q: try to exit and check that program is finished
- self.runCmd("q")
- import pexpect
- self.expect(pexpect.EOF)
diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiFile.py b/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiFile.py
index 1eea89f4fff4..b650eb89d812 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiFile.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiFile.py
@@ -41,9 +41,7 @@ class MiFileTestCase(lldbmi_testcase.MiTestCaseBase):
self.spawnLldbMi(args=None)
# Test that -file-exec-and-symbols works for absolute path
- import os
- path = os.path.join(os.getcwd(), self.myexe)
- self.runCmd("-file-exec-and-symbols \"%s\"" % path)
+ self.runCmd("-file-exec-and-symbols \"%s\"" % self.myexe)
self.expect("\^done")
# Run
@@ -60,7 +58,8 @@ class MiFileTestCase(lldbmi_testcase.MiTestCaseBase):
self.spawnLldbMi(args=None)
# Test that -file-exec-and-symbols works for relative path
- path = "./%s" % self.myexe
+ import os
+ path = os.path.relpath(self.myexe, self.getBuildDir())
self.runCmd("-file-exec-and-symbols %s" % path)
self.expect("\^done")
diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiGdbSetShow.py b/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiGdbSetShow.py
deleted file mode 100644
index 6bb7619e60b8..000000000000
--- a/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiGdbSetShow.py
+++ /dev/null
@@ -1,260 +0,0 @@
-"""
-Test lldb-mi -gdb-set and -gdb-show 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 MiGdbSetShowTestCase(lldbmi_testcase.MiTestCaseBase):
-
- mydir = TestBase.compute_mydir(__file__)
-
- @expectedFailureAll(
- oslist=["windows"],
- bugnumber="llvm.org/pr22274: need a pexpect replacement for 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_gdb_set_target_async_default(self):
- """Test that 'lldb-mi --interpreter' switches to async mode by default."""
-
- self.spawnLldbMi(args=None)
-
- # Switch to sync mode
- self.runCmd("-gdb-set target-async off")
- self.expect("\^done")
- self.runCmd("-gdb-show target-async")
- self.expect("\^done,value=\"off\"")
-
- # Test that -gdb-set switches to async by default
- self.runCmd("-gdb-set target-async")
- self.expect("\^done")
- self.runCmd("-gdb-show target-async")
- self.expect("\^done,value=\"on\"")
-
- @expectedFailureAll(
- oslist=["windows"],
- bugnumber="llvm.org/pr22274: need a pexpect replacement for windows")
- @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
- @expectedFlakeyLinux("llvm.org/pr26028") # Fails in ~1% of cases
- @skipIfRemote # We do not currently support remote debugging via the MI.
- def test_lldbmi_gdb_set_target_async_on(self):
- """Test that 'lldb-mi --interpreter' can execute commands in async mode."""
-
- self.spawnLldbMi(args=None)
-
- # Switch to sync mode
- self.runCmd("-gdb-set target-async off")
- self.expect("\^done")
- self.runCmd("-gdb-show target-async")
- self.expect("\^done,value=\"off\"")
-
- # Test that -gdb-set can switch to async mode
- self.runCmd("-gdb-set target-async on")
- self.expect("\^done")
- self.runCmd("-gdb-show target-async")
- self.expect("\^done,value=\"on\"")
-
- # Load executable
- self.runCmd("-file-exec-and-symbols %s" % self.myexe)
- self.expect("\^done")
-
- # Test that program is executed in async mode
- self.runCmd("-exec-run")
- self.expect("\*running")
- self.expect("@\"argc=1")
-
- @expectedFailureAll(
- oslist=["windows"],
- bugnumber="llvm.org/pr22274: need a pexpect replacement for windows")
- @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
- @expectedFailureAll(
- oslist=["linux"],
- bugnumber="Failing in ~11/600 dosep runs (build 3120-3122)")
- @skipIfRemote # We do not currently support remote debugging via the MI.
- def test_lldbmi_gdb_set_target_async_off(self):
- """Test that 'lldb-mi --interpreter' can execute commands in sync mode."""
-
- self.spawnLldbMi(args=None)
-
- # Test that -gdb-set can switch to sync mode
- self.runCmd("-gdb-set target-async off")
- self.expect("\^done")
- self.runCmd("-gdb-show target-async")
- self.expect("\^done,value=\"off\"")
-
- # Load executable
- self.runCmd("-file-exec-and-symbols %s" % self.myexe)
- self.expect("\^done")
-
- # Test that program is executed in async mode
- self.runCmd("-exec-run")
- unexpected = ["\*running"] # "\*running" is async notification
- it = self.expect(unexpected + ["@\"argc=1\\\\r\\\\n"])
- if it < len(unexpected):
- self.fail("unexpected found: %s" % unexpected[it])
-
- @expectedFailureAll(
- oslist=["windows"],
- bugnumber="llvm.org/pr22274: need a pexpect replacement for 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_gdb_show_target_async(self):
- """Test that 'lldb-mi --interpreter' in async mode by default."""
-
- self.spawnLldbMi(args=None)
-
- # Test that default target-async value is "on"
- self.runCmd("-gdb-show target-async")
- self.expect("\^done,value=\"on\"")
-
- @expectedFailureAll(
- oslist=["windows"],
- bugnumber="llvm.org/pr22274: need a pexpect replacement for 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_gdb_show_language(self):
- """Test that 'lldb-mi --interpreter' can get current language."""
-
- self.spawnLldbMi(args=None)
-
- # Load executable
- self.runCmd("-file-exec-and-symbols %s" % self.myexe)
- self.expect("\^done")
-
- # Run to main
- self.runCmd("-break-insert -f main")
- self.expect("\^done,bkpt={number=\"1\"")
- self.runCmd("-exec-run")
- self.expect("\^running")
- self.expect("\*stopped,reason=\"breakpoint-hit\"")
-
- # Test that -gdb-show language gets current language
- self.runCmd("-gdb-show language")
- self.expect("\^done,value=\"c\+\+\"")
-
- @expectedFailureAll(
- oslist=["windows"],
- bugnumber="llvm.org/pr22274: need a pexpect replacement for windows")
- @unittest2.expectedFailure("-gdb-set ignores unknown properties")
- @skipIfRemote # We do not currently support remote debugging via the MI.
- def test_lldbmi_gdb_set_unknown(self):
- """Test that 'lldb-mi --interpreter' fails when setting an unknown property."""
-
- self.spawnLldbMi(args=None)
-
- # Test that -gdb-set fails if property is unknown
- self.runCmd("-gdb-set unknown some_value")
- self.expect("\^error")
-
- @expectedFailureAll(
- oslist=["windows"],
- bugnumber="llvm.org/pr22274: need a pexpect replacement for windows")
- @unittest2.expectedFailure("-gdb-show ignores unknown properties")
- @skipIfRemote # We do not currently support remote debugging via the MI.
- def test_lldbmi_gdb_show_unknown(self):
- """Test that 'lldb-mi --interpreter' fails when showing an unknown property."""
-
- self.spawnLldbMi(args=None)
-
- # Test that -gdb-show fails if property is unknown
- self.runCmd("-gdb-show unknown")
- self.expect("\^error")
-
- @expectedFailureAll(
- oslist=["windows"],
- bugnumber="llvm.org/pr22274: need a pexpect replacement for windows")
- @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
- @skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots
- @skipIfRemote # We do not currently support remote debugging via the MI.
- def test_lldbmi_gdb_set_ouptut_radix(self):
- """Test that 'lldb-mi --interpreter' works for -gdb-set output-radix."""
-
- self.spawnLldbMi(args=None)
-
- # Load executable
- self.runCmd("-file-exec-and-symbols %s" % self.myexe)
- self.expect("\^done")
-
- # Run to BP_printf
- line = line_number('main.cpp', '// BP_printf')
- self.runCmd("-break-insert main.cpp:%d" % line)
- self.expect("\^done,bkpt={number=\"1\"")
- self.runCmd("-exec-run")
- self.expect("\^running")
- self.expect("\*stopped,reason=\"breakpoint-hit\"")
-
- # Setup variable
- self.runCmd("-var-create var_a * a")
- self.expect(
- "\^done,name=\"var_a\",numchild=\"0\",value=\"10\",type=\"int\",thread-id=\"1\",has_more=\"0\"")
-
- # Test default output
- self.runCmd("-var-evaluate-expression var_a")
- self.expect("\^done,value=\"10\"")
-
- # Test hex output
- self.runCmd("-gdb-set output-radix 16")
- self.expect("\^done")
- self.runCmd("-var-evaluate-expression var_a")
- self.expect("\^done,value=\"0xa\"")
-
- # Test octal output
- self.runCmd("-gdb-set output-radix 8")
- self.expect("\^done")
- self.runCmd("-var-evaluate-expression var_a")
- self.expect("\^done,value=\"012\"")
-
- # Test decimal output
- self.runCmd("-gdb-set output-radix 10")
- self.expect("\^done")
- self.runCmd("-var-evaluate-expression var_a")
- self.expect("\^done,value=\"10\"")
-
- @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.
- @expectedFailureAll(
- bugnumber="llvm.org/pr31485: data-disassemble doesn't follow flavor settings")
- def test_lldbmi_gdb_set_disassembly_flavor(self):
- """Test that 'lldb-mi --interpreter' works for -gdb-set disassembly-flavor."""
-
- self.spawnLldbMi(args=None)
-
- # Load executable
- self.runCmd("-file-exec-and-symbols %s" % self.myexe)
- self.expect("\^done")
-
- # Run to BP_printf
- line = line_number('main.cpp', '// BP_printf')
- self.runCmd("-break-insert main.cpp:%d" % line)
- self.expect("\^done,bkpt={number=\"1\"")
- self.runCmd("-exec-run")
- self.expect("\^running")
- self.expect("\*stopped,reason=\"breakpoint-hit\".+addr=\"(0x[0-9a-f]+)\"")
-
- # Get starting and ending address from $pc
- pc = int(self.child.match.group(1), base=16)
- s_addr, e_addr = pc, pc + 1
-
- # Test default output (att)
- self.runCmd("-data-disassemble -s %d -e %d -- 0" % (s_addr, e_addr))
- self.expect("movl ")
-
- # Test intel style
- self.runCmd("-gdb-set disassembly-flavor intel")
- self.expect("\^done")
- self.runCmd("-data-disassemble -s %d -e %d -- 0" % (s_addr, e_addr))
- self.expect("mov ")
-
- # Test AT&T style
- self.runCmd("-gdb-set disassembly-flavor intel")
- self.expect("\^done")
- self.runCmd("-data-disassemble -s %d -e %d -- 0" % (s_addr, e_addr))
- self.expect("movl ")
diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiLibraryLoaded.py b/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiLibraryLoaded.py
index a597ae1397ad..92b7fdaca662 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiLibraryLoaded.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiLibraryLoaded.py
@@ -18,6 +18,7 @@ class MiLibraryLoadedTestCase(lldbmi_testcase.MiTestCaseBase):
@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."""
@@ -29,13 +30,13 @@ class MiLibraryLoadedTestCase(lldbmi_testcase.MiTestCaseBase):
# Test =library-loaded
import os
- path = os.path.join(os.getcwd(), self.myexe)
+ path = self.getBuildArtifact(self.myexe)
symbols_path = os.path.join(
path + ".dSYM",
"Contents",
"Resources",
"DWARF",
- self.myexe)
+ "a.out")
def add_slashes(x): return x.replace(
"\\",
diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/breakpoint/TestMiBreak.py b/packages/Python/lldbsuite/test/tools/lldb-mi/breakpoint/TestMiBreak.py
index 16f71fe8130c..c8bb89e07f6b 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-mi/breakpoint/TestMiBreak.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-mi/breakpoint/TestMiBreak.py
@@ -200,7 +200,7 @@ class MiBreakTestCase(lldbmi_testcase.MiTestCaseBase):
self.expect("\*stopped,reason=\"breakpoint-hit\"")
import os
- path = os.path.join(os.getcwd(), "main.cpp")
+ 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\"")
diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/control/TestMiExec.py b/packages/Python/lldbsuite/test/tools/lldb-mi/control/TestMiExec.py
index 80ceadb6f268..00c52dbe97aa 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-mi/control/TestMiExec.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-mi/control/TestMiExec.py
@@ -18,29 +18,6 @@ class MiExecTestCase(lldbmi_testcase.MiTestCaseBase):
@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
- @expectedFailureAll(
- oslist=["linux"],
- bugnumber="llvm.org/pr25000: lldb-mi does not receive broadcasted notification from Core/Process about process stopped")
- def test_lldbmi_exec_run(self):
- """Test that 'lldb-mi --interpreter' can stop at entry."""
-
- self.spawnLldbMi(args=None)
-
- # Load executable
- self.runCmd("-file-exec-and-symbols %s" % self.myexe)
- self.expect("\^done")
-
- # Test that program is stopped at entry
- self.runCmd("-exec-run --start")
- self.expect("\^running")
- self.expect(
- "\*stopped,reason=\"signal-received\",signal-name=\"SIGSTOP\",signal-meaning=\"Stop\",.*?thread-id=\"1\",stopped-threads=\"all\"")
- # Test that lldb-mi is ready to execute next commands
- self.expect(self.child_prompt, exactly=True)
-
- @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."""
@@ -162,351 +139,3 @@ class MiExecTestCase(lldbmi_testcase.MiTestCaseBase):
# Check argc to see if arg passed
self.runCmd("-data-evaluate-expression argc")
self.expect("\^done,value=\"1\"")
-
- @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_next(self):
- """Test that 'lldb-mi --interpreter' works for stepping."""
-
- self.spawnLldbMi(args=None)
-
- # Load executable
- self.runCmd("-file-exec-and-symbols %s" % self.myexe)
- self.expect("\^done")
-
- # Run to main
- self.runCmd("-break-insert -f main")
- self.expect("\^done,bkpt={number=\"1\"")
- self.runCmd("-exec-run")
- self.expect("\^running")
- self.expect("\*stopped,reason=\"breakpoint-hit\"")
-
- # Warning: the following is sensitive to the lines in the source
-
- # Test -exec-next
- self.runCmd("-exec-next --thread 1 --frame 0")
- self.expect("\^running")
- self.expect(
- "\*stopped,reason=\"end-stepping-range\".+?main\.cpp\",line=\"29\"")
-
- # Test that --thread is optional
- self.runCmd("-exec-next --frame 0")
- self.expect("\^running")
- self.expect(
- "\*stopped,reason=\"end-stepping-range\".+?main\.cpp\",line=\"30\"")
-
- # Test that --frame is optional
- self.runCmd("-exec-next --thread 1")
- self.expect("\^running")
- self.expect(
- "\*stopped,reason=\"end-stepping-range\".+?main\.cpp\",line=\"31\"")
-
- # Test that both --thread and --frame are optional
- self.runCmd("-exec-next")
- self.expect("\^running")
- self.expect(
- "\*stopped,reason=\"end-stepping-range\".+?main\.cpp\",line=\"32\"")
-
- # Test that an invalid --thread is handled
- self.runCmd("-exec-next --thread 0")
- self.expect("\^error,message=\"error: Thread index 0 is out of range")
- self.runCmd("-exec-next --thread 10")
- self.expect("\^error,message=\"error: Thread index 10 is out of range")
-
- # Test that an invalid --frame is handled
- # FIXME: no error is returned
- self.runCmd("-exec-next --frame 10")
- #self.expect("\^error: Frame index 10 is out of range")
-
- @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_next_instruction(self):
- """Test that 'lldb-mi --interpreter' works for instruction stepping."""
-
- self.spawnLldbMi(args=None)
-
- # Load executable
- self.runCmd("-file-exec-and-symbols %s" % self.myexe)
- self.expect("\^done")
-
- # Run to main
- self.runCmd("-break-insert -f main")
- self.expect("\^done,bkpt={number=\"1\"")
- self.runCmd("-exec-run")
- self.expect("\^running")
- self.expect("\*stopped,reason=\"breakpoint-hit\"")
-
- # Warning: the following is sensitive to the lines in the
- # source and optimizations
-
- # Test -exec-next-instruction
- self.runCmd("-exec-next-instruction --thread 1 --frame 0")
- self.expect("\^running")
- self.expect(
- "\*stopped,reason=\"end-stepping-range\".+?main\.cpp\",line=\"28\"")
-
- # Test that --thread is optional
- self.runCmd("-exec-next-instruction --frame 0")
- self.expect("\^running")
- # Depending on compiler, it can stop at different line
- self.expect(
- "\*stopped,reason=\"end-stepping-range\".+?main\.cpp\",line=\"(28|29)\"")
-
- # Test that --frame is optional
- self.runCmd("-exec-next-instruction --thread 1")
- self.expect("\^running")
- # Depending on compiler, it can stop at different line
- self.expect(
- "\*stopped,reason=\"end-stepping-range\".+?main\.cpp\",line=\"(28|29|30)\"")
-
- # Test that both --thread and --frame are optional
- self.runCmd("-exec-next-instruction")
- self.expect("\^running")
- # Depending on compiler, it can stop at different line
- self.expect(
- "\*stopped,reason=\"end-stepping-range\".+?main\.cpp\",line=\"(28|29|30|31)\"")
-
- # Test that an invalid --thread is handled
- self.runCmd("-exec-next-instruction --thread 0")
- self.expect("\^error,message=\"error: Thread index 0 is out of range")
- self.runCmd("-exec-next-instruction --thread 10")
- self.expect("\^error,message=\"error: Thread index 10 is out of range")
-
- # Test that an invalid --frame is handled
- # FIXME: no error is returned
- self.runCmd("-exec-next-instruction --frame 10")
- #self.expect("\^error: Frame index 10 is out of range")
-
- @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_step(self):
- """Test that 'lldb-mi --interpreter' works for stepping into."""
-
- self.spawnLldbMi(args=None)
-
- # Load executable
- self.runCmd("-file-exec-and-symbols %s" % self.myexe)
- self.expect("\^done")
-
- # Run to main
- self.runCmd("-break-insert -f main")
- self.expect("\^done,bkpt={number=\"1\"")
- self.runCmd("-exec-run")
- self.expect("\^running")
- self.expect("\*stopped,reason=\"breakpoint-hit\"")
-
- # Warning: the following is sensitive to the lines in the source
-
- # Test that -exec-step steps into (or not) printf depending on debug info
- # Note that message is different in Darwin and Linux:
- # Darwin: "*stopped,reason=\"end-stepping-range\",frame={addr=\"0x[0-9a-f]+\",func=\"main\",args=[{name=\"argc\",value=\"1\"},{name=\"argv\",value="0x[0-9a-f]+\"}],file=\"main.cpp\",fullname=\".+main.cpp\",line=\"\d\"},thread-id=\"1\",stopped-threads=\"all\"
- # Linux:
- # "*stopped,reason=\"end-stepping-range\",frame={addr="0x[0-9a-f]+\",func=\"__printf\",args=[{name=\"format\",value=\"0x[0-9a-f]+\"}],file=\"printf.c\",fullname=\".+printf.c\",line="\d+"},thread-id=\"1\",stopped-threads=\"all\"
- self.runCmd("-exec-step --thread 1 --frame 0")
- self.expect("\^running")
- it = self.expect(["\*stopped,reason=\"end-stepping-range\".+?func=\"main\"",
- "\*stopped,reason=\"end-stepping-range\".+?func=\"(?!main).+?\""])
- # Exit from printf if needed
- if it == 1:
- self.runCmd("-exec-finish")
- self.expect("\^running")
- self.expect(
- "\*stopped,reason=\"end-stepping-range\".+?func=\"main\"")
-
- # Test that -exec-step steps into g_MyFunction and back out
- # (and that --thread is optional)
- self.runCmd("-exec-step --frame 0")
- self.expect("\^running")
- self.expect(
- "\*stopped,reason=\"end-stepping-range\".+?func=\"g_MyFunction.*?\"")
- # Use -exec-finish here to make sure that control reaches the caller.
- # -exec-step can keep us in the g_MyFunction for gcc
- self.runCmd("-exec-finish --frame 0")
- self.expect("\^running")
- it = self.expect(["\*stopped,reason=\"end-stepping-range\".+?main\.cpp\",line=\"30\"",
- "\*stopped,reason=\"end-stepping-range\".+?main\.cpp\",line=\"29\""])
-
- if it == 1:
- # Call to s_MyFunction may not follow immediately after g_MyFunction.
- # There might be some instructions in between to restore caller-saved registers.
- # We need to get past these instructions with a next to reach call to s_MyFunction.
- self.runCmd("-exec-next --thread 1")
- self.expect("\^running")
- self.expect("\*stopped,reason=\"end-stepping-range\".+?main\.cpp\",line=\"30\"")
-
- # Test that -exec-step steps into s_MyFunction
- # (and that --frame is optional)
- self.runCmd("-exec-step --thread 1")
- self.expect("\^running")
- self.expect(
- "\*stopped,reason=\"end-stepping-range\".+?func=\".*?s_MyFunction.*?\"")
-
- # Test that -exec-step steps into g_MyFunction from inside
- # s_MyFunction (and that both --thread and --frame are optional)
- self.runCmd("-exec-step")
- self.expect("\^running")
- self.expect(
- "\*stopped,reason=\"end-stepping-range\".+?func=\"g_MyFunction.*?\"")
-
- # Test that an invalid --thread is handled
- self.runCmd("-exec-step --thread 0")
- self.expect("\^error,message=\"error: Thread index 0 is out of range")
- self.runCmd("-exec-step --thread 10")
- self.expect("\^error,message=\"error: Thread index 10 is out of range")
-
- # Test that an invalid --frame is handled
- # FIXME: no error is returned
- self.runCmd("-exec-step --frame 10")
- #self.expect("\^error: Frame index 10 is out of range")
-
- @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_step_instruction(self):
- """Test that 'lldb-mi --interpreter' works for instruction stepping into."""
-
- self.spawnLldbMi(args=None)
-
- # Load executable
- self.runCmd("-file-exec-and-symbols %s" % self.myexe)
- self.expect("\^done")
-
- # Warning: the following is sensitive to the lines in the
- # source and optimizations
-
- # Run to main
- self.runCmd("-break-insert -f main")
- self.expect("\^done,bkpt={number=\"1\"")
- self.runCmd("-exec-run")
- self.expect("\^running")
- self.expect("\*stopped,reason=\"breakpoint-hit\"")
-
- # Test that -exec-next steps over printf
- self.runCmd("-exec-next --thread 1 --frame 0")
- self.expect("\^running")
- self.expect(
- "\*stopped,reason=\"end-stepping-range\".+?main\.cpp\",line=\"29\"")
-
- # Test that -exec-step-instruction steps over non branching
- # instruction
- self.runCmd("-exec-step-instruction --thread 1 --frame 0")
- self.expect("\^running")
- self.expect("\*stopped,reason=\"end-stepping-range\".+?main\.cpp\"")
-
- # Test that -exec-step-instruction steps into g_MyFunction
- # instruction (and that --thread is optional)
-
- # In case of MIPS, there might be more than one instruction
- # before actual call instruction (like load, move and call instructions).
- # The -exec-step-instruction would step one assembly instruction.
- # Thus we may not enter into g_MyFunction function. The -exec-step would definitely
- # step into the function.
-
- if self.isMIPS():
- self.runCmd("-exec-step --frame 0")
- else:
- self.runCmd("-exec-step-instruction --frame 0")
- self.expect("\^running")
- self.expect(
- "\*stopped,reason=\"end-stepping-range\".+?func=\"g_MyFunction.*?\"")
-
- # Test that -exec-step-instruction steps over non branching
- # (and that --frame is optional)
- self.runCmd("-exec-step-instruction --thread 1")
- self.expect("\^running")
- self.expect(
- "\*stopped,reason=\"end-stepping-range\".+?func=\"g_MyFunction.*?\"")
-
- # Test that -exec-step-instruction steps into g_MyFunction
- # (and that both --thread and --frame are optional)
- self.runCmd("-exec-step-instruction")
- self.expect("\^running")
- self.expect(
- "\*stopped,reason=\"end-stepping-range\".+?func=\"g_MyFunction.*?\"")
-
- # Test that an invalid --thread is handled
- self.runCmd("-exec-step-instruction --thread 0")
- self.expect("\^error,message=\"error: Thread index 0 is out of range")
- self.runCmd("-exec-step-instruction --thread 10")
- self.expect("\^error,message=\"error: Thread index 10 is out of range")
-
- # Test that an invalid --frame is handled
- # FIXME: no error is returned
- self.runCmd("-exec-step-instruction --frame 10")
- #self.expect("\^error: Frame index 10 is out of range")
-
- @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_finish(self):
- """Test that 'lldb-mi --interpreter' works for -exec-finish."""
-
- self.spawnLldbMi(args=None)
-
- # Load executable
- self.runCmd("-file-exec-and-symbols %s" % self.myexe)
- self.expect("\^done")
-
- # Set BP at g_MyFunction and run to BP
- self.runCmd("-break-insert -f g_MyFunction")
- self.expect("\^done,bkpt={number=\"1\"")
- self.runCmd("-exec-run")
- self.expect("\^running")
- self.expect("\*stopped,reason=\"breakpoint-hit\"")
-
- # Test that -exec-finish returns from g_MyFunction
- self.runCmd("-exec-finish --thread 1 --frame 0")
- self.expect("\^running")
- self.expect("\*stopped,reason=\"end-stepping-range\".+?func=\"main\"")
-
- # Run to BP inside s_MyFunction call
- self.runCmd("-break-insert s_MyFunction")
- self.expect("\^done,bkpt={number=\"2\"")
- self.runCmd("-exec-continue")
- self.expect("\^running")
- self.expect("\*stopped,reason=\"breakpoint-hit\"")
-
- # Test that -exec-finish hits BP at g_MyFunction call inside
- # s_MyFunction (and that --thread is optional)
- self.runCmd("-exec-finish --frame 0")
- self.expect("\^running")
- self.expect("\*stopped,reason=\"breakpoint-hit\"")
-
- # Test that -exec-finish returns from g_MyFunction call inside
- # s_MyFunction (and that --frame is optional)
- self.runCmd("-exec-finish --thread 1")
- self.expect("\^running")
- self.expect(
- "\*stopped,reason=\"end-stepping-range\".+?func=\".*?s_MyFunction.*?\"")
-
- # Test that -exec-finish returns from s_MyFunction
- # (and that both --thread and --frame are optional)
- self.runCmd("-exec-finish")
- self.expect("\^running")
- self.expect("\*stopped,reason=\"end-stepping-range\".+?func=\"main\"")
-
- # Test that an invalid --thread is handled
- self.runCmd("-exec-finish --thread 0")
- self.expect("\^error,message=\"error: Thread index 0 is out of range")
- self.runCmd("-exec-finish --thread 10")
- self.expect("\^error,message=\"error: Thread index 10 is out of range")
-
- # Test that an invalid --frame is handled
- # FIXME: no error is returned
- #self.runCmd("-exec-finish --frame 10")
- #self.expect("\^error: Frame index 10 is out of range")
-
- # Set BP at printf and run to BP
- self.runCmd("-break-insert -f printf")
- self.expect("\^done,bkpt={number=\"3\"")
- self.runCmd("-exec-continue")
- self.expect("\^running")
- self.expect("\*stopped,reason=\"breakpoint-hit\"")
-
- # Test that -exec-finish returns from printf
- self.runCmd("-exec-finish --thread 1 --frame 0")
- self.expect("\^running")
- self.expect("\*stopped,reason=\"end-stepping-range\".+?func=\"main\"")
diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/data/TestMiData.py b/packages/Python/lldbsuite/test/tools/lldb-mi/data/TestMiData.py
index f3a277246862..5e6b3f20dde7 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-mi/data/TestMiData.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-mi/data/TestMiData.py
@@ -18,6 +18,7 @@ class MiDataTestCase(lldbmi_testcase.MiTestCaseBase):
@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."""
@@ -79,8 +80,8 @@ class MiDataTestCase(lldbmi_testcase.MiTestCaseBase):
# 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 disassembler never prints stub name
- if self.isMIPS():
+ # 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:
@@ -89,6 +90,7 @@ class MiDataTestCase(lldbmi_testcase.MiTestCaseBase):
@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."""
@@ -132,6 +134,7 @@ class MiDataTestCase(lldbmi_testcase.MiTestCaseBase):
@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."""
@@ -272,6 +275,7 @@ class MiDataTestCase(lldbmi_testcase.MiTestCaseBase):
@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."""
@@ -299,6 +303,7 @@ class MiDataTestCase(lldbmi_testcase.MiTestCaseBase):
@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."""
@@ -328,61 +333,7 @@ class MiDataTestCase(lldbmi_testcase.MiTestCaseBase):
@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_data_info_line(self):
- """Test that 'lldb-mi --interpreter' works for -data-info-line."""
-
- self.spawnLldbMi(args=None)
-
- # Load executable
- self.runCmd("-file-exec-and-symbols %s" % self.myexe)
- self.expect("\^done")
-
- # Run to main
- self.runCmd("-break-insert -f main")
- self.expect("\^done,bkpt={number=\"1\"")
- self.runCmd("-exec-run")
- self.expect("\^running")
- self.expect("\*stopped,reason=\"breakpoint-hit\"")
-
- # Get the address of main and its line
- self.runCmd("-data-evaluate-expression main")
- self.expect(
- "\^done,value=\"0x[0-9a-f]+ \(a.out`main at main.cpp:[0-9]+\)\"")
- addr = int(self.child.after.split("\"")[1].split(" ")[0], 16)
- line = line_number('main.cpp', '// FUNC_main')
-
- # Test that -data-info-line works for address
- self.runCmd("-data-info-line *%#x" % addr)
- self.expect(
- "\^done,start=\"0x0*%x\",end=\"0x[0-9a-f]+\",file=\".+?main.cpp\",line=\"%d\"" %
- (addr, line))
-
- # Test that -data-info-line works for file:line
- self.runCmd("-data-info-line main.cpp:%d" % line)
- self.expect(
- "\^done,start=\"0x0*%x\",end=\"0x[0-9a-f]+\",file=\".+?main.cpp\",line=\"%d\"" %
- (addr, line))
-
- # Test that -data-info-line fails when invalid address is specified
- self.runCmd("-data-info-line *0x0")
- self.expect(
- "\^error,msg=\"Command 'data-info-line'\. Error: The LineEntry is absent or has an unknown format\.\"")
-
- # Test that -data-info-line fails when file is unknown
- self.runCmd("-data-info-line unknown_file:1")
- self.expect(
- "\^error,msg=\"Command 'data-info-line'\. Error: The LineEntry is absent or has an unknown format\.\"")
-
- # Test that -data-info-line fails when line has invalid format
- self.runCmd("-data-info-line main.cpp:bad_line")
- self.expect(
- "\^error,msg=\"error: invalid line number string 'bad_line'")
- self.runCmd("-data-info-line main.cpp:0")
- self.expect("\^error,msg=\"error: zero is an invalid line number")
-
- @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."""
diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/interpreter/TestMiCliSupport.py b/packages/Python/lldbsuite/test/tools/lldb-mi/interpreter/TestMiCliSupport.py
index 7a28f297a1c8..21c08ab74f17 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-mi/interpreter/TestMiCliSupport.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-mi/interpreter/TestMiCliSupport.py
@@ -34,6 +34,26 @@ class MiCliSupportTestCase(lldbmi_testcase.MiTestCaseBase):
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
diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/interpreter/TestMiInterpreterExec.py b/packages/Python/lldbsuite/test/tools/lldb-mi/interpreter/TestMiInterpreterExec.py
index 2f207928db7d..ccd7eba8bfe3 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-mi/interpreter/TestMiInterpreterExec.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-mi/interpreter/TestMiInterpreterExec.py
@@ -36,6 +36,25 @@ class MiInterpreterExecTestCase(lldbmi_testcase.MiTestCaseBase):
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("-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.
@@ -95,53 +114,6 @@ class MiInterpreterExecTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
- @expectedFailureAll(
- oslist=["linux"],
- bugnumber="Failing in ~9/600 dosep runs (build 3120-3122)")
- @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(
- "-interpreter-exec console \"setting set target.run-args arg1 \\\"2nd arg\\\" third_arg fourth=\\\"4th arg\\\"\"")
- self.expect("\^done")
-
- # Run to BP_printf
- line = line_number('main.cpp', '// BP_printf')
- self.runCmd("-break-insert main.cpp:%d" % line)
- self.expect("\^done,bkpt={number=\"1\"")
- self.runCmd("-exec-run")
- self.expect("\^running")
- self.expect("\*stopped,reason=\"breakpoint-hit\"")
-
- # Run to BP_return
- line = line_number('main.cpp', '// BP_return')
- self.runCmd("-break-insert main.cpp:%d" % line)
- self.expect("\^done,bkpt={number=\"2\"")
- self.runCmd("-exec-continue")
- self.expect("\^running")
-
- # Test that arguments were passed properly
- self.expect("@\"argc=5\\\\r\\\\n\"")
- self.expect("@\"argv.0.=.*lldb-mi")
- self.expect("@\"argv.1.=arg1\\\\r\\\\n\"")
- self.expect("@\"argv.2.=2nd arg\\\\r\\\\n\"")
- self.expect("@\"argv.3.=third_arg\\\\r\\\\n\"")
- self.expect("@\"argv.4.=fourth=4th arg\\\\r\\\\n\"")
-
- # Hit BP_return
- self.expect("\*stopped,reason=\"breakpoint-hit\"")
-
- @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
- @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
@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."""
diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/lldbmi_testcase.py b/packages/Python/lldbsuite/test/tools/lldb-mi/lldbmi_testcase.py
index 2226395dcf2e..7b6ee55b250e 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-mi/lldbmi_testcase.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-mi/lldbmi_testcase.py
@@ -11,18 +11,25 @@ from lldbsuite.test.lldbtest import *
class MiTestCaseBase(Base):
mydir = None
- myexe = "a.out"
- mylog = "child.log"
+ myexe = None
+ mylog = None
+ NO_DEBUG_INFO_TESTCASE = True
@classmethod
def classCleanup(cls):
- TestBase.RemoveTempFile(cls.myexe)
- TestBase.RemoveTempFile(cls.mylog)
+ 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():
@@ -36,8 +43,9 @@ class MiTestCaseBase(Base):
def spawnLldbMi(self, args=None):
import pexpect
self.child = pexpect.spawn("%s --interpreter %s" % (
- self.lldbMiExec, args if args else ""))
+ 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)
diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/signal/TestMiSignal.py b/packages/Python/lldbsuite/test/tools/lldb-mi/signal/TestMiSignal.py
index cea5e6f96e9c..13800de634f1 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-mi/signal/TestMiSignal.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-mi/signal/TestMiSignal.py
@@ -89,7 +89,7 @@ class MiSignalTestCase(lldbmi_testcase.MiTestCaseBase):
self.expect("\*stopped,reason=\"breakpoint-hit\"")
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
- @skipUnlessDarwin
+ @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)."""
diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/TestMiStartupOptions.py b/packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/TestMiStartupOptions.py
index 80b925993d31..7c225ab87a3c 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/TestMiStartupOptions.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/TestMiStartupOptions.py
@@ -9,6 +9,7 @@ from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
+import os
class MiStartupOptionsTestCase(lldbmi_testcase.MiTestCaseBase):
@@ -17,6 +18,7 @@ class MiStartupOptionsTestCase(lldbmi_testcase.MiTestCaseBase):
@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_executable_option_file(self):
"""Test that 'lldb-mi --interpreter %s' loads executable file."""
@@ -43,6 +45,7 @@ class MiStartupOptionsTestCase(lldbmi_testcase.MiTestCaseBase):
@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."""
@@ -63,18 +66,16 @@ class MiStartupOptionsTestCase(lldbmi_testcase.MiTestCaseBase):
@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_executable_option_absolute_path(self):
"""Test that 'lldb-mi --interpreter %s' loads executable which is specified via absolute path."""
# Prepare path to executable
- import os
- path = os.path.join(os.getcwd(), self.myexe)
-
- self.spawnLldbMi(args="%s" % path)
+ self.spawnLldbMi(args="%s" % self.myexe)
# Test that the executable is loaded when file was specified using
# absolute path
- self.expect("-file-exec-and-symbols \"%s\"" % path)
+ self.expect("-file-exec-and-symbols \"%s\"" % self.myexe)
self.expect("\^done")
# Test that lldb-mi is ready when executable was loaded
@@ -88,12 +89,12 @@ class MiStartupOptionsTestCase(lldbmi_testcase.MiTestCaseBase):
@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_executable_option_relative_path(self):
"""Test that 'lldb-mi --interpreter %s' loads executable which is specified via relative path."""
# Prepare path to executable
- path = "./%s" % self.myexe
-
+ path = os.path.relpath(self.myexe, self.getBuildDir())
self.spawnLldbMi(args="%s" % path)
# Test that the executable is loaded when file was specified using
@@ -111,11 +112,12 @@ class MiStartupOptionsTestCase(lldbmi_testcase.MiTestCaseBase):
@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/%s" % self.myexe
+ path = "unknown_dir" + self.myexe
self.spawnLldbMi(args="%s" % path)
@@ -129,16 +131,25 @@ class MiStartupOptionsTestCase(lldbmi_testcase.MiTestCaseBase):
# 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
+ @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 = "start_script"
-
+ sourceFile = self.copyScript("start_script")
self.spawnLldbMi(args="--source %s" % sourceFile)
# After '-file-exec-and-symbols a.out'
@@ -171,17 +182,18 @@ class MiStartupOptionsTestCase(lldbmi_testcase.MiTestCaseBase):
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
+ @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 = "start_script_exit"
-
+ sourceFile = self.copyScript("start_script_exit")
self.spawnLldbMi(args="--source %s" % sourceFile)
# After '-file-exec-and-symbols a.out'
@@ -215,15 +227,16 @@ class MiStartupOptionsTestCase(lldbmi_testcase.MiTestCaseBase):
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 = "start_script_error"
-
+ sourceFile = self.copyScript("start_script_error")
self.spawnLldbMi(args="--source %s" % sourceFile)
# After '-file-exec-and-symbols a.out'
@@ -236,14 +249,16 @@ class MiStartupOptionsTestCase(lldbmi_testcase.MiTestCaseBase):
# 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
def test_lldbmi_log_option(self):
"""Test that 'lldb-mi --log' creates a log file in the current directory."""
- logDirectory = "."
+ logDirectory = self.getBuildDir()
self.spawnLldbMi(args="%s --log" % self.myexe)
# Test that the executable is loaded when file was specified
@@ -273,6 +288,7 @@ class MiStartupOptionsTestCase(lldbmi_testcase.MiTestCaseBase):
@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_log_directory_option(self):
"""Test that 'lldb-mi --log --log-dir' creates a log file in the directory specified by --log-dir."""
diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/symbol/Makefile b/packages/Python/lldbsuite/test/tools/lldb-mi/symbol/Makefile
deleted file mode 100644
index dde38f4e486c..000000000000
--- a/packages/Python/lldbsuite/test/tools/lldb-mi/symbol/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
-LEVEL = ../../../make
-
-CXX_SOURCES := main.cpp symbol_list_lines_inline_test.cpp symbol_list_lines_inline_test2.cpp
-
-include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/symbol/TestMiSymbol.py b/packages/Python/lldbsuite/test/tools/lldb-mi/symbol/TestMiSymbol.py
deleted file mode 100644
index 6ac9bf813563..000000000000
--- a/packages/Python/lldbsuite/test/tools/lldb-mi/symbol/TestMiSymbol.py
+++ /dev/null
@@ -1,104 +0,0 @@
-"""
-Test lldb-mi -symbol-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 MiSymbolTestCase(lldbmi_testcase.MiTestCaseBase):
-
- mydir = TestBase.compute_mydir(__file__)
-
- @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
- @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
- @skipIfRemote # We do not currently support remote debugging via the MI.
- @expectedFailureAll(
- oslist=["linux"],
- bugnumber="new failure after r256863")
- def test_lldbmi_symbol_list_lines_file(self):
- """Test that 'lldb-mi --interpreter' works for -symbol-list-lines when file exists."""
-
- self.spawnLldbMi(args=None)
-
- # Load executable
- self.runCmd("-file-exec-and-symbols %s" % self.myexe)
- self.expect("\^done")
-
- # Run to main
- self.runCmd("-break-insert -f main")
- self.expect("\^done,bkpt={number=\"1\"")
- self.runCmd("-exec-run")
- self.expect("\^running")
- self.expect("\*stopped,reason=\"breakpoint-hit\"")
-
- # Get address of main and its line
- self.runCmd("-data-evaluate-expression main")
- self.expect(
- "\^done,value=\"0x[0-9a-f]+ \(a.out`main at main.cpp:[0-9]+\)\"")
- addr = int(self.child.after.split("\"")[1].split(" ")[0], 16)
- line = line_number('main.cpp', '// FUNC_main')
-
- # Test that -symbol-list-lines works on valid data
- self.runCmd("-symbol-list-lines main.cpp")
- self.expect(
- "\^done,lines=\[\{pc=\"0x0*%x\",line=\"%d\"\}(,\{pc=\"0x[0-9a-f]+\",line=\"\d+\"\})+\]" %
- (addr, line))
-
- # Test that -symbol-list-lines doesn't include lines from other sources
- # by checking the first and last line, and making sure the other lines
- # are between 30 and 39.
- sline = line_number(
- 'symbol_list_lines_inline_test2.cpp',
- '// FUNC_gfunc2')
- eline = line_number(
- 'symbol_list_lines_inline_test2.cpp',
- '// END_gfunc2')
- self.runCmd("-symbol-list-lines symbol_list_lines_inline_test2.cpp")
- self.expect(
- "\^done,lines=\[\{pc=\"0x[0-9a-f]+\",line=\"%d\"\}(,\{pc=\"0x[0-9a-f]+\",line=\"3\d\"\})*,\{pc=\"0x[0-9a-f]+\",line=\"%d\"\}(,\{pc=\"0x[0-9a-f]+\",line=\"3\d\"\})*\]" %
- (sline, eline))
- # FIXME: This doesn't work for symbol_list_lines_inline_test.cpp due to clang bug llvm.org/pr24716 (fixed in newer versions of clang)
- ##sline = line_number('symbol_list_lines_inline_test.cpp', '// FUNC_gfunc')
- ##eline = line_number('symbol_list_lines_inline_test.cpp', '// STRUCT_s')
- ##self.runCmd("-symbol-list-lines symbol_list_lines_inline_test.cpp")
- ##self.expect("\^done,lines=\[\{pc=\"0x[0-9a-f]+\",line=\"%d\"\}(,\{pc=\"0x[0-9a-f]+\",line=\"3\d\"\})*,\{pc=\"0x[0-9a-f]+\",line=\"%d\"\}\]" % (sline, eline))
-
- # Test that -symbol-list-lines works on header files by checking the first
- # and last line, and making sure the other lines are under 29.
- sline = line_number('symbol_list_lines_inline_test.h', '// FUNC_ifunc')
- eline = line_number('symbol_list_lines_inline_test.h', '// FUNC_mfunc')
- self.runCmd("-symbol-list-lines symbol_list_lines_inline_test.h")
- self.expect(
- "\^done,lines=\[\{pc=\"0x[0-9a-f]+\",line=\"%d\"\}(,\{pc=\"0x[0-9a-f]+\",line=\"\d\"\})*(,\{pc=\"0x[0-9a-f]+\",line=\"1\d\"\})*,\{pc=\"0x[0-9a-f]+\",line=\"%d\"\}(,\{pc=\"0x[0-9a-f]+\",line=\"2\d\"\})*\]" %
- (sline, eline))
-
- # Test that -symbol-list-lines fails when file doesn't exist
- self.runCmd("-symbol-list-lines unknown_file")
- self.expect(
- "\^error,message=\"error: No source filenames matched 'unknown_file'\. \"")
-
- # Test that -symbol-list-lines fails when file is specified using
- # relative path
- self.runCmd("-symbol-list-lines ./main.cpp")
- self.expect(
- "\^error,message=\"error: No source filenames matched '\./main\.cpp'\. \"")
-
- # Test that -symbol-list-lines works when file is specified using
- # absolute path
- import os
- path = os.path.join(os.getcwd(), "main.cpp")
- self.runCmd("-symbol-list-lines \"%s\"" % path)
- self.expect(
- "\^done,lines=\[\{pc=\"0x0*%x\",line=\"%d\"\}(,\{pc=\"0x[0-9a-f]+\",line=\"\d+\"\})+\]" %
- (addr, line))
-
- # Test that -symbol-list-lines fails when file doesn't exist
- self.runCmd("-symbol-list-lines unknown_dir/main.cpp")
- self.expect(
- "\^error,message=\"error: No source filenames matched 'unknown_dir/main\.cpp'\. \"")
diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/symbol/main.cpp b/packages/Python/lldbsuite/test/tools/lldb-mi/symbol/main.cpp
deleted file mode 100644
index 6d725a5759b5..000000000000
--- a/packages/Python/lldbsuite/test/tools/lldb-mi/symbol/main.cpp
+++ /dev/null
@@ -1,18 +0,0 @@
-//===-- main.cpp ------------------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-extern int j;
-extern int gfunc(int i);
-extern int gfunc2(int i);
-int
-main()
-{ // FUNC_main
- int i = gfunc(j) + gfunc2(j);
- return i == 0;
-}
diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/symbol/symbol_list_lines_inline_test.cpp b/packages/Python/lldbsuite/test/tools/lldb-mi/symbol/symbol_list_lines_inline_test.cpp
deleted file mode 100644
index c432ba8c477c..000000000000
--- a/packages/Python/lldbsuite/test/tools/lldb-mi/symbol/symbol_list_lines_inline_test.cpp
+++ /dev/null
@@ -1,39 +0,0 @@
-// Skip lines so we can make sure we're not seeing any lines from
-// symbol_list_lines_inline_test.h included in -symbol-list-lines
-// symbol_list_lines_inline_test.cpp, by checking that all the lines
-// are between 30 and 39.
-// line 5
-// line 6
-// line 7
-// line 8
-// line 9
-// line 10
-// line 11
-// line 12
-// line 13
-// line 14
-// line 15
-// line 16
-// line 17
-// line 18
-// line 19
-// line 20
-// line 21
-// line 22
-// line 23
-// line 24
-// line 25
-// line 26
-// line 27
-// line 28
-// line 29
-#include "symbol_list_lines_inline_test.h"
-int
-gfunc(int i)
-{ // FUNC_gfunc
- return ns::ifunc(i);
-}
-namespace ns
-{
-S s; // STRUCT_s
-}
diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/symbol/symbol_list_lines_inline_test.h b/packages/Python/lldbsuite/test/tools/lldb-mi/symbol/symbol_list_lines_inline_test.h
deleted file mode 100644
index 4b986dc69321..000000000000
--- a/packages/Python/lldbsuite/test/tools/lldb-mi/symbol/symbol_list_lines_inline_test.h
+++ /dev/null
@@ -1,24 +0,0 @@
-namespace ns
-{
-inline int
-ifunc(int i)
-{ // FUNC_ifunc
- return i;
-}
-struct S
-{
- int a;
- int b;
- S()
- : a(3)
- , b(4)
- {
- }
- int
- mfunc()
- { // FUNC_mfunc
- return a + b;
- }
-};
-extern S s;
-}
diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/symbol/symbol_list_lines_inline_test2.cpp b/packages/Python/lldbsuite/test/tools/lldb-mi/symbol/symbol_list_lines_inline_test2.cpp
deleted file mode 100644
index cfedf47ad6b1..000000000000
--- a/packages/Python/lldbsuite/test/tools/lldb-mi/symbol/symbol_list_lines_inline_test2.cpp
+++ /dev/null
@@ -1,38 +0,0 @@
-// Skip lines so we can make sure we're not seeing any lines from
-// symbol_list_lines_inline_test.h included in -symbol-list-lines
-// symbol_list_lines_inline_test2.cpp, by checking that all the lines
-// are between 30 and 39.
-// line 5
-// line 6
-// line 7
-// line 8
-// line 9
-// line 10
-// line 11
-// line 12
-// line 13
-// line 14
-// line 15
-// line 16
-// line 17
-// line 18
-// line 19
-// line 20
-// line 21
-// line 22
-// line 23
-// line 24
-// line 25
-// line 26
-// line 27
-// line 28
-// line 29
-#include "symbol_list_lines_inline_test.h"
-int j = 2;
-int
-gfunc2(int i)
-{ // FUNC_gfunc2
- i += ns::s.mfunc();
- i += ns::ifunc(i);
- return i == 0; // END_gfunc2
-}
diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/syntax/TestMiSyntax.py b/packages/Python/lldbsuite/test/tools/lldb-mi/syntax/TestMiSyntax.py
index 93f599317c6c..50a94b53a18b 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-mi/syntax/TestMiSyntax.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-mi/syntax/TestMiSyntax.py
@@ -19,6 +19,7 @@ class MiSyntaxTestCase(lldbmi_testcase.MiTestCaseBase):
@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_tokens(self):
"""Test that 'lldb-mi --interpreter' prints command tokens."""
@@ -43,11 +44,12 @@ class MiSyntaxTestCase(lldbmi_testcase.MiTestCaseBase):
@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 = "C--mpl-x file's`s @#$%^&*()_+-={}[]| name"
+ complicated_myexe = self.getBuildArtifact("C--mpl-x file's`s @#$%^&*()_+-={}[]| name")
os.symlink(self.myexe, complicated_myexe)
self.addTearDownHook(lambda: os.unlink(complicated_myexe))
@@ -68,31 +70,8 @@ class MiSyntaxTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfDarwin
@skipIfRemote # We do not currently support remote debugging via the MI.
- @expectedFailureAll(
- oslist=["linux"],
- bugnumber="Failing in ~6/600 dosep runs (build 3120-3122)")
- def test_lldbmi_process_output(self):
- """Test that 'lldb-mi --interpreter' wraps process output correctly."""
-
- self.spawnLldbMi(args=None)
-
- # Load executable
- self.runCmd("-file-exec-and-symbols %s" % self.myexe)
- self.expect("\^done")
-
- # Run
- self.runCmd("-exec-run")
- self.expect("\^running")
-
- # Test that a process output is wrapped correctly
- self.expect("\@\"'\\\\r\\\\n\"")
- self.expect("\@\"` - it's \\\\\\\\n\\\\x12\\\\\"\\\\\\\\\\\\\"")
-
- @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.
- @expectedFailureAll(oslist=["macosx"], bugnumber="rdar://28805064")
def test_lldbmi_output_grammar(self):
"""Test that 'lldb-mi --interpreter' uses standard output syntax."""
diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/target/TestMiTarget.py b/packages/Python/lldbsuite/test/tools/lldb-mi/target/TestMiTarget.py
index 137408a2bd2b..db6f9b2a820a 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-mi/target/TestMiTarget.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-mi/target/TestMiTarget.py
@@ -18,6 +18,7 @@ class MiTargetTestCase(lldbmi_testcase.MiTestCaseBase):
@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
def test_lldbmi_target_attach_wait_for(self):
"""Test that 'lldb-mi --interpreter' works for -target-attach -n <name> --waitfor."""
@@ -32,7 +33,7 @@ class MiTargetTestCase(lldbmi_testcase.MiTestCaseBase):
# Load executable
# FIXME: -file-exec-and-sybmols is not required for target attach, but
# the test will not pass without this
- self.runCmd("-file-exec-and-symbols %s" % exeName)
+ self.runCmd("-file-exec-and-symbols %s" % self.getBuildArtifact(exeName))
self.expect("\^done")
# Set up attach
@@ -40,7 +41,7 @@ class MiTargetTestCase(lldbmi_testcase.MiTestCaseBase):
time.sleep(4) # Give attach time to setup
# Start target process
- self.spawnSubprocess(os.path.join(os.path.dirname(__file__), exeName))
+ self.spawnSubprocess(self.getBuildArtifact(exeName))
self.addTearDownHook(self.cleanupSubprocesses)
self.expect("\^done")
@@ -61,6 +62,7 @@ class MiTargetTestCase(lldbmi_testcase.MiTestCaseBase):
@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
def test_lldbmi_target_attach_name(self):
"""Test that 'lldb-mi --interpreter' works for -target-attach -n <name>."""
@@ -71,8 +73,7 @@ class MiTargetTestCase(lldbmi_testcase.MiTestCaseBase):
self.addTearDownCleanup(dictionary=d)
# Start target process
- targetProcess = self.spawnSubprocess(
- os.path.join(os.path.dirname(__file__), exeName))
+ targetProcess = self.spawnSubprocess(self.getBuildArtifact(exeName))
self.addTearDownHook(self.cleanupSubprocesses)
self.spawnLldbMi(args=None)
@@ -98,6 +99,7 @@ class MiTargetTestCase(lldbmi_testcase.MiTestCaseBase):
@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
def test_lldbmi_target_attach_pid(self):
"""Test that 'lldb-mi --interpreter' works for -target-attach <pid>."""
@@ -109,7 +111,7 @@ class MiTargetTestCase(lldbmi_testcase.MiTestCaseBase):
# Start target process
targetProcess = self.spawnSubprocess(
- os.path.join(os.path.dirname(__file__), exeName))
+ self.getBuildArtifact(exeName))
self.addTearDownHook(self.cleanupSubprocesses)
self.spawnLldbMi(args=None)
diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/variable/TestMiGdbSetShowPrint.py b/packages/Python/lldbsuite/test/tools/lldb-mi/variable/TestMiGdbSetShowPrint.py
index 4384c79fc845..cf1da5bae9ce 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-mi/variable/TestMiGdbSetShowPrint.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-mi/variable/TestMiGdbSetShowPrint.py
@@ -175,81 +175,6 @@ class MiGdbSetShowTestCase(lldbmi_testcase.MiTestCaseBase):
@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_expand_aggregates(self):
- """Test that 'lldb-mi --interpreter' can expand aggregates everywhere."""
-
- self.spawnLldbMi(args=None)
-
- # Load executable
- self.runCmd("-file-exec-and-symbols %s" % self.myexe)
- self.expect("\^done")
-
- # Run to BP_gdb_set_show_print_expand_aggregates
- line = line_number(
- 'main.cpp',
- '// BP_gdb_set_show_print_expand_aggregates')
- self.runCmd("-break-insert main.cpp:%d" % line)
- self.expect("\^done,bkpt={number=\"1\"")
- self.runCmd("-exec-run")
- self.expect("\^running")
- self.expect("\*stopped,reason=\"breakpoint-hit\"")
-
- # Test that default print expand-aggregates value is "off"
- self.runCmd("-gdb-show print expand-aggregates")
- self.expect("\^done,value=\"off\"")
-
- # Test that composite type isn't expanded when print expand-aggregates
- # is "off"
- self.runCmd("-var-create var1 * complx")
- self.expect(
- "\^done,name=\"var1\",numchild=\"3\",value=\"{\.\.\.}\",type=\"complex_type\",thread-id=\"1\",has_more=\"0\"")
-
- # Test that composite type[] isn't expanded when print
- # expand-aggregates is "off"
- self.eval_and_check_array("complx_array", "complex_type", 2)
-
- # Test that a struct with a char first element is not formatted as a
- # string
- self.runCmd("-var-create - * &nstr")
- self.expect(
- "\^done,name=\"var\d+\",numchild=\"2\",value=\"0x[0-9a-f]+\",type=\"not_str \*\",thread-id=\"1\",has_more=\"0\"")
-
- # Test that -gdb-set can set print expand-aggregates flag
- self.runCmd("-gdb-set print expand-aggregates on")
- self.expect("\^done")
- self.runCmd("-gdb-set print expand-aggregates 1")
- self.expect("\^done")
- self.runCmd("-gdb-show print expand-aggregates")
- self.expect("\^done,value=\"on\"")
-
- # Test that composite type is expanded when print expand-aggregates is
- # "on"
- self.runCmd("-var-create var3 * complx")
- self.expect(
- "\^done,name=\"var3\",numchild=\"3\",value=\"{i = 3, inner = {l = 3}, complex_ptr = 0x[0-9a-f]+}\",type=\"complex_type\",thread-id=\"1\",has_more=\"0\"")
-
- # Test that composite type[] is expanded when print expand-aggregates
- # is "on"
- self.runCmd("-var-create var4 * complx_array")
- self.expect(
- "\^done,name=\"var4\",numchild=\"2\",value=\"{\[0\] = {i = 4, inner = {l = 4}, complex_ptr = 0x[0-9a-f]+}, \[1\] = {i = 5, inner = {l = 5}, complex_ptr = 0x[0-9a-f]+}}\",type=\"complex_type \[2\]\",thread-id=\"1\",has_more=\"0\"")
-
- # Test that -gdb-set print expand-aggregates fails if "on"/"off" isn't
- # specified
- self.runCmd("-gdb-set print expand-aggregates")
- self.expect(
- "\^error,msg=\"The request ''print' expects option-name and \"on\" or \"off\"' failed.\"")
-
- # Test that -gdb-set print expand-aggregates fails when option is
- # unknown
- self.runCmd("-gdb-set print expand-aggregates unknown")
- self.expect(
- "\^error,msg=\"The request ''print' expects option-name and \"on\" or \"off\"' failed.\"")
-
- @skipIfWindows # llvm.org/pr24452: Get lldb-mi working on Windows
- @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."""
diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/variable/TestMiVar.py b/packages/Python/lldbsuite/test/tools/lldb-mi/variable/TestMiVar.py
index 6155858cf112..5ef7d11b8ac0 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-mi/variable/TestMiVar.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-mi/variable/TestMiVar.py
@@ -18,6 +18,7 @@ class MiVarTestCase(lldbmi_testcase.MiTestCaseBase):
@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."""
@@ -159,7 +160,7 @@ class MiVarTestCase(lldbmi_testcase.MiTestCaseBase):
@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 # rdar://33462982
+ @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."""
@@ -231,6 +232,7 @@ class MiVarTestCase(lldbmi_testcase.MiTestCaseBase):
@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."""
@@ -275,6 +277,7 @@ class MiVarTestCase(lldbmi_testcase.MiTestCaseBase):
@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."""
@@ -395,6 +398,7 @@ class MiVarTestCase(lldbmi_testcase.MiTestCaseBase):
@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."""
@@ -421,6 +425,7 @@ class MiVarTestCase(lldbmi_testcase.MiTestCaseBase):
@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."""
diff --git a/packages/Python/lldbsuite/test/tools/lldb-server/TestAppleSimulatorOSType.py b/packages/Python/lldbsuite/test/tools/lldb-server/TestAppleSimulatorOSType.py
new file mode 100644
index 000000000000..8c8fed8e44e0
--- /dev/null
+++ b/packages/Python/lldbsuite/test/tools/lldb-server/TestAppleSimulatorOSType.py
@@ -0,0 +1,112 @@
+from __future__ import print_function
+
+
+import gdbremote_testcase
+import lldbgdbserverutils
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+import json
+
+class TestAppleSimulatorOSType(gdbremote_testcase.GdbRemoteTestCaseBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def check_simulator_ostype(self, sdk, platform, arch='x86_64'):
+ sim_devices_str = subprocess.check_output(['xcrun', 'simctl', 'list',
+ '-j', 'devices'])
+ sim_devices = json.loads(sim_devices_str)['devices']
+ # Find an available simulator for the requested platform
+ deviceUDID = None
+ for (runtime,devices) in sim_devices.items():
+ if not platform in runtime.lower():
+ continue
+ for device in devices:
+ if device['availability'] != '(available)':
+ continue
+ deviceUDID = device['udid']
+ break
+ if deviceUDID != None:
+ break
+
+ # Launch the process using simctl
+ self.assertIsNotNone(deviceUDID)
+ exe_name = 'test_simulator_platform_{}'.format(platform)
+ sdkroot = subprocess.check_output(['xcrun', '--show-sdk-path', '--sdk',
+ sdk])
+ self.build(dictionary={ 'EXE': exe_name, 'SDKROOT': sdkroot.strip(),
+ 'ARCH': arch })
+ exe_path = self.getBuildArtifact(exe_name)
+ sim_launcher = subprocess.Popen(['xcrun', 'simctl', 'spawn',
+ deviceUDID, exe_path,
+ 'print-pid', 'sleep:10'],
+ stderr=subprocess.PIPE)
+ # Get the PID from the process output
+ pid = None
+ while not pid:
+ stderr = sim_launcher.stderr.readline()
+ if stderr == '':
+ continue
+ m = re.match(r"PID: (.*)", stderr)
+ self.assertIsNotNone(m)
+ pid = int(m.group(1))
+
+ # Launch debug monitor attaching to the simulated process
+ self.init_debugserver_test()
+ server = self.connect_to_debug_monitor(attach_pid=pid)
+
+ # Setup packet sequences
+ self.add_no_ack_remote_stream()
+ self.add_process_info_collection_packets()
+ self.test_sequence.add_log_lines(
+ ["read packet: " +
+ "$jGetLoadedDynamicLibrariesInfos:{\"fetch_all_solibs\" : true}]#ce",
+ {"direction": "send", "regex": r"^\$(.+)#[0-9a-fA-F]{2}$",
+ "capture": {1: "dylib_info_raw"}}],
+ True)
+
+ # Run the stream
+ context = self.expect_gdbremote_sequence()
+ self.assertIsNotNone(context)
+
+ # Gather process info response
+ process_info = self.parse_process_info_response(context)
+ self.assertIsNotNone(process_info)
+
+ # Check that ostype is correct
+ self.assertEquals(process_info['ostype'], platform)
+
+ # Now for dylibs
+ dylib_info_raw = context.get("dylib_info_raw")
+ dylib_info = json.loads(self.decode_gdbremote_binary(dylib_info_raw))
+ images = dylib_info['images']
+
+ image_info = None
+ for image in images:
+ if image['pathname'] != exe_path:
+ continue
+ image_info = image
+ break
+
+ self.assertIsNotNone(image_info)
+ self.assertEquals(image['min_version_os_name'], platform)
+
+
+ @apple_simulator_test('iphone')
+ @debugserver_test
+ def test_simulator_ostype_ios(self):
+ self.check_simulator_ostype(sdk='iphonesimulator',
+ platform='ios')
+
+ @apple_simulator_test('appletv')
+ @debugserver_test
+ def test_simulator_ostype_tvos(self):
+ self.check_simulator_ostype(sdk='appletvsimulator',
+ platform='tvos')
+
+ @apple_simulator_test('watch')
+ @debugserver_test
+ def test_simulator_ostype_watchos(self):
+ self.check_simulator_ostype(sdk='watchsimulator',
+ platform='watchos', arch='i386')
diff --git a/packages/Python/lldbsuite/test/tools/lldb-server/exit-code/TestGdbRemoteExitCode.py b/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteExitCode.py
index 5ef4249bd241..5ef4249bd241 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-server/exit-code/TestGdbRemoteExitCode.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteExitCode.py
diff --git a/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteExpeditedRegisters.py b/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteExpeditedRegisters.py
index 94e81963483a..7d8e28c745c9 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteExpeditedRegisters.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteExpeditedRegisters.py
@@ -125,6 +125,8 @@ class TestGdbRemoteExpeditedRegisters(
self.set_inferior_startup_launch()
self.stop_notification_contains_pc_register()
+ # powerpc64 has no FP register
+ @skipIf(triple='^powerpc64')
def stop_notification_contains_fp_register(self):
self.stop_notification_contains_generic_register("fp")
diff --git a/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteGPacket.py b/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteGPacket.py
new file mode 100644
index 000000000000..76910758fa91
--- /dev/null
+++ b/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteGPacket.py
@@ -0,0 +1,40 @@
+from __future__ import print_function
+
+
+import gdbremote_testcase
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestGdbRemoteGPacket(gdbremote_testcase.GdbRemoteTestCaseBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def run_test_g_packet(self):
+ self.build()
+ self.prep_debug_monitor_and_inferior()
+ self.test_sequence.add_log_lines(
+ ["read packet: $g#67",
+ {"direction": "send", "regex": r"^\$(.+)#[0-9a-fA-F]{2}$",
+ "capture": {1: "register_bank"}}],
+ True)
+ self.connect_to_debug_monitor()
+ context = self.expect_gdbremote_sequence()
+ register_bank = context.get("register_bank")
+ self.assertTrue(register_bank[0] != 'E')
+
+ self.test_sequence.add_log_lines(
+ ["read packet: $G" + register_bank + "#00",
+ {"direction": "send", "regex": r"^\$(.+)#[0-9a-fA-F]{2}$",
+ "capture": {1: "G_reply"}}],
+ True)
+ context = self.expect_gdbremote_sequence()
+ self.assertTrue(context.get("G_reply")[0] != 'E')
+
+
+ @skipIfOutOfTreeDebugserver
+ @debugserver_test
+ def test_g_packet_debugserver(self):
+ self.init_debugserver_test()
+ self.run_test_g_packet()
diff --git a/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteModuleInfo.py b/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteModuleInfo.py
index cab8a9cedfa0..41205302f3bc 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteModuleInfo.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteModuleInfo.py
@@ -20,7 +20,7 @@ class TestGdbRemoteModuleInfo(gdbremote_testcase.GdbRemoteTestCaseBase):
self.test_sequence.add_log_lines([
'read packet: $jModulesInfo:[{"file":"%s","triple":"%s"}]]#00' % (
- lldbutil.append_to_process_working_directory("a.out"),
+ lldbutil.append_to_process_working_directory(self, "a.out"),
info["triple"].decode('hex')),
{"direction": "send",
"regex": r'^\$\[{(.*)}\]\]#[0-9A-Fa-f]{2}',
diff --git a/packages/Python/lldbsuite/test/tools/lldb-server/TestLldbGdbServer.py b/packages/Python/lldbsuite/test/tools/lldb-server/TestLldbGdbServer.py
index a4f306efdc98..82e76ca125bb 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-server/TestLldbGdbServer.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-server/TestLldbGdbServer.py
@@ -261,7 +261,6 @@ class LldbGdbServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase, DwarfOpcod
lldbgdbserverutils.parse_reg_info_response(reg_info_packet))
@debugserver_test
- @expectedFailureDarwin("llvm.org/pr25486")
@skipIfDarwinEmbedded # <rdar://problem/34539270> lldb-server tests not updated to work on ios etc yet
def test_qRegisterInfo_returns_one_valid_result_debugserver(self):
self.init_debugserver_test()
@@ -294,7 +293,6 @@ class LldbGdbServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase, DwarfOpcod
self.assert_valid_reg_info(reg_info)
@debugserver_test
- @expectedFailureDarwin("llvm.org/pr25486")
@skipIfDarwinEmbedded # <rdar://problem/34539270> lldb-server tests not updated to work on ios etc yet
def test_qRegisterInfo_returns_all_valid_results_debugserver(self):
self.init_debugserver_test()
@@ -332,8 +330,9 @@ class LldbGdbServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase, DwarfOpcod
# Ensure we have a program counter register.
self.assertTrue('pc' in generic_regs)
- # Ensure we have a frame pointer register.
- self.assertTrue('fp' in generic_regs)
+ # Ensure we have a frame pointer register. PPC64le's FP is the same as SP
+ if self.getArchitecture() != 'powerpc64le':
+ self.assertTrue('fp' in generic_regs)
# Ensure we have a stack pointer register.
self.assertTrue('sp' in generic_regs)
@@ -558,7 +557,7 @@ class LldbGdbServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase, DwarfOpcod
self.assertIsNotNone(reg_infos)
self.assertTrue(len(reg_infos) > 0)
- inferior_exe_path = os.path.abspath("a.out")
+ inferior_exe_path = self.getBuildArtifact("a.out")
Target = self.dbg.CreateTarget(inferior_exe_path)
byte_order = Target.GetByteOrder()
diff --git a/packages/Python/lldbsuite/test/tools/lldb-server/exit-code/Makefile b/packages/Python/lldbsuite/test/tools/lldb-server/exit-code/Makefile
deleted file mode 100644
index 6ff66a3ab5d9..000000000000
--- a/packages/Python/lldbsuite/test/tools/lldb-server/exit-code/Makefile
+++ /dev/null
@@ -1,8 +0,0 @@
-LEVEL = ../../../make
-
-override CFLAGS_EXTRAS += -D__STDC_LIMIT_MACROS -D__STDC_FORMAT_MACROS
-ENABLE_THREADS := YES
-CXX_SOURCES := main.cpp
-MAKE_DSYM :=NO
-
-include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/tools/lldb-server/exit-code/main.cpp b/packages/Python/lldbsuite/test/tools/lldb-server/exit-code/main.cpp
deleted file mode 100644
index a3691a8d42b9..000000000000
--- a/packages/Python/lldbsuite/test/tools/lldb-server/exit-code/main.cpp
+++ /dev/null
@@ -1,355 +0,0 @@
-#include <cstdlib>
-#include <cstring>
-#include <errno.h>
-#include <inttypes.h>
-#include <memory>
-#include <pthread.h>
-#include <setjmp.h>
-#include <signal.h>
-#include <stdint.h>
-#include <stdio.h>
-#include <string.h>
-#include <time.h>
-#include <unistd.h>
-#include <vector>
-
-#if defined(__APPLE__)
-__OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2)
-int pthread_threadid_np(pthread_t, __uint64_t *);
-#elif defined(__linux__)
-#include <sys/syscall.h>
-#elif defined(__NetBSD__)
-#include <lwp.h>
-#endif
-
-static const char *const RETVAL_PREFIX = "retval:";
-static const char *const SLEEP_PREFIX = "sleep:";
-static const char *const STDERR_PREFIX = "stderr:";
-static const char *const SET_MESSAGE_PREFIX = "set-message:";
-static const char *const PRINT_MESSAGE_COMMAND = "print-message:";
-static const char *const GET_DATA_ADDRESS_PREFIX = "get-data-address-hex:";
-static const char *const GET_STACK_ADDRESS_COMMAND = "get-stack-address-hex:";
-static const char *const GET_HEAP_ADDRESS_COMMAND = "get-heap-address-hex:";
-
-static const char *const GET_CODE_ADDRESS_PREFIX = "get-code-address-hex:";
-static const char *const CALL_FUNCTION_PREFIX = "call-function:";
-
-static const char *const THREAD_PREFIX = "thread:";
-static const char *const THREAD_COMMAND_NEW = "new";
-static const char *const THREAD_COMMAND_PRINT_IDS = "print-ids";
-static const char *const THREAD_COMMAND_SEGFAULT = "segfault";
-
-static bool g_print_thread_ids = false;
-static pthread_mutex_t g_print_mutex = PTHREAD_MUTEX_INITIALIZER;
-static bool g_threads_do_segfault = false;
-
-static pthread_mutex_t g_jump_buffer_mutex = PTHREAD_MUTEX_INITIALIZER;
-static jmp_buf g_jump_buffer;
-static bool g_is_segfaulting = false;
-
-static char g_message[256];
-
-static volatile char g_c1 = '0';
-static volatile char g_c2 = '1';
-
-static void print_thread_id() {
-// Put in the right magic here for your platform to spit out the thread id (tid)
-// that debugserver/lldb-gdbserver would see as a TID. Otherwise, let the else
-// clause print out the unsupported text so that the unit test knows to skip
-// verifying thread ids.
-#if defined(__APPLE__)
- __uint64_t tid = 0;
- pthread_threadid_np(pthread_self(), &tid);
- printf("%" PRIx64, tid);
-#elif defined(__linux__)
- // This is a call to gettid() via syscall.
- printf("%" PRIx64, static_cast<uint64_t>(syscall(__NR_gettid)));
-#elif defined(__NetBSD__)
- // Technically lwpid_t is 32-bit signed integer
- printf("%" PRIx64, static_cast<uint64_t>(_lwp_self()));
-#else
- printf("{no-tid-support}");
-#endif
-}
-
-static void signal_handler(int signo) {
- const char *signal_name = nullptr;
- switch (signo) {
- case SIGUSR1:
- signal_name = "SIGUSR1";
- break;
- case SIGSEGV:
- signal_name = "SIGSEGV";
- break;
- default:
- signal_name = nullptr;
- }
-
- // Print notice that we received the signal on a given thread.
- pthread_mutex_lock(&g_print_mutex);
- if (signal_name)
- printf("received %s on thread id: ", signal_name);
- else
- printf("received signo %d (%s) on thread id: ", signo, strsignal(signo));
- print_thread_id();
- printf("\n");
- pthread_mutex_unlock(&g_print_mutex);
-
- // Reset the signal handler if we're one of the expected signal handlers.
- switch (signo) {
- case SIGSEGV:
- if (g_is_segfaulting) {
- // Fix up the pointer we're writing to. This needs to happen if nothing
- // intercepts the SIGSEGV (i.e. if somebody runs this from the command
- // line).
- longjmp(g_jump_buffer, 1);
- }
- break;
- case SIGUSR1:
- if (g_is_segfaulting) {
- // Fix up the pointer we're writing to. This is used to test gdb remote
- // signal delivery. A SIGSEGV will be raised when the thread is created,
- // switched out for a SIGUSR1, and then this code still needs to fix the
- // seg fault. (i.e. if somebody runs this from the command line).
- longjmp(g_jump_buffer, 1);
- }
- break;
- }
-
- // Reset the signal handler.
- sig_t sig_result = signal(signo, signal_handler);
- if (sig_result == SIG_ERR) {
- fprintf(stderr, "failed to set signal handler: errno=%d\n", errno);
- exit(1);
- }
-}
-
-static void swap_chars() {
- g_c1 = '1';
- g_c2 = '0';
-
- g_c1 = '0';
- g_c2 = '1';
-}
-
-static void hello() {
- pthread_mutex_lock(&g_print_mutex);
- printf("hello, world\n");
- pthread_mutex_unlock(&g_print_mutex);
-}
-
-static void *thread_func(void *arg) {
- static pthread_mutex_t s_thread_index_mutex = PTHREAD_MUTEX_INITIALIZER;
- static int s_thread_index = 1;
-
- pthread_mutex_lock(&s_thread_index_mutex);
- const int this_thread_index = s_thread_index++;
- pthread_mutex_unlock(&s_thread_index_mutex);
-
- if (g_print_thread_ids) {
- pthread_mutex_lock(&g_print_mutex);
- printf("thread %d id: ", this_thread_index);
- print_thread_id();
- printf("\n");
- pthread_mutex_unlock(&g_print_mutex);
- }
-
- if (g_threads_do_segfault) {
- // Sleep for a number of seconds based on the thread index.
- // TODO add ability to send commands to test exe so we can
- // handle timing more precisely. This is clunky. All we're
- // trying to do is add predictability as to the timing of
- // signal generation by created threads.
- int sleep_seconds = 2 * (this_thread_index - 1);
- while (sleep_seconds > 0)
- sleep_seconds = sleep(sleep_seconds);
-
- // Test creating a SEGV.
- pthread_mutex_lock(&g_jump_buffer_mutex);
- g_is_segfaulting = true;
- int *bad_p = nullptr;
- if (setjmp(g_jump_buffer) == 0) {
- // Force a seg fault signal on this thread.
- *bad_p = 0;
- } else {
- // Tell the system we're no longer seg faulting.
- // Used by the SIGUSR1 signal handler that we inject
- // in place of the SIGSEGV so it only tries to
- // recover from the SIGSEGV if this seg fault code
- // was in play.
- g_is_segfaulting = false;
- }
- pthread_mutex_unlock(&g_jump_buffer_mutex);
-
- pthread_mutex_lock(&g_print_mutex);
- printf("thread ");
- print_thread_id();
- printf(": past SIGSEGV\n");
- pthread_mutex_unlock(&g_print_mutex);
- }
-
- int sleep_seconds_remaining = 60;
- while (sleep_seconds_remaining > 0) {
- sleep_seconds_remaining = sleep(sleep_seconds_remaining);
- }
-
- return nullptr;
-}
-
-int main(int argc, char **argv) {
- lldb_enable_attach();
-
- std::vector<pthread_t> threads;
- std::unique_ptr<uint8_t[]> heap_array_up;
- int return_value = 0;
-
- // Set the signal handler.
- sig_t sig_result = signal(SIGALRM, signal_handler);
- if (sig_result == SIG_ERR) {
- fprintf(stderr, "failed to set SIGALRM signal handler: errno=%d\n", errno);
- exit(1);
- }
-
- sig_result = signal(SIGUSR1, signal_handler);
- if (sig_result == SIG_ERR) {
- fprintf(stderr, "failed to set SIGUSR1 handler: errno=%d\n", errno);
- exit(1);
- }
-
- sig_result = signal(SIGSEGV, signal_handler);
- if (sig_result == SIG_ERR) {
- fprintf(stderr, "failed to set SIGUSR1 handler: errno=%d\n", errno);
- exit(1);
- }
-
- // Process command line args.
- for (int i = 1; i < argc; ++i) {
- if (std::strstr(argv[i], STDERR_PREFIX)) {
- // Treat remainder as text to go to stderr.
- fprintf(stderr, "%s\n", (argv[i] + strlen(STDERR_PREFIX)));
- } else if (std::strstr(argv[i], RETVAL_PREFIX)) {
- // Treat as the return value for the program.
- return_value = std::atoi(argv[i] + strlen(RETVAL_PREFIX));
- } else if (std::strstr(argv[i], SLEEP_PREFIX)) {
- // Treat as the amount of time to have this process sleep (in seconds).
- int sleep_seconds_remaining = std::atoi(argv[i] + strlen(SLEEP_PREFIX));
-
- // Loop around, sleeping until all sleep time is used up. Note that
- // signals will cause sleep to end early with the number of seconds
- // remaining.
- for (int i = 0; sleep_seconds_remaining > 0; ++i) {
- sleep_seconds_remaining = sleep(sleep_seconds_remaining);
- // std::cout << "sleep result (call " << i << "): " <<
- // sleep_seconds_remaining << std::endl;
- }
- } else if (std::strstr(argv[i], SET_MESSAGE_PREFIX)) {
- // Copy the contents after "set-message:" to the g_message buffer.
- // Used for reading inferior memory and verifying contents match
- // expectations.
- strncpy(g_message, argv[i] + strlen(SET_MESSAGE_PREFIX),
- sizeof(g_message));
-
- // Ensure we're null terminated.
- g_message[sizeof(g_message) - 1] = '\0';
-
- } else if (std::strstr(argv[i], PRINT_MESSAGE_COMMAND)) {
- pthread_mutex_lock(&g_print_mutex);
- printf("message: %s\n", g_message);
- pthread_mutex_unlock(&g_print_mutex);
- } else if (std::strstr(argv[i], GET_DATA_ADDRESS_PREFIX)) {
- volatile void *data_p = nullptr;
-
- if (std::strstr(argv[i] + strlen(GET_DATA_ADDRESS_PREFIX), "g_message"))
- data_p = &g_message[0];
- else if (std::strstr(argv[i] + strlen(GET_DATA_ADDRESS_PREFIX), "g_c1"))
- data_p = &g_c1;
- else if (std::strstr(argv[i] + strlen(GET_DATA_ADDRESS_PREFIX), "g_c2"))
- data_p = &g_c2;
-
- pthread_mutex_lock(&g_print_mutex);
- printf("data address: %p\n", data_p);
- pthread_mutex_unlock(&g_print_mutex);
- } else if (std::strstr(argv[i], GET_HEAP_ADDRESS_COMMAND)) {
- // Create a byte array if not already present.
- if (!heap_array_up)
- heap_array_up.reset(new uint8_t[32]);
-
- pthread_mutex_lock(&g_print_mutex);
- printf("heap address: %p\n", heap_array_up.get());
- pthread_mutex_unlock(&g_print_mutex);
- } else if (std::strstr(argv[i], GET_STACK_ADDRESS_COMMAND)) {
- pthread_mutex_lock(&g_print_mutex);
- printf("stack address: %p\n", &return_value);
- pthread_mutex_unlock(&g_print_mutex);
- } else if (std::strstr(argv[i], GET_CODE_ADDRESS_PREFIX)) {
- void (*func_p)() = nullptr;
-
- if (std::strstr(argv[i] + strlen(GET_CODE_ADDRESS_PREFIX), "hello"))
- func_p = hello;
- else if (std::strstr(argv[i] + strlen(GET_CODE_ADDRESS_PREFIX),
- "swap_chars"))
- func_p = swap_chars;
-
- pthread_mutex_lock(&g_print_mutex);
- printf("code address: %p\n", func_p);
- pthread_mutex_unlock(&g_print_mutex);
- } else if (std::strstr(argv[i], CALL_FUNCTION_PREFIX)) {
- // Defaut to providing the address of main.
- if (std::strcmp(argv[i] + strlen(CALL_FUNCTION_PREFIX), "hello") == 0)
- hello();
- else if (std::strcmp(argv[i] + strlen(CALL_FUNCTION_PREFIX),
- "swap_chars") == 0)
- swap_chars();
- else {
- pthread_mutex_lock(&g_print_mutex);
- printf("unknown function: %s\n",
- argv[i] + strlen(CALL_FUNCTION_PREFIX));
- pthread_mutex_unlock(&g_print_mutex);
- }
- } else if (std::strstr(argv[i], THREAD_PREFIX)) {
- // Check if we're creating a new thread.
- if (std::strstr(argv[i] + strlen(THREAD_PREFIX), THREAD_COMMAND_NEW)) {
- // Create a new thread.
- pthread_t new_thread;
- const int err =
- ::pthread_create(&new_thread, nullptr, thread_func, nullptr);
- if (err) {
- fprintf(stderr, "pthread_create() failed with error code %d\n", err);
- exit(err);
- }
- threads.push_back(new_thread);
- } else if (std::strstr(argv[i] + strlen(THREAD_PREFIX),
- THREAD_COMMAND_PRINT_IDS)) {
- // Turn on thread id announcing.
- g_print_thread_ids = true;
-
- // And announce us.
- pthread_mutex_lock(&g_print_mutex);
- printf("thread 0 id: ");
- print_thread_id();
- printf("\n");
- pthread_mutex_unlock(&g_print_mutex);
- } else if (std::strstr(argv[i] + strlen(THREAD_PREFIX),
- THREAD_COMMAND_SEGFAULT)) {
- g_threads_do_segfault = true;
- } else {
- // At this point we don't do anything else with threads.
- // Later use thread index and send command to thread.
- }
- } else {
- // Treat the argument as text for stdout.
- printf("%s\n", argv[i]);
- }
- }
-
- // If we launched any threads, join them
- for (std::vector<pthread_t>::iterator it = threads.begin();
- it != threads.end(); ++it) {
- void *thread_retval = nullptr;
- const int err = ::pthread_join(*it, &thread_retval);
- if (err != 0)
- fprintf(stderr, "pthread_join() failed with error code %d\n", err);
- }
-
- return return_value;
-}
diff --git a/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py b/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
index 67887256d97d..c5d21a9c9b7a 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
@@ -32,7 +32,7 @@ class GdbRemoteTestCaseBase(TestBase):
NO_DEBUG_INFO_TESTCASE = True
- _TIMEOUT_SECONDS = 7
+ _TIMEOUT_SECONDS = 120
_GDBREMOTE_KILL_PACKET = "$k#6b"
@@ -483,7 +483,7 @@ class GdbRemoteTestCaseBase(TestBase):
# This process needs to be started so that it just hangs around for a while. We'll
# have it sleep.
if not exe_path:
- exe_path = os.path.abspath("a.out")
+ exe_path = self.getBuildArtifact("a.out")
args = []
if inferior_args:
@@ -546,10 +546,10 @@ class GdbRemoteTestCaseBase(TestBase):
if self._inferior_startup == self._STARTUP_LAUNCH:
# Build launch args
if not inferior_exe_path:
- inferior_exe_path = os.path.abspath("a.out")
+ inferior_exe_path = self.getBuildArtifact("a.out")
if lldb.remote_platform:
- remote_path = lldbutil.append_to_process_working_directory(
+ remote_path = lldbutil.append_to_process_working_directory(self,
os.path.basename(inferior_exe_path))
remote_file_spec = lldb.SBFileSpec(remote_path, False)
err = lldb.remote_platform.Install(lldb.SBFileSpec(
@@ -1008,9 +1008,10 @@ class GdbRemoteTestCaseBase(TestBase):
reg_info["name"] in PREFERRED_REGISTER_NAMES):
# We found a preferred register. Use it.
return reg_info["lldb_register_index"]
- if ("generic" in reg_info) and (reg_info["generic"] == "fp"):
- # A frame pointer register will do as a register to modify
- # temporarily.
+ if ("generic" in reg_info) and (reg_info["generic"] == "fp" or
+ reg_info["generic"] == "arg1"):
+ # A frame pointer or first arg register will do as a
+ # register to modify temporarily.
alternative_register_index = reg_info["lldb_register_index"]
# We didn't find a preferred register. Return whatever alternative register
@@ -1076,6 +1077,18 @@ class GdbRemoteTestCaseBase(TestBase):
auxv_dict = {}
+ # PowerPC64le's auxvec has a special key that must be ignored.
+ # This special key may be used multiple times, resulting in
+ # multiple key/value pairs with the same key, which would otherwise
+ # break this test check for repeated keys.
+ #
+ # AT_IGNOREPPC = 22
+ ignored_keys_for_arch = { 'powerpc64le' : [22] }
+ arch = self.getArchitecture()
+ ignore_keys = None
+ if arch in ignored_keys_for_arch:
+ ignore_keys = ignored_keys_for_arch[arch]
+
while len(auxv_data) > 0:
# Chop off key.
raw_key = auxv_data[:word_size]
@@ -1089,6 +1102,9 @@ class GdbRemoteTestCaseBase(TestBase):
key = unpack_endian_binary_string(endian, raw_key)
value = unpack_endian_binary_string(endian, raw_value)
+ if ignore_keys and key in ignore_keys:
+ continue
+
# Handle ending entry.
if key == 0:
self.assertEqual(value, 0)
@@ -1607,10 +1623,10 @@ class GdbRemoteTestCaseBase(TestBase):
'.*' if lldbplatformutil.hasChattyStderr(self) else '^' + regex + '$'
def install_and_create_launch_args(self):
- exe_path = os.path.abspath('a.out')
+ exe_path = self.getBuildArtifact("a.out")
if not lldb.remote_platform:
return [exe_path]
- remote_path = lldbutil.append_to_process_working_directory(
+ remote_path = lldbutil.append_to_process_working_directory(self,
os.path.basename(exe_path))
remote_file_spec = lldb.SBFileSpec(remote_path, False)
err = lldb.remote_platform.Install(lldb.SBFileSpec(exe_path, True),
diff --git a/packages/Python/lldbsuite/test/tools/lldb-server/main.cpp b/packages/Python/lldbsuite/test/tools/lldb-server/main.cpp
index a574b41abf67..ca032c120beb 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-server/main.cpp
+++ b/packages/Python/lldbsuite/test/tools/lldb-server/main.cpp
@@ -48,6 +48,8 @@ static const char *const THREAD_COMMAND_NEW = "new";
static const char *const THREAD_COMMAND_PRINT_IDS = "print-ids";
static const char *const THREAD_COMMAND_SEGFAULT = "segfault";
+static const char *const PRINT_PID_COMMAND = "print-pid";
+
static bool g_print_thread_ids = false;
static pthread_mutex_t g_print_mutex = PTHREAD_MUTEX_INITIALIZER;
static bool g_threads_do_segfault = false;
@@ -61,6 +63,10 @@ static char g_message[256];
static volatile char g_c1 = '0';
static volatile char g_c2 = '1';
+static void print_pid() {
+ fprintf(stderr, "PID: %d\n", getpid());
+}
+
static void print_thread_id() {
// Put in the right magic here for your platform to spit out the thread id (tid)
// that debugserver/lldb-gdbserver would see as a TID. Otherwise, let the else
@@ -303,18 +309,22 @@ int main(int argc, char **argv) {
printf("code address: %p\n", func_p);
pthread_mutex_unlock(&g_print_mutex);
} else if (std::strstr(argv[i], CALL_FUNCTION_PREFIX)) {
+ void (*func_p)() = nullptr;
+
// Defaut to providing the address of main.
if (std::strcmp(argv[i] + strlen(CALL_FUNCTION_PREFIX), "hello") == 0)
- hello();
+ func_p = hello;
else if (std::strcmp(argv[i] + strlen(CALL_FUNCTION_PREFIX),
"swap_chars") == 0)
- swap_chars();
+ func_p = swap_chars;
else {
pthread_mutex_lock(&g_print_mutex);
printf("unknown function: %s\n",
argv[i] + strlen(CALL_FUNCTION_PREFIX));
pthread_mutex_unlock(&g_print_mutex);
}
+ if (func_p)
+ func_p();
} else if (std::strstr(argv[i], THREAD_PREFIX)) {
// Check if we're creating a new thread.
if (std::strstr(argv[i] + strlen(THREAD_PREFIX), THREAD_COMMAND_NEW)) {
@@ -345,6 +355,8 @@ int main(int argc, char **argv) {
// At this point we don't do anything else with threads.
// Later use thread index and send command to thread.
}
+ } else if (std::strstr(argv[i], PRINT_PID_COMMAND)) {
+ print_pid();
} else {
// Treat the argument as text for stdout.
printf("%s\n", argv[i]);
diff --git a/packages/Python/lldbsuite/test/tools/lldb-server/platform-process-connect/TestPlatformProcessConnect.py b/packages/Python/lldbsuite/test/tools/lldb-server/platform-process-connect/TestPlatformProcessConnect.py
index 7e4190b7fe95..aa4b3dee7921 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-server/platform-process-connect/TestPlatformProcessConnect.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-server/platform-process-connect/TestPlatformProcessConnect.py
@@ -20,12 +20,9 @@ class TestPlatformProcessConnect(gdbremote_testcase.GdbRemoteTestCaseBase):
self.init_llgs_test(False)
working_dir = lldb.remote_platform.GetWorkingDirectory()
- err = lldb.remote_platform.Put(
- lldb.SBFileSpec(
- os.path.join(
- os.getcwd(), "a.out")), lldb.SBFileSpec(
- os.path.join(
- working_dir, "a.out")))
+ src = lldb.SBFileSpec(self.getBuildArtifact("a.out"))
+ dest = lldb.SBFileSpec(os.path.join(working_dir, "a.out"))
+ err = lldb.remote_platform.Put(src, dest)
if err.Fail():
raise RuntimeError(
"Unable copy '%s' to '%s'.\n>>> %s" %
@@ -37,9 +34,9 @@ class TestPlatformProcessConnect(gdbremote_testcase.GdbRemoteTestCaseBase):
unix_protocol = protocol.startswith("unix-")
if unix_protocol:
p = re.search("^(.*)-connect", protocol)
- listen_url = "%s://%s" % (p.group(1),
- os.path.join(working_dir,
- "platform-%d.sock" % int(time.time())))
+ path = lldbutil.join_remote_paths(configuration.lldb_platform_working_dir,
+ self.getBuildDirBasename(), "platform-%d.sock" % int(time.time()))
+ listen_url = "%s://%s" % (p.group(1), path)
else:
listen_url = "*:0"