Bug 1125929 - Remove the unused GC stack capture; r=billm

--HG--
extra : rebase_source : e3e11fcde39720c6bf5b62bf670b04debc193426
This commit is contained in:
Terrence Cole 2015-01-28 11:52:01 -08:00
parent 930c032cf0
commit aa3b065ff1
10 changed files with 5 additions and 437 deletions

View File

@ -7272,18 +7272,6 @@ fi
AC_SUBST_LIST(MOZ_GLUE_WRAP_LDFLAGS)
export MOZ_GLUE_WRAP_LDFLAGS
dnl ========================================================
dnl JS opt-mode assertions and minidump instrumentation
dnl ========================================================
MOZ_ARG_ENABLE_BOOL(js-diagnostics,
[ --enable-js-diagnostics
Enable JS diagnostic assertions and breakpad data],
JS_CRASH_DIAGNOSTICS=1,
JS_CRASH_DIAGNOSTICS= )
if test -n "$JS_CRASH_DIAGNOSTICS"; then
AC_DEFINE(JS_CRASH_DIAGNOSTICS)
fi
dnl ========================================================
dnl = Enable static checking using gcc-dehydra
dnl ========================================================

View File

@ -3253,11 +3253,11 @@ if test -n "$JS_ION_PERF"; then
fi
dnl ========================================================
dnl JS opt-mode assertions and minidump instrumentation
dnl JS opt-mode assertions and heap poisoning
dnl ========================================================
MOZ_ARG_ENABLE_BOOL(js-diagnostics,
[ --enable-js-diagnostics
Enable JS diagnostic assertions and breakpad data],
Enable JS diagnostic assertions heap poisoning],
JS_CRASH_DIAGNOSTICS=1,
JS_CRASH_DIAGNOSTICS= )
if test -n "$JS_CRASH_DIAGNOSTICS"; then

View File

@ -14,7 +14,6 @@
#include <stdarg.h>
#include <stdio.h>
#include "jscrashreport.h"
#include "jsprf.h"
#include "jsutil.h"
#include "prmjtime.h"
@ -928,8 +927,6 @@ Statistics::beginGC(JSGCInvocationKind kind)
void
Statistics::endGC()
{
crash::SnapshotGCStack();
for (size_t j = 0; j < MAX_MULTIPARENT_PHASES + 1; j++)
for (int i = 0; i < PHASE_LIMIT; i++)
phaseTotals[j][i] += phaseTimes[j][i];

View File

@ -31,6 +31,9 @@
/* Define to 1 if SpiderMonkey should use small chunks. */
#undef JS_GC_SMALL_CHUNK_SIZE
/* Define to 1 to perform extra assertions and heap poisoning. */
#undef JS_CRASH_DIAGNOSTICS
/* Define to 1 if the <endian.h> header is present and
useable. See jscpucfg.h. */
#undef JS_HAVE_ENDIAN_H

View File

@ -1757,16 +1757,6 @@ extern JS_PUBLIC_API(void)
JS_SetCTypesCallbacks(JSObject *ctypesObj, const JSCTypesCallbacks *callbacks);
#endif
typedef bool
(* JSEnumerateDiagnosticMemoryCallback)(void *ptr, size_t length);
/*
* Enumerate memory regions that contain diagnostic information
* intended to be included in crash report minidumps.
*/
extern JS_PUBLIC_API(void)
JS_EnumerateDiagnosticMemoryRegions(JSEnumerateDiagnosticMemoryCallback callback);
extern JS_PUBLIC_API(void *)
JS_malloc(JSContext *cx, size_t nbytes);

View File

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

View File

@ -1,266 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* vim: set ts=8 sts=4 et sw=4 tw=99:
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "jscrashreport.h"
#include <time.h>
#include "jsapi.h"
#include "jscrashformat.h"
#include "jsutil.h"
using namespace js;
using namespace js::crash;
#if defined(XP_WIN)
static const int stack_snapshot_max_size = 32768;
#include <windows.h>
static bool
GetStack(uint64_t *stack, uint64_t *stack_len, CrashRegisters *regs, char *buffer, size_t size)
{
/* Try to figure out how big the stack is. */
char dummy;
MEMORY_BASIC_INFORMATION info;
if (VirtualQuery(reinterpret_cast<LPCVOID>(&dummy), &info, sizeof(info)) == 0)
return false;
if (info.State != MEM_COMMIT)
return false;
/* 256 is a fudge factor to account for the rest of GetStack's frame. */
uint64_t p = uint64_t(&dummy) - 256;
uint64_t len = stack_snapshot_max_size;
if (p + len > uint64_t(info.BaseAddress) + info.RegionSize)
len = uint64_t(info.BaseAddress) + info.RegionSize - p;
if (len > size)
len = size;
*stack = p;
*stack_len = len;
/* Get the register state. */
#if defined(_MSC_VER) && defined(_M_IX86)
/* ASM version for win2k that doesn't support RtlCaptureContext */
uint32_t vip, vsp, vbp;
__asm {
MyLabel:
mov [vbp], ebp;
mov [vsp], esp;
mov eax, [MyLabel];
mov [vip], eax;
}
regs->ip = vip;
regs->sp = vsp;
regs->bp = vbp;
#else
CONTEXT context;
RtlCaptureContext(&context);
#if defined(_M_IX86)
regs->ip = context.Eip;
regs->sp = context.Esp;
regs->bp = context.Ebp;
#elif defined(_M_X64)
regs->ip = context.Rip;
regs->sp = context.Rsp;
regs->bp = context.Rbp;
#else
#error unknown cpu architecture
#endif
#endif
js_memcpy(buffer, (void *)p, len);
return true;
}
#elif 0
#include <sys/mman.h>
#include <ucontext.h>
#include <unistd.h>
static bool
GetStack(uint64_t *stack, uint64_t *stack_len, CrashRegisters *regs, char *buffer, size_t size)
{
/* 256 is a fudge factor to account for the rest of GetStack's frame. */
char dummy;
uint64_t p = uint64_t(&dummy) - 256;
uint64_t pgsz = getpagesize();
uint64_t len = stack_snapshot_max_size;
p &= ~(pgsz - 1);
/* Try to figure out how big the stack is. */
while (len > 0) {
if (mlock((const void *)p, len) == 0) {
munlock((const void *)p, len);
break;
}
len -= pgsz;
}
if (len > size)
len = size;
*stack = p;
*stack_len = len;
/* Get the register state. */
ucontext_t context;
if (getcontext(&context) != 0)
return false;
#if defined(__x86_64__)
regs->sp = (uint64_t)context.uc_mcontext.gregs[REG_RSP];
regs->bp = (uint64_t)context.uc_mcontext.gregs[REG_RBP];
regs->ip = (uint64_t)context.uc_mcontext.gregs[REG_RIP];
#elif defined(__i386__)
regs->sp = (uint64_t)context.uc_mcontext.gregs[REG_ESP];
regs->bp = (uint64_t)context.uc_mcontext.gregs[REG_EBP];
regs->ip = (uint64_t)context.uc_mcontext.gregs[REG_EIP];
#else
#error unknown cpu architecture
#endif
js_memcpy(buffer, (void *)p, len);
return true;
}
#else
static bool
GetStack(uint64_t *stack, uint64_t *stack_len, CrashRegisters *regs, char *buffer, size_t size)
{
return false;
}
#endif
namespace js {
namespace crash {
class Stack : private CrashStack
{
public:
explicit Stack(uint64_t id);
bool snapshot();
};
Stack::Stack(uint64_t id)
: CrashStack(id)
{
}
bool
Stack::snapshot()
{
snaptime = time(nullptr);
return GetStack(&stack_base, &stack_len, &regs, stack, sizeof(stack));
}
class Ring : private CrashRing
{
public:
explicit Ring(uint64_t id);
void push(uint64_t tag, void *data, size_t size);
private:
size_t bufferSize() { return crash_buffer_size; }
void copyBytes(void *data, size_t size);
};
Ring::Ring(uint64_t id)
: CrashRing(id)
{
}
void
Ring::push(uint64_t tag, void *data, size_t size)
{
uint64_t t = time(nullptr);
copyBytes(&tag, sizeof(uint64_t));
copyBytes(&t, sizeof(uint64_t));
copyBytes(data, size);
uint64_t mysize = size;
copyBytes(&mysize, sizeof(uint64_t));
}
void
Ring::copyBytes(void *data, size_t size)
{
if (size >= bufferSize())
size = bufferSize();
if (offset + size > bufferSize()) {
size_t first = bufferSize() - offset;
size_t second = size - first;
js_memcpy(&buffer[offset], data, first);
js_memcpy(buffer, (char *)data + first, second);
offset = second;
} else {
js_memcpy(&buffer[offset], data, size);
offset += size;
}
}
} /* namespace crash */
} /* namespace js */
#ifdef JS_CRASH_DIAGNOSTICS
static bool gInitialized;
static Stack gGCStack(JS_CRASH_STACK_GC);
static Stack gErrorStack(JS_CRASH_STACK_ERROR);
static Ring gRingBuffer(JS_CRASH_RING);
#endif
void
js::crash::SnapshotGCStack()
{
#ifdef JS_CRASH_DIAGNOSTICS
if (gInitialized)
gGCStack.snapshot();
#endif
}
void
js::crash::SnapshotErrorStack()
{
#ifdef JS_CRASH_DIAGNOSTICS
if (gInitialized)
gErrorStack.snapshot();
#endif
}
void
js::crash::SaveCrashData(uint64_t tag, void *ptr, size_t size)
{
#ifdef JS_CRASH_DIAGNOSTICS
if (gInitialized)
gRingBuffer.push(tag, ptr, size);
#endif
}
JS_PUBLIC_API(void)
JS_EnumerateDiagnosticMemoryRegions(JSEnumerateDiagnosticMemoryCallback callback)
{
#ifdef JS_CRASH_DIAGNOSTICS
if (!gInitialized) {
gInitialized = true;
(*callback)(&gGCStack, sizeof(gGCStack));
(*callback)(&gErrorStack, sizeof(gErrorStack));
(*callback)(&gRingBuffer, sizeof(gRingBuffer));
}
#endif
}

View File

@ -1,57 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* vim: set ts=8 sts=4 et sw=4 tw=99:
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef jscrashreport_h
#define jscrashreport_h
#include "mozilla/GuardObjects.h"
#include <stdint.h>
namespace js {
namespace crash {
void
SnapshotGCStack();
void
SnapshotErrorStack();
void
SaveCrashData(uint64_t tag, void *ptr, size_t size);
template<size_t size, unsigned char marker>
class StackBuffer
{
public:
explicit StackBuffer(void *data
MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
{
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
buffer[0] = marker;
buffer[1] = '[';
for (size_t i = 0; i < size; i++) {
if (data)
buffer[i + 2] = static_cast<unsigned char*>(data)[i];
else
buffer[i + 2] = 0;
}
buffer[size - 2] = ']';
buffer[size - 1] = marker;
}
private:
MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
volatile unsigned char buffer[size + 4];
};
} /* namespace crash */
} /* namespace js */
#endif /* jscrashreport_h */

View File

@ -201,7 +201,6 @@ UNIFIED_SOURCES += [
'jsbool.cpp',
'jscntxt.cpp',
'jscompartment.cpp',
'jscrashreport.cpp',
'jsdate.cpp',
'jsdtoa.cpp',
'jsexn.cpp',

View File

@ -2989,14 +2989,6 @@ JSSizeOfTab(JSObject *objArg, size_t *jsObjectsSize, size_t *jsStringsSize,
} // namespace xpc
#ifdef MOZ_CRASHREPORTER
static bool
DiagnosticMemoryCallback(void *ptr, size_t size)
{
return CrashReporter::RegisterAppMemory(ptr, size) == NS_OK;
}
#endif
static void
AccumulateTelemetryCallback(int id, uint32_t sample, const char *key)
{
@ -3324,9 +3316,6 @@ XPCJSRuntime::XPCJSRuntime(nsXPConnect* aXPConnect)
JS_AddWeakPointerCallback(runtime, WeakPointerCallback, this);
JS_SetWrapObjectCallbacks(runtime, &WrapObjectCallbacks);
js::SetPreserveWrapperCallback(runtime, PreserveWrapper);
#ifdef MOZ_CRASHREPORTER
JS_EnumerateDiagnosticMemoryRegions(DiagnosticMemoryCallback);
#endif
#ifdef MOZ_ENABLE_PROFILER_SPS
if (PseudoStack *stack = mozilla_get_pseudo_stack())
stack->sampleRuntime(runtime);