forked from rezass/HMMsim-Server
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsplit.cpp
More file actions
executable file
·151 lines (139 loc) · 4.45 KB
/
split.cpp
File metadata and controls
executable file
·151 lines (139 loc) · 4.45 KB
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
/*
* Copyright (c) 2015 Santiago Bock
*
* See the file LICENSE.txt for copying permission.
*/
/*
* This program splits and compresses a trace read from a file (or pipe) into multiple files.
*/
#include "Arguments.H"
#include "TraceHandler.H"
int main(int argc, char * argv[]){
ArgumentContainer args("split", false);
PositionalArgument<string> inputFile(&args, "input_file", "input file", "");
PositionalArgument<string> outputPrefix(&args, "output_prefix", "output prefix", "");
OptionalArgument<string> compression(&args, "c", "compression algorithm (gzip|bzip2)", "gzip");
if (args.parse(argc, argv)){
args.usage(cerr);
return -1;
}
CompressionType comp;
if (compression.getValue() == "gzip"){
comp = GZIP;
} else if (compression.getValue() == "bzip2"){
comp = BZIP2;
} else {
args.usage(cerr);
return -1;
}
TraceReader reader(inputFile.getValue());
CompressedTraceWriter writer(outputPrefix.getValue(), comp);
TraceEntry entry;
while(reader.readEntry(&entry)){
writer.writeEntry(&entry);
}
return 0;
}
//int main(int argc, char * argv[]){
//
// ArgumentContainer args("split");
// Argument<string> traceFilename(&args, "trace_file_name", "trace file name", false, "trace");
//
// if (args.init(argc, argv)){
// args.usage(cerr);
// return -1;
// }
//
// TraceReader reader(traceFilename.getValue());
//
// BZFILE *instrTimestamp;
// BZFILE *instrAddress;
// BZFILE *instrSize;
// BZFILE *readTimestamp;
// BZFILE *readAddress;
// BZFILE *readSize;
// BZFILE *writeTimestamp;
// BZFILE *writeAddress;
// BZFILE *writeSize;
//
// string filename = traceFilename.getValue()+"-instr-time.bz2";
// if((instrTimestamp = BZ2_bzopen(filename.c_str(), "w")) == 0){
// error("Could not open file '%s'", filename.c_str());
// }
// filename = traceFilename.getValue()+"-instr-addr.bz2";
// if((instrAddress = BZ2_bzopen(filename.c_str(), "w")) == 0){
// error("Could not open file '%s'", filename.c_str());
// }
// filename = traceFilename.getValue()+"-instr-size.bz2";
// if((instrSize = BZ2_bzopen(filename.c_str(), "w")) == 0){
// error("Could not open file '%s'", filename.c_str());
// }
// filename = traceFilename.getValue()+"-read-time.bz2";
// if((readTimestamp = BZ2_bzopen(filename.c_str(), "w")) == 0){
// error("Could not open file '%s'", filename.c_str());
// }
// filename = traceFilename.getValue()+"-read-addr.bz2";
// if((readAddress = BZ2_bzopen(filename.c_str(), "w")) == 0){
// error("Could not open file '%s'", filename.c_str());
// }
// filename = traceFilename.getValue()+"-read-size.bz2";
// if((readSize = BZ2_bzopen(filename.c_str(), "w")) == 0){
// error("Could not open file '%s'", filename.c_str());
// }
// filename = traceFilename.getValue()+"-write-time.bz2";
// if((writeTimestamp = BZ2_bzopen(filename.c_str(), "w")) == 0){
// error("Could not open file '%s'", filename.c_str());
// }
// filename = traceFilename.getValue()+"-write-addr.bz2";
// if((writeAddress = BZ2_bzopen(filename.c_str(), "w")) == 0){
// error("Could not open file '%s'", filename.c_str());
// }
// filename = traceFilename.getValue()+"-write-size.bz2";
// if((writeSize = BZ2_bzopen(filename.c_str(), "w")) == 0){
// error("Could not open file '%s'", filename.c_str());
// }
//
// UINT64 lastITimestamp = 0, lastRTimestamp = 0, lastWTimestamp = 0;
//
// UINT64 timestamp;
// ADDRINT addr;
// UINT8 size;
// BOOL read;
// BOOL instr;
// while(reader.readEntry(×tamp, &addr, &size, &read, &instr)){
// if (instr){
// UINT64 ts = timestamp - lastITimestamp;
// lastITimestamp = timestamp;
// BZ2_bzwrite(instrTimestamp, &ts, sizeof(UINT64));
// BZ2_bzwrite(instrAddress, &addr, sizeof(ADDRINT));
// BZ2_bzwrite(instrSize, &size, sizeof(UINT8));
// } else {
// if (read){
// UINT64 ts = timestamp - lastRTimestamp;
// lastRTimestamp = timestamp;
// BZ2_bzwrite(readTimestamp, &ts, sizeof(UINT64));
// BZ2_bzwrite(readAddress, &addr, sizeof(ADDRINT));
// BZ2_bzwrite(readSize, &size, sizeof(UINT8));
// } else {
// UINT64 ts = timestamp - lastWTimestamp;
// lastWTimestamp = timestamp;
// BZ2_bzwrite(writeTimestamp, &ts , sizeof(UINT64));
// BZ2_bzwrite(writeAddress, &addr, sizeof(ADDRINT));
// BZ2_bzwrite(writeSize, &size, sizeof(UINT8));
// }
// }
// }
//
// BZ2_bzclose(instrTimestamp);
// BZ2_bzclose(instrAddress);
// BZ2_bzclose(instrSize);
// BZ2_bzclose(readTimestamp);
// BZ2_bzclose(readAddress);
// BZ2_bzclose(readSize);
// BZ2_bzclose(writeTimestamp);
// BZ2_bzclose(writeAddress);
// BZ2_bzclose(writeSize);
//
// return 0;
//
//}