Clean lldb-mi test cases.
This patch adds lldbmi_testcase.MiTestCaseBase class and removes a lot of repitition in the lldb-mi test cases. Also cleans import list and code-style. Presented for review in http://reviews.llvm.org/D7162. Patch from Ilia K <ki.stfu@gmail.com>. llvm-svn: 227218
This commit is contained in:
parent
27e5fe8604
commit
692f5f3795
|
@ -2,197 +2,95 @@
|
|||
Test that the lldb-mi driver understands an MI breakpoint command.
|
||||
"""
|
||||
|
||||
import os
|
||||
import unittest2
|
||||
import lldb
|
||||
import lldbmi_testcase
|
||||
from lldbtest import *
|
||||
import unittest2
|
||||
|
||||
class MiBreakpointTestCase(TestBase):
|
||||
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
myexe = "a.out"
|
||||
|
||||
@classmethod
|
||||
def classCleanup(cls):
|
||||
"""Cleanup the test byproducts."""
|
||||
try:
|
||||
os.remove("child_send.txt")
|
||||
os.remove("child_read.txt")
|
||||
os.remove(cls.myexe)
|
||||
except:
|
||||
pass
|
||||
class MiBreakpointTestCase(lldbmi_testcase.MiTestCaseBase):
|
||||
|
||||
@lldbmi_test
|
||||
@expectedFailureWindows("llvm.org/pr22274: need a pexpect replacement for windows")
|
||||
def test_lldbmi_pendbreakonsym(self):
|
||||
"""Test that 'lldb-mi --interpreter' works for pending symbol breakpoints."""
|
||||
import pexpect
|
||||
self.buildDefault()
|
||||
|
||||
# So that the child gets torn down after the test.
|
||||
self.child = pexpect.spawn('%s --interpreter' % (self.lldbMiExec))
|
||||
child = self.child
|
||||
child.setecho(True)
|
||||
# Turn on logging for input/output to/from the child.
|
||||
with open('child_send.txt', 'w') as f_send:
|
||||
with open('child_read.txt', 'w') as f_read:
|
||||
child.logfile_send = f_send
|
||||
child.logfile_read = f_read
|
||||
self.spawnLldbMi(args = None)
|
||||
|
||||
child.sendline("-file-exec-and-symbols " + self.myexe)
|
||||
child.expect("\^done")
|
||||
self.runCmd("-file-exec-and-symbols %s" % self.myexe)
|
||||
self.expect("\^done")
|
||||
|
||||
child.sendline("-break-insert -f a_MyFunction")
|
||||
child.expect("\^done,bkpt={number=\"1\"")
|
||||
self.runCmd("-break-insert -f a_MyFunction")
|
||||
self.expect("\^done,bkpt={number=\"1\"")
|
||||
|
||||
child.sendline("-exec-run")
|
||||
child.expect("\^running")
|
||||
child.expect("\*stopped,reason=\"breakpoint-hit\"")
|
||||
self.runCmd("-exec-run")
|
||||
self.expect("\^running")
|
||||
self.expect("\*stopped,reason=\"breakpoint-hit\"")
|
||||
|
||||
child.sendline("-exec-continue")
|
||||
child.expect("\^running")
|
||||
child.expect("\*stopped,reason=\"exited-normally\"")
|
||||
|
||||
# Now that the necessary logging is done, restore logfile to None to
|
||||
# stop further logging.
|
||||
child.logfile_send = None
|
||||
child.logfile_read = None
|
||||
|
||||
with open('child_send.txt', 'r') as fs:
|
||||
if self.TraceOn():
|
||||
print "\n\nContents of child_send.txt:"
|
||||
print fs.read()
|
||||
with open('child_read.txt', 'r') as fr:
|
||||
from_child = fr.read()
|
||||
if self.TraceOn():
|
||||
print "\n\nContents of child_read.txt:"
|
||||
print from_child
|
||||
|
||||
self.expect(from_child, exe=False,
|
||||
substrs = ["breakpoint-hit"])
|
||||
self.runCmd("-exec-continue")
|
||||
self.expect("\^running")
|
||||
self.expect("\*stopped,reason=\"exited-normally\"")
|
||||
|
||||
@lldbmi_test
|
||||
@expectedFailureWindows("llvm.org/pr22274: need a pexpect replacement for windows")
|
||||
def test_lldbmi_pendbreakonsrc(self):
|
||||
"""Test that 'lldb-mi --interpreter' works for pending source breakpoints."""
|
||||
import pexpect
|
||||
self.buildDefault()
|
||||
|
||||
# So that the child gets torn down after the test.
|
||||
self.child = pexpect.spawn('%s --interpreter' % (self.lldbMiExec))
|
||||
child = self.child
|
||||
child.setecho(True)
|
||||
# Turn on logging for input/output to/from the child.
|
||||
with open('child_send.txt', 'w') as f_send:
|
||||
with open('child_read.txt', 'w') as f_read:
|
||||
child.logfile_send = f_send
|
||||
child.logfile_read = f_read
|
||||
self.spawnLldbMi(args = None)
|
||||
|
||||
child.sendline("-file-exec-and-symbols " + self.myexe)
|
||||
child.expect("\^done")
|
||||
self.runCmd("-file-exec-and-symbols %s" % self.myexe)
|
||||
self.expect("\^done")
|
||||
|
||||
# Find the line number to break inside main() and set
|
||||
# pending BP.
|
||||
self.line = line_number('main.c', '//BP_source')
|
||||
child.sendline("-break-insert -f main.c:%d" % self.line)
|
||||
child.expect("\^done,bkpt={number=\"1\"")
|
||||
line = line_number('main.c', '//BP_source')
|
||||
self.runCmd("-break-insert -f main.c:%d" % line)
|
||||
self.expect("\^done,bkpt={number=\"1\"")
|
||||
|
||||
child.sendline("-exec-run")
|
||||
child.expect("\^running")
|
||||
child.expect("\*stopped,reason=\"breakpoint-hit\"")
|
||||
self.runCmd("-exec-run")
|
||||
self.expect("\^running")
|
||||
self.expect("\*stopped,reason=\"breakpoint-hit\"")
|
||||
|
||||
child.sendline("-exec-continue")
|
||||
child.expect("\^running")
|
||||
child.expect("\*stopped,reason=\"exited-normally\"")
|
||||
|
||||
# Now that the necessary logging is done, restore logfile to None to
|
||||
# stop further logging.
|
||||
child.logfile_send = None
|
||||
child.logfile_read = None
|
||||
|
||||
with open('child_send.txt', 'r') as fs:
|
||||
if self.TraceOn():
|
||||
print "\n\nContents of child_send.txt:"
|
||||
print fs.read()
|
||||
with open('child_read.txt', 'r') as fr:
|
||||
from_child = fr.read()
|
||||
if self.TraceOn():
|
||||
print "\n\nContents of child_read.txt:"
|
||||
print from_child
|
||||
|
||||
self.expect(from_child, exe=False,
|
||||
substrs = ["breakpoint-hit"])
|
||||
self.runCmd("-exec-continue")
|
||||
self.expect("\^running")
|
||||
self.expect("\*stopped,reason=\"exited-normally\"")
|
||||
|
||||
@lldbmi_test
|
||||
@expectedFailureWindows("llvm.org/pr22274: need a pexpect replacement for windows")
|
||||
def test_lldbmi_breakpoints(self):
|
||||
"""Test that 'lldb-mi --interpreter' works for breakpoints."""
|
||||
import pexpect
|
||||
self.buildDefault()
|
||||
|
||||
# So that the child gets torn down after the test.
|
||||
self.child = pexpect.spawn('%s --interpreter' % (self.lldbMiExec))
|
||||
child = self.child
|
||||
child.setecho(True)
|
||||
# Turn on logging for input/output to/from the child.
|
||||
with open('child_send.txt', 'w') as f_send:
|
||||
with open('child_read.txt', 'w') as f_read:
|
||||
child.logfile_send = f_send
|
||||
child.logfile_read = f_read
|
||||
self.spawnLldbMi(args = None)
|
||||
|
||||
child.sendline("-file-exec-and-symbols " + self.myexe)
|
||||
child.expect("\^done")
|
||||
self.runCmd("-file-exec-and-symbols %s" % self.myexe)
|
||||
self.expect("\^done")
|
||||
|
||||
child.sendline("-break-insert -f main")
|
||||
child.expect("\^done,bkpt={number=\"1\"")
|
||||
self.runCmd("-break-insert -f main")
|
||||
self.expect("\^done,bkpt={number=\"1\"")
|
||||
|
||||
child.sendline("-exec-run")
|
||||
child.expect("\^running")
|
||||
child.expect("\*stopped,reason=\"breakpoint-hit\"")
|
||||
self.runCmd("-exec-run")
|
||||
self.expect("\^running")
|
||||
self.expect("\*stopped,reason=\"breakpoint-hit\"")
|
||||
|
||||
#break on symbol
|
||||
child.sendline("-break-insert a_MyFunction")
|
||||
child.expect("\^done,bkpt={number=\"2\"")
|
||||
self.runCmd("-break-insert a_MyFunction")
|
||||
self.expect("\^done,bkpt={number=\"2\"")
|
||||
|
||||
child.sendline("-exec-continue")
|
||||
child.expect("\^running")
|
||||
child.expect("\*stopped,reason=\"breakpoint-hit\"")
|
||||
self.runCmd("-exec-continue")
|
||||
self.expect("\^running")
|
||||
self.expect("\*stopped,reason=\"breakpoint-hit\"")
|
||||
|
||||
#break on source
|
||||
self.line = line_number('main.c', '//BP_source')
|
||||
child.sendline("-break-insert main.c:%d" % self.line)
|
||||
child.expect("\^done,bkpt={number=\"3\"")
|
||||
line = line_number('main.c', '//BP_source')
|
||||
self.runCmd("-break-insert main.c:%d" % line)
|
||||
self.expect("\^done,bkpt={number=\"3\"")
|
||||
|
||||
child.sendline("-exec-continue")
|
||||
child.expect("\^running")
|
||||
child.expect("\*stopped,reason=\"breakpoint-hit\"")
|
||||
self.runCmd("-exec-continue")
|
||||
self.expect("\^running")
|
||||
self.expect("\*stopped,reason=\"breakpoint-hit\"")
|
||||
|
||||
#run to exit
|
||||
child.sendline("-exec-continue")
|
||||
child.expect("\^running")
|
||||
child.expect("\*stopped,reason=\"exited-normally\"")
|
||||
|
||||
# Now that the necessary logging is done, restore logfile to None to
|
||||
# stop further logging.
|
||||
child.logfile_send = None
|
||||
child.logfile_read = None
|
||||
|
||||
with open('child_send.txt', 'r') as fs:
|
||||
if self.TraceOn():
|
||||
print "\n\nContents of child_send.txt:"
|
||||
print fs.read()
|
||||
with open('child_read.txt', 'r') as fr:
|
||||
from_child = fr.read()
|
||||
if self.TraceOn():
|
||||
print "\n\nContents of child_read.txt:"
|
||||
print from_child
|
||||
|
||||
self.expect(from_child, exe=False,
|
||||
substrs = ["breakpoint-hit"])
|
||||
|
||||
self.runCmd("-exec-continue")
|
||||
self.expect("\^running")
|
||||
self.expect("\*stopped,reason=\"exited-normally\"")
|
||||
|
||||
if __name__ == '__main__':
|
||||
import atexit
|
||||
lldb.SBDebugger.Initialize()
|
||||
atexit.register(lambda: lldb.SBDebugger.Terminate())
|
||||
unittest2.main()
|
||||
|
|
|
@ -2,131 +2,88 @@
|
|||
Test that the lldb-mi driver can evaluate expressions.
|
||||
"""
|
||||
|
||||
import os
|
||||
import unittest2
|
||||
import lldb
|
||||
import lldbmi_testcase
|
||||
from lldbtest import *
|
||||
import unittest2
|
||||
|
||||
class MiEvaluateTestCase(TestBase):
|
||||
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
myexe = "a.out"
|
||||
|
||||
@classmethod
|
||||
def classCleanup(cls):
|
||||
"""Cleanup the test byproducts."""
|
||||
try:
|
||||
os.remove("child_send.txt")
|
||||
os.remove("child_read.txt")
|
||||
os.remove(cls.myexe)
|
||||
except:
|
||||
pass
|
||||
class MiEvaluateTestCase(lldbmi_testcase.MiTestCaseBase):
|
||||
|
||||
@lldbmi_test
|
||||
@expectedFailureWindows("llvm.org/pr22274: need a pexpect replacement for windows")
|
||||
def test_lldbmi_eval(self):
|
||||
"""Test that 'lldb-mi --interpreter' works for evaluating."""
|
||||
import pexpect
|
||||
self.buildDefault()
|
||||
|
||||
# So that the child gets torn down after the test.
|
||||
self.child = pexpect.spawn('%s --interpreter' % (self.lldbMiExec))
|
||||
child = self.child
|
||||
child.setecho(True)
|
||||
# Turn on logging for input/output to/from the child.
|
||||
with open('child_send.txt', 'w') as f_send:
|
||||
with open('child_read.txt', 'w') as f_read:
|
||||
child.logfile_send = f_send
|
||||
child.logfile_read = f_read
|
||||
self.spawnLldbMi(args = None)
|
||||
|
||||
child.sendline("-file-exec-and-symbols " + self.myexe)
|
||||
child.expect("\^done")
|
||||
self.runCmd("-file-exec-and-symbols %s" % self.myexe)
|
||||
self.expect("\^done")
|
||||
|
||||
#run to main
|
||||
child.sendline("-break-insert -f main")
|
||||
child.expect("\^done,bkpt={number=\"1\"")
|
||||
self.runCmd("-break-insert -f main")
|
||||
self.expect("\^done,bkpt={number=\"1\"")
|
||||
|
||||
child.sendline("-exec-run")
|
||||
child.expect("\^running")
|
||||
child.expect("\*stopped,reason=\"breakpoint-hit\"")
|
||||
self.runCmd("-exec-run")
|
||||
self.expect("\^running")
|
||||
self.expect("\*stopped,reason=\"breakpoint-hit\"")
|
||||
|
||||
#run to program return (marked BP_source)
|
||||
self.line = line_number('main.c', '//BP_source')
|
||||
child.sendline("-break-insert main.c:%d" % self.line)
|
||||
child.expect("\^done,bkpt={number=\"2\"")
|
||||
line = line_number('main.c', '//BP_source')
|
||||
self.runCmd("-break-insert main.c:%d" % line)
|
||||
self.expect("\^done,bkpt={number=\"2\"")
|
||||
|
||||
child.sendline("-exec-continue")
|
||||
child.expect("\^running")
|
||||
child.expect("\*stopped,reason=\"breakpoint-hit\"")
|
||||
self.runCmd("-exec-continue")
|
||||
self.expect("\^running")
|
||||
self.expect("\*stopped,reason=\"breakpoint-hit\"")
|
||||
|
||||
#print non-existant variable
|
||||
#child.sendline("-var-create var1 --thread 1 --frame 0 * undef") #FIXME: shows undef as {...}
|
||||
#child.expect("error")
|
||||
#child.sendline("-data-evaluate-expression undef") #FIXME: gets value="undef"
|
||||
#child.expect("error")
|
||||
#self.runCmd("-var-create var1 --thread 1 --frame 0 * undef") #FIXME: shows undef as {...}
|
||||
#self.expect("error")
|
||||
#self.runCmd("-data-evaluate-expression undef") #FIXME: gets value="undef"
|
||||
#self.expect("error")
|
||||
|
||||
#print global "g_MyVar"
|
||||
child.sendline("-var-create var1 --thread 1 --frame 0 * g_MyVar") #FIXME: shows name=<unnamedvariable>"
|
||||
child.expect("value=\"3\",type=\"int\"")
|
||||
#child.sendline("-var-evaluate-expression var1") #FIXME: gets var1 does not exist
|
||||
child.sendline("-var-show-attributes var1")
|
||||
child.expect("status=\"editable\"")
|
||||
child.sendline("-var-delete var1")
|
||||
child.expect("\^done")
|
||||
child.sendline("-var-create var1 --thread 1 --frame 0 * g_MyVar")
|
||||
child.expect("value=\"3\",type=\"int\"")
|
||||
self.runCmd("-var-create var1 --thread 1 --frame 0 * g_MyVar") #FIXME: shows name=<unnamedvariable>"
|
||||
self.expect("value=\"3\",type=\"int\"")
|
||||
#self.runCmd("-var-evaluate-expression var1") #FIXME: gets var1 does not exist
|
||||
self.runCmd("-var-show-attributes var1")
|
||||
self.expect("status=\"editable\"")
|
||||
self.runCmd("-var-delete var1")
|
||||
self.expect("\^done")
|
||||
self.runCmd("-var-create var1 --thread 1 --frame 0 * g_MyVar")
|
||||
self.expect("value=\"3\",type=\"int\"")
|
||||
|
||||
#print static "s_MyVar" and modify
|
||||
child.sendline("-data-evaluate-expression s_MyVar")
|
||||
child.expect("value=\"30\"")
|
||||
child.sendline("-var-create var3 --thread 1 --frame 0 * \"s_MyVar=3\"")
|
||||
child.expect("value=\"3\",type=\"int\"")
|
||||
child.sendline("-data-evaluate-expression \"s_MyVar=30\"")
|
||||
child.expect("value=\"30\"")
|
||||
self.runCmd("-data-evaluate-expression s_MyVar")
|
||||
self.expect("value=\"30\"")
|
||||
self.runCmd("-var-create var3 --thread 1 --frame 0 * \"s_MyVar=3\"")
|
||||
self.expect("value=\"3\",type=\"int\"")
|
||||
self.runCmd("-data-evaluate-expression \"s_MyVar=30\"")
|
||||
self.expect("value=\"30\"")
|
||||
|
||||
#print local "b" and modify
|
||||
child.sendline("-data-evaluate-expression b")
|
||||
child.expect("value=\"20\"")
|
||||
child.sendline("-var-create var3 --thread 1 --frame 0 * \"b=3\"")
|
||||
child.expect("value=\"3\",type=\"int\"")
|
||||
child.sendline("-data-evaluate-expression \"b=20\"")
|
||||
child.expect("value=\"20\"")
|
||||
self.runCmd("-data-evaluate-expression b")
|
||||
self.expect("value=\"20\"")
|
||||
self.runCmd("-var-create var3 --thread 1 --frame 0 * \"b=3\"")
|
||||
self.expect("value=\"3\",type=\"int\"")
|
||||
self.runCmd("-data-evaluate-expression \"b=20\"")
|
||||
self.expect("value=\"20\"")
|
||||
|
||||
#print "a + b"
|
||||
child.sendline("-data-evaluate-expression \"a + b\"")
|
||||
child.expect("value=\"30\"")
|
||||
child.sendline("-var-create var3 --thread 1 --frame 0 * \"a + b\"")
|
||||
child.expect("value=\"30\",type=\"int\"")
|
||||
self.runCmd("-data-evaluate-expression \"a + b\"")
|
||||
self.expect("value=\"30\"")
|
||||
self.runCmd("-var-create var3 --thread 1 --frame 0 * \"a + b\"")
|
||||
self.expect("value=\"30\",type=\"int\"")
|
||||
|
||||
#print "argv[0]"
|
||||
child.sendline("-data-evaluate-expression \"argv[0]\"")
|
||||
child.expect("value=\"0x")
|
||||
child.sendline("-var-create var3 --thread 1 --frame 0 * \"argv[0]\"")
|
||||
child.expect("numchild=\"1\",value=\"0x.*\",type=\"const char \*\"")
|
||||
self.runCmd("-data-evaluate-expression \"argv[0]\"")
|
||||
self.expect("value=\"0x")
|
||||
self.runCmd("-var-create var3 --thread 1 --frame 0 * \"argv[0]\"")
|
||||
self.expect("numchild=\"1\",value=\"0x.*\",type=\"const char \*\"")
|
||||
|
||||
#run to exit
|
||||
child.sendline("-exec-continue")
|
||||
child.expect("\^running")
|
||||
child.expect("\*stopped,reason=\"exited-normally\"")
|
||||
|
||||
# Now that the necessary logging is done, restore logfile to None to
|
||||
# stop further logging.
|
||||
child.logfile_send = None
|
||||
child.logfile_read = None
|
||||
|
||||
with open('child_send.txt', 'r') as fs:
|
||||
if self.TraceOn():
|
||||
print "\n\nContents of child_send.txt:"
|
||||
print fs.read()
|
||||
with open('child_read.txt', 'r') as fr:
|
||||
from_child = fr.read()
|
||||
if self.TraceOn():
|
||||
print "\n\nContents of child_read.txt:"
|
||||
print from_child
|
||||
|
||||
self.runCmd("-exec-continue")
|
||||
self.expect("\^running")
|
||||
self.expect("\*stopped,reason=\"exited-normally\"")
|
||||
|
||||
if __name__ == '__main__':
|
||||
import atexit
|
||||
lldb.SBDebugger.Initialize()
|
||||
atexit.register(lambda: lldb.SBDebugger.Terminate())
|
||||
unittest2.main()
|
||||
|
|
|
@ -2,96 +2,53 @@
|
|||
Test that the lldb-mi driver can interrupt and resume a looping app.
|
||||
"""
|
||||
|
||||
import os
|
||||
import unittest2
|
||||
import lldb
|
||||
import lldbmi_testcase
|
||||
from lldbtest import *
|
||||
import unittest2
|
||||
|
||||
class MiInterruptTestCase(TestBase):
|
||||
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
myexe = "a.out"
|
||||
|
||||
@classmethod
|
||||
def classCleanup(cls):
|
||||
"""Cleanup the test byproducts."""
|
||||
try:
|
||||
os.remove("child_send.txt")
|
||||
os.remove("child_read.txt")
|
||||
os.remove(cls.myexe)
|
||||
except:
|
||||
pass
|
||||
class MiInterruptTestCase(lldbmi_testcase.MiTestCaseBase):
|
||||
|
||||
@lldbmi_test
|
||||
@unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
|
||||
@expectedFailureWindows("llvm.org/pr22274: need a pexpect replacement for windows")
|
||||
@lldbmi_test
|
||||
def test_lldbmi_interrupt(self):
|
||||
"""Test that 'lldb-mi --interpreter' interrupt and resume a looping app."""
|
||||
import pexpect
|
||||
self.buildDefault()
|
||||
|
||||
# So that the child gets torn down after the test.
|
||||
self.child = pexpect.spawn('%s --interpreter' % (self.lldbMiExec))
|
||||
child = self.child
|
||||
child.setecho(True)
|
||||
# Turn on logging for input/output to/from the child.
|
||||
with open('child_send.txt', 'w') as f_send:
|
||||
with open('child_read.txt', 'w') as f_read:
|
||||
child.logfile_send = f_send
|
||||
child.logfile_read = f_read
|
||||
self.spawnLldbMi(args = None)
|
||||
|
||||
child.sendline("-file-exec-and-symbols " + self.myexe)
|
||||
child.expect("\^done")
|
||||
self.runCmd("-file-exec-and-symbols %s" % self.myexe)
|
||||
self.expect("\^done")
|
||||
|
||||
#run to main
|
||||
child.sendline("-break-insert -f main")
|
||||
child.expect("\^done,bkpt={number=\"1\"")
|
||||
child.sendline("-exec-run")
|
||||
child.expect("\^running")
|
||||
child.expect("\*stopped,reason=\"breakpoint-hit\"")
|
||||
self.runCmd("-break-insert -f main")
|
||||
self.expect("\^done,bkpt={number=\"1\"")
|
||||
self.runCmd("-exec-run")
|
||||
self.expect("\^running")
|
||||
self.expect("\*stopped,reason=\"breakpoint-hit\"")
|
||||
|
||||
#set doloop=1 and run (to loop forever)
|
||||
child.sendline("-data-evaluate-expression \"doloop=1\"")
|
||||
child.expect("value=\"1\"")
|
||||
child.sendline("-exec-continue")
|
||||
child.expect("\^running")
|
||||
self.runCmd("-data-evaluate-expression \"doloop=1\"")
|
||||
self.expect("value=\"1\"")
|
||||
self.runCmd("-exec-continue")
|
||||
self.expect("\^running")
|
||||
|
||||
#issue interrupt, set BP in loop (marked BP_loop), and resume
|
||||
child.sendline("-exec-interrupt")
|
||||
child.expect("\*stopped,reason=\"signal-received\"")
|
||||
self.line = line_number('loop.c', '//BP_loop')
|
||||
child.sendline("-break-insert loop.c:%d" % self.line)
|
||||
child.expect("\^done,bkpt={number=\"2\"")
|
||||
#child.sendline("-exec-resume") #FIXME: command not recognized
|
||||
child.sendline("-exec-continue")
|
||||
child.expect("\*stopped,reason=\"breakpoint-hit\"")
|
||||
self.runCmd("-exec-interrupt")
|
||||
self.expect("\*stopped,reason=\"signal-received\"")
|
||||
line = line_number('loop.c', '//BP_loop')
|
||||
self.runCmd("-break-insert loop.c:%d" % line)
|
||||
self.expect("\^done,bkpt={number=\"2\"")
|
||||
#self.runCmd("-exec-resume") #FIXME: command not recognized
|
||||
self.runCmd("-exec-continue")
|
||||
self.expect("\*stopped,reason=\"breakpoint-hit\"")
|
||||
|
||||
#we should have hit BP
|
||||
#set loop=-1 so we'll exit the loop
|
||||
child.sendline("-data-evaluate-expression \"loop=-1\"")
|
||||
child.expect("value=\"-1\"")
|
||||
child.sendline("-exec-continue")
|
||||
child.expect("\^running")
|
||||
child.expect("\*stopped,reason=\"exited-normally\"")
|
||||
|
||||
# Now that the necessary logging is done, restore logfile to None to
|
||||
# stop further logging.
|
||||
child.logfile_send = None
|
||||
child.logfile_read = None
|
||||
|
||||
with open('child_send.txt', 'r') as fs:
|
||||
if self.TraceOn():
|
||||
print "\n\nContents of child_send.txt:"
|
||||
print fs.read()
|
||||
with open('child_read.txt', 'r') as fr:
|
||||
from_child = fr.read()
|
||||
if self.TraceOn():
|
||||
print "\n\nContents of child_read.txt:"
|
||||
print from_child
|
||||
|
||||
self.runCmd("-data-evaluate-expression \"loop=-1\"")
|
||||
self.expect("value=\"-1\"")
|
||||
self.runCmd("-exec-continue")
|
||||
self.expect("\^running")
|
||||
self.expect("\*stopped,reason=\"exited-normally\"")
|
||||
|
||||
if __name__ == '__main__':
|
||||
import atexit
|
||||
lldb.SBDebugger.Initialize()
|
||||
atexit.register(lambda: lldb.SBDebugger.Terminate())
|
||||
unittest2.main()
|
||||
|
|
|
@ -2,188 +2,71 @@
|
|||
Test various ways the lldb-mi driver can launch a program.
|
||||
"""
|
||||
|
||||
import os
|
||||
import unittest2
|
||||
import lldb
|
||||
import lldbmi_testcase
|
||||
from lldbtest import *
|
||||
import unittest2
|
||||
|
||||
class MiLaunchTestCase(TestBase):
|
||||
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
myexe = "a.out"
|
||||
|
||||
@classmethod
|
||||
def classCleanup(cls):
|
||||
"""Cleanup the test byproducts."""
|
||||
try:
|
||||
os.remove("child_send.txt")
|
||||
os.remove("child_read.txt")
|
||||
os.remove(cls.myexe)
|
||||
except:
|
||||
pass
|
||||
class MiLaunchTestCase(lldbmi_testcase.MiTestCaseBase):
|
||||
|
||||
@lldbmi_test
|
||||
@expectedFailureWindows("llvm.org/pr22274: need a pexpect replacement for windows")
|
||||
def test_lldbmi_exe(self):
|
||||
"""Test that 'lldb-mi --interpreter' works for -file-exec-and-symbols exe."""
|
||||
import pexpect
|
||||
self.buildDefault()
|
||||
|
||||
# So that the child gets torn down after the test.
|
||||
self.child = pexpect.spawn('%s --interpreter' % (self.lldbMiExec))
|
||||
child = self.child
|
||||
child.setecho(True)
|
||||
# Turn on logging for input/output to/from the child.
|
||||
with open('child_send.txt', 'w') as f_send:
|
||||
with open('child_read.txt', 'w') as f_read:
|
||||
child.logfile_send = f_send
|
||||
child.logfile_read = f_read
|
||||
self.spawnLldbMi(args = None)
|
||||
|
||||
#use no path
|
||||
child.sendline("-file-exec-and-symbols " + self.myexe)
|
||||
child.expect("\^done")
|
||||
self.runCmd("-file-exec-and-symbols %s" % self.myexe)
|
||||
self.expect("\^done")
|
||||
|
||||
child.sendline("-exec-run")
|
||||
child.expect("\^running")
|
||||
child.expect("\*stopped,reason=\"exited-normally\"")
|
||||
|
||||
# Now that the necessary logging is done, restore logfile to None to
|
||||
# stop further logging.
|
||||
child.logfile_send = None
|
||||
child.logfile_read = None
|
||||
|
||||
with open('child_send.txt', 'r') as fs:
|
||||
if self.TraceOn():
|
||||
print "\n\nContents of child_send.txt:"
|
||||
print fs.read()
|
||||
with open('child_read.txt', 'r') as fr:
|
||||
from_child = fr.read()
|
||||
if self.TraceOn():
|
||||
print "\n\nContents of child_read.txt:"
|
||||
print from_child
|
||||
self.runCmd("-exec-run")
|
||||
self.expect("\^running")
|
||||
self.expect("\*stopped,reason=\"exited-normally\"")
|
||||
|
||||
@lldbmi_test
|
||||
@expectedFailureWindows("llvm.org/pr22274: need a pexpect replacement for windows")
|
||||
def test_lldbmi_abspathexe(self):
|
||||
"""Test that 'lldb-mi --interpreter' works for -file-exec-and-symbols fullpath/exe."""
|
||||
import pexpect
|
||||
self.buildDefault()
|
||||
|
||||
# So that the child gets torn down after the test.
|
||||
self.child = pexpect.spawn('%s --interpreter' % (self.lldbMiExec))
|
||||
child = self.child
|
||||
child.setecho(True)
|
||||
# Turn on logging for input/output to/from the child.
|
||||
with open('child_send.txt', 'w') as f_send:
|
||||
with open('child_read.txt', 'w') as f_read:
|
||||
child.logfile_send = f_send
|
||||
child.logfile_read = f_read
|
||||
self.spawnLldbMi(args = None)
|
||||
|
||||
#use full path
|
||||
exe = os.path.join(os.getcwd(), "a.out")
|
||||
child.sendline("-file-exec-and-symbols " + exe)
|
||||
child.expect("\^done")
|
||||
import os
|
||||
exe = os.path.join(os.getcwd(), self.myexe)
|
||||
self.runCmd("-file-exec-and-symbols %s" % exe)
|
||||
self.expect("\^done")
|
||||
|
||||
child.sendline("-exec-run")
|
||||
child.expect("\^running")
|
||||
child.expect("\*stopped,reason=\"exited-normally\"")
|
||||
|
||||
# Now that the necessary logging is done, restore logfile to None to
|
||||
# stop further logging.
|
||||
child.logfile_send = None
|
||||
child.logfile_read = None
|
||||
|
||||
with open('child_send.txt', 'r') as fs:
|
||||
if self.TraceOn():
|
||||
print "\n\nContents of child_send.txt:"
|
||||
print fs.read()
|
||||
with open('child_read.txt', 'r') as fr:
|
||||
from_child = fr.read()
|
||||
if self.TraceOn():
|
||||
print "\n\nContents of child_read.txt:"
|
||||
print from_child
|
||||
self.runCmd("-exec-run")
|
||||
self.expect("\^running")
|
||||
self.expect("\*stopped,reason=\"exited-normally\"")
|
||||
|
||||
@lldbmi_test
|
||||
@expectedFailureWindows("llvm.org/pr22274: need a pexpect replacement for windows")
|
||||
def test_lldbmi_relpathexe(self):
|
||||
"""Test that 'lldb-mi --interpreter' works for -file-exec-and-symbols relpath/exe."""
|
||||
import pexpect
|
||||
self.buildDefault()
|
||||
|
||||
# So that the child gets torn down after the test.
|
||||
self.child = pexpect.spawn('%s --interpreter' % (self.lldbMiExec))
|
||||
child = self.child
|
||||
child.setecho(True)
|
||||
# Turn on logging for input/output to/from the child.
|
||||
with open('child_send.txt', 'w') as f_send:
|
||||
with open('child_read.txt', 'w') as f_read:
|
||||
child.logfile_send = f_send
|
||||
child.logfile_read = f_read
|
||||
self.spawnLldbMi(args = None)
|
||||
|
||||
#use relative path
|
||||
exe = "../../" + self.mydir + "/" + self.myexe
|
||||
child.sendline("-file-exec-and-symbols " + exe)
|
||||
child.expect("\^done")
|
||||
self.runCmd("-file-exec-and-symbols %s" % exe)
|
||||
self.expect("\^done")
|
||||
|
||||
child.sendline("-exec-run")
|
||||
child.expect("\^running")
|
||||
child.expect("\*stopped,reason=\"exited-normally\"")
|
||||
|
||||
# Now that the necessary logging is done, restore logfile to None to
|
||||
# stop further logging.
|
||||
child.logfile_send = None
|
||||
child.logfile_read = None
|
||||
|
||||
with open('child_send.txt', 'r') as fs:
|
||||
if self.TraceOn():
|
||||
print "\n\nContents of child_send.txt:"
|
||||
print fs.read()
|
||||
with open('child_read.txt', 'r') as fr:
|
||||
from_child = fr.read()
|
||||
if self.TraceOn():
|
||||
print "\n\nContents of child_read.txt:"
|
||||
print from_child
|
||||
self.runCmd("-exec-run")
|
||||
self.expect("\^running")
|
||||
self.expect("\*stopped,reason=\"exited-normally\"")
|
||||
|
||||
@lldbmi_test
|
||||
@expectedFailureWindows("llvm.org/pr22274: need a pexpect replacement for windows")
|
||||
def test_lldbmi_badpathexe(self):
|
||||
"""Test that 'lldb-mi --interpreter' works for -file-exec-and-symbols badpath/exe."""
|
||||
import pexpect
|
||||
self.buildDefault()
|
||||
|
||||
# So that the child gets torn down after the test.
|
||||
self.child = pexpect.spawn('%s --interpreter' % (self.lldbMiExec))
|
||||
child = self.child
|
||||
child.setecho(True)
|
||||
# Turn on logging for input/output to/from the child.
|
||||
with open('child_send.txt', 'w') as f_send:
|
||||
with open('child_read.txt', 'w') as f_read:
|
||||
child.logfile_send = f_send
|
||||
child.logfile_read = f_read
|
||||
self.spawnLldbMi(args = None)
|
||||
|
||||
#use non-existant path
|
||||
exe = "badpath/" + self.myexe
|
||||
child.sendline("-file-exec-and-symbols " + exe)
|
||||
child.expect("\^error")
|
||||
|
||||
# Now that the necessary logging is done, restore logfile to None to
|
||||
# stop further logging.
|
||||
child.logfile_send = None
|
||||
child.logfile_read = None
|
||||
|
||||
with open('child_send.txt', 'r') as fs:
|
||||
if self.TraceOn():
|
||||
print "\n\nContents of child_send.txt:"
|
||||
print fs.read()
|
||||
with open('child_read.txt', 'r') as fr:
|
||||
from_child = fr.read()
|
||||
if self.TraceOn():
|
||||
print "\n\nContents of child_read.txt:"
|
||||
print from_child
|
||||
|
||||
self.runCmd("-file-exec-and-symbols %s" % exe)
|
||||
self.expect("\^error")
|
||||
|
||||
if __name__ == '__main__':
|
||||
import atexit
|
||||
lldb.SBDebugger.Initialize()
|
||||
atexit.register(lambda: lldb.SBDebugger.Terminate())
|
||||
unittest2.main()
|
||||
|
|
|
@ -2,86 +2,44 @@
|
|||
Test that the lldb-mi driver can pass arguments to the app.
|
||||
"""
|
||||
|
||||
import os
|
||||
import unittest2
|
||||
import lldb
|
||||
import lldbmi_testcase
|
||||
from lldbtest import *
|
||||
import unittest2
|
||||
|
||||
class MiProgramArgsTestCase(TestBase):
|
||||
class MiProgramArgsTestCase(lldbmi_testcase.MiTestCaseBase):
|
||||
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
myexe = "a.out"
|
||||
|
||||
@classmethod
|
||||
def classCleanup(cls):
|
||||
"""Cleanup the test byproducts."""
|
||||
try:
|
||||
os.remove("child_send.txt")
|
||||
os.remove("child_read.txt")
|
||||
os.remove(cls.myexe)
|
||||
except:
|
||||
pass
|
||||
|
||||
@unittest2.skip("lldb-mi can't pass params to app.")
|
||||
@lldbmi_test
|
||||
@unittest2.skip("lldb-mi can't pass params to app.")
|
||||
@expectedFailureWindows("llvm.org/pr22274: need a pexpect replacement for windows")
|
||||
def test_lldbmi_paramargs(self):
|
||||
"""Test that 'lldb-mi --interpreter' can pass arguments to the app."""
|
||||
import pexpect
|
||||
self.buildDefault()
|
||||
|
||||
# So that the child gets torn down after the test.
|
||||
self.child = pexpect.spawn('%s --interpreter' % (self.lldbMiExec))
|
||||
child = self.child
|
||||
child.setecho(True)
|
||||
# Turn on logging for input/output to/from the child.
|
||||
with open('child_send.txt', 'w') as f_send:
|
||||
with open('child_read.txt', 'w') as f_read:
|
||||
child.logfile_send = f_send
|
||||
child.logfile_read = f_read
|
||||
self.spawnLldbMi(args = None)
|
||||
|
||||
child.sendline("-file-exec-and-symbols " + self.myexe)
|
||||
child.expect("\^done")
|
||||
self.runCmd("-file-exec-and-symbols %s" % self.myexe)
|
||||
self.expect("\^done")
|
||||
|
||||
child.sendline("settings set target.run-args l") #FIXME: args not passed
|
||||
#child.sendline("-exec-arguments l") #FIXME: not recognized and hung lldb-mi
|
||||
self.runCmd("settings set target.run-args l") #FIXME: args not passed
|
||||
#self.runCmd("-exec-arguments l") #FIXME: not recognized and hung lldb-mi
|
||||
|
||||
#run to main
|
||||
child.sendline("-break-insert -f main")
|
||||
child.expect("\^done,bkpt={number=\"1\"")
|
||||
child.sendline("-exec-run")
|
||||
child.expect("\^running")
|
||||
child.expect("\*stopped,reason=\"breakpoint-hit\"")
|
||||
self.runCmd("-break-insert -f main")
|
||||
self.expect("\^done,bkpt={number=\"1\"")
|
||||
self.runCmd("-exec-run")
|
||||
self.expect("\^running")
|
||||
self.expect("\*stopped,reason=\"breakpoint-hit\"")
|
||||
|
||||
#check argc to see if arg passed
|
||||
child.sendline("-data-evaluate-expression argc")
|
||||
child.expect("value=\"2\"")
|
||||
self.runCmd("-data-evaluate-expression argc")
|
||||
self.expect("value=\"2\"")
|
||||
|
||||
#set BP on code which is only executed if "l" was passed correctly (marked BP_argtest)
|
||||
self.line = line_number('main.c', '//BP_argtest')
|
||||
child.sendline("-break-insert main.c:%d" % self.line)
|
||||
child.expect("\^done,bkpt={number=\"2\"")
|
||||
child.sendline("-exec-continue")
|
||||
child.expect("\^running")
|
||||
child.expect("\*stopped,reason=\"breakpoint-hit\"")
|
||||
|
||||
# Now that the necessary logging is done, restore logfile to None to
|
||||
# stop further logging.
|
||||
child.logfile_send = None
|
||||
child.logfile_read = None
|
||||
|
||||
with open('child_send.txt', 'r') as fs:
|
||||
if self.TraceOn():
|
||||
print "\n\nContents of child_send.txt:"
|
||||
print fs.read()
|
||||
with open('child_read.txt', 'r') as fr:
|
||||
from_child = fr.read()
|
||||
if self.TraceOn():
|
||||
print "\n\nContents of child_read.txt:"
|
||||
print from_child
|
||||
line = line_number('main.c', '//BP_argtest')
|
||||
self.runCmd("-break-insert main.c:%d" % line)
|
||||
self.expect("\^done,bkpt={number=\"2\"")
|
||||
self.runCmd("-exec-continue")
|
||||
self.expect("\^running")
|
||||
self.expect("\*stopped,reason=\"breakpoint-hit\"")
|
||||
|
||||
if __name__ == '__main__':
|
||||
import atexit
|
||||
lldb.SBDebugger.Initialize()
|
||||
atexit.register(lambda: lldb.SBDebugger.Terminate())
|
||||
unittest2.main()
|
||||
|
|
|
@ -2,123 +2,60 @@
|
|||
Test that the lldb-mi driver works with -stack-xxx commands
|
||||
"""
|
||||
|
||||
import os
|
||||
import unittest2
|
||||
import lldb
|
||||
import lldbmi_testcase
|
||||
from lldbtest import *
|
||||
import unittest2
|
||||
|
||||
class MiStackTestCase(TestBase):
|
||||
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
myexe = "a.out"
|
||||
|
||||
@classmethod
|
||||
def classCleanup(cls):
|
||||
"""Cleanup the test byproducts."""
|
||||
try:
|
||||
os.remove("child_send.txt")
|
||||
os.remove("child_read.txt")
|
||||
os.remove(cls.myexe)
|
||||
except:
|
||||
pass
|
||||
class MiStackTestCase(lldbmi_testcase.MiTestCaseBase):
|
||||
|
||||
@lldbmi_test
|
||||
@expectedFailureWindows("llvm.org/pr22274: need a pexpect replacement for windows")
|
||||
def test_lldbmi_stackargs(self):
|
||||
"""Test that 'lldb-mi --interpreter' can shows arguments."""
|
||||
import pexpect
|
||||
self.buildDefault()
|
||||
|
||||
# So that the child gets torn down after the test.
|
||||
self.child = pexpect.spawn('%s --interpreter' % (self.lldbMiExec))
|
||||
child = self.child
|
||||
child.setecho(True)
|
||||
# Turn on logging for input/output to/from the child.
|
||||
with open('child_send.txt', 'w') as f_send:
|
||||
with open('child_read.txt', 'w') as f_read:
|
||||
child.logfile_send = f_send
|
||||
child.logfile_read = f_read
|
||||
self.spawnLldbMi(args = None)
|
||||
|
||||
# Load executable
|
||||
child.sendline("-file-exec-and-symbols %s" % (self.myexe))
|
||||
child.expect("\^done")
|
||||
self.runCmd("-file-exec-and-symbols %s" % self.myexe)
|
||||
self.expect("\^done")
|
||||
|
||||
# Run to main
|
||||
child.sendline("-break-insert -f main")
|
||||
child.expect("\^done,bkpt={number=\"1\"")
|
||||
child.sendline("-exec-run")
|
||||
child.expect("\^running")
|
||||
child.expect("\*stopped,reason=\"breakpoint-hit\"")
|
||||
self.runCmd("-break-insert -f main")
|
||||
self.expect("\^done,bkpt={number=\"1\"")
|
||||
self.runCmd("-exec-run")
|
||||
self.expect("\^running")
|
||||
self.expect("\*stopped,reason=\"breakpoint-hit\"")
|
||||
|
||||
# Test arguments
|
||||
child.sendline("-stack-list-arguments 0")
|
||||
child.expect("\^done,stack-args=\[frame={level=\"0\",args=\[{name=\"argc\",value=\"1\"},{name=\"argv\",value=\".*\"}\]}")
|
||||
|
||||
# Now that the necessary logging is done, restore logfile to None to
|
||||
# stop further logging.
|
||||
child.logfile_send = None
|
||||
child.logfile_read = None
|
||||
|
||||
with open('child_send.txt', 'r') as fs:
|
||||
if self.TraceOn():
|
||||
print "\n\nContents of child_send.txt:"
|
||||
print fs.read()
|
||||
with open('child_read.txt', 'r') as fr:
|
||||
from_child = fr.read()
|
||||
if self.TraceOn():
|
||||
print "\n\nContents of child_read.txt:"
|
||||
print from_child
|
||||
#self.runCmd("-stack-list-arguments 0") #FIXME: --no-values doesn't work
|
||||
#self.expect("\^done,stack-args=\[frame={level=\"0\",args=\[name=\"argc\",name=\"argv\"\]}")
|
||||
self.runCmd("-stack-list-arguments 1")
|
||||
self.expect("\^done,stack-args=\[frame={level=\"0\",args=\[{name=\"argc\",value=\"1\"},{name=\"argv\",value=\".*\"}\]}")
|
||||
|
||||
@lldbmi_test
|
||||
@expectedFailureWindows("llvm.org/pr22274: need a pexpect replacement for windows")
|
||||
def test_lldbmi_locals(self):
|
||||
"""Test that 'lldb-mi --interpreter' can shows local variables."""
|
||||
import pexpect
|
||||
self.buildDefault()
|
||||
|
||||
# So that the child gets torn down after the test.
|
||||
self.child = pexpect.spawn('%s --interpreter' % (self.lldbMiExec))
|
||||
child = self.child
|
||||
child.setecho(True)
|
||||
# Turn on logging for input/output to/from the child.
|
||||
with open('child_send.txt', 'w') as f_send:
|
||||
with open('child_read.txt', 'w') as f_read:
|
||||
child.logfile_send = f_send
|
||||
child.logfile_read = f_read
|
||||
self.spawnLldbMi(args = None)
|
||||
|
||||
# Load executable
|
||||
child.sendline("-file-exec-and-symbols %s" % (self.myexe))
|
||||
child.expect("\^done")
|
||||
self.runCmd("-file-exec-and-symbols %s" % (self.myexe))
|
||||
self.expect("\^done")
|
||||
|
||||
# Run to main
|
||||
self.line = line_number('main.c', '//BP_localstest')
|
||||
child.sendline("-break-insert --file main.c:%d" % (self.line))
|
||||
child.expect("\^done,bkpt={number=\"1\"")
|
||||
child.sendline("-exec-run")
|
||||
child.expect("\^running")
|
||||
child.expect("\*stopped,reason=\"breakpoint-hit\"")
|
||||
line = line_number('main.c', '//BP_localstest')
|
||||
self.runCmd("-break-insert --file main.c:%d" % line)
|
||||
self.expect("\^done,bkpt={number=\"1\"")
|
||||
self.runCmd("-exec-run")
|
||||
self.expect("\^running")
|
||||
self.expect("\*stopped,reason=\"breakpoint-hit\"")
|
||||
|
||||
# Test locals
|
||||
child.sendline("-stack-list-locals 0")
|
||||
child.expect("\^done,locals=\[{name=\"a\",value=\"10\"},{name=\"b\",value=\"20\"}\]")
|
||||
|
||||
# Now that the necessary logging is done, restore logfile to None to
|
||||
# stop further logging.
|
||||
child.logfile_send = None
|
||||
child.logfile_read = None
|
||||
|
||||
with open('child_send.txt', 'r') as fs:
|
||||
if self.TraceOn():
|
||||
print "\n\nContents of child_send.txt:"
|
||||
print fs.read()
|
||||
with open('child_read.txt', 'r') as fr:
|
||||
from_child = fr.read()
|
||||
if self.TraceOn():
|
||||
print "\n\nContents of child_read.txt:"
|
||||
print from_child
|
||||
#self.runCmd("-stack-list-locals 0") #FIXME: --no-values doesn't work
|
||||
#self.expect("\^done,locals=\[name=\"a\",name=\"b\"\]")
|
||||
self.runCmd("-stack-list-locals 1")
|
||||
self.expect("\^done,locals=\[{name=\"a\",value=\"10\"},{name=\"b\",value=\"20\"}\]")
|
||||
|
||||
if __name__ == '__main__':
|
||||
import atexit
|
||||
lldb.SBDebugger.Initialize()
|
||||
atexit.register(lambda: lldb.SBDebugger.Terminate())
|
||||
unittest2.main()
|
||||
|
|
|
@ -2,74 +2,34 @@
|
|||
Test that the lldb-mi driver understands MI command syntax.
|
||||
"""
|
||||
|
||||
import os
|
||||
import unittest2
|
||||
import lldb
|
||||
import lldbmi_testcase
|
||||
from lldbtest import *
|
||||
import unittest2
|
||||
|
||||
class MiSyntaxTestCase(TestBase):
|
||||
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
myexe = "a.out"
|
||||
|
||||
@classmethod
|
||||
def classCleanup(cls):
|
||||
"""Cleanup the test byproducts."""
|
||||
try:
|
||||
os.remove("child_send.txt")
|
||||
os.remove("child_read.txt")
|
||||
os.remove(cls.myexe)
|
||||
except:
|
||||
pass
|
||||
class MiSyntaxTestCase(lldbmi_testcase.MiTestCaseBase):
|
||||
|
||||
@lldbmi_test
|
||||
@expectedFailureWindows("llvm.org/pr22274: need a pexpect replacement for windows")
|
||||
def test_lldbmi_tokens(self):
|
||||
"""Test that 'lldb-mi --interpreter' echos command tokens."""
|
||||
import pexpect
|
||||
self.buildDefault()
|
||||
|
||||
# So that the child gets torn down after the test.
|
||||
self.child = pexpect.spawn('%s --interpreter' % (self.lldbMiExec))
|
||||
child = self.child
|
||||
child.setecho(True)
|
||||
# Turn on logging for input/output to/from the child.
|
||||
with open('child_send.txt', 'w') as f_send:
|
||||
with open('child_read.txt', 'w') as f_read:
|
||||
child.logfile_send = f_send
|
||||
child.logfile_read = f_read
|
||||
self.spawnLldbMi(args = None)
|
||||
|
||||
child.sendline("000-file-exec-and-symbols " + self.myexe)
|
||||
child.expect("000\^done")
|
||||
# Load executable
|
||||
self.runCmd("000-file-exec-and-symbols %s" % self.myexe)
|
||||
self.expect("000\^done")
|
||||
|
||||
child.sendline("100000001-break-insert -f a_MyFunction")
|
||||
child.expect("100000001\^done,bkpt={number=\"1\"")
|
||||
# Run to main
|
||||
self.runCmd("100000001-break-insert -f a_MyFunction")
|
||||
self.expect("100000001\^done,bkpt={number=\"1\"")
|
||||
self.runCmd("2-exec-run")
|
||||
self.expect("2\^running")
|
||||
self.expect("\*stopped,reason=\"breakpoint-hit\"")
|
||||
|
||||
child.sendline("2-exec-run")
|
||||
child.expect("2\^running")
|
||||
child.expect("\*stopped,reason=\"breakpoint-hit\"")
|
||||
|
||||
child.sendline("0000000000000000000003-exec-continue")
|
||||
child.expect("0000000000000000000003\^running")
|
||||
child.expect("\*stopped,reason=\"exited-normally\"")
|
||||
|
||||
# Now that the necessary logging is done, restore logfile to None to
|
||||
# stop further logging.
|
||||
child.logfile_send = None
|
||||
child.logfile_read = None
|
||||
|
||||
with open('child_send.txt', 'r') as fs:
|
||||
if self.TraceOn():
|
||||
print "\n\nContents of child_send.txt:"
|
||||
print fs.read()
|
||||
with open('child_read.txt', 'r') as fr:
|
||||
from_child = fr.read()
|
||||
if self.TraceOn():
|
||||
print "\n\nContents of child_read.txt:"
|
||||
print from_child
|
||||
# Exit
|
||||
self.runCmd("0000000000000000000003-exec-continue")
|
||||
self.expect("0000000000000000000003\^running")
|
||||
self.expect("\*stopped,reason=\"exited-normally\"")
|
||||
|
||||
if __name__ == '__main__':
|
||||
import atexit
|
||||
lldb.SBDebugger.Initialize()
|
||||
atexit.register(lambda: lldb.SBDebugger.Terminate())
|
||||
unittest2.main()
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
"""
|
||||
Base class for lldb-mi test cases.
|
||||
"""
|
||||
|
||||
from lldbtest import *
|
||||
import pexpect
|
||||
import unittest2
|
||||
|
||||
class MiTestCaseBase(Base):
|
||||
|
||||
mydir = Base.compute_mydir(__file__)
|
||||
myexe = "a.out"
|
||||
mylog = "child.log"
|
||||
|
||||
@classmethod
|
||||
def classCleanup(cls):
|
||||
TestBase.RemoveTempFile(cls.myexe)
|
||||
TestBase.RemoveTempFile(cls.mylog)
|
||||
|
||||
def setUp(self):
|
||||
Base.setUp(self)
|
||||
self.buildDefault()
|
||||
self.child_prompt = "(gdb)"
|
||||
|
||||
def tearDown(self):
|
||||
if self.TraceOn():
|
||||
print "\n\nContents of %s:" % self.mylog
|
||||
print open(self.mylog, "r").read()
|
||||
Base.tearDown(self)
|
||||
|
||||
def spawnLldbMi(self, args=None):
|
||||
self.child = pexpect.spawn("%s --interpreter %s" % (
|
||||
self.lldbMiExec, args if args else ""))
|
||||
self.child.setecho(True)
|
||||
self.child.logfile_read = open(self.mylog, "w")
|
||||
|
||||
def runCmd(self, cmd):
|
||||
self.child.sendline(cmd)
|
||||
|
||||
def expect(self, pattern, *args, **kwargs):
|
||||
self.child.expect(pattern, *args, **kwargs)
|
Loading…
Reference in New Issue