forked from dcapwell/lightweight-java-profiler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprofiler.h
54 lines (34 loc) · 979 Bytes
/
profiler.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
#include <signal.h>
#include "globals.h"
#include "stacktraces.h"
#ifndef PROFILER_H
#define PROFILER_H
class SignalHandler {
public:
SignalHandler() {}
struct sigaction SetAction(void (*sigaction)(int, siginfo_t *, void *));
bool SetSigprofInterval(int sec, int usec);
private:
DISALLOW_COPY_AND_ASSIGN(SignalHandler);
};
struct TraceData {
intptr_t count;
JVMPI_CallTrace trace;
};
class Profiler {
public:
explicit Profiler(jvmtiEnv *jvmti) : jvmti_(jvmti) {}
bool Start();
void Stop();
void DumpToFile(FILE *file);
private:
jvmtiEnv *jvmti_;
SignalHandler handler_;
struct sigaction old_action_;
static TraceData traces_[kMaxStackTraces];
static JVMPI_CallFrame frame_buffer_[kMaxStackTraces][kMaxFramesToCapture];
static int failures_[kNumCallTraceErrors + 1]; // they are indexed from 1
static void Handle(int signum, siginfo_t *info, void *context);
DISALLOW_COPY_AND_ASSIGN(Profiler);
};
#endif // PROFILER_H