blob: 4b94f8f3b6eb000cea31c3e18b5e64406af7186a (
plain)
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
|
#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 {
class Debug {
public:
// If debugging is enabled, write a message to stderr.
static void message(const char* msg)
#ifndef NDEBUG
asm("playground$debugMessage")
#if defined(__x86_64__)
__attribute__((visibility("internal")))
#endif
;
#else
{ }
#endif
// If debugging is enabled, write the name of the syscall and an optional
// message to stderr.
static void syscall(int sysnum, const char* msg, int call = -1)
#ifndef NDEBUG
;
#else
{ }
#endif
// Check whether debugging is enabled.
static bool isEnabled() {
#ifndef NDEBUG
return enabled_;
#else
return false;
#endif
}
private:
#ifndef NDEBUG
Debug();
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__
|