Currently most of the test files have a separate dwarf and a separate dsym test with almost identical content (only the build step is different). With adding dwo symbol file handling to the test suit it would increase this to a 3-way duplication. The purpose of this change is to eliminate this redundancy with generating 2 test case (one dwarf and one dsym) for each test function specified (dwo handling will be added at a later commit). Main design goals: * There should be no boilerplate code in each test file to support the multiple debug info in most of the tests (custom scenarios are acceptable in special cases) so adding a new test case is easier and we can't miss one of the debug info type. * In case of a test failure, the debug symbols used during the test run have to be cleanly visible from the output of dotest.py to make debugging easier both from build bot logs and from local test runs * Each test case should have a unique, fully qualified name so we can run exactly 1 test with "-f <test-case>.<test-function>" syntax * Test output should be grouped based on test files the same way as it happens now (displaying dwarf/dsym results separately isn't preferable) Proposed solution (main logic in lldbtest.py, rest of them are test cases fixed up for the new style): * Have only 1 test fuction in the test files what will run for all debug info separately and this test function should call just "self.build(...)" to build an inferior with the right debug info * When a class is created by python (the class object, not the class instance), we will generate a new test method for each debug info format in the test class with the name "<test-function>_<debug-info>" and remove the original test method. This way unittest2 see multiple test methods (1 for each debug info, pretty much as of now) and will handle the test selection and the failure reporting correctly (the debug info will be visible from the end of the test name) * Add new annotation @no_debug_info_test to disable the generation of multiple tests for each debug info format when the test don't have an inferior Differential revision: http://reviews.llvm.org/D13028 llvm-svn: 248883
98 lines
5.4 KiB
Python
98 lines
5.4 KiB
Python
"""
|
|
Test that objective-c constant strings are generated correctly by the expression
|
|
parser.
|
|
"""
|
|
|
|
import os, time
|
|
import unittest2
|
|
import lldb
|
|
from lldbtest import *
|
|
import lldbutil
|
|
import shutil
|
|
import subprocess
|
|
|
|
@skipUnlessDarwin
|
|
class TestObjCBreakpoints(TestBase):
|
|
|
|
mydir = TestBase.compute_mydir(__file__)
|
|
|
|
def test_break(self):
|
|
"""Test setting Objective C specific breakpoints (DWARF in .o files)."""
|
|
self.build()
|
|
self.setTearDownCleanup()
|
|
self.check_objc_breakpoints(False)
|
|
|
|
def setUp(self):
|
|
# Call super's setUp().
|
|
TestBase.setUp(self)
|
|
# Find the line number to break inside main().
|
|
self.main_source = "main.m"
|
|
self.line = line_number(self.main_source, '// Set breakpoint here')
|
|
|
|
def check_category_breakpoints(self):
|
|
name_bp = self.target.BreakpointCreateByName ("myCategoryFunction")
|
|
selector_bp = self.target.BreakpointCreateByName ("myCategoryFunction", lldb.eFunctionNameTypeSelector, lldb.SBFileSpecList(), lldb.SBFileSpecList())
|
|
self.assertTrue(name_bp.GetNumLocations() == selector_bp.GetNumLocations(), 'Make sure setting a breakpoint by name "myCategoryFunction" sets a breakpoint even though it is in a category')
|
|
for bp_loc in selector_bp:
|
|
function_name = bp_loc.GetAddress().GetSymbol().GetName()
|
|
self.assertTrue(" myCategoryFunction]" in function_name, 'Make sure all function names have " myCategoryFunction]" in their names')
|
|
|
|
category_bp = self.target.BreakpointCreateByName ("-[MyClass(MyCategory) myCategoryFunction]")
|
|
stripped_bp = self.target.BreakpointCreateByName ("-[MyClass myCategoryFunction]")
|
|
stripped2_bp = self.target.BreakpointCreateByName ("[MyClass myCategoryFunction]")
|
|
self.assertTrue(category_bp.GetNumLocations() == 1, "Make sure we can set a breakpoint using a full objective C function name with the category included (-[MyClass(MyCategory) myCategoryFunction])")
|
|
self.assertTrue(stripped_bp.GetNumLocations() == 1, "Make sure we can set a breakpoint using a full objective C function name without the category included (-[MyClass myCategoryFunction])")
|
|
self.assertTrue(stripped2_bp.GetNumLocations() == 1, "Make sure we can set a breakpoint using a full objective C function name without the category included ([MyClass myCategoryFunction])")
|
|
|
|
def check_objc_breakpoints(self, have_dsym):
|
|
"""Test constant string generation amd comparison by the expression parser."""
|
|
|
|
# Set debugger into synchronous mode
|
|
self.dbg.SetAsync(False)
|
|
|
|
# Create a target by the debugger.
|
|
exe = os.path.join(os.getcwd(), "a.out")
|
|
self.target = self.dbg.CreateTarget(exe)
|
|
self.assertTrue(self.target, VALID_TARGET)
|
|
|
|
#----------------------------------------------------------------------
|
|
# Set breakpoints on all selectors whose name is "count". This should
|
|
# catch breakpoints that are both C functions _and_ anything whose
|
|
# selector is "count" because just looking at "count" we can't tell
|
|
# definitively if the name is a selector or a C function
|
|
#----------------------------------------------------------------------
|
|
name_bp = self.target.BreakpointCreateByName ("count")
|
|
selector_bp = self.target.BreakpointCreateByName ("count", lldb.eFunctionNameTypeSelector, lldb.SBFileSpecList(), lldb.SBFileSpecList())
|
|
self.assertTrue(name_bp.GetNumLocations() >= selector_bp.GetNumLocations(), 'Make sure we get at least the same amount of breakpoints if not more when setting by name "count"')
|
|
self.assertTrue(selector_bp.GetNumLocations() > 50, 'Make sure we find a lot of "count" selectors') # There are 93 on the latest MacOSX
|
|
for bp_loc in selector_bp:
|
|
function_name = bp_loc.GetAddress().GetSymbol().GetName()
|
|
self.assertTrue(" count]" in function_name, 'Make sure all function names have " count]" in their names')
|
|
|
|
#----------------------------------------------------------------------
|
|
# Set breakpoints on all selectors whose name is "isEqual:". This should
|
|
# catch breakpoints that are only ObjC selectors because no C function
|
|
# can end with a :
|
|
#----------------------------------------------------------------------
|
|
name_bp = self.target.BreakpointCreateByName ("isEqual:")
|
|
selector_bp = self.target.BreakpointCreateByName ("isEqual:", lldb.eFunctionNameTypeSelector, lldb.SBFileSpecList(), lldb.SBFileSpecList())
|
|
self.assertTrue(name_bp.GetNumLocations() == selector_bp.GetNumLocations(), 'Make sure setting a breakpoint by name "isEqual:" only sets selector breakpoints')
|
|
for bp_loc in selector_bp:
|
|
function_name = bp_loc.GetAddress().GetSymbol().GetName()
|
|
self.assertTrue(" isEqual:]" in function_name, 'Make sure all function names have " isEqual:]" in their names')
|
|
|
|
self.check_category_breakpoints()
|
|
|
|
if have_dsym:
|
|
shutil.rmtree(exe + ".dSYM")
|
|
self.assertTrue(subprocess.call(['/usr/bin/strip', '-Sx', exe]) == 0, 'stripping dylib succeeded')
|
|
|
|
# Check breakpoints again, this time using the symbol table only
|
|
self.check_category_breakpoints()
|
|
|
|
if __name__ == '__main__':
|
|
import atexit
|
|
lldb.SBDebugger.Initialize()
|
|
atexit.register(lambda: lldb.SBDebugger.Terminate())
|
|
unittest2.main()
|