Bug 1525968 - Make local development artifact builds on Android download full build symbols. r=froydnj
authorNick Alexander <nalexander@mozilla.com>
Wed, 27 Mar 2019 22:37:40 +0000
changeset 529336 bcc2aef70db38869ae7efae558e28d431cab9d15
parent 529335 e44091ef8d3f4e0423bfc234740b8b38198ecf0e
child 529337 4ebb324c0d9534dcecb301ea3f58887bc1f74f35
push id2082
push userffxbld-merge
push dateMon, 01 Jul 2019 08:34:18 +0000
treeherdermozilla-release@2fb19d0466d2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1525968, 1305502
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1525968 - Make local development artifact builds on Android download full build symbols. r=froydnj We produce two types of build symbol archives in automation: - "crashreporter-symbols.zip" contains Breakpad-format .sym files - "crashreporter-symbols-full.zip" contains Breakpad-format .sym files and compressed ELF debug symbol .dbg.gz files Right now, `--enable-artifact-build-symbols` from Bug 1305502 downloads only "crashreporter-symbols.zip". The Android Studio version of lldb, currently 7.0.0, doesn't support Breakpad-format .sym files. It does support (uncompressed) ELF debug symbols. (Note that gdb isn't supported on Android and hasn't been for some time.) This makes ` --enable-artifact-build-symbols` download the full symbols for Android builds that aren't in automation, to be useful for debugging Android builds with lldb locally. Differential Revision: https://phabricator.services.mozilla.com/D19091
moz.configure
python/mozbuild/mozbuild/artifacts.py
--- a/moz.configure
+++ b/moz.configure
@@ -26,19 +26,28 @@ set_config('MOZ_ARTIFACT_BUILDS', artifa
 
 imply_option('--enable-artifact-build-symbols',
              depends(artifact_builds)(lambda v: False if v is None else None),
              reason='--disable-artifact-builds')
 
 option('--enable-artifact-build-symbols', nargs='?', choices=('full',),
        help='Download symbols when artifact builds are enabled.')
 
+@depends('--enable-artifact-build-symbols', 'MOZ_AUTOMATION', target)
+def enable_artifact_build_symbols(value, automation, target):
+    if len(value):
+        return value[0]
+    if bool(value):
+        if target.os == 'Android' and not automation:
+            return 'full'
+        return True
+    return None
+
 set_config('MOZ_ARTIFACT_BUILD_SYMBOLS',
-           depends('--enable-artifact-build-symbols')(
-               lambda v: v[0] if len(v) else (bool(v) or None)))
+           enable_artifact_build_symbols)
 
 @depends('--enable-artifact-builds')
 def imply_disable_compile_environment(value):
     if value:
         return False
 
 option(env='MOZ_COPY_PDBS',
     help='For builds that do not support symbols in the normal fashion,'
--- a/python/mozbuild/mozbuild/artifacts.py
+++ b/python/mozbuild/mozbuild/artifacts.py
@@ -281,20 +281,25 @@ class ArtifactJob(object):
                             mode = entry.mode
                             writer.add(destpath.encode('utf-8'), entry.open(), mode=mode)
 
         if not added_entry:
             raise ValueError('Archive format changed! No pattern from "{patterns}"'
                              'matched an archive path.'.format(
                                  patterns=LinuxArtifactJob.test_artifact_patterns))
 
-    def process_symbols_archive(self, filename, processed_filename):
+    def process_symbols_archive(self, filename, processed_filename, skip_compressed=False):
         with JarWriter(file=processed_filename, compress_level=5) as writer:
             reader = JarReader(filename)
             for filename in reader.entries:
+                if skip_compressed and filename.endswith('.gz'):
+                    self.log(logging.INFO, 'artifact',
+                             {'filename': filename},
+                             'Skipping compressed ELF debug symbol file {filename}')
+                    continue
                 destpath = mozpath.join('crashreporter-symbols', filename)
                 self.log(logging.INFO, 'artifact',
                          {'destpath': destpath},
                          'Adding {destpath} to processed archive')
                 writer.add(destpath.encode('utf-8'), reader[filename])
 
     def process_host_bin(self, filename, processed_filename):
         with JarWriter(file=processed_filename, compress_level=5) as writer:
@@ -329,16 +334,45 @@ class AndroidArtifactJob(ArtifactJob):
                    'Adding {basename} to processed archive')
 
                 basedir = 'bin'
                 if not basename.endswith('.so'):
                     basedir = mozpath.join('bin', dirname.lstrip('assets/'))
                 basename = mozpath.join(basedir, basename)
                 writer.add(basename.encode('utf-8'), f.open())
 
+    def process_symbols_archive(self, filename, processed_filename):
+        ArtifactJob.process_symbols_archive(self, filename, processed_filename, skip_compressed=True)
+
+        if self._symbols_archive_suffix != 'crashreporter-symbols-full.zip':
+            return
+
+        import gzip
+
+        with JarWriter(file=processed_filename, compress_level=5) as writer:
+            reader = JarReader(filename)
+            for filename in reader.entries:
+                if not filename.endswith('.gz'):
+                    continue
+
+                # Uncompress "libxul.so/D3271457813E976AE7BF5DAFBABABBFD0/libxul.so.dbg.gz" into "libxul.so.dbg".
+                #
+                # After `settings append target.debug-file-search-paths /path/to/topobjdir/dist/crashreporter-symbols`,
+                # Android Studio's lldb (7.0.0, at least) will find the ELF debug symbol files.
+                #
+                # There are other paths that will work but none seem more desireable.  See
+                # https://github.com/llvm-mirror/lldb/blob/882670690ca69d9dd96b7236c620987b11894af9/source/Host/common/Symbols.cpp#L324.
+                basename = os.path.basename(filename).replace('.gz', '')
+                destpath = mozpath.join('crashreporter-symbols', basename)
+                self.log(logging.INFO, 'artifact',
+                         {'destpath': destpath},
+                         'Adding uncompressed ELF debug symbol file {destpath} to processed archive')
+                writer.add(destpath.encode('utf-8'),
+                           gzip.GzipFile(fileobj=reader[filename].uncompressed_data))
+
 
 class LinuxArtifactJob(ArtifactJob):
     package_re = r'public/build/target\.tar\.bz2'
     product = 'firefox'
 
     package_artifact_patterns = {
         'firefox/application.ini',
         'firefox/crashreporter',