Index: build/android/symbolize.py |
diff --git a/build/android/symbolize.py b/build/android/symbolize.py |
index b25261b19fd525faa2ade6e67eae9e101f65bc32..cb5d475984bc028eea8bbfbcb13091636d2e1cb0 100755 |
--- a/build/android/symbolize.py |
+++ b/build/android/symbolize.py |
@@ -28,17 +28,15 @@ TRACE_LINE = re.compile('(?P<frame>\#[0-9]+ 0x[0-9a-f]{8,8}) ' |
'(?P<lib>[^+]+)\+0x(?P<addr>[0-9a-f]{8,8})') |
class Symbolizer(object): |
- def __init__(self, file_in, file_out): |
- self.file_in = file_in |
- self.file_out = file_out |
+ def __init__(self, output): |
+ self._output = output |
- def ProcessInput(self): |
- for line in self.file_in: |
- match = re.search(TRACE_LINE, line) |
+ def write(self, data): |
bulach
2013/07/18 09:07:03
nit: it looks a bit weird to have "write(input_dat
scherkus (not reviewing)
2013/07/18 18:08:34
The idea is that an instance of this class can act
|
+ while True: |
+ match = re.search(TRACE_LINE, data) |
if not match: |
- self.file_out.write(line) |
- self.file_out.flush() |
- continue |
+ self._output.write(data) |
+ break |
frame = match.group('frame') |
lib = match.group('lib') |
@@ -60,24 +58,30 @@ class Symbolizer(object): |
sym = symbol.SymbolInformation(lib, addr, False)[0][0] |
if not sym: |
- self.file_out.write(line) |
- self.file_out.flush() |
+ post = match.end('addr') |
+ self._output.write(data[:post]) |
+ data = data[post:] |
continue |
- pre = line[0:match.start('frame')] |
- post = line[match.end('addr'):] |
+ pre = match.start('frame') |
+ post = match.end('addr') |
+ |
+ self._output.write(data[:pre]) |
+ self._output.write(frame) |
+ self._output.write(' ') |
+ self._output.write(sym) |
+ |
+ data = data[post:] |
- self.file_out.write(pre) |
- self.file_out.write(frame) |
- self.file_out.write(' ') |
- self.file_out.write(sym) |
- self.file_out.write(post) |
- self.file_out.flush() |
+ def flush(self): |
+ self._output.flush() |
def main(): |
- symbolizer = Symbolizer(sys.stdin, sys.stdout) |
- symbolizer.ProcessInput() |
+ symbolizer = Symbolizer(sys.stdout) |
+ for line in sys.stdin: |
+ symbolizer.write(line) |
+ symbolizer.flush() |
if __name__ == '__main__': |