1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 : * vim: set ts=4 sw=4 et tw=99:
3 : *
4 : * ***** BEGIN LICENSE BLOCK *****
5 : * Version: MPL 1.1/GPL 2.0/LGPL 2.1
6 : *
7 : * The contents of this file are subject to the Mozilla Public License Version
8 : * 1.1 (the "License"); you may not use this file except in compliance with
9 : * the License. You may obtain a copy of the License at
10 : * http://www.mozilla.org/MPL/
11 : *
12 : * Software distributed under the License is distributed on an "AS IS" basis,
13 : * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
14 : * for the specific language governing rights and limitations under the
15 : * License.
16 : *
17 : * The Original Code is Mozilla SpiderMonkey JavaScript 1.9 code, released
18 : * May 28, 2008.
19 : *
20 : * The Initial Developer of the Original Code is
21 : * Mozilla Foundation
22 : * Portions created by the Initial Developer are Copyright (C) 2011
23 : * the Initial Developer. All Rights Reserved.
24 : *
25 : * Contributor(s):
26 : *
27 : * Alternatively, the contents of this file may be used under the terms of
28 : * either of the GNU General Public License Version 2 or later (the "GPL"),
29 : * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
30 : * in which case the provisions of the GPL or the LGPL are applicable instead
31 : * of those above. If you wish to allow use of your version of this file only
32 : * under the terms of either the GPL or the LGPL, and not to allow others to
33 : * use your version of this file under the terms of the MPL, indicate your
34 : * decision by deleting the provisions above and replace them with the notice
35 : * and other provisions required by the GPL or the LGPL. If you do not delete
36 : * the provisions above, a recipient may use your version of this file under
37 : * the terms of any one of the MPL, the GPL or the LGPL.
38 : *
39 : * ***** END LICENSE BLOCK ***** */
40 :
41 : #ifndef jscrashformat_h___
42 : #define jscrashformat_h___
43 :
44 : #include <string.h>
45 :
46 : namespace js {
47 : namespace crash {
48 :
49 : const static int crash_cookie_len = 16;
50 : const static char crash_cookie[crash_cookie_len] = "*J*S*CRASHDATA*";
51 :
52 : /* These values are used for CrashHeader::id. */
53 : enum {
54 : JS_CRASH_STACK_GC = 0x400,
55 : JS_CRASH_STACK_ERROR = 0x401,
56 : JS_CRASH_RING = 0x800
57 : };
58 :
59 : /*
60 : * All the data here will be stored directly in the minidump, so we use
61 : * platform-independent types. We also ensure that the size of every field is a
62 : * multiple of 8 bytes, to guarantee that they won't be padded.
63 : */
64 :
65 : struct CrashHeader
66 : {
67 : char cookie[crash_cookie_len];
68 :
69 : /* id of the crash data, chosen from the enum above. */
70 : uint64_t id;
71 :
72 59610 : CrashHeader(uint64_t id) : id(id) { memcpy(cookie, crash_cookie, crash_cookie_len); }
73 : };
74 :
75 : struct CrashRegisters
76 : {
77 : uint64_t ip, sp, bp;
78 : };
79 :
80 : const static int crash_buffer_size = 32 * 1024;
81 :
82 : struct CrashStack
83 : {
84 39740 : CrashStack(uint64_t id) : header(id) {}
85 :
86 : CrashHeader header;
87 : uint64_t snaptime; /* Unix time when the stack was snapshotted. */
88 : CrashRegisters regs; /* Register contents for the snapshot. */
89 : uint64_t stack_base; /* Base address of stack at the time of snapshot. */
90 : uint64_t stack_len; /* Extent of the stack. */
91 : char stack[crash_buffer_size]; /* Contents of the stack. */
92 : };
93 :
94 : struct CrashRing
95 : {
96 19870 : CrashRing(uint64_t id) : header(id), offset(0) { memset(buffer, 0, sizeof(buffer)); }
97 :
98 : CrashHeader header;
99 : uint64_t offset; /* Next byte to be written in the buffer. */
100 : char buffer[crash_buffer_size];
101 : };
102 :
103 : /* These are the tag values for each entry in the CrashRing. */
104 : enum {
105 : JS_CRASH_TAG_GC = 0x200
106 : };
107 :
108 : } /* namespace crash */
109 : } /* namespace js */
110 :
111 : #endif
|