diff options
Diffstat (limited to 'tools/perf/util')
| -rw-r--r-- | tools/perf/util/evsel.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 9f6cebd798ee..dab893804a14 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c | |||
| @@ -86,16 +86,15 @@ const char *__perf_evsel__hw_name(u64 config) | |||
| 86 | return "unknown-hardware"; | 86 | return "unknown-hardware"; |
| 87 | } | 87 | } |
| 88 | 88 | ||
| 89 | static int perf_evsel__hw_name(struct perf_evsel *evsel, char *bf, size_t size) | 89 | static int perf_evsel__add_modifiers(struct perf_evsel *evsel, char *bf, size_t size) |
| 90 | { | 90 | { |
| 91 | int colon = 0; | 91 | int colon = 0, r = 0; |
| 92 | struct perf_event_attr *attr = &evsel->attr; | 92 | struct perf_event_attr *attr = &evsel->attr; |
| 93 | int r = scnprintf(bf, size, "%s", __perf_evsel__hw_name(attr->config)); | ||
| 94 | bool exclude_guest_default = false; | 93 | bool exclude_guest_default = false; |
| 95 | 94 | ||
| 96 | #define MOD_PRINT(context, mod) do { \ | 95 | #define MOD_PRINT(context, mod) do { \ |
| 97 | if (!attr->exclude_##context) { \ | 96 | if (!attr->exclude_##context) { \ |
| 98 | if (!colon) colon = r++; \ | 97 | if (!colon) colon = ++r; \ |
| 99 | r += scnprintf(bf + r, size - r, "%c", mod); \ | 98 | r += scnprintf(bf + r, size - r, "%c", mod); \ |
| 100 | } } while(0) | 99 | } } while(0) |
| 101 | 100 | ||
| @@ -108,7 +107,7 @@ static int perf_evsel__hw_name(struct perf_evsel *evsel, char *bf, size_t size) | |||
| 108 | 107 | ||
| 109 | if (attr->precise_ip) { | 108 | if (attr->precise_ip) { |
| 110 | if (!colon) | 109 | if (!colon) |
| 111 | colon = r++; | 110 | colon = ++r; |
| 112 | r += scnprintf(bf + r, size - r, "%.*s", attr->precise_ip, "ppp"); | 111 | r += scnprintf(bf + r, size - r, "%.*s", attr->precise_ip, "ppp"); |
| 113 | exclude_guest_default = true; | 112 | exclude_guest_default = true; |
| 114 | } | 113 | } |
| @@ -119,10 +118,16 @@ static int perf_evsel__hw_name(struct perf_evsel *evsel, char *bf, size_t size) | |||
| 119 | } | 118 | } |
| 120 | #undef MOD_PRINT | 119 | #undef MOD_PRINT |
| 121 | if (colon) | 120 | if (colon) |
| 122 | bf[colon] = ':'; | 121 | bf[colon - 1] = ':'; |
| 123 | return r; | 122 | return r; |
| 124 | } | 123 | } |
| 125 | 124 | ||
| 125 | static int perf_evsel__hw_name(struct perf_evsel *evsel, char *bf, size_t size) | ||
| 126 | { | ||
| 127 | int r = scnprintf(bf, size, "%s", __perf_evsel__hw_name(evsel->attr.config)); | ||
| 128 | return r + perf_evsel__add_modifiers(evsel, bf + r, size - r); | ||
| 129 | } | ||
| 130 | |||
| 126 | int perf_evsel__name(struct perf_evsel *evsel, char *bf, size_t size) | 131 | int perf_evsel__name(struct perf_evsel *evsel, char *bf, size_t size) |
| 127 | { | 132 | { |
| 128 | int ret; | 133 | int ret; |
