1"""Test that a dSYM can be found when a binary is in a bundle hnd has dots in the filename.""" 2 3 4import os.path 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 = 'find-bundle-with-dots-in-fn' # must match Makefile 14 15class BundleWithDotInFilenameTestCase(TestBase): 16 17 def setUp(self): 18 TestBase.setUp(self) 19 self.source = 'main.c' 20 21 def tearDown(self): 22 # Destroy process before TestBase.tearDown() 23 self.dbg.GetSelectedTarget().GetProcess().Destroy() 24 25 # Call super's tearDown(). 26 TestBase.tearDown(self) 27 28 @skipIfRemote 29 @skipUnlessDarwin 30 # This test is explicitly a dSYM test, it doesn't need to run for any other config. 31 @skipIf(debug_info=no_match(["dsym"])) 32 def test_attach_and_check_dsyms(self): 33 """Test attach to binary, see if the bundle dSYM is found""" 34 exe = self.getBuildArtifact(exe_name) 35 self.build() 36 os.chdir(self.getBuildDir()); 37 38 # Use a file as a synchronization point between test and inferior. 39 pid_file_path = lldbutil.append_to_process_working_directory(self, 40 "token_pid_%d" % (int(os.getpid()))) 41 self.addTearDownHook( 42 lambda: self.run_platform_command( 43 "rm %s" % 44 (pid_file_path))) 45 46 popen = self.spawnSubprocess(exe, [pid_file_path]) 47 48 # Wait for the inferior to start up, dlopen a bundle, remove the bundle it linked in 49 pid = lldbutil.wait_for_file_on_target(self, pid_file_path) 50 51 # Since the library that was dlopen()'ed is now removed, lldb will need to find the 52 # binary & dSYM via target.exec-search-paths 53 settings_str = "settings set target.exec-search-paths " + self.get_process_working_directory() + "/hide.app" 54 self.runCmd(settings_str) 55 56 self.runCmd("process attach -p " + str(popen.pid)) 57 58 target = self.dbg.GetSelectedTarget() 59 self.assertTrue(target.IsValid(), 'Should have a valid Target after attaching to process') 60 61 setup_complete = target.FindFirstGlobalVariable("setup_is_complete") 62 self.assertEquals(setup_complete.GetValueAsUnsigned(), 1, 'Check that inferior process has completed setup') 63 64 # Find the bundle module, see if we found the dSYM too (they're both in "hide.app") 65 i = 0 66 while i < target.GetNumModules(): 67 mod = target.GetModuleAtIndex(i) 68 if mod.GetFileSpec().GetFilename() == 'com.apple.sbd': 69 dsym_name = mod.GetSymbolFileSpec().GetFilename() 70 self.assertEqual(dsym_name, 'com.apple.sbd', "Check that we found the dSYM for the bundle that was loaded") 71 i=i+1 72 os.chdir(self.getSourceDir()); 73