1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/jscrashreport.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,57 @@ 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 jscrashreport_h 1.11 +#define jscrashreport_h 1.12 + 1.13 +#include "mozilla/GuardObjects.h" 1.14 + 1.15 +#include <stdint.h> 1.16 + 1.17 +namespace js { 1.18 +namespace crash { 1.19 + 1.20 +void 1.21 +SnapshotGCStack(); 1.22 + 1.23 +void 1.24 +SnapshotErrorStack(); 1.25 + 1.26 +void 1.27 +SaveCrashData(uint64_t tag, void *ptr, size_t size); 1.28 + 1.29 +template<size_t size, unsigned char marker> 1.30 +class StackBuffer 1.31 +{ 1.32 + public: 1.33 + StackBuffer(void *data 1.34 + MOZ_GUARD_OBJECT_NOTIFIER_PARAM) 1.35 + { 1.36 + MOZ_GUARD_OBJECT_NOTIFIER_INIT; 1.37 + 1.38 + buffer[0] = marker; 1.39 + buffer[1] = '['; 1.40 + 1.41 + for (size_t i = 0; i < size; i++) { 1.42 + if (data) 1.43 + buffer[i + 2] = static_cast<unsigned char*>(data)[i]; 1.44 + else 1.45 + buffer[i + 2] = 0; 1.46 + } 1.47 + 1.48 + buffer[size - 2] = ']'; 1.49 + buffer[size - 1] = marker; 1.50 + } 1.51 + 1.52 + private: 1.53 + MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER 1.54 + volatile unsigned char buffer[size + 4]; 1.55 +}; 1.56 + 1.57 +} /* namespace crash */ 1.58 +} /* namespace js */ 1.59 + 1.60 +#endif /* jscrashreport_h */