-
Notifications
You must be signed in to change notification settings - Fork 0
/
debug.h
96 lines (80 loc) · 1.83 KB
/
debug.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef DEBUG_H__
#define DEBUG_H__
#include <map>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <string.h>
#include "sandbox_impl.h"
namespace playground {
#ifndef INTERNAL
#define INTERNAL __attribute__((visibility("internal")))
#endif
class Debug {
public:
// If debugging is enabled, write a message to stderr.
static void message(const char* msg)
#ifndef NDEBUG
asm("playground$debugMessage") INTERNAL;
#else
{ }
#endif
// If debugging is enabled, write the name of the syscall and an optional
// message to stderr.
static void syscall(long long* tm, int sysnum,
const char* msg, int call = -1)
#ifndef NDEBUG
;
#else
{ }
#endif
// Print how much wall-time has elapsed since the last call to syscall()
static void elapsed(long long tm, int sysnum, int call = -1)
#ifndef NDEBUG
;
#else
{
}
#endif
// Check whether debugging is enabled.
static bool isEnabled() {
#ifndef NDEBUG
return enabled_;
#else
return false;
#endif
}
// Turn on debugging, if it has not already been enabled.
static void enable()
#ifndef NDEBUG
;
#else
{ }
#endif
// Turn off debugging.
static void disable()
#ifndef NDEBUG
;
#else
{ }
#endif
private:
#ifndef NDEBUG
Debug();
static bool enter();
static bool leave();
static void _message(const char* msg);
static void gettimeofday(long long* tm);
static char* itoa(char* s, int n);
static Debug debug_;
static bool enabled_;
static int numSyscallNames_;
static const char **syscallNames_;
static std::map<int, std::string> syscallNamesMap_;
#endif
};
} // namespace
#endif // DEBUG_H__