OLD | NEW |
---|---|
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Utility to decode a crash dump generated by untrusted_crash_dump.[ch] | 6 """Utility to decode a crash dump generated by untrusted_crash_dump.[ch] |
7 | 7 |
8 Currently this produces a simple stack trace. | 8 Currently this produces a simple stack trace. |
9 """ | 9 """ |
10 | 10 |
11 import json | 11 import json |
12 import optparse | 12 import argparse |
binji
2014/11/13 23:57:03
sort
Sam Clegg
2014/11/30 17:55:12
Done.
| |
13 import os | 13 import os |
14 import posixpath | 14 import posixpath |
15 import subprocess | 15 import subprocess |
16 import sys | 16 import sys |
17 | 17 |
18 | 18 |
19 class CoreDecoder(object): | 19 class CoreDecoder(object): |
20 """Class to process core dumps.""" | 20 """Class to process core dumps.""" |
21 | 21 |
22 def __init__(self, main_nexe, nmf_filename, | 22 def __init__(self, main_nexe, nmf_filename, |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
170 out: file like object to output the trace to. | 170 out: file like object to output the trace to. |
171 """ | 171 """ |
172 for scope in trace: | 172 for scope in trace: |
173 out.write('%s at %s:%d\n' % ( | 173 out.write('%s at %s:%d\n' % ( |
174 scope['function'], | 174 scope['function'], |
175 scope['filename'], | 175 scope['filename'], |
176 scope['lineno'])) | 176 scope['lineno'])) |
177 | 177 |
178 | 178 |
179 def Main(args): | 179 def Main(args): |
180 parser = optparse.OptionParser( | 180 parser = argparse.ArgumentParser( |
181 usage='USAGE: %prog [options] <core.json>') | 181 usage='USAGE: %prog [options] <core.json>') |
binji
2014/11/13 23:57:03
remove usage
Sam Clegg
2014/11/30 17:55:12
Done.
| |
182 parser.add_option('-m', '--main-nexe', dest='main_nexe', | 182 parser.add_argument('-m', '--main-nexe', dest='main_nexe', |
183 help='nexe to resolve NaClMain references from') | 183 help='nexe to resolve NaClMain references from') |
184 parser.add_option('-n', '--nmf', dest='nmf_filename', default='-', | 184 parser.add_argument('-n', '--nmf', dest='nmf_filename', default='-', |
185 help='nmf to resolve references from') | 185 help='nmf to resolve references from') |
186 parser.add_option('-a', '--addr2line', dest='addr2line', | 186 parser.add_argument('-a', '--addr2line', dest='addr2line', |
187 help='path to appropriate addr2line') | 187 help='path to appropriate addr2line') |
188 parser.add_option('-L', '--library-path', dest='library_paths', | 188 parser.add_argument('-L', '--library-path', dest='library_paths', |
189 action='append', default=[], | 189 action='append', default=[], |
190 help='path to search for shared libraries') | 190 help='path to search for shared libraries') |
191 parser.add_option('-p', '--platform', dest='platform', | 191 parser.add_argument('-p', '--platform', dest='platform', |
192 help='platform in a style match nmf files') | 192 help='platform in a style match nmf files') |
193 options, args = parser.parse_args(args) | 193 options, args = parser.parse_args(args) |
binji
2014/11/13 23:57:03
options = ...
Sam Clegg
2014/11/30 17:55:12
Done.
| |
194 if len(args) != 1: | 194 if len(args) != 1: |
binji
2014/11/13 23:57:03
add positional arg
Sam Clegg
2014/11/30 17:55:12
Done.
| |
195 parser.print_help() | 195 parser.print_help() |
196 sys.exit(1) | 196 sys.exit(1) |
197 decoder = CoreDecoder( | 197 decoder = CoreDecoder( |
198 main_nexe=options.main_nexe, | 198 main_nexe=options.main_nexe, |
199 nmf_filename=options.nmf_filename, | 199 nmf_filename=options.nmf_filename, |
200 addr2line=options.add2line, | 200 addr2line=options.add2line, |
201 library_paths=options.library_paths, | 201 library_paths=options.library_paths, |
202 platform=options.platform) | 202 platform=options.platform) |
203 info = decoder.LoadAndDecode(args[0]) | 203 info = decoder.LoadAndDecode(args[0]) |
204 trace = decoder.StackTrace(info) | 204 trace = decoder.StackTrace(info) |
205 decoder.PrintTrace(trace, sys.stdout) | 205 decoder.PrintTrace(trace, sys.stdout) |
206 | 206 |
207 | 207 |
208 if __name__ == '__main__': | 208 if __name__ == '__main__': |
209 Main(sys.argv[1:]) | 209 Main(sys.argv[1:]) |
OLD | NEW |