diff options
author | Frederic Weisbecker <fweisbec@gmail.com> | 2010-04-14 13:11:29 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2010-04-14 15:59:21 -0400 |
commit | fcd1498405c2c88ac632e7c3c3fce3213d9196db (patch) | |
tree | bba62d6928d259f2bd26d592432769fd3af0904b | |
parent | df8290bf7ea6b3051e2f315579a6e829309ec1ed (diff) |
perf tools: Fix accidentally preprocessed snprintf callback
struct sort_entry has a callback named snprintf that turns an
entry into a string result.
But there are glibc versions that implement snprintf through a
macro. The following expression is then going to get the snprintf
call preprocessed:
ent->snprintf(...)
to finally end up in a build error:
util/hist.c: Dans la fonction «hist_entry__snprintf» :
util/hist.c:539: erreur: «struct sort_entry» has no member named «__builtin___snprintf_chk»
To fix this, prepend struct sort_entry callbacks with an "se_"
prefix.
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r-- | tools/perf/util/hist.c | 28 | ||||
-rw-r--r-- | tools/perf/util/sort.c | 42 | ||||
-rw-r--r-- | tools/perf/util/sort.h | 12 |
3 files changed, 41 insertions, 41 deletions
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c index 18cf8b321608..9c2b8743cef6 100644 --- a/tools/perf/util/hist.c +++ b/tools/perf/util/hist.c | |||
@@ -68,7 +68,7 @@ hist_entry__cmp(struct hist_entry *left, struct hist_entry *right) | |||
68 | int64_t cmp = 0; | 68 | int64_t cmp = 0; |
69 | 69 | ||
70 | list_for_each_entry(se, &hist_entry__sort_list, list) { | 70 | list_for_each_entry(se, &hist_entry__sort_list, list) { |
71 | cmp = se->cmp(left, right); | 71 | cmp = se->se_cmp(left, right); |
72 | if (cmp) | 72 | if (cmp) |
73 | break; | 73 | break; |
74 | } | 74 | } |
@@ -85,7 +85,7 @@ hist_entry__collapse(struct hist_entry *left, struct hist_entry *right) | |||
85 | list_for_each_entry(se, &hist_entry__sort_list, list) { | 85 | list_for_each_entry(se, &hist_entry__sort_list, list) { |
86 | int64_t (*f)(struct hist_entry *, struct hist_entry *); | 86 | int64_t (*f)(struct hist_entry *, struct hist_entry *); |
87 | 87 | ||
88 | f = se->collapse ?: se->cmp; | 88 | f = se->se_collapse ?: se->se_cmp; |
89 | 89 | ||
90 | cmp = f(left, right); | 90 | cmp = f(left, right); |
91 | if (cmp) | 91 | if (cmp) |
@@ -536,8 +536,8 @@ int hist_entry__snprintf(struct hist_entry *self, | |||
536 | continue; | 536 | continue; |
537 | 537 | ||
538 | ret += snprintf(s + ret, size - ret, "%s", sep ?: " "); | 538 | ret += snprintf(s + ret, size - ret, "%s", sep ?: " "); |
539 | ret += se->snprintf(self, s + ret, size - ret, | 539 | ret += se->se_snprintf(self, s + ret, size - ret, |
540 | se->width ? *se->width : 0); | 540 | se->se_width ? *se->se_width : 0); |
541 | } | 541 | } |
542 | 542 | ||
543 | return ret; | 543 | return ret; |
@@ -564,7 +564,7 @@ static size_t hist_entry__fprintf_callchain(struct hist_entry *self, FILE *fp, | |||
564 | if (sort__first_dimension == SORT_COMM) { | 564 | if (sort__first_dimension == SORT_COMM) { |
565 | struct sort_entry *se = list_first_entry(&hist_entry__sort_list, | 565 | struct sort_entry *se = list_first_entry(&hist_entry__sort_list, |
566 | typeof(*se), list); | 566 | typeof(*se), list); |
567 | left_margin = se->width ? *se->width : 0; | 567 | left_margin = se->se_width ? *se->se_width : 0; |
568 | left_margin -= thread__comm_len(self->thread); | 568 | left_margin -= thread__comm_len(self->thread); |
569 | } | 569 | } |
570 | 570 | ||
@@ -615,22 +615,22 @@ size_t perf_session__fprintf_hists(struct rb_root *hists, | |||
615 | if (se->elide) | 615 | if (se->elide) |
616 | continue; | 616 | continue; |
617 | if (sep) { | 617 | if (sep) { |
618 | fprintf(fp, "%c%s", *sep, se->header); | 618 | fprintf(fp, "%c%s", *sep, se->se_header); |
619 | continue; | 619 | continue; |
620 | } | 620 | } |
621 | width = strlen(se->header); | 621 | width = strlen(se->se_header); |
622 | if (se->width) { | 622 | if (se->se_width) { |
623 | if (symbol_conf.col_width_list_str) { | 623 | if (symbol_conf.col_width_list_str) { |
624 | if (col_width) { | 624 | if (col_width) { |
625 | *se->width = atoi(col_width); | 625 | *se->se_width = atoi(col_width); |
626 | col_width = strchr(col_width, ','); | 626 | col_width = strchr(col_width, ','); |
627 | if (col_width) | 627 | if (col_width) |
628 | ++col_width; | 628 | ++col_width; |
629 | } | 629 | } |
630 | } | 630 | } |
631 | width = *se->width = max(*se->width, width); | 631 | width = *se->se_width = max(*se->se_width, width); |
632 | } | 632 | } |
633 | fprintf(fp, " %*s", width, se->header); | 633 | fprintf(fp, " %*s", width, se->se_header); |
634 | } | 634 | } |
635 | fprintf(fp, "\n"); | 635 | fprintf(fp, "\n"); |
636 | 636 | ||
@@ -652,10 +652,10 @@ size_t perf_session__fprintf_hists(struct rb_root *hists, | |||
652 | continue; | 652 | continue; |
653 | 653 | ||
654 | fprintf(fp, " "); | 654 | fprintf(fp, " "); |
655 | if (se->width) | 655 | if (se->se_width) |
656 | width = *se->width; | 656 | width = *se->se_width; |
657 | else | 657 | else |
658 | width = strlen(se->header); | 658 | width = strlen(se->se_header); |
659 | for (i = 0; i < width; i++) | 659 | for (i = 0; i < width; i++) |
660 | fprintf(fp, "."); | 660 | fprintf(fp, "."); |
661 | } | 661 | } |
diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c index 9d24d4b2c8fb..da30b305fba0 100644 --- a/tools/perf/util/sort.c +++ b/tools/perf/util/sort.c | |||
@@ -30,38 +30,38 @@ static int hist_entry__parent_snprintf(struct hist_entry *self, char *bf, | |||
30 | size_t size, unsigned int width); | 30 | size_t size, unsigned int width); |
31 | 31 | ||
32 | struct sort_entry sort_thread = { | 32 | struct sort_entry sort_thread = { |
33 | .header = "Command: Pid", | 33 | .se_header = "Command: Pid", |
34 | .cmp = sort__thread_cmp, | 34 | .se_cmp = sort__thread_cmp, |
35 | .snprintf = hist_entry__thread_snprintf, | 35 | .se_snprintf = hist_entry__thread_snprintf, |
36 | .width = &threads__col_width, | 36 | .se_width = &threads__col_width, |
37 | }; | 37 | }; |
38 | 38 | ||
39 | struct sort_entry sort_comm = { | 39 | struct sort_entry sort_comm = { |
40 | .header = "Command", | 40 | .se_header = "Command", |
41 | .cmp = sort__comm_cmp, | 41 | .se_cmp = sort__comm_cmp, |
42 | .collapse = sort__comm_collapse, | 42 | .se_collapse = sort__comm_collapse, |
43 | .snprintf = hist_entry__comm_snprintf, | 43 | .se_snprintf = hist_entry__comm_snprintf, |
44 | .width = &comms__col_width, | 44 | .se_width = &comms__col_width, |
45 | }; | 45 | }; |
46 | 46 | ||
47 | struct sort_entry sort_dso = { | 47 | struct sort_entry sort_dso = { |
48 | .header = "Shared Object", | 48 | .se_header = "Shared Object", |
49 | .cmp = sort__dso_cmp, | 49 | .se_cmp = sort__dso_cmp, |
50 | .snprintf = hist_entry__dso_snprintf, | 50 | .se_snprintf = hist_entry__dso_snprintf, |
51 | .width = &dsos__col_width, | 51 | .se_width = &dsos__col_width, |
52 | }; | 52 | }; |
53 | 53 | ||
54 | struct sort_entry sort_sym = { | 54 | struct sort_entry sort_sym = { |
55 | .header = "Symbol", | 55 | .se_header = "Symbol", |
56 | .cmp = sort__sym_cmp, | 56 | .se_cmp = sort__sym_cmp, |
57 | .snprintf = hist_entry__sym_snprintf, | 57 | .se_snprintf = hist_entry__sym_snprintf, |
58 | }; | 58 | }; |
59 | 59 | ||
60 | struct sort_entry sort_parent = { | 60 | struct sort_entry sort_parent = { |
61 | .header = "Parent symbol", | 61 | .se_header = "Parent symbol", |
62 | .cmp = sort__parent_cmp, | 62 | .se_cmp = sort__parent_cmp, |
63 | .snprintf = hist_entry__parent_snprintf, | 63 | .se_snprintf = hist_entry__parent_snprintf, |
64 | .width = &parent_symbol__col_width, | 64 | .se_width = &parent_symbol__col_width, |
65 | }; | 65 | }; |
66 | 66 | ||
67 | struct sort_dimension { | 67 | struct sort_dimension { |
@@ -255,7 +255,7 @@ int sort_dimension__add(const char *tok) | |||
255 | if (strncasecmp(tok, sd->name, strlen(tok))) | 255 | if (strncasecmp(tok, sd->name, strlen(tok))) |
256 | continue; | 256 | continue; |
257 | 257 | ||
258 | if (sd->entry->collapse) | 258 | if (sd->entry->se_collapse) |
259 | sort__need_collapse = 1; | 259 | sort__need_collapse = 1; |
260 | 260 | ||
261 | if (sd->entry == &sort_parent) { | 261 | if (sd->entry == &sort_parent) { |
diff --git a/tools/perf/util/sort.h b/tools/perf/util/sort.h index 6d7b4be70609..1d857aa2c01f 100644 --- a/tools/perf/util/sort.h +++ b/tools/perf/util/sort.h | |||
@@ -78,13 +78,13 @@ enum sort_type { | |||
78 | struct sort_entry { | 78 | struct sort_entry { |
79 | struct list_head list; | 79 | struct list_head list; |
80 | 80 | ||
81 | const char *header; | 81 | const char *se_header; |
82 | 82 | ||
83 | int64_t (*cmp)(struct hist_entry *, struct hist_entry *); | 83 | int64_t (*se_cmp)(struct hist_entry *, struct hist_entry *); |
84 | int64_t (*collapse)(struct hist_entry *, struct hist_entry *); | 84 | int64_t (*se_collapse)(struct hist_entry *, struct hist_entry *); |
85 | int (*snprintf)(struct hist_entry *self, char *bf, size_t size, | 85 | int (*se_snprintf)(struct hist_entry *self, char *bf, size_t size, |
86 | unsigned int width); | 86 | unsigned int width); |
87 | unsigned int *width; | 87 | unsigned int *se_width; |
88 | bool elide; | 88 | bool elide; |
89 | }; | 89 | }; |
90 | 90 | ||