diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2011-03-09 06:13:19 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2011-03-10 09:16:28 -0500 |
commit | 1c0b04d10bbe35279c50e3b36cf5b8ec2a0050d8 (patch) | |
tree | 04f52089231f0f62464a0b148eb99da23a00c91d /tools/perf | |
parent | a91e5431d54f5359fccb5ec2512f252eb217707e (diff) |
perf header: Stop using 'self'
Stop using this python/OOP convention, doesn't really helps. Will do
more from time to time till we get it cleaned up in all of tools/perf.
Suggested-by: Thomas Gleixner <tglx@linutronix.de>
LKML-Reference: <new-submission>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Tom Zanussi <tzanussi@gmail.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
-rw-r--r-- | tools/perf/util/header.c | 199 | ||||
-rw-r--r-- | tools/perf/util/header.h | 12 |
2 files changed, 105 insertions, 106 deletions
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index 40b10e4d3927..5a72d421e211 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c | |||
@@ -66,19 +66,19 @@ struct perf_file_attr { | |||
66 | struct perf_file_section ids; | 66 | struct perf_file_section ids; |
67 | }; | 67 | }; |
68 | 68 | ||
69 | void perf_header__set_feat(struct perf_header *self, int feat) | 69 | void perf_header__set_feat(struct perf_header *header, int feat) |
70 | { | 70 | { |
71 | set_bit(feat, self->adds_features); | 71 | set_bit(feat, header->adds_features); |
72 | } | 72 | } |
73 | 73 | ||
74 | void perf_header__clear_feat(struct perf_header *self, int feat) | 74 | void perf_header__clear_feat(struct perf_header *header, int feat) |
75 | { | 75 | { |
76 | clear_bit(feat, self->adds_features); | 76 | clear_bit(feat, header->adds_features); |
77 | } | 77 | } |
78 | 78 | ||
79 | bool perf_header__has_feat(const struct perf_header *self, int feat) | 79 | bool perf_header__has_feat(const struct perf_header *header, int feat) |
80 | { | 80 | { |
81 | return test_bit(feat, self->adds_features); | 81 | return test_bit(feat, header->adds_features); |
82 | } | 82 | } |
83 | 83 | ||
84 | static int do_write(int fd, const void *buf, size_t size) | 84 | static int do_write(int fd, const void *buf, size_t size) |
@@ -147,22 +147,22 @@ static int __dsos__write_buildid_table(struct list_head *head, pid_t pid, | |||
147 | return 0; | 147 | return 0; |
148 | } | 148 | } |
149 | 149 | ||
150 | static int machine__write_buildid_table(struct machine *self, int fd) | 150 | static int machine__write_buildid_table(struct machine *machine, int fd) |
151 | { | 151 | { |
152 | int err; | 152 | int err; |
153 | u16 kmisc = PERF_RECORD_MISC_KERNEL, | 153 | u16 kmisc = PERF_RECORD_MISC_KERNEL, |
154 | umisc = PERF_RECORD_MISC_USER; | 154 | umisc = PERF_RECORD_MISC_USER; |
155 | 155 | ||
156 | if (!machine__is_host(self)) { | 156 | if (!machine__is_host(machine)) { |
157 | kmisc = PERF_RECORD_MISC_GUEST_KERNEL; | 157 | kmisc = PERF_RECORD_MISC_GUEST_KERNEL; |
158 | umisc = PERF_RECORD_MISC_GUEST_USER; | 158 | umisc = PERF_RECORD_MISC_GUEST_USER; |
159 | } | 159 | } |
160 | 160 | ||
161 | err = __dsos__write_buildid_table(&self->kernel_dsos, self->pid, | 161 | err = __dsos__write_buildid_table(&machine->kernel_dsos, machine->pid, |
162 | kmisc, fd); | 162 | kmisc, fd); |
163 | if (err == 0) | 163 | if (err == 0) |
164 | err = __dsos__write_buildid_table(&self->user_dsos, | 164 | err = __dsos__write_buildid_table(&machine->user_dsos, |
165 | self->pid, umisc, fd); | 165 | machine->pid, umisc, fd); |
166 | return err; | 166 | return err; |
167 | } | 167 | } |
168 | 168 | ||
@@ -280,12 +280,12 @@ out_free: | |||
280 | return err; | 280 | return err; |
281 | } | 281 | } |
282 | 282 | ||
283 | static int dso__cache_build_id(struct dso *self, const char *debugdir) | 283 | static int dso__cache_build_id(struct dso *dso, const char *debugdir) |
284 | { | 284 | { |
285 | bool is_kallsyms = self->kernel && self->long_name[0] != '/'; | 285 | bool is_kallsyms = dso->kernel && dso->long_name[0] != '/'; |
286 | 286 | ||
287 | return build_id_cache__add_b(self->build_id, sizeof(self->build_id), | 287 | return build_id_cache__add_b(dso->build_id, sizeof(dso->build_id), |
288 | self->long_name, debugdir, is_kallsyms); | 288 | dso->long_name, debugdir, is_kallsyms); |
289 | } | 289 | } |
290 | 290 | ||
291 | static int __dsos__cache_build_ids(struct list_head *head, const char *debugdir) | 291 | static int __dsos__cache_build_ids(struct list_head *head, const char *debugdir) |
@@ -300,14 +300,14 @@ static int __dsos__cache_build_ids(struct list_head *head, const char *debugdir) | |||
300 | return err; | 300 | return err; |
301 | } | 301 | } |
302 | 302 | ||
303 | static int machine__cache_build_ids(struct machine *self, const char *debugdir) | 303 | static int machine__cache_build_ids(struct machine *machine, const char *debugdir) |
304 | { | 304 | { |
305 | int ret = __dsos__cache_build_ids(&self->kernel_dsos, debugdir); | 305 | int ret = __dsos__cache_build_ids(&machine->kernel_dsos, debugdir); |
306 | ret |= __dsos__cache_build_ids(&self->user_dsos, debugdir); | 306 | ret |= __dsos__cache_build_ids(&machine->user_dsos, debugdir); |
307 | return ret; | 307 | return ret; |
308 | } | 308 | } |
309 | 309 | ||
310 | static int perf_session__cache_build_ids(struct perf_session *self) | 310 | static int perf_session__cache_build_ids(struct perf_session *session) |
311 | { | 311 | { |
312 | struct rb_node *nd; | 312 | struct rb_node *nd; |
313 | int ret; | 313 | int ret; |
@@ -318,28 +318,28 @@ static int perf_session__cache_build_ids(struct perf_session *self) | |||
318 | if (mkdir(debugdir, 0755) != 0 && errno != EEXIST) | 318 | if (mkdir(debugdir, 0755) != 0 && errno != EEXIST) |
319 | return -1; | 319 | return -1; |
320 | 320 | ||
321 | ret = machine__cache_build_ids(&self->host_machine, debugdir); | 321 | ret = machine__cache_build_ids(&session->host_machine, debugdir); |
322 | 322 | ||
323 | for (nd = rb_first(&self->machines); nd; nd = rb_next(nd)) { | 323 | for (nd = rb_first(&session->machines); nd; nd = rb_next(nd)) { |
324 | struct machine *pos = rb_entry(nd, struct machine, rb_node); | 324 | struct machine *pos = rb_entry(nd, struct machine, rb_node); |
325 | ret |= machine__cache_build_ids(pos, debugdir); | 325 | ret |= machine__cache_build_ids(pos, debugdir); |
326 | } | 326 | } |
327 | return ret ? -1 : 0; | 327 | return ret ? -1 : 0; |
328 | } | 328 | } |
329 | 329 | ||
330 | static bool machine__read_build_ids(struct machine *self, bool with_hits) | 330 | static bool machine__read_build_ids(struct machine *machine, bool with_hits) |
331 | { | 331 | { |
332 | bool ret = __dsos__read_build_ids(&self->kernel_dsos, with_hits); | 332 | bool ret = __dsos__read_build_ids(&machine->kernel_dsos, with_hits); |
333 | ret |= __dsos__read_build_ids(&self->user_dsos, with_hits); | 333 | ret |= __dsos__read_build_ids(&machine->user_dsos, with_hits); |
334 | return ret; | 334 | return ret; |
335 | } | 335 | } |
336 | 336 | ||
337 | static bool perf_session__read_build_ids(struct perf_session *self, bool with_hits) | 337 | static bool perf_session__read_build_ids(struct perf_session *session, bool with_hits) |
338 | { | 338 | { |
339 | struct rb_node *nd; | 339 | struct rb_node *nd; |
340 | bool ret = machine__read_build_ids(&self->host_machine, with_hits); | 340 | bool ret = machine__read_build_ids(&session->host_machine, with_hits); |
341 | 341 | ||
342 | for (nd = rb_first(&self->machines); nd; nd = rb_next(nd)) { | 342 | for (nd = rb_first(&session->machines); nd; nd = rb_next(nd)) { |
343 | struct machine *pos = rb_entry(nd, struct machine, rb_node); | 343 | struct machine *pos = rb_entry(nd, struct machine, rb_node); |
344 | ret |= machine__read_build_ids(pos, with_hits); | 344 | ret |= machine__read_build_ids(pos, with_hits); |
345 | } | 345 | } |
@@ -347,7 +347,7 @@ static bool perf_session__read_build_ids(struct perf_session *self, bool with_hi | |||
347 | return ret; | 347 | return ret; |
348 | } | 348 | } |
349 | 349 | ||
350 | static int perf_header__adds_write(struct perf_header *self, | 350 | static int perf_header__adds_write(struct perf_header *header, |
351 | struct perf_evlist *evlist, int fd) | 351 | struct perf_evlist *evlist, int fd) |
352 | { | 352 | { |
353 | int nr_sections; | 353 | int nr_sections; |
@@ -357,13 +357,13 @@ static int perf_header__adds_write(struct perf_header *self, | |||
357 | u64 sec_start; | 357 | u64 sec_start; |
358 | int idx = 0, err; | 358 | int idx = 0, err; |
359 | 359 | ||
360 | session = container_of(self, struct perf_session, header); | 360 | session = container_of(header, struct perf_session, header); |
361 | 361 | ||
362 | if (perf_header__has_feat(self, HEADER_BUILD_ID && | 362 | if (perf_header__has_feat(header, HEADER_BUILD_ID && |
363 | !perf_session__read_build_ids(session, true))) | 363 | !perf_session__read_build_ids(session, true))) |
364 | perf_header__clear_feat(self, HEADER_BUILD_ID); | 364 | perf_header__clear_feat(header, HEADER_BUILD_ID); |
365 | 365 | ||
366 | nr_sections = bitmap_weight(self->adds_features, HEADER_FEAT_BITS); | 366 | nr_sections = bitmap_weight(header->adds_features, HEADER_FEAT_BITS); |
367 | if (!nr_sections) | 367 | if (!nr_sections) |
368 | return 0; | 368 | return 0; |
369 | 369 | ||
@@ -373,10 +373,10 @@ static int perf_header__adds_write(struct perf_header *self, | |||
373 | 373 | ||
374 | sec_size = sizeof(*feat_sec) * nr_sections; | 374 | sec_size = sizeof(*feat_sec) * nr_sections; |
375 | 375 | ||
376 | sec_start = self->data_offset + self->data_size; | 376 | sec_start = header->data_offset + header->data_size; |
377 | lseek(fd, sec_start + sec_size, SEEK_SET); | 377 | lseek(fd, sec_start + sec_size, SEEK_SET); |
378 | 378 | ||
379 | if (perf_header__has_feat(self, HEADER_TRACE_INFO)) { | 379 | if (perf_header__has_feat(header, HEADER_TRACE_INFO)) { |
380 | struct perf_file_section *trace_sec; | 380 | struct perf_file_section *trace_sec; |
381 | 381 | ||
382 | trace_sec = &feat_sec[idx++]; | 382 | trace_sec = &feat_sec[idx++]; |
@@ -387,14 +387,14 @@ static int perf_header__adds_write(struct perf_header *self, | |||
387 | trace_sec->size = lseek(fd, 0, SEEK_CUR) - trace_sec->offset; | 387 | trace_sec->size = lseek(fd, 0, SEEK_CUR) - trace_sec->offset; |
388 | } | 388 | } |
389 | 389 | ||
390 | if (perf_header__has_feat(self, HEADER_BUILD_ID)) { | 390 | if (perf_header__has_feat(header, HEADER_BUILD_ID)) { |
391 | struct perf_file_section *buildid_sec; | 391 | struct perf_file_section *buildid_sec; |
392 | 392 | ||
393 | buildid_sec = &feat_sec[idx++]; | 393 | buildid_sec = &feat_sec[idx++]; |
394 | 394 | ||
395 | /* Write build-ids */ | 395 | /* Write build-ids */ |
396 | buildid_sec->offset = lseek(fd, 0, SEEK_CUR); | 396 | buildid_sec->offset = lseek(fd, 0, SEEK_CUR); |
397 | err = dsos__write_buildid_table(self, fd); | 397 | err = dsos__write_buildid_table(header, fd); |
398 | if (err < 0) { | 398 | if (err < 0) { |
399 | pr_debug("failed to write buildid table\n"); | 399 | pr_debug("failed to write buildid table\n"); |
400 | goto out_free; | 400 | goto out_free; |
@@ -439,7 +439,7 @@ int perf_session__write_header(struct perf_session *session, | |||
439 | { | 439 | { |
440 | struct perf_file_header f_header; | 440 | struct perf_file_header f_header; |
441 | struct perf_file_attr f_attr; | 441 | struct perf_file_attr f_attr; |
442 | struct perf_header *self = &session->header; | 442 | struct perf_header *header = &session->header; |
443 | struct perf_evsel *attr, *pair = NULL; | 443 | struct perf_evsel *attr, *pair = NULL; |
444 | int err; | 444 | int err; |
445 | 445 | ||
@@ -465,7 +465,7 @@ out_err_write: | |||
465 | } | 465 | } |
466 | } | 466 | } |
467 | 467 | ||
468 | self->attr_offset = lseek(fd, 0, SEEK_CUR); | 468 | header->attr_offset = lseek(fd, 0, SEEK_CUR); |
469 | 469 | ||
470 | list_for_each_entry(attr, &evlist->entries, node) { | 470 | list_for_each_entry(attr, &evlist->entries, node) { |
471 | f_attr = (struct perf_file_attr){ | 471 | f_attr = (struct perf_file_attr){ |
@@ -482,20 +482,20 @@ out_err_write: | |||
482 | } | 482 | } |
483 | } | 483 | } |
484 | 484 | ||
485 | self->event_offset = lseek(fd, 0, SEEK_CUR); | 485 | header->event_offset = lseek(fd, 0, SEEK_CUR); |
486 | self->event_size = event_count * sizeof(struct perf_trace_event_type); | 486 | header->event_size = event_count * sizeof(struct perf_trace_event_type); |
487 | if (events) { | 487 | if (events) { |
488 | err = do_write(fd, events, self->event_size); | 488 | err = do_write(fd, events, header->event_size); |
489 | if (err < 0) { | 489 | if (err < 0) { |
490 | pr_debug("failed to write perf header events\n"); | 490 | pr_debug("failed to write perf header events\n"); |
491 | return err; | 491 | return err; |
492 | } | 492 | } |
493 | } | 493 | } |
494 | 494 | ||
495 | self->data_offset = lseek(fd, 0, SEEK_CUR); | 495 | header->data_offset = lseek(fd, 0, SEEK_CUR); |
496 | 496 | ||
497 | if (at_exit) { | 497 | if (at_exit) { |
498 | err = perf_header__adds_write(self, evlist, fd); | 498 | err = perf_header__adds_write(header, evlist, fd); |
499 | if (err < 0) | 499 | if (err < 0) |
500 | return err; | 500 | return err; |
501 | } | 501 | } |
@@ -505,20 +505,20 @@ out_err_write: | |||
505 | .size = sizeof(f_header), | 505 | .size = sizeof(f_header), |
506 | .attr_size = sizeof(f_attr), | 506 | .attr_size = sizeof(f_attr), |
507 | .attrs = { | 507 | .attrs = { |
508 | .offset = self->attr_offset, | 508 | .offset = header->attr_offset, |
509 | .size = evlist->nr_entries * sizeof(f_attr), | 509 | .size = evlist->nr_entries * sizeof(f_attr), |
510 | }, | 510 | }, |
511 | .data = { | 511 | .data = { |
512 | .offset = self->data_offset, | 512 | .offset = header->data_offset, |
513 | .size = self->data_size, | 513 | .size = header->data_size, |
514 | }, | 514 | }, |
515 | .event_types = { | 515 | .event_types = { |
516 | .offset = self->event_offset, | 516 | .offset = header->event_offset, |
517 | .size = self->event_size, | 517 | .size = header->event_size, |
518 | }, | 518 | }, |
519 | }; | 519 | }; |
520 | 520 | ||
521 | memcpy(&f_header.adds_features, &self->adds_features, sizeof(self->adds_features)); | 521 | memcpy(&f_header.adds_features, &header->adds_features, sizeof(header->adds_features)); |
522 | 522 | ||
523 | lseek(fd, 0, SEEK_SET); | 523 | lseek(fd, 0, SEEK_SET); |
524 | err = do_write(fd, &f_header, sizeof(f_header)); | 524 | err = do_write(fd, &f_header, sizeof(f_header)); |
@@ -526,26 +526,26 @@ out_err_write: | |||
526 | pr_debug("failed to write perf header\n"); | 526 | pr_debug("failed to write perf header\n"); |
527 | return err; | 527 | return err; |
528 | } | 528 | } |
529 | lseek(fd, self->data_offset + self->data_size, SEEK_SET); | 529 | lseek(fd, header->data_offset + header->data_size, SEEK_SET); |
530 | 530 | ||
531 | self->frozen = 1; | 531 | header->frozen = 1; |
532 | return 0; | 532 | return 0; |
533 | } | 533 | } |
534 | 534 | ||
535 | static int perf_header__getbuffer64(struct perf_header *self, | 535 | static int perf_header__getbuffer64(struct perf_header *header, |
536 | int fd, void *buf, size_t size) | 536 | int fd, void *buf, size_t size) |
537 | { | 537 | { |
538 | if (readn(fd, buf, size) <= 0) | 538 | if (readn(fd, buf, size) <= 0) |
539 | return -1; | 539 | return -1; |
540 | 540 | ||
541 | if (self->needs_swap) | 541 | if (header->needs_swap) |
542 | mem_bswap_64(buf, size); | 542 | mem_bswap_64(buf, size); |
543 | 543 | ||
544 | return 0; | 544 | return 0; |
545 | } | 545 | } |
546 | 546 | ||
547 | int perf_header__process_sections(struct perf_header *self, int fd, | 547 | int perf_header__process_sections(struct perf_header *header, int fd, |
548 | int (*process)(struct perf_file_section *self, | 548 | int (*process)(struct perf_file_section *section, |
549 | struct perf_header *ph, | 549 | struct perf_header *ph, |
550 | int feat, int fd)) | 550 | int feat, int fd)) |
551 | { | 551 | { |
@@ -555,7 +555,7 @@ int perf_header__process_sections(struct perf_header *self, int fd, | |||
555 | int idx = 0; | 555 | int idx = 0; |
556 | int err = -1, feat = 1; | 556 | int err = -1, feat = 1; |
557 | 557 | ||
558 | nr_sections = bitmap_weight(self->adds_features, HEADER_FEAT_BITS); | 558 | nr_sections = bitmap_weight(header->adds_features, HEADER_FEAT_BITS); |
559 | if (!nr_sections) | 559 | if (!nr_sections) |
560 | return 0; | 560 | return 0; |
561 | 561 | ||
@@ -565,17 +565,17 @@ int perf_header__process_sections(struct perf_header *self, int fd, | |||
565 | 565 | ||
566 | sec_size = sizeof(*feat_sec) * nr_sections; | 566 | sec_size = sizeof(*feat_sec) * nr_sections; |
567 | 567 | ||
568 | lseek(fd, self->data_offset + self->data_size, SEEK_SET); | 568 | lseek(fd, header->data_offset + header->data_size, SEEK_SET); |
569 | 569 | ||
570 | if (perf_header__getbuffer64(self, fd, feat_sec, sec_size)) | 570 | if (perf_header__getbuffer64(header, fd, feat_sec, sec_size)) |
571 | goto out_free; | 571 | goto out_free; |
572 | 572 | ||
573 | err = 0; | 573 | err = 0; |
574 | while (idx < nr_sections && feat < HEADER_LAST_FEATURE) { | 574 | while (idx < nr_sections && feat < HEADER_LAST_FEATURE) { |
575 | if (perf_header__has_feat(self, feat)) { | 575 | if (perf_header__has_feat(header, feat)) { |
576 | struct perf_file_section *sec = &feat_sec[idx++]; | 576 | struct perf_file_section *sec = &feat_sec[idx++]; |
577 | 577 | ||
578 | err = process(sec, self, feat, fd); | 578 | err = process(sec, header, feat, fd); |
579 | if (err < 0) | 579 | if (err < 0) |
580 | break; | 580 | break; |
581 | } | 581 | } |
@@ -586,35 +586,35 @@ out_free: | |||
586 | return err; | 586 | return err; |
587 | } | 587 | } |
588 | 588 | ||
589 | int perf_file_header__read(struct perf_file_header *self, | 589 | int perf_file_header__read(struct perf_file_header *header, |
590 | struct perf_header *ph, int fd) | 590 | struct perf_header *ph, int fd) |
591 | { | 591 | { |
592 | lseek(fd, 0, SEEK_SET); | 592 | lseek(fd, 0, SEEK_SET); |
593 | 593 | ||
594 | if (readn(fd, self, sizeof(*self)) <= 0 || | 594 | if (readn(fd, header, sizeof(*header)) <= 0 || |
595 | memcmp(&self->magic, __perf_magic, sizeof(self->magic))) | 595 | memcmp(&header->magic, __perf_magic, sizeof(header->magic))) |
596 | return -1; | 596 | return -1; |
597 | 597 | ||
598 | if (self->attr_size != sizeof(struct perf_file_attr)) { | 598 | if (header->attr_size != sizeof(struct perf_file_attr)) { |
599 | u64 attr_size = bswap_64(self->attr_size); | 599 | u64 attr_size = bswap_64(header->attr_size); |
600 | 600 | ||
601 | if (attr_size != sizeof(struct perf_file_attr)) | 601 | if (attr_size != sizeof(struct perf_file_attr)) |
602 | return -1; | 602 | return -1; |
603 | 603 | ||
604 | mem_bswap_64(self, offsetof(struct perf_file_header, | 604 | mem_bswap_64(header, offsetof(struct perf_file_header, |
605 | adds_features)); | 605 | adds_features)); |
606 | ph->needs_swap = true; | 606 | ph->needs_swap = true; |
607 | } | 607 | } |
608 | 608 | ||
609 | if (self->size != sizeof(*self)) { | 609 | if (header->size != sizeof(*header)) { |
610 | /* Support the previous format */ | 610 | /* Support the previous format */ |
611 | if (self->size == offsetof(typeof(*self), adds_features)) | 611 | if (header->size == offsetof(typeof(*header), adds_features)) |
612 | bitmap_zero(self->adds_features, HEADER_FEAT_BITS); | 612 | bitmap_zero(header->adds_features, HEADER_FEAT_BITS); |
613 | else | 613 | else |
614 | return -1; | 614 | return -1; |
615 | } | 615 | } |
616 | 616 | ||
617 | memcpy(&ph->adds_features, &self->adds_features, | 617 | memcpy(&ph->adds_features, &header->adds_features, |
618 | sizeof(ph->adds_features)); | 618 | sizeof(ph->adds_features)); |
619 | /* | 619 | /* |
620 | * FIXME: hack that assumes that if we need swap the perf.data file | 620 | * FIXME: hack that assumes that if we need swap the perf.data file |
@@ -628,10 +628,10 @@ int perf_file_header__read(struct perf_file_header *self, | |||
628 | perf_header__set_feat(ph, HEADER_BUILD_ID); | 628 | perf_header__set_feat(ph, HEADER_BUILD_ID); |
629 | } | 629 | } |
630 | 630 | ||
631 | ph->event_offset = self->event_types.offset; | 631 | ph->event_offset = header->event_types.offset; |
632 | ph->event_size = self->event_types.size; | 632 | ph->event_size = header->event_types.size; |
633 | ph->data_offset = self->data.offset; | 633 | ph->data_offset = header->data.offset; |
634 | ph->data_size = self->data.size; | 634 | ph->data_size = header->data.size; |
635 | return 0; | 635 | return 0; |
636 | } | 636 | } |
637 | 637 | ||
@@ -690,11 +690,10 @@ out: | |||
690 | return err; | 690 | return err; |
691 | } | 691 | } |
692 | 692 | ||
693 | static int perf_header__read_build_ids(struct perf_header *self, | 693 | static int perf_header__read_build_ids(struct perf_header *header, |
694 | int input, u64 offset, u64 size) | 694 | int input, u64 offset, u64 size) |
695 | { | 695 | { |
696 | struct perf_session *session = container_of(self, | 696 | struct perf_session *session = container_of(header, struct perf_session, header); |
697 | struct perf_session, header); | ||
698 | struct build_id_event bev; | 697 | struct build_id_event bev; |
699 | char filename[PATH_MAX]; | 698 | char filename[PATH_MAX]; |
700 | u64 limit = offset + size; | 699 | u64 limit = offset + size; |
@@ -706,7 +705,7 @@ static int perf_header__read_build_ids(struct perf_header *self, | |||
706 | if (read(input, &bev, sizeof(bev)) != sizeof(bev)) | 705 | if (read(input, &bev, sizeof(bev)) != sizeof(bev)) |
707 | goto out; | 706 | goto out; |
708 | 707 | ||
709 | if (self->needs_swap) | 708 | if (header->needs_swap) |
710 | perf_event_header__bswap(&bev.header); | 709 | perf_event_header__bswap(&bev.header); |
711 | 710 | ||
712 | len = bev.header.size - sizeof(bev); | 711 | len = bev.header.size - sizeof(bev); |
@@ -722,13 +721,13 @@ out: | |||
722 | return err; | 721 | return err; |
723 | } | 722 | } |
724 | 723 | ||
725 | static int perf_file_section__process(struct perf_file_section *self, | 724 | static int perf_file_section__process(struct perf_file_section *section, |
726 | struct perf_header *ph, | 725 | struct perf_header *ph, |
727 | int feat, int fd) | 726 | int feat, int fd) |
728 | { | 727 | { |
729 | if (lseek(fd, self->offset, SEEK_SET) == (off_t)-1) { | 728 | if (lseek(fd, section->offset, SEEK_SET) == (off_t)-1) { |
730 | pr_debug("Failed to lseek to %" PRIu64 " offset for feature " | 729 | pr_debug("Failed to lseek to %" PRIu64 " offset for feature " |
731 | "%d, continuing...\n", self->offset, feat); | 730 | "%d, continuing...\n", section->offset, feat); |
732 | return 0; | 731 | return 0; |
733 | } | 732 | } |
734 | 733 | ||
@@ -738,7 +737,7 @@ static int perf_file_section__process(struct perf_file_section *self, | |||
738 | break; | 737 | break; |
739 | 738 | ||
740 | case HEADER_BUILD_ID: | 739 | case HEADER_BUILD_ID: |
741 | if (perf_header__read_build_ids(ph, fd, self->offset, self->size)) | 740 | if (perf_header__read_build_ids(ph, fd, section->offset, section->size)) |
742 | pr_debug("Failed to read buildids, continuing...\n"); | 741 | pr_debug("Failed to read buildids, continuing...\n"); |
743 | break; | 742 | break; |
744 | default: | 743 | default: |
@@ -748,21 +747,21 @@ static int perf_file_section__process(struct perf_file_section *self, | |||
748 | return 0; | 747 | return 0; |
749 | } | 748 | } |
750 | 749 | ||
751 | static int perf_file_header__read_pipe(struct perf_pipe_file_header *self, | 750 | static int perf_file_header__read_pipe(struct perf_pipe_file_header *header, |
752 | struct perf_header *ph, int fd, | 751 | struct perf_header *ph, int fd, |
753 | bool repipe) | 752 | bool repipe) |
754 | { | 753 | { |
755 | if (readn(fd, self, sizeof(*self)) <= 0 || | 754 | if (readn(fd, header, sizeof(*header)) <= 0 || |
756 | memcmp(&self->magic, __perf_magic, sizeof(self->magic))) | 755 | memcmp(&header->magic, __perf_magic, sizeof(header->magic))) |
757 | return -1; | 756 | return -1; |
758 | 757 | ||
759 | if (repipe && do_write(STDOUT_FILENO, self, sizeof(*self)) < 0) | 758 | if (repipe && do_write(STDOUT_FILENO, header, sizeof(*header)) < 0) |
760 | return -1; | 759 | return -1; |
761 | 760 | ||
762 | if (self->size != sizeof(*self)) { | 761 | if (header->size != sizeof(*header)) { |
763 | u64 size = bswap_64(self->size); | 762 | u64 size = bswap_64(header->size); |
764 | 763 | ||
765 | if (size != sizeof(*self)) | 764 | if (size != sizeof(*header)) |
766 | return -1; | 765 | return -1; |
767 | 766 | ||
768 | ph->needs_swap = true; | 767 | ph->needs_swap = true; |
@@ -773,10 +772,10 @@ static int perf_file_header__read_pipe(struct perf_pipe_file_header *self, | |||
773 | 772 | ||
774 | static int perf_header__read_pipe(struct perf_session *session, int fd) | 773 | static int perf_header__read_pipe(struct perf_session *session, int fd) |
775 | { | 774 | { |
776 | struct perf_header *self = &session->header; | 775 | struct perf_header *header = &session->header; |
777 | struct perf_pipe_file_header f_header; | 776 | struct perf_pipe_file_header f_header; |
778 | 777 | ||
779 | if (perf_file_header__read_pipe(&f_header, self, fd, | 778 | if (perf_file_header__read_pipe(&f_header, header, fd, |
780 | session->repipe) < 0) { | 779 | session->repipe) < 0) { |
781 | pr_debug("incompatible file format\n"); | 780 | pr_debug("incompatible file format\n"); |
782 | return -EINVAL; | 781 | return -EINVAL; |
@@ -789,7 +788,7 @@ static int perf_header__read_pipe(struct perf_session *session, int fd) | |||
789 | 788 | ||
790 | int perf_session__read_header(struct perf_session *session, int fd) | 789 | int perf_session__read_header(struct perf_session *session, int fd) |
791 | { | 790 | { |
792 | struct perf_header *self = &session->header; | 791 | struct perf_header *header = &session->header; |
793 | struct perf_file_header f_header; | 792 | struct perf_file_header f_header; |
794 | struct perf_file_attr f_attr; | 793 | struct perf_file_attr f_attr; |
795 | u64 f_id; | 794 | u64 f_id; |
@@ -802,7 +801,7 @@ int perf_session__read_header(struct perf_session *session, int fd) | |||
802 | if (session->fd_pipe) | 801 | if (session->fd_pipe) |
803 | return perf_header__read_pipe(session, fd); | 802 | return perf_header__read_pipe(session, fd); |
804 | 803 | ||
805 | if (perf_file_header__read(&f_header, self, fd) < 0) { | 804 | if (perf_file_header__read(&f_header, header, fd) < 0) { |
806 | pr_debug("incompatible file format\n"); | 805 | pr_debug("incompatible file format\n"); |
807 | return -EINVAL; | 806 | return -EINVAL; |
808 | } | 807 | } |
@@ -814,7 +813,7 @@ int perf_session__read_header(struct perf_session *session, int fd) | |||
814 | struct perf_evsel *evsel; | 813 | struct perf_evsel *evsel; |
815 | off_t tmp; | 814 | off_t tmp; |
816 | 815 | ||
817 | if (perf_header__getbuffer64(self, fd, &f_attr, sizeof(f_attr))) | 816 | if (perf_header__getbuffer64(header, fd, &f_attr, sizeof(f_attr))) |
818 | goto out_errno; | 817 | goto out_errno; |
819 | 818 | ||
820 | tmp = lseek(fd, 0, SEEK_CUR); | 819 | tmp = lseek(fd, 0, SEEK_CUR); |
@@ -840,7 +839,7 @@ int perf_session__read_header(struct perf_session *session, int fd) | |||
840 | lseek(fd, f_attr.ids.offset, SEEK_SET); | 839 | lseek(fd, f_attr.ids.offset, SEEK_SET); |
841 | 840 | ||
842 | for (j = 0; j < nr_ids; j++) { | 841 | for (j = 0; j < nr_ids; j++) { |
843 | if (perf_header__getbuffer64(self, fd, &f_id, sizeof(f_id))) | 842 | if (perf_header__getbuffer64(header, fd, &f_id, sizeof(f_id))) |
844 | goto out_errno; | 843 | goto out_errno; |
845 | 844 | ||
846 | perf_evlist__id_add(session->evlist, evsel, 0, j, f_id); | 845 | perf_evlist__id_add(session->evlist, evsel, 0, j, f_id); |
@@ -854,17 +853,17 @@ int perf_session__read_header(struct perf_session *session, int fd) | |||
854 | events = malloc(f_header.event_types.size); | 853 | events = malloc(f_header.event_types.size); |
855 | if (events == NULL) | 854 | if (events == NULL) |
856 | return -ENOMEM; | 855 | return -ENOMEM; |
857 | if (perf_header__getbuffer64(self, fd, events, | 856 | if (perf_header__getbuffer64(header, fd, events, |
858 | f_header.event_types.size)) | 857 | f_header.event_types.size)) |
859 | goto out_errno; | 858 | goto out_errno; |
860 | event_count = f_header.event_types.size / sizeof(struct perf_trace_event_type); | 859 | event_count = f_header.event_types.size / sizeof(struct perf_trace_event_type); |
861 | } | 860 | } |
862 | 861 | ||
863 | perf_header__process_sections(self, fd, perf_file_section__process); | 862 | perf_header__process_sections(header, fd, perf_file_section__process); |
864 | 863 | ||
865 | lseek(fd, self->data_offset, SEEK_SET); | 864 | lseek(fd, header->data_offset, SEEK_SET); |
866 | 865 | ||
867 | self->frozen = 1; | 866 | header->frozen = 1; |
868 | return 0; | 867 | return 0; |
869 | out_errno: | 868 | out_errno: |
870 | return -errno; | 869 | return -errno; |
diff --git a/tools/perf/util/header.h b/tools/perf/util/header.h index 4cc267559bb6..456661d7f10e 100644 --- a/tools/perf/util/header.h +++ b/tools/perf/util/header.h | |||
@@ -39,7 +39,7 @@ struct perf_pipe_file_header { | |||
39 | 39 | ||
40 | struct perf_header; | 40 | struct perf_header; |
41 | 41 | ||
42 | int perf_file_header__read(struct perf_file_header *self, | 42 | int perf_file_header__read(struct perf_file_header *header, |
43 | struct perf_header *ph, int fd); | 43 | struct perf_header *ph, int fd); |
44 | 44 | ||
45 | struct perf_header { | 45 | struct perf_header { |
@@ -66,12 +66,12 @@ char *perf_header__find_event(u64 id); | |||
66 | 66 | ||
67 | u64 perf_evlist__sample_type(struct perf_evlist *evlist); | 67 | u64 perf_evlist__sample_type(struct perf_evlist *evlist); |
68 | bool perf_evlist__sample_id_all(const struct perf_evlist *evlist); | 68 | bool perf_evlist__sample_id_all(const struct perf_evlist *evlist); |
69 | void perf_header__set_feat(struct perf_header *self, int feat); | 69 | void perf_header__set_feat(struct perf_header *header, int feat); |
70 | void perf_header__clear_feat(struct perf_header *self, int feat); | 70 | void perf_header__clear_feat(struct perf_header *header, int feat); |
71 | bool perf_header__has_feat(const struct perf_header *self, int feat); | 71 | bool perf_header__has_feat(const struct perf_header *header, int feat); |
72 | 72 | ||
73 | int perf_header__process_sections(struct perf_header *self, int fd, | 73 | int perf_header__process_sections(struct perf_header *header, int fd, |
74 | int (*process)(struct perf_file_section *self, | 74 | int (*process)(struct perf_file_section *section, |
75 | struct perf_header *ph, | 75 | struct perf_header *ph, |
76 | int feat, int fd)); | 76 | int feat, int fd)); |
77 | 77 | ||