perf tools: Fix tracepoint id to string perf.data header table

It was broken by f006d25 that passed just the event name, not the complete
sys:event that it expected to open the /sys/.../sys/sys:event/id file to get
the id.

Fix it by moving it to after parse_events in cmd_record, as at that point
we can just traverse the evsel_list and use evsel->attr.config +
event_name(evsel) instead of re-opening the /id file.

Reported-by: Franck Bui-Huu <vagabon.xyz@gmail.com>
Cc: Franck Bui-Huu <vagabon.xyz@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Han Pingtian <phan@redhat.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: Tom Zanussi <tzanussi@gmail.com>
LKML-Reference: <20110117202801.GG2085@ghostprotocols.net>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

+2 -29
+2
tools/perf/builtin-record.c
··· 936 936 list_for_each_entry(pos, &evsel_list, node) { 937 937 if (perf_evsel__alloc_fd(pos, cpus->nr, threads->nr) < 0) 938 938 goto out_free_fd; 939 + if (perf_header__push_event(pos->attr.config, event_name(pos))) 940 + goto out_free_fd; 939 941 } 940 942 event_array = malloc((sizeof(struct pollfd) * MAX_NR_CPUS * 941 943 MAX_COUNTERS * threads->nr));
-29
tools/perf/util/parse-events.c
··· 490 490 return EVT_HANDLED_ALL; 491 491 } 492 492 493 - static int store_event_type(const char *orgname) 494 - { 495 - char filename[PATH_MAX], *c; 496 - FILE *file; 497 - int id, n; 498 - 499 - sprintf(filename, "%s/", debugfs_path); 500 - strncat(filename, orgname, strlen(orgname)); 501 - strcat(filename, "/id"); 502 - 503 - c = strchr(filename, ':'); 504 - if (c) 505 - *c = '/'; 506 - 507 - file = fopen(filename, "r"); 508 - if (!file) 509 - return 0; 510 - n = fscanf(file, "%i", &id); 511 - fclose(file); 512 - if (n < 1) { 513 - pr_err("cannot store event ID\n"); 514 - return -EINVAL; 515 - } 516 - return perf_header__push_event(id, orgname); 517 - } 518 - 519 493 static enum event_result parse_tracepoint_event(const char **strp, 520 494 struct perf_event_attr *attr) 521 495 { ··· 533 559 return parse_multiple_tracepoint_event(sys_name, evt_name, 534 560 flags); 535 561 } else { 536 - if (store_event_type(evt_name) < 0) 537 - return EVT_FAILED; 538 - 539 562 return parse_single_tracepoint_event(sys_name, evt_name, 540 563 evt_length, attr, strp); 541 564 }