1"""Test that a dSYM can be found when a binary is in a deep bundle with multiple pathname components.""" 2 3 4#import unittest2 5from time import sleep 6 7import lldb 8from lldbsuite.test.decorators import * 9from lldbsuite.test.lldbtest import * 10from lldbsuite.test import lldbutil 11 12 13exe_name = 'deep-bundle' # must match Makefile 14 15class DeepBundleTestCase(TestBase): 16 17 mydir = TestBase.compute_mydir(__file__) 18 19 def setUp(self): 20 TestBase.setUp(self) 21 self.source = 'main.c' 22 23 def tearDown(self): 24 # Destroy process before TestBase.tearDown() 25 self.dbg.GetSelectedTarget().GetProcess().Destroy() 26 27 # Call super's tearDown(). 28 TestBase.tearDown(self) 29 30 @skipIfRemote 31 @skipUnlessDarwin 32 # This test is explicitly a dSYM test, it doesn't need to run for any other config. 33 @skipIf(debug_info=no_match(["dsym"])) 34 @skipIfReproducer # File synchronization is not supported during replay. 35 def test_attach_and_check_dsyms(self): 36 """Test attach to binary, see if the framework dSYM is found""" 37 exe = self.getBuildArtifact(exe_name) 38 self.build() 39 40 # Use a file as a synchronization point between test and inferior. 41 pid_file_path = lldbutil.append_to_process_working_directory(self, 42 "token_pid_%d" % (int(os.getpid()))) 43 self.addTearDownHook( 44 lambda: self.run_platform_command( 45 "rm %s" % 46 (pid_file_path))) 47 48 popen = self.spawnSubprocess(exe, [self.getBuildDir(), pid_file_path]) 49 50 # Wait for the inferior to start up, dlopen a bundle, remove the bundle it linked in 51 pid = lldbutil.wait_for_file_on_target(self, pid_file_path) 52 53 # Since the library that was dlopen()'ed is now removed, lldb will need to find the 54 # binary & dSYM via target.exec-search-paths 55 settings_str = "settings set target.exec-search-paths " + self.get_process_working_directory() + "/hide.app" 56 self.runCmd(settings_str) 57 self.runCmd("process attach -p " + str(popen.pid)) 58 59 target = self.dbg.GetSelectedTarget() 60 self.assertTrue(target.IsValid(), 'Should have a valid Target after attaching to process') 61 62 setup_complete = target.FindFirstGlobalVariable("setup_is_complete") 63 self.assertEquals(setup_complete.GetValueAsUnsigned(), 1, 'Check that inferior process has completed setup') 64 65 # Find the bundle module, see if we found the dSYM too (they're both in "hide.app") 66 i = 0 67 found_module = False 68 while i < target.GetNumModules(): 69 mod = target.GetModuleAtIndex(i) 70 if mod.GetFileSpec().GetFilename() == 'MyFramework': 71 found_module = True 72 dsym_name = mod.GetSymbolFileSpec().GetFilename() 73 self.assertTrue (dsym_name == 'MyFramework', "Check that we found the dSYM for the bundle that was loaded") 74 i=i+1 75 76 self.assertTrue(found_module, "Check that we found the framework loaded in lldb's image list") 77