diff options
| -rw-r--r-- | tools/perf/util/annotate.c | 12 | ||||
| -rw-r--r-- | tools/perf/util/parse-events.l | 8 |
2 files changed, 17 insertions, 3 deletions
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 4397a8b6e6cd..aa66791b1bfc 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c | |||
| @@ -606,9 +606,19 @@ static struct arch *arch__find(const char *name) | |||
| 606 | int symbol__alloc_hist(struct symbol *sym) | 606 | int symbol__alloc_hist(struct symbol *sym) |
| 607 | { | 607 | { |
| 608 | struct annotation *notes = symbol__annotation(sym); | 608 | struct annotation *notes = symbol__annotation(sym); |
| 609 | const size_t size = symbol__size(sym); | 609 | size_t size = symbol__size(sym); |
| 610 | size_t sizeof_sym_hist; | 610 | size_t sizeof_sym_hist; |
| 611 | 611 | ||
| 612 | /* | ||
| 613 | * Add buffer of one element for zero length symbol. | ||
| 614 | * When sample is taken from first instruction of | ||
| 615 | * zero length symbol, perf still resolves it and | ||
| 616 | * shows symbol name in perf report and allows to | ||
| 617 | * annotate it. | ||
| 618 | */ | ||
| 619 | if (size == 0) | ||
| 620 | size = 1; | ||
| 621 | |||
| 612 | /* Check for overflow when calculating sizeof_sym_hist */ | 622 | /* Check for overflow when calculating sizeof_sym_hist */ |
| 613 | if (size > (SIZE_MAX - sizeof(struct sym_hist)) / sizeof(struct sym_hist_entry)) | 623 | if (size > (SIZE_MAX - sizeof(struct sym_hist)) / sizeof(struct sym_hist_entry)) |
| 614 | return -1; | 624 | return -1; |
diff --git a/tools/perf/util/parse-events.l b/tools/perf/util/parse-events.l index dcfdafdc2f1c..6680e4fb7967 100644 --- a/tools/perf/util/parse-events.l +++ b/tools/perf/util/parse-events.l | |||
| @@ -154,6 +154,10 @@ do { \ | |||
| 154 | yycolumn += yyleng; \ | 154 | yycolumn += yyleng; \ |
| 155 | } while (0); | 155 | } while (0); |
| 156 | 156 | ||
| 157 | #define USER_REJECT \ | ||
| 158 | yycolumn -= yyleng; \ | ||
| 159 | REJECT | ||
| 160 | |||
| 157 | %} | 161 | %} |
| 158 | 162 | ||
| 159 | %x mem | 163 | %x mem |
| @@ -335,8 +339,8 @@ r{num_raw_hex} { return raw(yyscanner); } | |||
| 335 | {num_hex} { return value(yyscanner, 16); } | 339 | {num_hex} { return value(yyscanner, 16); } |
| 336 | 340 | ||
| 337 | {modifier_event} { return str(yyscanner, PE_MODIFIER_EVENT); } | 341 | {modifier_event} { return str(yyscanner, PE_MODIFIER_EVENT); } |
| 338 | {bpf_object} { if (!isbpf(yyscanner)) REJECT; return str(yyscanner, PE_BPF_OBJECT); } | 342 | {bpf_object} { if (!isbpf(yyscanner)) USER_REJECT; return str(yyscanner, PE_BPF_OBJECT); } |
| 339 | {bpf_source} { if (!isbpf(yyscanner)) REJECT; return str(yyscanner, PE_BPF_SOURCE); } | 343 | {bpf_source} { if (!isbpf(yyscanner)) USER_REJECT; return str(yyscanner, PE_BPF_SOURCE); } |
| 340 | {name} { return pmu_str_check(yyscanner); } | 344 | {name} { return pmu_str_check(yyscanner); } |
| 341 | "/" { BEGIN(config); return '/'; } | 345 | "/" { BEGIN(config); return '/'; } |
| 342 | - { return '-'; } | 346 | - { return '-'; } |
