| OLD | NEW |
| 1 # Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2014 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import re | 5 import re |
| 6 | 6 |
| 7 import crash_utils | 7 import crash_utils |
| 8 | 8 |
| 9 | 9 |
| 10 SYZYASAN_STACK_FRAME_PATTERN = re.compile( | 10 SYZYASAN_STACK_FRAME_PATTERN = re.compile( |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 return None | 287 return None |
| 288 except ValueError: | 288 except ValueError: |
| 289 return None | 289 return None |
| 290 | 290 |
| 291 # Normalize the file path so that it can be compared to repository path. | 291 # Normalize the file path so that it can be compared to repository path. |
| 292 (component_path, component_name, file_path) = ( | 292 (component_path, component_name, file_path) = ( |
| 293 crash_utils.NormalizePath(file_path, parsed_deps)) | 293 crash_utils.NormalizePath(file_path, parsed_deps)) |
| 294 | 294 |
| 295 # Return a new stack frame object with the parsed information. | 295 # Return a new stack frame object with the parsed information. |
| 296 file_name = file_path.split('/')[-1] | 296 file_name = file_path.split('/')[-1] |
| 297 |
| 298 # If we have the common stack frame index pattern, then use it |
| 299 # since it is more reliable. |
| 300 index_match = re.match('\s*#(\d+)\s.*', line) |
| 301 if index_match: |
| 302 stack_frame_index = int(index_match.group(1)) |
| 303 |
| 297 return StackFrame(stack_frame_index, component_path, component_name, | 304 return StackFrame(stack_frame_index, component_path, component_name, |
| 298 file_name, function, file_path, crashed_line_range) | 305 file_name, function, file_path, crashed_line_range) |
| 299 | 306 |
| 300 def __getitem__(self, index): | 307 def __getitem__(self, index): |
| 301 return self.stack_list[index] | 308 return self.stack_list[index] |
| 302 | 309 |
| 303 def GetCrashStack(self): | 310 def GetCrashStack(self): |
| 304 """Returns the callstack with the highest priority. | 311 """Returns the callstack with the highest priority. |
| 305 | 312 |
| 306 Crash stack has priority 0, and allocation/freed/other thread stacks | 313 Crash stack has priority 0, and allocation/freed/other thread stacks |
| 307 get priority 1. | 314 get priority 1. |
| 308 | 315 |
| 309 Returns: | 316 Returns: |
| 310 The highest priority callstack in the stacktrace. | 317 The highest priority callstack in the stacktrace. |
| 311 """ | 318 """ |
| 312 sorted_stacklist = sorted(self.stack_list, | 319 sorted_stacklist = sorted(self.stack_list, |
| 313 key=lambda callstack: callstack.priority) | 320 key=lambda callstack: callstack.priority) |
| 314 return sorted_stacklist[0] | 321 return sorted_stacklist[0] |
| OLD | NEW |