aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIngo Molnar <mingo@kernel.org>2012-05-30 02:59:31 -0400
committerIngo Molnar <mingo@kernel.org>2012-05-30 03:01:40 -0400
commit55b78e34b12d07b8ab7d7732fd24892df8eea5c7 (patch)
treedead7017e67403bdae20db5f2a3a409af9eea7d3
parentc985f7812331d79483beab932e8966477411a942 (diff)
parenta44b45f236dd1c1a8caccf9a078adf2941a20267 (diff)
Merge tag 'perf-urgent-for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/urgent
Fixes for perf/urgent from Arnaldo Carvalho de Melo: * Fix fallback to --stdio when TUI not supported, from Namhyung Kim. * Use right cast for pointers/long in libtraceevent, from Namhyung Kim. * Be consistent on using the right error reporting interface for fatal errors, from Namhyung Kim. * Fix fallback to --stdio when TUI not supported, from Namhyung Kim. * Use the right index in asm only view in the annotate browser. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r--tools/lib/traceevent/parse-filter.c2
-rw-r--r--tools/perf/Makefile4
-rw-r--r--tools/perf/builtin-annotate.c2
-rw-r--r--tools/perf/builtin-record.c14
-rw-r--r--tools/perf/builtin-report.c14
-rw-r--r--tools/perf/builtin-top.c24
-rw-r--r--tools/perf/perf.h2
-rw-r--r--tools/perf/ui/browsers/annotate.c6
-rw-r--r--tools/perf/ui/setup.c1
-rw-r--r--tools/perf/util/evsel.c90
-rw-r--r--tools/perf/util/evsel.h3
-rw-r--r--tools/perf/util/parse-events.c27
-rw-r--r--tools/perf/util/thread_map.c21
13 files changed, 150 insertions, 60 deletions
diff --git a/tools/lib/traceevent/parse-filter.c b/tools/lib/traceevent/parse-filter.c
index e08d21ffd3a6..dfcfe2c131de 100644
--- a/tools/lib/traceevent/parse-filter.c
+++ b/tools/lib/traceevent/parse-filter.c
@@ -1584,7 +1584,7 @@ get_value(struct event_format *event,
1584 const char *name; 1584 const char *name;
1585 1585
1586 name = get_comm(event, record); 1586 name = get_comm(event, record);
1587 return (unsigned long long)name; 1587 return (unsigned long)name;
1588 } 1588 }
1589 1589
1590 pevent_read_number_field(field, record->data, &val); 1590 pevent_read_number_field(field, record->data, &val);
diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index 1d3d513beb9b..0eee64cfe9a0 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -80,7 +80,7 @@ ifeq ("$(origin DEBUG)", "command line")
80 PERF_DEBUG = $(DEBUG) 80 PERF_DEBUG = $(DEBUG)
81endif 81endif
82ifndef PERF_DEBUG 82ifndef PERF_DEBUG
83 CFLAGS_OPTIMIZE = -O6 83 CFLAGS_OPTIMIZE = -O6 -D_FORTIFY_SOURCE=2
84endif 84endif
85 85
86ifdef PARSER_DEBUG 86ifdef PARSER_DEBUG
@@ -89,7 +89,7 @@ ifdef PARSER_DEBUG
89 PARSER_DEBUG_CFLAGS := -DPARSER_DEBUG 89 PARSER_DEBUG_CFLAGS := -DPARSER_DEBUG
90endif 90endif
91 91
92CFLAGS = -fno-omit-frame-pointer -ggdb3 -Wall -Wextra -std=gnu99 $(CFLAGS_WERROR) $(CFLAGS_OPTIMIZE) -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) $(PARSER_DEBUG_CFLAGS) 92CFLAGS = -fno-omit-frame-pointer -ggdb3 -Wall -Wextra -std=gnu99 $(CFLAGS_WERROR) $(CFLAGS_OPTIMIZE) $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) $(PARSER_DEBUG_CFLAGS)
93EXTLIBS = -lpthread -lrt -lelf -lm 93EXTLIBS = -lpthread -lrt -lelf -lm
94ALL_CFLAGS = $(CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE 94ALL_CFLAGS = $(CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
95ALL_LDFLAGS = $(LDFLAGS) 95ALL_LDFLAGS = $(LDFLAGS)
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index 806e0a286634..67522cf87405 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -215,7 +215,7 @@ static int __cmd_annotate(struct perf_annotate *ann)
215 } 215 }
216 216
217 if (total_nr_samples == 0) { 217 if (total_nr_samples == 0) {
218 ui__warning("The %s file has no samples!\n", session->filename); 218 ui__error("The %s file has no samples!\n", session->filename);
219 goto out_delete; 219 goto out_delete;
220 } 220 }
221out_delete: 221out_delete:
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index e5cb08427e13..f95840d04e4c 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -264,7 +264,7 @@ try_again:
264 } 264 }
265 265
266 if (err == ENOENT) { 266 if (err == ENOENT) {
267 ui__warning("The %s event is not supported.\n", 267 ui__error("The %s event is not supported.\n",
268 event_name(pos)); 268 event_name(pos));
269 exit(EXIT_FAILURE); 269 exit(EXIT_FAILURE);
270 } 270 }
@@ -858,8 +858,8 @@ int cmd_record(int argc, const char **argv, const char *prefix __used)
858 usage_with_options(record_usage, record_options); 858 usage_with_options(record_usage, record_options);
859 859
860 if (rec->force && rec->append_file) { 860 if (rec->force && rec->append_file) {
861 fprintf(stderr, "Can't overwrite and append at the same time." 861 ui__error("Can't overwrite and append at the same time."
862 " You need to choose between -f and -A"); 862 " You need to choose between -f and -A");
863 usage_with_options(record_usage, record_options); 863 usage_with_options(record_usage, record_options);
864 } else if (rec->append_file) { 864 } else if (rec->append_file) {
865 rec->write_mode = WRITE_APPEND; 865 rec->write_mode = WRITE_APPEND;
@@ -868,8 +868,8 @@ int cmd_record(int argc, const char **argv, const char *prefix __used)
868 } 868 }
869 869
870 if (nr_cgroups && !rec->opts.target.system_wide) { 870 if (nr_cgroups && !rec->opts.target.system_wide) {
871 fprintf(stderr, "cgroup monitoring only available in" 871 ui__error("cgroup monitoring only available in"
872 " system-wide mode\n"); 872 " system-wide mode\n");
873 usage_with_options(record_usage, record_options); 873 usage_with_options(record_usage, record_options);
874 } 874 }
875 875
@@ -905,7 +905,7 @@ int cmd_record(int argc, const char **argv, const char *prefix __used)
905 int saved_errno = errno; 905 int saved_errno = errno;
906 906
907 perf_target__strerror(&rec->opts.target, err, errbuf, BUFSIZ); 907 perf_target__strerror(&rec->opts.target, err, errbuf, BUFSIZ);
908 ui__warning("%s", errbuf); 908 ui__error("%s", errbuf);
909 909
910 err = -saved_errno; 910 err = -saved_errno;
911 goto out_free_fd; 911 goto out_free_fd;
@@ -933,7 +933,7 @@ int cmd_record(int argc, const char **argv, const char *prefix __used)
933 else if (rec->opts.freq) { 933 else if (rec->opts.freq) {
934 rec->opts.default_interval = rec->opts.freq; 934 rec->opts.default_interval = rec->opts.freq;
935 } else { 935 } else {
936 fprintf(stderr, "frequency and count are zero, aborting\n"); 936 ui__error("frequency and count are zero, aborting\n");
937 err = -EINVAL; 937 err = -EINVAL;
938 goto out_free_fd; 938 goto out_free_fd;
939 } 939 }
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index d58e41445d0d..8c767c6bca91 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -251,13 +251,13 @@ static int perf_report__setup_sample_type(struct perf_report *rep)
251 251
252 if (!(self->sample_type & PERF_SAMPLE_CALLCHAIN)) { 252 if (!(self->sample_type & PERF_SAMPLE_CALLCHAIN)) {
253 if (sort__has_parent) { 253 if (sort__has_parent) {
254 ui__warning("Selected --sort parent, but no " 254 ui__error("Selected --sort parent, but no "
255 "callchain data. Did you call " 255 "callchain data. Did you call "
256 "'perf record' without -g?\n"); 256 "'perf record' without -g?\n");
257 return -EINVAL; 257 return -EINVAL;
258 } 258 }
259 if (symbol_conf.use_callchain) { 259 if (symbol_conf.use_callchain) {
260 ui__warning("Selected -g but no callchain data. Did " 260 ui__error("Selected -g but no callchain data. Did "
261 "you call 'perf record' without -g?\n"); 261 "you call 'perf record' without -g?\n");
262 return -1; 262 return -1;
263 } 263 }
@@ -266,17 +266,15 @@ static int perf_report__setup_sample_type(struct perf_report *rep)
266 !symbol_conf.use_callchain) { 266 !symbol_conf.use_callchain) {
267 symbol_conf.use_callchain = true; 267 symbol_conf.use_callchain = true;
268 if (callchain_register_param(&callchain_param) < 0) { 268 if (callchain_register_param(&callchain_param) < 0) {
269 ui__warning("Can't register callchain " 269 ui__error("Can't register callchain params.\n");
270 "params.\n");
271 return -EINVAL; 270 return -EINVAL;
272 } 271 }
273 } 272 }
274 273
275 if (sort__branch_mode == 1) { 274 if (sort__branch_mode == 1) {
276 if (!(self->sample_type & PERF_SAMPLE_BRANCH_STACK)) { 275 if (!(self->sample_type & PERF_SAMPLE_BRANCH_STACK)) {
277 fprintf(stderr, "selected -b but no branch data." 276 ui__error("Selected -b but no branch data. "
278 " Did you call perf record without" 277 "Did you call perf record without -b?\n");
279 " -b?\n");
280 return -1; 278 return -1;
281 } 279 }
282 } 280 }
@@ -420,7 +418,7 @@ static int __cmd_report(struct perf_report *rep)
420 } 418 }
421 419
422 if (nr_samples == 0) { 420 if (nr_samples == 0) {
423 ui__warning("The %s file has no samples!\n", session->filename); 421 ui__error("The %s file has no samples!\n", session->filename);
424 goto out_delete; 422 goto out_delete;
425 } 423 }
426 424
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 6031dce0429f..871b540293e1 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -953,22 +953,22 @@ try_again:
953 attr->config = PERF_COUNT_SW_CPU_CLOCK; 953 attr->config = PERF_COUNT_SW_CPU_CLOCK;
954 if (counter->name) { 954 if (counter->name) {
955 free(counter->name); 955 free(counter->name);
956 counter->name = strdup(event_name(counter)); 956 counter->name = NULL;
957 } 957 }
958 goto try_again; 958 goto try_again;
959 } 959 }
960 960
961 if (err == ENOENT) { 961 if (err == ENOENT) {
962 ui__warning("The %s event is not supported.\n", 962 ui__error("The %s event is not supported.\n",
963 event_name(counter)); 963 event_name(counter));
964 goto out_err; 964 goto out_err;
965 } else if (err == EMFILE) { 965 } else if (err == EMFILE) {
966 ui__warning("Too many events are opened.\n" 966 ui__error("Too many events are opened.\n"
967 "Try again after reducing the number of events\n"); 967 "Try again after reducing the number of events\n");
968 goto out_err; 968 goto out_err;
969 } 969 }
970 970
971 ui__warning("The sys_perf_event_open() syscall " 971 ui__error("The sys_perf_event_open() syscall "
972 "returned with %d (%s). /bin/dmesg " 972 "returned with %d (%s). /bin/dmesg "
973 "may provide additional information.\n" 973 "may provide additional information.\n"
974 "No CONFIG_PERF_EVENTS=y kernel support " 974 "No CONFIG_PERF_EVENTS=y kernel support "
@@ -978,7 +978,7 @@ try_again:
978 } 978 }
979 979
980 if (perf_evlist__mmap(evlist, top->mmap_pages, false) < 0) { 980 if (perf_evlist__mmap(evlist, top->mmap_pages, false) < 0) {
981 ui__warning("Failed to mmap with %d (%s)\n", 981 ui__error("Failed to mmap with %d (%s)\n",
982 errno, strerror(errno)); 982 errno, strerror(errno));
983 goto out_err; 983 goto out_err;
984 } 984 }
@@ -994,12 +994,12 @@ static int perf_top__setup_sample_type(struct perf_top *top)
994{ 994{
995 if (!top->sort_has_symbols) { 995 if (!top->sort_has_symbols) {
996 if (symbol_conf.use_callchain) { 996 if (symbol_conf.use_callchain) {
997 ui__warning("Selected -g but \"sym\" not present in --sort/-s."); 997 ui__error("Selected -g but \"sym\" not present in --sort/-s.");
998 return -EINVAL; 998 return -EINVAL;
999 } 999 }
1000 } else if (!top->dont_use_callchains && callchain_param.mode != CHAIN_NONE) { 1000 } else if (!top->dont_use_callchains && callchain_param.mode != CHAIN_NONE) {
1001 if (callchain_register_param(&callchain_param) < 0) { 1001 if (callchain_register_param(&callchain_param) < 0) {
1002 ui__warning("Can't register callchain params.\n"); 1002 ui__error("Can't register callchain params.\n");
1003 return -EINVAL; 1003 return -EINVAL;
1004 } 1004 }
1005 } 1005 }
@@ -1041,7 +1041,7 @@ static int __cmd_top(struct perf_top *top)
1041 1041
1042 if (pthread_create(&thread, NULL, (use_browser > 0 ? display_thread_tui : 1042 if (pthread_create(&thread, NULL, (use_browser > 0 ? display_thread_tui :
1043 display_thread), top)) { 1043 display_thread), top)) {
1044 printf("Could not create display thread.\n"); 1044 ui__error("Could not create display thread.\n");
1045 exit(-1); 1045 exit(-1);
1046 } 1046 }
1047 1047
@@ -1050,7 +1050,7 @@ static int __cmd_top(struct perf_top *top)
1050 1050
1051 param.sched_priority = top->realtime_prio; 1051 param.sched_priority = top->realtime_prio;
1052 if (sched_setscheduler(0, SCHED_FIFO, &param)) { 1052 if (sched_setscheduler(0, SCHED_FIFO, &param)) {
1053 printf("Could not set realtime priority.\n"); 1053 ui__error("Could not set realtime priority.\n");
1054 exit(-1); 1054 exit(-1);
1055 } 1055 }
1056 } 1056 }
@@ -1274,7 +1274,7 @@ int cmd_top(int argc, const char **argv, const char *prefix __used)
1274 int saved_errno = errno; 1274 int saved_errno = errno;
1275 1275
1276 perf_target__strerror(&top.target, status, errbuf, BUFSIZ); 1276 perf_target__strerror(&top.target, status, errbuf, BUFSIZ);
1277 ui__warning("%s", errbuf); 1277 ui__error("%s", errbuf);
1278 1278
1279 status = -saved_errno; 1279 status = -saved_errno;
1280 goto out_delete_evlist; 1280 goto out_delete_evlist;
@@ -1288,7 +1288,7 @@ int cmd_top(int argc, const char **argv, const char *prefix __used)
1288 1288
1289 if (!top.evlist->nr_entries && 1289 if (!top.evlist->nr_entries &&
1290 perf_evlist__add_default(top.evlist) < 0) { 1290 perf_evlist__add_default(top.evlist) < 0) {
1291 pr_err("Not enough memory for event selector list\n"); 1291 ui__error("Not enough memory for event selector list\n");
1292 return -ENOMEM; 1292 return -ENOMEM;
1293 } 1293 }
1294 1294
@@ -1305,7 +1305,7 @@ int cmd_top(int argc, const char **argv, const char *prefix __used)
1305 else if (top.freq) { 1305 else if (top.freq) {
1306 top.default_interval = top.freq; 1306 top.default_interval = top.freq;
1307 } else { 1307 } else {
1308 fprintf(stderr, "frequency and count are zero, aborting\n"); 1308 ui__error("frequency and count are zero, aborting\n");
1309 exit(EXIT_FAILURE); 1309 exit(EXIT_FAILURE);
1310 } 1310 }
1311 1311
diff --git a/tools/perf/perf.h b/tools/perf/perf.h
index 14f1034f14f9..f960ccb2edc6 100644
--- a/tools/perf/perf.h
+++ b/tools/perf/perf.h
@@ -227,7 +227,7 @@ struct perf_record_opts {
227 unsigned int freq; 227 unsigned int freq;
228 unsigned int mmap_pages; 228 unsigned int mmap_pages;
229 unsigned int user_freq; 229 unsigned int user_freq;
230 int branch_stack; 230 u64 branch_stack;
231 u64 default_interval; 231 u64 default_interval;
232 u64 user_interval; 232 u64 user_interval;
233}; 233};
diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c
index 6e0ef79be169..aaf36ce0b6fe 100644
--- a/tools/perf/ui/browsers/annotate.c
+++ b/tools/perf/ui/browsers/annotate.c
@@ -300,10 +300,14 @@ static void annotate_browser__set_rb_top(struct annotate_browser *browser,
300{ 300{
301 struct browser_disasm_line *bpos; 301 struct browser_disasm_line *bpos;
302 struct disasm_line *pos; 302 struct disasm_line *pos;
303 u32 idx;
303 304
304 bpos = rb_entry(nd, struct browser_disasm_line, rb_node); 305 bpos = rb_entry(nd, struct browser_disasm_line, rb_node);
305 pos = ((struct disasm_line *)bpos) - 1; 306 pos = ((struct disasm_line *)bpos) - 1;
306 annotate_browser__set_top(browser, pos, bpos->idx); 307 idx = bpos->idx;
308 if (browser->hide_src_code)
309 idx = bpos->idx_asm;
310 annotate_browser__set_top(browser, pos, idx);
307 browser->curr_hot = nd; 311 browser->curr_hot = nd;
308} 312}
309 313
diff --git a/tools/perf/ui/setup.c b/tools/perf/ui/setup.c
index 9f5f888f73e3..791fb15ce350 100644
--- a/tools/perf/ui/setup.c
+++ b/tools/perf/ui/setup.c
@@ -22,6 +22,7 @@ void setup_browser(bool fallback_to_pager)
22 break; 22 break;
23 /* fall through */ 23 /* fall through */
24 default: 24 default:
25 use_browser = 0;
25 if (fallback_to_pager) 26 if (fallback_to_pager)
26 setup_pager(); 27 setup_pager();
27 break; 28 break;
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 57e4ce57bbcc..91d19138f3ec 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -15,6 +15,7 @@
15#include "cpumap.h" 15#include "cpumap.h"
16#include "thread_map.h" 16#include "thread_map.h"
17#include "target.h" 17#include "target.h"
18#include "../../include/linux/perf_event.h"
18 19
19#define FD(e, x, y) (*(int *)xyarray__entry(e->fd, x, y)) 20#define FD(e, x, y) (*(int *)xyarray__entry(e->fd, x, y))
20#define GROUP_FD(group_fd, cpu) (*(int *)xyarray__entry(group_fd, cpu, 0)) 21#define GROUP_FD(group_fd, cpu) (*(int *)xyarray__entry(group_fd, cpu, 0))
@@ -64,6 +65,95 @@ struct perf_evsel *perf_evsel__new(struct perf_event_attr *attr, int idx)
64 return evsel; 65 return evsel;
65} 66}
66 67
68static const char *perf_evsel__hw_names[PERF_COUNT_HW_MAX] = {
69 "cycles",
70 "instructions",
71 "cache-references",
72 "cache-misses",
73 "branches",
74 "branch-misses",
75 "bus-cycles",
76 "stalled-cycles-frontend",
77 "stalled-cycles-backend",
78 "ref-cycles",
79};
80
81const char *__perf_evsel__hw_name(u64 config)
82{
83 if (config < PERF_COUNT_HW_MAX && perf_evsel__hw_names[config])
84 return perf_evsel__hw_names[config];
85
86 return "unknown-hardware";
87}
88
89static int perf_evsel__hw_name(struct perf_evsel *evsel, char *bf, size_t size)
90{
91 int colon = 0;
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;
95
96#define MOD_PRINT(context, mod) do { \
97 if (!attr->exclude_##context) { \
98 if (!colon) colon = r++; \
99 r += scnprintf(bf + r, size - r, "%c", mod); \
100 } } while(0)
101
102 if (attr->exclude_kernel || attr->exclude_user || attr->exclude_hv) {
103 MOD_PRINT(kernel, 'k');
104 MOD_PRINT(user, 'u');
105 MOD_PRINT(hv, 'h');
106 exclude_guest_default = true;
107 }
108
109 if (attr->precise_ip) {
110 if (!colon)
111 colon = r++;
112 r += scnprintf(bf + r, size - r, "%.*s", attr->precise_ip, "ppp");
113 exclude_guest_default = true;
114 }
115
116 if (attr->exclude_host || attr->exclude_guest == exclude_guest_default) {
117 MOD_PRINT(host, 'H');
118 MOD_PRINT(guest, 'G');
119 }
120#undef MOD_PRINT
121 if (colon)
122 bf[colon] = ':';
123 return r;
124}
125
126int perf_evsel__name(struct perf_evsel *evsel, char *bf, size_t size)
127{
128 int ret;
129
130 switch (evsel->attr.type) {
131 case PERF_TYPE_RAW:
132 ret = scnprintf(bf, size, "raw 0x%" PRIx64, evsel->attr.config);
133 break;
134
135 case PERF_TYPE_HARDWARE:
136 ret = perf_evsel__hw_name(evsel, bf, size);
137 break;
138 default:
139 /*
140 * FIXME
141 *
142 * This is the minimal perf_evsel__name so that we can
143 * reconstruct event names taking into account event modifiers.
144 *
145 * The old event_name uses it now for raw anr hw events, so that
146 * we don't drag all the parsing stuff into the python binding.
147 *
148 * On the next devel cycle the rest of the event naming will be
149 * brought here.
150 */
151 return 0;
152 }
153
154 return ret;
155}
156
67void perf_evsel__config(struct perf_evsel *evsel, struct perf_record_opts *opts, 157void perf_evsel__config(struct perf_evsel *evsel, struct perf_record_opts *opts,
68 struct perf_evsel *first) 158 struct perf_evsel *first)
69{ 159{
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
index 3d6b3e4cb66b..4ba8b564e6f4 100644
--- a/tools/perf/util/evsel.h
+++ b/tools/perf/util/evsel.h
@@ -83,6 +83,9 @@ void perf_evsel__config(struct perf_evsel *evsel,
83 struct perf_record_opts *opts, 83 struct perf_record_opts *opts,
84 struct perf_evsel *first); 84 struct perf_evsel *first);
85 85
86const char* __perf_evsel__hw_name(u64 config);
87int perf_evsel__name(struct perf_evsel *evsel, char *bf, size_t size);
88
86int perf_evsel__alloc_fd(struct perf_evsel *evsel, int ncpus, int nthreads); 89int perf_evsel__alloc_fd(struct perf_evsel *evsel, int ncpus, int nthreads);
87int perf_evsel__alloc_id(struct perf_evsel *evsel, int ncpus, int nthreads); 90int perf_evsel__alloc_id(struct perf_evsel *evsel, int ncpus, int nthreads);
88int perf_evsel__alloc_counts(struct perf_evsel *evsel, int ncpus); 91int perf_evsel__alloc_counts(struct perf_evsel *evsel, int ncpus);
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index fac7d59309b8..05dbc8b3c767 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -62,19 +62,6 @@ static struct event_symbol event_symbols[] = {
62#define PERF_EVENT_TYPE(config) __PERF_EVENT_FIELD(config, TYPE) 62#define PERF_EVENT_TYPE(config) __PERF_EVENT_FIELD(config, TYPE)
63#define PERF_EVENT_ID(config) __PERF_EVENT_FIELD(config, EVENT) 63#define PERF_EVENT_ID(config) __PERF_EVENT_FIELD(config, EVENT)
64 64
65static const char *hw_event_names[PERF_COUNT_HW_MAX] = {
66 "cycles",
67 "instructions",
68 "cache-references",
69 "cache-misses",
70 "branches",
71 "branch-misses",
72 "bus-cycles",
73 "stalled-cycles-frontend",
74 "stalled-cycles-backend",
75 "ref-cycles",
76};
77
78static const char *sw_event_names[PERF_COUNT_SW_MAX] = { 65static const char *sw_event_names[PERF_COUNT_SW_MAX] = {
79 "cpu-clock", 66 "cpu-clock",
80 "task-clock", 67 "task-clock",
@@ -300,6 +287,16 @@ const char *event_name(struct perf_evsel *evsel)
300 u64 config = evsel->attr.config; 287 u64 config = evsel->attr.config;
301 int type = evsel->attr.type; 288 int type = evsel->attr.type;
302 289
290 if (type == PERF_TYPE_RAW || type == PERF_TYPE_HARDWARE) {
291 /*
292 * XXX minimal fix, see comment on perf_evsen__name, this static buffer
293 * will go away together with event_name in the next devel cycle.
294 */
295 static char bf[128];
296 perf_evsel__name(evsel, bf, sizeof(bf));
297 return bf;
298 }
299
303 if (evsel->name) 300 if (evsel->name)
304 return evsel->name; 301 return evsel->name;
305 302
@@ -317,9 +314,7 @@ const char *__event_name(int type, u64 config)
317 314
318 switch (type) { 315 switch (type) {
319 case PERF_TYPE_HARDWARE: 316 case PERF_TYPE_HARDWARE:
320 if (config < PERF_COUNT_HW_MAX && hw_event_names[config]) 317 return __perf_evsel__hw_name(config);
321 return hw_event_names[config];
322 return "unknown-hardware";
323 318
324 case PERF_TYPE_HW_CACHE: { 319 case PERF_TYPE_HW_CACHE: {
325 u8 cache_type, cache_op, cache_result; 320 u8 cache_type, cache_op, cache_result;
diff --git a/tools/perf/util/thread_map.c b/tools/perf/util/thread_map.c
index 84d9bd782004..9b5f856cc280 100644
--- a/tools/perf/util/thread_map.c
+++ b/tools/perf/util/thread_map.c
@@ -188,28 +188,27 @@ static struct thread_map *thread_map__new_by_pid_str(const char *pid_str)
188 nt = realloc(threads, (sizeof(*threads) + 188 nt = realloc(threads, (sizeof(*threads) +
189 sizeof(pid_t) * total_tasks)); 189 sizeof(pid_t) * total_tasks));
190 if (nt == NULL) 190 if (nt == NULL)
191 goto out_free_threads; 191 goto out_free_namelist;
192 192
193 threads = nt; 193 threads = nt;
194 194
195 if (threads) { 195 for (i = 0; i < items; i++) {
196 for (i = 0; i < items; i++) 196 threads->map[j++] = atoi(namelist[i]->d_name);
197 threads->map[j++] = atoi(namelist[i]->d_name);
198 threads->nr = total_tasks;
199 }
200
201 for (i = 0; i < items; i++)
202 free(namelist[i]); 197 free(namelist[i]);
198 }
199 threads->nr = total_tasks;
203 free(namelist); 200 free(namelist);
204
205 if (!threads)
206 break;
207 } 201 }
208 202
209out: 203out:
210 strlist__delete(slist); 204 strlist__delete(slist);
211 return threads; 205 return threads;
212 206
207out_free_namelist:
208 for (i = 0; i < items; i++)
209 free(namelist[i]);
210 free(namelist);
211
213out_free_threads: 212out_free_threads:
214 free(threads); 213 free(threads);
215 threads = NULL; 214 threads = NULL;