blob: 63600e351d6a0ac69233d88555ad40e5fcbde935 [file] [log] [blame]
Iliyan Malchev4929d6a2011-08-04 17:44:40 -07001#!/usr/bin/env python
2#
Ben Chengb42dad02013-04-25 15:14:04 -07003# Copyright (C) 2013 The Android Open Source Project
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
Iliyan Malchev4929d6a2011-08-04 17:44:40 -070016
17"""stack symbolizes native crash dumps."""
18
Andreas Gampe3c9db522019-04-08 12:04:40 -070019import argparse
Iliyan Malchev4929d6a2011-08-04 17:44:40 -070020import sys
Iliyan Malchev4929d6a2011-08-04 17:44:40 -070021
Ben Chengb42dad02013-04-25 15:14:04 -070022import stack_core
Iliyan Malchev4929d6a2011-08-04 17:44:40 -070023import symbol
24
Iliyan Malchev4929d6a2011-08-04 17:44:40 -070025def main():
Andreas Gampe3c9db522019-04-08 12:04:40 -070026 parser = argparse.ArgumentParser(description='Parse and symbolize crashes')
27 parser.add_argument('--arch', help='the target architecture')
Andreas Gamped8c02932019-04-08 12:31:01 -070028 parser.add_argument('--syms', '--symdir', help='the symbols directory')
Andreas Gampe3c9db522019-04-08 12:04:40 -070029 parser.add_argument('file',
30 metavar='FILE',
31 default='-',
32 help='should contain a stack trace in it somewhere the '
33 'tool will find that and re-print it with source '
34 'files and line numbers. If you don\'t pass FILE, '
35 'or if file is -, it reads from stdin.')
Iliyan Malchev4929d6a2011-08-04 17:44:40 -070036
Andreas Gampe3c9db522019-04-08 12:04:40 -070037 args = parser.parse_args()
Iliyan Malchev4929d6a2011-08-04 17:44:40 -070038
Andreas Gampe3c9db522019-04-08 12:04:40 -070039 if args.arch:
40 symbol.ARCH = args.arch
Andreas Gamped8c02932019-04-08 12:31:01 -070041 if args.syms:
42 symbol.SYMBOLS_DIR = args.syms
Andreas Gampe3c9db522019-04-08 12:04:40 -070043 if args.file == '-':
Iliyan Malchev4929d6a2011-08-04 17:44:40 -070044 print "Reading native crash info from stdin"
45 f = sys.stdin
46 else:
Andreas Gampe3c9db522019-04-08 12:04:40 -070047 print "Searching for native crashes in %s" % args.file
48 f = open(args.file, "r")
Iliyan Malchev4929d6a2011-08-04 17:44:40 -070049
50 lines = f.readlines()
51 f.close()
52
Ben Chengb42dad02013-04-25 15:14:04 -070053 stack_core.ConvertTrace(lines)
Iliyan Malchev4929d6a2011-08-04 17:44:40 -070054
55if __name__ == "__main__":
56 main()
57
58# vi: ts=2 sw=2