5 #include <linux/errno.h>
9 #include "LinuxEvents.h"
11 #define TRACE_HEARTBEAT_ID 19
13 #define OVERFLOW_FIGURE 4294967296
15 #define write_to_buffer(DEST, SRC, SIZE) \
18 memcpy(DEST, SRC, SIZE);\
22 int readFile(int fd
, void * buf
, size_t size
, char * mesg
)
25 nbBytes
= read(fd
, buf
, size
);
33 void getDataEndianType(char * size
, char * endian
)
37 int sizeInt
=sizeof(int), sizeLong
=sizeof(long), sizePointer
=sizeof(void *);
39 if(c
== 1) strcpy(endian
,"LITTLE_ENDIAN");
40 else strcpy(endian
, "BIG_ENDIAN");
42 if(sizeInt
== 2 && sizeLong
== 4 && sizePointer
== 4)
44 else if(sizeInt
== 4 && sizeLong
== 4 && sizePointer
== 4)
46 else if(sizeInt
== 4 && sizeLong
== 8 && sizePointer
== 8)
48 else if(sizeInt
== 8 && sizeLong
== 8 && sizePointer
== 8)
50 else strcpy(size
,"UNKNOWN");
53 #define BUFFER_SIZE 80
55 typedef struct _buffer_start
{
60 } __attribute__ ((packed
)) buffer_start
;
62 typedef struct _heartbeat
{
66 } __attribute__ ((packed
)) heartbeat
;
69 int main(int argc
, char ** argv
){
73 int fdFac
, fdIntr
, fdProc
;
74 char arch_size
[BUFFER_SIZE
];
75 char endian
[BUFFER_SIZE
];
76 char node_name
[BUFFER_SIZE
];
77 char domainname
[BUFFER_SIZE
];
78 char kernel_name
[BUFFER_SIZE
];
79 char kernel_release
[BUFFER_SIZE
];
80 char kernel_version
[BUFFER_SIZE
];
81 char machine
[BUFFER_SIZE
];
82 char processor
[BUFFER_SIZE
];
83 char hardware_platform
[BUFFER_SIZE
];
84 char operating_system
[BUFFER_SIZE
];
87 int ltt_major_version
;
88 int ltt_minor_version
;
90 char buf
[BUFFER_SIZE
];
95 char foo
[4*BUFFER_SIZE
];
96 char foo_eventdefs
[4*BUFFER_SIZE
];
97 char foo_control
[4*BUFFER_SIZE
];
98 char foo_cpu
[4*BUFFER_SIZE
];
99 char foo_info
[4*BUFFER_SIZE
];
101 char foo_control_facilities
[4*BUFFER_SIZE
];
102 char foo_control_processes
[4*BUFFER_SIZE
];
103 char foo_control_interrupts
[4*BUFFER_SIZE
];
104 char foo_info_system
[4*BUFFER_SIZE
];
106 struct stat lTDFStat
;
108 int block_number
, block_size
;
109 char * buffer
, **buf_out
, cpuStr
[4*BUFFER_SIZE
];
110 char * buf_fac
, * buf_intr
, * buf_proc
;
111 void ** write_pos
, *write_pos_fac
, * write_pos_intr
, *write_pos_proc
;
113 trace_buffer_start
*tBufStart
;
114 trace_buffer_end
*tBufEnd
;
115 trace_file_system
* tFileSys
;
116 uint16_t newId
, startId
;
118 uint32_t time_delta
, startTimeDelta
;
119 void * cur_pos
, *end_pos
;
120 buffer_start start
, start_proc
, start_intr
;
121 buffer_start end
, end_proc
, end_intr
;
124 gboolean
* has_event
;
126 int reserve_size
= sizeof(buffer_start
) + sizeof(uint16_t) + 2*sizeof(uint32_t);//lost_size and buffer_end event
128 if(argc
!= 4 && argc
!= 5){
129 printf("need a trace file and cpu number or root directory for the new tracefile\n");
135 strcpy(foo_eventdefs
, "foo/eventdefs");
136 strcpy(foo_control
, "foo/control");
137 strcpy(foo_cpu
, "foo/cpu");
138 strcpy(foo_info
, "foo/info");
140 strcpy(foo
, argv
[4]);
141 strcpy(foo_eventdefs
, argv
[4]);
142 strcat(foo_eventdefs
,"/eventdefs");
143 strcpy(foo_control
, argv
[4]);
144 strcat(foo_control
,"/control");
145 strcpy(foo_cpu
, argv
[4]);
146 strcat(foo_cpu
,"/cpu");
147 strcpy(foo_info
, argv
[4]);
148 strcat(foo_info
,"/info");
150 strcpy(foo_control_facilities
, foo_control
);
151 strcat(foo_control_facilities
,"/facilities");
152 strcpy(foo_control_processes
, foo_control
);
153 strcat(foo_control_processes
, "/processes");
154 strcpy(foo_control_interrupts
, foo_control
);
155 strcat(foo_control_interrupts
, "/interrupts");
156 strcpy(foo_info_system
, foo_info
);
157 strcat(foo_info_system
, "/system.xml");
160 printf("cpu number = %d\n", cpu
);
163 getDataEndianType(arch_size
, endian
);
164 printf("Arch_size: %s, Endian: %s\n", arch_size
, endian
);
166 fp
= fopen("sysInfo.out","r");
168 g_error("Unable to open file sysInfo.out\n");
171 for(i
=0;i
<INFO_ENTRY
;i
++){
172 if(!fgets(buf
,BUFFER_SIZE
-1,fp
))
173 g_error("The format of sysInfo.out is not right\n");
174 if(strncmp(buf
,"node_name=",10)==0){
175 strcpy(node_name
,&buf
[10]);
176 node_name
[strlen(node_name
)-1] = '\0';
177 }else if(strncmp(buf
,"domainname=",11)==0){
178 strcpy(domainname
,&buf
[11]);
179 domainname
[strlen(domainname
)-1] = '\0';
180 }else if(strncmp(buf
,"kernel_name=",12)==0){
181 strcpy(kernel_name
,&buf
[12]);
182 kernel_name
[strlen(kernel_name
)-1] = '\0';
183 }else if(strncmp(buf
,"kernel_release=",15)==0){
184 strcpy(kernel_release
,&buf
[15]);
185 kernel_release
[strlen(kernel_release
)-1] = '\0';
186 }else if(strncmp(buf
,"kernel_version=",15)==0){
187 strcpy(kernel_version
,&buf
[15]);
188 kernel_version
[strlen(kernel_version
)-1] = '\0';
189 }else if(strncmp(buf
,"machine=",8)==0){
190 strcpy(machine
,&buf
[8]);
191 machine
[strlen(machine
)-1] = '\0';
192 }else if(strncmp(buf
,"processor=",10)==0){
193 strcpy(processor
,&buf
[10]);
194 processor
[strlen(processor
)-1] = '\0';
195 }else if(strncmp(buf
,"hardware_platform=",18)==0){
196 strcpy(hardware_platform
,&buf
[18]);
197 hardware_platform
[strlen(hardware_platform
)-1] = '\0';
198 }else if(strncmp(buf
,"operating_system=",17)==0){
199 strcpy(operating_system
,&buf
[17]);
200 operating_system
[strlen(operating_system
)-1] = '\0';
205 if(mkdir(foo
, S_IFDIR
| S_IRWXU
| S_IRGRP
| S_IROTH
))
206 g_error("can not make %s directory", foo
);
207 if(mkdir(foo_info
, S_IFDIR
| S_IRWXU
| S_IRGRP
| S_IROTH
))
208 g_error("can not make %s directory", foo_info
);
209 if(mkdir(foo_cpu
, S_IFDIR
| S_IRWXU
| S_IRGRP
| S_IROTH
))
210 g_error("can not make %s directory", foo_cpu
);
211 if(mkdir(foo_control
, S_IFDIR
| S_IRWXU
| S_IRGRP
| S_IROTH
))
212 g_error("can not make %s directory", foo_control
);
213 if(mkdir(foo_eventdefs
, S_IFDIR
| S_IRWXU
| S_IRGRP
| S_IROTH
))
214 g_error("can not make %s directory", foo_eventdefs
);
216 fp
= fopen(foo_info_system
,"w");
218 g_error("Unable to open file system.xml\n");
221 fd
= open(argv
[1], O_RDONLY
, 0);
223 g_error("Unable to open input data file %s\n", argv
[1]);
226 fdFac
= open(foo_control_facilities
,O_CREAT
| O_RDWR
| O_TRUNC
,S_IRUSR
|S_IWUSR
| S_IRGRP
| S_IROTH
);
228 g_error("Unable to open file facilities\n");
230 fdIntr
= open(foo_control_interrupts
,O_CREAT
| O_RDWR
| O_TRUNC
,S_IRUSR
|S_IWUSR
| S_IRGRP
| S_IROTH
);
232 g_error("Unable to open file interrupts\n");
234 fdProc
= open(foo_control_processes
,O_CREAT
| O_RDWR
| O_TRUNC
,S_IRUSR
|S_IWUSR
| S_IRGRP
| S_IROTH
);
236 g_error("Unable to open file process\n");
241 if(fstat(fd
, &lTDFStat
) < 0){
242 g_error("Unable to get the status of the input data file\n");
244 file_size
= lTDFStat
.st_size
;
246 buffer
= g_new(char, 4000);
247 readFile(fd
,(void*)buffer
, 3500, "Unable to read block header");
250 evId
= *(uint8_t *)cur_pos
;
251 cur_pos
+= sizeof(uint8_t);
253 time_delta
= *(uint32_t*)cur_pos
;
254 cur_pos
+= sizeof(uint32_t);
255 tBufStart
= (trace_buffer_start
*)cur_pos
;
256 cur_pos
+= sizeof(trace_buffer_start
);
257 cur_pos
+= sizeof(uint16_t); //Skip event size
259 evId
= *(uint8_t *)cur_pos
;
260 cur_pos
+= sizeof(uint8_t);
261 cur_pos
+= sizeof(uint32_t);
262 tStart
= (trace_start
*)cur_pos
;
265 startTimeDelta
= time_delta
;
266 start
.seconds
= tBufStart
->Time
.tv_sec
;
267 start
.nanoseconds
= tBufStart
->Time
.tv_usec
;
268 start
.cycle_count
= tBufStart
->TSC
;
269 start
.block_id
= tBufStart
->ID
;
270 end
.block_id
= start
.block_id
;
272 ltt_major_version
= tStart
->MajorVersion
;
273 ltt_minor_version
= tStart
->MinorVersion
;
274 ltt_block_size
= tStart
->BufferSize
;
275 ltt_log_cpu
= tStart
->LogCPUID
;
277 block_size
= ltt_block_size
;
278 block_number
= file_size
/block_size
;
281 buffer
= g_new(char, block_size
);
282 buf_fac
= g_new(char, block_size
);
283 write_pos_fac
= buf_fac
;
284 buf_intr
= g_new(char, block_size
);
285 write_pos_intr
= buf_intr
;
286 buf_proc
= g_new(char, block_size
);
287 write_pos_proc
= buf_proc
;
289 buf_out
= g_new(char*,cpu
);
290 write_pos
= g_new(void*, cpu
);
291 fdCpu
= g_new(int, cpu
);
292 has_event
= g_new(gboolean
, cpu
);
294 has_event
[i
] = FALSE
;
295 if(i
==0)has_event
[i
] = TRUE
;
296 buf_out
[i
] = g_new(char, block_size
);
297 write_pos
[i
] = NULL
;;
298 sprintf(cpuStr
,"%s/%d\0",foo_cpu
,i
);
299 fdCpu
[i
] = open(cpuStr
, O_CREAT
| O_RDWR
| O_TRUNC
,S_IRUSR
|S_IWUSR
| S_IRGRP
| S_IROTH
); //for cpu i
300 if(fdCpu
[i
] < 0) g_error("Unable to open cpu file %d\n", i
);
302 lseek(fd
,0,SEEK_SET
);
305 for(i
=0;i
<block_number
;i
++){
309 for(j
=1;j
<cpu
;j
++)has_event
[j
] = FALSE
;
311 memset((void*)buf_out
[j
], 0, block_size
);
312 write_pos
[j
] = buf_out
[j
];
314 memset((void*)buf_intr
, 0, block_size
);
315 memset((void*)buf_fac
, 0, block_size
);
316 memset((void*)buf_proc
, 0, block_size
);
317 write_pos_intr
= buf_intr
;
318 write_pos_fac
= buf_fac
;
319 write_pos_proc
= buf_proc
;
321 memset((void*)buffer
,0,block_size
);
322 readFile(fd
,(void*)buffer
, block_size
, "Unable to read block header");
325 evId
= *(uint8_t *)cur_pos
;
326 cur_pos
+= sizeof(uint8_t);
328 time_delta
= *(uint32_t*)cur_pos
;
329 cur_pos
+= sizeof(uint32_t);
330 tBufStart
= (trace_buffer_start
*)cur_pos
;
331 cur_pos
+= sizeof(trace_buffer_start
);
332 cur_pos
+= sizeof(uint16_t); //Skip event size
335 startTimeDelta
= time_delta
;
336 start
.seconds
= tBufStart
->Time
.tv_sec
;
337 start
.nanoseconds
= tBufStart
->Time
.tv_usec
;
338 start
.cycle_count
= tBufStart
->TSC
;
339 start
.block_id
= tBufStart
->ID
;
340 end
.block_id
= start
.block_id
;
342 end_pos
= buffer
+ block_size
; //end of the buffer
343 size_lost
= *(uint32_t*)(end_pos
- sizeof(uint32_t));
345 end_pos
= buffer
+ block_size
- size_lost
; //buffer_end event
347 tBufEnd
= (trace_buffer_end
*)(end_pos
+ 2 * sizeof(uint8_t)+sizeof(uint32_t));
349 tBufEnd
= (trace_buffer_end
*)(end_pos
+sizeof(uint8_t)+sizeof(uint32_t));
351 end
.seconds
= tBufEnd
->Time
.tv_sec
;
352 end
.nanoseconds
= tBufEnd
->Time
.tv_usec
;
353 end
.cycle_count
= tBufEnd
->TSC
;
355 //skip buffer start and trace start events
356 if(i
==0) //the first block
357 cur_pos
= buffer
+ sizeof(trace_buffer_start
) + sizeof(trace_start
) + 2*(sizeof(uint8_t)+sizeof(uint16_t)+sizeof(uint32_t));
359 cur_pos
= buffer
+ sizeof(trace_buffer_start
) + sizeof(uint8_t)+sizeof(uint16_t)+sizeof(uint32_t);
361 //for cpu 0, always make records
362 write_to_buffer(write_pos
[0],(void*)&startId
, sizeof(uint16_t));
363 write_to_buffer(write_pos
[0],(void*)&startTimeDelta
, sizeof(uint32_t));
364 write_to_buffer(write_pos
[0],(void*)&start
, sizeof(buffer_start
));
366 //write start block event into processes and interrupts files
367 write_to_buffer(write_pos_intr
,(void*)&startId
, sizeof(uint16_t));
368 write_to_buffer(write_pos_intr
,(void*)&startTimeDelta
, sizeof(uint32_t));
370 start_intr
.nanoseconds
-= 40;
371 write_to_buffer(write_pos_intr
,(void*)&start_intr
, sizeof(buffer_start
));
373 write_to_buffer(write_pos_proc
,(void*)&startId
, sizeof(uint16_t));
374 write_to_buffer(write_pos_proc
,(void*)&startTimeDelta
, sizeof(uint32_t));
376 start_proc
.nanoseconds
-= 20;
377 write_to_buffer(write_pos_proc
,(void*)&start_proc
, sizeof(buffer_start
));
379 //parse *.proc file to get process and irq info
381 int lIntID
; /* Interrupt ID */
382 int lPID
, lPPID
; /* Process PID and Parent PID */
383 char lName
[256]; /* Process name */
386 trace_process process
;
389 fProc
= fopen(argv
[2],"r");
391 g_error("Unable to open file %s\n", argv
[2]);
394 while(fscanf(fProc
, "PID: %d; PPID: %d; NAME: %s\n", &lPID
, &lPPID
, lName
) > 0){
395 defaultId
= TRACE_PROCESS
;
396 process
.event_sub_id
= TRACE_PROCESS_FORK
;
397 process
.event_data1
= lPID
;
398 process
.event_data2
= lPPID
;
399 write_to_buffer(write_pos_proc
,(void*)&defaultId
, sizeof(uint16_t));
400 write_to_buffer(write_pos_proc
,(void*)&startTimeDelta
, sizeof(uint32_t));
401 write_to_buffer(write_pos_proc
,(void*)&process
, sizeof(trace_process
));
404 while(fscanf(fProc
, "IRQ: %d; NAME: ", &lIntID
) > 0){
405 /* Read 'til the end of the line */
406 fgets(lName
, 200, fProc
);
408 defaultId
= TRACE_IRQ_ENTRY
;
411 write_to_buffer(write_pos_intr
,(void*)&defaultId
, sizeof(uint16_t));
412 write_to_buffer(write_pos_intr
,(void*)&startTimeDelta
, sizeof(uint32_t));
413 write_to_buffer(write_pos_intr
,(void*)&irq
, sizeof(trace_irq_entry
));
424 cpu_id
= *(uint8_t*)cur_pos
;
425 cur_pos
+= sizeof(uint8_t);
426 if(cpu_id
!= 0 && has_event
[cpu_id
] == FALSE
){
427 has_event
[cpu_id
] = TRUE
;
428 write_to_buffer(write_pos
[cpu_id
],(void*)&startId
,sizeof(uint16_t));
429 write_to_buffer(write_pos
[cpu_id
],(void*)&startTimeDelta
, sizeof(uint32_t));
430 write_to_buffer(write_pos
[cpu_id
],(void*)&start
, sizeof(buffer_start
));
433 evId
= *(uint8_t *)cur_pos
;
435 if(evId
== TRACE_HEARTBEAT
) {
436 newId
= TRACE_HEARTBEAT_ID
;
438 cur_pos
+= sizeof(uint8_t);
439 time_delta
= *(uint32_t*)cur_pos
;
440 cur_pos
+= sizeof(uint32_t);
443 write_to_buffer(write_pos
[cpu_id
],(void*)&newId
,sizeof(uint16_t));
444 write_to_buffer(write_pos
[cpu_id
],(void*)&time_delta
, sizeof(uint32_t));
446 write_to_buffer(write_pos
[0],(void*)&newId
,sizeof(uint16_t));
447 write_to_buffer(write_pos
[0],(void*)&time_delta
, sizeof(uint32_t));
450 if(evId
== TRACE_BUFFER_END
){
454 write_to_buffer(write_pos
[cpu_id
],(void*)&end
,sizeof(buffer_start
));
457 size
= block_size
+ ((void*)buf_out
[i
] - write_pos
[i
])+ sizeof(uint16_t) + sizeof(uint32_t);
458 write_pos
[i
] = buf_out
[i
] + block_size
- sizeof(uint32_t);
459 write_to_buffer(write_pos
[i
],(void*)&size
, sizeof(uint32_t));
460 write(fdCpu
[i
],(void*)buf_out
[i
], block_size
);
464 int size
= block_size
+ ((void*)buf_out
[0] - write_pos
[0])+ sizeof(uint16_t) + sizeof(uint32_t);
465 write_to_buffer(write_pos
[0],(void*)&end
,sizeof(buffer_start
));
466 write_pos
[0] = buf_out
[0] + block_size
- sizeof(uint32_t);
467 write_to_buffer(write_pos
[0],(void*)&size
, sizeof(uint32_t));
468 write(fdCpu
[0],(void*)buf_out
[0], block_size
);
471 //write out processes and intrrupts files
473 int size_intr
= block_size
- (write_pos_intr
- (void*)buf_intr
);
474 int size_proc
= block_size
- (write_pos_proc
- (void*)buf_proc
);
475 write_to_buffer(write_pos_intr
,(void*)&newId
,sizeof(uint16_t));
476 write_to_buffer(write_pos_intr
,(void*)&time_delta
, sizeof(uint32_t));
478 end_intr
.nanoseconds
+= 20;
479 write_to_buffer(write_pos_intr
,(void*)&end_intr
,sizeof(buffer_start
));
481 write_to_buffer(write_pos_proc
,(void*)&newId
,sizeof(uint16_t));
482 write_to_buffer(write_pos_proc
,(void*)&time_delta
, sizeof(uint32_t));
484 end_proc
.nanoseconds
+= 40;
485 write_to_buffer(write_pos_proc
,(void*)&end_proc
,sizeof(buffer_start
));
487 write_pos_intr
= buf_intr
+ block_size
- sizeof(uint32_t);
488 write_pos_proc
= buf_proc
+ block_size
- sizeof(uint32_t);
489 write_to_buffer(write_pos_intr
,(void*)&size_intr
, sizeof(uint32_t));
490 write_to_buffer(write_pos_proc
,(void*)&size_proc
, sizeof(uint32_t));
491 write(fdIntr
,(void*)buf_intr
,block_size
);
492 write(fdProc
,(void*)buf_proc
,block_size
);
499 case TRACE_SYSCALL_ENTRY
:
500 event_size
= sizeof(trace_syscall_entry
);
502 case TRACE_SYSCALL_EXIT
:
505 case TRACE_TRAP_ENTRY
:
506 event_size
= sizeof(trace_trap_entry
);
508 case TRACE_TRAP_EXIT
:
511 case TRACE_IRQ_ENTRY
:
512 event_size
= sizeof(trace_irq_entry
);
513 timeDelta
= time_delta
;
514 write_to_buffer(write_pos_intr
,(void*)&newId
, sizeof(uint16_t));
515 write_to_buffer(write_pos_intr
,(void*)&timeDelta
, sizeof(uint32_t));
516 write_to_buffer(write_pos_intr
,cur_pos
, event_size
);
520 timeDelta
= time_delta
;
521 write_to_buffer(write_pos_intr
,(void*)&newId
, sizeof(uint16_t));
522 write_to_buffer(write_pos_intr
,(void*)&timeDelta
, sizeof(uint32_t));
524 case TRACE_SCHEDCHANGE
:
525 event_size
= sizeof(trace_schedchange
);
527 case TRACE_KERNEL_TIMER
:
531 event_size
= sizeof(trace_soft_irq
);
532 // timeDelta = time_delta;
533 // write_to_buffer(write_pos_intr,(void*)&newId, sizeof(uint16_t));
534 // write_to_buffer(write_pos_intr,(void*)&timeDelta, sizeof(uint32_t));
535 // write_to_buffer(write_pos_intr,cur_pos, event_size);
538 event_size
= sizeof(trace_process
);
539 timeDelta
= time_delta
;
540 subId
= *(uint8_t*)cur_pos
;
541 if(subId
== TRACE_PROCESS_FORK
|| subId
==TRACE_PROCESS_EXIT
){
542 write_to_buffer(write_pos_proc
,(void*)&newId
, sizeof(uint16_t));
543 write_to_buffer(write_pos_proc
,(void*)&timeDelta
, sizeof(uint32_t));
544 write_to_buffer(write_pos_proc
,cur_pos
, event_size
);
547 case TRACE_FILE_SYSTEM
:
548 event_size
= sizeof(trace_file_system
)- sizeof(char*);
551 event_size
= sizeof(trace_timer
);
554 event_size
= sizeof(trace_memory
);
557 event_size
= sizeof(trace_socket
);
560 event_size
= sizeof(trace_ipc
);
563 event_size
= sizeof(trace_network
);
565 case TRACE_HEARTBEAT
:
568 beat
.nanoseconds
= 0;
569 beat
.cycle_count
= start
.cycle_count
+ beat_count
* OVERFLOW_FIGURE
;
572 end
.cycle_count
+= OVERFLOW_FIGURE
;
574 write_to_buffer(write_pos_intr
,(void*)&newId
, sizeof(uint16_t));
575 write_to_buffer(write_pos_intr
,(void*)&timeDelta
, sizeof(uint32_t));
576 write_to_buffer(write_pos_intr
,(void*)&beat
, sizeof(heartbeat
));
577 write_to_buffer(write_pos_proc
,(void*)&newId
, sizeof(uint16_t));
578 write_to_buffer(write_pos_proc
,(void*)&timeDelta
, sizeof(uint32_t));
579 write_to_buffer(write_pos_proc
,(void*)&beat
, sizeof(heartbeat
));
585 if(evId
!= TRACE_FILE_SYSTEM
&& event_size
>=0){
587 write_to_buffer(write_pos
[cpu_id
], cur_pos
, event_size
);
589 write_to_buffer(write_pos
[0], cur_pos
, event_size
);
592 if(evId
== TRACE_HEARTBEAT
){
594 write_to_buffer(write_pos
[cpu_id
],(void*)&beat
, sizeof(heartbeat
));
596 write_to_buffer(write_pos
[0], (void*)&beat
, sizeof(heartbeat
));
600 cur_pos
+= event_size
+ sizeof(uint16_t); //skip data_size
601 }else if(evId
== TRACE_FILE_SYSTEM
){
604 tFileSys
= (trace_file_system
*)cur_pos
;
605 subId
= tFileSys
->event_sub_id
;
606 if(subId
== TRACE_FILE_SYSTEM_OPEN
|| subId
== TRACE_FILE_SYSTEM_EXEC
){
607 nbBytes
= tFileSys
->event_data2
+1;
611 write_to_buffer(write_pos
[cpu_id
], cur_pos
, event_size
);
612 cur_pos
+= event_size
+ sizeof(char*);
614 write_to_buffer(write_pos
[cpu_id
], cur_pos
, nbBytes
);
616 write_to_buffer(write_pos
[cpu_id
], (void*)&c
, 1);
619 write_to_buffer(write_pos
[0], cur_pos
, event_size
);
620 cur_pos
+= event_size
+ sizeof(char*);
622 write_to_buffer(write_pos
[0], cur_pos
, nbBytes
);
624 write_to_buffer(write_pos
[0], (void*)&c
, 1);
627 cur_pos
+= nbBytes
+ sizeof(uint16_t); //skip data_size
628 }else if(event_size
== -1){
629 printf("Unknown event: evId=%d, i=%d, event_count=%d\n", newId
, i
, event_count
);
640 //write to system.xml
641 fprintf(fp
,"<system\n");
642 fprintf(fp
,"node_name=\"%s\"\n", node_name
);
643 fprintf(fp
,"domainname=\"%s\"\n", domainname
);
644 fprintf(fp
,"cpu=%d\n", cpu
);
645 fprintf(fp
,"arch_size=\"%s\"\n", arch_size
);
646 fprintf(fp
,"endian=\"%s\"\n",endian
);
647 fprintf(fp
,"kernel_name=\"%s\"\n",kernel_name
);
648 fprintf(fp
,"kernel_release=\"%s\"\n",kernel_release
);
649 fprintf(fp
,"kernel_version=\"%s\"\n",kernel_version
);
650 fprintf(fp
,"machine=\"%s\"\n",machine
);
651 fprintf(fp
,"processor=\"%s\"\n",processor
);
652 fprintf(fp
,"hardware_platform=\"%s\"\n",hardware_platform
);
653 fprintf(fp
,"operating_system=\"%s\"\n",operating_system
);
654 fprintf(fp
,"ltt_major_version=%d\n",ltt_major_version
);
655 fprintf(fp
,"ltt_minor_version=%d\n",ltt_minor_version
);
656 fprintf(fp
,"ltt_block_size=%d\n",ltt_block_size
);
658 fprintf(fp
,"This is just a test\n");
659 fprintf(fp
,"</system>\n");
668 for(i
=0;i
<cpu
;i
++) close(fdCpu
[i
]);
This page took 0.053414 seconds and 5 git commands to generate.