Chromium Code Reviews| 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/macros.h" | 10 #include "base/macros.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 54 #include <cstring> | 54 #include <cstring> |
| 55 #include <ctime> | 55 #include <ctime> |
| 56 #include <iomanip> | 56 #include <iomanip> |
| 57 #include <ostream> | 57 #include <ostream> |
| 58 #include <string> | 58 #include <string> |
| 59 | 59 |
| 60 #include "base/base_switches.h" | 60 #include "base/base_switches.h" |
| 61 #include "base/command_line.h" | 61 #include "base/command_line.h" |
| 62 #include "base/debug/alias.h" | 62 #include "base/debug/alias.h" |
| 63 #include "base/debug/debugger.h" | 63 #include "base/debug/debugger.h" |
| 64 #if defined(OFFICIAL_BUILD) | |
|
scottmg
2016/03/21 17:28:12
Remove the #if here.
Wez
2016/03/23 04:18:13
You prefer to include even if it won't be used?
D
| |
| 65 #include "base/debug/dump_without_crashing.h" | |
| 66 #endif | |
| 64 #include "base/debug/stack_trace.h" | 67 #include "base/debug/stack_trace.h" |
| 65 #include "base/posix/eintr_wrapper.h" | 68 #include "base/posix/eintr_wrapper.h" |
| 66 #include "base/strings/string_piece.h" | 69 #include "base/strings/string_piece.h" |
| 67 #include "base/strings/string_util.h" | 70 #include "base/strings/string_util.h" |
| 68 #include "base/strings/stringprintf.h" | 71 #include "base/strings/stringprintf.h" |
| 69 #include "base/strings/sys_string_conversions.h" | 72 #include "base/strings/sys_string_conversions.h" |
| 70 #include "base/strings/utf_string_conversions.h" | 73 #include "base/strings/utf_string_conversions.h" |
| 71 #include "base/synchronization/lock_impl.h" | 74 #include "base/synchronization/lock_impl.h" |
| 72 #include "base/threading/platform_thread.h" | 75 #include "base/threading/platform_thread.h" |
| 73 #include "base/vlog.h" | 76 #include "base/vlog.h" |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 328 void CloseLogFileUnlocked() { | 331 void CloseLogFileUnlocked() { |
| 329 if (!g_log_file) | 332 if (!g_log_file) |
| 330 return; | 333 return; |
| 331 | 334 |
| 332 CloseFile(g_log_file); | 335 CloseFile(g_log_file); |
| 333 g_log_file = nullptr; | 336 g_log_file = nullptr; |
| 334 } | 337 } |
| 335 | 338 |
| 336 } // namespace | 339 } // namespace |
| 337 | 340 |
| 341 #if defined(DCHECK_IS_DUMP_WITHOUT_CRASH) | |
| 342 // Used to implement dump-on-DCHECK. See crbug.com/596231. | |
| 343 void DCheckDumpWithoutCrashing() { | |
| 344 // To ensure we don't risk spamming Crash with dump-on-DCHECK reports we | |
| 345 // log only the first DCHECK to fail once DumpWithoutCrashing() is working. | |
| 346 static bool dump_on_dcheck = true; | |
|
Nico
2016/03/20 23:10:40
this is racy (doubt it matters though)
Wez
2016/03/23 04:18:13
Extended comment to clarify that yes, that's under
| |
| 347 if (dump_on_dcheck) | |
| 348 dump_on_dcheck = !base::debug::DumpWithoutCrashing(); | |
|
Nico
2016/03/20 23:10:40
for stacks in renderer processes, this will dump o
Wez
2016/03/23 04:18:13
Yes. Extended comment should make that clearer.
| |
| 349 } | |
| 350 #endif | |
| 351 | |
| 338 LoggingSettings::LoggingSettings() | 352 LoggingSettings::LoggingSettings() |
| 339 : logging_dest(LOG_DEFAULT), | 353 : logging_dest(LOG_DEFAULT), |
| 340 log_file(nullptr), | 354 log_file(nullptr), |
| 341 lock_log(LOCK_LOG_FILE), | 355 lock_log(LOCK_LOG_FILE), |
| 342 delete_old(APPEND_TO_OLD_LOG_FILE) {} | 356 delete_old(APPEND_TO_OLD_LOG_FILE) {} |
| 343 | 357 |
| 344 bool BaseInitLoggingImpl(const LoggingSettings& settings) { | 358 bool BaseInitLoggingImpl(const LoggingSettings& settings) { |
| 345 #if defined(OS_NACL) | 359 #if defined(OS_NACL) |
| 346 // Can log only to the system debug log. | 360 // Can log only to the system debug log. |
| 347 CHECK_EQ(settings.logging_dest & ~LOG_TO_SYSTEM_DEBUG_LOG, 0); | 361 CHECK_EQ(settings.logging_dest & ~LOG_TO_SYSTEM_DEBUG_LOG, 0); |
| (...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 910 BASE_EXPORT void LogErrorNotReached(const char* file, int line) { | 924 BASE_EXPORT void LogErrorNotReached(const char* file, int line) { |
| 911 LogMessage(file, line, LOG_ERROR).stream() | 925 LogMessage(file, line, LOG_ERROR).stream() |
| 912 << "NOTREACHED() hit."; | 926 << "NOTREACHED() hit."; |
| 913 } | 927 } |
| 914 | 928 |
| 915 } // namespace logging | 929 } // namespace logging |
| 916 | 930 |
| 917 std::ostream& std::operator<<(std::ostream& out, const wchar_t* wstr) { | 931 std::ostream& std::operator<<(std::ostream& out, const wchar_t* wstr) { |
| 918 return out << (wstr ? base::WideToUTF8(wstr) : std::string()); | 932 return out << (wstr ? base::WideToUTF8(wstr) : std::string()); |
| 919 } | 933 } |
| OLD | NEW |