Title: [233411] trunk/Tools
Revision
233411
Author
[email protected]
Date
2018-07-01 16:51:40 -0700 (Sun, 01 Jul 2018)

Log Message

[WPE][GTK] Fix retrieving backtrace from within flatpak sandbox in test runner
https://bugs.webkit.org/show_bug.cgi?id=187232

Patch by Thibault Saunier <[email protected]> on 2018-07-01
Reviewed by Michael Catanzaro.

The place where host tmp folder is mounted changed to /run/host/ we
need to take that into account.

Also explicitely close temporary files as relying on garbage collection to
remove them is a bad idea.

Also minor optimization avoiding to compile regex for each backtrace
retrieval.

* Scripts/webkitpy/port/linux_get_crash_log.py:
(GDBCrashLogGenerator):
(GDBCrashLogGenerator._get_tmp_file_name):
(GDBCrashLogGenerator._get_trace_from_systemd):

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (233410 => 233411)


--- trunk/Tools/ChangeLog	2018-07-01 22:38:04 UTC (rev 233410)
+++ trunk/Tools/ChangeLog	2018-07-01 23:51:40 UTC (rev 233411)
@@ -1,3 +1,24 @@
+2018-07-01  Thibault Saunier  <[email protected]>
+
+        [WPE][GTK] Fix retrieving backtrace from within flatpak sandbox in test runner
+        https://bugs.webkit.org/show_bug.cgi?id=187232
+
+        Reviewed by Michael Catanzaro.
+
+        The place where host tmp folder is mounted changed to /run/host/ we
+        need to take that into account.
+
+        Also explicitely close temporary files as relying on garbage collection to
+        remove them is a bad idea.
+
+        Also minor optimization avoiding to compile regex for each backtrace
+        retrieval.
+
+        * Scripts/webkitpy/port/linux_get_crash_log.py:
+        (GDBCrashLogGenerator):
+        (GDBCrashLogGenerator._get_tmp_file_name):
+        (GDBCrashLogGenerator._get_trace_from_systemd):
+
 2018-06-30  Daniel Bates  <[email protected]>
 
         test-webkitpy never rebuilds lldbWebKitTester

Modified: trunk/Tools/Scripts/webkitpy/port/linux_get_crash_log.py (233410 => 233411)


--- trunk/Tools/Scripts/webkitpy/port/linux_get_crash_log.py	2018-07-01 22:38:04 UTC (rev 233410)
+++ trunk/Tools/Scripts/webkitpy/port/linux_get_crash_log.py	2018-07-01 23:51:40 UTC (rev 233411)
@@ -39,6 +39,7 @@
 
 
 class GDBCrashLogGenerator(object):
+    _find_pid_regex = re.compile(r'PID: (\d+) \(.*\)')
 
     def __init__(self, executive, name, pid, newer_than, filesystem, path_to_driver):
         self.name = name
@@ -58,6 +59,12 @@
             stdout = ('ERROR: The gdb process exited with non-zero return code %s\n\n' % proc.returncode) + stdout
         return (stdout.decode('utf8', 'ignore'), errors)
 
+    def _get_tmp_file_name(self, coredumpctl, filename):
+        if coredumpctl[0] == 'flatpak-spawn':
+            return "/run/host/" + filename
+
+        return filename
+
     def _get_trace_from_systemd(self, coredumpctl, pid):
         # Letting up to 5 seconds for the backtrace to be generated on the systemd side
         for try_number in range(5):
@@ -74,18 +81,19 @@
             found_newer = False
             # Coredumpctl will use the latest core dump with the specified PID
             # assume it is the right one.
-            pids = re.findall(r'PID: (\d+) \(.*\)', info)
+            pids = self._find_pid_regex.findall(info)
             if not pids:
-                print(self.name + "\n" + info)
                 continue
 
             pid = pids[0]
+            with tempfile.NamedTemporaryFile() as temp_file:
+                if self._executive.run_command(coredumpctl + ['dump', pid, '--output',
+                        temp_file.name], return_exit_code=True):
+                    continue
 
-            temp_file = tempfile.NamedTemporaryFile()
-            if self._executive.run_command(coredumpctl + ['dump', pid, '--output', temp_file.name], return_exit_code=True):
-                continue
+                res = self._get_gdb_output(self._get_tmp_file_name(coredumpctl, temp_file.name))
 
-            return self._get_gdb_output(temp_file.name)
+                return res
 
         return '', []
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to