OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2006 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2006 The WebRTC Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 // Most of this was borrowed (with minor modifications) from V8's and Chromium's | 11 // Most of this was borrowed (with minor modifications) from V8's and Chromium's |
12 // src/base/logging.cc. | 12 // src/base/logging.cc. |
13 | 13 |
14 // Use the C++ version to provide __GLIBCXX__. | 14 // Use the C++ version to provide __GLIBCXX__. |
15 #include <cstdarg> | 15 #include <cstdarg> |
16 #include <cstdio> | 16 #include <cstdio> |
17 #include <cstdlib> | 17 #include <cstdlib> |
18 | 18 |
19 #if defined(__GLIBCXX__) && !defined(__UCLIBC__) | 19 #if defined(__GLIBCXX__) && !defined(__UCLIBC__) |
20 #include <cxxabi.h> | 20 #include <cxxabi.h> |
21 #include <execinfo.h> | 21 #include <execinfo.h> |
22 #endif | 22 #endif |
23 | 23 |
24 #if defined(WEBRTC_ANDROID) | 24 #if defined(WEBRTC_ANDROID) |
25 #define LOG_TAG "rtc" | 25 #define RTC_LOG_TAG "rtc" |
26 #include <android/log.h> // NOLINT | 26 #include <android/log.h> // NOLINT |
27 #endif | 27 #endif |
28 | 28 |
29 #if defined(WEBRTC_WIN) | |
30 #include <windows.h> | |
31 #endif | |
32 | |
29 #include "webrtc/base/checks.h" | 33 #include "webrtc/base/checks.h" |
34 #include "webrtc/base/logging.h" | |
30 | 35 |
31 #if defined(_MSC_VER) | 36 #if defined(_MSC_VER) |
32 // Warning C4722: destructor never returns, potential memory leak. | 37 // Warning C4722: destructor never returns, potential memory leak. |
33 // FatalMessage's dtor very intentionally aborts. | 38 // FatalMessage's dtor very intentionally aborts. |
34 #pragma warning(disable:4722) | 39 #pragma warning(disable:4722) |
35 #endif | 40 #endif |
36 | 41 |
37 namespace rtc { | 42 namespace rtc { |
38 | 43 |
39 void VPrintError(const char* format, va_list args) { | 44 void VPrintError(const char* format, va_list args) { |
40 #if defined(WEBRTC_ANDROID) | 45 #if defined(WEBRTC_ANDROID) |
41 __android_log_vprint(ANDROID_LOG_ERROR, LOG_TAG, format, args); | 46 __android_log_vprint(ANDROID_LOG_ERROR, RTC_LOG_TAG, format, args); |
42 #else | 47 #else |
43 vfprintf(stderr, format, args); | 48 vfprintf(stderr, format, args); |
44 #endif | 49 #endif |
45 } | 50 } |
46 | 51 |
47 void PrintError(const char* format, ...) { | 52 void PrintError(const char* format, ...) { |
48 va_list args; | 53 va_list args; |
49 va_start(args, format); | 54 va_start(args, format); |
50 VPrintError(format, args); | 55 VPrintError(format, args); |
51 va_end(args); | 56 va_end(args); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
98 fflush(stdout); | 103 fflush(stdout); |
99 fflush(stderr); | 104 fflush(stderr); |
100 stream_ << std::endl << "#" << std::endl; | 105 stream_ << std::endl << "#" << std::endl; |
101 PrintError(stream_.str().c_str()); | 106 PrintError(stream_.str().c_str()); |
102 DumpBacktrace(); | 107 DumpBacktrace(); |
103 fflush(stderr); | 108 fflush(stderr); |
104 abort(); | 109 abort(); |
105 } | 110 } |
106 | 111 |
107 void FatalMessage::Init(const char* file, int line) { | 112 void FatalMessage::Init(const char* file, int line) { |
108 stream_ << std::endl << std::endl << "#" << std::endl << "# Fatal error in " | 113 stream_ << std::endl << std::endl |
109 << file << ", line " << line << std::endl << "# "; | 114 << "#" << std::endl |
115 << "# Fatal error in " << file << ", line " << line << std::endl | |
116 << "# last error=" << LAST_SYSTEM_ERROR << std::endl | |
perkj_webrtc
2016/04/22 05:17:30
Suggest " last system error: " (or=)
It seems to
tommi
2016/04/22 07:12:24
Done.
| |
117 << "# "; | |
110 } | 118 } |
111 | 119 |
112 // MSVC doesn't like complex extern templates and DLLs. | 120 // MSVC doesn't like complex extern templates and DLLs. |
113 #if !defined(COMPILER_MSVC) | 121 #if !defined(COMPILER_MSVC) |
114 // Explicit instantiations for commonly used comparisons. | 122 // Explicit instantiations for commonly used comparisons. |
115 template std::string* MakeCheckOpString<int, int>( | 123 template std::string* MakeCheckOpString<int, int>( |
116 const int&, const int&, const char* names); | 124 const int&, const int&, const char* names); |
117 template std::string* MakeCheckOpString<unsigned long, unsigned long>( | 125 template std::string* MakeCheckOpString<unsigned long, unsigned long>( |
118 const unsigned long&, const unsigned long&, const char* names); | 126 const unsigned long&, const unsigned long&, const char* names); |
119 template std::string* MakeCheckOpString<unsigned long, unsigned int>( | 127 template std::string* MakeCheckOpString<unsigned long, unsigned int>( |
120 const unsigned long&, const unsigned int&, const char* names); | 128 const unsigned long&, const unsigned int&, const char* names); |
121 template std::string* MakeCheckOpString<unsigned int, unsigned long>( | 129 template std::string* MakeCheckOpString<unsigned int, unsigned long>( |
122 const unsigned int&, const unsigned long&, const char* names); | 130 const unsigned int&, const unsigned long&, const char* names); |
123 template std::string* MakeCheckOpString<std::string, std::string>( | 131 template std::string* MakeCheckOpString<std::string, std::string>( |
124 const std::string&, const std::string&, const char* name); | 132 const std::string&, const std::string&, const char* name); |
125 #endif | 133 #endif |
126 | 134 |
127 } // namespace rtc | 135 } // namespace rtc |
OLD | NEW |