OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 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 #include "base/mac/mach_logging.h" | 5 #include "base/mac/mach_logging.h" |
6 | 6 |
7 #include <servers/bootstrap.h> | |
8 | |
9 #include <iomanip> | 7 #include <iomanip> |
10 #include <string> | 8 #include <string> |
11 | 9 |
12 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
13 | 11 |
| 12 #if !defined(OS_IOS) |
| 13 #include <servers/bootstrap.h> |
| 14 #endif // !OS_IOS |
| 15 |
14 namespace { | 16 namespace { |
15 | 17 |
16 std::string FormatMachErrorNumber(mach_error_t mach_err) { | 18 std::string FormatMachErrorNumber(mach_error_t mach_err) { |
17 // For the os/kern subsystem, give the error number in decimal as in | 19 // For the os/kern subsystem, give the error number in decimal as in |
18 // <mach/kern_return.h>. Otherwise, give it in hexadecimal to make it easier | 20 // <mach/kern_return.h>. Otherwise, give it in hexadecimal to make it easier |
19 // to visualize the various bits. See <mach/error.h>. | 21 // to visualize the various bits. See <mach/error.h>. |
20 if (mach_err >= 0 && mach_err < KERN_RETURN_MAX) { | 22 if (mach_err >= 0 && mach_err < KERN_RETURN_MAX) { |
21 return base::StringPrintf(" (%d)", mach_err); | 23 return base::StringPrintf(" (%d)", mach_err); |
22 } | 24 } |
23 return base::StringPrintf(" (0x%08x)", mach_err); | 25 return base::StringPrintf(" (0x%08x)", mach_err); |
(...skipping 10 matching lines...) Expand all Loading... |
34 : LogMessage(file_path, line, severity), | 36 : LogMessage(file_path, line, severity), |
35 mach_err_(mach_err) { | 37 mach_err_(mach_err) { |
36 } | 38 } |
37 | 39 |
38 MachLogMessage::~MachLogMessage() { | 40 MachLogMessage::~MachLogMessage() { |
39 stream() << ": " | 41 stream() << ": " |
40 << mach_error_string(mach_err_) | 42 << mach_error_string(mach_err_) |
41 << FormatMachErrorNumber(mach_err_); | 43 << FormatMachErrorNumber(mach_err_); |
42 } | 44 } |
43 | 45 |
| 46 #if !defined(OS_IOS) |
| 47 |
44 BootstrapLogMessage::BootstrapLogMessage(const char* file_path, | 48 BootstrapLogMessage::BootstrapLogMessage(const char* file_path, |
45 int line, | 49 int line, |
46 LogSeverity severity, | 50 LogSeverity severity, |
47 kern_return_t bootstrap_err) | 51 kern_return_t bootstrap_err) |
48 : LogMessage(file_path, line, severity), | 52 : LogMessage(file_path, line, severity), |
49 bootstrap_err_(bootstrap_err) { | 53 bootstrap_err_(bootstrap_err) { |
50 } | 54 } |
51 | 55 |
52 BootstrapLogMessage::~BootstrapLogMessage() { | 56 BootstrapLogMessage::~BootstrapLogMessage() { |
53 stream() << ": " | 57 stream() << ": " |
(...skipping 17 matching lines...) Expand all Loading... |
71 default: { | 75 default: { |
72 // bootstrap_strerror passes unknown errors to mach_error_string, so | 76 // bootstrap_strerror passes unknown errors to mach_error_string, so |
73 // format them as they would be if they were handled by | 77 // format them as they would be if they were handled by |
74 // MachErrorMessage. | 78 // MachErrorMessage. |
75 stream() << FormatMachErrorNumber(bootstrap_err_); | 79 stream() << FormatMachErrorNumber(bootstrap_err_); |
76 break; | 80 break; |
77 } | 81 } |
78 } | 82 } |
79 } | 83 } |
80 | 84 |
| 85 #endif // !OS_IOS |
| 86 |
81 } // namespace logging | 87 } // namespace logging |
OLD | NEW |