1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/jscrashformat.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,75 @@ 1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- 1.5 + * vim: set ts=8 sts=4 et sw=4 tw=99: 1.6 + * This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +#ifndef jscrashformat_h 1.11 +#define jscrashformat_h 1.12 + 1.13 +namespace js { 1.14 +namespace crash { 1.15 + 1.16 +static const int crash_cookie_len = 16; 1.17 +static const char crash_cookie[crash_cookie_len] = "*J*S*CRASHDATA*"; 1.18 + 1.19 +/* These values are used for CrashHeader::id. */ 1.20 +enum { 1.21 + JS_CRASH_STACK_GC = 0x400, 1.22 + JS_CRASH_STACK_ERROR = 0x401, 1.23 + JS_CRASH_RING = 0x800 1.24 +}; 1.25 + 1.26 +/* 1.27 + * All the data here will be stored directly in the minidump, so we use 1.28 + * platform-independent types. We also ensure that the size of every field is a 1.29 + * multiple of 8 bytes, to guarantee that they won't be padded. 1.30 + */ 1.31 + 1.32 +struct CrashHeader 1.33 +{ 1.34 + char cookie[crash_cookie_len]; 1.35 + 1.36 + /* id of the crash data, chosen from the enum above. */ 1.37 + uint64_t id; 1.38 + 1.39 + CrashHeader(uint64_t id) : id(id) { memcpy(cookie, crash_cookie, crash_cookie_len); } 1.40 +}; 1.41 + 1.42 +struct CrashRegisters 1.43 +{ 1.44 + uint64_t ip, sp, bp; 1.45 +}; 1.46 + 1.47 +static const int crash_buffer_size = 32 * 1024; 1.48 + 1.49 +struct CrashStack 1.50 +{ 1.51 + CrashStack(uint64_t id) : header(id) {} 1.52 + 1.53 + CrashHeader header; 1.54 + uint64_t snaptime; /* Unix time when the stack was snapshotted. */ 1.55 + CrashRegisters regs; /* Register contents for the snapshot. */ 1.56 + uint64_t stack_base; /* Base address of stack at the time of snapshot. */ 1.57 + uint64_t stack_len; /* Extent of the stack. */ 1.58 + char stack[crash_buffer_size]; /* Contents of the stack. */ 1.59 +}; 1.60 + 1.61 +struct CrashRing 1.62 +{ 1.63 + CrashRing(uint64_t id) : header(id), offset(0) { memset(buffer, 0, sizeof(buffer)); } 1.64 + 1.65 + CrashHeader header; 1.66 + uint64_t offset; /* Next byte to be written in the buffer. */ 1.67 + char buffer[crash_buffer_size]; 1.68 +}; 1.69 + 1.70 +/* These are the tag values for each entry in the CrashRing. */ 1.71 +enum { 1.72 + JS_CRASH_TAG_GC = 0x200 1.73 +}; 1.74 + 1.75 +} /* namespace crash */ 1.76 +} /* namespace js */ 1.77 + 1.78 +#endif /* jscrashformat_h */