* [PATCH 21/34 v2] perf report: Add --header/--header-only options
2013-12-10 20:31 [GIT PULL 00/34] perf/core improvements and fixes Arnaldo Carvalho de Melo
@ 2013-12-10 20:31 ` Arnaldo Carvalho de Melo
2013-12-10 20:31 ` [PATCH 22/34] perf script: " Arnaldo Carvalho de Melo
` (13 subsequent siblings)
14 siblings, 0 replies; 17+ messages in thread
From: Arnaldo Carvalho de Melo @ 2013-12-10 20:31 UTC (permalink / raw)
To: Ingo Molnar
Cc: linux-kernel, Jiri Olsa, Corey Ashford, David Ahern,
Frederic Weisbecker, Ingo Molnar, Namhyung Kim, Paul Mackerras,
Peter Zijlstra, Stephane Eranian, Arnaldo Carvalho de Melo
From: Jiri Olsa <jolsa@redhat.com>
Currently the perf.data header is always displayed for stdio output,
which is no always useful.
Disabling header information by default and adding following options to
control header output:
--header - display header information (old default)
--header-only - display header information only w/o further
processing, forces stdio output
Signed-off-by: Jiri Olsa <jolsa@redhat.com>
Acked-by: David Ahern <dsahern@gmail.com>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1386583370-1699-2-git-send-email-jolsa@redhat.com
[ Added single line explaining talking about the new --header* options,
to address David Ahern comment; better man page entry for the new options,
from Namhyung Kim ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/Documentation/perf-report.txt | 9 +++++++++
tools/perf/builtin-report.c | 22 +++++++++++++++++++---
2 files changed, 28 insertions(+), 3 deletions(-)
diff --git a/tools/perf/Documentation/perf-report.txt b/tools/perf/Documentation/perf-report.txt
index 10a279871251..8eab8a4bdeb8 100644
--- a/tools/perf/Documentation/perf-report.txt
+++ b/tools/perf/Documentation/perf-report.txt
@@ -237,6 +237,15 @@ OPTIONS
Do not show entries which have an overhead under that percent.
(Default: 0).
+--header::
+ Show header information in the perf.data file. This includes
+ various information like hostname, OS and perf version, cpu/mem
+ info, perf command line, event list and so on. Currently only
+ --stdio output supports this feature.
+
+--header-only::
+ Show only perf.data header (forces --stdio).
+
SEE ALSO
--------
linkperf:perf-stat[1], linkperf:perf-annotate[1]
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 8cf8e66ba594..3a14dbed387c 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -49,6 +49,8 @@ struct perf_report {
bool show_threads;
bool inverted_callchain;
bool mem_mode;
+ bool header;
+ bool header_only;
int max_stack;
struct perf_read_values show_threads_values;
const char *pretty_printing_style;
@@ -514,9 +516,6 @@ static int __cmd_report(struct perf_report *rep)
return ret;
}
- if (use_browser <= 0)
- perf_session__fprintf_info(session, stdout, rep->show_full_info);
-
if (rep->show_threads)
perf_read_values_init(&rep->show_threads_values);
@@ -820,6 +819,9 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
OPT_BOOLEAN(0, "gtk", &report.use_gtk, "Use the GTK2 interface"),
OPT_BOOLEAN(0, "stdio", &report.use_stdio,
"Use the stdio interface"),
+ OPT_BOOLEAN(0, "header", &report.header, "Show data header."),
+ OPT_BOOLEAN(0, "header-only", &report.header_only,
+ "Show only data header."),
OPT_STRING('s', "sort", &sort_order, "key[,key2...]",
"sort by key(s): pid, comm, dso, symbol, parent, cpu, srcline,"
" dso_to, dso_from, symbol_to, symbol_from, mispredict,"
@@ -963,6 +965,10 @@ repeat:
goto error;
}
+ /* Force tty output for header output. */
+ if (report.header || report.header_only)
+ use_browser = 0;
+
if (strcmp(input_name, "-") != 0)
setup_browser(true);
else {
@@ -970,6 +976,16 @@ repeat:
perf_hpp__init();
}
+ if (report.header || report.header_only) {
+ perf_session__fprintf_info(session, stdout,
+ report.show_full_info);
+ if (report.header_only)
+ return 0;
+ } else if (use_browser == 0) {
+ fputs("# To display the perf.data header info, please use --header/--header-only options.\n#\n",
+ stdout);
+ }
+
/*
* Only in the TUI browser we are doing integrated annotation,
* so don't allocate extra space that won't be used in the stdio
--
1.8.1.4
^ permalink raw reply related [flat|nested] 17+ messages in thread* [PATCH 22/34] perf script: Add --header/--header-only options
2013-12-10 20:31 [GIT PULL 00/34] perf/core improvements and fixes Arnaldo Carvalho de Melo
2013-12-10 20:31 ` [PATCH 21/34 v2] perf report: Add --header/--header-only options Arnaldo Carvalho de Melo
@ 2013-12-10 20:31 ` Arnaldo Carvalho de Melo
2013-12-10 20:31 ` [PATCH 23/34] perf symbols: Rename [sl]name_alloc to match the members they refer to Arnaldo Carvalho de Melo
` (12 subsequent siblings)
14 siblings, 0 replies; 17+ messages in thread
From: Arnaldo Carvalho de Melo @ 2013-12-10 20:31 UTC (permalink / raw)
To: Ingo Molnar
Cc: linux-kernel, Jiri Olsa, Corey Ashford, David Ahern,
Frederic Weisbecker, Ingo Molnar, Namhyung Kim, Paul Mackerras,
Peter Zijlstra, Stephane Eranian, Arnaldo Carvalho de Melo
From: Jiri Olsa <jolsa@redhat.com>
Currently the perf.data header is always displayed for stdio output,
which is no always useful.
Disabling header information by default and adding following options to
control header output:
--header - display header information
--header-only - display header information only w/o further
processing
Signed-off-by: Jiri Olsa <jolsa@redhat.com>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1386583370-1699-3-git-send-email-jolsa@redhat.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/Documentation/perf-script.txt | 6 ++++++
tools/perf/builtin-script.c | 13 ++++++++++---
2 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/tools/perf/Documentation/perf-script.txt b/tools/perf/Documentation/perf-script.txt
index c2a5071cf8f8..05f9a0a6784c 100644
--- a/tools/perf/Documentation/perf-script.txt
+++ b/tools/perf/Documentation/perf-script.txt
@@ -209,6 +209,12 @@ OPTIONS
--show-mmap-events
Display mmap related events (e.g. MMAP, MMAP2).
+--header
+ Show perf.data header.
+
+--header-only
+ Show only perf.data header.
+
SEE ALSO
--------
linkperf:perf-record[1], linkperf:perf-script-perl[1],
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 7a571fb7eb8a..f8ab125aac48 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -1494,6 +1494,8 @@ static int have_cmd(int argc, const char **argv)
int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused)
{
bool show_full_info = false;
+ bool header = false;
+ bool header_only = false;
char *rec_script_path = NULL;
char *rep_script_path = NULL;
struct perf_session *session;
@@ -1532,6 +1534,8 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused)
OPT_STRING('i', "input", &input_name, "file", "input file name"),
OPT_BOOLEAN('d', "debug-mode", &debug_mode,
"do various checks like samples ordering and lost events"),
+ OPT_BOOLEAN(0, "header", &header, "Show data header."),
+ OPT_BOOLEAN(0, "header-only", &header_only, "Show only data header."),
OPT_STRING('k', "vmlinux", &symbol_conf.vmlinux_name,
"file", "vmlinux pathname"),
OPT_STRING(0, "kallsyms", &symbol_conf.kallsyms_name,
@@ -1748,6 +1752,12 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused)
if (session == NULL)
return -ENOMEM;
+ if (header || header_only) {
+ perf_session__fprintf_info(session, stdout, show_full_info);
+ if (header_only)
+ return 0;
+ }
+
script.session = session;
if (cpu_list) {
@@ -1755,9 +1765,6 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused)
return -1;
}
- if (!script_name && !generate_script_lang)
- perf_session__fprintf_info(session, stdout, show_full_info);
-
if (!no_callchain)
symbol_conf.use_callchain = true;
else
--
1.8.1.4
^ permalink raw reply related [flat|nested] 17+ messages in thread* [PATCH 23/34] perf symbols: Rename [sl]name_alloc to match the members they refer to
2013-12-10 20:31 [GIT PULL 00/34] perf/core improvements and fixes Arnaldo Carvalho de Melo
2013-12-10 20:31 ` [PATCH 21/34 v2] perf report: Add --header/--header-only options Arnaldo Carvalho de Melo
2013-12-10 20:31 ` [PATCH 22/34] perf script: " Arnaldo Carvalho de Melo
@ 2013-12-10 20:31 ` Arnaldo Carvalho de Melo
2013-12-10 20:31 ` [PATCH 24/34] perf machine: Don't open code assign dso->short_name Arnaldo Carvalho de Melo
` (11 subsequent siblings)
14 siblings, 0 replies; 17+ messages in thread
From: Arnaldo Carvalho de Melo @ 2013-12-10 20:31 UTC (permalink / raw)
To: Ingo Molnar
Cc: linux-kernel, Arnaldo Carvalho de Melo, Adrian Hunter,
David Ahern, Frederic Weisbecker, Jiri Olsa, Mike Galbraith,
Namhyung Kim, Paul Mackerras, Peter Zijlstra, Stephane Eranian
From: Arnaldo Carvalho de Melo <acme@redhat.com>
So we now have:
dso->short_name
dso->short_name_len
dso->short_name_allocated
Ditto for the 'long variants. To more quickly grasp what they refer to.
Suggested-by: Ingo Molnar <mingo@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-nu228f8vlp9w0lr7c0q77dqi@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/util/dso.c | 4 ++--
tools/perf/util/dso.h | 4 ++--
tools/perf/util/machine.c | 4 ++--
tools/perf/util/symbol.c | 6 +++---
4 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
index a0c7c591f4b2..55c983586b05 100644
--- a/tools/perf/util/dso.c
+++ b/tools/perf/util/dso.c
@@ -465,9 +465,9 @@ void dso__delete(struct dso *dso)
int i;
for (i = 0; i < MAP__NR_TYPES; ++i)
symbols__delete(&dso->symbols[i]);
- if (dso->sname_alloc)
+ if (dso->short_name_allocated)
free((char *)dso->short_name);
- if (dso->lname_alloc)
+ if (dso->long_name_allocated)
free(dso->long_name);
dso_cache__free(&dso->cache);
dso__free_a2l(dso);
diff --git a/tools/perf/util/dso.h b/tools/perf/util/dso.h
index 384f2d97e38e..00a232d89607 100644
--- a/tools/perf/util/dso.h
+++ b/tools/perf/util/dso.h
@@ -89,8 +89,8 @@ struct dso {
u8 has_srcline:1;
u8 hit:1;
u8 annotate_warned:1;
- u8 sname_alloc:1;
- u8 lname_alloc:1;
+ u8 short_name_allocated:1;
+ u8 long_name_allocated:1;
u8 sorted_by_name;
u8 loaded;
u8 rel;
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index bac817ab2068..f66f309a091a 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -764,7 +764,7 @@ static int map_groups__set_modules_path_dir(struct map_groups *mg,
goto out;
}
dso__set_long_name(map->dso, long_name);
- map->dso->lname_alloc = 1;
+ map->dso->long_name_allocated = 1;
dso__kernel_module_get_build_id(map->dso, "");
}
}
@@ -936,7 +936,7 @@ static int machine__process_kernel_mmap_event(struct machine *machine,
goto out_problem;
map->dso->short_name = name;
- map->dso->sname_alloc = 1;
+ map->dso->short_name_allocated = 1;
map->end = map->start + event->mmap.len;
} else if (is_kernel_mmap) {
const char *symbol_name = (event->mmap.filename +
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index de87dbac50a0..265a149bc43f 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -1458,7 +1458,7 @@ int dso__load_vmlinux_path(struct dso *dso, struct map *map,
if (filename != NULL) {
err = dso__load_vmlinux(dso, map, filename, filter);
if (err > 0) {
- dso->lname_alloc = 1;
+ dso->long_name_allocated = 1;
goto out;
}
free(filename);
@@ -1468,7 +1468,7 @@ int dso__load_vmlinux_path(struct dso *dso, struct map *map,
err = dso__load_vmlinux(dso, map, vmlinux_path[i], filter);
if (err > 0) {
dso__set_long_name(dso, strdup(vmlinux_path[i]));
- dso->lname_alloc = 1;
+ dso->long_name_allocated = 1;
break;
}
}
@@ -1612,7 +1612,7 @@ static int dso__load_kernel_sym(struct dso *dso, struct map *map,
if (err > 0) {
dso__set_long_name(dso,
strdup(symbol_conf.vmlinux_name));
- dso->lname_alloc = 1;
+ dso->long_name_allocated = 1;
return err;
}
return err;
--
1.8.1.4
^ permalink raw reply related [flat|nested] 17+ messages in thread* [PATCH 24/34] perf machine: Don't open code assign dso->short_name
2013-12-10 20:31 [GIT PULL 00/34] perf/core improvements and fixes Arnaldo Carvalho de Melo
` (2 preceding siblings ...)
2013-12-10 20:31 ` [PATCH 23/34] perf symbols: Rename [sl]name_alloc to match the members they refer to Arnaldo Carvalho de Melo
@ 2013-12-10 20:31 ` Arnaldo Carvalho de Melo
2013-12-10 20:31 ` [PATCH 25/34] perf symbols: Remove open coded management of short_name_allocated member Arnaldo Carvalho de Melo
` (10 subsequent siblings)
14 siblings, 0 replies; 17+ messages in thread
From: Arnaldo Carvalho de Melo @ 2013-12-10 20:31 UTC (permalink / raw)
To: Ingo Molnar
Cc: linux-kernel, Arnaldo Carvalho de Melo, Adrian Hunter,
David Ahern, Frederic Weisbecker, Jiri Olsa, Mike Galbraith,
Namhyung Kim, Paul Mackerras, Peter Zijlstra, Stephane Eranian
From: Arnaldo Carvalho de Melo <acme@redhat.com>
Use dso__set_short_name instead, as it will release any previously,
possibly allocated, short name.
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-1v39elw7v6nxczpntpp7ljwr@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/util/machine.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index f66f309a091a..f85da9a9a5d9 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -935,7 +935,7 @@ static int machine__process_kernel_mmap_event(struct machine *machine,
if (name == NULL)
goto out_problem;
- map->dso->short_name = name;
+ dso__set_short_name(map->dso, name);
map->dso->short_name_allocated = 1;
map->end = map->start + event->mmap.len;
} else if (is_kernel_mmap) {
--
1.8.1.4
^ permalink raw reply related [flat|nested] 17+ messages in thread* [PATCH 25/34] perf symbols: Remove open coded management of short_name_allocated member
2013-12-10 20:31 [GIT PULL 00/34] perf/core improvements and fixes Arnaldo Carvalho de Melo
` (3 preceding siblings ...)
2013-12-10 20:31 ` [PATCH 24/34] perf machine: Don't open code assign dso->short_name Arnaldo Carvalho de Melo
@ 2013-12-10 20:31 ` Arnaldo Carvalho de Melo
2013-12-10 20:31 ` [PATCH 26/34] perf symbols: Set alloc flag close to setting the long_name Arnaldo Carvalho de Melo
` (9 subsequent siblings)
14 siblings, 0 replies; 17+ messages in thread
From: Arnaldo Carvalho de Melo @ 2013-12-10 20:31 UTC (permalink / raw)
To: Ingo Molnar
Cc: linux-kernel, Adrian Hunter, Andi Kleen, David Ahern,
Dongsheng Yang, Frederic Weisbecker, Jiri Olsa, Mike Galbraith,
Namhyung Kim, Paul Mackerras, Peter Zijlstra, Stephane Eranian,
Steven Rostedt, Arnaldo Carvalho de Melo
From: Adrian Hunter <adrian.hunter@intel.com>
Instead of expecting callers to set this member accodingly so that later
at dso destruction it can, if needed, be correctly free()d, make it a
requirement by passing it as a parameter to dso__set_short_name.
Cc: Andi Kleen <ak@linux.intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
CC: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung.kim@lge.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Link: http://lkml.kernel.org/r/52A707A2.5020802@intel.com
[ Renamed the 'allocated' parameter to clearly indicate to which variable it refers to. ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/util/dso.c | 17 +++++++++++------
tools/perf/util/dso.h | 2 +-
tools/perf/util/machine.c | 3 +--
3 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
index 55c983586b05..f8c849767c4d 100644
--- a/tools/perf/util/dso.c
+++ b/tools/perf/util/dso.c
@@ -379,7 +379,7 @@ struct dso *dso__kernel_findnew(struct machine *machine, const char *name,
* processing we had no idea this was the kernel dso.
*/
if (dso != NULL) {
- dso__set_short_name(dso, short_name);
+ dso__set_short_name(dso, short_name, false);
dso->kernel = dso_type;
}
@@ -394,17 +394,22 @@ void dso__set_long_name(struct dso *dso, char *name)
dso->long_name_len = strlen(name);
}
-void dso__set_short_name(struct dso *dso, const char *name)
+void dso__set_short_name(struct dso *dso, const char *name, bool name_allocated)
{
if (name == NULL)
return;
- dso->short_name = name;
- dso->short_name_len = strlen(name);
+
+ if (dso->short_name_allocated)
+ free((char *)dso->short_name);
+
+ dso->short_name = name;
+ dso->short_name_len = strlen(name);
+ dso->short_name_allocated = name_allocated;
}
static void dso__set_basename(struct dso *dso)
{
- dso__set_short_name(dso, basename(dso->long_name));
+ dso__set_short_name(dso, basename(dso->long_name), false);
}
int dso__name_len(const struct dso *dso)
@@ -440,7 +445,7 @@ struct dso *dso__new(const char *name)
int i;
strcpy(dso->name, name);
dso__set_long_name(dso, dso->name);
- dso__set_short_name(dso, dso->name);
+ dso__set_short_name(dso, dso->name, false);
for (i = 0; i < MAP__NR_TYPES; ++i)
dso->symbols[i] = dso->symbol_names[i] = RB_ROOT;
dso->cache = RB_ROOT;
diff --git a/tools/perf/util/dso.h b/tools/perf/util/dso.h
index 00a232d89607..8eceab78088f 100644
--- a/tools/perf/util/dso.h
+++ b/tools/perf/util/dso.h
@@ -110,7 +110,7 @@ static inline void dso__set_loaded(struct dso *dso, enum map_type type)
struct dso *dso__new(const char *name);
void dso__delete(struct dso *dso);
-void dso__set_short_name(struct dso *dso, const char *name);
+void dso__set_short_name(struct dso *dso, const char *name, bool name_allocated);
void dso__set_long_name(struct dso *dso, char *name);
int dso__name_len(const struct dso *dso);
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index f85da9a9a5d9..09d5c66d4087 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -935,8 +935,7 @@ static int machine__process_kernel_mmap_event(struct machine *machine,
if (name == NULL)
goto out_problem;
- dso__set_short_name(map->dso, name);
- map->dso->short_name_allocated = 1;
+ dso__set_short_name(map->dso, name, true);
map->end = map->start + event->mmap.len;
} else if (is_kernel_mmap) {
const char *symbol_name = (event->mmap.filename +
--
1.8.1.4
^ permalink raw reply related [flat|nested] 17+ messages in thread* [PATCH 26/34] perf symbols: Set alloc flag close to setting the long_name
2013-12-10 20:31 [GIT PULL 00/34] perf/core improvements and fixes Arnaldo Carvalho de Melo
` (4 preceding siblings ...)
2013-12-10 20:31 ` [PATCH 25/34] perf symbols: Remove open coded management of short_name_allocated member Arnaldo Carvalho de Melo
@ 2013-12-10 20:31 ` Arnaldo Carvalho de Melo
2013-12-10 20:31 ` [PATCH 27/34] perf symbols: Remove open coded management of long_name_allocated member Arnaldo Carvalho de Melo
` (8 subsequent siblings)
14 siblings, 0 replies; 17+ messages in thread
From: Arnaldo Carvalho de Melo @ 2013-12-10 20:31 UTC (permalink / raw)
To: Ingo Molnar
Cc: linux-kernel, Arnaldo Carvalho de Melo, Adrian Hunter,
David Ahern, Frederic Weisbecker, Jiri Olsa, Mike Galbraith,
Namhyung Kim, Paul Mackerras, Peter Zijlstra, Stephane Eranian
From: Arnaldo Carvalho de Melo <acme@redhat.com>
This is a preparatory patch to do with dso__set_long_name what was done
with the short name variant.
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-mb7eqhkyejq1qcf3p22wz2x7@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/util/probe-event.c | 2 +-
tools/perf/util/symbol.c | 31 +++++++++++--------------------
tools/perf/util/symbol.h | 3 ++-
3 files changed, 14 insertions(+), 22 deletions(-)
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index 9c6989ca2bea..d7cff57945c2 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -154,7 +154,7 @@ static struct dso *kernel_get_module_dso(const char *module)
vmlinux_name = symbol_conf.vmlinux_name;
if (vmlinux_name) {
- if (dso__load_vmlinux(dso, map, vmlinux_name, NULL) <= 0)
+ if (dso__load_vmlinux(dso, map, vmlinux_name, false, NULL) <= 0)
return NULL;
} else {
if (dso__load_vmlinux_path(dso, map, NULL) <= 0) {
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index 265a149bc43f..9a5de8837d6d 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -1408,7 +1408,8 @@ struct map *map_groups__find_by_name(struct map_groups *mg,
}
int dso__load_vmlinux(struct dso *dso, struct map *map,
- const char *vmlinux, symbol_filter_t filter)
+ const char *vmlinux, bool vmlinux_allocated,
+ symbol_filter_t filter)
{
int err = -1;
struct symsrc ss;
@@ -1438,6 +1439,7 @@ int dso__load_vmlinux(struct dso *dso, struct map *map,
else
dso->data_type = DSO_BINARY_TYPE__VMLINUX;
dso__set_long_name(dso, (char *)vmlinux);
+ dso->long_name_allocated = vmlinux_allocated;
dso__set_loaded(dso, map->type);
pr_debug("Using %s for symbols\n", symfs_vmlinux);
}
@@ -1456,21 +1458,16 @@ int dso__load_vmlinux_path(struct dso *dso, struct map *map,
filename = dso__build_id_filename(dso, NULL, 0);
if (filename != NULL) {
- err = dso__load_vmlinux(dso, map, filename, filter);
- if (err > 0) {
- dso->long_name_allocated = 1;
+ err = dso__load_vmlinux(dso, map, filename, true, filter);
+ if (err > 0)
goto out;
- }
free(filename);
}
for (i = 0; i < vmlinux_path__nr_entries; ++i) {
- err = dso__load_vmlinux(dso, map, vmlinux_path[i], filter);
- if (err > 0) {
- dso__set_long_name(dso, strdup(vmlinux_path[i]));
- dso->long_name_allocated = 1;
+ err = dso__load_vmlinux(dso, map, vmlinux_path[i], false, filter);
+ if (err > 0)
break;
- }
}
out:
return err;
@@ -1607,15 +1604,8 @@ static int dso__load_kernel_sym(struct dso *dso, struct map *map,
}
if (!symbol_conf.ignore_vmlinux && symbol_conf.vmlinux_name != NULL) {
- err = dso__load_vmlinux(dso, map,
- symbol_conf.vmlinux_name, filter);
- if (err > 0) {
- dso__set_long_name(dso,
- strdup(symbol_conf.vmlinux_name));
- dso->long_name_allocated = 1;
- return err;
- }
- return err;
+ return dso__load_vmlinux(dso, map, symbol_conf.vmlinux_name,
+ false, filter);
}
if (!symbol_conf.ignore_vmlinux && vmlinux_path != NULL) {
@@ -1671,7 +1661,8 @@ static int dso__load_guest_kernel_sym(struct dso *dso, struct map *map,
*/
if (symbol_conf.default_guest_vmlinux_name != NULL) {
err = dso__load_vmlinux(dso, map,
- symbol_conf.default_guest_vmlinux_name, filter);
+ symbol_conf.default_guest_vmlinux_name,
+ false, filter);
return err;
}
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h
index f1031a1358a1..6de9c2b8a601 100644
--- a/tools/perf/util/symbol.h
+++ b/tools/perf/util/symbol.h
@@ -206,7 +206,8 @@ bool symsrc__possibly_runtime(struct symsrc *ss);
int dso__load(struct dso *dso, struct map *map, symbol_filter_t filter);
int dso__load_vmlinux(struct dso *dso, struct map *map,
- const char *vmlinux, symbol_filter_t filter);
+ const char *vmlinux, bool vmlinux_allocated,
+ symbol_filter_t filter);
int dso__load_vmlinux_path(struct dso *dso, struct map *map,
symbol_filter_t filter);
int dso__load_kallsyms(struct dso *dso, const char *filename, struct map *map,
--
1.8.1.4
^ permalink raw reply related [flat|nested] 17+ messages in thread* [PATCH 27/34] perf symbols: Remove open coded management of long_name_allocated member
2013-12-10 20:31 [GIT PULL 00/34] perf/core improvements and fixes Arnaldo Carvalho de Melo
` (5 preceding siblings ...)
2013-12-10 20:31 ` [PATCH 26/34] perf symbols: Set alloc flag close to setting the long_name Arnaldo Carvalho de Melo
@ 2013-12-10 20:31 ` Arnaldo Carvalho de Melo
2013-12-10 20:31 ` [PATCH 28/34] perf symbols: Constify dso->long_name Arnaldo Carvalho de Melo
` (7 subsequent siblings)
14 siblings, 0 replies; 17+ messages in thread
From: Arnaldo Carvalho de Melo @ 2013-12-10 20:31 UTC (permalink / raw)
To: Ingo Molnar
Cc: linux-kernel, Arnaldo Carvalho de Melo, Adrian Hunter,
David Ahern, Frederic Weisbecker, Jiri Olsa, Mike Galbraith,
Namhyung Kim, Paul Mackerras, Peter Zijlstra, Stephane Eranian
From: Arnaldo Carvalho de Melo <acme@redhat.com>
Instead of expecting callers to set this member accodingly so that later
at dso destruction it can, if needed, be correctly free()d, make it a
requirement by passing it as a parameter to dso__set_long_name.
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-na7t1tqim22vuqkt4zq5n4ri@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/util/dso.c | 13 +++++++++----
tools/perf/util/dso.h | 2 +-
tools/perf/util/machine.c | 3 +--
tools/perf/util/symbol.c | 9 ++++-----
tools/perf/util/vdso.c | 2 +-
5 files changed, 16 insertions(+), 13 deletions(-)
diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
index f8c849767c4d..ecb37d62f814 100644
--- a/tools/perf/util/dso.c
+++ b/tools/perf/util/dso.c
@@ -386,12 +386,17 @@ struct dso *dso__kernel_findnew(struct machine *machine, const char *name,
return dso;
}
-void dso__set_long_name(struct dso *dso, char *name)
+void dso__set_long_name(struct dso *dso, char *name, bool name_allocated)
{
if (name == NULL)
return;
- dso->long_name = name;
- dso->long_name_len = strlen(name);
+
+ if (dso->long_name_allocated)
+ free(dso->long_name);
+
+ dso->long_name = name;
+ dso->long_name_len = strlen(name);
+ dso->long_name_allocated = name_allocated;
}
void dso__set_short_name(struct dso *dso, const char *name, bool name_allocated)
@@ -444,7 +449,7 @@ struct dso *dso__new(const char *name)
if (dso != NULL) {
int i;
strcpy(dso->name, name);
- dso__set_long_name(dso, dso->name);
+ dso__set_long_name(dso, dso->name, false);
dso__set_short_name(dso, dso->name, false);
for (i = 0; i < MAP__NR_TYPES; ++i)
dso->symbols[i] = dso->symbol_names[i] = RB_ROOT;
diff --git a/tools/perf/util/dso.h b/tools/perf/util/dso.h
index 8eceab78088f..7b434691525a 100644
--- a/tools/perf/util/dso.h
+++ b/tools/perf/util/dso.h
@@ -111,7 +111,7 @@ struct dso *dso__new(const char *name);
void dso__delete(struct dso *dso);
void dso__set_short_name(struct dso *dso, const char *name, bool name_allocated);
-void dso__set_long_name(struct dso *dso, char *name);
+void dso__set_long_name(struct dso *dso, char *name, bool name_allocated);
int dso__name_len(const struct dso *dso);
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index 09d5c66d4087..751454bcde69 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -763,8 +763,7 @@ static int map_groups__set_modules_path_dir(struct map_groups *mg,
ret = -1;
goto out;
}
- dso__set_long_name(map->dso, long_name);
- map->dso->long_name_allocated = 1;
+ dso__set_long_name(map->dso, long_name, true);
dso__kernel_module_get_build_id(map->dso, "");
}
}
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index 9a5de8837d6d..5029ee1a9421 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -1159,7 +1159,7 @@ static int dso__load_kcore(struct dso *dso, struct map *map,
dso->data_type = DSO_BINARY_TYPE__GUEST_KCORE;
else
dso->data_type = DSO_BINARY_TYPE__KCORE;
- dso__set_long_name(dso, strdup(kcore_filename));
+ dso__set_long_name(dso, strdup(kcore_filename), true);
close(fd);
@@ -1438,8 +1438,7 @@ int dso__load_vmlinux(struct dso *dso, struct map *map,
dso->data_type = DSO_BINARY_TYPE__GUEST_VMLINUX;
else
dso->data_type = DSO_BINARY_TYPE__VMLINUX;
- dso__set_long_name(dso, (char *)vmlinux);
- dso->long_name_allocated = vmlinux_allocated;
+ dso__set_long_name(dso, (char *)vmlinux, vmlinux_allocated);
dso__set_loaded(dso, map->type);
pr_debug("Using %s for symbols\n", symfs_vmlinux);
}
@@ -1631,7 +1630,7 @@ do_kallsyms:
free(kallsyms_allocated_filename);
if (err > 0 && !dso__is_kcore(dso)) {
- dso__set_long_name(dso, strdup("[kernel.kallsyms]"));
+ dso__set_long_name(dso, strdup("[kernel.kallsyms]"), true);
map__fixup_start(map);
map__fixup_end(map);
}
@@ -1679,7 +1678,7 @@ static int dso__load_guest_kernel_sym(struct dso *dso, struct map *map,
pr_debug("Using %s for symbols\n", kallsyms_filename);
if (err > 0 && !dso__is_kcore(dso)) {
machine__mmap_name(machine, path, sizeof(path));
- dso__set_long_name(dso, strdup(path));
+ dso__set_long_name(dso, strdup(path), true);
map__fixup_start(map);
map__fixup_end(map);
}
diff --git a/tools/perf/util/vdso.c b/tools/perf/util/vdso.c
index 39159822d58f..0ddb3b8a89ec 100644
--- a/tools/perf/util/vdso.c
+++ b/tools/perf/util/vdso.c
@@ -103,7 +103,7 @@ struct dso *vdso__dso_findnew(struct list_head *head)
dso = dso__new(VDSO__MAP_NAME);
if (dso != NULL) {
dsos__add(head, dso);
- dso__set_long_name(dso, file);
+ dso__set_long_name(dso, file, false);
}
}
--
1.8.1.4
^ permalink raw reply related [flat|nested] 17+ messages in thread* [PATCH 28/34] perf symbols: Constify dso->long_name
2013-12-10 20:31 [GIT PULL 00/34] perf/core improvements and fixes Arnaldo Carvalho de Melo
` (6 preceding siblings ...)
2013-12-10 20:31 ` [PATCH 27/34] perf symbols: Remove open coded management of long_name_allocated member Arnaldo Carvalho de Melo
@ 2013-12-10 20:31 ` Arnaldo Carvalho de Melo
2013-12-10 20:31 ` [PATCH 29/34] perf symbols: Set freed members to NULL in dso destructor Arnaldo Carvalho de Melo
` (6 subsequent siblings)
14 siblings, 0 replies; 17+ messages in thread
From: Arnaldo Carvalho de Melo @ 2013-12-10 20:31 UTC (permalink / raw)
To: Ingo Molnar
Cc: linux-kernel, Arnaldo Carvalho de Melo, Adrian Hunter,
David Ahern, Frederic Weisbecker, Jiri Olsa, Mike Galbraith,
Namhyung Kim, Paul Mackerras, Peter Zijlstra, Stephane Eranian
From: Arnaldo Carvalho de Melo <acme@redhat.com>
Same reason as for dso->short_name, it may point to a const string, and
in most places it is treated as const, i.e. it is just accessed for
using its contents as a key or to show it on reports.
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-nf7mxf33zt5qw207pbxxryot@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/util/annotate.c | 2 +-
tools/perf/util/dso.c | 10 +++++-----
tools/perf/util/dso.h | 4 ++--
| 6 +++---
tools/perf/util/srcline.c | 2 +-
tools/perf/util/symbol.c | 4 ++--
6 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index cf6242c92ee2..0fcd81ea31ae 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -900,7 +900,7 @@ fallback:
* cache, or is just a kallsyms file, well, lets hope that this
* DSO is the same as when 'perf record' ran.
*/
- filename = dso->long_name;
+ filename = (char *)dso->long_name;
snprintf(symfs_filename, sizeof(symfs_filename), "%s%s",
symbol_conf.symfs, filename);
free_filename = false;
diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
index ecb37d62f814..2c7e1899a735 100644
--- a/tools/perf/util/dso.c
+++ b/tools/perf/util/dso.c
@@ -67,7 +67,7 @@ int dso__binary_type_file(struct dso *dso, enum dso_binary_type type,
case DSO_BINARY_TYPE__OPENEMBEDDED_DEBUGINFO:
{
- char *last_slash;
+ const char *last_slash;
size_t len;
size_t dir_size;
@@ -386,13 +386,13 @@ struct dso *dso__kernel_findnew(struct machine *machine, const char *name,
return dso;
}
-void dso__set_long_name(struct dso *dso, char *name, bool name_allocated)
+void dso__set_long_name(struct dso *dso, const char *name, bool name_allocated)
{
if (name == NULL)
return;
if (dso->long_name_allocated)
- free(dso->long_name);
+ free((char *)dso->long_name);
dso->long_name = name;
dso->long_name_len = strlen(name);
@@ -414,7 +414,7 @@ void dso__set_short_name(struct dso *dso, const char *name, bool name_allocated)
static void dso__set_basename(struct dso *dso)
{
- dso__set_short_name(dso, basename(dso->long_name), false);
+ dso__set_short_name(dso, basename((char *)dso->long_name), false);
}
int dso__name_len(const struct dso *dso)
@@ -478,7 +478,7 @@ void dso__delete(struct dso *dso)
if (dso->short_name_allocated)
free((char *)dso->short_name);
if (dso->long_name_allocated)
- free(dso->long_name);
+ free((char *)dso->long_name);
dso_cache__free(&dso->cache);
dso__free_a2l(dso);
free(dso->symsrc_filename);
diff --git a/tools/perf/util/dso.h b/tools/perf/util/dso.h
index 7b434691525a..a2d71292f746 100644
--- a/tools/perf/util/dso.h
+++ b/tools/perf/util/dso.h
@@ -96,7 +96,7 @@ struct dso {
u8 rel;
u8 build_id[BUILD_ID_SIZE];
const char *short_name;
- char *long_name;
+ const char *long_name;
u16 long_name_len;
u16 short_name_len;
char name[0];
@@ -111,7 +111,7 @@ struct dso *dso__new(const char *name);
void dso__delete(struct dso *dso);
void dso__set_short_name(struct dso *dso, const char *name, bool name_allocated);
-void dso__set_long_name(struct dso *dso, char *name, bool name_allocated);
+void dso__set_long_name(struct dso *dso, const char *name, bool name_allocated);
int dso__name_len(const struct dso *dso);
--git a/tools/perf/util/header.c b/tools/perf/util/header.c
index 125cdc9250ee..0bb830f6b49c 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -177,7 +177,7 @@ perf_header__set_cmdline(int argc, const char **argv)
continue; \
else
-static int write_buildid(char *name, size_t name_len, u8 *build_id,
+static int write_buildid(const char *name, size_t name_len, u8 *build_id,
pid_t pid, u16 misc, int fd)
{
int err;
@@ -209,7 +209,7 @@ static int __dsos__write_buildid_table(struct list_head *head,
dsos__for_each_with_build_id(pos, head) {
int err;
- char *name;
+ const char *name;
size_t name_len;
if (!pos->hit)
@@ -387,7 +387,7 @@ static int dso__cache_build_id(struct dso *dso, struct machine *machine,
{
bool is_kallsyms = dso->kernel && dso->long_name[0] != '/';
bool is_vdso = is_vdso_map(dso->short_name);
- char *name = dso->long_name;
+ const char *name = dso->long_name;
char nm[PATH_MAX];
if (dso__is_kcore(dso)) {
diff --git a/tools/perf/util/srcline.c b/tools/perf/util/srcline.c
index 0c075560ad46..58b2bd8f38c9 100644
--- a/tools/perf/util/srcline.c
+++ b/tools/perf/util/srcline.c
@@ -255,7 +255,7 @@ char *get_srcline(struct dso *dso, unsigned long addr)
char *file = NULL;
unsigned line = 0;
char *srcline;
- char *dso_name;
+ const char *dso_name;
if (!dso->has_srcline)
return SRCLINE_UNKNOWN;
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index 5029ee1a9421..e377c2e96191 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -1438,7 +1438,7 @@ int dso__load_vmlinux(struct dso *dso, struct map *map,
dso->data_type = DSO_BINARY_TYPE__GUEST_VMLINUX;
else
dso->data_type = DSO_BINARY_TYPE__VMLINUX;
- dso__set_long_name(dso, (char *)vmlinux, vmlinux_allocated);
+ dso__set_long_name(dso, vmlinux, vmlinux_allocated);
dso__set_loaded(dso, map->type);
pr_debug("Using %s for symbols\n", symfs_vmlinux);
}
@@ -1630,7 +1630,7 @@ do_kallsyms:
free(kallsyms_allocated_filename);
if (err > 0 && !dso__is_kcore(dso)) {
- dso__set_long_name(dso, strdup("[kernel.kallsyms]"), true);
+ dso__set_long_name(dso, "[kernel.kallsyms]", false);
map__fixup_start(map);
map__fixup_end(map);
}
--
1.8.1.4
^ permalink raw reply related [flat|nested] 17+ messages in thread* [PATCH 29/34] perf symbols: Set freed members to NULL in dso destructor
2013-12-10 20:31 [GIT PULL 00/34] perf/core improvements and fixes Arnaldo Carvalho de Melo
` (7 preceding siblings ...)
2013-12-10 20:31 ` [PATCH 28/34] perf symbols: Constify dso->long_name Arnaldo Carvalho de Melo
@ 2013-12-10 20:31 ` Arnaldo Carvalho de Melo
2013-12-10 20:31 ` [PATCH 30/34] perf symbols: Constify some DSO methods parameters Arnaldo Carvalho de Melo
` (5 subsequent siblings)
14 siblings, 0 replies; 17+ messages in thread
From: Arnaldo Carvalho de Melo @ 2013-12-10 20:31 UTC (permalink / raw)
To: Ingo Molnar
Cc: linux-kernel, Arnaldo Carvalho de Melo, Adrian Hunter,
David Ahern, Frederic Weisbecker, Jiri Olsa, Mike Galbraith,
Namhyung Kim, Paul Mackerras, Peter Zijlstra, Stephane Eranian
From: Arnaldo Carvalho de Melo <acme@redhat.com>
To help in debugging use after free bugs.
Reported-by: Ingo Molnar <mingo@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-3ckwsob2g1q23s77nuhexrq7@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/util/dso.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
index 2c7e1899a735..19babb0d365d 100644
--- a/tools/perf/util/dso.c
+++ b/tools/perf/util/dso.c
@@ -475,13 +475,23 @@ void dso__delete(struct dso *dso)
int i;
for (i = 0; i < MAP__NR_TYPES; ++i)
symbols__delete(&dso->symbols[i]);
- if (dso->short_name_allocated)
+
+ if (dso->short_name_allocated) {
free((char *)dso->short_name);
- if (dso->long_name_allocated)
+ dso->short_name = NULL;
+ dso->short_name_allocated = false;
+ }
+
+ if (dso->long_name_allocated) {
free((char *)dso->long_name);
+ dso->long_name = NULL;
+ dso->long_name_allocated = false;
+ }
+
dso_cache__free(&dso->cache);
dso__free_a2l(dso);
free(dso->symsrc_filename);
+ dso->symsrc_filename = NULL;
free(dso);
}
--
1.8.1.4
^ permalink raw reply related [flat|nested] 17+ messages in thread* [PATCH 30/34] perf symbols: Constify some DSO methods parameters
2013-12-10 20:31 [GIT PULL 00/34] perf/core improvements and fixes Arnaldo Carvalho de Melo
` (8 preceding siblings ...)
2013-12-10 20:31 ` [PATCH 29/34] perf symbols: Set freed members to NULL in dso destructor Arnaldo Carvalho de Melo
@ 2013-12-10 20:31 ` Arnaldo Carvalho de Melo
2013-12-10 20:31 ` [PATCH 31/34] perf symbols: Rename filename argument Arnaldo Carvalho de Melo
` (4 subsequent siblings)
14 siblings, 0 replies; 17+ messages in thread
From: Arnaldo Carvalho de Melo @ 2013-12-10 20:31 UTC (permalink / raw)
To: Ingo Molnar
Cc: linux-kernel, Arnaldo Carvalho de Melo, Adrian Hunter,
David Ahern, Frederic Weisbecker, Jiri Olsa, Mike Galbraith,
Namhyung Kim, Paul Mackerras, Peter Zijlstra, Stephane Eranian
From: Arnaldo Carvalho de Melo <acme@redhat.com>
Those methods are not supposed to change the data structures they
manipulate, so make that clearer by using the const qualifier in the
function signature and in some variables.
Suggested-by: Ingo Molnar <mingo@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-j7oyakex7zy3r82h33rdw25x@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/util/build-id.c | 2 +-
tools/perf/util/build-id.h | 2 +-
tools/perf/util/dso.c | 11 +++++------
tools/perf/util/dso.h | 4 ++--
4 files changed, 9 insertions(+), 10 deletions(-)
diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c
index a92770c98cc7..6baabe63182b 100644
--- a/tools/perf/util/build-id.c
+++ b/tools/perf/util/build-id.c
@@ -89,7 +89,7 @@ int build_id__sprintf(const u8 *build_id, int len, char *bf)
return raw - build_id;
}
-char *dso__build_id_filename(struct dso *dso, char *bf, size_t size)
+char *dso__build_id_filename(const struct dso *dso, char *bf, size_t size)
{
char build_id_hex[BUILD_ID_SIZE * 2 + 1];
diff --git a/tools/perf/util/build-id.h b/tools/perf/util/build-id.h
index 929f28a7c14d..845ef865eced 100644
--- a/tools/perf/util/build-id.h
+++ b/tools/perf/util/build-id.h
@@ -10,7 +10,7 @@ extern struct perf_tool build_id__mark_dso_hit_ops;
struct dso;
int build_id__sprintf(const u8 *build_id, int len, char *bf);
-char *dso__build_id_filename(struct dso *dso, char *bf, size_t size);
+char *dso__build_id_filename(const struct dso *dso, char *bf, size_t size);
int build_id__mark_dso_hit(struct perf_tool *tool, union perf_event *event,
struct perf_sample *sample, struct perf_evsel *evsel,
diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
index 19babb0d365d..fbc66fde6b30 100644
--- a/tools/perf/util/dso.c
+++ b/tools/perf/util/dso.c
@@ -28,7 +28,7 @@ char dso__symtab_origin(const struct dso *dso)
return origin[dso->symtab_type];
}
-int dso__binary_type_file(struct dso *dso, enum dso_binary_type type,
+int dso__binary_type_file(const struct dso *dso, enum dso_binary_type type,
char *root_dir, char *file, size_t size)
{
char build_id_hex[BUILD_ID_SIZE * 2 + 1];
@@ -200,11 +200,10 @@ dso_cache__free(struct rb_root *root)
}
}
-static struct dso_cache*
-dso_cache__find(struct rb_root *root, u64 offset)
+static struct dso_cache *dso_cache__find(const struct rb_root *root, u64 offset)
{
- struct rb_node **p = &root->rb_node;
- struct rb_node *parent = NULL;
+ struct rb_node * const *p = &root->rb_node;
+ const struct rb_node *parent = NULL;
struct dso_cache *cache;
while (*p != NULL) {
@@ -566,7 +565,7 @@ void dsos__add(struct list_head *head, struct dso *dso)
list_add_tail(&dso->node, head);
}
-struct dso *dsos__find(struct list_head *head, const char *name, bool cmp_short)
+struct dso *dsos__find(const struct list_head *head, const char *name, bool cmp_short)
{
struct dso *pos;
diff --git a/tools/perf/util/dso.h b/tools/perf/util/dso.h
index a2d71292f746..99f3c647d683 100644
--- a/tools/perf/util/dso.h
+++ b/tools/perf/util/dso.h
@@ -128,7 +128,7 @@ void dso__read_running_kernel_build_id(struct dso *dso,
int dso__kernel_module_get_build_id(struct dso *dso, const char *root_dir);
char dso__symtab_origin(const struct dso *dso);
-int dso__binary_type_file(struct dso *dso, enum dso_binary_type type,
+int dso__binary_type_file(const struct dso *dso, enum dso_binary_type type,
char *root_dir, char *file, size_t size);
int dso__data_fd(struct dso *dso, struct machine *machine);
@@ -143,7 +143,7 @@ struct dso *dso__kernel_findnew(struct machine *machine, const char *name,
const char *short_name, int dso_type);
void dsos__add(struct list_head *head, struct dso *dso);
-struct dso *dsos__find(struct list_head *head, const char *name,
+struct dso *dsos__find(const struct list_head *head, const char *name,
bool cmp_short);
struct dso *__dsos__findnew(struct list_head *head, const char *name);
bool __dsos__read_build_ids(struct list_head *head, bool with_hits);
--
1.8.1.4
^ permalink raw reply related [flat|nested] 17+ messages in thread* [PATCH 31/34] perf symbols: Rename filename argument
2013-12-10 20:31 [GIT PULL 00/34] perf/core improvements and fixes Arnaldo Carvalho de Melo
` (9 preceding siblings ...)
2013-12-10 20:31 ` [PATCH 30/34] perf symbols: Constify some DSO methods parameters Arnaldo Carvalho de Melo
@ 2013-12-10 20:31 ` Arnaldo Carvalho de Melo
2013-12-10 20:31 ` [PATCH 32/34 v3] perf symbols: Fix bug in usage of the basename() function Arnaldo Carvalho de Melo
` (3 subsequent siblings)
14 siblings, 0 replies; 17+ messages in thread
From: Arnaldo Carvalho de Melo @ 2013-12-10 20:31 UTC (permalink / raw)
To: Ingo Molnar
Cc: linux-kernel, Arnaldo Carvalho de Melo, Adrian Hunter,
David Ahern, Frederic Weisbecker, Jiri Olsa, Mike Galbraith,
Namhyung Kim, Paul Mackerras, Peter Zijlstra, Stephane Eranian
From: Arnaldo Carvalho de Melo <acme@redhat.com>
The 'file' is more commonly associated with a file descriptor of
some sort, rename it to 'filename' as this is the more common idiom
for a file name argument.
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-0ehaawv5xc83w6ag03c5hi10@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/util/dso.c | 32 ++++++++++++++++----------------
tools/perf/util/dso.h | 2 +-
2 files changed, 17 insertions(+), 17 deletions(-)
diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
index fbc66fde6b30..582b5d344aa3 100644
--- a/tools/perf/util/dso.c
+++ b/tools/perf/util/dso.c
@@ -29,7 +29,7 @@ char dso__symtab_origin(const struct dso *dso)
}
int dso__binary_type_file(const struct dso *dso, enum dso_binary_type type,
- char *root_dir, char *file, size_t size)
+ char *root_dir, char *filename, size_t size)
{
char build_id_hex[BUILD_ID_SIZE * 2 + 1];
int ret = 0;
@@ -38,30 +38,30 @@ int dso__binary_type_file(const struct dso *dso, enum dso_binary_type type,
case DSO_BINARY_TYPE__DEBUGLINK: {
char *debuglink;
- strncpy(file, dso->long_name, size);
- debuglink = file + dso->long_name_len;
- while (debuglink != file && *debuglink != '/')
+ strncpy(filename, dso->long_name, size);
+ debuglink = filename + dso->long_name_len;
+ while (debuglink != filename && *debuglink != '/')
debuglink--;
if (*debuglink == '/')
debuglink++;
filename__read_debuglink(dso->long_name, debuglink,
- size - (debuglink - file));
+ size - (debuglink - filename));
}
break;
case DSO_BINARY_TYPE__BUILD_ID_CACHE:
/* skip the locally configured cache if a symfs is given */
if (symbol_conf.symfs[0] ||
- (dso__build_id_filename(dso, file, size) == NULL))
+ (dso__build_id_filename(dso, filename, size) == NULL))
ret = -1;
break;
case DSO_BINARY_TYPE__FEDORA_DEBUGINFO:
- snprintf(file, size, "%s/usr/lib/debug%s.debug",
+ snprintf(filename, size, "%s/usr/lib/debug%s.debug",
symbol_conf.symfs, dso->long_name);
break;
case DSO_BINARY_TYPE__UBUNTU_DEBUGINFO:
- snprintf(file, size, "%s/usr/lib/debug%s",
+ snprintf(filename, size, "%s/usr/lib/debug%s",
symbol_conf.symfs, dso->long_name);
break;
@@ -75,14 +75,14 @@ int dso__binary_type_file(const struct dso *dso, enum dso_binary_type type,
while (last_slash != dso->long_name && *last_slash != '/')
last_slash--;
- len = scnprintf(file, size, "%s", symbol_conf.symfs);
+ len = scnprintf(filename, size, "%s", symbol_conf.symfs);
dir_size = last_slash - dso->long_name + 2;
if (dir_size > (size - len)) {
ret = -1;
break;
}
- len += scnprintf(file + len, dir_size, "%s", dso->long_name);
- len += scnprintf(file + len , size - len, ".debug%s",
+ len += scnprintf(filename + len, dir_size, "%s", dso->long_name);
+ len += scnprintf(filename + len , size - len, ".debug%s",
last_slash);
break;
}
@@ -96,7 +96,7 @@ int dso__binary_type_file(const struct dso *dso, enum dso_binary_type type,
build_id__sprintf(dso->build_id,
sizeof(dso->build_id),
build_id_hex);
- snprintf(file, size,
+ snprintf(filename, size,
"%s/usr/lib/debug/.build-id/%.2s/%s.debug",
symbol_conf.symfs, build_id_hex, build_id_hex + 2);
break;
@@ -104,23 +104,23 @@ int dso__binary_type_file(const struct dso *dso, enum dso_binary_type type,
case DSO_BINARY_TYPE__VMLINUX:
case DSO_BINARY_TYPE__GUEST_VMLINUX:
case DSO_BINARY_TYPE__SYSTEM_PATH_DSO:
- snprintf(file, size, "%s%s",
+ snprintf(filename, size, "%s%s",
symbol_conf.symfs, dso->long_name);
break;
case DSO_BINARY_TYPE__GUEST_KMODULE:
- snprintf(file, size, "%s%s%s", symbol_conf.symfs,
+ snprintf(filename, size, "%s%s%s", symbol_conf.symfs,
root_dir, dso->long_name);
break;
case DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE:
- snprintf(file, size, "%s%s", symbol_conf.symfs,
+ snprintf(filename, size, "%s%s", symbol_conf.symfs,
dso->long_name);
break;
case DSO_BINARY_TYPE__KCORE:
case DSO_BINARY_TYPE__GUEST_KCORE:
- snprintf(file, size, "%s", dso->long_name);
+ snprintf(filename, size, "%s", dso->long_name);
break;
default:
diff --git a/tools/perf/util/dso.h b/tools/perf/util/dso.h
index 99f3c647d683..e1cc50698137 100644
--- a/tools/perf/util/dso.h
+++ b/tools/perf/util/dso.h
@@ -129,7 +129,7 @@ int dso__kernel_module_get_build_id(struct dso *dso, const char *root_dir);
char dso__symtab_origin(const struct dso *dso);
int dso__binary_type_file(const struct dso *dso, enum dso_binary_type type,
- char *root_dir, char *file, size_t size);
+ char *root_dir, char *filename, size_t size);
int dso__data_fd(struct dso *dso, struct machine *machine);
ssize_t dso__data_read_offset(struct dso *dso, struct machine *machine,
--
1.8.1.4
^ permalink raw reply related [flat|nested] 17+ messages in thread* [PATCH 32/34 v3] perf symbols: Fix bug in usage of the basename() function
2013-12-10 20:31 [GIT PULL 00/34] perf/core improvements and fixes Arnaldo Carvalho de Melo
` (10 preceding siblings ...)
2013-12-10 20:31 ` [PATCH 31/34] perf symbols: Rename filename argument Arnaldo Carvalho de Melo
@ 2013-12-10 20:31 ` Arnaldo Carvalho de Melo
2013-12-10 20:31 ` [PATCH 33/34] perf tools: Add per-feature check flags Arnaldo Carvalho de Melo
` (2 subsequent siblings)
14 siblings, 0 replies; 17+ messages in thread
From: Arnaldo Carvalho de Melo @ 2013-12-10 20:31 UTC (permalink / raw)
To: Ingo Molnar
Cc: linux-kernel, Stephane Eranian, Ben Cheng, David Ahern, Jiri Olsa,
Peter Zijlstra, Arnaldo Carvalho de Melo
From: Stephane Eranian <eranian@google.com>
The basename() implementation varies a lot between systems.
The Linux man page says: "basename may modify the content of the path,
so it may be desirable to pass a copy when calling the function".
On some other systems, the returned address may come from an internal
buffer which can be reused in subsequent calls, thus the results should
also be copied.
The dso__set_basename() function was not doing this causing problems
on some systems with wrong library names being shown by perf report,
such as on Android systems.
This patch fixes the problem.
The patch is relative to tip.git.
In v2, we clean up the comments based on Ingo's feedback.
Reported-by: Ben Cheng <bccheng@google.com>
Signed-off-by: Stephane Eranian <eranian@google.com>
Acked-by: Ingo Molnar <mingo@kernel.org>
Cc: Ben Cheng <bccheng@google.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20131205182642.GA14614@quad
[ v3: Fixed up wrt allocated flag now being set in dso__set_short_name ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/util/dso.c | 23 ++++++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)
diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
index 582b5d344aa3..436922f1f9d9 100644
--- a/tools/perf/util/dso.c
+++ b/tools/perf/util/dso.c
@@ -413,7 +413,28 @@ void dso__set_short_name(struct dso *dso, const char *name, bool name_allocated)
static void dso__set_basename(struct dso *dso)
{
- dso__set_short_name(dso, basename((char *)dso->long_name), false);
+ /*
+ * basename() may modify path buffer, so we must pass
+ * a copy.
+ */
+ char *base, *lname = strdup(dso->long_name);
+
+ if (!lname)
+ return;
+
+ /*
+ * basename() may return a pointer to internal
+ * storage which is reused in subsequent calls
+ * so copy the result.
+ */
+ base = strdup(basename(lname));
+
+ free(lname);
+
+ if (!base)
+ return;
+
+ dso__set_short_name(dso, base, true);
}
int dso__name_len(const struct dso *dso)
--
1.8.1.4
^ permalink raw reply related [flat|nested] 17+ messages in thread* [PATCH 33/34] perf tools: Add per-feature check flags
2013-12-10 20:31 [GIT PULL 00/34] perf/core improvements and fixes Arnaldo Carvalho de Melo
` (11 preceding siblings ...)
2013-12-10 20:31 ` [PATCH 32/34 v3] perf symbols: Fix bug in usage of the basename() function Arnaldo Carvalho de Melo
@ 2013-12-10 20:31 ` Arnaldo Carvalho de Melo
2013-12-10 20:31 ` [PATCH 34/34] perf unwinding: Use the " Arnaldo Carvalho de Melo
2013-12-11 11:01 ` [GIT PULL 00/34] perf/core improvements and fixes Ingo Molnar
14 siblings, 0 replies; 17+ messages in thread
From: Arnaldo Carvalho de Melo @ 2013-12-10 20:31 UTC (permalink / raw)
To: Ingo Molnar
Cc: linux-kernel, Jean Pihet, Jiri Olsa, Will Deacon, linaro-kernel,
patches, Arnaldo Carvalho de Melo
From: Jean Pihet <jean.pihet@linaro.org>
Add CFLAGS and LDFLAGS for each feature to be checked. This allows to
pass flags and parameters to the feature checks compilation. Also
simplifies the feature check makefile, to come in a subsequent patch.
Signed-off-by: Jean Pihet <jean.pihet@linaro.org>
Acked-by: Ingo Molnar <mingo@kernel.org>
Acked-by: Jiri Olsa <jolsa@redhat.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Will Deacon <will.deacon@arm.com>
Cc: linaro-kernel@lists.linaro.org
Cc: patches@linaro.org
Link: http://lkml.kernel.org/r/1386678244-13535-2-git-send-email-jean.pihet@linaro.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/config/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index bae10720a136..2afb132db51a 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -102,7 +102,7 @@ endif
feature_check = $(eval $(feature_check_code))
define feature_check_code
- feature-$(1) := $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) CFLAGS="$(EXTRA_CFLAGS)" LDFLAGS="$(LDFLAGS)" LIBUNWIND_LIBS="$(LIBUNWIND_LIBS)" -C config/feature-checks test-$1 >/dev/null 2>/dev/null && echo 1 || echo 0)
+ feature-$(1) := $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) CFLAGS="$(EXTRA_CFLAGS) $(FEATURE_CHECK_CFLAGS-$(1))" LDFLAGS="$(LDFLAGS) $(FEATURE_CHECK_LDFLAGS-$(1))" LIBUNWIND_LIBS="$(LIBUNWIND_LIBS)" -C config/feature-checks test-$1 >/dev/null 2>/dev/null && echo 1 || echo 0)
endef
feature_set = $(eval $(feature_set_code))
--
1.8.1.4
^ permalink raw reply related [flat|nested] 17+ messages in thread* [PATCH 34/34] perf unwinding: Use the per-feature check flags
2013-12-10 20:31 [GIT PULL 00/34] perf/core improvements and fixes Arnaldo Carvalho de Melo
` (12 preceding siblings ...)
2013-12-10 20:31 ` [PATCH 33/34] perf tools: Add per-feature check flags Arnaldo Carvalho de Melo
@ 2013-12-10 20:31 ` Arnaldo Carvalho de Melo
2013-12-11 11:01 ` [GIT PULL 00/34] perf/core improvements and fixes Ingo Molnar
14 siblings, 0 replies; 17+ messages in thread
From: Arnaldo Carvalho de Melo @ 2013-12-10 20:31 UTC (permalink / raw)
To: Ingo Molnar
Cc: linux-kernel, Jean Pihet, Jiri Olsa, Will Deacon, linaro-kernel,
patches, Arnaldo Carvalho de Melo
From: Jean Pihet <jean.pihet@linaro.org>
Use the per-feature check flags for the unwinding feature in order to
correctly compile the test-all, libunwind and libunwind-debug-frame
feature checks.
Tested on x86_64, ARMv7 and ARMv8 with and without LIBUNWIND_DIR set in
'make -C tools/perf'
Signed-off-by: Jean Pihet <jean.pihet@linaro.org>
Acked-by: Ingo Molnar <mingo@kernel.org>
Acked-by: Jiri Olsa <jolsa@redhat.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Will Deacon <will.deacon@arm.com>
Cc: linaro-kernel@lists.linaro.org
Cc: patches@linaro.org
Link: http://lkml.kernel.org/r/1386678244-13535-3-git-send-email-jean.pihet@linaro.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/config/Makefile | 52 ++++++++++++++++++-------------
tools/perf/config/feature-checks/Makefile | 8 ++---
2 files changed, 34 insertions(+), 26 deletions(-)
diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 2afb132db51a..5a1f4df3c3a8 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -36,6 +36,30 @@ ifeq ($(ARCH),arm)
LIBUNWIND_LIBS = -lunwind -lunwind-arm
endif
+ifeq ($(LIBUNWIND_LIBS),)
+ NO_LIBUNWIND := 1
+else
+ #
+ # For linking with debug library, run like:
+ #
+ # make DEBUG=1 LIBUNWIND_DIR=/opt/libunwind/
+ #
+ ifdef LIBUNWIND_DIR
+ LIBUNWIND_CFLAGS = -I$(LIBUNWIND_DIR)/include
+ LIBUNWIND_LDFLAGS = -L$(LIBUNWIND_DIR)/lib
+ endif
+ LIBUNWIND_LDFLAGS += $(LIBUNWIND_LIBS)
+
+ # Set per-feature check compilation flags
+ FEATURE_CHECK_CFLAGS-libunwind = $(LIBUNWIND_CFLAGS)
+ FEATURE_CHECK_LDFLAGS-libunwind = $(LIBUNWIND_LDFLAGS)
+ FEATURE_CHECK_CFLAGS-libunwind-debug-frame = $(LIBUNWIND_CFLAGS)
+ FEATURE_CHECK_LDFLAGS-libunwind-debug-frame = $(LIBUNWIND_LDFLAGS)
+ # and the flags for the test-all case
+ FEATURE_CHECK_CFLAGS-all += $(LIBUNWIND_CFLAGS)
+ FEATURE_CHECK_LDFLAGS-all += $(LIBUNWIND_LDFLAGS)
+endif
+
ifeq ($(NO_PERF_REGS),0)
CFLAGS += -DHAVE_PERF_REGS_SUPPORT
endif
@@ -102,7 +126,7 @@ endif
feature_check = $(eval $(feature_check_code))
define feature_check_code
- feature-$(1) := $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) CFLAGS="$(EXTRA_CFLAGS) $(FEATURE_CHECK_CFLAGS-$(1))" LDFLAGS="$(LDFLAGS) $(FEATURE_CHECK_LDFLAGS-$(1))" LIBUNWIND_LIBS="$(LIBUNWIND_LIBS)" -C config/feature-checks test-$1 >/dev/null 2>/dev/null && echo 1 || echo 0)
+ feature-$(1) := $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) CFLAGS="$(EXTRA_CFLAGS) $(FEATURE_CHECK_CFLAGS-$(1))" LDFLAGS="$(LDFLAGS) $(FEATURE_CHECK_LDFLAGS-$(1))" -C config/feature-checks test-$1 >/dev/null 2>/dev/null && echo 1 || echo 0)
endef
feature_set = $(eval $(feature_set_code))
@@ -305,21 +329,7 @@ ifndef NO_LIBELF
endif # NO_DWARF
endif # NO_LIBELF
-ifeq ($(LIBUNWIND_LIBS),)
- NO_LIBUNWIND := 1
-endif
-
ifndef NO_LIBUNWIND
- #
- # For linking with debug library, run like:
- #
- # make DEBUG=1 LIBUNWIND_DIR=/opt/libunwind/
- #
- ifdef LIBUNWIND_DIR
- LIBUNWIND_CFLAGS := -I$(LIBUNWIND_DIR)/include
- LIBUNWIND_LDFLAGS := -L$(LIBUNWIND_DIR)/lib
- endif
-
ifneq ($(feature-libunwind), 1)
msg := $(warning No libunwind found, disabling post unwind support. Please install libunwind-dev[el] >= 1.1);
NO_LIBUNWIND := 1
@@ -334,14 +344,12 @@ ifndef NO_LIBUNWIND
# non-ARM has no dwarf_find_debug_frame() function:
CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME
endif
- endif
-endif
-ifndef NO_LIBUNWIND
- CFLAGS += -DHAVE_LIBUNWIND_SUPPORT
- EXTLIBS += $(LIBUNWIND_LIBS)
- CFLAGS += $(LIBUNWIND_CFLAGS)
- LDFLAGS += $(LIBUNWIND_LDFLAGS)
+ CFLAGS += -DHAVE_LIBUNWIND_SUPPORT
+ EXTLIBS += $(LIBUNWIND_LIBS)
+ CFLAGS += $(LIBUNWIND_CFLAGS)
+ LDFLAGS += $(LIBUNWIND_LDFLAGS)
+ endif # ifneq ($(feature-libunwind), 1)
endif
ifndef NO_LIBAUDIT
diff --git a/tools/perf/config/feature-checks/Makefile b/tools/perf/config/feature-checks/Makefile
index b8bb749c3392..bc86462e80a2 100644
--- a/tools/perf/config/feature-checks/Makefile
+++ b/tools/perf/config/feature-checks/Makefile
@@ -32,12 +32,12 @@ CC := $(CC) -MD
all: $(FILES)
-BUILD = $(CC) $(CFLAGS) $(LDFLAGS) -o $(OUTPUT)$@ $@.c
+BUILD = $(CC) $(CFLAGS) -o $(OUTPUT)$@ $@.c $(LDFLAGS)
###############################
test-all:
- $(BUILD) -Werror -fstack-protector-all -O2 -Werror -D_FORTIFY_SOURCE=2 -ldw -lelf -lnuma $(LIBUNWIND_LIBS) -lelf -laudit -I/usr/include/slang -lslang $(shell pkg-config --libs --cflags gtk+-2.0 2>/dev/null) $(FLAGS_PERL_EMBED) $(FLAGS_PYTHON_EMBED) -DPACKAGE='"perf"' -lbfd -ldl
+ $(BUILD) -Werror -fstack-protector-all -O2 -Werror -D_FORTIFY_SOURCE=2 -ldw -lelf -lnuma -lelf -laudit -I/usr/include/slang -lslang $(shell pkg-config --libs --cflags gtk+-2.0 2>/dev/null) $(FLAGS_PERL_EMBED) $(FLAGS_PYTHON_EMBED) -DPACKAGE='"perf"' -lbfd -ldl
test-hello:
$(BUILD)
@@ -70,10 +70,10 @@ test-libnuma:
$(BUILD) -lnuma
test-libunwind:
- $(BUILD) $(LIBUNWIND_LIBS) -lelf
+ $(BUILD) -lelf
test-libunwind-debug-frame:
- $(BUILD) $(LIBUNWIND_LIBS) -lelf
+ $(BUILD) -lelf
test-libaudit:
$(BUILD) -laudit
--
1.8.1.4
^ permalink raw reply related [flat|nested] 17+ messages in thread* Re: [GIT PULL 00/34] perf/core improvements and fixes
2013-12-10 20:31 [GIT PULL 00/34] perf/core improvements and fixes Arnaldo Carvalho de Melo
` (13 preceding siblings ...)
2013-12-10 20:31 ` [PATCH 34/34] perf unwinding: Use the " Arnaldo Carvalho de Melo
@ 2013-12-11 11:01 ` Ingo Molnar
14 siblings, 0 replies; 17+ messages in thread
From: Ingo Molnar @ 2013-12-11 11:01 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo
Cc: linux-kernel, Arnaldo Carvalho de Melo, Adrian Hunter, Andi Kleen,
Ben Cheng, Corey Ashford, David Ahern, Dongsheng Yang,
Frederic Weisbecker, Jean Pihet, Jiri Olsa, linaro-kernel,
Mike Galbraith, Namhyung Kim, patches, Paul Mackerras,
Peter Zijlstra, Stephane Eranian, Steven Rostedt, Will Deacon,
Arnaldo Carvalho de Melo
* Arnaldo Carvalho de Melo <acme@infradead.org> wrote:
> From: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
>
> Hi Ingo,
>
> The first 20 patches in this series are the same as in the previous
> one, so I'm not reposting them now.
>
> This series has the code style/constification changes you suggested in
> the symbols code and then a reworked fix to the basename problem plus some
> more patches not present in the previous series.
>
> Please let me know if you find any further problems,
>
> Best Regards,
>
> - Arnaldo
>
> The following changes since commit 6d65894bc028d0342829ea1e64c9e9efad571124:
>
> tools lib traceevent: Update kvm plugin with is_writable_pte helper (2013-12-04 15:38:14 -0300)
>
> are available in the git repository at:
>
> git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux tags/perf-core-for-mingo
>
> for you to fetch changes up to 1448fef40af6079de38380c3a81bcf9994a1037d:
>
> perf unwinding: Use the per-feature check flags (2013-12-10 16:51:12 -0300)
>
> ----------------------------------------------------------------
> perf/core improvements and fixes:
>
> . Add an option in 'perf script' to print the source line number, from Adrian Hunter
>
> . Add --header/--header-only options to 'script' and 'report', the default is not
> tho show the header info, but as this has been the default for some time,
> leave a single line explaining how to obtain that information, from Jiri Olsa.
>
> . Fix symoff printing in callchains in 'perf script', from Adrian Hunter.
>
> . Assorted mmap_pages handling fixes, from Adrian Hunter.
>
> . Fix summary percentage when processing files in 'perf trace', fom David Ahern.
>
> . Handle old kernels where the "raw_syscalls" tracepoints were called plan "syscalls",
> in 'perf trace', from David Ahern.
>
> . Several man pages typo fixes from Dongsheng Yang.
>
> . Add '-v' option to 'perf kvm', from Dongsheng Yang.
>
> . Make perf kvm diff support --guestmount, from Dongsheng Yang.
>
> . Get rid of several die() calls in libtraceevent, from Namhyung Kim.
>
> . Use basename() in a more robust way, to avoid problems related to different
> system library implementations for that function, from Stephane Eranian.
>
> . Remove open coded management of short_name_allocated member, from Adrian Hunter
>
> . Several cleanups in the "dso" methods, constifying some parameters and
> renaming some fields to clarify its purpose.
>
> . Add per-feature check flags, fixing libunwind related build problems on some
> architectures, from Jean Pihet.
>
> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
>
> ----------------------------------------------------------------
> Adrian Hunter (7):
> perf script: Fix symoff printing in callchains
> perf script: Add an option to print the source line number
> perf record: Fix display of incorrect mmap pages
> perf evlist: Remove unnecessary parentheses
> perf evlist: Fix max mmap_pages
> perf evlist: Fix mmap pages rounding to power of 2
> perf symbols: Remove open coded management of short_name_allocated member
>
> Arnaldo Carvalho de Melo (8):
> perf symbols: Rename [sl]name_alloc to match the members they refer to
> perf machine: Don't open code assign dso->short_name
> perf symbols: Set alloc flag close to setting the long_name
> perf symbols: Remove open coded management of long_name_allocated member
> perf symbols: Constify dso->long_name
> perf symbols: Set freed members to NULL in dso destructor
> perf symbols: Constify some DSO methods parameters
> perf symbols: Rename filename argument
>
> David Ahern (2):
> perf trace: Add support for syscalls vs raw_syscalls
> perf trace: Fix summary percentage when processing files
>
> Dongsheng Yang (6):
> perf kvm: Introduce option -v for perf kvm command.
> perf kvm: Fix bug in 'stat report'
> perf archive: Remove duplicated 'runs' in man page
> perf annotate: Fix typo
> perf kvm: Move code to generate filename for perf-kvm to function.
> perf kvm: Make perf kvm diff support --guestmount.
>
> Jean Pihet (2):
> perf tools: Add per-feature check flags
> perf unwinding: Use the per-feature check flags
>
> Jiri Olsa (2):
> perf report: Add --header/--header-only options
> perf script: Add --header/--header-only options
>
> Namhyung Kim (5):
> tools lib traceevent: Get rid of malloc_or_die() in pevent_filter_alloc()
> tools lib traceevent: Get rid of malloc_or_die() in add_event()
> tools lib traceevent: Get rid of die() in create_arg_item()
> tools lib traceevent: Get rid of malloc_or_die() in pevent_filter_add_filter_str()
> tools lib traceevent: Get rid of die() in pevent_filter_clear_trivial()
>
> Stephane Eranian (1):
> perf symbols: Fix bug in usage of the basename() function
>
> Steven Rostedt (1):
> tools lib traceevent: Report better error message on bad function args
>
> tools/lib/traceevent/event-parse.c | 28 +++++---
> tools/lib/traceevent/event-parse.h | 2 +-
> tools/lib/traceevent/parse-filter.c | 57 +++++++++++----
> tools/perf/Documentation/perf-archive.txt | 6 +-
> tools/perf/Documentation/perf-kvm.txt | 7 +-
> tools/perf/Documentation/perf-report.txt | 9 +++
> tools/perf/Documentation/perf-script.txt | 8 ++-
> tools/perf/builtin-annotate.c | 2 +-
> tools/perf/builtin-diff.c | 3 +-
> tools/perf/builtin-kvm.c | 11 ++-
> tools/perf/builtin-record.c | 2 +-
> tools/perf/builtin-report.c | 22 +++++-
> tools/perf/builtin-script.c | 23 +++++-
> tools/perf/builtin-trace.c | 32 ++++++++-
> tools/perf/config/Makefile | 52 ++++++++------
> tools/perf/config/feature-checks/Makefile | 8 +--
> tools/perf/util/annotate.c | 2 +-
> tools/perf/util/build-id.c | 2 +-
> tools/perf/util/build-id.h | 2 +-
> tools/perf/util/dso.c | 112 ++++++++++++++++++++----------
> tools/perf/util/dso.h | 16 ++---
> tools/perf/util/evlist.c | 10 +--
> tools/perf/util/header.c | 6 +-
> tools/perf/util/machine.c | 6 +-
> tools/perf/util/map.c | 17 +++++
> tools/perf/util/map.h | 2 +
> tools/perf/util/probe-event.c | 2 +-
> tools/perf/util/session.c | 15 +++-
> tools/perf/util/session.h | 1 +
> tools/perf/util/srcline.c | 2 +-
> tools/perf/util/symbol.c | 38 ++++------
> tools/perf/util/symbol.h | 3 +-
> tools/perf/util/util.c | 14 ++++
> tools/perf/util/util.h | 14 ++++
> tools/perf/util/vdso.c | 2 +-
> 35 files changed, 375 insertions(+), 163 deletions(-)
Pulled, thanks a lot Arnaldo!
Ingo
^ permalink raw reply [flat|nested] 17+ messages in thread