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
|
// Copyright 2006 The Android Open Source Project
#ifndef DMTRACE_H
#define DMTRACE_H
#include <vector>
class DmTrace {
public:
struct Header {
uint32_t magic;
uint16_t version;
uint16_t offset;
uint64_t date_time;
};
DmTrace();
~DmTrace();
void open(const char *dmtrace_file, uint64_t startTime);
void close();
void addFunctionEntry(int methodId, uint32_t cycle, uint32_t pid);
void addFunctionExit(int methodId, uint32_t cycle, uint32_t pid);
void addFunction(int functionId, const char *name);
void addFunction(int functionId, const char *clazz, const char *method,
const char *sig);
void parseAndAddFunction(int functionId, const char *name);
void addThread(int threadId, const char *name);
void updateName(int threadId, const char *name);
private:
static const Header header;
struct ThreadRecord {
int id;
const char *name;
};
struct FunctionRecord {
int id;
const char *name;
};
void write2LE(FILE* fstream, unsigned short val);
void write4LE(FILE* fstream, unsigned int val);
void write8LE(FILE* fstream, unsigned long long val);
void writeHeader(FILE *fstream, uint64_t startTime);
void writeDataRecord(FILE *fstream, int threadId,
unsigned int methodVal,
unsigned int elapsedTime);
void writeKeyFile(FILE *fstream);
void writeThreads(FILE *fstream);
void writeFunctions(FILE *fstream);
FILE *fData;
FILE *fTrace;
std::vector<ThreadRecord*> *threads;
std::vector<FunctionRecord*> *functions;
};
#endif // DMTRACE_H
|