OLD | NEW |
1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2008 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 | 5 |
6 #include "base/process_util.h" | 6 #include "base/process_util.h" |
7 | 7 |
8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
9 #include <crt_externs.h> | 9 #include <crt_externs.h> |
| 10 #include <mach/mach_init.h> |
| 11 #include <mach/task.h> |
10 #include <spawn.h> | 12 #include <spawn.h> |
11 #include <sys/sysctl.h> | 13 #include <sys/sysctl.h> |
12 #include <sys/types.h> | 14 #include <sys/types.h> |
13 #include <sys/wait.h> | 15 #include <sys/wait.h> |
14 | 16 |
15 #include <string> | 17 #include <string> |
16 | 18 |
17 #include "base/eintr_wrapper.h" | 19 #include "base/eintr_wrapper.h" |
18 #include "base/logging.h" | 20 #include "base/logging.h" |
19 #include "base/string_util.h" | 21 #include "base/string_util.h" |
20 #include "base/time.h" | 22 #include "base/time.h" |
21 | 23 |
22 namespace base { | 24 namespace base { |
23 | 25 |
| 26 void RestoreDefaultExceptionHandler() { |
| 27 // This function is tailored to remove the Breakpad exception handler. |
| 28 // exception_mask matches s_exception_mask in |
| 29 // breakpad/src/client/mac/handler/exception_handler.cc |
| 30 const exception_mask_t exception_mask = EXC_MASK_BAD_ACCESS | |
| 31 EXC_MASK_BAD_INSTRUCTION | |
| 32 EXC_MASK_ARITHMETIC | |
| 33 EXC_MASK_BREAKPOINT; |
| 34 |
| 35 // Setting the exception port to MACH_PORT_NULL may not be entirely |
| 36 // kosher to restore the default exception handler, but in practice, |
| 37 // it results in the exception port being set to Apple Crash Reporter, |
| 38 // the desired behavior. |
| 39 task_set_exception_ports(mach_task_self(), exception_mask, MACH_PORT_NULL, |
| 40 EXCEPTION_DEFAULT, THREAD_STATE_NONE); |
| 41 } |
| 42 |
24 NamedProcessIterator::NamedProcessIterator(const std::wstring& executable_name, | 43 NamedProcessIterator::NamedProcessIterator(const std::wstring& executable_name, |
25 const ProcessFilter* filter) | 44 const ProcessFilter* filter) |
26 : executable_name_(executable_name), | 45 : executable_name_(executable_name), |
27 index_of_kinfo_proc_(0), | 46 index_of_kinfo_proc_(0), |
28 filter_(filter) { | 47 filter_(filter) { |
29 // Get a snapshot of all of my processes (yes, as we loop it can go stale, but | 48 // Get a snapshot of all of my processes (yes, as we loop it can go stale, but |
30 // but trying to find where we were in a constantly changing list is basically | 49 // but trying to find where we were in a constantly changing list is basically |
31 // impossible. | 50 // impossible. |
32 | 51 |
33 int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_UID, geteuid() }; | 52 int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_UID, geteuid() }; |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 size_t ProcessMetrics::GetWorkingSetSize() const { | 195 size_t ProcessMetrics::GetWorkingSetSize() const { |
177 return 0; | 196 return 0; |
178 } | 197 } |
179 size_t ProcessMetrics::GetPeakWorkingSetSize() const { | 198 size_t ProcessMetrics::GetPeakWorkingSetSize() const { |
180 return 0; | 199 return 0; |
181 } | 200 } |
182 | 201 |
183 // ------------------------------------------------------------------------ | 202 // ------------------------------------------------------------------------ |
184 | 203 |
185 } // namespace base | 204 } // namespace base |
OLD | NEW |