*** This commit represents a complete reformatting of the LLDB source code
*** to conform to clang-format’s LLVM style. This kind of mass change has
*** two obvious implications:
Firstly, merging this particular commit into a downstream fork may be a huge
effort. Alternatively, it may be worth merging all changes up to this commit,
performing the same reformatting operation locally, and then discarding the
merge for this particular commit. The commands used to accomplish this
reformatting were as follows (with current working directory as the root of
the repository):
find . \( -iname "*.c" -or -iname "*.cpp" -or -iname "*.h" -or -iname "*.mm" \) -exec clang-format -i {} +
find . -iname "*.py" -exec autopep8 --in-place --aggressive --aggressive {} + ;
The version of clang-format used was 3.9.0, and autopep8 was 1.2.4.
Secondly, “blame” style tools will generally point to this commit instead of
a meaningful prior commit. There are alternatives available that will attempt
to look through this change and find the appropriate prior commit. YMMV.
llvm-svn: 280751
This commit is contained in:
@@ -4,6 +4,7 @@ import inspect
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
||||
def find_lldb_root():
|
||||
lldb_root = os.path.dirname(inspect.getfile(inspect.currentframe()))
|
||||
while True:
|
||||
|
||||
@@ -14,6 +14,7 @@ import io
|
||||
# Third party modules
|
||||
import six
|
||||
|
||||
|
||||
def _encoded_read(old_read, encoding):
|
||||
def impl(size):
|
||||
result = old_read(size)
|
||||
@@ -24,6 +25,7 @@ def _encoded_read(old_read, encoding):
|
||||
return result
|
||||
return impl
|
||||
|
||||
|
||||
def _encoded_write(old_write, encoding):
|
||||
def impl(s):
|
||||
# If we were asked to write a `str` (in Py2) or a `bytes` (in Py3) decode it
|
||||
@@ -38,9 +40,24 @@ Create a Text I/O file object that can be written to with either unicode strings
|
||||
under Python 2 and Python 3, and automatically encodes and decodes as necessary to return the
|
||||
native string type for the current Python version
|
||||
'''
|
||||
def open(file, encoding, mode='r', buffering=-1, errors=None, newline=None, closefd=True):
|
||||
wrapped_file = io.open(file, mode=mode, buffering=buffering, encoding=encoding,
|
||||
errors=errors, newline=newline, closefd=closefd)
|
||||
|
||||
|
||||
def open(
|
||||
file,
|
||||
encoding,
|
||||
mode='r',
|
||||
buffering=-1,
|
||||
errors=None,
|
||||
newline=None,
|
||||
closefd=True):
|
||||
wrapped_file = io.open(
|
||||
file,
|
||||
mode=mode,
|
||||
buffering=buffering,
|
||||
encoding=encoding,
|
||||
errors=errors,
|
||||
newline=newline,
|
||||
closefd=closefd)
|
||||
new_read = _encoded_read(getattr(wrapped_file, 'read'), encoding)
|
||||
new_write = _encoded_write(getattr(wrapped_file, 'write'), encoding)
|
||||
setattr(wrapped_file, 'read', new_read)
|
||||
|
||||
@@ -31,6 +31,7 @@ def _find_file_in_paths(paths, exe_basename):
|
||||
return os.path.normcase(trial_exe_path)
|
||||
return None
|
||||
|
||||
|
||||
def find_executable(executable):
|
||||
"""Finds the specified executable in the PATH or known good locations."""
|
||||
|
||||
@@ -59,6 +60,6 @@ def find_executable(executable):
|
||||
|
||||
if not result or len(result) < 1:
|
||||
raise os.OSError(
|
||||
"failed to find exe='%s' in paths='%s'" % (executable, paths_to_check))
|
||||
"failed to find exe='%s' in paths='%s'" %
|
||||
(executable, paths_to_check))
|
||||
return result
|
||||
|
||||
|
||||
@@ -8,9 +8,17 @@ import inspect
|
||||
|
||||
# LLDB modules
|
||||
|
||||
|
||||
def requires_self(func):
|
||||
func_argc = len(inspect.getargspec(func).args)
|
||||
if func_argc == 0 or (getattr(func,'im_self', None) is not None) or (hasattr(func, '__self__')):
|
||||
if func_argc == 0 or (
|
||||
getattr(
|
||||
func,
|
||||
'im_self',
|
||||
None) is not None) or (
|
||||
hasattr(
|
||||
func,
|
||||
'__self__')):
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
@@ -22,9 +22,8 @@ def is_compiler_clang_with_gmodules(compiler_path):
|
||||
else:
|
||||
# Check the compiler help for the -gmodules option.
|
||||
clang_help = os.popen("%s --help" % compiler_path).read()
|
||||
return GMODULES_HELP_REGEX.search(clang_help, re.DOTALL) is not None
|
||||
return GMODULES_HELP_REGEX.search(
|
||||
clang_help, re.DOTALL) is not None
|
||||
|
||||
GMODULES_SUPPORT_MAP[compiler_path] = _gmodules_supported_internal()
|
||||
return GMODULES_SUPPORT_MAP[compiler_path]
|
||||
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
# Provides a with-style resource handler for optionally-None resources
|
||||
# ====================================================================
|
||||
|
||||
|
||||
class optional_with(object):
|
||||
# pylint: disable=too-few-public-methods
|
||||
# This is a wrapper - it is not meant to provide any extra methods.
|
||||
@@ -39,6 +40,7 @@ class optional_with(object):
|
||||
forget the try/finally using optional_with(), since
|
||||
the with syntax can be used.
|
||||
"""
|
||||
|
||||
def __init__(self, wrapped_object):
|
||||
self.wrapped_object = wrapped_object
|
||||
|
||||
|
||||
@@ -10,11 +10,16 @@ else:
|
||||
def get_command_status_output(command):
|
||||
try:
|
||||
import subprocess
|
||||
return (0, subprocess.check_output(command, shell=True, universal_newlines=True))
|
||||
return (
|
||||
0,
|
||||
subprocess.check_output(
|
||||
command,
|
||||
shell=True,
|
||||
universal_newlines=True))
|
||||
except subprocess.CalledProcessError as e:
|
||||
return (e.returncode, e.output)
|
||||
|
||||
def get_command_output(command):
|
||||
return get_command_status_output(command)[1]
|
||||
|
||||
cmp_ = lambda x, y: (x > y) - (x < y)
|
||||
cmp_ = lambda x, y: (x > y) - (x < y)
|
||||
|
||||
@@ -14,6 +14,7 @@ import socket
|
||||
# LLDB modules
|
||||
import use_lldb_suite
|
||||
|
||||
|
||||
def recvall(sock, size):
|
||||
bytes = io.BytesIO()
|
||||
while size > 0:
|
||||
|
||||
@@ -5,13 +5,13 @@ Verify the default cache line size for android targets
|
||||
from __future__ import print_function
|
||||
|
||||
|
||||
|
||||
import os
|
||||
import lldb
|
||||
from lldbsuite.test.decorators import *
|
||||
from lldbsuite.test.lldbtest import *
|
||||
from lldbsuite.test import lldbutil
|
||||
|
||||
|
||||
class DefaultCacheLineSizeTestCase(TestBase):
|
||||
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
@@ -24,15 +24,23 @@ class DefaultCacheLineSizeTestCase(TestBase):
|
||||
self.assertTrue(target and target.IsValid(), "Target is valid")
|
||||
|
||||
breakpoint = target.BreakpointCreateByName("main")
|
||||
self.assertTrue(breakpoint and breakpoint.IsValid(), "Breakpoint is valid")
|
||||
self.assertTrue(
|
||||
breakpoint and breakpoint.IsValid(),
|
||||
"Breakpoint is valid")
|
||||
|
||||
# Run the program.
|
||||
process = target.LaunchSimple(None, None, self.get_process_working_directory())
|
||||
process = target.LaunchSimple(
|
||||
None, None, self.get_process_working_directory())
|
||||
self.assertTrue(process and process.IsValid(), PROCESS_IS_VALID)
|
||||
self.assertEqual(process.GetState(), lldb.eStateStopped, PROCESS_STOPPED)
|
||||
self.assertEqual(
|
||||
process.GetState(),
|
||||
lldb.eStateStopped,
|
||||
PROCESS_STOPPED)
|
||||
|
||||
# check the setting value
|
||||
self.expect("settings show target.process.memory-cache-line-size", patterns=[" = 2048"])
|
||||
self.expect(
|
||||
"settings show target.process.memory-cache-line-size",
|
||||
patterns=[" = 2048"])
|
||||
|
||||
# Run to completion.
|
||||
process.Continue()
|
||||
|
||||
@@ -6,12 +6,13 @@ should compile and link with the LLDB framework."""
|
||||
from __future__ import print_function
|
||||
|
||||
|
||||
|
||||
import os, re
|
||||
import os
|
||||
import re
|
||||
from lldbsuite.test.decorators import *
|
||||
from lldbsuite.test.lldbtest import *
|
||||
from lldbsuite.test import lldbutil
|
||||
|
||||
|
||||
class SBDirCheckerCase(TestBase):
|
||||
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
@@ -30,7 +31,8 @@ class SBDirCheckerCase(TestBase):
|
||||
if not (self.platformIsDarwin() and self.getArchitecture() == "x86_64"):
|
||||
self.skipTest("This test is only for LLDB.framework built 64-bit")
|
||||
if self.getArchitecture() == "i386":
|
||||
self.skipTest("LLDB is 64-bit and cannot be linked to 32-bit test program.")
|
||||
self.skipTest(
|
||||
"LLDB is 64-bit and cannot be linked to 32-bit test program.")
|
||||
|
||||
# Generate main.cpp, build it, and execute.
|
||||
self.generate_main_cpp()
|
||||
@@ -43,7 +45,8 @@ class SBDirCheckerCase(TestBase):
|
||||
with open(temp, 'r') as f:
|
||||
content = f.read()
|
||||
|
||||
public_api_dir = os.path.join(os.environ["LLDB_SRC"], "include", "lldb", "API")
|
||||
public_api_dir = os.path.join(
|
||||
os.environ["LLDB_SRC"], "include", "lldb", "API")
|
||||
|
||||
# Look under the include/lldb/API directory and add #include statements
|
||||
# for all the SB API headers.
|
||||
@@ -51,10 +54,11 @@ class SBDirCheckerCase(TestBase):
|
||||
# For different platforms, the include statement can vary.
|
||||
if self.platformIsDarwin():
|
||||
include_stmt = "'#include <%s>' % os.path.join('LLDB', header)"
|
||||
if self.getPlatform() == "freebsd" or self.getPlatform() == "linux" or os.environ.get('LLDB_BUILD_TYPE') == 'Makefile':
|
||||
if self.getPlatform() == "freebsd" or self.getPlatform(
|
||||
) == "linux" or os.environ.get('LLDB_BUILD_TYPE') == 'Makefile':
|
||||
include_stmt = "'#include <%s>' % os.path.join(public_api_dir, header)"
|
||||
list = [eval(include_stmt) for header in public_headers if (header.startswith("SB") and
|
||||
header.endswith(".h"))]
|
||||
list = [eval(include_stmt) for header in public_headers if (
|
||||
header.startswith("SB") and header.endswith(".h"))]
|
||||
includes = '\n'.join(list)
|
||||
new_content = content.replace('%include_SB_APIs%', includes)
|
||||
src = os.path.join(os.getcwd(), self.source)
|
||||
@@ -69,21 +73,27 @@ class SBDirCheckerCase(TestBase):
|
||||
exe = os.path.join(os.getcwd(), exe_name)
|
||||
self.runCmd("file %s" % exe, CURRENT_EXECUTABLE_SET)
|
||||
|
||||
self.line_to_break = line_number(self.source, '// Set breakpoint here.')
|
||||
self.line_to_break = line_number(
|
||||
self.source, '// Set breakpoint here.')
|
||||
|
||||
env_cmd = "settings set target.env-vars %s=%s" %(self.dylibPath, self.getLLDBLibraryEnvVal())
|
||||
env_cmd = "settings set target.env-vars %s=%s" % (
|
||||
self.dylibPath, self.getLLDBLibraryEnvVal())
|
||||
if self.TraceOn():
|
||||
print("Set environment to: ", env_cmd)
|
||||
self.runCmd(env_cmd)
|
||||
self.addTearDownHook(lambda: self.dbg.HandleCommand("settings remove target.env-vars %s" % self.dylibPath))
|
||||
self.addTearDownHook(
|
||||
lambda: self.dbg.HandleCommand(
|
||||
"settings remove target.env-vars %s" %
|
||||
self.dylibPath))
|
||||
|
||||
lldbutil.run_break_set_by_file_and_line (self, self.source, self.line_to_break, num_expected_locations = -1)
|
||||
lldbutil.run_break_set_by_file_and_line(
|
||||
self, self.source, self.line_to_break, num_expected_locations=-1)
|
||||
|
||||
self.runCmd("run", RUN_SUCCEEDED)
|
||||
|
||||
# The stop reason of the thread should be breakpoint.
|
||||
self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
|
||||
substrs = ['stopped',
|
||||
'stop reason = breakpoint'])
|
||||
substrs=['stopped',
|
||||
'stop reason = breakpoint'])
|
||||
|
||||
self.runCmd('frame variable')
|
||||
|
||||
@@ -15,6 +15,7 @@ from lldbsuite.test import lldbutil
|
||||
|
||||
import six
|
||||
|
||||
|
||||
class ListenToModuleLoadedEvents (TestBase):
|
||||
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
@@ -24,14 +25,17 @@ class ListenToModuleLoadedEvents (TestBase):
|
||||
TestBase.setUp(self)
|
||||
self.build()
|
||||
|
||||
def test_receiving_breakpoint_added (self):
|
||||
def test_receiving_breakpoint_added(self):
|
||||
"""Test that we get breakpoint added events, waiting on event classes on the debugger"""
|
||||
|
||||
my_listener = lldb.SBListener("test_listener")
|
||||
|
||||
my_listener.StartListeningForEventClass(self.dbg, lldb.SBTarget.GetBroadcasterClassName(), lldb.SBTarget.eBroadcastBitBreakpointChanged)
|
||||
|
||||
exe = os.path.join (os.getcwd(), "a.out")
|
||||
my_listener.StartListeningForEventClass(
|
||||
self.dbg,
|
||||
lldb.SBTarget.GetBroadcasterClassName(),
|
||||
lldb.SBTarget.eBroadcastBitBreakpointChanged)
|
||||
|
||||
exe = os.path.join(os.getcwd(), "a.out")
|
||||
|
||||
target = self.dbg.CreateTarget(exe)
|
||||
|
||||
@@ -39,17 +43,29 @@ class ListenToModuleLoadedEvents (TestBase):
|
||||
|
||||
event = lldb.SBEvent()
|
||||
my_listener.WaitForEvent(1, event)
|
||||
|
||||
|
||||
self.assertTrue(event.IsValid(), "Got a valid event.")
|
||||
self.assertTrue(lldb.SBBreakpoint.EventIsBreakpointEvent(event), "It is a breakpoint event.")
|
||||
self.assertTrue(lldb.SBBreakpoint.GetBreakpointEventTypeFromEvent(event) == lldb.eBreakpointEventTypeAdded, "It is a breakpoint added event.")
|
||||
self.assertTrue(bkpt == lldb.SBBreakpoint.GetBreakpointFromEvent(event), "It is our breakpoint.")
|
||||
self.assertTrue(
|
||||
lldb.SBBreakpoint.EventIsBreakpointEvent(event),
|
||||
"It is a breakpoint event.")
|
||||
self.assertTrue(lldb.SBBreakpoint.GetBreakpointEventTypeFromEvent(
|
||||
event) == lldb.eBreakpointEventTypeAdded, "It is a breakpoint added event.")
|
||||
self.assertTrue(
|
||||
bkpt == lldb.SBBreakpoint.GetBreakpointFromEvent(event),
|
||||
"It is our breakpoint.")
|
||||
|
||||
# Now make sure if we stop listening for events we don't get them:
|
||||
|
||||
my_listener.StopListeningForEventClass(self.dbg, lldb.SBTarget.GetBroadcasterClassName(), lldb.SBTarget.eBroadcastBitBreakpointChanged)
|
||||
my_listener.StopListeningForEvents(target.GetBroadcaster(), lldb.SBTarget.eBroadcastBitBreakpointChanged)
|
||||
my_listener.StopListeningForEventClass(
|
||||
self.dbg,
|
||||
lldb.SBTarget.GetBroadcasterClassName(),
|
||||
lldb.SBTarget.eBroadcastBitBreakpointChanged)
|
||||
my_listener.StopListeningForEvents(
|
||||
target.GetBroadcaster(),
|
||||
lldb.SBTarget.eBroadcastBitBreakpointChanged)
|
||||
|
||||
bkpt2 = target.BreakpointCreateByName("main")
|
||||
my_listener.WaitForEvent(1, event)
|
||||
self.assertTrue(not event.IsValid(), "We don't get events we aren't listening to.")
|
||||
self.assertTrue(
|
||||
not event.IsValid(),
|
||||
"We don't get events we aren't listening to.")
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
from __future__ import print_function
|
||||
|
||||
|
||||
|
||||
import os, re
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
|
||||
import lldb
|
||||
@@ -12,16 +12,24 @@ from lldbsuite.test.decorators import *
|
||||
from lldbsuite.test.lldbtest import *
|
||||
from lldbsuite.test import lldbutil
|
||||
|
||||
|
||||
class TestMultipleSimultaneousDebuggers(TestBase):
|
||||
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
|
||||
@skipIfNoSBHeaders
|
||||
@expectedFlakeyDarwin()
|
||||
@expectedFailureAll(archs="i[3-6]86", bugnumber="multi-process-driver.cpp creates an x64 target")
|
||||
@expectedFailureAll(oslist=["windows", "linux", "freebsd"], bugnumber="llvm.org/pr20282")
|
||||
@expectedFailureAll(
|
||||
archs="i[3-6]86",
|
||||
bugnumber="multi-process-driver.cpp creates an x64 target")
|
||||
@expectedFailureAll(
|
||||
oslist=[
|
||||
"windows",
|
||||
"linux",
|
||||
"freebsd"],
|
||||
bugnumber="llvm.org/pr20282")
|
||||
def test_multiple_debuggers(self):
|
||||
env = {self.dylibPath : self.getLLDBLibraryEnvVal()}
|
||||
env = {self.dylibPath: self.getLLDBLibraryEnvVal()}
|
||||
|
||||
self.driver_exe = os.path.join(os.getcwd(), "multi-process-driver")
|
||||
self.buildDriver('multi-process-driver.cpp', self.driver_exe)
|
||||
@@ -41,4 +49,5 @@ class TestMultipleSimultaneousDebuggers(TestBase):
|
||||
check_call([self.driver_exe, self.inferior_exe], env=env)
|
||||
else:
|
||||
with open(os.devnull, 'w') as fnull:
|
||||
check_call([self.driver_exe, self.inferior_exe], env=env, stdout=fnull, stderr=fnull)
|
||||
check_call([self.driver_exe, self.inferior_exe],
|
||||
env=env, stdout=fnull, stderr=fnull)
|
||||
|
||||
@@ -5,19 +5,22 @@ from __future__ import print_function
|
||||
# __package__ = "lldbsuite.test"
|
||||
|
||||
|
||||
import os, re
|
||||
import os
|
||||
import re
|
||||
from lldbsuite.test.decorators import *
|
||||
from lldbsuite.test.lldbtest import *
|
||||
from lldbsuite.test import lldbutil
|
||||
import subprocess
|
||||
|
||||
|
||||
class SBBreakpointCallbackCase(TestBase):
|
||||
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
|
||||
@skipIfRemote
|
||||
@skipIfNoSBHeaders
|
||||
@skipIfWindows # clang-cl does not support throw or catch (llvm.org/pr24538)
|
||||
# clang-cl does not support throw or catch (llvm.org/pr24538)
|
||||
@skipIfWindows
|
||||
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',
|
||||
@@ -25,40 +28,52 @@ class SBBreakpointCallbackCase(TestBase):
|
||||
|
||||
@skipIfRemote
|
||||
@skipIfNoSBHeaders
|
||||
@skipIfWindows # clang-cl does not support throw or catch (llvm.org/pr24538)
|
||||
# clang-cl does not support throw or catch (llvm.org/pr24538)
|
||||
@skipIfWindows
|
||||
@expectedFlakeyFreeBSD
|
||||
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')
|
||||
self.build_and_test(
|
||||
'driver.cpp listener_test.cpp test_listener_event_description.cpp',
|
||||
'test_listener_event_description')
|
||||
pass
|
||||
|
||||
@skipIfRemote
|
||||
@skipIfNoSBHeaders
|
||||
@skipIfWindows # clang-cl does not support throw or catch (llvm.org/pr24538)
|
||||
# clang-cl does not support throw or catch (llvm.org/pr24538)
|
||||
@skipIfWindows
|
||||
@expectedFlakeyFreeBSD
|
||||
@expectedFailureAll("llvm.org/pr23139", oslist=["linux"], compiler="gcc", compiler_version=[">=","4.9"], archs=["x86_64"])
|
||||
@expectedFailureAll(
|
||||
"llvm.org/pr23139",
|
||||
oslist=["linux"],
|
||||
compiler="gcc",
|
||||
compiler_version=[
|
||||
">=",
|
||||
"4.9"],
|
||||
archs=["x86_64"])
|
||||
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')
|
||||
self.build_and_test(
|
||||
'driver.cpp listener_test.cpp test_listener_event_process_state.cpp',
|
||||
'test_listener_event_process_state')
|
||||
pass
|
||||
|
||||
|
||||
@skipIfRemote
|
||||
@skipIfNoSBHeaders
|
||||
@skipIfWindows # clang-cl does not support throw or catch (llvm.org/pr24538)
|
||||
# clang-cl does not support throw or catch (llvm.org/pr24538)
|
||||
@skipIfWindows
|
||||
@expectedFlakeyFreeBSD
|
||||
@expectedFailureAll(oslist=["linux"])
|
||||
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')
|
||||
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):
|
||||
def build_and_test(self, sources, test_name, args=None):
|
||||
""" Build LLDB test from sources, and run expecting 0 exit code """
|
||||
|
||||
# These tests link against host lldb API.
|
||||
@@ -66,7 +81,8 @@ class SBBreakpointCallbackCase(TestBase):
|
||||
# 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")
|
||||
self.skipTest(
|
||||
"This test is only run if the target arch is the same as the lldb binary arch")
|
||||
|
||||
self.inferior = 'inferior_program'
|
||||
self.buildProgram('inferior.cpp', self.inferior)
|
||||
@@ -79,7 +95,7 @@ class SBBreakpointCallbackCase(TestBase):
|
||||
self.signBinary(test_exe)
|
||||
exe = [test_exe, self.inferior]
|
||||
|
||||
env = {self.dylibPath : self.getLLDBLibraryEnvVal()}
|
||||
env = {self.dylibPath: self.getLLDBLibraryEnvVal()}
|
||||
if self.TraceOn():
|
||||
print("Running test %s" % " ".join(exe))
|
||||
check_call(exe, env=env)
|
||||
|
||||
@@ -5,52 +5,53 @@ Test some ARM instruction emulation.
|
||||
from __future__ import print_function
|
||||
|
||||
|
||||
|
||||
import os, time
|
||||
import os
|
||||
import time
|
||||
import lldb
|
||||
from lldbsuite.test.decorators import *
|
||||
from lldbsuite.test.lldbtest import *
|
||||
from lldbsuite.test import lldbutil
|
||||
|
||||
|
||||
class ARMEmulationTestCase(TestBase):
|
||||
|
||||
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
|
||||
@no_debug_info_test
|
||||
def test_thumb_emulations (self):
|
||||
current_dir = os.getcwd();
|
||||
test_dir = os.path.join (current_dir, "new-test-files")
|
||||
files = os.listdir (test_dir)
|
||||
def test_thumb_emulations(self):
|
||||
current_dir = os.getcwd()
|
||||
test_dir = os.path.join(current_dir, "new-test-files")
|
||||
files = os.listdir(test_dir)
|
||||
thumb_files = list()
|
||||
for f in files:
|
||||
if '-thumb.dat' in f:
|
||||
thumb_files.append (f)
|
||||
|
||||
thumb_files.append(f)
|
||||
|
||||
for f in thumb_files:
|
||||
test_file = os.path.join (test_dir, f)
|
||||
self.run_a_single_test (test_file)
|
||||
test_file = os.path.join(test_dir, f)
|
||||
self.run_a_single_test(test_file)
|
||||
|
||||
@no_debug_info_test
|
||||
def test_arm_emulations (self):
|
||||
current_dir = os.getcwd();
|
||||
test_dir = os.path.join (current_dir, "new-test-files")
|
||||
files = os.listdir (test_dir)
|
||||
def test_arm_emulations(self):
|
||||
current_dir = os.getcwd()
|
||||
test_dir = os.path.join(current_dir, "new-test-files")
|
||||
files = os.listdir(test_dir)
|
||||
arm_files = list()
|
||||
for f in files:
|
||||
if '-arm.dat' in f:
|
||||
arm_files.append (f)
|
||||
|
||||
for f in arm_files:
|
||||
test_file = os.path.join (test_dir, f)
|
||||
self.run_a_single_test (test_file)
|
||||
arm_files.append(f)
|
||||
|
||||
def run_a_single_test (self, filename):
|
||||
insn = lldb.SBInstruction ();
|
||||
stream = lldb.SBStream ();
|
||||
success = insn.TestEmulation (stream, filename);
|
||||
output = stream.GetData();
|
||||
for f in arm_files:
|
||||
test_file = os.path.join(test_dir, f)
|
||||
self.run_a_single_test(test_file)
|
||||
|
||||
def run_a_single_test(self, filename):
|
||||
insn = lldb.SBInstruction()
|
||||
stream = lldb.SBStream()
|
||||
success = insn.TestEmulation(stream, filename)
|
||||
output = stream.GetData()
|
||||
if self.TraceOn():
|
||||
print('\nRunning test ' + os.path.basename(filename))
|
||||
print(output)
|
||||
|
||||
self.assertTrue (success, 'Emulation test succeeded.')
|
||||
self.assertTrue(success, 'Emulation test succeeded.')
|
||||
|
||||
@@ -3,112 +3,146 @@
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import math, os.path, re, sys, time, unittest
|
||||
import math
|
||||
import os.path
|
||||
import re
|
||||
import sys
|
||||
import time
|
||||
import unittest
|
||||
|
||||
|
||||
def setupSysPath():
|
||||
testPath = sys.path[0]
|
||||
rem = re.match("(^.*/)test$", testPath)
|
||||
if not rem:
|
||||
print("This script expects to reside in .../test.")
|
||||
sys.exit(-1)
|
||||
lldbBasePath = rem.group(1)
|
||||
lldbDebugPythonPath = "build/Debug/LLDB.framework/Resources/Python"
|
||||
lldbReleasePythonPath = "build/Release/LLDB.framework/Resources/Python"
|
||||
lldbPythonPath = None
|
||||
if os.path.isfile(lldbDebugPythonPath + "/lldb.py"):
|
||||
lldbPythonPath = lldbDebugPythonPath
|
||||
if os.path.isfile(lldbReleasePythonPath + "/lldb.py"):
|
||||
lldbPythonPath = lldbReleasePythonPath
|
||||
if not lldbPythonPath:
|
||||
print("This script requires lldb.py to be in either " + lldbDebugPythonPath, end='')
|
||||
print("or" + lldbReleasePythonPath)
|
||||
sys.exit(-1)
|
||||
sys.path.append(lldbPythonPath)
|
||||
testPath = sys.path[0]
|
||||
rem = re.match("(^.*/)test$", testPath)
|
||||
if not rem:
|
||||
print("This script expects to reside in .../test.")
|
||||
sys.exit(-1)
|
||||
lldbBasePath = rem.group(1)
|
||||
lldbDebugPythonPath = "build/Debug/LLDB.framework/Resources/Python"
|
||||
lldbReleasePythonPath = "build/Release/LLDB.framework/Resources/Python"
|
||||
lldbPythonPath = None
|
||||
if os.path.isfile(lldbDebugPythonPath + "/lldb.py"):
|
||||
lldbPythonPath = lldbDebugPythonPath
|
||||
if os.path.isfile(lldbReleasePythonPath + "/lldb.py"):
|
||||
lldbPythonPath = lldbReleasePythonPath
|
||||
if not lldbPythonPath:
|
||||
print(
|
||||
"This script requires lldb.py to be in either " +
|
||||
lldbDebugPythonPath,
|
||||
end='')
|
||||
print("or" + lldbReleasePythonPath)
|
||||
sys.exit(-1)
|
||||
sys.path.append(lldbPythonPath)
|
||||
|
||||
|
||||
def prettyTime(t):
|
||||
if t == 0.0:
|
||||
return "0s"
|
||||
if t < 0.000001:
|
||||
return ("%.3f" % (t * 1000000000.0)) + "ns"
|
||||
if t < 0.001:
|
||||
return ("%.3f" % (t * 1000000.0)) + "µs"
|
||||
if t < 1:
|
||||
return ("%.3f" % (t * 1000.0)) + "ms"
|
||||
return str(t) + "s"
|
||||
if t == 0.0:
|
||||
return "0s"
|
||||
if t < 0.000001:
|
||||
return ("%.3f" % (t * 1000000000.0)) + "ns"
|
||||
if t < 0.001:
|
||||
return ("%.3f" % (t * 1000000.0)) + "µs"
|
||||
if t < 1:
|
||||
return ("%.3f" % (t * 1000.0)) + "ms"
|
||||
return str(t) + "s"
|
||||
|
||||
|
||||
class ExecutionTimes:
|
||||
@classmethod
|
||||
def executionTimes(cls):
|
||||
if cls.m_executionTimes == None:
|
||||
cls.m_executionTimes = ExecutionTimes()
|
||||
for i in range(100):
|
||||
cls.m_executionTimes.start()
|
||||
cls.m_executionTimes.end("null")
|
||||
return cls.m_executionTimes
|
||||
def __init__(self):
|
||||
self.m_times = dict()
|
||||
def start(self):
|
||||
self.m_start = time.time()
|
||||
def end(self, component):
|
||||
e = time.time()
|
||||
if component not in self.m_times:
|
||||
self.m_times[component] = list()
|
||||
self.m_times[component].append(e - self.m_start)
|
||||
def dumpStats(self):
|
||||
for key in list(self.m_times.keys()):
|
||||
if len(self.m_times[key]):
|
||||
sampleMin = float('inf')
|
||||
sampleMax = float('-inf')
|
||||
sampleSum = 0.0
|
||||
sampleCount = 0.0
|
||||
for time in self.m_times[key]:
|
||||
if time > sampleMax:
|
||||
sampleMax = time
|
||||
if time < sampleMin:
|
||||
sampleMin = time
|
||||
sampleSum += time
|
||||
sampleCount += 1.0
|
||||
sampleMean = sampleSum / sampleCount
|
||||
sampleVariance = 0
|
||||
for time in self.m_times[key]:
|
||||
sampleVariance += (time - sampleMean) ** 2
|
||||
sampleVariance /= sampleCount
|
||||
sampleStandardDeviation = math.sqrt(sampleVariance)
|
||||
print(key + ": [" + prettyTime(sampleMin) + ", " + prettyTime(sampleMax) + "] ", end='')
|
||||
print("µ " + prettyTime(sampleMean) + ", σ " + prettyTime(sampleStandardDeviation))
|
||||
m_executionTimes = None
|
||||
|
||||
@classmethod
|
||||
def executionTimes(cls):
|
||||
if cls.m_executionTimes is None:
|
||||
cls.m_executionTimes = ExecutionTimes()
|
||||
for i in range(100):
|
||||
cls.m_executionTimes.start()
|
||||
cls.m_executionTimes.end("null")
|
||||
return cls.m_executionTimes
|
||||
|
||||
def __init__(self):
|
||||
self.m_times = dict()
|
||||
|
||||
def start(self):
|
||||
self.m_start = time.time()
|
||||
|
||||
def end(self, component):
|
||||
e = time.time()
|
||||
if component not in self.m_times:
|
||||
self.m_times[component] = list()
|
||||
self.m_times[component].append(e - self.m_start)
|
||||
|
||||
def dumpStats(self):
|
||||
for key in list(self.m_times.keys()):
|
||||
if len(self.m_times[key]):
|
||||
sampleMin = float('inf')
|
||||
sampleMax = float('-inf')
|
||||
sampleSum = 0.0
|
||||
sampleCount = 0.0
|
||||
for time in self.m_times[key]:
|
||||
if time > sampleMax:
|
||||
sampleMax = time
|
||||
if time < sampleMin:
|
||||
sampleMin = time
|
||||
sampleSum += time
|
||||
sampleCount += 1.0
|
||||
sampleMean = sampleSum / sampleCount
|
||||
sampleVariance = 0
|
||||
for time in self.m_times[key]:
|
||||
sampleVariance += (time - sampleMean) ** 2
|
||||
sampleVariance /= sampleCount
|
||||
sampleStandardDeviation = math.sqrt(sampleVariance)
|
||||
print(
|
||||
key +
|
||||
": [" +
|
||||
prettyTime(sampleMin) +
|
||||
", " +
|
||||
prettyTime(sampleMax) +
|
||||
"] ",
|
||||
end='')
|
||||
print(
|
||||
"µ " +
|
||||
prettyTime(sampleMean) +
|
||||
", σ " +
|
||||
prettyTime(sampleStandardDeviation))
|
||||
m_executionTimes = None
|
||||
|
||||
setupSysPath()
|
||||
|
||||
import lldb
|
||||
|
||||
|
||||
class LLDBTestCase(unittest.TestCase):
|
||||
def setUp(self):
|
||||
debugger = lldb.SBDebugger.Create()
|
||||
debugger.SetAsync(True)
|
||||
self.m_commandInterpreter = debugger.GetCommandInterpreter()
|
||||
if not self.m_commandInterpreter:
|
||||
print("Couldn't get the command interpreter")
|
||||
sys.exit(-1)
|
||||
def runCommand(self, command, component):
|
||||
res = lldb.SBCommandReturnObject()
|
||||
ExecutionTimes.executionTimes().start()
|
||||
self.m_commandInterpreter.HandleCommand(command, res, False)
|
||||
ExecutionTimes.executionTimes().end(component)
|
||||
if res.Succeeded():
|
||||
return res.GetOutput()
|
||||
else:
|
||||
self.fail("Command " + command + " returned an error")
|
||||
return None
|
||||
def getCategories(self):
|
||||
return []
|
||||
|
||||
def setUp(self):
|
||||
debugger = lldb.SBDebugger.Create()
|
||||
debugger.SetAsync(True)
|
||||
self.m_commandInterpreter = debugger.GetCommandInterpreter()
|
||||
if not self.m_commandInterpreter:
|
||||
print("Couldn't get the command interpreter")
|
||||
sys.exit(-1)
|
||||
|
||||
def runCommand(self, command, component):
|
||||
res = lldb.SBCommandReturnObject()
|
||||
ExecutionTimes.executionTimes().start()
|
||||
self.m_commandInterpreter.HandleCommand(command, res, False)
|
||||
ExecutionTimes.executionTimes().end(component)
|
||||
if res.Succeeded():
|
||||
return res.GetOutput()
|
||||
else:
|
||||
self.fail("Command " + command + " returned an error")
|
||||
return None
|
||||
|
||||
def getCategories(self):
|
||||
return []
|
||||
|
||||
|
||||
class SanityCheckTestCase(LLDBTestCase):
|
||||
def runTest(self):
|
||||
ret = self.runCommand("show arch", "show-arch")
|
||||
#print(ret)
|
||||
def getCategories(self):
|
||||
return []
|
||||
|
||||
def runTest(self):
|
||||
ret = self.runCommand("show arch", "show-arch")
|
||||
# print(ret)
|
||||
|
||||
def getCategories(self):
|
||||
return []
|
||||
|
||||
suite = unittest.TestLoader().loadTestsFromTestCase(SanityCheckTestCase)
|
||||
unittest.TextTestRunner(verbosity=2).run(suite)
|
||||
|
||||
@@ -17,14 +17,16 @@ See also bench-history.
|
||||
from __future__ import print_function
|
||||
from __future__ import absolute_import
|
||||
|
||||
import os, sys
|
||||
import os
|
||||
import sys
|
||||
import re
|
||||
from optparse import OptionParser
|
||||
|
||||
# dotest.py invocation with no '-e exe-path' uses lldb as the inferior program,
|
||||
# unless there is a mentioning of custom executable program.
|
||||
benches = [
|
||||
# Measure startup delays creating a target, setting a breakpoint, and run to breakpoint stop.
|
||||
# Measure startup delays creating a target, setting a breakpoint, and run
|
||||
# to breakpoint stop.
|
||||
'./dotest.py -v +b %E %X -n -p TestStartupDelays.py',
|
||||
|
||||
# Measure 'frame variable' response after stopping at a breakpoint.
|
||||
@@ -40,6 +42,7 @@ benches = [
|
||||
'./dotest.py -v +b -n %E -p TestDoAttachThenDisassembly.py'
|
||||
]
|
||||
|
||||
|
||||
def main():
|
||||
"""Read the items from 'benches' and run the command line one by one."""
|
||||
parser = OptionParser(usage="""\
|
||||
@@ -57,14 +60,14 @@ Run the standard benchmarks defined in the list named 'benches'.\
|
||||
|
||||
# Parses the options, if any.
|
||||
opts, args = parser.parse_args()
|
||||
|
||||
|
||||
print("Starting bench runner....")
|
||||
|
||||
for item in benches:
|
||||
command = item.replace('%E',
|
||||
'-e "%s"' % opts.exe if opts.exe else '')
|
||||
command = command.replace('%X',
|
||||
'-x "%s"' % opts.break_spec if opts.break_spec else '')
|
||||
command = command.replace('%X', '-x "%s"' %
|
||||
opts.break_spec if opts.break_spec else '')
|
||||
print("Running %s" % (command))
|
||||
os.system(command)
|
||||
|
||||
|
||||
@@ -5,14 +5,15 @@ Test lldb data formatter subsystem.
|
||||
from __future__ import print_function
|
||||
|
||||
|
||||
|
||||
import os, time
|
||||
import os
|
||||
import time
|
||||
import lldb
|
||||
from lldbsuite.test.decorators import *
|
||||
from lldbsuite.test.lldbbench import *
|
||||
from lldbsuite.test.lldbtest import *
|
||||
from lldbsuite.test import lldbutil
|
||||
|
||||
|
||||
class TestBenchmarkContinue(BenchBase):
|
||||
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
@@ -31,14 +32,16 @@ class TestBenchmarkContinue(BenchBase):
|
||||
"""Benchmark different ways to continue a process"""
|
||||
self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
|
||||
|
||||
bkpt = self.target().FindBreakpointByID(lldbutil.run_break_set_by_source_regexp (self, "// break here"))
|
||||
bkpt = self.target().FindBreakpointByID(
|
||||
lldbutil.run_break_set_by_source_regexp(
|
||||
self, "// break here"))
|
||||
|
||||
self.runCmd("run", RUN_SUCCEEDED)
|
||||
|
||||
# The stop reason of the thread should be breakpoint.
|
||||
self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
|
||||
substrs = ['stopped',
|
||||
'stop reason = breakpoint'])
|
||||
substrs=['stopped',
|
||||
'stop reason = breakpoint'])
|
||||
|
||||
# This is the function to remove the custom formats in order to have a
|
||||
# clean slate for the next test case.
|
||||
@@ -47,22 +50,24 @@ class TestBenchmarkContinue(BenchBase):
|
||||
self.runCmd('type summary clear', check=False)
|
||||
self.runCmd('type filter clear', check=False)
|
||||
self.runCmd('type synth clear', check=False)
|
||||
self.runCmd("settings set target.max-children-count 256", check=False)
|
||||
self.runCmd(
|
||||
"settings set target.max-children-count 256",
|
||||
check=False)
|
||||
|
||||
# Execute the cleanup function during test case tear down.
|
||||
self.addTearDownHook(cleanup)
|
||||
|
||||
|
||||
runCmd_sw = Stopwatch()
|
||||
lldbutil_sw = Stopwatch()
|
||||
|
||||
for i in range(0,15):
|
||||
for i in range(0, 15):
|
||||
runCmd_sw.start()
|
||||
self.runCmd("continue")
|
||||
runCmd_sw.stop()
|
||||
|
||||
for i in range(0,15):
|
||||
|
||||
for i in range(0, 15):
|
||||
lldbutil_sw.start()
|
||||
lldbutil.continue_to_breakpoint(self.process(), bkpt)
|
||||
lldbutil_sw.stop()
|
||||
|
||||
print("runCmd: %s\nlldbutil: %s" % (runCmd_sw,lldbutil_sw))
|
||||
|
||||
print("runCmd: %s\nlldbutil: %s" % (runCmd_sw, lldbutil_sw))
|
||||
|
||||
@@ -3,18 +3,20 @@
|
||||
from __future__ import print_function
|
||||
|
||||
|
||||
|
||||
import os, sys
|
||||
import os
|
||||
import sys
|
||||
import lldb
|
||||
from lldbsuite.test.decorators import *
|
||||
from lldbsuite.test.lldbbench import *
|
||||
from lldbsuite.test.lldbtest import *
|
||||
from lldbsuite.test import lldbutil
|
||||
|
||||
|
||||
def is_exe(fpath):
|
||||
"""Returns true if fpath is an executable."""
|
||||
return os.path.isfile(fpath) and os.access(fpath, os.X_OK)
|
||||
|
||||
|
||||
class DisassembleDriverMainLoop(BenchBase):
|
||||
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
@@ -42,7 +44,9 @@ class DisassembleDriverMainLoop(BenchBase):
|
||||
|
||||
@benchmarks_test
|
||||
@no_debug_info_test
|
||||
@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")
|
||||
def test_run_lldb_then_gdb(self):
|
||||
"""Test disassembly on a large function with lldb vs. gdb."""
|
||||
print()
|
||||
@@ -54,11 +58,13 @@ class DisassembleDriverMainLoop(BenchBase):
|
||||
print("lldb benchmark:", self.stopwatch)
|
||||
self.run_gdb_disassembly(self.exe, self.function, self.count)
|
||||
print("gdb benchmark:", self.stopwatch)
|
||||
print("lldb_avg/gdb_avg: %f" % (self.lldb_avg/self.gdb_avg))
|
||||
print("lldb_avg/gdb_avg: %f" % (self.lldb_avg / self.gdb_avg))
|
||||
|
||||
@benchmarks_test
|
||||
@no_debug_info_test
|
||||
@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")
|
||||
def test_run_gdb_then_lldb(self):
|
||||
"""Test disassembly on a large function with lldb vs. gdb."""
|
||||
print()
|
||||
@@ -70,7 +76,7 @@ class DisassembleDriverMainLoop(BenchBase):
|
||||
print("gdb benchmark:", self.stopwatch)
|
||||
self.run_lldb_disassembly(self.exe, self.function, self.count)
|
||||
print("lldb benchmark:", self.stopwatch)
|
||||
print("lldb_avg/gdb_avg: %f" % (self.lldb_avg/self.gdb_avg))
|
||||
print("lldb_avg/gdb_avg: %f" % (self.lldb_avg / self.gdb_avg))
|
||||
|
||||
def run_lldb_disassembly(self, exe, function, count):
|
||||
import pexpect
|
||||
@@ -79,7 +85,9 @@ class DisassembleDriverMainLoop(BenchBase):
|
||||
prompt = self.child_prompt
|
||||
|
||||
# So that the child gets torn down after the test.
|
||||
self.child = pexpect.spawn('%s %s %s' % (lldbtest_config.lldbExec, self.lldbOption, exe))
|
||||
self.child = pexpect.spawn(
|
||||
'%s %s %s' %
|
||||
(lldbtest_config.lldbExec, self.lldbOption, exe))
|
||||
child = self.child
|
||||
|
||||
# Turn on logging for what the child sends back.
|
||||
|
||||
@@ -5,13 +5,14 @@ inferior and traverses the stack for thread0 to arrive at frame with function
|
||||
from __future__ import print_function
|
||||
|
||||
|
||||
|
||||
import os, sys
|
||||
import os
|
||||
import sys
|
||||
import lldb
|
||||
from lldbsuite.test.decorators import *
|
||||
from lldbsuite.test.lldbbench import *
|
||||
from lldbsuite.test.lldbtest import *
|
||||
|
||||
|
||||
class AttachThenDisassemblyBench(BenchBase):
|
||||
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
@@ -32,10 +33,11 @@ class AttachThenDisassemblyBench(BenchBase):
|
||||
def run_lldb_attach_then_disassembly(self, exe, count):
|
||||
target = self.dbg.CreateTarget(exe)
|
||||
|
||||
# Spawn a new process and don't display the stdout if not in TraceOn() mode.
|
||||
# Spawn a new process and don't display the stdout if not in TraceOn()
|
||||
# mode.
|
||||
import subprocess
|
||||
popen = subprocess.Popen([exe, self.lldbOption],
|
||||
stdout = open(os.devnull, 'w') if not self.TraceOn() else None)
|
||||
popen = subprocess.Popen([exe, self.lldbOption], stdout=open(
|
||||
os.devnull, 'w') if not self.TraceOn() else None)
|
||||
if self.TraceOn():
|
||||
print("pid of spawned process: %d" % popen.pid)
|
||||
|
||||
@@ -51,7 +53,7 @@ class AttachThenDisassemblyBench(BenchBase):
|
||||
i = 0
|
||||
found = False
|
||||
for f in thread0:
|
||||
#print("frame#%d %s" % (i, f.GetFunctionName()))
|
||||
# print("frame#%d %s" % (i, f.GetFunctionName()))
|
||||
if "MainLoop" in f.GetFunctionName():
|
||||
found = True
|
||||
thread0.SetSelectedFrame(i)
|
||||
@@ -59,7 +61,7 @@ class AttachThenDisassemblyBench(BenchBase):
|
||||
print("Found frame#%d for function 'MainLoop'" % i)
|
||||
break
|
||||
i += 1
|
||||
|
||||
|
||||
# Reset the stopwatch now.
|
||||
self.stopwatch.reset()
|
||||
for i in range(count):
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
from __future__ import print_function
|
||||
|
||||
|
||||
|
||||
import os, sys
|
||||
import os
|
||||
import sys
|
||||
import lldb
|
||||
from lldbsuite.test.decorators import *
|
||||
from lldbsuite.test.lldbbench import *
|
||||
@@ -12,6 +12,7 @@ from lldbsuite.test.lldbtest import *
|
||||
from lldbsuite.test import configuration
|
||||
from lldbsuite.test import lldbutil
|
||||
|
||||
|
||||
class XCode41Vs42GDBDisassembly(BenchBase):
|
||||
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
@@ -28,31 +29,53 @@ class XCode41Vs42GDBDisassembly(BenchBase):
|
||||
|
||||
@benchmarks_test
|
||||
@no_debug_info_test
|
||||
@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")
|
||||
def test_run_41_then_42(self):
|
||||
"""Test disassembly on a large function with 4.1 vs. 4.2's gdb."""
|
||||
print()
|
||||
self.run_gdb_disassembly(self.gdb_41_exe, self.exe, self.function, self.count)
|
||||
self.run_gdb_disassembly(
|
||||
self.gdb_41_exe,
|
||||
self.exe,
|
||||
self.function,
|
||||
self.count)
|
||||
print("4.1 gdb benchmark:", self.stopwatch)
|
||||
self.gdb_41_avg = self.stopwatch.avg()
|
||||
self.run_gdb_disassembly(self.gdb_42_exe, self.exe, self.function, self.count)
|
||||
self.run_gdb_disassembly(
|
||||
self.gdb_42_exe,
|
||||
self.exe,
|
||||
self.function,
|
||||
self.count)
|
||||
print("4.2 gdb benchmark:", self.stopwatch)
|
||||
self.gdb_42_avg = self.stopwatch.avg()
|
||||
print("gdb_42_avg/gdb_41_avg: %f" % (self.gdb_42_avg/self.gdb_41_avg))
|
||||
print("gdb_42_avg/gdb_41_avg: %f" %
|
||||
(self.gdb_42_avg / self.gdb_41_avg))
|
||||
|
||||
@benchmarks_test
|
||||
@no_debug_info_test
|
||||
@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")
|
||||
def test_run_42_then_41(self):
|
||||
"""Test disassembly on a large function with 4.1 vs. 4.2's gdb."""
|
||||
print()
|
||||
self.run_gdb_disassembly(self.gdb_42_exe, self.exe, self.function, self.count)
|
||||
self.run_gdb_disassembly(
|
||||
self.gdb_42_exe,
|
||||
self.exe,
|
||||
self.function,
|
||||
self.count)
|
||||
print("4.2 gdb benchmark:", self.stopwatch)
|
||||
self.gdb_42_avg = self.stopwatch.avg()
|
||||
self.run_gdb_disassembly(self.gdb_41_exe, self.exe, self.function, self.count)
|
||||
self.run_gdb_disassembly(
|
||||
self.gdb_41_exe,
|
||||
self.exe,
|
||||
self.function,
|
||||
self.count)
|
||||
print("4.1 gdb benchmark:", self.stopwatch)
|
||||
self.gdb_41_avg = self.stopwatch.avg()
|
||||
print("gdb_42_avg/gdb_41_avg: %f" % (self.gdb_42_avg/self.gdb_41_avg))
|
||||
print("gdb_42_avg/gdb_41_avg: %f" %
|
||||
(self.gdb_42_avg / self.gdb_41_avg))
|
||||
|
||||
def run_gdb_disassembly(self, gdb_exe_path, exe, function, count):
|
||||
import pexpect
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
from __future__ import print_function
|
||||
|
||||
|
||||
|
||||
import os, sys
|
||||
import os
|
||||
import sys
|
||||
import lldb
|
||||
from lldbsuite.test.decorators import *
|
||||
from lldbsuite.test.lldbbench import *
|
||||
@@ -12,6 +12,7 @@ from lldbsuite.test.lldbtest import *
|
||||
from lldbsuite.test import configuration
|
||||
from lldbsuite.test import lldbutil
|
||||
|
||||
|
||||
class ExpressionEvaluationCase(BenchBase):
|
||||
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
@@ -19,11 +20,14 @@ class ExpressionEvaluationCase(BenchBase):
|
||||
def setUp(self):
|
||||
BenchBase.setUp(self)
|
||||
self.source = 'main.cpp'
|
||||
self.line_to_break = line_number(self.source, '// Set breakpoint here.')
|
||||
self.line_to_break = line_number(
|
||||
self.source, '// Set breakpoint here.')
|
||||
self.count = 25
|
||||
|
||||
@benchmarks_test
|
||||
@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")
|
||||
def test_expr_cmd(self):
|
||||
"""Test lldb's expression commands and collect statistics."""
|
||||
self.build()
|
||||
@@ -45,7 +49,9 @@ class ExpressionEvaluationCase(BenchBase):
|
||||
self.stopwatch.reset()
|
||||
for i in range(count):
|
||||
# So that the child gets torn down after the test.
|
||||
self.child = pexpect.spawn('%s %s %s' % (lldbtest_config.lldbExec, self.lldbOption, exe))
|
||||
self.child = pexpect.spawn(
|
||||
'%s %s %s' %
|
||||
(lldbtest_config.lldbExec, self.lldbOption, exe))
|
||||
child = self.child
|
||||
|
||||
# Turn on logging for what the child sends back.
|
||||
@@ -53,7 +59,9 @@ class ExpressionEvaluationCase(BenchBase):
|
||||
child.logfile_read = sys.stdout
|
||||
|
||||
child.expect_exact(prompt)
|
||||
child.sendline('breakpoint set -f %s -l %d' % (self.source, self.line_to_break))
|
||||
child.sendline(
|
||||
'breakpoint set -f %s -l %d' %
|
||||
(self.source, self.line_to_break))
|
||||
child.expect_exact(prompt)
|
||||
child.sendline('run')
|
||||
child.expect_exact(prompt)
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
from __future__ import print_function
|
||||
|
||||
|
||||
|
||||
import os, sys
|
||||
import os
|
||||
import sys
|
||||
import lldb
|
||||
from lldbsuite.test.lldbbench import BenchBase
|
||||
from lldbsuite.test.decorators import *
|
||||
@@ -12,6 +12,7 @@ from lldbsuite.test.lldbtest import *
|
||||
from lldbsuite.test import configuration
|
||||
from lldbsuite.test import lldbutil
|
||||
|
||||
|
||||
class RepeatedExprsCase(BenchBase):
|
||||
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
@@ -19,13 +20,16 @@ class RepeatedExprsCase(BenchBase):
|
||||
def setUp(self):
|
||||
BenchBase.setUp(self)
|
||||
self.source = 'main.cpp'
|
||||
self.line_to_break = line_number(self.source, '// Set breakpoint here.')
|
||||
self.line_to_break = line_number(
|
||||
self.source, '// Set breakpoint here.')
|
||||
self.lldb_avg = None
|
||||
self.gdb_avg = None
|
||||
self.count = 100
|
||||
|
||||
@benchmarks_test
|
||||
@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")
|
||||
def test_compare_lldb_to_gdb(self):
|
||||
"""Test repeated expressions with lldb vs. gdb."""
|
||||
self.build()
|
||||
@@ -36,7 +40,7 @@ class RepeatedExprsCase(BenchBase):
|
||||
print("lldb benchmark:", self.stopwatch)
|
||||
self.run_gdb_repeated_exprs(self.exe_name, self.count)
|
||||
print("gdb benchmark:", self.stopwatch)
|
||||
print("lldb_avg/gdb_avg: %f" % (self.lldb_avg/self.gdb_avg))
|
||||
print("lldb_avg/gdb_avg: %f" % (self.lldb_avg / self.gdb_avg))
|
||||
|
||||
def run_lldb_repeated_exprs(self, exe_name, count):
|
||||
import pexpect
|
||||
@@ -47,7 +51,9 @@ class RepeatedExprsCase(BenchBase):
|
||||
prompt = self.child_prompt
|
||||
|
||||
# So that the child gets torn down after the test.
|
||||
self.child = pexpect.spawn('%s %s %s' % (lldbtest_config.lldbExec, self.lldbOption, exe))
|
||||
self.child = pexpect.spawn(
|
||||
'%s %s %s' %
|
||||
(lldbtest_config.lldbExec, self.lldbOption, exe))
|
||||
child = self.child
|
||||
|
||||
# Turn on logging for what the child sends back.
|
||||
@@ -55,7 +61,9 @@ class RepeatedExprsCase(BenchBase):
|
||||
child.logfile_read = sys.stdout
|
||||
|
||||
child.expect_exact(prompt)
|
||||
child.sendline('breakpoint set -f %s -l %d' % (self.source, self.line_to_break))
|
||||
child.sendline(
|
||||
'breakpoint set -f %s -l %d' %
|
||||
(self.source, self.line_to_break))
|
||||
child.expect_exact(prompt)
|
||||
child.sendline('run')
|
||||
child.expect_exact(prompt)
|
||||
@@ -71,7 +79,7 @@ class RepeatedExprsCase(BenchBase):
|
||||
child.sendline(expr_cmd2)
|
||||
child.expect_exact(prompt)
|
||||
child.sendline('process continue')
|
||||
child.expect_exact(prompt)
|
||||
child.expect_exact(prompt)
|
||||
|
||||
child.sendline('quit')
|
||||
try:
|
||||
@@ -117,7 +125,7 @@ class RepeatedExprsCase(BenchBase):
|
||||
child.sendline(expr_cmd2)
|
||||
child.expect_exact(prompt)
|
||||
child.sendline('continue')
|
||||
child.expect_exact(prompt)
|
||||
child.expect_exact(prompt)
|
||||
|
||||
child.sendline('quit')
|
||||
child.expect_exact('The program is running. Exit anyway?')
|
||||
|
||||
@@ -3,14 +3,15 @@
|
||||
from __future__ import print_function
|
||||
|
||||
|
||||
|
||||
import os, sys
|
||||
import os
|
||||
import sys
|
||||
import lldb
|
||||
from lldbsuite.test import configuration
|
||||
from lldbsuite.test import lldbtest_config
|
||||
from lldbsuite.test.decorators import *
|
||||
from lldbsuite.test.lldbbench import *
|
||||
|
||||
|
||||
class FrameVariableResponseBench(BenchBase):
|
||||
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
@@ -23,7 +24,9 @@ class FrameVariableResponseBench(BenchBase):
|
||||
|
||||
@benchmarks_test
|
||||
@no_debug_info_test
|
||||
@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")
|
||||
def test_startup_delay(self):
|
||||
"""Test response time for the 'frame variable' command."""
|
||||
print()
|
||||
@@ -40,7 +43,9 @@ class FrameVariableResponseBench(BenchBase):
|
||||
self.stopwatch.reset()
|
||||
for i in range(count):
|
||||
# So that the child gets torn down after the test.
|
||||
self.child = pexpect.spawn('%s %s %s' % (lldbtest_config.lldbExec, self.lldbOption, exe))
|
||||
self.child = pexpect.spawn(
|
||||
'%s %s %s' %
|
||||
(lldbtest_config.lldbExec, self.lldbOption, exe))
|
||||
child = self.child
|
||||
|
||||
# Turn on logging for what the child sends back.
|
||||
@@ -52,9 +57,9 @@ class FrameVariableResponseBench(BenchBase):
|
||||
child.expect_exact(prompt)
|
||||
|
||||
# Run the target and expect it to be stopped due to breakpoint.
|
||||
child.sendline('run') # Aka 'process launch'.
|
||||
child.sendline('run') # Aka 'process launch'.
|
||||
child.expect_exact(prompt)
|
||||
|
||||
|
||||
with self.stopwatch:
|
||||
# Measure the 'frame variable' response time.
|
||||
child.sendline('frame variable')
|
||||
|
||||
@@ -5,14 +5,15 @@ Test lldb data formatter subsystem.
|
||||
from __future__ import print_function
|
||||
|
||||
|
||||
|
||||
import os, time
|
||||
import os
|
||||
import time
|
||||
import lldb
|
||||
from lldbsuite.test.decorators import *
|
||||
from lldbsuite.test.lldbbench import *
|
||||
from lldbsuite.test.lldbtest import *
|
||||
from lldbsuite.test import lldbutil
|
||||
|
||||
|
||||
class TestBenchmarkLibcxxList(BenchBase):
|
||||
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
@@ -31,14 +32,16 @@ class TestBenchmarkLibcxxList(BenchBase):
|
||||
"""Benchmark the std::list data formatter (libc++)"""
|
||||
self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
|
||||
|
||||
bkpt = self.target().FindBreakpointByID(lldbutil.run_break_set_by_source_regexp (self, "break here"))
|
||||
bkpt = self.target().FindBreakpointByID(
|
||||
lldbutil.run_break_set_by_source_regexp(
|
||||
self, "break here"))
|
||||
|
||||
self.runCmd("run", RUN_SUCCEEDED)
|
||||
|
||||
# The stop reason of the thread should be breakpoint.
|
||||
self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
|
||||
substrs = ['stopped',
|
||||
'stop reason = breakpoint'])
|
||||
substrs=['stopped',
|
||||
'stop reason = breakpoint'])
|
||||
|
||||
# This is the function to remove the custom formats in order to have a
|
||||
# clean slate for the next test case.
|
||||
@@ -47,15 +50,17 @@ class TestBenchmarkLibcxxList(BenchBase):
|
||||
self.runCmd('type summary clear', check=False)
|
||||
self.runCmd('type filter clear', check=False)
|
||||
self.runCmd('type synth clear', check=False)
|
||||
self.runCmd("settings set target.max-children-count 256", check=False)
|
||||
self.runCmd(
|
||||
"settings set target.max-children-count 256",
|
||||
check=False)
|
||||
|
||||
# Execute the cleanup function during test case tear down.
|
||||
self.addTearDownHook(cleanup)
|
||||
|
||||
|
||||
sw = Stopwatch()
|
||||
|
||||
|
||||
sw.start()
|
||||
self.expect('frame variable -A list', substrs=['[300]', '300'])
|
||||
sw.stop()
|
||||
|
||||
|
||||
print("time to print: %s" % (sw))
|
||||
|
||||
@@ -5,14 +5,15 @@ Test lldb data formatter subsystem.
|
||||
from __future__ import print_function
|
||||
|
||||
|
||||
|
||||
import os, time
|
||||
import os
|
||||
import time
|
||||
import lldb
|
||||
from lldbsuite.test.lldbbench import *
|
||||
from lldbsuite.test.decorators import *
|
||||
from lldbsuite.test.lldbtest import *
|
||||
from lldbsuite.test import lldbutil
|
||||
|
||||
|
||||
class TestBenchmarkLibcxxMap(BenchBase):
|
||||
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
@@ -31,14 +32,16 @@ class TestBenchmarkLibcxxMap(BenchBase):
|
||||
"""Benchmark the std::map data formatter (libc++)"""
|
||||
self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
|
||||
|
||||
bkpt = self.target().FindBreakpointByID(lldbutil.run_break_set_by_source_regexp (self, "break here"))
|
||||
bkpt = self.target().FindBreakpointByID(
|
||||
lldbutil.run_break_set_by_source_regexp(
|
||||
self, "break here"))
|
||||
|
||||
self.runCmd("run", RUN_SUCCEEDED)
|
||||
|
||||
# The stop reason of the thread should be breakpoint.
|
||||
self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
|
||||
substrs = ['stopped',
|
||||
'stop reason = breakpoint'])
|
||||
substrs=['stopped',
|
||||
'stop reason = breakpoint'])
|
||||
|
||||
# This is the function to remove the custom formats in order to have a
|
||||
# clean slate for the next test case.
|
||||
@@ -47,15 +50,17 @@ class TestBenchmarkLibcxxMap(BenchBase):
|
||||
self.runCmd('type summary clear', check=False)
|
||||
self.runCmd('type filter clear', check=False)
|
||||
self.runCmd('type synth clear', check=False)
|
||||
self.runCmd("settings set target.max-children-count 256", check=False)
|
||||
self.runCmd(
|
||||
"settings set target.max-children-count 256",
|
||||
check=False)
|
||||
|
||||
# Execute the cleanup function during test case tear down.
|
||||
self.addTearDownHook(cleanup)
|
||||
|
||||
|
||||
sw = Stopwatch()
|
||||
|
||||
|
||||
sw.start()
|
||||
self.expect('frame variable -A map', substrs=['[300]', '300'])
|
||||
sw.stop()
|
||||
|
||||
|
||||
print("time to print: %s" % (sw))
|
||||
|
||||
@@ -3,14 +3,15 @@
|
||||
from __future__ import print_function
|
||||
|
||||
|
||||
|
||||
import os, sys
|
||||
import os
|
||||
import sys
|
||||
import lldb
|
||||
from lldbsuite.test import configuration
|
||||
from lldbsuite.test import lldbtest_config
|
||||
from lldbsuite.test.decorators import *
|
||||
from lldbsuite.test.lldbbench import *
|
||||
|
||||
|
||||
class StartupDelaysBench(BenchBase):
|
||||
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
@@ -28,14 +29,22 @@ class StartupDelaysBench(BenchBase):
|
||||
|
||||
@benchmarks_test
|
||||
@no_debug_info_test
|
||||
@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")
|
||||
def test_startup_delay(self):
|
||||
"""Test start up delays creating a target, setting a breakpoint, and run to breakpoint stop."""
|
||||
print()
|
||||
self.run_startup_delays_bench(self.exe, self.break_spec, self.count)
|
||||
print("lldb startup delay (create fresh target) benchmark:", self.stopwatch)
|
||||
print("lldb startup delay (set first breakpoint) benchmark:", self.stopwatch2)
|
||||
print("lldb startup delay (run to breakpoint) benchmark:", self.stopwatch3)
|
||||
print(
|
||||
"lldb startup delay (create fresh target) benchmark:",
|
||||
self.stopwatch)
|
||||
print(
|
||||
"lldb startup delay (set first breakpoint) benchmark:",
|
||||
self.stopwatch2)
|
||||
print(
|
||||
"lldb startup delay (run to breakpoint) benchmark:",
|
||||
self.stopwatch3)
|
||||
|
||||
def run_startup_delays_bench(self, exe, break_spec, count):
|
||||
import pexpect
|
||||
@@ -48,7 +57,9 @@ class StartupDelaysBench(BenchBase):
|
||||
self.stopwatch2.reset()
|
||||
for i in range(count):
|
||||
# So that the child gets torn down after the test.
|
||||
self.child = pexpect.spawn('%s %s' % (lldbtest_config.lldbExec, self.lldbOption))
|
||||
self.child = pexpect.spawn(
|
||||
'%s %s' %
|
||||
(lldbtest_config.lldbExec, self.lldbOption))
|
||||
child = self.child
|
||||
|
||||
# Turn on logging for what the child sends back.
|
||||
@@ -57,7 +68,7 @@ class StartupDelaysBench(BenchBase):
|
||||
|
||||
with self.stopwatch:
|
||||
# Create a fresh target.
|
||||
child.sendline('file %s' % exe) # Aka 'target create'.
|
||||
child.sendline('file %s' % exe) # Aka 'target create'.
|
||||
child.expect_exact(prompt)
|
||||
|
||||
with self.stopwatch2:
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import os, sys
|
||||
import os
|
||||
import sys
|
||||
import lldb
|
||||
from lldbsuite.test import configuration
|
||||
from lldbsuite.test import lldbtest_config
|
||||
@@ -11,6 +12,7 @@ from lldbsuite.test.decorators import *
|
||||
from lldbsuite.test.lldbtest import *
|
||||
from lldbsuite.test import lldbutil
|
||||
|
||||
|
||||
class SteppingSpeedBench(BenchBase):
|
||||
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
@@ -26,7 +28,9 @@ class SteppingSpeedBench(BenchBase):
|
||||
|
||||
@benchmarks_test
|
||||
@no_debug_info_test
|
||||
@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")
|
||||
def test_run_lldb_steppings(self):
|
||||
"""Test lldb steppings on a large executable."""
|
||||
print()
|
||||
@@ -40,7 +44,9 @@ class SteppingSpeedBench(BenchBase):
|
||||
prompt = self.child_prompt
|
||||
|
||||
# So that the child gets torn down after the test.
|
||||
self.child = pexpect.spawn('%s %s %s' % (lldbtest_config.lldbExec, self.lldbOption, exe))
|
||||
self.child = pexpect.spawn(
|
||||
'%s %s %s' %
|
||||
(lldbtest_config.lldbExec, self.lldbOption, exe))
|
||||
child = self.child
|
||||
|
||||
# Turn on logging for what the child sends back.
|
||||
@@ -58,7 +64,7 @@ class SteppingSpeedBench(BenchBase):
|
||||
for i in range(count):
|
||||
with self.stopwatch:
|
||||
# Disassemble the function.
|
||||
child.sendline('next') # Aka 'thread step-over'.
|
||||
child.sendline('next') # Aka 'thread step-over'.
|
||||
child.expect_exact(prompt)
|
||||
|
||||
child.sendline('quit')
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
from __future__ import print_function
|
||||
|
||||
|
||||
|
||||
import os, sys
|
||||
import os
|
||||
import sys
|
||||
import lldb
|
||||
from lldbsuite.test.lldbbench import *
|
||||
from lldbsuite.test.decorators import *
|
||||
@@ -12,6 +12,7 @@ from lldbsuite.test.lldbtest import *
|
||||
from lldbsuite.test import configuration
|
||||
from lldbsuite.test import lldbutil
|
||||
|
||||
|
||||
class CompileRunToBreakpointBench(BenchBase):
|
||||
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
@@ -27,7 +28,9 @@ class CompileRunToBreakpointBench(BenchBase):
|
||||
|
||||
@benchmarks_test
|
||||
@no_debug_info_test
|
||||
@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")
|
||||
def test_run_lldb_then_gdb(self):
|
||||
"""Benchmark turnaround time with lldb vs. gdb."""
|
||||
print()
|
||||
@@ -35,15 +38,18 @@ class CompileRunToBreakpointBench(BenchBase):
|
||||
print("lldb turnaround benchmark:", self.stopwatch)
|
||||
self.run_gdb_turnaround(self.exe, self.function, self.count)
|
||||
print("gdb turnaround benchmark:", self.stopwatch)
|
||||
print("lldb_avg/gdb_avg: %f" % (self.lldb_avg/self.gdb_avg))
|
||||
print("lldb_avg/gdb_avg: %f" % (self.lldb_avg / self.gdb_avg))
|
||||
|
||||
def run_lldb_turnaround(self, exe, function, count):
|
||||
import pexpect
|
||||
|
||||
def run_one_round():
|
||||
prompt = self.child_prompt
|
||||
|
||||
# So that the child gets torn down after the test.
|
||||
self.child = pexpect.spawn('%s %s %s' % (lldbtest_config.lldbExec, self.lldbOption, exe))
|
||||
self.child = pexpect.spawn(
|
||||
'%s %s %s' %
|
||||
(lldbtest_config.lldbExec, self.lldbOption, exe))
|
||||
child = self.child
|
||||
|
||||
# Turn on logging for what the child sends back.
|
||||
@@ -62,7 +68,8 @@ class CompileRunToBreakpointBench(BenchBase):
|
||||
self.stopwatch.reset()
|
||||
|
||||
for i in range(count + 1):
|
||||
# Ignore the first invoke lldb and run to the breakpoint turnaround time.
|
||||
# Ignore the first invoke lldb and run to the breakpoint turnaround
|
||||
# time.
|
||||
if i == 0:
|
||||
run_one_round()
|
||||
else:
|
||||
@@ -80,6 +87,7 @@ class CompileRunToBreakpointBench(BenchBase):
|
||||
|
||||
def run_gdb_turnaround(self, exe, function, count):
|
||||
import pexpect
|
||||
|
||||
def run_one_round():
|
||||
prompt = self.child_prompt
|
||||
|
||||
@@ -102,8 +110,9 @@ class CompileRunToBreakpointBench(BenchBase):
|
||||
# Reset the stopwatch now.
|
||||
self.stopwatch.reset()
|
||||
|
||||
for i in range(count+1):
|
||||
# Ignore the first invoke lldb and run to the breakpoint turnaround time.
|
||||
for i in range(count + 1):
|
||||
# Ignore the first invoke lldb and run to the breakpoint turnaround
|
||||
# time.
|
||||
if i == 0:
|
||||
run_one_round()
|
||||
else:
|
||||
|
||||
@@ -13,14 +13,15 @@ verified to match the expected number of events.
|
||||
from __future__ import print_function
|
||||
|
||||
|
||||
|
||||
import unittest2
|
||||
import os, time
|
||||
import os
|
||||
import time
|
||||
import lldb
|
||||
from lldbsuite.test.decorators import *
|
||||
from lldbsuite.test.lldbtest import *
|
||||
from lldbsuite.test import lldbutil
|
||||
|
||||
|
||||
class ConcurrentEventsBase(TestBase):
|
||||
|
||||
# Concurrency is the primary test factor here, not debug info variants.
|
||||
@@ -49,18 +50,24 @@ class ConcurrentEventsBase(TestBase):
|
||||
if reason == lldb.eStopReasonBreakpoint:
|
||||
bpid = x.GetStopReasonDataAtIndex(0)
|
||||
bp = self.inferior_target.FindBreakpointByID(bpid)
|
||||
reason_str = "%s hit %d times" % (lldbutil.get_description(bp), bp.GetHitCount())
|
||||
reason_str = "%s hit %d times" % (
|
||||
lldbutil.get_description(bp), bp.GetHitCount())
|
||||
elif reason == lldb.eStopReasonWatchpoint:
|
||||
watchid = x.GetStopReasonDataAtIndex(0)
|
||||
watch = self.inferior_target.FindWatchpointByID(watchid)
|
||||
reason_str = "%s hit %d times" % (lldbutil.get_description(watch), watch.GetHitCount())
|
||||
reason_str = "%s hit %d times" % (
|
||||
lldbutil.get_description(watch), watch.GetHitCount())
|
||||
elif reason == lldb.eStopReasonSignal:
|
||||
signals = self.inferior_process.GetUnixSignals()
|
||||
signal_name = signals.GetSignalAsCString(x.GetStopReasonDataAtIndex(0))
|
||||
signal_name = signals.GetSignalAsCString(
|
||||
x.GetStopReasonDataAtIndex(0))
|
||||
reason_str = "signal %s" % signal_name
|
||||
|
||||
location = "\t".join([lldbutil.get_description(x.GetFrameAtIndex(i)) for i in range(x.GetNumFrames())])
|
||||
ret.append("thread %d %s due to %s at\n\t%s" % (id, status, reason_str, location))
|
||||
location = "\t".join([lldbutil.get_description(
|
||||
x.GetFrameAtIndex(i)) for i in range(x.GetNumFrames())])
|
||||
ret.append(
|
||||
"thread %d %s due to %s at\n\t%s" %
|
||||
(id, status, reason_str, location))
|
||||
return ret
|
||||
|
||||
def add_breakpoint(self, line, descriptions):
|
||||
@@ -68,35 +75,39 @@ class ConcurrentEventsBase(TestBase):
|
||||
returns the LLDB SBBreakpoint object.
|
||||
"""
|
||||
|
||||
bpno = lldbutil.run_break_set_by_file_and_line(self, self.filename, line, num_expected_locations=-1)
|
||||
bpno = lldbutil.run_break_set_by_file_and_line(
|
||||
self, self.filename, line, num_expected_locations=-1)
|
||||
bp = self.inferior_target.FindBreakpointByID(bpno)
|
||||
descriptions.append(": file = 'main.cpp', line = %d" % self.finish_breakpoint_line)
|
||||
descriptions.append(
|
||||
": file = 'main.cpp', line = %d" %
|
||||
self.finish_breakpoint_line)
|
||||
return bp
|
||||
|
||||
def inferior_done(self):
|
||||
""" Returns true if the inferior is done executing all the event threads (and is stopped at self.finish_breakpoint,
|
||||
""" Returns true if the inferior is done executing all the event threads (and is stopped at self.finish_breakpoint,
|
||||
or has terminated execution.
|
||||
"""
|
||||
return self.finish_breakpoint.GetHitCount() > 0 or \
|
||||
self.crash_count > 0 or \
|
||||
self.inferior_process.GetState() == lldb.eStateExited
|
||||
self.crash_count > 0 or \
|
||||
self.inferior_process.GetState() == lldb.eStateExited
|
||||
|
||||
def count_signaled_threads(self):
|
||||
count = 0
|
||||
for thread in self.inferior_process:
|
||||
if thread.GetStopReason() == lldb.eStopReasonSignal and thread.GetStopReasonDataAtIndex(0) == self.inferior_process.GetUnixSignals().GetSignalNumberFromName('SIGUSR1'):
|
||||
if thread.GetStopReason() == lldb.eStopReasonSignal and thread.GetStopReasonDataAtIndex(
|
||||
0) == self.inferior_process.GetUnixSignals().GetSignalNumberFromName('SIGUSR1'):
|
||||
count += 1
|
||||
return count
|
||||
|
||||
def do_thread_actions(self,
|
||||
num_breakpoint_threads = 0,
|
||||
num_signal_threads = 0,
|
||||
num_watchpoint_threads = 0,
|
||||
num_crash_threads = 0,
|
||||
num_delay_breakpoint_threads = 0,
|
||||
num_delay_signal_threads = 0,
|
||||
num_delay_watchpoint_threads = 0,
|
||||
num_delay_crash_threads = 0):
|
||||
num_breakpoint_threads=0,
|
||||
num_signal_threads=0,
|
||||
num_watchpoint_threads=0,
|
||||
num_crash_threads=0,
|
||||
num_delay_breakpoint_threads=0,
|
||||
num_delay_signal_threads=0,
|
||||
num_delay_watchpoint_threads=0,
|
||||
num_delay_crash_threads=0):
|
||||
""" Sets a breakpoint in the main thread where test parameters (numbers of threads) can be adjusted, runs the inferior
|
||||
to that point, and modifies the locals that control the event thread counts. Also sets a breakpoint in
|
||||
breakpoint_func (the function executed by each 'breakpoint' thread) and a watchpoint on a global modified in
|
||||
@@ -112,105 +123,166 @@ class ConcurrentEventsBase(TestBase):
|
||||
expected_bps = []
|
||||
|
||||
# Initialize all the breakpoints (main thread/aux thread)
|
||||
self.setup_breakpoint = self.add_breakpoint(self.setup_breakpoint_line, expected_bps)
|
||||
self.finish_breakpoint = self.add_breakpoint(self.finish_breakpoint_line, expected_bps)
|
||||
self.setup_breakpoint = self.add_breakpoint(
|
||||
self.setup_breakpoint_line, expected_bps)
|
||||
self.finish_breakpoint = self.add_breakpoint(
|
||||
self.finish_breakpoint_line, expected_bps)
|
||||
|
||||
# Set the thread breakpoint
|
||||
if num_breakpoint_threads + num_delay_breakpoint_threads > 0:
|
||||
self.thread_breakpoint = self.add_breakpoint(self.thread_breakpoint_line, expected_bps)
|
||||
self.thread_breakpoint = self.add_breakpoint(
|
||||
self.thread_breakpoint_line, expected_bps)
|
||||
|
||||
# Verify breakpoints
|
||||
self.expect("breakpoint list -f", "Breakpoint locations shown correctly", substrs = expected_bps)
|
||||
self.expect(
|
||||
"breakpoint list -f",
|
||||
"Breakpoint locations shown correctly",
|
||||
substrs=expected_bps)
|
||||
|
||||
# Run the program.
|
||||
self.runCmd("run", RUN_SUCCEEDED)
|
||||
|
||||
# Check we are at line self.setup_breakpoint
|
||||
self.expect("thread backtrace", STOPPED_DUE_TO_BREAKPOINT,
|
||||
substrs = ["stop reason = breakpoint 1."])
|
||||
substrs=["stop reason = breakpoint 1."])
|
||||
|
||||
# Initialize the (single) watchpoint on the global variable (g_watchme)
|
||||
if num_watchpoint_threads + num_delay_watchpoint_threads > 0:
|
||||
self.runCmd("watchpoint set variable g_watchme")
|
||||
for w in self.inferior_target.watchpoint_iter():
|
||||
self.thread_watchpoint = w
|
||||
self.assertTrue("g_watchme" in str(self.thread_watchpoint), "Watchpoint location not shown correctly")
|
||||
self.assertTrue(
|
||||
"g_watchme" in str(
|
||||
self.thread_watchpoint),
|
||||
"Watchpoint location not shown correctly")
|
||||
|
||||
# Get the process
|
||||
self.inferior_process = self.inferior_target.GetProcess()
|
||||
|
||||
# We should be stopped at the setup site where we can set the number of
|
||||
# threads doing each action (break/crash/signal/watch)
|
||||
self.assertEqual(self.inferior_process.GetNumThreads(), 1, 'Expected to stop before any additional threads are spawned.')
|
||||
self.assertEqual(
|
||||
self.inferior_process.GetNumThreads(),
|
||||
1,
|
||||
'Expected to stop before any additional threads are spawned.')
|
||||
|
||||
self.runCmd("expr num_breakpoint_threads=%d" % num_breakpoint_threads)
|
||||
self.runCmd("expr num_crash_threads=%d" % num_crash_threads)
|
||||
self.runCmd("expr num_signal_threads=%d" % num_signal_threads)
|
||||
self.runCmd("expr num_watchpoint_threads=%d" % num_watchpoint_threads)
|
||||
|
||||
self.runCmd("expr num_delay_breakpoint_threads=%d" % num_delay_breakpoint_threads)
|
||||
self.runCmd("expr num_delay_crash_threads=%d" % num_delay_crash_threads)
|
||||
self.runCmd("expr num_delay_signal_threads=%d" % num_delay_signal_threads)
|
||||
self.runCmd("expr num_delay_watchpoint_threads=%d" % num_delay_watchpoint_threads)
|
||||
self.runCmd(
|
||||
"expr num_delay_breakpoint_threads=%d" %
|
||||
num_delay_breakpoint_threads)
|
||||
self.runCmd(
|
||||
"expr num_delay_crash_threads=%d" %
|
||||
num_delay_crash_threads)
|
||||
self.runCmd(
|
||||
"expr num_delay_signal_threads=%d" %
|
||||
num_delay_signal_threads)
|
||||
self.runCmd(
|
||||
"expr num_delay_watchpoint_threads=%d" %
|
||||
num_delay_watchpoint_threads)
|
||||
|
||||
# Continue the inferior so threads are spawned
|
||||
self.runCmd("continue")
|
||||
|
||||
# Make sure we see all the threads. The inferior program's threads all synchronize with a pseudo-barrier; that is,
|
||||
# the inferior program ensures all threads are started and running before any thread triggers its 'event'.
|
||||
# the inferior program ensures all threads are started and running
|
||||
# before any thread triggers its 'event'.
|
||||
num_threads = self.inferior_process.GetNumThreads()
|
||||
expected_num_threads = num_breakpoint_threads + num_delay_breakpoint_threads \
|
||||
+ num_signal_threads + num_delay_signal_threads \
|
||||
+ num_watchpoint_threads + num_delay_watchpoint_threads \
|
||||
+ num_crash_threads + num_delay_crash_threads + 1
|
||||
self.assertEqual(num_threads, expected_num_threads,
|
||||
'Expected to see %d threads, but seeing %d. Details:\n%s' % (expected_num_threads,
|
||||
num_threads,
|
||||
"\n\t".join(self.describe_threads())))
|
||||
+ num_signal_threads + num_delay_signal_threads \
|
||||
+ num_watchpoint_threads + num_delay_watchpoint_threads \
|
||||
+ num_crash_threads + num_delay_crash_threads + 1
|
||||
self.assertEqual(
|
||||
num_threads,
|
||||
expected_num_threads,
|
||||
'Expected to see %d threads, but seeing %d. Details:\n%s' %
|
||||
(expected_num_threads,
|
||||
num_threads,
|
||||
"\n\t".join(
|
||||
self.describe_threads())))
|
||||
|
||||
self.signal_count = self.count_signaled_threads()
|
||||
self.crash_count = len(lldbutil.get_crashed_threads(self, self.inferior_process))
|
||||
self.crash_count = len(
|
||||
lldbutil.get_crashed_threads(
|
||||
self, self.inferior_process))
|
||||
|
||||
# Run to completion (or crash)
|
||||
while not self.inferior_done():
|
||||
while not self.inferior_done():
|
||||
if self.TraceOn():
|
||||
self.runCmd("thread backtrace all")
|
||||
self.runCmd("continue")
|
||||
self.signal_count += self.count_signaled_threads()
|
||||
self.crash_count += len(lldbutil.get_crashed_threads(self, self.inferior_process))
|
||||
self.crash_count += len(
|
||||
lldbutil.get_crashed_threads(
|
||||
self, self.inferior_process))
|
||||
|
||||
if num_crash_threads > 0 or num_delay_crash_threads > 0:
|
||||
# Expecting a crash
|
||||
self.assertTrue(self.crash_count > 0,
|
||||
"Expecting at least one thread to crash. Details: %s" % "\t\n".join(self.describe_threads()))
|
||||
self.assertTrue(
|
||||
self.crash_count > 0,
|
||||
"Expecting at least one thread to crash. Details: %s" %
|
||||
"\t\n".join(
|
||||
self.describe_threads()))
|
||||
|
||||
# Ensure the zombie process is reaped
|
||||
self.runCmd("process kill")
|
||||
|
||||
elif num_crash_threads == 0 and num_delay_crash_threads == 0:
|
||||
# There should be a single active thread (the main one) which hit the breakpoint after joining
|
||||
self.assertEqual(1, self.finish_breakpoint.GetHitCount(), "Expected main thread (finish) breakpoint to be hit once")
|
||||
# There should be a single active thread (the main one) which hit
|
||||
# the breakpoint after joining
|
||||
self.assertEqual(
|
||||
1,
|
||||
self.finish_breakpoint.GetHitCount(),
|
||||
"Expected main thread (finish) breakpoint to be hit once")
|
||||
|
||||
num_threads = self.inferior_process.GetNumThreads()
|
||||
self.assertEqual(1, num_threads, "Expecting 1 thread but seeing %d. Details:%s" % (num_threads,
|
||||
"\n\t".join(self.describe_threads())))
|
||||
self.assertEqual(
|
||||
1,
|
||||
num_threads,
|
||||
"Expecting 1 thread but seeing %d. Details:%s" %
|
||||
(num_threads,
|
||||
"\n\t".join(
|
||||
self.describe_threads())))
|
||||
self.runCmd("continue")
|
||||
|
||||
# The inferior process should have exited without crashing
|
||||
self.assertEqual(0, self.crash_count, "Unexpected thread(s) in crashed state")
|
||||
self.assertEqual(self.inferior_process.GetState(), lldb.eStateExited, PROCESS_EXITED)
|
||||
self.assertEqual(
|
||||
0,
|
||||
self.crash_count,
|
||||
"Unexpected thread(s) in crashed state")
|
||||
self.assertEqual(
|
||||
self.inferior_process.GetState(),
|
||||
lldb.eStateExited,
|
||||
PROCESS_EXITED)
|
||||
|
||||
# Verify the number of actions took place matches expected numbers
|
||||
expected_breakpoint_threads = num_delay_breakpoint_threads + num_breakpoint_threads
|
||||
breakpoint_hit_count = self.thread_breakpoint.GetHitCount() if expected_breakpoint_threads > 0 else 0
|
||||
self.assertEqual(expected_breakpoint_threads, breakpoint_hit_count,
|
||||
"Expected %d breakpoint hits, but got %d" % (expected_breakpoint_threads, breakpoint_hit_count))
|
||||
breakpoint_hit_count = self.thread_breakpoint.GetHitCount(
|
||||
) if expected_breakpoint_threads > 0 else 0
|
||||
self.assertEqual(
|
||||
expected_breakpoint_threads,
|
||||
breakpoint_hit_count,
|
||||
"Expected %d breakpoint hits, but got %d" %
|
||||
(expected_breakpoint_threads,
|
||||
breakpoint_hit_count))
|
||||
|
||||
expected_signal_threads = num_delay_signal_threads + num_signal_threads
|
||||
self.assertEqual(expected_signal_threads, self.signal_count,
|
||||
"Expected %d stops due to signal delivery, but got %d" % (expected_signal_threads, self.signal_count))
|
||||
self.assertEqual(
|
||||
expected_signal_threads,
|
||||
self.signal_count,
|
||||
"Expected %d stops due to signal delivery, but got %d" %
|
||||
(expected_signal_threads,
|
||||
self.signal_count))
|
||||
|
||||
expected_watchpoint_threads = num_delay_watchpoint_threads + num_watchpoint_threads
|
||||
watchpoint_hit_count = self.thread_watchpoint.GetHitCount() if expected_watchpoint_threads > 0 else 0
|
||||
self.assertEqual(expected_watchpoint_threads, watchpoint_hit_count,
|
||||
"Expected %d watchpoint hits, got %d" % (expected_watchpoint_threads, watchpoint_hit_count))
|
||||
watchpoint_hit_count = self.thread_watchpoint.GetHitCount(
|
||||
) if expected_watchpoint_threads > 0 else 0
|
||||
self.assertEqual(
|
||||
expected_watchpoint_threads,
|
||||
watchpoint_hit_count,
|
||||
"Expected %d watchpoint hits, got %d" %
|
||||
(expected_watchpoint_threads,
|
||||
watchpoint_hit_count))
|
||||
|
||||
@@ -23,26 +23,31 @@ import unittest2
|
||||
# LLDB Modules
|
||||
import lldbsuite
|
||||
|
||||
|
||||
def __setCrashInfoHook_Mac(text):
|
||||
from . import crashinfo
|
||||
crashinfo.setCrashReporterDescription(text)
|
||||
|
||||
|
||||
def setupCrashInfoHook():
|
||||
if platform.system() == "Darwin":
|
||||
from . import lock
|
||||
test_dir = os.environ['LLDB_TEST']
|
||||
if not test_dir or not os.path.exists(test_dir):
|
||||
return
|
||||
dylib_lock = os.path.join(test_dir,"crashinfo.lock")
|
||||
dylib_src = os.path.join(test_dir,"crashinfo.c")
|
||||
dylib_dst = os.path.join(test_dir,"crashinfo.so")
|
||||
dylib_lock = os.path.join(test_dir, "crashinfo.lock")
|
||||
dylib_src = os.path.join(test_dir, "crashinfo.c")
|
||||
dylib_dst = os.path.join(test_dir, "crashinfo.so")
|
||||
try:
|
||||
compile_lock = lock.Lock(dylib_lock)
|
||||
compile_lock.acquire()
|
||||
if not os.path.isfile(dylib_dst) or os.path.getmtime(dylib_dst) < os.path.getmtime(dylib_src):
|
||||
if not os.path.isfile(dylib_dst) or os.path.getmtime(
|
||||
dylib_dst) < os.path.getmtime(dylib_src):
|
||||
# we need to compile
|
||||
cmd = "SDKROOT= xcrun clang %s -o %s -framework Python -Xlinker -dylib -iframework /System/Library/Frameworks/ -Xlinker -F /System/Library/Frameworks/" % (dylib_src,dylib_dst)
|
||||
if subprocess.call(cmd,shell=True) != 0 or not os.path.isfile(dylib_dst):
|
||||
cmd = "SDKROOT= xcrun clang %s -o %s -framework Python -Xlinker -dylib -iframework /System/Library/Frameworks/ -Xlinker -F /System/Library/Frameworks/" % (
|
||||
dylib_src, dylib_dst)
|
||||
if subprocess.call(
|
||||
cmd, shell=True) != 0 or not os.path.isfile(dylib_dst):
|
||||
raise Exception('command failed: "{}"'.format(cmd))
|
||||
finally:
|
||||
compile_lock.release()
|
||||
@@ -92,7 +97,8 @@ skip_long_running_test = True
|
||||
# prints machine-readable output similar to what clang tests produce.
|
||||
parsable = False
|
||||
|
||||
# The regular expression pattern to match against eligible filenames as our test cases.
|
||||
# The regular expression pattern to match against eligible filenames as
|
||||
# our test cases.
|
||||
regexp = None
|
||||
|
||||
# By default, recorded session info for errored/failed test are dumped into its
|
||||
@@ -121,7 +127,7 @@ verbose = 0
|
||||
# By default, search from the script directory.
|
||||
# We can't use sys.path[0] to determine the script directory
|
||||
# because it doesn't work under a debugger
|
||||
testdirs = [ os.path.dirname(os.path.realpath(__file__)) ]
|
||||
testdirs = [os.path.dirname(os.path.realpath(__file__))]
|
||||
|
||||
# Separator string.
|
||||
separator = '-' * 70
|
||||
@@ -152,15 +158,18 @@ test_result = None
|
||||
rerun_all_issues = False
|
||||
rerun_max_file_threhold = 0
|
||||
|
||||
# The names of all tests. Used to assert we don't have two tests with the same base name.
|
||||
# The names of all tests. Used to assert we don't have two tests with the
|
||||
# same base name.
|
||||
all_tests = set()
|
||||
|
||||
# safe default
|
||||
setCrashInfoHook = lambda x : None
|
||||
setCrashInfoHook = lambda x: None
|
||||
|
||||
|
||||
def shouldSkipBecauseOfCategories(test_categories):
|
||||
if useCategories:
|
||||
if len(test_categories) == 0 or len(categoriesList & set(test_categories)) == 0:
|
||||
if len(test_categories) == 0 or len(
|
||||
categoriesList & set(test_categories)) == 0:
|
||||
return True
|
||||
|
||||
for category in skipCategories:
|
||||
|
||||
@@ -46,9 +46,9 @@ class DarwinLogTestBase(lldbtest.TestBase):
|
||||
# or greater.
|
||||
version = platform.mac_ver()[0].split('.')
|
||||
if ((int(version[0]) == 10) and (int(version[1]) < 12) or
|
||||
(int(version[0]) < 10)):
|
||||
self.skipTest("DarwinLog tests currently require macOS 10.12+")
|
||||
return
|
||||
(int(version[0]) < 10)):
|
||||
self.skipTest("DarwinLog tests currently require macOS 10.12+")
|
||||
return
|
||||
|
||||
self.child = None
|
||||
self.child_prompt = '(lldb) '
|
||||
@@ -73,8 +73,9 @@ class DarwinLogTestBase(lldbtest.TestBase):
|
||||
|
||||
if self.enable_process_monitor_logging:
|
||||
if platform.system() == 'Darwin':
|
||||
self.runCmd("settings set target.process.extra-startup-command "
|
||||
"QSetLogging:bitmask=LOG_DARWIN_LOG;")
|
||||
self.runCmd(
|
||||
"settings set target.process.extra-startup-command "
|
||||
"QSetLogging:bitmask=LOG_DARWIN_LOG;")
|
||||
self.expect_prompt()
|
||||
|
||||
# Run the enable command if we have one.
|
||||
@@ -98,7 +99,8 @@ class DarwinLogTestBase(lldbtest.TestBase):
|
||||
|
||||
# Prevent mirroring of NSLog/os_log content to stderr. We want log
|
||||
# messages to come exclusively through our log channel.
|
||||
self.runCmd("settings set target.env-vars IDE_DISABLED_OS_ACTIVITY_DT_MODE=1")
|
||||
self.runCmd(
|
||||
"settings set target.env-vars IDE_DISABLED_OS_ACTIVITY_DT_MODE=1")
|
||||
self.expect_prompt()
|
||||
|
||||
# Run any darwin-log settings commands now, before we enable logging.
|
||||
@@ -176,7 +178,7 @@ class DarwinLogTestBase(lldbtest.TestBase):
|
||||
expect_regexes = (
|
||||
[re.compile(r"source-log-([^-]+)-(\S+)"),
|
||||
re.compile(r"exited with status")
|
||||
])
|
||||
])
|
||||
self.expect(expect_regexes)
|
||||
|
||||
|
||||
@@ -193,8 +195,11 @@ class DarwinLogEventBasedTestBase(lldbtest.TestBase):
|
||||
NO_DEBUG_INFO_TESTCASE = True
|
||||
|
||||
class EventListenerThread(threading.Thread):
|
||||
|
||||
def __init__(self, listener, process, trace_on, max_entry_count):
|
||||
super(DarwinLogEventBasedTestBase.EventListenerThread, self).__init__()
|
||||
super(
|
||||
DarwinLogEventBasedTestBase.EventListenerThread,
|
||||
self).__init__()
|
||||
self.process = process
|
||||
self.listener = listener
|
||||
self.trace_on = trace_on
|
||||
@@ -301,9 +306,9 @@ class DarwinLogEventBasedTestBase(lldbtest.TestBase):
|
||||
# or greater.
|
||||
version = platform.mac_ver()[0].split('.')
|
||||
if ((int(version[0]) == 10) and (int(version[1]) < 12) or
|
||||
(int(version[0]) < 10)):
|
||||
self.skipTest("DarwinLog tests currently require macOS 10.12+")
|
||||
return
|
||||
(int(version[0]) < 10)):
|
||||
self.skipTest("DarwinLog tests currently require macOS 10.12+")
|
||||
return
|
||||
|
||||
# Source filename.
|
||||
self.source = 'main.c'
|
||||
@@ -406,8 +411,8 @@ class DarwinLogEventBasedTestBase(lldbtest.TestBase):
|
||||
listener = lldb.SBListener("SBStructuredData listener")
|
||||
self.assertIsNotNone(listener)
|
||||
|
||||
rc = broadcaster.AddListener(listener,
|
||||
lldb.SBProcess.eBroadcastBitStructuredData)
|
||||
rc = broadcaster.AddListener(
|
||||
listener, lldb.SBProcess.eBroadcastBitStructuredData)
|
||||
self.assertTrue(rc, "Successfully add listener to process broadcaster")
|
||||
|
||||
# Start the listening thread to retrieve the events.
|
||||
|
||||
@@ -24,24 +24,33 @@ from lldbsuite.support import funcutils
|
||||
from lldbsuite.test import lldbplatform
|
||||
from lldbsuite.test import lldbplatformutil
|
||||
|
||||
|
||||
class DecorateMode:
|
||||
Skip, Xfail = range(2)
|
||||
|
||||
|
||||
|
||||
# You can use no_match to reverse the test of the conditional that is used to match keyword
|
||||
# arguments in the skip / xfail decorators. If oslist=["windows", "linux"] skips windows
|
||||
# and linux, oslist=no_match(["windows", "linux"]) skips *unless* windows or linux.
|
||||
# and linux, oslist=no_match(["windows", "linux"]) skips *unless* windows
|
||||
# or linux.
|
||||
class no_match:
|
||||
|
||||
def __init__(self, item):
|
||||
self.item = item
|
||||
|
||||
|
||||
def _check_expected_version(comparison, expected, actual):
|
||||
def fn_leq(x,y): return x <= y
|
||||
def fn_less(x,y): return x < y
|
||||
def fn_geq(x,y): return x >= y
|
||||
def fn_greater(x,y): return x > y
|
||||
def fn_eq(x,y): return x == y
|
||||
def fn_neq(x,y): return x != y
|
||||
def fn_leq(x, y): return x <= y
|
||||
|
||||
def fn_less(x, y): return x < y
|
||||
|
||||
def fn_geq(x, y): return x >= y
|
||||
|
||||
def fn_greater(x, y): return x > y
|
||||
|
||||
def fn_eq(x, y): return x == y
|
||||
|
||||
def fn_neq(x, y): return x != y
|
||||
|
||||
op_lookup = {
|
||||
"==": fn_eq,
|
||||
@@ -52,11 +61,14 @@ def _check_expected_version(comparison, expected, actual):
|
||||
"<": fn_less,
|
||||
">=": fn_geq,
|
||||
"<=": fn_leq
|
||||
}
|
||||
}
|
||||
expected_str = '.'.join([str(x) for x in expected])
|
||||
actual_str = '.'.join([str(x) for x in actual])
|
||||
|
||||
return op_lookup[comparison](LooseVersion(actual_str), LooseVersion(expected_str))
|
||||
return op_lookup[comparison](
|
||||
LooseVersion(actual_str),
|
||||
LooseVersion(expected_str))
|
||||
|
||||
|
||||
def _match_decorator_property(expected, actual):
|
||||
if actual is None or expected is None:
|
||||
@@ -64,17 +76,21 @@ def _match_decorator_property(expected, actual):
|
||||
|
||||
if isinstance(expected, no_match):
|
||||
return not _match_decorator_property(expected.item, actual)
|
||||
elif isinstance(expected, (re._pattern_type,)+six.string_types):
|
||||
elif isinstance(expected, (re._pattern_type,) + six.string_types):
|
||||
return re.search(expected, actual) is not None
|
||||
elif hasattr(expected, "__iter__"):
|
||||
return any([x is not None and _match_decorator_property(x, actual) for x in expected])
|
||||
return any([x is not None and _match_decorator_property(x, actual)
|
||||
for x in expected])
|
||||
else:
|
||||
return expected == actual
|
||||
|
||||
|
||||
def expectedFailure(expected_fn, bugnumber=None):
|
||||
def expectedFailure_impl(func):
|
||||
if isinstance(func, type) and issubclass(func, unittest2.TestCase):
|
||||
raise Exception("Decorator can only be used to decorate a test method")
|
||||
raise Exception(
|
||||
"Decorator can only be used to decorate a test method")
|
||||
|
||||
@wraps(func)
|
||||
def wrapper(*args, **kwargs):
|
||||
self = args[0]
|
||||
@@ -102,10 +118,12 @@ def expectedFailure(expected_fn, bugnumber=None):
|
||||
else:
|
||||
return expectedFailure_impl
|
||||
|
||||
|
||||
def skipTestIfFn(expected_fn, bugnumber=None):
|
||||
def skipTestIfFn_impl(func):
|
||||
if isinstance(func, type) and issubclass(func, unittest2.TestCase):
|
||||
raise Exception("@skipTestIfFn can only be used to decorate a test method")
|
||||
raise Exception(
|
||||
"@skipTestIfFn can only be used to decorate a test method")
|
||||
|
||||
@wraps(func)
|
||||
def wrapper(*args, **kwargs):
|
||||
@@ -116,7 +134,7 @@ def skipTestIfFn(expected_fn, bugnumber=None):
|
||||
reason = expected_fn()
|
||||
|
||||
if reason is not None:
|
||||
self.skipTest(reason)
|
||||
self.skipTest(reason)
|
||||
else:
|
||||
func(*args, **kwargs)
|
||||
return wrapper
|
||||
@@ -124,30 +142,50 @@ def skipTestIfFn(expected_fn, bugnumber=None):
|
||||
# Some decorators can be called both with no arguments (e.g. @expectedFailureWindows)
|
||||
# or with arguments (e.g. @expectedFailureWindows(compilers=['gcc'])). When called
|
||||
# the first way, the first argument will be the actual function because decorators are
|
||||
# weird like that. So this is basically a check that says "how was the decorator used"
|
||||
# weird like that. So this is basically a check that says "how was the
|
||||
# decorator used"
|
||||
if six.callable(bugnumber):
|
||||
return skipTestIfFn_impl(bugnumber)
|
||||
else:
|
||||
return skipTestIfFn_impl
|
||||
|
||||
def _decorateTest(mode,
|
||||
bugnumber=None, oslist=None, hostoslist=None,
|
||||
compiler=None, compiler_version=None,
|
||||
archs=None, triple=None,
|
||||
debug_info=None,
|
||||
swig_version=None, py_version=None,
|
||||
remote=None):
|
||||
def fn(self):
|
||||
skip_for_os = _match_decorator_property(lldbplatform.translate(oslist), self.getPlatform())
|
||||
skip_for_hostos = _match_decorator_property(lldbplatform.translate(hostoslist), lldbplatformutil.getHostPlatform())
|
||||
skip_for_compiler = _match_decorator_property(compiler, self.getCompiler()) and self.expectedCompilerVersion(compiler_version)
|
||||
skip_for_arch = _match_decorator_property(archs, self.getArchitecture())
|
||||
skip_for_debug_info = _match_decorator_property(debug_info, self.debug_info)
|
||||
skip_for_triple = _match_decorator_property(triple, lldb.DBG.GetSelectedPlatform().GetTriple())
|
||||
skip_for_remote = _match_decorator_property(remote, lldb.remote_platform is not None)
|
||||
|
||||
skip_for_swig_version = (swig_version is None) or (not hasattr(lldb, 'swig_version')) or (_check_expected_version(swig_version[0], swig_version[1], lldb.swig_version))
|
||||
skip_for_py_version = (py_version is None) or _check_expected_version(py_version[0], py_version[1], sys.version_info)
|
||||
def _decorateTest(mode,
|
||||
bugnumber=None, oslist=None, hostoslist=None,
|
||||
compiler=None, compiler_version=None,
|
||||
archs=None, triple=None,
|
||||
debug_info=None,
|
||||
swig_version=None, py_version=None,
|
||||
remote=None):
|
||||
def fn(self):
|
||||
skip_for_os = _match_decorator_property(
|
||||
lldbplatform.translate(oslist), self.getPlatform())
|
||||
skip_for_hostos = _match_decorator_property(
|
||||
lldbplatform.translate(hostoslist),
|
||||
lldbplatformutil.getHostPlatform())
|
||||
skip_for_compiler = _match_decorator_property(
|
||||
compiler, self.getCompiler()) and self.expectedCompilerVersion(compiler_version)
|
||||
skip_for_arch = _match_decorator_property(
|
||||
archs, self.getArchitecture())
|
||||
skip_for_debug_info = _match_decorator_property(
|
||||
debug_info, self.debug_info)
|
||||
skip_for_triple = _match_decorator_property(
|
||||
triple, lldb.DBG.GetSelectedPlatform().GetTriple())
|
||||
skip_for_remote = _match_decorator_property(
|
||||
remote, lldb.remote_platform is not None)
|
||||
|
||||
skip_for_swig_version = (
|
||||
swig_version is None) or (
|
||||
not hasattr(
|
||||
lldb,
|
||||
'swig_version')) or (
|
||||
_check_expected_version(
|
||||
swig_version[0],
|
||||
swig_version[1],
|
||||
lldb.swig_version))
|
||||
skip_for_py_version = (
|
||||
py_version is None) or _check_expected_version(
|
||||
py_version[0], py_version[1], sys.version_info)
|
||||
|
||||
# For the test to be skipped, all specified (e.g. not None) parameters must be True.
|
||||
# An unspecified parameter means "any", so those are marked skip by default. And we skip
|
||||
@@ -169,10 +207,13 @@ def _decorateTest(mode,
|
||||
reasons.append(this_condition[2])
|
||||
reason_str = None
|
||||
if final_skip_result:
|
||||
mode_str = {DecorateMode.Skip : "skipping", DecorateMode.Xfail : "xfailing"}[mode]
|
||||
mode_str = {
|
||||
DecorateMode.Skip: "skipping",
|
||||
DecorateMode.Xfail: "xfailing"}[mode]
|
||||
if len(reasons) > 0:
|
||||
reason_str = ",".join(reasons)
|
||||
reason_str = "{} due to the following parameter(s): {}".format(mode_str, reason_str)
|
||||
reason_str = "{} due to the following parameter(s): {}".format(
|
||||
mode_str, reason_str)
|
||||
else:
|
||||
reason_str = "{} unconditionally"
|
||||
if bugnumber is not None and not six.callable(bugnumber):
|
||||
@@ -192,6 +233,8 @@ def _decorateTest(mode,
|
||||
# @expectedFailureAll, xfail for all platform/compiler/arch,
|
||||
# @expectedFailureAll(compiler='gcc'), xfail for gcc on all platform/architecture
|
||||
# @expectedFailureAll(bugnumber, ["linux"], "gcc", ['>=', '4.9'], ['i386']), xfail for gcc>=4.9 on linux with i386
|
||||
|
||||
|
||||
def expectedFailureAll(bugnumber=None,
|
||||
oslist=None, hostoslist=None,
|
||||
compiler=None, compiler_version=None,
|
||||
@@ -200,13 +243,13 @@ def expectedFailureAll(bugnumber=None,
|
||||
swig_version=None, py_version=None,
|
||||
remote=None):
|
||||
return _decorateTest(DecorateMode.Xfail,
|
||||
bugnumber=bugnumber,
|
||||
oslist=oslist, hostoslist=hostoslist,
|
||||
compiler=compiler, compiler_version=compiler_version,
|
||||
archs=archs, triple=triple,
|
||||
debug_info=debug_info,
|
||||
swig_version=swig_version, py_version=py_version,
|
||||
remote=remote)
|
||||
bugnumber=bugnumber,
|
||||
oslist=oslist, hostoslist=hostoslist,
|
||||
compiler=compiler, compiler_version=compiler_version,
|
||||
archs=archs, triple=triple,
|
||||
debug_info=debug_info,
|
||||
swig_version=swig_version, py_version=py_version,
|
||||
remote=remote)
|
||||
|
||||
|
||||
# provide a function to skip on defined oslist, compiler version, and archs
|
||||
@@ -223,26 +266,31 @@ def skipIf(bugnumber=None,
|
||||
swig_version=None, py_version=None,
|
||||
remote=None):
|
||||
return _decorateTest(DecorateMode.Skip,
|
||||
bugnumber=bugnumber,
|
||||
oslist=oslist, hostoslist=hostoslist,
|
||||
compiler=compiler, compiler_version=compiler_version,
|
||||
archs=archs, triple=triple,
|
||||
debug_info=debug_info,
|
||||
swig_version=swig_version, py_version=py_version,
|
||||
remote=remote)
|
||||
bugnumber=bugnumber,
|
||||
oslist=oslist, hostoslist=hostoslist,
|
||||
compiler=compiler, compiler_version=compiler_version,
|
||||
archs=archs, triple=triple,
|
||||
debug_info=debug_info,
|
||||
swig_version=swig_version, py_version=py_version,
|
||||
remote=remote)
|
||||
|
||||
|
||||
def _skip_for_android(reason, api_levels, archs):
|
||||
def impl(obj):
|
||||
result = lldbplatformutil.match_android_device(obj.getArchitecture(), valid_archs=archs, valid_api_levels=api_levels)
|
||||
result = lldbplatformutil.match_android_device(
|
||||
obj.getArchitecture(), valid_archs=archs, valid_api_levels=api_levels)
|
||||
return reason if result else None
|
||||
return impl
|
||||
|
||||
|
||||
def add_test_categories(cat):
|
||||
"""Add test categories to a TestCase method"""
|
||||
cat = test_categories.validate(cat, True)
|
||||
|
||||
def impl(func):
|
||||
if isinstance(func, type) and issubclass(func, unittest2.TestCase):
|
||||
raise Exception("@add_test_categories can only be used to decorate a test method")
|
||||
raise Exception(
|
||||
"@add_test_categories can only be used to decorate a test method")
|
||||
if hasattr(func, "categories"):
|
||||
cat.extend(func.categories)
|
||||
func.categories = cat
|
||||
@@ -250,6 +298,7 @@ def add_test_categories(cat):
|
||||
|
||||
return impl
|
||||
|
||||
|
||||
def benchmarks_test(func):
|
||||
"""Decorate the item as a benchmarks test."""
|
||||
def should_skip_benchmarks_test():
|
||||
@@ -260,11 +309,14 @@ def benchmarks_test(func):
|
||||
result.__benchmarks_test__ = True
|
||||
return result
|
||||
|
||||
|
||||
def no_debug_info_test(func):
|
||||
"""Decorate the item as a test what don't use any debug info. If this annotation is specified
|
||||
then the test runner won't generate a separate test for each debug info format. """
|
||||
if isinstance(func, type) and issubclass(func, unittest2.TestCase):
|
||||
raise Exception("@no_debug_info_test can only be used to decorate a test method")
|
||||
raise Exception(
|
||||
"@no_debug_info_test can only be used to decorate a test method")
|
||||
|
||||
@wraps(func)
|
||||
def wrapper(self, *args, **kwargs):
|
||||
return func(self, *args, **kwargs)
|
||||
@@ -273,30 +325,51 @@ def no_debug_info_test(func):
|
||||
wrapper.__no_debug_info_test__ = True
|
||||
return wrapper
|
||||
|
||||
|
||||
def debugserver_test(func):
|
||||
"""Decorate the item as a debugserver test."""
|
||||
def should_skip_debugserver_test():
|
||||
return "debugserver tests" if configuration.dont_do_debugserver_test else None
|
||||
return skipTestIfFn(should_skip_debugserver_test)(func)
|
||||
|
||||
|
||||
def llgs_test(func):
|
||||
"""Decorate the item as a lldb-server test."""
|
||||
def should_skip_llgs_tests():
|
||||
return "llgs tests" if configuration.dont_do_llgs_test else None
|
||||
return skipTestIfFn(should_skip_llgs_tests)(func)
|
||||
|
||||
|
||||
def not_remote_testsuite_ready(func):
|
||||
"""Decorate the item as a test which is not ready yet for remote testsuite."""
|
||||
def is_remote():
|
||||
return "Not ready for remote testsuite" if lldb.remote_platform else None
|
||||
return skipTestIfFn(is_remote)(func)
|
||||
|
||||
def expectedFailureOS(oslist, bugnumber=None, compilers=None, debug_info=None, archs=None):
|
||||
return expectedFailureAll(oslist=oslist, bugnumber=bugnumber, compiler=compilers, archs=archs, debug_info=debug_info)
|
||||
|
||||
def expectedFailureOS(
|
||||
oslist,
|
||||
bugnumber=None,
|
||||
compilers=None,
|
||||
debug_info=None,
|
||||
archs=None):
|
||||
return expectedFailureAll(
|
||||
oslist=oslist,
|
||||
bugnumber=bugnumber,
|
||||
compiler=compilers,
|
||||
archs=archs,
|
||||
debug_info=debug_info)
|
||||
|
||||
|
||||
def expectedFailureDarwin(bugnumber=None, compilers=None, debug_info=None):
|
||||
# For legacy reasons, we support both "darwin" and "macosx" as OS X triples.
|
||||
return expectedFailureOS(lldbplatform.darwin_all, bugnumber, compilers, debug_info=debug_info)
|
||||
# For legacy reasons, we support both "darwin" and "macosx" as OS X
|
||||
# triples.
|
||||
return expectedFailureOS(
|
||||
lldbplatform.darwin_all,
|
||||
bugnumber,
|
||||
compilers,
|
||||
debug_info=debug_info)
|
||||
|
||||
|
||||
def expectedFailureAndroid(bugnumber=None, api_levels=None, archs=None):
|
||||
""" Mark a test as xfail for Android.
|
||||
@@ -308,10 +381,17 @@ def expectedFailureAndroid(bugnumber=None, api_levels=None, archs=None):
|
||||
arch - A sequence of architecture names specifying the architectures
|
||||
for which a test is expected to fail. None means all architectures.
|
||||
"""
|
||||
return expectedFailure(_skip_for_android("xfailing on android", api_levels, archs), bugnumber)
|
||||
return expectedFailure(
|
||||
_skip_for_android(
|
||||
"xfailing on android",
|
||||
api_levels,
|
||||
archs),
|
||||
bugnumber)
|
||||
|
||||
# Flakey tests get two chances to run. If they fail the first time round, the result formatter
|
||||
# makes sure it is run one more time.
|
||||
|
||||
|
||||
def expectedFlakey(expected_fn, bugnumber=None):
|
||||
def expectedFailure_impl(func):
|
||||
@wraps(func)
|
||||
@@ -335,52 +415,76 @@ def expectedFlakey(expected_fn, bugnumber=None):
|
||||
else:
|
||||
return expectedFailure_impl
|
||||
|
||||
|
||||
def expectedFlakeyDwarf(bugnumber=None):
|
||||
def fn(self):
|
||||
return self.debug_info == "dwarf"
|
||||
return expectedFlakey(fn, bugnumber)
|
||||
|
||||
|
||||
def expectedFlakeyDsym(bugnumber=None):
|
||||
def fn(self):
|
||||
return self.debug_info == "dwarf"
|
||||
return expectedFlakey(fn, bugnumber)
|
||||
|
||||
|
||||
def expectedFlakeyOS(oslist, bugnumber=None, compilers=None):
|
||||
def fn(self):
|
||||
return (self.getPlatform() in oslist and
|
||||
self.expectedCompiler(compilers))
|
||||
return expectedFlakey(fn, bugnumber)
|
||||
|
||||
|
||||
def expectedFlakeyDarwin(bugnumber=None, compilers=None):
|
||||
# For legacy reasons, we support both "darwin" and "macosx" as OS X triples.
|
||||
return expectedFlakeyOS(lldbplatformutil.getDarwinOSTriples(), bugnumber, compilers)
|
||||
# For legacy reasons, we support both "darwin" and "macosx" as OS X
|
||||
# triples.
|
||||
return expectedFlakeyOS(
|
||||
lldbplatformutil.getDarwinOSTriples(),
|
||||
bugnumber,
|
||||
compilers)
|
||||
|
||||
|
||||
def expectedFlakeyFreeBSD(bugnumber=None, compilers=None):
|
||||
return expectedFlakeyOS(['freebsd'], bugnumber, compilers)
|
||||
|
||||
|
||||
def expectedFlakeyLinux(bugnumber=None, compilers=None):
|
||||
return expectedFlakeyOS(['linux'], bugnumber, compilers)
|
||||
|
||||
|
||||
def expectedFlakeyNetBSD(bugnumber=None, compilers=None):
|
||||
return expectedFlakeyOS(['netbsd'], bugnumber, compilers)
|
||||
|
||||
|
||||
def expectedFlakeyCompiler(compiler, compiler_version=None, bugnumber=None):
|
||||
if compiler_version is None:
|
||||
compiler_version=['=', None]
|
||||
compiler_version = ['=', None]
|
||||
|
||||
def fn(self):
|
||||
return compiler in self.getCompiler() and self.expectedCompilerVersion(compiler_version)
|
||||
return expectedFlakey(fn, bugnumber)
|
||||
|
||||
# @expectedFlakeyClang('bugnumber', ['<=', '3.4'])
|
||||
|
||||
|
||||
def expectedFlakeyClang(bugnumber=None, compiler_version=None):
|
||||
return expectedFlakeyCompiler('clang', compiler_version, bugnumber)
|
||||
|
||||
# @expectedFlakeyGcc('bugnumber', ['<=', '3.4'])
|
||||
|
||||
|
||||
def expectedFlakeyGcc(bugnumber=None, compiler_version=None):
|
||||
return expectedFlakeyCompiler('gcc', compiler_version, bugnumber)
|
||||
|
||||
|
||||
def expectedFlakeyAndroid(bugnumber=None, api_levels=None, archs=None):
|
||||
return expectedFlakey(_skip_for_android("flakey on android", api_levels, archs), bugnumber)
|
||||
return expectedFlakey(
|
||||
_skip_for_android(
|
||||
"flakey on android",
|
||||
api_levels,
|
||||
archs),
|
||||
bugnumber)
|
||||
|
||||
|
||||
def skipIfRemote(func):
|
||||
"""Decorate the item to skip tests if testing remotely."""
|
||||
@@ -388,61 +492,86 @@ def skipIfRemote(func):
|
||||
return "skip on remote platform" if lldb.remote_platform else None
|
||||
return skipTestIfFn(is_remote)(func)
|
||||
|
||||
|
||||
def skipIfRemoteDueToDeadlock(func):
|
||||
"""Decorate the item to skip tests if testing remotely due to the test deadlocking."""
|
||||
def is_remote():
|
||||
return "skip on remote platform (deadlocks)" if lldb.remote_platform else None
|
||||
return skipTestIfFn(is_remote)(func)
|
||||
|
||||
|
||||
def skipIfNoSBHeaders(func):
|
||||
"""Decorate the item to mark tests that should be skipped when LLDB is built with no SB API headers."""
|
||||
def are_sb_headers_missing():
|
||||
if lldbplatformutil.getHostPlatform() == 'darwin':
|
||||
header = os.path.join(os.environ["LLDB_LIB_DIR"], 'LLDB.framework', 'Versions','Current','Headers','LLDB.h')
|
||||
header = os.path.join(
|
||||
os.environ["LLDB_LIB_DIR"],
|
||||
'LLDB.framework',
|
||||
'Versions',
|
||||
'Current',
|
||||
'Headers',
|
||||
'LLDB.h')
|
||||
else:
|
||||
header = os.path.join(os.environ["LLDB_SRC"], "include", "lldb", "API", "LLDB.h")
|
||||
header = os.path.join(
|
||||
os.environ["LLDB_SRC"],
|
||||
"include",
|
||||
"lldb",
|
||||
"API",
|
||||
"LLDB.h")
|
||||
if not os.path.exists(header):
|
||||
return "skip because LLDB.h header not found"
|
||||
return None
|
||||
|
||||
return skipTestIfFn(are_sb_headers_missing)(func)
|
||||
|
||||
|
||||
def skipIfiOSSimulator(func):
|
||||
"""Decorate the item to skip tests that should be skipped on the iOS Simulator."""
|
||||
def is_ios_simulator():
|
||||
return "skip on the iOS Simulator" if configuration.lldb_platform_name == 'ios-simulator' else None
|
||||
return skipTestIfFn(is_ios_simulator)(func)
|
||||
|
||||
|
||||
def skipIfFreeBSD(func):
|
||||
"""Decorate the item to skip tests that should be skipped on FreeBSD."""
|
||||
return skipIfPlatform(["freebsd"])(func)
|
||||
|
||||
|
||||
def skipIfNetBSD(func):
|
||||
"""Decorate the item to skip tests that should be skipped on NetBSD."""
|
||||
return skipIfPlatform(["netbsd"])(func)
|
||||
|
||||
|
||||
def skipIfDarwin(func):
|
||||
"""Decorate the item to skip tests that should be skipped on Darwin."""
|
||||
return skipIfPlatform(lldbplatform.translate(lldbplatform.darwin_all))(func)
|
||||
return skipIfPlatform(
|
||||
lldbplatform.translate(
|
||||
lldbplatform.darwin_all))(func)
|
||||
|
||||
|
||||
def skipIfLinux(func):
|
||||
"""Decorate the item to skip tests that should be skipped on Linux."""
|
||||
return skipIfPlatform(["linux"])(func)
|
||||
|
||||
|
||||
def skipIfWindows(func):
|
||||
"""Decorate the item to skip tests that should be skipped on Windows."""
|
||||
return skipIfPlatform(["windows"])(func)
|
||||
|
||||
|
||||
def skipUnlessWindows(func):
|
||||
"""Decorate the item to skip tests that should be skipped on any non-Windows platform."""
|
||||
return skipUnlessPlatform(["windows"])(func)
|
||||
|
||||
|
||||
def skipUnlessDarwin(func):
|
||||
"""Decorate the item to skip tests that should be skipped on any non Darwin platform."""
|
||||
return skipUnlessPlatform(lldbplatformutil.getDarwinOSTriples())(func)
|
||||
|
||||
|
||||
def skipUnlessGoInstalled(func):
|
||||
"""Decorate the item to skip tests when no Go compiler is available."""
|
||||
|
||||
def is_go_missing(self):
|
||||
compiler = self.getGoCompilerVersion()
|
||||
if not compiler:
|
||||
@@ -450,7 +579,8 @@ def skipUnlessGoInstalled(func):
|
||||
match_version = re.search(r"(\d+\.\d+(\.\d+)?)", compiler)
|
||||
if not match_version:
|
||||
# Couldn't determine version.
|
||||
return "skipping because go version could not be parsed out of {}".format(compiler)
|
||||
return "skipping because go version could not be parsed out of {}".format(
|
||||
compiler)
|
||||
else:
|
||||
min_strict_version = StrictVersion("1.4.0")
|
||||
compiler_strict_version = StrictVersion(match_version.group(1))
|
||||
@@ -460,20 +590,26 @@ def skipUnlessGoInstalled(func):
|
||||
return None
|
||||
return skipTestIfFn(is_go_missing)(func)
|
||||
|
||||
|
||||
def skipIfHostIncompatibleWithRemote(func):
|
||||
"""Decorate the item to skip tests if binaries built on this host are incompatible."""
|
||||
|
||||
def is_host_incompatible_with_remote(self):
|
||||
host_arch = self.getLldbArchitecture()
|
||||
host_platform = lldbplatformutil.getHostPlatform()
|
||||
target_arch = self.getArchitecture()
|
||||
target_platform = 'darwin' if self.platformIsDarwin() else self.getPlatform()
|
||||
if not (target_arch == 'x86_64' and host_arch == 'i386') and host_arch != target_arch:
|
||||
return "skipping because target %s is not compatible with host architecture %s" % (target_arch, host_arch)
|
||||
if not (target_arch == 'x86_64' and host_arch ==
|
||||
'i386') and host_arch != target_arch:
|
||||
return "skipping because target %s is not compatible with host architecture %s" % (
|
||||
target_arch, host_arch)
|
||||
elif target_platform != host_platform:
|
||||
return "skipping because target is %s but host is %s" % (target_platform, host_platform)
|
||||
return "skipping because target is %s but host is %s" % (
|
||||
target_platform, host_platform)
|
||||
return None
|
||||
return skipTestIfFn(is_host_incompatible_with_remote)(func)
|
||||
|
||||
|
||||
def skipIfPlatform(oslist):
|
||||
"""Decorate the item to skip tests if running on one of the listed platforms."""
|
||||
# This decorator cannot be ported to `skipIf` yet because it is used on entire
|
||||
@@ -481,6 +617,7 @@ def skipIfPlatform(oslist):
|
||||
return unittest2.skipIf(lldbplatformutil.getPlatform() in oslist,
|
||||
"skip on %s" % (", ".join(oslist)))
|
||||
|
||||
|
||||
def skipUnlessPlatform(oslist):
|
||||
"""Decorate the item to skip tests unless running on one of the listed platforms."""
|
||||
# This decorator cannot be ported to `skipIf` yet because it is used on entire
|
||||
@@ -488,6 +625,7 @@ def skipUnlessPlatform(oslist):
|
||||
return unittest2.skipUnless(lldbplatformutil.getPlatform() in oslist,
|
||||
"requires one of %s" % (", ".join(oslist)))
|
||||
|
||||
|
||||
def skipIfTargetAndroid(api_levels=None, archs=None):
|
||||
"""Decorator to skip tests when the target is Android.
|
||||
|
||||
@@ -497,17 +635,33 @@ def skipIfTargetAndroid(api_levels=None, archs=None):
|
||||
arch - A sequence of architecture names specifying the architectures
|
||||
for which a test is skipped. None means all architectures.
|
||||
"""
|
||||
return skipTestIfFn(_skip_for_android("skipping for android", api_levels, archs))
|
||||
return skipTestIfFn(
|
||||
_skip_for_android(
|
||||
"skipping for android",
|
||||
api_levels,
|
||||
archs))
|
||||
|
||||
|
||||
def skipUnlessCompilerRt(func):
|
||||
"""Decorate the item to skip tests if testing remotely."""
|
||||
def is_compiler_rt_missing():
|
||||
compilerRtPath = os.path.join(os.path.dirname(__file__), "..", "..", "..", "..", "llvm","projects","compiler-rt")
|
||||
return "compiler-rt not found" if not os.path.exists(compilerRtPath) else None
|
||||
compilerRtPath = os.path.join(
|
||||
os.path.dirname(__file__),
|
||||
"..",
|
||||
"..",
|
||||
"..",
|
||||
"..",
|
||||
"llvm",
|
||||
"projects",
|
||||
"compiler-rt")
|
||||
return "compiler-rt not found" if not os.path.exists(
|
||||
compilerRtPath) else None
|
||||
return skipTestIfFn(is_compiler_rt_missing)(func)
|
||||
|
||||
|
||||
def skipUnlessThreadSanitizer(func):
|
||||
"""Decorate the item to skip test unless Clang -fsanitize=thread is supported."""
|
||||
|
||||
def is_compiler_clang_with_thread_sanitizer(self):
|
||||
compiler_path = self.getCompiler()
|
||||
compiler = os.path.basename(compiler_path)
|
||||
@@ -515,10 +669,10 @@ def skipUnlessThreadSanitizer(func):
|
||||
return "Test requires clang as compiler"
|
||||
f = tempfile.NamedTemporaryFile()
|
||||
cmd = "echo 'int main() {}' | %s -x c -o %s -" % (compiler_path, f.name)
|
||||
if os.popen(cmd).close() != None:
|
||||
if os.popen(cmd).close() is not None:
|
||||
return None # The compiler cannot compile at all, let's *not* skip the test
|
||||
cmd = "echo 'int main() {}' | %s -fsanitize=thread -x c -o %s -" % (compiler_path, f.name)
|
||||
if os.popen(cmd).close() != None:
|
||||
if os.popen(cmd).close() is not None:
|
||||
return "Compiler cannot compile with -fsanitize=thread"
|
||||
return None
|
||||
return skipTestIfFn(is_compiler_clang_with_thread_sanitizer)(func)
|
||||
|
||||
@@ -104,6 +104,7 @@ def setup_global_variables(
|
||||
global GET_WORKER_INDEX
|
||||
GET_WORKER_INDEX = get_worker_index_use_pid
|
||||
|
||||
|
||||
def report_test_failure(name, command, output, timeout):
|
||||
global output_lock
|
||||
with output_lock:
|
||||
@@ -152,14 +153,15 @@ def parse_test_results(output):
|
||||
result, re.MULTILINE)
|
||||
error_count = re.search("^RESULT:.*([0-9]+) errors",
|
||||
result, re.MULTILINE)
|
||||
unexpected_success_count = re.search("^RESULT:.*([0-9]+) unexpected successes",
|
||||
result, re.MULTILINE)
|
||||
unexpected_success_count = re.search(
|
||||
"^RESULT:.*([0-9]+) unexpected successes", result, re.MULTILINE)
|
||||
if pass_count is not None:
|
||||
passes = passes + int(pass_count.group(1))
|
||||
if fail_count is not None:
|
||||
failures = failures + int(fail_count.group(1))
|
||||
if unexpected_success_count is not None:
|
||||
unexpected_successes = unexpected_successes + int(unexpected_success_count.group(1))
|
||||
unexpected_successes = unexpected_successes + \
|
||||
int(unexpected_success_count.group(1))
|
||||
if error_count is not None:
|
||||
failures = failures + int(error_count.group(1))
|
||||
return passes, failures, unexpected_successes
|
||||
@@ -167,6 +169,7 @@ def parse_test_results(output):
|
||||
|
||||
class DoTestProcessDriver(process_control.ProcessDriver):
|
||||
"""Drives the dotest.py inferior process and handles bookkeeping."""
|
||||
|
||||
def __init__(self, output_file, output_file_lock, pid_events, file_name,
|
||||
soft_terminate_timeout):
|
||||
super(DoTestProcessDriver, self).__init__(
|
||||
@@ -210,7 +213,11 @@ class DoTestProcessDriver(process_control.ProcessDriver):
|
||||
# only stderr does.
|
||||
report_test_pass(self.file_name, output[1])
|
||||
else:
|
||||
report_test_failure(self.file_name, command, output[1], was_timeout)
|
||||
report_test_failure(
|
||||
self.file_name,
|
||||
command,
|
||||
output[1],
|
||||
was_timeout)
|
||||
|
||||
# Save off the results for the caller.
|
||||
self.results = (
|
||||
@@ -635,8 +642,13 @@ def initialize_global_vars_common(num_threads, test_work_items):
|
||||
test_counter = multiprocessing.Value('i', 0)
|
||||
test_name_len = multiprocessing.Value('i', 0)
|
||||
if not (RESULTS_FORMATTER and RESULTS_FORMATTER.is_using_terminal()):
|
||||
print("Testing: %d test suites, %d thread%s" % (
|
||||
total_tests, num_threads, (num_threads > 1) * "s"), file=sys.stderr)
|
||||
print(
|
||||
"Testing: %d test suites, %d thread%s" %
|
||||
(total_tests,
|
||||
num_threads,
|
||||
(num_threads > 1) *
|
||||
"s"),
|
||||
file=sys.stderr)
|
||||
update_progress()
|
||||
|
||||
|
||||
@@ -671,7 +683,6 @@ def initialize_global_vars_threading(num_threads, test_work_items):
|
||||
index_map[thread_id] = len(index_map)
|
||||
return index_map[thread_id]
|
||||
|
||||
|
||||
global GET_WORKER_INDEX
|
||||
GET_WORKER_INDEX = get_worker_index_threading
|
||||
|
||||
@@ -1079,6 +1090,7 @@ def inprocess_exec_test_runner(test_work_items):
|
||||
|
||||
return test_results
|
||||
|
||||
|
||||
def walk_and_invoke(test_files, dotest_argv, num_workers, test_runner_func):
|
||||
"""Invokes the test runner on each test file specified by test_files.
|
||||
|
||||
@@ -1278,7 +1290,7 @@ def _remove_option(
|
||||
removal_count = 2
|
||||
else:
|
||||
removal_count = 1
|
||||
del args[index:index+removal_count]
|
||||
del args[index:index + removal_count]
|
||||
return True
|
||||
except ValueError:
|
||||
# Thanks to argparse not handling options with known arguments
|
||||
@@ -1516,7 +1528,8 @@ def main(num_threads, test_subdir, test_runner_name, results_formatter):
|
||||
if test_subdir and len(test_subdir) > 0:
|
||||
test_subdir = os.path.join(test_directory, test_subdir)
|
||||
if not os.path.isdir(test_subdir):
|
||||
print('specified test subdirectory {} is not a valid directory\n'.format(test_subdir))
|
||||
print(
|
||||
'specified test subdirectory {} is not a valid directory\n'.format(test_subdir))
|
||||
else:
|
||||
test_subdir = test_directory
|
||||
|
||||
@@ -1662,7 +1675,9 @@ def main(num_threads, test_subdir, test_runner_name, results_formatter):
|
||||
unexpected_successes.sort()
|
||||
print("\nUnexpected Successes (%d)" % len(unexpected_successes))
|
||||
for u in unexpected_successes:
|
||||
print("UNEXPECTED SUCCESS: LLDB (suite) :: %s (%s)" % (u, system_info))
|
||||
print(
|
||||
"UNEXPECTED SUCCESS: LLDB (suite) :: %s (%s)" %
|
||||
(u, system_info))
|
||||
|
||||
sys.exit(exit_code)
|
||||
|
||||
|
||||
@@ -46,10 +46,12 @@ from . import test_result
|
||||
from lldbsuite.test_event.event_builder import EventBuilder
|
||||
from ..support import seven
|
||||
|
||||
|
||||
def is_exe(fpath):
|
||||
"""Returns true if fpath is an executable."""
|
||||
return os.path.isfile(fpath) and os.access(fpath, os.X_OK)
|
||||
|
||||
|
||||
def which(program):
|
||||
"""Returns the full path to a program; None otherwise."""
|
||||
fpath, fname = os.path.split(program)
|
||||
@@ -63,24 +65,28 @@ def which(program):
|
||||
return exe_file
|
||||
return None
|
||||
|
||||
|
||||
class _WritelnDecorator(object):
|
||||
"""Used to decorate file-like objects with a handy 'writeln' method"""
|
||||
def __init__(self,stream):
|
||||
|
||||
def __init__(self, stream):
|
||||
self.stream = stream
|
||||
|
||||
def __getattr__(self, attr):
|
||||
if attr in ('stream', '__getstate__'):
|
||||
raise AttributeError(attr)
|
||||
return getattr(self.stream,attr)
|
||||
return getattr(self.stream, attr)
|
||||
|
||||
def writeln(self, arg=None):
|
||||
if arg:
|
||||
self.write(arg)
|
||||
self.write('\n') # text-mode streams translate to \r\n if needed
|
||||
self.write('\n') # text-mode streams translate to \r\n if needed
|
||||
|
||||
#
|
||||
# Global variables:
|
||||
#
|
||||
|
||||
|
||||
def usage(parser):
|
||||
parser.print_help()
|
||||
if configuration.verbose > 0:
|
||||
@@ -195,6 +201,7 @@ o GDB_REMOTE_LOG: if defined, specifies the log file pathname for the
|
||||
""")
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
def parseOptionsAndInitTestdirs():
|
||||
"""Initialize the list of directories containing our unittest scripts.
|
||||
|
||||
@@ -213,9 +220,10 @@ def parseOptionsAndInitTestdirs():
|
||||
for env_var in args.unset_env_varnames:
|
||||
if env_var in os.environ:
|
||||
# From Python Doc: When unsetenv() is supported, deletion of items in os.environ
|
||||
# is automatically translated into a corresponding call to unsetenv().
|
||||
# is automatically translated into a corresponding call to
|
||||
# unsetenv().
|
||||
del os.environ[env_var]
|
||||
#os.unsetenv(env_var)
|
||||
# os.unsetenv(env_var)
|
||||
|
||||
if args.set_env_vars:
|
||||
for env_var in args.set_env_vars:
|
||||
@@ -235,9 +243,13 @@ def parseOptionsAndInitTestdirs():
|
||||
if args.compilers:
|
||||
configuration.compilers = args.compilers
|
||||
else:
|
||||
# Use a compiler appropriate appropriate for the Apple SDK if one was specified
|
||||
# Use a compiler appropriate appropriate for the Apple SDK if one was
|
||||
# specified
|
||||
if platform_system == 'Darwin' and args.apple_sdk:
|
||||
configuration.compilers = [seven.get_command_output('xcrun -sdk "%s" -find clang 2> /dev/null' % (args.apple_sdk))]
|
||||
configuration.compilers = [
|
||||
seven.get_command_output(
|
||||
'xcrun -sdk "%s" -find clang 2> /dev/null' %
|
||||
(args.apple_sdk))]
|
||||
else:
|
||||
# 'clang' on ubuntu 14.04 is 3.4 so we try clang-3.5 first
|
||||
candidateCompilers = ['clang-3.5', 'clang', 'gcc']
|
||||
@@ -254,33 +266,43 @@ def parseOptionsAndInitTestdirs():
|
||||
|
||||
# Set SDKROOT if we are using an Apple SDK
|
||||
if platform_system == 'Darwin' and args.apple_sdk:
|
||||
os.environ['SDKROOT'] = seven.get_command_output('xcrun --sdk "%s" --show-sdk-path 2> /dev/null' % (args.apple_sdk))
|
||||
os.environ['SDKROOT'] = seven.get_command_output(
|
||||
'xcrun --sdk "%s" --show-sdk-path 2> /dev/null' %
|
||||
(args.apple_sdk))
|
||||
|
||||
if args.archs:
|
||||
configuration.archs = args.archs
|
||||
for arch in configuration.archs:
|
||||
if arch.startswith('arm') and platform_system == 'Darwin' and not args.apple_sdk:
|
||||
os.environ['SDKROOT'] = seven.get_command_output('xcrun --sdk iphoneos.internal --show-sdk-path 2> /dev/null')
|
||||
if arch.startswith(
|
||||
'arm') and platform_system == 'Darwin' and not args.apple_sdk:
|
||||
os.environ['SDKROOT'] = seven.get_command_output(
|
||||
'xcrun --sdk iphoneos.internal --show-sdk-path 2> /dev/null')
|
||||
if not os.path.exists(os.environ['SDKROOT']):
|
||||
os.environ['SDKROOT'] = seven.get_command_output('xcrun --sdk iphoneos --show-sdk-path 2> /dev/null')
|
||||
os.environ['SDKROOT'] = seven.get_command_output(
|
||||
'xcrun --sdk iphoneos --show-sdk-path 2> /dev/null')
|
||||
else:
|
||||
configuration.archs = [platform_machine]
|
||||
|
||||
if args.categoriesList:
|
||||
configuration.categoriesList = set(test_categories.validate(args.categoriesList, False))
|
||||
configuration.categoriesList = set(
|
||||
test_categories.validate(
|
||||
args.categoriesList, False))
|
||||
configuration.useCategories = True
|
||||
else:
|
||||
configuration.categoriesList = []
|
||||
|
||||
if args.skipCategories:
|
||||
configuration.skipCategories = test_categories.validate(args.skipCategories, False)
|
||||
configuration.skipCategories = test_categories.validate(
|
||||
args.skipCategories, False)
|
||||
|
||||
if args.E:
|
||||
cflags_extras = args.E
|
||||
os.environ['CFLAGS_EXTRAS'] = cflags_extras
|
||||
|
||||
if args.d:
|
||||
sys.stdout.write("Suspending the process %d to wait for debugger to attach...\n" % os.getpid())
|
||||
sys.stdout.write(
|
||||
"Suspending the process %d to wait for debugger to attach...\n" %
|
||||
os.getpid())
|
||||
sys.stdout.flush()
|
||||
os.kill(os.getpid(), signal.SIGSTOP)
|
||||
|
||||
@@ -334,10 +356,11 @@ def parseOptionsAndInitTestdirs():
|
||||
configuration.count = args.sharp
|
||||
|
||||
if sys.platform.startswith('win32'):
|
||||
os.environ['LLDB_DISABLE_CRASH_DIALOG'] = str(args.disable_crash_dialog)
|
||||
os.environ['LLDB_DISABLE_CRASH_DIALOG'] = str(
|
||||
args.disable_crash_dialog)
|
||||
os.environ['LLDB_LAUNCH_INFERIORS_WITHOUT_CONSOLE'] = str(True)
|
||||
|
||||
if do_help == True:
|
||||
if do_help:
|
||||
usage(parser)
|
||||
|
||||
if args.no_multiprocess:
|
||||
@@ -415,12 +438,14 @@ def parseOptionsAndInitTestdirs():
|
||||
|
||||
# Gather all the dirs passed on the command line.
|
||||
if len(args.args) > 0:
|
||||
configuration.testdirs = list(map(lambda x: os.path.realpath(os.path.abspath(x)), args.args))
|
||||
configuration.testdirs = list(
|
||||
map(lambda x: os.path.realpath(os.path.abspath(x)), args.args))
|
||||
# Shut off multiprocessing mode when test directories are specified.
|
||||
configuration.no_multiprocess_test_runner = True
|
||||
|
||||
#print("testdirs:", testdirs)
|
||||
|
||||
|
||||
def getXcodeOutputPaths(lldbRootDirectory):
|
||||
result = []
|
||||
|
||||
@@ -428,11 +453,16 @@ def getXcodeOutputPaths(lldbRootDirectory):
|
||||
xcode3_build_dir = ['build']
|
||||
xcode4_build_dir = ['build', 'lldb', 'Build', 'Products']
|
||||
|
||||
configurations = [['Debug'], ['DebugClang'], ['Release'], ['BuildAndIntegration']]
|
||||
configurations = [
|
||||
['Debug'],
|
||||
['DebugClang'],
|
||||
['Release'],
|
||||
['BuildAndIntegration']]
|
||||
xcode_build_dirs = [xcode3_build_dir, xcode4_build_dir]
|
||||
for configuration in configurations:
|
||||
for xcode_build_dir in xcode_build_dirs:
|
||||
outputPath = os.path.join(lldbRootDirectory, *(xcode_build_dir+configuration) )
|
||||
outputPath = os.path.join(
|
||||
lldbRootDirectory, *(xcode_build_dir + configuration))
|
||||
result.append(outputPath)
|
||||
|
||||
return result
|
||||
@@ -499,17 +529,24 @@ def getOutputPaths(lldbRootDirectory):
|
||||
|
||||
# cmake builds? look for build or build/host folder next to llvm directory
|
||||
# lldb is located in llvm/tools/lldb so we need to go up three levels
|
||||
llvmParentDir = os.path.abspath(os.path.join(lldbRootDirectory, os.pardir, os.pardir, os.pardir))
|
||||
llvmParentDir = os.path.abspath(
|
||||
os.path.join(
|
||||
lldbRootDirectory,
|
||||
os.pardir,
|
||||
os.pardir,
|
||||
os.pardir))
|
||||
result.append(os.path.join(llvmParentDir, 'build', 'bin'))
|
||||
result.append(os.path.join(llvmParentDir, 'build', 'host', 'bin'))
|
||||
|
||||
# some cmake developers keep their build directory beside their lldb directory
|
||||
# some cmake developers keep their build directory beside their lldb
|
||||
# directory
|
||||
lldbParentDir = os.path.abspath(os.path.join(lldbRootDirectory, os.pardir))
|
||||
result.append(os.path.join(lldbParentDir, 'build', 'bin'))
|
||||
result.append(os.path.join(lldbParentDir, 'build', 'host', 'bin'))
|
||||
|
||||
return result
|
||||
|
||||
|
||||
def setupSysPath():
|
||||
"""
|
||||
Add LLDB.framework/Resources/Python to the search paths for modules.
|
||||
@@ -535,12 +572,15 @@ def setupSysPath():
|
||||
toolsLLDBMIPath = os.path.join(scriptPath, 'tools', 'lldb-mi')
|
||||
toolsLLDBServerPath = os.path.join(scriptPath, 'tools', 'lldb-server')
|
||||
|
||||
# Insert script dir, plugin dir, lldb-mi dir and lldb-server dir to the sys.path.
|
||||
# Insert script dir, plugin dir, lldb-mi dir and lldb-server dir to the
|
||||
# sys.path.
|
||||
sys.path.insert(0, pluginPath)
|
||||
sys.path.insert(0, toolsLLDBMIPath) # Adding test/tools/lldb-mi to the path makes it easy
|
||||
# to "import lldbmi_testcase" from the MI tests
|
||||
sys.path.insert(0, toolsLLDBServerPath) # Adding test/tools/lldb-server to the path makes it easy
|
||||
# to "import lldbgdbserverutils" from the lldb-server tests
|
||||
# Adding test/tools/lldb-mi to the path makes it easy
|
||||
sys.path.insert(0, toolsLLDBMIPath)
|
||||
# to "import lldbmi_testcase" from the MI tests
|
||||
# Adding test/tools/lldb-server to the path makes it easy
|
||||
sys.path.insert(0, toolsLLDBServerPath)
|
||||
# to "import lldbgdbserverutils" from the lldb-server tests
|
||||
|
||||
# This is the root of the lldb git/svn checkout
|
||||
# When this changes over to a package instead of a standalone script, this
|
||||
@@ -572,16 +612,22 @@ def setupSysPath():
|
||||
lldbtest_config.lldbExec = which('lldb')
|
||||
|
||||
if lldbtest_config.lldbExec and not is_exe(lldbtest_config.lldbExec):
|
||||
print("'{}' is not a path to a valid executable".format(lldbtest_config.lldbExec))
|
||||
print(
|
||||
"'{}' is not a path to a valid executable".format(
|
||||
lldbtest_config.lldbExec))
|
||||
lldbtest_config.lldbExec = None
|
||||
|
||||
if not lldbtest_config.lldbExec:
|
||||
print("The 'lldb' executable cannot be located. Some of the tests may not be run as a result.")
|
||||
sys.exit(-1)
|
||||
|
||||
lldbLibDir = os.path.dirname(lldbtest_config.lldbExec) # confusingly, this is the "bin" directory
|
||||
# confusingly, this is the "bin" directory
|
||||
lldbLibDir = os.path.dirname(lldbtest_config.lldbExec)
|
||||
os.environ["LLDB_LIB_DIR"] = lldbLibDir
|
||||
lldbImpLibDir = os.path.join(lldbLibDir, '..', 'lib') if sys.platform.startswith('win32') else lldbLibDir
|
||||
lldbImpLibDir = os.path.join(
|
||||
lldbLibDir,
|
||||
'..',
|
||||
'lib') if sys.platform.startswith('win32') else lldbLibDir
|
||||
os.environ["LLDB_IMPLIB_DIR"] = lldbImpLibDir
|
||||
print("LLDB library dir:", os.environ["LLDB_LIB_DIR"])
|
||||
print("LLDB import library dir:", os.environ["LLDB_IMPLIB_DIR"])
|
||||
@@ -594,27 +640,32 @@ def setupSysPath():
|
||||
lldbMiExec = lldbtest_config.lldbExec + "-mi"
|
||||
if not lldbMiExec:
|
||||
if not configuration.shouldSkipBecauseOfCategories(["lldb-mi"]):
|
||||
print("The 'lldb-mi' executable cannot be located. The lldb-mi tests can not be run as a result.")
|
||||
print(
|
||||
"The 'lldb-mi' executable cannot be located. The lldb-mi tests can not be run as a result.")
|
||||
configuration.skipCategories.append("lldb-mi")
|
||||
else:
|
||||
os.environ["LLDBMI_EXEC"] = lldbMiExec
|
||||
|
||||
lldbPythonDir = None # The directory that contains 'lldb/__init__.py'
|
||||
lldbPythonDir = None # The directory that contains 'lldb/__init__.py'
|
||||
if configuration.lldbFrameworkPath:
|
||||
candidatePath = os.path.join(configuration.lldbFrameworkPath, 'Resources', 'Python')
|
||||
candidatePath = os.path.join(
|
||||
configuration.lldbFrameworkPath, 'Resources', 'Python')
|
||||
if os.path.isfile(os.path.join(candidatePath, 'lldb/__init__.py')):
|
||||
lldbPythonDir = candidatePath
|
||||
if not lldbPythonDir:
|
||||
print('Resources/Python/lldb/__init__.py was not found in ' + configuration.lldbFrameworkPath)
|
||||
print(
|
||||
'Resources/Python/lldb/__init__.py was not found in ' +
|
||||
configuration.lldbFrameworkPath)
|
||||
sys.exit(-1)
|
||||
else:
|
||||
# If our lldb supports the -P option, use it to find the python path:
|
||||
init_in_python_dir = os.path.join('lldb', '__init__.py')
|
||||
|
||||
lldb_dash_p_result = subprocess.check_output([lldbtest_config.lldbExec, "-P"], stderr=subprocess.STDOUT, universal_newlines=True)
|
||||
lldb_dash_p_result = subprocess.check_output(
|
||||
[lldbtest_config.lldbExec, "-P"], stderr=subprocess.STDOUT, universal_newlines=True)
|
||||
|
||||
if lldb_dash_p_result and not lldb_dash_p_result.startswith(("<", "lldb: invalid option:")) \
|
||||
and not lldb_dash_p_result.startswith("Traceback"):
|
||||
if lldb_dash_p_result and not lldb_dash_p_result.startswith(
|
||||
("<", "lldb: invalid option:")) and not lldb_dash_p_result.startswith("Traceback"):
|
||||
lines = lldb_dash_p_result.splitlines()
|
||||
|
||||
# Workaround for readline vs libedit issue on FreeBSD. If stdout
|
||||
@@ -625,55 +676,73 @@ def setupSysPath():
|
||||
# because cpython commit f0ab6f9f0603 added a #ifndef __APPLE__
|
||||
# around the call. See http://bugs.python.org/issue19884 for more
|
||||
# information. For now we just discard the warning output.
|
||||
if len(lines) >= 1 and lines[0].startswith("bind: Invalid command"):
|
||||
if len(lines) >= 1 and lines[0].startswith(
|
||||
"bind: Invalid command"):
|
||||
lines.pop(0)
|
||||
|
||||
# Taking the last line because lldb outputs
|
||||
# 'Cannot read termcap database;\nusing dumb terminal settings.\n'
|
||||
# before the path
|
||||
if len(lines) >= 1 and os.path.isfile(os.path.join(lines[-1], init_in_python_dir)):
|
||||
if len(lines) >= 1 and os.path.isfile(
|
||||
os.path.join(lines[-1], init_in_python_dir)):
|
||||
lldbPythonDir = lines[-1]
|
||||
if "freebsd" in sys.platform or "linux" in sys.platform:
|
||||
os.environ['LLDB_LIB_DIR'] = os.path.join(lldbPythonDir, '..', '..')
|
||||
|
||||
os.environ['LLDB_LIB_DIR'] = os.path.join(
|
||||
lldbPythonDir, '..', '..')
|
||||
|
||||
if not lldbPythonDir:
|
||||
if platform.system() == "Darwin":
|
||||
python_resource_dir = ['LLDB.framework', 'Resources', 'Python']
|
||||
outputPaths = getXcodeOutputPaths(lldbRootDirectory)
|
||||
for outputPath in outputPaths:
|
||||
candidatePath = os.path.join(outputPath, *python_resource_dir)
|
||||
if os.path.isfile(os.path.join(candidatePath, init_in_python_dir)):
|
||||
candidatePath = os.path.join(
|
||||
outputPath, *python_resource_dir)
|
||||
if os.path.isfile(
|
||||
os.path.join(
|
||||
candidatePath,
|
||||
init_in_python_dir)):
|
||||
lldbPythonDir = candidatePath
|
||||
break
|
||||
|
||||
if not lldbPythonDir:
|
||||
print("lldb.py is not found, some tests may fail.")
|
||||
else:
|
||||
print("Unable to load lldb extension module. Possible reasons for this include:")
|
||||
print(
|
||||
"Unable to load lldb extension module. Possible reasons for this include:")
|
||||
print(" 1) LLDB was built with LLDB_DISABLE_PYTHON=1")
|
||||
print(" 2) PYTHONPATH and PYTHONHOME are not set correctly. PYTHONHOME should refer to")
|
||||
print(" the version of Python that LLDB built and linked against, and PYTHONPATH")
|
||||
print(" should contain the Lib directory for the same python distro, as well as the")
|
||||
print(
|
||||
" 2) PYTHONPATH and PYTHONHOME are not set correctly. PYTHONHOME should refer to")
|
||||
print(
|
||||
" the version of Python that LLDB built and linked against, and PYTHONPATH")
|
||||
print(
|
||||
" should contain the Lib directory for the same python distro, as well as the")
|
||||
print(" location of LLDB\'s site-packages folder.")
|
||||
print(" 3) A different version of Python than that which was built against is exported in")
|
||||
print(
|
||||
" 3) A different version of Python than that which was built against is exported in")
|
||||
print(" the system\'s PATH environment variable, causing conflicts.")
|
||||
print(" 4) The executable '%s' could not be found. Please check " % lldbtest_config.lldbExec)
|
||||
print(
|
||||
" 4) The executable '%s' could not be found. Please check " %
|
||||
lldbtest_config.lldbExec)
|
||||
print(" that it exists and is executable.")
|
||||
|
||||
if lldbPythonDir:
|
||||
lldbPythonDir = os.path.normpath(lldbPythonDir)
|
||||
# Some of the code that uses this path assumes it hasn't resolved the Versions... link.
|
||||
# If the path we've constructed looks like that, then we'll strip out the Versions/A part.
|
||||
(before, frameWithVersion, after) = lldbPythonDir.rpartition("LLDB.framework/Versions/A")
|
||||
if frameWithVersion != "" :
|
||||
# Some of the code that uses this path assumes it hasn't resolved the Versions... link.
|
||||
# If the path we've constructed looks like that, then we'll strip out
|
||||
# the Versions/A part.
|
||||
(before, frameWithVersion, after) = lldbPythonDir.rpartition(
|
||||
"LLDB.framework/Versions/A")
|
||||
if frameWithVersion != "":
|
||||
lldbPythonDir = before + "LLDB.framework" + after
|
||||
|
||||
lldbPythonDir = os.path.abspath(lldbPythonDir)
|
||||
|
||||
# If tests need to find LLDB_FRAMEWORK, now they can do it
|
||||
os.environ["LLDB_FRAMEWORK"] = os.path.dirname(os.path.dirname(lldbPythonDir))
|
||||
os.environ["LLDB_FRAMEWORK"] = os.path.dirname(
|
||||
os.path.dirname(lldbPythonDir))
|
||||
|
||||
# This is to locate the lldb.py module. Insert it right after sys.path[0].
|
||||
# This is to locate the lldb.py module. Insert it right after
|
||||
# sys.path[0].
|
||||
sys.path[1:1] = [lldbPythonDir]
|
||||
|
||||
|
||||
@@ -713,7 +782,8 @@ def visit_file(dir, name):
|
||||
if filtered:
|
||||
# print("adding filter spec %s to module %s" % (filterspec, module))
|
||||
configuration.suite.addTests(
|
||||
unittest2.defaultTestLoader.loadTestsFromName(filterspec, module))
|
||||
unittest2.defaultTestLoader.loadTestsFromName(
|
||||
filterspec, module))
|
||||
continue
|
||||
|
||||
# Forgo this module if the (base, filterspec) combo is invalid
|
||||
@@ -724,7 +794,8 @@ def visit_file(dir, name):
|
||||
# Add the entire file's worth of tests since we're not filtered.
|
||||
# Also the fail-over case when the filterspec branch
|
||||
# (base, filterspec) combo doesn't make sense.
|
||||
configuration.suite.addTests(unittest2.defaultTestLoader.loadTestsFromName(base))
|
||||
configuration.suite.addTests(
|
||||
unittest2.defaultTestLoader.loadTestsFromName(base))
|
||||
|
||||
|
||||
def visit(prefix, dir, names):
|
||||
@@ -774,10 +845,14 @@ def disabledynamics():
|
||||
import lldb
|
||||
ci = lldb.DBG.GetCommandInterpreter()
|
||||
res = lldb.SBCommandReturnObject()
|
||||
ci.HandleCommand("setting set target.prefer-dynamic-value no-dynamic-values", res, False)
|
||||
ci.HandleCommand(
|
||||
"setting set target.prefer-dynamic-value no-dynamic-values",
|
||||
res,
|
||||
False)
|
||||
if not res.Succeeded():
|
||||
raise Exception('disabling dynamic type support failed')
|
||||
|
||||
|
||||
def lldbLoggings():
|
||||
import lldb
|
||||
"""Check and do lldb loggings if necessary."""
|
||||
@@ -793,7 +868,10 @@ def lldbLoggings():
|
||||
else:
|
||||
lldb_log_option = "event process expr state api"
|
||||
ci.HandleCommand(
|
||||
"log enable -n -f " + os.environ["LLDB_LOG"] + " lldb " + lldb_log_option,
|
||||
"log enable -n -f " +
|
||||
os.environ["LLDB_LOG"] +
|
||||
" lldb " +
|
||||
lldb_log_option,
|
||||
res)
|
||||
if not res.Succeeded():
|
||||
raise Exception('log enable failed (check LLDB_LOG env variable)')
|
||||
@@ -805,11 +883,15 @@ def lldbLoggings():
|
||||
else:
|
||||
lldb_log_option = "event process expr state api"
|
||||
ci.HandleCommand(
|
||||
"log enable -n -f " + os.environ["LLDB_LINUX_LOG"] + " linux " + lldb_log_option,
|
||||
"log enable -n -f " +
|
||||
os.environ["LLDB_LINUX_LOG"] +
|
||||
" linux " +
|
||||
lldb_log_option,
|
||||
res)
|
||||
if not res.Succeeded():
|
||||
raise Exception('log enable failed (check LLDB_LINUX_LOG env variable)')
|
||||
|
||||
raise Exception(
|
||||
'log enable failed (check LLDB_LINUX_LOG env variable)')
|
||||
|
||||
# Ditto for gdb-remote logging if ${GDB_REMOTE_LOG} environment variable is defined.
|
||||
# Use ${GDB_REMOTE_LOG} to specify the log file.
|
||||
if ("GDB_REMOTE_LOG" in os.environ):
|
||||
@@ -822,7 +904,9 @@ def lldbLoggings():
|
||||
+ gdb_remote_log_option,
|
||||
res)
|
||||
if not res.Succeeded():
|
||||
raise Exception('log enable failed (check GDB_REMOTE_LOG env variable)')
|
||||
raise Exception(
|
||||
'log enable failed (check GDB_REMOTE_LOG env variable)')
|
||||
|
||||
|
||||
def getMyCommandLine():
|
||||
return ' '.join(sys.argv)
|
||||
@@ -833,18 +917,24 @@ def getMyCommandLine():
|
||||
# #
|
||||
# ======================================== #
|
||||
|
||||
|
||||
def checkDsymForUUIDIsNotOn():
|
||||
cmd = ["defaults", "read", "com.apple.DebugSymbols"]
|
||||
pipe = subprocess.Popen(cmd, stdout = subprocess.PIPE, stderr = subprocess.STDOUT)
|
||||
pipe = subprocess.Popen(
|
||||
cmd,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.STDOUT)
|
||||
cmd_output = pipe.stdout.read()
|
||||
if cmd_output and "DBGFileMappedPaths = " in cmd_output:
|
||||
print("%s =>" % ' '.join(cmd))
|
||||
print(cmd_output)
|
||||
print("Disable automatic lookup and caching of dSYMs before running the test suite!")
|
||||
print(
|
||||
"Disable automatic lookup and caching of dSYMs before running the test suite!")
|
||||
print("Exiting...")
|
||||
sys.exit(0)
|
||||
|
||||
def exitTestSuite(exitCode = None):
|
||||
|
||||
def exitTestSuite(exitCode=None):
|
||||
import lldb
|
||||
lldb.SBDebugger.Terminate()
|
||||
if exitCode:
|
||||
@@ -856,7 +946,9 @@ def isMultiprocessTestRunner():
|
||||
# the inferior (as specified by the multiprocess test
|
||||
# runner) OR we've been told to skip using the multiprocess
|
||||
# test runner
|
||||
return not (configuration.is_inferior_test_runner or configuration.no_multiprocess_test_runner)
|
||||
return not (
|
||||
configuration.is_inferior_test_runner or configuration.no_multiprocess_test_runner)
|
||||
|
||||
|
||||
def getVersionForSDK(sdk):
|
||||
sdk = str.lower(sdk)
|
||||
@@ -867,19 +959,24 @@ def getVersionForSDK(sdk):
|
||||
ver = basename.replace(sdk, '')
|
||||
return ver
|
||||
|
||||
|
||||
def getPathForSDK(sdk):
|
||||
sdk = str.lower(sdk)
|
||||
full_path = seven.get_command_output('xcrun -sdk %s --show-sdk-path' % sdk)
|
||||
if os.path.exists(full_path): return full_path
|
||||
if os.path.exists(full_path):
|
||||
return full_path
|
||||
return None
|
||||
|
||||
|
||||
def setDefaultTripleForPlatform():
|
||||
if configuration.lldb_platform_name == 'ios-simulator':
|
||||
triple_str = 'x86_64-apple-ios%s' % (getVersionForSDK('iphonesimulator'))
|
||||
triple_str = 'x86_64-apple-ios%s' % (
|
||||
getVersionForSDK('iphonesimulator'))
|
||||
os.environ['TRIPLE'] = triple_str
|
||||
return {'TRIPLE':triple_str}
|
||||
return {'TRIPLE': triple_str}
|
||||
return {}
|
||||
|
||||
|
||||
def run_suite():
|
||||
# On MacOS X, check to make sure that domain for com.apple.DebugSymbols defaults
|
||||
# does not exist before proceeding to running the test suite.
|
||||
@@ -900,8 +997,11 @@ def run_suite():
|
||||
# multiprocess test runner here.
|
||||
if isMultiprocessTestRunner():
|
||||
from . import dosep
|
||||
dosep.main(configuration.num_threads, configuration.multiprocess_test_subdir,
|
||||
configuration.test_runner_name, configuration.results_formatter_object)
|
||||
dosep.main(
|
||||
configuration.num_threads,
|
||||
configuration.multiprocess_test_subdir,
|
||||
configuration.test_runner_name,
|
||||
configuration.results_formatter_object)
|
||||
raise Exception("should never get here")
|
||||
elif configuration.is_inferior_test_runner:
|
||||
# Shut off Ctrl-C processing in inferiors. The parallel
|
||||
@@ -924,20 +1024,29 @@ def run_suite():
|
||||
lldb.DBG = lldb.SBDebugger.Create()
|
||||
|
||||
if configuration.lldb_platform_name:
|
||||
print("Setting up remote platform '%s'" % (configuration.lldb_platform_name))
|
||||
lldb.remote_platform = lldb.SBPlatform(configuration.lldb_platform_name)
|
||||
print("Setting up remote platform '%s'" %
|
||||
(configuration.lldb_platform_name))
|
||||
lldb.remote_platform = lldb.SBPlatform(
|
||||
configuration.lldb_platform_name)
|
||||
if not lldb.remote_platform.IsValid():
|
||||
print("error: unable to create the LLDB platform named '%s'." % (configuration.lldb_platform_name))
|
||||
print(
|
||||
"error: unable to create the LLDB platform named '%s'." %
|
||||
(configuration.lldb_platform_name))
|
||||
exitTestSuite(1)
|
||||
if configuration.lldb_platform_url:
|
||||
# We must connect to a remote platform if a LLDB platform URL was specified
|
||||
print("Connecting to remote platform '%s' at '%s'..." % (configuration.lldb_platform_name, configuration.lldb_platform_url))
|
||||
platform_connect_options = lldb.SBPlatformConnectOptions(configuration.lldb_platform_url)
|
||||
# We must connect to a remote platform if a LLDB platform URL was
|
||||
# specified
|
||||
print(
|
||||
"Connecting to remote platform '%s' at '%s'..." %
|
||||
(configuration.lldb_platform_name, configuration.lldb_platform_url))
|
||||
platform_connect_options = lldb.SBPlatformConnectOptions(
|
||||
configuration.lldb_platform_url)
|
||||
err = lldb.remote_platform.ConnectRemote(platform_connect_options)
|
||||
if err.Success():
|
||||
print("Connected.")
|
||||
else:
|
||||
print("error: failed to connect to remote platform using URL '%s': %s" % (configuration.lldb_platform_url, err))
|
||||
print("error: failed to connect to remote platform using URL '%s': %s" % (
|
||||
configuration.lldb_platform_url, err))
|
||||
exitTestSuite(1)
|
||||
else:
|
||||
configuration.lldb_platform_url = None
|
||||
@@ -948,11 +1057,13 @@ def run_suite():
|
||||
if first:
|
||||
print("Environment variables setup for platform support:")
|
||||
first = False
|
||||
print("%s = %s" % (key,platform_changes[key]))
|
||||
print("%s = %s" % (key, platform_changes[key]))
|
||||
|
||||
if configuration.lldb_platform_working_dir:
|
||||
print("Setting remote platform working directory to '%s'..." % (configuration.lldb_platform_working_dir))
|
||||
lldb.remote_platform.SetWorkingDirectory(configuration.lldb_platform_working_dir)
|
||||
print("Setting remote platform working directory to '%s'..." %
|
||||
(configuration.lldb_platform_working_dir))
|
||||
lldb.remote_platform.SetWorkingDirectory(
|
||||
configuration.lldb_platform_working_dir)
|
||||
lldb.DBG.SetSelectedPlatform(lldb.remote_platform)
|
||||
else:
|
||||
lldb.remote_platform = None
|
||||
@@ -998,10 +1109,13 @@ def run_suite():
|
||||
timestamp_started = datetime.datetime.now().strftime("%Y-%m-%d-%H_%M_%S")
|
||||
if not configuration.sdir_name:
|
||||
configuration.sdir_name = timestamp_started
|
||||
os.environ["LLDB_SESSION_DIRNAME"] = os.path.join(os.getcwd(), configuration.sdir_name)
|
||||
os.environ["LLDB_SESSION_DIRNAME"] = os.path.join(
|
||||
os.getcwd(), configuration.sdir_name)
|
||||
|
||||
sys.stderr.write("\nSession logs for test failures/errors/unexpected successes"
|
||||
" will go into directory '%s'\n" % configuration.sdir_name)
|
||||
sys.stderr.write(
|
||||
"\nSession logs for test failures/errors/unexpected successes"
|
||||
" will go into directory '%s'\n" %
|
||||
configuration.sdir_name)
|
||||
sys.stderr.write("Command invoked: %s\n" % getMyCommandLine())
|
||||
|
||||
if not os.path.isdir(configuration.sdir_name):
|
||||
@@ -1024,14 +1138,16 @@ def run_suite():
|
||||
|
||||
#
|
||||
# Add some intervention here to sanity check that the compilers requested are sane.
|
||||
# If found not to be an executable program, the invalid one is dropped from the list.
|
||||
# If found not to be an executable program, the invalid one is dropped
|
||||
# from the list.
|
||||
for i in range(len(configuration.compilers)):
|
||||
c = configuration.compilers[i]
|
||||
if which(c):
|
||||
continue
|
||||
else:
|
||||
if sys.platform.startswith("darwin"):
|
||||
pipe = subprocess.Popen(['xcrun', '-find', c], stdout = subprocess.PIPE, stderr = subprocess.STDOUT)
|
||||
pipe = subprocess.Popen(
|
||||
['xcrun', '-find', c], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||
cmd_output = pipe.stdout.read()
|
||||
if cmd_output:
|
||||
if "not found" in cmd_output:
|
||||
@@ -1039,7 +1155,9 @@ def run_suite():
|
||||
configuration.compilers.remove(i)
|
||||
else:
|
||||
configuration.compilers[i] = cmd_output.split('\n')[0]
|
||||
print("'xcrun -find %s' returning %s" % (c, configuration.compilers[i]))
|
||||
print(
|
||||
"'xcrun -find %s' returning %s" %
|
||||
(c, configuration.compilers[i]))
|
||||
|
||||
if not configuration.parsable:
|
||||
print("compilers=%s" % str(configuration.compilers))
|
||||
@@ -1048,10 +1166,14 @@ def run_suite():
|
||||
print("No eligible compiler found, exiting.")
|
||||
exitTestSuite(1)
|
||||
|
||||
if isinstance(configuration.compilers, list) and len(configuration.compilers) >= 1:
|
||||
if isinstance(
|
||||
configuration.compilers,
|
||||
list) and len(
|
||||
configuration.compilers) >= 1:
|
||||
iterCompilers = True
|
||||
|
||||
# If we iterate on archs or compilers, there is a chance we want to split stderr/stdout.
|
||||
# If we iterate on archs or compilers, there is a chance we want to split
|
||||
# stderr/stdout.
|
||||
if iterArchs or iterCompilers:
|
||||
old_stderr = sys.stderr
|
||||
old_stdout = sys.stdout
|
||||
@@ -1067,7 +1189,8 @@ def run_suite():
|
||||
for ic in range(len(configuration.compilers) if iterCompilers else 1):
|
||||
if iterCompilers:
|
||||
os.environ["CC"] = configuration.compilers[ic]
|
||||
configString = "%s compiler=%s" % (archConfig, configuration.compilers[ic])
|
||||
configString = "%s compiler=%s" % (
|
||||
archConfig, configuration.compilers[ic])
|
||||
else:
|
||||
configString = archConfig
|
||||
|
||||
@@ -1090,9 +1213,10 @@ def run_suite():
|
||||
# First, write out the number of collected test cases.
|
||||
if not configuration.parsable:
|
||||
sys.stderr.write(configuration.separator + "\n")
|
||||
sys.stderr.write("Collected %d test%s\n\n"
|
||||
% (configuration.suite.countTestCases(),
|
||||
configuration.suite.countTestCases() != 1 and "s" or ""))
|
||||
sys.stderr.write(
|
||||
"Collected %d test%s\n\n" %
|
||||
(configuration.suite.countTestCases(),
|
||||
configuration.suite.countTestCases() != 1 and "s" or ""))
|
||||
|
||||
if configuration.parsable:
|
||||
v = 0
|
||||
@@ -1101,30 +1225,39 @@ def run_suite():
|
||||
|
||||
# Invoke the test runner.
|
||||
if configuration.count == 1:
|
||||
result = unittest2.TextTestRunner(stream=sys.stderr,
|
||||
verbosity=v,
|
||||
resultclass=test_result.LLDBTestResult).run(configuration.suite)
|
||||
result = unittest2.TextTestRunner(
|
||||
stream=sys.stderr,
|
||||
verbosity=v,
|
||||
resultclass=test_result.LLDBTestResult).run(
|
||||
configuration.suite)
|
||||
else:
|
||||
# We are invoking the same test suite more than once. In this case,
|
||||
# mark __ignore_singleton__ flag as True so the signleton pattern is
|
||||
# not enforced.
|
||||
test_result.LLDBTestResult.__ignore_singleton__ = True
|
||||
for i in range(configuration.count):
|
||||
|
||||
result = unittest2.TextTestRunner(stream=sys.stderr,
|
||||
verbosity=v,
|
||||
resultclass=test_result.LLDBTestResult).run(configuration.suite)
|
||||
|
||||
result = unittest2.TextTestRunner(
|
||||
stream=sys.stderr,
|
||||
verbosity=v,
|
||||
resultclass=test_result.LLDBTestResult).run(
|
||||
configuration.suite)
|
||||
|
||||
configuration.failed = configuration.failed or not result.wasSuccessful()
|
||||
|
||||
if configuration.sdir_has_content and not configuration.parsable:
|
||||
sys.stderr.write("Session logs for test failures/errors/unexpected successes"
|
||||
" can be found in directory '%s'\n" % configuration.sdir_name)
|
||||
sys.stderr.write(
|
||||
"Session logs for test failures/errors/unexpected successes"
|
||||
" can be found in directory '%s'\n" %
|
||||
configuration.sdir_name)
|
||||
|
||||
if configuration.useCategories and len(configuration.failuresPerCategory) > 0:
|
||||
if configuration.useCategories and len(
|
||||
configuration.failuresPerCategory) > 0:
|
||||
sys.stderr.write("Failures per category:\n")
|
||||
for category in configuration.failuresPerCategory:
|
||||
sys.stderr.write("%s - %d\n" % (category, configuration.failuresPerCategory[category]))
|
||||
sys.stderr.write(
|
||||
"%s - %d\n" %
|
||||
(category, configuration.failuresPerCategory[category]))
|
||||
|
||||
# Terminate the test suite if ${LLDB_TESTSUITE_FORCE_FINISH} is defined.
|
||||
# This should not be necessary now.
|
||||
@@ -1136,5 +1269,7 @@ def run_suite():
|
||||
exitTestSuite(configuration.failed)
|
||||
|
||||
if __name__ == "__main__":
|
||||
print(__file__ + " is for use as a module only. It should not be run as a standalone script.")
|
||||
print(
|
||||
__file__ +
|
||||
" is for use as a module only. It should not be run as a standalone script.")
|
||||
sys.exit(-1)
|
||||
|
||||
@@ -13,9 +13,11 @@ import textwrap
|
||||
# LLDB modules
|
||||
from . import configuration
|
||||
|
||||
|
||||
class ArgParseNamespace(object):
|
||||
pass
|
||||
|
||||
|
||||
def parse_args(parser, argv):
|
||||
""" Returns an argument object. LLDB_TEST_ARGUMENTS environment variable can
|
||||
be used to pass additional arguments.
|
||||
@@ -23,8 +25,11 @@ def parse_args(parser, argv):
|
||||
args = ArgParseNamespace()
|
||||
|
||||
if ('LLDB_TEST_ARGUMENTS' in os.environ):
|
||||
print("Arguments passed through environment: '%s'" % os.environ['LLDB_TEST_ARGUMENTS'])
|
||||
args = parser.parse_args([sys.argv[0]].__add__(os.environ['LLDB_TEST_ARGUMENTS'].split()),namespace=args)
|
||||
print(
|
||||
"Arguments passed through environment: '%s'" %
|
||||
os.environ['LLDB_TEST_ARGUMENTS'])
|
||||
args = parser.parse_args([sys.argv[0]].__add__(
|
||||
os.environ['LLDB_TEST_ARGUMENTS'].split()), namespace=args)
|
||||
|
||||
return parser.parse_args(args=argv, namespace=args)
|
||||
|
||||
@@ -39,59 +44,152 @@ def default_thread_count():
|
||||
|
||||
|
||||
def create_parser():
|
||||
parser = argparse.ArgumentParser(description='description', prefix_chars='+-', add_help=False)
|
||||
parser = argparse.ArgumentParser(
|
||||
description='description',
|
||||
prefix_chars='+-',
|
||||
add_help=False)
|
||||
group = None
|
||||
|
||||
# Helper function for boolean options (group will point to the current group when executing X)
|
||||
X = lambda optstr, helpstr, **kwargs: group.add_argument(optstr, help=helpstr, action='store_true', **kwargs)
|
||||
# Helper function for boolean options (group will point to the current
|
||||
# group when executing X)
|
||||
X = lambda optstr, helpstr, **kwargs: group.add_argument(
|
||||
optstr, help=helpstr, action='store_true', **kwargs)
|
||||
|
||||
group = parser.add_argument_group('Help')
|
||||
group.add_argument('-h', '--help', dest='h', action='store_true', help="Print this help message and exit. Add '-v' for more detailed help.")
|
||||
group.add_argument(
|
||||
'-h',
|
||||
'--help',
|
||||
dest='h',
|
||||
action='store_true',
|
||||
help="Print this help message and exit. Add '-v' for more detailed help.")
|
||||
|
||||
# C and Python toolchain options
|
||||
group = parser.add_argument_group('Toolchain options')
|
||||
group.add_argument('-A', '--arch', metavar='arch', action='append', dest='archs', help=textwrap.dedent('''Specify the architecture(s) to test. This option can be specified more than once'''))
|
||||
group.add_argument('-C', '--compiler', metavar='compiler', dest='compilers', action='append', help=textwrap.dedent('''Specify the compiler(s) used to build the inferior executables. The compiler path can be an executable basename or a full path to a compiler executable. This option can be specified multiple times.'''))
|
||||
group.add_argument(
|
||||
'-A',
|
||||
'--arch',
|
||||
metavar='arch',
|
||||
action='append',
|
||||
dest='archs',
|
||||
help=textwrap.dedent('''Specify the architecture(s) to test. This option can be specified more than once'''))
|
||||
group.add_argument('-C', '--compiler', metavar='compiler', dest='compilers', action='append', help=textwrap.dedent(
|
||||
'''Specify the compiler(s) used to build the inferior executables. The compiler path can be an executable basename or a full path to a compiler executable. This option can be specified multiple times.'''))
|
||||
if sys.platform == 'darwin':
|
||||
group.add_argument('--apple-sdk', metavar='apple_sdk', dest='apple_sdk', help=textwrap.dedent('''Specify the name of the Apple SDK (macosx, macosx.internal, iphoneos, iphoneos.internal, or path to SDK) and use the appropriate tools from that SDK's toolchain.'''))
|
||||
group.add_argument('--apple-sdk', metavar='apple_sdk', dest='apple_sdk', help=textwrap.dedent(
|
||||
'''Specify the name of the Apple SDK (macosx, macosx.internal, iphoneos, iphoneos.internal, or path to SDK) and use the appropriate tools from that SDK's toolchain.'''))
|
||||
# FIXME? This won't work for different extra flags according to each arch.
|
||||
group.add_argument('-E', metavar='extra-flags', help=textwrap.dedent('''Specify the extra flags to be passed to the toolchain when building the inferior programs to be debugged
|
||||
group.add_argument(
|
||||
'-E',
|
||||
metavar='extra-flags',
|
||||
help=textwrap.dedent('''Specify the extra flags to be passed to the toolchain when building the inferior programs to be debugged
|
||||
suggestions: do not lump the "-A arch1 -A arch2" together such that the -E option applies to only one of the architectures'''))
|
||||
|
||||
# Test filtering options
|
||||
group = parser.add_argument_group('Test filtering options')
|
||||
group.add_argument('-f', metavar='filterspec', action='append', help='Specify a filter, which consists of the test class name, a dot, followed by the test method, to only admit such test into the test suite') # FIXME: Example?
|
||||
group.add_argument(
|
||||
'-f',
|
||||
metavar='filterspec',
|
||||
action='append',
|
||||
help='Specify a filter, which consists of the test class name, a dot, followed by the test method, to only admit such test into the test suite') # FIXME: Example?
|
||||
X('-l', "Don't skip long running tests")
|
||||
group.add_argument('-p', metavar='pattern', help='Specify a regexp filename pattern for inclusion in the test suite')
|
||||
group.add_argument('-G', '--category', metavar='category', action='append', dest='categoriesList', help=textwrap.dedent('''Specify categories of test cases of interest. Can be specified more than once.'''))
|
||||
group.add_argument('--skip-category', metavar='category', action='append', dest='skipCategories', help=textwrap.dedent('''Specify categories of test cases to skip. Takes precedence over -G. Can be specified more than once.'''))
|
||||
group.add_argument(
|
||||
'-p',
|
||||
metavar='pattern',
|
||||
help='Specify a regexp filename pattern for inclusion in the test suite')
|
||||
group.add_argument(
|
||||
'-G',
|
||||
'--category',
|
||||
metavar='category',
|
||||
action='append',
|
||||
dest='categoriesList',
|
||||
help=textwrap.dedent('''Specify categories of test cases of interest. Can be specified more than once.'''))
|
||||
group.add_argument(
|
||||
'--skip-category',
|
||||
metavar='category',
|
||||
action='append',
|
||||
dest='skipCategories',
|
||||
help=textwrap.dedent('''Specify categories of test cases to skip. Takes precedence over -G. Can be specified more than once.'''))
|
||||
|
||||
# Configuration options
|
||||
group = parser.add_argument_group('Configuration options')
|
||||
group.add_argument('--framework', metavar='framework-path', help='The path to LLDB.framework')
|
||||
group.add_argument('--executable', metavar='executable-path', help='The path to the lldb executable')
|
||||
group.add_argument('-s', metavar='name', help='Specify the name of the dir created to store the session files of tests with errored or failed status. If not specified, the test driver uses the timestamp as the session dir name')
|
||||
group.add_argument('-S', '--session-file-format', default=configuration.session_file_format, metavar='format', help='Specify session file name format. See configuration.py for a description.')
|
||||
group.add_argument('-y', type=int, metavar='count', help="Specify the iteration count used to collect our benchmarks. An example is the number of times to do 'thread step-over' to measure stepping speed.")
|
||||
group.add_argument('-#', type=int, metavar='sharp', dest='sharp', help='Repeat the test suite for a specified number of times')
|
||||
group.add_argument('--channel', metavar='channel', dest='channels', action='append', help=textwrap.dedent("Specify the log channels (and optional categories) e.g. 'lldb all' or 'gdb-remote packets' if no categories are specified, 'default' is used"))
|
||||
group.add_argument('--log-success', dest='log_success', action='store_true', help="Leave logs/traces even for successful test runs (useful for creating reference log files during debugging.)")
|
||||
group.add_argument(
|
||||
'--framework',
|
||||
metavar='framework-path',
|
||||
help='The path to LLDB.framework')
|
||||
group.add_argument(
|
||||
'--executable',
|
||||
metavar='executable-path',
|
||||
help='The path to the lldb executable')
|
||||
group.add_argument(
|
||||
'-s',
|
||||
metavar='name',
|
||||
help='Specify the name of the dir created to store the session files of tests with errored or failed status. If not specified, the test driver uses the timestamp as the session dir name')
|
||||
group.add_argument(
|
||||
'-S',
|
||||
'--session-file-format',
|
||||
default=configuration.session_file_format,
|
||||
metavar='format',
|
||||
help='Specify session file name format. See configuration.py for a description.')
|
||||
group.add_argument(
|
||||
'-y',
|
||||
type=int,
|
||||
metavar='count',
|
||||
help="Specify the iteration count used to collect our benchmarks. An example is the number of times to do 'thread step-over' to measure stepping speed.")
|
||||
group.add_argument(
|
||||
'-#',
|
||||
type=int,
|
||||
metavar='sharp',
|
||||
dest='sharp',
|
||||
help='Repeat the test suite for a specified number of times')
|
||||
group.add_argument('--channel', metavar='channel', dest='channels', action='append', help=textwrap.dedent(
|
||||
"Specify the log channels (and optional categories) e.g. 'lldb all' or 'gdb-remote packets' if no categories are specified, 'default' is used"))
|
||||
group.add_argument(
|
||||
'--log-success',
|
||||
dest='log_success',
|
||||
action='store_true',
|
||||
help="Leave logs/traces even for successful test runs (useful for creating reference log files during debugging.)")
|
||||
|
||||
# Configuration options
|
||||
group = parser.add_argument_group('Remote platform options')
|
||||
group.add_argument('--platform-name', dest='lldb_platform_name', metavar='platform-name', help='The name of a remote platform to use')
|
||||
group.add_argument('--platform-url', dest='lldb_platform_url', metavar='platform-url', help='A LLDB platform URL to use when connecting to a remote platform to run the test suite')
|
||||
group.add_argument('--platform-working-dir', dest='lldb_platform_working_dir', metavar='platform-working-dir', help='The directory to use on the remote platform.')
|
||||
group.add_argument(
|
||||
'--platform-name',
|
||||
dest='lldb_platform_name',
|
||||
metavar='platform-name',
|
||||
help='The name of a remote platform to use')
|
||||
group.add_argument(
|
||||
'--platform-url',
|
||||
dest='lldb_platform_url',
|
||||
metavar='platform-url',
|
||||
help='A LLDB platform URL to use when connecting to a remote platform to run the test suite')
|
||||
group.add_argument(
|
||||
'--platform-working-dir',
|
||||
dest='lldb_platform_working_dir',
|
||||
metavar='platform-working-dir',
|
||||
help='The directory to use on the remote platform.')
|
||||
|
||||
# Test-suite behaviour
|
||||
group = parser.add_argument_group('Runtime behaviour options')
|
||||
X('-d', 'Suspend the process after launch to wait indefinitely for a debugger to attach')
|
||||
X('-q', "Don't print extra output from this script.")
|
||||
X('-t', 'Turn on tracing of lldb command and other detailed test executions')
|
||||
group.add_argument('-u', dest='unset_env_varnames', metavar='variable', action='append', help='Specify an environment variable to unset before running the test cases. e.g., -u DYLD_INSERT_LIBRARIES -u MallocScribble')
|
||||
group.add_argument('--env', dest='set_env_vars', metavar='variable', action='append', help='Specify an environment variable to set to the given value before running the test cases e.g.: --env CXXFLAGS=-O3 --env DYLD_INSERT_LIBRARIES')
|
||||
group.add_argument(
|
||||
'-u',
|
||||
dest='unset_env_varnames',
|
||||
metavar='variable',
|
||||
action='append',
|
||||
help='Specify an environment variable to unset before running the test cases. e.g., -u DYLD_INSERT_LIBRARIES -u MallocScribble')
|
||||
group.add_argument(
|
||||
'--env',
|
||||
dest='set_env_vars',
|
||||
metavar='variable',
|
||||
action='append',
|
||||
help='Specify an environment variable to set to the given value before running the test cases e.g.: --env CXXFLAGS=-O3 --env DYLD_INSERT_LIBRARIES')
|
||||
X('-v', 'Do verbose mode of unittest framework (print out each test case invocation)')
|
||||
group.add_argument('--enable-crash-dialog', dest='disable_crash_dialog', action='store_false', help='(Windows only) When LLDB crashes, display the Windows crash dialog.')
|
||||
group.add_argument(
|
||||
'--enable-crash-dialog',
|
||||
dest='disable_crash_dialog',
|
||||
action='store_false',
|
||||
help='(Windows only) When LLDB crashes, display the Windows crash dialog.')
|
||||
group.set_defaults(disable_crash_dialog=True)
|
||||
|
||||
group = parser.add_argument_group('Parallel execution options')
|
||||
@@ -185,6 +283,10 @@ def create_parser():
|
||||
del X
|
||||
|
||||
group = parser.add_argument_group('Test directories')
|
||||
group.add_argument('args', metavar='test-dir', nargs='*', help='Specify a list of directory names to search for test modules named after Test*.py (test discovery). If empty, search from the current working directory instead.')
|
||||
group.add_argument(
|
||||
'args',
|
||||
metavar='test-dir',
|
||||
nargs='*',
|
||||
help='Specify a list of directory names to search for test modules named after Test*.py (test discovery). If empty, search from the current working directory instead.')
|
||||
|
||||
return parser
|
||||
|
||||
@@ -5,13 +5,14 @@ Test that the lldb driver's batch mode works correctly.
|
||||
from __future__ import print_function
|
||||
|
||||
|
||||
|
||||
import os, time
|
||||
import os
|
||||
import time
|
||||
import lldb
|
||||
from lldbsuite.test.decorators import *
|
||||
from lldbsuite.test.lldbtest import *
|
||||
from lldbsuite.test import lldbutil
|
||||
|
||||
|
||||
class DriverBatchModeTest (TestBase):
|
||||
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
@@ -23,21 +24,23 @@ class DriverBatchModeTest (TestBase):
|
||||
self.source = 'main.c'
|
||||
self.victim = None
|
||||
|
||||
def expect_string (self, string):
|
||||
def expect_string(self, string):
|
||||
import pexpect
|
||||
"""This expects for "string", with timeout & EOF being test fails."""
|
||||
try:
|
||||
self.child.expect_exact(string)
|
||||
except pexpect.EOF:
|
||||
self.fail ("Got EOF waiting for '%s'"%(string))
|
||||
self.fail("Got EOF waiting for '%s'" % (string))
|
||||
except pexpect.TIMEOUT:
|
||||
self.fail ("Timed out waiting for '%s'"%(string))
|
||||
self.fail("Timed out waiting for '%s'" % (string))
|
||||
|
||||
@skipIfRemote # test not remote-ready llvm.org/pr24813
|
||||
@skipIfRemote # test not remote-ready llvm.org/pr24813
|
||||
@expectedFlakeyFreeBSD("llvm.org/pr25172 fails rarely on the buildbot")
|
||||
@expectedFlakeyLinux("llvm.org/pr25172")
|
||||
@expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr22274: need a pexpect replacement for windows")
|
||||
def test_batch_mode_run_crash (self):
|
||||
@expectedFailureAll(
|
||||
oslist=["windows"],
|
||||
bugnumber="llvm.org/pr22274: need a pexpect replacement for windows")
|
||||
def test_batch_mode_run_crash(self):
|
||||
"""Test that the lldb driver's batch mode works correctly."""
|
||||
self.build()
|
||||
self.setTearDownCleanup()
|
||||
@@ -48,33 +51,36 @@ class DriverBatchModeTest (TestBase):
|
||||
|
||||
# Pass CRASH so the process will crash and stop in batch mode.
|
||||
run_commands = ' -b -o "break set -n main" -o "run" -o "continue" -k "frame var touch_me_not"'
|
||||
self.child = pexpect.spawn('%s %s %s %s -- CRASH' % (lldbtest_config.lldbExec, self.lldbOption, run_commands, exe))
|
||||
self.child = pexpect.spawn(
|
||||
'%s %s %s %s -- CRASH' %
|
||||
(lldbtest_config.lldbExec, self.lldbOption, run_commands, exe))
|
||||
child = self.child
|
||||
# Turn on logging for what the child sends back.
|
||||
if self.TraceOn():
|
||||
child.logfile_read = sys.stdout
|
||||
|
||||
# We should see the "run":
|
||||
self.expect_string ("run")
|
||||
self.expect_string("run")
|
||||
# We should have hit the breakpoint & continued:
|
||||
self.expect_string ("continue")
|
||||
self.expect_string("continue")
|
||||
# The App should have crashed:
|
||||
self.expect_string("About to crash")
|
||||
# The -k option should have printed the frame variable once:
|
||||
self.expect_string ('(char *) touch_me_not')
|
||||
self.expect_string('(char *) touch_me_not')
|
||||
# Then we should have a live prompt:
|
||||
self.expect_string (prompt)
|
||||
self.expect_string(prompt)
|
||||
self.child.sendline("frame variable touch_me_not")
|
||||
self.expect_string ('(char *) touch_me_not')
|
||||
|
||||
self.expect_string('(char *) touch_me_not')
|
||||
|
||||
self.deletePexpectChild()
|
||||
|
||||
|
||||
@skipIfRemote # test not remote-ready llvm.org/pr24813
|
||||
@skipIfRemote # test not remote-ready llvm.org/pr24813
|
||||
@expectedFlakeyFreeBSD("llvm.org/pr25172 fails rarely on the buildbot")
|
||||
@expectedFlakeyLinux("llvm.org/pr25172")
|
||||
@expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr22274: need a pexpect replacement for windows")
|
||||
def test_batch_mode_run_exit (self):
|
||||
@expectedFailureAll(
|
||||
oslist=["windows"],
|
||||
bugnumber="llvm.org/pr22274: need a pexpect replacement for windows")
|
||||
def test_batch_mode_run_exit(self):
|
||||
"""Test that the lldb driver's batch mode works correctly."""
|
||||
self.build()
|
||||
self.setTearDownCleanup()
|
||||
@@ -85,66 +91,78 @@ class DriverBatchModeTest (TestBase):
|
||||
|
||||
# Now do it again, and make sure if we don't crash, we quit:
|
||||
run_commands = ' -b -o "break set -n main" -o "run" -o "continue" '
|
||||
self.child = pexpect.spawn('%s %s %s %s -- NOCRASH' % (lldbtest_config.lldbExec, self.lldbOption, run_commands, exe))
|
||||
self.child = pexpect.spawn(
|
||||
'%s %s %s %s -- NOCRASH' %
|
||||
(lldbtest_config.lldbExec, self.lldbOption, run_commands, exe))
|
||||
child = self.child
|
||||
# Turn on logging for what the child sends back.
|
||||
if self.TraceOn():
|
||||
child.logfile_read = sys.stdout
|
||||
|
||||
# We should see the "run":
|
||||
self.expect_string ("run")
|
||||
self.expect_string("run")
|
||||
# We should have hit the breakpoint & continued:
|
||||
self.expect_string ("continue")
|
||||
self.expect_string("continue")
|
||||
# The App should have not have crashed:
|
||||
self.expect_string("Got there on time and it did not crash.")
|
||||
# Then we should have a live prompt:
|
||||
self.expect_string ("exited")
|
||||
self.expect_string("exited")
|
||||
index = self.child.expect([pexpect.EOF, pexpect.TIMEOUT])
|
||||
self.assertTrue(index == 0, "lldb didn't close on successful batch completion.")
|
||||
self.assertTrue(
|
||||
index == 0,
|
||||
"lldb didn't close on successful batch completion.")
|
||||
|
||||
def closeVictim(self):
|
||||
if self.victim != None:
|
||||
if self.victim is not None:
|
||||
self.victim.close()
|
||||
self.victim = None
|
||||
|
||||
@skipIfRemote # test not remote-ready llvm.org/pr24813
|
||||
@skipIfRemote # test not remote-ready llvm.org/pr24813
|
||||
@expectedFlakeyFreeBSD("llvm.org/pr25172 fails rarely on the buildbot")
|
||||
@expectedFlakeyLinux("llvm.org/pr25172")
|
||||
@expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr22274: need a pexpect replacement for windows")
|
||||
def test_batch_mode_attach_exit (self):
|
||||
@expectedFailureAll(
|
||||
oslist=["windows"],
|
||||
bugnumber="llvm.org/pr22274: need a pexpect replacement for windows")
|
||||
def test_batch_mode_attach_exit(self):
|
||||
"""Test that the lldb driver's batch mode works correctly."""
|
||||
self.build()
|
||||
self.setTearDownCleanup()
|
||||
|
||||
|
||||
import pexpect
|
||||
exe = os.path.join(os.getcwd(), "a.out")
|
||||
prompt = "(lldb) "
|
||||
|
||||
# Finally, start up the process by hand, attach to it, and wait for its completion.
|
||||
# Attach is funny, since it looks like it stops with a signal on most Unixen so
|
||||
# Attach is funny, since it looks like it stops with a signal on most Unixen so
|
||||
# care must be taken not to treat that as a reason to exit batch mode.
|
||||
|
||||
|
||||
# Start up the process by hand and wait for it to get to the wait loop.
|
||||
|
||||
self.victim = pexpect.spawn('%s WAIT' %(exe))
|
||||
if self.victim == None:
|
||||
self.victim = pexpect.spawn('%s WAIT' % (exe))
|
||||
if self.victim is None:
|
||||
self.fail("Could not spawn ", exe, ".")
|
||||
|
||||
self.addTearDownHook (self.closeVictim)
|
||||
self.addTearDownHook(self.closeVictim)
|
||||
|
||||
if self.TraceOn():
|
||||
self.victim.logfile_read = sys.stdout
|
||||
|
||||
self.victim.expect("PID: ([0-9]+) END")
|
||||
if self.victim.match == None:
|
||||
if self.victim.match is None:
|
||||
self.fail("Couldn't get the target PID.")
|
||||
|
||||
victim_pid = int(self.victim.match.group(1))
|
||||
|
||||
|
||||
self.victim.expect("Waiting")
|
||||
|
||||
run_commands = ' -b -o "process attach -p %d" -o "breakpoint set --file %s -p \'Stop here to unset keep_waiting\' -N keep_waiting" -o "continue" -o "break delete keep_waiting" -o "expr keep_waiting = 0" -o "continue" ' % (victim_pid, self.source)
|
||||
self.child = pexpect.spawn('%s %s %s %s' % (lldbtest_config.lldbExec, self.lldbOption, run_commands, exe))
|
||||
run_commands = ' -b -o "process attach -p %d" -o "breakpoint set --file %s -p \'Stop here to unset keep_waiting\' -N keep_waiting" -o "continue" -o "break delete keep_waiting" -o "expr keep_waiting = 0" -o "continue" ' % (
|
||||
victim_pid, self.source)
|
||||
self.child = pexpect.spawn(
|
||||
'%s %s %s %s' %
|
||||
(lldbtest_config.lldbExec,
|
||||
self.lldbOption,
|
||||
run_commands,
|
||||
exe))
|
||||
|
||||
child = self.child
|
||||
# Turn on logging for what the child sends back.
|
||||
@@ -152,19 +170,19 @@ class DriverBatchModeTest (TestBase):
|
||||
child.logfile_read = sys.stdout
|
||||
|
||||
# We should see the "run":
|
||||
self.expect_string ("attach")
|
||||
self.expect_string("attach")
|
||||
|
||||
self.expect_string(prompt + "continue")
|
||||
|
||||
self.expect_string(prompt + "continue")
|
||||
|
||||
# Then we should see the process exit:
|
||||
self.expect_string ("Process %d exited with status"%(victim_pid))
|
||||
|
||||
self.expect_string("Process %d exited with status" % (victim_pid))
|
||||
|
||||
victim_index = self.victim.expect([pexpect.EOF, pexpect.TIMEOUT])
|
||||
self.assertTrue(victim_index == 0, "Victim didn't really exit.")
|
||||
|
||||
index = self.child.expect([pexpect.EOF, pexpect.TIMEOUT])
|
||||
self.assertTrue(index == 0, "lldb didn't close on successful batch completion.")
|
||||
|
||||
|
||||
self.assertTrue(
|
||||
index == 0,
|
||||
"lldb didn't close on successful batch completion.")
|
||||
|
||||
@@ -4,14 +4,15 @@ import random
|
||||
import unittest
|
||||
import traceback
|
||||
|
||||
|
||||
class SequenceFunctionsTestCase(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
#traceback.print_stack()
|
||||
# traceback.print_stack()
|
||||
self.seq = list(range(10))
|
||||
|
||||
def tearDown(self):
|
||||
#traceback.print_stack()
|
||||
# traceback.print_stack()
|
||||
pass
|
||||
|
||||
def test_shuffle(self):
|
||||
|
||||
@@ -24,7 +24,10 @@ class TestExprLookupAnonStructTypedef(TestBase):
|
||||
self.line = line_number('main.cpp', '// lldb testsuite break')
|
||||
|
||||
@expectedFailureAll(oslist=["windows"])
|
||||
@expectedFailureAll(oslist=['linux'], archs=['arm'], bugnumber="llvm.org/pr27868")
|
||||
@expectedFailureAll(
|
||||
oslist=['linux'],
|
||||
archs=['arm'],
|
||||
bugnumber="llvm.org/pr27868")
|
||||
def test(self):
|
||||
"""Test typedeffed untagged struct arguments for function call expressions"""
|
||||
self.build()
|
||||
|
||||
@@ -5,12 +5,12 @@ Test calling std::String member functions.
|
||||
from __future__ import print_function
|
||||
|
||||
|
||||
|
||||
import lldb
|
||||
from lldbsuite.test.decorators import *
|
||||
from lldbsuite.test.lldbtest import *
|
||||
from lldbsuite.test import lldbutil
|
||||
|
||||
|
||||
class ExprCommandCallFunctionTestCase(TestBase):
|
||||
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
@@ -19,26 +19,33 @@ class ExprCommandCallFunctionTestCase(TestBase):
|
||||
# Call super's setUp().
|
||||
TestBase.setUp(self)
|
||||
# Find the line number to break for main.c.
|
||||
self.line = line_number('main.cpp',
|
||||
'// Please test these expressions while stopped at this line:')
|
||||
self.line = line_number(
|
||||
'main.cpp',
|
||||
'// Please test these expressions while stopped at this line:')
|
||||
|
||||
@expectedFailureAll(compiler="icc", bugnumber="llvm.org/pr14437, fails with ICC 13.1")
|
||||
@expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr17807 Fails on FreeBSD buildbot')
|
||||
@expectedFailureAll(
|
||||
compiler="icc",
|
||||
bugnumber="llvm.org/pr14437, fails with ICC 13.1")
|
||||
@expectedFailureAll(
|
||||
oslist=['freebsd'],
|
||||
bugnumber='llvm.org/pr17807 Fails on FreeBSD buildbot')
|
||||
@expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr21765")
|
||||
def test_with(self):
|
||||
"""Test calling std::String member function."""
|
||||
self.build()
|
||||
self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
|
||||
|
||||
# Some versions of GCC encode two locations for the 'return' statement in main.cpp
|
||||
lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=-1, loc_exact=True)
|
||||
# Some versions of GCC encode two locations for the 'return' statement
|
||||
# in main.cpp
|
||||
lldbutil.run_break_set_by_file_and_line(
|
||||
self, "main.cpp", self.line, num_expected_locations=-1, loc_exact=True)
|
||||
|
||||
self.runCmd("run", RUN_SUCCEEDED)
|
||||
|
||||
self.expect("print str",
|
||||
substrs = ['Hello world'])
|
||||
substrs=['Hello world'])
|
||||
|
||||
# Calling this function now succeeds, but we follow the typedef return type through to
|
||||
# const char *, and thus don't invoke the Summary formatter.
|
||||
self.expect("print str.c_str()",
|
||||
substrs = ['Hello world'])
|
||||
substrs=['Hello world'])
|
||||
|
||||
@@ -5,12 +5,12 @@ Test calling a function, stopping in the call, continue and gather the result on
|
||||
from __future__ import print_function
|
||||
|
||||
|
||||
|
||||
import lldb
|
||||
from lldbsuite.test.decorators import *
|
||||
from lldbsuite.test.lldbtest import *
|
||||
from lldbsuite.test import lldbutil
|
||||
|
||||
|
||||
class ExprCommandCallStopContinueTestCase(TestBase):
|
||||
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
@@ -19,28 +19,40 @@ class ExprCommandCallStopContinueTestCase(TestBase):
|
||||
# Call super's setUp().
|
||||
TestBase.setUp(self)
|
||||
# Find the line number to break for main.c.
|
||||
self.line = line_number('main.cpp',
|
||||
'// Please test these expressions while stopped at this line:')
|
||||
self.func_line = line_number ('main.cpp', '{5, "five"}')
|
||||
self.line = line_number(
|
||||
'main.cpp',
|
||||
'// Please test these expressions while stopped at this line:')
|
||||
self.func_line = line_number('main.cpp', '{5, "five"}')
|
||||
|
||||
@expectedFlakeyDarwin("llvm.org/pr20274")
|
||||
@expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24489: Name lookup not working correctly on Windows")
|
||||
@expectedFailureAll(
|
||||
oslist=["windows"],
|
||||
bugnumber="llvm.org/pr24489: Name lookup not working correctly on Windows")
|
||||
def test(self):
|
||||
"""Test gathering result from interrupted function call."""
|
||||
self.build()
|
||||
self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
|
||||
|
||||
# Some versions of GCC encode two locations for the 'return' statement in main.cpp
|
||||
lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=-1, loc_exact=True)
|
||||
# Some versions of GCC encode two locations for the 'return' statement
|
||||
# in main.cpp
|
||||
lldbutil.run_break_set_by_file_and_line(
|
||||
self, "main.cpp", self.line, num_expected_locations=-1, loc_exact=True)
|
||||
|
||||
self.runCmd("run", RUN_SUCCEEDED)
|
||||
|
||||
lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.func_line, num_expected_locations=-1, loc_exact=True)
|
||||
|
||||
lldbutil.run_break_set_by_file_and_line(
|
||||
self,
|
||||
"main.cpp",
|
||||
self.func_line,
|
||||
num_expected_locations=-1,
|
||||
loc_exact=True)
|
||||
|
||||
self.expect("expr -i false -- returnsFive()", error=True,
|
||||
substrs = ['Execution was interrupted, reason: breakpoint'])
|
||||
substrs=['Execution was interrupted, reason: breakpoint'])
|
||||
|
||||
self.runCmd("continue", "Continue completed")
|
||||
self.expect ("thread list",
|
||||
substrs = ['stop reason = User Expression thread plan',
|
||||
r'Completed expression: (Five) $0 = (number = 5, name = "five")'])
|
||||
self.expect(
|
||||
"thread list",
|
||||
substrs=[
|
||||
'stop reason = User Expression thread plan',
|
||||
r'Completed expression: (Five) $0 = (number = 5, name = "five")'])
|
||||
|
||||
@@ -10,12 +10,12 @@ Note:
|
||||
from __future__ import print_function
|
||||
|
||||
|
||||
|
||||
import lldb
|
||||
from lldbsuite.test.decorators import *
|
||||
from lldbsuite.test.lldbtest import *
|
||||
from lldbsuite.test import lldbutil
|
||||
|
||||
|
||||
class ExprCommandCallUserDefinedFunction(TestBase):
|
||||
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
@@ -24,30 +24,39 @@ class ExprCommandCallUserDefinedFunction(TestBase):
|
||||
# Call super's setUp().
|
||||
TestBase.setUp(self)
|
||||
# Find the line number to break for main.c.
|
||||
self.line = line_number('main.cpp',
|
||||
'// Please test these expressions while stopped at this line:')
|
||||
self.line = line_number(
|
||||
'main.cpp',
|
||||
'// Please test these expressions while stopped at this line:')
|
||||
|
||||
@expectedFlakeyDsym("llvm.org/pr20274")
|
||||
@expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24489: Name lookup not working correctly on Windows")
|
||||
@expectedFailureAll(
|
||||
oslist=["windows"],
|
||||
bugnumber="llvm.org/pr24489: Name lookup not working correctly on Windows")
|
||||
def test(self):
|
||||
"""Test return values of user defined function calls."""
|
||||
self.build()
|
||||
|
||||
# Set breakpoint in main and run exe
|
||||
self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
|
||||
lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=-1, loc_exact=True)
|
||||
lldbutil.run_break_set_by_file_and_line(
|
||||
self, "main.cpp", self.line, num_expected_locations=-1, loc_exact=True)
|
||||
|
||||
self.runCmd("run", RUN_SUCCEEDED)
|
||||
|
||||
# Test recursive function call.
|
||||
self.expect("expr fib(5)", substrs = ['$0 = 5'])
|
||||
self.expect("expr fib(5)", substrs=['$0 = 5'])
|
||||
|
||||
# Test function with more than one paramter
|
||||
self.expect("expr add(4,8)", substrs = ['$1 = 12'])
|
||||
self.expect("expr add(4,8)", substrs=['$1 = 12'])
|
||||
|
||||
# Test nesting function calls in function paramters
|
||||
self.expect("expr add(add(5,2),add(3,4))", substrs = ['$2 = 14'])
|
||||
self.expect("expr add(add(5,2),fib(5))", substrs = ['$3 = 12'])
|
||||
self.expect("expr add(add(5,2),add(3,4))", substrs=['$2 = 14'])
|
||||
self.expect("expr add(add(5,2),fib(5))", substrs=['$3 = 12'])
|
||||
|
||||
# Test function with pointer paramter
|
||||
self.expect("exp stringCompare((const char*) \"Hello world\")", substrs = ['$4 = true'])
|
||||
self.expect("exp stringCompare((const char*) \"Hellworld\")", substrs = ['$5 = false'])
|
||||
self.expect(
|
||||
"exp stringCompare((const char*) \"Hello world\")",
|
||||
substrs=['$4 = true'])
|
||||
self.expect(
|
||||
"exp stringCompare((const char*) \"Hellworld\")",
|
||||
substrs=['$5 = false'])
|
||||
|
||||
@@ -5,12 +5,12 @@ Test calling a function that hits a signal set to auto-restart, make sure the ca
|
||||
from __future__ import print_function
|
||||
|
||||
|
||||
|
||||
import lldb
|
||||
from lldbsuite.test.decorators import *
|
||||
from lldbsuite.test.lldbtest import *
|
||||
from lldbsuite.test import lldbutil
|
||||
|
||||
|
||||
class ExprCommandThatRestartsTestCase(TestBase):
|
||||
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
@@ -20,24 +20,30 @@ class ExprCommandThatRestartsTestCase(TestBase):
|
||||
TestBase.setUp(self)
|
||||
|
||||
self.main_source = "lotta-signals.c"
|
||||
self.main_source_spec = lldb.SBFileSpec (self.main_source)
|
||||
self.main_source_spec = lldb.SBFileSpec(self.main_source)
|
||||
|
||||
@skipIfFreeBSD # llvm.org/pr19246: intermittent failure
|
||||
@skipIfDarwin # llvm.org/pr19246: intermittent failure
|
||||
@skipIfWindows # Test relies on signals, unsupported on Windows
|
||||
@skipIfFreeBSD # llvm.org/pr19246: intermittent failure
|
||||
@skipIfDarwin # llvm.org/pr19246: intermittent failure
|
||||
@skipIfWindows # Test relies on signals, unsupported on Windows
|
||||
def test(self):
|
||||
"""Test calling function that hits a signal and restarts."""
|
||||
self.build()
|
||||
self.call_function()
|
||||
|
||||
def check_after_call (self, num_sigchld):
|
||||
def check_after_call(self, num_sigchld):
|
||||
after_call = self.sigchld_no.GetValueAsSigned(-1)
|
||||
self.assertTrue (after_call - self.start_sigchld_no == num_sigchld, "Really got %d SIGCHLD signals through the call."%(num_sigchld))
|
||||
self.assertTrue(
|
||||
after_call -
|
||||
self.start_sigchld_no == num_sigchld,
|
||||
"Really got %d SIGCHLD signals through the call." %
|
||||
(num_sigchld))
|
||||
self.start_sigchld_no = after_call
|
||||
|
||||
# Check that we are back where we were before:
|
||||
frame = self.thread.GetFrameAtIndex(0)
|
||||
self.assertTrue (self.orig_frame_pc == frame.GetPC(), "Restored the zeroth frame correctly")
|
||||
self.assertTrue(
|
||||
self.orig_frame_pc == frame.GetPC(),
|
||||
"Restored the zeroth frame correctly")
|
||||
|
||||
def call_function(self):
|
||||
exe_name = "a.out"
|
||||
@@ -46,95 +52,133 @@ class ExprCommandThatRestartsTestCase(TestBase):
|
||||
target = self.dbg.CreateTarget(exe)
|
||||
self.assertTrue(target, VALID_TARGET)
|
||||
empty = lldb.SBFileSpec()
|
||||
breakpoint = target.BreakpointCreateBySourceRegex('Stop here in main.',self.main_source_spec)
|
||||
breakpoint = target.BreakpointCreateBySourceRegex(
|
||||
'Stop here in main.', self.main_source_spec)
|
||||
self.assertTrue(breakpoint.GetNumLocations() > 0, VALID_BREAKPOINT)
|
||||
|
||||
# Launch the process, and do not stop at the entry point.
|
||||
process = target.LaunchSimple (None, None, self.get_process_working_directory())
|
||||
process = target.LaunchSimple(
|
||||
None, None, self.get_process_working_directory())
|
||||
|
||||
self.assertTrue(process, PROCESS_IS_VALID)
|
||||
|
||||
# Frame #0 should be at our breakpoint.
|
||||
threads = lldbutil.get_threads_stopped_at_breakpoint (process, breakpoint)
|
||||
|
||||
threads = lldbutil.get_threads_stopped_at_breakpoint(
|
||||
process, breakpoint)
|
||||
|
||||
self.assertTrue(len(threads) == 1)
|
||||
self.thread = threads[0]
|
||||
|
||||
|
||||
# Make sure the SIGCHLD behavior is pass/no-stop/no-notify:
|
||||
return_obj = lldb.SBCommandReturnObject()
|
||||
self.dbg.GetCommandInterpreter().HandleCommand("process handle SIGCHLD -s 0 -p 1 -n 0", return_obj)
|
||||
self.assertTrue (return_obj.Succeeded() == True, "Set SIGCHLD to pass, no-stop")
|
||||
self.dbg.GetCommandInterpreter().HandleCommand(
|
||||
"process handle SIGCHLD -s 0 -p 1 -n 0", return_obj)
|
||||
self.assertTrue(return_obj.Succeeded(), "Set SIGCHLD to pass, no-stop")
|
||||
|
||||
# The sigchld_no variable should be 0 at this point.
|
||||
self.sigchld_no = target.FindFirstGlobalVariable("sigchld_no")
|
||||
self.assertTrue (self.sigchld_no.IsValid(), "Got a value for sigchld_no")
|
||||
self.assertTrue(
|
||||
self.sigchld_no.IsValid(),
|
||||
"Got a value for sigchld_no")
|
||||
|
||||
self.start_sigchld_no = self.sigchld_no.GetValueAsSigned (-1)
|
||||
self.assertTrue (self.start_sigchld_no != -1, "Got an actual value for sigchld_no")
|
||||
self.start_sigchld_no = self.sigchld_no.GetValueAsSigned(-1)
|
||||
self.assertTrue(
|
||||
self.start_sigchld_no != -1,
|
||||
"Got an actual value for sigchld_no")
|
||||
|
||||
options = lldb.SBExpressionOptions()
|
||||
# processing 30 signals takes a while, increase the expression timeout a bit
|
||||
options.SetTimeoutInMicroSeconds(3000000) # 3s
|
||||
# processing 30 signals takes a while, increase the expression timeout
|
||||
# a bit
|
||||
options.SetTimeoutInMicroSeconds(3000000) # 3s
|
||||
options.SetUnwindOnError(True)
|
||||
|
||||
frame = self.thread.GetFrameAtIndex(0)
|
||||
# Store away the PC to check that the functions unwind to the right place after calls
|
||||
# Store away the PC to check that the functions unwind to the right
|
||||
# place after calls
|
||||
self.orig_frame_pc = frame.GetPC()
|
||||
|
||||
num_sigchld = 30
|
||||
value = frame.EvaluateExpression ("call_me (%d)"%(num_sigchld), options)
|
||||
self.assertTrue (value.IsValid())
|
||||
self.assertTrue (value.GetError().Success() == True)
|
||||
self.assertTrue (value.GetValueAsSigned(-1) == num_sigchld)
|
||||
value = frame.EvaluateExpression(
|
||||
"call_me (%d)" %
|
||||
(num_sigchld), options)
|
||||
self.assertTrue(value.IsValid())
|
||||
self.assertTrue(value.GetError().Success())
|
||||
self.assertTrue(value.GetValueAsSigned(-1) == num_sigchld)
|
||||
|
||||
self.check_after_call(num_sigchld)
|
||||
|
||||
# Okay, now try with a breakpoint in the called code in the case where
|
||||
# we are ignoring breakpoint hits.
|
||||
handler_bkpt = target.BreakpointCreateBySourceRegex("Got sigchld %d.", self.main_source_spec)
|
||||
self.assertTrue (handler_bkpt.GetNumLocations() > 0)
|
||||
handler_bkpt = target.BreakpointCreateBySourceRegex(
|
||||
"Got sigchld %d.", self.main_source_spec)
|
||||
self.assertTrue(handler_bkpt.GetNumLocations() > 0)
|
||||
options.SetIgnoreBreakpoints(True)
|
||||
options.SetUnwindOnError(True)
|
||||
|
||||
value = frame.EvaluateExpression("call_me (%d)"%(num_sigchld), options)
|
||||
value = frame.EvaluateExpression(
|
||||
"call_me (%d)" %
|
||||
(num_sigchld), options)
|
||||
|
||||
self.assertTrue (value.IsValid() and value.GetError().Success() == True)
|
||||
self.assertTrue (value.GetValueAsSigned(-1) == num_sigchld)
|
||||
self.assertTrue(value.IsValid() and value.GetError().Success())
|
||||
self.assertTrue(value.GetValueAsSigned(-1) == num_sigchld)
|
||||
self.check_after_call(num_sigchld)
|
||||
|
||||
# Now set the signal to print but not stop and make sure that calling still works:
|
||||
self.dbg.GetCommandInterpreter().HandleCommand("process handle SIGCHLD -s 0 -p 1 -n 1", return_obj)
|
||||
self.assertTrue (return_obj.Succeeded() == True, "Set SIGCHLD to pass, no-stop, notify")
|
||||
# Now set the signal to print but not stop and make sure that calling
|
||||
# still works:
|
||||
self.dbg.GetCommandInterpreter().HandleCommand(
|
||||
"process handle SIGCHLD -s 0 -p 1 -n 1", return_obj)
|
||||
self.assertTrue(
|
||||
return_obj.Succeeded(),
|
||||
"Set SIGCHLD to pass, no-stop, notify")
|
||||
|
||||
value = frame.EvaluateExpression("call_me (%d)"%(num_sigchld), options)
|
||||
value = frame.EvaluateExpression(
|
||||
"call_me (%d)" %
|
||||
(num_sigchld), options)
|
||||
|
||||
self.assertTrue (value.IsValid() and value.GetError().Success() == True)
|
||||
self.assertTrue (value.GetValueAsSigned(-1) == num_sigchld)
|
||||
self.assertTrue(value.IsValid() and value.GetError().Success())
|
||||
self.assertTrue(value.GetValueAsSigned(-1) == num_sigchld)
|
||||
self.check_after_call(num_sigchld)
|
||||
|
||||
# Now set this unwind on error to false, and make sure that we still complete the call:
|
||||
# Now set this unwind on error to false, and make sure that we still
|
||||
# complete the call:
|
||||
options.SetUnwindOnError(False)
|
||||
value = frame.EvaluateExpression("call_me (%d)"%(num_sigchld), options)
|
||||
value = frame.EvaluateExpression(
|
||||
"call_me (%d)" %
|
||||
(num_sigchld), options)
|
||||
|
||||
self.assertTrue (value.IsValid() and value.GetError().Success() == True)
|
||||
self.assertTrue (value.GetValueAsSigned(-1) == num_sigchld)
|
||||
self.assertTrue(value.IsValid() and value.GetError().Success())
|
||||
self.assertTrue(value.GetValueAsSigned(-1) == num_sigchld)
|
||||
self.check_after_call(num_sigchld)
|
||||
|
||||
# Okay, now set UnwindOnError to true, and then make the signal behavior to stop
|
||||
# and see that now we do stop at the signal point:
|
||||
|
||||
self.dbg.GetCommandInterpreter().HandleCommand("process handle SIGCHLD -s 1 -p 1 -n 1", return_obj)
|
||||
self.assertTrue (return_obj.Succeeded() == True, "Set SIGCHLD to pass, stop, notify")
|
||||
|
||||
value = frame.EvaluateExpression("call_me (%d)"%(num_sigchld), options)
|
||||
self.assertTrue (value.IsValid() and value.GetError().Success() == False)
|
||||
|
||||
# Set signal handling back to no-stop, and continue and we should end up back in out starting frame:
|
||||
self.dbg.GetCommandInterpreter().HandleCommand("process handle SIGCHLD -s 0 -p 1 -n 1", return_obj)
|
||||
self.assertTrue (return_obj.Succeeded() == True, "Set SIGCHLD to pass, no-stop, notify")
|
||||
|
||||
self.dbg.GetCommandInterpreter().HandleCommand(
|
||||
"process handle SIGCHLD -s 1 -p 1 -n 1", return_obj)
|
||||
self.assertTrue(
|
||||
return_obj.Succeeded(),
|
||||
"Set SIGCHLD to pass, stop, notify")
|
||||
|
||||
value = frame.EvaluateExpression(
|
||||
"call_me (%d)" %
|
||||
(num_sigchld), options)
|
||||
self.assertTrue(
|
||||
value.IsValid() and value.GetError().Success() == False)
|
||||
|
||||
# Set signal handling back to no-stop, and continue and we should end
|
||||
# up back in out starting frame:
|
||||
self.dbg.GetCommandInterpreter().HandleCommand(
|
||||
"process handle SIGCHLD -s 0 -p 1 -n 1", return_obj)
|
||||
self.assertTrue(
|
||||
return_obj.Succeeded(),
|
||||
"Set SIGCHLD to pass, no-stop, notify")
|
||||
|
||||
error = process.Continue()
|
||||
self.assertTrue (error.Success(), "Continuing after stopping for signal succeeds.")
|
||||
|
||||
self.assertTrue(
|
||||
error.Success(),
|
||||
"Continuing after stopping for signal succeeds.")
|
||||
|
||||
frame = self.thread.GetFrameAtIndex(0)
|
||||
self.assertTrue (frame.GetPC() == self.orig_frame_pc, "Continuing returned to the place we started.")
|
||||
self.assertTrue(
|
||||
frame.GetPC() == self.orig_frame_pc,
|
||||
"Continuing returned to the place we started.")
|
||||
|
||||
@@ -5,12 +5,12 @@ Test calling a function that throws an ObjC exception, make sure that it doesn't
|
||||
from __future__ import print_function
|
||||
|
||||
|
||||
|
||||
import lldb
|
||||
from lldbsuite.test.decorators import *
|
||||
from lldbsuite.test.lldbtest import *
|
||||
from lldbsuite.test import lldbutil
|
||||
|
||||
|
||||
class ExprCommandWithThrowTestCase(TestBase):
|
||||
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
@@ -20,7 +20,7 @@ class ExprCommandWithThrowTestCase(TestBase):
|
||||
TestBase.setUp(self)
|
||||
|
||||
self.main_source = "call-throws.m"
|
||||
self.main_source_spec = lldb.SBFileSpec (self.main_source)
|
||||
self.main_source_spec = lldb.SBFileSpec(self.main_source)
|
||||
|
||||
@skipUnlessDarwin
|
||||
def test(self):
|
||||
@@ -28,12 +28,13 @@ class ExprCommandWithThrowTestCase(TestBase):
|
||||
self.build()
|
||||
self.call_function()
|
||||
|
||||
def check_after_call (self):
|
||||
def check_after_call(self):
|
||||
# Check that we are back where we were before:
|
||||
frame = self.thread.GetFrameAtIndex(0)
|
||||
self.assertTrue (self.orig_frame_pc == frame.GetPC(), "Restored the zeroth frame correctly")
|
||||
self.assertTrue(
|
||||
self.orig_frame_pc == frame.GetPC(),
|
||||
"Restored the zeroth frame correctly")
|
||||
|
||||
|
||||
def call_function(self):
|
||||
"""Test calling function that throws."""
|
||||
exe_name = "a.out"
|
||||
@@ -42,72 +43,82 @@ class ExprCommandWithThrowTestCase(TestBase):
|
||||
target = self.dbg.CreateTarget(exe)
|
||||
self.assertTrue(target, VALID_TARGET)
|
||||
|
||||
breakpoint = target.BreakpointCreateBySourceRegex('I am about to throw.',self.main_source_spec)
|
||||
breakpoint = target.BreakpointCreateBySourceRegex(
|
||||
'I am about to throw.', self.main_source_spec)
|
||||
self.assertTrue(breakpoint.GetNumLocations() > 0, VALID_BREAKPOINT)
|
||||
|
||||
# Launch the process, and do not stop at the entry point.
|
||||
process = target.LaunchSimple (None, None, self.get_process_working_directory())
|
||||
process = target.LaunchSimple(
|
||||
None, None, self.get_process_working_directory())
|
||||
|
||||
self.assertTrue(process, PROCESS_IS_VALID)
|
||||
|
||||
# Frame #0 should be at our breakpoint.
|
||||
threads = lldbutil.get_threads_stopped_at_breakpoint (process, breakpoint)
|
||||
|
||||
threads = lldbutil.get_threads_stopped_at_breakpoint(
|
||||
process, breakpoint)
|
||||
|
||||
self.assertTrue(len(threads) == 1)
|
||||
self.thread = threads[0]
|
||||
|
||||
|
||||
options = lldb.SBExpressionOptions()
|
||||
options.SetUnwindOnError(True)
|
||||
|
||||
frame = self.thread.GetFrameAtIndex(0)
|
||||
# Store away the PC to check that the functions unwind to the right place after calls
|
||||
# Store away the PC to check that the functions unwind to the right
|
||||
# place after calls
|
||||
self.orig_frame_pc = frame.GetPC()
|
||||
|
||||
value = frame.EvaluateExpression ("[my_class callMeIThrow]", options)
|
||||
self.assertTrue (value.IsValid())
|
||||
self.assertTrue (value.GetError().Success() == False)
|
||||
value = frame.EvaluateExpression("[my_class callMeIThrow]", options)
|
||||
self.assertTrue(value.IsValid())
|
||||
self.assertTrue(value.GetError().Success() == False)
|
||||
|
||||
self.check_after_call()
|
||||
|
||||
# Okay, now try with a breakpoint in the called code in the case where
|
||||
# we are ignoring breakpoint hits.
|
||||
handler_bkpt = target.BreakpointCreateBySourceRegex("I felt like it", self.main_source_spec)
|
||||
self.assertTrue (handler_bkpt.GetNumLocations() > 0)
|
||||
handler_bkpt = target.BreakpointCreateBySourceRegex(
|
||||
"I felt like it", self.main_source_spec)
|
||||
self.assertTrue(handler_bkpt.GetNumLocations() > 0)
|
||||
options.SetIgnoreBreakpoints(True)
|
||||
options.SetUnwindOnError(True)
|
||||
|
||||
value = frame.EvaluateExpression ("[my_class callMeIThrow]", options)
|
||||
value = frame.EvaluateExpression("[my_class callMeIThrow]", options)
|
||||
|
||||
self.assertTrue (value.IsValid() and value.GetError().Success() == False)
|
||||
self.assertTrue(
|
||||
value.IsValid() and value.GetError().Success() == False)
|
||||
self.check_after_call()
|
||||
|
||||
# Now set the ObjC language breakpoint and make sure that doesn't interfere with the call:
|
||||
exception_bkpt = target.BreakpointCreateForException (lldb.eLanguageTypeObjC, False, True)
|
||||
# Now set the ObjC language breakpoint and make sure that doesn't
|
||||
# interfere with the call:
|
||||
exception_bkpt = target.BreakpointCreateForException(
|
||||
lldb.eLanguageTypeObjC, False, True)
|
||||
self.assertTrue(exception_bkpt.GetNumLocations() > 0)
|
||||
|
||||
options.SetIgnoreBreakpoints(True)
|
||||
options.SetUnwindOnError(True)
|
||||
|
||||
value = frame.EvaluateExpression ("[my_class callMeIThrow]", options)
|
||||
value = frame.EvaluateExpression("[my_class callMeIThrow]", options)
|
||||
|
||||
self.assertTrue (value.IsValid() and value.GetError().Success() == False)
|
||||
self.assertTrue(
|
||||
value.IsValid() and value.GetError().Success() == False)
|
||||
self.check_after_call()
|
||||
|
||||
|
||||
# Now turn off exception trapping, and call a function that catches the exceptions,
|
||||
# and make sure the function actually completes, and we get the right value:
|
||||
# and make sure the function actually completes, and we get the right
|
||||
# value:
|
||||
options.SetTrapExceptions(False)
|
||||
value = frame.EvaluateExpression ("[my_class iCatchMyself]", options)
|
||||
self.assertTrue (value.IsValid())
|
||||
self.assertTrue (value.GetError().Success() == True)
|
||||
self.assertTrue (value.GetValueAsUnsigned() == 57)
|
||||
value = frame.EvaluateExpression("[my_class iCatchMyself]", options)
|
||||
self.assertTrue(value.IsValid())
|
||||
self.assertTrue(value.GetError().Success())
|
||||
self.assertTrue(value.GetValueAsUnsigned() == 57)
|
||||
self.check_after_call()
|
||||
options.SetTrapExceptions(True)
|
||||
|
||||
# Now set this unwind on error to false, and make sure that we stop where the exception was thrown
|
||||
# Now set this unwind on error to false, and make sure that we stop
|
||||
# where the exception was thrown
|
||||
options.SetUnwindOnError(False)
|
||||
value = frame.EvaluateExpression ("[my_class callMeIThrow]", options)
|
||||
value = frame.EvaluateExpression("[my_class callMeIThrow]", options)
|
||||
|
||||
|
||||
self.assertTrue (value.IsValid() and value.GetError().Success() == False)
|
||||
self.assertTrue(
|
||||
value.IsValid() and value.GetError().Success() == False)
|
||||
self.check_after_call()
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
from __future__ import print_function
|
||||
|
||||
|
||||
|
||||
import lldb
|
||||
from lldbsuite.test.decorators import *
|
||||
from lldbsuite.test.lldbtest import *
|
||||
from lldbsuite.test import lldbutil
|
||||
|
||||
|
||||
class ExprCharTestCase(TestBase):
|
||||
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
@@ -16,24 +16,27 @@ class ExprCharTestCase(TestBase):
|
||||
TestBase.setUp(self)
|
||||
|
||||
self.main_source = "main.cpp"
|
||||
self.main_source_spec = lldb.SBFileSpec (self.main_source)
|
||||
self.main_source_spec = lldb.SBFileSpec(self.main_source)
|
||||
self.exe = os.path.join(os.getcwd(), "a.out")
|
||||
|
||||
def do_test(self, dictionary=None):
|
||||
"""These basic expression commands should work as expected."""
|
||||
self.build(dictionary = dictionary)
|
||||
self.build(dictionary=dictionary)
|
||||
|
||||
target = self.dbg.CreateTarget(self.exe)
|
||||
self.assertTrue(target)
|
||||
|
||||
breakpoint = target.BreakpointCreateBySourceRegex('// Break here', self.main_source_spec)
|
||||
breakpoint = target.BreakpointCreateBySourceRegex(
|
||||
'// Break here', self.main_source_spec)
|
||||
self.assertTrue(breakpoint)
|
||||
|
||||
# Launch the process, and do not stop at the entry point.
|
||||
process = target.LaunchSimple(None, None, self.get_process_working_directory())
|
||||
process = target.LaunchSimple(
|
||||
None, None, self.get_process_working_directory())
|
||||
self.assertTrue(process)
|
||||
|
||||
threads = lldbutil.get_threads_stopped_at_breakpoint(process, breakpoint)
|
||||
threads = lldbutil.get_threads_stopped_at_breakpoint(
|
||||
process, breakpoint)
|
||||
self.assertEqual(len(threads), 1)
|
||||
|
||||
frame = threads[0].GetFrameAtIndex(0)
|
||||
@@ -57,13 +60,22 @@ class ExprCharTestCase(TestBase):
|
||||
def test_default_char(self):
|
||||
self.do_test()
|
||||
|
||||
@expectedFailureAll(archs=["arm", "aarch64", "s390x"], bugnumber="llvm.org/pr23069")
|
||||
@expectedFailureAll(
|
||||
archs=[
|
||||
"arm",
|
||||
"aarch64",
|
||||
"s390x"],
|
||||
bugnumber="llvm.org/pr23069")
|
||||
@expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr21765")
|
||||
def test_signed_char(self):
|
||||
self.do_test(dictionary={'CFLAGS_EXTRAS': '-fsigned-char'})
|
||||
|
||||
@expectedFailureAll(archs=["i[3-6]86", "x86_64"], bugnumber="llvm.org/pr23069")
|
||||
@expectedFailureAll(
|
||||
archs=[
|
||||
"i[3-6]86",
|
||||
"x86_64"],
|
||||
bugnumber="llvm.org/pr23069")
|
||||
@expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr21765")
|
||||
@expectedFailureAll(triple = 'mips*', bugnumber="llvm.org/pr23069")
|
||||
@expectedFailureAll(triple='mips*', bugnumber="llvm.org/pr23069")
|
||||
def test_unsigned_char(self):
|
||||
self.do_test(dictionary={'CFLAGS_EXTRAS': '-funsigned-char'})
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
from __future__ import print_function
|
||||
|
||||
|
||||
|
||||
import os
|
||||
import lldb
|
||||
from lldbsuite.test.decorators import *
|
||||
@@ -15,7 +14,9 @@ class ExprSyscallTestCase(TestBase):
|
||||
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
|
||||
@expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr21765, getpid() does not exist on Windows")
|
||||
@expectedFailureAll(
|
||||
oslist=["windows"],
|
||||
bugnumber="llvm.org/pr21765, getpid() does not exist on Windows")
|
||||
def test_setpgid(self):
|
||||
self.build()
|
||||
self.expr_syscall()
|
||||
@@ -32,16 +33,16 @@ class ExprSyscallTestCase(TestBase):
|
||||
# launch the inferior and don't wait for it to stop
|
||||
self.dbg.SetAsync(True)
|
||||
error = lldb.SBError()
|
||||
process = target.Launch (listener,
|
||||
None, # argv
|
||||
None, # envp
|
||||
None, # stdin_path
|
||||
None, # stdout_path
|
||||
None, # stderr_path
|
||||
None, # working directory
|
||||
0, # launch flags
|
||||
False, # Stop at entry
|
||||
error) # error
|
||||
process = target.Launch(listener,
|
||||
None, # argv
|
||||
None, # envp
|
||||
None, # stdin_path
|
||||
None, # stdout_path
|
||||
None, # stderr_path
|
||||
None, # working directory
|
||||
0, # launch flags
|
||||
False, # Stop at entry
|
||||
error) # error
|
||||
|
||||
self.assertTrue(process and process.IsValid(), PROCESS_IS_VALID)
|
||||
|
||||
@@ -54,7 +55,10 @@ class ExprSyscallTestCase(TestBase):
|
||||
pass
|
||||
|
||||
# now the process should be running (blocked in the syscall)
|
||||
self.assertEqual(process.GetState(), lldb.eStateRunning, "Process is running")
|
||||
self.assertEqual(
|
||||
process.GetState(),
|
||||
lldb.eStateRunning,
|
||||
"Process is running")
|
||||
|
||||
# send the process a signal
|
||||
process.SendAsyncInterrupt()
|
||||
@@ -62,13 +66,18 @@ class ExprSyscallTestCase(TestBase):
|
||||
pass
|
||||
|
||||
# as a result the process should stop
|
||||
# in all likelihood we have stopped in the middle of the sleep() syscall
|
||||
self.assertEqual(process.GetState(), lldb.eStateStopped, PROCESS_STOPPED)
|
||||
# in all likelihood we have stopped in the middle of the sleep()
|
||||
# syscall
|
||||
self.assertEqual(
|
||||
process.GetState(),
|
||||
lldb.eStateStopped,
|
||||
PROCESS_STOPPED)
|
||||
thread = process.GetSelectedThread()
|
||||
|
||||
# try evaluating a couple of expressions in this state
|
||||
self.expect("expr release_flag = 1", substrs = [" = 1"])
|
||||
self.expect("print (int)getpid()", substrs = [str(process.GetProcessID())])
|
||||
self.expect("expr release_flag = 1", substrs=[" = 1"])
|
||||
self.expect("print (int)getpid()",
|
||||
substrs=[str(process.GetProcessID())])
|
||||
|
||||
# and run the process to completion
|
||||
process.Continue()
|
||||
|
||||
@@ -5,12 +5,12 @@ Test calling an expression with errors that a FixIt can fix.
|
||||
from __future__ import print_function
|
||||
|
||||
|
||||
|
||||
import lldb
|
||||
from lldbsuite.test.decorators import *
|
||||
from lldbsuite.test.lldbtest import *
|
||||
from lldbsuite.test import lldbutil
|
||||
|
||||
|
||||
class ExprCommandWithFixits(TestBase):
|
||||
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
@@ -20,7 +20,7 @@ class ExprCommandWithFixits(TestBase):
|
||||
TestBase.setUp(self)
|
||||
|
||||
self.main_source = "main.cpp"
|
||||
self.main_source_spec = lldb.SBFileSpec (self.main_source)
|
||||
self.main_source_spec = lldb.SBFileSpec(self.main_source)
|
||||
|
||||
@skipUnlessDarwin
|
||||
def test(self):
|
||||
@@ -36,20 +36,23 @@ class ExprCommandWithFixits(TestBase):
|
||||
target = self.dbg.CreateTarget(exe)
|
||||
self.assertTrue(target, VALID_TARGET)
|
||||
|
||||
breakpoint = target.BreakpointCreateBySourceRegex('Stop here to evaluate expressions',self.main_source_spec)
|
||||
breakpoint = target.BreakpointCreateBySourceRegex(
|
||||
'Stop here to evaluate expressions', self.main_source_spec)
|
||||
self.assertTrue(breakpoint.GetNumLocations() > 0, VALID_BREAKPOINT)
|
||||
|
||||
# Launch the process, and do not stop at the entry point.
|
||||
process = target.LaunchSimple (None, None, self.get_process_working_directory())
|
||||
process = target.LaunchSimple(
|
||||
None, None, self.get_process_working_directory())
|
||||
|
||||
self.assertTrue(process, PROCESS_IS_VALID)
|
||||
|
||||
# Frame #0 should be at our breakpoint.
|
||||
threads = lldbutil.get_threads_stopped_at_breakpoint (process, breakpoint)
|
||||
|
||||
threads = lldbutil.get_threads_stopped_at_breakpoint(
|
||||
process, breakpoint)
|
||||
|
||||
self.assertTrue(len(threads) == 1)
|
||||
self.thread = threads[0]
|
||||
|
||||
|
||||
options = lldb.SBExpressionOptions()
|
||||
options.SetAutoApplyFixIts(True)
|
||||
|
||||
@@ -60,7 +63,7 @@ class ExprCommandWithFixits(TestBase):
|
||||
self.assertTrue(value.IsValid())
|
||||
self.assertTrue(value.GetError().Success())
|
||||
self.assertTrue(value.GetValueAsUnsigned() == 10)
|
||||
|
||||
|
||||
# Try with two errors:
|
||||
two_error_expression = "my_pointer.second->a"
|
||||
value = frame.EvaluateExpression(two_error_expression, options)
|
||||
@@ -74,8 +77,9 @@ class ExprCommandWithFixits(TestBase):
|
||||
self.assertTrue(value.IsValid())
|
||||
self.assertTrue(value.GetError().Fail())
|
||||
error_string = value.GetError().GetCString()
|
||||
self.assertTrue(error_string.find("fixed expression suggested:") != -1, "Fix was suggested")
|
||||
self.assertTrue(error_string.find("my_pointer->second.a") != -1, "Fix was right")
|
||||
|
||||
|
||||
|
||||
self.assertTrue(
|
||||
error_string.find("fixed expression suggested:") != -1,
|
||||
"Fix was suggested")
|
||||
self.assertTrue(
|
||||
error_string.find("my_pointer->second.a") != -1,
|
||||
"Fix was right")
|
||||
|
||||
@@ -5,12 +5,12 @@ Test using LLDB data formatters with frozen objects coming from the expression p
|
||||
from __future__ import print_function
|
||||
|
||||
|
||||
|
||||
import lldb
|
||||
from lldbsuite.test.decorators import *
|
||||
from lldbsuite.test.lldbtest import *
|
||||
from lldbsuite.test import lldbutil
|
||||
|
||||
|
||||
class ExprFormattersTestCase(TestBase):
|
||||
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
@@ -22,11 +22,13 @@ class ExprFormattersTestCase(TestBase):
|
||||
self.line = line_number('main.cpp',
|
||||
'// Stop here')
|
||||
|
||||
@skipIfFreeBSD # llvm.org/pr24691 skipping to avoid crashing the test runner
|
||||
@expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr19011 Newer Clang omits C1 complete object constructor')
|
||||
@skipIfFreeBSD # llvm.org/pr24691 skipping to avoid crashing the test runner
|
||||
@expectedFailureAll(
|
||||
oslist=['freebsd'],
|
||||
bugnumber='llvm.org/pr19011 Newer Clang omits C1 complete object constructor')
|
||||
@expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr21765")
|
||||
@skipIfTargetAndroid() # skipping to avoid crashing the test runner
|
||||
@expectedFailureAndroid('llvm.org/pr24691') # we hit an assertion in clang
|
||||
@skipIfTargetAndroid() # skipping to avoid crashing the test runner
|
||||
@expectedFailureAndroid('llvm.org/pr24691') # we hit an assertion in clang
|
||||
def test(self):
|
||||
"""Test expr + formatters for good interoperability."""
|
||||
self.build()
|
||||
@@ -36,64 +38,117 @@ class ExprFormattersTestCase(TestBase):
|
||||
def cleanup():
|
||||
self.runCmd('type summary clear', check=False)
|
||||
self.runCmd('type synthetic clear', check=False)
|
||||
|
||||
|
||||
# Execute the cleanup function during test case tear down.
|
||||
self.addTearDownHook(cleanup)
|
||||
|
||||
"""Test expr + formatters for good interoperability."""
|
||||
self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
|
||||
|
||||
lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, loc_exact=True)
|
||||
lldbutil.run_break_set_by_file_and_line(
|
||||
self, "main.cpp", self.line, loc_exact=True)
|
||||
|
||||
self.runCmd("run", RUN_SUCCEEDED)
|
||||
self.runCmd("command script import formatters.py")
|
||||
self.runCmd("command script import foosynth.py")
|
||||
|
||||
|
||||
if self.TraceOn():
|
||||
self.runCmd("frame variable foo1 --show-types")
|
||||
self.runCmd("frame variable foo1.b --show-types")
|
||||
self.runCmd("frame variable foo1.b.b_ref --show-types")
|
||||
|
||||
self.expect("expression --show-types -- *(new foo(47))",
|
||||
substrs = ['(int) a = 47', '(bar) b = {', '(int) i = 94', '(baz) b = {', '(int) k = 99'])
|
||||
self.expect(
|
||||
"expression --show-types -- *(new foo(47))",
|
||||
substrs=[
|
||||
'(int) a = 47',
|
||||
'(bar) b = {',
|
||||
'(int) i = 94',
|
||||
'(baz) b = {',
|
||||
'(int) k = 99'])
|
||||
|
||||
self.runCmd("type summary add -F formatters.foo_SummaryProvider foo")
|
||||
|
||||
self.expect("expression new int(12)",
|
||||
substrs = ['(int *) $', ' = 0x'])
|
||||
substrs=['(int *) $', ' = 0x'])
|
||||
|
||||
self.runCmd("type summary add -s \"${var%pointer} -> ${*var%decimal}\" \"int *\"")
|
||||
self.runCmd(
|
||||
"type summary add -s \"${var%pointer} -> ${*var%decimal}\" \"int *\"")
|
||||
|
||||
self.expect("expression new int(12)",
|
||||
substrs = ['(int *) $', '= 0x', ' -> 12'])
|
||||
substrs=['(int *) $', '= 0x', ' -> 12'])
|
||||
|
||||
self.expect("expression foo1.a_ptr",
|
||||
substrs = ['(int *) $', '= 0x', ' -> 13'])
|
||||
substrs=['(int *) $', '= 0x', ' -> 13'])
|
||||
|
||||
self.expect("expression foo1",
|
||||
substrs = ['(foo) $', ' a = 12', 'a_ptr = ', ' -> 13','i = 24','i_ptr = ', ' -> 25'])
|
||||
self.expect(
|
||||
"expression foo1",
|
||||
substrs=[
|
||||
'(foo) $',
|
||||
' a = 12',
|
||||
'a_ptr = ',
|
||||
' -> 13',
|
||||
'i = 24',
|
||||
'i_ptr = ',
|
||||
' -> 25'])
|
||||
|
||||
self.expect("expression --ptr-depth=1 -- new foo(47)",
|
||||
substrs = ['(foo *) $', 'a = 47','a_ptr = ', ' -> 48','i = 94','i_ptr = ', ' -> 95'])
|
||||
self.expect(
|
||||
"expression --ptr-depth=1 -- new foo(47)",
|
||||
substrs=[
|
||||
'(foo *) $',
|
||||
'a = 47',
|
||||
'a_ptr = ',
|
||||
' -> 48',
|
||||
'i = 94',
|
||||
'i_ptr = ',
|
||||
' -> 95'])
|
||||
|
||||
self.expect("expression foo2",
|
||||
substrs = ['(foo) $', 'a = 121','a_ptr = ', ' -> 122','i = 242','i_ptr = ', ' -> 243'])
|
||||
self.expect(
|
||||
"expression foo2",
|
||||
substrs=[
|
||||
'(foo) $',
|
||||
'a = 121',
|
||||
'a_ptr = ',
|
||||
' -> 122',
|
||||
'i = 242',
|
||||
'i_ptr = ',
|
||||
' -> 243'])
|
||||
|
||||
object_name = self.res.GetOutput()
|
||||
object_name = object_name[7:]
|
||||
object_name = object_name[0:object_name.find(' =')]
|
||||
|
||||
self.expect("frame variable foo2",
|
||||
substrs = ['(foo)', 'foo2', 'a = 121','a_ptr = ', ' -> 122','i = 242','i_ptr = ', ' -> 243'])
|
||||
|
||||
self.expect("expression $" + object_name,
|
||||
substrs = ['(foo) $', 'a = 121','a_ptr = ', ' -> 122','i = 242','i_ptr = ', ' -> 243', 'h = 245','k = 247'])
|
||||
self.expect(
|
||||
"frame variable foo2",
|
||||
substrs=[
|
||||
'(foo)',
|
||||
'foo2',
|
||||
'a = 121',
|
||||
'a_ptr = ',
|
||||
' -> 122',
|
||||
'i = 242',
|
||||
'i_ptr = ',
|
||||
' -> 243'])
|
||||
|
||||
self.expect(
|
||||
"expression $" +
|
||||
object_name,
|
||||
substrs=[
|
||||
'(foo) $',
|
||||
'a = 121',
|
||||
'a_ptr = ',
|
||||
' -> 122',
|
||||
'i = 242',
|
||||
'i_ptr = ',
|
||||
' -> 243',
|
||||
'h = 245',
|
||||
'k = 247'])
|
||||
|
||||
self.runCmd("type summary delete foo")
|
||||
self.runCmd("type synthetic add --python-class foosynth.FooSyntheticProvider foo")
|
||||
self.runCmd(
|
||||
"type synthetic add --python-class foosynth.FooSyntheticProvider foo")
|
||||
|
||||
self.expect("expression --show-types -- $" + object_name,
|
||||
substrs = ['(foo) $', ' = {', '(int) *i_ptr = 243'])
|
||||
substrs=['(foo) $', ' = {', '(int) *i_ptr = 243'])
|
||||
|
||||
self.runCmd("n")
|
||||
self.runCmd("n")
|
||||
@@ -101,31 +156,61 @@ class ExprFormattersTestCase(TestBase):
|
||||
self.runCmd("type synthetic delete foo")
|
||||
self.runCmd("type summary add -F formatters.foo_SummaryProvider foo")
|
||||
|
||||
self.expect("expression foo2",
|
||||
substrs = ['(foo) $', 'a = 7777','a_ptr = ', ' -> 122','i = 242','i_ptr = ', ' -> 8888'])
|
||||
self.expect(
|
||||
"expression foo2",
|
||||
substrs=[
|
||||
'(foo) $',
|
||||
'a = 7777',
|
||||
'a_ptr = ',
|
||||
' -> 122',
|
||||
'i = 242',
|
||||
'i_ptr = ',
|
||||
' -> 8888'])
|
||||
|
||||
self.expect("expression $" + object_name + '.a',
|
||||
substrs = ['7777'])
|
||||
substrs=['7777'])
|
||||
|
||||
self.expect("expression *$" + object_name + '.b.i_ptr',
|
||||
substrs = ['8888'])
|
||||
substrs=['8888'])
|
||||
|
||||
self.expect("expression $" + object_name,
|
||||
substrs = ['(foo) $', 'a = 121', 'a_ptr = ', ' -> 122', 'i = 242', 'i_ptr = ', ' -> 8888', 'h = 245','k = 247'])
|
||||
self.expect(
|
||||
"expression $" +
|
||||
object_name,
|
||||
substrs=[
|
||||
'(foo) $',
|
||||
'a = 121',
|
||||
'a_ptr = ',
|
||||
' -> 122',
|
||||
'i = 242',
|
||||
'i_ptr = ',
|
||||
' -> 8888',
|
||||
'h = 245',
|
||||
'k = 247'])
|
||||
|
||||
self.runCmd("type summary delete foo")
|
||||
self.runCmd("type synthetic add --python-class foosynth.FooSyntheticProvider foo")
|
||||
self.runCmd(
|
||||
"type synthetic add --python-class foosynth.FooSyntheticProvider foo")
|
||||
|
||||
self.expect("expression --show-types -- $" + object_name,
|
||||
substrs = ['(foo) $', ' = {', '(int) *i_ptr = 8888'])
|
||||
substrs=['(foo) $', ' = {', '(int) *i_ptr = 8888'])
|
||||
|
||||
self.runCmd("n")
|
||||
|
||||
self.runCmd("type synthetic delete foo")
|
||||
self.runCmd("type summary add -F formatters.foo_SummaryProvider foo")
|
||||
|
||||
self.expect("expression $" + object_name,
|
||||
substrs = ['(foo) $', 'a = 121','a_ptr = ', ' -> 122','i = 242', 'i_ptr = ', ' -> 8888','k = 247'])
|
||||
self.expect(
|
||||
"expression $" +
|
||||
object_name,
|
||||
substrs=[
|
||||
'(foo) $',
|
||||
'a = 121',
|
||||
'a_ptr = ',
|
||||
' -> 122',
|
||||
'i = 242',
|
||||
'i_ptr = ',
|
||||
' -> 8888',
|
||||
'k = 247'])
|
||||
|
||||
process = self.dbg.GetSelectedTarget().GetProcess()
|
||||
thread = process.GetThreadAtIndex(0)
|
||||
@@ -136,32 +221,78 @@ class ExprFormattersTestCase(TestBase):
|
||||
a_data = frozen.GetPointeeData()
|
||||
|
||||
error = lldb.SBError()
|
||||
self.assertTrue(a_data.GetUnsignedInt32(error, 0) == 122, '*a_ptr = 122')
|
||||
self.assertTrue(
|
||||
a_data.GetUnsignedInt32(
|
||||
error,
|
||||
0) == 122,
|
||||
'*a_ptr = 122')
|
||||
|
||||
self.runCmd("n");self.runCmd("n");self.runCmd("n");
|
||||
self.runCmd("n")
|
||||
self.runCmd("n")
|
||||
self.runCmd("n")
|
||||
|
||||
self.expect("frame variable numbers",
|
||||
substrs = ['1','2','3','4','5'])
|
||||
substrs=['1', '2', '3', '4', '5'])
|
||||
|
||||
self.expect("expression numbers",
|
||||
substrs = ['1','2','3','4','5'])
|
||||
substrs=['1', '2', '3', '4', '5'])
|
||||
|
||||
frozen = frame.EvaluateExpression("&numbers")
|
||||
|
||||
a_data = frozen.GetPointeeData(0, 1)
|
||||
|
||||
self.assertTrue(a_data.GetUnsignedInt32(error, 0) == 1, 'numbers[0] == 1')
|
||||
self.assertTrue(a_data.GetUnsignedInt32(error, 4) == 2, 'numbers[1] == 2')
|
||||
self.assertTrue(a_data.GetUnsignedInt32(error, 8) == 3, 'numbers[2] == 3')
|
||||
self.assertTrue(a_data.GetUnsignedInt32(error, 12) == 4, 'numbers[3] == 4')
|
||||
self.assertTrue(a_data.GetUnsignedInt32(error, 16) == 5, 'numbers[4] == 5')
|
||||
self.assertTrue(
|
||||
a_data.GetUnsignedInt32(
|
||||
error,
|
||||
0) == 1,
|
||||
'numbers[0] == 1')
|
||||
self.assertTrue(
|
||||
a_data.GetUnsignedInt32(
|
||||
error,
|
||||
4) == 2,
|
||||
'numbers[1] == 2')
|
||||
self.assertTrue(
|
||||
a_data.GetUnsignedInt32(
|
||||
error,
|
||||
8) == 3,
|
||||
'numbers[2] == 3')
|
||||
self.assertTrue(
|
||||
a_data.GetUnsignedInt32(
|
||||
error,
|
||||
12) == 4,
|
||||
'numbers[3] == 4')
|
||||
self.assertTrue(
|
||||
a_data.GetUnsignedInt32(
|
||||
error,
|
||||
16) == 5,
|
||||
'numbers[4] == 5')
|
||||
|
||||
frozen = frame.EvaluateExpression("numbers")
|
||||
|
||||
a_data = frozen.GetData()
|
||||
|
||||
self.assertTrue(a_data.GetUnsignedInt32(error, 0) == 1, 'numbers[0] == 1')
|
||||
self.assertTrue(a_data.GetUnsignedInt32(error, 4) == 2, 'numbers[1] == 2')
|
||||
self.assertTrue(a_data.GetUnsignedInt32(error, 8) == 3, 'numbers[2] == 3')
|
||||
self.assertTrue(a_data.GetUnsignedInt32(error, 12) == 4, 'numbers[3] == 4')
|
||||
self.assertTrue(a_data.GetUnsignedInt32(error, 16) == 5, 'numbers[4] == 5')
|
||||
self.assertTrue(
|
||||
a_data.GetUnsignedInt32(
|
||||
error,
|
||||
0) == 1,
|
||||
'numbers[0] == 1')
|
||||
self.assertTrue(
|
||||
a_data.GetUnsignedInt32(
|
||||
error,
|
||||
4) == 2,
|
||||
'numbers[1] == 2')
|
||||
self.assertTrue(
|
||||
a_data.GetUnsignedInt32(
|
||||
error,
|
||||
8) == 3,
|
||||
'numbers[2] == 3')
|
||||
self.assertTrue(
|
||||
a_data.GetUnsignedInt32(
|
||||
error,
|
||||
12) == 4,
|
||||
'numbers[3] == 4')
|
||||
self.assertTrue(
|
||||
a_data.GetUnsignedInt32(
|
||||
error,
|
||||
16) == 5,
|
||||
'numbers[4] == 5')
|
||||
|
||||
@@ -1,29 +1,33 @@
|
||||
import lldb
|
||||
|
||||
|
||||
class FooSyntheticProvider:
|
||||
def __init__(self,valobj,dict):
|
||||
self.valobj = valobj;
|
||||
self.update();
|
||||
|
||||
def update(self):
|
||||
self.adjust_for_architecture()
|
||||
def __init__(self, valobj, dict):
|
||||
self.valobj = valobj
|
||||
self.update()
|
||||
|
||||
def num_children(self):
|
||||
return 1;
|
||||
def update(self):
|
||||
self.adjust_for_architecture()
|
||||
|
||||
def get_child_at_index(self,index):
|
||||
if index != 0:
|
||||
return None;
|
||||
return self.i_ptr.Dereference();
|
||||
def num_children(self):
|
||||
return 1
|
||||
|
||||
def get_child_index(self,name):
|
||||
if name == "*i_ptr":
|
||||
return 0;
|
||||
return None;
|
||||
def get_child_at_index(self, index):
|
||||
if index != 0:
|
||||
return None
|
||||
return self.i_ptr.Dereference()
|
||||
|
||||
def adjust_for_architecture(self):
|
||||
self.lp64 = (self.valobj.GetTarget().GetProcess().GetAddressByteSize() == 8)
|
||||
self.is_little = (self.valobj.GetTarget().GetProcess().GetByteOrder() == lldb.eByteOrderLittle)
|
||||
self.pointer_size = self.valobj.GetTarget().GetProcess().GetAddressByteSize()
|
||||
self.bar = self.valobj.GetChildMemberWithName('b');
|
||||
self.i_ptr = self.bar.GetChildMemberWithName('i_ptr');
|
||||
def get_child_index(self, name):
|
||||
if name == "*i_ptr":
|
||||
return 0
|
||||
return None
|
||||
|
||||
def adjust_for_architecture(self):
|
||||
self.lp64 = (
|
||||
self.valobj.GetTarget().GetProcess().GetAddressByteSize() == 8)
|
||||
self.is_little = (self.valobj.GetTarget().GetProcess(
|
||||
).GetByteOrder() == lldb.eByteOrderLittle)
|
||||
self.pointer_size = self.valobj.GetTarget().GetProcess().GetAddressByteSize()
|
||||
self.bar = self.valobj.GetChildMemberWithName('b')
|
||||
self.i_ptr = self.bar.GetChildMemberWithName('i_ptr')
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
def foo_SummaryProvider (valobj,dict):
|
||||
a = valobj.GetChildMemberWithName('a');
|
||||
a_ptr = valobj.GetChildMemberWithName('a_ptr');
|
||||
bar = valobj.GetChildMemberWithName('b');
|
||||
i = bar.GetChildMemberWithName('i');
|
||||
i_ptr = bar.GetChildMemberWithName('i_ptr');
|
||||
b_ref = bar.GetChildMemberWithName('b_ref');
|
||||
b_ref_ptr = b_ref.AddressOf()
|
||||
b_ref = b_ref_ptr.Dereference()
|
||||
h = b_ref.GetChildMemberWithName('h');
|
||||
k = b_ref.GetChildMemberWithName('k');
|
||||
return 'a = ' + str(a.GetValueAsUnsigned(0)) + ', a_ptr = ' + \
|
||||
str(a_ptr.GetValueAsUnsigned(0)) + ' -> ' + str(a_ptr.Dereference().GetValueAsUnsigned(0)) + \
|
||||
', i = ' + str(i.GetValueAsUnsigned(0)) + \
|
||||
', i_ptr = ' + str(i_ptr.GetValueAsUnsigned(0)) + ' -> ' + str(i_ptr.Dereference().GetValueAsUnsigned(0)) + \
|
||||
', b_ref = ' + str(b_ref.GetValueAsUnsigned(0)) + \
|
||||
', h = ' + str(h.GetValueAsUnsigned(0)) + ' , k = ' + str(k.GetValueAsUnsigned(0))
|
||||
def foo_SummaryProvider(valobj, dict):
|
||||
a = valobj.GetChildMemberWithName('a')
|
||||
a_ptr = valobj.GetChildMemberWithName('a_ptr')
|
||||
bar = valobj.GetChildMemberWithName('b')
|
||||
i = bar.GetChildMemberWithName('i')
|
||||
i_ptr = bar.GetChildMemberWithName('i_ptr')
|
||||
b_ref = bar.GetChildMemberWithName('b_ref')
|
||||
b_ref_ptr = b_ref.AddressOf()
|
||||
b_ref = b_ref_ptr.Dereference()
|
||||
h = b_ref.GetChildMemberWithName('h')
|
||||
k = b_ref.GetChildMemberWithName('k')
|
||||
return 'a = ' + str(a.GetValueAsUnsigned(0)) + ', a_ptr = ' + \
|
||||
str(a_ptr.GetValueAsUnsigned(0)) + ' -> ' + str(a_ptr.Dereference().GetValueAsUnsigned(0)) + \
|
||||
', i = ' + str(i.GetValueAsUnsigned(0)) + \
|
||||
', i_ptr = ' + str(i_ptr.GetValueAsUnsigned(0)) + ' -> ' + str(i_ptr.Dereference().GetValueAsUnsigned(0)) + \
|
||||
', b_ref = ' + str(b_ref.GetValueAsUnsigned(0)) + \
|
||||
', h = ' + str(h.GetValueAsUnsigned(0)) + ' , k = ' + str(k.GetValueAsUnsigned(0))
|
||||
|
||||
@@ -2,38 +2,41 @@
|
||||
Test PHI nodes work in the IR interpreter.
|
||||
"""
|
||||
|
||||
import os, os.path
|
||||
import os
|
||||
import os.path
|
||||
|
||||
import lldb
|
||||
from lldbsuite.test.lldbtest import *
|
||||
import lldbsuite.test.lldbutil as lldbutil
|
||||
|
||||
|
||||
class IRInterpreterPHINodesTestCase(TestBase):
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
|
||||
def test_phi_node_support(self):
|
||||
"""Test support for PHI nodes in the IR interpreter."""
|
||||
|
||||
|
||||
self.build()
|
||||
exe = os.path.join(os.getcwd(), 'a.out')
|
||||
self.runCmd('file ' + exe, CURRENT_EXECUTABLE_SET)
|
||||
|
||||
|
||||
# Break on the first assignment to i
|
||||
line = line_number('main.cpp', 'i = 5')
|
||||
lldbutil.run_break_set_by_file_and_line(self, 'main.cpp', line, num_expected_locations=1, loc_exact=True)
|
||||
|
||||
lldbutil.run_break_set_by_file_and_line(
|
||||
self, 'main.cpp', line, num_expected_locations=1, loc_exact=True)
|
||||
|
||||
self.runCmd('run', RUN_SUCCEEDED)
|
||||
|
||||
|
||||
# The stop reason of the thread should be breakpoint
|
||||
self.expect('thread list', STOPPED_DUE_TO_BREAKPOINT,
|
||||
substrs = ['stopped', 'stop reason = breakpoint'])
|
||||
|
||||
substrs=['stopped', 'stop reason = breakpoint'])
|
||||
|
||||
self.runCmd('s')
|
||||
|
||||
|
||||
# The logical 'or' causes a PHI node to be generated. Execute without JIT
|
||||
# to test that the interpreter can handle this
|
||||
self.expect('expr -j 0 -- i == 3 || i == 5', substrs=['true'])
|
||||
|
||||
|
||||
self.runCmd('s')
|
||||
self.expect('expr -j 0 -- i == 3 || i == 5', substrs=['false'])
|
||||
self.runCmd('s')
|
||||
|
||||
@@ -6,12 +6,14 @@ from __future__ import print_function
|
||||
|
||||
import unittest2
|
||||
|
||||
import os, time
|
||||
import os
|
||||
import time
|
||||
import lldb
|
||||
from lldbsuite.test.decorators import *
|
||||
from lldbsuite.test.lldbtest import *
|
||||
from lldbsuite.test import lldbutil
|
||||
|
||||
|
||||
class IRInterpreterTestCase(TestBase):
|
||||
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
@@ -25,7 +27,8 @@ class IRInterpreterTestCase(TestBase):
|
||||
|
||||
# Disable confirmation prompt to avoid infinite wait
|
||||
self.runCmd("settings set auto-confirm true")
|
||||
self.addTearDownHook(lambda: self.runCmd("settings clear auto-confirm"))
|
||||
self.addTearDownHook(
|
||||
lambda: self.runCmd("settings clear auto-confirm"))
|
||||
|
||||
def build_and_run(self):
|
||||
"""Test the IR interpreter"""
|
||||
@@ -33,13 +36,20 @@ class IRInterpreterTestCase(TestBase):
|
||||
|
||||
self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
|
||||
|
||||
lldbutil.run_break_set_by_file_and_line (self, "main.c", self.line, num_expected_locations=1, loc_exact=False)
|
||||
lldbutil.run_break_set_by_file_and_line(
|
||||
self, "main.c", self.line, num_expected_locations=1, loc_exact=False)
|
||||
|
||||
self.runCmd("run", RUN_SUCCEEDED)
|
||||
|
||||
@add_test_categories(['pyapi'])
|
||||
@expectedFailureAll(oslist=['windows'], bugnumber="http://llvm.org/pr21765") # getpid() is POSIX, among other problems, see bug
|
||||
@expectedFailureAll(oslist=['linux'], archs=['arm'], bugnumber="llvm.org/pr27868")
|
||||
# getpid() is POSIX, among other problems, see bug
|
||||
@expectedFailureAll(
|
||||
oslist=['windows'],
|
||||
bugnumber="http://llvm.org/pr21765")
|
||||
@expectedFailureAll(
|
||||
oslist=['linux'],
|
||||
archs=['arm'],
|
||||
bugnumber="llvm.org/pr27868")
|
||||
def test_ir_interpreter(self):
|
||||
self.build_and_run()
|
||||
|
||||
@@ -62,11 +72,16 @@ class IRInterpreterTestCase(TestBase):
|
||||
self.frame().EvaluateExpression(expression, options)
|
||||
|
||||
for expression in expressions:
|
||||
interp_expression = expression
|
||||
jit_expression = "(int)getpid(); " + expression
|
||||
interp_expression = expression
|
||||
jit_expression = "(int)getpid(); " + expression
|
||||
|
||||
interp_result = self.frame().EvaluateExpression(interp_expression, options).GetValueAsSigned()
|
||||
jit_result = self.frame().EvaluateExpression(jit_expression, options).GetValueAsSigned()
|
||||
|
||||
self.assertEqual(interp_result, jit_result, "While evaluating " + expression)
|
||||
interp_result = self.frame().EvaluateExpression(
|
||||
interp_expression, options).GetValueAsSigned()
|
||||
jit_result = self.frame().EvaluateExpression(
|
||||
jit_expression, options).GetValueAsSigned()
|
||||
|
||||
self.assertEqual(
|
||||
interp_result,
|
||||
jit_result,
|
||||
"While evaluating " +
|
||||
expression)
|
||||
|
||||
@@ -7,13 +7,14 @@ expected in a SyntheticChildrenProvider
|
||||
from __future__ import print_function
|
||||
|
||||
|
||||
|
||||
import os, time
|
||||
import os
|
||||
import time
|
||||
import lldb
|
||||
from lldbsuite.test.decorators import *
|
||||
from lldbsuite.test.lldbtest import *
|
||||
from lldbsuite.test import lldbutil
|
||||
|
||||
|
||||
class Issue11581TestCase(TestBase):
|
||||
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
@@ -25,54 +26,61 @@ class Issue11581TestCase(TestBase):
|
||||
def cleanup():
|
||||
self.runCmd('type synthetic clear', check=False)
|
||||
|
||||
|
||||
# Execute the cleanup function during test case tear down.
|
||||
self.addTearDownHook(cleanup)
|
||||
|
||||
"""valobj.AddressOf() should return correct values."""
|
||||
self.build()
|
||||
|
||||
|
||||
exe = os.path.join(os.getcwd(), "a.out")
|
||||
|
||||
|
||||
target = self.dbg.CreateTarget(exe)
|
||||
self.assertTrue(target, VALID_TARGET)
|
||||
|
||||
breakpoint = target.BreakpointCreateBySourceRegex('Set breakpoint here.',lldb.SBFileSpec ("main.cpp", False))
|
||||
|
||||
process = target.LaunchSimple (None, None, self.get_process_working_directory())
|
||||
self.assertTrue (process, "Created a process.")
|
||||
self.assertTrue (process.GetState() == lldb.eStateStopped, "Stopped it too.")
|
||||
breakpoint = target.BreakpointCreateBySourceRegex(
|
||||
'Set breakpoint here.', lldb.SBFileSpec("main.cpp", False))
|
||||
|
||||
thread_list = lldbutil.get_threads_stopped_at_breakpoint (process, breakpoint)
|
||||
self.assertTrue (len(thread_list) == 1)
|
||||
process = target.LaunchSimple(
|
||||
None, None, self.get_process_working_directory())
|
||||
self.assertTrue(process, "Created a process.")
|
||||
self.assertTrue(
|
||||
process.GetState() == lldb.eStateStopped,
|
||||
"Stopped it too.")
|
||||
|
||||
thread_list = lldbutil.get_threads_stopped_at_breakpoint(
|
||||
process, breakpoint)
|
||||
self.assertTrue(len(thread_list) == 1)
|
||||
thread = thread_list[0]
|
||||
|
||||
self.runCmd("command script import --allow-reload s11588.py")
|
||||
self.runCmd("type synthetic add --python-class s11588.Issue11581SyntheticProvider StgClosure")
|
||||
self.runCmd(
|
||||
"type synthetic add --python-class s11588.Issue11581SyntheticProvider StgClosure")
|
||||
|
||||
self.expect("expr --show-types -- *((StgClosure*)(r14-1))",
|
||||
substrs = ["(StgClosure) $",
|
||||
"(StgClosure *) &$","0x",
|
||||
"addr = ",
|
||||
"load_address = "])
|
||||
substrs=["(StgClosure) $",
|
||||
"(StgClosure *) &$", "0x",
|
||||
"addr = ",
|
||||
"load_address = "])
|
||||
|
||||
# register r14 is an x86_64 extension let's skip this part of the test
|
||||
# if we are on a different architecture
|
||||
if self.getArchitecture() == 'x86_64':
|
||||
target = lldb.debugger.GetSelectedTarget()
|
||||
process = target.GetProcess()
|
||||
frame = process.GetSelectedThread().GetSelectedFrame()
|
||||
pointer = frame.FindVariable("r14")
|
||||
addr = pointer.GetValueAsUnsigned(0)
|
||||
self.assertTrue(addr != 0, "could not read pointer to StgClosure")
|
||||
addr = addr - 1
|
||||
self.runCmd("register write r14 %d" % addr)
|
||||
self.expect("register read r14",
|
||||
substrs = ["0x",hex(addr)[2:].rstrip("L")]) # Remove trailing 'L' if it exists
|
||||
self.expect("expr --show-types -- *(StgClosure*)$r14",
|
||||
substrs = ["(StgClosure) $",
|
||||
"(StgClosure *) &$","0x",
|
||||
"addr = ",
|
||||
"load_address = ",
|
||||
hex(addr)[2:].rstrip("L"),
|
||||
str(addr)])
|
||||
target = lldb.debugger.GetSelectedTarget()
|
||||
process = target.GetProcess()
|
||||
frame = process.GetSelectedThread().GetSelectedFrame()
|
||||
pointer = frame.FindVariable("r14")
|
||||
addr = pointer.GetValueAsUnsigned(0)
|
||||
self.assertTrue(addr != 0, "could not read pointer to StgClosure")
|
||||
addr = addr - 1
|
||||
self.runCmd("register write r14 %d" % addr)
|
||||
self.expect(
|
||||
"register read r14", substrs=[
|
||||
"0x", hex(addr)[
|
||||
2:].rstrip("L")]) # Remove trailing 'L' if it exists
|
||||
self.expect("expr --show-types -- *(StgClosure*)$r14",
|
||||
substrs=["(StgClosure) $",
|
||||
"(StgClosure *) &$", "0x",
|
||||
"addr = ",
|
||||
"load_address = ",
|
||||
hex(addr)[2:].rstrip("L"),
|
||||
str(addr)])
|
||||
|
||||
@@ -1,26 +1,28 @@
|
||||
class Issue11581SyntheticProvider(object):
|
||||
def __init__(self, valobj, dict):
|
||||
self.valobj = valobj
|
||||
self.addrOf = valobj.AddressOf()
|
||||
self.addr = valobj.GetAddress()
|
||||
self.load_address = valobj.GetLoadAddress()
|
||||
|
||||
def num_children(self):
|
||||
return 3;
|
||||
def __init__(self, valobj, dict):
|
||||
self.valobj = valobj
|
||||
self.addrOf = valobj.AddressOf()
|
||||
self.addr = valobj.GetAddress()
|
||||
self.load_address = valobj.GetLoadAddress()
|
||||
|
||||
def get_child_at_index(self, index):
|
||||
if index == 0:
|
||||
return self.addrOf
|
||||
if index == 1:
|
||||
return self.valobj.CreateValueFromExpression("addr", str(self.addr))
|
||||
if index == 2:
|
||||
return self.valobj.CreateValueFromExpression("load_address", str(self.load_address))
|
||||
def num_children(self):
|
||||
return 3
|
||||
|
||||
def get_child_index(self, name):
|
||||
if name == "addrOf":
|
||||
return 0
|
||||
if name == "addr":
|
||||
return 1
|
||||
if name == "load_address":
|
||||
return 2
|
||||
def get_child_at_index(self, index):
|
||||
if index == 0:
|
||||
return self.addrOf
|
||||
if index == 1:
|
||||
return self.valobj.CreateValueFromExpression(
|
||||
"addr", str(self.addr))
|
||||
if index == 2:
|
||||
return self.valobj.CreateValueFromExpression(
|
||||
"load_address", str(self.load_address))
|
||||
|
||||
def get_child_index(self, name):
|
||||
if name == "addrOf":
|
||||
return 0
|
||||
if name == "addr":
|
||||
return 1
|
||||
if name == "load_address":
|
||||
return 2
|
||||
|
||||
@@ -6,13 +6,21 @@ from lldbsuite.test.decorators import *
|
||||
from lldbsuite.test.lldbtest import *
|
||||
from lldbsuite.test import lldbutil
|
||||
|
||||
|
||||
class TestMacros(TestBase):
|
||||
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
|
||||
@expectedFailureAll(compiler="clang", bugnumber="clang does not emit .debug_macro[.dwo] sections.")
|
||||
@expectedFailureAll(debug_info="dwo", bugnumber="GCC produces multiple .debug_macro.dwo sections and the spec is unclear as to what it means")
|
||||
@expectedFailureAll(hostoslist=["windows"], compiler="gcc", triple='.*-android')
|
||||
@expectedFailureAll(
|
||||
compiler="clang",
|
||||
bugnumber="clang does not emit .debug_macro[.dwo] sections.")
|
||||
@expectedFailureAll(
|
||||
debug_info="dwo",
|
||||
bugnumber="GCC produces multiple .debug_macro.dwo sections and the spec is unclear as to what it means")
|
||||
@expectedFailureAll(
|
||||
hostoslist=["windows"],
|
||||
compiler="gcc",
|
||||
triple='.*-android')
|
||||
def test_expr_with_macros(self):
|
||||
self.build()
|
||||
|
||||
@@ -25,7 +33,7 @@ class TestMacros(TestBase):
|
||||
# Get the path of the executable
|
||||
cwd = os.getcwd()
|
||||
exe_file = "a.out"
|
||||
exe_path = os.path.join(cwd, exe_file)
|
||||
exe_path = os.path.join(cwd, exe_file)
|
||||
|
||||
# Load the executable
|
||||
target = self.dbg.CreateTarget(exe_path)
|
||||
@@ -33,51 +41,78 @@ class TestMacros(TestBase):
|
||||
|
||||
# Set breakpoints
|
||||
bp1 = target.BreakpointCreateBySourceRegex("Break here", src_file_spec)
|
||||
self.assertTrue(bp1.IsValid() and bp1.GetNumLocations() >= 1, VALID_BREAKPOINT)
|
||||
self.assertTrue(
|
||||
bp1.IsValid() and bp1.GetNumLocations() >= 1,
|
||||
VALID_BREAKPOINT)
|
||||
|
||||
# Launch the process
|
||||
process = target.LaunchSimple(None, None, self.get_process_working_directory())
|
||||
process = target.LaunchSimple(
|
||||
None, None, self.get_process_working_directory())
|
||||
self.assertTrue(process.IsValid(), PROCESS_IS_VALID)
|
||||
|
||||
# Get the thread of the process
|
||||
self.assertTrue(process.GetState() == lldb.eStateStopped, PROCESS_STOPPED)
|
||||
thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint)
|
||||
self.assertTrue(
|
||||
process.GetState() == lldb.eStateStopped,
|
||||
PROCESS_STOPPED)
|
||||
thread = lldbutil.get_stopped_thread(
|
||||
process, lldb.eStopReasonBreakpoint)
|
||||
|
||||
# Get frame for current thread
|
||||
frame = thread.GetSelectedFrame()
|
||||
|
||||
result = frame.EvaluateExpression("MACRO_1")
|
||||
self.assertTrue(result.IsValid() and result.GetValue() == "100", "MACRO_1 = 100")
|
||||
self.assertTrue(
|
||||
result.IsValid() and result.GetValue() == "100",
|
||||
"MACRO_1 = 100")
|
||||
|
||||
result = frame.EvaluateExpression("MACRO_2")
|
||||
self.assertTrue(result.IsValid() and result.GetValue() == "200", "MACRO_2 = 200")
|
||||
self.assertTrue(
|
||||
result.IsValid() and result.GetValue() == "200",
|
||||
"MACRO_2 = 200")
|
||||
|
||||
result = frame.EvaluateExpression("ONE")
|
||||
self.assertTrue(result.IsValid() and result.GetValue() == "1", "ONE = 1")
|
||||
self.assertTrue(
|
||||
result.IsValid() and result.GetValue() == "1",
|
||||
"ONE = 1")
|
||||
|
||||
result = frame.EvaluateExpression("TWO")
|
||||
self.assertTrue(result.IsValid() and result.GetValue() == "2", "TWO = 2")
|
||||
self.assertTrue(
|
||||
result.IsValid() and result.GetValue() == "2",
|
||||
"TWO = 2")
|
||||
|
||||
result = frame.EvaluateExpression("THREE")
|
||||
self.assertTrue(result.IsValid() and result.GetValue() == "3", "THREE = 3")
|
||||
self.assertTrue(
|
||||
result.IsValid() and result.GetValue() == "3",
|
||||
"THREE = 3")
|
||||
|
||||
result = frame.EvaluateExpression("FOUR")
|
||||
self.assertTrue(result.IsValid() and result.GetValue() == "4", "FOUR = 4")
|
||||
self.assertTrue(
|
||||
result.IsValid() and result.GetValue() == "4",
|
||||
"FOUR = 4")
|
||||
|
||||
result = frame.EvaluateExpression("HUNDRED")
|
||||
self.assertTrue(result.IsValid() and result.GetValue() == "100", "HUNDRED = 100")
|
||||
self.assertTrue(
|
||||
result.IsValid() and result.GetValue() == "100",
|
||||
"HUNDRED = 100")
|
||||
|
||||
result = frame.EvaluateExpression("THOUSAND")
|
||||
self.assertTrue(result.IsValid() and result.GetValue() == "1000", "THOUSAND = 1000")
|
||||
self.assertTrue(
|
||||
result.IsValid() and result.GetValue() == "1000",
|
||||
"THOUSAND = 1000")
|
||||
|
||||
result = frame.EvaluateExpression("MILLION")
|
||||
self.assertTrue(result.IsValid() and result.GetValue() == "1000000", "MILLION = 1000000")
|
||||
self.assertTrue(result.IsValid() and result.GetValue()
|
||||
== "1000000", "MILLION = 1000000")
|
||||
|
||||
result = frame.EvaluateExpression("MAX(ONE, TWO)")
|
||||
self.assertTrue(result.IsValid() and result.GetValue() == "2", "MAX(ONE, TWO) = 2")
|
||||
self.assertTrue(
|
||||
result.IsValid() and result.GetValue() == "2",
|
||||
"MAX(ONE, TWO) = 2")
|
||||
|
||||
result = frame.EvaluateExpression("MAX(THREE, TWO)")
|
||||
self.assertTrue(result.IsValid() and result.GetValue() == "3", "MAX(THREE, TWO) = 3")
|
||||
self.assertTrue(
|
||||
result.IsValid() and result.GetValue() == "3",
|
||||
"MAX(THREE, TWO) = 3")
|
||||
|
||||
# Get the thread of the process
|
||||
thread.StepOver()
|
||||
@@ -86,10 +121,14 @@ class TestMacros(TestBase):
|
||||
frame = thread.GetSelectedFrame()
|
||||
|
||||
result = frame.EvaluateExpression("MACRO_2")
|
||||
self.assertTrue(result.GetError().Fail(), "Printing MACRO_2 fails in the mail file")
|
||||
self.assertTrue(
|
||||
result.GetError().Fail(),
|
||||
"Printing MACRO_2 fails in the mail file")
|
||||
|
||||
result = frame.EvaluateExpression("FOUR")
|
||||
self.assertTrue(result.GetError().Fail(), "Printing FOUR fails in the main file")
|
||||
self.assertTrue(
|
||||
result.GetError().Fail(),
|
||||
"Printing FOUR fails in the main file")
|
||||
|
||||
thread.StepInto()
|
||||
|
||||
@@ -97,14 +136,20 @@ class TestMacros(TestBase):
|
||||
frame = thread.GetSelectedFrame()
|
||||
|
||||
result = frame.EvaluateExpression("ONE")
|
||||
self.assertTrue(result.IsValid() and result.GetValue() == "1", "ONE = 1")
|
||||
self.assertTrue(
|
||||
result.IsValid() and result.GetValue() == "1",
|
||||
"ONE = 1")
|
||||
|
||||
result = frame.EvaluateExpression("MAX(ONE, TWO)")
|
||||
self.assertTrue(result.IsValid() and result.GetValue() == "2", "MAX(ONE, TWO) = 2")
|
||||
self.assertTrue(
|
||||
result.IsValid() and result.GetValue() == "2",
|
||||
"MAX(ONE, TWO) = 2")
|
||||
|
||||
# This time, MACRO_1 and MACRO_2 are not visible.
|
||||
result = frame.EvaluateExpression("MACRO_1")
|
||||
self.assertTrue(result.GetError().Fail(), "Printing MACRO_1 fails in the header file")
|
||||
self.assertTrue(result.GetError().Fail(),
|
||||
"Printing MACRO_1 fails in the header file")
|
||||
|
||||
result = frame.EvaluateExpression("MACRO_2")
|
||||
self.assertTrue(result.GetError().Fail(), "Printing MACRO_2 fails in the header file")
|
||||
self.assertTrue(result.GetError().Fail(),
|
||||
"Printing MACRO_2 fails in the header file")
|
||||
|
||||
@@ -8,6 +8,7 @@ from lldbsuite.test.decorators import *
|
||||
from lldbsuite.test.lldbtest import *
|
||||
from lldbsuite.test import lldbutil
|
||||
|
||||
|
||||
class MultilineExpressionsTestCase(TestBase):
|
||||
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
@@ -19,7 +20,9 @@ class MultilineExpressionsTestCase(TestBase):
|
||||
self.line = line_number('main.c', 'break')
|
||||
|
||||
@skipIfRemote
|
||||
@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")
|
||||
def test_with_run_commands(self):
|
||||
"""Test that multiline expressions work correctly"""
|
||||
self.build()
|
||||
@@ -28,7 +31,9 @@ class MultilineExpressionsTestCase(TestBase):
|
||||
prompt = "(lldb) "
|
||||
|
||||
# So that the child gets torn down after the test.
|
||||
self.child = pexpect.spawn('%s %s %s' % (lldbtest_config.lldbExec, self.lldbOption, exe))
|
||||
self.child = pexpect.spawn(
|
||||
'%s %s %s' %
|
||||
(lldbtest_config.lldbExec, self.lldbOption, exe))
|
||||
child = self.child
|
||||
# Turn on logging for what the child sends back.
|
||||
if self.TraceOn():
|
||||
@@ -54,4 +59,4 @@ class MultilineExpressionsTestCase(TestBase):
|
||||
child.sendline('')
|
||||
child.expect_exact(prompt)
|
||||
self.expect(child.before, exe=False,
|
||||
patterns = ['= 5'])
|
||||
patterns=['= 5'])
|
||||
|
||||
@@ -10,12 +10,13 @@ o test_expr_options:
|
||||
from __future__ import print_function
|
||||
|
||||
|
||||
|
||||
import os, time
|
||||
import os
|
||||
import time
|
||||
import lldb
|
||||
import lldbsuite.test.lldbutil as lldbutil
|
||||
from lldbsuite.test.lldbtest import *
|
||||
|
||||
|
||||
class ExprOptionsTestCase(TestBase):
|
||||
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
@@ -25,7 +26,7 @@ class ExprOptionsTestCase(TestBase):
|
||||
TestBase.setUp(self)
|
||||
|
||||
self.main_source = "main.cpp"
|
||||
self.main_source_spec = lldb.SBFileSpec (self.main_source)
|
||||
self.main_source_spec = lldb.SBFileSpec(self.main_source)
|
||||
self.line = line_number('main.cpp', '// breakpoint_in_main')
|
||||
self.exe = os.path.join(os.getcwd(), "a.out")
|
||||
|
||||
@@ -41,14 +42,17 @@ class ExprOptionsTestCase(TestBase):
|
||||
self.assertTrue(target, VALID_TARGET)
|
||||
|
||||
# Set breakpoints inside main.
|
||||
breakpoint = target.BreakpointCreateBySourceRegex('// breakpoint_in_main', self.main_source_spec)
|
||||
breakpoint = target.BreakpointCreateBySourceRegex(
|
||||
'// breakpoint_in_main', self.main_source_spec)
|
||||
self.assertTrue(breakpoint)
|
||||
|
||||
# Now launch the process, and do not stop at entry point.
|
||||
process = target.LaunchSimple(None, None, self.get_process_working_directory())
|
||||
process = target.LaunchSimple(
|
||||
None, None, self.get_process_working_directory())
|
||||
self.assertTrue(process, PROCESS_IS_VALID)
|
||||
|
||||
threads = lldbutil.get_threads_stopped_at_breakpoint(process, breakpoint)
|
||||
threads = lldbutil.get_threads_stopped_at_breakpoint(
|
||||
process, breakpoint)
|
||||
self.assertEqual(len(threads), 1)
|
||||
|
||||
frame = threads[0].GetFrameAtIndex(0)
|
||||
|
||||
@@ -5,12 +5,12 @@ Test that we can p *objcObject
|
||||
from __future__ import print_function
|
||||
|
||||
|
||||
|
||||
import lldb
|
||||
from lldbsuite.test.decorators import *
|
||||
from lldbsuite.test.lldbtest import *
|
||||
from lldbsuite.test import lldbutil
|
||||
|
||||
|
||||
class PersistObjCPointeeType(TestBase):
|
||||
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
@@ -19,7 +19,7 @@ class PersistObjCPointeeType(TestBase):
|
||||
# Call super's setUp().
|
||||
TestBase.setUp(self)
|
||||
# Find the line number to break for main.cpp.
|
||||
self.line = line_number('main.m','// break here')
|
||||
self.line = line_number('main.m', '// break here')
|
||||
|
||||
@skipUnlessDarwin
|
||||
@expectedFailureAll(
|
||||
@@ -37,15 +37,16 @@ class PersistObjCPointeeType(TestBase):
|
||||
|
||||
self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
|
||||
|
||||
lldbutil.run_break_set_by_file_and_line (self, "main.m", self.line, loc_exact=True)
|
||||
lldbutil.run_break_set_by_file_and_line(
|
||||
self, "main.m", self.line, loc_exact=True)
|
||||
|
||||
self.runCmd("run", RUN_SUCCEEDED)
|
||||
|
||||
|
||||
self.expect("p *self", substrs=['_sc_name = nil',
|
||||
'_sc_name2 = nil',
|
||||
'_sc_name3 = nil',
|
||||
'_sc_name4 = nil',
|
||||
'_sc_name5 = nil',
|
||||
'_sc_name6 = nil',
|
||||
'_sc_name7 = nil',
|
||||
'_sc_name8 = nil'])
|
||||
'_sc_name2 = nil',
|
||||
'_sc_name3 = nil',
|
||||
'_sc_name4 = nil',
|
||||
'_sc_name5 = nil',
|
||||
'_sc_name6 = nil',
|
||||
'_sc_name7 = nil',
|
||||
'_sc_name8 = nil'])
|
||||
|
||||
@@ -5,11 +5,11 @@ Test that we can have persistent pointer variables
|
||||
from __future__ import print_function
|
||||
|
||||
|
||||
|
||||
import lldb
|
||||
import lldbsuite.test.lldbutil as lldbutil
|
||||
from lldbsuite.test.lldbtest import *
|
||||
|
||||
|
||||
class PersistentPtrUpdateTestCase(TestBase):
|
||||
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
@@ -24,18 +24,18 @@ class PersistentPtrUpdateTestCase(TestBase):
|
||||
|
||||
def cleanup():
|
||||
pass
|
||||
|
||||
|
||||
# Execute the cleanup function during test case tear down.
|
||||
self.addTearDownHook(cleanup)
|
||||
|
||||
self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
|
||||
|
||||
|
||||
self.runCmd('break set -p here')
|
||||
|
||||
self.runCmd("run", RUN_SUCCEEDED)
|
||||
|
||||
|
||||
self.runCmd("expr void* $foo = 0")
|
||||
|
||||
|
||||
self.runCmd("continue")
|
||||
|
||||
self.expect("expr $foo", substrs=['$foo','0x0'])
|
||||
|
||||
self.expect("expr $foo", substrs=['$foo', '0x0'])
|
||||
|
||||
@@ -5,13 +5,14 @@ Test that nested persistent types work.
|
||||
from __future__ import print_function
|
||||
|
||||
|
||||
|
||||
import os, time
|
||||
import os
|
||||
import time
|
||||
import lldb
|
||||
from lldbsuite.test.decorators import *
|
||||
from lldbsuite.test.lldbtest import *
|
||||
from lldbsuite.test import lldbutil
|
||||
|
||||
|
||||
class NestedPersistentTypesTestCase(TestBase):
|
||||
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
@@ -29,15 +30,16 @@ class NestedPersistentTypesTestCase(TestBase):
|
||||
|
||||
self.runCmd("expression struct $foo { int a; int b; };")
|
||||
|
||||
self.runCmd("expression struct $bar { struct $foo start; struct $foo end; };")
|
||||
self.runCmd(
|
||||
"expression struct $bar { struct $foo start; struct $foo end; };")
|
||||
|
||||
self.runCmd("expression struct $bar $my_bar = {{ 2, 3 }, { 4, 5 }};")
|
||||
|
||||
self.expect("expression $my_bar",
|
||||
substrs = ['a = 2', 'b = 3', 'a = 4', 'b = 5'])
|
||||
substrs=['a = 2', 'b = 3', 'a = 4', 'b = 5'])
|
||||
|
||||
self.expect("expression $my_bar.start.b",
|
||||
substrs = ['(int)', '3'])
|
||||
substrs=['(int)', '3'])
|
||||
|
||||
self.expect("expression $my_bar.end.b",
|
||||
substrs = ['(int)', '5'])
|
||||
substrs=['(int)', '5'])
|
||||
|
||||
@@ -5,13 +5,14 @@ Test that lldb persistent types works correctly.
|
||||
from __future__ import print_function
|
||||
|
||||
|
||||
|
||||
import os, time
|
||||
import os
|
||||
import time
|
||||
import lldb
|
||||
from lldbsuite.test.decorators import *
|
||||
from lldbsuite.test.lldbtest import *
|
||||
from lldbsuite.test import lldbutil
|
||||
|
||||
|
||||
class PersistenttypesTestCase(TestBase):
|
||||
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
@@ -29,31 +30,57 @@ class PersistenttypesTestCase(TestBase):
|
||||
|
||||
self.runCmd("expression struct $foo { int a; int b; };")
|
||||
|
||||
self.expect("expression struct $foo $my_foo; $my_foo.a = 2; $my_foo.b = 3;",
|
||||
startstr = "(int) $0 = 3")
|
||||
self.expect(
|
||||
"expression struct $foo $my_foo; $my_foo.a = 2; $my_foo.b = 3;",
|
||||
startstr="(int) $0 = 3")
|
||||
|
||||
self.expect("expression $my_foo",
|
||||
substrs = ['a = 2', 'b = 3'])
|
||||
substrs=['a = 2', 'b = 3'])
|
||||
|
||||
self.runCmd("expression typedef int $bar")
|
||||
|
||||
self.expect("expression $bar i = 5; i",
|
||||
startstr = "($bar) $1 = 5")
|
||||
startstr="($bar) $1 = 5")
|
||||
|
||||
self.runCmd("expression struct $foobar { char a; char b; char c; char d; };")
|
||||
self.runCmd(
|
||||
"expression struct $foobar { char a; char b; char c; char d; };")
|
||||
self.runCmd("next")
|
||||
|
||||
self.expect("memory read foo -t $foobar",
|
||||
substrs = ['($foobar) 0x', ' = ', "a = 'H'","b = 'e'","c = 'l'","d = 'l'"]) # persistent types are OK to use for memory read
|
||||
self.expect(
|
||||
"memory read foo -t $foobar",
|
||||
substrs=[
|
||||
'($foobar) 0x',
|
||||
' = ',
|
||||
"a = 'H'",
|
||||
"b = 'e'",
|
||||
"c = 'l'",
|
||||
"d = 'l'"]) # persistent types are OK to use for memory read
|
||||
|
||||
self.expect("memory read foo -t foobar",
|
||||
substrs = ['($foobar) 0x', ' = ', "a = 'H'","b = 'e'","c = 'l'","d = 'l'"],matching=False,error=True) # the type name is $foobar, make sure we settle for nothing less
|
||||
self.expect(
|
||||
"memory read foo -t foobar",
|
||||
substrs=[
|
||||
'($foobar) 0x',
|
||||
' = ',
|
||||
"a = 'H'",
|
||||
"b = 'e'",
|
||||
"c = 'l'",
|
||||
"d = 'l'"],
|
||||
matching=False,
|
||||
error=True) # the type name is $foobar, make sure we settle for nothing less
|
||||
|
||||
self.expect("expression struct { int a; int b; } x = { 2, 3 }; x",
|
||||
substrs = ['a = 2', 'b = 3'])
|
||||
substrs=['a = 2', 'b = 3'])
|
||||
|
||||
self.expect("expression struct { int x; int y; int z; } object; object.y = 1; object.z = 3; object.x = 2; object",
|
||||
substrs = ['x = 2', 'y = 1', 'z = 3'])
|
||||
self.expect(
|
||||
"expression struct { int x; int y; int z; } object; object.y = 1; object.z = 3; object.x = 2; object",
|
||||
substrs=[
|
||||
'x = 2',
|
||||
'y = 1',
|
||||
'z = 3'])
|
||||
|
||||
self.expect("expression struct A { int x; int y; }; struct { struct A a; int z; } object; object.a.y = 1; object.z = 3; object.a.x = 2; object",
|
||||
substrs = ['x = 2', 'y = 1', 'z = 3'])
|
||||
self.expect(
|
||||
"expression struct A { int x; int y; }; struct { struct A a; int z; } object; object.a.y = 1; object.z = 3; object.a.x = 2; object",
|
||||
substrs=[
|
||||
'x = 2',
|
||||
'y = 1',
|
||||
'z = 3'])
|
||||
|
||||
@@ -5,11 +5,12 @@ Test that lldb persistent variables works correctly.
|
||||
from __future__ import print_function
|
||||
|
||||
|
||||
|
||||
import os, time
|
||||
import os
|
||||
import time
|
||||
import lldb
|
||||
from lldbsuite.test.lldbtest import *
|
||||
|
||||
|
||||
class PersistentVariablesTestCase(TestBase):
|
||||
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
@@ -27,28 +28,28 @@ class PersistentVariablesTestCase(TestBase):
|
||||
self.runCmd("expression int $i = i")
|
||||
|
||||
self.expect("expression $i == i",
|
||||
startstr = "(bool) $0 = true")
|
||||
startstr="(bool) $0 = true")
|
||||
|
||||
self.expect("expression $i + 1",
|
||||
startstr = "(int) $1 = 6")
|
||||
startstr="(int) $1 = 6")
|
||||
|
||||
self.expect("expression $i + 3",
|
||||
startstr = "(int) $2 = 8")
|
||||
startstr="(int) $2 = 8")
|
||||
|
||||
self.expect("expression $2 + $1",
|
||||
startstr = "(int) $3 = 14")
|
||||
startstr="(int) $3 = 14")
|
||||
|
||||
self.expect("expression $3",
|
||||
startstr = "(int) $3 = 14")
|
||||
startstr="(int) $3 = 14")
|
||||
|
||||
self.expect("expression $2",
|
||||
startstr = "(int) $2 = 8")
|
||||
startstr="(int) $2 = 8")
|
||||
|
||||
self.expect("expression (int)-2",
|
||||
startstr = "(int) $4 = -2")
|
||||
startstr="(int) $4 = -2")
|
||||
|
||||
self.expect("expression $4 > (int)31",
|
||||
startstr = "(bool) $5 = false")
|
||||
startstr="(bool) $5 = false")
|
||||
|
||||
self.expect("expression (long)$4",
|
||||
startstr = "(long) $6 = -2")
|
||||
startstr="(long) $6 = -2")
|
||||
|
||||
@@ -5,12 +5,12 @@ Test that the po command acts correctly.
|
||||
from __future__ import print_function
|
||||
|
||||
|
||||
|
||||
import lldb
|
||||
from lldbsuite.test.decorators import *
|
||||
from lldbsuite.test.lldbtest import *
|
||||
from lldbsuite.test import lldbutil
|
||||
|
||||
|
||||
class PoVerbosityTestCase(TestBase):
|
||||
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
@@ -26,37 +26,38 @@ class PoVerbosityTestCase(TestBase):
|
||||
def test(self):
|
||||
"""Test that the po command acts correctly."""
|
||||
self.build()
|
||||
|
||||
|
||||
# This is the function to remove the custom formats in order to have a
|
||||
# clean slate for the next test case.
|
||||
def cleanup():
|
||||
self.runCmd('type summary clear', check=False)
|
||||
self.runCmd('type synthetic clear', check=False)
|
||||
|
||||
|
||||
# Execute the cleanup function during test case tear down.
|
||||
self.addTearDownHook(cleanup)
|
||||
|
||||
"""Test expr + formatters for good interoperability."""
|
||||
self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
|
||||
|
||||
lldbutil.run_break_set_by_file_and_line (self, "main.m", self.line, loc_exact=True)
|
||||
lldbutil.run_break_set_by_file_and_line(
|
||||
self, "main.m", self.line, loc_exact=True)
|
||||
|
||||
self.runCmd("run", RUN_SUCCEEDED)
|
||||
|
||||
self.expect("expr -O -v -- foo",
|
||||
substrs = ['(id) $',' = 0x', '1 = 2','2 = 3;'])
|
||||
self.expect("expr -O -vfull -- foo",
|
||||
substrs = ['(id) $',' = 0x', '1 = 2','2 = 3;'])
|
||||
self.expect("expr -O -- foo",matching=False,
|
||||
substrs = ['(id) $'])
|
||||
|
||||
self.expect("expr -O -- 22",matching=False,
|
||||
substrs = ['(int) $'])
|
||||
self.expect("expr -O -v -- foo",
|
||||
substrs=['(id) $', ' = 0x', '1 = 2', '2 = 3;'])
|
||||
self.expect("expr -O -vfull -- foo",
|
||||
substrs=['(id) $', ' = 0x', '1 = 2', '2 = 3;'])
|
||||
self.expect("expr -O -- foo", matching=False,
|
||||
substrs=['(id) $'])
|
||||
|
||||
self.expect("expr -O -- 22", matching=False,
|
||||
substrs=['(int) $'])
|
||||
self.expect("expr -O -- 22",
|
||||
substrs = ['22'])
|
||||
substrs=['22'])
|
||||
|
||||
self.expect("expr -O -vfull -- 22",
|
||||
substrs = ['(int) $', ' = 22'])
|
||||
substrs=['(int) $', ' = 22'])
|
||||
|
||||
self.expect("expr -O -v -- 22",
|
||||
substrs = ['(int) $', ' = 22'])
|
||||
substrs=['(int) $', ' = 22'])
|
||||
|
||||
@@ -5,11 +5,12 @@ Test the robustness of lldb expression parser.
|
||||
from __future__ import print_function
|
||||
|
||||
|
||||
|
||||
import os, time
|
||||
import os
|
||||
import time
|
||||
import lldb
|
||||
from lldbsuite.test.lldbtest import *
|
||||
|
||||
|
||||
class Radar8638051TestCase(TestBase):
|
||||
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
@@ -25,15 +26,15 @@ class Radar8638051TestCase(TestBase):
|
||||
self.runCmd("run", RUN_SUCCEEDED)
|
||||
|
||||
self.expect("expression val",
|
||||
startstr = "(int) $0 = 1")
|
||||
startstr="(int) $0 = 1")
|
||||
# (int) $0 = 1
|
||||
|
||||
self.expect("expression *(&val)",
|
||||
startstr = "(int) $1 = 1")
|
||||
startstr="(int) $1 = 1")
|
||||
# (int) $1 = 1
|
||||
|
||||
# rdar://problem/8638051
|
||||
# lldb expression command: Could this crash be avoided
|
||||
self.expect("expression &val",
|
||||
startstr = "(int *) $2 = ")
|
||||
startstr="(int *) $2 = ")
|
||||
# (int *) $2 = 0x....
|
||||
|
||||
@@ -5,13 +5,14 @@ The evaluating printf(...) after break stop and then up a stack frame.
|
||||
from __future__ import print_function
|
||||
|
||||
|
||||
|
||||
import os, time
|
||||
import os
|
||||
import time
|
||||
import lldb
|
||||
from lldbsuite.test.decorators import *
|
||||
from lldbsuite.test.lldbtest import *
|
||||
from lldbsuite.test import lldbutil
|
||||
|
||||
|
||||
class Radar9531204TestCase(TestBase):
|
||||
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
@@ -24,7 +25,8 @@ class Radar9531204TestCase(TestBase):
|
||||
|
||||
self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
|
||||
|
||||
lldbutil.run_break_set_by_symbol (self, 'foo', sym_exact=True, num_expected_locations=1)
|
||||
lldbutil.run_break_set_by_symbol(
|
||||
self, 'foo', sym_exact=True, num_expected_locations=1)
|
||||
|
||||
self.runCmd("run", RUN_SUCCEEDED)
|
||||
|
||||
@@ -35,7 +37,7 @@ class Radar9531204TestCase(TestBase):
|
||||
|
||||
# rdar://problem/9531204
|
||||
# "Error dematerializing struct" error when evaluating expressions "up" on the stack
|
||||
self.runCmd('up') # frame select -r 1
|
||||
self.runCmd('up') # frame select -r 1
|
||||
|
||||
self.runCmd("frame variable")
|
||||
|
||||
|
||||
@@ -5,13 +5,14 @@ Test example snippets from the lldb 'help expression' output.
|
||||
from __future__ import print_function
|
||||
|
||||
|
||||
|
||||
import os, time
|
||||
import os
|
||||
import time
|
||||
import lldb
|
||||
from lldbsuite.test.decorators import *
|
||||
from lldbsuite.test.lldbtest import *
|
||||
from lldbsuite.test import lldbutil
|
||||
|
||||
|
||||
class Radar9673644TestCase(TestBase):
|
||||
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
@@ -30,13 +31,18 @@ class Radar9673644TestCase(TestBase):
|
||||
|
||||
self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
|
||||
|
||||
lldbutil.run_break_set_by_file_and_line (self, self.main_source, self.line, num_expected_locations=1, loc_exact=True)
|
||||
lldbutil.run_break_set_by_file_and_line(
|
||||
self,
|
||||
self.main_source,
|
||||
self.line,
|
||||
num_expected_locations=1,
|
||||
loc_exact=True)
|
||||
|
||||
self.runCmd("run", RUN_SUCCEEDED)
|
||||
|
||||
# rdar://problem/9673664 lldb expression evaluation problem
|
||||
|
||||
self.expect('expr char c[] = "foo"; c[0]',
|
||||
substrs = ["'f'"])
|
||||
substrs=["'f'"])
|
||||
# runCmd: expr char c[] = "foo"; c[0]
|
||||
# output: (char) $0 = 'f'
|
||||
|
||||
@@ -14,15 +14,16 @@ o test_expr_commands_can_handle_quotes:
|
||||
from __future__ import print_function
|
||||
|
||||
|
||||
|
||||
import unittest2
|
||||
|
||||
import os, time
|
||||
import os
|
||||
import time
|
||||
import lldb
|
||||
from lldbsuite.test.decorators import *
|
||||
from lldbsuite.test.lldbtest import *
|
||||
from lldbsuite.test import lldbutil
|
||||
|
||||
|
||||
class BasicExprCommandsTestCase(TestBase):
|
||||
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
@@ -31,13 +32,14 @@ class BasicExprCommandsTestCase(TestBase):
|
||||
# Call super's setUp().
|
||||
TestBase.setUp(self)
|
||||
# Find the line number to break for main.c.
|
||||
self.line = line_number('main.cpp',
|
||||
'// Please test many expressions while stopped at this line:')
|
||||
self.line = line_number(
|
||||
'main.cpp',
|
||||
'// Please test many expressions while stopped at this line:')
|
||||
|
||||
# Disable confirmation prompt to avoid infinite wait
|
||||
self.runCmd("settings set auto-confirm true")
|
||||
self.addTearDownHook(lambda: self.runCmd("settings clear auto-confirm"))
|
||||
|
||||
self.addTearDownHook(
|
||||
lambda: self.runCmd("settings clear auto-confirm"))
|
||||
|
||||
def build_and_run(self):
|
||||
"""These basic expression commands should work as expected."""
|
||||
@@ -45,56 +47,58 @@ class BasicExprCommandsTestCase(TestBase):
|
||||
|
||||
self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
|
||||
|
||||
lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=False)
|
||||
lldbutil.run_break_set_by_file_and_line(
|
||||
self, "main.cpp", self.line, num_expected_locations=1, loc_exact=False)
|
||||
|
||||
self.runCmd("run", RUN_SUCCEEDED)
|
||||
|
||||
@unittest2.expectedFailure("llvm.org/pr17135 <rdar://problem/14874559> APFloat::toString does not identify the correct (i.e. least) precision.")
|
||||
@unittest2.expectedFailure(
|
||||
"llvm.org/pr17135 <rdar://problem/14874559> APFloat::toString does not identify the correct (i.e. least) precision.")
|
||||
def test_floating_point_expr_commands(self):
|
||||
self.build_and_run()
|
||||
|
||||
self.expect("expression 2.234f",
|
||||
patterns = ["\(float\) \$.* = 2\.234"])
|
||||
patterns=["\(float\) \$.* = 2\.234"])
|
||||
# (float) $2 = 2.234
|
||||
|
||||
def test_many_expr_commands(self):
|
||||
self.build_and_run()
|
||||
|
||||
self.expect("expression 2",
|
||||
patterns = ["\(int\) \$.* = 2"])
|
||||
patterns=["\(int\) \$.* = 2"])
|
||||
# (int) $0 = 1
|
||||
|
||||
self.expect("expression 2ull",
|
||||
patterns = ["\(unsigned long long\) \$.* = 2"])
|
||||
patterns=["\(unsigned long long\) \$.* = 2"])
|
||||
# (unsigned long long) $1 = 2
|
||||
|
||||
self.expect("expression 0.5f",
|
||||
patterns = ["\(float\) \$.* = 0\.5"])
|
||||
patterns=["\(float\) \$.* = 0\.5"])
|
||||
# (float) $2 = 0.5
|
||||
|
||||
self.expect("expression 2.234",
|
||||
patterns = ["\(double\) \$.* = 2\.234"])
|
||||
patterns=["\(double\) \$.* = 2\.234"])
|
||||
# (double) $3 = 2.234
|
||||
|
||||
self.expect("expression 2+3",
|
||||
patterns = ["\(int\) \$.* = 5"])
|
||||
patterns=["\(int\) \$.* = 5"])
|
||||
# (int) $4 = 5
|
||||
|
||||
self.expect("expression argc",
|
||||
patterns = ["\(int\) \$.* = 1"])
|
||||
patterns=["\(int\) \$.* = 1"])
|
||||
# (int) $5 = 1
|
||||
|
||||
self.expect("expression argc + 22",
|
||||
patterns = ["\(int\) \$.* = 23"])
|
||||
patterns=["\(int\) \$.* = 23"])
|
||||
# (int) $6 = 23
|
||||
|
||||
self.expect("expression argv",
|
||||
patterns = ["\(const char \*\*\) \$.* = 0x"])
|
||||
patterns=["\(const char \*\*\) \$.* = 0x"])
|
||||
# (const char *) $7 = ...
|
||||
|
||||
self.expect("expression argv[0]",
|
||||
substrs = ["(const char *)",
|
||||
"a.out"])
|
||||
substrs=["(const char *)",
|
||||
"a.out"])
|
||||
# (const char *) $8 = 0x... "/Volumes/data/lldb/svn/trunk/test/expression_command/test/a.out"
|
||||
|
||||
@add_test_categories(['pyapi'])
|
||||
@@ -115,12 +119,13 @@ class BasicExprCommandsTestCase(TestBase):
|
||||
|
||||
# Verify the breakpoint just created.
|
||||
self.expect(str(breakpoint), BREAKPOINT_CREATED, exe=False,
|
||||
substrs = ['main.cpp',
|
||||
str(self.line)])
|
||||
substrs=['main.cpp',
|
||||
str(self.line)])
|
||||
|
||||
# Launch the process, and do not stop at the entry point.
|
||||
# Pass 'X Y Z' as the args, which makes argc == 4.
|
||||
process = target.LaunchSimple (['X', 'Y', 'Z'], None, self.get_process_working_directory())
|
||||
process = target.LaunchSimple(
|
||||
['X', 'Y', 'Z'], None, self.get_process_working_directory())
|
||||
|
||||
if not process:
|
||||
self.fail("SBTarget.LaunchProcess() failed")
|
||||
@@ -130,16 +135,18 @@ class BasicExprCommandsTestCase(TestBase):
|
||||
"instead the actual state is: '%s'" %
|
||||
lldbutil.state_type_to_str(process.GetState()))
|
||||
|
||||
thread = lldbutil.get_one_thread_stopped_at_breakpoint(process, breakpoint)
|
||||
self.assertIsNotNone(thread, "Expected one thread to be stopped at the breakpoint")
|
||||
thread = lldbutil.get_one_thread_stopped_at_breakpoint(
|
||||
process, breakpoint)
|
||||
self.assertIsNotNone(
|
||||
thread, "Expected one thread to be stopped at the breakpoint")
|
||||
|
||||
# The filename of frame #0 should be 'main.cpp' and function is main.
|
||||
self.expect(lldbutil.get_filenames(thread)[0],
|
||||
"Break correctly at main.cpp", exe=False,
|
||||
startstr = "main.cpp")
|
||||
startstr="main.cpp")
|
||||
self.expect(lldbutil.get_function_names(thread)[0],
|
||||
"Break correctly at main()", exe=False,
|
||||
startstr = "main")
|
||||
startstr="main")
|
||||
|
||||
# We should be stopped on the breakpoint with a hit count of 1.
|
||||
self.assertTrue(breakpoint.GetHitCount() == 1, BREAKPOINT_HIT_ONCE)
|
||||
@@ -151,49 +158,51 @@ class BasicExprCommandsTestCase(TestBase):
|
||||
|
||||
val = frame.EvaluateExpression("2.234")
|
||||
self.expect(val.GetValue(), "2.345 evaluated correctly", exe=False,
|
||||
startstr = "2.234")
|
||||
startstr="2.234")
|
||||
self.expect(val.GetTypeName(), "2.345 evaluated correctly", exe=False,
|
||||
startstr = "double")
|
||||
startstr="double")
|
||||
self.DebugSBValue(val)
|
||||
|
||||
val = frame.EvaluateExpression("argc")
|
||||
self.expect(val.GetValue(), "Argc evaluated correctly", exe=False,
|
||||
startstr = "4")
|
||||
startstr="4")
|
||||
self.DebugSBValue(val)
|
||||
|
||||
val = frame.EvaluateExpression("*argv[1]")
|
||||
self.expect(val.GetValue(), "Argv[1] evaluated correctly", exe=False,
|
||||
startstr = "'X'")
|
||||
startstr="'X'")
|
||||
self.DebugSBValue(val)
|
||||
|
||||
val = frame.EvaluateExpression("*argv[2]")
|
||||
self.expect(val.GetValue(), "Argv[2] evaluated correctly", exe=False,
|
||||
startstr = "'Y'")
|
||||
startstr="'Y'")
|
||||
self.DebugSBValue(val)
|
||||
|
||||
val = frame.EvaluateExpression("*argv[3]")
|
||||
self.expect(val.GetValue(), "Argv[3] evaluated correctly", exe=False,
|
||||
startstr = "'Z'")
|
||||
startstr="'Z'")
|
||||
self.DebugSBValue(val)
|
||||
|
||||
callee_break = target.BreakpointCreateByName ("a_function_to_call", None)
|
||||
callee_break = target.BreakpointCreateByName(
|
||||
"a_function_to_call", None)
|
||||
self.assertTrue(callee_break.GetNumLocations() > 0)
|
||||
|
||||
# Make sure ignoring breakpoints works from the command line:
|
||||
self.expect("expression -i true -- a_function_to_call()",
|
||||
substrs = ['(int) $', ' 1'])
|
||||
self.assertTrue (callee_break.GetHitCount() == 1)
|
||||
substrs=['(int) $', ' 1'])
|
||||
self.assertTrue(callee_break.GetHitCount() == 1)
|
||||
|
||||
# Now try ignoring breakpoints using the SB API's:
|
||||
options = lldb.SBExpressionOptions()
|
||||
options.SetIgnoreBreakpoints(True)
|
||||
value = frame.EvaluateExpression('a_function_to_call()', options)
|
||||
self.assertTrue (value.IsValid())
|
||||
self.assertTrue (value.GetValueAsSigned(0) == 2)
|
||||
self.assertTrue (callee_break.GetHitCount() == 2)
|
||||
self.assertTrue(value.IsValid())
|
||||
self.assertTrue(value.GetValueAsSigned(0) == 2)
|
||||
self.assertTrue(callee_break.GetHitCount() == 2)
|
||||
|
||||
# rdar://problem/8686536
|
||||
# CommandInterpreter::HandleCommand is stripping \'s from input for WantsRawCommand commands
|
||||
# CommandInterpreter::HandleCommand is stripping \'s from input for
|
||||
# WantsRawCommand commands
|
||||
@expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr21765")
|
||||
def test_expr_commands_can_handle_quotes(self):
|
||||
"""Throw some expression commands with quotes at lldb."""
|
||||
@@ -201,44 +210,46 @@ class BasicExprCommandsTestCase(TestBase):
|
||||
|
||||
self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
|
||||
|
||||
lldbutil.run_break_set_by_file_and_line(self, "main.cpp", self.line, num_expected_locations=1,loc_exact=False)
|
||||
lldbutil.run_break_set_by_file_and_line(
|
||||
self, "main.cpp", self.line, num_expected_locations=1, loc_exact=False)
|
||||
|
||||
self.runCmd("run", RUN_SUCCEEDED)
|
||||
|
||||
# runCmd: expression 'a'
|
||||
# output: (char) $0 = 'a'
|
||||
self.expect("expression 'a'",
|
||||
substrs = ['(char) $',
|
||||
"'a'"])
|
||||
substrs=['(char) $',
|
||||
"'a'"])
|
||||
|
||||
# runCmd: expression (int) printf ("\n\n\tHello there!\n")
|
||||
# output: (int) $1 = 16
|
||||
self.expect(r'''expression (int) printf ("\n\n\tHello there!\n")''',
|
||||
substrs = ['(int) $',
|
||||
'16'])
|
||||
substrs=['(int) $',
|
||||
'16'])
|
||||
|
||||
# runCmd: expression (int) printf("\t\x68\n")
|
||||
# output: (int) $2 = 3
|
||||
self.expect(r'''expression (int) printf("\t\x68\n")''',
|
||||
substrs = ['(int) $',
|
||||
'3'])
|
||||
substrs=['(int) $',
|
||||
'3'])
|
||||
|
||||
# runCmd: expression (int) printf("\"\n")
|
||||
# output: (int) $3 = 2
|
||||
self.expect(r'''expression (int) printf("\"\n")''',
|
||||
substrs = ['(int) $',
|
||||
'2'])
|
||||
substrs=['(int) $',
|
||||
'2'])
|
||||
|
||||
# runCmd: expression (int) printf("'\n")
|
||||
# output: (int) $4 = 2
|
||||
self.expect(r'''expression (int) printf("'\n")''',
|
||||
substrs = ['(int) $',
|
||||
'2'])
|
||||
substrs=['(int) $',
|
||||
'2'])
|
||||
|
||||
# runCmd: command alias print_hi expression (int) printf ("\n\tHi!\n")
|
||||
# output:
|
||||
self.runCmd(r'''command alias print_hi expression (int) printf ("\n\tHi!\n")''')
|
||||
# output:
|
||||
self.runCmd(
|
||||
r'''command alias print_hi expression (int) printf ("\n\tHi!\n")''')
|
||||
# This fails currently.
|
||||
self.expect('print_hi',
|
||||
substrs = ['(int) $',
|
||||
'6'])
|
||||
substrs=['(int) $',
|
||||
'6'])
|
||||
|
||||
@@ -5,13 +5,13 @@ Test some more expression commands.
|
||||
from __future__ import print_function
|
||||
|
||||
|
||||
|
||||
import os
|
||||
import lldb
|
||||
from lldbsuite.test.decorators import *
|
||||
from lldbsuite.test.lldbtest import *
|
||||
from lldbsuite.test import lldbutil
|
||||
|
||||
|
||||
class ExprCommands2TestCase(TestBase):
|
||||
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
@@ -20,42 +20,46 @@ class ExprCommands2TestCase(TestBase):
|
||||
# Call super's setUp().
|
||||
TestBase.setUp(self)
|
||||
# Find the line number to break for main.c.
|
||||
self.line = line_number('main.cpp',
|
||||
'// Please test many expressions while stopped at this line:')
|
||||
self.line = line_number(
|
||||
'main.cpp',
|
||||
'// Please test many expressions while stopped at this line:')
|
||||
|
||||
@expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24489: Name lookup not working correctly on Windows")
|
||||
@expectedFailureAll(
|
||||
oslist=["windows"],
|
||||
bugnumber="llvm.org/pr24489: Name lookup not working correctly on Windows")
|
||||
def test_more_expr_commands(self):
|
||||
"""Test some more expression commands."""
|
||||
self.build()
|
||||
|
||||
self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
|
||||
|
||||
lldbutil.run_break_set_by_file_and_line(self, "main.cpp", self.line, num_expected_locations=1,loc_exact=False)
|
||||
lldbutil.run_break_set_by_file_and_line(
|
||||
self, "main.cpp", self.line, num_expected_locations=1, loc_exact=False)
|
||||
|
||||
self.runCmd("run", RUN_SUCCEEDED)
|
||||
|
||||
# Does static casting work?
|
||||
self.expect("expression (int*)argv",
|
||||
startstr = "(int *) $0 = 0x")
|
||||
startstr="(int *) $0 = 0x")
|
||||
# (int *) $0 = 0x00007fff5fbff258
|
||||
|
||||
# Do anonymous symbols work?
|
||||
self.expect("expression ((char**)environ)[0]",
|
||||
startstr = "(char *) $1 = 0x")
|
||||
startstr="(char *) $1 = 0x")
|
||||
# (char *) $1 = 0x00007fff5fbff298 "Apple_PubSub_Socket_Render=/tmp/launch-7AEsUD/Render"
|
||||
|
||||
# Do return values containing the contents of expression locals work?
|
||||
self.expect("expression int i = 5; i",
|
||||
startstr = "(int) $2 = 5")
|
||||
startstr="(int) $2 = 5")
|
||||
# (int) $2 = 5
|
||||
self.expect("expression $2 + 1",
|
||||
startstr = "(int) $3 = 6")
|
||||
startstr="(int) $3 = 6")
|
||||
# (int) $3 = 6
|
||||
|
||||
# Do return values containing the results of static expressions work?
|
||||
self.expect("expression 20 + 3",
|
||||
startstr = "(int) $4 = 23")
|
||||
startstr="(int) $4 = 23")
|
||||
# (int) $4 = 5
|
||||
self.expect("expression $4 + 1",
|
||||
startstr = "(int) $5 = 24")
|
||||
startstr="(int) $5 = 24")
|
||||
# (int) $5 = 6
|
||||
|
||||
@@ -5,12 +5,12 @@ Test calling a function that waits a while, and make sure the timeout option to
|
||||
from __future__ import print_function
|
||||
|
||||
|
||||
|
||||
import lldb
|
||||
from lldbsuite.test.decorators import *
|
||||
from lldbsuite.test.lldbtest import *
|
||||
from lldbsuite.test import lldbutil
|
||||
|
||||
|
||||
class ExprCommandWithTimeoutsTestCase(TestBase):
|
||||
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
@@ -20,11 +20,14 @@ class ExprCommandWithTimeoutsTestCase(TestBase):
|
||||
TestBase.setUp(self)
|
||||
|
||||
self.main_source = "wait-a-while.cpp"
|
||||
self.main_source_spec = lldb.SBFileSpec (self.main_source)
|
||||
|
||||
self.main_source_spec = lldb.SBFileSpec(self.main_source)
|
||||
|
||||
@expectedFlakeyFreeBSD("llvm.org/pr19605")
|
||||
@expectedFailureAll(oslist=["windows", "macosx"], bugnumber="llvm.org/pr21765")
|
||||
@expectedFailureAll(
|
||||
oslist=[
|
||||
"windows",
|
||||
"macosx"],
|
||||
bugnumber="llvm.org/pr21765")
|
||||
def test(self):
|
||||
"""Test calling std::String member function."""
|
||||
self.build()
|
||||
@@ -35,58 +38,65 @@ class ExprCommandWithTimeoutsTestCase(TestBase):
|
||||
target = self.dbg.CreateTarget(exe)
|
||||
self.assertTrue(target, VALID_TARGET)
|
||||
|
||||
breakpoint = target.BreakpointCreateBySourceRegex('stop here in main.',self.main_source_spec)
|
||||
breakpoint = target.BreakpointCreateBySourceRegex(
|
||||
'stop here in main.', self.main_source_spec)
|
||||
self.assertTrue(breakpoint, VALID_BREAKPOINT)
|
||||
self.runCmd("breakpoint list")
|
||||
|
||||
# Launch the process, and do not stop at the entry point.
|
||||
process = target.LaunchSimple (None, None, self.get_process_working_directory())
|
||||
process = target.LaunchSimple(
|
||||
None, None, self.get_process_working_directory())
|
||||
|
||||
self.assertTrue(process, PROCESS_IS_VALID)
|
||||
|
||||
# Frame #0 should be on self.step_out_of_malloc.
|
||||
threads = lldbutil.get_threads_stopped_at_breakpoint (process, breakpoint)
|
||||
|
||||
threads = lldbutil.get_threads_stopped_at_breakpoint(
|
||||
process, breakpoint)
|
||||
|
||||
self.assertTrue(len(threads) == 1)
|
||||
thread = threads[0]
|
||||
|
||||
|
||||
# First set the timeout too short, and make sure we fail.
|
||||
options = lldb.SBExpressionOptions()
|
||||
options.SetTimeoutInMicroSeconds(10)
|
||||
options.SetUnwindOnError(True)
|
||||
|
||||
frame = thread.GetFrameAtIndex(0)
|
||||
|
||||
value = frame.EvaluateExpression("wait_a_while(1000000)", options)
|
||||
self.assertTrue (value.IsValid())
|
||||
self.assertFalse (value.GetError().Success())
|
||||
|
||||
# Now do the same thing with the command line command, and make sure it works too.
|
||||
value = frame.EvaluateExpression("wait_a_while(1000000)", options)
|
||||
self.assertTrue(value.IsValid())
|
||||
self.assertFalse(value.GetError().Success())
|
||||
|
||||
# Now do the same thing with the command line command, and make sure it
|
||||
# works too.
|
||||
interp = self.dbg.GetCommandInterpreter()
|
||||
|
||||
result = lldb.SBCommandReturnObject()
|
||||
return_value = interp.HandleCommand("expr -t 100 -u true -- wait_a_while(1000000)", result)
|
||||
self.assertTrue (return_value == lldb.eReturnStatusFailed)
|
||||
return_value = interp.HandleCommand(
|
||||
"expr -t 100 -u true -- wait_a_while(1000000)", result)
|
||||
self.assertTrue(return_value == lldb.eReturnStatusFailed)
|
||||
|
||||
# Okay, now do it again with long enough time outs:
|
||||
|
||||
options.SetTimeoutInMicroSeconds(1000000)
|
||||
value = frame.EvaluateExpression ("wait_a_while (1000)", options)
|
||||
value = frame.EvaluateExpression("wait_a_while (1000)", options)
|
||||
self.assertTrue(value.IsValid())
|
||||
self.assertTrue (value.GetError().Success() == True)
|
||||
|
||||
# Now do the same thingwith the command line command, and make sure it works too.
|
||||
self.assertTrue(value.GetError().Success())
|
||||
|
||||
# Now do the same thingwith the command line command, and make sure it
|
||||
# works too.
|
||||
interp = self.dbg.GetCommandInterpreter()
|
||||
|
||||
result = lldb.SBCommandReturnObject()
|
||||
return_value = interp.HandleCommand ("expr -t 1000000 -u true -- wait_a_while(1000)", result)
|
||||
return_value = interp.HandleCommand(
|
||||
"expr -t 1000000 -u true -- wait_a_while(1000)", result)
|
||||
self.assertTrue(return_value == lldb.eReturnStatusSuccessFinishResult)
|
||||
|
||||
|
||||
# Finally set the one thread timeout and make sure that doesn't change things much:
|
||||
# Finally set the one thread timeout and make sure that doesn't change
|
||||
# things much:
|
||||
|
||||
options.SetTimeoutInMicroSeconds(1000000)
|
||||
options.SetOneThreadTimeoutInMicroSeconds(500000)
|
||||
value = frame.EvaluateExpression ("wait_a_while (1000)", options)
|
||||
value = frame.EvaluateExpression("wait_a_while (1000)", options)
|
||||
self.assertTrue(value.IsValid())
|
||||
self.assertTrue (value.GetError().Success() == True)
|
||||
self.assertTrue(value.GetError().Success())
|
||||
|
||||
@@ -5,15 +5,16 @@ Test top-level expressions.
|
||||
from __future__ import print_function
|
||||
|
||||
|
||||
|
||||
import unittest2
|
||||
|
||||
import os, time
|
||||
import os
|
||||
import time
|
||||
import lldb
|
||||
from lldbsuite.test.decorators import *
|
||||
from lldbsuite.test.lldbtest import *
|
||||
from lldbsuite.test import lldbutil
|
||||
|
||||
|
||||
class TopLevelExpressionsTestCase(TestBase):
|
||||
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
@@ -29,8 +30,8 @@ class TopLevelExpressionsTestCase(TestBase):
|
||||
|
||||
# Disable confirmation prompt to avoid infinite wait
|
||||
self.runCmd("settings set auto-confirm true")
|
||||
self.addTearDownHook(lambda: self.runCmd("settings clear auto-confirm"))
|
||||
|
||||
self.addTearDownHook(
|
||||
lambda: self.runCmd("settings clear auto-confirm"))
|
||||
|
||||
def build_and_run(self):
|
||||
"""Test top-level expressions."""
|
||||
@@ -38,23 +39,43 @@ class TopLevelExpressionsTestCase(TestBase):
|
||||
|
||||
self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
|
||||
|
||||
lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=False)
|
||||
lldbutil.run_break_set_by_file_and_line(
|
||||
self, "main.cpp", self.line, num_expected_locations=1, loc_exact=False)
|
||||
|
||||
self.runCmd("run", RUN_SUCCEEDED)
|
||||
|
||||
def run_dummy(self):
|
||||
self.runCmd("file dummy", CURRENT_EXECUTABLE_SET)
|
||||
|
||||
lldbutil.run_break_set_by_file_and_line (self, "dummy.cpp", self.dummy_line, num_expected_locations=1, loc_exact=False)
|
||||
lldbutil.run_break_set_by_file_and_line(
|
||||
self,
|
||||
"dummy.cpp",
|
||||
self.dummy_line,
|
||||
num_expected_locations=1,
|
||||
loc_exact=False)
|
||||
|
||||
self.runCmd("run", RUN_SUCCEEDED)
|
||||
|
||||
@add_test_categories(['pyapi'])
|
||||
@expectedFailureAndroid(api_levels=[21, 22], bugnumber="llvm.org/pr27787")
|
||||
@expectedFailureAll(oslist=["linux"], archs=["arm", "aarch64"], bugnumber="llvm.org/pr27787")
|
||||
@expectedFailureAll(bugnumber="llvm.org/pr28353", oslist=["linux"], archs=["i386", "x86_64"], compiler="gcc", compiler_version=["<", "4.9"])
|
||||
@skipIf(debug_info="gmodules") # not relevant
|
||||
@skipIf(oslist=["windows"]) # Error in record layout on Windows
|
||||
@expectedFailureAll(
|
||||
oslist=["linux"],
|
||||
archs=[
|
||||
"arm",
|
||||
"aarch64"],
|
||||
bugnumber="llvm.org/pr27787")
|
||||
@expectedFailureAll(
|
||||
bugnumber="llvm.org/pr28353",
|
||||
oslist=["linux"],
|
||||
archs=[
|
||||
"i386",
|
||||
"x86_64"],
|
||||
compiler="gcc",
|
||||
compiler_version=[
|
||||
"<",
|
||||
"4.9"])
|
||||
@skipIf(debug_info="gmodules") # not relevant
|
||||
@skipIf(oslist=["windows"]) # Error in record layout on Windows
|
||||
def test_top_level_expressions(self):
|
||||
self.build_and_run()
|
||||
|
||||
@@ -86,4 +107,6 @@ class TopLevelExpressionsTestCase(TestBase):
|
||||
resultFromTopLevel = self.frame().EvaluateExpression("doTest()")
|
||||
|
||||
self.assertTrue(resultFromTopLevel.IsValid())
|
||||
self.assertEqual(resultFromCode, resultFromTopLevel.GetValueAsUnsigned())
|
||||
self.assertEqual(
|
||||
resultFromCode,
|
||||
resultFromTopLevel.GetValueAsUnsigned())
|
||||
|
||||
@@ -7,12 +7,12 @@ The expression parser's type search only looks in the current compilation unit f
|
||||
from __future__ import print_function
|
||||
|
||||
|
||||
|
||||
import lldb
|
||||
from lldbsuite.test.decorators import *
|
||||
from lldbsuite.test.lldbtest import *
|
||||
from lldbsuite.test import lldbutil
|
||||
|
||||
|
||||
class ObjCTypeQueryTestCase(TestBase):
|
||||
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
@@ -21,8 +21,8 @@ class ObjCTypeQueryTestCase(TestBase):
|
||||
# Call super's setUp().
|
||||
TestBase.setUp(self)
|
||||
# Find the line number to break for main.m.
|
||||
self.line = line_number('main.m',
|
||||
"// Set breakpoint here, then do 'expr (NSArray*)array_token'.")
|
||||
self.line = line_number(
|
||||
'main.m', "// Set breakpoint here, then do 'expr (NSArray*)array_token'.")
|
||||
|
||||
@skipUnlessDarwin
|
||||
def test(self):
|
||||
@@ -30,11 +30,12 @@ class ObjCTypeQueryTestCase(TestBase):
|
||||
self.build()
|
||||
self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
|
||||
|
||||
lldbutil.run_break_set_by_file_and_line (self, "main.m", self.line, num_expected_locations=1, loc_exact=True)
|
||||
lldbutil.run_break_set_by_file_and_line(
|
||||
self, "main.m", self.line, num_expected_locations=1, loc_exact=True)
|
||||
|
||||
self.runCmd("run", RUN_SUCCEEDED)
|
||||
|
||||
# Now do a NSArry type query from the 'main.m' compile uint.
|
||||
self.expect("expression (NSArray*)array_token",
|
||||
substrs = ['(NSArray *) $0 = 0x'])
|
||||
substrs=['(NSArray *) $0 = 0x'])
|
||||
# (NSArray *) $0 = 0x00007fff70118398
|
||||
|
||||
@@ -5,15 +5,16 @@ Test stopping at a breakpoint in an expression, and unwinding from there.
|
||||
from __future__ import print_function
|
||||
|
||||
|
||||
|
||||
import unittest2
|
||||
|
||||
import os, time
|
||||
import os
|
||||
import time
|
||||
import lldb
|
||||
from lldbsuite.test.decorators import *
|
||||
from lldbsuite.test.lldbtest import *
|
||||
from lldbsuite.test import lldbutil
|
||||
|
||||
|
||||
class UnwindFromExpressionTest(TestBase):
|
||||
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
@@ -23,7 +24,6 @@ class UnwindFromExpressionTest(TestBase):
|
||||
TestBase.setUp(self)
|
||||
|
||||
@add_test_categories(['pyapi'])
|
||||
|
||||
def test_unwind_expression(self):
|
||||
"""Test unwinding from an expression."""
|
||||
self.build()
|
||||
@@ -35,11 +35,13 @@ class UnwindFromExpressionTest(TestBase):
|
||||
|
||||
# Create the breakpoint.
|
||||
main_spec = lldb.SBFileSpec("main.cpp", False)
|
||||
breakpoint = target.BreakpointCreateBySourceRegex("// Set a breakpoint here to get started", main_spec)
|
||||
breakpoint = target.BreakpointCreateBySourceRegex(
|
||||
"// Set a breakpoint here to get started", main_spec)
|
||||
self.assertTrue(breakpoint, VALID_BREAKPOINT)
|
||||
|
||||
# Launch the process, and do not stop at the entry point.
|
||||
process = target.LaunchSimple (None, None, self.get_process_working_directory())
|
||||
process = target.LaunchSimple(
|
||||
None, None, self.get_process_working_directory())
|
||||
|
||||
if not process:
|
||||
self.fail("SBTarget.LaunchProcess() failed")
|
||||
@@ -49,17 +51,20 @@ class UnwindFromExpressionTest(TestBase):
|
||||
"instead the actual state is: '%s'" %
|
||||
lldbutil.state_type_to_str(process.GetState()))
|
||||
|
||||
thread = lldbutil.get_one_thread_stopped_at_breakpoint(process, breakpoint)
|
||||
self.assertIsNotNone(thread, "Expected one thread to be stopped at the breakpoint")
|
||||
thread = lldbutil.get_one_thread_stopped_at_breakpoint(
|
||||
process, breakpoint)
|
||||
self.assertIsNotNone(
|
||||
thread, "Expected one thread to be stopped at the breakpoint")
|
||||
|
||||
#
|
||||
# Use Python API to evaluate expressions while stopped in a stack frame.
|
||||
#
|
||||
main_frame = thread.GetFrameAtIndex(0)
|
||||
|
||||
# Next set a breakpoint in this function, set up Expression options to stop on
|
||||
# Next set a breakpoint in this function, set up Expression options to stop on
|
||||
# breakpoint hits, and call the function.
|
||||
fun_bkpt = target.BreakpointCreateBySourceRegex("// Stop inside the function here.", main_spec)
|
||||
fun_bkpt = target.BreakpointCreateBySourceRegex(
|
||||
"// Stop inside the function here.", main_spec)
|
||||
self.assertTrue(fun_bkpt, VALID_BREAKPOINT)
|
||||
options = lldb.SBExpressionOptions()
|
||||
options.SetIgnoreBreakpoints(False)
|
||||
@@ -67,17 +72,26 @@ class UnwindFromExpressionTest(TestBase):
|
||||
|
||||
val = main_frame.EvaluateExpression("a_function_to_call()", options)
|
||||
|
||||
self.assertTrue(val.GetError().Fail(), "We did not complete the execution.")
|
||||
self.assertTrue(
|
||||
val.GetError().Fail(),
|
||||
"We did not complete the execution.")
|
||||
error_str = val.GetError().GetCString()
|
||||
self.assertTrue("Execution was interrupted, reason: breakpoint" in error_str, "And the reason was right.")
|
||||
self.assertTrue(
|
||||
"Execution was interrupted, reason: breakpoint" in error_str,
|
||||
"And the reason was right.")
|
||||
|
||||
thread = lldbutil.get_one_thread_stopped_at_breakpoint(process, fun_bkpt)
|
||||
self.assertTrue(thread.IsValid(), "We are indeed stopped at our breakpoint")
|
||||
|
||||
# Now unwind the expression, and make sure we got back to where we started.
|
||||
thread = lldbutil.get_one_thread_stopped_at_breakpoint(
|
||||
process, fun_bkpt)
|
||||
self.assertTrue(
|
||||
thread.IsValid(),
|
||||
"We are indeed stopped at our breakpoint")
|
||||
|
||||
# Now unwind the expression, and make sure we got back to where we
|
||||
# started.
|
||||
error = thread.UnwindInnermostExpression()
|
||||
self.assertTrue(error.Success(), "We succeeded in unwinding")
|
||||
|
||||
cur_frame = thread.GetFrameAtIndex(0)
|
||||
self.assertTrue(cur_frame.IsEqual(main_frame), "We got back to the main frame.")
|
||||
|
||||
cur_frame = thread.GetFrameAtIndex(0)
|
||||
self.assertTrue(
|
||||
cur_frame.IsEqual(main_frame),
|
||||
"We got back to the main frame.")
|
||||
|
||||
@@ -5,19 +5,20 @@ Test some lldb command abbreviations and aliases for proper resolution.
|
||||
from __future__ import print_function
|
||||
|
||||
|
||||
|
||||
import os, time
|
||||
import os
|
||||
import time
|
||||
import lldb
|
||||
from lldbsuite.test.decorators import *
|
||||
from lldbsuite.test.lldbtest import *
|
||||
from lldbsuite.test import lldbutil
|
||||
|
||||
|
||||
class AbbreviationsTestCase(TestBase):
|
||||
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
|
||||
@no_debug_info_test
|
||||
def test_command_abbreviations_and_aliases (self):
|
||||
def test_command_abbreviations_and_aliases(self):
|
||||
command_interpreter = self.dbg.GetCommandInterpreter()
|
||||
self.assertTrue(command_interpreter, VALID_COMMAND_INTERPRETER)
|
||||
result = lldb.SBCommandReturnObject()
|
||||
@@ -47,9 +48,12 @@ class AbbreviationsTestCase(TestBase):
|
||||
self.assertTrue(result.GetError().startswith("Ambiguous command"))
|
||||
|
||||
# Make sure an unabbreviated command is not mangled.
|
||||
command_interpreter.ResolveCommand("breakpoint set --name main --line 123", result)
|
||||
command_interpreter.ResolveCommand(
|
||||
"breakpoint set --name main --line 123", result)
|
||||
self.assertTrue(result.Succeeded())
|
||||
self.assertEqual("breakpoint set --name main --line 123", result.GetOutput())
|
||||
self.assertEqual(
|
||||
"breakpoint set --name main --line 123",
|
||||
result.GetOutput())
|
||||
|
||||
# Create some aliases.
|
||||
self.runCmd("com a alias com al")
|
||||
@@ -69,33 +73,40 @@ class AbbreviationsTestCase(TestBase):
|
||||
self.runCmd("alias pltty process launch -s -o %1 -e %1")
|
||||
command_interpreter.ResolveCommand("pltty /dev/tty0", result)
|
||||
self.assertTrue(result.Succeeded())
|
||||
self.assertEqual("process launch -s -o /dev/tty0 -e /dev/tty0", result.GetOutput())
|
||||
self.assertEqual(
|
||||
"process launch -s -o /dev/tty0 -e /dev/tty0",
|
||||
result.GetOutput())
|
||||
|
||||
self.runCmd("alias xyzzy breakpoint set -n %1 -l %2")
|
||||
command_interpreter.ResolveCommand("xyzzy main 123", result)
|
||||
self.assertTrue(result.Succeeded())
|
||||
self.assertEqual("breakpoint set -n main -l 123", result.GetOutput().strip())
|
||||
self.assertEqual(
|
||||
"breakpoint set -n main -l 123",
|
||||
result.GetOutput().strip())
|
||||
|
||||
# And again, without enough parameters.
|
||||
command_interpreter.ResolveCommand("xyzzy main", result)
|
||||
self.assertFalse(result.Succeeded())
|
||||
|
||||
# Check a command that wants the raw input.
|
||||
command_interpreter.ResolveCommand(r'''sc print("\n\n\tHello!\n")''', result)
|
||||
command_interpreter.ResolveCommand(
|
||||
r'''sc print("\n\n\tHello!\n")''', result)
|
||||
self.assertTrue(result.Succeeded())
|
||||
self.assertEqual(r'''script print("\n\n\tHello!\n")''', result.GetOutput())
|
||||
self.assertEqual(
|
||||
r'''script print("\n\n\tHello!\n")''',
|
||||
result.GetOutput())
|
||||
|
||||
# Prompt changing stuff should be tested, but this doesn't seem like the
|
||||
# right test to do it in. It has nothing to do with aliases or abbreviations.
|
||||
#self.runCmd("com sou ./change_prompt.lldb")
|
||||
#self.expect("settings show prompt",
|
||||
# self.expect("settings show prompt",
|
||||
# startstr = 'prompt (string) = "[with-three-trailing-spaces] "')
|
||||
#self.runCmd("settings clear prompt")
|
||||
#self.expect("settings show prompt",
|
||||
# self.expect("settings show prompt",
|
||||
# startstr = 'prompt (string) = "(lldb) "')
|
||||
#self.runCmd("se se prompt 'Sycamore> '")
|
||||
#self.expect("se sh prompt",
|
||||
# self.expect("se sh prompt",
|
||||
# startstr = 'prompt (string) = "Sycamore> "')
|
||||
#self.runCmd("se cl prompt")
|
||||
#self.expect("set sh prompt",
|
||||
# self.expect("set sh prompt",
|
||||
# startstr = 'prompt (string) = "(lldb) "')
|
||||
|
||||
@@ -6,19 +6,20 @@ many commands remain available even after we add/delete commands in the future.
|
||||
from __future__ import print_function
|
||||
|
||||
|
||||
|
||||
import os, time
|
||||
import os
|
||||
import time
|
||||
import lldb
|
||||
from lldbsuite.test.decorators import *
|
||||
from lldbsuite.test.lldbtest import *
|
||||
from lldbsuite.test import lldbutil
|
||||
|
||||
|
||||
class CommonShortSpellingsTestCase(TestBase):
|
||||
|
||||
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
|
||||
@no_debug_info_test
|
||||
def test_abbrevs2 (self):
|
||||
def test_abbrevs2(self):
|
||||
command_interpreter = self.dbg.GetCommandInterpreter()
|
||||
self.assertTrue(command_interpreter, VALID_COMMAND_INTERPRETER)
|
||||
result = lldb.SBCommandReturnObject()
|
||||
|
||||
@@ -5,13 +5,14 @@ Test that apropos env doesn't crash trying to touch the process plugin commmand
|
||||
from __future__ import print_function
|
||||
|
||||
|
||||
|
||||
import os, time
|
||||
import os
|
||||
import time
|
||||
import re
|
||||
import lldb
|
||||
from lldbsuite.test.lldbtest import *
|
||||
import lldbsuite.test.lldbutil as lldbutil
|
||||
|
||||
|
||||
class AproposWithProcessTestCase(TestBase):
|
||||
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
@@ -29,16 +30,17 @@ class AproposWithProcessTestCase(TestBase):
|
||||
self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
|
||||
|
||||
# Break in main() aftre the variables are assigned values.
|
||||
lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True)
|
||||
lldbutil.run_break_set_by_file_and_line(
|
||||
self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True)
|
||||
|
||||
self.runCmd("run", RUN_SUCCEEDED)
|
||||
|
||||
# The stop reason of the thread should be breakpoint.
|
||||
self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
|
||||
substrs = ['stopped', 'stop reason = breakpoint'])
|
||||
substrs=['stopped', 'stop reason = breakpoint'])
|
||||
|
||||
# The breakpoint should have a hit count of 1.
|
||||
self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
|
||||
substrs = [' resolved, hit count = 1'])
|
||||
substrs=[' resolved, hit count = 1'])
|
||||
|
||||
self.runCmd('apropos env')
|
||||
|
||||
@@ -3,13 +3,14 @@
|
||||
from __future__ import print_function
|
||||
|
||||
|
||||
|
||||
import os, time
|
||||
import os
|
||||
import time
|
||||
import lldb
|
||||
from lldbsuite.test.decorators import *
|
||||
from lldbsuite.test.lldbtest import *
|
||||
from lldbsuite.test import lldbutil
|
||||
|
||||
|
||||
class BSDArchivesTestCase(TestBase):
|
||||
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
@@ -18,10 +19,18 @@ class BSDArchivesTestCase(TestBase):
|
||||
# Call super's setUp().
|
||||
TestBase.setUp(self)
|
||||
# Find the line number in a(int) to break at.
|
||||
self.line = line_number('a.c', '// Set file and line breakpoint inside a().')
|
||||
self.line = line_number(
|
||||
'a.c', '// Set file and line breakpoint inside a().')
|
||||
|
||||
@expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24527. Makefile.rules doesn't know how to build static libs on Windows")
|
||||
@expectedFailureAll(oslist=["linux"], archs=["arm", "aarch64"], bugnumber="llvm.org/pr27795")
|
||||
@expectedFailureAll(
|
||||
oslist=["windows"],
|
||||
bugnumber="llvm.org/pr24527. Makefile.rules doesn't know how to build static libs on Windows")
|
||||
@expectedFailureAll(
|
||||
oslist=["linux"],
|
||||
archs=[
|
||||
"arm",
|
||||
"aarch64"],
|
||||
bugnumber="llvm.org/pr27795")
|
||||
def test(self):
|
||||
"""Break inside a() and b() defined within libfoo.a."""
|
||||
self.build()
|
||||
@@ -30,30 +39,32 @@ class BSDArchivesTestCase(TestBase):
|
||||
self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
|
||||
|
||||
# Break inside a() by file and line first.
|
||||
lldbutil.run_break_set_by_file_and_line (self, "a.c", self.line, num_expected_locations=1, loc_exact=True)
|
||||
lldbutil.run_break_set_by_file_and_line(
|
||||
self, "a.c", self.line, num_expected_locations=1, loc_exact=True)
|
||||
|
||||
self.runCmd("run", RUN_SUCCEEDED)
|
||||
|
||||
# The stop reason of the thread should be breakpoint.
|
||||
self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
|
||||
substrs = ['stopped',
|
||||
'stop reason = breakpoint'])
|
||||
substrs=['stopped',
|
||||
'stop reason = breakpoint'])
|
||||
|
||||
# Break at a(int) first.
|
||||
self.expect("frame variable", VARIABLES_DISPLAYED_CORRECTLY,
|
||||
substrs = ['(int) arg = 1'])
|
||||
substrs=['(int) arg = 1'])
|
||||
self.expect("frame variable __a_global", VARIABLES_DISPLAYED_CORRECTLY,
|
||||
substrs = ['(int) __a_global = 1'])
|
||||
substrs=['(int) __a_global = 1'])
|
||||
|
||||
# Set breakpoint for b() next.
|
||||
lldbutil.run_break_set_by_symbol (self, "b", num_expected_locations=1, sym_exact=True)
|
||||
lldbutil.run_break_set_by_symbol(
|
||||
self, "b", num_expected_locations=1, sym_exact=True)
|
||||
|
||||
# Continue the program, we should break at b(int) next.
|
||||
self.runCmd("continue")
|
||||
self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
|
||||
substrs = ['stopped',
|
||||
'stop reason = breakpoint'])
|
||||
substrs=['stopped',
|
||||
'stop reason = breakpoint'])
|
||||
self.expect("frame variable", VARIABLES_DISPLAYED_CORRECTLY,
|
||||
substrs = ['(int) arg = 2'])
|
||||
substrs=['(int) arg = 2'])
|
||||
self.expect("frame variable __b_global", VARIABLES_DISPLAYED_CORRECTLY,
|
||||
substrs = ['(int) __b_global = 2'])
|
||||
substrs=['(int) __b_global = 2'])
|
||||
|
||||
@@ -5,25 +5,28 @@ Test that ASan memory history provider returns correct stack traces
|
||||
from __future__ import print_function
|
||||
|
||||
|
||||
|
||||
import os, time
|
||||
import os
|
||||
import time
|
||||
import lldb
|
||||
from lldbsuite.test.decorators import *
|
||||
from lldbsuite.test.lldbtest import *
|
||||
from lldbsuite.test import lldbplatform
|
||||
from lldbsuite.test import lldbutil
|
||||
|
||||
|
||||
class AsanTestCase(TestBase):
|
||||
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
|
||||
@expectedFailureAll(oslist=["linux"], bugnumber="non-core functionality, need to reenable and fix later (DES 2014.11.07)")
|
||||
@skipIfFreeBSD # llvm.org/pr21136 runtimes not yet available by default
|
||||
@expectedFailureAll(
|
||||
oslist=["linux"],
|
||||
bugnumber="non-core functionality, need to reenable and fix later (DES 2014.11.07)")
|
||||
@skipIfFreeBSD # llvm.org/pr21136 runtimes not yet available by default
|
||||
@skipIfRemote
|
||||
@skipUnlessCompilerRt
|
||||
def test (self):
|
||||
self.build ()
|
||||
self.asan_tests ()
|
||||
def test(self):
|
||||
self.build()
|
||||
self.asan_tests()
|
||||
|
||||
def setUp(self):
|
||||
# Call super's setUp().
|
||||
@@ -33,68 +36,99 @@ class AsanTestCase(TestBase):
|
||||
self.line_free = line_number('main.c', '// free line')
|
||||
self.line_breakpoint = line_number('main.c', '// break line')
|
||||
|
||||
def asan_tests (self):
|
||||
exe = os.path.join (os.getcwd(), "a.out")
|
||||
self.expect("file " + exe, patterns = [ "Current executable set to .*a.out" ])
|
||||
def asan_tests(self):
|
||||
exe = os.path.join(os.getcwd(), "a.out")
|
||||
self.expect(
|
||||
"file " + exe,
|
||||
patterns=["Current executable set to .*a.out"])
|
||||
|
||||
self.runCmd("breakpoint set -f main.c -l %d" % self.line_breakpoint)
|
||||
|
||||
# "memory history" command should not work without a process
|
||||
self.expect("memory history 0",
|
||||
error = True,
|
||||
substrs = ["invalid process"])
|
||||
error=True,
|
||||
substrs=["invalid process"])
|
||||
|
||||
self.runCmd("run")
|
||||
|
||||
stop_reason = self.dbg.GetSelectedTarget().process.GetSelectedThread().GetStopReason()
|
||||
if stop_reason == lldb.eStopReasonExec:
|
||||
# On OS X 10.10 and older, we need to re-exec to enable interceptors.
|
||||
# On OS X 10.10 and older, we need to re-exec to enable
|
||||
# interceptors.
|
||||
self.runCmd("continue")
|
||||
|
||||
# the stop reason of the thread should be breakpoint.
|
||||
self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
|
||||
substrs = ['stopped', 'stop reason = breakpoint'])
|
||||
substrs=['stopped', 'stop reason = breakpoint'])
|
||||
|
||||
# test that the ASan dylib is present
|
||||
self.expect("image lookup -n __asan_describe_address", "__asan_describe_address should be present",
|
||||
substrs = ['1 match found'])
|
||||
self.expect(
|
||||
"image lookup -n __asan_describe_address",
|
||||
"__asan_describe_address should be present",
|
||||
substrs=['1 match found'])
|
||||
|
||||
# test the 'memory history' command
|
||||
self.expect("memory history 'pointer'",
|
||||
substrs = [
|
||||
'Memory allocated by Thread', 'a.out`f1', 'main.c:%d' % self.line_malloc,
|
||||
'Memory deallocated by Thread', 'a.out`f2', 'main.c:%d' % self.line_free])
|
||||
self.expect(
|
||||
"memory history 'pointer'",
|
||||
substrs=[
|
||||
'Memory allocated by Thread',
|
||||
'a.out`f1',
|
||||
'main.c:%d' %
|
||||
self.line_malloc,
|
||||
'Memory deallocated by Thread',
|
||||
'a.out`f2',
|
||||
'main.c:%d' %
|
||||
self.line_free])
|
||||
|
||||
# do the same using SB API
|
||||
process = self.dbg.GetSelectedTarget().process
|
||||
val = process.GetSelectedThread().GetSelectedFrame().EvaluateExpression("pointer")
|
||||
addr = val.GetValueAsUnsigned()
|
||||
threads = process.GetHistoryThreads(addr);
|
||||
threads = process.GetHistoryThreads(addr)
|
||||
self.assertEqual(threads.GetSize(), 2)
|
||||
|
||||
|
||||
history_thread = threads.GetThreadAtIndex(0)
|
||||
self.assertTrue(history_thread.num_frames >= 2)
|
||||
self.assertEqual(history_thread.frames[1].GetLineEntry().GetFileSpec().GetFilename(), "main.c")
|
||||
self.assertEqual(history_thread.frames[1].GetLineEntry().GetLine(), self.line_free)
|
||||
|
||||
self.assertEqual(history_thread.frames[1].GetLineEntry(
|
||||
).GetFileSpec().GetFilename(), "main.c")
|
||||
self.assertEqual(
|
||||
history_thread.frames[1].GetLineEntry().GetLine(),
|
||||
self.line_free)
|
||||
|
||||
history_thread = threads.GetThreadAtIndex(1)
|
||||
self.assertTrue(history_thread.num_frames >= 2)
|
||||
self.assertEqual(history_thread.frames[1].GetLineEntry().GetFileSpec().GetFilename(), "main.c")
|
||||
self.assertEqual(history_thread.frames[1].GetLineEntry().GetLine(), self.line_malloc)
|
||||
self.assertEqual(history_thread.frames[1].GetLineEntry(
|
||||
).GetFileSpec().GetFilename(), "main.c")
|
||||
self.assertEqual(
|
||||
history_thread.frames[1].GetLineEntry().GetLine(),
|
||||
self.line_malloc)
|
||||
|
||||
# let's free the container (SBThreadCollection) and see if the SBThreads still live
|
||||
# let's free the container (SBThreadCollection) and see if the
|
||||
# SBThreads still live
|
||||
threads = None
|
||||
self.assertTrue(history_thread.num_frames >= 2)
|
||||
self.assertEqual(history_thread.frames[1].GetLineEntry().GetFileSpec().GetFilename(), "main.c")
|
||||
self.assertEqual(history_thread.frames[1].GetLineEntry().GetLine(), self.line_malloc)
|
||||
|
||||
self.assertEqual(history_thread.frames[1].GetLineEntry(
|
||||
).GetFileSpec().GetFilename(), "main.c")
|
||||
self.assertEqual(
|
||||
history_thread.frames[1].GetLineEntry().GetLine(),
|
||||
self.line_malloc)
|
||||
|
||||
# ASan will break when a report occurs and we'll try the API then
|
||||
self.runCmd("continue")
|
||||
|
||||
self.expect("thread list", "Process should be stopped due to ASan report",
|
||||
substrs = ['stopped', 'stop reason = Use of deallocated memory detected'])
|
||||
self.expect(
|
||||
"thread list",
|
||||
"Process should be stopped due to ASan report",
|
||||
substrs=[
|
||||
'stopped',
|
||||
'stop reason = Use of deallocated memory detected'])
|
||||
|
||||
# make sure the 'memory history' command still works even when we're generating a report now
|
||||
self.expect("memory history 'another_pointer'",
|
||||
substrs = [
|
||||
'Memory allocated by Thread', 'a.out`f1', 'main.c:%d' % self.line_malloc2])
|
||||
# make sure the 'memory history' command still works even when we're
|
||||
# generating a report now
|
||||
self.expect(
|
||||
"memory history 'another_pointer'",
|
||||
substrs=[
|
||||
'Memory allocated by Thread',
|
||||
'a.out`f1',
|
||||
'main.c:%d' %
|
||||
self.line_malloc2])
|
||||
|
||||
@@ -5,25 +5,28 @@ Test the AddressSanitizer runtime support for report breakpoint and data extract
|
||||
from __future__ import print_function
|
||||
|
||||
|
||||
|
||||
import os, time
|
||||
import os
|
||||
import time
|
||||
import json
|
||||
import lldb
|
||||
from lldbsuite.test.decorators import *
|
||||
from lldbsuite.test.lldbtest import *
|
||||
from lldbsuite.test import lldbutil
|
||||
|
||||
|
||||
class AsanTestReportDataCase(TestBase):
|
||||
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
|
||||
@expectedFailureAll(oslist=["linux"], bugnumber="non-core functionality, need to reenable and fix later (DES 2014.11.07)")
|
||||
@skipIfFreeBSD # llvm.org/pr21136 runtimes not yet available by default
|
||||
@expectedFailureAll(
|
||||
oslist=["linux"],
|
||||
bugnumber="non-core functionality, need to reenable and fix later (DES 2014.11.07)")
|
||||
@skipIfFreeBSD # llvm.org/pr21136 runtimes not yet available by default
|
||||
@skipIfRemote
|
||||
@skipUnlessCompilerRt
|
||||
def test(self):
|
||||
self.build ()
|
||||
self.asan_tests ()
|
||||
self.build()
|
||||
self.asan_tests()
|
||||
|
||||
def setUp(self):
|
||||
# Call super's setUp().
|
||||
@@ -34,26 +37,43 @@ class AsanTestReportDataCase(TestBase):
|
||||
self.line_breakpoint = line_number('main.c', '// break line')
|
||||
self.line_crash = line_number('main.c', '// BOOM line')
|
||||
|
||||
def asan_tests (self):
|
||||
exe = os.path.join (os.getcwd(), "a.out")
|
||||
self.expect("file " + exe, patterns = [ "Current executable set to .*a.out" ])
|
||||
def asan_tests(self):
|
||||
exe = os.path.join(os.getcwd(), "a.out")
|
||||
self.expect(
|
||||
"file " + exe,
|
||||
patterns=["Current executable set to .*a.out"])
|
||||
self.runCmd("run")
|
||||
|
||||
stop_reason = self.dbg.GetSelectedTarget().process.GetSelectedThread().GetStopReason()
|
||||
if stop_reason == lldb.eStopReasonExec:
|
||||
# On OS X 10.10 and older, we need to re-exec to enable interceptors.
|
||||
# On OS X 10.10 and older, we need to re-exec to enable
|
||||
# interceptors.
|
||||
self.runCmd("continue")
|
||||
|
||||
self.expect("thread list", "Process should be stopped due to ASan report",
|
||||
substrs = ['stopped', 'stop reason = Use of deallocated memory detected'])
|
||||
self.expect(
|
||||
"thread list",
|
||||
"Process should be stopped due to ASan report",
|
||||
substrs=[
|
||||
'stopped',
|
||||
'stop reason = Use of deallocated memory detected'])
|
||||
|
||||
self.assertEqual(self.dbg.GetSelectedTarget().process.GetSelectedThread().GetStopReason(), lldb.eStopReasonInstrumentation)
|
||||
self.assertEqual(
|
||||
self.dbg.GetSelectedTarget().process.GetSelectedThread().GetStopReason(),
|
||||
lldb.eStopReasonInstrumentation)
|
||||
|
||||
self.expect("bt", "The backtrace should show the crashing line",
|
||||
substrs = ['main.c:%d' % self.line_crash])
|
||||
substrs=['main.c:%d' % self.line_crash])
|
||||
|
||||
self.expect("thread info -s", "The extended stop info should contain the ASan provided fields",
|
||||
substrs = ["access_size", "access_type", "address", "pc", "description", "heap-use-after-free"])
|
||||
self.expect(
|
||||
"thread info -s",
|
||||
"The extended stop info should contain the ASan provided fields",
|
||||
substrs=[
|
||||
"access_size",
|
||||
"access_type",
|
||||
"address",
|
||||
"pc",
|
||||
"description",
|
||||
"heap-use-after-free"])
|
||||
|
||||
output_lines = self.res.GetOutput().split('\n')
|
||||
json_line = '\n'.join(output_lines[2:])
|
||||
|
||||
@@ -5,8 +5,8 @@ Test process attach/resume.
|
||||
from __future__ import print_function
|
||||
|
||||
|
||||
|
||||
import os, time
|
||||
import os
|
||||
import time
|
||||
import lldb
|
||||
from lldbsuite.test.decorators import *
|
||||
from lldbsuite.test.lldbtest import *
|
||||
@@ -14,6 +14,7 @@ from lldbsuite.test import lldbutil
|
||||
|
||||
exe_name = "AttachResume" # Must match Makefile
|
||||
|
||||
|
||||
class AttachResumeTestCase(TestBase):
|
||||
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
@@ -41,35 +42,53 @@ class AttachResumeTestCase(TestBase):
|
||||
process = self.dbg.GetSelectedTarget().GetProcess()
|
||||
|
||||
self.runCmd("c")
|
||||
lldbutil.expect_state_changes(self, listener, process, [lldb.eStateRunning])
|
||||
lldbutil.expect_state_changes(
|
||||
self, listener, process, [
|
||||
lldb.eStateRunning])
|
||||
|
||||
self.runCmd("process interrupt")
|
||||
lldbutil.expect_state_changes(self, listener, process, [lldb.eStateStopped])
|
||||
lldbutil.expect_state_changes(
|
||||
self, listener, process, [
|
||||
lldb.eStateStopped])
|
||||
|
||||
# be sure to continue/interrupt/continue (r204504)
|
||||
self.runCmd("c")
|
||||
lldbutil.expect_state_changes(self, listener, process, [lldb.eStateRunning])
|
||||
lldbutil.expect_state_changes(
|
||||
self, listener, process, [
|
||||
lldb.eStateRunning])
|
||||
|
||||
self.runCmd("process interrupt")
|
||||
lldbutil.expect_state_changes(self, listener, process, [lldb.eStateStopped])
|
||||
lldbutil.expect_state_changes(
|
||||
self, listener, process, [
|
||||
lldb.eStateStopped])
|
||||
|
||||
# Second interrupt should have no effect.
|
||||
self.expect("process interrupt", patterns=["Process is not running"], error=True)
|
||||
self.expect(
|
||||
"process interrupt",
|
||||
patterns=["Process is not running"],
|
||||
error=True)
|
||||
|
||||
# check that this breakpoint is auto-cleared on detach (r204752)
|
||||
self.runCmd("br set -f main.cpp -l %u" % (line_number('main.cpp', '// Set breakpoint here')))
|
||||
self.runCmd("br set -f main.cpp -l %u" %
|
||||
(line_number('main.cpp', '// Set breakpoint here')))
|
||||
|
||||
self.runCmd("c")
|
||||
lldbutil.expect_state_changes(self, listener, process, [lldb.eStateRunning, lldb.eStateStopped])
|
||||
lldbutil.expect_state_changes(
|
||||
self, listener, process, [
|
||||
lldb.eStateRunning, lldb.eStateStopped])
|
||||
self.expect('br list', 'Breakpoint not hit',
|
||||
substrs = ['hit count = 1'])
|
||||
substrs=['hit count = 1'])
|
||||
|
||||
# Make sure the breakpoint is not hit again.
|
||||
self.expect("expr debugger_flag = false", substrs=[" = false"]);
|
||||
self.expect("expr debugger_flag = false", substrs=[" = false"])
|
||||
|
||||
self.runCmd("c")
|
||||
lldbutil.expect_state_changes(self, listener, process, [lldb.eStateRunning])
|
||||
lldbutil.expect_state_changes(
|
||||
self, listener, process, [
|
||||
lldb.eStateRunning])
|
||||
|
||||
# make sure to detach while in running state (r204759)
|
||||
self.runCmd("detach")
|
||||
lldbutil.expect_state_changes(self, listener, process, [lldb.eStateDetached])
|
||||
lldbutil.expect_state_changes(
|
||||
self, listener, process, [
|
||||
lldb.eStateDetached])
|
||||
|
||||
@@ -5,7 +5,6 @@ Test whether a process started by lldb has no extra file descriptors open.
|
||||
from __future__ import print_function
|
||||
|
||||
|
||||
|
||||
import os
|
||||
import lldb
|
||||
from lldbsuite.test import lldbutil
|
||||
@@ -28,55 +27,79 @@ class AvoidsFdLeakTestCase(TestBase):
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
|
||||
@expectedFailure(python_leaky_fd_version, "bugs.freebsd.org/197376")
|
||||
@expectedFailureAll(oslist=['freebsd'], bugnumber="llvm.org/pr25624 still failing with Python 2.7.10")
|
||||
@skipIfWindows # The check for descriptor leakage needs to be implemented differently here.
|
||||
@skipIfTargetAndroid() # Android have some other file descriptors open by the shell
|
||||
def test_fd_leak_basic (self):
|
||||
@expectedFailureAll(
|
||||
oslist=['freebsd'],
|
||||
bugnumber="llvm.org/pr25624 still failing with Python 2.7.10")
|
||||
# The check for descriptor leakage needs to be implemented differently
|
||||
# here.
|
||||
@skipIfWindows
|
||||
@skipIfTargetAndroid() # Android have some other file descriptors open by the shell
|
||||
def test_fd_leak_basic(self):
|
||||
self.do_test([])
|
||||
|
||||
@expectedFailure(python_leaky_fd_version, "bugs.freebsd.org/197376")
|
||||
@expectedFailureAll(oslist=['freebsd'], bugnumber="llvm.org/pr25624 still failing with Python 2.7.10")
|
||||
@skipIfWindows # The check for descriptor leakage needs to be implemented differently here.
|
||||
@skipIfTargetAndroid() # Android have some other file descriptors open by the shell
|
||||
def test_fd_leak_log (self):
|
||||
@expectedFailureAll(
|
||||
oslist=['freebsd'],
|
||||
bugnumber="llvm.org/pr25624 still failing with Python 2.7.10")
|
||||
# The check for descriptor leakage needs to be implemented differently
|
||||
# here.
|
||||
@skipIfWindows
|
||||
@skipIfTargetAndroid() # Android have some other file descriptors open by the shell
|
||||
def test_fd_leak_log(self):
|
||||
self.do_test(["log enable -f '/dev/null' lldb commands"])
|
||||
|
||||
def do_test (self, commands):
|
||||
def do_test(self, commands):
|
||||
self.build()
|
||||
exe = os.path.join (os.getcwd(), "a.out")
|
||||
exe = os.path.join(os.getcwd(), "a.out")
|
||||
|
||||
for c in commands:
|
||||
self.runCmd(c)
|
||||
|
||||
target = self.dbg.CreateTarget(exe)
|
||||
|
||||
process = target.LaunchSimple (None, None, self.get_process_working_directory())
|
||||
process = target.LaunchSimple(
|
||||
None, None, self.get_process_working_directory())
|
||||
self.assertTrue(process, PROCESS_IS_VALID)
|
||||
|
||||
self.assertTrue(process.GetState() == lldb.eStateExited, "Process should have exited.")
|
||||
self.assertTrue(process.GetExitStatus() == 0,
|
||||
"Process returned non-zero status. Were incorrect file descriptors passed?")
|
||||
self.assertTrue(
|
||||
process.GetState() == lldb.eStateExited,
|
||||
"Process should have exited.")
|
||||
self.assertTrue(
|
||||
process.GetExitStatus() == 0,
|
||||
"Process returned non-zero status. Were incorrect file descriptors passed?")
|
||||
|
||||
@expectedFailure(python_leaky_fd_version, "bugs.freebsd.org/197376")
|
||||
@expectedFailureAll(oslist=['freebsd'], bugnumber="llvm.org/pr25624 still failing with Python 2.7.10")
|
||||
@skipIfWindows # The check for descriptor leakage needs to be implemented differently here.
|
||||
@skipIfTargetAndroid() # Android have some other file descriptors open by the shell
|
||||
def test_fd_leak_multitarget (self):
|
||||
@expectedFailureAll(
|
||||
oslist=['freebsd'],
|
||||
bugnumber="llvm.org/pr25624 still failing with Python 2.7.10")
|
||||
# The check for descriptor leakage needs to be implemented differently
|
||||
# here.
|
||||
@skipIfWindows
|
||||
@skipIfTargetAndroid() # Android have some other file descriptors open by the shell
|
||||
def test_fd_leak_multitarget(self):
|
||||
self.build()
|
||||
exe = os.path.join (os.getcwd(), "a.out")
|
||||
exe = os.path.join(os.getcwd(), "a.out")
|
||||
|
||||
target = self.dbg.CreateTarget(exe)
|
||||
breakpoint = target.BreakpointCreateBySourceRegex ('Set breakpoint here', lldb.SBFileSpec ("main.c", False))
|
||||
breakpoint = target.BreakpointCreateBySourceRegex(
|
||||
'Set breakpoint here', lldb.SBFileSpec("main.c", False))
|
||||
self.assertTrue(breakpoint, VALID_BREAKPOINT)
|
||||
|
||||
process1 = target.LaunchSimple (None, None, self.get_process_working_directory())
|
||||
process1 = target.LaunchSimple(
|
||||
None, None, self.get_process_working_directory())
|
||||
self.assertTrue(process1, PROCESS_IS_VALID)
|
||||
self.assertTrue(process1.GetState() == lldb.eStateStopped, "Process should have been stopped.")
|
||||
self.assertTrue(
|
||||
process1.GetState() == lldb.eStateStopped,
|
||||
"Process should have been stopped.")
|
||||
|
||||
target2 = self.dbg.CreateTarget(exe)
|
||||
process2 = target2.LaunchSimple (None, None, self.get_process_working_directory())
|
||||
process2 = target2.LaunchSimple(
|
||||
None, None, self.get_process_working_directory())
|
||||
self.assertTrue(process2, PROCESS_IS_VALID)
|
||||
|
||||
self.assertTrue(process2.GetState() == lldb.eStateExited, "Process should have exited.")
|
||||
self.assertTrue(process2.GetExitStatus() == 0,
|
||||
"Process returned non-zero status. Were incorrect file descriptors passed?")
|
||||
self.assertTrue(
|
||||
process2.GetState() == lldb.eStateExited,
|
||||
"Process should have exited.")
|
||||
self.assertTrue(
|
||||
process2.GetExitStatus() == 0,
|
||||
"Process returned non-zero status. Were incorrect file descriptors passed?")
|
||||
|
||||
@@ -5,13 +5,14 @@ Test that backticks without a target should work (not infinite looping).
|
||||
from __future__ import print_function
|
||||
|
||||
|
||||
|
||||
import os, time
|
||||
import os
|
||||
import time
|
||||
import lldb
|
||||
from lldbsuite.test.decorators import *
|
||||
from lldbsuite.test.lldbtest import *
|
||||
from lldbsuite.test import lldbutil
|
||||
|
||||
|
||||
class BackticksWithNoTargetTestCase(TestBase):
|
||||
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
@@ -20,4 +21,4 @@ class BackticksWithNoTargetTestCase(TestBase):
|
||||
def test_backticks_no_target(self):
|
||||
"""A simple test of backticks without a target."""
|
||||
self.expect("print `1+2-3`",
|
||||
substrs = [' = 0'])
|
||||
substrs=[' = 0'])
|
||||
|
||||
@@ -5,18 +5,19 @@ Test address breakpoints set with shared library of SBAddress work correctly.
|
||||
from __future__ import print_function
|
||||
|
||||
|
||||
|
||||
import os, time
|
||||
import os
|
||||
import time
|
||||
import re
|
||||
import lldb
|
||||
import lldbsuite.test.lldbutil as lldbutil
|
||||
from lldbsuite.test.lldbtest import *
|
||||
|
||||
|
||||
class AddressBreakpointTestCase(TestBase):
|
||||
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
|
||||
def test_address_breakpoints (self):
|
||||
def test_address_breakpoints(self):
|
||||
"""Test address breakpoints set with shared library of SBAddress work correctly."""
|
||||
self.build()
|
||||
self.address_breakpoints()
|
||||
@@ -34,7 +35,8 @@ class AddressBreakpointTestCase(TestBase):
|
||||
self.assertTrue(target, VALID_TARGET)
|
||||
|
||||
# Now create a breakpoint on main.c by name 'c'.
|
||||
breakpoint = target.BreakpointCreateBySourceRegex("Set a breakpoint here", lldb.SBFileSpec("main.c"))
|
||||
breakpoint = target.BreakpointCreateBySourceRegex(
|
||||
"Set a breakpoint here", lldb.SBFileSpec("main.c"))
|
||||
self.assertTrue(breakpoint and
|
||||
breakpoint.GetNumLocations() == 1,
|
||||
VALID_BREAKPOINT)
|
||||
@@ -48,7 +50,7 @@ class AddressBreakpointTestCase(TestBase):
|
||||
|
||||
# Next get the address from the location, and create an address breakpoint using
|
||||
# that address:
|
||||
|
||||
|
||||
address = location.GetAddress()
|
||||
target.BreakpointDelete(breakpoint.GetID())
|
||||
|
||||
@@ -61,16 +63,18 @@ class AddressBreakpointTestCase(TestBase):
|
||||
flags = launch_info.GetLaunchFlags()
|
||||
flags &= ~lldb.eLaunchFlagDisableASLR
|
||||
launch_info.SetLaunchFlags(flags)
|
||||
|
||||
|
||||
error = lldb.SBError()
|
||||
|
||||
process = target.Launch (launch_info, error)
|
||||
process = target.Launch(launch_info, error)
|
||||
self.assertTrue(process, PROCESS_IS_VALID)
|
||||
|
||||
# Did we hit our breakpoint?
|
||||
from lldbsuite.test.lldbutil import get_threads_stopped_at_breakpoint
|
||||
threads = get_threads_stopped_at_breakpoint (process, breakpoint)
|
||||
self.assertTrue(len(threads) == 1, "There should be a thread stopped at our breakpoint")
|
||||
from lldbsuite.test.lldbutil import get_threads_stopped_at_breakpoint
|
||||
threads = get_threads_stopped_at_breakpoint(process, breakpoint)
|
||||
self.assertTrue(
|
||||
len(threads) == 1,
|
||||
"There should be a thread stopped at our breakpoint")
|
||||
|
||||
# The hit count for the breakpoint should be 1.
|
||||
self.assertTrue(breakpoint.GetHitCount() == 1)
|
||||
@@ -82,10 +86,12 @@ class AddressBreakpointTestCase(TestBase):
|
||||
launch_info.SetLaunchFlags(flags)
|
||||
|
||||
process = target.Launch(launch_info, error)
|
||||
self.assertTrue (process, PROCESS_IS_VALID)
|
||||
self.assertTrue(process, PROCESS_IS_VALID)
|
||||
|
||||
thread = get_threads_stopped_at_breakpoint (process, breakpoint)
|
||||
self.assertTrue(len(threads) == 1, "There should be a thread stopped at our breakpoint")
|
||||
thread = get_threads_stopped_at_breakpoint(process, breakpoint)
|
||||
self.assertTrue(
|
||||
len(threads) == 1,
|
||||
"There should be a thread stopped at our breakpoint")
|
||||
|
||||
# The hit count for the breakpoint should now be 2.
|
||||
self.assertTrue(breakpoint.GetHitCount() == 2)
|
||||
|
||||
@@ -5,18 +5,19 @@ Test that breakpoints set on a bad address say they are bad.
|
||||
from __future__ import print_function
|
||||
|
||||
|
||||
|
||||
import os, time
|
||||
import os
|
||||
import time
|
||||
import re
|
||||
import lldb
|
||||
import lldbsuite.test.lldbutil as lldbutil
|
||||
from lldbsuite.test.lldbtest import *
|
||||
|
||||
|
||||
class BadAddressBreakpointTestCase(TestBase):
|
||||
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
|
||||
def test_bad_address_breakpoints (self):
|
||||
def test_bad_address_breakpoints(self):
|
||||
"""Test that breakpoints set on a bad address say they are bad."""
|
||||
self.build()
|
||||
self.address_breakpoints()
|
||||
@@ -34,7 +35,8 @@ class BadAddressBreakpointTestCase(TestBase):
|
||||
self.assertTrue(target, VALID_TARGET)
|
||||
|
||||
# Now create a breakpoint on main.c by name 'c'.
|
||||
breakpoint = target.BreakpointCreateBySourceRegex("Set a breakpoint here", lldb.SBFileSpec("main.c"))
|
||||
breakpoint = target.BreakpointCreateBySourceRegex(
|
||||
"Set a breakpoint here", lldb.SBFileSpec("main.c"))
|
||||
self.assertTrue(breakpoint and
|
||||
breakpoint.GetNumLocations() == 1,
|
||||
VALID_BREAKPOINT)
|
||||
@@ -47,16 +49,18 @@ class BadAddressBreakpointTestCase(TestBase):
|
||||
VALID_BREAKPOINT_LOCATION)
|
||||
|
||||
launch_info = lldb.SBLaunchInfo(None)
|
||||
|
||||
|
||||
error = lldb.SBError()
|
||||
|
||||
process = target.Launch (launch_info, error)
|
||||
process = target.Launch(launch_info, error)
|
||||
self.assertTrue(process, PROCESS_IS_VALID)
|
||||
|
||||
# Did we hit our breakpoint?
|
||||
from lldbsuite.test.lldbutil import get_threads_stopped_at_breakpoint
|
||||
threads = get_threads_stopped_at_breakpoint (process, breakpoint)
|
||||
self.assertTrue(len(threads) == 1, "There should be a thread stopped at our breakpoint")
|
||||
from lldbsuite.test.lldbutil import get_threads_stopped_at_breakpoint
|
||||
threads = get_threads_stopped_at_breakpoint(process, breakpoint)
|
||||
self.assertTrue(
|
||||
len(threads) == 1,
|
||||
"There should be a thread stopped at our breakpoint")
|
||||
|
||||
# The hit count for the breakpoint should be 1.
|
||||
self.assertTrue(breakpoint.GetHitCount() == 1)
|
||||
@@ -72,6 +76,5 @@ class BadAddressBreakpointTestCase(TestBase):
|
||||
for bp_loc in bkpt:
|
||||
self.assertTrue(bp_loc.IsResolved() == False)
|
||||
else:
|
||||
self.fail("Could not find an illegal address at which to set a bad breakpoint.")
|
||||
|
||||
|
||||
self.fail(
|
||||
"Could not find an illegal address at which to set a bad breakpoint.")
|
||||
|
||||
@@ -9,6 +9,7 @@ from lldbsuite.test.lldbtest import *
|
||||
from lldbsuite.test.decorators import *
|
||||
from lldbsuite.test import lldbplatform, lldbplatformutil
|
||||
|
||||
|
||||
class BreakpointCaseSensitivityTestCase(TestBase):
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
BREAKPOINT_TEXT = 'Set a breakpoint here'
|
||||
@@ -24,8 +25,9 @@ class BreakpointCaseSensitivityTestCase(TestBase):
|
||||
self.build()
|
||||
self.case_sensitivity_breakpoint(True)
|
||||
|
||||
@skipIf(oslist=['windows']) # Skip for windows platforms
|
||||
@expectedFailureAll() # Failing for unknown reason on non-Windows platforms.
|
||||
@skipIf(oslist=['windows']) # Skip for windows platforms
|
||||
# Failing for unknown reason on non-Windows platforms.
|
||||
@expectedFailureAll()
|
||||
def test_breakpoint_doesnt_match_file_with_different_case(self):
|
||||
"""Set breakpoint on file, shouldn't match files with different case on POSIX systems"""
|
||||
self.build()
|
||||
@@ -33,19 +35,19 @@ class BreakpointCaseSensitivityTestCase(TestBase):
|
||||
|
||||
def case_sensitivity_breakpoint(self, case_insensitive):
|
||||
"""Set breakpoint on file, should match files with different case if case_insensitive is True"""
|
||||
|
||||
|
||||
# use different case to check CreateTarget
|
||||
exe = 'a.out'
|
||||
if case_insensitive:
|
||||
exe = exe.upper()
|
||||
|
||||
|
||||
exe = os.path.join(os.getcwd(), exe)
|
||||
|
||||
# Create a target by the debugger.
|
||||
self.target = self.dbg.CreateTarget(exe)
|
||||
self.assertTrue(self.target, VALID_TARGET)
|
||||
cwd = self.get_process_working_directory();
|
||||
|
||||
cwd = self.get_process_working_directory()
|
||||
|
||||
# try both BreakpointCreateByLocation and BreakpointCreateBySourceRegex
|
||||
for regex in [False, True]:
|
||||
# should always hit
|
||||
@@ -68,47 +70,54 @@ class BreakpointCaseSensitivityTestCase(TestBase):
|
||||
def check_breakpoint(self, file, source_regex, should_hit):
|
||||
"""
|
||||
Check breakpoint hit at given file set by given method
|
||||
|
||||
|
||||
file:
|
||||
File where insert the breakpoint
|
||||
|
||||
|
||||
source_regex:
|
||||
True for testing using BreakpointCreateBySourceRegex,
|
||||
False for BreakpointCreateByLocation
|
||||
|
||||
|
||||
should_hit:
|
||||
True if the breakpoint should hit, False otherwise
|
||||
"""
|
||||
|
||||
desc = ' file %s set by %s' % (file, 'regex' if source_regex else 'location')
|
||||
|
||||
desc = ' file %s set by %s' % (
|
||||
file, 'regex' if source_regex else 'location')
|
||||
if source_regex:
|
||||
breakpoint = self.target.BreakpointCreateBySourceRegex(self.BREAKPOINT_TEXT,
|
||||
lldb.SBFileSpec(file))
|
||||
else:
|
||||
breakpoint = self.target.BreakpointCreateByLocation(file, self.line)
|
||||
|
||||
breakpoint = self.target.BreakpointCreateBySourceRegex(
|
||||
self.BREAKPOINT_TEXT, lldb.SBFileSpec(file))
|
||||
else:
|
||||
breakpoint = self.target.BreakpointCreateByLocation(
|
||||
file, self.line)
|
||||
|
||||
self.assertEqual(breakpoint and breakpoint.GetNumLocations() == 1,
|
||||
should_hit,
|
||||
VALID_BREAKPOINT + desc)
|
||||
should_hit,
|
||||
VALID_BREAKPOINT + desc)
|
||||
|
||||
# Get the breakpoint location from breakpoint after we verified that,
|
||||
# indeed, it has one location.
|
||||
location = breakpoint.GetLocationAtIndex(0)
|
||||
self.assertEqual(location and location.IsEnabled(),
|
||||
should_hit,
|
||||
VALID_BREAKPOINT_LOCATION + desc)
|
||||
|
||||
process = self.target.LaunchSimple(None, None, self.get_process_working_directory())
|
||||
should_hit,
|
||||
VALID_BREAKPOINT_LOCATION + desc)
|
||||
|
||||
process = self.target.LaunchSimple(
|
||||
None, None, self.get_process_working_directory())
|
||||
self.assertTrue(process, PROCESS_IS_VALID + desc)
|
||||
|
||||
if should_hit:
|
||||
# Did we hit our breakpoint?
|
||||
from lldbsuite.test.lldbutil import get_threads_stopped_at_breakpoint
|
||||
threads = get_threads_stopped_at_breakpoint (process, breakpoint)
|
||||
self.assertEqual(len(threads), 1, "There should be a thread stopped at breakpoint" + desc)
|
||||
from lldbsuite.test.lldbutil import get_threads_stopped_at_breakpoint
|
||||
threads = get_threads_stopped_at_breakpoint(process, breakpoint)
|
||||
self.assertEqual(
|
||||
len(threads),
|
||||
1,
|
||||
"There should be a thread stopped at breakpoint" +
|
||||
desc)
|
||||
# The hit count for the breakpoint should be 1.
|
||||
self.assertEqual(breakpoint.GetHitCount(), 1)
|
||||
|
||||
|
||||
else:
|
||||
# check the breakpoint was not hit
|
||||
self.assertEqual(lldb.eStateExited, process.GetState())
|
||||
@@ -116,6 +125,6 @@ class BreakpointCaseSensitivityTestCase(TestBase):
|
||||
|
||||
# let process finish
|
||||
process.Continue()
|
||||
|
||||
|
||||
# cleanup
|
||||
self.target.BreakpointDelete(breakpoint.GetID())
|
||||
|
||||
@@ -5,13 +5,14 @@ Test lldb breakpoint command add/list/delete.
|
||||
from __future__ import print_function
|
||||
|
||||
|
||||
|
||||
import os, time
|
||||
import os
|
||||
import time
|
||||
import lldb
|
||||
from lldbsuite.test.decorators import *
|
||||
from lldbsuite.test.lldbtest import *
|
||||
from lldbsuite.test import lldbutil
|
||||
|
||||
|
||||
class BreakpointCommandTestCase(TestBase):
|
||||
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
@@ -27,7 +28,7 @@ class BreakpointCommandTestCase(TestBase):
|
||||
"""Test a sequence of breakpoint command add, list, and delete."""
|
||||
self.build()
|
||||
self.breakpoint_command_sequence()
|
||||
self.breakpoint_command_script_parameters ()
|
||||
self.breakpoint_command_script_parameters()
|
||||
|
||||
def setUp(self):
|
||||
# Call super's setUp().
|
||||
@@ -36,7 +37,8 @@ class BreakpointCommandTestCase(TestBase):
|
||||
self.line = line_number('main.c', '// Set break point at this line.')
|
||||
# disable "There is a running process, kill it and restart?" prompt
|
||||
self.runCmd("settings set auto-confirm true")
|
||||
self.addTearDownHook(lambda: self.runCmd("settings clear auto-confirm"))
|
||||
self.addTearDownHook(
|
||||
lambda: self.runCmd("settings clear auto-confirm"))
|
||||
|
||||
def breakpoint_command_sequence(self):
|
||||
"""Test a sequence of breakpoint command add, list, and delete."""
|
||||
@@ -45,45 +47,64 @@ class BreakpointCommandTestCase(TestBase):
|
||||
|
||||
# Add three breakpoints on the same line. The first time we don't specify the file,
|
||||
# since the default file is the one containing main:
|
||||
lldbutil.run_break_set_by_file_and_line (self, None, self.line, num_expected_locations=1, loc_exact=True)
|
||||
lldbutil.run_break_set_by_file_and_line (self, "main.c", self.line, num_expected_locations=1, loc_exact=True)
|
||||
lldbutil.run_break_set_by_file_and_line (self, "main.c", self.line, num_expected_locations=1, loc_exact=True)
|
||||
# Breakpoint 4 - set at the same location as breakpoint 1 to test setting breakpoint commands on two breakpoints at a time
|
||||
lldbutil.run_break_set_by_file_and_line (self, None, self.line, num_expected_locations=1, loc_exact=True)
|
||||
lldbutil.run_break_set_by_file_and_line(
|
||||
self, None, self.line, num_expected_locations=1, loc_exact=True)
|
||||
lldbutil.run_break_set_by_file_and_line(
|
||||
self, "main.c", self.line, num_expected_locations=1, loc_exact=True)
|
||||
lldbutil.run_break_set_by_file_and_line(
|
||||
self, "main.c", self.line, num_expected_locations=1, loc_exact=True)
|
||||
# Breakpoint 4 - set at the same location as breakpoint 1 to test
|
||||
# setting breakpoint commands on two breakpoints at a time
|
||||
lldbutil.run_break_set_by_file_and_line(
|
||||
self, None, self.line, num_expected_locations=1, loc_exact=True)
|
||||
|
||||
# Now add callbacks for the breakpoints just created.
|
||||
self.runCmd("breakpoint command add -s command -o 'frame variable --show-types --scope' 1 4")
|
||||
self.runCmd("breakpoint command add -s python -o 'here = open(\"output.txt\", \"w\"); here.write(\"lldb\\n\"); here.close()' 2")
|
||||
self.runCmd("breakpoint command add --python-function bktptcmd.function 3")
|
||||
self.runCmd(
|
||||
"breakpoint command add -s command -o 'frame variable --show-types --scope' 1 4")
|
||||
self.runCmd(
|
||||
"breakpoint command add -s python -o 'here = open(\"output.txt\", \"w\"); here.write(\"lldb\\n\"); here.close()' 2")
|
||||
self.runCmd(
|
||||
"breakpoint command add --python-function bktptcmd.function 3")
|
||||
|
||||
# Check that the breakpoint commands are correctly set.
|
||||
|
||||
# The breakpoint list now only contains breakpoint 1.
|
||||
self.expect("breakpoint list", "Breakpoints 1 & 2 created",
|
||||
substrs = ["2: file = 'main.c', line = %d, exact_match = 0, locations = 1" % self.line],
|
||||
patterns = ["1: file = '.*main.c', line = %d, exact_match = 0, locations = 1" % self.line] )
|
||||
self.expect(
|
||||
"breakpoint list", "Breakpoints 1 & 2 created", substrs=[
|
||||
"2: file = 'main.c', line = %d, exact_match = 0, locations = 1" %
|
||||
self.line], patterns=[
|
||||
"1: file = '.*main.c', line = %d, exact_match = 0, locations = 1" %
|
||||
self.line])
|
||||
|
||||
self.expect("breakpoint list -f", "Breakpoints 1 & 2 created",
|
||||
substrs = ["2: file = 'main.c', line = %d, exact_match = 0, locations = 1" % self.line],
|
||||
patterns = ["1: file = '.*main.c', line = %d, exact_match = 0, locations = 1" % self.line,
|
||||
"1.1: .+at main.c:%d, .+unresolved, hit count = 0" % self.line,
|
||||
"2.1: .+at main.c:%d, .+unresolved, hit count = 0" % self.line])
|
||||
self.expect(
|
||||
"breakpoint list -f",
|
||||
"Breakpoints 1 & 2 created",
|
||||
substrs=[
|
||||
"2: file = 'main.c', line = %d, exact_match = 0, locations = 1" %
|
||||
self.line],
|
||||
patterns=[
|
||||
"1: file = '.*main.c', line = %d, exact_match = 0, locations = 1" %
|
||||
self.line,
|
||||
"1.1: .+at main.c:%d, .+unresolved, hit count = 0" %
|
||||
self.line,
|
||||
"2.1: .+at main.c:%d, .+unresolved, hit count = 0" %
|
||||
self.line])
|
||||
|
||||
self.expect("breakpoint command list 1", "Breakpoint 1 command ok",
|
||||
substrs = ["Breakpoint commands:",
|
||||
"frame variable --show-types --scope"])
|
||||
substrs=["Breakpoint commands:",
|
||||
"frame variable --show-types --scope"])
|
||||
self.expect("breakpoint command list 2", "Breakpoint 2 command ok",
|
||||
substrs = ["Breakpoint commands:",
|
||||
"here = open",
|
||||
"here.write",
|
||||
"here.close()"])
|
||||
substrs=["Breakpoint commands:",
|
||||
"here = open",
|
||||
"here.write",
|
||||
"here.close()"])
|
||||
self.expect("breakpoint command list 3", "Breakpoint 3 command ok",
|
||||
substrs = ["Breakpoint commands:",
|
||||
"bktptcmd.function(frame, bp_loc, internal_dict)"])
|
||||
substrs=["Breakpoint commands:",
|
||||
"bktptcmd.function(frame, bp_loc, internal_dict)"])
|
||||
|
||||
self.expect("breakpoint command list 4", "Breakpoint 4 command ok",
|
||||
substrs = ["Breakpoint commands:",
|
||||
"frame variable --show-types --scope"])
|
||||
substrs=["Breakpoint commands:",
|
||||
"frame variable --show-types --scope"])
|
||||
|
||||
self.runCmd("breakpoint delete 4")
|
||||
|
||||
@@ -93,43 +114,68 @@ class BreakpointCommandTestCase(TestBase):
|
||||
# and then specify only one file. The first time we should get two locations,
|
||||
# the second time only one:
|
||||
|
||||
lldbutil.run_break_set_by_regexp (self, r"._MyFunction", num_expected_locations=2)
|
||||
|
||||
lldbutil.run_break_set_by_regexp (self, r"._MyFunction", extra_options="-f a.c", num_expected_locations=1)
|
||||
|
||||
lldbutil.run_break_set_by_regexp (self, r"._MyFunction", extra_options="-f a.c -f b.c", num_expected_locations=2)
|
||||
lldbutil.run_break_set_by_regexp(
|
||||
self, r"._MyFunction", num_expected_locations=2)
|
||||
|
||||
lldbutil.run_break_set_by_regexp(
|
||||
self,
|
||||
r"._MyFunction",
|
||||
extra_options="-f a.c",
|
||||
num_expected_locations=1)
|
||||
|
||||
lldbutil.run_break_set_by_regexp(
|
||||
self,
|
||||
r"._MyFunction",
|
||||
extra_options="-f a.c -f b.c",
|
||||
num_expected_locations=2)
|
||||
|
||||
# Now try a source regex breakpoint:
|
||||
lldbutil.run_break_set_by_source_regexp (self, r"is about to return [12]0", extra_options="-f a.c -f b.c", num_expected_locations=2)
|
||||
|
||||
lldbutil.run_break_set_by_source_regexp (self, r"is about to return [12]0", extra_options="-f a.c", num_expected_locations=1)
|
||||
|
||||
lldbutil.run_break_set_by_source_regexp(
|
||||
self,
|
||||
r"is about to return [12]0",
|
||||
extra_options="-f a.c -f b.c",
|
||||
num_expected_locations=2)
|
||||
|
||||
lldbutil.run_break_set_by_source_regexp(
|
||||
self,
|
||||
r"is about to return [12]0",
|
||||
extra_options="-f a.c",
|
||||
num_expected_locations=1)
|
||||
|
||||
# Run the program. Remove 'output.txt' if it exists.
|
||||
self.RemoveTempFile("output.txt")
|
||||
self.RemoveTempFile("output2.txt")
|
||||
self.runCmd("run", RUN_SUCCEEDED)
|
||||
|
||||
# Check that the file 'output.txt' exists and contains the string "lldb".
|
||||
# Check that the file 'output.txt' exists and contains the string
|
||||
# "lldb".
|
||||
|
||||
# The 'output.txt' file should now exist.
|
||||
self.assertTrue(os.path.isfile("output.txt"),
|
||||
"'output.txt' exists due to breakpoint command for breakpoint 2.")
|
||||
self.assertTrue(os.path.isfile("output2.txt"),
|
||||
"'output2.txt' exists due to breakpoint command for breakpoint 3.")
|
||||
self.assertTrue(
|
||||
os.path.isfile("output.txt"),
|
||||
"'output.txt' exists due to breakpoint command for breakpoint 2.")
|
||||
self.assertTrue(
|
||||
os.path.isfile("output2.txt"),
|
||||
"'output2.txt' exists due to breakpoint command for breakpoint 3.")
|
||||
|
||||
# Read the output file produced by running the program.
|
||||
with open('output.txt', 'r') as f:
|
||||
output = f.read()
|
||||
|
||||
self.expect(output, "File 'output.txt' and the content matches", exe=False,
|
||||
startstr = "lldb")
|
||||
self.expect(
|
||||
output,
|
||||
"File 'output.txt' and the content matches",
|
||||
exe=False,
|
||||
startstr="lldb")
|
||||
|
||||
with open('output2.txt', 'r') as f:
|
||||
output = f.read()
|
||||
|
||||
self.expect(output, "File 'output2.txt' and the content matches", exe=False,
|
||||
startstr = "lldb")
|
||||
|
||||
self.expect(
|
||||
output,
|
||||
"File 'output2.txt' and the content matches",
|
||||
exe=False,
|
||||
startstr="lldb")
|
||||
|
||||
# Finish the program.
|
||||
self.runCmd("process continue")
|
||||
@@ -140,21 +186,31 @@ class BreakpointCommandTestCase(TestBase):
|
||||
# Remove breakpoint 2.
|
||||
self.runCmd("breakpoint delete 2")
|
||||
|
||||
self.expect("breakpoint command list 1",
|
||||
startstr = "Breakpoint 1 does not have an associated command.")
|
||||
self.expect("breakpoint command list 2", error=True,
|
||||
startstr = "error: '2' is not a currently valid breakpoint ID.")
|
||||
self.expect(
|
||||
"breakpoint command list 1",
|
||||
startstr="Breakpoint 1 does not have an associated command.")
|
||||
self.expect(
|
||||
"breakpoint command list 2",
|
||||
error=True,
|
||||
startstr="error: '2' is not a currently valid breakpoint ID.")
|
||||
|
||||
# The breakpoint list now only contains breakpoint 1.
|
||||
self.expect("breakpoint list -f", "Breakpoint 1 exists",
|
||||
patterns = ["1: file = '.*main.c', line = %d, exact_match = 0, locations = 1, resolved = 1" %
|
||||
self.line,
|
||||
"hit count = 1"])
|
||||
self.expect(
|
||||
"breakpoint list -f",
|
||||
"Breakpoint 1 exists",
|
||||
patterns=[
|
||||
"1: file = '.*main.c', line = %d, exact_match = 0, locations = 1, resolved = 1" %
|
||||
self.line,
|
||||
"hit count = 1"])
|
||||
|
||||
# Not breakpoint 2.
|
||||
self.expect("breakpoint list -f", "No more breakpoint 2", matching=False,
|
||||
substrs = ["2: file = 'main.c', line = %d, exact_match = 0, locations = 1, resolved = 1" %
|
||||
self.line])
|
||||
self.expect(
|
||||
"breakpoint list -f",
|
||||
"No more breakpoint 2",
|
||||
matching=False,
|
||||
substrs=[
|
||||
"2: file = 'main.c', line = %d, exact_match = 0, locations = 1, resolved = 1" %
|
||||
self.line])
|
||||
|
||||
# Run the program again, with breakpoint 1 remaining.
|
||||
self.runCmd("run", RUN_SUCCEEDED)
|
||||
@@ -163,20 +219,21 @@ class BreakpointCommandTestCase(TestBase):
|
||||
|
||||
# The stop reason of the thread should be breakpoint.
|
||||
self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
|
||||
substrs = ['stopped',
|
||||
'stop reason = breakpoint'])
|
||||
substrs=['stopped',
|
||||
'stop reason = breakpoint'])
|
||||
|
||||
# The breakpoint should have a hit count of 2.
|
||||
self.expect("breakpoint list -f", BREAKPOINT_HIT_TWICE,
|
||||
substrs = ['resolved, hit count = 2'])
|
||||
substrs=['resolved, hit count = 2'])
|
||||
|
||||
def breakpoint_command_script_parameters (self):
|
||||
def breakpoint_command_script_parameters(self):
|
||||
"""Test that the frame and breakpoint location are being properly passed to the script breakpoint command function."""
|
||||
exe = os.path.join(os.getcwd(), "a.out")
|
||||
self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
|
||||
|
||||
# Add a breakpoint.
|
||||
lldbutil.run_break_set_by_file_and_line (self, "main.c", self.line, num_expected_locations=1, loc_exact=True)
|
||||
lldbutil.run_break_set_by_file_and_line(
|
||||
self, "main.c", self.line, num_expected_locations=1, loc_exact=True)
|
||||
|
||||
# Now add callbacks for the breakpoints just created.
|
||||
self.runCmd("breakpoint command add -s python -o 'here = open(\"output-2.txt\", \"w\"); here.write(str(frame) + \"\\n\"); here.write(str(bp_loc) + \"\\n\"); here.close()' 1")
|
||||
@@ -184,24 +241,30 @@ class BreakpointCommandTestCase(TestBase):
|
||||
# Remove 'output-2.txt' if it already exists.
|
||||
|
||||
if (os.path.exists('output-2.txt')):
|
||||
os.remove ('output-2.txt')
|
||||
os.remove('output-2.txt')
|
||||
|
||||
# Run program, hit breakpoint, and hopefully write out new version of 'output-2.txt'
|
||||
self.runCmd ("run", RUN_SUCCEEDED)
|
||||
# Run program, hit breakpoint, and hopefully write out new version of
|
||||
# 'output-2.txt'
|
||||
self.runCmd("run", RUN_SUCCEEDED)
|
||||
|
||||
# Check that the file 'output.txt' exists and contains the string "lldb".
|
||||
# Check that the file 'output.txt' exists and contains the string
|
||||
# "lldb".
|
||||
|
||||
# The 'output-2.txt' file should now exist.
|
||||
self.assertTrue(os.path.isfile("output-2.txt"),
|
||||
"'output-2.txt' exists due to breakpoint command for breakpoint 1.")
|
||||
self.assertTrue(
|
||||
os.path.isfile("output-2.txt"),
|
||||
"'output-2.txt' exists due to breakpoint command for breakpoint 1.")
|
||||
|
||||
# Read the output file produced by running the program.
|
||||
with open('output-2.txt', 'r') as f:
|
||||
output = f.read()
|
||||
|
||||
self.expect (output, "File 'output-2.txt' and the content matches", exe=False,
|
||||
startstr = "frame #0:",
|
||||
patterns = ["1.* where = .*main .* resolved, hit count = 1" ])
|
||||
self.expect(
|
||||
output,
|
||||
"File 'output-2.txt' and the content matches",
|
||||
exe=False,
|
||||
startstr="frame #0:",
|
||||
patterns=["1.* where = .*main .* resolved, hit count = 1"])
|
||||
|
||||
# Now remove 'output-2.txt'
|
||||
os.remove ('output-2.txt')
|
||||
os.remove('output-2.txt')
|
||||
|
||||
@@ -5,7 +5,6 @@ Test that you can set breakpoint commands successfully with the Python API's:
|
||||
from __future__ import print_function
|
||||
|
||||
|
||||
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
@@ -14,6 +13,7 @@ from lldbsuite.test.decorators import *
|
||||
from lldbsuite.test.lldbtest import *
|
||||
from lldbsuite.test import lldbutil
|
||||
|
||||
|
||||
class PythonBreakpointCommandSettingTestCase(TestBase):
|
||||
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
@@ -23,36 +23,42 @@ class PythonBreakpointCommandSettingTestCase(TestBase):
|
||||
def test_step_out_python(self):
|
||||
"""Test stepping out using avoid-no-debug with dsyms."""
|
||||
self.build()
|
||||
self.do_set_python_command_from_python ()
|
||||
self.do_set_python_command_from_python()
|
||||
|
||||
def setUp (self):
|
||||
def setUp(self):
|
||||
TestBase.setUp(self)
|
||||
self.main_source = "main.c"
|
||||
self.main_source_spec = lldb.SBFileSpec(self.main_source)
|
||||
|
||||
|
||||
def do_set_python_command_from_python (self):
|
||||
def do_set_python_command_from_python(self):
|
||||
exe = os.path.join(os.getcwd(), "a.out")
|
||||
error = lldb.SBError()
|
||||
|
||||
self.target = self.dbg.CreateTarget(exe)
|
||||
self.assertTrue(self.target, VALID_TARGET)
|
||||
|
||||
body_bkpt = self.target.BreakpointCreateBySourceRegex("Set break point at this line.", self.main_source_spec)
|
||||
body_bkpt = self.target.BreakpointCreateBySourceRegex(
|
||||
"Set break point at this line.", self.main_source_spec)
|
||||
self.assertTrue(body_bkpt, VALID_BREAKPOINT)
|
||||
|
||||
func_bkpt = self.target.BreakpointCreateBySourceRegex("Set break point at this line.", self.main_source_spec)
|
||||
func_bkpt = self.target.BreakpointCreateBySourceRegex(
|
||||
"Set break point at this line.", self.main_source_spec)
|
||||
self.assertTrue(func_bkpt, VALID_BREAKPOINT)
|
||||
|
||||
# Also test that setting a source regex breakpoint with an empty file spec list sets it on all files:
|
||||
no_files_bkpt = self.target.BreakpointCreateBySourceRegex("Set a breakpoint here", lldb.SBFileSpecList(), lldb.SBFileSpecList())
|
||||
# Also test that setting a source regex breakpoint with an empty file
|
||||
# spec list sets it on all files:
|
||||
no_files_bkpt = self.target.BreakpointCreateBySourceRegex(
|
||||
"Set a breakpoint here", lldb.SBFileSpecList(), lldb.SBFileSpecList())
|
||||
self.assertTrue(no_files_bkpt, VALID_BREAKPOINT)
|
||||
num_locations = no_files_bkpt.GetNumLocations()
|
||||
self.assertTrue(num_locations >= 2, "Got at least two breakpoint locations")
|
||||
self.assertTrue(
|
||||
num_locations >= 2,
|
||||
"Got at least two breakpoint locations")
|
||||
got_one_in_A = False
|
||||
got_one_in_B = False
|
||||
for idx in range(0, num_locations):
|
||||
comp_unit = no_files_bkpt.GetLocationAtIndex(idx).GetAddress().GetSymbolContext(lldb.eSymbolContextCompUnit).GetCompileUnit().GetFileSpec()
|
||||
comp_unit = no_files_bkpt.GetLocationAtIndex(idx).GetAddress().GetSymbolContext(
|
||||
lldb.eSymbolContextCompUnit).GetCompileUnit().GetFileSpec()
|
||||
print("Got comp unit: ", comp_unit.GetFilename())
|
||||
if comp_unit.GetFilename() == "a.c":
|
||||
got_one_in_A = True
|
||||
@@ -69,28 +75,36 @@ class PythonBreakpointCommandSettingTestCase(TestBase):
|
||||
import TestBreakpointCommandsFromPython\n\
|
||||
TestBreakpointCommandsFromPython.PythonBreakpointCommandSettingTestCase.my_var = 20\n\
|
||||
print('Hit breakpoint')")
|
||||
self.assertTrue (error.Success(), "Failed to set the script callback body: %s."%(error.GetCString()))
|
||||
self.assertTrue(
|
||||
error.Success(),
|
||||
"Failed to set the script callback body: %s." %
|
||||
(error.GetCString()))
|
||||
|
||||
self.dbg.HandleCommand("command script import --allow-reload ./bktptcmd.py")
|
||||
self.dbg.HandleCommand(
|
||||
"command script import --allow-reload ./bktptcmd.py")
|
||||
func_bkpt.SetScriptCallbackFunction("bktptcmd.function")
|
||||
|
||||
# We will use the function that touches a text file, so remove it first:
|
||||
# We will use the function that touches a text file, so remove it
|
||||
# first:
|
||||
self.RemoveTempFile("output2.txt")
|
||||
|
||||
# Now launch the process, and do not stop at entry point.
|
||||
self.process = self.target.LaunchSimple (None, None, self.get_process_working_directory())
|
||||
self.process = self.target.LaunchSimple(
|
||||
None, None, self.get_process_working_directory())
|
||||
|
||||
self.assertTrue(self.process, PROCESS_IS_VALID)
|
||||
|
||||
# Now finish, and make sure the return value is correct.
|
||||
threads = lldbutil.get_threads_stopped_at_breakpoint (self.process, body_bkpt)
|
||||
threads = lldbutil.get_threads_stopped_at_breakpoint(
|
||||
self.process, body_bkpt)
|
||||
self.assertTrue(len(threads) == 1, "Stopped at inner breakpoint.")
|
||||
self.thread = threads[0]
|
||||
|
||||
|
||||
self.assertTrue(PythonBreakpointCommandSettingTestCase.my_var == 20)
|
||||
|
||||
# Check for the function version as well, which produced this file:
|
||||
# Remember to clean up after ourselves...
|
||||
self.assertTrue(os.path.isfile("output2.txt"),
|
||||
"'output2.txt' exists due to breakpoint command for breakpoint function.")
|
||||
self.assertTrue(
|
||||
os.path.isfile("output2.txt"),
|
||||
"'output2.txt' exists due to breakpoint command for breakpoint function.")
|
||||
self.RemoveTempFile("output2.txt")
|
||||
|
||||
@@ -5,12 +5,13 @@ Test _regexp-break command which uses regular expression matching to dispatch to
|
||||
from __future__ import print_function
|
||||
|
||||
|
||||
|
||||
import os, time
|
||||
import os
|
||||
import time
|
||||
import lldb
|
||||
from lldbsuite.test.lldbtest import *
|
||||
import lldbsuite.test.lldbutil as lldbutil
|
||||
|
||||
|
||||
class RegexpBreakCommandTestCase(TestBase):
|
||||
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
@@ -25,27 +26,47 @@ class RegexpBreakCommandTestCase(TestBase):
|
||||
TestBase.setUp(self)
|
||||
# Find the line number to break inside main().
|
||||
self.source = 'main.c'
|
||||
self.line = line_number(self.source, '// Set break point at this line.')
|
||||
self.line = line_number(
|
||||
self.source, '// Set break point at this line.')
|
||||
|
||||
def regexp_break_command(self):
|
||||
"""Test the super consie "b" command, which is analias for _regexp-break."""
|
||||
exe = os.path.join(os.getcwd(), "a.out")
|
||||
self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
|
||||
|
||||
break_results = lldbutil.run_break_set_command (self, "b %d" % self.line)
|
||||
lldbutil.check_breakpoint_result (self, break_results, file_name='main.c', line_number=self.line, num_locations=1)
|
||||
break_results = lldbutil.run_break_set_command(
|
||||
self, "b %d" %
|
||||
self.line)
|
||||
lldbutil.check_breakpoint_result(
|
||||
self,
|
||||
break_results,
|
||||
file_name='main.c',
|
||||
line_number=self.line,
|
||||
num_locations=1)
|
||||
|
||||
break_results = lldbutil.run_break_set_command (self, "b %s:%d" % (self.source, self.line))
|
||||
lldbutil.check_breakpoint_result (self, break_results, file_name='main.c', line_number=self.line, num_locations=1)
|
||||
break_results = lldbutil.run_break_set_command(
|
||||
self, "b %s:%d" % (self.source, self.line))
|
||||
lldbutil.check_breakpoint_result(
|
||||
self,
|
||||
break_results,
|
||||
file_name='main.c',
|
||||
line_number=self.line,
|
||||
num_locations=1)
|
||||
|
||||
# Check breakpoint with full file path.
|
||||
full_path = os.path.join(os.getcwd(), self.source)
|
||||
break_results = lldbutil.run_break_set_command (self, "b %s:%d" % (full_path, self.line))
|
||||
lldbutil.check_breakpoint_result (self, break_results, file_name='main.c', line_number=self.line, num_locations=1)
|
||||
break_results = lldbutil.run_break_set_command(
|
||||
self, "b %s:%d" % (full_path, self.line))
|
||||
lldbutil.check_breakpoint_result(
|
||||
self,
|
||||
break_results,
|
||||
file_name='main.c',
|
||||
line_number=self.line,
|
||||
num_locations=1)
|
||||
|
||||
self.runCmd("run", RUN_SUCCEEDED)
|
||||
|
||||
# The stop reason of the thread should be breakpoint.
|
||||
self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
|
||||
substrs = ['stopped',
|
||||
'stop reason = breakpoint'])
|
||||
substrs=['stopped',
|
||||
'stop reason = breakpoint'])
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
from __future__ import print_function
|
||||
|
||||
|
||||
def function(frame, bp_loc, dict):
|
||||
there = open("output2.txt", "w");
|
||||
print("lldb", file=there)
|
||||
there.close()
|
||||
there = open("output2.txt", "w")
|
||||
print("lldb", file=there)
|
||||
there.close()
|
||||
|
||||
@@ -5,38 +5,43 @@ Test breakpoint conditions with 'breakpoint modify -c <expr> id'.
|
||||
from __future__ import print_function
|
||||
|
||||
|
||||
|
||||
import os, time
|
||||
import os
|
||||
import time
|
||||
import re
|
||||
import lldb
|
||||
from lldbsuite.test.decorators import *
|
||||
from lldbsuite.test.lldbtest import *
|
||||
from lldbsuite.test import lldbutil
|
||||
|
||||
|
||||
class BreakpointConditionsTestCase(TestBase):
|
||||
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
|
||||
@skipIfWindows # Requires EE to support COFF on Windows (http://llvm.org/pr22232)
|
||||
# Requires EE to support COFF on Windows (http://llvm.org/pr22232)
|
||||
@skipIfWindows
|
||||
def test_breakpoint_condition_and_run_command(self):
|
||||
"""Exercise breakpoint condition with 'breakpoint modify -c <expr> id'."""
|
||||
self.build()
|
||||
self.breakpoint_conditions()
|
||||
|
||||
@skipIfWindows # Requires EE to support COFF on Windows (http://llvm.org/pr22232)
|
||||
# Requires EE to support COFF on Windows (http://llvm.org/pr22232)
|
||||
@skipIfWindows
|
||||
def test_breakpoint_condition_inline_and_run_command(self):
|
||||
"""Exercise breakpoint condition inline with 'breakpoint set'."""
|
||||
self.build()
|
||||
self.breakpoint_conditions(inline=True)
|
||||
|
||||
@skipIfWindows # Requires EE to support COFF on Windows (http://llvm.org/pr22232)
|
||||
# Requires EE to support COFF on Windows (http://llvm.org/pr22232)
|
||||
@skipIfWindows
|
||||
@add_test_categories(['pyapi'])
|
||||
def test_breakpoint_condition_and_python_api(self):
|
||||
"""Use Python APIs to set breakpoint conditions."""
|
||||
self.build()
|
||||
self.breakpoint_conditions_python()
|
||||
|
||||
@skipIfWindows # Requires EE to support COFF on Windows (http://llvm.org/pr22232)
|
||||
# Requires EE to support COFF on Windows (http://llvm.org/pr22232)
|
||||
@skipIfWindows
|
||||
@add_test_categories(['pyapi'])
|
||||
def test_breakpoint_invalid_condition_and_python_api(self):
|
||||
"""Use Python APIs to set breakpoint conditions."""
|
||||
@@ -47,8 +52,10 @@ class BreakpointConditionsTestCase(TestBase):
|
||||
# Call super's setUp().
|
||||
TestBase.setUp(self)
|
||||
# Find the line number to of function 'c'.
|
||||
self.line1 = line_number('main.c', '// Find the line number of function "c" here.')
|
||||
self.line2 = line_number('main.c', "// Find the line number of c's parent call here.")
|
||||
self.line1 = line_number(
|
||||
'main.c', '// Find the line number of function "c" here.')
|
||||
self.line2 = line_number(
|
||||
'main.c', "// Find the line number of c's parent call here.")
|
||||
|
||||
def breakpoint_conditions(self, inline=False):
|
||||
"""Exercise breakpoint condition with 'breakpoint modify -c <expr> id'."""
|
||||
@@ -57,10 +64,16 @@ class BreakpointConditionsTestCase(TestBase):
|
||||
|
||||
if inline:
|
||||
# Create a breakpoint by function name 'c' and set the condition.
|
||||
lldbutil.run_break_set_by_symbol (self, "c", extra_options="-c 'val == 3'", num_expected_locations=1, sym_exact=True)
|
||||
lldbutil.run_break_set_by_symbol(
|
||||
self,
|
||||
"c",
|
||||
extra_options="-c 'val == 3'",
|
||||
num_expected_locations=1,
|
||||
sym_exact=True)
|
||||
else:
|
||||
# Create a breakpoint by function name 'c'.
|
||||
lldbutil.run_break_set_by_symbol (self, "c", num_expected_locations=1, sym_exact=True)
|
||||
lldbutil.run_break_set_by_symbol(
|
||||
self, "c", num_expected_locations=1, sym_exact=True)
|
||||
|
||||
# And set a condition on the breakpoint to stop on when 'val == 3'.
|
||||
self.runCmd("breakpoint modify -c 'val == 3' 1")
|
||||
@@ -70,42 +83,50 @@ class BreakpointConditionsTestCase(TestBase):
|
||||
|
||||
# The process should be stopped at this point.
|
||||
self.expect("process status", PROCESS_STOPPED,
|
||||
patterns = ['Process .* stopped'])
|
||||
patterns=['Process .* stopped'])
|
||||
|
||||
# 'frame variable --show-types val' should return 3 due to breakpoint condition.
|
||||
self.expect("frame variable --show-types val", VARIABLES_DISPLAYED_CORRECTLY,
|
||||
startstr = '(int) val = 3')
|
||||
self.expect(
|
||||
"frame variable --show-types val",
|
||||
VARIABLES_DISPLAYED_CORRECTLY,
|
||||
startstr='(int) val = 3')
|
||||
|
||||
# Also check the hit count, which should be 3, by design.
|
||||
self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
|
||||
substrs = ["resolved = 1",
|
||||
"Condition: val == 3",
|
||||
"hit count = 1"])
|
||||
substrs=["resolved = 1",
|
||||
"Condition: val == 3",
|
||||
"hit count = 1"])
|
||||
|
||||
# The frame #0 should correspond to main.c:36, the executable statement
|
||||
# in function name 'c'. And the parent frame should point to main.c:24.
|
||||
# in function name 'c'. And the parent frame should point to
|
||||
# main.c:24.
|
||||
self.expect("thread backtrace", STOPPED_DUE_TO_BREAKPOINT_CONDITION,
|
||||
#substrs = ["stop reason = breakpoint"],
|
||||
patterns = ["frame #0.*main.c:%d" % self.line1,
|
||||
"frame #1.*main.c:%d" % self.line2])
|
||||
#substrs = ["stop reason = breakpoint"],
|
||||
patterns=["frame #0.*main.c:%d" % self.line1,
|
||||
"frame #1.*main.c:%d" % self.line2])
|
||||
|
||||
# Test that "breakpoint modify -c ''" clears the condition for the last
|
||||
# created breakpoint, so that when the breakpoint hits, val == 1.
|
||||
self.runCmd("process kill")
|
||||
self.runCmd("breakpoint modify -c ''")
|
||||
self.expect("breakpoint list -f", BREAKPOINT_STATE_CORRECT, matching=False,
|
||||
substrs = ["Condition:"])
|
||||
self.expect(
|
||||
"breakpoint list -f",
|
||||
BREAKPOINT_STATE_CORRECT,
|
||||
matching=False,
|
||||
substrs=["Condition:"])
|
||||
|
||||
# Now run the program again.
|
||||
self.runCmd("run", RUN_SUCCEEDED)
|
||||
|
||||
# The process should be stopped at this point.
|
||||
self.expect("process status", PROCESS_STOPPED,
|
||||
patterns = ['Process .* stopped'])
|
||||
patterns=['Process .* stopped'])
|
||||
|
||||
# 'frame variable --show-types val' should return 1 since it is the first breakpoint hit.
|
||||
self.expect("frame variable --show-types val", VARIABLES_DISPLAYED_CORRECTLY,
|
||||
startstr = '(int) val = 1')
|
||||
self.expect(
|
||||
"frame variable --show-types val",
|
||||
VARIABLES_DISPLAYED_CORRECTLY,
|
||||
startstr='(int) val = 1')
|
||||
|
||||
self.runCmd("process kill")
|
||||
|
||||
@@ -124,7 +145,8 @@ class BreakpointConditionsTestCase(TestBase):
|
||||
breakpoint.GetNumLocations() == 1,
|
||||
VALID_BREAKPOINT)
|
||||
|
||||
# We didn't associate a thread index with the breakpoint, so it should be invalid.
|
||||
# We didn't associate a thread index with the breakpoint, so it should
|
||||
# be invalid.
|
||||
self.assertTrue(breakpoint.GetThreadIndex() == lldb.UINT32_MAX,
|
||||
"The thread index should be invalid")
|
||||
# The thread name should be invalid, too.
|
||||
@@ -133,7 +155,8 @@ class BreakpointConditionsTestCase(TestBase):
|
||||
|
||||
# Let's set the thread index for this breakpoint and verify that it is,
|
||||
# indeed, being set correctly.
|
||||
breakpoint.SetThreadIndex(1) # There's only one thread for the process.
|
||||
# There's only one thread for the process.
|
||||
breakpoint.SetThreadIndex(1)
|
||||
self.assertTrue(breakpoint.GetThreadIndex() == 1,
|
||||
"The thread index has been set correctly")
|
||||
|
||||
@@ -147,16 +170,19 @@ class BreakpointConditionsTestCase(TestBase):
|
||||
# Set the condition on the breakpoint location.
|
||||
location.SetCondition('val == 3')
|
||||
self.expect(location.GetCondition(), exe=False,
|
||||
startstr = 'val == 3')
|
||||
startstr='val == 3')
|
||||
|
||||
# Now launch the process, and do not stop at entry point.
|
||||
process = target.LaunchSimple (None, None, self.get_process_working_directory())
|
||||
process = target.LaunchSimple(
|
||||
None, None, self.get_process_working_directory())
|
||||
self.assertTrue(process, PROCESS_IS_VALID)
|
||||
|
||||
# Frame #0 should be on self.line1 and the break condition should hold.
|
||||
from lldbsuite.test.lldbutil import get_stopped_thread
|
||||
thread = get_stopped_thread(process, lldb.eStopReasonBreakpoint)
|
||||
self.assertTrue(thread.IsValid(), "There should be a thread stopped due to breakpoint condition")
|
||||
self.assertTrue(
|
||||
thread.IsValid(),
|
||||
"There should be a thread stopped due to breakpoint condition")
|
||||
frame0 = thread.GetFrameAtIndex(0)
|
||||
var = frame0.FindValue('val', lldb.eValueTypeVariableArgument)
|
||||
self.assertTrue(frame0.GetLineEntry().GetLine() == self.line1 and
|
||||
@@ -168,7 +194,8 @@ class BreakpointConditionsTestCase(TestBase):
|
||||
# Test that the condition expression didn't create a result variable:
|
||||
options = lldb.SBExpressionOptions()
|
||||
value = frame0.EvaluateExpression("$0", options)
|
||||
self.assertTrue(value.GetError().Fail(), "Conditions should not make result variables.")
|
||||
self.assertTrue(value.GetError().Fail(),
|
||||
"Conditions should not make result variables.")
|
||||
process.Continue()
|
||||
|
||||
def breakpoint_invalid_conditions_python(self):
|
||||
@@ -189,21 +216,22 @@ class BreakpointConditionsTestCase(TestBase):
|
||||
# Set the condition on the breakpoint.
|
||||
breakpoint.SetCondition('no_such_variable == not_this_one_either')
|
||||
self.expect(breakpoint.GetCondition(), exe=False,
|
||||
startstr = 'no_such_variable == not_this_one_either')
|
||||
startstr='no_such_variable == not_this_one_either')
|
||||
|
||||
# Now launch the process, and do not stop at entry point.
|
||||
process = target.LaunchSimple (None, None, self.get_process_working_directory())
|
||||
process = target.LaunchSimple(
|
||||
None, None, self.get_process_working_directory())
|
||||
self.assertTrue(process, PROCESS_IS_VALID)
|
||||
|
||||
# Frame #0 should be on self.line1 and the break condition should hold.
|
||||
from lldbsuite.test.lldbutil import get_stopped_thread
|
||||
thread = get_stopped_thread(process, lldb.eStopReasonBreakpoint)
|
||||
self.assertTrue(thread.IsValid(), "There should be a thread stopped due to breakpoint condition")
|
||||
self.assertTrue(
|
||||
thread.IsValid(),
|
||||
"There should be a thread stopped due to breakpoint condition")
|
||||
frame0 = thread.GetFrameAtIndex(0)
|
||||
var = frame0.FindValue('val', lldb.eValueTypeVariableArgument)
|
||||
self.assertTrue(frame0.GetLineEntry().GetLine() == self.line1)
|
||||
|
||||
# The hit count for the breakpoint should be 1.
|
||||
self.assertTrue(breakpoint.GetHitCount() == 1)
|
||||
|
||||
|
||||
|
||||
@@ -5,47 +5,56 @@ Test lldb breakpoint ids.
|
||||
from __future__ import print_function
|
||||
|
||||
|
||||
|
||||
import os, time
|
||||
import os
|
||||
import time
|
||||
import lldb
|
||||
from lldbsuite.test.lldbtest import *
|
||||
import lldbsuite.test.lldbutil as lldbutil
|
||||
|
||||
|
||||
class BreakpointIDTestCase(TestBase):
|
||||
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
|
||||
def test (self):
|
||||
def test(self):
|
||||
self.build()
|
||||
|
||||
exe = os.path.join (os.getcwd(), "a.out")
|
||||
exe = os.path.join(os.getcwd(), "a.out")
|
||||
self.expect("file " + exe,
|
||||
patterns = [ "Current executable set to .*a.out" ])
|
||||
patterns=["Current executable set to .*a.out"])
|
||||
|
||||
|
||||
bpno = lldbutil.run_break_set_by_symbol (self, 'product', num_expected_locations=-1, sym_exact=False)
|
||||
self.assertTrue (bpno == 1, "First breakpoint number is 1.")
|
||||
bpno = lldbutil.run_break_set_by_symbol(
|
||||
self, 'product', num_expected_locations=-1, sym_exact=False)
|
||||
self.assertTrue(bpno == 1, "First breakpoint number is 1.")
|
||||
|
||||
bpno = lldbutil.run_break_set_by_symbol (self, 'sum', num_expected_locations=-1, sym_exact=False)
|
||||
self.assertTrue (bpno == 2, "Second breakpoint number is 2.")
|
||||
bpno = lldbutil.run_break_set_by_symbol(
|
||||
self, 'sum', num_expected_locations=-1, sym_exact=False)
|
||||
self.assertTrue(bpno == 2, "Second breakpoint number is 2.")
|
||||
|
||||
bpno = lldbutil.run_break_set_by_symbol (self, 'junk', num_expected_locations=0, sym_exact=False)
|
||||
self.assertTrue (bpno == 3, "Third breakpoint number is 3.")
|
||||
bpno = lldbutil.run_break_set_by_symbol(
|
||||
self, 'junk', num_expected_locations=0, sym_exact=False)
|
||||
self.assertTrue(bpno == 3, "Third breakpoint number is 3.")
|
||||
|
||||
self.expect ("breakpoint disable 1.1 - 2.2 ",
|
||||
COMMAND_FAILED_AS_EXPECTED, error = True,
|
||||
startstr = "error: Invalid range: Ranges that specify particular breakpoint locations must be within the same major breakpoint; you specified two different major breakpoints, 1 and 2.")
|
||||
self.expect(
|
||||
"breakpoint disable 1.1 - 2.2 ",
|
||||
COMMAND_FAILED_AS_EXPECTED,
|
||||
error=True,
|
||||
startstr="error: Invalid range: Ranges that specify particular breakpoint locations must be within the same major breakpoint; you specified two different major breakpoints, 1 and 2.")
|
||||
|
||||
self.expect ("breakpoint disable 2 - 2.2",
|
||||
COMMAND_FAILED_AS_EXPECTED, error = True,
|
||||
startstr = "error: Invalid breakpoint id range: Either both ends of range must specify a breakpoint location, or neither can specify a breakpoint location.")
|
||||
self.expect(
|
||||
"breakpoint disable 2 - 2.2",
|
||||
COMMAND_FAILED_AS_EXPECTED,
|
||||
error=True,
|
||||
startstr="error: Invalid breakpoint id range: Either both ends of range must specify a breakpoint location, or neither can specify a breakpoint location.")
|
||||
|
||||
self.expect ("breakpoint disable 2.1 - 2",
|
||||
COMMAND_FAILED_AS_EXPECTED, error = True,
|
||||
startstr = "error: Invalid breakpoint id range: Either both ends of range must specify a breakpoint location, or neither can specify a breakpoint location.")
|
||||
self.expect(
|
||||
"breakpoint disable 2.1 - 2",
|
||||
COMMAND_FAILED_AS_EXPECTED,
|
||||
error=True,
|
||||
startstr="error: Invalid breakpoint id range: Either both ends of range must specify a breakpoint location, or neither can specify a breakpoint location.")
|
||||
|
||||
self.expect ("breakpoint disable 2.1 - 2.2",
|
||||
startstr = "2 breakpoints disabled.")
|
||||
self.expect("breakpoint disable 2.1 - 2.2",
|
||||
startstr="2 breakpoints disabled.")
|
||||
|
||||
self.expect ("breakpoint enable 2.*",
|
||||
patterns = [ ".* breakpoints enabled."] )
|
||||
self.expect("breakpoint enable 2.*",
|
||||
patterns=[".* breakpoints enabled."])
|
||||
|
||||
@@ -5,14 +5,15 @@ Test breakpoint ignore count features.
|
||||
from __future__ import print_function
|
||||
|
||||
|
||||
|
||||
import os, time
|
||||
import os
|
||||
import time
|
||||
import re
|
||||
import lldb
|
||||
from lldbsuite.test.decorators import *
|
||||
from lldbsuite.test.lldbtest import *
|
||||
from lldbsuite.test import lldbutil
|
||||
|
||||
|
||||
class BreakpointIgnoreCountTestCase(TestBase):
|
||||
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
@@ -32,11 +33,16 @@ class BreakpointIgnoreCountTestCase(TestBase):
|
||||
# Call super's setUp().
|
||||
TestBase.setUp(self)
|
||||
# Find the line number to of function 'c'.
|
||||
self.line1 = line_number('main.c', '// Find the line number of function "c" here.')
|
||||
self.line2 = line_number('main.c', '// b(2) -> c(2) Find the call site of b(2).')
|
||||
self.line3 = line_number('main.c', '// a(3) -> c(3) Find the call site of c(3).')
|
||||
self.line4 = line_number('main.c', '// a(3) -> c(3) Find the call site of a(3).')
|
||||
self.line5 = line_number('main.c', '// Find the call site of c in main.')
|
||||
self.line1 = line_number(
|
||||
'main.c', '// Find the line number of function "c" here.')
|
||||
self.line2 = line_number(
|
||||
'main.c', '// b(2) -> c(2) Find the call site of b(2).')
|
||||
self.line3 = line_number(
|
||||
'main.c', '// a(3) -> c(3) Find the call site of c(3).')
|
||||
self.line4 = line_number(
|
||||
'main.c', '// a(3) -> c(3) Find the call site of a(3).')
|
||||
self.line5 = line_number(
|
||||
'main.c', '// Find the call site of c in main.')
|
||||
|
||||
def breakpoint_ignore_count(self):
|
||||
"""Exercise breakpoint ignore count with 'breakpoint set -i <count>'."""
|
||||
@@ -44,26 +50,33 @@ class BreakpointIgnoreCountTestCase(TestBase):
|
||||
self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
|
||||
|
||||
# Create a breakpoint in main.c at line1.
|
||||
lldbutil.run_break_set_by_file_and_line (self, 'main.c', self.line1, extra_options='-i 1', num_expected_locations=1, loc_exact=True)
|
||||
lldbutil.run_break_set_by_file_and_line(
|
||||
self,
|
||||
'main.c',
|
||||
self.line1,
|
||||
extra_options='-i 1',
|
||||
num_expected_locations=1,
|
||||
loc_exact=True)
|
||||
|
||||
# Now run the program.
|
||||
self.runCmd("run", RUN_SUCCEEDED)
|
||||
|
||||
# The process should be stopped at this point.
|
||||
self.expect("process status", PROCESS_STOPPED,
|
||||
patterns = ['Process .* stopped'])
|
||||
patterns=['Process .* stopped'])
|
||||
|
||||
# Also check the hit count, which should be 2, due to ignore count of 1.
|
||||
# Also check the hit count, which should be 2, due to ignore count of
|
||||
# 1.
|
||||
self.expect("breakpoint list -f", BREAKPOINT_HIT_THRICE,
|
||||
substrs = ["resolved = 1",
|
||||
"hit count = 2"])
|
||||
substrs=["resolved = 1",
|
||||
"hit count = 2"])
|
||||
|
||||
# The frame #0 should correspond to main.c:37, the executable statement
|
||||
# in function name 'c'. And frame #2 should point to main.c:45.
|
||||
self.expect("thread backtrace", STOPPED_DUE_TO_BREAKPOINT_IGNORE_COUNT,
|
||||
#substrs = ["stop reason = breakpoint"],
|
||||
patterns = ["frame #0.*main.c:%d" % self.line1,
|
||||
"frame #2.*main.c:%d" % self.line2])
|
||||
#substrs = ["stop reason = breakpoint"],
|
||||
patterns=["frame #0.*main.c:%d" % self.line1,
|
||||
"frame #2.*main.c:%d" % self.line2])
|
||||
|
||||
# continue -i 1 is the same as setting the ignore count to 1 again, try that:
|
||||
# Now run the program.
|
||||
@@ -71,21 +84,20 @@ class BreakpointIgnoreCountTestCase(TestBase):
|
||||
|
||||
# The process should be stopped at this point.
|
||||
self.expect("process status", PROCESS_STOPPED,
|
||||
patterns = ['Process .* stopped'])
|
||||
patterns=['Process .* stopped'])
|
||||
|
||||
# Also check the hit count, which should be 2, due to ignore count of 1.
|
||||
# Also check the hit count, which should be 2, due to ignore count of
|
||||
# 1.
|
||||
self.expect("breakpoint list -f", BREAKPOINT_HIT_THRICE,
|
||||
substrs = ["resolved = 1",
|
||||
"hit count = 4"])
|
||||
substrs=["resolved = 1",
|
||||
"hit count = 4"])
|
||||
|
||||
# The frame #0 should correspond to main.c:37, the executable statement
|
||||
# in function name 'c'. And frame #2 should point to main.c:45.
|
||||
self.expect("thread backtrace", STOPPED_DUE_TO_BREAKPOINT_IGNORE_COUNT,
|
||||
#substrs = ["stop reason = breakpoint"],
|
||||
patterns = ["frame #0.*main.c:%d" % self.line1,
|
||||
"frame #1.*main.c:%d" % self.line5])
|
||||
|
||||
|
||||
#substrs = ["stop reason = breakpoint"],
|
||||
patterns=["frame #0.*main.c:%d" % self.line1,
|
||||
"frame #1.*main.c:%d" % self.line5])
|
||||
|
||||
def breakpoint_ignore_count_python(self):
|
||||
"""Use Python APIs to set breakpoint ignore count."""
|
||||
@@ -114,15 +126,18 @@ class BreakpointIgnoreCountTestCase(TestBase):
|
||||
"SetIgnoreCount() works correctly")
|
||||
|
||||
# Now launch the process, and do not stop at entry point.
|
||||
process = target.LaunchSimple (None, None, self.get_process_working_directory())
|
||||
process = target.LaunchSimple(
|
||||
None, None, self.get_process_working_directory())
|
||||
self.assertTrue(process, PROCESS_IS_VALID)
|
||||
|
||||
# Frame#0 should be on main.c:37, frame#1 should be on main.c:25, and
|
||||
# frame#2 should be on main.c:48.
|
||||
#lldbutil.print_stacktraces(process)
|
||||
# lldbutil.print_stacktraces(process)
|
||||
from lldbsuite.test.lldbutil import get_stopped_thread
|
||||
thread = get_stopped_thread(process, lldb.eStopReasonBreakpoint)
|
||||
self.assertTrue(thread.IsValid(), "There should be a thread stopped due to breakpoint")
|
||||
self.assertTrue(
|
||||
thread.IsValid(),
|
||||
"There should be a thread stopped due to breakpoint")
|
||||
frame0 = thread.GetFrameAtIndex(0)
|
||||
frame1 = thread.GetFrameAtIndex(1)
|
||||
frame2 = thread.GetFrameAtIndex(2)
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
"""
|
||||
Test specific to MIPS
|
||||
Test specific to MIPS
|
||||
"""
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import os, time
|
||||
import os
|
||||
import time
|
||||
import re
|
||||
import unittest2
|
||||
import lldb
|
||||
@@ -12,6 +13,7 @@ from lldbsuite.test.decorators import *
|
||||
from lldbsuite.test.lldbtest import *
|
||||
from lldbsuite.test import lldbutil
|
||||
|
||||
|
||||
class AvoidBreakpointInDelaySlotAPITestCase(TestBase):
|
||||
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
@@ -21,8 +23,8 @@ class AvoidBreakpointInDelaySlotAPITestCase(TestBase):
|
||||
self.build()
|
||||
exe = os.path.join(os.getcwd(), "a.out")
|
||||
self.expect("file " + exe,
|
||||
patterns = [ "Current executable set to .*a.out.*" ])
|
||||
|
||||
patterns=["Current executable set to .*a.out.*"])
|
||||
|
||||
# Create a target by the debugger.
|
||||
target = self.dbg.CreateTarget(exe)
|
||||
self.assertTrue(target, VALID_TARGET)
|
||||
@@ -33,7 +35,8 @@ class AvoidBreakpointInDelaySlotAPITestCase(TestBase):
|
||||
VALID_BREAKPOINT)
|
||||
|
||||
# Now launch the process, and do not stop at entry point.
|
||||
process = target.LaunchSimple (None, None, self.get_process_working_directory())
|
||||
process = target.LaunchSimple(
|
||||
None, None, self.get_process_working_directory())
|
||||
self.assertTrue(process, PROCESS_IS_VALID)
|
||||
|
||||
list = target.FindFunctions('foo', lldb.eFunctionNameTypeAuto)
|
||||
@@ -44,7 +47,7 @@ class AvoidBreakpointInDelaySlotAPITestCase(TestBase):
|
||||
self.assertTrue(function)
|
||||
self.function(function, target)
|
||||
|
||||
def function (self, function, target):
|
||||
def function(self, function, target):
|
||||
"""Iterate over instructions in function and place a breakpoint on delay slot instruction"""
|
||||
# Get the list of all instructions in the function
|
||||
insts = function.GetInstructions(target)
|
||||
@@ -56,7 +59,7 @@ class AvoidBreakpointInDelaySlotAPITestCase(TestBase):
|
||||
branchinstaddress = inst.GetAddress().GetLoadAddress(target)
|
||||
|
||||
# Get next instruction i.e delay slot instruction.
|
||||
delayinst = insts.GetInstructionAtIndex(i+1)
|
||||
delayinst = insts.GetInstructionAtIndex(i + 1)
|
||||
delayinstaddr = delayinst.GetAddress().GetLoadAddress(target)
|
||||
|
||||
# Set breakpoint on delay slot instruction
|
||||
@@ -71,9 +74,10 @@ class AvoidBreakpointInDelaySlotAPITestCase(TestBase):
|
||||
|
||||
# Get the address where breakpoint is actually set.
|
||||
bpaddr = location.GetLoadAddress()
|
||||
|
||||
# Breakpoint address should be adjusted to the address of branch instruction.
|
||||
self.assertTrue(branchinstaddress == bpaddr)
|
||||
|
||||
# Breakpoint address should be adjusted to the address of
|
||||
# branch instruction.
|
||||
self.assertTrue(branchinstaddress == bpaddr)
|
||||
i += 1
|
||||
else:
|
||||
i += 1
|
||||
|
||||
@@ -6,14 +6,15 @@ parser.
|
||||
from __future__ import print_function
|
||||
|
||||
|
||||
|
||||
import os, time
|
||||
import os
|
||||
import time
|
||||
import lldb
|
||||
from lldbsuite.test.lldbtest import *
|
||||
import lldbsuite.test.lldbutil as lldbutil
|
||||
import shutil
|
||||
import subprocess
|
||||
|
||||
|
||||
class TestBreakpointLanguage(TestBase):
|
||||
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
@@ -23,7 +24,7 @@ class TestBreakpointLanguage(TestBase):
|
||||
TestBase.setUp(self)
|
||||
# Find the line number to break inside main().
|
||||
|
||||
def check_location_file (self, bp, loc, test_name):
|
||||
def check_location_file(self, bp, loc, test_name):
|
||||
bp_loc = bp.GetLocationAtIndex(loc)
|
||||
addr = bp_loc.GetAddress()
|
||||
comp_unit = addr.GetCompileUnit()
|
||||
@@ -37,22 +38,40 @@ class TestBreakpointLanguage(TestBase):
|
||||
# Create a target by the debugger.
|
||||
exe = os.path.join(os.getcwd(), "a.out")
|
||||
error = lldb.SBError()
|
||||
# Don't read in dependencies so we don't come across false matches that
|
||||
# Don't read in dependencies so we don't come across false matches that
|
||||
# add unwanted breakpoint hits.
|
||||
self.target = self.dbg.CreateTarget(exe, None, None, False, error)
|
||||
self.assertTrue(self.target, VALID_TARGET)
|
||||
|
||||
cpp_bp = self.target.BreakpointCreateByRegex("func_from", lldb.eLanguageTypeC_plus_plus, lldb.SBFileSpecList(), lldb.SBFileSpecList())
|
||||
self.assertTrue(cpp_bp.GetNumLocations() == 1, "Only one C++ symbol matches")
|
||||
cpp_bp = self.target.BreakpointCreateByRegex(
|
||||
"func_from",
|
||||
lldb.eLanguageTypeC_plus_plus,
|
||||
lldb.SBFileSpecList(),
|
||||
lldb.SBFileSpecList())
|
||||
self.assertTrue(
|
||||
cpp_bp.GetNumLocations() == 1,
|
||||
"Only one C++ symbol matches")
|
||||
self.assertTrue(self.check_location_file(cpp_bp, 0, "b.cpp"))
|
||||
|
||||
c_bp = self.target.BreakpointCreateByRegex("func_from", lldb.eLanguageTypeC, lldb.SBFileSpecList(), lldb.SBFileSpecList())
|
||||
self.assertTrue(c_bp.GetNumLocations() == 1, "Only one C symbol matches")
|
||||
c_bp = self.target.BreakpointCreateByRegex(
|
||||
"func_from",
|
||||
lldb.eLanguageTypeC,
|
||||
lldb.SBFileSpecList(),
|
||||
lldb.SBFileSpecList())
|
||||
self.assertTrue(
|
||||
c_bp.GetNumLocations() == 1,
|
||||
"Only one C symbol matches")
|
||||
self.assertTrue(self.check_location_file(c_bp, 0, "a.c"))
|
||||
|
||||
objc_bp = self.target.BreakpointCreateByRegex("func_from", lldb.eLanguageTypeObjC, lldb.SBFileSpecList(), lldb.SBFileSpecList())
|
||||
self.assertTrue(objc_bp.GetNumLocations() == 0, "No ObjC symbol matches")
|
||||
|
||||
|
||||
objc_bp = self.target.BreakpointCreateByRegex(
|
||||
"func_from",
|
||||
lldb.eLanguageTypeObjC,
|
||||
lldb.SBFileSpecList(),
|
||||
lldb.SBFileSpecList())
|
||||
self.assertTrue(
|
||||
objc_bp.GetNumLocations() == 0,
|
||||
"No ObjC symbol matches")
|
||||
|
||||
def test_by_name_breakpoint_language(self):
|
||||
"""Test that the name regex breakpoint commands obey the language filter."""
|
||||
|
||||
@@ -60,26 +79,59 @@ class TestBreakpointLanguage(TestBase):
|
||||
# Create a target by the debugger.
|
||||
exe = os.path.join(os.getcwd(), "a.out")
|
||||
error = lldb.SBError()
|
||||
# Don't read in dependencies so we don't come across false matches that
|
||||
# Don't read in dependencies so we don't come across false matches that
|
||||
# add unwanted breakpoint hits.
|
||||
self.target = self.dbg.CreateTarget(exe, None, None, False, error)
|
||||
self.assertTrue(self.target, VALID_TARGET)
|
||||
|
||||
cpp_bp = self.target.BreakpointCreateByName("func_from_cpp", lldb.eFunctionNameTypeAuto, lldb.eLanguageTypeC_plus_plus, lldb.SBFileSpecList(), lldb.SBFileSpecList())
|
||||
self.assertTrue(cpp_bp.GetNumLocations() == 1, "Only one C++ symbol matches")
|
||||
cpp_bp = self.target.BreakpointCreateByName(
|
||||
"func_from_cpp",
|
||||
lldb.eFunctionNameTypeAuto,
|
||||
lldb.eLanguageTypeC_plus_plus,
|
||||
lldb.SBFileSpecList(),
|
||||
lldb.SBFileSpecList())
|
||||
self.assertTrue(
|
||||
cpp_bp.GetNumLocations() == 1,
|
||||
"Only one C++ symbol matches")
|
||||
self.assertTrue(self.check_location_file(cpp_bp, 0, "b.cpp"))
|
||||
|
||||
no_cpp_bp = self.target.BreakpointCreateByName("func_from_c", lldb.eFunctionNameTypeAuto, lldb.eLanguageTypeC_plus_plus, lldb.SBFileSpecList(), lldb.SBFileSpecList())
|
||||
self.assertTrue(no_cpp_bp.GetNumLocations() == 0, "And the C one doesn't match")
|
||||
no_cpp_bp = self.target.BreakpointCreateByName(
|
||||
"func_from_c",
|
||||
lldb.eFunctionNameTypeAuto,
|
||||
lldb.eLanguageTypeC_plus_plus,
|
||||
lldb.SBFileSpecList(),
|
||||
lldb.SBFileSpecList())
|
||||
self.assertTrue(
|
||||
no_cpp_bp.GetNumLocations() == 0,
|
||||
"And the C one doesn't match")
|
||||
|
||||
c_bp = self.target.BreakpointCreateByName("func_from_c", lldb.eFunctionNameTypeAuto, lldb.eLanguageTypeC, lldb.SBFileSpecList(), lldb.SBFileSpecList())
|
||||
self.assertTrue(c_bp.GetNumLocations() == 1, "Only one C symbol matches")
|
||||
c_bp = self.target.BreakpointCreateByName(
|
||||
"func_from_c",
|
||||
lldb.eFunctionNameTypeAuto,
|
||||
lldb.eLanguageTypeC,
|
||||
lldb.SBFileSpecList(),
|
||||
lldb.SBFileSpecList())
|
||||
self.assertTrue(
|
||||
c_bp.GetNumLocations() == 1,
|
||||
"Only one C symbol matches")
|
||||
self.assertTrue(self.check_location_file(c_bp, 0, "a.c"))
|
||||
|
||||
no_c_bp = self.target.BreakpointCreateByName("func_from_cpp", lldb.eFunctionNameTypeAuto, lldb.eLanguageTypeC, lldb.SBFileSpecList(), lldb.SBFileSpecList())
|
||||
self.assertTrue(no_c_bp.GetNumLocations() == 0, "And the C++ one doesn't match")
|
||||
|
||||
objc_bp = self.target.BreakpointCreateByName("func_from_cpp", lldb.eFunctionNameTypeAuto, lldb.eLanguageTypeObjC, lldb.SBFileSpecList(), lldb.SBFileSpecList())
|
||||
self.assertTrue(objc_bp.GetNumLocations() == 0, "No ObjC symbol matches")
|
||||
|
||||
no_c_bp = self.target.BreakpointCreateByName(
|
||||
"func_from_cpp",
|
||||
lldb.eFunctionNameTypeAuto,
|
||||
lldb.eLanguageTypeC,
|
||||
lldb.SBFileSpecList(),
|
||||
lldb.SBFileSpecList())
|
||||
self.assertTrue(
|
||||
no_c_bp.GetNumLocations() == 0,
|
||||
"And the C++ one doesn't match")
|
||||
|
||||
objc_bp = self.target.BreakpointCreateByName(
|
||||
"func_from_cpp",
|
||||
lldb.eFunctionNameTypeAuto,
|
||||
lldb.eLanguageTypeObjC,
|
||||
lldb.SBFileSpecList(),
|
||||
lldb.SBFileSpecList())
|
||||
self.assertTrue(
|
||||
objc_bp.GetNumLocations() == 0,
|
||||
"No ObjC symbol matches")
|
||||
|
||||
@@ -5,13 +5,14 @@ Test breakpoint commands for a breakpoint ID with multiple locations.
|
||||
from __future__ import print_function
|
||||
|
||||
|
||||
|
||||
import os, time
|
||||
import os
|
||||
import time
|
||||
import lldb
|
||||
from lldbsuite.test.decorators import *
|
||||
from lldbsuite.test.lldbtest import *
|
||||
from lldbsuite.test import lldbutil
|
||||
|
||||
|
||||
class BreakpointLocationsTestCase(TestBase):
|
||||
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
@@ -34,55 +35,72 @@ class BreakpointLocationsTestCase(TestBase):
|
||||
self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
|
||||
|
||||
# This should create a breakpoint with 3 locations.
|
||||
lldbutil.run_break_set_by_file_and_line (self, "main.c", self.line, num_expected_locations=3)
|
||||
lldbutil.run_break_set_by_file_and_line(
|
||||
self, "main.c", self.line, num_expected_locations=3)
|
||||
|
||||
# The breakpoint list should show 3 locations.
|
||||
self.expect("breakpoint list -f", "Breakpoint locations shown correctly",
|
||||
substrs = ["1: file = 'main.c', line = %d, exact_match = 0, locations = 3" % self.line],
|
||||
patterns = ["where = a.out`func_inlined .+unresolved, hit count = 0",
|
||||
"where = a.out`main .+\[inlined\].+unresolved, hit count = 0"])
|
||||
self.expect(
|
||||
"breakpoint list -f",
|
||||
"Breakpoint locations shown correctly",
|
||||
substrs=[
|
||||
"1: file = 'main.c', line = %d, exact_match = 0, locations = 3" %
|
||||
self.line],
|
||||
patterns=[
|
||||
"where = a.out`func_inlined .+unresolved, hit count = 0",
|
||||
"where = a.out`main .+\[inlined\].+unresolved, hit count = 0"])
|
||||
|
||||
# The 'breakpoint disable 3.*' command should fail gracefully.
|
||||
self.expect("breakpoint disable 3.*",
|
||||
"Disabling an invalid breakpoint should fail gracefully",
|
||||
error=True,
|
||||
startstr = "error: '3' is not a valid breakpoint ID.")
|
||||
startstr="error: '3' is not a valid breakpoint ID.")
|
||||
|
||||
# The 'breakpoint disable 1.*' command should disable all 3 locations.
|
||||
self.expect("breakpoint disable 1.*", "All 3 breakpoint locatons disabled correctly",
|
||||
startstr = "3 breakpoints disabled.")
|
||||
self.expect(
|
||||
"breakpoint disable 1.*",
|
||||
"All 3 breakpoint locatons disabled correctly",
|
||||
startstr="3 breakpoints disabled.")
|
||||
|
||||
# Run the program.
|
||||
self.runCmd("run", RUN_SUCCEEDED)
|
||||
|
||||
# We should not stopped on any breakpoint at all.
|
||||
self.expect("process status", "No stopping on any disabled breakpoint",
|
||||
patterns = ["^Process [0-9]+ exited with status = 0"])
|
||||
patterns=["^Process [0-9]+ exited with status = 0"])
|
||||
|
||||
# The 'breakpoint enable 1.*' command should enable all 3 breakpoints.
|
||||
self.expect("breakpoint enable 1.*", "All 3 breakpoint locatons enabled correctly",
|
||||
startstr = "3 breakpoints enabled.")
|
||||
self.expect(
|
||||
"breakpoint enable 1.*",
|
||||
"All 3 breakpoint locatons enabled correctly",
|
||||
startstr="3 breakpoints enabled.")
|
||||
|
||||
# The 'breakpoint disable 1.1' command should disable 1 location.
|
||||
self.expect("breakpoint disable 1.1", "1 breakpoint locatons disabled correctly",
|
||||
startstr = "1 breakpoints disabled.")
|
||||
self.expect(
|
||||
"breakpoint disable 1.1",
|
||||
"1 breakpoint locatons disabled correctly",
|
||||
startstr="1 breakpoints disabled.")
|
||||
|
||||
# Run the program againt. We should stop on the two breakpoint locations.
|
||||
# Run the program againt. We should stop on the two breakpoint
|
||||
# locations.
|
||||
self.runCmd("run", RUN_SUCCEEDED)
|
||||
|
||||
# Stopped once.
|
||||
self.expect("thread backtrace", STOPPED_DUE_TO_BREAKPOINT,
|
||||
substrs = ["stop reason = breakpoint 1."])
|
||||
substrs=["stop reason = breakpoint 1."])
|
||||
|
||||
# Continue the program, there should be another stop.
|
||||
self.runCmd("process continue")
|
||||
|
||||
# Stopped again.
|
||||
self.expect("thread backtrace", STOPPED_DUE_TO_BREAKPOINT,
|
||||
substrs = ["stop reason = breakpoint 1."])
|
||||
substrs=["stop reason = breakpoint 1."])
|
||||
|
||||
# At this point, 1.1 has a hit count of 0 and the other a hit count of 1".
|
||||
self.expect("breakpoint list -f", "The breakpoints should report correct hit counts",
|
||||
patterns = ["1\.1: .+ unresolved, hit count = 0 +Options: disabled",
|
||||
"1\.2: .+ resolved, hit count = 1",
|
||||
"1\.3: .+ resolved, hit count = 1"])
|
||||
# At this point, 1.1 has a hit count of 0 and the other a hit count of
|
||||
# 1".
|
||||
self.expect(
|
||||
"breakpoint list -f",
|
||||
"The breakpoints should report correct hit counts",
|
||||
patterns=[
|
||||
"1\.1: .+ unresolved, hit count = 0 +Options: disabled",
|
||||
"1\.2: .+ resolved, hit count = 1",
|
||||
"1\.3: .+ resolved, hit count = 1"])
|
||||
|
||||
@@ -5,12 +5,12 @@ Test breakpoint command for different options.
|
||||
from __future__ import print_function
|
||||
|
||||
|
||||
|
||||
import os
|
||||
import lldb
|
||||
from lldbsuite.test.lldbtest import *
|
||||
import lldbsuite.test.lldbutil as lldbutil
|
||||
|
||||
|
||||
class BreakpointOptionsTestCase(TestBase):
|
||||
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
@@ -32,38 +32,59 @@ class BreakpointOptionsTestCase(TestBase):
|
||||
self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
|
||||
|
||||
# This should create a breakpoint with 1 locations.
|
||||
lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, extra_options = "-K 1", num_expected_locations = 1)
|
||||
lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, extra_options = "-K 0", num_expected_locations = 1)
|
||||
lldbutil.run_break_set_by_file_and_line(
|
||||
self,
|
||||
"main.cpp",
|
||||
self.line,
|
||||
extra_options="-K 1",
|
||||
num_expected_locations=1)
|
||||
lldbutil.run_break_set_by_file_and_line(
|
||||
self,
|
||||
"main.cpp",
|
||||
self.line,
|
||||
extra_options="-K 0",
|
||||
num_expected_locations=1)
|
||||
|
||||
# This should create a breakpoint 0 locations.
|
||||
lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, extra_options = "-m 0", num_expected_locations = 0)
|
||||
lldbutil.run_break_set_by_file_and_line(
|
||||
self,
|
||||
"main.cpp",
|
||||
self.line,
|
||||
extra_options="-m 0",
|
||||
num_expected_locations=0)
|
||||
|
||||
# Run the program.
|
||||
self.runCmd("run", RUN_SUCCEEDED)
|
||||
|
||||
# Stopped once.
|
||||
self.expect("thread backtrace", STOPPED_DUE_TO_BREAKPOINT,
|
||||
substrs = ["stop reason = breakpoint 2."])
|
||||
substrs=["stop reason = breakpoint 2."])
|
||||
|
||||
# Check the list of breakpoint.
|
||||
self.expect("breakpoint list -f", "Breakpoint locations shown correctly",
|
||||
substrs = ["1: file = 'main.cpp', line = %d, exact_match = 0, locations = 1" % self.line,
|
||||
"2: file = 'main.cpp', line = %d, exact_match = 0, locations = 1" % self.line,
|
||||
"3: file = 'main.cpp', line = %d, exact_match = 1, locations = 0" % self.line])
|
||||
self.expect(
|
||||
"breakpoint list -f",
|
||||
"Breakpoint locations shown correctly",
|
||||
substrs=[
|
||||
"1: file = 'main.cpp', line = %d, exact_match = 0, locations = 1" %
|
||||
self.line,
|
||||
"2: file = 'main.cpp', line = %d, exact_match = 0, locations = 1" %
|
||||
self.line,
|
||||
"3: file = 'main.cpp', line = %d, exact_match = 1, locations = 0" %
|
||||
self.line])
|
||||
|
||||
# Continue the program, there should be another stop.
|
||||
self.runCmd("process continue")
|
||||
|
||||
# Stopped again.
|
||||
self.expect("thread backtrace", STOPPED_DUE_TO_BREAKPOINT,
|
||||
substrs = ["stop reason = breakpoint 1."])
|
||||
substrs=["stop reason = breakpoint 1."])
|
||||
|
||||
# Continue the program, we should exit.
|
||||
self.runCmd("process continue")
|
||||
|
||||
# We should exit.
|
||||
self.expect("process status", "Process exited successfully",
|
||||
patterns = ["^Process [0-9]+ exited with status = 0"])
|
||||
patterns=["^Process [0-9]+ exited with status = 0"])
|
||||
|
||||
def breakpoint_options_language_test(self):
|
||||
"""Test breakpoint command for language option."""
|
||||
@@ -71,23 +92,34 @@ class BreakpointOptionsTestCase(TestBase):
|
||||
self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
|
||||
|
||||
# This should create a breakpoint with 1 locations.
|
||||
lldbutil.run_break_set_by_symbol (self, 'ns::func', sym_exact=False, extra_options = "-L c++", num_expected_locations=1)
|
||||
lldbutil.run_break_set_by_symbol(
|
||||
self,
|
||||
'ns::func',
|
||||
sym_exact=False,
|
||||
extra_options="-L c++",
|
||||
num_expected_locations=1)
|
||||
|
||||
# This should create a breakpoint with 0 locations.
|
||||
lldbutil.run_break_set_by_symbol (self, 'ns::func', sym_exact=False, extra_options = "-L c", num_expected_locations=0)
|
||||
lldbutil.run_break_set_by_symbol(
|
||||
self,
|
||||
'ns::func',
|
||||
sym_exact=False,
|
||||
extra_options="-L c",
|
||||
num_expected_locations=0)
|
||||
self.runCmd("settings set target.language c")
|
||||
lldbutil.run_break_set_by_symbol (self, 'ns::func', sym_exact=False, num_expected_locations=0)
|
||||
lldbutil.run_break_set_by_symbol(
|
||||
self, 'ns::func', sym_exact=False, num_expected_locations=0)
|
||||
|
||||
# Run the program.
|
||||
self.runCmd("run", RUN_SUCCEEDED)
|
||||
|
||||
# Stopped once.
|
||||
self.expect("thread backtrace", STOPPED_DUE_TO_BREAKPOINT,
|
||||
substrs = ["stop reason = breakpoint 1."])
|
||||
substrs=["stop reason = breakpoint 1."])
|
||||
|
||||
# Continue the program, we should exit.
|
||||
self.runCmd("process continue")
|
||||
|
||||
# We should exit.
|
||||
self.expect("process status", "Process exited successfully",
|
||||
patterns = ["^Process [0-9]+ exited with status = 0"])
|
||||
patterns=["^Process [0-9]+ exited with status = 0"])
|
||||
|
||||
@@ -6,6 +6,7 @@ import os
|
||||
import lldb
|
||||
from lldbsuite.test.lldbtest import *
|
||||
|
||||
|
||||
class BreakpointSetRestart(TestBase):
|
||||
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
@@ -16,12 +17,13 @@ class BreakpointSetRestart(TestBase):
|
||||
|
||||
cwd = os.getcwd()
|
||||
exe = os.path.join(cwd, 'a.out')
|
||||
|
||||
|
||||
target = self.dbg.CreateTarget(exe)
|
||||
self.assertTrue(target, VALID_TARGET)
|
||||
|
||||
self.dbg.SetAsync(True)
|
||||
process = target.LaunchSimple(None, None, self.get_process_working_directory())
|
||||
process = target.LaunchSimple(
|
||||
None, None, self.get_process_working_directory())
|
||||
self.assertTrue(process, PROCESS_IS_VALID)
|
||||
|
||||
event = lldb.SBEvent()
|
||||
@@ -29,15 +31,22 @@ class BreakpointSetRestart(TestBase):
|
||||
while self.dbg.GetListener().WaitForEvent(2, event):
|
||||
if lldb.SBProcess.GetStateFromEvent(event) == lldb.eStateRunning:
|
||||
break
|
||||
|
||||
bp = target.BreakpointCreateBySourceRegex(self.BREAKPOINT_TEXT,
|
||||
lldb.SBFileSpec(os.path.join(cwd, 'main.cpp')))
|
||||
self.assertTrue(bp.IsValid() and bp.GetNumLocations() == 1, VALID_BREAKPOINT)
|
||||
|
||||
bp = target.BreakpointCreateBySourceRegex(
|
||||
self.BREAKPOINT_TEXT, lldb.SBFileSpec(
|
||||
os.path.join(
|
||||
cwd, 'main.cpp')))
|
||||
self.assertTrue(
|
||||
bp.IsValid() and bp.GetNumLocations() == 1,
|
||||
VALID_BREAKPOINT)
|
||||
|
||||
while self.dbg.GetListener().WaitForEvent(2, event):
|
||||
if lldb.SBProcess.GetStateFromEvent(event) == lldb.eStateStopped and lldb.SBProcess.GetRestartedFromEvent(event):
|
||||
if lldb.SBProcess.GetStateFromEvent(
|
||||
event) == lldb.eStateStopped and lldb.SBProcess.GetRestartedFromEvent(event):
|
||||
continue
|
||||
if lldb.SBProcess.GetStateFromEvent(event) == lldb.eStateRunning:
|
||||
continue
|
||||
self.fail("Setting a breakpoint generated an unexpected event: %s" % lldb.SBDebugger.StateAsCString(lldb.SBProcess.GetStateFromEvent(event)))
|
||||
|
||||
self.fail(
|
||||
"Setting a breakpoint generated an unexpected event: %s" %
|
||||
lldb.SBDebugger.StateAsCString(
|
||||
lldb.SBProcess.GetStateFromEvent(event)))
|
||||
|
||||
@@ -4,7 +4,6 @@ Test breakpoint command with AT_comp_dir set to symbolic link.
|
||||
from __future__ import print_function
|
||||
|
||||
|
||||
|
||||
import os
|
||||
import shutil
|
||||
import lldb
|
||||
@@ -17,6 +16,7 @@ _EXE_NAME = 'CompDirSymLink' # Must match Makefile
|
||||
_SRC_FILE = 'main.cpp'
|
||||
_COMP_DIR_SYM_LINK_PROP = 'plugin.symbol-file.dwarf.comp-dir-symlink-paths'
|
||||
|
||||
|
||||
class CompDirSymLinkTestCase(TestBase):
|
||||
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
@@ -32,14 +32,18 @@ class CompDirSymLinkTestCase(TestBase):
|
||||
def test_symlink_paths_set(self):
|
||||
pwd_symlink = self.create_src_symlink()
|
||||
self.doBuild(pwd_symlink)
|
||||
self.runCmd("settings set %s %s" % (_COMP_DIR_SYM_LINK_PROP, pwd_symlink))
|
||||
self.runCmd(
|
||||
"settings set %s %s" %
|
||||
(_COMP_DIR_SYM_LINK_PROP, pwd_symlink))
|
||||
lldbutil.run_break_set_by_file_and_line(self, self.src_path, self.line)
|
||||
|
||||
@skipIf(hostoslist=no_match(["linux"]))
|
||||
def test_symlink_paths_set_procselfcwd(self):
|
||||
pwd_symlink = '/proc/self/cwd'
|
||||
self.doBuild(pwd_symlink)
|
||||
self.runCmd("settings set %s %s" % (_COMP_DIR_SYM_LINK_PROP, pwd_symlink))
|
||||
self.runCmd(
|
||||
"settings set %s %s" %
|
||||
(_COMP_DIR_SYM_LINK_PROP, pwd_symlink))
|
||||
lldbutil.run_break_set_by_file_and_line(self, self.src_path, self.line)
|
||||
|
||||
@skipIf(hostoslist=["windows"])
|
||||
@@ -47,12 +51,17 @@ class CompDirSymLinkTestCase(TestBase):
|
||||
pwd_symlink = self.create_src_symlink()
|
||||
self.doBuild(pwd_symlink)
|
||||
self.runCmd('settings clear ' + _COMP_DIR_SYM_LINK_PROP)
|
||||
self.assertRaises(AssertionError, lldbutil.run_break_set_by_file_and_line, self, self.src_path, self.line)
|
||||
self.assertRaises(
|
||||
AssertionError,
|
||||
lldbutil.run_break_set_by_file_and_line,
|
||||
self,
|
||||
self.src_path,
|
||||
self.line)
|
||||
|
||||
def create_src_symlink(self):
|
||||
pwd_symlink = os.path.join(os.getcwd(), 'pwd_symlink')
|
||||
if os.path.exists(pwd_symlink):
|
||||
os.unlink(pwd_symlink)
|
||||
os.unlink(pwd_symlink)
|
||||
os.symlink(os.getcwd(), pwd_symlink)
|
||||
self.addTearDownHook(lambda: os.remove(pwd_symlink))
|
||||
return pwd_symlink
|
||||
|
||||
@@ -5,35 +5,42 @@ Test that we handle breakpoints on consecutive instructions correctly.
|
||||
from __future__ import print_function
|
||||
|
||||
|
||||
|
||||
import unittest2
|
||||
import lldb
|
||||
from lldbsuite.test.decorators import *
|
||||
from lldbsuite.test.lldbtest import *
|
||||
from lldbsuite.test import lldbutil
|
||||
|
||||
|
||||
class ConsecutiveBreakpointsTestCase(TestBase):
|
||||
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
|
||||
def prepare_test(self):
|
||||
self.build()
|
||||
exe = os.path.join (os.getcwd(), "a.out")
|
||||
exe = os.path.join(os.getcwd(), "a.out")
|
||||
|
||||
# Create a target by the debugger.
|
||||
self.target = self.dbg.CreateTarget(exe)
|
||||
self.assertTrue(self.target, VALID_TARGET)
|
||||
|
||||
breakpoint1 = self.target.BreakpointCreateBySourceRegex("Set breakpoint here", lldb.SBFileSpec("main.cpp"))
|
||||
self.assertTrue(breakpoint1 and breakpoint1.GetNumLocations() == 1, VALID_BREAKPOINT)
|
||||
breakpoint1 = self.target.BreakpointCreateBySourceRegex(
|
||||
"Set breakpoint here", lldb.SBFileSpec("main.cpp"))
|
||||
self.assertTrue(
|
||||
breakpoint1 and breakpoint1.GetNumLocations() == 1,
|
||||
VALID_BREAKPOINT)
|
||||
|
||||
# Now launch the process, and do not stop at entry point.
|
||||
self.process = self.target.LaunchSimple (None, None, self.get_process_working_directory())
|
||||
self.process = self.target.LaunchSimple(
|
||||
None, None, self.get_process_working_directory())
|
||||
self.assertIsNotNone(self.process, PROCESS_IS_VALID)
|
||||
|
||||
# We should be stopped at the first breakpoint
|
||||
self.thread = lldbutil.get_one_thread_stopped_at_breakpoint(self.process, breakpoint1)
|
||||
self.assertIsNotNone(self.thread, "Expected one thread to be stopped at breakpoint 1")
|
||||
self.thread = lldbutil.get_one_thread_stopped_at_breakpoint(
|
||||
self.process, breakpoint1)
|
||||
self.assertIsNotNone(
|
||||
self.thread,
|
||||
"Expected one thread to be stopped at breakpoint 1")
|
||||
|
||||
# Set breakpoint to the next instruction
|
||||
frame = self.thread.GetFrameAtIndex(0)
|
||||
@@ -42,8 +49,11 @@ class ConsecutiveBreakpointsTestCase(TestBase):
|
||||
instructions = self.target.ReadInstructions(address, 2)
|
||||
self.assertTrue(len(instructions) == 2)
|
||||
self.bkpt_address = instructions[1].GetAddress()
|
||||
self.breakpoint2 = self.target.BreakpointCreateByAddress(self.bkpt_address.GetLoadAddress(self.target))
|
||||
self.assertTrue(self.breakpoint2 and self.breakpoint2.GetNumLocations() == 1, VALID_BREAKPOINT)
|
||||
self.breakpoint2 = self.target.BreakpointCreateByAddress(
|
||||
self.bkpt_address.GetLoadAddress(self.target))
|
||||
self.assertTrue(
|
||||
self.breakpoint2 and self.breakpoint2.GetNumLocations() == 1,
|
||||
VALID_BREAKPOINT)
|
||||
|
||||
def finish_test(self):
|
||||
# Run the process until termination
|
||||
@@ -58,8 +68,11 @@ class ConsecutiveBreakpointsTestCase(TestBase):
|
||||
self.process.Continue()
|
||||
self.assertEquals(self.process.GetState(), lldb.eStateStopped)
|
||||
# We should be stopped at the second breakpoint
|
||||
self.thread = lldbutil.get_one_thread_stopped_at_breakpoint(self.process, self.breakpoint2)
|
||||
self.assertIsNotNone(self.thread, "Expected one thread to be stopped at breakpoint 2")
|
||||
self.thread = lldbutil.get_one_thread_stopped_at_breakpoint(
|
||||
self.process, self.breakpoint2)
|
||||
self.assertIsNotNone(
|
||||
self.thread,
|
||||
"Expected one thread to be stopped at breakpoint 2")
|
||||
|
||||
self.finish_test()
|
||||
|
||||
@@ -72,10 +85,15 @@ class ConsecutiveBreakpointsTestCase(TestBase):
|
||||
self.thread.StepInstruction(step_over)
|
||||
|
||||
self.assertEquals(self.process.GetState(), lldb.eStateStopped)
|
||||
self.assertEquals(self.thread.GetFrameAtIndex(0).GetPCAddress().GetLoadAddress(self.target),
|
||||
self.bkpt_address.GetLoadAddress(self.target))
|
||||
self.thread = lldbutil.get_one_thread_stopped_at_breakpoint(self.process, self.breakpoint2)
|
||||
self.assertIsNotNone(self.thread, "Expected one thread to be stopped at breakpoint 2")
|
||||
self.assertEquals(
|
||||
self.thread.GetFrameAtIndex(0).GetPCAddress().GetLoadAddress(
|
||||
self.target), self.bkpt_address.GetLoadAddress(
|
||||
self.target))
|
||||
self.thread = lldbutil.get_one_thread_stopped_at_breakpoint(
|
||||
self.process, self.breakpoint2)
|
||||
self.assertIsNotNone(
|
||||
self.thread,
|
||||
"Expected one thread to be stopped at breakpoint 2")
|
||||
|
||||
self.finish_test()
|
||||
|
||||
@@ -84,8 +102,9 @@ class ConsecutiveBreakpointsTestCase(TestBase):
|
||||
"""Test that single step stops, even though the second breakpoint is not valid."""
|
||||
self.prepare_test()
|
||||
|
||||
# Choose a thread other than the current one. A non-existing thread is fine.
|
||||
thread_index = self.process.GetNumThreads()+1
|
||||
# Choose a thread other than the current one. A non-existing thread is
|
||||
# fine.
|
||||
thread_index = self.process.GetNumThreads() + 1
|
||||
self.assertFalse(self.process.GetThreadAtIndex(thread_index).IsValid())
|
||||
self.breakpoint2.SetThreadIndex(thread_index)
|
||||
|
||||
@@ -93,9 +112,13 @@ class ConsecutiveBreakpointsTestCase(TestBase):
|
||||
self.thread.StepInstruction(step_over)
|
||||
|
||||
self.assertEquals(self.process.GetState(), lldb.eStateStopped)
|
||||
self.assertEquals(self.thread.GetFrameAtIndex(0).GetPCAddress().GetLoadAddress(self.target),
|
||||
self.bkpt_address.GetLoadAddress(self.target))
|
||||
self.assertEquals(self.thread.GetStopReason(), lldb.eStopReasonPlanComplete,
|
||||
"Stop reason should be 'plan complete'")
|
||||
self.assertEquals(
|
||||
self.thread.GetFrameAtIndex(0).GetPCAddress().GetLoadAddress(
|
||||
self.target), self.bkpt_address.GetLoadAddress(
|
||||
self.target))
|
||||
self.assertEquals(
|
||||
self.thread.GetStopReason(),
|
||||
lldb.eStopReasonPlanComplete,
|
||||
"Stop reason should be 'plan complete'")
|
||||
|
||||
self.finish_test()
|
||||
|
||||
@@ -5,60 +5,64 @@ Test lldb breakpoint ids.
|
||||
from __future__ import print_function
|
||||
|
||||
|
||||
|
||||
import os, time
|
||||
import os
|
||||
import time
|
||||
import lldb
|
||||
from lldbsuite.test.decorators import *
|
||||
from lldbsuite.test.lldbtest import *
|
||||
from lldbsuite.test import lldbutil
|
||||
|
||||
|
||||
class TestCPPBreakpointLocations(TestBase):
|
||||
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
|
||||
@expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24764")
|
||||
def test (self):
|
||||
self.build ()
|
||||
self.breakpoint_id_tests ()
|
||||
def test(self):
|
||||
self.build()
|
||||
self.breakpoint_id_tests()
|
||||
|
||||
def verify_breakpoint_locations(self, target, bp_dict):
|
||||
|
||||
|
||||
name = bp_dict['name']
|
||||
names = bp_dict['loc_names']
|
||||
bp = target.BreakpointCreateByName (name)
|
||||
self.assertEquals(bp.GetNumLocations(), len(names), "Make sure we find the right number of breakpoint locations")
|
||||
|
||||
bp = target.BreakpointCreateByName(name)
|
||||
self.assertEquals(
|
||||
bp.GetNumLocations(),
|
||||
len(names),
|
||||
"Make sure we find the right number of breakpoint locations")
|
||||
|
||||
bp_loc_names = list()
|
||||
for bp_loc in bp:
|
||||
bp_loc_names.append(bp_loc.GetAddress().GetFunction().GetName())
|
||||
|
||||
|
||||
for name in names:
|
||||
found = name in bp_loc_names
|
||||
if not found:
|
||||
print("Didn't find '%s' in: %s" % (name, bp_loc_names))
|
||||
self.assertTrue (found, "Make sure we find all required locations")
|
||||
|
||||
def breakpoint_id_tests (self):
|
||||
|
||||
self.assertTrue(found, "Make sure we find all required locations")
|
||||
|
||||
def breakpoint_id_tests(self):
|
||||
|
||||
# Create a target by the debugger.
|
||||
exe = os.path.join(os.getcwd(), "a.out")
|
||||
target = self.dbg.CreateTarget(exe)
|
||||
self.assertTrue(target, VALID_TARGET)
|
||||
bp_dicts = [
|
||||
{ 'name' : 'func1', 'loc_names' : [ 'a::c::func1()', 'b::c::func1()'] },
|
||||
{ 'name' : 'func2', 'loc_names' : [ 'a::c::func2()', 'c::d::func2()'] },
|
||||
{ 'name' : 'func3', 'loc_names' : [ 'a::c::func3()', 'b::c::func3()', 'c::d::func3()'] },
|
||||
{ 'name' : 'c::func1', 'loc_names' : [ 'a::c::func1()', 'b::c::func1()'] },
|
||||
{ 'name' : 'c::func2', 'loc_names' : [ 'a::c::func2()'] },
|
||||
{ 'name' : 'c::func3', 'loc_names' : [ 'a::c::func3()', 'b::c::func3()'] },
|
||||
{ 'name' : 'a::c::func1', 'loc_names' : [ 'a::c::func1()'] },
|
||||
{ 'name' : 'b::c::func1', 'loc_names' : [ 'b::c::func1()'] },
|
||||
{ 'name' : 'c::d::func2', 'loc_names' : [ 'c::d::func2()'] },
|
||||
{ 'name' : 'a::c::func1()', 'loc_names' : [ 'a::c::func1()'] },
|
||||
{ 'name' : 'b::c::func1()', 'loc_names' : [ 'b::c::func1()'] },
|
||||
{ 'name' : 'c::d::func2()', 'loc_names' : [ 'c::d::func2()'] },
|
||||
{'name': 'func1', 'loc_names': ['a::c::func1()', 'b::c::func1()']},
|
||||
{'name': 'func2', 'loc_names': ['a::c::func2()', 'c::d::func2()']},
|
||||
{'name': 'func3', 'loc_names': ['a::c::func3()', 'b::c::func3()', 'c::d::func3()']},
|
||||
{'name': 'c::func1', 'loc_names': ['a::c::func1()', 'b::c::func1()']},
|
||||
{'name': 'c::func2', 'loc_names': ['a::c::func2()']},
|
||||
{'name': 'c::func3', 'loc_names': ['a::c::func3()', 'b::c::func3()']},
|
||||
{'name': 'a::c::func1', 'loc_names': ['a::c::func1()']},
|
||||
{'name': 'b::c::func1', 'loc_names': ['b::c::func1()']},
|
||||
{'name': 'c::d::func2', 'loc_names': ['c::d::func2()']},
|
||||
{'name': 'a::c::func1()', 'loc_names': ['a::c::func1()']},
|
||||
{'name': 'b::c::func1()', 'loc_names': ['b::c::func1()']},
|
||||
{'name': 'c::d::func2()', 'loc_names': ['c::d::func2()']},
|
||||
]
|
||||
|
||||
|
||||
for bp_dict in bp_dicts:
|
||||
self.verify_breakpoint_locations(target, bp_dict)
|
||||
|
||||
@@ -68,28 +72,43 @@ class TestCPPBreakpointLocations(TestBase):
|
||||
exe = os.path.join(os.getcwd(), "a.out")
|
||||
target = self.dbg.CreateTarget(exe)
|
||||
|
||||
# Don't skip prologue, so we can check the breakpoint address more easily
|
||||
# Don't skip prologue, so we can check the breakpoint address more
|
||||
# easily
|
||||
self.runCmd("settings set target.skip-prologue false")
|
||||
try:
|
||||
names = ['~c', 'c::~c', 'c::~c()']
|
||||
loc_names = {'a::c::~c()', 'b::c::~c()'}
|
||||
# TODO: For windows targets we should put windows mangled names here
|
||||
symbols = ['_ZN1a1cD1Ev', '_ZN1a1cD2Ev', '_ZN1b1cD1Ev', '_ZN1b1cD2Ev']
|
||||
# TODO: For windows targets we should put windows mangled names
|
||||
# here
|
||||
symbols = [
|
||||
'_ZN1a1cD1Ev',
|
||||
'_ZN1a1cD2Ev',
|
||||
'_ZN1b1cD1Ev',
|
||||
'_ZN1b1cD2Ev']
|
||||
|
||||
for name in names:
|
||||
bp = target.BreakpointCreateByName(name)
|
||||
|
||||
bp_loc_names = { bp_loc.GetAddress().GetFunction().GetName() for bp_loc in bp }
|
||||
self.assertEquals(bp_loc_names, loc_names, "Breakpoint set on the correct symbol")
|
||||
bp_loc_names = {bp_loc.GetAddress().GetFunction().GetName()
|
||||
for bp_loc in bp}
|
||||
self.assertEquals(
|
||||
bp_loc_names,
|
||||
loc_names,
|
||||
"Breakpoint set on the correct symbol")
|
||||
|
||||
bp_addresses = { bp_loc.GetLoadAddress() for bp_loc in bp }
|
||||
bp_addresses = {bp_loc.GetLoadAddress() for bp_loc in bp}
|
||||
symbol_addresses = set()
|
||||
for symbol in symbols:
|
||||
sc_list = target.FindSymbols(symbol, lldb.eSymbolTypeCode)
|
||||
self.assertEquals(sc_list.GetSize(), 1, "Found symbol " + symbol)
|
||||
self.assertEquals(
|
||||
sc_list.GetSize(), 1, "Found symbol " + symbol)
|
||||
symbol = sc_list.GetContextAtIndex(0).GetSymbol()
|
||||
symbol_addresses.add(symbol.GetStartAddress().GetLoadAddress(target))
|
||||
symbol_addresses.add(
|
||||
symbol.GetStartAddress().GetLoadAddress(target))
|
||||
|
||||
self.assertEquals(symbol_addresses, bp_addresses, "Breakpoint set on correct address")
|
||||
self.assertEquals(
|
||||
symbol_addresses,
|
||||
bp_addresses,
|
||||
"Breakpoint set on correct address")
|
||||
finally:
|
||||
self.runCmd("settings clear target.skip-prologue")
|
||||
|
||||
@@ -5,7 +5,6 @@ Test that you can set breakpoint and hit the C++ language exception breakpoint
|
||||
from __future__ import print_function
|
||||
|
||||
|
||||
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
@@ -14,6 +13,7 @@ from lldbsuite.test.decorators import *
|
||||
from lldbsuite.test.lldbtest import *
|
||||
from lldbsuite.test import lldbutil
|
||||
|
||||
|
||||
class TestCPPExceptionBreakpoint (TestBase):
|
||||
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
@@ -24,26 +24,31 @@ class TestCPPExceptionBreakpoint (TestBase):
|
||||
def test_cpp_exception_breakpoint(self):
|
||||
"""Test setting and hitting the C++ exception breakpoint."""
|
||||
self.build()
|
||||
self.do_cpp_exception_bkpt ()
|
||||
self.do_cpp_exception_bkpt()
|
||||
|
||||
def setUp (self):
|
||||
def setUp(self):
|
||||
TestBase.setUp(self)
|
||||
self.main_source = "main.c"
|
||||
self.main_source_spec = lldb.SBFileSpec(self.main_source)
|
||||
|
||||
|
||||
def do_cpp_exception_bkpt (self):
|
||||
def do_cpp_exception_bkpt(self):
|
||||
exe = os.path.join(os.getcwd(), "a.out")
|
||||
error = lldb.SBError()
|
||||
|
||||
self.target = self.dbg.CreateTarget(exe)
|
||||
self.assertTrue(self.target, VALID_TARGET)
|
||||
|
||||
exception_bkpt = self.target.BreakpointCreateForException(lldb.eLanguageTypeC_plus_plus, False, True)
|
||||
self.assertTrue (exception_bkpt.IsValid(), "Created exception breakpoint.")
|
||||
exception_bkpt = self.target.BreakpointCreateForException(
|
||||
lldb.eLanguageTypeC_plus_plus, False, True)
|
||||
self.assertTrue(
|
||||
exception_bkpt.IsValid(),
|
||||
"Created exception breakpoint.")
|
||||
|
||||
process = self.target.LaunchSimple (None, None, self.get_process_working_directory())
|
||||
process = self.target.LaunchSimple(
|
||||
None, None, self.get_process_working_directory())
|
||||
self.assertTrue(process, PROCESS_IS_VALID)
|
||||
|
||||
thread_list = lldbutil.get_threads_stopped_at_breakpoint (process, exception_bkpt)
|
||||
self.assertTrue (len(thread_list) == 1, "One thread stopped at the exception breakpoint.")
|
||||
|
||||
thread_list = lldbutil.get_threads_stopped_at_breakpoint(
|
||||
process, exception_bkpt)
|
||||
self.assertTrue(len(thread_list) == 1,
|
||||
"One thread stopped at the exception breakpoint.")
|
||||
|
||||
@@ -10,6 +10,7 @@ from lldbsuite.test.decorators import *
|
||||
from lldbsuite.test.lldbtest import *
|
||||
from lldbsuite.test import lldbutil
|
||||
|
||||
|
||||
class DebugBreakTestCase(TestBase):
|
||||
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
@@ -23,19 +24,23 @@ class DebugBreakTestCase(TestBase):
|
||||
|
||||
# Run the program.
|
||||
target = self.dbg.CreateTarget(exe)
|
||||
process = target.LaunchSimple(None, None, self.get_process_working_directory())
|
||||
process = target.LaunchSimple(
|
||||
None, None, self.get_process_working_directory())
|
||||
|
||||
# We've hit the first stop, so grab the frame.
|
||||
self.assertEqual(process.GetState(), lldb.eStateStopped)
|
||||
stop_reason = lldb.eStopReasonException if (lldbplatformutil.getPlatform()=="windows" or lldbplatformutil.getPlatform()=="macosx") else lldb.eStopReasonSignal
|
||||
stop_reason = lldb.eStopReasonException if (lldbplatformutil.getPlatform(
|
||||
) == "windows" or lldbplatformutil.getPlatform() == "macosx") else lldb.eStopReasonSignal
|
||||
thread = lldbutil.get_stopped_thread(process, stop_reason)
|
||||
self.assertIsNotNone(thread, "Unable to find thread stopped at the __debugbreak()")
|
||||
self.assertIsNotNone(
|
||||
thread, "Unable to find thread stopped at the __debugbreak()")
|
||||
frame = thread.GetFrameAtIndex(0)
|
||||
|
||||
# We should be in funciton 'bar'.
|
||||
self.assertTrue(frame.IsValid())
|
||||
function_name = frame.GetFunctionName()
|
||||
self.assertTrue('bar' in function_name, "Unexpected function name {}".format(function_name))
|
||||
self.assertTrue('bar' in function_name,
|
||||
"Unexpected function name {}".format(function_name))
|
||||
|
||||
# We should be able to evaluate the parameter foo.
|
||||
value = frame.EvaluateExpression('*foo')
|
||||
@@ -45,10 +50,10 @@ class DebugBreakTestCase(TestBase):
|
||||
# subsequent stop.
|
||||
counter = 1
|
||||
while counter < 20:
|
||||
value = frame.EvaluateExpression('count')
|
||||
self.assertEqual(value.GetValueAsSigned(), counter)
|
||||
counter += 2
|
||||
process.Continue()
|
||||
value = frame.EvaluateExpression('count')
|
||||
self.assertEqual(value.GetValueAsSigned(), counter)
|
||||
counter += 2
|
||||
process.Continue()
|
||||
|
||||
# The inferior should exit after the last iteration.
|
||||
self.assertEqual(process.GetState(), lldb.eStateExited)
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user