• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
3 // found in the LICENSE file.
4 
5 // Support for collecting useful information when crashing.
6 
7 #ifndef BASE_CRASH_H_
8 #define BASE_CRASH_H_
9 
10 namespace base {
11 
12 struct CrashReason {
CrashReasonCrashReason13   CrashReason() : filename(0), line_number(0), message(0), depth(0) {}
14 
15   const char* filename;
16   int line_number;
17   const char* message;
18 
19   // We'll also store a bit of stack trace context at the time of crash as
20   // it may not be available later on.
21   void* stack[32];
22   int depth;
23 
24   // We'll try to store some trace information if it's available - this should
25   // reflect information from TraceContext::Thread()->tracer()->ToString().
26   // This field should probably not be set from within a signal handler or
27   // low-level code unless absolutely safe to do so.
28   char trace_info[512];
29 };
30 
31 // Stores "reason" as an explanation for why the process is about to
32 // crash.  The reason and its contents must remain live for the life
33 // of the process.  Only the first reason is kept.
34 void SetCrashReason(const CrashReason* reason);
35 
36 // Returns first reason passed to SetCrashReason(), or NULL.
37 const CrashReason* GetCrashReason();
38 
39 }  // namespace base
40 
41 #endif  // BASE_CRASH_H_
42