OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <windows.h> | 8 #include <windows.h> |
9 typedef HANDLE FileHandle; | 9 typedef HANDLE FileHandle; |
10 typedef HANDLE MutexHandle; | 10 typedef HANDLE MutexHandle; |
11 #elif defined(OS_MACOSX) | 11 #elif defined(OS_MACOSX) |
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
513 } else { | 513 } else { |
514 log_lock->Unlock(); | 514 log_lock->Unlock(); |
515 } | 515 } |
516 } | 516 } |
517 | 517 |
518 if (severity_ == LOG_FATAL) { | 518 if (severity_ == LOG_FATAL) { |
519 // display a message or break into the debugger on a fatal error | 519 // display a message or break into the debugger on a fatal error |
520 if (DebugUtil::BeingDebugged()) { | 520 if (DebugUtil::BeingDebugged()) { |
521 DebugUtil::BreakDebugger(); | 521 DebugUtil::BreakDebugger(); |
522 } else { | 522 } else { |
| 523 #ifndef NDEBUG |
| 524 // Dump a stack trace on a fatal. |
| 525 StackTrace trace; |
| 526 stream_ << "\n"; // Newline to separate from log message. |
| 527 trace.OutputToStream(&stream_); |
| 528 #endif |
| 529 |
523 if (log_assert_handler) { | 530 if (log_assert_handler) { |
524 // make a copy of the string for the handler out of paranoia | 531 // make a copy of the string for the handler out of paranoia |
525 log_assert_handler(std::string(stream_.str())); | 532 log_assert_handler(std::string(stream_.str())); |
526 } else { | 533 } else { |
527 // Don't use the string with the newline, get a fresh version to send to | 534 // Don't use the string with the newline, get a fresh version to send to |
528 // the debug message process. We also don't display assertions to the | 535 // the debug message process. We also don't display assertions to the |
529 // user in release mode. The enduser can't do anything with this | 536 // user in release mode. The enduser can't do anything with this |
530 // information, and displaying message boxes when the application is | 537 // information, and displaying message boxes when the application is |
531 // hosed can cause additional problems. | 538 // hosed can cause additional problems. |
532 #ifndef NDEBUG | 539 #ifndef NDEBUG |
(...skipping 14 matching lines...) Expand all Loading... |
547 } | 554 } |
548 | 555 |
549 void CloseLogFile() { | 556 void CloseLogFile() { |
550 if (!log_file) | 557 if (!log_file) |
551 return; | 558 return; |
552 | 559 |
553 CloseFile(log_file); | 560 CloseFile(log_file); |
554 log_file = NULL; | 561 log_file = NULL; |
555 } | 562 } |
556 | 563 |
557 } // namespace logging | 564 } // namespace logging |
558 | 565 |
559 std::ostream& operator<<(std::ostream& out, const wchar_t* wstr) { | 566 std::ostream& operator<<(std::ostream& out, const wchar_t* wstr) { |
560 return out << base::SysWideToUTF8(std::wstring(wstr)); | 567 return out << base::SysWideToUTF8(std::wstring(wstr)); |
561 } | 568 } |
OLD | NEW |