<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[191018] trunk/Tools</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/191018">191018</a></dd>
<dt>Author</dt> <dd>bfulgham@apple.com</dd>
<dt>Date</dt> <dd>2015-10-13 17:15:38 -0700 (Tue, 13 Oct 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>[Win] Generate Crash Traces
https://bugs.webkit.org/show_bug.cgi?id=150103

Reviewed by Daniel Bates.

We were using an exception filter to try to emit &quot;#CRASHED&quot; to stderr
when a test program crashed. However, the modern Python implementation
seems capable of recognizing crashes on its own. Furthermore, registering
the exception handler was preventing the JIT debugger (NTSD) from
automatically attaching to the crashing program, so we were not getting
crash traces.
        
* DumpRenderTree/win/DumpRenderTree.cpp:
(main): Don't register an exception filter.
(exceptionFilter): Deleted.
* Scripts/webkitpy/common/system/crashlogs.py:
(CrashLogs): Add another regular expression to handle a second crash trace
syntax I encountered during testing.
(CrashLogs._find_newest_log_win): If the old regular expression doesn't match,
try the new one. The PID found by the new expression is in hexadecimal, so
convert it to an integer before returning it.
* Scripts/webkitpy/port/driver.py:
(Driver._check_for_driver_crash_or_unresponsiveness): Windows was not recognizing
the &quot;#CRASHED&quot; state because it was appending '\r\n', rather than just '\r'. Instead,
check for &quot;#CRASHED&quot; after stripping off the EOL characters.
* Scripts/webkitpy/port/win.py:
(WinPort.setup_crash_log_saving): Put back the '-e %ld' flag in the debugger
invocation. This is apparently used to signal an event when the debugger is finished.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsDumpRenderTreewinDumpRenderTreecpp">trunk/Tools/DumpRenderTree/win/DumpRenderTree.cpp</a></li>
<li><a href="#trunkToolsScriptswebkitpycommonsystemcrashlogspy">trunk/Tools/Scripts/webkitpy/common/system/crashlogs.py</a></li>
<li><a href="#trunkToolsScriptswebkitpyportdriverpy">trunk/Tools/Scripts/webkitpy/port/driver.py</a></li>
<li><a href="#trunkToolsScriptswebkitpyportwinpy">trunk/Tools/Scripts/webkitpy/port/win.py</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (191017 => 191018)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2015-10-14 00:14:29 UTC (rev 191017)
+++ trunk/Tools/ChangeLog        2015-10-14 00:15:38 UTC (rev 191018)
</span><span class="lines">@@ -1,3 +1,34 @@
</span><ins>+2015-10-13  Brent Fulgham  &lt;bfulgham@apple.com&gt;
+
+        [Win] Generate Crash Traces
+        https://bugs.webkit.org/show_bug.cgi?id=150103
+
+        Reviewed by Daniel Bates.
+
+        We were using an exception filter to try to emit &quot;#CRASHED&quot; to stderr
+        when a test program crashed. However, the modern Python implementation
+        seems capable of recognizing crashes on its own. Furthermore, registering
+        the exception handler was preventing the JIT debugger (NTSD) from
+        automatically attaching to the crashing program, so we were not getting
+        crash traces.
+        
+        * DumpRenderTree/win/DumpRenderTree.cpp:
+        (main): Don't register an exception filter.
+        (exceptionFilter): Deleted.
+        * Scripts/webkitpy/common/system/crashlogs.py:
+        (CrashLogs): Add another regular expression to handle a second crash trace
+        syntax I encountered during testing.
+        (CrashLogs._find_newest_log_win): If the old regular expression doesn't match,
+        try the new one. The PID found by the new expression is in hexadecimal, so
+        convert it to an integer before returning it.
+        * Scripts/webkitpy/port/driver.py:
+        (Driver._check_for_driver_crash_or_unresponsiveness): Windows was not recognizing
+        the &quot;#CRASHED&quot; state because it was appending '\r\n', rather than just '\r'. Instead,
+        check for &quot;#CRASHED&quot; after stripping off the EOL characters.
+        * Scripts/webkitpy/port/win.py:
+        (WinPort.setup_crash_log_saving): Put back the '-e %ld' flag in the debugger
+        invocation. This is apparently used to signal an event when the debugger is finished.
+
</ins><span class="cx"> 2015-10-13  Alexey Proskuryakov  &lt;ap@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Mac Debug and 32-bit queues should be separate
</span></span></pre></div>
<a id="trunkToolsDumpRenderTreewinDumpRenderTreecpp"></a>
<div class="modfile"><h4>Modified: trunk/Tools/DumpRenderTree/win/DumpRenderTree.cpp (191017 => 191018)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/DumpRenderTree/win/DumpRenderTree.cpp        2015-10-14 00:14:29 UTC (rev 191017)
+++ trunk/Tools/DumpRenderTree/win/DumpRenderTree.cpp        2015-10-14 00:15:38 UTC (rev 191018)
</span><span class="lines">@@ -1297,13 +1297,6 @@
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-static LONG WINAPI exceptionFilter(EXCEPTION_POINTERS*)
-{
-    fputs(&quot;#CRASHED\n&quot;, stderr);
-    fflush(stderr);
-    return EXCEPTION_CONTINUE_SEARCH;
-}
-
</del><span class="cx"> static Vector&lt;const char*&gt; initializeGlobalsFromCommandLineOptions(int argc, const char* argv[])
</span><span class="cx"> {
</span><span class="cx">     Vector&lt;const char*&gt; tests;
</span><span class="lines">@@ -1414,8 +1407,6 @@
</span><span class="cx">     // error mode here to work around Cygwin's behavior. See &lt;http://webkit.org/b/55222&gt;.
</span><span class="cx">     ::SetErrorMode(0);
</span><span class="cx"> 
</span><del>-    ::SetUnhandledExceptionFilter(exceptionFilter);
-
</del><span class="cx">     leakChecking = false;
</span><span class="cx"> 
</span><span class="cx">     _setmode(1, _O_BINARY);
</span></span></pre></div>
<a id="trunkToolsScriptswebkitpycommonsystemcrashlogspy"></a>
<div class="modfile"><h4>Modified: trunk/Tools/Scripts/webkitpy/common/system/crashlogs.py (191017 => 191018)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/Scripts/webkitpy/common/system/crashlogs.py        2015-10-14 00:14:29 UTC (rev 191017)
+++ trunk/Tools/Scripts/webkitpy/common/system/crashlogs.py        2015-10-14 00:15:38 UTC (rev 191018)
</span><span class="lines">@@ -1,4 +1,5 @@
</span><span class="cx"> # Copyright (c) 2011, Google Inc. All rights reserved.
</span><ins>+# Copyright (c) 2015, Apple Inc. All rights reserved.
</ins><span class="cx"> #
</span><span class="cx"> # Redistribution and use in source and binary forms, with or without
</span><span class="cx"> # modification, are permitted provided that the following conditions are
</span><span class="lines">@@ -32,7 +33,8 @@
</span><span class="cx"> 
</span><span class="cx"> class CrashLogs(object):
</span><span class="cx"> 
</span><del>-    PID_LINE_REGEX = re.compile(r'\s+Global\s+PID:\s+\[(?P&lt;pid&gt;\d+)\]')
</del><ins>+    GLOBAL_PID_REGEX = re.compile(r'\s+Global\s+PID:\s+\[(?P&lt;pid&gt;\d+)\]')
+    EXIT_PROCESS_PID_REGEX = re.compile(r'Exit process \d+:(?P&lt;pid&gt;\w+), code')
</ins><span class="cx"> 
</span><span class="cx">     def __init__(self, host, results_directory=None):
</span><span class="cx">         self._host = host
</span><span class="lines">@@ -90,10 +92,15 @@
</span><span class="cx">             try:
</span><span class="cx">                 if not newer_than or self._host.filesystem.mtime(path) &gt; newer_than:
</span><span class="cx">                     log_file = self._host.filesystem.read_binary_file(path).decode('ascii', 'ignore')
</span><del>-                    match = self.PID_LINE_REGEX.search(log_file)
</del><ins>+                    match = self.GLOBAL_PID_REGEX.search(log_file)
+                    if match:
+                        if int(match.group('pid')) == pid:
+                            return errors + log_file
+                    match = self.EXIT_PROCESS_PID_REGEX.search(log_file)
</ins><span class="cx">                     if match is None:
</span><span class="cx">                         continue
</span><del>-                    if int(match.group('pid')) == pid:
</del><ins>+                    # Note: This output comes from a program that shows PID in hex:
+                    if int(match.group('pid'), 16) == pid:
</ins><span class="cx">                         return errors + log_file
</span><span class="cx">             except IOError, e:
</span><span class="cx">                 print &quot;IOError %s&quot; % str(e)
</span></span></pre></div>
<a id="trunkToolsScriptswebkitpyportdriverpy"></a>
<div class="modfile"><h4>Modified: trunk/Tools/Scripts/webkitpy/port/driver.py (191017 => 191018)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/Scripts/webkitpy/port/driver.py        2015-10-14 00:14:29 UTC (rev 191017)
+++ trunk/Tools/Scripts/webkitpy/port/driver.py        2015-10-14 00:15:38 UTC (rev 191018)
</span><span class="lines">@@ -1,4 +1,5 @@
</span><span class="cx"> # Copyright (C) 2011 Google Inc. All rights reserved.
</span><ins>+# Copyright (c) 2015, Apple Inc. All rights reserved.
</ins><span class="cx"> #
</span><span class="cx"> # Redistribution and use in source and binary forms, with or without
</span><span class="cx"> # modification, are permitted provided that the following conditions are
</span><span class="lines">@@ -399,7 +400,8 @@
</span><span class="cx">             return True
</span><span class="cx"> 
</span><span class="cx">     def _check_for_driver_crash_or_unresponsiveness(self, error_line):
</span><del>-        if error_line == &quot;#CRASHED\n&quot;:
</del><ins>+        crashed_check = error_line.rstrip('\r\n')
+        if crashed_check == &quot;#CRASHED&quot;:
</ins><span class="cx">             self._crashed_process_name = self._server_process.name()
</span><span class="cx">             self._crashed_pid = self._server_process.pid()
</span><span class="cx">             return True
</span></span></pre></div>
<a id="trunkToolsScriptswebkitpyportwinpy"></a>
<div class="modfile"><h4>Modified: trunk/Tools/Scripts/webkitpy/port/win.py (191017 => 191018)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/Scripts/webkitpy/port/win.py        2015-10-14 00:14:29 UTC (rev 191017)
+++ trunk/Tools/Scripts/webkitpy/port/win.py        2015-10-14 00:15:38 UTC (rev 191018)
</span><span class="lines">@@ -245,7 +245,7 @@
</span><span class="cx">         command_file = self.create_debugger_command_file()
</span><span class="cx">         if not command_file:
</span><span class="cx">             return None
</span><del>-        debugger_options = '&quot;{0}&quot; -p %ld -g -noio -lines -cf &quot;{1}&quot;'.format(cygpath(ntsd_path), cygpath(command_file))
</del><ins>+        debugger_options = '&quot;{0}&quot; -p %ld -e %ld -g -noio -lines -cf &quot;{1}&quot;'.format(cygpath(ntsd_path), cygpath(command_file))
</ins><span class="cx">         registry_settings = {'Debugger': debugger_options, 'Auto': &quot;1&quot;}
</span><span class="cx">         for key in registry_settings:
</span><span class="cx">             for arch in [&quot;--wow32&quot;, &quot;--wow64&quot;]:
</span></span></pre>
</div>
</div>

</body>
</html>