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

Side by Side Diff: native_client_sdk/src/tools/decode_dump.py

Issue 720233003: [NaCl SDK] Convert python scripts from optparse to argparse. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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 unified diff | Download patch
« no previous file with comments | « native_client_sdk/src/tools/create_nmf.py ('k') | native_client_sdk/src/tools/fix_deps.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env 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 argparse
11 import json 12 import json
12 import optparse
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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 out: file like object to output the trace to. 169 out: file like object to output the trace to.
170 """ 170 """
171 for scope in trace: 171 for scope in trace:
172 out.write('%s at %s:%d\n' % ( 172 out.write('%s at %s:%d\n' % (
173 scope['function'], 173 scope['function'],
174 scope['filename'], 174 scope['filename'],
175 scope['lineno'])) 175 scope['lineno']))
176 176
177 177
178 def main(args): 178 def main(args):
179 parser = optparse.OptionParser( 179 parser = argparse.ArgumentParser(description=__doc__)
180 usage='USAGE: %prog [options] <core.json>') 180 parser.add_argument('-m', '--main-nexe',
181 parser.add_option('-m', '--main-nexe', dest='main_nexe', 181 help='nexe to resolve NaClMain references from')
182 help='nexe to resolve NaClMain references from') 182 parser.add_argument('-n', '--nmf', default='-',
183 parser.add_option('-n', '--nmf', dest='nmf_filename', default='-', 183 help='nmf to resolve references from')
184 help='nmf to resolve references from') 184 parser.add_argument('-a', '--addr2line',
185 parser.add_option('-a', '--addr2line', dest='addr2line', 185 help='path to appropriate addr2line')
186 help='path to appropriate addr2line') 186 parser.add_argument('-L', '--library-path', dest='library_paths',
187 parser.add_option('-L', '--library-path', dest='library_paths', 187 action='append', default=[],
188 action='append', default=[], 188 help='path to search for shared libraries')
189 help='path to search for shared libraries') 189 parser.add_argument('-p', '--platform',
190 parser.add_option('-p', '--platform', dest='platform', 190 help='platform in a style match nmf files')
191 help='platform in a style match nmf files') 191 parser.add_argument('core_json')
192 options, args = parser.parse_args(args) 192 options = parser.parse_args(args)
193 if len(args) != 1:
194 parser.print_help()
195 sys.exit(1)
196 decoder = CoreDecoder( 193 decoder = CoreDecoder(
197 main_nexe=options.main_nexe, 194 main_nexe=options.main_nexe,
198 nmf_filename=options.nmf_filename, 195 nmf_filename=options.nmf,
199 addr2line=options.add2line, 196 addr2line=options.addr2line,
200 library_paths=options.library_paths, 197 library_paths=options.library_paths,
201 platform=options.platform) 198 platform=options.platform)
202 info = decoder.LoadAndDecode(args[0]) 199 info = decoder.LoadAndDecode(options.core_json)
203 trace = decoder.StackTrace(info) 200 trace = decoder.StackTrace(info)
204 decoder.PrintTrace(trace, sys.stdout) 201 decoder.PrintTrace(trace, sys.stdout)
205 return 0 202 return 0
206 203
207 204
208 if __name__ == '__main__': 205 if __name__ == '__main__':
209 sys.exit(main(sys.argv[1:])) 206 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « native_client_sdk/src/tools/create_nmf.py ('k') | native_client_sdk/src/tools/fix_deps.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698