Iliyan Malchev | 4929d6a | 2011-08-04 17:44:40 -0700 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | # |
Ben Cheng | b42dad0 | 2013-04-25 15:14:04 -0700 | [diff] [blame] | 3 | # 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 Malchev | 4929d6a | 2011-08-04 17:44:40 -0700 | [diff] [blame] | 16 | |
| 17 | """stack symbolizes native crash dumps.""" |
| 18 | |
Andreas Gampe | 3c9db52 | 2019-04-08 12:04:40 -0700 | [diff] [blame] | 19 | import argparse |
Iliyan Malchev | 4929d6a | 2011-08-04 17:44:40 -0700 | [diff] [blame] | 20 | import sys |
Iliyan Malchev | 4929d6a | 2011-08-04 17:44:40 -0700 | [diff] [blame] | 21 | |
Ben Cheng | b42dad0 | 2013-04-25 15:14:04 -0700 | [diff] [blame] | 22 | import stack_core |
Iliyan Malchev | 4929d6a | 2011-08-04 17:44:40 -0700 | [diff] [blame] | 23 | import symbol |
| 24 | |
Iliyan Malchev | 4929d6a | 2011-08-04 17:44:40 -0700 | [diff] [blame] | 25 | def main(): |
Andreas Gampe | 3c9db52 | 2019-04-08 12:04:40 -0700 | [diff] [blame] | 26 | parser = argparse.ArgumentParser(description='Parse and symbolize crashes') |
| 27 | parser.add_argument('--arch', help='the target architecture') |
Andreas Gampe | d8c0293 | 2019-04-08 12:31:01 -0700 | [diff] [blame] | 28 | parser.add_argument('--syms', '--symdir', help='the symbols directory') |
Andreas Gampe | 3c9db52 | 2019-04-08 12:04:40 -0700 | [diff] [blame] | 29 | parser.add_argument('file', |
| 30 | metavar='FILE', |
| 31 | default='-', |
Andreas Gampe | dcf9800 | 2019-04-30 10:07:24 -0700 | [diff] [blame^] | 32 | nargs='?', # Required for default. |
Andreas Gampe | 3c9db52 | 2019-04-08 12:04:40 -0700 | [diff] [blame] | 33 | help='should contain a stack trace in it somewhere the ' |
| 34 | 'tool will find that and re-print it with source ' |
| 35 | 'files and line numbers. If you don\'t pass FILE, ' |
| 36 | 'or if file is -, it reads from stdin.') |
Iliyan Malchev | 4929d6a | 2011-08-04 17:44:40 -0700 | [diff] [blame] | 37 | |
Andreas Gampe | 3c9db52 | 2019-04-08 12:04:40 -0700 | [diff] [blame] | 38 | args = parser.parse_args() |
Iliyan Malchev | 4929d6a | 2011-08-04 17:44:40 -0700 | [diff] [blame] | 39 | |
Andreas Gampe | 3c9db52 | 2019-04-08 12:04:40 -0700 | [diff] [blame] | 40 | if args.arch: |
| 41 | symbol.ARCH = args.arch |
Andreas Gampe | d8c0293 | 2019-04-08 12:31:01 -0700 | [diff] [blame] | 42 | if args.syms: |
| 43 | symbol.SYMBOLS_DIR = args.syms |
Andreas Gampe | 3c9db52 | 2019-04-08 12:04:40 -0700 | [diff] [blame] | 44 | if args.file == '-': |
Iliyan Malchev | 4929d6a | 2011-08-04 17:44:40 -0700 | [diff] [blame] | 45 | print "Reading native crash info from stdin" |
| 46 | f = sys.stdin |
| 47 | else: |
Andreas Gampe | 3c9db52 | 2019-04-08 12:04:40 -0700 | [diff] [blame] | 48 | print "Searching for native crashes in %s" % args.file |
| 49 | f = open(args.file, "r") |
Iliyan Malchev | 4929d6a | 2011-08-04 17:44:40 -0700 | [diff] [blame] | 50 | |
| 51 | lines = f.readlines() |
| 52 | f.close() |
| 53 | |
Ben Cheng | b42dad0 | 2013-04-25 15:14:04 -0700 | [diff] [blame] | 54 | stack_core.ConvertTrace(lines) |
Iliyan Malchev | 4929d6a | 2011-08-04 17:44:40 -0700 | [diff] [blame] | 55 | |
| 56 | if __name__ == "__main__": |
| 57 | main() |
| 58 | |
| 59 | # vi: ts=2 sw=2 |