Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- |
michael@0 | 2 | * vim: set ts=8 sts=4 et sw=4 tw=99: |
michael@0 | 3 | * This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | |
michael@0 | 7 | #ifndef jscrashreport_h |
michael@0 | 8 | #define jscrashreport_h |
michael@0 | 9 | |
michael@0 | 10 | #include "mozilla/GuardObjects.h" |
michael@0 | 11 | |
michael@0 | 12 | #include <stdint.h> |
michael@0 | 13 | |
michael@0 | 14 | namespace js { |
michael@0 | 15 | namespace crash { |
michael@0 | 16 | |
michael@0 | 17 | void |
michael@0 | 18 | SnapshotGCStack(); |
michael@0 | 19 | |
michael@0 | 20 | void |
michael@0 | 21 | SnapshotErrorStack(); |
michael@0 | 22 | |
michael@0 | 23 | void |
michael@0 | 24 | SaveCrashData(uint64_t tag, void *ptr, size_t size); |
michael@0 | 25 | |
michael@0 | 26 | template<size_t size, unsigned char marker> |
michael@0 | 27 | class StackBuffer |
michael@0 | 28 | { |
michael@0 | 29 | public: |
michael@0 | 30 | StackBuffer(void *data |
michael@0 | 31 | MOZ_GUARD_OBJECT_NOTIFIER_PARAM) |
michael@0 | 32 | { |
michael@0 | 33 | MOZ_GUARD_OBJECT_NOTIFIER_INIT; |
michael@0 | 34 | |
michael@0 | 35 | buffer[0] = marker; |
michael@0 | 36 | buffer[1] = '['; |
michael@0 | 37 | |
michael@0 | 38 | for (size_t i = 0; i < size; i++) { |
michael@0 | 39 | if (data) |
michael@0 | 40 | buffer[i + 2] = static_cast<unsigned char*>(data)[i]; |
michael@0 | 41 | else |
michael@0 | 42 | buffer[i + 2] = 0; |
michael@0 | 43 | } |
michael@0 | 44 | |
michael@0 | 45 | buffer[size - 2] = ']'; |
michael@0 | 46 | buffer[size - 1] = marker; |
michael@0 | 47 | } |
michael@0 | 48 | |
michael@0 | 49 | private: |
michael@0 | 50 | MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER |
michael@0 | 51 | volatile unsigned char buffer[size + 4]; |
michael@0 | 52 | }; |
michael@0 | 53 | |
michael@0 | 54 | } /* namespace crash */ |
michael@0 | 55 | } /* namespace js */ |
michael@0 | 56 | |
michael@0 | 57 | #endif /* jscrashreport_h */ |