<div dir="ltr">(Sorry I'm late to this)<div>What about the case where you're running on Windows, but the output from ASan comes from somewhere else? Let's say, from Android, or some other OS.</div><div>llvm-symbolizer could still work with this, as long as you had the executable “close by”.</div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature"> Filipe<br></div></div>
<br><div class="gmail_quote">On Wed, Jan 28, 2015 at 9:28 AM, Nico Weber <span dir="ltr"><<a href="mailto:nicolasweber@gmx.de" target="_blank">nicolasweber@gmx.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: nico<br>
Date: Wed Jan 28 11:28:04 2015<br>
New Revision: 227326<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=227326&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=227326&view=rev</a><br>
Log:<br>
Make asan_symbolize.py not crash on Windows.<br>
<br>
asan_symbolize.py isn't needed on Windows, but it's nice if asan has a unified<br>
UI on all platforms. So rather than have asan_symolize.py die on startup due to<br>
it importing modules that don't exist on Windows, let it just echo the input.<br>
<br>
Modified:<br>
compiler-rt/trunk/lib/asan/scripts/asan_symbolize.py<br>
<br>
Modified: compiler-rt/trunk/lib/asan/scripts/asan_symbolize.py<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/scripts/asan_symbolize.py?rev=227326&r1=227325&r2=227326&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/scripts/asan_symbolize.py?rev=227326&r1=227325&r2=227326&view=diff</a><br>
==============================================================================<br>
--- compiler-rt/trunk/lib/asan/scripts/asan_symbolize.py (original)<br>
+++ compiler-rt/trunk/lib/asan/scripts/asan_symbolize.py Wed Jan 28 11:28:04 2015<br>
@@ -11,11 +11,9 @@ import argparse<br>
import bisect<br>
import getopt<br>
import os<br>
-import pty<br>
import re<br>
import subprocess<br>
import sys<br>
-import termios<br>
<br>
symbolizers = {}<br>
DEBUG = False<br>
@@ -171,6 +169,9 @@ class UnbufferedLineConverter(object):<br>
output. Uses pty to trick the child into providing unbuffered output.<br>
"""<br>
def __init__(self, args, close_stderr=False):<br>
+ # Local imports so that the script can start on Windows.<br>
+ import pty<br>
+ import termios<br>
pid, fd = pty.fork()<br>
if pid == 0:<br>
# We're the child. Transfer control to command.<br>
@@ -341,17 +342,23 @@ class BreakpadSymbolizer(Symbolizer):<br>
<br>
class SymbolizationLoop(object):<br>
def __init__(self, binary_name_filter=None, dsym_hint_producer=None):<br>
- # Used by clients who may want to supply a different binary name.<br>
- # E.g. in Chrome several binaries may share a single .dSYM.<br>
- self.binary_name_filter = binary_name_filter<br>
- self.dsym_hint_producer = dsym_hint_producer<br>
- self.system = os.uname()[0]<br>
- if self.system not in ['Linux', 'Darwin', 'FreeBSD']:<br>
- raise Exception('Unknown system')<br>
- self.llvm_symbolizers = {}<br>
- self.last_llvm_symbolizer = None<br>
- self.dsym_hints = set([])<br>
- self.frame_no = 0<br>
+ if sys.platform == 'win32':<br>
+ # ASan on Windows uses dbghelp.dll to symbolize in-process, which works<br>
+ # even in sandboxed processes. Nothing needs to be done here.<br>
+ self.process_line = self.process_line_echo<br>
+ else:<br>
+ # Used by clients who may want to supply a different binary name.<br>
+ # E.g. in Chrome several binaries may share a single .dSYM.<br>
+ self.binary_name_filter = binary_name_filter<br>
+ self.dsym_hint_producer = dsym_hint_producer<br>
+ self.system = os.uname()[0]<br>
+ if self.system not in ['Linux', 'Darwin', 'FreeBSD']:<br>
+ raise Exception('Unknown system')<br>
+ self.llvm_symbolizers = {}<br>
+ self.last_llvm_symbolizer = None<br>
+ self.dsym_hints = set([])<br>
+ self.frame_no = 0<br>
+ self.process_line = self.process_line_posix<br>
<br>
def symbolize_address(self, addr, binary, offset):<br>
# On non-Darwin (i.e. on platforms without .dSYM debug info) always use<br>
@@ -405,14 +412,14 @@ class SymbolizationLoop(object):<br>
<br>
def process_logfile(self):<br>
self.frame_no = 0<br>
- while True:<br>
- line = logfile.readline()<br>
- if not line:<br>
- break<br>
+ for line in logfile:<br>
processed = self.process_line(line)<br>
print '\n'.join(processed)<br>
<br>
- def process_line(self, line):<br>
+ def process_line_echo(self, line):<br>
+ return [line.rstrip()]<br>
+<br>
+ def process_line_posix(self, line):<br>
self.current_line = line.rstrip()<br>
#0 0x7f6e35cf2e45 (/blah/foo.so+0x11fe45)<br>
stack_trace_line_format = (<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div></div>