* [PATCH 0/3] perf tool: basename cleanups
@ 2012-09-08 15:06 David Ahern
2012-09-08 15:06 ` [PATCH 1/3] perf annotate: make a copy of filename for passing to basename David Ahern
` (4 more replies)
0 siblings, 5 replies; 9+ messages in thread
From: David Ahern @ 2012-09-08 15:06 UTC (permalink / raw)
To: acme, linux-kernel; +Cc: irina.tirdea, David Ahern
basename can modify strings passed to it, so the strings should not
be marked const. Clean up the offenders and remove the BIONIC wrapper
for libgen.h
Irina: Would you verify perf still compiles cleanly for Android. Thanks.
David Ahern (3):
perf annotate: make a copy of filename for passing to basename
perf probe: make a copy of exec path for passing to basename
perf tool: remove BIONIC wrapper around libgen.h
tools/perf/util/annotate.c | 9 ++++++++-
tools/perf/util/probe-event.c | 12 ++++++++++--
tools/perf/util/symbol.h | 2 --
3 files changed, 18 insertions(+), 5 deletions(-)
--
1.7.10.1
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/3] perf annotate: make a copy of filename for passing to basename
2012-09-08 15:06 [PATCH 0/3] perf tool: basename cleanups David Ahern
@ 2012-09-08 15:06 ` David Ahern
2012-09-09 8:59 ` [tip:perf/core] perf annotate: Make " tip-bot for David Ahern
2012-09-08 15:06 ` [PATCH 2/3] perf probe: make a copy of exec path " David Ahern
` (3 subsequent siblings)
4 siblings, 1 reply; 9+ messages in thread
From: David Ahern @ 2012-09-08 15:06 UTC (permalink / raw)
To: acme, linux-kernel; +Cc: irina.tirdea, David Ahern, Pekka Enberg
basename may modify the string passed to it, so the string should not be
marked const.
Signed-off-by: David Ahern <dsahern@gmail.com>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: Irina Tirdea <irina.tirdea@gmail.com>
---
tools/perf/util/annotate.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index 51ef69c..04eafd3 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -984,7 +984,8 @@ int symbol__annotate_printf(struct symbol *sym, struct map *map, int evidx,
int context)
{
struct dso *dso = map->dso;
- const char *filename = dso->long_name, *d_filename;
+ char *filename;
+ const char *d_filename;
struct annotation *notes = symbol__annotation(sym);
struct disasm_line *pos, *queue = NULL;
u64 start = map__rip_2objdump(map, sym->start);
@@ -992,6 +993,10 @@ int symbol__annotate_printf(struct symbol *sym, struct map *map, int evidx,
int more = 0;
u64 len;
+ filename = strdup(dso->long_name);
+ if (!filename)
+ return -ENOMEM;
+
if (full_paths)
d_filename = filename;
else
@@ -1042,6 +1047,8 @@ int symbol__annotate_printf(struct symbol *sym, struct map *map, int evidx,
}
}
+ free(filename);
+
return more;
}
--
1.7.10.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 2/3] perf probe: make a copy of exec path for passing to basename
2012-09-08 15:06 [PATCH 0/3] perf tool: basename cleanups David Ahern
2012-09-08 15:06 ` [PATCH 1/3] perf annotate: make a copy of filename for passing to basename David Ahern
@ 2012-09-08 15:06 ` David Ahern
2012-09-09 9:00 ` [tip:perf/core] perf probe: Make " tip-bot for David Ahern
2012-09-08 15:06 ` [PATCH 3/3] perf tool: remove BIONIC wrapper around libgen.h David Ahern
` (2 subsequent siblings)
4 siblings, 1 reply; 9+ messages in thread
From: David Ahern @ 2012-09-08 15:06 UTC (permalink / raw)
To: acme, linux-kernel
Cc: irina.tirdea, David Ahern, Srikar Dronamraju, Pekka Enberg
basename may modify the string passed to it, so the string should not be
marked const.
Signed-off-by: David Ahern <dsahern@gmail.com>
Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: Irina Tirdea <irina.tirdea@gmail.com>
---
tools/perf/util/probe-event.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index 0dda25d..e8c72de 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -2307,10 +2307,17 @@ static int convert_name_to_addr(struct perf_probe_event *pev, const char *exec)
function = NULL;
}
if (!pev->group) {
- char *ptr1, *ptr2;
+ char *ptr1, *ptr2, *exec_copy;
pev->group = zalloc(sizeof(char *) * 64);
- ptr1 = strdup(basename(exec));
+ exec_copy = strdup(exec);
+ if (!exec_copy) {
+ ret = -ENOMEM;
+ pr_warning("Failed to copy exec string.\n");
+ goto out;
+ }
+
+ ptr1 = strdup(basename(exec_copy));
if (ptr1) {
ptr2 = strpbrk(ptr1, "-._");
if (ptr2)
@@ -2319,6 +2326,7 @@ static int convert_name_to_addr(struct perf_probe_event *pev, const char *exec)
ptr1);
free(ptr1);
}
+ free(exec_copy);
}
free(pp->function);
pp->function = zalloc(sizeof(char *) * MAX_PROBE_ARGS);
--
1.7.10.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 3/3] perf tool: remove BIONIC wrapper around libgen.h
2012-09-08 15:06 [PATCH 0/3] perf tool: basename cleanups David Ahern
2012-09-08 15:06 ` [PATCH 1/3] perf annotate: make a copy of filename for passing to basename David Ahern
2012-09-08 15:06 ` [PATCH 2/3] perf probe: make a copy of exec path " David Ahern
@ 2012-09-08 15:06 ` David Ahern
2012-09-09 9:01 ` [tip:perf/core] perf symbols: Remove BIONIC wrapper around libgen. h tip-bot for David Ahern
2012-09-08 16:24 ` [PATCH 0/3] perf tool: basename cleanups Pekka Enberg
2012-09-08 22:25 ` Irina Tirdea
4 siblings, 1 reply; 9+ messages in thread
From: David Ahern @ 2012-09-08 15:06 UTC (permalink / raw)
To: acme, linux-kernel; +Cc: irina.tirdea, David Ahern, Pekka Enberg
Now that the 2 offenders are fixed, the BIONIC conditional around
libgen.h can be removed.
Signed-off-by: David Ahern <dsahern@gmail.com>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: Irina Tirdea <irina.tirdea@gmail.com>
---
tools/perf/util/symbol.h | 2 --
1 file changed, 2 deletions(-)
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h
index d3b330c..41a15da 100644
--- a/tools/perf/util/symbol.h
+++ b/tools/perf/util/symbol.h
@@ -10,9 +10,7 @@
#include <linux/rbtree.h>
#include <stdio.h>
#include <byteswap.h>
-#if defined(__BIONIC__)
#include <libgen.h>
-#endif
#ifndef NO_LIBELF_SUPPORT
#include <libelf.h>
--
1.7.10.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 0/3] perf tool: basename cleanups
2012-09-08 15:06 [PATCH 0/3] perf tool: basename cleanups David Ahern
` (2 preceding siblings ...)
2012-09-08 15:06 ` [PATCH 3/3] perf tool: remove BIONIC wrapper around libgen.h David Ahern
@ 2012-09-08 16:24 ` Pekka Enberg
2012-09-08 22:25 ` Irina Tirdea
4 siblings, 0 replies; 9+ messages in thread
From: Pekka Enberg @ 2012-09-08 16:24 UTC (permalink / raw)
To: David Ahern; +Cc: acme, linux-kernel, irina.tirdea
On Sat, Sep 8, 2012 at 6:06 PM, David Ahern <dsahern@gmail.com> wrote:
> basename can modify strings passed to it, so the strings should not
> be marked const. Clean up the offenders and remove the BIONIC wrapper
> for libgen.h
>
> Irina: Would you verify perf still compiles cleanly for Android. Thanks.
To all three patches:
Acked-by: Pekka Enberg <penberg@kernel.org>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 0/3] perf tool: basename cleanups
2012-09-08 15:06 [PATCH 0/3] perf tool: basename cleanups David Ahern
` (3 preceding siblings ...)
2012-09-08 16:24 ` [PATCH 0/3] perf tool: basename cleanups Pekka Enberg
@ 2012-09-08 22:25 ` Irina Tirdea
4 siblings, 0 replies; 9+ messages in thread
From: Irina Tirdea @ 2012-09-08 22:25 UTC (permalink / raw)
To: David Ahern; +Cc: acme, linux-kernel
> Irina: Would you verify perf still compiles cleanly for Android. Thanks.
>
With these 3 patches perf still compiles cleanly for Android.
Thanks for making the changes.
Irina
^ permalink raw reply [flat|nested] 9+ messages in thread
* [tip:perf/core] perf annotate: Make a copy of filename for passing to basename
2012-09-08 15:06 ` [PATCH 1/3] perf annotate: make a copy of filename for passing to basename David Ahern
@ 2012-09-09 8:59 ` tip-bot for David Ahern
0 siblings, 0 replies; 9+ messages in thread
From: tip-bot for David Ahern @ 2012-09-09 8:59 UTC (permalink / raw)
To: linux-tip-commits
Cc: acme, linux-kernel, hpa, mingo, penberg, dsahern, irina.tirdea, tglx
Commit-ID: bfd14b9a7231e7cf77520bca1848c40c6b6360ae
Gitweb: http://git.kernel.org/tip/bfd14b9a7231e7cf77520bca1848c40c6b6360ae
Author: David Ahern <dsahern@gmail.com>
AuthorDate: Sat, 8 Sep 2012 09:06:50 -0600
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Sat, 8 Sep 2012 17:14:43 -0300
perf annotate: Make a copy of filename for passing to basename
The basename function may modify the string passed to it, so the string
should not be marked const.
Signed-off-by: David Ahern <dsahern@gmail.com>
Acked-by: Pekka Enberg <penberg@kernel.org>
Cc: Irina Tirdea <irina.tirdea@gmail.com>
Cc: Pekka Enberg <penberg@kernel.org>
Link: http://lkml.kernel.org/r/1347116812-93646-2-git-send-email-dsahern@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/util/annotate.c | 9 ++++++++-
1 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index 51ef69c..04eafd3 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -984,7 +984,8 @@ int symbol__annotate_printf(struct symbol *sym, struct map *map, int evidx,
int context)
{
struct dso *dso = map->dso;
- const char *filename = dso->long_name, *d_filename;
+ char *filename;
+ const char *d_filename;
struct annotation *notes = symbol__annotation(sym);
struct disasm_line *pos, *queue = NULL;
u64 start = map__rip_2objdump(map, sym->start);
@@ -992,6 +993,10 @@ int symbol__annotate_printf(struct symbol *sym, struct map *map, int evidx,
int more = 0;
u64 len;
+ filename = strdup(dso->long_name);
+ if (!filename)
+ return -ENOMEM;
+
if (full_paths)
d_filename = filename;
else
@@ -1042,6 +1047,8 @@ int symbol__annotate_printf(struct symbol *sym, struct map *map, int evidx,
}
}
+ free(filename);
+
return more;
}
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [tip:perf/core] perf probe: Make a copy of exec path for passing to basename
2012-09-08 15:06 ` [PATCH 2/3] perf probe: make a copy of exec path " David Ahern
@ 2012-09-09 9:00 ` tip-bot for David Ahern
0 siblings, 0 replies; 9+ messages in thread
From: tip-bot for David Ahern @ 2012-09-09 9:00 UTC (permalink / raw)
To: linux-tip-commits
Cc: acme, linux-kernel, hpa, mingo, penberg, srikar, dsahern,
irina.tirdea, tglx
Commit-ID: 1fb89448871500e5d5e7ad93d6dae68ee4fa464a
Gitweb: http://git.kernel.org/tip/1fb89448871500e5d5e7ad93d6dae68ee4fa464a
Author: David Ahern <dsahern@gmail.com>
AuthorDate: Sat, 8 Sep 2012 09:06:51 -0600
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Sat, 8 Sep 2012 17:15:04 -0300
perf probe: Make a copy of exec path for passing to basename
The basename function may modify the string passed to it, so the string
should not be marked const.
Signed-off-by: David Ahern <dsahern@gmail.com>
Acked-by: Pekka Enberg <penberg@kernel.org>
Cc: Irina Tirdea <irina.tirdea@gmail.com>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Link: http://lkml.kernel.org/r/1347116812-93646-3-git-send-email-dsahern@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/util/probe-event.c | 12 ++++++++++--
1 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index 0dda25d..e8c72de 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -2307,10 +2307,17 @@ static int convert_name_to_addr(struct perf_probe_event *pev, const char *exec)
function = NULL;
}
if (!pev->group) {
- char *ptr1, *ptr2;
+ char *ptr1, *ptr2, *exec_copy;
pev->group = zalloc(sizeof(char *) * 64);
- ptr1 = strdup(basename(exec));
+ exec_copy = strdup(exec);
+ if (!exec_copy) {
+ ret = -ENOMEM;
+ pr_warning("Failed to copy exec string.\n");
+ goto out;
+ }
+
+ ptr1 = strdup(basename(exec_copy));
if (ptr1) {
ptr2 = strpbrk(ptr1, "-._");
if (ptr2)
@@ -2319,6 +2326,7 @@ static int convert_name_to_addr(struct perf_probe_event *pev, const char *exec)
ptr1);
free(ptr1);
}
+ free(exec_copy);
}
free(pp->function);
pp->function = zalloc(sizeof(char *) * MAX_PROBE_ARGS);
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [tip:perf/core] perf symbols: Remove BIONIC wrapper around libgen. h
2012-09-08 15:06 ` [PATCH 3/3] perf tool: remove BIONIC wrapper around libgen.h David Ahern
@ 2012-09-09 9:01 ` tip-bot for David Ahern
0 siblings, 0 replies; 9+ messages in thread
From: tip-bot for David Ahern @ 2012-09-09 9:01 UTC (permalink / raw)
To: linux-tip-commits
Cc: acme, linux-kernel, hpa, mingo, penberg, dsahern, irina.tirdea, tglx
Commit-ID: 6c7f631261064762a8ba1ee34fc2b76d117ef3fa
Gitweb: http://git.kernel.org/tip/6c7f631261064762a8ba1ee34fc2b76d117ef3fa
Author: David Ahern <dsahern@gmail.com>
AuthorDate: Sat, 8 Sep 2012 09:06:52 -0600
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Sat, 8 Sep 2012 17:15:16 -0300
perf symbols: Remove BIONIC wrapper around libgen.h
Now that the 2 offenders are fixed, the BIONIC conditional around
libgen.h can be removed.
Signed-off-by: David Ahern <dsahern@gmail.com>
Acked-by: Pekka Enberg <penberg@kernel.org>
Cc: Irina Tirdea <irina.tirdea@gmail.com>
Cc: Pekka Enberg <penberg@kernel.org>
Link: http://lkml.kernel.org/r/1347116812-93646-4-git-send-email-dsahern@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/util/symbol.h | 2 --
1 files changed, 0 insertions(+), 2 deletions(-)
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h
index d3b330c..41a15da 100644
--- a/tools/perf/util/symbol.h
+++ b/tools/perf/util/symbol.h
@@ -10,9 +10,7 @@
#include <linux/rbtree.h>
#include <stdio.h>
#include <byteswap.h>
-#if defined(__BIONIC__)
#include <libgen.h>
-#endif
#ifndef NO_LIBELF_SUPPORT
#include <libelf.h>
^ permalink raw reply related [flat|nested] 9+ messages in thread
end of thread, other threads:[~2012-09-09 9:04 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-09-08 15:06 [PATCH 0/3] perf tool: basename cleanups David Ahern
2012-09-08 15:06 ` [PATCH 1/3] perf annotate: make a copy of filename for passing to basename David Ahern
2012-09-09 8:59 ` [tip:perf/core] perf annotate: Make " tip-bot for David Ahern
2012-09-08 15:06 ` [PATCH 2/3] perf probe: make a copy of exec path " David Ahern
2012-09-09 9:00 ` [tip:perf/core] perf probe: Make " tip-bot for David Ahern
2012-09-08 15:06 ` [PATCH 3/3] perf tool: remove BIONIC wrapper around libgen.h David Ahern
2012-09-09 9:01 ` [tip:perf/core] perf symbols: Remove BIONIC wrapper around libgen. h tip-bot for David Ahern
2012-09-08 16:24 ` [PATCH 0/3] perf tool: basename cleanups Pekka Enberg
2012-09-08 22:25 ` Irina Tirdea
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).