2013-05-14 19:13:25 +00:00
|
|
|
"""Test the lldb public C++ api breakpoint callbacks. """
|
|
|
|
|
|
|
|
import os, re, StringIO
|
|
|
|
import unittest2
|
|
|
|
from lldbtest import *
|
|
|
|
import lldbutil
|
|
|
|
import subprocess
|
|
|
|
|
|
|
|
class SBBreakpointCallbackCase(TestBase):
|
|
|
|
|
2013-12-10 23:19:29 +00:00
|
|
|
mydir = TestBase.compute_mydir(__file__)
|
2013-05-14 19:13:25 +00:00
|
|
|
|
|
|
|
def setUp(self):
|
|
|
|
TestBase.setUp(self)
|
|
|
|
self.lib_dir = os.environ["LLDB_LIB_DIR"]
|
2015-03-27 20:47:35 +00:00
|
|
|
self.implib_dir = os.environ["LLDB_IMPLIB_DIR"]
|
2013-05-14 19:13:25 +00:00
|
|
|
self.inferior = 'inferior_program'
|
2015-05-04 00:17:53 +00:00
|
|
|
if self.getLldbArchitecture() == self.getArchitecture():
|
|
|
|
self.buildProgram('inferior.cpp', self.inferior)
|
|
|
|
self.addTearDownHook(lambda: os.remove(self.inferior))
|
2013-05-14 19:13:25 +00:00
|
|
|
|
2014-09-18 21:32:05 +00:00
|
|
|
@skipIfRemote
|
2014-10-06 21:42:22 +00:00
|
|
|
@skipIfNoSBHeaders
|
2015-05-04 03:53:22 +00:00
|
|
|
@expectedFailureAll("llvm.org/pr23139", oslist=["linux"], compiler="gcc", compiler_version=[">=","4.9"], archs=["x86_64"])
|
2013-05-14 19:13:25 +00:00
|
|
|
def test_breakpoint_callback(self):
|
|
|
|
"""Test the that SBBreakpoint callback is invoked when a breakpoint is hit. """
|
|
|
|
self.build_and_test('driver.cpp test_breakpoint_callback.cpp',
|
|
|
|
'test_breakpoint_callback')
|
|
|
|
|
2014-09-18 21:32:05 +00:00
|
|
|
@skipIfRemote
|
2014-10-06 21:42:22 +00:00
|
|
|
@skipIfNoSBHeaders
|
2015-04-21 01:15:47 +00:00
|
|
|
@expectedFailureAll("llvm.org/pr23139", oslist=["linux"], compiler="gcc", compiler_version=[">=","4.9"], archs=["x86_64"])
|
2013-05-14 19:13:25 +00:00
|
|
|
def test_sb_api_listener_event_description(self):
|
|
|
|
""" Test the description of an SBListener breakpoint event is valid."""
|
|
|
|
self.build_and_test('driver.cpp listener_test.cpp test_listener_event_description.cpp',
|
|
|
|
'test_listener_event_description')
|
|
|
|
pass
|
|
|
|
|
2014-09-18 21:32:05 +00:00
|
|
|
@skipIfRemote
|
2014-10-06 21:42:22 +00:00
|
|
|
@skipIfNoSBHeaders
|
2015-04-21 01:15:47 +00:00
|
|
|
@expectedFailureAll("llvm.org/pr23139", oslist=["linux"], compiler="gcc", compiler_version=[">=","4.9"], archs=["x86_64"])
|
2013-05-14 19:13:25 +00:00
|
|
|
def test_sb_api_listener_event_process_state(self):
|
|
|
|
""" Test that a registered SBListener receives events when a process
|
|
|
|
changes state.
|
|
|
|
"""
|
|
|
|
self.build_and_test('driver.cpp listener_test.cpp test_listener_event_process_state.cpp',
|
|
|
|
'test_listener_event_process_state')
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
2014-09-18 21:32:05 +00:00
|
|
|
@skipIfRemote
|
2014-10-06 21:42:22 +00:00
|
|
|
@skipIfNoSBHeaders
|
2015-04-21 01:15:47 +00:00
|
|
|
@expectedFailureAll("llvm.org/pr23139", oslist=["linux"], compiler="gcc", compiler_version=[">=","4.9"], archs=["x86_64"])
|
2013-05-14 19:13:25 +00:00
|
|
|
def test_sb_api_listener_resume(self):
|
|
|
|
""" Test that a process can be resumed from a non-main thread. """
|
|
|
|
self.build_and_test('driver.cpp listener_test.cpp test_listener_resume.cpp',
|
|
|
|
'test_listener_resume')
|
|
|
|
pass
|
|
|
|
|
|
|
|
def build_and_test(self, sources, test_name, args = None):
|
|
|
|
""" Build LLDB test from sources, and run expecting 0 exit code """
|
2015-05-04 00:17:53 +00:00
|
|
|
|
|
|
|
# These tests link against host lldb API.
|
|
|
|
# Compiler's target triple must match liblldb triple
|
|
|
|
# because remote is disabled, we can assume that the os is the same
|
|
|
|
# still need to check architecture
|
|
|
|
if self.getLldbArchitecture() != self.getArchitecture():
|
|
|
|
self.skipTest("This test is only run if the target arch is the same as the lldb binary arch")
|
|
|
|
|
2013-05-14 19:13:25 +00:00
|
|
|
self.buildDriver(sources, test_name)
|
2013-05-15 01:12:43 +00:00
|
|
|
self.addTearDownHook(lambda: os.remove(test_name))
|
2013-05-14 19:13:25 +00:00
|
|
|
|
2015-01-22 20:03:21 +00:00
|
|
|
test_exe = os.path.join(os.getcwd(), test_name)
|
|
|
|
self.signBinary(test_exe)
|
|
|
|
exe = [test_exe, self.inferior]
|
2013-05-14 19:13:25 +00:00
|
|
|
|
2013-08-26 23:57:52 +00:00
|
|
|
env = {self.dylibPath : self.getLLDBLibraryEnvVal()}
|
2013-05-14 19:13:25 +00:00
|
|
|
if self.TraceOn():
|
|
|
|
print "Running test %s" % " ".join(exe)
|
2013-08-26 23:57:52 +00:00
|
|
|
check_call(exe, env=env)
|
|
|
|
else:
|
|
|
|
with open(os.devnull, 'w') as fnull:
|
|
|
|
check_call(exe, env=env, stdout=fnull, stderr=fnull)
|
2013-05-14 19:13:25 +00:00
|
|
|
|
|
|
|
def build_program(self, sources, program):
|
|
|
|
return self.buildDriver(sources, program)
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
import atexit
|
|
|
|
lldb.SBDebugger.Initialize()
|
|
|
|
atexit.register(lambda: lldb.SBDebugger.Terminate())
|
|
|
|
unittest2.main()
|