From: Stephane Eranian <eranian@google.com>
To: linux-kernel@vger.kernel.org
Cc: mingo@elte.hu, peterz@infradead.org, acme@redhat.com
Subject: [PATCH] perf: fix missing event name init for default event
Date: Mon, 6 Jun 2011 17:10:24 +0200 [thread overview]
Message-ID: <20110606151024.GA9464@quad> (raw)
When no event is given to perf record, perf top, a default
event is initialized (cycles). However, perf_evlist__add_default()
was not setting the symbolic name for the event. Perf top
worked simply because it was reconstructing the name from the event
code. But it should not have to do this. This patch initializes the
evsel->name field properly.
Signed-off-by: Stephane Eranian <eranian@google.com>
---
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index b021ea9..1584af6 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -87,6 +87,13 @@ int perf_evlist__add_default(struct perf_evlist *evlist)
if (evsel == NULL)
return -ENOMEM;
+ /* use strdup() because free(evsel) assumes name is allocated */
+ evsel->name = strdup("cycles");
+ if (!evsel->name) {
+ free(evsel);
+ return -ENOMEM;
+ }
+
perf_evlist__add(evlist, evsel);
return 0;
}
next reply other threads:[~2011-06-06 15:10 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-06 15:10 Stephane Eranian [this message]
2011-06-06 17:32 ` [PATCH] perf: fix missing event name init for default event Ingo Molnar
2011-06-07 15:45 ` Stephane Eranian
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110606151024.GA9464@quad \
--to=eranian@google.com \
--cc=acme@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=peterz@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.