Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6951)

Unified Diff: build/android/symbolize.py

Issue 19670004: Refactor build/android/symbolize.py to function as an output filter. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | build/android/symbolize_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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__':
« no previous file with comments | « no previous file | build/android/symbolize_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698