~ubuntu-branches/ubuntu/saucy/mozjs17/saucy

« back to all changes in this revision

Viewing changes to js/src/jscrashreport.h

  • Committer: Package Import Robot
  • Author(s): Rico Tzschichholz
  • Date: 2013-05-25 12:24:23 UTC
  • Revision ID: package-import@ubuntu.com-20130525122423-zmxucrhtensw90xy
Tags: upstream-17.0.0
ImportĀ upstreamĀ versionĀ 17.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
 
2
 * vim: set ts=4 sw=4 et tw=99:
 
3
 *
 
4
 * This Source Code Form is subject to the terms of the Mozilla Public
 
5
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 
6
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
7
 
 
8
#ifndef jscrashreport_h___
 
9
#define jscrashreport_h___
 
10
 
 
11
#include "jstypes.h"
 
12
#include "jsutil.h"
 
13
 
 
14
namespace js {
 
15
namespace crash {
 
16
 
 
17
void
 
18
SnapshotGCStack();
 
19
 
 
20
void
 
21
SnapshotErrorStack();
 
22
 
 
23
void
 
24
SaveCrashData(uint64_t tag, void *ptr, size_t size);
 
25
 
 
26
template<size_t size, unsigned char marker>
 
27
class StackBuffer {
 
28
  private:
 
29
    JS_DECL_USE_GUARD_OBJECT_NOTIFIER
 
30
    volatile unsigned char buffer[size + 4];
 
31
 
 
32
  public:
 
33
    StackBuffer(void *data JS_GUARD_OBJECT_NOTIFIER_PARAM) {
 
34
        JS_GUARD_OBJECT_NOTIFIER_INIT;
 
35
 
 
36
        buffer[0] = marker;
 
37
        buffer[1] = '[';
 
38
 
 
39
        for (size_t i = 0; i < size; i++) {
 
40
            if (data)
 
41
                buffer[i + 2] = ((unsigned char *)data)[i];
 
42
            else
 
43
                buffer[i + 2] = 0;
 
44
        }
 
45
 
 
46
        buffer[size - 2] = ']';
 
47
        buffer[size - 1] = marker;
 
48
    }
 
49
};
 
50
 
 
51
} /* namespace crash */
 
52
} /* namespace js */
 
53
 
 
54
#endif /* jscrashreport_h___ */