js/src/jscrashformat.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     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/. */
     7 #ifndef jscrashformat_h
     8 #define jscrashformat_h
    10 namespace js {
    11 namespace crash {
    13 static const int crash_cookie_len = 16;
    14 static const char crash_cookie[crash_cookie_len] = "*J*S*CRASHDATA*";
    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 };
    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  */
    29 struct CrashHeader
    30 {
    31     char cookie[crash_cookie_len];
    33     /* id of the crash data, chosen from the enum above. */
    34     uint64_t id;
    36     CrashHeader(uint64_t id) : id(id) { memcpy(cookie, crash_cookie, crash_cookie_len); }
    37 };
    39 struct CrashRegisters
    40 {
    41     uint64_t ip, sp, bp;
    42 };
    44 static const int crash_buffer_size = 32 * 1024;
    46 struct CrashStack
    47 {
    48     CrashStack(uint64_t id) : header(id) {}
    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 };
    58 struct CrashRing
    59 {
    60     CrashRing(uint64_t id) : header(id), offset(0) { memset(buffer, 0, sizeof(buffer)); }
    62     CrashHeader header;
    63     uint64_t offset; /* Next byte to be written in the buffer. */
    64     char buffer[crash_buffer_size];
    65 };
    67 /* These are the tag values for each entry in the CrashRing. */
    68 enum {
    69     JS_CRASH_TAG_GC = 0x200
    70 };
    72 } /* namespace crash */
    73 } /* namespace js */
    75 #endif /* jscrashformat_h */

mercurial