16 #include "LinuxEvents.h"
18 #define TRACE_HEARTBEAT_ID 19
19 #define PROCESS_FORK_ID 20
20 #define PROCESS_EXIT_ID 21
23 #define OVERFLOW_FIGURE 0x100000000ULL
25 typedef struct _new_process
27 uint32_t event_data1
; /* Data associated with event */
29 } LTT_PACKED_STRUCT new_process
;
31 #define write_to_buffer(DEST, SRC, SIZE) \
34 memcpy(DEST, SRC, SIZE);\
38 int readFile(int fd
, void * buf
, size_t size
, char * mesg
)
40 ssize_t nbBytes
= read(fd
, buf
, size
);
42 if((size_t)nbBytes
!= size
) {
44 perror("Error in readFile : ");
53 void getDataEndianType(char * size
, char * endian
)
57 int sizeInt
=sizeof(int), sizeLong
=sizeof(long), sizePointer
=sizeof(void *);
59 if(c
== 1) strcpy(endian
,"LITTLE_ENDIAN");
60 else strcpy(endian
, "BIG_ENDIAN");
62 if(sizeInt
== 2 && sizeLong
== 4 && sizePointer
== 4)
64 else if(sizeInt
== 4 && sizeLong
== 4 && sizePointer
== 4)
66 else if(sizeInt
== 4 && sizeLong
== 8 && sizePointer
== 8)
68 else if(sizeInt
== 8 && sizeLong
== 8 && sizePointer
== 8)
70 else strcpy(size
,"UNKNOWN");
73 #define BUFFER_SIZE 80
75 typedef struct _buffer_start
{
80 } __attribute__ ((packed
)) buffer_start
;
82 typedef struct _buffer_end
{
87 } __attribute__ ((packed
)) buffer_end
;
90 typedef struct _heartbeat
{
94 } __attribute__ ((packed
)) heartbeat
;
97 int main(int argc
, char ** argv
){
101 int fdFac
, fdIntr
, fdProc
;
102 char arch_size
[BUFFER_SIZE
];
103 char endian
[BUFFER_SIZE
];
104 char node_name
[BUFFER_SIZE
];
105 char domainname
[BUFFER_SIZE
];
106 char kernel_name
[BUFFER_SIZE
];
107 char kernel_release
[BUFFER_SIZE
];
108 char kernel_version
[BUFFER_SIZE
];
109 char machine
[BUFFER_SIZE
];
110 char processor
[BUFFER_SIZE
];
111 char hardware_platform
[BUFFER_SIZE
];
112 char operating_system
[BUFFER_SIZE
];
114 int ltt_block_size
=0;
115 int ltt_major_version
=0;
116 int ltt_minor_version
=0;
118 guint ltt_trace_start_size
= 0;
119 char buf
[BUFFER_SIZE
];
124 char foo
[4*BUFFER_SIZE
];
125 char foo_eventdefs
[4*BUFFER_SIZE
];
126 char foo_control
[4*BUFFER_SIZE
];
127 char foo_cpu
[4*BUFFER_SIZE
];
128 char foo_info
[4*BUFFER_SIZE
];
130 char foo_control_facilities
[4*BUFFER_SIZE
];
131 char foo_control_processes
[4*BUFFER_SIZE
];
132 char foo_control_interrupts
[4*BUFFER_SIZE
];
133 char foo_info_system
[4*BUFFER_SIZE
];
135 struct stat lTDFStat
;
137 int block_number
, block_size
;
138 char * buffer
, *buf_out
, cpuStr
[4*BUFFER_SIZE
];
139 char * buf_fac
, * buf_intr
, * buf_proc
;
140 void * write_pos
, *write_pos_fac
, * write_pos_intr
, *write_pos_proc
;
141 trace_start_any
*tStart
;
142 trace_buffer_start
*tBufStart
;
143 trace_buffer_end
*tBufEnd
;
144 trace_file_system
* tFileSys
;
145 uint16_t newId
, startId
, tmpId
;
147 uint32_t time_delta
, startTimeDelta
;
148 void * cur_pos
, *end_pos
;
149 buffer_start start
, start_proc
, start_intr
;
150 buffer_end end
, end_proc
, end_intr
;
152 uint64_t adaptation_tsc
; // (Mathieu)
159 printf("Usage : ./convert processfile_name number_of_cpu tracefile1 tracefile2 ... trace_creation_directory\n");
160 printf("For more details, see README.\n");
165 printf("cpu number = %d\n", cpu
);
168 if(argc
!= nb_para
&& argc
!= nb_para
+1){
169 printf("need trace files and cpu number or root directory for the new tracefile\n");
175 strcpy(foo_eventdefs
, "foo/eventdefs");
176 strcpy(foo_control
, "foo/control");
177 strcpy(foo_cpu
, "foo/cpu");
178 strcpy(foo_info
, "foo/info");
180 strcpy(foo
, argv
[nb_para
]);
181 strcpy(foo_eventdefs
, argv
[nb_para
]);
182 strcat(foo_eventdefs
,"/eventdefs");
183 strcpy(foo_control
, argv
[nb_para
]);
184 strcat(foo_control
,"/control");
185 strcpy(foo_cpu
, argv
[nb_para
]);
186 strcat(foo_cpu
,"/cpu");
187 strcpy(foo_info
, argv
[nb_para
]);
188 strcat(foo_info
,"/info");
190 strcpy(foo_control_facilities
, foo_control
);
191 strcat(foo_control_facilities
,"/facilities");
192 strcpy(foo_control_processes
, foo_control
);
193 strcat(foo_control_processes
, "/processes");
194 strcpy(foo_control_interrupts
, foo_control
);
195 strcat(foo_control_interrupts
, "/interrupts");
196 strcpy(foo_info_system
, foo_info
);
197 strcat(foo_info_system
, "/system.xml");
200 getDataEndianType(arch_size
, endian
);
201 printf("Arch_size: %s, Endian: %s\n", arch_size
, endian
);
203 fp
= fopen("sysInfo.out","r");
205 g_error("Unable to open file sysInfo.out\n");
208 for(i
=0;i
<INFO_ENTRY
;i
++){
209 if(!fgets(buf
,BUFFER_SIZE
-1,fp
))
210 g_error("The format of sysInfo.out is not right\n");
211 if(strncmp(buf
,"node_name=",10)==0){
212 strcpy(node_name
,&buf
[10]);
213 node_name
[strlen(node_name
)-1] = '\0';
214 }else if(strncmp(buf
,"domainname=",11)==0){
215 strcpy(domainname
,&buf
[11]);
216 domainname
[strlen(domainname
)-1] = '\0';
217 }else if(strncmp(buf
,"kernel_name=",12)==0){
218 strcpy(kernel_name
,&buf
[12]);
219 kernel_name
[strlen(kernel_name
)-1] = '\0';
220 }else if(strncmp(buf
,"kernel_release=",15)==0){
221 strcpy(kernel_release
,&buf
[15]);
222 kernel_release
[strlen(kernel_release
)-1] = '\0';
223 }else if(strncmp(buf
,"kernel_version=",15)==0){
224 strcpy(kernel_version
,&buf
[15]);
225 kernel_version
[strlen(kernel_version
)-1] = '\0';
226 }else if(strncmp(buf
,"machine=",8)==0){
227 strcpy(machine
,&buf
[8]);
228 machine
[strlen(machine
)-1] = '\0';
229 }else if(strncmp(buf
,"processor=",10)==0){
230 strcpy(processor
,&buf
[10]);
231 processor
[strlen(processor
)-1] = '\0';
232 }else if(strncmp(buf
,"hardware_platform=",18)==0){
233 strcpy(hardware_platform
,&buf
[18]);
234 hardware_platform
[strlen(hardware_platform
)-1] = '\0';
235 }else if(strncmp(buf
,"operating_system=",17)==0){
236 strcpy(operating_system
,&buf
[17]);
237 operating_system
[strlen(operating_system
)-1] = '\0';
242 if(mkdir(foo
, S_IFDIR
| S_IRWXU
| S_IRGRP
| S_IROTH
))
243 g_error("can not make %s directory", foo
);
244 if(mkdir(foo_info
, S_IFDIR
| S_IRWXU
| S_IRGRP
| S_IROTH
))
245 g_error("can not make %s directory", foo_info
);
246 if(mkdir(foo_cpu
, S_IFDIR
| S_IRWXU
| S_IRGRP
| S_IROTH
))
247 g_error("can not make %s directory", foo_cpu
);
248 if(mkdir(foo_control
, S_IFDIR
| S_IRWXU
| S_IRGRP
| S_IROTH
))
249 g_error("can not make %s directory", foo_control
);
250 if(mkdir(foo_eventdefs
, S_IFDIR
| S_IRWXU
| S_IRGRP
| S_IROTH
))
251 g_error("can not make %s directory", foo_eventdefs
);
253 fp
= fopen(foo_info_system
,"w");
255 g_error("Unable to open file system.xml\n");
258 fdFac
= open(foo_control_facilities
,O_CREAT
| O_RDWR
| O_TRUNC
,S_IRUSR
|S_IWUSR
| S_IRGRP
| S_IROTH
);
260 g_error("Unable to open file facilities\n");
262 fdIntr
= open(foo_control_interrupts
,O_CREAT
| O_RDWR
| O_TRUNC
,S_IRUSR
|S_IWUSR
| S_IRGRP
| S_IROTH
);
264 g_error("Unable to open file interrupts\n");
266 fdProc
= open(foo_control_processes
,O_CREAT
| O_RDWR
| O_TRUNC
,S_IRUSR
|S_IWUSR
| S_IRGRP
| S_IROTH
);
268 g_error("Unable to open file process\n");
273 fd
= open(argv
[nb_para
-cpu
+k
], O_RDONLY
, 0);
275 g_error("Unable to open input data file %s\n", argv
[nb_para
-cpu
+k
]);
278 if(fstat(fd
, &lTDFStat
) < 0){
279 g_error("Unable to get the status of the input data file\n");
281 file_size
= lTDFStat
.st_size
;
283 buffer
= g_new(char, 4000);
284 readFile(fd
,(void*)buffer
, 3500, "Unable to read block header");
287 evId
= *(uint8_t *)cur_pos
;
288 cur_pos
+= sizeof(uint8_t);
290 time_delta
= *(uint32_t*)cur_pos
;
291 cur_pos
+= sizeof(uint32_t);
292 tBufStart
= (trace_buffer_start
*)cur_pos
;
293 cur_pos
+= sizeof(trace_buffer_start
);
294 cur_pos
+= sizeof(uint16_t); //Skip event size
296 evId
= *(uint8_t *)cur_pos
;
297 g_assert(evId
== TRACE_START
);
298 cur_pos
+= sizeof(uint8_t); //skip EvId
299 cur_pos
+= sizeof(uint32_t); //skip time delta
300 tStart
= (trace_start_any
*)cur_pos
;
301 if(tStart
->MagicNumber
!= TRACER_MAGIC_NUMBER
)
302 g_error("Trace magic number does not match : %x, should be %x",
303 tStart
->MagicNumber
, TRACER_MAGIC_NUMBER
);
304 if(tStart
->MajorVersion
!= TRACER_SUP_VERSION_MAJOR
)
305 g_error("Trace Major number does match : %hu, should be %u",
306 tStart
->MajorVersion
, TRACER_SUP_VERSION_MAJOR
);
309 startTimeDelta
= time_delta
;
310 start
.seconds
= tBufStart
->Time
.tv_sec
;
312 start
.nanoseconds
= tBufStart
->Time
.tv_usec
* 1000;
313 start
.cycle_count
= tBufStart
->TSC
;
314 start
.block_id
= tBufStart
->ID
;
315 end
.block_id
= start
.block_id
;
318 g_message("Trace version %hu.%hu detected\n",
319 tStart
->MajorVersion
,
320 tStart
->MinorVersion
);
321 if(tStart
->MinorVersion
== 2) {
322 trace_start_2_2
* tStart_2_2
= (trace_start_2_2
*)tStart
;
323 ltt_major_version
= tStart_2_2
->MajorVersion
;
324 ltt_minor_version
= tStart_2_2
->MinorVersion
;
325 ltt_block_size
= tStart_2_2
->BufferSize
;
326 ltt_log_cpu
= tStart_2_2
->LogCPUID
;
327 ltt_trace_start_size
= sizeof(trace_start_2_2
);
328 /* Verify if it's a broken 2.2 format */
329 if(*(uint8_t*)(cur_pos
+ sizeof(trace_start_2_2
)) == 0) {
330 /* Cannot have two trace start events. We cannot detect the problem
331 * if the flight recording flag is set to 1, as it conflicts
332 * with TRACE_SYSCALL_ENTRY.
334 g_warning("This is a 2.3 trace format that has a 2.2 tag. Please upgrade your kernel");
335 g_message("Processing the trace as a 2.3 format\n");
337 tStart
->MinorVersion
= 3;
341 if(tStart
->MinorVersion
== 3) {
342 trace_start_2_3
* tStart_2_3
= (trace_start_2_3
*)tStart
;
343 ltt_major_version
= tStart_2_3
->MajorVersion
;
344 ltt_minor_version
= tStart_2_3
->MinorVersion
;
345 ltt_block_size
= tStart_2_3
->BufferSize
;
346 ltt_log_cpu
= tStart_2_3
->LogCPUID
;
347 ltt_trace_start_size
= sizeof(trace_start_2_3
);
348 /* We do not use the flight recorder information for now, because we
349 * never use the .proc file anyway */
352 if(ltt_trace_start_size
== 0)
353 g_error("Minor version unknown : %hu. Supported minors : 2, 3",
354 tStart
->MinorVersion
);
356 block_size
= ltt_block_size
;//FIXME
357 block_number
= file_size
/ltt_block_size
;
360 buffer
= g_new(char, ltt_block_size
);
361 buf_fac
= g_new(char, block_size
);
362 write_pos_fac
= buf_fac
;
363 buf_intr
= g_new(char, block_size
);
364 write_pos_intr
= buf_intr
;
365 buf_proc
= g_new(char, block_size
);
366 write_pos_proc
= buf_proc
;
368 buf_out
= g_new(char, block_size
);
370 sprintf(cpuStr
,"%s/%d",foo_cpu
,k
);
371 fdCpu
= open(cpuStr
, O_CREAT
| O_RDWR
| O_TRUNC
,S_IRUSR
|S_IWUSR
| S_IRGRP
| S_IROTH
); //for cpu k
372 if(fdCpu
< 0) g_error("Unable to open cpu file %d\n", k
);
373 lseek(fd
,0,SEEK_SET
);
375 for(i
=0;i
<block_number
;i
++){
378 memset((void*)buf_out
, 0, block_size
);
380 memset((void*)buf_intr
, 0, block_size
);
381 memset((void*)buf_fac
, 0, block_size
);
382 memset((void*)buf_proc
, 0, block_size
);
383 write_pos_intr
= buf_intr
;
384 write_pos_fac
= buf_fac
;
385 write_pos_proc
= buf_proc
;
387 memset((void*)buffer
,0,ltt_block_size
);
388 readFile(fd
,(void*)buffer
, ltt_block_size
, "Unable to read block header");
391 evId
= *(uint8_t *)cur_pos
;
392 cur_pos
+= sizeof(uint8_t);
394 time_delta
= *(uint32_t*)cur_pos
;
395 cur_pos
+= sizeof(uint32_t);
396 tBufStart
= (trace_buffer_start
*)cur_pos
;
397 cur_pos
+= sizeof(trace_buffer_start
);
398 cur_pos
+= sizeof(uint16_t); //Skip event size
401 startTimeDelta
= time_delta
;
402 start
.seconds
= tBufStart
->Time
.tv_sec
;
403 /* usec -> nsec (Mathieu) */
404 start
.nanoseconds
= tBufStart
->Time
.tv_usec
* 1000;
405 start
.block_id
= tBufStart
->ID
;
406 end
.block_id
= start
.block_id
;
408 end_pos
= buffer
+ ltt_block_size
; //end of the buffer
409 size_lost
= *(uint32_t*)(end_pos
- sizeof(uint32_t));
411 end_pos
= buffer
+ ltt_block_size
- size_lost
; //buffer_end event
413 tBufEnd
= (trace_buffer_end
*)(end_pos
+ 2 * sizeof(uint8_t)+sizeof(uint32_t));
415 tBufEnd
= (trace_buffer_end
*)(end_pos
+sizeof(uint8_t)+sizeof(uint32_t));
417 end
.seconds
= tBufEnd
->Time
.tv_sec
;
418 /* usec -> nsec (Mathieu) */
419 end
.nanoseconds
= tBufEnd
->Time
.tv_usec
* 1000;
421 //end.cycle_count = tBufEnd->TSC;
423 //skip buffer start and trace start events
426 adaptation_tsc
= (uint64_t)tBufStart
->TSC
;
427 cur_pos
= buffer
+ sizeof(trace_buffer_start
)
428 + ltt_trace_start_size
430 + sizeof(uint16_t)+sizeof(uint32_t));
433 cur_pos
= buffer
+ sizeof(trace_buffer_start
)
435 + sizeof(uint16_t)+sizeof(uint32_t);
438 if(time_delta
< (0xFFFFFFFFULL
&adaptation_tsc
)) {
440 adaptation_tsc
= (adaptation_tsc
&0xFFFFFFFF00000000ULL
)
442 + (uint64_t)time_delta
;
445 adaptation_tsc
= (adaptation_tsc
&0xFFFFFFFF00000000ULL
) + time_delta
;
449 start
.cycle_count
= adaptation_tsc
;
451 //write start block event
452 write_to_buffer(write_pos
,(void*)&startId
, sizeof(uint16_t));
453 write_to_buffer(write_pos
,(void*)&startTimeDelta
, sizeof(uint32_t));
454 write_to_buffer(write_pos
,(void*)&start
, sizeof(buffer_start
));
456 //write start block event into processes and interrupts files
457 write_to_buffer(write_pos_intr
,(void*)&startId
, sizeof(uint16_t));
458 write_to_buffer(write_pos_intr
,(void*)&startTimeDelta
, sizeof(uint32_t));
460 start_intr
.nanoseconds
-= 20;
461 write_to_buffer(write_pos_intr
,(void*)&start_intr
, sizeof(buffer_start
));
463 write_to_buffer(write_pos_proc
,(void*)&startId
, sizeof(uint16_t));
464 write_to_buffer(write_pos_proc
,(void*)&startTimeDelta
, sizeof(uint32_t));
466 start_proc
.nanoseconds
-= 40;
467 write_to_buffer(write_pos_proc
,(void*)&start_proc
, sizeof(buffer_start
));
469 //parse *.proc file to get process and irq info
471 int lIntID
; /* Interrupt ID */
472 int lPID
, lPPID
; /* Process PID and Parent PID */
473 char lName
[256]; /* Process name */
478 fProc
= fopen(argv
[1],"r");
480 g_error("Unable to open file %s\n", argv
[1]);
483 while(fscanf(fProc
, "PID: %d; PPID: %d; NAME: %s\n", &lPID
, &lPPID
, lName
) > 0){
484 defaultId
= PROCESS_FORK_ID
;
485 process
.event_data1
= lPID
;
486 process
.event_data2
= lPPID
;
487 write_to_buffer(write_pos_proc
,(void*)&defaultId
, sizeof(uint16_t));
488 write_to_buffer(write_pos_proc
,(void*)&startTimeDelta
, sizeof(uint32_t));
489 write_to_buffer(write_pos_proc
,(void*)&process
, sizeof(new_process
));
492 while(fscanf(fProc
, "IRQ: %d; NAME: ", &lIntID
) > 0){
493 /* Read 'til the end of the line */
494 fgets(lName
, 200, fProc
);
496 defaultId
= TRACE_IRQ_ENTRY
;
499 write_to_buffer(write_pos_intr
,(void*)&defaultId
, sizeof(uint16_t));
500 write_to_buffer(write_pos_intr
,(void*)&startTimeDelta
, sizeof(uint32_t));
501 write_to_buffer(write_pos_intr
,(void*)&irq
, sizeof(trace_irq_entry
));
512 cpu_id
= *(uint8_t*)cur_pos
;
513 cur_pos
+= sizeof(uint8_t);
515 evId
= *(uint8_t *)cur_pos
;
517 if(evId
== TRACE_HEARTBEAT
) {
518 newId
= TRACE_HEARTBEAT_ID
;
520 cur_pos
+= sizeof(uint8_t);
521 time_delta
= *(uint32_t*)cur_pos
;
522 cur_pos
+= sizeof(uint32_t);
525 //write event_id and time_delta
526 write_to_buffer(write_pos
,(void*)&newId
,sizeof(uint16_t));
527 write_to_buffer(write_pos
,(void*)&time_delta
, sizeof(uint32_t));
530 if(time_delta
< (0xFFFFFFFFULL
&adaptation_tsc
)) {
532 adaptation_tsc
= (adaptation_tsc
&0xFFFFFFFF00000000ULL
) + 0x100000000ULL
533 + (uint64_t)time_delta
;
536 adaptation_tsc
= (adaptation_tsc
&0xFFFFFFFF00000000ULL
) + time_delta
;
540 if(evId
== TRACE_BUFFER_END
){
543 if(time_delta
< (0xFFFFFFFFULL
&adaptation_tsc
)) {
545 adaptation_tsc
= (adaptation_tsc
&0xFFFFFFFF00000000ULL
) + 0x100000000ULL
546 + (uint64_t)time_delta
;
549 adaptation_tsc
= (adaptation_tsc
&0xFFFFFFFF00000000ULL
) + time_delta
;
552 end
.cycle_count
= adaptation_tsc
;
553 int size
= (void*)buf_out
+ block_size
- write_pos
554 - sizeof(buffer_end
) - sizeof(uint32_t);
557 //int size = (void*)buf_out + block_size - write_pos
558 // + sizeof(uint16_t) + sizeof(uint32_t);
559 g_assert((void*)write_pos
< (void*)buf_out
+ block_size
);
560 write_to_buffer(write_pos
,(void*)&end
,sizeof(buffer_end
));
561 write_pos
= buf_out
+ block_size
- sizeof(uint32_t);
562 write_to_buffer(write_pos
,(void*)&size
, sizeof(uint32_t));
563 write(fdCpu
,(void*)buf_out
, block_size
);
565 //write out processes and intrrupts files
567 int size_intr
= block_size
+ (void*)buf_intr
- write_pos_intr
568 - sizeof(buffer_end
) - sizeof(uint32_t);
569 int size_proc
= block_size
+ (void*)buf_proc
- write_pos_proc
570 - sizeof(buffer_end
) - sizeof(uint32_t);
571 //int size_intr = block_size - (write_pos_intr - (void*)buf_intr);
572 //int size_proc = block_size - (write_pos_proc - (void*)buf_proc);
573 write_to_buffer(write_pos_intr
,(void*)&newId
,sizeof(uint16_t));
574 write_to_buffer(write_pos_intr
,(void*)&time_delta
, sizeof(uint32_t));
576 end_intr
.nanoseconds
-= 20;
577 write_to_buffer(write_pos_intr
,(void*)&end_intr
,sizeof(buffer_start
));
579 write_to_buffer(write_pos_proc
,(void*)&newId
,sizeof(uint16_t));
580 write_to_buffer(write_pos_proc
,(void*)&time_delta
, sizeof(uint32_t));
582 end_proc
.nanoseconds
-= 40;
583 write_to_buffer(write_pos_proc
,(void*)&end_proc
,sizeof(buffer_start
));
585 write_pos_intr
= buf_intr
+ block_size
- sizeof(uint32_t);
586 write_pos_proc
= buf_proc
+ block_size
- sizeof(uint32_t);
587 write_to_buffer(write_pos_intr
,(void*)&size_intr
, sizeof(uint32_t));
588 write_to_buffer(write_pos_proc
,(void*)&size_proc
, sizeof(uint32_t));
589 //for now don't output processes and interrupt information
590 // write(fdIntr,(void*)buf_intr,block_size);
591 // write(fdProc,(void*)buf_proc,block_size);
598 case TRACE_SYSCALL_ENTRY
:
599 event_size
= sizeof(trace_syscall_entry
);
601 case TRACE_SYSCALL_EXIT
:
604 case TRACE_TRAP_ENTRY
:
605 event_size
= sizeof(trace_trap_entry
);
607 case TRACE_TRAP_EXIT
:
610 case TRACE_IRQ_ENTRY
:
611 event_size
= sizeof(trace_irq_entry
);
612 timeDelta
= time_delta
;
613 write_to_buffer(write_pos_intr
,(void*)&newId
, sizeof(uint16_t));
614 write_to_buffer(write_pos_intr
,(void*)&timeDelta
, sizeof(uint32_t));
615 write_to_buffer(write_pos_intr
,cur_pos
, event_size
);
619 timeDelta
= time_delta
;
620 write_to_buffer(write_pos_intr
,(void*)&newId
, sizeof(uint16_t));
621 write_to_buffer(write_pos_intr
,(void*)&timeDelta
, sizeof(uint32_t));
623 case TRACE_SCHEDCHANGE
:
624 event_size
= sizeof(trace_schedchange
);
626 case TRACE_KERNEL_TIMER
:
630 event_size
= sizeof(trace_soft_irq
);
631 // timeDelta = time_delta;
632 // write_to_buffer(write_pos_intr,(void*)&newId, sizeof(uint16_t));
633 // write_to_buffer(write_pos_intr,(void*)&timeDelta, sizeof(uint32_t));
634 // write_to_buffer(write_pos_intr,cur_pos, event_size);
637 event_size
= sizeof(trace_process
);
638 timeDelta
= time_delta
;
639 subId
= *(uint8_t*)cur_pos
;
640 if(subId
== TRACE_PROCESS_FORK
|| subId
==TRACE_PROCESS_EXIT
){
641 if( subId
== TRACE_PROCESS_FORK
)tmpId
= PROCESS_FORK_ID
;
642 else tmpId
= PROCESS_EXIT_ID
;
643 write_to_buffer(write_pos_proc
,(void*)&tmpId
, sizeof(uint16_t));
644 write_to_buffer(write_pos_proc
,(void*)&timeDelta
, sizeof(uint32_t));
646 process
= *(new_process
*)(cur_pos
+ sizeof(uint8_t));
647 write_to_buffer(write_pos_proc
,(void*)&process
, sizeof(new_process
));
650 case TRACE_FILE_SYSTEM
:
651 event_size
= sizeof(trace_file_system
)- sizeof(char*);
654 event_size
= sizeof(trace_timer
);
657 event_size
= sizeof(trace_memory
);
660 event_size
= sizeof(trace_socket
);
663 event_size
= sizeof(trace_ipc
);
666 event_size
= sizeof(trace_network
);
668 case TRACE_HEARTBEAT
:
670 beat
.nanoseconds
= 0;
671 beat
.cycle_count
= adaptation_tsc
;
674 write_to_buffer(write_pos_intr
,(void*)&newId
, sizeof(uint16_t));
675 write_to_buffer(write_pos_intr
,(void*)&time_delta
, sizeof(uint32_t));
676 write_to_buffer(write_pos_intr
,(void*)&beat
, sizeof(heartbeat
));
677 write_to_buffer(write_pos_proc
,(void*)&newId
, sizeof(uint16_t));
678 write_to_buffer(write_pos_proc
,(void*)&time_delta
, sizeof(uint32_t));
679 write_to_buffer(write_pos_proc
,(void*)&beat
, sizeof(heartbeat
));
685 if(evId
!= TRACE_FILE_SYSTEM
&& event_size
>=0){
686 write_to_buffer(write_pos
, cur_pos
, event_size
);
688 if(evId
== TRACE_HEARTBEAT
){
689 write_to_buffer(write_pos
, (void*)&beat
, sizeof(heartbeat
));
692 cur_pos
+= event_size
+ sizeof(uint16_t); //skip data_size
693 }else if(evId
== TRACE_FILE_SYSTEM
){
696 tFileSys
= (trace_file_system
*)cur_pos
;
697 subId
= tFileSys
->event_sub_id
;
698 if(subId
== TRACE_FILE_SYSTEM_OPEN
|| subId
== TRACE_FILE_SYSTEM_EXEC
){
699 nbBytes
= tFileSys
->event_data2
+1;
702 write_to_buffer(write_pos
, cur_pos
, event_size
);
703 cur_pos
+= event_size
+ sizeof(char*);
705 write_to_buffer(write_pos
, cur_pos
, nbBytes
);
707 write_to_buffer(write_pos
, (void*)&c
, 1);
709 cur_pos
+= nbBytes
+ sizeof(uint16_t); //skip data_size
710 }else if(event_size
== -1){
711 printf("Unknown event: evId=%d, i=%d, event_count=%d\n", newId
, i
, event_count
);
730 //write to system.xml
731 fprintf(fp
,"<system \n");
732 fprintf(fp
,"node_name=\"%s\" \n", node_name
);
733 fprintf(fp
,"domainname=\"%s\" \n", domainname
);
734 fprintf(fp
,"cpu=\"%d\" \n", cpu
);
735 fprintf(fp
,"arch_size=\"%s\" \n", arch_size
);
736 fprintf(fp
,"endian=\"%s\" \n",endian
);
737 fprintf(fp
,"kernel_name=\"%s\" \n",kernel_name
);
738 fprintf(fp
,"kernel_release=\"%s\" \n",kernel_release
);
739 fprintf(fp
,"kernel_version=\"%s\" \n",kernel_version
);
740 fprintf(fp
,"machine=\"%s\" \n",machine
);
741 fprintf(fp
,"processor=\"%s\" \n",processor
);
742 fprintf(fp
,"hardware_platform=\"%s\" \n",hardware_platform
);
743 fprintf(fp
,"operating_system=\"%s\" \n",operating_system
);
744 fprintf(fp
,"ltt_major_version=\"%d\" \n",ltt_major_version
);
745 fprintf(fp
,"ltt_minor_version=\"%d\" \n",ltt_minor_version
);
746 fprintf(fp
,"ltt_block_size=\"%d\" \n",ltt_block_size
);
748 fprintf(fp
,"This is just a test\n");
749 fprintf(fp
,"</system>\n");
757 g_message("Conversion completed. Don't forget to copy core.xml to eventdefs directory\n");