diff options
author | ajwong@chromium.org <ajwong@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-24 00:13:08 +0000 |
---|---|---|
committer | ajwong@chromium.org <ajwong@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-24 00:13:08 +0000 |
commit | 96fd00320f4eef1cc52f68939f86b319f6d2095f (patch) | |
tree | 8fd31ba95099df9a246e95792162e2ab812128d6 /base/logging.cc | |
parent | 719ceedfb713882fb1308fc99cac13962d5c8fb8 (diff) | |
download | chromium_src-96fd00320f4eef1cc52f68939f86b319f6d2095f.zip chromium_src-96fd00320f4eef1cc52f68939f86b319f6d2095f.tar.gz chromium_src-96fd00320f4eef1cc52f68939f86b319f6d2095f.tar.bz2 |
Print backtraces on FATAL log messages in debug mode.
This provides basic support for looking up backtrace information on GNU libc systems and in Windows. The code is only enabled for FATAL log messages in debug mode. In a release build, it is unlikely that symbols will be available making the backtrace less useful.
Review URL: http://codereview.chromium.org/62140
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14391 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/logging.cc')
-rw-r--r-- | base/logging.cc | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/base/logging.cc b/base/logging.cc index 961ea6c..7b89020 100644 --- a/base/logging.cc +++ b/base/logging.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -520,6 +520,13 @@ LogMessage::~LogMessage() { if (DebugUtil::BeingDebugged()) { DebugUtil::BreakDebugger(); } else { +#ifndef NDEBUG + // Dump a stack trace on a fatal. + StackTrace trace; + stream_ << "\n"; // Newline to separate from log message. + trace.OutputToStream(&stream_); +#endif + if (log_assert_handler) { // make a copy of the string for the handler out of paranoia log_assert_handler(std::string(stream_.str())); @@ -554,7 +561,7 @@ void CloseLogFile() { log_file = NULL; } -} // namespace logging +} // namespace logging std::ostream& operator<<(std::ostream& out, const wchar_t* wstr) { return out << base::SysWideToUTF8(std::wstring(wstr)); |