Introduce RecordCrashReason().
git-svn-id: https://google-glog.googlecode.com/svn/trunk@40 eb4d4688-79bd-11dd-afb4-1d65580434c0
This commit is contained in:
parent
f365379532
commit
4a3f102ce0
@ -840,6 +840,7 @@ namespace glog_internal_namespace_ {
|
||||
template <bool>
|
||||
struct CompileAssert {
|
||||
};
|
||||
class CrashReason;
|
||||
} // namespace glog_internal_namespace_
|
||||
|
||||
#define GOOGLE_GLOG_COMPILE_ASSERT(expr, msg) \
|
||||
@ -1106,6 +1107,9 @@ private:
|
||||
void Init(const char* file, int line, LogSeverity severity,
|
||||
void (LogMessage::*send_method)());
|
||||
|
||||
// Used to fill in crash information during LOG(FATAL) failures.
|
||||
void RecordCrashReason(glog_internal_namespace_::CrashReason* reason);
|
||||
|
||||
// Counts of messages sent at each priority:
|
||||
static int64 num_messages_[NUM_SEVERITIES]; // under log_mutex
|
||||
|
||||
|
||||
@ -1182,17 +1182,9 @@ void LogMessage::SendToLog() EXCLUSIVE_LOCKS_REQUIRED(log_mutex) {
|
||||
// someone else can use them (as long as they flush afterwards)
|
||||
if (data_->severity_ == FATAL && exit_on_dfatal) {
|
||||
if (data_->first_fatal_) {
|
||||
crash_reason.filename = fatal_msg_data_exclusive_.fullname_;
|
||||
crash_reason.line_number = fatal_msg_data_exclusive_.line_;
|
||||
crash_reason.message = fatal_msg_buf_exclusive +
|
||||
fatal_msg_data_exclusive_.num_prefix_chars_;
|
||||
#ifdef HAVE_STACKTRACE
|
||||
crash_reason.depth = GetStackTrace(crash_reason.stack,
|
||||
ARRAYSIZE(crash_reason.stack),
|
||||
3);
|
||||
#else
|
||||
crash_reason.depth = 0;
|
||||
#endif
|
||||
// Store crash information so that it is accessible from within signal
|
||||
// handlers that may be invoked later.
|
||||
RecordCrashReason(&crash_reason);
|
||||
SetCrashReason(&crash_reason);
|
||||
|
||||
// Store shortened fatal message for other logs and GWQ status
|
||||
@ -1224,6 +1216,20 @@ void LogMessage::SendToLog() EXCLUSIVE_LOCKS_REQUIRED(log_mutex) {
|
||||
}
|
||||
}
|
||||
|
||||
void LogMessage::RecordCrashReason(
|
||||
glog_internal_namespace_::CrashReason* reason) {
|
||||
reason->filename = fatal_msg_data_exclusive_.fullname_;
|
||||
reason->line_number = fatal_msg_data_exclusive_.line_;
|
||||
reason->message = fatal_msg_buf_exclusive +
|
||||
fatal_msg_data_exclusive_.num_prefix_chars_;
|
||||
#ifdef HAVE_STACKTRACE
|
||||
// Retrieve the stack trace, omitting the logging frames that got us here.
|
||||
reason->depth = GetStackTrace(reason->stack, ARRAYSIZE(reason->stack), 4);
|
||||
#else
|
||||
reason->depth = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void logging_fail() {
|
||||
#if defined(_DEBUG) && defined(_MSC_VER)
|
||||
// When debugging on windows, avoid the obnoxious dialog and make
|
||||
|
||||
@ -201,8 +201,8 @@ struct CrashReason {
|
||||
int line_number;
|
||||
const char* message;
|
||||
|
||||
// We'll also store a bit of context at the time of crash as it may not be
|
||||
// available later on.
|
||||
// We'll also store a bit of stack trace context at the time of crash as
|
||||
// it may not be available later on.
|
||||
void* stack[32];
|
||||
int depth;
|
||||
};
|
||||
|
||||
@ -844,6 +844,7 @@ namespace glog_internal_namespace_ {
|
||||
template <bool>
|
||||
struct CompileAssert {
|
||||
};
|
||||
class CrashReason;
|
||||
} // namespace glog_internal_namespace_
|
||||
|
||||
#define GOOGLE_GLOG_COMPILE_ASSERT(expr, msg) \
|
||||
@ -1110,6 +1111,9 @@ private:
|
||||
void Init(const char* file, int line, LogSeverity severity,
|
||||
void (LogMessage::*send_method)());
|
||||
|
||||
// Used to fill in crash information during LOG(FATAL) failures.
|
||||
void RecordCrashReason(glog_internal_namespace_::CrashReason* reason);
|
||||
|
||||
// Counts of messages sent at each priority:
|
||||
static int64 num_messages_[NUM_SEVERITIES]; // under log_mutex
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user