OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/logging.h" | 5 #include "base/logging.h" |
6 | 6 |
7 #include <limits.h> | 7 #include <limits.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "base/debug/activity_tracker.h" | 10 #include "base/debug/activity_tracker.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 #include <cstring> | 50 #include <cstring> |
51 #include <ctime> | 51 #include <ctime> |
52 #include <iomanip> | 52 #include <iomanip> |
53 #include <ostream> | 53 #include <ostream> |
54 #include <string> | 54 #include <string> |
55 | 55 |
56 #include "base/base_switches.h" | 56 #include "base/base_switches.h" |
57 #include "base/command_line.h" | 57 #include "base/command_line.h" |
58 #include "base/debug/alias.h" | 58 #include "base/debug/alias.h" |
59 #include "base/debug/debugger.h" | 59 #include "base/debug/debugger.h" |
| 60 #include "base/debug/dump_without_crashing.h" |
60 #include "base/debug/stack_trace.h" | 61 #include "base/debug/stack_trace.h" |
61 #include "base/posix/eintr_wrapper.h" | 62 #include "base/posix/eintr_wrapper.h" |
62 #include "base/strings/string_piece.h" | 63 #include "base/strings/string_piece.h" |
63 #include "base/strings/string_util.h" | 64 #include "base/strings/string_util.h" |
64 #include "base/strings/stringprintf.h" | 65 #include "base/strings/stringprintf.h" |
65 #include "base/strings/sys_string_conversions.h" | 66 #include "base/strings/sys_string_conversions.h" |
66 #include "base/strings/utf_string_conversions.h" | 67 #include "base/strings/utf_string_conversions.h" |
67 #include "base/synchronization/lock_impl.h" | 68 #include "base/synchronization/lock_impl.h" |
68 #include "base/threading/platform_thread.h" | 69 #include "base/threading/platform_thread.h" |
69 #include "base/vlog.h" | 70 #include "base/vlog.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 bool g_log_thread_id = false; | 118 bool g_log_thread_id = false; |
118 bool g_log_timestamp = true; | 119 bool g_log_timestamp = true; |
119 bool g_log_tickcount = false; | 120 bool g_log_tickcount = false; |
120 | 121 |
121 // Should we pop up fatal debug messages in a dialog? | 122 // Should we pop up fatal debug messages in a dialog? |
122 bool show_error_dialogs = false; | 123 bool show_error_dialogs = false; |
123 | 124 |
124 // An assert handler override specified by the client to be called instead of | 125 // An assert handler override specified by the client to be called instead of |
125 // the debug message dialog and process termination. | 126 // the debug message dialog and process termination. |
126 LogAssertHandlerFunction log_assert_handler = nullptr; | 127 LogAssertHandlerFunction log_assert_handler = nullptr; |
| 128 |
127 // A log message handler that gets notified of every log message we process. | 129 // A log message handler that gets notified of every log message we process. |
128 LogMessageHandlerFunction log_message_handler = nullptr; | 130 LogMessageHandlerFunction log_message_handler = nullptr; |
129 | 131 |
130 // Helper functions to wrap platform differences. | 132 // Helper functions to wrap platform differences. |
131 | 133 |
132 int32_t CurrentProcessId() { | 134 int32_t CurrentProcessId() { |
133 #if defined(OS_WIN) | 135 #if defined(OS_WIN) |
134 return GetCurrentProcessId(); | 136 return GetCurrentProcessId(); |
135 #elif defined(OS_POSIX) | 137 #elif defined(OS_POSIX) |
136 return getpid(); | 138 return getpid(); |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 void CloseLogFileUnlocked() { | 338 void CloseLogFileUnlocked() { |
337 if (!g_log_file) | 339 if (!g_log_file) |
338 return; | 340 return; |
339 | 341 |
340 CloseFile(g_log_file); | 342 CloseFile(g_log_file); |
341 g_log_file = nullptr; | 343 g_log_file = nullptr; |
342 } | 344 } |
343 | 345 |
344 } // namespace | 346 } // namespace |
345 | 347 |
| 348 #if defined(DCHECK_IS_DUMP_WITHOUT_CRASH) |
| 349 // Used to implement dump-on-DCHECK. See crbug.com/596231. |
| 350 void DCheckDumpWithoutCrashingOnce() { |
| 351 // To ensure we don't risk spamming Crash with dump-on-DCHECK reports we |
| 352 // log only the first[*] DCHECK to fail once DumpWithoutCrashing() is |
| 353 // working. |
| 354 // [*] This is racey, but in the pathological case still only results in |
| 355 // one dump per-racing-thread, rather than one per-process. |
| 356 static bool dump_on_dcheck = true; |
| 357 if (dump_on_dcheck) |
| 358 dump_on_dcheck = !base::debug::DumpWithoutCrashing(); |
| 359 } |
| 360 #endif // defined(DCHECK_IS_DUMP_WITHOUT_CRASH) |
| 361 |
346 // This is never instantiated, it's just used for EAT_STREAM_PARAMETERS to have | 362 // This is never instantiated, it's just used for EAT_STREAM_PARAMETERS to have |
347 // an object of the correct type on the LHS of the unused part of the ternary | 363 // an object of the correct type on the LHS of the unused part of the ternary |
348 // operator. | 364 // operator. |
349 std::ostream* g_swallow_stream; | 365 std::ostream* g_swallow_stream; |
350 | 366 |
351 LoggingSettings::LoggingSettings() | 367 LoggingSettings::LoggingSettings() |
352 : logging_dest(LOG_DEFAULT), | 368 : logging_dest(LOG_DEFAULT), |
353 log_file(nullptr), | 369 log_file(nullptr), |
354 lock_log(LOCK_LOG_FILE), | 370 lock_log(LOCK_LOG_FILE), |
355 delete_old(APPEND_TO_OLD_LOG_FILE) {} | 371 delete_old(APPEND_TO_OLD_LOG_FILE) {} |
(...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
948 BASE_EXPORT void LogErrorNotReached(const char* file, int line) { | 964 BASE_EXPORT void LogErrorNotReached(const char* file, int line) { |
949 LogMessage(file, line, LOG_ERROR).stream() | 965 LogMessage(file, line, LOG_ERROR).stream() |
950 << "NOTREACHED() hit."; | 966 << "NOTREACHED() hit."; |
951 } | 967 } |
952 | 968 |
953 } // namespace logging | 969 } // namespace logging |
954 | 970 |
955 std::ostream& std::operator<<(std::ostream& out, const wchar_t* wstr) { | 971 std::ostream& std::operator<<(std::ostream& out, const wchar_t* wstr) { |
956 return out << (wstr ? base::WideToUTF8(wstr) : std::string()); | 972 return out << (wstr ? base::WideToUTF8(wstr) : std::string()); |
957 } | 973 } |
OLD | NEW |