|
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- |
|
2 * vim: set ts=8 sts=4 et sw=4 tw=99: |
|
3 * This Source Code Form is subject to the terms of the Mozilla Public |
|
4 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
6 |
|
7 #ifndef jscrashformat_h |
|
8 #define jscrashformat_h |
|
9 |
|
10 namespace js { |
|
11 namespace crash { |
|
12 |
|
13 static const int crash_cookie_len = 16; |
|
14 static const char crash_cookie[crash_cookie_len] = "*J*S*CRASHDATA*"; |
|
15 |
|
16 /* These values are used for CrashHeader::id. */ |
|
17 enum { |
|
18 JS_CRASH_STACK_GC = 0x400, |
|
19 JS_CRASH_STACK_ERROR = 0x401, |
|
20 JS_CRASH_RING = 0x800 |
|
21 }; |
|
22 |
|
23 /* |
|
24 * All the data here will be stored directly in the minidump, so we use |
|
25 * platform-independent types. We also ensure that the size of every field is a |
|
26 * multiple of 8 bytes, to guarantee that they won't be padded. |
|
27 */ |
|
28 |
|
29 struct CrashHeader |
|
30 { |
|
31 char cookie[crash_cookie_len]; |
|
32 |
|
33 /* id of the crash data, chosen from the enum above. */ |
|
34 uint64_t id; |
|
35 |
|
36 CrashHeader(uint64_t id) : id(id) { memcpy(cookie, crash_cookie, crash_cookie_len); } |
|
37 }; |
|
38 |
|
39 struct CrashRegisters |
|
40 { |
|
41 uint64_t ip, sp, bp; |
|
42 }; |
|
43 |
|
44 static const int crash_buffer_size = 32 * 1024; |
|
45 |
|
46 struct CrashStack |
|
47 { |
|
48 CrashStack(uint64_t id) : header(id) {} |
|
49 |
|
50 CrashHeader header; |
|
51 uint64_t snaptime; /* Unix time when the stack was snapshotted. */ |
|
52 CrashRegisters regs; /* Register contents for the snapshot. */ |
|
53 uint64_t stack_base; /* Base address of stack at the time of snapshot. */ |
|
54 uint64_t stack_len; /* Extent of the stack. */ |
|
55 char stack[crash_buffer_size]; /* Contents of the stack. */ |
|
56 }; |
|
57 |
|
58 struct CrashRing |
|
59 { |
|
60 CrashRing(uint64_t id) : header(id), offset(0) { memset(buffer, 0, sizeof(buffer)); } |
|
61 |
|
62 CrashHeader header; |
|
63 uint64_t offset; /* Next byte to be written in the buffer. */ |
|
64 char buffer[crash_buffer_size]; |
|
65 }; |
|
66 |
|
67 /* These are the tag values for each entry in the CrashRing. */ |
|
68 enum { |
|
69 JS_CRASH_TAG_GC = 0x200 |
|
70 }; |
|
71 |
|
72 } /* namespace crash */ |
|
73 } /* namespace js */ |
|
74 |
|
75 #endif /* jscrashformat_h */ |