Source code

Revision control

Other Tools

1
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2
* vim: set ts=8 sts=2 et sw=2 tw=80:
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/. */
6
7
#ifndef ds_MemoryProtectionExceptionHandler_h
8
#define ds_MemoryProtectionExceptionHandler_h
9
10
#include "jstypes.h"
11
12
namespace js {
13
14
/*
15
* This structure allows you to annotate crashes resulting from unauthorized
16
* access to protected memory in regions of interest, to make them stand out
17
* from other heap corruption crashes.
18
*/
19
20
struct MemoryProtectionExceptionHandler {
21
/* Installs the exception handler; called early during initialization. */
22
static bool install();
23
24
/* If the exception handler is disabled, it won't be installed. */
25
static bool isDisabled();
26
27
/*
28
* Marks a region of memory as important; if something tries to access this
29
* region in an unauthorized way (e.g. writing to read-only memory),
30
* the resulting crash will be annotated to stand out from other random
31
* heap corruption.
32
*/
33
static void addRegion(void* addr, size_t size);
34
35
/* Removes a previously added region. */
36
static void removeRegion(void* addr);
37
38
/* Uninstalls the exception handler; called late during shutdown. */
39
static void uninstall();
40
};
41
42
} /* namespace js */
43
44
#endif /* ds_MemoryProtectionExceptionHandler_h */