OLD | NEW |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # | 2 # |
3 # Copyright (C) 2013 The Android Open Source Project | 3 # Copyright (C) 2013 The Android Open Source Project |
4 # | 4 # |
5 # Licensed under the Apache License, Version 2.0 (the "License"); | 5 # Licensed under the Apache License, Version 2.0 (the "License"); |
6 # you may not use this file except in compliance with 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 | 7 # You may obtain a copy of the License at |
8 # | 8 # |
9 # http://www.apache.org/licenses/LICENSE-2.0 | 9 # http://www.apache.org/licenses/LICENSE-2.0 |
10 # | 10 # |
11 # Unless required by applicable law or agreed to in writing, software | 11 # Unless required by applicable law or agreed to in writing, software |
12 # distributed under the License is distributed on an "AS IS" BASIS, | 12 # distributed under the License is distributed on an "AS IS" BASIS, |
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
14 # See the License for the specific language governing permissions and | 14 # See the License for the specific language governing permissions and |
15 # limitations under the License. | 15 # limitations under the License. |
16 | 16 |
17 """stack symbolizes native crash dumps.""" | 17 """stack symbolizes native crash dumps.""" |
ppi
2015/08/21 08:15:11
Does this patch fix https://github.com/domokit/dev
etiennej
2015/08/21 14:43:07
Done.
| |
18 | 18 |
19 import getopt | 19 import getopt |
20 import glob | 20 import glob |
21 import os | 21 import os |
22 import os.path | |
22 import re | 23 import re |
23 import sys | 24 import sys |
24 | 25 |
25 import stack_core | 26 import stack_core |
26 import subprocess | 27 import subprocess |
27 import symbol | 28 import symbol |
28 | 29 |
29 _DEFAULT_SYMROOT = '/tmp/symbols' | 30 _DEFAULT_SYMROOT = '/tmp/symbols' |
30 _DEFAULT_BUILD_DIR = 'out/android_Debug' | 31 _DEFAULT_BUILD_DIR = 'out/android_Debug' |
31 _DEFAULT_NDK_DIR = 'third_party/android_tools/ndk' | 32 _DEFAULT_NDK_DIR = 'third_party/android_tools/ndk' |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
125 """Used by GetSymbolMapping to get the non-stripped library name for an | 126 """Used by GetSymbolMapping to get the non-stripped library name for an |
126 installed mojo app.""" | 127 installed mojo app.""" |
127 # e.g. tracing.mojo -> libtracing_library.so | 128 # e.g. tracing.mojo -> libtracing_library.so |
128 name, ext = os.path.splitext(path) | 129 name, ext = os.path.splitext(path) |
129 if ext != '.mojo': | 130 if ext != '.mojo': |
130 return path | 131 return path |
131 return 'lib%s_library.so' % name | 132 return 'lib%s_library.so' % name |
132 | 133 |
133 | 134 |
134 def GetSymbolMapping(lines): | 135 def GetSymbolMapping(lines): |
135 """Returns a mapping (dictionary) from download file to .so.""" | 136 """Returns a mapping (dictionary) from download file to .so.""" |
ppi
2015/08/21 08:15:11
Would it be feasible to add a unittest for this pa
etiennej
2015/08/21 14:43:06
Done.
| |
136 regex = re.compile('Caching mojo app (\S+) at (\S+)') | 137 regex = re.compile('Caching mojo app (\S+?)(?:\?\S+)? at (\S+)') |
137 mappings = {} | 138 mappings = {} |
138 for line in lines: | 139 for line in lines: |
139 result = regex.search(line) | 140 result = regex.search(line) |
140 if result: | 141 if result: |
141 url = GetBasenameFromMojoApp(result.group(1)) | 142 url = GetBasenameFromMojoApp(result.group(1)) |
142 mappings[result.group(2)] = GetSymboledNameForMojoApp(url) | 143 mappings[os.path.normpath(result.group(2))] = GetSymboledNameForMojoApp( |
144 url) | |
143 return mappings | 145 return mappings |
144 | 146 |
145 | 147 |
146 def _LowestAncestorContainingRelpath(dir_path, relpath): | 148 def _LowestAncestorContainingRelpath(dir_path, relpath): |
147 """Returns the lowest ancestor dir of |dir_path| that contains |relpath|. | 149 """Returns the lowest ancestor dir of |dir_path| that contains |relpath|. |
148 """ | 150 """ |
149 cur_dir_path = os.path.abspath(dir_path) | 151 cur_dir_path = os.path.abspath(dir_path) |
150 while True: | 152 while True: |
151 if os.path.exists(os.path.join(cur_dir_path, relpath)): | 153 if os.path.exists(os.path.join(cur_dir_path, relpath)): |
152 return cur_dir_path | 154 return cur_dir_path |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
246 if rootdir: | 248 if rootdir: |
247 # be a good citizen and clean up...os.rmdir and os.removedirs() don't work | 249 # be a good citizen and clean up...os.rmdir and os.removedirs() don't work |
248 cmd = "rm -rf \"%s\"" % rootdir | 250 cmd = "rm -rf \"%s\"" % rootdir |
249 print "\ncleaning up (%s)" % cmd | 251 print "\ncleaning up (%s)" % cmd |
250 os.system(cmd) | 252 os.system(cmd) |
251 | 253 |
252 if __name__ == "__main__": | 254 if __name__ == "__main__": |
253 main() | 255 main() |
254 | 256 |
255 # vi: ts=2 sw=2 | 257 # vi: ts=2 sw=2 |
OLD | NEW |