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