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 jscrashreport_h michael@0: #define jscrashreport_h michael@0: michael@0: #include "mozilla/GuardObjects.h" michael@0: michael@0: #include michael@0: michael@0: namespace js { michael@0: namespace crash { michael@0: michael@0: void michael@0: SnapshotGCStack(); michael@0: michael@0: void michael@0: SnapshotErrorStack(); michael@0: michael@0: void michael@0: SaveCrashData(uint64_t tag, void *ptr, size_t size); michael@0: michael@0: template michael@0: class StackBuffer michael@0: { michael@0: public: michael@0: StackBuffer(void *data michael@0: MOZ_GUARD_OBJECT_NOTIFIER_PARAM) michael@0: { michael@0: MOZ_GUARD_OBJECT_NOTIFIER_INIT; michael@0: michael@0: buffer[0] = marker; michael@0: buffer[1] = '['; michael@0: michael@0: for (size_t i = 0; i < size; i++) { michael@0: if (data) michael@0: buffer[i + 2] = static_cast(data)[i]; michael@0: else michael@0: buffer[i + 2] = 0; michael@0: } michael@0: michael@0: buffer[size - 2] = ']'; michael@0: buffer[size - 1] = marker; michael@0: } michael@0: michael@0: private: michael@0: MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER michael@0: volatile unsigned char buffer[size + 4]; michael@0: }; michael@0: michael@0: } /* namespace crash */ michael@0: } /* namespace js */ michael@0: michael@0: #endif /* jscrashreport_h */