aboutsummaryrefslogtreecommitdiff
path: root/packages/Python/lldbsuite/test/tools
diff options
context:
space:
mode:
Diffstat (limited to 'packages/Python/lldbsuite/test/tools')
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-mi/TestMiExit.py25
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-mi/TestMiFile.py26
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-mi/TestMiGdbSetShow.py110
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-mi/TestMiLibraryLoaded.py39
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-mi/TestMiPrompt.py25
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-mi/breakpoint/TestMiBreak.py203
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-mi/control/TestMiExec.py139
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-mi/data/TestMiData.py184
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-mi/interpreter/TestMiCliSupport.py84
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-mi/interpreter/TestMiInterpreterExec.py82
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-mi/lldbmi_testcase.py4
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-mi/signal/TestMiSignal.py100
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-mi/stack/TestMiStack.py263
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/TestMiStartupOptions.py118
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-mi/symbol/TestMiSymbol.py56
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-mi/syntax/TestMiSyntax.py130
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-mi/target/TestMiTarget.py86
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-mi/threadinfo/TestMiThreadInfo.py11
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-mi/variable/TestMiGdbSetShowPrint.py262
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-mi/variable/TestMiVar.py203
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-server/Makefile2
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-server/TestGDBRemoteMemoryRead.py45
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteAttach.py15
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteAuxvSupport.py42
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteExpeditedRegisters.py39
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteKill.py24
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteModuleInfo.py43
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteProcessInfo.py36
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteRegisterState.py28
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteSingleStep.py21
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteThreadsInStopReply.py63
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemote_qThreadStopInfo.py72
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemote_vCont.py51
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-server/TestLldbGdbServer.py552
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-server/commandline/TestStubReverseConnect.py18
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-server/commandline/TestStubSetSID.py18
-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/TestGdbRemoteExitCode.py124
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-server/exit-code/main.cpp391
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py685
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-server/host-info/Makefile10
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-server/host-info/TestGdbRemoteHostInfo.py126
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-server/inferior-crash/TestGdbRemoteAbort.py15
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-server/inferior-crash/TestGdbRemoteSegFault.py15
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py248
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-server/platform-process-connect/TestPlatformProcessConnect.py39
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-server/socket_packet_pump.py8
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-server/test/test_lldbgdbserverutils.py30
48 files changed, 3348 insertions, 1570 deletions
diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiExit.py b/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiExit.py
index 6f814c13ec83..0cc50370b164 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiExit.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiExit.py
@@ -9,16 +9,19 @@ 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
+ @expectedFailureAll(
+ oslist=["windows"],
+ bugnumber="llvm.org/pr22274: need a pexpect replacement for windows")
+ @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
def test_lldbmi_gdb_exit(self):
"""Test that '-gdb-exit' terminates local debug session and exits."""
- self.spawnLldbMi(args = None)
+ self.spawnLldbMi(args=None)
# Load executable
self.runCmd("-file-exec-and-symbols %s" % self.myexe)
@@ -37,12 +40,14 @@ class MiExitTestCase(lldbmi_testcase.MiTestCaseBase):
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
+ @expectedFailureAll(
+ oslist=["windows"],
+ bugnumber="llvm.org/pr22274: need a pexpect replacement for windows")
+ @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
def test_lldbmi_quit(self):
"""Test that 'quit' exits immediately."""
- self.spawnLldbMi(args = None)
+ self.spawnLldbMi(args=None)
# Load executable
self.runCmd("-file-exec-and-symbols %s" % self.myexe)
@@ -60,12 +65,14 @@ class MiExitTestCase(lldbmi_testcase.MiTestCaseBase):
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
+ @expectedFailureAll(
+ oslist=["windows"],
+ bugnumber="llvm.org/pr22274: need a pexpect replacement for windows")
+ @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
def test_lldbmi_q(self):
"""Test that 'q' exits immediately."""
- self.spawnLldbMi(args = None)
+ self.spawnLldbMi(args=None)
# Load executable
self.runCmd("-file-exec-and-symbols %s" % self.myexe)
diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiFile.py b/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiFile.py
index 99a06f2711fa..7a99ecf7d1e5 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiFile.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiFile.py
@@ -5,22 +5,22 @@ Test lldb-mi -file-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 MiFileTestCase(lldbmi_testcase.MiTestCaseBase):
mydir = TestBase.compute_mydir(__file__)
- @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows
- @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
+ @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
def test_lldbmi_file_exec_and_symbols_file(self):
"""Test that 'lldb-mi --interpreter' works for -file-exec-and-symbols exe."""
- self.spawnLldbMi(args = None)
+ self.spawnLldbMi(args=None)
# Test that -file-exec-and-symbols works for filename
self.runCmd("-file-exec-and-symbols %s" % self.myexe)
@@ -31,12 +31,12 @@ class MiFileTestCase(lldbmi_testcase.MiTestCaseBase):
self.expect("\^running")
self.expect("\*stopped,reason=\"exited-normally\"")
- @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows
- @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
+ @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
def test_lldbmi_file_exec_and_symbols_absolute_path(self):
"""Test that 'lldb-mi --interpreter' works for -file-exec-and-symbols fullpath/exe."""
- self.spawnLldbMi(args = None)
+ self.spawnLldbMi(args=None)
# Test that -file-exec-and-symbols works for absolute path
import os
@@ -49,12 +49,12 @@ class MiFileTestCase(lldbmi_testcase.MiTestCaseBase):
self.expect("\^running")
self.expect("\*stopped,reason=\"exited-normally\"")
- @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows
- @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
+ @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
def test_lldbmi_file_exec_and_symbols_relative_path(self):
"""Test that 'lldb-mi --interpreter' works for -file-exec-and-symbols relpath/exe."""
- self.spawnLldbMi(args = None)
+ self.spawnLldbMi(args=None)
# Test that -file-exec-and-symbols works for relative path
path = "./%s" % self.myexe
@@ -66,12 +66,12 @@ class MiFileTestCase(lldbmi_testcase.MiTestCaseBase):
self.expect("\^running")
self.expect("\*stopped,reason=\"exited-normally\"")
- @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows
- @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
+ @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
def test_lldbmi_file_exec_and_symbols_unknown_path(self):
"""Test that 'lldb-mi --interpreter' works for -file-exec-and-symbols badpath/exe."""
- self.spawnLldbMi(args = None)
+ self.spawnLldbMi(args=None)
# Test that -file-exec-and-symbols fails on unknown path
path = "unknown_dir/%s" % self.myexe
diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiGdbSetShow.py b/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiGdbSetShow.py
index 9898ad4398fb..5daf3fe0939c 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiGdbSetShow.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiGdbSetShow.py
@@ -5,23 +5,25 @@ 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
+ @expectedFailureAll(
+ oslist=["windows"],
+ bugnumber="llvm.org/pr22274: need a pexpect replacement for windows")
+ @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
def test_lldbmi_gdb_set_target_async_default(self):
"""Test that 'lldb-mi --interpreter' switches to async mode by default."""
- self.spawnLldbMi(args = None)
+ self.spawnLldbMi(args=None)
# Switch to sync mode
self.runCmd("-gdb-set target-async off")
@@ -35,13 +37,15 @@ class MiGdbSetShowTestCase(lldbmi_testcase.MiTestCaseBase):
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
+ @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
def test_lldbmi_gdb_set_target_async_on(self):
"""Test that 'lldb-mi --interpreter' can execute commands in async mode."""
- self.spawnLldbMi(args = None)
+ self.spawnLldbMi(args=None)
# Switch to sync mode
self.runCmd("-gdb-set target-async off")
@@ -64,13 +68,17 @@ class MiGdbSetShowTestCase(lldbmi_testcase.MiTestCaseBase):
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)")
+ @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)")
def test_lldbmi_gdb_set_target_async_off(self):
"""Test that 'lldb-mi --interpreter' can execute commands in sync mode."""
- self.spawnLldbMi(args = None)
+ self.spawnLldbMi(args=None)
# Test that -gdb-set can switch to sync mode
self.runCmd("-gdb-set target-async off")
@@ -84,28 +92,32 @@ class MiGdbSetShowTestCase(lldbmi_testcase.MiTestCaseBase):
# 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" ])
+ 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
+ @expectedFailureAll(
+ oslist=["windows"],
+ bugnumber="llvm.org/pr22274: need a pexpect replacement for windows")
+ @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
def test_lldbmi_gdb_show_target_async(self):
"""Test that 'lldb-mi --interpreter' in async mode by default."""
- self.spawnLldbMi(args = None)
+ 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
+ @expectedFailureAll(
+ oslist=["windows"],
+ bugnumber="llvm.org/pr22274: need a pexpect replacement for windows")
+ @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
def test_lldbmi_gdb_show_language(self):
"""Test that 'lldb-mi --interpreter' can get current language."""
- self.spawnLldbMi(args = None)
+ self.spawnLldbMi(args=None)
# Load executable
self.runCmd("-file-exec-and-symbols %s" % self.myexe)
@@ -122,36 +134,41 @@ class MiGdbSetShowTestCase(lldbmi_testcase.MiTestCaseBase):
self.runCmd("-gdb-show language")
self.expect("\^done,value=\"c\+\+\"")
- @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr22274: need a pexpect replacement for windows")
+ @expectedFailureAll(
+ oslist=["windows"],
+ bugnumber="llvm.org/pr22274: need a pexpect replacement for windows")
@unittest2.expectedFailure("-gdb-set ignores unknown properties")
def test_lldbmi_gdb_set_unknown(self):
"""Test that 'lldb-mi --interpreter' fails when setting an unknown property."""
- self.spawnLldbMi(args = None)
+ 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")
+ @expectedFailureAll(
+ oslist=["windows"],
+ bugnumber="llvm.org/pr22274: need a pexpect replacement for windows")
@unittest2.expectedFailure("-gdb-show ignores unknown properties")
def test_lldbmi_gdb_show_unknown(self):
"""Test that 'lldb-mi --interpreter' fails when showing an unknown property."""
- self.spawnLldbMi(args = None)
+ 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
+ @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
def test_lldbmi_gdb_set_ouptut_radix(self):
"""Test that 'lldb-mi --interpreter' works for -gdb-set output-radix."""
- self.spawnLldbMi(args = None)
+ self.spawnLldbMi(args=None)
# Load executable
self.runCmd("-file-exec-and-symbols %s" % self.myexe)
@@ -162,31 +179,32 @@ class MiGdbSetShowTestCase(lldbmi_testcase.MiTestCaseBase):
self.runCmd("-break-insert main.cpp:%d" % line)
self.expect("\^done,bkpt={number=\"1\"")
self.runCmd("-exec-run")
- self.expect("\^running");
+ 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\"")
+ 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\"");
+ 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\"");
+ 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\"");
+ 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\"");
+ self.runCmd("-gdb-set output-radix 10")
+ self.expect("\^done")
+ self.runCmd("-var-evaluate-expression var_a")
+ self.expect("\^done,value=\"10\"")
diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiLibraryLoaded.py b/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiLibraryLoaded.py
index 8e1d72aa19c6..68d670c9cd1e 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiLibraryLoaded.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiLibraryLoaded.py
@@ -5,22 +5,22 @@ Test lldb-mi =library-loaded notifications.
from __future__ import print_function
-
import lldbmi_testcase
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
+
class MiLibraryLoadedTestCase(lldbmi_testcase.MiTestCaseBase):
mydir = TestBase.compute_mydir(__file__)
- @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows
- @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
+ @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
def test_lldbmi_library_loaded(self):
"""Test that 'lldb-mi --interpreter' shows the =library-loaded notifications."""
- self.spawnLldbMi(args = None)
+ self.spawnLldbMi(args=None)
# Load executable
self.runCmd("-file-exec-and-symbols %s" % self.myexe)
@@ -29,7 +29,30 @@ class MiLibraryLoadedTestCase(lldbmi_testcase.MiTestCaseBase):
# Test =library-loaded
import os
path = os.path.join(os.getcwd(), self.myexe)
- symbols_path = os.path.join(path + ".dSYM", "Contents", "Resources", "DWARF", self.myexe)
- def add_slashes(x): return x.replace("\\", "\\\\").replace("\"", "\\\"").replace("\'", "\\\'").replace("\0", "\\\0")
- self.expect([ "=library-loaded,id=\"%s\",target-name=\"%s\",host-name=\"%s\",symbols-loaded=\"1\",symbols-path=\"%s\",loaded_addr=\"-\",size=\"[0-9]+\"" % (add_slashes(path), add_slashes(path), add_slashes(path), add_slashes(symbols_path)),
- "=library-loaded,id=\"%s\",target-name=\"%s\",host-name=\"%s\",symbols-loaded=\"0\",loaded_addr=\"-\",size=\"[0-9]+\"" % (add_slashes(path), add_slashes(path), add_slashes(path)) ])
+ symbols_path = os.path.join(
+ path + ".dSYM",
+ "Contents",
+ "Resources",
+ "DWARF",
+ self.myexe)
+
+ def add_slashes(x): return x.replace(
+ "\\",
+ "\\\\").replace(
+ "\"",
+ "\\\"").replace(
+ "\'",
+ "\\\'").replace(
+ "\0",
+ "\\\0")
+ self.expect(
+ [
+ "=library-loaded,id=\"%s\",target-name=\"%s\",host-name=\"%s\",symbols-loaded=\"1\",symbols-path=\"%s\",loaded_addr=\"-\",size=\"[0-9]+\"" %
+ (add_slashes(path),
+ add_slashes(path),
+ add_slashes(path),
+ add_slashes(symbols_path)),
+ "=library-loaded,id=\"%s\",target-name=\"%s\",host-name=\"%s\",symbols-loaded=\"0\",loaded_addr=\"-\",size=\"[0-9]+\"" %
+ (add_slashes(path),
+ add_slashes(path),
+ add_slashes(path))])
diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiPrompt.py b/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiPrompt.py
index 50e108e9fa20..b853673211bb 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiPrompt.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiPrompt.py
@@ -5,52 +5,53 @@ Test that the lldb-mi driver prints prompt properly.
from __future__ import print_function
-
import lldbmi_testcase
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
+
class MiPromptTestCase(lldbmi_testcase.MiTestCaseBase):
mydir = TestBase.compute_mydir(__file__)
- @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows
- @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
+ @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
def test_lldbmi_prompt(self):
"""Test that 'lldb-mi --interpreter' echos '(gdb)' after commands and events."""
- self.spawnLldbMi(args = None)
+ self.spawnLldbMi(args=None)
# Test that lldb-mi is ready after unknown command
self.runCmd("-unknown-command")
- self.expect("\^error,msg=\"Driver\. Received command '-unknown-command'\. It was not handled\. Command 'unknown-command' not in Command Factory\"")
- self.expect(self.child_prompt, exactly = True)
+ self.expect(
+ "\^error,msg=\"Driver\. Received command '-unknown-command'\. It was not handled\. Command 'unknown-command' not in Command Factory\"")
+ self.expect(self.child_prompt, exactly=True)
# Test that lldb-mi is ready after -file-exec-and-symbols
self.runCmd("-file-exec-and-symbols %s" % self.myexe)
self.expect("\^done")
- self.expect(self.child_prompt, exactly = True)
+ self.expect(self.child_prompt, exactly=True)
# Test that lldb-mi is ready after -break-insert
self.runCmd("-break-insert -f main")
self.expect("\^done,bkpt={number=\"1\"")
- self.expect(self.child_prompt, exactly = True)
+ self.expect(self.child_prompt, exactly=True)
# Test that lldb-mi is ready after -exec-run
self.runCmd("-exec-run")
self.expect("\*running")
- self.expect(self.child_prompt, exactly = True)
+ self.expect(self.child_prompt, exactly=True)
# Test that lldb-mi is ready after BP hit
self.expect("\*stopped,reason=\"breakpoint-hit\"")
- self.expect(self.child_prompt, exactly = True)
+ self.expect(self.child_prompt, exactly=True)
# Test that lldb-mi is ready after -exec-continue
self.runCmd("-exec-continue")
self.expect("\^running")
- self.expect(self.child_prompt, exactly = True)
+ self.expect(self.child_prompt, exactly=True)
# Test that lldb-mi is ready after program exited
self.expect("\*stopped,reason=\"exited-normally\"")
- self.expect(self.child_prompt, exactly = True)
+ self.expect(self.child_prompt, exactly=True)
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 c4a801c991a4..38c6b1f0b179 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-mi/breakpoint/TestMiBreak.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-mi/breakpoint/TestMiBreak.py
@@ -11,68 +11,79 @@ from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
+
class MiBreakTestCase(lldbmi_testcase.MiTestCaseBase):
mydir = TestBase.compute_mydir(__file__)
- @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows
- @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
+ @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
@expectedFlakeyLinux("llvm.org/pr24717")
def test_lldbmi_break_insert_function_pending(self):
"""Test that 'lldb-mi --interpreter' works for pending function breakpoints."""
- self.spawnLldbMi(args = None)
+ self.spawnLldbMi(args=None)
self.runCmd("-file-exec-and-symbols %s" % self.myexe)
self.expect("\^done")
self.runCmd("-break-insert -f printf")
- #FIXME function name is unknown on Darwin, fullname should be ??, line is -1
- #self.expect("\^done,bkpt={number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"0xffffffffffffffff\",func=\"printf\",file=\"\?\?\",fullname=\"\?\?\",line=\"-1\",pending=\[\"printf\"\],times=\"0\",original-location=\"printf\"}")
- self.expect("\^done,bkpt={number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"0xffffffffffffffff\",func=\"\?\?\",file=\"\?\?\",fullname=\"\?\?/\?\?\",line=\"0\",pending=\[\"printf\"\],times=\"0\",original-location=\"printf\"}")
- #FIXME function name is unknown on Darwin, fullname should be ??, line -1
- #self.expect("=breakpoint-modified,bkpt={number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"0xffffffffffffffff\",func=\"printf\",file=\"\?\?\",fullname=\"\?\?\",line=\"-1\",pending=\[\"printf\"\],times=\"0\",original-location=\"printf\"}")
- self.expect("=breakpoint-modified,bkpt={number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"0xffffffffffffffff\",func=\"\?\?\",file=\"\?\?\",fullname=\"\?\?/\?\?\",line=\"0\",pending=\[\"printf\"\],times=\"0\",original-location=\"printf\"}")
+ # FIXME function name is unknown on Darwin, fullname should be ??, line is -1
+ # self.expect("\^done,bkpt={number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"0xffffffffffffffff\",func=\"printf\",file=\"\?\?\",fullname=\"\?\?\",line=\"-1\",pending=\[\"printf\"\],times=\"0\",original-location=\"printf\"}")
+ self.expect(
+ "\^done,bkpt={number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"0xffffffffffffffff\",func=\"\?\?\",file=\"\?\?\",fullname=\"\?\?/\?\?\",line=\"0\",pending=\[\"printf\"\],times=\"0\",original-location=\"printf\"}")
+ # FIXME function name is unknown on Darwin, fullname should be ??, line -1
+ # self.expect("=breakpoint-modified,bkpt={number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"0xffffffffffffffff\",func=\"printf\",file=\"\?\?\",fullname=\"\?\?\",line=\"-1\",pending=\[\"printf\"\],times=\"0\",original-location=\"printf\"}")
+ self.expect(
+ "=breakpoint-modified,bkpt={number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"0xffffffffffffffff\",func=\"\?\?\",file=\"\?\?\",fullname=\"\?\?/\?\?\",line=\"0\",pending=\[\"printf\"\],times=\"0\",original-location=\"printf\"}")
self.runCmd("-exec-run")
self.expect("\^running")
- self.expect("=breakpoint-modified,bkpt={number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"(?!0xffffffffffffffff)0x[0-9a-f]+\",func=\".+?\",file=\".+?\",fullname=\".+?\",line=\"(-1|\d+)\",pending=\[\"printf\"\],times=\"0\",original-location=\"printf\"}")
+ self.expect(
+ "=breakpoint-modified,bkpt={number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"(?!0xffffffffffffffff)0x[0-9a-f]+\",func=\".+?\",file=\".+?\",fullname=\".+?\",line=\"(-1|\d+)\",pending=\[\"printf\"\],times=\"0\",original-location=\"printf\"}")
self.expect("\*stopped,reason=\"breakpoint-hit\"")
- @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows
- @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
+ @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
def test_lldbmi_break_insert_function(self):
"""Test that 'lldb-mi --interpreter' works for function breakpoints."""
- self.spawnLldbMi(args = None)
+ self.spawnLldbMi(args=None)
self.runCmd("-file-exec-and-symbols %s" % self.myexe)
self.expect("\^done")
self.runCmd("-break-insert -f main")
- self.expect("\^done,bkpt={number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"(?!0xffffffffffffffff)0x[0-9a-f]+\",func=\"main\",file=\"main\.cpp\",fullname=\".+?main\.cpp\",line=\"\d+\",pending=\[\"main\"\],times=\"0\",original-location=\"main\"}")
- self.expect("=breakpoint-modified,bkpt={number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"(?!0xffffffffffffffff)0x[0-9a-f]+\",func=\"main\",file=\"main\.cpp\",fullname=\".+?main\.cpp\",line=\"\d+\",pending=\[\"main\"\],times=\"0\",original-location=\"main\"}")
+ self.expect(
+ "\^done,bkpt={number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"(?!0xffffffffffffffff)0x[0-9a-f]+\",func=\"main\",file=\"main\.cpp\",fullname=\".+?main\.cpp\",line=\"\d+\",pending=\[\"main\"\],times=\"0\",original-location=\"main\"}")
+ self.expect(
+ "=breakpoint-modified,bkpt={number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"(?!0xffffffffffffffff)0x[0-9a-f]+\",func=\"main\",file=\"main\.cpp\",fullname=\".+?main\.cpp\",line=\"\d+\",pending=\[\"main\"\],times=\"0\",original-location=\"main\"}")
self.runCmd("-exec-run")
self.expect("\^running")
- self.expect("=breakpoint-modified,bkpt={number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"(?!0xffffffffffffffff)0x[0-9a-f]+\",func=\"main\",file=\"main\.cpp\",fullname=\".+?main\.cpp\",line=\"\d+\",pending=\[\"main\"\],times=\"0\",original-location=\"main\"}")
+ self.expect(
+ "=breakpoint-modified,bkpt={number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"(?!0xffffffffffffffff)0x[0-9a-f]+\",func=\"main\",file=\"main\.cpp\",fullname=\".+?main\.cpp\",line=\"\d+\",pending=\[\"main\"\],times=\"0\",original-location=\"main\"}")
self.expect("\*stopped,reason=\"breakpoint-hit\"")
# Test that -break-insert can set non-pending BP
self.runCmd("-break-insert printf")
- #FIXME function name is unknown on Darwin
- #self.expect("\^done,bkpt={number=\"2\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"(?!0xffffffffffffffff)0x[0-9a-f]+\",func=\"printf\",file=\".+?\",fullname=\".+?\",line=\"(-1|\d+)\",times=\"0\",original-location=\"printf\"}")
- self.expect("\^done,bkpt={number=\"2\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"(?!0xffffffffffffffff)0x[0-9a-f]+\",func=\".+?\",file=\".+?\",fullname=\".+?\",line=\"(-1|\d+)\",times=\"0\",original-location=\"printf\"}")
- #FIXME function name is unknown on Darwin
- #self.expect("=breakpoint-modified,bkpt={number=\"2\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"(?!0xffffffffffffffff)0x[0-9a-f]+\",func=\"printf\",file=\".+?\",fullname=\".+?\",line=\"(-1|\d+)\",times=\"0\",original-location=\"printf\"}")
- self.expect("=breakpoint-modified,bkpt={number=\"2\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"(?!0xffffffffffffffff)0x[0-9a-f]+\",func=\".+?\",file=\".+?\",fullname=\".+?\",line=\"(-1|\d+)\",times=\"0\",original-location=\"printf\"}")
# FIXME function name is unknown on Darwin
- #self.expect("=breakpoint-modified,bkpt={number=\"2\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"(?!0xffffffffffffffff)0x[0-9a-f]+\",func=\"printf\",file=\".+?\",fullname=\".+?\",line=\"(-1|\d+)\",times=\"0\",original-location=\"printf\"}")
- self.expect("=breakpoint-modified,bkpt={number=\"2\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"(?!0xffffffffffffffff)0x[0-9a-f]+\",func=\".+?\",file=\".+?\",fullname=\".+?\",line=\"(-1|\d+)\",times=\"0\",original-location=\"printf\"}")
+ # self.expect("\^done,bkpt={number=\"2\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"(?!0xffffffffffffffff)0x[0-9a-f]+\",func=\"printf\",file=\".+?\",fullname=\".+?\",line=\"(-1|\d+)\",times=\"0\",original-location=\"printf\"}")
+ self.expect(
+ "\^done,bkpt={number=\"2\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"(?!0xffffffffffffffff)0x[0-9a-f]+\",func=\".+?\",file=\".+?\",fullname=\".+?\",line=\"(-1|\d+)\",times=\"0\",original-location=\"printf\"}")
+ # FIXME function name is unknown on Darwin
+ # self.expect("=breakpoint-modified,bkpt={number=\"2\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"(?!0xffffffffffffffff)0x[0-9a-f]+\",func=\"printf\",file=\".+?\",fullname=\".+?\",line=\"(-1|\d+)\",times=\"0\",original-location=\"printf\"}")
+ self.expect(
+ "=breakpoint-modified,bkpt={number=\"2\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"(?!0xffffffffffffffff)0x[0-9a-f]+\",func=\".+?\",file=\".+?\",fullname=\".+?\",line=\"(-1|\d+)\",times=\"0\",original-location=\"printf\"}")
+ # FIXME function name is unknown on Darwin
+ # self.expect("=breakpoint-modified,bkpt={number=\"2\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"(?!0xffffffffffffffff)0x[0-9a-f]+\",func=\"printf\",file=\".+?\",fullname=\".+?\",line=\"(-1|\d+)\",times=\"0\",original-location=\"printf\"}")
+ self.expect(
+ "=breakpoint-modified,bkpt={number=\"2\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"(?!0xffffffffffffffff)0x[0-9a-f]+\",func=\".+?\",file=\".+?\",fullname=\".+?\",line=\"(-1|\d+)\",times=\"0\",original-location=\"printf\"}")
# Test that -break-insert fails if non-pending BP can't be resolved
self.runCmd("-break-insert unknown_func")
- self.expect("\^error,msg=\"Command 'break-insert'. Breakpoint location 'unknown_func' not found\"")
+ self.expect(
+ "\^error,msg=\"Command 'break-insert'. Breakpoint location 'unknown_func' not found\"")
# Test that non-pending BP was set correctly
self.runCmd("-exec-continue")
@@ -84,28 +95,28 @@ class MiBreakTestCase(lldbmi_testcase.MiTestCaseBase):
self.expect("\^done,bkpt={number=\"4\"")
self.runCmd("-break-insert main.cpp:ns::foo1")
self.expect("\^done,bkpt={number=\"5\"")
- #FIXME: quotes on filenames aren't handled correctly in lldb-mi.
+ # FIXME: quotes on filenames aren't handled correctly in lldb-mi.
#self.runCmd("-break-insert \"main.cpp\":main")
- #self.expect("\^done,bkpt={number=\"6\"")
+ # self.expect("\^done,bkpt={number=\"6\"")
# We should hit BP #5 on 'main.cpp:ns::foo1'
self.runCmd("-exec-continue")
self.expect("\^running")
self.expect("\*stopped,reason=\"breakpoint-hit\".*bkptno=\"5\"")
- #FIXME: this test is disabled due to lldb bug llvm.org/pr24271.
+ # FIXME: this test is disabled due to lldb bug llvm.org/pr24271.
# Test that we can set a BP using the global namespace token
#self.runCmd("-break-insert ::main")
- #self.expect("\^done,bkpt={number=\"7\"")
+ # self.expect("\^done,bkpt={number=\"7\"")
#self.runCmd("-break-insert main.cpp:::main")
- #self.expect("\^done,bkpt={number=\"8\"")
+ # self.expect("\^done,bkpt={number=\"8\"")
- @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows
- @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
+ @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
def test_lldbmi_break_insert_file_line_pending(self):
"""Test that 'lldb-mi --interpreter' works for pending file:line breakpoints."""
- self.spawnLldbMi(args = None)
+ self.spawnLldbMi(args=None)
self.runCmd("-file-exec-and-symbols %s" % self.myexe)
self.expect("\^done")
@@ -114,19 +125,27 @@ class MiBreakTestCase(lldbmi_testcase.MiTestCaseBase):
# pending BP
line = line_number('main.cpp', '// BP_return')
self.runCmd("-break-insert -f main.cpp:%d" % line)
- self.expect("\^done,bkpt={number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"(?!0xffffffffffffffff)0x[0-9a-f]+\",func=\"main\",file=\"main\.cpp\",fullname=\".+?main\.cpp\",line=\"%d\",pending=\[\"main.cpp:%d\"\],times=\"0\",original-location=\"main.cpp:%d\"}" % (line, line, line))
- self.expect("=breakpoint-modified,bkpt={number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"(?!0xffffffffffffffff)0x[0-9a-f]+\",func=\"main\",file=\"main\.cpp\",fullname=\".+?main\.cpp\",line=\"%d\",pending=\[\"main.cpp:%d\"\],times=\"0\",original-location=\"main.cpp:%d\"}" % (line, line, line))
+ self.expect(
+ "\^done,bkpt={number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"(?!0xffffffffffffffff)0x[0-9a-f]+\",func=\"main\",file=\"main\.cpp\",fullname=\".+?main\.cpp\",line=\"%d\",pending=\[\"main.cpp:%d\"\],times=\"0\",original-location=\"main.cpp:%d\"}" %
+ (line,
+ line,
+ line))
+ self.expect(
+ "=breakpoint-modified,bkpt={number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"(?!0xffffffffffffffff)0x[0-9a-f]+\",func=\"main\",file=\"main\.cpp\",fullname=\".+?main\.cpp\",line=\"%d\",pending=\[\"main.cpp:%d\"\],times=\"0\",original-location=\"main.cpp:%d\"}" %
+ (line,
+ line,
+ line))
self.runCmd("-exec-run")
self.expect("\^running")
self.expect("\*stopped,reason=\"breakpoint-hit\"")
- @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows
- @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
+ @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
def test_lldbmi_break_insert_file_line(self):
"""Test that 'lldb-mi --interpreter' works for file:line breakpoints."""
- self.spawnLldbMi(args = None)
+ self.spawnLldbMi(args=None)
self.runCmd("-file-exec-and-symbols %s" % self.myexe)
self.expect("\^done")
@@ -141,25 +160,29 @@ class MiBreakTestCase(lldbmi_testcase.MiTestCaseBase):
# Test that -break-insert can set non-pending BP
line = line_number('main.cpp', '// BP_return')
self.runCmd("-break-insert main.cpp:%d" % line)
- self.expect("\^done,bkpt={number=\"2\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"(?!0xffffffffffffffff)0x[0-9a-f]+\",func=\"main\",file=\"main\.cpp\",fullname=\".+?main\.cpp\",line=\"%d\",times=\"0\",original-location=\"main.cpp:%d\"}" % (line, line))
- self.expect("=breakpoint-modified,bkpt={number=\"2\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"(?!0xffffffffffffffff)0x[0-9a-f]+\",func=\"main\",file=\"main\.cpp\",fullname=\".+?main\.cpp\",line=\"%d\",times=\"0\",original-location=\"main.cpp:%d\"}" % (line, line))
+ self.expect(
+ "\^done,bkpt={number=\"2\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"(?!0xffffffffffffffff)0x[0-9a-f]+\",func=\"main\",file=\"main\.cpp\",fullname=\".+?main\.cpp\",line=\"%d\",times=\"0\",original-location=\"main.cpp:%d\"}" %
+ (line, line))
+ self.expect(
+ "=breakpoint-modified,bkpt={number=\"2\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"(?!0xffffffffffffffff)0x[0-9a-f]+\",func=\"main\",file=\"main\.cpp\",fullname=\".+?main\.cpp\",line=\"%d\",times=\"0\",original-location=\"main.cpp:%d\"}" %
+ (line, line))
# Test that -break-insert fails if non-pending BP can't be resolved
self.runCmd("-break-insert unknown_file:1")
- self.expect("\^error,msg=\"Command 'break-insert'. Breakpoint location 'unknown_file:1' not found\"")
+ self.expect(
+ "\^error,msg=\"Command 'break-insert'. Breakpoint location 'unknown_file:1' not found\"")
# Test that non-pending BP was set correctly
self.runCmd("-exec-continue")
self.expect("\^running")
self.expect("\*stopped,reason=\"breakpoint-hit\"")
- @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows
- @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
- @unittest2.expectedFailure("-break-insert doesn't work for absolute path")
+ @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
+ @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
def test_lldbmi_break_insert_file_line_absolute_path(self):
"""Test that 'lldb-mi --interpreter' works for file:line breakpoints."""
- self.spawnLldbMi(args = None)
+ self.spawnLldbMi(args=None)
self.runCmd("-file-exec-and-symbols %s" % self.myexe)
self.expect("\^done")
@@ -181,19 +204,21 @@ class MiBreakTestCase(lldbmi_testcase.MiTestCaseBase):
self.expect("\^running")
self.expect("\*stopped,reason=\"breakpoint-hit\"")
- @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows
- @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
+ @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
def test_lldbmi_break_insert_settings(self):
"""Test that 'lldb-mi --interpreter' can set breakpoints accoridng to global options."""
- self.spawnLldbMi(args = None)
+ self.spawnLldbMi(args=None)
# Load executable
self.runCmd("-file-exec-and-symbols %s" % self.myexe)
self.expect("\^done")
- # Set target.move-to-nearest-code=off and try to set BP #1 that shouldn't be hit
- self.runCmd("-interpreter-exec console \"settings set target.move-to-nearest-code off\"")
+ # Set target.move-to-nearest-code=off and try to set BP #1 that
+ # shouldn't be hit
+ self.runCmd(
+ "-interpreter-exec console \"settings set target.move-to-nearest-code off\"")
self.expect("\^done")
line = line_number('main.cpp', '// BP_before_main')
self.runCmd("-break-insert -f main.cpp:%d" % line)
@@ -202,17 +227,23 @@ class MiBreakTestCase(lldbmi_testcase.MiTestCaseBase):
# Test that non-pending BP will not be set on non-existing line if target.move-to-nearest-code=off
# Note: this increases the BP number by 1 even though BP #2 is invalid.
self.runCmd("-break-insert main.cpp:%d" % line)
- self.expect("\^error,msg=\"Command 'break-insert'. Breakpoint location 'main.cpp:%d' not found\"" % line)
-
- # Set target.move-to-nearest-code=on and target.skip-prologue=on and set BP #3
- self.runCmd("-interpreter-exec console \"settings set target.move-to-nearest-code on\"")
- self.runCmd("-interpreter-exec console \"settings set target.skip-prologue on\"")
+ self.expect(
+ "\^error,msg=\"Command 'break-insert'. Breakpoint location 'main.cpp:%d' not found\"" %
+ line)
+
+ # Set target.move-to-nearest-code=on and target.skip-prologue=on and
+ # set BP #3
+ self.runCmd(
+ "-interpreter-exec console \"settings set target.move-to-nearest-code on\"")
+ self.runCmd(
+ "-interpreter-exec console \"settings set target.skip-prologue on\"")
self.expect("\^done")
self.runCmd("-break-insert main.cpp:%d" % line)
self.expect("\^done,bkpt={number=\"3\"")
# Set target.skip-prologue=off and set BP #4
- self.runCmd("-interpreter-exec console \"settings set target.skip-prologue off\"")
+ self.runCmd(
+ "-interpreter-exec console \"settings set target.skip-prologue off\"")
self.expect("\^done")
self.runCmd("-break-insert main.cpp:%d" % line)
self.expect("\^done,bkpt={number=\"4\"")
@@ -220,74 +251,92 @@ class MiBreakTestCase(lldbmi_testcase.MiTestCaseBase):
# Test that BP #4 is located before BP #3
self.runCmd("-exec-run")
self.expect("\^running")
- self.expect("\*stopped,reason=\"breakpoint-hit\",disp=\"del\",bkptno=\"4\"")
+ self.expect(
+ "\*stopped,reason=\"breakpoint-hit\",disp=\"del\",bkptno=\"4\"")
# Test that BP #3 is hit
self.runCmd("-exec-continue")
self.expect("\^running")
- self.expect("\*stopped,reason=\"breakpoint-hit\",disp=\"del\",bkptno=\"3\"")
+ self.expect(
+ "\*stopped,reason=\"breakpoint-hit\",disp=\"del\",bkptno=\"3\"")
- # Test that the target.language=pascal setting works and that BP #5 is NOT set
- self.runCmd("-interpreter-exec console \"settings set target.language c\"")
+ # Test that the target.language=pascal setting works and that BP #5 is
+ # NOT set
+ self.runCmd(
+ "-interpreter-exec console \"settings set target.language c\"")
self.expect("\^done")
self.runCmd("-break-insert ns.foo1")
self.expect("\^error")
# Test that the target.language=c++ setting works and that BP #6 is hit
- self.runCmd("-interpreter-exec console \"settings set target.language c++\"")
+ self.runCmd(
+ "-interpreter-exec console \"settings set target.language c++\"")
self.expect("\^done")
self.runCmd("-break-insert ns::foo1")
self.expect("\^done,bkpt={number=\"6\"")
self.runCmd("-exec-continue")
self.expect("\^running")
- self.expect("\*stopped,reason=\"breakpoint-hit\",disp=\"del\",bkptno=\"6\"")
+ self.expect(
+ "\*stopped,reason=\"breakpoint-hit\",disp=\"del\",bkptno=\"6\"")
# Test that BP #1 and #2 weren't set by running to program exit
self.runCmd("-exec-continue")
self.expect("\^running")
self.expect("\*stopped,reason=\"exited-normally\"")
- @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows
- @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
+ @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
def test_lldbmi_break_enable_disable(self):
"""Test that 'lldb-mi --interpreter' works for enabling / disabling breakpoints."""
- self.spawnLldbMi(args = None)
+ self.spawnLldbMi(args=None)
self.runCmd("-file-exec-and-symbols %s" % self.myexe)
self.expect("\^done")
self.runCmd("-break-insert main")
- self.expect("\^done,bkpt={number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"(?!0xffffffffffffffff)0x[0-9a-f]+\",func=\"main\"")
- self.expect("=breakpoint-modified,bkpt={number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"(?!0xffffffffffffffff)0x[0-9a-f]+\",func=\"main\",file=\"main\.cpp\",fullname=\".+?main\.cpp\",line=\"\d+\",times=\"0\",original-location=\"main\"}")
+ self.expect(
+ "\^done,bkpt={number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"(?!0xffffffffffffffff)0x[0-9a-f]+\",func=\"main\"")
+ self.expect(
+ "=breakpoint-modified,bkpt={number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"(?!0xffffffffffffffff)0x[0-9a-f]+\",func=\"main\",file=\"main\.cpp\",fullname=\".+?main\.cpp\",line=\"\d+\",times=\"0\",original-location=\"main\"}")
self.runCmd("-exec-run")
self.expect("\^running")
- self.expect("=breakpoint-modified,bkpt={number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"(?!0xffffffffffffffff)0x[0-9a-f]+\",func=\"main\",file=\"main\.cpp\",fullname=\".+?main\.cpp\",line=\"\d+\",times=\"0\",original-location=\"main\"}")
- self.expect("\*stopped,reason=\"breakpoint-hit\",disp=\"del\",bkptno=\"1\"")
+ self.expect(
+ "=breakpoint-modified,bkpt={number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"(?!0xffffffffffffffff)0x[0-9a-f]+\",func=\"main\",file=\"main\.cpp\",fullname=\".+?main\.cpp\",line=\"\d+\",times=\"0\",original-location=\"main\"}")
+ self.expect(
+ "\*stopped,reason=\"breakpoint-hit\",disp=\"del\",bkptno=\"1\"")
self.runCmd("-break-insert ns::foo1")
- self.expect("\^done,bkpt={number=\"2\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"(?!0xffffffffffffffff)0x[0-9a-f]+\",func=\"ns::foo1\(\)\"")
- self.expect("=breakpoint-modified,bkpt={number=\"2\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"(?!0xffffffffffffffff)0x[0-9a-f]+\",func=\"ns::foo1\(\)\",file=\"main\.cpp\",fullname=\".+?main\.cpp\",line=\"\d+\",times=\"0\",original-location=\"ns::foo1\"}")
+ self.expect(
+ "\^done,bkpt={number=\"2\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"(?!0xffffffffffffffff)0x[0-9a-f]+\",func=\"ns::foo1\(\)\"")
+ self.expect(
+ "=breakpoint-modified,bkpt={number=\"2\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"(?!0xffffffffffffffff)0x[0-9a-f]+\",func=\"ns::foo1\(\)\",file=\"main\.cpp\",fullname=\".+?main\.cpp\",line=\"\d+\",times=\"0\",original-location=\"ns::foo1\"}")
self.runCmd("-break-insert ns::foo2")
- self.expect("\^done,bkpt={number=\"3\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"(?!0xffffffffffffffff)0x[0-9a-f]+\",func=\"ns::foo2\(\)\"")
- self.expect("=breakpoint-modified,bkpt={number=\"3\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"(?!0xffffffffffffffff)0x[0-9a-f]+\",func=\"ns::foo2\(\)\",file=\"main\.cpp\",fullname=\".+?main\.cpp\",line=\"\d+\",times=\"0\",original-location=\"ns::foo2\"}")
+ self.expect(
+ "\^done,bkpt={number=\"3\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"(?!0xffffffffffffffff)0x[0-9a-f]+\",func=\"ns::foo2\(\)\"")
+ self.expect(
+ "=breakpoint-modified,bkpt={number=\"3\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"(?!0xffffffffffffffff)0x[0-9a-f]+\",func=\"ns::foo2\(\)\",file=\"main\.cpp\",fullname=\".+?main\.cpp\",line=\"\d+\",times=\"0\",original-location=\"ns::foo2\"}")
# disable the 2nd breakpoint
self.runCmd("-break-disable 2")
self.expect("\^done")
- self.expect("=breakpoint-modified,bkpt={number=\"2\",type=\"breakpoint\",disp=\"keep\",enabled=\"n\",addr=\"(?!0xffffffffffffffff)0x[0-9a-f]+\",func=\"ns::foo1\(\)\",file=\"main\.cpp\",fullname=\".+?main\.cpp\",line=\"\d+\",times=\"0\",original-location=\"ns::foo1\"}")
+ self.expect(
+ "=breakpoint-modified,bkpt={number=\"2\",type=\"breakpoint\",disp=\"keep\",enabled=\"n\",addr=\"(?!0xffffffffffffffff)0x[0-9a-f]+\",func=\"ns::foo1\(\)\",file=\"main\.cpp\",fullname=\".+?main\.cpp\",line=\"\d+\",times=\"0\",original-location=\"ns::foo1\"}")
# disable the 3rd breakpoint and re-enable
self.runCmd("-break-disable 3")
self.expect("\^done")
- self.expect("=breakpoint-modified,bkpt={number=\"3\",type=\"breakpoint\",disp=\"keep\",enabled=\"n\",addr=\"(?!0xffffffffffffffff)0x[0-9a-f]+\",func=\"ns::foo2\(\)\",file=\"main\.cpp\",fullname=\".+?main\.cpp\",line=\"\d+\",times=\"0\",original-location=\"ns::foo2\"}")
+ self.expect(
+ "=breakpoint-modified,bkpt={number=\"3\",type=\"breakpoint\",disp=\"keep\",enabled=\"n\",addr=\"(?!0xffffffffffffffff)0x[0-9a-f]+\",func=\"ns::foo2\(\)\",file=\"main\.cpp\",fullname=\".+?main\.cpp\",line=\"\d+\",times=\"0\",original-location=\"ns::foo2\"}")
self.runCmd("-break-enable 3")
self.expect("\^done")
- self.expect("=breakpoint-modified,bkpt={number=\"3\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"(?!0xffffffffffffffff)0x[0-9a-f]+\",func=\"ns::foo2\(\)\",file=\"main\.cpp\",fullname=\".+?main\.cpp\",line=\"\d+\",times=\"0\",original-location=\"ns::foo2\"}")
+ self.expect(
+ "=breakpoint-modified,bkpt={number=\"3\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"(?!0xffffffffffffffff)0x[0-9a-f]+\",func=\"ns::foo2\(\)\",file=\"main\.cpp\",fullname=\".+?main\.cpp\",line=\"\d+\",times=\"0\",original-location=\"ns::foo2\"}")
self.runCmd("-exec-continue")
self.expect("\^running")
- self.expect("\*stopped,reason=\"breakpoint-hit\",disp=\"del\",bkptno=\"3\"")
+ self.expect(
+ "\*stopped,reason=\"breakpoint-hit\",disp=\"del\",bkptno=\"3\"")
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 a62b9a25400c..354f955b7478 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-mi/control/TestMiExec.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-mi/control/TestMiExec.py
@@ -5,23 +5,25 @@ Test lldb-mi -exec-xxx commands.
from __future__ import print_function
-
import lldbmi_testcase
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
+
class MiExecTestCase(lldbmi_testcase.MiTestCaseBase):
mydir = TestBase.compute_mydir(__file__)
- @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")
+ @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)
+ self.spawnLldbMi(args=None)
# Load executable
self.runCmd("-file-exec-and-symbols %s" % self.myexe)
@@ -30,20 +32,22 @@ class MiExecTestCase(lldbmi_testcase.MiTestCaseBase):
# 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\"")
+ 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)
+ self.expect(self.child_prompt, exactly=True)
- @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows
- @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
+ @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
def test_lldbmi_exec_abort(self):
"""Test that 'lldb-mi --interpreter' works for -exec-abort."""
- self.spawnLldbMi(args = None)
+ self.spawnLldbMi(args=None)
# Test that -exec-abort fails on invalid process
self.runCmd("-exec-abort")
- self.expect("\^error,msg=\"Command 'exec-abort'\. Invalid process during debug session\"")
+ self.expect(
+ "\^error,msg=\"Command 'exec-abort'\. Invalid process during debug session\"")
# Load executable
self.runCmd("-file-exec-and-symbols %s" % self.myexe)
@@ -83,19 +87,20 @@ class MiExecTestCase(lldbmi_testcase.MiTestCaseBase):
self.expect("\^done")
self.expect("\*stopped,reason=\"exited-normally\"")
- @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows
- @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
+ @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
def test_lldbmi_exec_arguments_set(self):
"""Test that 'lldb-mi --interpreter' can pass args using -exec-arguments."""
- self.spawnLldbMi(args = None)
+ self.spawnLldbMi(args=None)
# Load executable
self.runCmd("-file-exec-and-symbols %s" % self.myexe)
self.expect("\^done")
# Set arguments
- self.runCmd("-exec-arguments --arg1 \"2nd arg\" third_arg fourth=\"4th arg\"")
+ self.runCmd(
+ "-exec-arguments --arg1 \"2nd arg\" third_arg fourth=\"4th arg\"")
self.expect("\^done")
# Run to main
@@ -109,7 +114,7 @@ class MiExecTestCase(lldbmi_testcase.MiTestCaseBase):
self.runCmd("-data-evaluate-expression argc")
self.expect("\^done,value=\"5\"")
#self.runCmd("-data-evaluate-expression argv[1]")
- #self.expect("\^done,value=\"--arg1\"")
+ # self.expect("\^done,value=\"--arg1\"")
self.runCmd("-interpreter-exec command \"print argv[1]\"")
self.expect("\"--arg1\"")
#self.runCmd("-data-evaluate-expression argv[2]")
@@ -117,7 +122,7 @@ class MiExecTestCase(lldbmi_testcase.MiTestCaseBase):
self.runCmd("-interpreter-exec command \"print argv[2]\"")
self.expect("\"2nd arg\"")
#self.runCmd("-data-evaluate-expression argv[3]")
- #self.expect("\^done,value=\"third_arg\"")
+ # self.expect("\^done,value=\"third_arg\"")
self.runCmd("-interpreter-exec command \"print argv[3]\"")
self.expect("\"third_arg\"")
#self.runCmd("-data-evaluate-expression argv[4]")
@@ -125,12 +130,12 @@ class MiExecTestCase(lldbmi_testcase.MiTestCaseBase):
self.runCmd("-interpreter-exec command \"print argv[4]\"")
self.expect("\"fourth=\\\\\\\"4th arg\\\\\\\"\"")
- @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows
- @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
+ @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
def test_lldbmi_exec_arguments_reset(self):
"""Test that 'lldb-mi --interpreter' can reset previously set args using -exec-arguments."""
- self.spawnLldbMi(args = None)
+ self.spawnLldbMi(args=None)
# Load executable
self.runCmd("-file-exec-and-symbols %s" % self.myexe)
@@ -153,12 +158,12 @@ class MiExecTestCase(lldbmi_testcase.MiTestCaseBase):
self.runCmd("-data-evaluate-expression argc")
self.expect("\^done,value=\"1\"")
- @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows
- @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @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)
+ self.spawnLldbMi(args=None)
# Load executable
self.runCmd("-file-exec-and-symbols %s" % self.myexe)
@@ -176,22 +181,26 @@ class MiExecTestCase(lldbmi_testcase.MiTestCaseBase):
# Test -exec-next
self.runCmd("-exec-next --thread 1 --frame 0")
self.expect("\^running")
- self.expect("\*stopped,reason=\"end-stepping-range\".+?main\.cpp\",line=\"29\"")
+ self.expect(
+ "\*stopped,reason=\"end-stepping-range\".+?main\.cpp\",line=\"29\"")
# Test that --thread is optional
self.runCmd("-exec-next --frame 0")
self.expect("\^running")
- self.expect("\*stopped,reason=\"end-stepping-range\".+?main\.cpp\",line=\"30\"")
+ self.expect(
+ "\*stopped,reason=\"end-stepping-range\".+?main\.cpp\",line=\"30\"")
# Test that --frame is optional
self.runCmd("-exec-next --thread 1")
self.expect("\^running")
- self.expect("\*stopped,reason=\"end-stepping-range\".+?main\.cpp\",line=\"31\"")
+ self.expect(
+ "\*stopped,reason=\"end-stepping-range\".+?main\.cpp\",line=\"31\"")
# Test that both --thread and --frame are optional
self.runCmd("-exec-next")
self.expect("\^running")
- self.expect("\*stopped,reason=\"end-stepping-range\".+?main\.cpp\",line=\"32\"")
+ self.expect(
+ "\*stopped,reason=\"end-stepping-range\".+?main\.cpp\",line=\"32\"")
# Test that an invalid --thread is handled
self.runCmd("-exec-next --thread 0")
@@ -204,13 +213,12 @@ class MiExecTestCase(lldbmi_testcase.MiTestCaseBase):
self.runCmd("-exec-next --frame 10")
#self.expect("\^error: Frame index 10 is out of range")
- @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows
- @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
- @expectedFailureAll(archs=["i[3-6]86"], bugnumber="xfail to get buildbot green, failing config: i386 binary running on ubuntu 14.04 x86_64")
+ @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)
+ self.spawnLldbMi(args=None)
# Load executable
self.runCmd("-file-exec-and-symbols %s" % self.myexe)
@@ -229,25 +237,29 @@ class MiExecTestCase(lldbmi_testcase.MiTestCaseBase):
# Test -exec-next-instruction
self.runCmd("-exec-next-instruction --thread 1 --frame 0")
self.expect("\^running")
- self.expect("\*stopped,reason=\"end-stepping-range\".+?main\.cpp\",line=\"28\"")
+ self.expect(
+ "\*stopped,reason=\"end-stepping-range\".+?main\.cpp\",line=\"28\"")
# Test that --thread is optional
self.runCmd("-exec-next-instruction --frame 0")
self.expect("\^running")
# Depending on compiler, it can stop at different line
- self.expect("\*stopped,reason=\"end-stepping-range\".+?main\.cpp\",line=\"(28|29)\"")
+ 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=\"(29|30)\"")
+ 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=\"(29|30|31)\"")
+ self.expect(
+ "\*stopped,reason=\"end-stepping-range\".+?main\.cpp\",line=\"(29|30|31)\"")
# Test that an invalid --thread is handled
self.runCmd("-exec-next-instruction --thread 0")
@@ -260,12 +272,12 @@ class MiExecTestCase(lldbmi_testcase.MiTestCaseBase):
self.runCmd("-exec-next-instruction --frame 10")
#self.expect("\^error: Frame index 10 is out of range")
- @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows
- @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @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)
+ self.spawnLldbMi(args=None)
# Load executable
self.runCmd("-file-exec-and-symbols %s" % self.myexe)
@@ -283,39 +295,45 @@ class MiExecTestCase(lldbmi_testcase.MiTestCaseBase):
# 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\"
+ # 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).+?\"" ])
+ 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\"")
+ 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.*?\"")
+ self.expect(
+ "\*stopped,reason=\"end-stepping-range\".+?func=\"g_MyFunction.*?\"")
# Use -exec-finish here to make sure that control reaches the caller.
# -exec-step can keep us in the g_MyFunction for gcc
self.runCmd("-exec-finish --frame 0")
self.expect("\^running")
- self.expect("\*stopped,reason=\"end-stepping-range\".+?main\.cpp\",line=\"30\"")
+ self.expect(
+ "\*stopped,reason=\"end-stepping-range\".+?main\.cpp\",line=\"30\"")
# Test that -exec-step steps into s_MyFunction
# (and that --frame is optional)
self.runCmd("-exec-step --thread 1")
self.expect("\^running")
- self.expect("\*stopped,reason=\"end-stepping-range\".+?func=\".*?s_MyFunction.*?\"")
+ self.expect(
+ "\*stopped,reason=\"end-stepping-range\".+?func=\".*?s_MyFunction.*?\"")
# Test that -exec-step steps into g_MyFunction from inside
# s_MyFunction (and that both --thread and --frame are optional)
self.runCmd("-exec-step")
self.expect("\^running")
- self.expect("\*stopped,reason=\"end-stepping-range\".+?func=\"g_MyFunction.*?\"")
+ self.expect(
+ "\*stopped,reason=\"end-stepping-range\".+?func=\"g_MyFunction.*?\"")
# Test that an invalid --thread is handled
self.runCmd("-exec-step --thread 0")
@@ -328,12 +346,12 @@ class MiExecTestCase(lldbmi_testcase.MiTestCaseBase):
self.runCmd("-exec-step --frame 10")
#self.expect("\^error: Frame index 10 is out of range")
- @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows
- @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @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)
+ self.spawnLldbMi(args=None)
# Load executable
self.runCmd("-file-exec-and-symbols %s" % self.myexe)
@@ -352,7 +370,8 @@ class MiExecTestCase(lldbmi_testcase.MiTestCaseBase):
# Test that -exec-next steps over printf
self.runCmd("-exec-next --thread 1 --frame 0")
self.expect("\^running")
- self.expect("\*stopped,reason=\"end-stepping-range\".+?main\.cpp\",line=\"29\"")
+ self.expect(
+ "\*stopped,reason=\"end-stepping-range\".+?main\.cpp\",line=\"29\"")
# Test that -exec-step-instruction steps over non branching
# instruction
@@ -364,19 +383,22 @@ class MiExecTestCase(lldbmi_testcase.MiTestCaseBase):
# instruction (and that --thread is optional)
self.runCmd("-exec-step-instruction --frame 0")
self.expect("\^running")
- self.expect("\*stopped,reason=\"end-stepping-range\".+?func=\"g_MyFunction.*?\"")
+ self.expect(
+ "\*stopped,reason=\"end-stepping-range\".+?func=\"g_MyFunction.*?\"")
# Test that -exec-step-instruction steps over non branching
# (and that --frame is optional)
self.runCmd("-exec-step-instruction --thread 1")
self.expect("\^running")
- self.expect("\*stopped,reason=\"end-stepping-range\".+?func=\"g_MyFunction.*?\"")
+ self.expect(
+ "\*stopped,reason=\"end-stepping-range\".+?func=\"g_MyFunction.*?\"")
# Test that -exec-step-instruction steps into g_MyFunction
# (and that both --thread and --frame are optional)
self.runCmd("-exec-step-instruction")
self.expect("\^running")
- self.expect("\*stopped,reason=\"end-stepping-range\".+?func=\"g_MyFunction.*?\"")
+ self.expect(
+ "\*stopped,reason=\"end-stepping-range\".+?func=\"g_MyFunction.*?\"")
# Test that an invalid --thread is handled
self.runCmd("-exec-step-instruction --thread 0")
@@ -389,12 +411,12 @@ class MiExecTestCase(lldbmi_testcase.MiTestCaseBase):
self.runCmd("-exec-step-instruction --frame 10")
#self.expect("\^error: Frame index 10 is out of range")
- @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows
- @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @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)
+ self.spawnLldbMi(args=None)
# Load executable
self.runCmd("-file-exec-and-symbols %s" % self.myexe)
@@ -429,7 +451,8 @@ class MiExecTestCase(lldbmi_testcase.MiTestCaseBase):
# s_MyFunction (and that --frame is optional)
self.runCmd("-exec-finish --thread 1")
self.expect("\^running")
- self.expect("\*stopped,reason=\"end-stepping-range\".+?func=\".*?s_MyFunction.*?\"")
+ self.expect(
+ "\*stopped,reason=\"end-stepping-range\".+?func=\".*?s_MyFunction.*?\"")
# Test that -exec-finish returns from s_MyFunction
# (and that both --thread and --frame are optional)
@@ -455,7 +478,7 @@ class MiExecTestCase(lldbmi_testcase.MiTestCaseBase):
self.expect("\^running")
self.expect("\*stopped,reason=\"breakpoint-hit\"")
- ## Test that -exec-finish returns from printf
+ # 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 a19387627c49..7281ae305dbe 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-mi/data/TestMiData.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-mi/data/TestMiData.py
@@ -5,23 +5,23 @@ Test lldb-mi -data-xxx commands.
from __future__ import print_function
-
import unittest2
import lldbmi_testcase
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
+
class MiDataTestCase(lldbmi_testcase.MiTestCaseBase):
mydir = TestBase.compute_mydir(__file__)
- @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows
- @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
+ @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
def test_lldbmi_data_disassemble(self):
"""Test that 'lldb-mi --interpreter' works for -data-disassemble."""
- self.spawnLldbMi(args = None)
+ self.spawnLldbMi(args=None)
# Load executable
self.runCmd("-file-exec-and-symbols %s" % self.myexe)
@@ -36,16 +36,23 @@ class MiDataTestCase(lldbmi_testcase.MiTestCaseBase):
# Get an address for disassembling: use main
self.runCmd("-data-evaluate-expression main")
- self.expect("\^done,value=\"0x[0-9a-f]+ \(a.out`main at main.cpp:[0-9]+\)\"")
+ self.expect(
+ "\^done,value=\"0x[0-9a-f]+ \(a.out`main at main.cpp:[0-9]+\)\"")
addr = int(self.child.after.split("\"")[1].split(" ")[0], 16)
# Test -data-disassemble: try to disassemble some address
- self.runCmd("-data-disassemble -s %#x -e %#x -- 0" % (addr, addr + 0x10))
- self.expect("\^done,asm_insns=\[{address=\"0x0*%x\",func-name=\"main\",offset=\"0\",size=\"[1-9]+\",inst=\".+?\"}," % addr)
-
+ self.runCmd(
+ "-data-disassemble -s %#x -e %#x -- 0" %
+ (addr, addr + 0x10))
+ self.expect(
+ "\^done,asm_insns=\[{address=\"0x0*%x\",func-name=\"main\",offset=\"0\",size=\"[1-9]+\",inst=\".+?\"}," %
+ addr)
+
# Test -data-disassemble without "--"
self.runCmd("-data-disassemble -s %#x -e %#x 0" % (addr, addr + 0x10))
- self.expect("\^done,asm_insns=\[{address=\"0x0*%x\",func-name=\"main\",offset=\"0\",size=\"[1-9]+\",inst=\".+?\"}," % addr)
+ self.expect(
+ "\^done,asm_insns=\[{address=\"0x0*%x\",func-name=\"main\",offset=\"0\",size=\"[1-9]+\",inst=\".+?\"}," %
+ addr)
# Run to hello_world
self.runCmd("-break-insert -f hello_world")
@@ -56,27 +63,31 @@ class MiDataTestCase(lldbmi_testcase.MiTestCaseBase):
# Get an address for disassembling: use hello_world
self.runCmd("-data-evaluate-expression hello_world")
- self.expect("\^done,value=\"0x[0-9a-f]+ \(a.out`hello_world\(\) at main.cpp:[0-9]+\)\"")
+ self.expect(
+ "\^done,value=\"0x[0-9a-f]+ \(a.out`hello_world\(\) at main.cpp:[0-9]+\)\"")
addr = int(self.child.after.split("\"")[1].split(" ")[0], 16)
# Test -data-disassemble: try to disassemble some address
- self.runCmd("-data-disassemble -s %#x -e %#x -- 0" % (addr, addr + 0x10))
+ self.runCmd(
+ "-data-disassemble -s %#x -e %#x -- 0" %
+ (addr, addr + 0x10))
# This matches a line similar to:
# Darwin: {address="0x0000000100000f18",func-name="hello_world()",offset="8",size="7",inst="leaq 0x65(%rip), %rdi; \"Hello, World!\\n\""},
# Linux: {address="0x0000000000400642",func-name="hello_world()",offset="18",size="5",inst="callq 0x4004d0; symbol stub for: printf"}
# To match the escaped characters in the ouptut, we must use four backslashes per matches backslash
# See https://docs.python.org/2/howto/regex.html#the-backslash-plague
- self.expect([ "{address=\"0x[0-9a-f]+\",func-name=\"hello_world\(\)\",offset=\"[0-9]+\",size=\"[0-9]+\",inst=\".+?; \\\\\"Hello, World!\\\\\\\\n\\\\\"\"}",
- "{address=\"0x[0-9a-f]+\",func-name=\"hello_world\(\)\",offset=\"[0-9]+\",size=\"[0-9]+\",inst=\".+?; symbol stub for: printf\"}" ])
+ self.expect(["{address=\"0x[0-9a-f]+\",func-name=\"hello_world\(\)\",offset=\"[0-9]+\",size=\"[0-9]+\",inst=\".+?; \\\\\"Hello, World!\\\\\\\\n\\\\\"\"}",
+ "{address=\"0x[0-9a-f]+\",func-name=\"hello_world\(\)\",offset=\"[0-9]+\",size=\"[0-9]+\",inst=\".+?; symbol stub for: printf\"}"])
- @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows
- @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
- @unittest2.skip("-data-evaluate-expression doesn't work on globals") #FIXME: the global case worked before refactoring
+ @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
+ @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ # FIXME: the global case worked before refactoring
+ @unittest2.skip("-data-evaluate-expression doesn't work on globals")
def test_lldbmi_data_read_memory_bytes_global(self):
"""Test that -data-read-memory-bytes can access global buffers."""
- self.spawnLldbMi(args = None)
+ self.spawnLldbMi(args=None)
# Load executable
self.runCmd("-file-exec-and-symbols %s" % self.myexe)
@@ -97,7 +108,9 @@ class MiDataTestCase(lldbmi_testcase.MiTestCaseBase):
# Test that -data-read-memory-bytes works for char[] type (global)
self.runCmd("-data-read-memory-bytes %#x %d" % (addr, size))
- self.expect("\^done,memory=\[{begin=\"0x0*%x\",offset=\"0x0+\",end=\"0x0*%x\",contents=\"1112131400\"}\]" % (addr, addr + size))
+ self.expect(
+ "\^done,memory=\[{begin=\"0x0*%x\",offset=\"0x0+\",end=\"0x0*%x\",contents=\"1112131400\"}\]" %
+ (addr, addr + size))
# Get address of static char[]
self.runCmd("-data-evaluate-expression &s_CharArray")
@@ -107,14 +120,16 @@ class MiDataTestCase(lldbmi_testcase.MiTestCaseBase):
# Test that -data-read-memory-bytes works for static char[] type
self.runCmd("-data-read-memory-bytes %#x %d" % (addr, size))
- self.expect("\^done,memory=\[{begin=\"0x0*%x\",offset=\"0x0+\",end=\"0x0*%x\",contents=\"1112131400\"}\]" % (addr, addr + size))
+ self.expect(
+ "\^done,memory=\[{begin=\"0x0*%x\",offset=\"0x0+\",end=\"0x0*%x\",contents=\"1112131400\"}\]" %
+ (addr, addr + size))
- @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows
- @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
+ @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
def test_lldbmi_data_read_memory_bytes_local(self):
"""Test that -data-read-memory-bytes can access local buffers."""
- self.spawnLldbMi(args = None)
+ self.spawnLldbMi(args=None)
# Load executable
self.runCmd('-file-exec-and-symbols %s' % self.myexe)
@@ -136,44 +151,65 @@ class MiDataTestCase(lldbmi_testcase.MiTestCaseBase):
# Test that an unquoted hex literal address works
self.runCmd('-data-read-memory-bytes %#x %d' % (addr, size))
- self.expect(r'\^done,memory=\[\{begin="0x0*%x",offset="0x0+",end="0x0*%x",contents="01020304"\}\]' % (addr, addr + size))
+ self.expect(
+ r'\^done,memory=\[\{begin="0x0*%x",offset="0x0+",end="0x0*%x",contents="01020304"\}\]' %
+ (addr, addr + size))
# Test that a double-quoted hex literal address works
self.runCmd('-data-read-memory-bytes "%#x" %d' % (addr, size))
- self.expect(r'\^done,memory=\[\{begin="0x0*%x",offset="0x0+",end="0x0*%x",contents="01020304"\}\]' % (addr, addr + size))
+ self.expect(
+ r'\^done,memory=\[\{begin="0x0*%x",offset="0x0+",end="0x0*%x",contents="01020304"\}\]' %
+ (addr, addr + size))
# Test that unquoted expressions work
self.runCmd('-data-read-memory-bytes &array %d' % size)
- self.expect(r'\^done,memory=\[\{begin="0x0*%x",offset="0x0+",end="0x0*%x",contents="01020304"\}\]' % (addr, addr + size))
+ self.expect(
+ r'\^done,memory=\[\{begin="0x0*%x",offset="0x0+",end="0x0*%x",contents="01020304"\}\]' %
+ (addr, addr + size))
- # This doesn't work, and perhaps that makes sense, but it does work on GDB
+ # This doesn't work, and perhaps that makes sense, but it does work on
+ # GDB
self.runCmd('-data-read-memory-bytes array 4')
self.expect(r'\^error')
#self.expect(r'\^done,memory=\[\{begin="0x0*%x",offset="0x0+",end="0x0*%x",contents="01020304"\}\]' % (addr, addr + size))
self.runCmd('-data-read-memory-bytes &array[2] 2')
- self.expect(r'\^done,memory=\[\{begin="0x0*%x",offset="0x0+",end="0x0*%x",contents="0304"\}\]' % (addr + 2, addr + size))
+ self.expect(
+ r'\^done,memory=\[\{begin="0x0*%x",offset="0x0+",end="0x0*%x",contents="0304"\}\]' %
+ (addr + 2, addr + size))
self.runCmd('-data-read-memory-bytes first_element_ptr %d' % size)
- self.expect(r'\^done,memory=\[\{begin="0x0*%x",offset="0x0+",end="0x0*%x",contents="01020304"\}\]' % (addr, addr + size))
+ self.expect(
+ r'\^done,memory=\[\{begin="0x0*%x",offset="0x0+",end="0x0*%x",contents="01020304"\}\]' %
+ (addr, addr + size))
# Test that double-quoted expressions work
self.runCmd('-data-read-memory-bytes "&array" %d' % size)
- self.expect(r'\^done,memory=\[\{begin="0x0*%x",offset="0x0+",end="0x0*%x",contents="01020304"\}\]' % (addr, addr + size))
+ self.expect(
+ r'\^done,memory=\[\{begin="0x0*%x",offset="0x0+",end="0x0*%x",contents="01020304"\}\]' %
+ (addr, addr + size))
self.runCmd('-data-read-memory-bytes "&array[0] + 1" 3')
- self.expect(r'\^done,memory=\[\{begin="0x0*%x",offset="0x0+",end="0x0*%x",contents="020304"\}\]' % (addr + 1, addr + size))
+ self.expect(
+ r'\^done,memory=\[\{begin="0x0*%x",offset="0x0+",end="0x0*%x",contents="020304"\}\]' %
+ (addr + 1, addr + size))
self.runCmd('-data-read-memory-bytes "first_element_ptr + 1" 3')
- self.expect(r'\^done,memory=\[\{begin="0x0*%x",offset="0x0+",end="0x0*%x",contents="020304"\}\]' % (addr + 1, addr + size))
+ self.expect(
+ r'\^done,memory=\[\{begin="0x0*%x",offset="0x0+",end="0x0*%x",contents="020304"\}\]' %
+ (addr + 1, addr + size))
# Test the -o (offset) option
self.runCmd('-data-read-memory-bytes -o 1 &array 3')
- self.expect(r'\^done,memory=\[\{begin="0x0*%x",offset="0x0+",end="0x0*%x",contents="020304"\}\]' % (addr + 1, addr + size))
+ self.expect(
+ r'\^done,memory=\[\{begin="0x0*%x",offset="0x0+",end="0x0*%x",contents="020304"\}\]' %
+ (addr + 1, addr + size))
# Test the --thread option
self.runCmd('-data-read-memory-bytes --thread 1 &array 4')
- self.expect(r'\^done,memory=\[\{begin="0x0*%x",offset="0x0+",end="0x0*%x",contents="01020304"\}\]' % (addr, addr + size))
+ self.expect(
+ r'\^done,memory=\[\{begin="0x0*%x",offset="0x0+",end="0x0*%x",contents="01020304"\}\]' %
+ (addr, addr + size))
# Test the --thread option with an invalid value
self.runCmd('-data-read-memory-bytes --thread 999 &array 4')
@@ -181,22 +217,29 @@ class MiDataTestCase(lldbmi_testcase.MiTestCaseBase):
# Test the --frame option (current frame)
self.runCmd('-data-read-memory-bytes --frame 0 &array 4')
- self.expect(r'\^done,memory=\[\{begin="0x0*%x",offset="0x0+",end="0x0*%x",contents="01020304"\}\]' % (addr, addr + size))
+ self.expect(
+ r'\^done,memory=\[\{begin="0x0*%x",offset="0x0+",end="0x0*%x",contents="01020304"\}\]' %
+ (addr, addr + size))
# Test the --frame option (outer frame)
self.runCmd('-data-read-memory-bytes --frame 1 &array 4')
- self.expect(r'\^done,memory=\[\{begin="0x[0-9a-f]+",offset="0x0+",end="0x[0-9a-f]+",contents="05060708"\}\]')
+ self.expect(
+ r'\^done,memory=\[\{begin="0x[0-9a-f]+",offset="0x0+",end="0x[0-9a-f]+",contents="05060708"\}\]')
# Test the --frame option with an invalid value
self.runCmd('-data-read-memory-bytes --frame 999 &array 4')
self.expect(r'\^error')
# Test all the options at once
- self.runCmd('-data-read-memory-bytes --thread 1 --frame 1 -o 2 &array 2')
- self.expect(r'\^done,memory=\[\{begin="0x[0-9a-f]+",offset="0x0+",end="0x[0-9a-f]+",contents="0708"\}\]')
-
- # Test that an expression that references undeclared variables doesn't work
- self.runCmd('-data-read-memory-bytes "&undeclared_array1 + undeclared_array2[1]" 2')
+ self.runCmd(
+ '-data-read-memory-bytes --thread 1 --frame 1 -o 2 &array 2')
+ self.expect(
+ r'\^done,memory=\[\{begin="0x[0-9a-f]+",offset="0x0+",end="0x[0-9a-f]+",contents="0708"\}\]')
+
+ # Test that an expression that references undeclared variables doesn't
+ # work
+ self.runCmd(
+ '-data-read-memory-bytes "&undeclared_array1 + undeclared_array2[1]" 2')
self.expect(r'\^error')
# Test that the address argument is required
@@ -207,23 +250,25 @@ class MiDataTestCase(lldbmi_testcase.MiTestCaseBase):
self.runCmd('-data-read-memory-bytes &array')
self.expect(r'\^error')
- # Test that the address and count arguments are required when other options are present
+ # Test that the address and count arguments are required when other
+ # options are present
self.runCmd('-data-read-memory-bytes --thread 1')
self.expect(r'\^error')
self.runCmd('-data-read-memory-bytes --thread 1 --frame 0')
self.expect(r'\^error')
- # Test that the count argument is required when other options are present
+ # Test that the count argument is required when other options are
+ # present
self.runCmd('-data-read-memory-bytes --thread 1 &array')
self.expect(r'\^error')
- @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows
- @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
+ @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
def test_lldbmi_data_list_register_names(self):
"""Test that 'lldb-mi --interpreter' works for -data-list-register-names."""
- self.spawnLldbMi(args = None)
+ self.spawnLldbMi(args=None)
# Load executable
self.runCmd("-file-exec-and-symbols %s" % self.myexe)
@@ -244,12 +289,12 @@ class MiDataTestCase(lldbmi_testcase.MiTestCaseBase):
self.runCmd("-data-list-register-names 0")
self.expect("\^done,register-names=\[\".+?\"\]")
- @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows
- @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
+ @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
def test_lldbmi_data_list_register_values(self):
"""Test that 'lldb-mi --interpreter' works for -data-list-register-values."""
- self.spawnLldbMi(args = None)
+ self.spawnLldbMi(args=None)
# Load executable
self.runCmd("-file-exec-and-symbols %s" % self.myexe)
@@ -264,18 +309,20 @@ class MiDataTestCase(lldbmi_testcase.MiTestCaseBase):
# Test -data-list-register-values: try to get all registers
self.runCmd("-data-list-register-values x")
- self.expect("\^done,register-values=\[{number=\"0\",value=\"0x[0-9a-f]+\"")
+ self.expect(
+ "\^done,register-values=\[{number=\"0\",value=\"0x[0-9a-f]+\"")
# Test -data-list-register-values: try to get specified registers
self.runCmd("-data-list-register-values x 0")
- self.expect("\^done,register-values=\[{number=\"0\",value=\"0x[0-9a-f]+\"}\]")
+ self.expect(
+ "\^done,register-values=\[{number=\"0\",value=\"0x[0-9a-f]+\"}\]")
- @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows
- @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @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)
+ self.spawnLldbMi(args=None)
# Load executable
self.runCmd("-file-exec-and-symbols %s" % self.myexe)
@@ -290,38 +337,46 @@ class MiDataTestCase(lldbmi_testcase.MiTestCaseBase):
# 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]+\)\"")
+ 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))
+ 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))
+ 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\.\"")
+ 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\.\"")
+ 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.expect(
+ "\^error,msg=\"error: invalid line number string 'bad_line'")
self.runCmd("-data-info-line main.cpp:0")
self.expect("\^error,msg=\"error: zero is an invalid line number")
- @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows
- @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
+ @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
def test_lldbmi_data_evaluate_expression(self):
"""Test that 'lldb-mi --interpreter' works for -data-evaluate-expression."""
- self.spawnLldbMi(args = None)
+ self.spawnLldbMi(args=None)
# Load executable
self.runCmd("-file-exec-and-symbols %s" % self.myexe)
@@ -334,6 +389,7 @@ class MiDataTestCase(lldbmi_testcase.MiTestCaseBase):
self.expect("\^running")
self.expect("\*stopped,reason=\"breakpoint-hit\"")
- # Check 2d array
+ # Check 2d array
self.runCmd("-data-evaluate-expression array2d")
- self.expect("\^done,value=\"\{\[0\] = \{\[0\] = 1, \[1\] = 2, \[2\] = 3\}, \[1\] = \{\[0\] = 4, \[1\] = 5, \[2\] = 6\}\}\"")
+ self.expect(
+ "\^done,value=\"\{\[0\] = \{\[0\] = 1, \[1\] = 2, \[2\] = 3\}, \[1\] = \{\[0\] = 4, \[1\] = 5, \[2\] = 6\}\}\"")
diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/interpreter/TestMiCliSupport.py b/packages/Python/lldbsuite/test/tools/lldb-mi/interpreter/TestMiCliSupport.py
index d80bc7f94a65..24b3881c1be1 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-mi/interpreter/TestMiCliSupport.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-mi/interpreter/TestMiCliSupport.py
@@ -5,22 +5,22 @@ Test lldb-mi can interpret CLI commands directly.
from __future__ import print_function
-
import lldbmi_testcase
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
+
class MiCliSupportTestCase(lldbmi_testcase.MiTestCaseBase):
mydir = TestBase.compute_mydir(__file__)
- @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows
- @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
+ @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
def test_lldbmi_target_create(self):
"""Test that 'lldb-mi --interpreter' can create target by 'target create' command."""
- self.spawnLldbMi(args = None)
+ self.spawnLldbMi(args=None)
# Test that "target create" loads executable
self.runCmd("target create \"%s\"" % self.myexe)
@@ -33,13 +33,13 @@ class MiCliSupportTestCase(lldbmi_testcase.MiTestCaseBase):
self.expect("\^running")
self.expect("\*stopped,reason=\"breakpoint-hit\"")
- @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows
- @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
- @skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots
+ @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
+ @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots
def test_lldbmi_breakpoint_set(self):
"""Test that 'lldb-mi --interpreter' can set breakpoint by 'breakpoint set' command."""
- self.spawnLldbMi(args = None)
+ self.spawnLldbMi(args=None)
# Load executable
self.runCmd("-file-exec-and-symbols %s" % self.myexe)
@@ -56,17 +56,18 @@ class MiCliSupportTestCase(lldbmi_testcase.MiTestCaseBase):
self.expect("=breakpoint-modified,bkpt={number=\"1\"")
self.expect("\*stopped,reason=\"breakpoint-hit\"")
- @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows
- @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
- @skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots
+ @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
+ @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots
def test_lldbmi_settings_set_target_run_args_before(self):
"""Test that 'lldb-mi --interpreter' can set target arguments by 'setting set target.run-args' command before than target was created."""
- self.spawnLldbMi(args = None)
+ self.spawnLldbMi(args=None)
# Test that "settings set target.run-args" passes arguments to executable
- #FIXME: --arg1 causes an error
- self.runCmd("setting set target.run-args arg1 \"2nd arg\" third_arg fourth=\"4th arg\"")
+ # FIXME: --arg1 causes an error
+ self.runCmd(
+ "setting set target.run-args arg1 \"2nd arg\" third_arg fourth=\"4th arg\"")
self.expect("\^done")
# Load executable
@@ -80,21 +81,22 @@ class MiCliSupportTestCase(lldbmi_testcase.MiTestCaseBase):
# Test that arguments were passed properly
self.expect("@\"argc=5\\\\r\\\\n\"")
- @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows
- @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
- @skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots
+ @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
+ @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots
def test_lldbmi_settings_set_target_run_args_after(self):
"""Test that 'lldb-mi --interpreter' can set target arguments by 'setting set target.run-args' command after than target was created."""
- self.spawnLldbMi(args = None)
+ self.spawnLldbMi(args=None)
# Load executable
self.runCmd("-file-exec-and-symbols %s" % self.myexe)
self.expect("\^done")
# Test that "settings set target.run-args" passes arguments to executable
- #FIXME: --arg1 causes an error
- self.runCmd("setting set target.run-args arg1 \"2nd arg\" third_arg fourth=\"4th arg\"")
+ # FIXME: --arg1 causes an error
+ self.runCmd(
+ "setting set target.run-args arg1 \"2nd arg\" third_arg fourth=\"4th arg\"")
self.expect("\^done")
# Run
@@ -104,13 +106,13 @@ class MiCliSupportTestCase(lldbmi_testcase.MiTestCaseBase):
# Test that arguments were passed properly
self.expect("@\"argc=5\\\\r\\\\n\"")
- @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows
- @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
- @skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots
+ @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
+ @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots
def test_lldbmi_process_launch(self):
"""Test that 'lldb-mi --interpreter' can launch process by "process launch" command."""
- self.spawnLldbMi(args = None)
+ self.spawnLldbMi(args=None)
# Load executable
self.runCmd("-file-exec-and-symbols %s" % self.myexe)
@@ -127,13 +129,13 @@ class MiCliSupportTestCase(lldbmi_testcase.MiTestCaseBase):
# Test that breakpoint hit
self.expect("\*stopped,reason=\"breakpoint-hit\"")
- @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows
- @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
- @skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots
+ @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
+ @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots
def test_lldbmi_thread_step_in(self):
"""Test that 'lldb-mi --interpreter' can step in by "thread step-in" command."""
- self.spawnLldbMi(args = None)
+ self.spawnLldbMi(args=None)
# Load executable
self.runCmd("-file-exec-and-symbols %s" % self.myexe)
@@ -149,21 +151,23 @@ class MiCliSupportTestCase(lldbmi_testcase.MiTestCaseBase):
# Test that "thread step-in" steps into (or not) printf depending on debug info
# Note that message is different in Darwin and Linux:
# Darwin: "*stopped,reason=\"end-stepping-range\",frame={addr=\"0x[0-9a-f]+\",func=\"main\",args=[{name=\"argc\",value=\"1\"},{name=\"argv\",value="0x[0-9a-f]+\"}],file=\"main.cpp\",fullname=\".+main.cpp\",line=\"\d\"},thread-id=\"1\",stopped-threads=\"all\"
- # Linux: "*stopped,reason=\"end-stepping-range\",frame={addr="0x[0-9a-f]+\",func=\"__printf\",args=[{name=\"format\",value=\"0x[0-9a-f]+\"}],file=\"printf.c\",fullname=\".+printf.c\",line="\d+"},thread-id=\"1\",stopped-threads=\"all\"
+ # Linux:
+ # "*stopped,reason=\"end-stepping-range\",frame={addr="0x[0-9a-f]+\",func=\"__printf\",args=[{name=\"format\",value=\"0x[0-9a-f]+\"}],file=\"printf.c\",fullname=\".+printf.c\",line="\d+"},thread-id=\"1\",stopped-threads=\"all\"
self.runCmd("thread step-in")
self.expect("\^done")
- it = self.expect([ "@\"argc=1\\\\r\\\\n\"",
- "\*stopped,reason=\"end-stepping-range\".+?func=\"(?!main).+?\"" ])
+ it = self.expect(["@\"argc=1\\\\r\\\\n\"",
+ "\*stopped,reason=\"end-stepping-range\".+?func=\"(?!main).+?\""])
if it == 0:
- self.expect("\*stopped,reason=\"end-stepping-range\".+?func=\"main\"")
+ self.expect(
+ "\*stopped,reason=\"end-stepping-range\".+?func=\"main\"")
- @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows
- @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
- @skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots
+ @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
+ @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots
def test_lldbmi_thread_step_over(self):
"""Test that 'lldb-mi --interpreter' can step over by "thread step-over" command."""
- self.spawnLldbMi(args = None)
+ self.spawnLldbMi(args=None)
# Load executable
self.runCmd("-file-exec-and-symbols %s" % self.myexe)
@@ -182,13 +186,13 @@ class MiCliSupportTestCase(lldbmi_testcase.MiTestCaseBase):
self.expect("@\"argc=1\\\\r\\\\n\"")
self.expect("\*stopped,reason=\"end-stepping-range\"")
- @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows
- @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
- @skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots
+ @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
+ @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots
def test_lldbmi_thread_continue(self):
"""Test that 'lldb-mi --interpreter' can continue execution by "thread continue" command."""
- self.spawnLldbMi(args = None)
+ self.spawnLldbMi(args=None)
# Load executable
self.runCmd("-file-exec-and-symbols %s" % self.myexe)
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 2bcaaad38f45..23da825d591b 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-mi/interpreter/TestMiInterpreterExec.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-mi/interpreter/TestMiInterpreterExec.py
@@ -5,25 +5,27 @@ Test lldb-mi -interpreter-exec command.
from __future__ import print_function
-
import lldbmi_testcase
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
+
class MiInterpreterExecTestCase(lldbmi_testcase.MiTestCaseBase):
mydir = TestBase.compute_mydir(__file__)
- @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows
- @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
+ @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
def test_lldbmi_target_create(self):
"""Test that 'lldb-mi --interpreter' can create target by 'target create' command."""
- self.spawnLldbMi(args = None)
+ self.spawnLldbMi(args=None)
# Test that "target create" loads executable
- self.runCmd("-interpreter-exec console \"target create \\\"%s\\\"\"" % self.myexe)
+ self.runCmd(
+ "-interpreter-exec console \"target create \\\"%s\\\"\"" %
+ self.myexe)
self.expect("\^done")
# Test that executable was loaded properly
@@ -33,12 +35,12 @@ class MiInterpreterExecTestCase(lldbmi_testcase.MiTestCaseBase):
self.expect("\^running")
self.expect("\*stopped,reason=\"breakpoint-hit\"")
- @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows
- @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
+ @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
def test_lldbmi_breakpoint_set(self):
"""Test that 'lldb-mi --interpreter' can set breakpoint by 'breakpoint set' command."""
- self.spawnLldbMi(args = None)
+ self.spawnLldbMi(args=None)
# Load executable
self.runCmd("-file-exec-and-symbols %s" % self.myexe)
@@ -55,17 +57,18 @@ class MiInterpreterExecTestCase(lldbmi_testcase.MiTestCaseBase):
self.expect("=breakpoint-modified,bkpt={number=\"1\"")
self.expect("\*stopped,reason=\"breakpoint-hit\"")
- @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows
- @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
+ @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
@expectedFlakeyLinux(bugnumber="llvm.org/pr25470")
def test_lldbmi_settings_set_target_run_args_before(self):
"""Test that 'lldb-mi --interpreter' can set target arguments by 'setting set target.run-args' command before than target was created."""
- self.spawnLldbMi(args = None)
+ self.spawnLldbMi(args=None)
# Test that "settings set target.run-args" passes arguments to executable
- #FIXME: --arg1 causes an error
- self.runCmd("-interpreter-exec console \"setting set target.run-args arg1 \\\"2nd arg\\\" third_arg fourth=\\\"4th arg\\\"\"")
+ # FIXME: --arg1 causes an error
+ self.runCmd(
+ "-interpreter-exec console \"setting set target.run-args arg1 \\\"2nd arg\\\" third_arg fourth=\\\"4th arg\\\"\"")
self.expect("\^done")
# Load executable
@@ -87,21 +90,24 @@ class MiInterpreterExecTestCase(lldbmi_testcase.MiTestCaseBase):
# Test that program exited normally
self.expect("\*stopped,reason=\"exited-normally\"")
- @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows
- @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
- @expectedFailureAll(oslist=["linux"], bugnumber="Failing in ~9/600 dosep runs (build 3120-3122)")
+ @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)")
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)
+ 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\\\"\"")
+ # 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
@@ -109,7 +115,7 @@ class MiInterpreterExecTestCase(lldbmi_testcase.MiTestCaseBase):
self.runCmd("-break-insert main.cpp:%d" % line)
self.expect("\^done,bkpt={number=\"1\"")
self.runCmd("-exec-run")
- self.expect("\^running");
+ self.expect("\^running")
self.expect("\*stopped,reason=\"breakpoint-hit\"")
# Run to BP_return
@@ -117,7 +123,7 @@ class MiInterpreterExecTestCase(lldbmi_testcase.MiTestCaseBase):
self.runCmd("-break-insert main.cpp:%d" % line)
self.expect("\^done,bkpt={number=\"2\"")
self.runCmd("-exec-continue")
- self.expect("\^running");
+ self.expect("\^running")
# Test that arguments were passed properly
self.expect("@\"argc=5\\\\r\\\\n\"")
@@ -130,12 +136,12 @@ class MiInterpreterExecTestCase(lldbmi_testcase.MiTestCaseBase):
# 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
+ @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
+ @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
def test_lldbmi_process_launch(self):
"""Test that 'lldb-mi --interpreter' can launch process by "process launch" command."""
- self.spawnLldbMi(args = None)
+ self.spawnLldbMi(args=None)
# Load executable
self.runCmd("-file-exec-and-symbols %s" % self.myexe)
@@ -152,12 +158,12 @@ class MiInterpreterExecTestCase(lldbmi_testcase.MiTestCaseBase):
# Test that breakpoint hit
self.expect("\*stopped,reason=\"breakpoint-hit\"")
- @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows
- @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
+ @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
def test_lldbmi_thread_step_in(self):
"""Test that 'lldb-mi --interpreter' can step in by "thread step-in" command."""
- self.spawnLldbMi(args = None)
+ self.spawnLldbMi(args=None)
# Load executable
self.runCmd("-file-exec-and-symbols %s" % self.myexe)
@@ -173,20 +179,22 @@ class MiInterpreterExecTestCase(lldbmi_testcase.MiTestCaseBase):
# Test that "thread step-in" steps into (or not) printf depending on debug info
# Note that message is different in Darwin and Linux:
# Darwin: "*stopped,reason=\"end-stepping-range\",frame={addr=\"0x[0-9a-f]+\",func=\"main\",args=[{name=\"argc\",value=\"1\"},{name=\"argv\",value="0x[0-9a-f]+\"}],file=\"main.cpp\",fullname=\".+main.cpp\",line=\"\d\"},thread-id=\"1\",stopped-threads=\"all\"
- # Linux: "*stopped,reason=\"end-stepping-range\",frame={addr="0x[0-9a-f]+\",func=\"__printf\",args=[{name=\"format\",value=\"0x[0-9a-f]+\"}],file=\"printf.c\",fullname=\".+printf.c\",line="\d+"},thread-id=\"1\",stopped-threads=\"all\"
+ # Linux:
+ # "*stopped,reason=\"end-stepping-range\",frame={addr="0x[0-9a-f]+\",func=\"__printf\",args=[{name=\"format\",value=\"0x[0-9a-f]+\"}],file=\"printf.c\",fullname=\".+printf.c\",line="\d+"},thread-id=\"1\",stopped-threads=\"all\"
self.runCmd("-interpreter-exec console \"thread step-in\"")
self.expect("\^done")
- it = self.expect([ "@\"argc=1\\\\r\\\\n\"",
- "\*stopped,reason=\"end-stepping-range\".+?func=\"(?!main).+?\"" ])
+ it = self.expect(["@\"argc=1\\\\r\\\\n\"",
+ "\*stopped,reason=\"end-stepping-range\".+?func=\"(?!main).+?\""])
if it == 0:
- self.expect("\*stopped,reason=\"end-stepping-range\".+?func=\"main\"")
+ self.expect(
+ "\*stopped,reason=\"end-stepping-range\".+?func=\"main\"")
- @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows
- @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
+ @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
def test_lldbmi_thread_step_over(self):
"""Test that 'lldb-mi --interpreter' can step over by "thread step-over" command."""
- self.spawnLldbMi(args = None)
+ self.spawnLldbMi(args=None)
# Load executable
self.runCmd("-file-exec-and-symbols %s" % self.myexe)
@@ -205,13 +213,13 @@ class MiInterpreterExecTestCase(lldbmi_testcase.MiTestCaseBase):
self.expect("@\"argc=1\\\\r\\\\n\"")
self.expect("\*stopped,reason=\"end-stepping-range\"")
- @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows
- @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
+ @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
@expectedFlakeyLinux("llvm.org/pr25470")
def test_lldbmi_thread_continue(self):
"""Test that 'lldb-mi --interpreter' can continue execution by "thread continue" command."""
- self.spawnLldbMi(args = None)
+ self.spawnLldbMi(args=None)
# Load executable
self.runCmd("-file-exec-and-symbols %s" % self.myexe)
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 277ffe70c1ca..a862609d6978 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-mi/lldbmi_testcase.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-mi/lldbmi_testcase.py
@@ -5,9 +5,9 @@ Base class for lldb-mi test cases.
from __future__ import print_function
-
from lldbsuite.test.lldbtest import *
+
class MiTestCaseBase(Base):
mydir = None
@@ -43,7 +43,7 @@ class MiTestCaseBase(Base):
self.child.setecho(True)
self.child.logfile_read = open(self.mylog, "w")
# wait until lldb-mi has started up and is ready to go
- self.expect(self.child_prompt, exactly = True)
+ self.expect(self.child_prompt, exactly=True)
def runCmd(self, cmd):
self.child.sendline(cmd)
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 197bfa80b3a0..e4cd98b22928 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-mi/signal/TestMiSignal.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-mi/signal/TestMiSignal.py
@@ -5,22 +5,22 @@ Test that the lldb-mi handles signals properly.
from __future__ import print_function
-
import lldbmi_testcase
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
+
class MiSignalTestCase(lldbmi_testcase.MiTestCaseBase):
mydir = TestBase.compute_mydir(__file__)
- @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows
- @skipIfFreeBSD # llvm.org/pr22411: Fails on FreeBSD apparently due to thread race conditions
+ @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
+ @skipIfFreeBSD # llvm.org/pr22411: Fails on FreeBSD apparently due to thread race conditions
def test_lldbmi_stopped_when_interrupt(self):
"""Test that 'lldb-mi --interpreter' interrupt and resume a looping app."""
- self.spawnLldbMi(args = None)
+ self.spawnLldbMi(args=None)
# Load executable
self.runCmd("-file-exec-and-symbols %s" % self.myexe)
@@ -41,23 +41,25 @@ class MiSignalTestCase(lldbmi_testcase.MiTestCaseBase):
# Test that -exec-interrupt can interrupt an execution
self.runCmd("-exec-interrupt")
- self.expect("\*stopped,reason=\"signal-received\",signal-name=\"SIGINT\",signal-meaning=\"Interrupt\",.+?thread-id=\"1\",stopped-threads=\"all\"")
+ self.expect(
+ "\*stopped,reason=\"signal-received\",signal-name=\"SIGINT\",signal-meaning=\"Interrupt\",.+?thread-id=\"1\",stopped-threads=\"all\"")
# Continue (to loop forever)
self.runCmd("-exec-continue")
self.expect("\^running")
# Test that Ctrl+C can interrupt an execution
- self.child.sendintr() #FIXME: here uses self.child directly
- self.expect("\*stopped,reason=\"signal-received\",signal-name=\"SIGINT\",signal-meaning=\"Interrupt\",.*thread-id=\"1\",stopped-threads=\"all\"")
+ self.child.sendintr() # FIXME: here uses self.child directly
+ self.expect(
+ "\*stopped,reason=\"signal-received\",signal-name=\"SIGINT\",signal-meaning=\"Interrupt\",.*thread-id=\"1\",stopped-threads=\"all\"")
- @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows
- @skipIfFreeBSD # llvm.org/pr22411: Fails on FreeBSD apparently due to thread race conditions
- @skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots
+ @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
+ @skipIfFreeBSD # llvm.org/pr22411: Fails on FreeBSD apparently due to thread race conditions
+ @skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots
def test_lldbmi_stopped_when_stopatentry_local(self):
"""Test that 'lldb-mi --interpreter' notifies after it was stopped on entry (local)."""
- self.spawnLldbMi(args = None)
+ self.spawnLldbMi(args=None)
# Load executable
self.runCmd("-file-exec-and-symbols %s" % self.myexe)
@@ -70,9 +72,12 @@ class MiSignalTestCase(lldbmi_testcase.MiTestCaseBase):
# Test that *stopped is printed
# Note that message is different in Darwin and Linux:
# Darwin: "*stopped,reason=\"signal-received\",signal-name=\"SIGSTOP\",signal-meaning=\"Stop\",frame={level=\"0\",addr=\"0x[0-9a-f]+\",func=\"_dyld_start\",file=\"??\",fullname=\"??\",line=\"-1\"},thread-id=\"1\",stopped-threads=\"all\"
- # Linux: "*stopped,reason=\"end-stepping-range\",frame={addr=\"0x[0-9a-f]+\",func=\"??\",args=[],file=\"??\",fullname=\"??\",line=\"-1\"},thread-id=\"1\",stopped-threads=\"all\"
- self.expect([ "\*stopped,reason=\"signal-received\",signal-name=\"SIGSTOP\",signal-meaning=\"Stop\",frame=\{level=\"0\",addr=\"0x[0-9a-f]+\",func=\"_dyld_start\",file=\"\?\?\",fullname=\"\?\?\",line=\"-1\"\},thread-id=\"1\",stopped-threads=\"all\"",
- "\*stopped,reason=\"end-stepping-range\",frame={addr=\"0x[0-9a-f]+\",func=\"\?\?\",args=\[\],file=\"\?\?\",fullname=\"\?\?\",line=\"-1\"},thread-id=\"1\",stopped-threads=\"all\"" ])
+ # Linux:
+ # "*stopped,reason=\"end-stepping-range\",frame={addr=\"0x[0-9a-f]+\",func=\"??\",args=[],file=\"??\",fullname=\"??\",line=\"-1\"},thread-id=\"1\",stopped-threads=\"all\"
+ self.expect(
+ [
+ "\*stopped,reason=\"signal-received\",signal-name=\"SIGSTOP\",signal-meaning=\"Stop\",frame=\{level=\"0\",addr=\"0x[0-9a-f]+\",func=\"_dyld_start\",file=\"\?\?\",fullname=\"\?\?\",line=\"-1\"\},thread-id=\"1\",stopped-threads=\"all\"",
+ "\*stopped,reason=\"end-stepping-range\",frame={addr=\"0x[0-9a-f]+\",func=\"\?\?\",args=\[\],file=\"\?\?\",fullname=\"\?\?\",line=\"-1\"},thread-id=\"1\",stopped-threads=\"all\""])
# Run to main to make sure we have not exited the application
self.runCmd("-break-insert -f main")
@@ -81,7 +86,7 @@ class MiSignalTestCase(lldbmi_testcase.MiTestCaseBase):
self.expect("\^running")
self.expect("\*stopped,reason=\"breakpoint-hit\"")
- @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows
+ @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipUnlessDarwin
def test_lldbmi_stopped_when_stopatentry_remote(self):
"""Test that 'lldb-mi --interpreter' notifies after it was stopped on entry (remote)."""
@@ -93,19 +98,25 @@ class MiSignalTestCase(lldbmi_testcase.MiTestCaseBase):
self.skipTest("debugserver exe not found")
hostname = "localhost"
import random
- port = 12000 + random.randint(0,3999) # the same as GdbRemoteTestCaseBase.get_next_port
+ # the same as GdbRemoteTestCaseBase.get_next_port
+ port = 12000 + random.randint(0, 3999)
import pexpect
- debugserver_child = pexpect.spawn("%s %s:%d" % (debugserver_exe, hostname, port))
- self.addTearDownHook(lambda: debugserver_child.terminate(force = True))
+ debugserver_child = pexpect.spawn(
+ "%s %s:%d" %
+ (debugserver_exe, hostname, port))
+ self.addTearDownHook(lambda: debugserver_child.terminate(force=True))
- self.spawnLldbMi(args = None)
+ self.spawnLldbMi(args=None)
# Connect to debugserver
- self.runCmd("-interpreter-exec command \"platform select remote-macosx --sysroot /\"")
+ self.runCmd(
+ "-interpreter-exec command \"platform select remote-macosx --sysroot /\"")
self.expect("\^done")
self.runCmd("-file-exec-and-symbols %s" % self.myexe)
self.expect("\^done")
- self.runCmd("-interpreter-exec command \"process connect connect://%s:%d\"" % (hostname, port))
+ self.runCmd(
+ "-interpreter-exec command \"process connect connect://%s:%d\"" %
+ (hostname, port))
self.expect("\^done")
# Run with stop-at-entry flag
@@ -113,19 +124,20 @@ class MiSignalTestCase(lldbmi_testcase.MiTestCaseBase):
self.expect("\^done")
# Test that *stopped is printed
- self.expect("\*stopped,reason=\"signal-received\",signal-name=\"SIGSTOP\",signal-meaning=\"Stop\",.+?thread-id=\"1\",stopped-threads=\"all\"")
+ self.expect(
+ "\*stopped,reason=\"signal-received\",signal-name=\"SIGSTOP\",signal-meaning=\"Stop\",.+?thread-id=\"1\",stopped-threads=\"all\"")
# Exit
self.runCmd("-gdb-exit")
self.expect("\^exit")
- @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows
- @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
- @skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots
+ @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
+ @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots
def test_lldbmi_stopped_when_segfault_local(self):
"""Test that 'lldb-mi --interpreter' notifies after it was stopped when segfault occurred (local)."""
- self.spawnLldbMi(args = None)
+ self.spawnLldbMi(args=None)
# Load executable
self.runCmd("-file-exec-and-symbols %s" % self.myexe)
@@ -147,9 +159,11 @@ class MiSignalTestCase(lldbmi_testcase.MiTestCaseBase):
# Test that *stopped is printed
# Note that message is different in Darwin and Linux:
# Darwin: "*stopped,reason=\"exception-received\",exception=\"EXC_BAD_ACCESS (code=1, address=0x0)\",thread-id=\"1\",stopped-threads=\"all\""
- # Linux: "*stopped,reason=\"exception-received\",exception=\"invalid address (fault address: 0x0)\",thread-id=\"1\",stopped-threads=\"all\""
- self.expect([ "\*stopped,reason=\"exception-received\",exception=\"EXC_BAD_ACCESS \(code=1, address=0x0\)\",thread-id=\"1\",stopped-threads=\"all\"",
- "\*stopped,reason=\"exception-received\",exception=\"invalid address \(fault address: 0x0\)\",thread-id=\"1\",stopped-threads=\"all\"" ])
+ # Linux: "*stopped,reason=\"exception-received\",exception=\"invalid
+ # address (fault address:
+ # 0x0)\",thread-id=\"1\",stopped-threads=\"all\""
+ self.expect(["\*stopped,reason=\"exception-received\",exception=\"EXC_BAD_ACCESS \(code=1, address=0x0\)\",thread-id=\"1\",stopped-threads=\"all\"",
+ "\*stopped,reason=\"exception-received\",exception=\"invalid address \(fault address: 0x0\)\",thread-id=\"1\",stopped-threads=\"all\""])
@skipUnlessDarwin
def test_lldbmi_stopped_when_segfault_remote(self):
@@ -162,27 +176,34 @@ class MiSignalTestCase(lldbmi_testcase.MiTestCaseBase):
self.skipTest("debugserver exe not found")
hostname = "localhost"
import random
- port = 12000 + random.randint(0,3999) # the same as GdbRemoteTestCaseBase.get_next_port
+ # the same as GdbRemoteTestCaseBase.get_next_port
+ port = 12000 + random.randint(0, 3999)
import pexpect
- debugserver_child = pexpect.spawn("%s %s:%d" % (debugserver_exe, hostname, port))
- self.addTearDownHook(lambda: debugserver_child.terminate(force = True))
+ debugserver_child = pexpect.spawn(
+ "%s %s:%d" %
+ (debugserver_exe, hostname, port))
+ self.addTearDownHook(lambda: debugserver_child.terminate(force=True))
- self.spawnLldbMi(args = None)
+ self.spawnLldbMi(args=None)
# Connect to debugserver
- self.runCmd("-interpreter-exec command \"platform select remote-macosx --sysroot /\"")
+ self.runCmd(
+ "-interpreter-exec command \"platform select remote-macosx --sysroot /\"")
self.expect("\^done")
self.runCmd("-file-exec-and-symbols %s" % self.myexe)
self.expect("\^done")
- self.runCmd("-interpreter-exec command \"process connect connect://%s:%d\"" % (hostname, port))
+ self.runCmd(
+ "-interpreter-exec command \"process connect connect://%s:%d\"" %
+ (hostname, port))
self.expect("\^done")
# Run to main
self.runCmd("-break-insert -f main")
self.expect("\^done,bkpt={number=\"1\"")
- #FIXME -exec-run doesn't work
- self.runCmd("-interpreter-exec command \"process launch\"") #FIXME: self.runCmd("-exec-run")
- self.expect("\^done") #FIXME: self.expect("\^running")
+ # FIXME -exec-run doesn't work
+ # FIXME: self.runCmd("-exec-run")
+ self.runCmd("-interpreter-exec command \"process launch\"")
+ self.expect("\^done") # FIXME: self.expect("\^running")
self.expect("\*stopped,reason=\"breakpoint-hit\"")
# Set do_segfault=1 and run (to cause a segfault error)
@@ -192,7 +213,8 @@ class MiSignalTestCase(lldbmi_testcase.MiTestCaseBase):
self.expect("\^running")
# Test that *stopped is printed
- self.expect("\*stopped,reason=\"exception-received\",exception=\"EXC_BAD_ACCESS \(code=1, address=0x0\)\",thread-id=\"1\",stopped-threads=\"all\"")
+ self.expect(
+ "\*stopped,reason=\"exception-received\",exception=\"EXC_BAD_ACCESS \(code=1, address=0x0\)\",thread-id=\"1\",stopped-threads=\"all\"")
# Exit
self.runCmd("-gdb-exit")
diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/stack/TestMiStack.py b/packages/Python/lldbsuite/test/tools/lldb-mi/stack/TestMiStack.py
index 54ed91951333..454597c1c5dd 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-mi/stack/TestMiStack.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-mi/stack/TestMiStack.py
@@ -5,22 +5,22 @@ Test lldb-mi -stack-xxx commands.
from __future__ import print_function
-
import lldbmi_testcase
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
+
class MiStackTestCase(lldbmi_testcase.MiTestCaseBase):
mydir = TestBase.compute_mydir(__file__)
- @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows
- @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
+ @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
def test_lldbmi_stack_list_arguments(self):
"""Test that 'lldb-mi --interpreter' can shows arguments."""
- self.spawnLldbMi(args = None)
+ self.spawnLldbMi(args=None)
# Load executable
self.runCmd("-file-exec-and-symbols %s" % self.myexe)
@@ -33,55 +33,66 @@ class MiStackTestCase(lldbmi_testcase.MiTestCaseBase):
self.expect("\^running")
self.expect("\*stopped,reason=\"breakpoint-hit\"")
- # Test that -stack-list-arguments lists empty stack arguments if range is empty
+ # Test that -stack-list-arguments lists empty stack arguments if range
+ # is empty
self.runCmd("-stack-list-arguments 0 1 0")
self.expect("\^done,stack-args=\[\]")
# Test that -stack-list-arguments lists stack arguments without values
# (and that low-frame and high-frame are optional)
self.runCmd("-stack-list-arguments 0")
- self.expect("\^done,stack-args=\[frame={level=\"0\",args=\[name=\"argc\",name=\"argv\"\]}")
+ self.expect(
+ "\^done,stack-args=\[frame={level=\"0\",args=\[name=\"argc\",name=\"argv\"\]}")
self.runCmd("-stack-list-arguments --no-values")
- self.expect("\^done,stack-args=\[frame={level=\"0\",args=\[name=\"argc\",name=\"argv\"\]}")
+ self.expect(
+ "\^done,stack-args=\[frame={level=\"0\",args=\[name=\"argc\",name=\"argv\"\]}")
# Test that -stack-list-arguments lists stack arguments with all values
self.runCmd("-stack-list-arguments 1 0 0")
- self.expect("\^done,stack-args=\[frame={level=\"0\",args=\[{name=\"argc\",value=\"1\"},{name=\"argv\",value=\".*\"}\]}\]")
+ self.expect(
+ "\^done,stack-args=\[frame={level=\"0\",args=\[{name=\"argc\",value=\"1\"},{name=\"argv\",value=\".*\"}\]}\]")
self.runCmd("-stack-list-arguments --all-values 0 0")
- self.expect("\^done,stack-args=\[frame={level=\"0\",args=\[{name=\"argc\",value=\"1\"},{name=\"argv\",value=\".*\"}\]}\]")
+ self.expect(
+ "\^done,stack-args=\[frame={level=\"0\",args=\[{name=\"argc\",value=\"1\"},{name=\"argv\",value=\".*\"}\]}\]")
- # Test that -stack-list-arguments lists stack arguments with simple values
+ # Test that -stack-list-arguments lists stack arguments with simple
+ # values
self.runCmd("-stack-list-arguments 2 0 1")
- self.expect("\^done,stack-args=\[frame={level=\"0\",args=\[{name=\"argc\",type=\"int\",value=\"1\"},{name=\"argv\",type=\"const char \*\*\",value=\".*\"}\]}")
+ self.expect(
+ "\^done,stack-args=\[frame={level=\"0\",args=\[{name=\"argc\",type=\"int\",value=\"1\"},{name=\"argv\",type=\"const char \*\*\",value=\".*\"}\]}")
self.runCmd("-stack-list-arguments --simple-values 0 1")
- self.expect("\^done,stack-args=\[frame={level=\"0\",args=\[{name=\"argc\",type=\"int\",value=\"1\"},{name=\"argv\",type=\"const char \*\*\",value=\".*\"}\]}")
+ self.expect(
+ "\^done,stack-args=\[frame={level=\"0\",args=\[{name=\"argc\",type=\"int\",value=\"1\"},{name=\"argv\",type=\"const char \*\*\",value=\".*\"}\]}")
- # Test that an invalid low-frame is handled
+ # Test that an invalid low-frame is handled
# FIXME: -1 is treated as unsigned int
self.runCmd("-stack-list-arguments 0 -1 0")
- #self.expect("\^error")
+ # self.expect("\^error")
self.runCmd("-stack-list-arguments 0 0")
- self.expect("\^error,msg=\"Command 'stack-list-arguments'\. Thread frame range invalid\"")
+ self.expect(
+ "\^error,msg=\"Command 'stack-list-arguments'\. Thread frame range invalid\"")
# Test that an invalid high-frame is handled
# FIXME: -1 is treated as unsigned int
self.runCmd("-stack-list-arguments 0 0 -1")
- #self.expect("\^error")
+ # self.expect("\^error")
# Test that a missing low-frame or high-frame is handled
self.runCmd("-stack-list-arguments 0 0")
- self.expect("\^error,msg=\"Command 'stack-list-arguments'\. Thread frame range invalid\"")
+ self.expect(
+ "\^error,msg=\"Command 'stack-list-arguments'\. Thread frame range invalid\"")
- # Test that an invalid low-frame is handled
+ # Test that an invalid low-frame is handled
self.runCmd("-stack-list-arguments 0 0")
- self.expect("\^error,msg=\"Command 'stack-list-arguments'\. Thread frame range invalid\"")
+ self.expect(
+ "\^error,msg=\"Command 'stack-list-arguments'\. Thread frame range invalid\"")
- @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows
- @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
+ @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
def test_lldbmi_stack_list_locals(self):
"""Test that 'lldb-mi --interpreter' can shows local variables."""
- self.spawnLldbMi(args = None)
+ self.spawnLldbMi(args=None)
# Load executable
self.runCmd("-file-exec-and-symbols %s" % self.myexe)
@@ -111,16 +122,20 @@ class MiStackTestCase(lldbmi_testcase.MiTestCaseBase):
# Test -stack-list-locals: use 1 or --all-values
self.runCmd("-stack-list-locals 1")
- self.expect("\^done,locals=\[{name=\"a\",value=\"10\"},{name=\"b\",value=\"20\"}\]")
+ self.expect(
+ "\^done,locals=\[{name=\"a\",value=\"10\"},{name=\"b\",value=\"20\"}\]")
self.runCmd("-stack-list-locals --all-values")
- self.expect("\^done,locals=\[{name=\"a\",value=\"10\"},{name=\"b\",value=\"20\"}\]")
+ self.expect(
+ "\^done,locals=\[{name=\"a\",value=\"10\"},{name=\"b\",value=\"20\"}\]")
# Test -stack-list-locals: use 2 or --simple-values
self.runCmd("-stack-list-locals 2")
- self.expect("\^done,locals=\[{name=\"a\",type=\"int\",value=\"10\"},{name=\"b\",type=\"int\",value=\"20\"}\]")
+ self.expect(
+ "\^done,locals=\[{name=\"a\",type=\"int\",value=\"10\"},{name=\"b\",type=\"int\",value=\"20\"}\]")
self.runCmd("-stack-list-locals --simple-values")
- self.expect("\^done,locals=\[{name=\"a\",type=\"int\",value=\"10\"},{name=\"b\",type=\"int\",value=\"20\"}\]")
-
+ self.expect(
+ "\^done,locals=\[{name=\"a\",type=\"int\",value=\"10\"},{name=\"b\",type=\"int\",value=\"20\"}\]")
+
# Test struct local variable:
# Run to BP_local_struct_test
line = line_number('main.cpp', '// BP_local_struct_test')
@@ -129,7 +144,7 @@ class MiStackTestCase(lldbmi_testcase.MiTestCaseBase):
self.runCmd("-exec-continue")
self.expect("\^running")
self.expect("\*stopped,reason=\"breakpoint-hit\"")
-
+
# Test -stack-list-locals: use 0 or --no-values
self.runCmd("-stack-list-locals 0")
self.expect("\^done,locals=\[name=\"var_c\"\]")
@@ -138,16 +153,18 @@ class MiStackTestCase(lldbmi_testcase.MiTestCaseBase):
# Test -stack-list-locals: use 1 or --all-values
self.runCmd("-stack-list-locals 1")
- self.expect("\^done,locals=\[{name=\"var_c\",value=\"{var_a = 10, var_b = 97 'a', inner_ = {var_d = 30}}\"}\]")
+ self.expect(
+ "\^done,locals=\[{name=\"var_c\",value=\"{var_a = 10, var_b = 97 'a', inner_ = {var_d = 30}}\"}\]")
self.runCmd("-stack-list-locals --all-values")
- self.expect("\^done,locals=\[{name=\"var_c\",value=\"{var_a = 10, var_b = 97 'a', inner_ = {var_d = 30}}\"}\]")
+ self.expect(
+ "\^done,locals=\[{name=\"var_c\",value=\"{var_a = 10, var_b = 97 'a', inner_ = {var_d = 30}}\"}\]")
# Test -stack-list-locals: use 2 or --simple-values
self.runCmd("-stack-list-locals 2")
self.expect("\^done,locals=\[{name=\"var_c\",type=\"my_type\"}\]")
self.runCmd("-stack-list-locals --simple-values")
self.expect("\^done,locals=\[{name=\"var_c\",type=\"my_type\"}\]")
-
+
# Test array local variable:
# Run to BP_local_array_test
line = line_number('main.cpp', '// BP_local_array_test')
@@ -156,7 +173,7 @@ class MiStackTestCase(lldbmi_testcase.MiTestCaseBase):
self.runCmd("-exec-continue")
self.expect("\^running")
self.expect("\*stopped,reason=\"breakpoint-hit\"")
-
+
# Test -stack-list-locals: use 0 or --no-values
self.runCmd("-stack-list-locals 0")
self.expect("\^done,locals=\[name=\"array\"\]")
@@ -165,16 +182,18 @@ class MiStackTestCase(lldbmi_testcase.MiTestCaseBase):
# Test -stack-list-locals: use 1 or --all-values
self.runCmd("-stack-list-locals 1")
- self.expect("\^done,locals=\[{name=\"array\",value=\"{\[0\] = 100, \[1\] = 200, \[2\] = 300}\"}\]")
+ self.expect(
+ "\^done,locals=\[{name=\"array\",value=\"{\[0\] = 100, \[1\] = 200, \[2\] = 300}\"}\]")
self.runCmd("-stack-list-locals --all-values")
- self.expect("\^done,locals=\[{name=\"array\",value=\"{\[0\] = 100, \[1\] = 200, \[2\] = 300}\"}\]")
+ self.expect(
+ "\^done,locals=\[{name=\"array\",value=\"{\[0\] = 100, \[1\] = 200, \[2\] = 300}\"}\]")
# Test -stack-list-locals: use 2 or --simple-values
self.runCmd("-stack-list-locals 2")
self.expect("\^done,locals=\[{name=\"array\",type=\"int \[3\]\"}\]")
self.runCmd("-stack-list-locals --simple-values")
self.expect("\^done,locals=\[{name=\"array\",type=\"int \[3\]\"}\]")
-
+
# Test pointers as local variable:
# Run to BP_local_pointer_test
line = line_number('main.cpp', '// BP_local_pointer_test')
@@ -183,26 +202,32 @@ class MiStackTestCase(lldbmi_testcase.MiTestCaseBase):
self.runCmd("-exec-continue")
self.expect("\^running")
self.expect("\*stopped,reason=\"breakpoint-hit\"")
-
+
# Test -stack-list-locals: use 0 or --no-values
self.runCmd("-stack-list-locals 0")
- self.expect("\^done,locals=\[name=\"test_str\",name=\"var_e\",name=\"ptr\"\]")
+ self.expect(
+ "\^done,locals=\[name=\"test_str\",name=\"var_e\",name=\"ptr\"\]")
self.runCmd("-stack-list-locals --no-values")
- self.expect("\^done,locals=\[name=\"test_str\",name=\"var_e\",name=\"ptr\"\]")
+ self.expect(
+ "\^done,locals=\[name=\"test_str\",name=\"var_e\",name=\"ptr\"\]")
# Test -stack-list-locals: use 1 or --all-values
self.runCmd("-stack-list-locals 1")
- self.expect("\^done,locals=\[{name=\"test_str\",value=\".*?Rakaposhi.*?\"},{name=\"var_e\",value=\"24\"},{name=\"ptr\",value=\".*?\"}\]")
+ self.expect(
+ "\^done,locals=\[{name=\"test_str\",value=\".*?Rakaposhi.*?\"},{name=\"var_e\",value=\"24\"},{name=\"ptr\",value=\".*?\"}\]")
self.runCmd("-stack-list-locals --all-values")
- self.expect("\^done,locals=\[{name=\"test_str\",value=\".*?Rakaposhi.*?\"},{name=\"var_e\",value=\"24\"},{name=\"ptr\",value=\".*?\"}\]")
+ self.expect(
+ "\^done,locals=\[{name=\"test_str\",value=\".*?Rakaposhi.*?\"},{name=\"var_e\",value=\"24\"},{name=\"ptr\",value=\".*?\"}\]")
# Test -stack-list-locals: use 2 or --simple-values
self.runCmd("-stack-list-locals 2")
- self.expect("\^done,locals=\[{name=\"test_str\",type=\"const char \*\",value=\".*?Rakaposhi.*?\"},{name=\"var_e\",type=\"int\",value=\"24\"},{name=\"ptr\",type=\"int \*\",value=\".*?\"}\]")
+ self.expect(
+ "\^done,locals=\[{name=\"test_str\",type=\"const char \*\",value=\".*?Rakaposhi.*?\"},{name=\"var_e\",type=\"int\",value=\"24\"},{name=\"ptr\",type=\"int \*\",value=\".*?\"}\]")
self.runCmd("-stack-list-locals --simple-values")
- self.expect("\^done,locals=\[{name=\"test_str\",type=\"const char \*\",value=\".*?Rakaposhi.*?\"},{name=\"var_e\",type=\"int\",value=\"24\"},{name=\"ptr\",type=\"int \*\",value=\".*?\"}\]")
-
- # Test -stack-list-locals in a function with catch clause,
+ self.expect(
+ "\^done,locals=\[{name=\"test_str\",type=\"const char \*\",value=\".*?Rakaposhi.*?\"},{name=\"var_e\",type=\"int\",value=\"24\"},{name=\"ptr\",type=\"int \*\",value=\".*?\"}\]")
+
+ # Test -stack-list-locals in a function with catch clause,
# having unnamed parameter
# Run to BP_catch_unnamed
line = line_number('main.cpp', '// BP_catch_unnamed')
@@ -215,12 +240,13 @@ class MiStackTestCase(lldbmi_testcase.MiTestCaseBase):
# Test -stack-list-locals: use --no-values
self.runCmd("-stack-list-locals --no-values")
self.expect("\^done,locals=\[name=\"i\",name=\"j\"\]")
- @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows
- @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+
+ @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
+ @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
def test_lldbmi_stack_list_variables(self):
"""Test that 'lldb-mi --interpreter' can shows local variables and arguments."""
- self.spawnLldbMi(args = None)
+ self.spawnLldbMi(args=None)
# Load executable
self.runCmd("-file-exec-and-symbols %s" % self.myexe)
@@ -244,22 +270,28 @@ class MiStackTestCase(lldbmi_testcase.MiTestCaseBase):
# Test -stack-list-variables: use 0 or --no-values
self.runCmd("-stack-list-variables 0")
- self.expect("\^done,variables=\[{arg=\"1\",name=\"c\"},{arg=\"1\",name=\"d\"},{name=\"a\"},{name=\"b\"}\]")
+ self.expect(
+ "\^done,variables=\[{arg=\"1\",name=\"c\"},{arg=\"1\",name=\"d\"},{name=\"a\"},{name=\"b\"}\]")
self.runCmd("-stack-list-variables --no-values")
- self.expect("\^done,variables=\[{arg=\"1\",name=\"c\"},{arg=\"1\",name=\"d\"},{name=\"a\"},{name=\"b\"}\]")
+ self.expect(
+ "\^done,variables=\[{arg=\"1\",name=\"c\"},{arg=\"1\",name=\"d\"},{name=\"a\"},{name=\"b\"}\]")
# Test -stack-list-variables: use 1 or --all-values
self.runCmd("-stack-list-variables 1")
- self.expect("\^done,variables=\[{arg=\"1\",name=\"c\",value=\"30\"},{arg=\"1\",name=\"d\",value=\"40\"},{name=\"a\",value=\"10\"},{name=\"b\",value=\"20\"}\]")
+ self.expect(
+ "\^done,variables=\[{arg=\"1\",name=\"c\",value=\"30\"},{arg=\"1\",name=\"d\",value=\"40\"},{name=\"a\",value=\"10\"},{name=\"b\",value=\"20\"}\]")
self.runCmd("-stack-list-variables --all-values")
- self.expect("\^done,variables=\[{arg=\"1\",name=\"c\",value=\"30\"},{arg=\"1\",name=\"d\",value=\"40\"},{name=\"a\",value=\"10\"},{name=\"b\",value=\"20\"}\]")
+ self.expect(
+ "\^done,variables=\[{arg=\"1\",name=\"c\",value=\"30\"},{arg=\"1\",name=\"d\",value=\"40\"},{name=\"a\",value=\"10\"},{name=\"b\",value=\"20\"}\]")
# Test -stack-list-variables: use 2 or --simple-values
self.runCmd("-stack-list-variables 2")
- self.expect("\^done,variables=\[{arg=\"1\",name=\"c\",type=\"int\",value=\"30\"},{arg=\"1\",name=\"d\",type=\"int\",value=\"40\"},{name=\"a\",type=\"int\",value=\"10\"},{name=\"b\",type=\"int\",value=\"20\"}\]")
+ self.expect(
+ "\^done,variables=\[{arg=\"1\",name=\"c\",type=\"int\",value=\"30\"},{arg=\"1\",name=\"d\",type=\"int\",value=\"40\"},{name=\"a\",type=\"int\",value=\"10\"},{name=\"b\",type=\"int\",value=\"20\"}\]")
self.runCmd("-stack-list-variables --simple-values")
- self.expect("\^done,variables=\[{arg=\"1\",name=\"c\",type=\"int\",value=\"30\"},{arg=\"1\",name=\"d\",type=\"int\",value=\"40\"},{name=\"a\",type=\"int\",value=\"10\"},{name=\"b\",type=\"int\",value=\"20\"}\]")
-
+ self.expect(
+ "\^done,variables=\[{arg=\"1\",name=\"c\",type=\"int\",value=\"30\"},{arg=\"1\",name=\"d\",type=\"int\",value=\"40\"},{name=\"a\",type=\"int\",value=\"10\"},{name=\"b\",type=\"int\",value=\"20\"}\]")
+
# Test struct local variable:
# Run to BP_local_struct_test
line = line_number('main.cpp', '// BP_local_struct_test_with_args')
@@ -268,25 +300,31 @@ class MiStackTestCase(lldbmi_testcase.MiTestCaseBase):
self.runCmd("-exec-continue")
self.expect("\^running")
self.expect("\*stopped,reason=\"breakpoint-hit\"")
-
+
# Test -stack-list-variables: use 0 or --no-values
self.runCmd("-stack-list-variables 0")
- self.expect("\^done,variables=\[{arg=\"1\",name=\"var_e\"},{name=\"var_c\"}\]")
+ self.expect(
+ "\^done,variables=\[{arg=\"1\",name=\"var_e\"},{name=\"var_c\"}\]")
self.runCmd("-stack-list-variables --no-values")
- self.expect("\^done,variables=\[{arg=\"1\",name=\"var_e\"},{name=\"var_c\"}\]")
+ self.expect(
+ "\^done,variables=\[{arg=\"1\",name=\"var_e\"},{name=\"var_c\"}\]")
# Test -stack-list-variables: use 1 or --all-values
self.runCmd("-stack-list-variables 1")
- self.expect("\^done,variables=\[{arg=\"1\",name=\"var_e\",value=\"{var_a = 20, var_b = 98 'b', inner_ = {var_d = 40}}\"},{name=\"var_c\",value=\"{var_a = 10, var_b = 97 'a', inner_ = {var_d = 30}}\"}\]")
+ self.expect(
+ "\^done,variables=\[{arg=\"1\",name=\"var_e\",value=\"{var_a = 20, var_b = 98 'b', inner_ = {var_d = 40}}\"},{name=\"var_c\",value=\"{var_a = 10, var_b = 97 'a', inner_ = {var_d = 30}}\"}\]")
self.runCmd("-stack-list-variables --all-values")
- self.expect("\^done,variables=\[{arg=\"1\",name=\"var_e\",value=\"{var_a = 20, var_b = 98 'b', inner_ = {var_d = 40}}\"},{name=\"var_c\",value=\"{var_a = 10, var_b = 97 'a', inner_ = {var_d = 30}}\"}\]")
+ self.expect(
+ "\^done,variables=\[{arg=\"1\",name=\"var_e\",value=\"{var_a = 20, var_b = 98 'b', inner_ = {var_d = 40}}\"},{name=\"var_c\",value=\"{var_a = 10, var_b = 97 'a', inner_ = {var_d = 30}}\"}\]")
# Test -stack-list-variables: use 2 or --simple-values
self.runCmd("-stack-list-variables 2")
- self.expect("\^done,variables=\[{arg=\"1\",name=\"var_e\",type=\"my_type\"},{name=\"var_c\",type=\"my_type\"}\]")
+ self.expect(
+ "\^done,variables=\[{arg=\"1\",name=\"var_e\",type=\"my_type\"},{name=\"var_c\",type=\"my_type\"}\]")
self.runCmd("-stack-list-variables --simple-values")
- self.expect("\^done,variables=\[{arg=\"1\",name=\"var_e\",type=\"my_type\"},{name=\"var_c\",type=\"my_type\"}\]")
-
+ self.expect(
+ "\^done,variables=\[{arg=\"1\",name=\"var_e\",type=\"my_type\"},{name=\"var_c\",type=\"my_type\"}\]")
+
# Test array local variable:
# Run to BP_local_array_test
line = line_number('main.cpp', '// BP_local_array_test_with_args')
@@ -295,25 +333,31 @@ class MiStackTestCase(lldbmi_testcase.MiTestCaseBase):
self.runCmd("-exec-continue")
self.expect("\^running")
self.expect("\*stopped,reason=\"breakpoint-hit\"")
-
+
# Test -stack-list-variables: use 0 or --no-values
self.runCmd("-stack-list-variables 0")
- self.expect("\^done,variables=\[{arg=\"1\",name=\"other_array\"},{name=\"array\"}\]")
+ self.expect(
+ "\^done,variables=\[{arg=\"1\",name=\"other_array\"},{name=\"array\"}\]")
self.runCmd("-stack-list-variables --no-values")
- self.expect("\^done,variables=\[{arg=\"1\",name=\"other_array\"},{name=\"array\"}\]")
+ self.expect(
+ "\^done,variables=\[{arg=\"1\",name=\"other_array\"},{name=\"array\"}\]")
# Test -stack-list-variables: use 1 or --all-values
self.runCmd("-stack-list-variables 1")
- self.expect("\^done,variables=\[{arg=\"1\",name=\"other_array\",value=\".*?\"},{name=\"array\",value=\"{\[0\] = 100, \[1\] = 200, \[2\] = 300}\"}\]")
+ self.expect(
+ "\^done,variables=\[{arg=\"1\",name=\"other_array\",value=\".*?\"},{name=\"array\",value=\"{\[0\] = 100, \[1\] = 200, \[2\] = 300}\"}\]")
self.runCmd("-stack-list-variables --all-values")
- self.expect("\^done,variables=\[{arg=\"1\",name=\"other_array\",value=\".*?\"},{name=\"array\",value=\"{\[0\] = 100, \[1\] = 200, \[2\] = 300}\"}\]")
+ self.expect(
+ "\^done,variables=\[{arg=\"1\",name=\"other_array\",value=\".*?\"},{name=\"array\",value=\"{\[0\] = 100, \[1\] = 200, \[2\] = 300}\"}\]")
# Test -stack-list-variables: use 2 or --simple-values
self.runCmd("-stack-list-variables 2")
- self.expect("\^done,variables=\[{arg=\"1\",name=\"other_array\",type=\"int \*\",value=\".*?\"},{name=\"array\",type=\"int \[3\]\"}\]")
+ self.expect(
+ "\^done,variables=\[{arg=\"1\",name=\"other_array\",type=\"int \*\",value=\".*?\"},{name=\"array\",type=\"int \[3\]\"}\]")
self.runCmd("-stack-list-variables --simple-values")
- self.expect("\^done,variables=\[{arg=\"1\",name=\"other_array\",type=\"int \*\",value=\".*?\"},{name=\"array\",type=\"int \[3\]\"}\]")
-
+ self.expect(
+ "\^done,variables=\[{arg=\"1\",name=\"other_array\",type=\"int \*\",value=\".*?\"},{name=\"array\",type=\"int \[3\]\"}\]")
+
# Test pointers as local variable:
# Run to BP_local_pointer_test
line = line_number('main.cpp', '// BP_local_pointer_test_with_args')
@@ -322,12 +366,14 @@ class MiStackTestCase(lldbmi_testcase.MiTestCaseBase):
self.runCmd("-exec-continue")
self.expect("\^running")
self.expect("\*stopped,reason=\"breakpoint-hit\"")
-
+
# Test -stack-list-variables: use 0 or --no-values
self.runCmd("-stack-list-variables 0")
- self.expect("\^done,variables=\[{arg=\"1\",name=\"arg_str\"},{arg=\"1\",name=\"arg_ptr\"},{name=\"test_str\"},{name=\"var_e\"},{name=\"ptr\"}\]")
+ self.expect(
+ "\^done,variables=\[{arg=\"1\",name=\"arg_str\"},{arg=\"1\",name=\"arg_ptr\"},{name=\"test_str\"},{name=\"var_e\"},{name=\"ptr\"}\]")
self.runCmd("-stack-list-variables --no-values")
- self.expect("\^done,variables=\[{arg=\"1\",name=\"arg_str\"},{arg=\"1\",name=\"arg_ptr\"},{name=\"test_str\"},{name=\"var_e\"},{name=\"ptr\"}\]")
+ self.expect(
+ "\^done,variables=\[{arg=\"1\",name=\"arg_str\"},{arg=\"1\",name=\"arg_ptr\"},{name=\"test_str\"},{name=\"var_e\"},{name=\"ptr\"}\]")
# Test -stack-list-variables: use 1 or --all-values
self.runCmd("-stack-list-variables 1")
@@ -340,13 +386,13 @@ class MiStackTestCase(lldbmi_testcase.MiTestCaseBase):
self.expect("\^done,variables=\[{arg=\"1\",name=\"arg_str\",type=\"const char \*\",value=\".*?String.*?\"},{arg=\"1\",name=\"arg_ptr\",type=\"int \*\",value=\".*?\"},{name=\"test_str\",type=\"const char \*\",value=\".*?Rakaposhi.*?\"},{name=\"var_e\",type=\"int\",value=\"24\"},{name=\"ptr\",type=\"int \*\",value=\".*?\"}\]")
self.runCmd("-stack-list-variables --simple-values")
self.expect("\^done,variables=\[{arg=\"1\",name=\"arg_str\",type=\"const char \*\",value=\".*?String.*?\"},{arg=\"1\",name=\"arg_ptr\",type=\"int \*\",value=\".*?\"},{name=\"test_str\",type=\"const char \*\",value=\".*?Rakaposhi.*?\"},{name=\"var_e\",type=\"int\",value=\"24\"},{name=\"ptr\",type=\"int \*\",value=\".*?\"}\]")
-
- @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows
- @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+
+ @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
+ @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
def test_lldbmi_stack_info_depth(self):
"""Test that 'lldb-mi --interpreter' can shows depth of the stack."""
- self.spawnLldbMi(args = None)
+ self.spawnLldbMi(args=None)
# Load executable
self.runCmd("-file-exec-and-symbols %s" % self.myexe)
@@ -365,26 +411,27 @@ class MiStackTestCase(lldbmi_testcase.MiTestCaseBase):
self.expect("\^done,depth=\"[1-9]\"")
# Test that max-depth restricts check of stack depth
- #FIXME: max-depth argument is ignored
+ # FIXME: max-depth argument is ignored
self.runCmd("-stack-info-depth 1")
- #self.expect("\^done,depth=\"1\"")
+ # self.expect("\^done,depth=\"1\"")
# Test that invalid max-depth argument is handled
- #FIXME: max-depth argument is ignored
+ # FIXME: max-depth argument is ignored
self.runCmd("-stack-info-depth -1")
- #self.expect("\^error")
+ # self.expect("\^error")
- @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows
- @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
+ @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
@skipUnlessDarwin
def test_lldbmi_stack_info_frame(self):
"""Test that 'lldb-mi --interpreter' can show information about current frame."""
- self.spawnLldbMi(args = None)
+ self.spawnLldbMi(args=None)
# Test that -stack-info-frame fails when program isn't running
self.runCmd("-stack-info-frame")
- self.expect("\^error,msg=\"Command 'stack-info-frame'\. Invalid process during debug session\"")
+ self.expect(
+ "\^error,msg=\"Command 'stack-info-frame'\. Invalid process during debug session\"")
# Load executable
self.runCmd("-file-exec-and-symbols %s" % self.myexe)
@@ -399,7 +446,8 @@ class MiStackTestCase(lldbmi_testcase.MiTestCaseBase):
# Test that -stack-info-frame works when program was stopped on BP
self.runCmd("-stack-info-frame")
- self.expect("\^done,frame=\{level=\"0\",addr=\"0x[0-9a-f]+\",func=\"main\",file=\"main\.cpp\",fullname=\".+?main\.cpp\",line=\"\d+\"\}")
+ self.expect(
+ "\^done,frame=\{level=\"0\",addr=\"0x[0-9a-f]+\",func=\"main\",file=\"main\.cpp\",fullname=\".+?main\.cpp\",line=\"\d+\"\}")
# Select frame #1
self.runCmd("-stack-select-frame 1")
@@ -407,19 +455,20 @@ class MiStackTestCase(lldbmi_testcase.MiTestCaseBase):
# Test that -stack-info-frame works when specified frame was selected
self.runCmd("-stack-info-frame")
- self.expect("\^done,frame=\{level=\"1\",addr=\"0x[0-9a-f]+\",func=\".+?\",file=\"\?\?\",fullname=\"\?\?\",line=\"-1\"\}")
+ self.expect(
+ "\^done,frame=\{level=\"1\",addr=\"0x[0-9a-f]+\",func=\".+?\",file=\"\?\?\",fullname=\"\?\?\",line=\"-1\"\}")
# Test that -stack-info-frame fails when an argument is specified
- #FIXME: unknown argument is ignored
+ # FIXME: unknown argument is ignored
self.runCmd("-stack-info-frame unknown_arg")
- #self.expect("\^error")
+ # self.expect("\^error")
- @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows
- @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
+ @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
def test_lldbmi_stack_list_frames(self):
"""Test that 'lldb-mi --interpreter' can lists the frames on the stack."""
- self.spawnLldbMi(args = None)
+ self.spawnLldbMi(args=None)
# Load executable
self.runCmd("-file-exec-and-symbols %s" % self.myexe)
@@ -434,14 +483,15 @@ class MiStackTestCase(lldbmi_testcase.MiTestCaseBase):
# Test stack frame: get frame #0 info
self.runCmd("-stack-list-frames 0 0")
- self.expect("\^done,stack=\[frame=\{level=\"0\",addr=\"0x[0-9a-f]+\",func=\"main\",file=\"main\.cpp\",fullname=\".+?main\.cpp\",line=\"\d+\"\}\]")
+ self.expect(
+ "\^done,stack=\[frame=\{level=\"0\",addr=\"0x[0-9a-f]+\",func=\"main\",file=\"main\.cpp\",fullname=\".+?main\.cpp\",line=\"\d+\"\}\]")
- @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows
- @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
+ @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
def test_lldbmi_stack_select_frame(self):
"""Test that 'lldb-mi --interpreter' can choose current frame."""
- self.spawnLldbMi(args = None)
+ self.spawnLldbMi(args=None)
# Load executable
self.runCmd("-file-exec-and-symbols %s" % self.myexe)
@@ -456,15 +506,18 @@ class MiStackTestCase(lldbmi_testcase.MiTestCaseBase):
# Test that -stack-select-frame requires 1 mandatory argument
self.runCmd("-stack-select-frame")
- self.expect("\^error,msg=\"Command 'stack-select-frame'\. Command Args\. Validation failed. Mandatory args not found: frame_id\"")
+ self.expect(
+ "\^error,msg=\"Command 'stack-select-frame'\. Command Args\. Validation failed. Mandatory args not found: frame_id\"")
# Test that -stack-select-frame fails on invalid frame number
self.runCmd("-stack-select-frame 99")
- self.expect("\^error,msg=\"Command 'stack-select-frame'\. Frame ID invalid\"")
+ self.expect(
+ "\^error,msg=\"Command 'stack-select-frame'\. Frame ID invalid\"")
# Test that current frame is #0
self.runCmd("-stack-info-frame")
- self.expect("\^done,frame=\{level=\"0\",addr=\"0x[0-9a-f]+\",func=\"main\",file=\"main\.cpp\",fullname=\".+?main\.cpp\",line=\"\d+\"\}")
+ self.expect(
+ "\^done,frame=\{level=\"0\",addr=\"0x[0-9a-f]+\",func=\"main\",file=\"main\.cpp\",fullname=\".+?main\.cpp\",line=\"\d+\"\}")
# Test that -stack-select-frame can select the selected frame
self.runCmd("-stack-select-frame 0")
@@ -472,7 +525,8 @@ class MiStackTestCase(lldbmi_testcase.MiTestCaseBase):
# Test that current frame is still #0
self.runCmd("-stack-info-frame")
- self.expect("\^done,frame=\{level=\"0\",addr=\"0x[0-9a-f]+\",func=\"main\",file=\"main\.cpp\",fullname=\".+?main\.cpp\",line=\"\d+\"\}")
+ self.expect(
+ "\^done,frame=\{level=\"0\",addr=\"0x[0-9a-f]+\",func=\"main\",file=\"main\.cpp\",fullname=\".+?main\.cpp\",line=\"\d+\"\}")
# Test that -stack-select-frame can select frame #1 (parent frame)
self.runCmd("-stack-select-frame 1")
@@ -481,9 +535,11 @@ class MiStackTestCase(lldbmi_testcase.MiTestCaseBase):
# Test that current frame is #1
# Note that message is different in Darwin and Linux:
# Darwin: "^done,frame={level=\"1\",addr=\"0x[0-9a-f]+\",func=\"start\",file=\"??\",fullname=\"??\",line=\"-1\"}"
- # Linux: "^done,frame={level=\"1\",addr=\"0x[0-9a-f]+\",func=\".+\",file=\".+\",fullname=\".+\",line=\"\d+\"}"
+ # Linux:
+ # "^done,frame={level=\"1\",addr=\"0x[0-9a-f]+\",func=\".+\",file=\".+\",fullname=\".+\",line=\"\d+\"}"
self.runCmd("-stack-info-frame")
- self.expect("\^done,frame=\{level=\"1\",addr=\"0x[0-9a-f]+\",func=\".+?\",file=\".+?\",fullname=\".+?\",line=\"(-1|\d+)\"\}")
+ self.expect(
+ "\^done,frame=\{level=\"1\",addr=\"0x[0-9a-f]+\",func=\".+?\",file=\".+?\",fullname=\".+?\",line=\"(-1|\d+)\"\}")
# Test that -stack-select-frame can select frame #0 (child frame)
self.runCmd("-stack-select-frame 0")
@@ -491,4 +547,5 @@ class MiStackTestCase(lldbmi_testcase.MiTestCaseBase):
# Test that current frame is #0 and it has the same information
self.runCmd("-stack-info-frame")
- self.expect("\^done,frame=\{level=\"0\",addr=\"0x[0-9a-f]+\",func=\"main\",file=\"main\.cpp\",fullname=\".+?main\.cpp\",line=\"\d+\"\}")
+ self.expect(
+ "\^done,frame=\{level=\"0\",addr=\"0x[0-9a-f]+\",func=\"main\",file=\"main\.cpp\",fullname=\".+?main\.cpp\",line=\"\d+\"\}")
diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/TestMiStartupOptions.py b/packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/TestMiStartupOptions.py
index 8ddb6b3a1509..7673846d6df5 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,23 +9,24 @@ from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
+
class MiStartupOptionsTestCase(lldbmi_testcase.MiTestCaseBase):
mydir = TestBase.compute_mydir(__file__)
- @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows
- @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
+ @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
def test_lldbmi_executable_option_file(self):
"""Test that 'lldb-mi --interpreter %s' loads executable file."""
- self.spawnLldbMi(args = "%s" % self.myexe)
+ self.spawnLldbMi(args="%s" % self.myexe)
# Test that the executable is loaded when file was specified
self.expect("-file-exec-and-symbols \"%s\"" % self.myexe)
self.expect("\^done")
# Test that lldb-mi is ready when executable was loaded
- self.expect(self.child_prompt, exactly = True)
+ self.expect(self.child_prompt, exactly=True)
# Run to main
self.runCmd("-break-insert -f main")
@@ -39,25 +40,27 @@ class MiStartupOptionsTestCase(lldbmi_testcase.MiTestCaseBase):
self.expect("\^running")
self.expect("\*stopped,reason=\"exited-normally\"")
- @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows
- @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
+ @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
def test_lldbmi_executable_option_unknown_file(self):
"""Test that 'lldb-mi --interpreter %s' fails on unknown executable file."""
# Prepare path to executable
path = "unknown_file"
- self.spawnLldbMi(args = "%s" % path)
+ self.spawnLldbMi(args="%s" % path)
# Test that the executable isn't loaded when unknown file was specified
self.expect("-file-exec-and-symbols \"%s\"" % path)
- self.expect("\^error,msg=\"Command 'file-exec-and-symbols'. Target binary '%s' is invalid. error: unable to find executable for '%s'\"" % (path, path))
+ self.expect(
+ "\^error,msg=\"Command 'file-exec-and-symbols'. Target binary '%s' is invalid. error: unable to find executable for '%s'\"" %
+ (path, path))
# Test that lldb-mi is ready when executable was loaded
- self.expect(self.child_prompt, exactly = True)
+ self.expect(self.child_prompt, exactly=True)
- @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows
- @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
+ @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
def test_lldbmi_executable_option_absolute_path(self):
"""Test that 'lldb-mi --interpreter %s' loads executable which is specified via absolute path."""
@@ -65,69 +68,74 @@ class MiStartupOptionsTestCase(lldbmi_testcase.MiTestCaseBase):
import os
path = os.path.join(os.getcwd(), self.myexe)
- self.spawnLldbMi(args = "%s" % path)
+ self.spawnLldbMi(args="%s" % path)
- # Test that the executable is loaded when file was specified using absolute path
+ # Test that the executable is loaded when file was specified using
+ # absolute path
self.expect("-file-exec-and-symbols \"%s\"" % path)
self.expect("\^done")
# Test that lldb-mi is ready when executable was loaded
- self.expect(self.child_prompt, exactly = True)
+ self.expect(self.child_prompt, exactly=True)
# Run
self.runCmd("-exec-run")
self.expect("\^running")
self.expect("\*stopped,reason=\"exited-normally\"")
- @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows
- @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
+ @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
def test_lldbmi_executable_option_relative_path(self):
"""Test that 'lldb-mi --interpreter %s' loads executable which is specified via relative path."""
# Prepare path to executable
path = "./%s" % self.myexe
- self.spawnLldbMi(args = "%s" % path)
+ self.spawnLldbMi(args="%s" % path)
- # Test that the executable is loaded when file was specified using relative path
+ # Test that the executable is loaded when file was specified using
+ # relative path
self.expect("-file-exec-and-symbols \"%s\"" % path)
self.expect("\^done")
# Test that lldb-mi is ready when executable was loaded
- self.expect(self.child_prompt, exactly = True)
+ self.expect(self.child_prompt, exactly=True)
# Run
self.runCmd("-exec-run")
self.expect("\^running")
self.expect("\*stopped,reason=\"exited-normally\"")
- @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows
- @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
+ @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
def test_lldbmi_executable_option_unknown_path(self):
"""Test that 'lldb-mi --interpreter %s' fails on executable file which is specified via unknown path."""
# Prepare path to executable
path = "unknown_dir/%s" % self.myexe
- self.spawnLldbMi(args = "%s" % path)
+ self.spawnLldbMi(args="%s" % path)
- # Test that the executable isn't loaded when file was specified using unknown path
+ # Test that the executable isn't loaded when file was specified using
+ # unknown path
self.expect("-file-exec-and-symbols \"%s\"" % path)
- self.expect("\^error,msg=\"Command 'file-exec-and-symbols'. Target binary '%s' is invalid. error: unable to find executable for '%s'\"" % (path, path))
+ self.expect(
+ "\^error,msg=\"Command 'file-exec-and-symbols'. Target binary '%s' is invalid. error: unable to find executable for '%s'\"" %
+ (path, path))
# Test that lldb-mi is ready when executable was loaded
- self.expect(self.child_prompt, exactly = True)
+ self.expect(self.child_prompt, exactly=True)
- @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows
- @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
- @skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots
+ @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
+ @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots
def test_lldbmi_source_option_start_script(self):
"""Test that 'lldb-mi --interpreter' can execute user's commands after initial commands were executed."""
# Prepared source file
sourceFile = "start_script"
- self.spawnLldbMi(args = "--source %s" % sourceFile)
+ self.spawnLldbMi(args="--source %s" % sourceFile)
# After '-file-exec-and-symbols a.out'
self.expect("-file-exec-and-symbols %s" % self.myexe)
@@ -153,23 +161,23 @@ class MiStartupOptionsTestCase(lldbmi_testcase.MiTestCaseBase):
self.expect("\*stopped,reason=\"breakpoint-hit\"")
# Test that lldb-mi is ready after execution of --source start_script
- self.expect(self.child_prompt, exactly = True)
+ self.expect(self.child_prompt, exactly=True)
# Try to evaluate 'a' expression
self.runCmd("-data-evaluate-expression a")
self.expect("\^done,value=\"10\"")
- self.expect(self.child_prompt, exactly = True)
+ self.expect(self.child_prompt, exactly=True)
- @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows
- @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
- @skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots
+ @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
+ @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots
def test_lldbmi_source_option_start_script_exit(self):
"""Test that 'lldb-mi --interpreter' can execute a prepared file which passed via --source option."""
# Prepared source file
sourceFile = "start_script_exit"
- self.spawnLldbMi(args = "--source %s" % sourceFile)
+ self.spawnLldbMi(args="--source %s" % sourceFile)
# After '-file-exec-and-symbols a.out'
self.expect("-file-exec-and-symbols %s" % self.myexe)
@@ -203,15 +211,15 @@ class MiStartupOptionsTestCase(lldbmi_testcase.MiTestCaseBase):
self.expect("\^exit")
self.expect("\*stopped,reason=\"exited-normally\"")
- @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows
- @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
+ @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
def test_lldbmi_source_option_start_script_error(self):
"""Test that 'lldb-mi --interpreter' stops execution of initial commands in case of error."""
# Prepared source file
sourceFile = "start_script_error"
- self.spawnLldbMi(args = "--source %s" % sourceFile)
+ self.spawnLldbMi(args="--source %s" % sourceFile)
# After '-file-exec-and-symbols a.out'
self.expect("-file-exec-and-symbols %s" % self.myexe)
@@ -222,22 +230,22 @@ class MiStartupOptionsTestCase(lldbmi_testcase.MiTestCaseBase):
self.expect("\^error")
# Test that lldb-mi is ready after execution of --source start_script
- self.expect(self.child_prompt, exactly = True)
+ self.expect(self.child_prompt, exactly=True)
- @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows
- @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
+ @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
def test_lldbmi_log_option(self):
"""Test that 'lldb-mi --log' creates a log file in the current directory."""
-
+
logDirectory = "."
- self.spawnLldbMi(args = "%s --log" % self.myexe)
+ self.spawnLldbMi(args="%s --log" % self.myexe)
# Test that the executable is loaded when file was specified
self.expect("-file-exec-and-symbols \"%s\"" % self.myexe)
self.expect("\^done")
# Test that lldb-mi is ready when executable was loaded
- self.expect(self.child_prompt, exactly = True)
+ self.expect(self.child_prompt, exactly=True)
# Run
self.runCmd("-exec-run")
@@ -245,7 +253,8 @@ class MiStartupOptionsTestCase(lldbmi_testcase.MiTestCaseBase):
self.expect("\*stopped,reason=\"exited-normally\"")
# Check log file is created
- import glob,os
+ import glob
+ import os
logFile = glob.glob(logDirectory + "/lldb-mi-*.log")
if not logFile:
@@ -255,23 +264,25 @@ class MiStartupOptionsTestCase(lldbmi_testcase.MiTestCaseBase):
for f in logFile:
os.remove(f)
- @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows
- @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
+ @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
def test_lldbmi_log_directory_option(self):
"""Test that 'lldb-mi --log --log-dir' creates a log file in the directory specified by --log-dir."""
-
+
# Create log in temp directory
import tempfile
logDirectory = tempfile.gettempdir()
- self.spawnLldbMi(args = "%s --log --log-dir=%s" % (self.myexe,logDirectory))
+ self.spawnLldbMi(
+ args="%s --log --log-dir=%s" %
+ (self.myexe, logDirectory))
# Test that the executable is loaded when file was specified
self.expect("-file-exec-and-symbols \"%s\"" % self.myexe)
self.expect("\^done")
# Test that lldb-mi is ready when executable was loaded
- self.expect(self.child_prompt, exactly = True)
+ self.expect(self.child_prompt, exactly=True)
# Run
self.runCmd("-exec-run")
@@ -279,12 +290,13 @@ class MiStartupOptionsTestCase(lldbmi_testcase.MiTestCaseBase):
self.expect("\*stopped,reason=\"exited-normally\"")
# Check log file is created
- import glob,os
+ import glob
+ import os
logFile = glob.glob(logDirectory + "/lldb-mi-*.log")
if not logFile:
- self.fail("log file not found")
-
+ self.fail("log file not found")
+
# Delete log
for f in logFile:
os.remove(f)
diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/symbol/TestMiSymbol.py b/packages/Python/lldbsuite/test/tools/lldb-mi/symbol/TestMiSymbol.py
index 859c096e336d..23374330ba1f 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-mi/symbol/TestMiSymbol.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-mi/symbol/TestMiSymbol.py
@@ -5,23 +5,25 @@ 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
- @expectedFailureAll(oslist=["linux"], bugnumber="new failure after r256863")
+ @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="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)
+ self.spawnLldbMi(args=None)
# Load executable
self.runCmd("-file-exec-and-symbols %s" % self.myexe)
@@ -36,22 +38,31 @@ class MiSymbolTestCase(lldbmi_testcase.MiTestCaseBase):
# 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]+\)\"")
+ 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))
+ 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')
+ 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)
+ 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")
@@ -62,22 +73,31 @@ class MiSymbolTestCase(lldbmi_testcase.MiTestCaseBase):
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))
+ 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'\. \"")
+ self.expect(
+ "\^error,message=\"error: No source filenames matched 'unknown_file'\. \"")
- # Test that -symbol-list-lines fails when file is specified using relative path
+ # 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'\. \"")
+ self.expect(
+ "\^error,message=\"error: No source filenames matched '\./main\.cpp'\. \"")
- # Test that -symbol-list-lines works when file is specified using absolute path
+ # 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))
+ 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'\. \"")
+ self.expect(
+ "\^error,message=\"error: No source filenames matched 'unknown_dir/main\.cpp'\. \"")
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 a40e49f70e7e..02059080f305 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-mi/syntax/TestMiSyntax.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-mi/syntax/TestMiSyntax.py
@@ -5,22 +5,23 @@ Test that the lldb-mi driver understands MI command syntax.
from __future__ import print_function
-
import lldbmi_testcase
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
+from functools import reduce
+
class MiSyntaxTestCase(lldbmi_testcase.MiTestCaseBase):
mydir = TestBase.compute_mydir(__file__)
- @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows
- @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
+ @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
def test_lldbmi_tokens(self):
"""Test that 'lldb-mi --interpreter' prints command tokens."""
- self.spawnLldbMi(args = None)
+ self.spawnLldbMi(args=None)
# Load executable
self.runCmd("000-file-exec-and-symbols %s" % self.myexe)
@@ -38,8 +39,8 @@ class MiSyntaxTestCase(lldbmi_testcase.MiTestCaseBase):
self.expect("0000000000000000000003\^running")
self.expect("\*stopped,reason=\"exited-normally\"")
- @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows
- @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
+ @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
def test_lldbmi_specialchars(self):
"""Test that 'lldb-mi --interpreter' handles complicated strings."""
@@ -48,10 +49,12 @@ class MiSyntaxTestCase(lldbmi_testcase.MiTestCaseBase):
os.symlink(self.myexe, complicated_myexe)
self.addTearDownHook(lambda: os.unlink(complicated_myexe))
- self.spawnLldbMi(args = "\"%s\"" % complicated_myexe)
+ self.spawnLldbMi(args="\"%s\"" % complicated_myexe)
# Test that the executable was loaded
- self.expect("-file-exec-and-symbols \"%s\"" % complicated_myexe, exactly = True)
+ self.expect(
+ "-file-exec-and-symbols \"%s\"" %
+ complicated_myexe, exactly=True)
self.expect("\^done")
# Check that it was loaded correctly
@@ -61,13 +64,15 @@ class MiSyntaxTestCase(lldbmi_testcase.MiTestCaseBase):
self.expect("\^running")
self.expect("\*stopped,reason=\"breakpoint-hit\"")
- @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows
- @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
- @expectedFailureAll(oslist=["linux"], bugnumber="Failing in ~6/600 dosep runs (build 3120-3122)")
+ @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 ~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)
+ self.spawnLldbMi(args=None)
# Load executable
self.runCmd("-file-exec-and-symbols %s" % self.myexe)
@@ -80,3 +85,104 @@ class MiSyntaxTestCase(lldbmi_testcase.MiTestCaseBase):
# 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
+ @expectedFailureAll(oslist=["macosx"], bugnumber="rdar://28805064")
+ def test_lldbmi_output_grammar(self):
+ """Test that 'lldb-mi --interpreter' uses standard output syntax."""
+
+ self.spawnLldbMi(args=None)
+ self.child.setecho(False)
+
+ # Run all commands simultaneously
+ self.runCmd("-unknown-command")
+ self.runCmd("-file-exec-and-symbols %s" % self.myexe)
+ self.runCmd("-break-insert -f main")
+ self.runCmd("-gdb-set target-async off")
+ self.runCmd("-exec-run")
+ self.runCmd("-gdb-set target-async on")
+ self.runCmd("-exec-continue")
+ self.runCmd("-gdb-exit")
+
+ # Test that the program's output matches to the following pattern:
+ # ( async-record | stream-record )* [ result-record ] "(gdb)" nl
+ async_record = "^[0-9]*(\*|\+|=).+?\n" # 1
+ stream_record = "^(~|@|&).+?\n" # 2
+ result_record = "^[0-9]*\^.+?\n" # 3
+ prompt = "^\(gdb\)\r\n" # 4
+ command = "^\r\n" # 5 (it looks like empty line for pexpect)
+ error = "^.+?\n" # 6
+ import pexpect # 7 (EOF)
+ all_patterns = [
+ async_record,
+ stream_record,
+ result_record,
+ prompt,
+ command,
+ error,
+ pexpect.EOF]
+
+ # Routines to get a bit-mask for the specified list of patterns
+ def get_bit(pattern): return all_patterns.index(pattern)
+ def get_mask(pattern): return 1 << get_bit(pattern)
+ def or_op(x, y): return x | y
+ def get_state(*args): return reduce(or_op, map(get_mask, args))
+
+ next_state = get_state(command)
+ while True:
+ it = self.expect(all_patterns)
+ matched_pattern = all_patterns[it]
+
+ # Check that state is acceptable
+ if not (next_state & get_mask(matched_pattern)):
+ self.fail(
+ "error: inconsistent pattern '%s' for state %#x (matched string: %s)" %
+ (repr(matched_pattern), next_state, self.child.after))
+ elif matched_pattern == async_record or matched_pattern == stream_record:
+ next_state = get_state(
+ async_record,
+ stream_record,
+ result_record,
+ prompt)
+ elif matched_pattern == result_record:
+ # FIXME lldb-mi prints async-records out of turn
+ # ```
+ # ^done
+ # (gdb)
+ # ^running
+ # =thread-group-started,id="i1",pid="13875"
+ # (gdb)
+ # ```
+ # Therefore to pass that test I changed the grammar's rule:
+ # next_state = get_state(prompt)
+ # to:
+ next_state = get_state(async_record, prompt)
+ elif matched_pattern == prompt:
+ # FIXME lldb-mi prints the prompt out of turn
+ # ```
+ # ^done
+ # (gdb)
+ # ^running
+ # (gdb)
+ # (gdb)
+ # ```
+ # Therefore to pass that test I changed the grammar's rule:
+ # next_state = get_state(async_record, stream_record, result_record, command, pexpect.EOF)
+ # to:
+ next_state = get_state(
+ async_record,
+ stream_record,
+ result_record,
+ prompt,
+ command,
+ pexpect.EOF)
+ elif matched_pattern == command:
+ next_state = get_state(
+ async_record,
+ stream_record,
+ result_record)
+ elif matched_pattern == pexpect.EOF:
+ break
+ else:
+ self.fail("error: pexpect returned an unknown state")
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 2d47db03637c..31a05ff402ed 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-mi/target/TestMiTarget.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-mi/target/TestMiTarget.py
@@ -9,117 +9,121 @@ from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
+
class MiTargetTestCase(lldbmi_testcase.MiTestCaseBase):
mydir = TestBase.compute_mydir(__file__)
- @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows
- @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
- @skipIfLinux # cannot attach to process on linux
+ @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
+ @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfLinux # cannot attach to process on linux
def test_lldbmi_target_attach_wait_for(self):
"""Test that 'lldb-mi --interpreter' works for -target-attach -n <name> --waitfor."""
-
+
# Build target executable with unique name
exeName = self.testMethodName
d = {'EXE': exeName}
self.buildProgram("test_attach.cpp", exeName)
self.addTearDownCleanup(dictionary=d)
-
- self.spawnLldbMi(args = None)
-
+
+ self.spawnLldbMi(args=None)
+
# Load executable
- # FIXME: -file-exec-and-sybmols is not required for target attach, but the test will not pass without this
+ # FIXME: -file-exec-and-sybmols is not required for target attach, but
+ # the test will not pass without this
self.runCmd("-file-exec-and-symbols %s" % exeName)
self.expect("\^done")
-
+
# Set up attach
self.runCmd("-target-attach -n %s --waitfor" % exeName)
- time.sleep(4) # Give attach time to setup
-
+ time.sleep(4) # Give attach time to setup
+
# Start target process
- self.spawnSubprocess(os.path.join(os.path.dirname(__file__), exeName));
+ self.spawnSubprocess(os.path.join(os.path.dirname(__file__), exeName))
self.addTearDownHook(self.cleanupSubprocesses)
self.expect("\^done")
-
+
# Set breakpoint on printf
line = line_number('test_attach.cpp', '// BP_i++')
self.runCmd("-break-insert -f test_attach.cpp:%d" % line)
self.expect("\^done,bkpt={number=\"1\"")
-
+
# Continue to breakpoint
self.runCmd("-exec-continue")
self.expect("\*stopped,reason=\"breakpoint-hit\"")
-
+
# Detach
self.runCmd("-target-detach")
self.expect("\^done")
-
- @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows
- @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
- @skipIfLinux # cannot attach to process on linux
+
+ @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
+ @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfLinux # cannot attach to process on linux
def test_lldbmi_target_attach_name(self):
"""Test that 'lldb-mi --interpreter' works for -target-attach -n <name>."""
-
+
# Build target executable with unique name
exeName = self.testMethodName
d = {'EXE': exeName}
self.buildProgram("test_attach.cpp", exeName)
self.addTearDownCleanup(dictionary=d)
-
+
# Start target process
- targetProcess = self.spawnSubprocess(os.path.join(os.path.dirname(__file__), exeName));
+ targetProcess = self.spawnSubprocess(
+ os.path.join(os.path.dirname(__file__), exeName))
self.addTearDownHook(self.cleanupSubprocesses)
-
- self.spawnLldbMi(args = None)
-
+
+ self.spawnLldbMi(args=None)
+
# Set up atatch
self.runCmd("-target-attach -n %s" % exeName)
self.expect("\^done")
-
+
# Set breakpoint on printf
line = line_number('test_attach.cpp', '// BP_i++')
self.runCmd("-break-insert -f test_attach.cpp:%d" % line)
self.expect("\^done,bkpt={number=\"1\"")
-
+
# Continue to breakpoint
self.runCmd("-exec-continue")
self.expect("\*stopped,reason=\"breakpoint-hit\"")
-
+
# Detach
self.runCmd("-target-detach")
self.expect("\^done")
-
- @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows
- @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
- @skipIfLinux # cannot attach to process on linux
+
+ @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
+ @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfLinux # cannot attach to process on linux
def test_lldbmi_target_attach_pid(self):
"""Test that 'lldb-mi --interpreter' works for -target-attach <pid>."""
-
+
# Build target executable with unique name
exeName = self.testMethodName
d = {'EXE': exeName}
self.buildProgram("test_attach.cpp", exeName)
self.addTearDownCleanup(dictionary=d)
-
+
# Start target process
- targetProcess = self.spawnSubprocess(os.path.join(os.path.dirname(__file__), exeName));
+ targetProcess = self.spawnSubprocess(
+ os.path.join(os.path.dirname(__file__), exeName))
self.addTearDownHook(self.cleanupSubprocesses)
-
- self.spawnLldbMi(args = None)
-
+
+ self.spawnLldbMi(args=None)
+
# Set up atatch
self.runCmd("-target-attach %d" % targetProcess.pid)
self.expect("\^done")
-
+
# Set breakpoint on printf
line = line_number('test_attach.cpp', '// BP_i++')
self.runCmd("-break-insert -f test_attach.cpp:%d" % line)
self.expect("\^done,bkpt={number=\"1\"")
-
+
# Continue to breakpoint
self.runCmd("-exec-continue")
self.expect("\*stopped,reason=\"breakpoint-hit\"")
-
+
# Detach
self.runCmd("-target-detach")
self.expect("\^done")
diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/threadinfo/TestMiThreadInfo.py b/packages/Python/lldbsuite/test/tools/lldb-mi/threadinfo/TestMiThreadInfo.py
index 7226f2e8d320..729674e6e111 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-mi/threadinfo/TestMiThreadInfo.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-mi/threadinfo/TestMiThreadInfo.py
@@ -9,16 +9,17 @@ from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
+
class MiThreadInfoTestCase(lldbmi_testcase.MiTestCaseBase):
mydir = TestBase.compute_mydir(__file__)
- @skipIfWindows # pthreads not supported on Windows
- @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfWindows # pthreads not supported on Windows
+ @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
def test_lldbmi_thread_info(self):
"""Test that -thread-info prints thread info and the current-thread-id"""
- self.spawnLldbMi(args = None)
+ self.spawnLldbMi(args=None)
# Load executable
self.runCmd("-file-exec-and-symbols %s" % self.myexe)
@@ -33,7 +34,7 @@ class MiThreadInfoTestCase(lldbmi_testcase.MiTestCaseBase):
self.expect("\*stopped,reason=\"breakpoint-hit\"")
self.runCmd("-thread-info")
- self.expect("\^done,threads=\[\{id=\"1\",(.*)\},\{id=\"2\",(.*)\],current-thread-id=\"2\"")
+ self.expect(
+ "\^done,threads=\[\{id=\"1\",(.*)\},\{id=\"2\",(.*)\],current-thread-id=\"2\"")
self.runCmd("-gdb-quit")
-
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 5ce2b99bbdee..61d54cab055a 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-mi/variable/TestMiGdbSetShowPrint.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-mi/variable/TestMiGdbSetShowPrint.py
@@ -1,4 +1,4 @@
-#coding=utf8
+# coding=utf8
"""
Test lldb-mi -gdb-set and -gdb-show commands for 'print option-name'.
"""
@@ -6,12 +6,12 @@ Test lldb-mi -gdb-set and -gdb-show commands for 'print option-name'.
from __future__ import print_function
-
import lldbmi_testcase
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
+
class MiGdbSetShowTestCase(lldbmi_testcase.MiTestCaseBase):
mydir = TestBase.compute_mydir(__file__)
@@ -19,28 +19,34 @@ class MiGdbSetShowTestCase(lldbmi_testcase.MiTestCaseBase):
# evaluates array when char-array-as-string is off
def eval_and_check_array(self, var, typ, length):
self.runCmd("-var-create - * %s" % var)
- self.expect('\^done,name="var\d+",numchild="%d",value="\[%d\]",type="%s \[%d\]",thread-id="1",has_more="0"' % (length, length, typ, length))
+ self.expect(
+ '\^done,name="var\d+",numchild="%d",value="\[%d\]",type="%s \[%d\]",thread-id="1",has_more="0"' %
+ (length, length, typ, length))
# evaluates any type which can be represented as string of characters
def eval_and_match_string(self, var, value, typ):
- value=value.replace("\\", "\\\\").replace("\"", "\\\"")
+ value = value.replace("\\", "\\\\").replace("\"", "\\\"")
self.runCmd("-var-create - * " + var)
- self.expect('\^done,name="var\d+",numchild="[0-9]+",value="%s",type="%s",thread-id="1",has_more="0"' % (value, typ))
+ self.expect(
+ '\^done,name="var\d+",numchild="[0-9]+",value="%s",type="%s",thread-id="1",has_more="0"' %
+ (value, typ))
- @skipIfWindows #llvm.org/pr24452: Get lldb-mi working on Windows
- @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
- @skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots
+ @skipIfWindows # llvm.org/pr24452: Get lldb-mi working on Windows
+ @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots
def test_lldbmi_gdb_set_show_print_char_array_as_string(self):
"""Test that 'lldb-mi --interpreter' can print array of chars as string."""
- self.spawnLldbMi(args = None)
+ self.spawnLldbMi(args=None)
# Load executable
self.runCmd("-file-exec-and-symbols %s" % self.myexe)
self.expect("\^done")
# Run to BP_gdb_set_show_print_char_array_as_string_test
- line = line_number('main.cpp', '// BP_gdb_set_show_print_char_array_as_string_test')
+ line = line_number(
+ 'main.cpp',
+ '// BP_gdb_set_show_print_char_array_as_string_test')
self.runCmd("-break-insert main.cpp:%d" % line)
self.expect("\^done,bkpt={number=\"1\"")
self.runCmd("-exec-run")
@@ -51,23 +57,38 @@ class MiGdbSetShowTestCase(lldbmi_testcase.MiTestCaseBase):
self.runCmd("-gdb-show print char-array-as-string")
self.expect("\^done,value=\"off\"")
- # Test that a char* is expanded to string when print char-array-as-string is "off"
- self.eval_and_match_string("cp", r'0x[0-9a-f]+ \"\\t\\\"hello\\\"\\n\"', r'const char \*')
-
- # Test that a char[] isn't expanded to string when print char-array-as-string is "off"
- self.eval_and_check_array("ca", "const char", 10);
-
- # Test that a char16_t* is expanded to string when print char-array-as-string is "off"
- self.eval_and_match_string("u16p", r'0x[0-9a-f]+ u\"\\t\\\"hello\\\"\\n\"', r'const char16_t \*')
-
- # Test that a char16_t[] isn't expanded to string when print char-array-as-string is "off"
- self.eval_and_check_array("u16a", "const char16_t", 10);
-
- # Test that a char32_t* is expanded to string when print char-array-as-string is "off"
- self.eval_and_match_string("u32p", r'0x[0-9a-f]+ U\"\\t\\\"hello\\\"\\n\"', r'const char32_t \*')
-
- # Test that a char32_t[] isn't expanded to string when print char-array-as-string is "off"
- self.eval_and_check_array("u32a", "const char32_t", 10);
+ # Test that a char* is expanded to string when print
+ # char-array-as-string is "off"
+ self.eval_and_match_string(
+ "cp",
+ r'0x[0-9a-f]+ \"\\t\\\"hello\\\"\\n\"',
+ r'const char \*')
+
+ # Test that a char[] isn't expanded to string when print
+ # char-array-as-string is "off"
+ self.eval_and_check_array("ca", "const char", 10)
+
+ # Test that a char16_t* is expanded to string when print
+ # char-array-as-string is "off"
+ self.eval_and_match_string(
+ "u16p",
+ r'0x[0-9a-f]+ u\"\\t\\\"hello\\\"\\n\"',
+ r'const char16_t \*')
+
+ # Test that a char16_t[] isn't expanded to string when print
+ # char-array-as-string is "off"
+ self.eval_and_check_array("u16a", "const char16_t", 10)
+
+ # Test that a char32_t* is expanded to string when print
+ # char-array-as-string is "off"
+ self.eval_and_match_string(
+ "u32p",
+ r'0x[0-9a-f]+ U\"\\t\\\"hello\\\"\\n\"',
+ r'const char32_t \*')
+
+ # Test that a char32_t[] isn't expanded to string when print
+ # char-array-as-string is "off"
+ self.eval_and_check_array("u32a", "const char32_t", 10)
# Test that -gdb-set can set print char-array-as-string flag
self.runCmd("-gdb-set print char-array-as-string on")
@@ -77,52 +98,94 @@ class MiGdbSetShowTestCase(lldbmi_testcase.MiTestCaseBase):
self.runCmd("-gdb-show print char-array-as-string")
self.expect("\^done,value=\"on\"")
- # Test that a char* with escape chars is expanded to string when print char-array-as-string is "on"
- self.eval_and_match_string("cp", r'0x[0-9a-f]+ \"\\t\\\"hello\\\"\\n\"', r'const char \*')
-
- # Test that a char[] with escape chars is expanded to string when print char-array-as-string is "on"
- self.eval_and_match_string("ca", r'\"\\t\\\"hello\\\"\\n\"', r'const char \[10\]')
-
- # Test that a char16_t* with escape chars is expanded to string when print char-array-as-string is "on"
- self.eval_and_match_string("u16p", r'0x[0-9a-f]+ u\"\\t\\\"hello\\\"\\n\"', r'const char16_t \*')
-
- # Test that a char16_t[] with escape chars is expanded to string when print char-array-as-string is "on"
- self.eval_and_match_string("u16a", r'u\"\\t\\\"hello\\\"\\n\"', r'const char16_t \[10\]')
-
- # Test that a char32_t* with escape chars is expanded to string when print char-array-as-string is "on"
- self.eval_and_match_string("u32p", r'0x[0-9a-f]+ U\"\\t\\\"hello\\\"\\n\"', r'const char32_t \*')
-
- # Test that a char32_t[] with escape chars is expanded to string when print char-array-as-string is "on"
- self.eval_and_match_string("u32a", r'U\"\\t\\\"hello\\\"\\n\"', r'const char32_t \[10\]')
+ # Test that a char* with escape chars is expanded to string when print
+ # char-array-as-string is "on"
+ self.eval_and_match_string(
+ "cp",
+ r'0x[0-9a-f]+ \"\\t\\\"hello\\\"\\n\"',
+ r'const char \*')
+
+ # Test that a char[] with escape chars is expanded to string when print
+ # char-array-as-string is "on"
+ self.eval_and_match_string(
+ "ca",
+ r'\"\\t\\\"hello\\\"\\n\"',
+ r'const char \[10\]')
+
+ # Test that a char16_t* with escape chars is expanded to string when
+ # print char-array-as-string is "on"
+ self.eval_and_match_string(
+ "u16p",
+ r'0x[0-9a-f]+ u\"\\t\\\"hello\\\"\\n\"',
+ r'const char16_t \*')
+
+ # Test that a char16_t[] with escape chars is expanded to string when
+ # print char-array-as-string is "on"
+ self.eval_and_match_string(
+ "u16a",
+ r'u\"\\t\\\"hello\\\"\\n\"',
+ r'const char16_t \[10\]')
+
+ # Test that a char32_t* with escape chars is expanded to string when
+ # print char-array-as-string is "on"
+ self.eval_and_match_string(
+ "u32p",
+ r'0x[0-9a-f]+ U\"\\t\\\"hello\\\"\\n\"',
+ r'const char32_t \*')
+
+ # Test that a char32_t[] with escape chars is expanded to string when
+ # print char-array-as-string is "on"
+ self.eval_and_match_string(
+ "u32a",
+ r'U\"\\t\\\"hello\\\"\\n\"',
+ r'const char32_t \[10\]')
# Test russian unicode strings
- self.eval_and_match_string("u16p_rus", r'0x[0-9a-f]+ u\"\\\\Аламо-сквер\"', r'const char16_t \*')
- self.eval_and_match_string("u16a_rus", r'u\"\\\\Бейвью\"', r'const char16_t \[8\]')
- self.eval_and_match_string("u32p_rus", r'0x[0-9a-f]+ U\"\\\\Чайнатаун\"', r'const char32_t \*')
- self.eval_and_match_string("u32a_rus", r'U\"\\\\Догпатч\"', r'const char32_t \[9\]')
-
- # Test that -gdb-set print char-array-as-string fails if "on"/"off" isn't specified
+ self.eval_and_match_string(
+ "u16p_rus",
+ r'0x[0-9a-f]+ u\"\\\\Аламо-сквер\"',
+ r'const char16_t \*')
+ self.eval_and_match_string(
+ "u16a_rus",
+ r'u\"\\\\Бейвью\"',
+ r'const char16_t \[8\]')
+ self.eval_and_match_string(
+ "u32p_rus",
+ r'0x[0-9a-f]+ U\"\\\\Чайнатаун\"',
+ r'const char32_t \*')
+ self.eval_and_match_string(
+ "u32a_rus",
+ r'U\"\\\\Догпатч\"',
+ r'const char32_t \[9\]')
+
+ # Test that -gdb-set print char-array-as-string fails if "on"/"off"
+ # isn't specified
self.runCmd("-gdb-set print char-array-as-string")
- self.expect("\^error,msg=\"The request ''print' expects option-name and \"on\" or \"off\"' failed.\"")
+ self.expect(
+ "\^error,msg=\"The request ''print' expects option-name and \"on\" or \"off\"' failed.\"")
- # Test that -gdb-set print char-array-as-string fails when option is unknown
+ # Test that -gdb-set print char-array-as-string fails when option is
+ # unknown
self.runCmd("-gdb-set print char-array-as-string unknown")
- self.expect("\^error,msg=\"The request ''print' expects option-name and \"on\" or \"off\"' failed.\"")
+ 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
+ @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
+ @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
def test_lldbmi_gdb_set_show_print_expand_aggregates(self):
"""Test that 'lldb-mi --interpreter' can expand aggregates everywhere."""
- self.spawnLldbMi(args = None)
+ 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')
+ 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")
@@ -133,16 +196,21 @@ class MiGdbSetShowTestCase(lldbmi_testcase.MiTestCaseBase):
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"
+ # 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\"")
+ 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"
+ # 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
+ # 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\"")
+ 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")
@@ -152,36 +220,46 @@ class MiGdbSetShowTestCase(lldbmi_testcase.MiTestCaseBase):
self.runCmd("-gdb-show print expand-aggregates")
self.expect("\^done,value=\"on\"")
- # Test that composite type is expanded when print expand-aggregates is "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\"")
+ 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"
+ # 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\"")
+ 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
+ # 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.\"")
+ 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
+ # 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.\"")
+ 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
+ @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
+ @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
def test_lldbmi_gdb_set_show_print_aggregate_field_names(self):
"""Test that 'lldb-mi --interpreter' can expand aggregates everywhere."""
- self.spawnLldbMi(args = None)
+ self.spawnLldbMi(args=None)
# Load executable
self.runCmd("-file-exec-and-symbols %s" % self.myexe)
self.expect("\^done")
# Run to BP_gdb_set_show_print_aggregate_field_names
- line = line_number('main.cpp', '// BP_gdb_set_show_print_aggregate_field_names')
+ line = line_number(
+ 'main.cpp',
+ '// BP_gdb_set_show_print_aggregate_field_names')
self.runCmd("-break-insert main.cpp:%d" % line)
self.expect("\^done,bkpt={number=\"1\"")
self.runCmd("-exec-run")
@@ -196,13 +274,17 @@ class MiGdbSetShowTestCase(lldbmi_testcase.MiTestCaseBase):
self.runCmd("-gdb-set print expand-aggregates on")
self.expect("\^done")
- # Test that composite type is expanded with field name when print aggregate-field-names is "on"
+ # Test that composite type is expanded with field name when print
+ # aggregate-field-names is "on"
self.runCmd("-var-create var1 * complx")
- self.expect("\^done,name=\"var1\",numchild=\"3\",value=\"{i = 3, inner = {l = 3}, complex_ptr = 0x[0-9a-f]+}\",type=\"complex_type\",thread-id=\"1\",has_more=\"0\"")
+ self.expect(
+ "\^done,name=\"var1\",numchild=\"3\",value=\"{i = 3, inner = {l = 3}, complex_ptr = 0x[0-9a-f]+}\",type=\"complex_type\",thread-id=\"1\",has_more=\"0\"")
- # Test that composite type[] is expanded with field name when print aggregate-field-names is "on"
+ # Test that composite type[] is expanded with field name when print
+ # aggregate-field-names is "on"
self.runCmd("-var-create var2 * complx_array")
- self.expect("\^done,name=\"var2\",numchild=\"2\",value=\"{\[0\] = {i = 4, inner = {l = 4}, complex_ptr = 0x[0-9a-f]+}, \[1\] = {i = 5, inner = {l = 5}, complex_ptr = 0x[0-9a-f]+}}\",type=\"complex_type \[2\]\",thread-id=\"1\",has_more=\"0\"")
+ self.expect(
+ "\^done,name=\"var2\",numchild=\"2\",value=\"{\[0\] = {i = 4, inner = {l = 4}, complex_ptr = 0x[0-9a-f]+}, \[1\] = {i = 5, inner = {l = 5}, complex_ptr = 0x[0-9a-f]+}}\",type=\"complex_type \[2\]\",thread-id=\"1\",has_more=\"0\"")
# Test that -gdb-set can set print aggregate-field-names flag
self.runCmd("-gdb-set print aggregate-field-names off")
@@ -212,18 +294,26 @@ class MiGdbSetShowTestCase(lldbmi_testcase.MiTestCaseBase):
self.runCmd("-gdb-show print aggregate-field-names")
self.expect("\^done,value=\"off\"")
- # Test that composite type is expanded without field name when print aggregate-field-names is "off"
+ # Test that composite type is expanded without field name when print
+ # aggregate-field-names is "off"
self.runCmd("-var-create var3 * complx")
- self.expect("\^done,name=\"var3\",numchild=\"3\",value=\"{3,\{3\},0x[0-9a-f]+}\",type=\"complex_type\",thread-id=\"1\",has_more=\"0\"")
+ self.expect(
+ "\^done,name=\"var3\",numchild=\"3\",value=\"{3,\{3\},0x[0-9a-f]+}\",type=\"complex_type\",thread-id=\"1\",has_more=\"0\"")
- # Test that composite type[] is expanded without field name when print aggregate-field-names is "off"
+ # Test that composite type[] is expanded without field name when print
+ # aggregate-field-names is "off"
self.runCmd("-var-create var4 * complx_array")
- self.expect("\^done,name=\"var4\",numchild=\"2\",value=\"{{4,\{4\},0x[0-9a-f]+},{5,\{5\},0x[0-9a-f]+}}\",type=\"complex_type \[2\]\",thread-id=\"1\",has_more=\"0\"")
+ self.expect(
+ "\^done,name=\"var4\",numchild=\"2\",value=\"{{4,\{4\},0x[0-9a-f]+},{5,\{5\},0x[0-9a-f]+}}\",type=\"complex_type \[2\]\",thread-id=\"1\",has_more=\"0\"")
- # Test that -gdb-set print aggregate-field-names fails if "on"/"off" isn't specified
+ # Test that -gdb-set print aggregate-field-names fails if "on"/"off"
+ # isn't specified
self.runCmd("-gdb-set print aggregate-field-names")
- self.expect("\^error,msg=\"The request ''print' expects option-name and \"on\" or \"off\"' failed.\"")
+ self.expect(
+ "\^error,msg=\"The request ''print' expects option-name and \"on\" or \"off\"' failed.\"")
- # Test that -gdb-set print aggregate-field-names fails when option is unknown
+ # Test that -gdb-set print aggregate-field-names fails when option is
+ # unknown
self.runCmd("-gdb-set print aggregate-field-names unknown")
- self.expect("\^error,msg=\"The request ''print' expects option-name and \"on\" or \"off\"' failed.\"")
+ self.expect(
+ "\^error,msg=\"The request ''print' expects option-name and \"on\" or \"off\"' failed.\"")
diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/variable/TestMiVar.py b/packages/Python/lldbsuite/test/tools/lldb-mi/variable/TestMiVar.py
index 51f02b9e4a74..b76b59ab97e3 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-mi/variable/TestMiVar.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-mi/variable/TestMiVar.py
@@ -5,22 +5,22 @@ Test lldb-mi -var-xxx commands.
from __future__ import print_function
-
import lldbmi_testcase
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
+
class MiVarTestCase(lldbmi_testcase.MiTestCaseBase):
mydir = TestBase.compute_mydir(__file__)
- @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows
- @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
+ @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
def test_lldbmi_eval(self):
"""Test that 'lldb-mi --interpreter' works for evaluating."""
- self.spawnLldbMi(args = None)
+ self.spawnLldbMi(args=None)
# Load executable
self.runCmd("-file-exec-and-symbols %s" % self.myexe)
@@ -36,15 +36,18 @@ class MiVarTestCase(lldbmi_testcase.MiTestCaseBase):
# Print non-existant variable
self.runCmd("-var-create var1 * undef")
- self.expect("\^error,msg=\"error: use of undeclared identifier \'undef\'\\\\n\"")
+ self.expect(
+ "\^error,msg=\"error: use of undeclared identifier \'undef\'\\\\n\"")
self.runCmd("-data-evaluate-expression undef")
- self.expect("\^error,msg=\"error: use of undeclared identifier \'undef\'\\\\n\"")
+ self.expect(
+ "\^error,msg=\"error: use of undeclared identifier \'undef\'\\\\n\"")
# Print global "g_MyVar", modify, delete and create again
self.runCmd("-data-evaluate-expression g_MyVar")
self.expect("\^done,value=\"3\"")
self.runCmd("-var-create var2 * g_MyVar")
- self.expect("\^done,name=\"var2\",numchild=\"0\",value=\"3\",type=\"int\",thread-id=\"1\",has_more=\"0\"")
+ self.expect(
+ "\^done,name=\"var2\",numchild=\"0\",value=\"3\",type=\"int\",thread-id=\"1\",has_more=\"0\"")
self.runCmd("-var-evaluate-expression var2")
self.expect("\^done,value=\"3\"")
self.runCmd("-var-show-attributes var2")
@@ -57,17 +60,20 @@ class MiVarTestCase(lldbmi_testcase.MiTestCaseBase):
self.runCmd("-data-evaluate-expression \"g_MyVar=30\"")
self.expect("\^done,value=\"30\"")
self.runCmd("-var-update --all-values var2")
- #self.expect("\^done,changelist=\[\{name=\"var2\",value=\"30\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\}\]") #FIXME -var-update doesn't work
+ # self.expect("\^done,changelist=\[\{name=\"var2\",value=\"30\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\}\]")
+ # FIXME -var-update doesn't work
self.runCmd("-var-delete var2")
self.expect("\^done")
self.runCmd("-var-create var2 * g_MyVar")
- self.expect("\^done,name=\"var2\",numchild=\"0\",value=\"30\",type=\"int\",thread-id=\"1\",has_more=\"0\"")
+ self.expect(
+ "\^done,name=\"var2\",numchild=\"0\",value=\"30\",type=\"int\",thread-id=\"1\",has_more=\"0\"")
# Print static "s_MyVar", modify, delete and create again
self.runCmd("-data-evaluate-expression s_MyVar")
self.expect("\^done,value=\"30\"")
self.runCmd("-var-create var3 * s_MyVar")
- self.expect("\^done,name=\"var3\",numchild=\"0\",value=\"30\",type=\"int\",thread-id=\"1\",has_more=\"0\"")
+ self.expect(
+ "\^done,name=\"var3\",numchild=\"0\",value=\"30\",type=\"int\",thread-id=\"1\",has_more=\"0\"")
self.runCmd("-var-evaluate-expression var3")
self.expect("\^done,value=\"30\"")
self.runCmd("-var-show-attributes var3")
@@ -77,17 +83,20 @@ class MiVarTestCase(lldbmi_testcase.MiTestCaseBase):
self.runCmd("-data-evaluate-expression \"s_MyVar=3\"")
self.expect("\^done,value=\"3\"")
self.runCmd("-var-update --all-values var3")
- #self.expect("\^done,changelist=\[\{name=\"var3\",value=\"3\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\}\]") #FIXME -var-update doesn't work
+ # self.expect("\^done,changelist=\[\{name=\"var3\",value=\"3\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\}\]")
+ # FIXME -var-update doesn't work
self.runCmd("-var-delete var3")
self.expect("\^done")
self.runCmd("-var-create var3 * s_MyVar")
- self.expect("\^done,name=\"var3\",numchild=\"0\",value=\"3\",type=\"int\",thread-id=\"1\",has_more=\"0\"")
+ self.expect(
+ "\^done,name=\"var3\",numchild=\"0\",value=\"3\",type=\"int\",thread-id=\"1\",has_more=\"0\"")
# Print local "b", modify, delete and create again
self.runCmd("-data-evaluate-expression b")
self.expect("\^done,value=\"20\"")
self.runCmd("-var-create var4 * b")
- self.expect("\^done,name=\"var4\",numchild=\"0\",value=\"20\",type=\"int\",thread-id=\"1\",has_more=\"0\"")
+ self.expect(
+ "\^done,name=\"var4\",numchild=\"0\",value=\"20\",type=\"int\",thread-id=\"1\",has_more=\"0\"")
self.runCmd("-var-evaluate-expression var4")
self.expect("\^done,value=\"20\"")
self.runCmd("-var-show-attributes var4")
@@ -97,44 +106,62 @@ class MiVarTestCase(lldbmi_testcase.MiTestCaseBase):
self.runCmd("-data-evaluate-expression \"b=2\"")
self.expect("\^done,value=\"2\"")
self.runCmd("-var-update --all-values var4")
- #self.expect("\^done,changelist=\[\{name=\"var4\",value=\"2\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\}\]") #FIXME -var-update doesn't work
+ # self.expect("\^done,changelist=\[\{name=\"var4\",value=\"2\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\}\]")
+ # FIXME -var-update doesn't work
self.runCmd("-var-delete var4")
self.expect("\^done")
self.runCmd("-var-create var4 * b")
- self.expect("\^done,name=\"var4\",numchild=\"0\",value=\"2\",type=\"int\",thread-id=\"1\",has_more=\"0\"")
+ self.expect(
+ "\^done,name=\"var4\",numchild=\"0\",value=\"2\",type=\"int\",thread-id=\"1\",has_more=\"0\"")
# Print temp "a + b"
self.runCmd("-data-evaluate-expression \"a + b\"")
self.expect("\^done,value=\"12\"")
self.runCmd("-var-create var5 * \"a + b\"")
- self.expect("\^done,name=\"var5\",numchild=\"0\",value=\"12\",type=\"int\",thread-id=\"1\",has_more=\"0\"")
+ self.expect(
+ "\^done,name=\"var5\",numchild=\"0\",value=\"12\",type=\"int\",thread-id=\"1\",has_more=\"0\"")
self.runCmd("-var-evaluate-expression var5")
self.expect("\^done,value=\"12\"")
self.runCmd("-var-show-attributes var5")
- self.expect("\^done,status=\"editable\"") #FIXME editable or not?
+ self.expect("\^done,status=\"editable\"") # FIXME editable or not?
self.runCmd("-var-list-children var5")
self.expect("\^done,numchild=\"0\",has_more=\"0\"")
# Print argument "argv[0]"
self.runCmd("-data-evaluate-expression \"argv[0]\"")
- self.expect("\^done,value=\"0x[0-9a-f]+ \\\\\\\".*?%s\\\\\\\"\"" % self.myexe)
+ self.expect(
+ "\^done,value=\"0x[0-9a-f]+ \\\\\\\".*?%s\\\\\\\"\"" %
+ self.myexe)
self.runCmd("-var-create var6 * \"argv[0]\"")
- self.expect("\^done,name=\"var6\",numchild=\"1\",value=\"0x[0-9a-f]+ \\\\\\\".*?%s\\\\\\\"\",type=\"const char \*\",thread-id=\"1\",has_more=\"0\"" % self.myexe)
+ self.expect(
+ "\^done,name=\"var6\",numchild=\"1\",value=\"0x[0-9a-f]+ \\\\\\\".*?%s\\\\\\\"\",type=\"const char \*\",thread-id=\"1\",has_more=\"0\"" %
+ self.myexe)
self.runCmd("-var-evaluate-expression var6")
- self.expect("\^done,value=\"0x[0-9a-f]+ \\\\\\\".*?%s\\\\\\\"\"" % self.myexe)
+ self.expect(
+ "\^done,value=\"0x[0-9a-f]+ \\\\\\\".*?%s\\\\\\\"\"" %
+ self.myexe)
self.runCmd("-var-show-attributes var6")
self.expect("\^done,status=\"editable\"")
self.runCmd("-var-list-children --all-values var6")
# FIXME: The name below is not correct. It should be "var.*argv[0]".
- self.expect("\^done,numchild=\"1\",children=\[child=\{name=\"var6\.\*\$[0-9]+\",exp=\"\*\$[0-9]+\",numchild=\"0\",type=\"const char\",thread-id=\"4294967295\",value=\"47 '/'\",has_more=\"0\"\}\],has_more=\"0\"") #FIXME -var-list-children shows invalid thread-id
+ # FIXME -var-list-children shows invalid thread-id
+ self.expect(
+ "\^done,numchild=\"1\",children=\[child=\{name=\"var6\.\*\$[0-9]+\",exp=\"\*\$[0-9]+\",numchild=\"0\",type=\"const char\",thread-id=\"4294967295\",value=\"47 '/'\",has_more=\"0\"\}\],has_more=\"0\"")
+
+ # Print an expression with spaces and optional arguments
+ self.runCmd("-data-evaluate-expression \"a + b\"")
+ self.expect("\^done,value=\"12\"")
+ self.runCmd("-var-create var7 * \"a + b\" --thread 1 --frame 0")
+ self.expect(
+ "\^done,name=\"var7\",numchild=\"0\",value=\"12\",type=\"int\",thread-id=\"1\",has_more=\"0\"")
- @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows
- @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
- @skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots
+ @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
+ @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots
def test_lldbmi_var_update(self):
"""Test that 'lldb-mi --interpreter' works for -var-update."""
- self.spawnLldbMi(args = None)
+ self.spawnLldbMi(args=None)
# Load executable
self.runCmd("-file-exec-and-symbols %s" % self.myexe)
@@ -150,11 +177,14 @@ class MiVarTestCase(lldbmi_testcase.MiTestCaseBase):
# Setup variables
self.runCmd("-var-create var_l * l")
- self.expect("\^done,name=\"var_l\",numchild=\"0\",value=\"1\",type=\"long\",thread-id=\"1\",has_more=\"0\"")
+ self.expect(
+ "\^done,name=\"var_l\",numchild=\"0\",value=\"1\",type=\"long\",thread-id=\"1\",has_more=\"0\"")
self.runCmd("-var-create var_complx * complx")
- self.expect("\^done,name=\"var_complx\",numchild=\"3\",value=\"\{\.\.\.\}\",type=\"complex_type\",thread-id=\"1\",has_more=\"0\"")
+ self.expect(
+ "\^done,name=\"var_complx\",numchild=\"3\",value=\"\{\.\.\.\}\",type=\"complex_type\",thread-id=\"1\",has_more=\"0\"")
self.runCmd("-var-create var_complx_array * complx_array")
- self.expect("\^done,name=\"var_complx_array\",numchild=\"2\",value=\"\[2\]\",type=\"complex_type \[2\]\",thread-id=\"1\",has_more=\"0\"")
+ self.expect(
+ "\^done,name=\"var_complx_array\",numchild=\"2\",value=\"\[2\]\",type=\"complex_type \[2\]\",thread-id=\"1\",has_more=\"0\"")
# Go to BP_var_update_test_l
line = line_number('main.cpp', '// BP_var_update_test_l')
@@ -166,7 +196,8 @@ class MiVarTestCase(lldbmi_testcase.MiTestCaseBase):
# Test that var_l was updated
self.runCmd("-var-update --all-values var_l")
- self.expect("\^done,changelist=\[\{name=\"var_l\",value=\"0\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\}\]")
+ self.expect(
+ "\^done,changelist=\[\{name=\"var_l\",value=\"0\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\}\]")
# Go to BP_var_update_test_complx
line = line_number('main.cpp', '// BP_var_update_test_complx')
@@ -178,7 +209,8 @@ class MiVarTestCase(lldbmi_testcase.MiTestCaseBase):
# Test that var_complx was updated
self.runCmd("-var-update --all-values var_complx")
- self.expect("\^done,changelist=\[\{name=\"var_complx\",value=\"\{\.\.\.\}\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\}\]")
+ self.expect(
+ "\^done,changelist=\[\{name=\"var_complx\",value=\"\{\.\.\.\}\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\}\]")
# Go to BP_var_update_test_complx_array
line = line_number('main.cpp', '// BP_var_update_test_complx_array')
@@ -190,14 +222,15 @@ class MiVarTestCase(lldbmi_testcase.MiTestCaseBase):
# Test that var_complex_array was updated
self.runCmd("-var-update --all-values var_complx_array")
- self.expect("\^done,changelist=\[\{name=\"var_complx_array\",value=\"\[2\]\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\}\]")
+ self.expect(
+ "\^done,changelist=\[\{name=\"var_complx_array\",value=\"\[2\]\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\}\]")
- @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows
- @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
+ @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
def test_lldbmi_var_create_register(self):
"""Test that 'lldb-mi --interpreter' works for -var-create $regname."""
- self.spawnLldbMi(args = None)
+ self.spawnLldbMi(args=None)
# Load executable
self.runCmd("-file-exec-and-symbols %s" % self.myexe)
@@ -218,26 +251,29 @@ class MiVarTestCase(lldbmi_testcase.MiTestCaseBase):
# Create variable for register 0
# Note that message is different in Darwin and Linux:
# Darwin: "^done,name=\"var_reg\",numchild=\"0\",value=\"0x[0-9a-f]+\",type=\"unsigned long\",thread-id=\"1\",has_more=\"0\"
- # Linux: "^done,name=\"var_reg\",numchild=\"0\",value=\"0x[0-9a-f]+\",type=\"unsigned int\",thread-id=\"1\",has_more=\"0\"
+ # Linux:
+ # "^done,name=\"var_reg\",numchild=\"0\",value=\"0x[0-9a-f]+\",type=\"unsigned
+ # int\",thread-id=\"1\",has_more=\"0\"
self.runCmd("-var-create var_reg * $%s" % register_name)
- self.expect("\^done,name=\"var_reg\",numchild=\"0\",value=\"0x[0-9a-f]+\",type=\"unsigned (long|int)\",thread-id=\"1\",has_more=\"0\"")
+ self.expect(
+ "\^done,name=\"var_reg\",numchild=\"0\",value=\"0x[0-9a-f]+\",type=\"unsigned (long|int)\",thread-id=\"1\",has_more=\"0\"")
# Assign value to variable
self.runCmd("-var-assign var_reg \"6\"")
- #FIXME: the output has different format for 32bit and 64bit values
+ # FIXME: the output has different format for 32bit and 64bit values
self.expect("\^done,value=\"0x0*?6\"")
# Assert register 0 updated
self.runCmd("-data-list-register-values d 0")
self.expect("\^done,register-values=\[{number=\"0\",value=\"6\"")
- @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows
- @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
- @skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots
+ @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
+ @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots
def test_lldbmi_var_list_children(self):
"""Test that 'lldb-mi --interpreter' works for -var-list-children."""
- self.spawnLldbMi(args = None)
+ self.spawnLldbMi(args=None)
# Load executable
self.runCmd("-file-exec-and-symbols %s" % self.myexe)
@@ -253,13 +289,17 @@ class MiVarTestCase(lldbmi_testcase.MiTestCaseBase):
# Create variable
self.runCmd("-var-create var_complx * complx")
- self.expect("\^done,name=\"var_complx\",numchild=\"3\",value=\"\{\.\.\.\}\",type=\"complex_type\",thread-id=\"1\",has_more=\"0\"")
+ self.expect(
+ "\^done,name=\"var_complx\",numchild=\"3\",value=\"\{\.\.\.\}\",type=\"complex_type\",thread-id=\"1\",has_more=\"0\"")
self.runCmd("-var-create var_complx_array * complx_array")
- self.expect("\^done,name=\"var_complx_array\",numchild=\"2\",value=\"\[2\]\",type=\"complex_type \[2\]\",thread-id=\"1\",has_more=\"0\"")
+ self.expect(
+ "\^done,name=\"var_complx_array\",numchild=\"2\",value=\"\[2\]\",type=\"complex_type \[2\]\",thread-id=\"1\",has_more=\"0\"")
self.runCmd("-var-create var_pcomplx * pcomplx")
- self.expect("\^done,name=\"var_pcomplx\",numchild=\"2\",value=\"\{\.\.\.\}\",type=\"pcomplex_type\",thread-id=\"1\",has_more=\"0\"")
+ self.expect(
+ "\^done,name=\"var_pcomplx\",numchild=\"2\",value=\"\{\.\.\.\}\",type=\"pcomplex_type\",thread-id=\"1\",has_more=\"0\"")
- # Test that -var-evaluate-expression can evaluate the children of created varobj
+ # Test that -var-evaluate-expression can evaluate the children of
+ # created varobj
self.runCmd("-var-list-children var_complx")
self.runCmd("-var-evaluate-expression var_complx.i")
self.expect("\^done,value=\"3\"")
@@ -282,37 +322,50 @@ class MiVarTestCase(lldbmi_testcase.MiTestCaseBase):
# Test that -var-list-children lists all children with their values
# (and that from and to are optional)
self.runCmd("-var-list-children --all-values var_complx")
- self.expect("\^done,numchild=\"3\",children=\[child=\{name=\"var_complx\.i\",exp=\"i\",numchild=\"0\",type=\"int\",thread-id=\"1\",value=\"3\",has_more=\"0\"\},child=\{name=\"var_complx\.inner\",exp=\"inner\",numchild=\"1\",type=\"complex_type::\(anonymous struct\)\",thread-id=\"1\",value=\"\{\.\.\.\}\",has_more=\"0\"\},child=\{name=\"var_complx\.complex_ptr\",exp=\"complex_ptr\",numchild=\"3\",type=\"complex_type \*\",thread-id=\"1\",value=\"0x[0-9a-f]+\",has_more=\"0\"\}\],has_more=\"0\"")
+ self.expect(
+ "\^done,numchild=\"3\",children=\[child=\{name=\"var_complx\.i\",exp=\"i\",numchild=\"0\",type=\"int\",thread-id=\"1\",value=\"3\",has_more=\"0\"\},child=\{name=\"var_complx\.inner\",exp=\"inner\",numchild=\"1\",type=\"complex_type::\(anonymous struct\)\",thread-id=\"1\",value=\"\{\.\.\.\}\",has_more=\"0\"\},child=\{name=\"var_complx\.complex_ptr\",exp=\"complex_ptr\",numchild=\"3\",type=\"complex_type \*\",thread-id=\"1\",value=\"0x[0-9a-f]+\",has_more=\"0\"\}\],has_more=\"0\"")
self.runCmd("-var-list-children --simple-values var_complx_array")
- self.expect("\^done,numchild=\"2\",children=\[child=\{name=\"var_complx_array\.\[0\]\",exp=\"\[0\]\",numchild=\"3\",type=\"complex_type\",thread-id=\"1\",has_more=\"0\"\},child=\{name=\"var_complx_array\.\[1\]\",exp=\"\[1\]\",numchild=\"3\",type=\"complex_type\",thread-id=\"1\",has_more=\"0\"\}\],has_more=\"0\"")
+ self.expect(
+ "\^done,numchild=\"2\",children=\[child=\{name=\"var_complx_array\.\[0\]\",exp=\"\[0\]\",numchild=\"3\",type=\"complex_type\",thread-id=\"1\",has_more=\"0\"\},child=\{name=\"var_complx_array\.\[1\]\",exp=\"\[1\]\",numchild=\"3\",type=\"complex_type\",thread-id=\"1\",has_more=\"0\"\}\],has_more=\"0\"")
self.runCmd("-var-list-children 0 var_pcomplx")
- self.expect("\^done,numchild=\"2\",children=\[child=\{name=\"var_pcomplx\.complex_type\",exp=\"complex_type\",numchild=\"3\",type=\"complex_type\",thread-id=\"1\",has_more=\"0\"\},child={name=\"var_pcomplx\.complx\",exp=\"complx\",numchild=\"3\",type=\"complex_type\",thread-id=\"1\",has_more=\"0\"\}\],has_more=\"0\"")
+ self.expect(
+ "\^done,numchild=\"2\",children=\[child=\{name=\"var_pcomplx\.complex_type\",exp=\"complex_type\",numchild=\"3\",type=\"complex_type\",thread-id=\"1\",has_more=\"0\"\},child={name=\"var_pcomplx\.complx\",exp=\"complx\",numchild=\"3\",type=\"complex_type\",thread-id=\"1\",has_more=\"0\"\}\],has_more=\"0\"")
# Test that -var-list-children lists children without values
self.runCmd("-var-list-children 0 var_complx 0 1")
- self.expect("\^done,numchild=\"1\",children=\[child=\{name=\"var_complx\.i\",exp=\"i\",numchild=\"0\",type=\"int\",thread-id=\"1\",has_more=\"0\"\}\],has_more=\"1\"")
+ self.expect(
+ "\^done,numchild=\"1\",children=\[child=\{name=\"var_complx\.i\",exp=\"i\",numchild=\"0\",type=\"int\",thread-id=\"1\",has_more=\"0\"\}\],has_more=\"1\"")
self.runCmd("-var-list-children --no-values var_complx 0 1")
- self.expect("\^done,numchild=\"1\",children=\[child=\{name=\"var_complx\.i\",exp=\"i\",numchild=\"0\",type=\"int\",thread-id=\"1\",has_more=\"0\"\}\],has_more=\"1\"")
+ self.expect(
+ "\^done,numchild=\"1\",children=\[child=\{name=\"var_complx\.i\",exp=\"i\",numchild=\"0\",type=\"int\",thread-id=\"1\",has_more=\"0\"\}\],has_more=\"1\"")
self.runCmd("-var-list-children --no-values var_complx_array 0 1")
- self.expect("\^done,numchild=\"1\",children=\[child=\{name=\"var_complx_array\.\[0\]\",exp=\"\[0\]\",numchild=\"3\",type=\"complex_type\",thread-id=\"1\",has_more=\"0\"\}\],has_more=\"1\"")
+ self.expect(
+ "\^done,numchild=\"1\",children=\[child=\{name=\"var_complx_array\.\[0\]\",exp=\"\[0\]\",numchild=\"3\",type=\"complex_type\",thread-id=\"1\",has_more=\"0\"\}\],has_more=\"1\"")
self.runCmd("-var-list-children --no-values var_pcomplx 0 1")
- self.expect("\^done,numchild=\"1\",children=\[child=\{name=\"var_pcomplx\.complex_type\",exp=\"complex_type\",numchild=\"3\",type=\"complex_type\",thread-id=\"1\",has_more=\"0\"\}\],has_more=\"1\"")
+ self.expect(
+ "\^done,numchild=\"1\",children=\[child=\{name=\"var_pcomplx\.complex_type\",exp=\"complex_type\",numchild=\"3\",type=\"complex_type\",thread-id=\"1\",has_more=\"0\"\}\],has_more=\"1\"")
# Test that -var-list-children lists children with all values
self.runCmd("-var-list-children 1 var_complx 1 2")
- self.expect("\^done,numchild=\"1\",children=\[child=\{name=\"var_complx\.inner\",exp=\"inner\",numchild=\"1\",type=\"complex_type::\(anonymous struct\)\",thread-id=\"1\",value=\"\{\.\.\.\}\",has_more=\"0\"\}\],has_more=\"1\"")
+ self.expect(
+ "\^done,numchild=\"1\",children=\[child=\{name=\"var_complx\.inner\",exp=\"inner\",numchild=\"1\",type=\"complex_type::\(anonymous struct\)\",thread-id=\"1\",value=\"\{\.\.\.\}\",has_more=\"0\"\}\],has_more=\"1\"")
self.runCmd("-var-list-children --all-values var_complx 1 2")
- self.expect("\^done,numchild=\"1\",children=\[child=\{name=\"var_complx\.inner\",exp=\"inner\",numchild=\"1\",type=\"complex_type::\(anonymous struct\)\",thread-id=\"1\",value=\"\{\.\.\.\}\",has_more=\"0\"\}\],has_more=\"1\"")
+ self.expect(
+ "\^done,numchild=\"1\",children=\[child=\{name=\"var_complx\.inner\",exp=\"inner\",numchild=\"1\",type=\"complex_type::\(anonymous struct\)\",thread-id=\"1\",value=\"\{\.\.\.\}\",has_more=\"0\"\}\],has_more=\"1\"")
self.runCmd("-var-list-children --all-values var_complx_array 1 2")
- self.expect("\^done,numchild=\"1\",children=\[child=\{name=\"var_complx_array\.\[1\]\",exp=\"\[1\]\",numchild=\"3\",type=\"complex_type\",thread-id=\"1\",value=\"\{\.\.\.\}\",has_more=\"0\"\}\],has_more=\"0\"")
+ self.expect(
+ "\^done,numchild=\"1\",children=\[child=\{name=\"var_complx_array\.\[1\]\",exp=\"\[1\]\",numchild=\"3\",type=\"complex_type\",thread-id=\"1\",value=\"\{\.\.\.\}\",has_more=\"0\"\}\],has_more=\"0\"")
self.runCmd("-var-list-children --all-values var_pcomplx 1 2")
- self.expect("\^done,numchild=\"1\",children=\[child={name=\"var_pcomplx\.complx\",exp=\"complx\",numchild=\"3\",type=\"complex_type\",thread-id=\"1\",value=\"\{\.\.\.\}\",has_more=\"0\"\}\],has_more=\"0\"")
+ self.expect(
+ "\^done,numchild=\"1\",children=\[child={name=\"var_pcomplx\.complx\",exp=\"complx\",numchild=\"3\",type=\"complex_type\",thread-id=\"1\",value=\"\{\.\.\.\}\",has_more=\"0\"\}\],has_more=\"0\"")
# Test that -var-list-children lists children with simple values
self.runCmd("-var-list-children 2 var_complx 2 4")
- self.expect("\^done,numchild=\"1\",children=\[child=\{name=\"var_complx\.complex_ptr\",exp=\"complex_ptr\",numchild=\"3\",type=\"complex_type \*\",thread-id=\"1\",has_more=\"0\"\}\],has_more=\"0\"")
+ self.expect(
+ "\^done,numchild=\"1\",children=\[child=\{name=\"var_complx\.complex_ptr\",exp=\"complex_ptr\",numchild=\"3\",type=\"complex_type \*\",thread-id=\"1\",has_more=\"0\"\}\],has_more=\"0\"")
self.runCmd("-var-list-children --simple-values var_complx 2 4")
- self.expect("\^done,numchild=\"1\",children=\[child=\{name=\"var_complx\.complex_ptr\",exp=\"complex_ptr\",numchild=\"3\",type=\"complex_type \*\",thread-id=\"1\",has_more=\"0\"\}\],has_more=\"0\"")
+ self.expect(
+ "\^done,numchild=\"1\",children=\[child=\{name=\"var_complx\.complex_ptr\",exp=\"complex_ptr\",numchild=\"3\",type=\"complex_type \*\",thread-id=\"1\",has_more=\"0\"\}\],has_more=\"0\"")
self.runCmd("-var-list-children --simple-values var_complx_array 2 4")
self.expect("\^done,numchild=\"0\",has_more=\"0\"")
self.runCmd("-var-list-children --simple-values var_pcomplx 2 4")
@@ -330,15 +383,16 @@ class MiVarTestCase(lldbmi_testcase.MiTestCaseBase):
# Test that a missing low-frame or high-frame is handled
self.runCmd("-var-list-children 0 var_complx 0")
- self.expect("\^error,msg=\"Command 'var-list-children'. Variable children range invalid\"")
+ self.expect(
+ "\^error,msg=\"Command 'var-list-children'. Variable children range invalid\"")
- @skipIfWindows #llvm.org/pr24452: Get lldb-mi working on Windows
- @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
- @skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots
+ @skipIfWindows # llvm.org/pr24452: Get lldb-mi working on Windows
+ @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots
def test_lldbmi_var_create_for_stl_types(self):
"""Test that 'lldb-mi --interpreter' print summary for STL types."""
- self.spawnLldbMi(args = None)
+ self.spawnLldbMi(args=None)
# Load executable
self.runCmd("-file-exec-and-symbols %s" % self.myexe)
@@ -354,15 +408,16 @@ class MiVarTestCase(lldbmi_testcase.MiTestCaseBase):
# Test for std::string
self.runCmd("-var-create - * std_string")
- self.expect('\^done,name="var\d+",numchild="[0-9]+",value="\\\\"hello\\\\"",type="std::[\S]*?string",thread-id="1",has_more="0"')
-
- @skipIfWindows #llvm.org/pr24452: Get lldb-mi working on Windows
- @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
- @skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots
+ self.expect(
+ '\^done,name="var\d+",numchild="[0-9]+",value="\\\\"hello\\\\"",type="std::[\S]*?string",thread-id="1",has_more="0"')
+
+ @skipIfWindows # llvm.org/pr24452: Get lldb-mi working on Windows
+ @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots
def test_lldbmi_var_create_for_unnamed_objects(self):
"""Test that 'lldb-mi --interpreter' can expand unnamed structures and unions."""
- self.spawnLldbMi(args = None)
+ self.spawnLldbMi(args=None)
# Load executable
self.runCmd("-file-exec-and-symbols %s" % self.myexe)
@@ -378,15 +433,16 @@ class MiVarTestCase(lldbmi_testcase.MiTestCaseBase):
# Evaluate struct_with_unions type and its children
self.runCmd("-var-create v0 * swu")
- self.expect('\^done,name="v0",numchild="2",value="\{\.\.\.\}",type="struct_with_unions",thread-id="1",has_more="0"')
-
+ self.expect(
+ '\^done,name="v0",numchild="2",value="\{\.\.\.\}",type="struct_with_unions",thread-id="1",has_more="0"')
+
self.runCmd("-var-list-children v0")
-
+
# inspect the first unnamed union
self.runCmd("-var-list-children v0.$0")
self.runCmd("-var-evaluate-expression v0.$0.u_i")
self.expect('\^done,value="1"')
-
+
# inspect the second unnamed union
self.runCmd("-var-list-children v0.$1")
self.runCmd("-var-evaluate-expression v0.$1.u1")
@@ -395,4 +451,3 @@ class MiVarTestCase(lldbmi_testcase.MiTestCaseBase):
self.runCmd("-var-list-children v0.$1.$1")
self.runCmd("-var-evaluate-expression v0.$1.$1.s1")
self.expect('\^done,value="-1"')
-
diff --git a/packages/Python/lldbsuite/test/tools/lldb-server/Makefile b/packages/Python/lldbsuite/test/tools/lldb-server/Makefile
index 6ae4e6624eef..28aba3cf5463 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-server/Makefile
+++ b/packages/Python/lldbsuite/test/tools/lldb-server/Makefile
@@ -1,6 +1,6 @@
LEVEL = ../../make
-CFLAGS_EXTRAS += -D__STDC_LIMIT_MACROS -D__STDC_FORMAT_MACROS
+override CFLAGS_EXTRAS += -D__STDC_LIMIT_MACROS -D__STDC_FORMAT_MACROS
ENABLE_THREADS := YES
CXX_SOURCES := main.cpp
MAKE_DSYM :=NO
diff --git a/packages/Python/lldbsuite/test/tools/lldb-server/TestGDBRemoteMemoryRead.py b/packages/Python/lldbsuite/test/tools/lldb-server/TestGDBRemoteMemoryRead.py
deleted file mode 100644
index 1296d513b917..000000000000
--- a/packages/Python/lldbsuite/test/tools/lldb-server/TestGDBRemoteMemoryRead.py
+++ /dev/null
@@ -1,45 +0,0 @@
-"""
-Tests the binary ($x) and hex ($m) memory read packets of the remote stub
-"""
-
-from __future__ import print_function
-
-
-
-import binascii
-import os
-
-import lldb
-from lldbsuite.test.decorators import *
-from lldbsuite.test.lldbtest import *
-from lldbsuite.test import lldbutil
-from lldbsuite.test import lldbplatformutil
-
-
-class MemoryReadTestCase(TestBase):
-
- mydir = TestBase.compute_mydir(__file__)
-
- @skipUnlessPlatform(lldbplatformutil.getDarwinOSTriples()+["linux"])
- def test_memory_read(self):
- self.build()
- exe = os.path.join (os.getcwd(), "a.out")
-
- target = self.dbg.CreateTarget(exe)
- lldbutil.run_break_set_by_symbol(self, "main")
-
- process = target.LaunchSimple (None, None, self.get_process_working_directory())
- self.assertTrue(process, PROCESS_IS_VALID)
- self.assertEqual(process.GetState(), lldb.eStateStopped, "Process is stopped")
-
- pc = process.GetSelectedThread().GetSelectedFrame().GetPC()
- for size in [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]:
- error = lldb.SBError()
- memory = process.ReadMemory(pc, size, error)
- self.assertTrue(error.Success())
- # Results in trying to write non-printable characters to the session log.
- # self.match("process plugin packet send x%x,%x" % (pc, size), ["response:", memory])
- self.match("process plugin packet send m%x,%x" % (pc, size), ["response:", binascii.hexlify(memory)])
-
- process.Continue()
- self.assertEqual(process.GetState(), lldb.eStateExited, "Process exited")
diff --git a/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteAttach.py b/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteAttach.py
index 5460b21382ec..e53d80b48f9d 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteAttach.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteAttach.py
@@ -1,35 +1,40 @@
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
+
class TestGdbRemoteAttach(gdbremote_testcase.GdbRemoteTestCaseBase):
mydir = TestBase.compute_mydir(__file__)
def attach_with_vAttach(self):
# Start the inferior, start the debug monitor, nothing is attached yet.
- procs = self.prep_debug_monitor_and_inferior(inferior_args=["sleep:60"])
+ procs = self.prep_debug_monitor_and_inferior(
+ inferior_args=["sleep:60"])
self.assertIsNotNone(procs)
# Make sure the target process has been launched.
inferior = procs.get("inferior")
self.assertIsNotNone(inferior)
self.assertTrue(inferior.pid > 0)
- self.assertTrue(lldbgdbserverutils.process_is_running(inferior.pid, True))
+ self.assertTrue(
+ lldbgdbserverutils.process_is_running(
+ inferior.pid, True))
# Add attach packets.
self.test_sequence.add_log_lines([
# Do the attach.
"read packet: $vAttach;{:x}#00".format(inferior.pid),
# Expect a stop notification from the attach.
- { "direction":"send", "regex":r"^\$T([0-9a-fA-F]{2})[^#]*#[0-9a-fA-F]{2}$", "capture":{1:"stop_signal_hex"} },
- ], True)
+ {"direction": "send",
+ "regex": r"^\$T([0-9a-fA-F]{2})[^#]*#[0-9a-fA-F]{2}$",
+ "capture": {1: "stop_signal_hex"}},
+ ], True)
self.add_process_info_collection_packets()
# Run the stream
diff --git a/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteAuxvSupport.py b/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteAuxvSupport.py
index e70ad5f570a7..ffabefc70f8d 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteAuxvSupport.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteAuxvSupport.py
@@ -1,12 +1,12 @@
from __future__ import print_function
-
import gdbremote_testcase
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
+
class TestGdbRemoteAuxvSupport(gdbremote_testcase.GdbRemoteTestCaseBase):
mydir = TestBase.compute_mydir(__file__)
@@ -15,7 +15,8 @@ class TestGdbRemoteAuxvSupport(gdbremote_testcase.GdbRemoteTestCaseBase):
def has_auxv_support(self):
inferior_args = ["message:main entered", "sleep:5"]
- procs = self.prep_debug_monitor_and_inferior(inferior_args=inferior_args)
+ procs = self.prep_debug_monitor_and_inferior(
+ inferior_args=inferior_args)
# Don't do anything until we match the launched inferior main entry output.
# Then immediately interrupt the process.
@@ -25,8 +26,9 @@ class TestGdbRemoteAuxvSupport(gdbremote_testcase.GdbRemoteTestCaseBase):
# Start the inferior...
"read packet: $c#63",
# ... match output....
- { "type":"output_match", "regex":self.maybe_strict_output_regex(r"message:main entered\r\n") },
- ], True)
+ {"type": "output_match", "regex": self.maybe_strict_output_regex(
+ r"message:main entered\r\n")},
+ ], True)
# ... then interrupt.
self.add_interrupt_packets()
self.add_qSupported_packets()
@@ -35,7 +37,8 @@ class TestGdbRemoteAuxvSupport(gdbremote_testcase.GdbRemoteTestCaseBase):
self.assertIsNotNone(context)
features = self.parse_qSupported_response(context)
- return self.AUXV_SUPPORT_FEATURE_NAME in features and features[self.AUXV_SUPPORT_FEATURE_NAME] == "+"
+ return self.AUXV_SUPPORT_FEATURE_NAME in features and features[
+ self.AUXV_SUPPORT_FEATURE_NAME] == "+"
def get_raw_auxv_data(self):
# Start up llgs and inferior, and check for auxv support.
@@ -60,10 +63,20 @@ class TestGdbRemoteAuxvSupport(gdbremote_testcase.GdbRemoteTestCaseBase):
# Grab the auxv data.
self.reset_test_sequence()
- self.test_sequence.add_log_lines([
- "read packet: $qXfer:auxv:read::{:x},{:x}:#00".format(OFFSET, LENGTH),
- {"direction":"send", "regex":re.compile(r"^\$([^E])(.*)#[0-9a-fA-F]{2}$", re.MULTILINE|re.DOTALL), "capture":{1:"response_type", 2:"content_raw"} }
- ], True)
+ self.test_sequence.add_log_lines(
+ [
+ "read packet: $qXfer:auxv:read::{:x},{:x}:#00".format(
+ OFFSET,
+ LENGTH),
+ {
+ "direction": "send",
+ "regex": re.compile(
+ r"^\$([^E])(.*)#[0-9a-fA-F]{2}$",
+ re.MULTILINE | re.DOTALL),
+ "capture": {
+ 1: "response_type",
+ 2: "content_raw"}}],
+ True)
context = self.expect_gdbremote_sequence()
self.assertIsNotNone(context)
@@ -101,8 +114,9 @@ class TestGdbRemoteAuxvSupport(gdbremote_testcase.GdbRemoteTestCaseBase):
(word_size, auxv_data) = self.get_raw_auxv_data()
self.assertIsNotNone(auxv_data)
- # Ensure auxv data is a multiple of 2*word_size (there should be two unsigned long fields per auxv entry).
- self.assertEqual(len(auxv_data) % (2*word_size), 0)
+ # Ensure auxv data is a multiple of 2*word_size (there should be two
+ # unsigned long fields per auxv entry).
+ self.assertEqual(len(auxv_data) % (2 * word_size), 0)
# print("auxv contains {} entries".format(len(auxv_data) / (2*word_size)))
@debugserver_test
@@ -179,10 +193,12 @@ class TestGdbRemoteAuxvSupport(gdbremote_testcase.GdbRemoteTestCaseBase):
auxv_dict = self.build_auxv_dict(endian, word_size, auxv_data)
self.assertIsNotNone(auxv_dict)
- iterated_auxv_data = self.read_binary_data_in_chunks("qXfer:auxv:read::", 2*word_size)
+ iterated_auxv_data = self.read_binary_data_in_chunks(
+ "qXfer:auxv:read::", 2 * word_size)
self.assertIsNotNone(iterated_auxv_data)
- auxv_dict_iterated = self.build_auxv_dict(endian, word_size, iterated_auxv_data)
+ auxv_dict_iterated = self.build_auxv_dict(
+ endian, word_size, iterated_auxv_data)
self.assertIsNotNone(auxv_dict_iterated)
# Verify both types of data collection returned same content.
diff --git a/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteExpeditedRegisters.py b/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteExpeditedRegisters.py
index 7daae871caf6..dc2b99f54bd6 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteExpeditedRegisters.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteExpeditedRegisters.py
@@ -1,13 +1,14 @@
from __future__ import print_function
-
import gdbremote_testcase
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
-class TestGdbRemoteExpeditedRegisters(gdbremote_testcase.GdbRemoteTestCaseBase):
+
+class TestGdbRemoteExpeditedRegisters(
+ gdbremote_testcase.GdbRemoteTestCaseBase):
mydir = TestBase.compute_mydir(__file__)
@@ -19,8 +20,11 @@ class TestGdbRemoteExpeditedRegisters(gdbremote_testcase.GdbRemoteTestCaseBase):
"read packet: $c#63",
# Immediately tell it to stop. We want to see what it reports.
"read packet: {}".format(chr(3)),
- {"direction":"send", "regex":r"^\$T([0-9a-fA-F]+)([^#]+)#[0-9a-fA-F]{2}$", "capture":{1:"stop_result", 2:"key_vals_text"} },
- ], True)
+ {"direction": "send",
+ "regex": r"^\$T([0-9a-fA-F]+)([^#]+)#[0-9a-fA-F]{2}$",
+ "capture": {1: "stop_result",
+ 2: "key_vals_text"}},
+ ], True)
# Run the gdb remote command stream.
context = self.expect_gdbremote_sequence()
@@ -30,13 +34,16 @@ class TestGdbRemoteExpeditedRegisters(gdbremote_testcase.GdbRemoteTestCaseBase):
key_vals_text = context.get("key_vals_text")
self.assertIsNotNone(key_vals_text)
- expedited_registers = self.extract_registers_from_stop_notification(key_vals_text)
+ expedited_registers = self.extract_registers_from_stop_notification(
+ key_vals_text)
self.assertIsNotNone(expedited_registers)
return expedited_registers
- def stop_notification_contains_generic_register(self, generic_register_name):
- # Generate a stop reply, parse out expedited registers from stop notification.
+ def stop_notification_contains_generic_register(
+ self, generic_register_name):
+ # Generate a stop reply, parse out expedited registers from stop
+ # notification.
expedited_registers = self.gather_expedited_registers()
self.assertIsNotNone(expedited_registers)
self.assertTrue(len(expedited_registers) > 0)
@@ -45,7 +52,8 @@ class TestGdbRemoteExpeditedRegisters(gdbremote_testcase.GdbRemoteTestCaseBase):
reg_infos = self.gather_register_infos()
# Find the generic register.
- reg_info = self.find_generic_register_with_name(reg_infos, generic_register_name)
+ reg_info = self.find_generic_register_with_name(
+ reg_infos, generic_register_name)
self.assertIsNotNone(reg_info)
# Ensure the expedited registers contained it.
@@ -53,7 +61,8 @@ class TestGdbRemoteExpeditedRegisters(gdbremote_testcase.GdbRemoteTestCaseBase):
# print("{} reg_info:{}".format(generic_register_name, reg_info))
def stop_notification_contains_any_registers(self):
- # Generate a stop reply, parse out expedited registers from stop notification.
+ # Generate a stop reply, parse out expedited registers from stop
+ # notification.
expedited_registers = self.gather_expedited_registers()
# Verify we have at least one expedited register.
self.assertTrue(len(expedited_registers) > 0)
@@ -73,15 +82,19 @@ class TestGdbRemoteExpeditedRegisters(gdbremote_testcase.GdbRemoteTestCaseBase):
self.stop_notification_contains_any_registers()
def stop_notification_contains_no_duplicate_registers(self):
- # Generate a stop reply, parse out expedited registers from stop notification.
+ # Generate a stop reply, parse out expedited registers from stop
+ # notification.
expedited_registers = self.gather_expedited_registers()
# Verify no expedited register was specified multiple times.
for (reg_num, value) in list(expedited_registers.items()):
- if (type(value) == list) and (len(value) > 0):
- self.fail("expedited register number {} specified more than once ({} times)".format(reg_num, len(value)))
+ if (isinstance(value, list)) and (len(value) > 0):
+ self.fail(
+ "expedited register number {} specified more than once ({} times)".format(
+ reg_num, len(value)))
@debugserver_test
- def test_stop_notification_contains_no_duplicate_registers_debugserver(self):
+ def test_stop_notification_contains_no_duplicate_registers_debugserver(
+ self):
self.init_debugserver_test()
self.build()
self.set_inferior_startup_launch()
diff --git a/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteKill.py b/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteKill.py
index 560da9d41429..c3ecf5bc24df 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteKill.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteKill.py
@@ -1,13 +1,13 @@
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
+
class TestGdbRemoteKill(gdbremote_testcase.GdbRemoteTestCaseBase):
mydir = TestBase.compute_mydir(__file__)
@@ -16,18 +16,20 @@ class TestGdbRemoteKill(gdbremote_testcase.GdbRemoteTestCaseBase):
procs = self.prep_debug_monitor_and_inferior()
self.test_sequence.add_log_lines([
"read packet: $k#6b",
- {"direction":"send", "regex":r"^\$X[0-9a-fA-F]+([^#]*)#[0-9A-Fa-f]{2}" },
- ], True)
+ {"direction": "send", "regex": r"^\$X[0-9a-fA-F]+([^#]*)#[0-9A-Fa-f]{2}"},
+ ], True)
if self.stub_sends_two_stop_notifications_on_kill:
- # Add an expectation for a second X result for stubs that send two of these.
+ # Add an expectation for a second X result for stubs that send two
+ # of these.
self.test_sequence.add_log_lines([
- {"direction":"send", "regex":r"^\$X[0-9a-fA-F]+([^#]*)#[0-9A-Fa-f]{2}" },
- ], True)
+ {"direction": "send", "regex": r"^\$X[0-9a-fA-F]+([^#]*)#[0-9A-Fa-f]{2}"},
+ ], True)
self.expect_gdbremote_sequence()
- # Wait a moment for completed and now-detached inferior process to clear.
+ # Wait a moment for completed and now-detached inferior process to
+ # clear.
time.sleep(1)
if not lldb.remote_platform:
@@ -35,8 +37,11 @@ class TestGdbRemoteKill(gdbremote_testcase.GdbRemoteTestCaseBase):
poll_result = procs["inferior"].poll()
self.assertIsNotNone(poll_result)
- # Where possible, verify at the system level that the process is not running.
- self.assertFalse(lldbgdbserverutils.process_is_running(procs["inferior"].pid, False))
+ # Where possible, verify at the system level that the process is not
+ # running.
+ self.assertFalse(
+ lldbgdbserverutils.process_is_running(
+ procs["inferior"].pid, False))
@debugserver_test
def test_attach_commandline_kill_after_initial_stop_debugserver(self):
@@ -51,4 +56,3 @@ class TestGdbRemoteKill(gdbremote_testcase.GdbRemoteTestCaseBase):
self.build()
self.set_inferior_startup_attach()
self.attach_commandline_kill_after_initial_stop()
-
diff --git a/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteModuleInfo.py b/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteModuleInfo.py
new file mode 100644
index 000000000000..cab8a9cedfa0
--- /dev/null
+++ b/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteModuleInfo.py
@@ -0,0 +1,43 @@
+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
+
+
+class TestGdbRemoteModuleInfo(gdbremote_testcase.GdbRemoteTestCaseBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def module_info(self):
+ procs = self.prep_debug_monitor_and_inferior()
+ self.add_process_info_collection_packets()
+ context = self.expect_gdbremote_sequence()
+ info = self.parse_process_info_response(context)
+
+ self.test_sequence.add_log_lines([
+ 'read packet: $jModulesInfo:[{"file":"%s","triple":"%s"}]]#00' % (
+ lldbutil.append_to_process_working_directory("a.out"),
+ info["triple"].decode('hex')),
+ {"direction": "send",
+ "regex": r'^\$\[{(.*)}\]\]#[0-9A-Fa-f]{2}',
+ "capture": {1: "spec"}},
+ ], True)
+
+ context = self.expect_gdbremote_sequence()
+ spec = context.get("spec")
+ self.assertRegexpMatches(spec, '"file_path":".*"')
+ self.assertRegexpMatches(spec, '"file_offset":\d+')
+ self.assertRegexpMatches(spec, '"file_size":\d+')
+ self.assertRegexpMatches(spec, '"triple":"\w*-\w*-.*"')
+ self.assertRegexpMatches(spec, '"uuid":"[A-Fa-f0-9]+"')
+
+ @llgs_test
+ def test_module_info(self):
+ self.init_llgs_test()
+ self.build()
+ self.set_inferior_startup_launch()
+ self.module_info()
diff --git a/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteProcessInfo.py b/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteProcessInfo.py
index f26b62043613..21af255cfd94 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteProcessInfo.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteProcessInfo.py
@@ -9,6 +9,7 @@ from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
+
class TestGdbRemoteProcessInfo(gdbremote_testcase.GdbRemoteTestCaseBase):
mydir = TestBase.compute_mydir(__file__)
@@ -52,7 +53,7 @@ class TestGdbRemoteProcessInfo(gdbremote_testcase.GdbRemoteTestCaseBase):
self.add_process_info_collection_packets()
# Run the stream
- context = self.expect_gdbremote_sequence(timeout_seconds = 8)
+ context = self.expect_gdbremote_sequence(timeout_seconds=8)
self.assertIsNotNone(context)
# Gather process info response
@@ -66,7 +67,8 @@ class TestGdbRemoteProcessInfo(gdbremote_testcase.GdbRemoteTestCaseBase):
self.assertEqual(reported_pid, procs["inferior"].pid)
@debugserver_test
- def test_attach_commandline_qProcessInfo_reports_correct_pid_debugserver(self):
+ def test_attach_commandline_qProcessInfo_reports_correct_pid_debugserver(
+ self):
self.init_debugserver_test()
self.build()
self.set_inferior_startup_attach()
@@ -120,13 +122,17 @@ class TestGdbRemoteProcessInfo(gdbremote_testcase.GdbRemoteTestCaseBase):
process_info = self.parse_process_info_response(context)
self.assertIsNotNone(process_info)
- # Ensure the expected keys are present and non-None within the process info.
+ # Ensure the expected keys are present and non-None within the process
+ # info.
missing_key_set = set()
for expected_key in expected_key_set:
if expected_key not in process_info:
missing_key_set.add(expected_key)
- self.assertEqual(missing_key_set, set(), "the listed keys are missing in the qProcessInfo result")
+ self.assertEqual(
+ missing_key_set,
+ set(),
+ "the listed keys are missing in the qProcessInfo result")
def qProcessInfo_does_not_contain_keys(self, absent_key_set):
procs = self.prep_debug_monitor_and_inferior()
@@ -146,7 +152,10 @@ class TestGdbRemoteProcessInfo(gdbremote_testcase.GdbRemoteTestCaseBase):
if unexpected_key in process_info:
unexpected_key_set.add(unexpected_key)
- self.assertEqual(unexpected_key_set, set(), "the listed keys were present but unexpected in qProcessInfo result")
+ self.assertEqual(
+ unexpected_key_set,
+ set(),
+ "the listed keys were present but unexpected in qProcessInfo result")
@skipUnlessDarwin
@debugserver_test
@@ -155,6 +164,13 @@ class TestGdbRemoteProcessInfo(gdbremote_testcase.GdbRemoteTestCaseBase):
self.build()
self.qProcessInfo_contains_keys(set(['cputype', 'cpusubtype']))
+ @skipUnlessDarwin
+ @llgs_test
+ def test_qProcessInfo_contains_cputype_cpusubtype_llgs_darwin(self):
+ self.init_llgs_test()
+ self.build()
+ self.qProcessInfo_contains_keys(set(['cputype', 'cpusubtype']))
+
@skipUnlessPlatform(["linux"])
@llgs_test
def test_qProcessInfo_contains_triple_llgs_linux(self):
@@ -172,6 +188,16 @@ class TestGdbRemoteProcessInfo(gdbremote_testcase.GdbRemoteTestCaseBase):
# for the remote Host and Process.
self.qProcessInfo_does_not_contain_keys(set(['triple']))
+ @skipUnlessDarwin
+ @llgs_test
+ def test_qProcessInfo_does_not_contain_triple_llgs_darwin(self):
+ self.init_llgs_test()
+ self.build()
+ # We don't expect to see triple on darwin. If we do, we'll prefer triple
+ # to cputype/cpusubtype and skip some darwin-based ProcessGDBRemote ArchSpec setup
+ # for the remote Host and Process.
+ self.qProcessInfo_does_not_contain_keys(set(['triple']))
+
@skipUnlessPlatform(["linux"])
@llgs_test
def test_qProcessInfo_does_not_contain_cputype_cpusubtype_llgs_linux(self):
diff --git a/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteRegisterState.py b/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteRegisterState.py
index 63a8995c6729..b484bdcc4d57 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteRegisterState.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteRegisterState.py
@@ -1,12 +1,12 @@
from __future__ import print_function
-
import gdbremote_testcase
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
+
class TestGdbRemoteRegisterState(gdbremote_testcase.GdbRemoteTestCaseBase):
"""Test QSaveRegisterState/QRestoreRegisterState support."""
@@ -15,7 +15,8 @@ class TestGdbRemoteRegisterState(gdbremote_testcase.GdbRemoteTestCaseBase):
def grp_register_save_restore_works(self, with_suffix):
# Start up the process, use thread suffix, grab main thread id.
inferior_args = ["message:main entered", "sleep:5"]
- procs = self.prep_debug_monitor_and_inferior(inferior_args=inferior_args)
+ procs = self.prep_debug_monitor_and_inferior(
+ inferior_args=inferior_args)
self.add_process_info_collection_packets()
self.add_register_info_collection_packets()
@@ -26,8 +27,9 @@ class TestGdbRemoteRegisterState(gdbremote_testcase.GdbRemoteTestCaseBase):
# Start the inferior...
"read packet: $c#63",
# ... match output....
- { "type":"output_match", "regex":self.maybe_strict_output_regex(r"message:main entered\r\n") },
- ], True)
+ {"type": "output_match", "regex": self.maybe_strict_output_regex(
+ r"message:main entered\r\n")},
+ ], True)
# ... then interrupt.
self.add_interrupt_packets()
@@ -44,8 +46,10 @@ class TestGdbRemoteRegisterState(gdbremote_testcase.GdbRemoteTestCaseBase):
self.assertIsNotNone(reg_infos)
self.add_lldb_register_index(reg_infos)
- # Pull out the register infos that we think we can bit flip successfully.
- gpr_reg_infos = [reg_info for reg_info in reg_infos if self.is_bit_flippable_register(reg_info)]
+ # Pull out the register infos that we think we can bit flip
+ # successfully.
+ gpr_reg_infos = [
+ reg_info for reg_info in reg_infos if self.is_bit_flippable_register(reg_info)]
self.assertTrue(len(gpr_reg_infos) > 0)
# Gather thread info.
@@ -71,15 +75,18 @@ class TestGdbRemoteRegisterState(gdbremote_testcase.GdbRemoteTestCaseBase):
# print("saved register state id: {}".format(state_id))
# Remember initial register values.
- initial_reg_values = self.read_register_values(gpr_reg_infos, endian, thread_id=thread_id)
+ initial_reg_values = self.read_register_values(
+ gpr_reg_infos, endian, thread_id=thread_id)
# print("initial_reg_values: {}".format(initial_reg_values))
# Flip gpr register values.
- (successful_writes, failed_writes) = self.flip_all_bits_in_each_register_value(gpr_reg_infos, endian, thread_id=thread_id)
+ (successful_writes, failed_writes) = self.flip_all_bits_in_each_register_value(
+ gpr_reg_infos, endian, thread_id=thread_id)
# print("successful writes: {}, failed writes: {}".format(successful_writes, failed_writes))
self.assertTrue(successful_writes > 0)
- flipped_reg_values = self.read_register_values(gpr_reg_infos, endian, thread_id=thread_id)
+ flipped_reg_values = self.read_register_values(
+ gpr_reg_infos, endian, thread_id=thread_id)
# print("flipped_reg_values: {}".format(flipped_reg_values))
# Restore register values.
@@ -90,7 +97,8 @@ class TestGdbRemoteRegisterState(gdbremote_testcase.GdbRemoteTestCaseBase):
self.assertIsNotNone(context)
# Verify registers match initial register values.
- final_reg_values = self.read_register_values(gpr_reg_infos, endian, thread_id=thread_id)
+ final_reg_values = self.read_register_values(
+ gpr_reg_infos, endian, thread_id=thread_id)
# print("final_reg_values: {}".format(final_reg_values))
self.assertIsNotNone(final_reg_values)
self.assertEqual(final_reg_values, initial_reg_values)
diff --git a/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteSingleStep.py b/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteSingleStep.py
index 31d53bed2593..f3a18786b03a 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteSingleStep.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteSingleStep.py
@@ -1,12 +1,12 @@
from __future__ import print_function
-
import gdbremote_testcase
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
+
class TestGdbRemoteSingleStep(gdbremote_testcase.GdbRemoteTestCaseBase):
mydir = TestBase.compute_mydir(__file__)
@@ -16,13 +16,24 @@ class TestGdbRemoteSingleStep(gdbremote_testcase.GdbRemoteTestCaseBase):
self.init_debugserver_test()
self.build()
self.set_inferior_startup_launch()
- self.single_step_only_steps_one_instruction(use_Hc_packet=True, step_instruction="s")
+ self.single_step_only_steps_one_instruction(
+ use_Hc_packet=True, step_instruction="s")
@llgs_test
- @expectedFailureAndroid(bugnumber="llvm.org/pr24739", archs=["arm", "aarch64"])
- @expectedFailureAll(oslist=["linux"], archs=["arm", "aarch64"], bugnumber="llvm.org/pr24739")
+ @expectedFailureAndroid(
+ bugnumber="llvm.org/pr24739",
+ archs=[
+ "arm",
+ "aarch64"])
+ @expectedFailureAll(
+ oslist=["linux"],
+ archs=[
+ "arm",
+ "aarch64"],
+ bugnumber="llvm.org/pr24739")
def test_single_step_only_steps_one_instruction_with_s_llgs(self):
self.init_llgs_test()
self.build()
self.set_inferior_startup_launch()
- self.single_step_only_steps_one_instruction(use_Hc_packet=True, step_instruction="s")
+ self.single_step_only_steps_one_instruction(
+ use_Hc_packet=True, step_instruction="s")
diff --git a/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteThreadsInStopReply.py b/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteThreadsInStopReply.py
index d55416569ac4..57d4d5ab4bb1 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteThreadsInStopReply.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteThreadsInStopReply.py
@@ -5,7 +5,9 @@ from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
-class TestGdbRemoteThreadsInStopReply(gdbremote_testcase.GdbRemoteTestCaseBase):
+
+class TestGdbRemoteThreadsInStopReply(
+ gdbremote_testcase.GdbRemoteTestCaseBase):
mydir = TestBase.compute_mydir(__file__)
@@ -16,11 +18,12 @@ class TestGdbRemoteThreadsInStopReply(gdbremote_testcase.GdbRemoteTestCaseBase):
def gather_stop_reply_threads(self, post_startup_log_lines, thread_count):
# Set up the inferior args.
- inferior_args=[]
+ inferior_args = []
for i in range(thread_count - 1):
inferior_args.append("thread:new")
inferior_args.append("sleep:10")
- procs = self.prep_debug_monitor_and_inferior(inferior_args=inferior_args)
+ procs = self.prep_debug_monitor_and_inferior(
+ inferior_args=inferior_args)
# Assumes test_sequence has anything added needed to setup the initial state.
# (Like optionally enabling QThreadsInStopReply.)
@@ -28,17 +31,25 @@ class TestGdbRemoteThreadsInStopReply(gdbremote_testcase.GdbRemoteTestCaseBase):
self.test_sequence.add_log_lines(post_startup_log_lines, True)
self.test_sequence.add_log_lines([
"read packet: $c#63"
- ], True)
+ ], True)
context = self.expect_gdbremote_sequence()
self.assertIsNotNone(context)
# Give threads time to start up, then break.
time.sleep(1)
self.reset_test_sequence()
- self.test_sequence.add_log_lines([
- "read packet: {}".format(chr(3)),
- {"direction":"send", "regex":r"^\$T([0-9a-fA-F]+)([^#]+)#[0-9a-fA-F]{2}$", "capture":{1:"stop_result", 2:"key_vals_text"} },
- ], True)
+ self.test_sequence.add_log_lines(
+ [
+ "read packet: {}".format(
+ chr(3)),
+ {
+ "direction": "send",
+ "regex": r"^\$T([0-9a-fA-F]+)([^#]+)#[0-9a-fA-F]{2}$",
+ "capture": {
+ 1: "stop_result",
+ 2: "key_vals_text"}},
+ ],
+ True)
context = self.expect_gdbremote_sequence()
self.assertIsNotNone(context)
@@ -49,11 +60,14 @@ class TestGdbRemoteThreadsInStopReply(gdbremote_testcase.GdbRemoteTestCaseBase):
# Run, then stop the process, grab the stop reply content.
self.reset_test_sequence()
- self.test_sequence.add_log_lines([
- "read packet: $c#63",
- "read packet: {}".format(chr(3)),
- {"direction":"send", "regex":r"^\$T([0-9a-fA-F]+)([^#]+)#[0-9a-fA-F]{2}$", "capture":{1:"stop_result", 2:"key_vals_text"} },
- ], True)
+ self.test_sequence.add_log_lines(["read packet: $c#63",
+ "read packet: {}".format(chr(3)),
+ {"direction": "send",
+ "regex": r"^\$T([0-9a-fA-F]+)([^#]+)#[0-9a-fA-F]{2}$",
+ "capture": {1: "stop_result",
+ 2: "key_vals_text"}},
+ ],
+ True)
context = self.expect_gdbremote_sequence()
self.assertIsNotNone(context)
@@ -66,13 +80,15 @@ class TestGdbRemoteThreadsInStopReply(gdbremote_testcase.GdbRemoteTestCaseBase):
# Pull out threads from stop response.
stop_reply_threads_text = kv_dict.get("threads")
if stop_reply_threads_text:
- return [int(thread_id, 16) for thread_id in stop_reply_threads_text.split(",")]
+ return [int(thread_id, 16)
+ for thread_id in stop_reply_threads_text.split(",")]
else:
return []
def QListThreadsInStopReply_supported(self):
procs = self.prep_debug_monitor_and_inferior()
- self.test_sequence.add_log_lines(self.ENABLE_THREADS_IN_STOP_REPLY_ENTRIES, True)
+ self.test_sequence.add_log_lines(
+ self.ENABLE_THREADS_IN_STOP_REPLY_ENTRIES, True)
context = self.expect_gdbremote_sequence()
self.assertIsNotNone(context)
@@ -92,8 +108,10 @@ class TestGdbRemoteThreadsInStopReply(gdbremote_testcase.GdbRemoteTestCaseBase):
self.QListThreadsInStopReply_supported()
def stop_reply_reports_multiple_threads(self, thread_count):
- # Gather threads from stop notification when QThreadsInStopReply is enabled.
- stop_reply_threads = self.gather_stop_reply_threads(self.ENABLE_THREADS_IN_STOP_REPLY_ENTRIES, thread_count)
+ # Gather threads from stop notification when QThreadsInStopReply is
+ # enabled.
+ stop_reply_threads = self.gather_stop_reply_threads(
+ self.ENABLE_THREADS_IN_STOP_REPLY_ENTRIES, thread_count)
self.assertEqual(len(stop_reply_threads), thread_count)
@debugserver_test
@@ -111,7 +129,8 @@ class TestGdbRemoteThreadsInStopReply(gdbremote_testcase.GdbRemoteTestCaseBase):
self.stop_reply_reports_multiple_threads(5)
def no_QListThreadsInStopReply_supplies_no_threads(self, thread_count):
- # Gather threads from stop notification when QThreadsInStopReply is not enabled.
+ # Gather threads from stop notification when QThreadsInStopReply is not
+ # enabled.
stop_reply_threads = self.gather_stop_reply_threads(None, thread_count)
self.assertEqual(len(stop_reply_threads), 0)
@@ -130,8 +149,10 @@ class TestGdbRemoteThreadsInStopReply(gdbremote_testcase.GdbRemoteTestCaseBase):
self.no_QListThreadsInStopReply_supplies_no_threads(5)
def stop_reply_reports_correct_threads(self, thread_count):
- # Gather threads from stop notification when QThreadsInStopReply is enabled.
- stop_reply_threads = self.gather_stop_reply_threads(self.ENABLE_THREADS_IN_STOP_REPLY_ENTRIES, thread_count)
+ # Gather threads from stop notification when QThreadsInStopReply is
+ # enabled.
+ stop_reply_threads = self.gather_stop_reply_threads(
+ self.ENABLE_THREADS_IN_STOP_REPLY_ENTRIES, thread_count)
self.assertEqual(len(stop_reply_threads), thread_count)
# Gather threads from q{f,s}ThreadInfo.
@@ -144,7 +165,7 @@ class TestGdbRemoteThreadsInStopReply(gdbremote_testcase.GdbRemoteTestCaseBase):
threads = self.parse_threadinfo_packets(context)
self.assertIsNotNone(threads)
self.assertEqual(len(threads), thread_count)
-
+
# Ensure each thread in q{f,s}ThreadInfo appears in stop reply threads
for tid in threads:
self.assertTrue(tid in stop_reply_threads)
diff --git a/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemote_qThreadStopInfo.py b/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemote_qThreadStopInfo.py
index b2b54e3f0394..74e4849b0cb6 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemote_qThreadStopInfo.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemote_qThreadStopInfo.py
@@ -1,7 +1,6 @@
from __future__ import print_function
-
import sys
import unittest2
@@ -10,6 +9,7 @@ from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
+
class TestGdbRemote_qThreadStopInfo(gdbremote_testcase.GdbRemoteTestCaseBase):
mydir = TestBase.compute_mydir(__file__)
@@ -17,27 +17,36 @@ class TestGdbRemote_qThreadStopInfo(gdbremote_testcase.GdbRemoteTestCaseBase):
def gather_stop_replies_via_qThreadStopInfo(self, thread_count):
# Set up the inferior args.
- inferior_args=[]
+ inferior_args = []
for i in range(thread_count - 1):
inferior_args.append("thread:new")
inferior_args.append("sleep:10")
- procs = self.prep_debug_monitor_and_inferior(inferior_args=inferior_args)
+ procs = self.prep_debug_monitor_and_inferior(
+ inferior_args=inferior_args)
# Assumes test_sequence has anything added needed to setup the initial state.
# (Like optionally enabling QThreadsInStopReply.)
self.test_sequence.add_log_lines([
"read packet: $c#63"
- ], True)
+ ], True)
context = self.expect_gdbremote_sequence()
self.assertIsNotNone(context)
# Give threads time to start up, then break.
time.sleep(1)
self.reset_test_sequence()
- self.test_sequence.add_log_lines([
- "read packet: {}".format(chr(3)),
- {"direction":"send", "regex":r"^\$T([0-9a-fA-F]+)([^#]+)#[0-9a-fA-F]{2}$", "capture":{1:"stop_result", 2:"key_vals_text"} },
- ], True)
+ self.test_sequence.add_log_lines(
+ [
+ "read packet: {}".format(
+ chr(3)),
+ {
+ "direction": "send",
+ "regex": r"^\$T([0-9a-fA-F]+)([^#]+)#[0-9a-fA-F]{2}$",
+ "capture": {
+ 1: "stop_result",
+ 2: "key_vals_text"}},
+ ],
+ True)
context = self.expect_gdbremote_sequence()
self.assertIsNotNone(context)
@@ -52,10 +61,17 @@ class TestGdbRemote_qThreadStopInfo(gdbremote_testcase.GdbRemoteTestCaseBase):
for thread in threads:
# Run the qThreadStopInfo command.
self.reset_test_sequence()
- self.test_sequence.add_log_lines([
- "read packet: $qThreadStopInfo{:x}#00".format(thread),
- {"direction":"send", "regex":r"^\$T([0-9a-fA-F]+)([^#]+)#[0-9a-fA-F]{2}$", "capture":{1:"stop_result", 2:"key_vals_text"} },
- ], True)
+ self.test_sequence.add_log_lines(
+ [
+ "read packet: $qThreadStopInfo{:x}#00".format(thread),
+ {
+ "direction": "send",
+ "regex": r"^\$T([0-9a-fA-F]+)([^#]+)#[0-9a-fA-F]{2}$",
+ "capture": {
+ 1: "stop_result",
+ 2: "key_vals_text"}},
+ ],
+ True)
context = self.expect_gdbremote_sequence()
self.assertIsNotNone(context)
@@ -65,7 +81,8 @@ class TestGdbRemote_qThreadStopInfo(gdbremote_testcase.GdbRemoteTestCaseBase):
kv_dict = self.parse_key_val_dict(key_vals_text)
self.assertIsNotNone(kv_dict)
- # Verify there is a thread and that it matches the expected thread id.
+ # Verify there is a thread and that it matches the expected thread
+ # id.
kv_thread = kv_dict.get("thread")
self.assertIsNotNone(kv_thread)
kv_thread_id = int(kv_thread, 16)
@@ -99,12 +116,17 @@ class TestGdbRemote_qThreadStopInfo(gdbremote_testcase.GdbRemoteTestCaseBase):
self.set_inferior_startup_launch()
self.qThreadStopInfo_works_for_multiple_threads(self.THREAD_COUNT)
- def qThreadStopInfo_only_reports_one_thread_stop_reason_during_interrupt(self, thread_count):
+ def qThreadStopInfo_only_reports_one_thread_stop_reason_during_interrupt(
+ self, thread_count):
(stop_replies, _) = self.gather_stop_replies_via_qThreadStopInfo(thread_count)
self.assertIsNotNone(stop_replies)
- no_stop_reason_count = sum(1 for stop_reason in list(stop_replies.values()) if stop_reason == 0)
- with_stop_reason_count = sum(1 for stop_reason in list(stop_replies.values()) if stop_reason != 0)
+ no_stop_reason_count = sum(
+ 1 for stop_reason in list(
+ stop_replies.values()) if stop_reason == 0)
+ with_stop_reason_count = sum(
+ 1 for stop_reason in list(
+ stop_replies.values()) if stop_reason != 0)
# All but one thread should report no stop reason.
self.assertEqual(no_stop_reason_count, thread_count - 1)
@@ -113,20 +135,25 @@ class TestGdbRemote_qThreadStopInfo(gdbremote_testcase.GdbRemoteTestCaseBase):
self.assertEqual(with_stop_reason_count, 1)
@debugserver_test
- def test_qThreadStopInfo_only_reports_one_thread_stop_reason_during_interrupt_debugserver(self):
+ def test_qThreadStopInfo_only_reports_one_thread_stop_reason_during_interrupt_debugserver(
+ self):
self.init_debugserver_test()
self.build()
self.set_inferior_startup_launch()
- self.qThreadStopInfo_only_reports_one_thread_stop_reason_during_interrupt(self.THREAD_COUNT)
+ self.qThreadStopInfo_only_reports_one_thread_stop_reason_during_interrupt(
+ self.THREAD_COUNT)
@llgs_test
- def test_qThreadStopInfo_only_reports_one_thread_stop_reason_during_interrupt_llgs(self):
+ def test_qThreadStopInfo_only_reports_one_thread_stop_reason_during_interrupt_llgs(
+ self):
self.init_llgs_test()
self.build()
self.set_inferior_startup_launch()
- self.qThreadStopInfo_only_reports_one_thread_stop_reason_during_interrupt(self.THREAD_COUNT)
+ self.qThreadStopInfo_only_reports_one_thread_stop_reason_during_interrupt(
+ self.THREAD_COUNT)
- def qThreadStopInfo_has_valid_thread_names(self, thread_count, expected_thread_name):
+ def qThreadStopInfo_has_valid_thread_names(
+ self, thread_count, expected_thread_name):
(_, thread_dicts) = self.gather_stop_replies_via_qThreadStopInfo(thread_count)
self.assertIsNotNone(thread_dicts)
@@ -143,7 +170,8 @@ class TestGdbRemote_qThreadStopInfo(gdbremote_testcase.GdbRemoteTestCaseBase):
self.set_inferior_startup_launch()
self.qThreadStopInfo_has_valid_thread_names(self.THREAD_COUNT, "a.out")
- @skipUnlessPlatform(["linux"]) # test requires OS with set, equal thread names by default.
+ # test requires OS with set, equal thread names by default.
+ @skipUnlessPlatform(["linux"])
@llgs_test
def test_qThreadStopInfo_has_valid_thread_names_llgs(self):
self.init_llgs_test()
diff --git a/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemote_vCont.py b/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemote_vCont.py
index 335d96c2b074..1d98b9279f4f 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemote_vCont.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemote_vCont.py
@@ -5,13 +5,15 @@ from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
+
class TestGdbRemote_vCont(gdbremote_testcase.GdbRemoteTestCaseBase):
mydir = TestBase.compute_mydir(__file__)
def vCont_supports_mode(self, mode, inferior_args=None):
# Setup the stub and set the gdb remote command stream.
- procs = self.prep_debug_monitor_and_inferior(inferior_args=inferior_args)
+ procs = self.prep_debug_monitor_and_inferior(
+ inferior_args=inferior_args)
self.add_vCont_query_packets()
# Run the gdb remote command stream.
@@ -86,33 +88,58 @@ class TestGdbRemote_vCont(gdbremote_testcase.GdbRemoteTestCaseBase):
self.vCont_supports_S()
@debugserver_test
- def test_single_step_only_steps_one_instruction_with_Hc_vCont_s_debugserver(self):
+ def test_single_step_only_steps_one_instruction_with_Hc_vCont_s_debugserver(
+ self):
self.init_debugserver_test()
self.build()
self.set_inferior_startup_launch()
- self.single_step_only_steps_one_instruction(use_Hc_packet=True, step_instruction="vCont;s")
+ self.single_step_only_steps_one_instruction(
+ use_Hc_packet=True, step_instruction="vCont;s")
@llgs_test
- @expectedFailureAndroid(bugnumber="llvm.org/pr24739", archs=["arm", "aarch64"])
- @expectedFailureAll(oslist=["linux"], archs=["arm", "aarch64"], bugnumber="llvm.org/pr24739")
+ @expectedFailureAndroid(
+ bugnumber="llvm.org/pr24739",
+ archs=[
+ "arm",
+ "aarch64"])
+ @expectedFailureAll(
+ oslist=["linux"],
+ archs=[
+ "arm",
+ "aarch64"],
+ bugnumber="llvm.org/pr24739")
def test_single_step_only_steps_one_instruction_with_Hc_vCont_s_llgs(self):
self.init_llgs_test()
self.build()
self.set_inferior_startup_launch()
- self.single_step_only_steps_one_instruction(use_Hc_packet=True, step_instruction="vCont;s")
+ self.single_step_only_steps_one_instruction(
+ use_Hc_packet=True, step_instruction="vCont;s")
@debugserver_test
- def test_single_step_only_steps_one_instruction_with_vCont_s_thread_debugserver(self):
+ def test_single_step_only_steps_one_instruction_with_vCont_s_thread_debugserver(
+ self):
self.init_debugserver_test()
self.build()
self.set_inferior_startup_launch()
- self.single_step_only_steps_one_instruction(use_Hc_packet=False, step_instruction="vCont;s:{thread}")
+ self.single_step_only_steps_one_instruction(
+ use_Hc_packet=False, step_instruction="vCont;s:{thread}")
@llgs_test
- @expectedFailureAndroid(bugnumber="llvm.org/pr24739", archs=["arm", "aarch64"])
- @expectedFailureAll(oslist=["linux"], archs=["arm", "aarch64"], bugnumber="llvm.org/pr24739")
- def test_single_step_only_steps_one_instruction_with_vCont_s_thread_llgs(self):
+ @expectedFailureAndroid(
+ bugnumber="llvm.org/pr24739",
+ archs=[
+ "arm",
+ "aarch64"])
+ @expectedFailureAll(
+ oslist=["linux"],
+ archs=[
+ "arm",
+ "aarch64"],
+ bugnumber="llvm.org/pr24739")
+ def test_single_step_only_steps_one_instruction_with_vCont_s_thread_llgs(
+ self):
self.init_llgs_test()
self.build()
self.set_inferior_startup_launch()
- self.single_step_only_steps_one_instruction(use_Hc_packet=False, step_instruction="vCont;s:{thread}")
+ self.single_step_only_steps_one_instruction(
+ use_Hc_packet=False, step_instruction="vCont;s:{thread}")
diff --git a/packages/Python/lldbsuite/test/tools/lldb-server/TestLldbGdbServer.py b/packages/Python/lldbsuite/test/tools/lldb-server/TestLldbGdbServer.py
index c01cc7a17250..1ba49f339402 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-server/TestLldbGdbServer.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-server/TestLldbGdbServer.py
@@ -13,7 +13,6 @@ the initial set of tests implemented.
from __future__ import print_function
-
import unittest2
import gdbremote_testcase
import lldbgdbserverutils
@@ -23,6 +22,7 @@ from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
+
class LldbGdbServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase):
mydir = TestBase.compute_mydir(__file__)
@@ -97,101 +97,6 @@ class LldbGdbServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase):
self.init_llgs_test()
self.list_threads_in_stop_reply_supported()
- def install_and_create_launch_args(self):
- exe_path = os.path.abspath('a.out')
- if not lldb.remote_platform:
- return [exe_path]
- remote_path = lldbutil.append_to_process_working_directory(os.path.basename(exe_path))
- remote_file_spec = lldb.SBFileSpec(remote_path, False)
- err = lldb.remote_platform.Install(lldb.SBFileSpec(exe_path, True), remote_file_spec)
- if err.Fail():
- raise Exception("remote_platform.Install('%s', '%s') failed: %s" % (exe_path, remote_path, err))
- return [remote_path]
-
- def start_inferior(self):
- launch_args = self.install_and_create_launch_args()
-
- server = self.connect_to_debug_monitor()
- self.assertIsNotNone(server)
-
- self.add_no_ack_remote_stream()
- self.test_sequence.add_log_lines(
- ["read packet: %s" % lldbgdbserverutils.build_gdbremote_A_packet(launch_args),
- "send packet: $OK#9a"],
- True)
- self.expect_gdbremote_sequence()
-
- @debugserver_test
- def test_start_inferior_debugserver(self):
- self.init_debugserver_test()
- self.build()
- self.start_inferior()
-
- @llgs_test
- def test_start_inferior_llgs(self):
- self.init_llgs_test()
- self.build()
- self.start_inferior()
-
- def inferior_exit_0(self):
- launch_args = self.install_and_create_launch_args()
-
- server = self.connect_to_debug_monitor()
- self.assertIsNotNone(server)
-
- self.add_no_ack_remote_stream()
- self.add_verified_launch_packets(launch_args)
- self.test_sequence.add_log_lines(
- ["read packet: $vCont;c#a8",
- "send packet: $W00#00"],
- True)
-
- self.expect_gdbremote_sequence()
-
- @debugserver_test
- def test_inferior_exit_0_debugserver(self):
- self.init_debugserver_test()
- self.build()
- self.inferior_exit_0()
-
- @llgs_test
- def test_inferior_exit_0_llgs(self):
- self.init_llgs_test()
- self.build()
- self.inferior_exit_0()
-
- def inferior_exit_42(self):
- launch_args = self.install_and_create_launch_args()
-
- server = self.connect_to_debug_monitor()
- self.assertIsNotNone(server)
-
- RETVAL = 42
-
- # build launch args
- launch_args += ["retval:%d" % RETVAL]
-
- self.add_no_ack_remote_stream()
- self.add_verified_launch_packets(launch_args)
- self.test_sequence.add_log_lines(
- ["read packet: $vCont;c#a8",
- "send packet: $W{0:02x}#00".format(RETVAL)],
- True)
-
- self.expect_gdbremote_sequence()
-
- @debugserver_test
- def test_inferior_exit_42_debugserver(self):
- self.init_debugserver_test()
- self.build()
- self.inferior_exit_42()
-
- @llgs_test
- def test_inferior_exit_42_llgs(self):
- self.init_llgs_test()
- self.build()
- self.inferior_exit_42()
-
def c_packet_works(self):
launch_args = self.install_and_create_launch_args()
@@ -232,7 +137,7 @@ class LldbGdbServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase):
self.add_verified_launch_packets(launch_args)
self.test_sequence.add_log_lines(
["read packet: $vCont;c#a8",
- {"type":"output_match", "regex": self.maybe_strict_output_regex(r"hello, world\r\n")},
+ {"type": "output_match", "regex": self.maybe_strict_output_regex(r"hello, world\r\n")},
"send packet: $W00#00"],
True)
@@ -263,12 +168,15 @@ class LldbGdbServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase):
self.add_no_ack_remote_stream()
self.add_verified_launch_packets(launch_args)
- self.test_sequence.add_log_lines(
- ["read packet: $qC#00",
- { "direction":"send", "regex":r"^\$QC([0-9a-fA-F]+)#", "capture":{1:"thread_id"} },
- "read packet: $?#00",
- { "direction":"send", "regex":r"^\$T[0-9a-fA-F]{2}thread:([0-9a-fA-F]+)", "expect_captures":{1:"thread_id"} }],
- True)
+ self.test_sequence.add_log_lines(["read packet: $qC#00",
+ {"direction": "send",
+ "regex": r"^\$QC([0-9a-fA-F]+)#",
+ "capture": {1: "thread_id"}},
+ "read packet: $?#00",
+ {"direction": "send",
+ "regex": r"^\$T[0-9a-fA-F]{2}thread:([0-9a-fA-F]+)",
+ "expect_captures": {1: "thread_id"}}],
+ True)
self.expect_gdbremote_sequence()
@debugserver_test
@@ -291,7 +199,8 @@ class LldbGdbServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase):
True)
self.expect_gdbremote_sequence()
- # Wait a moment for completed and now-detached inferior process to clear.
+ # Wait a moment for completed and now-detached inferior process to
+ # clear.
time.sleep(1)
if not lldb.remote_platform:
@@ -299,8 +208,11 @@ class LldbGdbServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase):
poll_result = procs["inferior"].poll()
self.assertIsNotNone(poll_result)
- # Where possible, verify at the system level that the process is not running.
- self.assertFalse(lldbgdbserverutils.process_is_running(procs["inferior"].pid, False))
+ # Where possible, verify at the system level that the process is not
+ # running.
+ self.assertFalse(
+ lldbgdbserverutils.process_is_running(
+ procs["inferior"].pid, False))
@debugserver_test
def test_attach_commandline_continue_app_exits_debugserver(self):
@@ -327,7 +239,7 @@ class LldbGdbServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase):
self.add_verified_launch_packets(launch_args)
self.test_sequence.add_log_lines(
["read packet: $qRegisterInfo0#00",
- { "direction":"send", "regex":r"^\$(.+);#[0-9A-Fa-f]{2}", "capture":{1:"reginfo_0"} }],
+ {"direction": "send", "regex": r"^\$(.+);#[0-9A-Fa-f]{2}", "capture": {1: "reginfo_0"}}],
True)
# Run the stream
@@ -336,7 +248,8 @@ class LldbGdbServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase):
reg_info_packet = context.get("reginfo_0")
self.assertIsNotNone(reg_info_packet)
- self.assert_valid_reg_info(lldbgdbserverutils.parse_reg_info_response(reg_info_packet))
+ self.assert_valid_reg_info(
+ lldbgdbserverutils.parse_reg_info_response(reg_info_packet))
@debugserver_test
@expectedFailureDarwin("llvm.org/pr25486")
@@ -402,7 +315,8 @@ class LldbGdbServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase):
reg_infos = self.parse_register_info_packets(context)
# Collect all generic registers found.
- generic_regs = { reg_info['generic']:1 for reg_info in reg_infos if 'generic' in reg_info }
+ generic_regs = {
+ reg_info['generic']: 1 for reg_info in reg_infos if 'generic' in reg_info}
# Ensure we have a program counter register.
self.assertTrue('pc' in generic_regs)
@@ -447,11 +361,13 @@ class LldbGdbServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase):
reg_infos = self.parse_register_info_packets(context)
# Collect all register sets found.
- register_sets = { reg_info['set']:1 for reg_info in reg_infos if 'set' in reg_info }
+ register_sets = {
+ reg_info['set']: 1 for reg_info in reg_infos if 'set' in reg_info}
self.assertTrue(len(register_sets) >= 1)
@debugserver_test
- def test_qRegisterInfo_contains_at_least_one_register_set_debugserver(self):
+ def test_qRegisterInfo_contains_at_least_one_register_set_debugserver(
+ self):
self.init_debugserver_test()
self.build()
self.qRegisterInfo_contains_at_least_one_register_set()
@@ -501,8 +417,11 @@ class LldbGdbServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase):
reg_infos = self.parse_register_info_packets(context)
# Collect all generics found.
- register_sets = { reg_info['set']:1 for reg_info in reg_infos if 'set' in reg_info }
- self.assertEqual(self.targetHasAVX(), "Advanced Vector Extensions" in register_sets)
+ register_sets = {
+ reg_info['set']: 1 for reg_info in reg_infos if 'set' in reg_info}
+ self.assertEqual(
+ self.targetHasAVX(),
+ "Advanced Vector Extensions" in register_sets)
@llgs_test
def test_qRegisterInfo_contains_avx_registers_llgs(self):
@@ -559,7 +478,7 @@ class LldbGdbServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase):
self.add_threadinfo_collection_packets()
self.test_sequence.add_log_lines(
["read packet: $qC#00",
- { "direction":"send", "regex":r"^\$QC([0-9a-fA-F]+)#", "capture":{1:"thread_id"} }
+ {"direction": "send", "regex": r"^\$QC([0-9a-fA-F]+)#", "capture": {1: "thread_id"}}
], True)
# Run the packet stream.
@@ -627,7 +546,8 @@ class LldbGdbServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase):
for reg_info in reg_infos:
# Skip registers that don't have a register set. For x86, these are
# the DRx registers, which have no LLDB-kind register number and thus
- # cannot be read via normal NativeRegisterContext::ReadRegister(reg_info,...) calls.
+ # cannot be read via normal
+ # NativeRegisterContext::ReadRegister(reg_info,...) calls.
if not "set" in reg_info:
continue
@@ -637,7 +557,7 @@ class LldbGdbServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase):
# Run the register query
self.test_sequence.add_log_lines(
["read packet: $p{0:x}#00".format(reg_index),
- { "direction":"send", "regex":r"^\$([0-9a-fA-F]+)#", "capture":{1:"p_response"} }],
+ {"direction": "send", "regex": r"^\$([0-9a-fA-F]+)#", "capture": {1: "p_response"}}],
True)
context = self.expect_gdbremote_sequence()
self.assertIsNotNone(context)
@@ -651,28 +571,32 @@ class LldbGdbServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase):
reg_index += 1
@debugserver_test
- def test_p_returns_correct_data_size_for_each_qRegisterInfo_launch_debugserver(self):
+ def test_p_returns_correct_data_size_for_each_qRegisterInfo_launch_debugserver(
+ self):
self.init_debugserver_test()
self.build()
self.set_inferior_startup_launch()
self.p_returns_correct_data_size_for_each_qRegisterInfo()
@llgs_test
- def test_p_returns_correct_data_size_for_each_qRegisterInfo_launch_llgs(self):
+ def test_p_returns_correct_data_size_for_each_qRegisterInfo_launch_llgs(
+ self):
self.init_llgs_test()
self.build()
self.set_inferior_startup_launch()
self.p_returns_correct_data_size_for_each_qRegisterInfo()
@debugserver_test
- def test_p_returns_correct_data_size_for_each_qRegisterInfo_attach_debugserver(self):
+ def test_p_returns_correct_data_size_for_each_qRegisterInfo_attach_debugserver(
+ self):
self.init_debugserver_test()
self.build()
self.set_inferior_startup_attach()
self.p_returns_correct_data_size_for_each_qRegisterInfo()
@llgs_test
- def test_p_returns_correct_data_size_for_each_qRegisterInfo_attach_llgs(self):
+ def test_p_returns_correct_data_size_for_each_qRegisterInfo_attach_llgs(
+ self):
self.init_llgs_test()
self.build()
self.set_inferior_startup_attach()
@@ -680,9 +604,12 @@ class LldbGdbServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase):
def Hg_switches_to_3_threads(self):
# Startup the inferior with three threads (main + 2 new ones).
- procs = self.prep_debug_monitor_and_inferior(inferior_args=["thread:new", "thread:new"])
+ procs = self.prep_debug_monitor_and_inferior(
+ inferior_args=["thread:new", "thread:new"])
- # Let the inferior process have a few moments to start up the thread when launched. (The launch scenario has no time to run, so threads won't be there yet.)
+ # Let the inferior process have a few moments to start up the thread
+ # when launched. (The launch scenario has no time to run, so threads
+ # won't be there yet.)
self.run_process_then_stop(run_seconds=1)
# Wait at most x seconds for 3 threads to be present.
@@ -697,7 +624,7 @@ class LldbGdbServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase):
["read packet: $Hg{0:x}#00".format(thread), # Set current thread.
"send packet: $OK#00",
"read packet: $qC#00",
- { "direction":"send", "regex":r"^\$QC([0-9a-fA-F]+)#", "capture":{1:"thread_id"} }],
+ {"direction": "send", "regex": r"^\$QC([0-9a-fA-F]+)#", "capture": {1: "thread_id"}}],
True)
context = self.expect_gdbremote_sequence()
@@ -743,7 +670,7 @@ class LldbGdbServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase):
# Startup the inferior with three threads (main + NUM_THREADS-1 worker threads).
# inferior_args=["thread:print-ids"]
- inferior_args=["thread:segfault"]
+ inferior_args = ["thread:segfault"]
for i in range(NUM_THREADS - 1):
# if i > 0:
# Give time between thread creation/segfaulting for the handler to work.
@@ -751,8 +678,10 @@ class LldbGdbServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase):
inferior_args.append("thread:new")
inferior_args.append("sleep:10")
- # Launch/attach. (In our case, this should only ever be launched since we need inferior stdout/stderr).
- procs = self.prep_debug_monitor_and_inferior(inferior_args=inferior_args)
+ # Launch/attach. (In our case, this should only ever be launched since
+ # we need inferior stdout/stderr).
+ procs = self.prep_debug_monitor_and_inferior(
+ inferior_args=inferior_args)
self.test_sequence.add_log_lines(["read packet: $c#63"], True)
context = self.expect_gdbremote_sequence()
@@ -770,9 +699,11 @@ class LldbGdbServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase):
for i in range(NUM_THREADS - 1):
# Run until SIGSEGV comes in.
self.reset_test_sequence()
- self.test_sequence.add_log_lines(
- [{"direction":"send", "regex":r"^\$T([0-9a-fA-F]{2})thread:([0-9a-fA-F]+);", "capture":{1:"signo", 2:"thread_id"} }
- ], True)
+ self.test_sequence.add_log_lines([{"direction": "send",
+ "regex": r"^\$T([0-9a-fA-F]{2})thread:([0-9a-fA-F]+);",
+ "capture": {1: "signo",
+ 2: "thread_id"}}],
+ True)
context = self.expect_gdbremote_sequence(timeout_seconds=10)
self.assertIsNotNone(context)
@@ -788,23 +719,24 @@ class LldbGdbServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase):
self.reset_test_sequence()
self.test_sequence.add_log_lines(
[
- # Set the continue thread.
- "read packet: $Hc{0:x}#00".format(thread_id), # Set current thread.
- "send packet: $OK#00",
-
- # Continue sending the signal number to the continue thread.
- # The commented out packet is a way to do this same operation without using
- # a $Hc (but this test is testing $Hc, so we'll stick with the former).
- "read packet: $C{0:x}#00".format(lldbutil.get_signal_number('SIGUSR1')),
- # "read packet: $vCont;C{0:x}:{1:x};c#00".format(lldbutil.get_signal_number('SIGUSR1'), thread_id),
-
- # FIXME: Linux does not report the thread stop on the delivered signal (SIGUSR1 here). MacOSX debugserver does.
- # But MacOSX debugserver isn't guaranteeing the thread the signal handler runs on, so currently its an XFAIL.
- # Need to rectify behavior here. The linux behavior is more intuitive to me since we're essentially swapping out
- # an about-to-be-delivered signal (for which we already sent a stop packet) to a different signal.
- # {"direction":"send", "regex":r"^\$T([0-9a-fA-F]{2})thread:([0-9a-fA-F]+);", "capture":{1:"stop_signo", 2:"stop_thread_id"} },
- # "read packet: $c#63",
- { "type":"output_match", "regex":r"^received SIGUSR1 on thread id: ([0-9a-fA-F]+)\r\nthread ([0-9a-fA-F]+): past SIGSEGV\r\n", "capture":{ 1:"print_thread_id", 2:"post_handle_thread_id" } },
+ # Set the continue thread.
+ # Set current thread.
+ "read packet: $Hc{0:x}#00".format(thread_id),
+ "send packet: $OK#00",
+
+ # Continue sending the signal number to the continue thread.
+ # The commented out packet is a way to do this same operation without using
+ # a $Hc (but this test is testing $Hc, so we'll stick with the former).
+ "read packet: $C{0:x}#00".format(lldbutil.get_signal_number('SIGUSR1')),
+ # "read packet: $vCont;C{0:x}:{1:x};c#00".format(lldbutil.get_signal_number('SIGUSR1'), thread_id),
+
+ # FIXME: Linux does not report the thread stop on the delivered signal (SIGUSR1 here). MacOSX debugserver does.
+ # But MacOSX debugserver isn't guaranteeing the thread the signal handler runs on, so currently its an XFAIL.
+ # Need to rectify behavior here. The linux behavior is more intuitive to me since we're essentially swapping out
+ # an about-to-be-delivered signal (for which we already sent a stop packet) to a different signal.
+ # {"direction":"send", "regex":r"^\$T([0-9a-fA-F]{2})thread:([0-9a-fA-F]+);", "capture":{1:"stop_signo", 2:"stop_thread_id"} },
+ # "read packet: $c#63",
+ {"type": "output_match", "regex": r"^received SIGUSR1 on thread id: ([0-9a-fA-F]+)\r\nthread ([0-9a-fA-F]+): past SIGSEGV\r\n", "capture": {1: "print_thread_id", 2: "post_handle_thread_id"}},
],
True)
@@ -822,16 +754,20 @@ class LldbGdbServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase):
# self.assertIsNotNone(stop_thread_id)
# self.assertEquals(int(stop_thread_id,16), thread_id)
- # Ensure we haven't seen this thread id yet. The inferior's self-obtained thread ids are not guaranteed to match the stub tids (at least on MacOSX).
+ # Ensure we haven't seen this thread id yet. The inferior's
+ # self-obtained thread ids are not guaranteed to match the stub
+ # tids (at least on MacOSX).
print_thread_id = context.get("print_thread_id")
self.assertIsNotNone(print_thread_id)
print_thread_id = int(print_thread_id, 16)
self.assertFalse(print_thread_id in print_thread_ids)
-
- # Now remember this print (i.e. inferior-reflected) thread id and ensure we don't hit it again.
+
+ # Now remember this print (i.e. inferior-reflected) thread id and
+ # ensure we don't hit it again.
print_thread_ids[print_thread_id] = 1
- # Ensure post signal-handle thread id matches the thread that initially raised the SIGSEGV.
+ # Ensure post signal-handle thread id matches the thread that
+ # initially raised the SIGSEGV.
post_handle_thread_id = context.get("post_handle_thread_id")
self.assertIsNotNone(post_handle_thread_id)
post_handle_thread_id = int(post_handle_thread_id, 16)
@@ -843,7 +779,8 @@ class LldbGdbServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase):
self.init_debugserver_test()
self.build()
self.set_inferior_startup_launch()
- # Darwin debugserver translates some signals like SIGSEGV into some gdb expectations about fixed signal numbers.
+ # Darwin debugserver translates some signals like SIGSEGV into some gdb
+ # expectations about fixed signal numbers.
self.Hc_then_Csignal_signals_correct_thread(self.TARGET_EXC_BAD_ACCESS)
@llgs_test
@@ -851,29 +788,35 @@ class LldbGdbServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase):
self.init_llgs_test()
self.build()
self.set_inferior_startup_launch()
- self.Hc_then_Csignal_signals_correct_thread(lldbutil.get_signal_number('SIGSEGV'))
+ self.Hc_then_Csignal_signals_correct_thread(
+ lldbutil.get_signal_number('SIGSEGV'))
def m_packet_reads_memory(self):
- # This is the memory we will write into the inferior and then ensure we can read back with $m.
+ # This is the memory we will write into the inferior and then ensure we
+ # can read back with $m.
MEMORY_CONTENTS = "Test contents 0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz"
# Start up the inferior.
procs = self.prep_debug_monitor_and_inferior(
- inferior_args=["set-message:%s" % MEMORY_CONTENTS, "get-data-address-hex:g_message", "sleep:5"])
+ inferior_args=[
+ "set-message:%s" %
+ MEMORY_CONTENTS,
+ "get-data-address-hex:g_message",
+ "sleep:5"])
# Run the process
self.test_sequence.add_log_lines(
[
- # Start running after initial stop.
- "read packet: $c#63",
- # Match output line that prints the memory address of the message buffer within the inferior.
- # Note we require launch-only testing so we can get inferior otuput.
- { "type":"output_match", "regex":self.maybe_strict_output_regex(r"data address: 0x([0-9a-fA-F]+)\r\n"),
- "capture":{ 1:"message_address"} },
- # Now stop the inferior.
- "read packet: {}".format(chr(3)),
- # And wait for the stop notification.
- {"direction":"send", "regex":r"^\$T([0-9a-fA-F]{2})thread:([0-9a-fA-F]+);", "capture":{1:"stop_signo", 2:"stop_thread_id"} }],
+ # Start running after initial stop.
+ "read packet: $c#63",
+ # Match output line that prints the memory address of the message buffer within the inferior.
+ # Note we require launch-only testing so we can get inferior otuput.
+ {"type": "output_match", "regex": self.maybe_strict_output_regex(r"data address: 0x([0-9a-fA-F]+)\r\n"),
+ "capture": {1: "message_address"}},
+ # Now stop the inferior.
+ "read packet: {}".format(chr(3)),
+ # And wait for the stop notification.
+ {"direction": "send", "regex": r"^\$T([0-9a-fA-F]{2})thread:([0-9a-fA-F]+);", "capture": {1: "stop_signo", 2: "stop_thread_id"}}],
True)
# Run the packet stream.
@@ -888,7 +831,7 @@ class LldbGdbServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase):
self.reset_test_sequence()
self.test_sequence.add_log_lines(
["read packet: $m{0:x},{1:x}#00".format(message_address, len(MEMORY_CONTENTS)),
- {"direction":"send", "regex":r"^\$(.+)#[0-9a-fA-F]{2}$", "capture":{1:"read_contents"} }],
+ {"direction": "send", "regex": r"^\$(.+)#[0-9a-fA-F]{2}$", "capture": {1: "read_contents"}}],
True)
# Run the packet stream.
@@ -947,16 +890,16 @@ class LldbGdbServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase):
# Run the process
self.test_sequence.add_log_lines(
[
- # Start running after initial stop.
- "read packet: $c#63",
- # Match output line that prints the memory address of the message buffer within the inferior.
- # Note we require launch-only testing so we can get inferior otuput.
- { "type":"output_match", "regex":self.maybe_strict_output_regex(r"code address: 0x([0-9a-fA-F]+)\r\n"),
- "capture":{ 1:"code_address"} },
- # Now stop the inferior.
- "read packet: {}".format(chr(3)),
- # And wait for the stop notification.
- {"direction":"send", "regex":r"^\$T([0-9a-fA-F]{2})thread:([0-9a-fA-F]+);", "capture":{1:"stop_signo", 2:"stop_thread_id"} }],
+ # Start running after initial stop.
+ "read packet: $c#63",
+ # Match output line that prints the memory address of the message buffer within the inferior.
+ # Note we require launch-only testing so we can get inferior otuput.
+ {"type": "output_match", "regex": self.maybe_strict_output_regex(r"code address: 0x([0-9a-fA-F]+)\r\n"),
+ "capture": {1: "code_address"}},
+ # Now stop the inferior.
+ "read packet: {}".format(chr(3)),
+ # And wait for the stop notification.
+ {"direction": "send", "regex": r"^\$T([0-9a-fA-F]{2})thread:([0-9a-fA-F]+);", "capture": {1: "stop_signo", 2: "stop_thread_id"}}],
True)
# Run the packet stream.
@@ -988,7 +931,8 @@ class LldbGdbServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase):
self.assert_address_within_memory_region(code_address, mem_region_dict)
@debugserver_test
- def test_qMemoryRegionInfo_reports_code_address_as_executable_debugserver(self):
+ def test_qMemoryRegionInfo_reports_code_address_as_executable_debugserver(
+ self):
self.init_debugserver_test()
self.build()
self.set_inferior_startup_launch()
@@ -1009,16 +953,16 @@ class LldbGdbServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase):
# Run the process
self.test_sequence.add_log_lines(
[
- # Start running after initial stop.
- "read packet: $c#63",
- # Match output line that prints the memory address of the message buffer within the inferior.
- # Note we require launch-only testing so we can get inferior otuput.
- { "type":"output_match", "regex":self.maybe_strict_output_regex(r"stack address: 0x([0-9a-fA-F]+)\r\n"),
- "capture":{ 1:"stack_address"} },
- # Now stop the inferior.
- "read packet: {}".format(chr(3)),
- # And wait for the stop notification.
- {"direction":"send", "regex":r"^\$T([0-9a-fA-F]{2})thread:([0-9a-fA-F]+);", "capture":{1:"stop_signo", 2:"stop_thread_id"} }],
+ # Start running after initial stop.
+ "read packet: $c#63",
+ # Match output line that prints the memory address of the message buffer within the inferior.
+ # Note we require launch-only testing so we can get inferior otuput.
+ {"type": "output_match", "regex": self.maybe_strict_output_regex(r"stack address: 0x([0-9a-fA-F]+)\r\n"),
+ "capture": {1: "stack_address"}},
+ # Now stop the inferior.
+ "read packet: {}".format(chr(3)),
+ # And wait for the stop notification.
+ {"direction": "send", "regex": r"^\$T([0-9a-fA-F]{2})thread:([0-9a-fA-F]+);", "capture": {1: "stop_signo", 2: "stop_thread_id"}}],
True)
# Run the packet stream.
@@ -1047,17 +991,20 @@ class LldbGdbServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase):
self.assertTrue("w" in mem_region_dict["permissions"])
# Ensure the start address and size encompass the address we queried.
- self.assert_address_within_memory_region(stack_address, mem_region_dict)
+ self.assert_address_within_memory_region(
+ stack_address, mem_region_dict)
@debugserver_test
- def test_qMemoryRegionInfo_reports_stack_address_as_readable_writeable_debugserver(self):
+ def test_qMemoryRegionInfo_reports_stack_address_as_readable_writeable_debugserver(
+ self):
self.init_debugserver_test()
self.build()
self.set_inferior_startup_launch()
self.qMemoryRegionInfo_reports_stack_address_as_readable_writeable()
@llgs_test
- def test_qMemoryRegionInfo_reports_stack_address_as_readable_writeable_llgs(self):
+ def test_qMemoryRegionInfo_reports_stack_address_as_readable_writeable_llgs(
+ self):
self.init_llgs_test()
self.build()
self.set_inferior_startup_launch()
@@ -1071,16 +1018,16 @@ class LldbGdbServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase):
# Run the process
self.test_sequence.add_log_lines(
[
- # Start running after initial stop.
- "read packet: $c#63",
- # Match output line that prints the memory address of the message buffer within the inferior.
- # Note we require launch-only testing so we can get inferior otuput.
- { "type":"output_match", "regex":self.maybe_strict_output_regex(r"heap address: 0x([0-9a-fA-F]+)\r\n"),
- "capture":{ 1:"heap_address"} },
- # Now stop the inferior.
- "read packet: {}".format(chr(3)),
- # And wait for the stop notification.
- {"direction":"send", "regex":r"^\$T([0-9a-fA-F]{2})thread:([0-9a-fA-F]+);", "capture":{1:"stop_signo", 2:"stop_thread_id"} }],
+ # Start running after initial stop.
+ "read packet: $c#63",
+ # Match output line that prints the memory address of the message buffer within the inferior.
+ # Note we require launch-only testing so we can get inferior otuput.
+ {"type": "output_match", "regex": self.maybe_strict_output_regex(r"heap address: 0x([0-9a-fA-F]+)\r\n"),
+ "capture": {1: "heap_address"}},
+ # Now stop the inferior.
+ "read packet: {}".format(chr(3)),
+ # And wait for the stop notification.
+ {"direction": "send", "regex": r"^\$T([0-9a-fA-F]{2})thread:([0-9a-fA-F]+);", "capture": {1: "stop_signo", 2: "stop_thread_id"}}],
True)
# Run the packet stream.
@@ -1111,16 +1058,17 @@ class LldbGdbServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase):
# Ensure the start address and size encompass the address we queried.
self.assert_address_within_memory_region(heap_address, mem_region_dict)
-
@debugserver_test
- def test_qMemoryRegionInfo_reports_heap_address_as_readable_writeable_debugserver(self):
+ def test_qMemoryRegionInfo_reports_heap_address_as_readable_writeable_debugserver(
+ self):
self.init_debugserver_test()
self.build()
self.set_inferior_startup_launch()
self.qMemoryRegionInfo_reports_heap_address_as_readable_writeable()
@llgs_test
- def test_qMemoryRegionInfo_reports_heap_address_as_readable_writeable_llgs(self):
+ def test_qMemoryRegionInfo_reports_heap_address_as_readable_writeable_llgs(
+ self):
self.init_llgs_test()
self.build()
self.set_inferior_startup_launch()
@@ -1129,29 +1077,33 @@ class LldbGdbServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase):
def software_breakpoint_set_and_remove_work(self):
# Start up the inferior.
procs = self.prep_debug_monitor_and_inferior(
- inferior_args=["get-code-address-hex:hello", "sleep:1", "call-function:hello"])
+ inferior_args=[
+ "get-code-address-hex:hello",
+ "sleep:1",
+ "call-function:hello"])
# Run the process
self.add_register_info_collection_packets()
self.add_process_info_collection_packets()
self.test_sequence.add_log_lines(
- [# Start running after initial stop.
- "read packet: $c#63",
- # Match output line that prints the memory address of the function call entry point.
- # Note we require launch-only testing so we can get inferior otuput.
- { "type":"output_match", "regex":self.maybe_strict_output_regex(r"code address: 0x([0-9a-fA-F]+)\r\n"),
- "capture":{ 1:"function_address"} },
- # Now stop the inferior.
- "read packet: {}".format(chr(3)),
- # And wait for the stop notification.
- {"direction":"send", "regex":r"^\$T([0-9a-fA-F]{2})thread:([0-9a-fA-F]+);", "capture":{1:"stop_signo", 2:"stop_thread_id"} }],
+ [ # Start running after initial stop.
+ "read packet: $c#63",
+ # Match output line that prints the memory address of the function call entry point.
+ # Note we require launch-only testing so we can get inferior otuput.
+ {"type": "output_match", "regex": self.maybe_strict_output_regex(r"code address: 0x([0-9a-fA-F]+)\r\n"),
+ "capture": {1: "function_address"}},
+ # Now stop the inferior.
+ "read packet: {}".format(chr(3)),
+ # And wait for the stop notification.
+ {"direction": "send", "regex": r"^\$T([0-9a-fA-F]{2})thread:([0-9a-fA-F]+);", "capture": {1: "stop_signo", 2: "stop_thread_id"}}],
True)
# Run the packet stream.
context = self.expect_gdbremote_sequence()
self.assertIsNotNone(context)
- # Gather process info - we need endian of target to handle register value conversions.
+ # Gather process info - we need endian of target to handle register
+ # value conversions.
process_info = self.parse_process_info_response(context)
endian = process_info.get("endian")
self.assertIsNotNone(endian)
@@ -1173,7 +1125,10 @@ class LldbGdbServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase):
else:
BREAKPOINT_KIND = 1
self.reset_test_sequence()
- self.add_set_breakpoint_packets(function_address, do_continue=True, breakpoint_kind=BREAKPOINT_KIND)
+ self.add_set_breakpoint_packets(
+ function_address,
+ do_continue=True,
+ breakpoint_kind=BREAKPOINT_KIND)
# Run the packet stream.
context = self.expect_gdbremote_sequence()
@@ -1182,7 +1137,8 @@ class LldbGdbServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase):
# Verify the stop signal reported was the breakpoint signal number.
stop_signo = context.get("stop_signo")
self.assertIsNotNone(stop_signo)
- self.assertEqual(int(stop_signo,16), lldbutil.get_signal_number('SIGTRAP'))
+ self.assertEqual(int(stop_signo, 16),
+ lldbutil.get_signal_number('SIGTRAP'))
# Ensure we did not receive any output. If the breakpoint was not set, we would
# see output (from a launched process with captured stdio) printing a hello, world message.
@@ -1194,37 +1150,43 @@ class LldbGdbServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase):
self.reset_test_sequence()
self.test_sequence.add_log_lines(
[
- # Print the PC. This should match the breakpoint address.
- "read packet: $p{0:x}#00".format(pc_lldb_reg_index),
- # Capture $p results.
- { "direction":"send", "regex":r"^\$([0-9a-fA-F]+)#", "capture":{1:"p_response"} },
- ], True)
-
+ # Print the PC. This should match the breakpoint address.
+ "read packet: $p{0:x}#00".format(pc_lldb_reg_index),
+ # Capture $p results.
+ {"direction": "send",
+ "regex": r"^\$([0-9a-fA-F]+)#",
+ "capture": {1: "p_response"}},
+ ], True)
+
context = self.expect_gdbremote_sequence()
self.assertIsNotNone(context)
-
- # Verify the PC is where we expect. Note response is in endianness of the inferior.
+
+ # Verify the PC is where we expect. Note response is in endianness of
+ # the inferior.
p_response = context.get("p_response")
self.assertIsNotNone(p_response)
# Convert from target endian to int.
- returned_pc = lldbgdbserverutils.unpack_register_hex_unsigned(endian, p_response)
+ returned_pc = lldbgdbserverutils.unpack_register_hex_unsigned(
+ endian, p_response)
self.assertEqual(returned_pc, function_address)
- # Verify that a breakpoint remove and continue gets us the expected output.
+ # Verify that a breakpoint remove and continue gets us the expected
+ # output.
self.reset_test_sequence()
self.test_sequence.add_log_lines(
[
- # Remove the breakpoint.
- "read packet: $z0,{0:x},{1}#00".format(function_address, BREAKPOINT_KIND),
- # Verify the stub could unset it.
- "send packet: $OK#00",
- # Continue running.
- "read packet: $c#63",
- # We should now receive the output from the call.
- { "type":"output_match", "regex":r"^hello, world\r\n$" },
- # And wait for program completion.
- {"direction":"send", "regex":r"^\$W00(.*)#[0-9a-fA-F]{2}$" },
+ # Remove the breakpoint.
+ "read packet: $z0,{0:x},{1}#00".format(
+ function_address, BREAKPOINT_KIND),
+ # Verify the stub could unset it.
+ "send packet: $OK#00",
+ # Continue running.
+ "read packet: $c#63",
+ # We should now receive the output from the call.
+ {"type": "output_match", "regex": r"^hello, world\r\n$"},
+ # And wait for program completion.
+ {"direction": "send", "regex": r"^\$W00(.*)#[0-9a-fA-F]{2}$"},
], True)
context = self.expect_gdbremote_sequence()
@@ -1233,7 +1195,11 @@ class LldbGdbServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase):
@debugserver_test
def test_software_breakpoint_set_and_remove_work_debugserver(self):
self.init_debugserver_test()
- self.build()
+ if self.getArchitecture() == "arm":
+ # TODO: Handle case when setting breakpoint in thumb code
+ self.build(dictionary={'CFLAGS_EXTRAS': '-marm'})
+ else:
+ self.build()
self.set_inferior_startup_launch()
self.software_breakpoint_set_and_remove_work()
@@ -1241,7 +1207,11 @@ class LldbGdbServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase):
@expectedFlakeyLinux("llvm.org/pr25652")
def test_software_breakpoint_set_and_remove_work_llgs(self):
self.init_llgs_test()
- self.build()
+ if self.getArchitecture() == "arm":
+ # TODO: Handle case when setting breakpoint in thumb code
+ self.build(dictionary={'CFLAGS_EXTRAS': '-marm'})
+ else:
+ self.build()
self.set_inferior_startup_launch()
self.software_breakpoint_set_and_remove_work()
@@ -1277,19 +1247,24 @@ class LldbGdbServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase):
TEST_MESSAGE = "Hello, memory"
# Start up the stub and start/prep the inferior.
- procs = self.prep_debug_monitor_and_inferior(inferior_args=["set-message:xxxxxxxxxxxxxX", "get-data-address-hex:g_message", "sleep:1", "print-message:"])
+ procs = self.prep_debug_monitor_and_inferior(
+ inferior_args=[
+ "set-message:xxxxxxxxxxxxxX",
+ "get-data-address-hex:g_message",
+ "sleep:1",
+ "print-message:"])
self.test_sequence.add_log_lines(
[
- # Start running after initial stop.
- "read packet: $c#63",
- # Match output line that prints the memory address of the message buffer within the inferior.
- # Note we require launch-only testing so we can get inferior otuput.
- { "type":"output_match", "regex":self.maybe_strict_output_regex(r"data address: 0x([0-9a-fA-F]+)\r\n"),
- "capture":{ 1:"message_address"} },
- # Now stop the inferior.
- "read packet: {}".format(chr(3)),
- # And wait for the stop notification.
- {"direction":"send", "regex":r"^\$T([0-9a-fA-F]{2})thread:([0-9a-fA-F]+);", "capture":{1:"stop_signo", 2:"stop_thread_id"} }],
+ # Start running after initial stop.
+ "read packet: $c#63",
+ # Match output line that prints the memory address of the message buffer within the inferior.
+ # Note we require launch-only testing so we can get inferior otuput.
+ {"type": "output_match", "regex": self.maybe_strict_output_regex(r"data address: 0x([0-9a-fA-F]+)\r\n"),
+ "capture": {1: "message_address"}},
+ # Now stop the inferior.
+ "read packet: {}".format(chr(3)),
+ # And wait for the stop notification.
+ {"direction": "send", "regex": r"^\$T([0-9a-fA-F]{2})thread:([0-9a-fA-F]+);", "capture": {1: "stop_signo", 2: "stop_thread_id"}}],
True)
context = self.expect_gdbremote_sequence()
self.assertIsNotNone(context)
@@ -1301,15 +1276,24 @@ class LldbGdbServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase):
# Hex-encode the test message, adding null termination.
hex_encoded_message = TEST_MESSAGE.encode("hex")
- # Write the message to the inferior.
+ # Write the message to the inferior. Verify that we can read it with the hex-encoded (m)
+ # and binary (x) memory read packets.
self.reset_test_sequence()
self.test_sequence.add_log_lines(
- ["read packet: $M{0:x},{1:x}:{2}#00".format(message_address, len(hex_encoded_message)/2, hex_encoded_message),
+ ["read packet: $M{0:x},{1:x}:{2}#00".format(message_address, len(TEST_MESSAGE), hex_encoded_message),
"send packet: $OK#00",
+ "read packet: $m{0:x},{1:x}#00".format(message_address, len(TEST_MESSAGE)),
+ "send packet: ${0}#00".format(hex_encoded_message),
+ "read packet: $x{0:x},{1:x}#00".format(message_address, len(TEST_MESSAGE)),
+ "send packet: ${0}#00".format(TEST_MESSAGE),
+ "read packet: $m{0:x},4#00".format(message_address),
+ "send packet: ${0}#00".format(hex_encoded_message[0:8]),
+ "read packet: $x{0:x},4#00".format(message_address),
+ "send packet: ${0}#00".format(TEST_MESSAGE[0:4]),
"read packet: $c#63",
- { "type":"output_match", "regex":r"^message: (.+)\r\n$", "capture":{ 1:"printed_message"} },
+ {"type": "output_match", "regex": r"^message: (.+)\r\n$", "capture": {1: "printed_message"}},
"send packet: $W00#00",
- ], True)
+ ], True)
context = self.expect_gdbremote_sequence()
self.assertIsNotNone(context)
@@ -1352,17 +1336,21 @@ class LldbGdbServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase):
endian = process_info.get("endian")
self.assertIsNotNone(endian)
- # Pull out the register infos that we think we can bit flip successfully,.
- gpr_reg_infos = [reg_info for reg_info in reg_infos if self.is_bit_flippable_register(reg_info)]
+ # Pull out the register infos that we think we can bit flip
+ # successfully,.
+ gpr_reg_infos = [
+ reg_info for reg_info in reg_infos if self.is_bit_flippable_register(reg_info)]
self.assertTrue(len(gpr_reg_infos) > 0)
# Write flipped bit pattern of existing value to each register.
- (successful_writes, failed_writes) = self.flip_all_bits_in_each_register_value(gpr_reg_infos, endian)
+ (successful_writes, failed_writes) = self.flip_all_bits_in_each_register_value(
+ gpr_reg_infos, endian)
# print("successful writes: {}, failed writes: {}".format(successful_writes, failed_writes))
self.assertTrue(successful_writes > 0)
# Note: as of this moment, a hefty number of the GPR writes are failing with E32 (everything except rax-rdx, rdi, rsi, rbp).
- # Come back to this. I have the test rigged to verify that at least some of the bit-flip writes work.
+ # Come back to this. I have the test rigged to verify that at least some
+ # of the bit-flip writes work.
@debugserver_test
def test_P_writes_all_gpr_registers_debugserver(self):
self.init_debugserver_test()
@@ -1379,7 +1367,8 @@ class LldbGdbServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase):
def P_and_p_thread_suffix_work(self):
# Startup the inferior with three threads.
- procs = self.prep_debug_monitor_and_inferior(inferior_args=["thread:new", "thread:new"])
+ procs = self.prep_debug_monitor_and_inferior(
+ inferior_args=["thread:new", "thread:new"])
self.add_thread_suffix_request_packets()
self.add_register_info_collection_packets()
self.add_process_info_collection_packets()
@@ -1401,7 +1390,8 @@ class LldbGdbServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase):
reg_byte_size = int(reg_infos[reg_index]["bitsize"]) / 8
self.assertTrue(reg_byte_size > 0)
- # Run the process a bit so threads can start up, and collect register info.
+ # Run the process a bit so threads can start up, and collect register
+ # info.
context = self.run_process_then_stop(run_seconds=1)
self.assertIsNotNone(context)
@@ -1416,59 +1406,75 @@ class LldbGdbServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase):
# Set the same register in each of 3 threads to a different value.
# Verify each one has the unique value.
for thread in threads:
- # If we don't have a next value yet, start it with the initial read value + 1
+ # If we don't have a next value yet, start it with the initial read
+ # value + 1
if not next_value:
# Read pre-existing register value.
self.reset_test_sequence()
self.test_sequence.add_log_lines(
["read packet: $p{0:x};thread:{1:x}#00".format(reg_index, thread),
- { "direction":"send", "regex":r"^\$([0-9a-fA-F]+)#", "capture":{1:"p_response"} },
- ], True)
+ {"direction": "send", "regex": r"^\$([0-9a-fA-F]+)#", "capture": {1: "p_response"}},
+ ], True)
context = self.expect_gdbremote_sequence()
self.assertIsNotNone(context)
- # Set the next value to use for writing as the increment plus current value.
+ # Set the next value to use for writing as the increment plus
+ # current value.
p_response = context.get("p_response")
self.assertIsNotNone(p_response)
- next_value = lldbgdbserverutils.unpack_register_hex_unsigned(endian, p_response)
+ next_value = lldbgdbserverutils.unpack_register_hex_unsigned(
+ endian, p_response)
# Set new value using P and thread suffix.
self.reset_test_sequence()
self.test_sequence.add_log_lines(
- ["read packet: $P{0:x}={1};thread:{2:x}#00".format(reg_index, lldbgdbserverutils.pack_register_hex(endian, next_value, byte_size=reg_byte_size), thread),
- "send packet: $OK#00",
- ], True)
+ [
+ "read packet: $P{0:x}={1};thread:{2:x}#00".format(
+ reg_index,
+ lldbgdbserverutils.pack_register_hex(
+ endian,
+ next_value,
+ byte_size=reg_byte_size),
+ thread),
+ "send packet: $OK#00",
+ ],
+ True)
context = self.expect_gdbremote_sequence()
self.assertIsNotNone(context)
# Save the value we set.
expected_reg_values.append(next_value)
- # Increment value for next thread to use (we want them all different so we can verify they wrote to each thread correctly next.)
+ # Increment value for next thread to use (we want them all
+ # different so we can verify they wrote to each thread correctly
+ # next.)
next_value += register_increment
- # Revisit each thread and verify they have the expected value set for the register we wrote.
+ # Revisit each thread and verify they have the expected value set for
+ # the register we wrote.
thread_index = 0
for thread in threads:
# Read pre-existing register value.
self.reset_test_sequence()
self.test_sequence.add_log_lines(
["read packet: $p{0:x};thread:{1:x}#00".format(reg_index, thread),
- { "direction":"send", "regex":r"^\$([0-9a-fA-F]+)#", "capture":{1:"p_response"} },
- ], True)
+ {"direction": "send", "regex": r"^\$([0-9a-fA-F]+)#", "capture": {1: "p_response"}},
+ ], True)
context = self.expect_gdbremote_sequence()
self.assertIsNotNone(context)
# Get the register value.
p_response = context.get("p_response")
self.assertIsNotNone(p_response)
- read_value = lldbgdbserverutils.unpack_register_hex_unsigned(endian, p_response)
+ read_value = lldbgdbserverutils.unpack_register_hex_unsigned(
+ endian, p_response)
# Make sure we read back what we wrote.
self.assertEqual(read_value, expected_reg_values[thread_index])
thread_index += 1
- # Note: as of this moment, a hefty number of the GPR writes are failing with E32 (everything except rax-rdx, rdi, rsi, rbp).
+ # Note: as of this moment, a hefty number of the GPR writes are failing
+ # with E32 (everything except rax-rdx, rdi, rsi, rbp).
@debugserver_test
def test_P_and_p_thread_suffix_work_debugserver(self):
self.init_debugserver_test()
diff --git a/packages/Python/lldbsuite/test/tools/lldb-server/commandline/TestStubReverseConnect.py b/packages/Python/lldbsuite/test/tools/lldb-server/commandline/TestStubReverseConnect.py
index 6894d1ceacc6..c1a63af5424f 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-server/commandline/TestStubReverseConnect.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-server/commandline/TestStubReverseConnect.py
@@ -10,6 +10,7 @@ from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
+
class TestStubReverseConnect(gdbremote_testcase.GdbRemoteTestCaseBase):
mydir = TestBase.compute_mydir(__file__)
@@ -30,7 +31,7 @@ class TestStubReverseConnect(gdbremote_testcase.GdbRemoteTestCaseBase):
self.assertIsNotNone(sock)
sock.settimeout(timeout_seconds)
- sock.bind(("127.0.0.1",0))
+ sock.bind(("127.0.0.1", 0))
sock.listen(1)
def tear_down_listener():
@@ -56,18 +57,25 @@ class TestStubReverseConnect(gdbremote_testcase.GdbRemoteTestCaseBase):
triple = self.dbg.GetSelectedPlatform().GetTriple()
if re.match(".*-.*-.*-android", triple):
- self.forward_adb_port(self.port, self.port, "reverse", self.stub_device)
+ self.forward_adb_port(
+ self.port,
+ self.port,
+ "reverse",
+ self.stub_device)
# Start the stub.
server = self.launch_debug_monitor(logfile=sys.stdout)
self.assertIsNotNone(server)
- self.assertTrue(lldbgdbserverutils.process_is_running(server.pid, True))
+ self.assertTrue(
+ lldbgdbserverutils.process_is_running(
+ server.pid, True))
# Listen for the stub's connection to us.
(stub_socket, address) = self.listener_socket.accept()
self.assertIsNotNone(stub_socket)
self.assertIsNotNone(address)
- print("connected to stub {} on {}".format(address, stub_socket.getsockname()))
+ print("connected to stub {} on {}".format(
+ address, stub_socket.getsockname()))
# Verify we can do the handshake. If that works, we'll call it good.
self.do_handshake(stub_socket, timeout_seconds=self._DEFAULT_TIMEOUT)
@@ -82,7 +90,7 @@ class TestStubReverseConnect(gdbremote_testcase.GdbRemoteTestCaseBase):
self.reverse_connect_works()
@llgs_test
- @skipIfRemote # reverse connect is not a supported use case for now
+ @skipIfRemote # reverse connect is not a supported use case for now
def test_reverse_connect_works_llgs(self):
self.init_llgs_test(use_named_pipe=False)
self.set_inferior_startup_launch()
diff --git a/packages/Python/lldbsuite/test/tools/lldb-server/commandline/TestStubSetSID.py b/packages/Python/lldbsuite/test/tools/lldb-server/commandline/TestStubSetSID.py
index bda93155d27e..27daf30f189d 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-server/commandline/TestStubSetSID.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-server/commandline/TestStubSetSID.py
@@ -1,7 +1,6 @@
from __future__ import print_function
-
import gdbremote_testcase
import lldbgdbserverutils
import os
@@ -12,6 +11,7 @@ from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
+
class TestStubSetSIDTestCase(gdbremote_testcase.GdbRemoteTestCaseBase):
mydir = TestBase.compute_mydir(__file__)
@@ -23,7 +23,9 @@ class TestStubSetSIDTestCase(gdbremote_testcase.GdbRemoteTestCaseBase):
server = self.launch_debug_monitor()
self.assertIsNotNone(server)
- self.assertTrue(lldbgdbserverutils.process_is_running(server.pid, True))
+ self.assertTrue(
+ lldbgdbserverutils.process_is_running(
+ server.pid, True))
# Get the process id for the stub.
return os.getsid(server.pid)
@@ -41,14 +43,14 @@ class TestStubSetSIDTestCase(gdbremote_testcase.GdbRemoteTestCaseBase):
self.assertNotEqual(stub_sid, os.getsid(0))
@debugserver_test
- @skipIfRemote # --setsid not used on remote platform and currently it is also impossible to get the sid of lldb-platform running on a remote target
+ @skipIfRemote # --setsid not used on remote platform and currently it is also impossible to get the sid of lldb-platform running on a remote target
def test_sid_is_same_without_setsid_debugserver(self):
self.init_debugserver_test()
self.set_inferior_startup_launch()
self.sid_is_same_without_setsid()
@llgs_test
- @skipIfRemote # --setsid not used on remote platform and currently it is also impossible to get the sid of lldb-platform running on a remote target
+ @skipIfRemote # --setsid not used on remote platform and currently it is also impossible to get the sid of lldb-platform running on a remote target
@expectedFailureAll(oslist=['freebsd'])
def test_sid_is_same_without_setsid_llgs(self):
self.init_llgs_test()
@@ -56,28 +58,28 @@ class TestStubSetSIDTestCase(gdbremote_testcase.GdbRemoteTestCaseBase):
self.sid_is_same_without_setsid()
@debugserver_test
- @skipIfRemote # --setsid not used on remote platform and currently it is also impossible to get the sid of lldb-platform running on a remote target
+ @skipIfRemote # --setsid not used on remote platform and currently it is also impossible to get the sid of lldb-platform running on a remote target
def test_sid_is_different_with_setsid_debugserver(self):
self.init_debugserver_test()
self.set_inferior_startup_launch()
self.sid_is_different_with_setsid()
@llgs_test
- @skipIfRemote # --setsid not used on remote platform and currently it is also impossible to get the sid of lldb-platform running on a remote target
+ @skipIfRemote # --setsid not used on remote platform and currently it is also impossible to get the sid of lldb-platform running on a remote target
def test_sid_is_different_with_setsid_llgs(self):
self.init_llgs_test()
self.set_inferior_startup_launch()
self.sid_is_different_with_setsid()
@debugserver_test
- @skipIfRemote # --setsid not used on remote platform and currently it is also impossible to get the sid of lldb-platform running on a remote target
+ @skipIfRemote # --setsid not used on remote platform and currently it is also impossible to get the sid of lldb-platform running on a remote target
def test_sid_is_different_with_S_debugserver(self):
self.init_debugserver_test()
self.set_inferior_startup_launch()
self.sid_is_different_with_S()
@llgs_test
- @skipIfRemote # --setsid not used on remote platform and currently it is also impossible to get the sid of lldb-platform running on a remote target
+ @skipIfRemote # --setsid not used on remote platform and currently it is also impossible to get the sid of lldb-platform running on a remote target
def test_sid_is_different_with_S_llgs(self):
self.init_llgs_test()
self.set_inferior_startup_launch()
diff --git a/packages/Python/lldbsuite/test/tools/lldb-server/exit-code/Makefile b/packages/Python/lldbsuite/test/tools/lldb-server/exit-code/Makefile
new file mode 100644
index 000000000000..6ff66a3ab5d9
--- /dev/null
+++ b/packages/Python/lldbsuite/test/tools/lldb-server/exit-code/Makefile
@@ -0,0 +1,8 @@
+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/TestGdbRemoteExitCode.py b/packages/Python/lldbsuite/test/tools/lldb-server/exit-code/TestGdbRemoteExitCode.py
new file mode 100644
index 000000000000..e77f2b7acec0
--- /dev/null
+++ b/packages/Python/lldbsuite/test/tools/lldb-server/exit-code/TestGdbRemoteExitCode.py
@@ -0,0 +1,124 @@
+from __future__ import print_function
+
+# lldb test suite imports
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import TestBase
+
+# gdb-remote-specific imports
+import lldbgdbserverutils
+from gdbremote_testcase import GdbRemoteTestCaseBase
+
+
+class TestGdbRemoteExitCode(GdbRemoteTestCaseBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ FAILED_LAUNCH_CODE = "E08"
+
+ def get_launch_fail_reason(self):
+ self.reset_test_sequence()
+ self.test_sequence.add_log_lines(
+ ["read packet: $qLaunchSuccess#00"],
+ True)
+ self.test_sequence.add_log_lines(
+ [{"direction": "send", "regex": r"^\$(.+)#[0-9a-fA-F]{2}$",
+ "capture": {1: "launch_result"}}],
+ True)
+ context = self.expect_gdbremote_sequence()
+ self.assertIsNotNone(context)
+ return context.get("launch_result")[1:]
+
+ def start_inferior(self):
+ launch_args = self.install_and_create_launch_args()
+
+ server = self.connect_to_debug_monitor()
+ self.assertIsNotNone(server)
+
+ self.add_no_ack_remote_stream()
+ self.test_sequence.add_log_lines(
+ ["read packet: %s" % lldbgdbserverutils.build_gdbremote_A_packet(
+ launch_args)],
+ True)
+ self.test_sequence.add_log_lines(
+ [{"direction": "send", "regex": r"^\$(.+)#[0-9a-fA-F]{2}$",
+ "capture": {1: "A_result"}}],
+ True)
+ context = self.expect_gdbremote_sequence()
+ self.assertIsNotNone(context)
+
+ launch_result = context.get("A_result")
+ self.assertIsNotNone(launch_result)
+ if launch_result == self.FAILED_LAUNCH_CODE:
+ fail_reason = self.get_launch_fail_reason()
+ self.fail("failed to launch inferior: " + fail_reason)
+
+ @debugserver_test
+ def test_start_inferior_debugserver(self):
+ self.init_debugserver_test()
+ self.build()
+ self.start_inferior()
+
+ @llgs_test
+ def test_start_inferior_llgs(self):
+ self.init_llgs_test()
+ self.build()
+ self.start_inferior()
+
+ def inferior_exit_0(self):
+ launch_args = self.install_and_create_launch_args()
+
+ server = self.connect_to_debug_monitor()
+ self.assertIsNotNone(server)
+
+ self.add_no_ack_remote_stream()
+ self.add_verified_launch_packets(launch_args)
+ self.test_sequence.add_log_lines(
+ ["read packet: $vCont;c#a8",
+ "send packet: $W00#00"],
+ True)
+
+ self.expect_gdbremote_sequence()
+
+ @debugserver_test
+ def test_inferior_exit_0_debugserver(self):
+ self.init_debugserver_test()
+ self.build()
+ self.inferior_exit_0()
+
+ @llgs_test
+ def test_inferior_exit_0_llgs(self):
+ self.init_llgs_test()
+ self.build()
+ self.inferior_exit_0()
+
+ def inferior_exit_42(self):
+ launch_args = self.install_and_create_launch_args()
+
+ server = self.connect_to_debug_monitor()
+ self.assertIsNotNone(server)
+
+ RETVAL = 42
+
+ # build launch args
+ launch_args += ["retval:%d" % RETVAL]
+
+ self.add_no_ack_remote_stream()
+ self.add_verified_launch_packets(launch_args)
+ self.test_sequence.add_log_lines(
+ ["read packet: $vCont;c#a8",
+ "send packet: $W{0:02x}#00".format(RETVAL)],
+ True)
+
+ self.expect_gdbremote_sequence()
+
+ @debugserver_test
+ def test_inferior_exit_42_debugserver(self):
+ self.init_debugserver_test()
+ self.build()
+ self.inferior_exit_42()
+
+ @llgs_test
+ def test_inferior_exit_42_llgs(self):
+ self.init_llgs_test()
+ self.build()
+ self.inferior_exit_42()
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
new file mode 100644
index 000000000000..b97c6ebc18e3
--- /dev/null
+++ b/packages/Python/lldbsuite/test/tools/lldb-server/exit-code/main.cpp
@@ -0,0 +1,391 @@
+#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>
+#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)));
+#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 d63ddbe39998..ef6a0a21aaeb 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
@@ -5,7 +5,6 @@ Base class for gdb-remote test cases.
from __future__ import print_function
-
import errno
import os
import os.path
@@ -24,9 +23,11 @@ from lldbsuite.test.lldbtest import *
from lldbgdbserverutils import *
import logging
+
class _ConnectionRefused(IOError):
pass
+
class GdbRemoteTestCaseBase(TestBase):
NO_DEBUG_INFO_TESTCASE = True
@@ -35,29 +36,34 @@ class GdbRemoteTestCaseBase(TestBase):
_GDBREMOTE_KILL_PACKET = "$k#6b"
- # Start the inferior separately, attach to the inferior on the stub command line.
+ # Start the inferior separately, attach to the inferior on the stub
+ # command line.
_STARTUP_ATTACH = "attach"
- # Start the inferior separately, start the stub without attaching, allow the test to attach to the inferior however it wants (e.g. $vAttach;pid).
+ # Start the inferior separately, start the stub without attaching, allow
+ # the test to attach to the inferior however it wants (e.g. $vAttach;pid).
_STARTUP_ATTACH_MANUALLY = "attach_manually"
- # Start the stub, and launch the inferior with an $A packet via the initial packet stream.
+ # Start the stub, and launch the inferior with an $A packet via the
+ # initial packet stream.
_STARTUP_LAUNCH = "launch"
- # GDB Signal numbers that are not target-specific used for common exceptions
- TARGET_EXC_BAD_ACCESS = 0x91
+ # GDB Signal numbers that are not target-specific used for common
+ # exceptions
+ TARGET_EXC_BAD_ACCESS = 0x91
TARGET_EXC_BAD_INSTRUCTION = 0x92
- TARGET_EXC_ARITHMETIC = 0x93
- TARGET_EXC_EMULATION = 0x94
- TARGET_EXC_SOFTWARE = 0x95
- TARGET_EXC_BREAKPOINT = 0x96
+ TARGET_EXC_ARITHMETIC = 0x93
+ TARGET_EXC_EMULATION = 0x94
+ TARGET_EXC_SOFTWARE = 0x95
+ TARGET_EXC_BREAKPOINT = 0x96
_verbose_log_handler = None
- _log_formatter = logging.Formatter(fmt='%(asctime)-15s %(levelname)-8s %(message)s')
+ _log_formatter = logging.Formatter(
+ fmt='%(asctime)-15s %(levelname)-8s %(message)s')
def setUpBaseLogging(self):
self.logger = logging.getLogger(__name__)
if len(self.logger.handlers) > 0:
- return # We have set up this handler already
+ return # We have set up this handler already
self.logger.propagate = False
self.logger.setLevel(logging.DEBUG)
@@ -68,11 +74,11 @@ class GdbRemoteTestCaseBase(TestBase):
handler.setFormatter(self._log_formatter)
self.logger.addHandler(handler)
-
def isVerboseLoggingRequested(self):
# We will report our detailed logs if the user requested that the "gdb-remote" channel is
# logged.
- return any(("gdb-remote" in channel) for channel in lldbtest_config.channels)
+ return any(("gdb-remote" in channel)
+ for channel in lldbtest_config.channels)
def setUp(self):
TestBase.setUp(self)
@@ -83,7 +89,8 @@ class GdbRemoteTestCaseBase(TestBase):
if self.isVerboseLoggingRequested():
# If requested, full logs go to a log file
- self._verbose_log_handler = logging.FileHandler(self.log_basename + "-host.log")
+ self._verbose_log_handler = logging.FileHandler(
+ self.log_basename + "-host.log")
self._verbose_log_handler.setFormatter(self._log_formatter)
self._verbose_log_handler.setLevel(logging.DEBUG)
self.logger.addHandler(self._verbose_log_handler)
@@ -100,7 +107,8 @@ class GdbRemoteTestCaseBase(TestBase):
url_pattern = '(.+)://\[?(.+?)\]?/.*'
else:
url_pattern = '(.+)://(.+):\d+'
- scheme, host = re.match(url_pattern, configuration.lldb_platform_url).groups()
+ scheme, host = re.match(
+ url_pattern, configuration.lldb_platform_url).groups()
if configuration.lldb_platform_name == 'remote-android' and host != 'localhost':
self.stub_device = host
self.stub_hostname = 'localhost'
@@ -122,21 +130,24 @@ class GdbRemoteTestCaseBase(TestBase):
def setUpServerLogging(self, is_llgs):
if len(lldbtest_config.channels) == 0:
- return # No logging requested
+ return # No logging requested
if lldb.remote_platform:
- log_file = lldbutil.join_remote_paths(lldb.remote_platform.GetWorkingDirectory(), "server.log")
+ log_file = lldbutil.join_remote_paths(
+ lldb.remote_platform.GetWorkingDirectory(), "server.log")
else:
log_file = self.getLocalServerLogFile()
if is_llgs:
self.debug_monitor_extra_args.append("--log-file=" + log_file)
- self.debug_monitor_extra_args.append("--log-channels={}".format(":".join(lldbtest_config.channels)))
+ self.debug_monitor_extra_args.append(
+ "--log-channels={}".format(":".join(lldbtest_config.channels)))
else:
- self.debug_monitor_extra_args = ["--log-file=" + self.log_file, "--log-flags=0x800000"]
+ self.debug_monitor_extra_args = [
+ "--log-file=" + log_file, "--log-flags=0x800000"]
def get_next_port(self):
- return 12000 + random.randint(0,3999)
+ return 12000 + random.randint(0, 3999)
def reset_test_sequence(self):
self.test_sequence = GdbRemoteTestSequence(self.logger)
@@ -149,7 +160,8 @@ class GdbRemoteTestCaseBase(TestBase):
# Create the named pipe.
os.mkfifo(named_pipe_path)
- # Open the read side of the pipe in non-blocking mode. This will return right away, ready or not.
+ # Open the read side of the pipe in non-blocking mode. This will
+ # return right away, ready or not.
named_pipe_fd = os.open(named_pipe_path, os.O_RDONLY | os.O_NONBLOCK)
# Create the file for the named pipe. Note this will follow semantics of
@@ -177,7 +189,9 @@ class GdbRemoteTestCaseBase(TestBase):
try:
os.rmdir(temp_dir)
except:
- print("failed to delete temp dir: {}, directory contents: '{}'".format(temp_dir, os.listdir(temp_dir)))
+ print(
+ "failed to delete temp dir: {}, directory contents: '{}'".format(
+ temp_dir, os.listdir(temp_dir)))
None
# Add the shutdown hook to clean up the named pipe.
@@ -190,14 +204,23 @@ class GdbRemoteTestCaseBase(TestBase):
def get_stub_port_from_named_socket(self, read_timeout_seconds=5):
# Wait for something to read with a max timeout.
- (ready_readers, _, _) = select.select([self.named_pipe_fd], [], [], read_timeout_seconds)
- self.assertIsNotNone(ready_readers, "write side of pipe has not written anything - stub isn't writing to pipe.")
- self.assertNotEqual(len(ready_readers), 0, "write side of pipe has not written anything - stub isn't writing to pipe.")
+ (ready_readers, _, _) = select.select(
+ [self.named_pipe_fd], [], [], read_timeout_seconds)
+ self.assertIsNotNone(
+ ready_readers,
+ "write side of pipe has not written anything - stub isn't writing to pipe.")
+ self.assertNotEqual(
+ len(ready_readers),
+ 0,
+ "write side of pipe has not written anything - stub isn't writing to pipe.")
# Read the port from the named pipe.
stub_port_raw = self.named_pipe.read()
self.assertIsNotNone(stub_port_raw)
- self.assertNotEqual(len(stub_port_raw), 0, "no content to read on pipe")
+ self.assertNotEqual(
+ len(stub_port_raw),
+ 0,
+ "no content to read on pipe")
# Trim null byte, convert to int.
stub_port_raw = stub_port_raw[:-1]
@@ -212,15 +235,24 @@ class GdbRemoteTestCaseBase(TestBase):
use_named_pipe = False
# Grab the ppid from /proc/[shell pid]/stat
- err, retcode, shell_stat = self.run_platform_command("cat /proc/$$/stat")
- self.assertTrue(err.Success() and retcode == 0,
- "Failed to read file /proc/$$/stat: %s, retcode: %d" % (err.GetCString(), retcode))
+ err, retcode, shell_stat = self.run_platform_command(
+ "cat /proc/$$/stat")
+ self.assertTrue(
+ err.Success() and retcode == 0,
+ "Failed to read file /proc/$$/stat: %s, retcode: %d" %
+ (err.GetCString(),
+ retcode))
# [pid] ([executable]) [state] [*ppid*]
pid = re.match(r"^\d+ \(.+\) . (\d+)", shell_stat).group(1)
- err, retcode, ls_output = self.run_platform_command("ls -l /proc/%s/exe" % pid)
- self.assertTrue(err.Success() and retcode == 0,
- "Failed to read file /proc/%s/exe: %s, retcode: %d" % (pid, err.GetCString(), retcode))
+ err, retcode, ls_output = self.run_platform_command(
+ "ls -l /proc/%s/exe" % pid)
+ self.assertTrue(
+ err.Success() and retcode == 0,
+ "Failed to read file /proc/%s/exe: %s, retcode: %d" %
+ (pid,
+ err.GetCString(),
+ retcode))
exe = ls_output.split()[-1]
# If the binary has been deleted, the link name has " (deleted)" appended.
@@ -235,7 +267,8 @@ class GdbRemoteTestCaseBase(TestBase):
self.setUpServerLogging(is_llgs=True)
if use_named_pipe:
- (self.named_pipe_path, self.named_pipe, self.named_pipe_fd) = self.create_named_pipe()
+ (self.named_pipe_path, self.named_pipe,
+ self.named_pipe_fd) = self.create_named_pipe()
def init_debugserver_test(self, use_named_pipe=True):
self.debug_monitor_exe = get_debugserver_exe()
@@ -243,17 +276,19 @@ class GdbRemoteTestCaseBase(TestBase):
self.skipTest("debugserver exe not found")
self.setUpServerLogging(is_llgs=False)
if use_named_pipe:
- (self.named_pipe_path, self.named_pipe, self.named_pipe_fd) = self.create_named_pipe()
+ (self.named_pipe_path, self.named_pipe,
+ self.named_pipe_fd) = self.create_named_pipe()
# The debugserver stub has a race on handling the 'k' command, so it sends an X09 right away, then sends the real X notification
# when the process truly dies.
self.stub_sends_two_stop_notifications_on_kill = True
def forward_adb_port(self, source, target, direction, device):
- adb = [ 'adb' ] + ([ '-s', device ] if device else []) + [ direction ]
+ adb = ['adb'] + (['-s', device] if device else []) + [direction]
+
def remove_port_forward():
- subprocess.call(adb + [ "--remove", "tcp:%d" % source])
+ subprocess.call(adb + ["--remove", "tcp:%d" % source])
- subprocess.call(adb + [ "tcp:%d" % source, "tcp:%d" % target])
+ subprocess.call(adb + ["tcp:%d" % source, "tcp:%d" % target])
self.addTearDownHook(remove_port_forward)
def _verify_socket(self, sock):
@@ -265,12 +300,12 @@ class GdbRemoteTestCaseBase(TestBase):
# connection again.
triple = self.dbg.GetSelectedPlatform().GetTriple()
if not re.match(".*-.*-.*-android", triple):
- return # Not android.
+ return # Not android.
can_read, _, _ = select.select([sock], [], [], 0.1)
if sock not in can_read:
- return # Data is not available, but the connection is alive.
+ return # Data is not available, but the connection is alive.
if len(sock.recv(1, socket.MSG_PEEK)) == 0:
- raise _ConnectionRefused() # Got EOF, connection dropped.
+ raise _ConnectionRefused() # Got EOF, connection dropped.
def create_socket(self):
sock = socket.socket()
@@ -278,9 +313,16 @@ class GdbRemoteTestCaseBase(TestBase):
triple = self.dbg.GetSelectedPlatform().GetTriple()
if re.match(".*-.*-.*-android", triple):
- self.forward_adb_port(self.port, self.port, "forward", self.stub_device)
-
- logger.info("Connecting to debug monitor on %s:%d", self.stub_hostname, self.port)
+ self.forward_adb_port(
+ self.port,
+ self.port,
+ "forward",
+ self.stub_device)
+
+ logger.info(
+ "Connecting to debug monitor on %s:%d",
+ self.stub_hostname,
+ self.port)
connect_info = (self.stub_hostname, self.port)
try:
sock.connect(connect_info)
@@ -295,12 +337,16 @@ class GdbRemoteTestCaseBase(TestBase):
# send the kill packet so lldb-server shuts down gracefully
sock.sendall(GdbRemoteTestCaseBase._GDBREMOTE_KILL_PACKET)
except:
- logger.warning("failed to send kill packet to debug monitor: {}; ignoring".format(sys.exc_info()[0]))
+ logger.warning(
+ "failed to send kill packet to debug monitor: {}; ignoring".format(
+ sys.exc_info()[0]))
try:
sock.close()
except:
- logger.warning("failed to close socket to debug monitor: {}; ignoring".format(sys.exc_info()[0]))
+ logger.warning(
+ "failed to close socket to debug monitor: {}; ignoring".format(
+ sys.exc_info()[0]))
self.addTearDownHook(shutdown_socket)
@@ -319,9 +365,11 @@ class GdbRemoteTestCaseBase(TestBase):
def get_debug_monitor_command_line_args(self, attach_pid=None):
if lldb.remote_platform:
- commandline_args = self.debug_monitor_extra_args + ["*:{}".format(self.port)]
+ commandline_args = self.debug_monitor_extra_args + \
+ ["*:{}".format(self.port)]
else:
- commandline_args = self.debug_monitor_extra_args + ["localhost:{}".format(self.port)]
+ commandline_args = self.debug_monitor_extra_args + \
+ ["localhost:{}".format(self.port)]
if attach_pid:
commandline_args += ["--attach=%d" % attach_pid]
@@ -331,14 +379,19 @@ class GdbRemoteTestCaseBase(TestBase):
def launch_debug_monitor(self, attach_pid=None, logfile=None):
# Create the command line.
- commandline_args = self.get_debug_monitor_command_line_args(attach_pid=attach_pid)
+ commandline_args = self.get_debug_monitor_command_line_args(
+ attach_pid=attach_pid)
# Start the server.
- server = self.spawnSubprocess(self.debug_monitor_exe, commandline_args, install_remote=False)
+ server = self.spawnSubprocess(
+ self.debug_monitor_exe,
+ commandline_args,
+ install_remote=False)
self.addTearDownHook(self.cleanupSubprocesses)
self.assertIsNotNone(server)
- # If we're receiving the stub's listening port from the named pipe, do that here.
+ # If we're receiving the stub's listening port from the named pipe, do
+ # that here.
if self.named_pipe:
self.port = self.get_stub_port_from_named_socket()
@@ -354,7 +407,9 @@ class GdbRemoteTestCaseBase(TestBase):
try:
server.terminate()
except:
- logger.warning("failed to terminate server for debug monitor: {}; ignoring".format(sys.exc_info()[0]))
+ logger.warning(
+ "failed to terminate server for debug monitor: {}; ignoring".format(
+ sys.exc_info()[0]))
self.addTearDownHook(shutdown_debug_monitor)
# Schedule debug monitor to be shut down during teardown.
@@ -374,11 +429,14 @@ class GdbRemoteTestCaseBase(TestBase):
# Schedule debug monitor to be shut down during teardown.
logger = self.logger
+
def shutdown_debug_monitor():
try:
server.terminate()
except:
- logger.warning("failed to terminate server for debug monitor: {}; ignoring".format(sys.exc_info()[0]))
+ logger.warning(
+ "failed to terminate server for debug monitor: {}; ignoring".format(
+ sys.exc_info()[0]))
self.addTearDownHook(shutdown_debug_monitor)
connect_attemps = 0
@@ -387,7 +445,7 @@ class GdbRemoteTestCaseBase(TestBase):
while connect_attemps < MAX_CONNECT_ATTEMPTS:
# Create a socket to talk to the server
try:
- logger.info("Connect attempt %d", connect_attemps+1)
+ logger.info("Connect attempt %d", connect_attemps + 1)
self.sock = self.create_socket()
return server
except _ConnectionRefused as serr:
@@ -400,18 +458,27 @@ class GdbRemoteTestCaseBase(TestBase):
server.terminate()
# Increment attempts.
- print("connect to debug monitor on port %d failed, attempt #%d of %d" % (self.port, attempts + 1, MAX_ATTEMPTS))
+ print(
+ "connect to debug monitor on port %d failed, attempt #%d of %d" %
+ (self.port, attempts + 1, MAX_ATTEMPTS))
attempts += 1
- # And wait a random length of time before next attempt, to avoid collisions.
- time.sleep(random.randint(1,5))
-
+ # And wait a random length of time before next attempt, to avoid
+ # collisions.
+ time.sleep(random.randint(1, 5))
+
# Now grab a new port number.
self.port = self.get_next_port()
- raise Exception("failed to create a socket to the launched debug monitor after %d tries" % attempts)
+ raise Exception(
+ "failed to create a socket to the launched debug monitor after %d tries" %
+ attempts)
- def launch_process_for_attach(self, inferior_args=None, sleep_seconds=3, exe_path=None):
+ def launch_process_for_attach(
+ self,
+ inferior_args=None,
+ sleep_seconds=3,
+ exe_path=None):
# We're going to start a child process that the debug monitor stub can later attach to.
# This process needs to be started so that it just hangs around for a while. We'll
# have it sleep.
@@ -425,15 +492,22 @@ class GdbRemoteTestCaseBase(TestBase):
args.append("sleep:%d" % sleep_seconds)
inferior = self.spawnSubprocess(exe_path, args)
+
def shutdown_process_for_attach():
try:
inferior.terminate()
except:
- logger.warning("failed to terminate inferior process for attach: {}; ignoring".format(sys.exc_info()[0]))
+ logger.warning(
+ "failed to terminate inferior process for attach: {}; ignoring".format(
+ sys.exc_info()[0]))
self.addTearDownHook(shutdown_process_for_attach)
return inferior
- def prep_debug_monitor_and_inferior(self, inferior_args=None, inferior_sleep_seconds=3, inferior_exe_path=None):
+ def prep_debug_monitor_and_inferior(
+ self,
+ inferior_args=None,
+ inferior_sleep_seconds=3,
+ inferior_exe_path=None):
"""Prep the debug monitor, the inferior, and the expected packet stream.
Handle the separate cases of using the debug monitor in attach-to-inferior mode
@@ -458,11 +532,15 @@ class GdbRemoteTestCaseBase(TestBase):
if self._inferior_startup == self._STARTUP_ATTACH or self._inferior_startup == self._STARTUP_ATTACH_MANUALLY:
# Launch the process that we'll use as the inferior.
- inferior = self.launch_process_for_attach(inferior_args=inferior_args, sleep_seconds=inferior_sleep_seconds, exe_path=inferior_exe_path)
+ inferior = self.launch_process_for_attach(
+ inferior_args=inferior_args,
+ sleep_seconds=inferior_sleep_seconds,
+ exe_path=inferior_exe_path)
self.assertIsNotNone(inferior)
self.assertTrue(inferior.pid > 0)
if self._inferior_startup == self._STARTUP_ATTACH:
- # In this case, we want the stub to attach via the command line, so set the command line attach pid here.
+ # In this case, we want the stub to attach via the command
+ # line, so set the command line attach pid here.
attach_pid = inferior.pid
if self._inferior_startup == self._STARTUP_LAUNCH:
@@ -471,11 +549,15 @@ class GdbRemoteTestCaseBase(TestBase):
inferior_exe_path = os.path.abspath("a.out")
if lldb.remote_platform:
- remote_path = lldbutil.append_to_process_working_directory(os.path.basename(inferior_exe_path))
+ remote_path = lldbutil.append_to_process_working_directory(
+ os.path.basename(inferior_exe_path))
remote_file_spec = lldb.SBFileSpec(remote_path, False)
- err = lldb.remote_platform.Install(lldb.SBFileSpec(inferior_exe_path, True), remote_file_spec)
+ err = lldb.remote_platform.Install(lldb.SBFileSpec(
+ inferior_exe_path, True), remote_file_spec)
if err.Fail():
- raise Exception("remote_platform.Install('%s', '%s') failed: %s" % (inferior_exe_path, remote_path, err))
+ raise Exception(
+ "remote_platform.Install('%s', '%s') failed: %s" %
+ (inferior_exe_path, remote_path, err))
inferior_exe_path = remote_path
launch_args = [inferior_exe_path]
@@ -491,13 +573,18 @@ class GdbRemoteTestCaseBase(TestBase):
if self._inferior_startup == self._STARTUP_LAUNCH:
self.add_verified_launch_packets(launch_args)
- return {"inferior":inferior, "server":server}
+ return {"inferior": inferior, "server": server}
- def expect_socket_recv(self, sock, expected_content_regex, timeout_seconds):
+ def expect_socket_recv(
+ self,
+ sock,
+ expected_content_regex,
+ timeout_seconds):
response = ""
timeout_time = time.time() + timeout_seconds
- while not expected_content_regex.match(response) and time.time() < timeout_time:
+ while not expected_content_regex.match(
+ response) and time.time() < timeout_time:
can_read, _, _ = select.select([sock], [], [], timeout_seconds)
if can_read and sock in can_read:
recv_bytes = sock.recv(4096)
@@ -514,7 +601,8 @@ class GdbRemoteTestCaseBase(TestBase):
_, can_write, _ = select.select([], [sock], [], timeout_seconds)
if can_write and sock in can_write:
written_byte_count = sock.send(request_bytes_remaining)
- request_bytes_remaining = request_bytes_remaining[written_byte_count:]
+ request_bytes_remaining = request_bytes_remaining[
+ written_byte_count:]
self.assertEqual(len(request_bytes_remaining), 0)
def do_handshake(self, stub_socket, timeout_seconds=5):
@@ -527,7 +615,8 @@ class GdbRemoteTestCaseBase(TestBase):
self.assertEqual(bytes_sent, len(NO_ACK_MODE_REQUEST))
# Receive the ack and "OK"
- self.expect_socket_recv(stub_socket, re.compile(r"^\+\$OK#[0-9a-fA-F]{2}$"), timeout_seconds)
+ self.expect_socket_recv(stub_socket, re.compile(
+ r"^\+\$OK#[0-9a-fA-F]{2}$"), timeout_seconds)
# Send the final ack.
self.expect_socket_send(stub_socket, "+", timeout_seconds)
@@ -553,12 +642,12 @@ class GdbRemoteTestCaseBase(TestBase):
self.test_sequence.add_log_lines(
["read packet: $QThreadSuffixSupported#e4",
"send packet: $OK#00",
- ], True)
+ ], True)
def add_process_info_collection_packets(self):
self.test_sequence.add_log_lines(
["read packet: $qProcessInfo#dc",
- { "direction":"send", "regex":r"^\$(.+)#[0-9a-fA-F]{2}$", "capture":{1:"process_info_raw"} }],
+ {"direction": "send", "regex": r"^\$(.+)#[0-9a-fA-F]{2}$", "capture": {1: "process_info_raw"}}],
True)
_KNOWN_PROCESS_INFO_KEYS = [
@@ -574,8 +663,9 @@ class GdbRemoteTestCaseBase(TestBase):
"triple",
"vendor",
"endian",
+ "elf_abi",
"ptrsize"
- ]
+ ]
def parse_process_info_response(self, context):
# Ensure we have a process info response.
@@ -584,7 +674,9 @@ class GdbRemoteTestCaseBase(TestBase):
self.assertIsNotNone(process_info_raw)
# Pull out key:value; pairs.
- process_info_dict = { match.group(1):match.group(2) for match in re.finditer(r"([^:]+):([^;]+);", process_info_raw) }
+ process_info_dict = {
+ match.group(1): match.group(2) for match in re.finditer(
+ r"([^:]+):([^;]+);", process_info_raw)}
# Validate keys are known.
for (key, val) in list(process_info_dict.items()):
@@ -595,9 +687,9 @@ class GdbRemoteTestCaseBase(TestBase):
def add_register_info_collection_packets(self):
self.test_sequence.add_log_lines(
- [ { "type":"multi_response", "query":"qRegisterInfo", "append_iteration_suffix":True,
- "end_regex":re.compile(r"^\$(E\d+)?#[0-9a-fA-F]{2}$"),
- "save_key":"reg_info_responses" } ],
+ [{"type": "multi_response", "query": "qRegisterInfo", "append_iteration_suffix": True,
+ "end_regex": re.compile(r"^\$(E\d+)?#[0-9a-fA-F]{2}$"),
+ "save_key": "reg_info_responses"}],
True)
def parse_register_info_packets(self, context):
@@ -606,13 +698,19 @@ class GdbRemoteTestCaseBase(TestBase):
self.assertIsNotNone(reg_info_responses)
# Parse register infos.
- return [parse_reg_info_response(reg_info_response) for reg_info_response in reg_info_responses]
+ return [parse_reg_info_response(reg_info_response)
+ for reg_info_response in reg_info_responses]
def expect_gdbremote_sequence(self, timeout_seconds=None):
if not timeout_seconds:
timeout_seconds = self._TIMEOUT_SECONDS
- return expect_lldb_gdbserver_replay(self, self.sock, self.test_sequence,
- self._pump_queues, timeout_seconds, self.logger)
+ return expect_lldb_gdbserver_replay(
+ self,
+ self.sock,
+ self.test_sequence,
+ self._pump_queues,
+ timeout_seconds,
+ self.logger)
_KNOWN_REGINFO_KEYS = [
"name",
@@ -627,7 +725,9 @@ class GdbRemoteTestCaseBase(TestBase):
"dwarf",
"generic",
"container-regs",
- "invalidate-regs"
+ "invalidate-regs",
+ "dynamic_size_dwarf_expr_bytes",
+ "dynamic_size_dwarf_len"
]
def assert_valid_reg_info(self, reg_info):
@@ -667,7 +767,7 @@ class GdbRemoteTestCaseBase(TestBase):
def add_query_memory_region_packets(self, address):
self.test_sequence.add_log_lines(
["read packet: $qMemoryRegionInfo:{0:x}#00".format(address),
- {"direction":"send", "regex":r"^\$(.+)#[0-9a-fA-F]{2}$", "capture":{1:"memory_region_response"} }],
+ {"direction": "send", "regex": r"^\$(.+)#[0-9a-fA-F]{2}$", "capture": {1: "memory_region_response"}}],
True)
def parse_key_val_dict(self, key_val_text, allow_dupes=True):
@@ -678,13 +778,15 @@ class GdbRemoteTestCaseBase(TestBase):
val = match.group(2)
if key in kv_dict:
if allow_dupes:
- if type(kv_dict[key]) == list:
+ if isinstance(kv_dict[key], list):
kv_dict[key].append(val)
else:
# Promote to list
kv_dict[key] = [kv_dict[key], val]
else:
- self.fail("key '{}' already present when attempting to add value '{}' (text='{}', dict={})".format(key, val, key_val_text, kv_dict))
+ self.fail(
+ "key '{}' already present when attempting to add value '{}' (text='{}', dict={})".format(
+ key, val, key_val_text, kv_dict))
else:
kv_dict[key] = val
return kv_dict
@@ -694,17 +796,25 @@ class GdbRemoteTestCaseBase(TestBase):
self.assertIsNotNone(context.get("memory_region_response"))
# Pull out key:value; pairs.
- mem_region_dict = self.parse_key_val_dict(context.get("memory_region_response"))
+ mem_region_dict = self.parse_key_val_dict(
+ context.get("memory_region_response"))
# Validate keys are known.
for (key, val) in list(mem_region_dict.items()):
- self.assertTrue(key in ["start", "size", "permissions", "error"])
+ self.assertTrue(
+ key in [
+ "start",
+ "size",
+ "permissions",
+ "name",
+ "error"])
self.assertIsNotNone(val)
# Return the dictionary of key-value pairs for the memory region.
return mem_region_dict
- def assert_address_within_memory_region(self, test_address, mem_region_dict):
+ def assert_address_within_memory_region(
+ self, test_address, mem_region_dict):
self.assertIsNotNone(mem_region_dict)
self.assertTrue("start" in mem_region_dict)
self.assertTrue("size" in mem_region_dict)
@@ -714,15 +824,25 @@ class GdbRemoteTestCaseBase(TestBase):
range_end = range_start + range_size
if test_address < range_start:
- self.fail("address 0x{0:x} comes before range 0x{1:x} - 0x{2:x} (size 0x{3:x})".format(test_address, range_start, range_end, range_size))
+ self.fail(
+ "address 0x{0:x} comes before range 0x{1:x} - 0x{2:x} (size 0x{3:x})".format(
+ test_address,
+ range_start,
+ range_end,
+ range_size))
elif test_address >= range_end:
- self.fail("address 0x{0:x} comes after range 0x{1:x} - 0x{2:x} (size 0x{3:x})".format(test_address, range_start, range_end, range_size))
+ self.fail(
+ "address 0x{0:x} comes after range 0x{1:x} - 0x{2:x} (size 0x{3:x})".format(
+ test_address,
+ range_start,
+ range_end,
+ range_size))
def add_threadinfo_collection_packets(self):
self.test_sequence.add_log_lines(
- [ { "type":"multi_response", "first_query":"qfThreadInfo", "next_query":"qsThreadInfo",
- "append_iteration_suffix":False, "end_regex":re.compile(r"^\$(l)?#[0-9a-fA-F]{2}$"),
- "save_key":"threadinfo_responses" } ],
+ [{"type": "multi_response", "first_query": "qfThreadInfo", "next_query": "qsThreadInfo",
+ "append_iteration_suffix": False, "end_regex": re.compile(r"^\$(l)?#[0-9a-fA-F]{2}$"),
+ "save_key": "threadinfo_responses"}],
True)
def parse_threadinfo_packets(self, context):
@@ -760,35 +880,44 @@ class GdbRemoteTestCaseBase(TestBase):
return threads
- def add_set_breakpoint_packets(self, address, do_continue=True, breakpoint_kind=1):
+ def add_set_breakpoint_packets(
+ self,
+ address,
+ do_continue=True,
+ breakpoint_kind=1):
self.test_sequence.add_log_lines(
- [# Set the breakpoint.
- "read packet: $Z0,{0:x},{1}#00".format(address, breakpoint_kind),
- # Verify the stub could set it.
- "send packet: $OK#00",
- ], True)
+ [ # Set the breakpoint.
+ "read packet: $Z0,{0:x},{1}#00".format(
+ address, breakpoint_kind),
+ # Verify the stub could set it.
+ "send packet: $OK#00",
+ ], True)
if (do_continue):
self.test_sequence.add_log_lines(
- [# Continue the inferior.
- "read packet: $c#63",
- # Expect a breakpoint stop report.
- {"direction":"send", "regex":r"^\$T([0-9a-fA-F]{2})thread:([0-9a-fA-F]+);", "capture":{1:"stop_signo", 2:"stop_thread_id"} },
- ], True)
+ [ # Continue the inferior.
+ "read packet: $c#63",
+ # Expect a breakpoint stop report.
+ {"direction": "send",
+ "regex": r"^\$T([0-9a-fA-F]{2})thread:([0-9a-fA-F]+);",
+ "capture": {1: "stop_signo",
+ 2: "stop_thread_id"}},
+ ], True)
def add_remove_breakpoint_packets(self, address, breakpoint_kind=1):
self.test_sequence.add_log_lines(
- [# Remove the breakpoint.
- "read packet: $z0,{0:x},{1}#00".format(address, breakpoint_kind),
- # Verify the stub could unset it.
- "send packet: $OK#00",
+ [ # Remove the breakpoint.
+ "read packet: $z0,{0:x},{1}#00".format(
+ address, breakpoint_kind),
+ # Verify the stub could unset it.
+ "send packet: $OK#00",
], True)
def add_qSupported_packets(self):
self.test_sequence.add_log_lines(
["read packet: $qSupported#00",
- {"direction":"send", "regex":r"^\$(.*)#[0-9a-fA-F]{2}", "capture":{1: "qSupported_response"}},
- ], True)
+ {"direction": "send", "regex": r"^\$(.*)#[0-9a-fA-F]{2}", "capture": {1: "qSupported_response"}},
+ ], True)
_KNOWN_QSUPPORTED_STUB_FEATURES = [
"augmented-libraries-svr4-read",
@@ -821,23 +950,27 @@ class GdbRemoteTestCaseBase(TestBase):
supported_dict[key] = val
else:
if len(key) < 2:
- raise Exception("singular stub feature is too short: must be stub_feature{+,-,?}")
+ raise Exception(
+ "singular stub feature is too short: must be stub_feature{+,-,?}")
supported_type = key[-1]
key = key[:-1]
if not supported_type in ["+", "-", "?"]:
- raise Exception("malformed stub feature: final character {} not in expected set (+,-,?)".format(supported_type))
- supported_dict[key] = supported_type
+ raise Exception(
+ "malformed stub feature: final character {} not in expected set (+,-,?)".format(supported_type))
+ supported_dict[key] = supported_type
# Ensure we know the supported element
- if not key in self._KNOWN_QSUPPORTED_STUB_FEATURES:
- raise Exception("unknown qSupported stub feature reported: %s" % key)
+ if key not in self._KNOWN_QSUPPORTED_STUB_FEATURES:
+ raise Exception(
+ "unknown qSupported stub feature reported: %s" %
+ key)
return supported_dict
def run_process_then_stop(self, run_seconds=1):
# Tell the stub to continue.
self.test_sequence.add_log_lines(
- ["read packet: $vCont;c#a8"],
- True)
+ ["read packet: $vCont;c#a8"],
+ True)
context = self.expect_gdbremote_sequence()
# Wait for run_seconds.
@@ -847,7 +980,7 @@ class GdbRemoteTestCaseBase(TestBase):
self.reset_test_sequence()
self.test_sequence.add_log_lines(
["read packet: {}".format(chr(3)),
- {"direction":"send", "regex":r"^\$T([0-9a-fA-F]+)([^#]+)#[0-9a-fA-F]{2}$", "capture":{1:"stop_result"} }],
+ {"direction": "send", "regex": r"^\$T([0-9a-fA-F]+)([^#]+)#[0-9a-fA-F]{2}$", "capture": {1: "stop_result"}}],
True)
context = self.expect_gdbremote_sequence()
self.assertIsNotNone(context)
@@ -857,18 +990,21 @@ class GdbRemoteTestCaseBase(TestBase):
def select_modifiable_register(self, reg_infos):
"""Find a register that can be read/written freely."""
- PREFERRED_REGISTER_NAMES = set(["rax",])
+ PREFERRED_REGISTER_NAMES = set(["rax", ])
- # First check for the first register from the preferred register name set.
+ # First check for the first register from the preferred register name
+ # set.
alternative_register_index = None
self.assertIsNotNone(reg_infos)
for reg_info in reg_infos:
- if ("name" in reg_info) and (reg_info["name"] in PREFERRED_REGISTER_NAMES):
+ if ("name" in reg_info) and (
+ 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.
+ # A frame pointer 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
@@ -901,7 +1037,8 @@ class GdbRemoteTestCaseBase(TestBase):
def find_generic_register_with_name(self, reg_infos, generic_name):
self.assertIsNotNone(reg_infos)
for reg_info in reg_infos:
- if ("generic" in reg_info) and (reg_info["generic"] == generic_name):
+ if ("generic" in reg_info) and (
+ reg_info["generic"] == generic_name):
return reg_info
return None
@@ -912,13 +1049,13 @@ class GdbRemoteTestCaseBase(TestBase):
if encoded_bytes[i] == "}":
# Handle escaped char.
self.assertTrue(i + 1 < len(encoded_bytes))
- decoded_bytes += chr(ord(encoded_bytes[i+1]) ^ 0x20)
- i +=2
+ decoded_bytes += chr(ord(encoded_bytes[i + 1]) ^ 0x20)
+ i += 2
elif encoded_bytes[i] == "*":
# Handle run length encoding.
self.assertTrue(len(decoded_bytes) > 0)
self.assertTrue(i + 1 < len(encoded_bytes))
- repeat_count = ord(encoded_bytes[i+1]) - 29
+ repeat_count = ord(encoded_bytes[i + 1]) - 29
decoded_bytes += decoded_bytes[-1] * repeat_count
i += 2
else:
@@ -955,7 +1092,8 @@ class GdbRemoteTestCaseBase(TestBase):
self.assertFalse(key in auxv_dict)
auxv_dict[key] = value
- self.fail("should not reach here - implies required double zero entry not found")
+ self.fail(
+ "should not reach here - implies required double zero entry not found")
return auxv_dict
def read_binary_data_in_chunks(self, command_prefix, chunk_length):
@@ -967,10 +1105,21 @@ class GdbRemoteTestCaseBase(TestBase):
while not done:
# Grab the next iteration of data.
self.reset_test_sequence()
- self.test_sequence.add_log_lines([
- "read packet: ${}{:x},{:x}:#00".format(command_prefix, offset, chunk_length),
- {"direction":"send", "regex":re.compile(r"^\$([^E])(.*)#[0-9a-fA-F]{2}$", re.MULTILINE|re.DOTALL), "capture":{1:"response_type", 2:"content_raw"} }
- ], True)
+ self.test_sequence.add_log_lines(
+ [
+ "read packet: ${}{:x},{:x}:#00".format(
+ command_prefix,
+ offset,
+ chunk_length),
+ {
+ "direction": "send",
+ "regex": re.compile(
+ r"^\$([^E])(.*)#[0-9a-fA-F]{2}$",
+ re.MULTILINE | re.DOTALL),
+ "capture": {
+ 1: "response_type",
+ 2: "content_raw"}}],
+ True)
context = self.expect_gdbremote_sequence()
self.assertIsNotNone(context)
@@ -997,25 +1146,32 @@ class GdbRemoteTestCaseBase(TestBase):
# Send the intterupt.
"read packet: {}".format(chr(3)),
# And wait for the stop notification.
- {"direction":"send", "regex":r"^\$T([0-9a-fA-F]{2})(.*)#[0-9a-fA-F]{2}$", "capture":{1:"stop_signo", 2:"stop_key_val_text" } },
- ], True)
+ {"direction": "send",
+ "regex": r"^\$T([0-9a-fA-F]{2})(.*)#[0-9a-fA-F]{2}$",
+ "capture": {1: "stop_signo",
+ 2: "stop_key_val_text"}},
+ ], True)
def parse_interrupt_packets(self, context):
self.assertIsNotNone(context.get("stop_signo"))
self.assertIsNotNone(context.get("stop_key_val_text"))
- return (int(context["stop_signo"], 16), self.parse_key_val_dict(context["stop_key_val_text"]))
+ return (int(context["stop_signo"], 16), self.parse_key_val_dict(
+ context["stop_key_val_text"]))
def add_QSaveRegisterState_packets(self, thread_id):
if thread_id:
# Use the thread suffix form.
- request = "read packet: $QSaveRegisterState;thread:{:x}#00".format(thread_id)
+ request = "read packet: $QSaveRegisterState;thread:{:x}#00".format(
+ thread_id)
else:
request = "read packet: $QSaveRegisterState#00"
-
- self.test_sequence.add_log_lines([
- request,
- {"direction":"send", "regex":r"^\$(E?.*)#[0-9a-fA-F]{2}$", "capture":{1:"save_response" } },
- ], True)
+
+ self.test_sequence.add_log_lines([request,
+ {"direction": "send",
+ "regex": r"^\$(E?.*)#[0-9a-fA-F]{2}$",
+ "capture": {1: "save_response"}},
+ ],
+ True)
def parse_QSaveRegisterState_response(self, context):
self.assertIsNotNone(context)
@@ -1032,16 +1188,19 @@ class GdbRemoteTestCaseBase(TestBase):
def add_QRestoreRegisterState_packets(self, save_id, thread_id=None):
if thread_id:
# Use the thread suffix form.
- request = "read packet: $QRestoreRegisterState:{};thread:{:x}#00".format(save_id, thread_id)
+ request = "read packet: $QRestoreRegisterState:{};thread:{:x}#00".format(
+ save_id, thread_id)
else:
- request = "read packet: $QRestoreRegisterState:{}#00".format(save_id)
+ request = "read packet: $QRestoreRegisterState:{}#00".format(
+ save_id)
self.test_sequence.add_log_lines([
request,
"send packet: $OK#00"
- ], True)
+ ], True)
- def flip_all_bits_in_each_register_value(self, reg_infos, endian, thread_id=None):
+ def flip_all_bits_in_each_register_value(
+ self, reg_infos, endian, thread_id=None):
self.assertIsNotNone(reg_infos)
successful_writes = 0
@@ -1049,16 +1208,18 @@ class GdbRemoteTestCaseBase(TestBase):
for reg_info in reg_infos:
# Use the lldb register index added to the reg info. We're not necessarily
- # working off a full set of register infos, so an inferred register index could be wrong.
+ # working off a full set of register infos, so an inferred register
+ # index could be wrong.
reg_index = reg_info["lldb_register_index"]
self.assertIsNotNone(reg_index)
- reg_byte_size = int(reg_info["bitsize"])/8
+ reg_byte_size = int(reg_info["bitsize"]) / 8
self.assertTrue(reg_byte_size > 0)
# Handle thread suffix.
if thread_id:
- p_request = "read packet: $p{:x};thread:{:x}#00".format(reg_index, thread_id)
+ p_request = "read packet: $p{:x};thread:{:x}#00".format(
+ reg_index, thread_id)
else:
p_request = "read packet: $p{:x}#00".format(reg_index)
@@ -1066,15 +1227,16 @@ class GdbRemoteTestCaseBase(TestBase):
self.reset_test_sequence()
self.test_sequence.add_log_lines([
p_request,
- { "direction":"send", "regex":r"^\$([0-9a-fA-F]+)#", "capture":{1:"p_response"} },
- ], True)
+ {"direction": "send", "regex": r"^\$([0-9a-fA-F]+)#", "capture": {1: "p_response"}},
+ ], True)
context = self.expect_gdbremote_sequence()
self.assertIsNotNone(context)
# Verify the response length.
p_response = context.get("p_response")
self.assertIsNotNone(p_response)
- initial_reg_value = unpack_register_hex_unsigned(endian, p_response)
+ initial_reg_value = unpack_register_hex_unsigned(
+ endian, p_response)
# Flip the value by xoring with all 1s
all_one_bits_raw = "ff" * (int(reg_info["bitsize"]) / 8)
@@ -1083,16 +1245,22 @@ class GdbRemoteTestCaseBase(TestBase):
# Handle thread suffix for P.
if thread_id:
- P_request = "read packet: $P{:x}={};thread:{:x}#00".format(reg_index, pack_register_hex(endian, flipped_bits_int, byte_size=reg_byte_size), thread_id)
+ P_request = "read packet: $P{:x}={};thread:{:x}#00".format(
+ reg_index, pack_register_hex(
+ endian, flipped_bits_int, byte_size=reg_byte_size), thread_id)
else:
- P_request = "read packet: $P{:x}={}#00".format(reg_index, pack_register_hex(endian, flipped_bits_int, byte_size=reg_byte_size))
+ P_request = "read packet: $P{:x}={}#00".format(
+ reg_index, pack_register_hex(
+ endian, flipped_bits_int, byte_size=reg_byte_size))
# Write the flipped value to the register.
self.reset_test_sequence()
- self.test_sequence.add_log_lines([
- P_request,
- { "direction":"send", "regex":r"^\$(OK|E[0-9a-fA-F]+)#[0-9a-fA-F]{2}", "capture":{1:"P_response"} },
- ], True)
+ self.test_sequence.add_log_lines([P_request,
+ {"direction": "send",
+ "regex": r"^\$(OK|E[0-9a-fA-F]+)#[0-9a-fA-F]{2}",
+ "capture": {1: "P_response"}},
+ ],
+ True)
context = self.expect_gdbremote_sequence()
self.assertIsNotNone(context)
@@ -1107,25 +1275,27 @@ class GdbRemoteTestCaseBase(TestBase):
failed_writes += 1
# print("reg (index={}, name={}) write FAILED (error: {})".format(reg_index, reg_info["name"], P_response))
- # Read back the register value, ensure it matches the flipped value.
+ # Read back the register value, ensure it matches the flipped
+ # value.
if P_response == "OK":
self.reset_test_sequence()
self.test_sequence.add_log_lines([
p_request,
- { "direction":"send", "regex":r"^\$([0-9a-fA-F]+)#", "capture":{1:"p_response"} },
- ], True)
+ {"direction": "send", "regex": r"^\$([0-9a-fA-F]+)#", "capture": {1: "p_response"}},
+ ], True)
context = self.expect_gdbremote_sequence()
self.assertIsNotNone(context)
verify_p_response_raw = context.get("p_response")
self.assertIsNotNone(verify_p_response_raw)
- verify_bits = unpack_register_hex_unsigned(endian, verify_p_response_raw)
+ verify_bits = unpack_register_hex_unsigned(
+ endian, verify_p_response_raw)
if verify_bits != flipped_bits_int:
# Some registers, like mxcsrmask and others, will permute what's written. Adjust succeed/fail counts.
# print("reg (index={}, name={}): read verify FAILED: wrote {:x}, verify read back {:x}".format(reg_index, reg_info["name"], flipped_bits_int, verify_bits))
successful_writes -= 1
- failed_writes +=1
+ failed_writes += 1
return (successful_writes, failed_writes)
@@ -1136,7 +1306,8 @@ class GdbRemoteTestCaseBase(TestBase):
return False
if reg_info["set"] != "General Purpose Registers":
return False
- if ("container-regs" in reg_info) and (len(reg_info["container-regs"]) > 0):
+ if ("container-regs" in reg_info) and (
+ len(reg_info["container-regs"]) > 0):
# Don't try to bit flip registers contained in another register.
return False
if re.match("^.s$", reg_info["name"]):
@@ -1154,13 +1325,15 @@ class GdbRemoteTestCaseBase(TestBase):
values = {}
for reg_info in reg_infos:
- # We append a register index when load reg infos so we can work with subsets.
+ # We append a register index when load reg infos so we can work
+ # with subsets.
reg_index = reg_info.get("lldb_register_index")
self.assertIsNotNone(reg_index)
# Handle thread suffix.
if thread_id:
- p_request = "read packet: $p{:x};thread:{:x}#00".format(reg_index, thread_id)
+ p_request = "read packet: $p{:x};thread:{:x}#00".format(
+ reg_index, thread_id)
else:
p_request = "read packet: $p{:x}#00".format(reg_index)
@@ -1168,8 +1341,8 @@ class GdbRemoteTestCaseBase(TestBase):
self.reset_test_sequence()
self.test_sequence.add_log_lines([
p_request,
- { "direction":"send", "regex":r"^\$([0-9a-fA-F]+)#", "capture":{1:"p_response"} },
- ], True)
+ {"direction": "send", "regex": r"^\$([0-9a-fA-F]+)#", "capture": {1: "p_response"}},
+ ], True)
context = self.expect_gdbremote_sequence()
self.assertIsNotNone(context)
@@ -1178,58 +1351,75 @@ class GdbRemoteTestCaseBase(TestBase):
self.assertIsNotNone(p_response)
self.assertTrue(len(p_response) > 0)
self.assertFalse(p_response[0] == "E")
-
- values[reg_index] = unpack_register_hex_unsigned(endian, p_response)
-
+
+ values[reg_index] = unpack_register_hex_unsigned(
+ endian, p_response)
+
return values
def add_vCont_query_packets(self):
- self.test_sequence.add_log_lines([
- "read packet: $vCont?#49",
- {"direction":"send", "regex":r"^\$(vCont)?(.*)#[0-9a-fA-F]{2}$", "capture":{2:"vCont_query_response" } },
- ], True)
+ self.test_sequence.add_log_lines(["read packet: $vCont?#49",
+ {"direction": "send",
+ "regex": r"^\$(vCont)?(.*)#[0-9a-fA-F]{2}$",
+ "capture": {2: "vCont_query_response"}},
+ ],
+ True)
def parse_vCont_query_response(self, context):
self.assertIsNotNone(context)
vCont_query_response = context.get("vCont_query_response")
- # Handle case of no vCont support at all - in which case the capture group will be none or zero length.
+ # Handle case of no vCont support at all - in which case the capture
+ # group will be none or zero length.
if not vCont_query_response or len(vCont_query_response) == 0:
return {}
- return {key:1 for key in vCont_query_response.split(";") if key and len(key) > 0}
-
- def count_single_steps_until_true(self, thread_id, predicate, args, max_step_count=100, use_Hc_packet=True, step_instruction="s"):
+ return {key: 1 for key in vCont_query_response.split(
+ ";") if key and len(key) > 0}
+
+ def count_single_steps_until_true(
+ self,
+ thread_id,
+ predicate,
+ args,
+ max_step_count=100,
+ use_Hc_packet=True,
+ step_instruction="s"):
"""Used by single step test that appears in a few different contexts."""
single_step_count = 0
while single_step_count < max_step_count:
self.assertIsNotNone(thread_id)
- # Build the packet for the single step instruction. We replace {thread}, if present, with the thread_id.
- step_packet = "read packet: ${}#00".format(re.sub(r"{thread}", "{:x}".format(thread_id), step_instruction))
+ # Build the packet for the single step instruction. We replace
+ # {thread}, if present, with the thread_id.
+ step_packet = "read packet: ${}#00".format(
+ re.sub(r"{thread}", "{:x}".format(thread_id), step_instruction))
# print("\nstep_packet created: {}\n".format(step_packet))
# Single step.
self.reset_test_sequence()
if use_Hc_packet:
self.test_sequence.add_log_lines(
- [# Set the continue thread.
- "read packet: $Hc{0:x}#00".format(thread_id),
- "send packet: $OK#00",
- ], True)
+ [ # Set the continue thread.
+ "read packet: $Hc{0:x}#00".format(thread_id),
+ "send packet: $OK#00",
+ ], True)
self.test_sequence.add_log_lines([
- # Single step.
- step_packet,
- # "read packet: $vCont;s:{0:x}#00".format(thread_id),
- # Expect a breakpoint stop report.
- {"direction":"send", "regex":r"^\$T([0-9a-fA-F]{2})thread:([0-9a-fA-F]+);", "capture":{1:"stop_signo", 2:"stop_thread_id"} },
- ], True)
+ # Single step.
+ step_packet,
+ # "read packet: $vCont;s:{0:x}#00".format(thread_id),
+ # Expect a breakpoint stop report.
+ {"direction": "send",
+ "regex": r"^\$T([0-9a-fA-F]{2})thread:([0-9a-fA-F]+);",
+ "capture": {1: "stop_signo",
+ 2: "stop_thread_id"}},
+ ], True)
context = self.expect_gdbremote_sequence()
self.assertIsNotNone(context)
self.assertIsNotNone(context.get("stop_signo"))
self.assertEqual(int(context.get("stop_signo"), 16),
- lldbutil.get_signal_number('SIGTRAP'))
+ lldbutil.get_signal_number('SIGTRAP'))
single_step_count += 1
@@ -1251,9 +1441,9 @@ class GdbRemoteTestCaseBase(TestBase):
self.reset_test_sequence()
self.test_sequence.add_log_lines(
["read packet: $m{0:x},{1:x}#00".format(g_c1_address, 1),
- {"direction":"send", "regex":r"^\$(.+)#[0-9a-fA-F]{2}$", "capture":{1:"g_c1_contents"} },
+ {"direction": "send", "regex": r"^\$(.+)#[0-9a-fA-F]{2}$", "capture": {1: "g_c1_contents"}},
"read packet: $m{0:x},{1:x}#00".format(g_c2_address, 1),
- {"direction":"send", "regex":r"^\$(.+)#[0-9a-fA-F]{2}$", "capture":{1:"g_c2_contents"} }],
+ {"direction": "send", "regex": r"^\$(.+)#[0-9a-fA-F]{2}$", "capture": {1: "g_c2_contents"}}],
True)
# Run the packet stream.
@@ -1264,26 +1454,34 @@ class GdbRemoteTestCaseBase(TestBase):
self.assertIsNotNone(context.get("g_c1_contents"))
self.assertIsNotNone(context.get("g_c2_contents"))
- return (context.get("g_c1_contents").decode("hex") == expected_g_c1) and (context.get("g_c2_contents").decode("hex") == expected_g_c2)
+ return (context.get("g_c1_contents").decode("hex") == expected_g_c1) and (
+ context.get("g_c2_contents").decode("hex") == expected_g_c2)
- def single_step_only_steps_one_instruction(self, use_Hc_packet=True, step_instruction="s"):
+ def single_step_only_steps_one_instruction(
+ self, use_Hc_packet=True, step_instruction="s"):
"""Used by single step test that appears in a few different contexts."""
# Start up the inferior.
procs = self.prep_debug_monitor_and_inferior(
- inferior_args=["get-code-address-hex:swap_chars", "get-data-address-hex:g_c1", "get-data-address-hex:g_c2", "sleep:1", "call-function:swap_chars", "sleep:5"])
+ inferior_args=[
+ "get-code-address-hex:swap_chars",
+ "get-data-address-hex:g_c1",
+ "get-data-address-hex:g_c2",
+ "sleep:1",
+ "call-function:swap_chars",
+ "sleep:5"])
# Run the process
self.test_sequence.add_log_lines(
- [# Start running after initial stop.
- "read packet: $c#63",
- # Match output line that prints the memory address of the function call entry point.
- # Note we require launch-only testing so we can get inferior otuput.
- { "type":"output_match", "regex":r"^code address: 0x([0-9a-fA-F]+)\r\ndata address: 0x([0-9a-fA-F]+)\r\ndata address: 0x([0-9a-fA-F]+)\r\n$",
- "capture":{ 1:"function_address", 2:"g_c1_address", 3:"g_c2_address"} },
- # Now stop the inferior.
- "read packet: {}".format(chr(3)),
- # And wait for the stop notification.
- {"direction":"send", "regex":r"^\$T([0-9a-fA-F]{2})thread:([0-9a-fA-F]+);", "capture":{1:"stop_signo", 2:"stop_thread_id"} }],
+ [ # Start running after initial stop.
+ "read packet: $c#63",
+ # Match output line that prints the memory address of the function call entry point.
+ # Note we require launch-only testing so we can get inferior otuput.
+ {"type": "output_match", "regex": r"^code address: 0x([0-9a-fA-F]+)\r\ndata address: 0x([0-9a-fA-F]+)\r\ndata address: 0x([0-9a-fA-F]+)\r\n$",
+ "capture": {1: "function_address", 2: "g_c1_address", 3: "g_c2_address"}},
+ # Now stop the inferior.
+ "read packet: {}".format(chr(3)),
+ # And wait for the stop notification.
+ {"direction": "send", "regex": r"^\$T([0-9a-fA-F]{2})thread:([0-9a-fA-F]+);", "capture": {1: "stop_signo", 2: "stop_thread_id"}}],
True)
# Run the packet stream.
@@ -1312,13 +1510,17 @@ class GdbRemoteTestCaseBase(TestBase):
else:
BREAKPOINT_KIND = 1
self.reset_test_sequence()
- self.add_set_breakpoint_packets(function_address, do_continue=True, breakpoint_kind=BREAKPOINT_KIND)
+ self.add_set_breakpoint_packets(
+ function_address,
+ do_continue=True,
+ breakpoint_kind=BREAKPOINT_KIND)
context = self.expect_gdbremote_sequence()
self.assertIsNotNone(context)
# Remove the breakpoint.
self.reset_test_sequence()
- self.add_remove_breakpoint_packets(function_address, breakpoint_kind=BREAKPOINT_KIND)
+ self.add_remove_breakpoint_packets(
+ function_address, breakpoint_kind=BREAKPOINT_KIND)
context = self.expect_gdbremote_sequence()
self.assertIsNotNone(context)
@@ -1331,42 +1533,83 @@ class GdbRemoteTestCaseBase(TestBase):
self.assertTrue(self.g_c1_c2_contents_are(args))
- # Verify we take only a small number of steps to hit the first state. Might need to work through function entry prologue code.
+ # Verify we take only a small number of steps to hit the first state.
+ # Might need to work through function entry prologue code.
args["expected_g_c1"] = "1"
args["expected_g_c2"] = "1"
- (state_reached, step_count) = self.count_single_steps_until_true(main_thread_id, self.g_c1_c2_contents_are, args, max_step_count=25, use_Hc_packet=use_Hc_packet, step_instruction=step_instruction)
+ (state_reached,
+ step_count) = self.count_single_steps_until_true(main_thread_id,
+ self.g_c1_c2_contents_are,
+ args,
+ max_step_count=25,
+ use_Hc_packet=use_Hc_packet,
+ step_instruction=step_instruction)
self.assertTrue(state_reached)
# Verify we hit the next state.
args["expected_g_c1"] = "1"
args["expected_g_c2"] = "0"
- (state_reached, step_count) = self.count_single_steps_until_true(main_thread_id, self.g_c1_c2_contents_are, args, max_step_count=5, use_Hc_packet=use_Hc_packet, step_instruction=step_instruction)
+ (state_reached,
+ step_count) = self.count_single_steps_until_true(main_thread_id,
+ self.g_c1_c2_contents_are,
+ args,
+ max_step_count=5,
+ use_Hc_packet=use_Hc_packet,
+ step_instruction=step_instruction)
self.assertTrue(state_reached)
expected_step_count = 1
arch = self.getArchitecture()
- #MIPS required "3" (ADDIU, SB, LD) machine instructions for updation of variable value
- if re.match("mips",arch):
- expected_step_count = 3
- #S390X requires "2" (LARL, MVI) machine instructions for updation of variable value
- if re.match("s390x",arch):
- expected_step_count = 2
+ # MIPS required "3" (ADDIU, SB, LD) machine instructions for updation
+ # of variable value
+ if re.match("mips", arch):
+ expected_step_count = 3
+ # S390X requires "2" (LARL, MVI) machine instructions for updation of
+ # variable value
+ if re.match("s390x", arch):
+ expected_step_count = 2
self.assertEqual(step_count, expected_step_count)
# Verify we hit the next state.
args["expected_g_c1"] = "0"
args["expected_g_c2"] = "0"
- (state_reached, step_count) = self.count_single_steps_until_true(main_thread_id, self.g_c1_c2_contents_are, args, max_step_count=5, use_Hc_packet=use_Hc_packet, step_instruction=step_instruction)
+ (state_reached,
+ step_count) = self.count_single_steps_until_true(main_thread_id,
+ self.g_c1_c2_contents_are,
+ args,
+ max_step_count=5,
+ use_Hc_packet=use_Hc_packet,
+ step_instruction=step_instruction)
self.assertTrue(state_reached)
self.assertEqual(step_count, expected_step_count)
# Verify we hit the next state.
args["expected_g_c1"] = "0"
args["expected_g_c2"] = "1"
- (state_reached, step_count) = self.count_single_steps_until_true(main_thread_id, self.g_c1_c2_contents_are, args, max_step_count=5, use_Hc_packet=use_Hc_packet, step_instruction=step_instruction)
+ (state_reached,
+ step_count) = self.count_single_steps_until_true(main_thread_id,
+ self.g_c1_c2_contents_are,
+ args,
+ max_step_count=5,
+ use_Hc_packet=use_Hc_packet,
+ step_instruction=step_instruction)
self.assertTrue(state_reached)
self.assertEqual(step_count, expected_step_count)
def maybe_strict_output_regex(self, regex):
- return '.*'+regex+'.*' if lldbplatformutil.hasChattyStderr(self) else '^'+regex+'$'
-
+ return '.*' + regex + \
+ '.*' if lldbplatformutil.hasChattyStderr(self) else '^' + regex + '$'
+
+ def install_and_create_launch_args(self):
+ exe_path = os.path.abspath('a.out')
+ if not lldb.remote_platform:
+ return [exe_path]
+ remote_path = lldbutil.append_to_process_working_directory(
+ os.path.basename(exe_path))
+ remote_file_spec = lldb.SBFileSpec(remote_path, False)
+ err = lldb.remote_platform.Install(lldb.SBFileSpec(exe_path, True),
+ remote_file_spec)
+ if err.Fail():
+ raise Exception("remote_platform.Install('%s', '%s') failed: %s" %
+ (exe_path, remote_path, err))
+ return [remote_path]
diff --git a/packages/Python/lldbsuite/test/tools/lldb-server/host-info/Makefile b/packages/Python/lldbsuite/test/tools/lldb-server/host-info/Makefile
new file mode 100644
index 000000000000..1370b53b5a67
--- /dev/null
+++ b/packages/Python/lldbsuite/test/tools/lldb-server/host-info/Makefile
@@ -0,0 +1,10 @@
+LEVEL = ../../../make
+
+VPATH = ..
+
+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/host-info/TestGdbRemoteHostInfo.py b/packages/Python/lldbsuite/test/tools/lldb-server/host-info/TestGdbRemoteHostInfo.py
new file mode 100644
index 000000000000..5089ee85773f
--- /dev/null
+++ b/packages/Python/lldbsuite/test/tools/lldb-server/host-info/TestGdbRemoteHostInfo.py
@@ -0,0 +1,126 @@
+from __future__ import print_function
+
+# lldb test suite imports
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import TestBase
+
+# gdb-remote-specific imports
+import lldbgdbserverutils
+from gdbremote_testcase import GdbRemoteTestCaseBase
+
+
+class TestGdbRemoteHostInfo(GdbRemoteTestCaseBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ KNOWN_HOST_INFO_KEYS = set([
+ "cputype",
+ "cpusubtype",
+ "distribution_id",
+ "endian",
+ "hostname",
+ "ostype",
+ "os_build",
+ "os_kernel",
+ "os_version",
+ "ptrsize",
+ "triple",
+ "vendor",
+ "watchpoint_exceptions_received",
+ "default_packet_timeout",
+ ])
+
+ DARWIN_REQUIRED_HOST_INFO_KEYS = set([
+ "cputype",
+ "cpusubtype",
+ "endian",
+ "ostype",
+ "ptrsize",
+ "vendor",
+ "watchpoint_exceptions_received"
+ ])
+
+ def add_host_info_collection_packets(self):
+ self.test_sequence.add_log_lines(
+ ["read packet: $qHostInfo#9b",
+ {"direction": "send", "regex": r"^\$(.+)#[0-9a-fA-F]{2}$",
+ "capture": {1: "host_info_raw"}}],
+ True)
+
+ def parse_host_info_response(self, context):
+ # Ensure we have a host info response.
+ self.assertIsNotNone(context)
+ host_info_raw = context.get("host_info_raw")
+ self.assertIsNotNone(host_info_raw)
+
+ # Pull out key:value; pairs.
+ host_info_dict = {match.group(1): match.group(2)
+ for match in re.finditer(r"([^:]+):([^;]+);",
+ host_info_raw)}
+
+ import pprint
+ print("\nqHostInfo response:")
+ pprint.pprint(host_info_dict)
+
+ # Validate keys are known.
+ for (key, val) in list(host_info_dict.items()):
+ self.assertTrue(key in self.KNOWN_HOST_INFO_KEYS,
+ "unknown qHostInfo key: " + key)
+ self.assertIsNotNone(val)
+
+ # Return the key:val pairs.
+ return host_info_dict
+
+ def get_qHostInfo_response(self):
+ # Launch the debug monitor stub, attaching to the inferior.
+ server = self.connect_to_debug_monitor()
+ self.assertIsNotNone(server)
+ self.add_no_ack_remote_stream()
+
+ # Request qHostInfo and get response
+ self.add_host_info_collection_packets()
+ context = self.expect_gdbremote_sequence()
+ self.assertIsNotNone(context)
+
+ # Parse qHostInfo response.
+ host_info = self.parse_host_info_response(context)
+ self.assertIsNotNone(host_info)
+ self.assertGreater(len(host_info), 0, "qHostInfo should have returned "
+ "at least one key:val pair.")
+ return host_info
+
+ def validate_darwin_minimum_host_info_keys(self, host_info_dict):
+ self.assertIsNotNone(host_info_dict)
+ missing_keys = [key for key in self.DARWIN_REQUIRED_HOST_INFO_KEYS
+ if key not in host_info_dict]
+ self.assertEquals(0, len(missing_keys),
+ "qHostInfo is missing the following required "
+ "keys: " + str(missing_keys))
+
+ @debugserver_test
+ def test_qHostInfo_returns_at_least_one_key_val_pair_debugserver(self):
+ self.init_debugserver_test()
+ self.build()
+ self.get_qHostInfo_response()
+
+ @llgs_test
+ def test_qHostInfo_returns_at_least_one_key_val_pair_llgs(self):
+ self.init_llgs_test()
+ self.build()
+ self.get_qHostInfo_response()
+
+ @skipUnlessDarwin
+ @debugserver_test
+ def test_qHostInfo_contains_darwin_required_keys_debugserver(self):
+ self.init_debugserver_test()
+ self.build()
+ host_info_dict = self.get_qHostInfo_response()
+ self.validate_darwin_minimum_host_info_keys(host_info_dict)
+
+ @skipUnlessDarwin
+ @llgs_test
+ def test_qHostInfo_contains_darwin_required_keys_llgs(self):
+ self.init_llgs_test()
+ self.build()
+ host_info_dict = self.get_qHostInfo_response()
+ self.validate_darwin_minimum_host_info_keys(host_info_dict)
diff --git a/packages/Python/lldbsuite/test/tools/lldb-server/inferior-crash/TestGdbRemoteAbort.py b/packages/Python/lldbsuite/test/tools/lldb-server/inferior-crash/TestGdbRemoteAbort.py
index 8bd00a3f1b21..b417b3292e75 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-server/inferior-crash/TestGdbRemoteAbort.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-server/inferior-crash/TestGdbRemoteAbort.py
@@ -1,13 +1,13 @@
from __future__ import print_function
-
import gdbremote_testcase
import signal
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
+
class TestGdbRemoteAbort(gdbremote_testcase.GdbRemoteTestCaseBase):
mydir = TestBase.compute_mydir(__file__)
@@ -15,10 +15,12 @@ class TestGdbRemoteAbort(gdbremote_testcase.GdbRemoteTestCaseBase):
procs = self.prep_debug_monitor_and_inferior(inferior_args=["abort"])
self.assertIsNotNone(procs)
- self.test_sequence.add_log_lines([
- "read packet: $vCont;c#a8",
- {"direction":"send", "regex":r"^\$T([0-9a-fA-F]{2}).*#[0-9a-fA-F]{2}$", "capture":{ 1:"hex_exit_code"} },
- ], True)
+ self.test_sequence.add_log_lines(["read packet: $vCont;c#a8",
+ {"direction": "send",
+ "regex": r"^\$T([0-9a-fA-F]{2}).*#[0-9a-fA-F]{2}$",
+ "capture": {1: "hex_exit_code"}},
+ ],
+ True)
context = self.expect_gdbremote_sequence()
self.assertIsNotNone(context)
@@ -26,7 +28,7 @@ class TestGdbRemoteAbort(gdbremote_testcase.GdbRemoteTestCaseBase):
hex_exit_code = context.get("hex_exit_code")
self.assertIsNotNone(hex_exit_code)
self.assertEqual(int(hex_exit_code, 16),
- lldbutil.get_signal_number('SIGABRT'))
+ lldbutil.get_signal_number('SIGABRT'))
@debugserver_test
def test_inferior_abort_received_debugserver(self):
@@ -41,4 +43,3 @@ class TestGdbRemoteAbort(gdbremote_testcase.GdbRemoteTestCaseBase):
self.init_llgs_test()
self.build()
self.inferior_abort_received()
-
diff --git a/packages/Python/lldbsuite/test/tools/lldb-server/inferior-crash/TestGdbRemoteSegFault.py b/packages/Python/lldbsuite/test/tools/lldb-server/inferior-crash/TestGdbRemoteSegFault.py
index 949b00b0f614..5bbca3c146d1 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-server/inferior-crash/TestGdbRemoteSegFault.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-server/inferior-crash/TestGdbRemoteSegFault.py
@@ -1,26 +1,29 @@
from __future__ import print_function
-
import gdbremote_testcase
import signal
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
+
class TestGdbRemoteSegFault(gdbremote_testcase.GdbRemoteTestCaseBase):
mydir = TestBase.compute_mydir(__file__)
GDB_REMOTE_STOP_CODE_BAD_ACCESS = 0x91
def inferior_seg_fault_received(self, expected_signo):
- procs = self.prep_debug_monitor_and_inferior(inferior_args=["segfault"])
+ procs = self.prep_debug_monitor_and_inferior(
+ inferior_args=["segfault"])
self.assertIsNotNone(procs)
- self.test_sequence.add_log_lines([
- "read packet: $vCont;c#a8",
- {"direction":"send", "regex":r"^\$T([0-9a-fA-F]{2}).*#[0-9a-fA-F]{2}$", "capture":{ 1:"hex_exit_code"} },
- ], True)
+ self.test_sequence.add_log_lines(["read packet: $vCont;c#a8",
+ {"direction": "send",
+ "regex": r"^\$T([0-9a-fA-F]{2}).*#[0-9a-fA-F]{2}$",
+ "capture": {1: "hex_exit_code"}},
+ ],
+ True)
context = self.expect_gdbremote_sequence()
self.assertIsNotNone(context)
diff --git a/packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py b/packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py
index 0c73bed9ea0a..c89cd301899a 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py
@@ -4,7 +4,6 @@
from __future__ import print_function
-
import os
import os.path
import platform
@@ -17,6 +16,7 @@ from lldbsuite.test.lldbtest import *
from six.moves import queue
+
def _get_debug_monitor_from_lldb(lldb_exe, debug_monitor_basename):
"""Return the debug monitor exe path given the lldb exe path.
@@ -55,7 +55,10 @@ def _get_debug_monitor_from_lldb(lldb_exe, debug_monitor_basename):
if os.path.exists(debug_monitor_exe):
return debug_monitor_exe
- new_base = regex.sub( 'LLDB.framework/Versions/A/Resources/' + debug_monitor_basename, exe_base)
+ new_base = regex.sub(
+ 'LLDB.framework/Versions/A/Resources/' +
+ debug_monitor_basename,
+ exe_base)
debug_monitor_exe = os.path.join(exe_dir, new_base)
if os.path.exists(debug_monitor_exe):
return debug_monitor_exe
@@ -73,7 +76,9 @@ def get_lldb_server_exe():
if "LLDB_DEBUGSERVER_PATH" in os.environ:
return os.environ["LLDB_DEBUGSERVER_PATH"]
- return _get_debug_monitor_from_lldb(lldbtest_config.lldbExec, "lldb-server")
+ return _get_debug_monitor_from_lldb(
+ lldbtest_config.lldbExec, "lldb-server")
+
def get_debugserver_exe():
"""Return the debugserver exe path.
@@ -85,10 +90,11 @@ def get_debugserver_exe():
if "LLDB_DEBUGSERVER_PATH" in os.environ:
return os.environ["LLDB_DEBUGSERVER_PATH"]
- return _get_debug_monitor_from_lldb(lldbtest_config.lldbExec, "debugserver")
+ return _get_debug_monitor_from_lldb(
+ lldbtest_config.lldbExec, "debugserver")
_LOG_LINE_REGEX = re.compile(r'^(lldb-server|debugserver)\s+<\s*(\d+)>' +
- '\s+(read|send)\s+packet:\s+(.+)$')
+ '\s+(read|send)\s+packet:\s+(.+)$')
def _is_packet_lldb_gdbserver_input(packet_type, llgs_input_is_read):
@@ -131,10 +137,12 @@ def handle_O_packet(context, packet_contents, logger):
new_text = gdbremote_hex_decode_string(packet_contents[1:])
context["O_content"] += new_text
context["O_count"] += 1
-
+
if logger:
- logger.debug("text: new \"{}\", cumulative: \"{}\"".format(new_text, context["O_content"]))
-
+ logger.debug(
+ "text: new \"{}\", cumulative: \"{}\"".format(
+ new_text, context["O_content"]))
+
return True
_STRIP_CHECKSUM_REGEX = re.compile(r'#[0-9a-fA-F]{2}$')
@@ -150,13 +158,14 @@ def assert_packets_equal(asserter, actual_packet, expected_packet):
expected_stripped = _STRIP_CHECKSUM_REGEX.sub('', expected_packet)
asserter.assertEqual(actual_stripped, expected_stripped)
+
def expect_lldb_gdbserver_replay(
- asserter,
- sock,
- test_sequence,
- pump_queues,
- timeout_seconds,
- logger=None):
+ asserter,
+ sock,
+ test_sequence,
+ pump_queues,
+ timeout_seconds,
+ logger=None):
"""Replay socket communication with lldb-gdbserver and verify responses.
Args:
@@ -188,16 +197,16 @@ def expect_lldb_gdbserver_replay(
context["O_count"] will contain an integer of the number of
O packets received.
"""
-
+
# Ensure we have some work to do.
if len(test_sequence.entries) < 1:
return {}
- context = {"O_count":0, "O_content":""}
+ context = {"O_count": 0, "O_content": ""}
with socket_packet_pump.SocketPacketPump(sock, pump_queues, logger) as pump:
# Grab the first sequence entry.
sequence_entry = test_sequence.entries.pop(0)
-
+
# While we have an active sequence entry, send messages
# destined for the stub and collect/match/process responses
# expected from the stub.
@@ -210,10 +219,12 @@ def expect_lldb_gdbserver_replay(
packet_desc = "^C"
else:
packet_desc = send_packet
- logger.info("sending packet to remote: {}".format(packet_desc))
+ logger.info(
+ "sending packet to remote: {}".format(packet_desc))
sock.sendall(send_packet)
else:
- # This is an entry expecting to receive content from the remote debug monitor.
+ # This is an entry expecting to receive content from the remote
+ # debug monitor.
# We'll pull from (and wait on) the queue appropriate for the type of matcher.
# We keep separate queues for process output (coming from non-deterministic
@@ -224,51 +235,65 @@ def expect_lldb_gdbserver_replay(
content = pump_queues.output_queue().get(True, timeout_seconds)
except queue.Empty:
if logger:
- logger.warning("timeout waiting for stub output (accumulated output:{})".format(pump.get_accumulated_output()))
- raise Exception("timed out while waiting for output match (accumulated output: {})".format(pump.get_accumulated_output()))
+ logger.warning(
+ "timeout waiting for stub output (accumulated output:{})".format(
+ pump.get_accumulated_output()))
+ raise Exception(
+ "timed out while waiting for output match (accumulated output: {})".format(
+ pump.get_accumulated_output()))
else:
try:
content = pump_queues.packet_queue().get(True, timeout_seconds)
except queue.Empty:
if logger:
- logger.warning("timeout waiting for packet match (receive buffer: {})".format(pump.get_receive_buffer()))
- raise Exception("timed out while waiting for packet match (receive buffer: {})".format(pump.get_receive_buffer()))
-
+ logger.warning(
+ "timeout waiting for packet match (receive buffer: {})".format(
+ pump.get_receive_buffer()))
+ raise Exception(
+ "timed out while waiting for packet match (receive buffer: {})".format(
+ pump.get_receive_buffer()))
+
# Give the sequence entry the opportunity to match the content.
# Output matchers might match or pass after more output accumulates.
# Other packet types generally must match.
asserter.assertIsNotNone(content)
- context = sequence_entry.assert_match(asserter, content, context=context)
+ context = sequence_entry.assert_match(
+ asserter, content, context=context)
# Move on to next sequence entry as needed. Some sequence entries support executing multiple
- # times in different states (for looping over query/response packets).
+ # times in different states (for looping over query/response
+ # packets).
if sequence_entry.is_consumed():
if len(test_sequence.entries) > 0:
sequence_entry = test_sequence.entries.pop(0)
else:
sequence_entry = None
-
+
# Fill in the O_content entries.
context["O_count"] = 1
context["O_content"] = pump.get_accumulated_output()
-
+
return context
+
def gdbremote_hex_encode_string(str):
output = ''
for c in str:
output += '{0:02x}'.format(ord(c))
return output
+
def gdbremote_hex_decode_string(str):
return str.decode("hex")
+
def gdbremote_packet_encode_string(str):
checksum = 0
for c in str:
checksum += ord(c)
return '$' + str + '#{0:02x}'.format(checksum % 256)
+
def build_gdbremote_A_packet(args_list):
"""Given a list of args, create a properly-formed $A packet containing each arg.
"""
@@ -322,7 +347,9 @@ def parse_threadinfo_response(response_packet):
response_packet = _STRIP_CHECKSUM_REGEX.sub("", response_packet)
# Return list of thread ids
- return [int(thread_id_hex,16) for thread_id_hex in response_packet.split(",") if len(thread_id_hex) > 0]
+ return [int(thread_id_hex, 16) for thread_id_hex in response_packet.split(
+ ",") if len(thread_id_hex) > 0]
+
def unpack_endian_binary_string(endian, value_string):
"""Unpack a gdb-remote binary (post-unescaped, i.e. not escaped) response to an unsigned int given endianness of the inferior."""
@@ -349,6 +376,7 @@ def unpack_endian_binary_string(endian, value_string):
# pdp is valid but need to add parse code once needed.
raise Exception("unsupported endian:{}".format(endian))
+
def unpack_register_hex_unsigned(endian, value_string):
"""Unpack a gdb-remote $p-style response to an unsigned int given endianness of inferior."""
if not endian:
@@ -370,6 +398,7 @@ def unpack_register_hex_unsigned(endian, value_string):
# pdp is valid but need to add parse code once needed.
raise Exception("unsupported endian:{}".format(endian))
+
def pack_register_hex(endian, value, byte_size=None):
"""Unpack a gdb-remote $p-style response to an unsigned int given endianness of inferior."""
if not endian:
@@ -383,7 +412,7 @@ def pack_register_hex(endian, value, byte_size=None):
value = value >> 8
if byte_size:
# Add zero-fill to the right/end (MSB side) of the value.
- retval += "00" * (byte_size - len(retval)/2)
+ retval += "00" * (byte_size - len(retval) / 2)
return retval
elif endian == 'big':
@@ -393,20 +422,29 @@ def pack_register_hex(endian, value, byte_size=None):
value = value >> 8
if byte_size:
# Add zero-fill to the left/front (MSB side) of the value.
- retval = ("00" * (byte_size - len(retval)/2)) + retval
+ retval = ("00" * (byte_size - len(retval) / 2)) + retval
return retval
else:
# pdp is valid but need to add parse code once needed.
raise Exception("unsupported endian:{}".format(endian))
+
class GdbRemoteEntryBase(object):
+
def is_output_matcher(self):
return False
+
class GdbRemoteEntry(GdbRemoteEntryBase):
- def __init__(self, is_send_to_remote=True, exact_payload=None, regex=None, capture=None, expect_captures=None):
+ def __init__(
+ self,
+ is_send_to_remote=True,
+ exact_payload=None,
+ regex=None,
+ capture=None,
+ expect_captures=None):
"""Create an entry representing one piece of the I/O to/from a gdb remote debug monitor.
Args:
@@ -469,9 +507,11 @@ class GdbRemoteEntry(GdbRemoteEntryBase):
def get_send_packet(self):
if not self.is_send_to_remote():
- raise Exception("get_send_packet() called on GdbRemoteEntry that is not a send-to-remote packet")
+ raise Exception(
+ "get_send_packet() called on GdbRemoteEntry that is not a send-to-remote packet")
if not self.exact_payload:
- raise Exception("get_send_packet() called on GdbRemoteEntry but it doesn't have an exact payload")
+ raise Exception(
+ "get_send_packet() called on GdbRemoteEntry but it doesn't have an exact payload")
return self.exact_payload
def _assert_exact_payload_match(self, asserter, actual_packet):
@@ -482,14 +522,17 @@ class GdbRemoteEntry(GdbRemoteEntryBase):
# Ensure the actual packet matches from the start of the actual packet.
match = self.regex.match(actual_packet)
if not match:
- asserter.fail("regex '{}' failed to match against content '{}'".format(self.regex.pattern, actual_packet))
+ asserter.fail(
+ "regex '{}' failed to match against content '{}'".format(
+ self.regex.pattern, actual_packet))
if self.capture:
# Handle captures.
for group_index, var_name in list(self.capture.items()):
capture_text = match.group(group_index)
# It is okay for capture text to be None - which it will be if it is a group that can match nothing.
- # The user must be okay with it since the regex itself matched above.
+ # The user must be okay with it since the regex itself matched
+ # above.
context[var_name] = capture_text
if self.expect_captures:
@@ -497,7 +540,8 @@ class GdbRemoteEntry(GdbRemoteEntryBase):
for group_index, var_name in list(self.expect_captures.items()):
capture_text = match.group(group_index)
if not capture_text:
- raise Exception("No content to expect for group index {}".format(group_index))
+ raise Exception(
+ "No content to expect for group index {}".format(group_index))
asserter.assertEqual(capture_text, context[var_name])
return context
@@ -506,7 +550,8 @@ class GdbRemoteEntry(GdbRemoteEntryBase):
# This only makes sense for matching lines coming from the
# remote debug monitor.
if self.is_send_to_remote():
- raise Exception("Attempted to match a packet being sent to the remote debug monitor, doesn't make sense.")
+ raise Exception(
+ "Attempted to match a packet being sent to the remote debug monitor, doesn't make sense.")
# Create a new context if needed.
if not context:
@@ -521,16 +566,18 @@ class GdbRemoteEntry(GdbRemoteEntryBase):
elif self.regex:
return self._assert_regex_match(asserter, actual_packet, context)
else:
- raise Exception("Don't know how to match a remote-sent packet when exact_payload isn't specified.")
+ raise Exception(
+ "Don't know how to match a remote-sent packet when exact_payload isn't specified.")
+
class MultiResponseGdbRemoteEntry(GdbRemoteEntryBase):
"""Represents a query/response style packet.
-
+
Assumes the first item is sent to the gdb remote.
An end sequence regex indicates the end of the query/response
packet sequence. All responses up through (but not including) the
end response are stored in a context variable.
-
+
Settings accepted from params:
next_query or query: required. The typical query packet without the $ prefix or #xx suffix.
@@ -557,17 +604,20 @@ class MultiResponseGdbRemoteEntry(GdbRemoteEntryBase):
assume there is something wrong with either the response collection or the ending
detection regex and throw an exception.
"""
+
def __init__(self, params):
self._next_query = params.get("next_query", params.get("query"))
if not self._next_query:
raise "either next_query or query key must be specified for MultiResponseGdbRemoteEntry"
-
+
self._first_query = params.get("first_query", self._next_query)
- self._append_iteration_suffix = params.get("append_iteration_suffix", False)
+ self._append_iteration_suffix = params.get(
+ "append_iteration_suffix", False)
self._iteration = 0
self._end_regex = params["end_regex"]
self._save_key = params["save_key"]
- self._runaway_response_count = params.get("runaway_response_count", 10000)
+ self._runaway_response_count = params.get(
+ "runaway_response_count", 10000)
self._is_send_to_remote = True
self._end_matched = False
@@ -576,9 +626,11 @@ class MultiResponseGdbRemoteEntry(GdbRemoteEntryBase):
def get_send_packet(self):
if not self.is_send_to_remote():
- raise Exception("get_send_packet() called on MultiResponseGdbRemoteEntry that is not in the send state")
+ raise Exception(
+ "get_send_packet() called on MultiResponseGdbRemoteEntry that is not in the send state")
if self._end_matched:
- raise Exception("get_send_packet() called on MultiResponseGdbRemoteEntry but end of query/response sequence has already been seen.")
+ raise Exception(
+ "get_send_packet() called on MultiResponseGdbRemoteEntry but end of query/response sequence has already been seen.")
# Choose the first or next query for the base payload.
if self._iteration == 0 and self._first_query:
@@ -593,7 +645,8 @@ class MultiResponseGdbRemoteEntry(GdbRemoteEntryBase):
# Keep track of the iteration.
self._iteration += 1
- # Now that we've given the query packet, flip the mode to receive/match.
+ # Now that we've given the query packet, flip the mode to
+ # receive/match.
self._is_send_to_remote = False
# Return the result, converted to packet form.
@@ -603,12 +656,15 @@ class MultiResponseGdbRemoteEntry(GdbRemoteEntryBase):
return self._end_matched
def assert_match(self, asserter, actual_packet, context=None):
- # This only makes sense for matching lines coming from the remote debug monitor.
+ # This only makes sense for matching lines coming from the remote debug
+ # monitor.
if self.is_send_to_remote():
- raise Exception("assert_match() called on MultiResponseGdbRemoteEntry but state is set to send a query packet.")
+ raise Exception(
+ "assert_match() called on MultiResponseGdbRemoteEntry but state is set to send a query packet.")
if self._end_matched:
- raise Exception("assert_match() called on MultiResponseGdbRemoteEntry but end of query/response sequence has already been seen.")
+ raise Exception(
+ "assert_match() called on MultiResponseGdbRemoteEntry but end of query/response sequence has already been seen.")
# Set up a context as needed.
if not context:
@@ -627,21 +683,27 @@ class MultiResponseGdbRemoteEntry(GdbRemoteEntryBase):
# Check for a runaway response cycle.
if len(context[self._save_key]) >= self._runaway_response_count:
- raise Exception("runaway query/response cycle detected: %d responses captured so far. Last response: %s" %
- (len(context[self._save_key]), context[self._save_key][-1]))
+ raise Exception(
+ "runaway query/response cycle detected: %d responses captured so far. Last response: %s" %
+ (len(
+ context[
+ self._save_key]), context[
+ self._save_key][
+ -1]))
# Flip the mode to send for generating the query.
self._is_send_to_remote = True
return context
+
class MatchRemoteOutputEntry(GdbRemoteEntryBase):
"""Waits for output from the debug monitor to match a regex or time out.
-
+
This entry type tries to match each time new gdb remote output is accumulated
using a provided regex. If the output does not match the regex within the
given timeframe, the command fails the playback session. If the regex does
match, any capture fields are recorded in the context.
-
+
Settings accepted from params:
regex: required. Specifies a compiled regex object that must either succeed
@@ -653,7 +715,7 @@ class MatchRemoteOutputEntry(GdbRemoteEntryBase):
must match starting somewhere within the output text accumulated thus far.
Default: "match" (i.e. the regex must match the entirety of the accumulated output
buffer, so unexpected text will generally fail the match).
-
+
capture: optional. If specified, is a dictionary of regex match group indices (should start
with 1) to variable names that will store the capture group indicated by the
index. For example, {1:"thread_id"} will store capture group 1's content in the
@@ -661,6 +723,7 @@ class MatchRemoteOutputEntry(GdbRemoteEntryBase):
the value. The value stored off can be used later in a expect_captures expression.
This arg only makes sense when regex is specified.
"""
+
def __init__(self, regex=None, regex_mode="match", capture=None):
self._regex = regex
self._regex_mode = regex_mode
@@ -671,7 +734,9 @@ class MatchRemoteOutputEntry(GdbRemoteEntryBase):
raise Exception("regex cannot be None")
if not self._regex_mode in ["match", "search"]:
- raise Exception("unsupported regex mode \"{}\": must be \"match\" or \"search\"".format(self._regex_mode))
+ raise Exception(
+ "unsupported regex mode \"{}\": must be \"match\" or \"search\"".format(
+ self._regex_mode))
def is_output_matcher(self):
return True
@@ -692,7 +757,8 @@ class MatchRemoteOutputEntry(GdbRemoteEntryBase):
# Validate that we haven't already matched.
if self._matched:
- raise Exception("invalid state - already matched, attempting to match again")
+ raise Exception(
+ "invalid state - already matched, attempting to match again")
# If we don't have any content yet, we don't match.
if len(accumulated_output) < 1:
@@ -704,9 +770,12 @@ class MatchRemoteOutputEntry(GdbRemoteEntryBase):
elif self._regex_mode == "search":
match = self._regex.search(accumulated_output)
else:
- raise Exception("Unexpected regex mode: {}".format(self._regex_mode))
+ raise Exception(
+ "Unexpected regex mode: {}".format(
+ self._regex_mode))
- # If we don't match, wait to try again after next $O content, or time out.
+ # If we don't match, wait to try again after next $O content, or time
+ # out.
if not match:
# print("re pattern \"{}\" did not match against \"{}\"".format(self._regex.pattern, accumulated_output))
return context
@@ -721,7 +790,8 @@ class MatchRemoteOutputEntry(GdbRemoteEntryBase):
for group_index, var_name in list(self._capture.items()):
capture_text = match.group(group_index)
if not capture_text:
- raise Exception("No content for group index {}".format(group_index))
+ raise Exception(
+ "No content for group index {}".format(group_index))
context[var_name] = capture_text
return context
@@ -737,7 +807,7 @@ class GdbRemoteTestSequence(object):
def add_log_lines(self, log_lines, remote_input_is_read):
for line in log_lines:
- if type(line) == str:
+ if isinstance(line, str):
# Handle log line import
# if self.logger:
# self.logger.debug("processing log line: {}".format(line))
@@ -745,19 +815,27 @@ class GdbRemoteTestSequence(object):
if match:
playback_packet = match.group(2)
direction = match.group(1)
- if _is_packet_lldb_gdbserver_input(direction, remote_input_is_read):
+ if _is_packet_lldb_gdbserver_input(
+ direction, remote_input_is_read):
# Handle as something to send to the remote debug monitor.
# if self.logger:
# self.logger.info("processed packet to send to remote: {}".format(playback_packet))
- self.entries.append(GdbRemoteEntry(is_send_to_remote=True, exact_payload=playback_packet))
+ self.entries.append(
+ GdbRemoteEntry(
+ is_send_to_remote=True,
+ exact_payload=playback_packet))
else:
# Log line represents content to be expected from the remote debug monitor.
# if self.logger:
# self.logger.info("receiving packet from llgs, should match: {}".format(playback_packet))
- self.entries.append(GdbRemoteEntry(is_send_to_remote=False,exact_payload=playback_packet))
+ self.entries.append(
+ GdbRemoteEntry(
+ is_send_to_remote=False,
+ exact_payload=playback_packet))
else:
- raise Exception("failed to interpret log line: {}".format(line))
- elif type(line) == dict:
+ raise Exception(
+ "failed to interpret log line: {}".format(line))
+ elif isinstance(line, dict):
entry_type = line.get("type", "regex_capture")
if entry_type == "regex_capture":
# Handle more explicit control over details via dictionary.
@@ -767,34 +845,50 @@ class GdbRemoteTestSequence(object):
expect_captures = line.get("expect_captures", None)
# Compile the regex.
- if regex and (type(regex) == str):
+ if regex and (isinstance(regex, str)):
regex = re.compile(regex)
- if _is_packet_lldb_gdbserver_input(direction, remote_input_is_read):
+ if _is_packet_lldb_gdbserver_input(
+ direction, remote_input_is_read):
# Handle as something to send to the remote debug monitor.
# if self.logger:
# self.logger.info("processed dict sequence to send to remote")
- self.entries.append(GdbRemoteEntry(is_send_to_remote=True, regex=regex, capture=capture, expect_captures=expect_captures))
+ self.entries.append(
+ GdbRemoteEntry(
+ is_send_to_remote=True,
+ regex=regex,
+ capture=capture,
+ expect_captures=expect_captures))
else:
# Log line represents content to be expected from the remote debug monitor.
# if self.logger:
# self.logger.info("processed dict sequence to match receiving from remote")
- self.entries.append(GdbRemoteEntry(is_send_to_remote=False, regex=regex, capture=capture, expect_captures=expect_captures))
+ self.entries.append(
+ GdbRemoteEntry(
+ is_send_to_remote=False,
+ regex=regex,
+ capture=capture,
+ expect_captures=expect_captures))
elif entry_type == "multi_response":
self.entries.append(MultiResponseGdbRemoteEntry(line))
elif entry_type == "output_match":
regex = line.get("regex", None)
# Compile the regex.
- if regex and (type(regex) == str):
+ if regex and (isinstance(regex, str)):
regex = re.compile(regex, re.DOTALL)
regex_mode = line.get("regex_mode", "match")
capture = line.get("capture", None)
- self.entries.append(MatchRemoteOutputEntry(regex=regex, regex_mode=regex_mode, capture=capture))
+ self.entries.append(
+ MatchRemoteOutputEntry(
+ regex=regex,
+ regex_mode=regex_mode,
+ capture=capture))
else:
raise Exception("unknown entry type \"%s\"" % entry_type)
+
def process_is_running(pid, unknown_value=True):
"""If possible, validate that the given pid represents a running process on the local system.
@@ -814,7 +908,9 @@ def process_is_running(pid, unknown_value=True):
return the value provided by the unknown_value arg.
"""
if not isinstance(pid, six.integer_types):
- raise Exception("pid must be an integral type (actual type: %s)" % str(type(pid)))
+ raise Exception(
+ "pid must be an integral type (actual type: %s)" % str(
+ type(pid)))
process_ids = []
@@ -824,10 +920,12 @@ def process_is_running(pid, unknown_value=True):
return unknown_value
elif platform.system() in ['Darwin', 'Linux', 'FreeBSD', 'NetBSD']:
# Build the list of running process ids
- output = subprocess.check_output("ps ax | awk '{ print $1; }'", shell=True)
+ output = subprocess.check_output(
+ "ps ax | awk '{ print $1; }'", shell=True)
text_process_ids = output.split('\n')[1:]
# Convert text pids to ints
- process_ids = [int(text_pid) for text_pid in text_process_ids if text_pid != '']
+ process_ids = [int(text_pid)
+ for text_pid in text_process_ids if text_pid != '']
# elif {your_platform_here}:
# fill in process_ids as a list of int type process IDs running on
# the local system.
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 5c28d288db53..7e4190b7fe95 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
@@ -7,6 +7,7 @@ from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
+
class TestPlatformProcessConnect(gdbremote_testcase.GdbRemoteTestCaseBase):
mydir = TestBase.compute_mydir(__file__)
@@ -19,10 +20,16 @@ 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")))
+ err = lldb.remote_platform.Put(
+ lldb.SBFileSpec(
+ os.path.join(
+ os.getcwd(), "a.out")), lldb.SBFileSpec(
+ os.path.join(
+ working_dir, "a.out")))
if err.Fail():
- raise RuntimeError("Unable copy '%s' to '%s'.\n>>> %s" % (f, wd, err.GetCString()))
+ raise RuntimeError(
+ "Unable copy '%s' to '%s'.\n>>> %s" %
+ (f, wd, err.GetCString()))
m = re.search("^(.*)://([^:/]*)", configuration.lldb_platform_url)
protocol = m.group(1)
@@ -30,19 +37,34 @@ 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())))
+ listen_url = "%s://%s" % (p.group(1),
+ os.path.join(working_dir,
+ "platform-%d.sock" % int(time.time())))
else:
listen_url = "*:0"
port_file = "%s/port" % working_dir
- commandline_args = ["platform", "--listen", listen_url, "--socket-file", port_file, "--", "%s/a.out" % working_dir, "foo"]
- self.spawnSubprocess(self.debug_monitor_exe, commandline_args, install_remote=False)
+ commandline_args = [
+ "platform",
+ "--listen",
+ listen_url,
+ "--socket-file",
+ port_file,
+ "--",
+ "%s/a.out" %
+ working_dir,
+ "foo"]
+ self.spawnSubprocess(
+ self.debug_monitor_exe,
+ commandline_args,
+ install_remote=False)
self.addTearDownHook(self.cleanupSubprocesses)
socket_id = lldbutil.wait_for_file_on_target(self, port_file)
new_debugger = lldb.SBDebugger.Create()
new_debugger.SetAsync(False)
+
def del_debugger(new_debugger=new_debugger):
del new_debugger
self.addTearDownHook(del_debugger)
@@ -59,7 +81,10 @@ class TestPlatformProcessConnect(gdbremote_testcase.GdbRemoteTestCaseBase):
command = "platform connect %s" % (connect_url)
result = lldb.SBCommandReturnObject()
new_interpreter.HandleCommand(command, result)
- self.assertTrue(result.Succeeded(), "platform process connect failed: %s" % result.GetOutput())
+ self.assertTrue(
+ result.Succeeded(),
+ "platform process connect failed: %s" %
+ result.GetOutput())
target = new_debugger.GetSelectedTarget()
process = target.GetProcess()
diff --git a/packages/Python/lldbsuite/test/tools/lldb-server/socket_packet_pump.py b/packages/Python/lldbsuite/test/tools/lldb-server/socket_packet_pump.py
index 9f594b7df73c..6f32dcacd353 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-server/socket_packet_pump.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-server/socket_packet_pump.py
@@ -2,7 +2,6 @@
from __future__ import print_function
-
import re
import select
import threading
@@ -11,6 +10,7 @@ import codecs
from six.moves import queue
+
def _handle_output_packet_string(packet_contents):
if (not packet_contents) or (len(packet_contents) < 1):
return None
@@ -21,12 +21,15 @@ def _handle_output_packet_string(packet_contents):
else:
return packet_contents[1:].decode("hex")
+
def _dump_queue(the_queue):
while not the_queue.empty():
print(codecs.encode(the_queue.get(True), "string_escape"))
print("\n")
+
class PumpQueues(object):
+
def __init__(self):
self._output_queue = queue.Queue()
self._packet_queue = queue.Queue()
@@ -179,7 +182,8 @@ class SocketPacketPump(object):
# Likely a closed socket. Done with the pump thread.
if self._logger:
self._logger.debug(
- "socket read failed, stopping pump read thread\n" + traceback.format_exc(3))
+ "socket read failed, stopping pump read thread\n" +
+ traceback.format_exc(3))
break
self._process_new_bytes(new_bytes)
diff --git a/packages/Python/lldbsuite/test/tools/lldb-server/test/test_lldbgdbserverutils.py b/packages/Python/lldbsuite/test/tools/lldb-server/test/test_lldbgdbserverutils.py
index 8b3b6b68cf02..dc52f244aa4a 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-server/test/test_lldbgdbserverutils.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-server/test/test_lldbgdbserverutils.py
@@ -1,7 +1,6 @@
from __future__ import print_function
-
import unittest2
import os.path
import re
@@ -11,6 +10,7 @@ from lldbgdbserverutils import *
class TestLldbGdbServerUtils(unittest2.TestCase):
+
def test_entry_exact_payload_match(self):
entry = GdbRemoteEntry(is_send_to_remote=False, exact_payload="$OK#9a")
entry.assert_match(self, "$OK#9a")
@@ -25,22 +25,38 @@ class TestLldbGdbServerUtils(unittest2.TestCase):
self.assertIsNotNone(context)
def test_entry_regex_matches(self):
- entry = GdbRemoteEntry(is_send_to_remote=False, regex=re.compile(r"^\$QC([0-9a-fA-F]+)#"), capture={ 1:"thread_id" })
+ entry = GdbRemoteEntry(
+ is_send_to_remote=False,
+ regex=re.compile(r"^\$QC([0-9a-fA-F]+)#"),
+ capture={
+ 1: "thread_id"})
context = entry.assert_match(self, "$QC980#00")
def test_entry_regex_saves_match(self):
- entry = GdbRemoteEntry(is_send_to_remote=False, regex=re.compile(r"^\$QC([0-9a-fA-F]+)#"), capture={ 1:"thread_id" })
+ entry = GdbRemoteEntry(
+ is_send_to_remote=False,
+ regex=re.compile(r"^\$QC([0-9a-fA-F]+)#"),
+ capture={
+ 1: "thread_id"})
context = entry.assert_match(self, "$QC980#00")
self.assertEqual(context["thread_id"], "980")
def test_entry_regex_expect_captures_success(self):
- context = { "thread_id":"980" }
- entry = GdbRemoteEntry(is_send_to_remote=False, regex=re.compile(r"^\$T([0-9a-fA-F]{2})thread:([0-9a-fA-F]+)"), expect_captures={ 2:"thread_id" })
+ context = {"thread_id": "980"}
+ entry = GdbRemoteEntry(
+ is_send_to_remote=False,
+ regex=re.compile(r"^\$T([0-9a-fA-F]{2})thread:([0-9a-fA-F]+)"),
+ expect_captures={
+ 2: "thread_id"})
entry.assert_match(self, "$T11thread:980;", context=context)
def test_entry_regex_expect_captures_raises_on_fail(self):
- context = { "thread_id":"980" }
- entry = GdbRemoteEntry(is_send_to_remote=False, regex=re.compile(r"^\$T([0-9a-fA-F]{2})thread:([0-9a-fA-F]+)"), expect_captures={ 2:"thread_id" })
+ context = {"thread_id": "980"}
+ entry = GdbRemoteEntry(
+ is_send_to_remote=False,
+ regex=re.compile(r"^\$T([0-9a-fA-F]{2})thread:([0-9a-fA-F]+)"),
+ expect_captures={
+ 2: "thread_id"})
try:
entry.assert_match(self, "$T11thread:970;", context=context)
self.fail()