OLD | NEW |
1 # Copyright (C) 2013 Google Inc. All rights reserved. | 1 # Copyright (C) 2013 Google Inc. All rights reserved. |
2 # | 2 # |
3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
5 # met: | 5 # met: |
6 # | 6 # |
7 # * Redistributions of source code must retain the above copyright | 7 # * Redistributions of source code must retain the above copyright |
8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
9 # * Redistributions in binary form must reproduce the above | 9 # * Redistributions in binary form must reproduce the above |
10 # copyright notice, this list of conditions and the following disclaimer | 10 # copyright notice, this list of conditions and the following disclaimer |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 self._host.filesystem.rmtree(self.crash_dumps_directory()) | 53 self._host.filesystem.rmtree(self.crash_dumps_directory()) |
54 | 54 |
55 def look_for_new_crash_logs(self, crashed_processes, start_time): | 55 def look_for_new_crash_logs(self, crashed_processes, start_time): |
56 if not crashed_processes: | 56 if not crashed_processes: |
57 return None | 57 return None |
58 | 58 |
59 if not self.check_is_functional(): | 59 if not self.check_is_functional(): |
60 return None | 60 return None |
61 | 61 |
62 pid_to_minidump = dict() | 62 pid_to_minidump = dict() |
63 for root, dirs, files in self._host.filesystem.walk(self.crash_dumps_dir
ectory()): | 63 for root, _, files in self._host.filesystem.walk(self.crash_dumps_direct
ory()): |
64 for dmp in [f for f in files if f.endswith(self._file_extension())]: | 64 for dmp in [f for f in files if f.endswith(self._file_extension())]: |
65 dmp_file = self._host.filesystem.join(root, dmp) | 65 dmp_file = self._host.filesystem.join(root, dmp) |
66 if self._host.filesystem.mtime(dmp_file) < start_time: | 66 if self._host.filesystem.mtime(dmp_file) < start_time: |
67 continue | 67 continue |
68 pid = self._get_pid_from_dump(dmp_file) | 68 pid = self._get_pid_from_dump(dmp_file) |
69 if pid: | 69 if pid: |
70 pid_to_minidump[pid] = dmp_file | 70 pid_to_minidump[pid] = dmp_file |
71 | 71 |
72 result = dict() | 72 result = dict() |
73 for test, process_name, pid in crashed_processes: | 73 for test, _, pid in crashed_processes: |
74 if str(pid) in pid_to_minidump: | 74 if str(pid) in pid_to_minidump: |
75 stack = self._get_stack_from_dump(pid_to_minidump[str(pid)]) | 75 stack = self._get_stack_from_dump(pid_to_minidump[str(pid)]) |
76 if stack: | 76 if stack: |
77 result[test] = stack | 77 result[test] = stack |
78 | 78 |
79 return result | 79 return result |
80 | 80 |
81 def _get_pid_from_dump(self, dump_file): | 81 def _get_pid_from_dump(self, dump_file): |
82 """This routine must be implemented by subclasses. | 82 """This routine must be implemented by subclasses. |
83 | 83 |
84 This routine returns the PID of the crashed process that produced the gi
ven dump_file.""" | 84 This routine returns the PID of the crashed process that produced the gi
ven dump_file.""" |
85 raise NotImplementedError() | 85 raise NotImplementedError() |
86 | 86 |
87 def _get_stack_from_dump(self, dump_file): | 87 def _get_stack_from_dump(self, dump_file): |
88 """This routine must be implemented by subclasses. | 88 """This routine must be implemented by subclasses. |
89 | 89 |
90 Returns the stack stored in the given breakpad dump_file.""" | 90 Returns the stack stored in the given breakpad dump_file.""" |
91 raise NotImplementedError() | 91 raise NotImplementedError() |
92 | 92 |
93 def _file_extension(self): | 93 def _file_extension(self): |
94 """This routine must be implemented by subclasses. | 94 """This routine must be implemented by subclasses. |
95 | 95 |
96 Returns the file extension of crash dumps written by breakpad.""" | 96 Returns the file extension of crash dumps written by breakpad.""" |
97 raise NotImplementedError() | 97 raise NotImplementedError() |
OLD | NEW |