[PATCH] perf: fix core dump

From: jovi zhang
Date: Tue Aug 24 2010 - 03:07:38 EST


Perf invoke symbol__init function twice when we input command "perf
kmem/sched record ls", then it will core dump when symbol__exit
invoked.
So give a flag to make symbol__init can be invoked once.

Signed-off-by: Jovi Zhang <bookjovi@xxxxxxxxx>
tools/perf/util/symbol.c | Â Â9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index 1a36773..aded121 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -43,6 +43,8 @@ struct symbol_conf symbol_conf = {
   Â.try_vmlinux_path = true,
};

+static bool symbol_initizated;
+
int dso__name_len(const struct dso *self)
{
   Âif (verbose)
@@ -2268,6 +2270,11 @@ static int setup_list(struct strlist **list,
const char *list_str,

int symbol__init(void)
{
+ Â Â Â if (symbol_initizated == true)
+ Â Â Â Â Â Â Â return 0;
+ Â Â Â else
+ Â Â Â Â Â Â Â symbol_initizated = true;
+
   Âelf_version(EV_CURRENT);
   Âif (symbol_conf.sort_by_name)
       Âsymbol_conf.priv_size += (sizeof(struct symbol_name_rb_node) -
@@ -2304,6 +2311,8 @@ out_free_comm_list:

void symbol__exit(void)
{
+ Â Â Â if (symbol_initizated == false)
+ Â Â Â Â Â Â Â return;
   Âstrlist__delete(symbol_conf.sym_list);
   Âstrlist__delete(symbol_conf.dso_list);
   Âstrlist__delete(symbol_conf.comm_list);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/