From 8f705c16c3e4354866f266ab7ab04c4b3812bb5a Mon Sep 17 00:00:00 2001 From: Dominik Schmidt Date: Fri, 11 Jan 2019 19:11:22 +0100 Subject: Use .dSYM files when dumping symbols for breakpad --- admin/osx/gen_sym_files.py | 20 +++++++++++++++-- admin/osx/macdeployqt.py | 53 +++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 68 insertions(+), 5 deletions(-) diff --git a/admin/osx/gen_sym_files.py b/admin/osx/gen_sym_files.py index 1d9fa2489..3335492a1 100755 --- a/admin/osx/gen_sym_files.py +++ b/admin/osx/gen_sym_files.py @@ -13,6 +13,7 @@ if len(sys.argv) < 4: dump_symsPath = sys.argv[1] bundlePath = sys.argv[2] +dsymsPath = os.path.realpath(os.path.join(bundlePath, '..', os.path.basename(bundlePath)+'_symbols')) outPath = sys.argv[3] macOsDir = os.path.join(bundlePath, 'Contents', 'MacOS') pluginsDir = os.path.join(bundlePath, 'Contents', 'PlugIns') @@ -31,7 +32,7 @@ def extractDeps(macho): if m: path = resolvePath(m.group(0)) if not os.path.exists(path): - logging.warning("Non-existant file found in dependencies, ignoring: [%s]", path) + logging.warning("Non-existant file found in dependencies of %s, ignoring: [%s]", macho, path) continue deps.append(path) return deps @@ -48,11 +49,26 @@ def findDeps(): deps += extractDeps(path) return sorted(set(deps)) +def dumpSymsDSYMOptions(dep): + frameworkString = '.framework' + pos = dep.rfind(frameworkString) + dsymPath = dep + ".dSYM" + if pos > -1: + frameworkPath = dep[:pos+len(frameworkString)] + dsymPath = frameworkPath + ".dSYM" + + dsymPath = os.path.join(dsymsPath, os.path.basename(dsymPath)) + if os.path.exists(dsymPath): + return ['-g', dsymPath] + + return [] + def dumpSyms(deps): for dep in deps: print("Generating symbols for [%s]" % dep) with open('temp.sym', 'w') as temp: - subprocess.check_call([dump_symsPath, dep], stdout=temp) + command = [dump_symsPath] + dumpSymsDSYMOptions(dep) + [dep] + subprocess.check_call(command, stdout=temp) with open('temp.sym', 'r') as temp: header = temp.readline() fields = header.split() diff --git a/admin/osx/macdeployqt.py b/admin/osx/macdeployqt.py index 7294dc02a..de13c4931 100755 --- a/admin/osx/macdeployqt.py +++ b/admin/osx/macdeployqt.py @@ -25,6 +25,7 @@ from glob import glob from distutils.version import LooseVersion bundle_dir = sys.argv[1] +dsyms_dir = os.path.realpath(os.path.join(bundle_dir, '..', os.path.basename(bundle_dir)+'_symbols')) qmake_path = sys.argv[2] def QueryQMake(attrib): @@ -239,8 +240,30 @@ def FixBinary(path): for library in broken_libs['libs']: FixLibraryInstallPath(library, path) + +def CopyDSYM(dep): + frameworkString = '.framework' + pos = dep.rfind(frameworkString) + dsym_path = dep + ".dSYM" + if pos > -1: + frameworkPath = dep[:pos+len(frameworkString)] + dsym_path = frameworkPath + ".dSYM" + + if os.path.exists(dsym_path): + new_dsym_path = os.path.join(dsyms_dir, os.path.basename(dsym_path)) + print("CopyDSYM: [%s]" % dsym_path) + args = ['rm', '-rf', os.path.join(dsyms_dir, os.path.basename(dsym_path))] + commands.append(args) + args = ['cp', '-R', dsym_path, dsyms_dir] + commands.append(args) + else: + print("CopyDSYM: no .dSYM found.") + + + def CopyLibrary(path): print "CopyLibrary:", path + CopyDSYM(path) new_path = os.path.join(binary_dir, os.path.basename(path)) args = ['ditto', '--arch=x86_64', path, new_path] commands.append(args) @@ -250,6 +273,7 @@ def CopyLibrary(path): def CopyPlugin(path, subdir): print "CopyPlugin:", path, subdir + CopyDSYM(path) new_path = os.path.join(plugins_dir, subdir, os.path.basename(path)) args = ['mkdir', '-p', os.path.dirname(new_path)] commands.append(args) @@ -261,6 +285,7 @@ def CopyPlugin(path, subdir): def CopyFramework(source_dylib): print "CopyFramework:", source_dylib + CopyDSYM(source_dylib) parts = source_dylib.split(os.sep) for i, part in enumerate(parts): matchObj = re.match(r'(\w+\.framework)', part) @@ -326,6 +351,9 @@ def FixLibraryInstallPath(library_path, library): new_path = '@executable_path/../MacOS/%s' % os.path.basename(library_path) FixInstallPath(library_path, library, new_path) else: + print "Fix as system library: [%s]" % library_path + print "We currently don't need this and it's most likely an error if this code path is hit. Exiting…" + sys.exit(53) FixInstallPath(library_path, library, system_library) def FixFrameworkInstallPath(library_path, library): @@ -346,10 +374,30 @@ def FindQtPlugin(name): return os.path.join(path, name) raise CouldNotFindQtPluginError(name) + +def runCommand(command): + p = subprocess.Popen(command) + os.waitpid(p.pid, 0) + +def runCommandDebug(command): + print "Run command: %s" % command + runCommand(command) + +if 'ENABLE_CRASHREPORTS' in os.environ and os.environ['ENABLE_CRASHREPORTS'] == 'true': + print "Crashreports enabled. Dump symbols of our own binaries." + for binary in binaries: + print("Create .dSYM for [binary]") + dsym_path = binary+'.dSYM' + runCommandDebug(['dsymutil', binary]) + runCommandDebug(['rm', '-rf', os.path.join(dsyms_dir, os.path.basename(dsym_path))]) + runCommandDebug(['mv', dsym_path, dsyms_dir]) +else: + print "Crashreports disabled." + + for binary in binaries: FixBinary(binary) - if LooseVersion(qt_version) >= LooseVersion("5.10.0"): QT_PLUGINS.append('styles/libqmacstyle.dylib') for plugin in QT_PLUGINS: @@ -368,7 +416,6 @@ if len(sys.argv) <= 2: print ' '.join(command) for command in commands: - p = subprocess.Popen(command) - os.waitpid(p.pid, 0) + runCommand(command) WriteQtConf() -- cgit v1.2.3