michael@0: /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- michael@0: * vim: set ts=8 sts=4 et sw=4 tw=99: michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef jscrashformat_h michael@0: #define jscrashformat_h michael@0: michael@0: namespace js { michael@0: namespace crash { michael@0: michael@0: static const int crash_cookie_len = 16; michael@0: static const char crash_cookie[crash_cookie_len] = "*J*S*CRASHDATA*"; michael@0: michael@0: /* These values are used for CrashHeader::id. */ michael@0: enum { michael@0: JS_CRASH_STACK_GC = 0x400, michael@0: JS_CRASH_STACK_ERROR = 0x401, michael@0: JS_CRASH_RING = 0x800 michael@0: }; michael@0: michael@0: /* michael@0: * All the data here will be stored directly in the minidump, so we use michael@0: * platform-independent types. We also ensure that the size of every field is a michael@0: * multiple of 8 bytes, to guarantee that they won't be padded. michael@0: */ michael@0: michael@0: struct CrashHeader michael@0: { michael@0: char cookie[crash_cookie_len]; michael@0: michael@0: /* id of the crash data, chosen from the enum above. */ michael@0: uint64_t id; michael@0: michael@0: CrashHeader(uint64_t id) : id(id) { memcpy(cookie, crash_cookie, crash_cookie_len); } michael@0: }; michael@0: michael@0: struct CrashRegisters michael@0: { michael@0: uint64_t ip, sp, bp; michael@0: }; michael@0: michael@0: static const int crash_buffer_size = 32 * 1024; michael@0: michael@0: struct CrashStack michael@0: { michael@0: CrashStack(uint64_t id) : header(id) {} michael@0: michael@0: CrashHeader header; michael@0: uint64_t snaptime; /* Unix time when the stack was snapshotted. */ michael@0: CrashRegisters regs; /* Register contents for the snapshot. */ michael@0: uint64_t stack_base; /* Base address of stack at the time of snapshot. */ michael@0: uint64_t stack_len; /* Extent of the stack. */ michael@0: char stack[crash_buffer_size]; /* Contents of the stack. */ michael@0: }; michael@0: michael@0: struct CrashRing michael@0: { michael@0: CrashRing(uint64_t id) : header(id), offset(0) { memset(buffer, 0, sizeof(buffer)); } michael@0: michael@0: CrashHeader header; michael@0: uint64_t offset; /* Next byte to be written in the buffer. */ michael@0: char buffer[crash_buffer_size]; michael@0: }; michael@0: michael@0: /* These are the tag values for each entry in the CrashRing. */ michael@0: enum { michael@0: JS_CRASH_TAG_GC = 0x200 michael@0: }; michael@0: michael@0: } /* namespace crash */ michael@0: } /* namespace js */ michael@0: michael@0: #endif /* jscrashformat_h */