26 #include <sys/types.h> 49 int ret = read(fd, buf, size);
55 int retw = write(STDOUT_FILENO, buf, ret);
57 if (retw <= 0 || retw != ret) {
76 pr_debug(
"reading input file (size expected=%d received=%d)",
93 r = size > BUFSIZ ? BUFSIZ :
size;
99 static unsigned int read4(
struct pevent *pevent)
105 return __data2host4(pevent, data);
108 static unsigned long long read8(
struct pevent *pevent)
110 unsigned long long data;
114 return __data2host8(pevent, data);
138 int retw = write(STDOUT_FILENO, &c, 1);
140 if (retw <= 0 || retw != r) {
141 pr_debug(
"repiping input file string");
165 size =
read4(pevent);
190 size =
read4(pevent);
213 unsigned long long size;
221 if (memcmp(buf,
"header_page", 12) != 0) {
222 pr_debug(
"did not read header page");
226 size =
read8(pevent);
228 header_page =
malloc(size);
229 if (header_page == NULL)
232 if (
do_read(header_page, size) < 0) {
233 pr_debug(
"did not read header page");
238 if (!pevent_parse_header_page(pevent, header_page, size,
239 pevent_get_long_size(pevent))) {
244 pevent_set_long_size(pevent, pevent->header_page_size_size);
251 if (memcmp(buf,
"header_event", 13) != 0) {
252 pr_debug(
"did not read header event");
256 size =
read8(pevent);
269 pr_debug(
"memory allocation failure\n");
275 pr_debug(
"error reading ftrace file.\n");
281 pr_debug(
"error parsing ftrace file.\n");
288 unsigned long long size)
295 pr_debug(
"memory allocation failure\n");
307 pr_debug(
"error parsing event file.\n");
315 unsigned long long size;
320 count =
read4(pevent);
322 for (i = 0; i < count; i++) {
323 size =
read8(pevent);
333 unsigned long long size;
340 systems =
read4(pevent);
342 for (i = 0; i < systems; i++) {
347 count =
read4(pevent);
349 for (x=0; x < count; x++) {
350 size =
read8(pevent);
361 unsigned long long size;
366 size =
read8(pevent);
372 pr_debug(
"memory allocation failure\n");
378 pr_debug(
"error reading saved cmdlines\n");
392 char test[] = { 23, 8, 68 };
394 int show_version = 0;
402 struct pevent *pevent = NULL;
410 if (memcmp(buf, test, 3) != 0) {
411 pr_debug(
"no trace data in the file");
417 if (memcmp(buf,
"tracing", 7) != 0) {
418 pr_debug(
"not a trace file (missing 'tracing' tag)");
426 printf(
"version = %s\n", version);
432 file_bigendian = buf[0];
436 pr_debug(
"trace_event__init failed");
442 pevent_set_flag(pevent, PEVENT_NSEC_OUTPUT);
443 pevent_set_file_bigendian(pevent, file_bigendian);
444 pevent_set_host_bigendian(pevent, host_bigendian);
448 file_long_size = buf[0];
450 file_page_size =
read4(pevent);
454 pevent_set_long_size(pevent, file_long_size);
455 pevent_set_page_size(pevent, file_page_size);
472 if (atof(version) >= 0.6) {
482 pevent_print_funcs(pevent);
483 }
else if (show_printk) {
484 pevent_print_printk(pevent);
int parse_event_file(struct pevent *pevent, char *buf, unsigned long size, char *sys)
static void skip(int size)
static int read_ftrace_file(struct pevent *pevent, unsigned long long size)
static struct version version
ssize_t trace_report(int fd, struct trace_event *tevent, bool __repipe)
void parse_ftrace_printk(struct pevent *pevent, char *file, unsigned int size __maybe_unused)
static struct trace_event tevent
static int read_ftrace_files(struct pevent *pevent)
static int read_ftrace_printk(struct pevent *pevent)
int trace_event__init(struct trace_event *t)
#define pr_debug(fmt,...)
static unsigned int read4(struct pevent *pevent)
void trace_event__cleanup(struct trace_event *t)
static int __do_read(int fd, void *buf, int size)
static int str(yyscan_t scanner, int token)
x86 movsq based memcpy() in arch/x86/lib/memcpy_64.S") MEMCPY_FN(memcpy_erms
int parse_ftrace_file(struct pevent *pevent, char *buf, unsigned long size)
static int do_read(void *data, int size)
static ssize_t trace_data_size
void parse_saved_cmdline(struct pevent *pevent, char *file, unsigned int size __maybe_unused)
static int read_event_files(struct pevent *pevent)
static char * read_string(void)
static int read_saved_cmdline(struct pevent *pevent)
static int read_event_file(struct pevent *pevent, char *sys, unsigned long long size)
static unsigned long long read8(struct pevent *pevent)
static int read_proc_kallsyms(struct pevent *pevent)
static int read_header_files(struct pevent *pevent)