Porting perf to Android
v2 cover Porting perf to Android
This is version 2 for the patches to port perf to Android. With these patches perf compiles on latest Android tree (JellyBean).
The patches are on top of current perf/core branch of the tip tree.
Changes for v2:
() dropped the patch that replaced on_exit with at_exit.
A better solution is the one in Bernhard's patch [1]
() dropped one patch and removed unecessary code from patch 02 after the removal of unneeded network header files [2]
() added two more patches in order to build perf in Android (patches 10 and 11) () fixed whitespace anc checkpatch issues for patch 12
() make sure all patches are in txt form and will apply properly
[1] https://lkml.org/lkml/2012/8/23/316
[2] https://lkml.org/lkml/2012/8/29/150
Irina Tirdea (12):
perf tools: include wrapper for magic.h
perf tools: update types definitions for Android perf tools: include __WORDSIZE definition
perf tools: fix ALIGN redefinition in system headers perf tools: include basename for non-glibc systems perf tools: fix missing winsize definition
perf tools: include missing pthread.h header
perf tools: fix no return in non-void function perf tools: replace mkostemp with mkstemp
tools lib traceevent: replace mempcpy with memcpy perf tools: add NO_BACKTRACE for application self-debugging perf tools: Use __maybe_used for unused variables
tools/lib/traceevent/event-parse.c | 12 ++- tools/lib/traceevent/event-parse.h | 4 +- tools/perf/Makefile | 9 ++ tools/perf/bench/bench.h | 3 +- tools/perf/bench/mem-memcpy.c | 2 +- tools/perf/bench/mem-memset.c | 2 +- tools/perf/bench/sched-messaging.c | 2 +- tools/perf/bench/sched-pipe.c | 4 +- tools/perf/builtin-annotate.c | 2 +- tools/perf/builtin-bench.c | 2 +- tools/perf/builtin-buildid-cache.c | 7 +- tools/perf/builtin-buildid-list.c | 3 +- tools/perf/builtin-diff.c | 4 +- tools/perf/builtin-evlist.c | 2 +- tools/perf/builtin-help.c | 2 +- tools/perf/builtin-inject.c | 24 +++-- tools/perf/builtin-kmem.c | 22 ++-- tools/perf/builtin-kvm.c | 2 +- tools/perf/builtin-list.c | 2 +- tools/perf/builtin-lock.c | 4 +- tools/perf/builtin-probe.c | 24 ++--- tools/perf/builtin-record.c | 10 +- tools/perf/builtin-report.c | 11 +- tools/perf/builtin-sched.c | 69 +++++++------ tools/perf/builtin-script.c | 29 +++--- tools/perf/builtin-stat.c | 40 ++++--- tools/perf/builtin-test.c | 9 +- tools/perf/builtin-timechart.c | 30 +++--- tools/perf/builtin-top.c | 7 +- tools/perf/config/feature-tests.mak | 14 +++ tools/perf/perf.c | 1 + tools/perf/ui/browser.c | 7 +- tools/perf/ui/browsers/annotate.c | 6 +- tools/perf/ui/gtk/browser.c | 5 +- tools/perf/ui/gtk/setup.c | 2 +- tools/perf/ui/gtk/util.c | 4 +- tools/perf/ui/helpline.c | 2 +- tools/perf/ui/helpline.h | 8 +- tools/perf/ui/tui/setup.c | 4 +- tools/perf/util/alias.c | 3 +- tools/perf/util/annotate.c | 6 +- tools/perf/util/annotate.h | 14 +-- tools/perf/util/build-id.c | 11 +- tools/perf/util/cache.h | 6 +- tools/perf/util/callchain.c | 6 +- tools/perf/util/cgroup.c | 4 +- tools/perf/util/config.c | 6 +- tools/perf/util/debug.h | 9 +- tools/perf/util/dso-test-data.c | 2 +- tools/perf/util/event.c | 29 +++--- tools/perf/util/event.h | 2 +- tools/perf/util/header.c | 109 +++++++++++--------- tools/perf/util/help.c | 4 +- tools/perf/util/hist.c | 2 +- tools/perf/util/hist.h | 32 +++--- tools/perf/util/include/linux/bitops.h | 9 ++ tools/perf/util/include/linux/compiler.h | 8 +- tools/perf/util/include/linux/kernel.h | 13 ++- tools/perf/util/include/linux/magic.h | 12 +++ tools/perf/util/include/linux/types.h | 8 ++ tools/perf/util/intlist.c | 4 +- tools/perf/util/map.h | 2 +- tools/perf/util/parse-events-test.c | 6 +- tools/perf/util/parse-events.c | 7 +- tools/perf/util/parse-events.l | 2 +- tools/perf/util/parse-events.y | 4 +- tools/perf/util/parse-options.c | 3 +- tools/perf/util/perf_regs.h | 2 +- tools/perf/util/pmu.y | 6 +- tools/perf/util/probe-event.c | 21 ++-- tools/perf/util/probe-finder.c | 4 +- tools/perf/util/python.c | 8 +- .../perf/util/scripting-engines/trace-event-perl.c | 8 +- .../util/scripting-engines/trace-event-python.c | 10 +- tools/perf/util/session.c | 54 +++++----- tools/perf/util/sort.c | 14 ++- tools/perf/util/symbol-minimal.c | 28 ++--- tools/perf/util/symbol.c | 4 +- tools/perf/util/symbol.h | 10 +- tools/perf/util/top.h | 1 + tools/perf/util/trace-event-parse.c | 4 +- tools/perf/util/trace-event-scripting.c | 33 +++--- tools/perf/util/unwind.c | 36 ++++--- tools/perf/util/unwind.h | 11 +- tools/perf/util/util.c | 6 ++ tools/perf/util/util.h | 2 +- tools/perf/util/wrapper.c | 3 +- 87 files changed, 576 insertions(+), 408 deletions(-) create mode 100644 tools/perf/util/include/linux/magic.h
Signature · 1 line
1.7.9.5
PATCH v2 1/12 perf tools: include wrapper for magic.h
From: Irina Tirdea <[email protected]>
perf is currently including magic.h directly from the kernel. If the glibc magic.h is also included, this leads to warnings that the constants are redefined. This happens on some systems (e.g. Android).
Redefinition errors on Android:
In file included from util/util.h:79:0,
from util/cache.h:5,
from util/abspath.c:1:util/../../../include/linux/magic.h:5:0:
error: "AFFS_SUPER_MAGIC" redefined [-Werror] bionic/libc/include/sys/vfs.h:53:0:
note: this is the location of the previous definition util/../../../include/linux/magic.h:19:0:
error: "EFS_SUPER_MAGIC" redefined [-Werror] bionic/libc/include/sys/vfs.h:61:0:
note: this is the location of the previous definition util/../../../include/linux/magic.h:26:0:
error: "HPFS_SUPER_MAGIC" redefined [-Werror] bionic/libc/include/sys/vfs.h:67:0:
note: this is the location of the previous definition
Only two constants from magic.h are used by perf (DEBUGFS_MAGIC and SYSFS_MAGIC). This fix provides a wrapper for magic.h that includes only these constants instead of including the kernel header file directly.
--- tools/perf/Makefile | 1 + tools/perf/util/include/linux/magic.h | 12 ++++++++++++ tools/perf/util/util.h | 2 +- 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 tools/perf/util/include/linux/magic.h
tools/perf/Makefile +1 -0
@@ -264,6 +264,7 @@ LIB_H += util/include/linux/ctype.h LIB_H += util/include/linux/kernel.h LIB_H += util/include/linux/list.h LIB_H += util/include/linux/export.h +LIB_H += util/include/linux/magic.h LIB_H += util/include/linux/poison.h LIB_H += util/include/linux/prefetch.h LIB_H += util/include/linux/rbtree.h
tools/perf/util/include/linux/magic.h new file +12 -0
@@ -0,0 +1,12 @@ +#ifndef _PERF_LINUX_MAGIC_H_ +#define _PERF_LINUX_MAGIC_H_ + +#ifndef DEBUGFS_MAGIC +#define DEBUGFS_MAGIC 0x64626720 +#endif + +#ifndef SYSFS_MAGIC +#define SYSFS_MAGIC 0x62656572 +#endif + +#endif
tools/perf/util/util.h +1 -1
@@ -70,7 +70,7 @@#include <sys/socket.h> #include <sys/ioctl.h> #include <inttypes.h> -#include "../../../include/linux/magic.h" +#include <linux/magic.h> #include "types.h" #include <sys/ttydefaults.h>
Signature · 1 line
1.7.9.5
Re: [PATCH v2 01/12] perf tools: include wrapper for magic.h
Hi Irina,
I commented on some of the patches but overall, I think the series makes sense:
Pekka
Re: [PATCH v2 01/12] perf tools: include wrapper for magic.h
Quoted 2 lines · Pekka Enberg
Hi Irina,
Hi Pekka,
Quoted 3 lines
I commented on some of the patches but overall, I think the series makes sense:
Acked-by Pekka Enberg <[email protected]>
Thanks for reviewing it!
Irina
PATCH v2 2/12 perf tools: update types definitions for Android
In reply to Irina TirdeaFrom: Irina Tirdea <[email protected]>
Some type definitions are missing from Android or are already defined in bionic and lead to redefinition errors.
Android defines in types.h __le32. Since perf is wrapping <linux/types.h> with a local version, we need to define this constant in the local version too. Error in Android:
In file included from bionic/libc/include/unistd.h:36:0,
from external/perf/tools/perf/util/util.h:46,
from external/perf/tools/perf/util/cache.h:5,
from external/perf/tools/perf/util/abspath.c:1:bionic/libc/kernel/common/linux/capability.h:60:2:
error: unknown type name '__le32'
roundup() definition is missing:util/symbol.c: In function 'symbols__fixup_end':util/symbol.c:106: warning: implicit declaration of function 'roundup' util/symbol.c:106: warning: nested extern declaration of 'roundup'
__force macro defined in perf is also defined in libc which leads to redefinition errors. In order to avoid these, we guard these definition with
--- tools/perf/util/include/linux/compiler.h | 4 ++++ tools/perf/util/include/linux/kernel.h | 9 +++++++++ tools/perf/util/include/linux/types.h | 8 ++++++++ 3 files changed, 21 insertions(+)
tools/perf/util/include/linux/compiler.h +4 -0
@@ -12,4 +12,8 @@#define __used __attribute__((__unused__))#define __packed __attribute__((__packed__)) +#ifndef __force +#define __force +#endif +#endif
tools/perf/util/include/linux/kernel.h +9 -0
@@ -46,6 +46,15 @@ _min1 < _min2 ? _min1 : _min2; })#endif +#ifndef roundup +#define roundup (x, y) ( \ +{ \ + const typeof(y) __y = y; \ + (((x) + (__y - 1)) / __y) * __y; \ +} \ +) +#endif +#ifndef BUG_ON #define BUG_ON (cond) assert(!(cond))#endif
tools/perf/util/include/linux/types.h +8 -0
@@ -3,6 +3,14 @@#include <asm/types.h> +#ifndef __bitwise +#define __bitwise +#endif + +#ifndef __le32 +typedef __u32 __bitwise __le32 ; +#endif +#define DECLARE_BITMAP (name,bits) \ unsigned long name[BITS_TO_LONGS(bits)]
Signature · 1 line
1.7.9.5
PATCH v2 3/12 perf tools: include __WORDSIZE definition
In reply to Irina TirdeaFrom: Irina Tirdea <[email protected]>
__WORDSIZE is GLibC-specific and is not defined on all systems or glibc versions (e.g. Android's bionic does not define it).
In file included from util/include/linux/bitmap.h:5:0,
from util/header.h:10,
from util/session.h:6,
from util/build-id.h:4,
from util/annotate.c:11:util/include/linux/bitops.h: In function 'set_bit':util/include/linux/bitops.h:25:12: error:
'__WORDSIZE' undeclared (first use in this function) util/include/linux/bitops.h:25:12: note:
each undeclared identifier is reported only once for each function it appears in util/include/linux/bitops.h:23:51: error:
parameter 'addr' set but not used [-Werror=unused-but-set-parameter] util/include/linux/bitops.h: In function 'clear_bit':util/include/linux/bitops.h:30:12: error:
'__WORDSIZE' undeclared (first use in this function) util/include/linux/bitops.h:28:53: error:
parameter 'addr' set but not used [-Werror=unused-but-set-parameter] In file included from util/header.h:10:0,
from util/session.h:6,
from util/build-id.h:4,
from util/annotate.c:11:util/include/linux/bitmap.h: In function 'bitmap_zero':util/include/linux/bitmap.h:22:6: error:
'__WORDSIZE' undeclared (first use in this function)
Defining __WORDSIZE in perf's headers if it is not already defined.
--- tools/perf/util/include/linux/bitops.h | 9 +++++++++ 1 file changed, 9 insertions(+)
tools/perf/util/include/linux/bitops.h +9 -0
@@ -5,6 +5,15 @@#include <linux/compiler.h> #include <asm/hweight.h> +#ifndef __WORDSIZE +#if defined(__x86_64__) +# define __WORDSIZE 64 +#endif +#if defined(__i386__) || defined(__arm__) +# define __WORDSIZE 32 +#endif +#endif +#define BITS_PER_LONG __WORDSIZE#define BITS_PER_BYTE 8#define BITS_TO_LONGS (nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long))
Signature · 1 line
1.7.9.5
Re: [PATCH v2 03/12] perf tools: include __WORDSIZE definition
Quoted 43 lines · Irina Tirdea
From: Irina Tirdea <[email protected]>
__WORDSIZEis GLibC-specific and is not defined on all systems or glibc versions (e.g. Android's bionic does not define it).In file included from
util/include/linux/bitmap.h:5:0,from util/header.h:10, from util/session.h:6, from util/build-id.h:4, from util/annotate.c:11:
util/include/linux/bitops.h: In function 'set_bit':util/include/linux/bitops.h:25:12: error:
'__WORDSIZE' undeclared (first use in this function)util/include/linux/bitops.h:25:12: note:
each undeclared identifier is reported only once for each function it appears inutil/include/linux/bitops.h:23:51: error:
parameter 'addr' set but not used [-Werror=unused-but-set-parameter]util/include/linux/bitops.h: In function 'clear_bit':util/include/linux/bitops.h:30:12: error:
'__WORDSIZE' undeclared (first use in this function)util/include/linux/bitops.h:28:53: error:
parameter 'addr' set but not used [-Werror=unused-but-set-parameter] In file included fromutil/header.h:10:0,from util/session.h:6, from util/build-id.h:4, from util/annotate.c:11:
util/include/linux/bitmap.h: In function 'bitmap_zero':util/include/linux/bitmap.h:22:6: error:
'__WORDSIZE' undeclared (first use in this function)Defining
__WORDSIZEin perf's headers if it is not already defined.Signed-off-by Irina Tirdea <[email protected]>--- tools/perf/util/include/linux/bitops.h | 9 +++++++++ 1 file changed, 9 insertions(+)tools/perf/util/include/linux/bitops.h +0
-0@@ -5,6 +5,15 @@#include <linux/compiler.h>
tools/perf/util/include/linux/bitops.h line 15
Quoted 10 lines
tools/perf/util/include/linux/bitops.h +8
-0#include <asm/hweight.h> +#ifndef __WORDSIZE +#if defined(__x86_64__) +# define __WORDSIZE 64 +#endif +#if defined(__i386__) || defined(__arm__) +# define __WORDSIZE 32 +#endif +#endif
Why not use "sizeof(unsigned long) * 8" ?
Re: [PATCH v2 03/12] perf tools: include __WORDSIZE definition
Quoted 10 lines
tools/perf/util/include/linux/bitops.h line 15
Quoted 8 lines
tools/perf/util/include/linux/bitops.h +8
-0+#ifndef __WORDSIZE +#if defined(__x86_64__) +# define __WORDSIZE 64 +#endif +#if defined(__i386__) || defined(__arm__) +# define __WORDSIZE 32 +#endif +#endif Why not use "sizeof(unsigned long) * 8" ?
I tried to do it this, but the compilation crashes because this value is tested in an #if:
target C: libperf <= tools/perf/util/annotate.c
In file included from tools/perf/util/include/linux/bitmap.h:5:0,
from tools/perf/util/header.h:10,
from tools/perf/util/session.h:6,
from tools/perf/util/build-id.h:4,
from tools/perf/util/annotate.c:11:tools/perf/util/include/linux/bitops.h: In function '__ffs':tools/perf/util/include/linux/bitops.h:62:5: warning: "sizeof" is not defined [-Wundef] tools/perf/util/include/linux/bitops.h:62:5: error: missing binary operator before token "("
Thanks,
Irina
Re: [PATCH v2 03/12] perf tools: include __WORDSIZE definition
Quoted 14 lines · Irina Tirdea
Quoted 10 lines
tools/perf/util/include/linux/bitops.h line 15
Quoted 8 lines
tools/perf/util/include/linux/bitops.h +8
-0+#ifndef __WORDSIZE +#if defined(__x86_64__) +# define __WORDSIZE 64 +#endif +#if defined(__i386__) || defined(__arm__) +# define __WORDSIZE 32 +#endif +#endif Why not use "sizeof(unsigned long) * 8" ?
I tried to do it this, but the compilation crashes because this value is tested in an #if:
Quoted 11 lines
target C: libperf <=
tools/perf/util/annotate.c
In file included fromtools/perf/util/include/linux/bitmap.h:5:0,
fromtools/perf/util/header.h:10,
fromtools/perf/util/session.h:6,
fromtools/perf/util/build-id.h:4,
fromtools/perf/util/annotate.c:11:tools/perf/util/include/linux/bitops.h: In function '__ffs':tools/perf/util/include/linux/bitops.h:62:5: warning: "sizeof" is not defined [-Wundef]tools/perf/util/include/linux/bitops.h:62:5: error: missing binary operator before token "("
Use either: __SIZEOF_LONG__ (8) or __LP64__ (1)
Re: [PATCH v2 03/12] perf tools: include __WORDSIZE definition
Quoted 27 lines · Peter Zijlstra
Quoted 14 lines · Irina Tirdea
Quoted 10 lines
tools/perf/util/include/linux/bitops.h line 15
Quoted 8 lines
tools/perf/util/include/linux/bitops.h +8
-0+#ifndef __WORDSIZE +#if defined(__x86_64__) +# define __WORDSIZE 64 +#endif +#if defined(__i386__) || defined(__arm__) +# define __WORDSIZE 32 +#endif +#endif Why not use "sizeof(unsigned long) * 8" ?
I tried to do it this, but the compilation crashes because this value is tested in an #if:
Quoted 11 lines
target C: libperf <=
tools/perf/util/annotate.c
In file included fromtools/perf/util/include/linux/bitmap.h:5:0,
fromtools/perf/util/header.h:10,
fromtools/perf/util/session.h:6,
fromtools/perf/util/build-id.h:4,
fromtools/perf/util/annotate.c:11:tools/perf/util/include/linux/bitops.h: In function '__ffs':tools/perf/util/include/linux/bitops.h:62:5: warning: "sizeof" is not defined [-Wundef]tools/perf/util/include/linux/bitops.h:62:5: error: missing binary operator before token "("
Quoted 1 line
Use either:
__SIZEOF_LONG__(8) or__LP64__(1)
Thanks! Using __SIZEOF_LONG__ works. I'll update the patch.
Thanks,
Irina
PATCH v2 4/12 perf tools: fix ALIGN redefinition in system headers
In reply to Irina TirdeaFrom: Irina Tirdea <[email protected]>
On some systems (e.g. Android), ALIGN is defined in system headers as ALIGN(p). The definition of ALIGN used in perf takes 2 parameters: ALIGN(x,a). This leads to redefinition conflicts.
Redefinition error on Android:
In file included from util/include/linux/list.h:1:0,
from util/callchain.h:5,
from util/hist.h:6,
from util/session.h:4,
from util/build-id.h:4,
from util/annotate.c:11:util/include/linux/kernel.h:11:0: error: "ALIGN" redefined [-Werror] bionic/libc/include/sys/param.h:38:0: note: this is the location of the previous definition
Conflics with system defined ALIGN in Android:util/event.c: In function 'perf_event__synthesize_comm':util/event.c:115:32: error: macro "ALIGN" passed 2 arguments, but takes just 1 util/event.c:115:9: error: 'ALIGN' undeclared (first use in this function) util/event.c:115:9: note: each undeclared identifier is reported only once for each function it appears in
In order to avoid this redefinition, ALIGN is renamed to PERF_ALIGN.
--- tools/perf/util/event.c | 10 +++++----- tools/perf/util/event.h | 2 +- tools/perf/util/header.c | 16 ++++++++-------- tools/perf/util/include/linux/kernel.h | 4 ++-- tools/perf/util/session.c | 4 ++-- tools/perf/util/symbol.c | 2 +- 6 files changed, 19 insertions(+), 19 deletions(-)
tools/perf/util/event.c +5 -5
@@ -112,7 +112,7 @@ static pid_t perf_event__synthesize_comm(struct perf_tool *tool, event->comm.header.type =PERF_RECORD_COMM ; size =strlen (event->comm.comm) +1 ; - size =ALIGN (size,sizeof (u64)); + size =PERF_ALIGN (size,sizeof (u64));memset (event->comm.comm + size,0 , machine->id_hdr_size); event->comm.header.size = (sizeof(event->comm) - (sizeof(event->comm.comm) - size) +
@@ -145,7 +145,7 @@ static pid_t perf_event__synthesize_comm(struct perf_tool *tool, sizeof(event->comm.comm)); size =strlen (event->comm.comm) +1 ; - size =ALIGN (size,sizeof (u64)); + size =PERF_ALIGN (size,sizeof (u64));memset (event->comm.comm + size,0 , machine->id_hdr_size); event->comm.header.size = (sizeof(event->comm) - (sizeof(event->comm.comm) - size) +
@@ -228,7 +228,7 @@ static int perf_event__synthesize_mmap_events(struct perf_tool *tool, size =strlen (execname); execname[size -1 ] ='\0' ;/* Remove \n */ memcpy (event->mmap.filename, execname, size); - size =ALIGN (size,sizeof (u64)); + size =PERF_ALIGN (size,sizeof (u64)); event->mmap.len -= event->mmap.start; event->mmap.header.size = (sizeof (event->mmap) - (sizeof (event->mmap.filename) - size));
@@ -282,7 +282,7 @@ int perf_event__synthesize_modules(struct perf_tool *tool,if (pos->dso->kernel)continue ; - size =ALIGN (pos->dso->long_name_len +1 ,sizeof (u64)); + size =PERF_ALIGN (pos->dso->long_name_len +1 ,sizeof (u64)); event->mmap.header.type =PERF_RECORD_MMAP ; event->mmap.header.size = (sizeof (event->mmap) - (sizeof (event->mmap.filename) - size));
@@ -494,7 +494,7 @@ int perf_event__synthesize_kernel_mmap(struct perf_tool *tool, map = machine->vmlinux_maps[MAP__FUNCTION ]; size =snprintf (event->mmap.filename,sizeof (event->mmap.filename),"%s%s" , mmap_name, symbol_name) +1 ; - size =ALIGN (size,sizeof (u64)); + size =PERF_ALIGN (size,sizeof (u64)); event->mmap.header.type =PERF_RECORD_MMAP ; event->mmap.header.size = (sizeof (event->mmap) - (sizeof (event->mmap.filename) - size) + machine->id_hdr_size);
tools/perf/util/event.h +1 -1
@@ -101,7 +101,7 @@ struct perf_sample {struct build_id_event {struct perf_event_header header;pid_t pid; -u8 build_id[ALIGN (BUILD_ID_SIZE ,sizeof (u64))]; +u8 build_id[PERF_ALIGN (BUILD_ID_SIZE ,sizeof (u64))];char filename[]; };
tools/perf/util/header.c +8 -8
@@ -129,7 +129,7 @@ static int do_write_string(int fd, const char *str)int ret; olen =strlen (str) +1 ; - len =ALIGN (olen,NAME_ALIGN ); + len =PERF_ALIGN (olen,NAME_ALIGN );/* write len, incl. \0 */ ret =do_write (fd, &len,sizeof (len));
@@ -220,7 +220,7 @@ static int __dsos__write_buildid_table(struct list_head *head, pid_t pid,if (!pos->hit)continue ; len = pos->long_name_len +1 ; - len =ALIGN (len,NAME_ALIGN ); + len =PERF_ALIGN (len,NAME_ALIGN );memset (&b,0 ,sizeof (b));memcpy (&b.build_id, pos->build_id,sizeof (pos->build_id)); b.pid = pid;
@@ -1532,7 +1532,7 @@ static int perf_header__read_build_ids_abi_quirk(struct perf_header *header, struct perf_session *session = container_of(header, struct perf_session, header);struct {struct perf_event_header header; -u8 build_id[ALIGN (BUILD_ID_SIZE ,sizeof (u64))]; +u8 build_id[PERF_ALIGN (BUILD_ID_SIZE ,sizeof (u64))];char filename[0 ]; } old_bev;struct build_id_event bev;
@@ -2439,7 +2439,7 @@ int perf_event__synthesize_attr(struct perf_tool *tool,int err; size =sizeof (struct perf_event_attr ); - size =ALIGN (size,sizeof (u64)); + size =PERF_ALIGN (size,sizeof (u64)); size +=sizeof (struct perf_event_header ); size += ids *sizeof (u64);
@@ -2537,7 +2537,7 @@ int perf_event__synthesize_event_type(struct perf_tool *tool, ev.event_type.header.type =PERF_RECORD_HEADER_EVENT_TYPE ; size =strlen (ev.event_type.event_type.name); - size =ALIGN (size,sizeof (u64)); + size =PERF_ALIGN (size,sizeof (u64)); ev.event_type.header.size =sizeof (ev.event_type) - (sizeof (ev.event_type.event_type.name) - size);
@@ -2606,7 +2606,7 @@ int perf_event__synthesize_tracing_data(struct perf_tool *tool, int fd, ev.tracing_data.header.type =PERF_RECORD_HEADER_TRACING_DATA ; size = tdata->size; - aligned_size =ALIGN (size,sizeof (u64)); + aligned_size =PERF_ALIGN (size,sizeof (u64)); padding = aligned_size - size; ev.tracing_data.header.size =sizeof (ev.tracing_data); ev.tracing_data.size = aligned_size;
@@ -2637,7 +2637,7 @@ int perf_event__process_tracing_data(union perf_event *event, size_read =trace_report (session->fd, &session->pevent, session->repipe); - padding =ALIGN (size_read,sizeof (u64)) - size_read; + padding =PERF_ALIGN (size_read,sizeof (u64)) - size_read;if (read (session->fd, buf, padding) <0 )die ("reading input file" );
@@ -2671,7 +2671,7 @@ int perf_event__synthesize_build_id(struct perf_tool *tool,memset (&ev,0 ,sizeof (ev)); len = pos->long_name_len +1 ; - len =ALIGN (len,NAME_ALIGN ); + len =PERF_ALIGN (len,NAME_ALIGN );memcpy (&ev.build_id.build_id, pos->build_id,sizeof (pos->build_id)); ev.build_id.header.type =PERF_RECORD_HEADER_BUILD_ID ; ev.build_id.header.misc = misc;
tools/perf/util/include/linux/kernel.h +2 -2
@@ -8,8 +8,8 @@#define DIV_ROUND_UP (n,d) (((n) + (d) - 1) / (d)) -#define ALIGN (x,a) __ALIGN_MASK(x,(typeof(x))(a)-1) -#define __ALIGN_MASK (x,mask) (((x)+(mask))&~(mask)) +#define PERF_ALIGN (x, a) __PERF_ALIGN_MASK(x, (typeof(x))(a)-1) +#define __PERF_ALIGN_MASK (x, mask) (((x)+(mask))&~(mask))#ifndef offsetof#define offsetof (TYPE ,MEMBER ) ((size_t) &((TYPE *)0)->MEMBER)
tools/perf/util/session.c +2 -2
@@ -527,7 +527,7 @@ static void perf_event__comm_swap(union perf_event *event, bool sample_id_all)if (sample_id_all) {void *data = &event->comm.comm; - data +=ALIGN (strlen (data) +1 ,sizeof (u64)); + data +=PERF_ALIGN (strlen (data) +1 ,sizeof (u64));swap_sample_id_all (event, data); } }
@@ -544,7 +544,7 @@ static void perf_event__mmap_swap(union perf_event *event,if (sample_id_all) {void *data = &event->mmap.filename; - data +=ALIGN (strlen (data) +1 ,sizeof (u64)); + data +=PERF_ALIGN (strlen (data) +1 ,sizeof (u64));swap_sample_id_all (event, data); } }
tools/perf/util/symbol.c +1 -1
@@ -1991,7 +1991,7 @@ int symbol__init(void)if (symbol_conf.initialized)return 0 ; - symbol_conf.priv_size =ALIGN (symbol_conf.priv_size,sizeof (u64)); + symbol_conf.priv_size =PERF_ALIGN (symbol_conf.priv_size,sizeof (u64));symbol__elf_init ();
Signature · 1 line
1.7.9.5
PATCH v2 5/12 perf tools: include basename for non-glibc systems
In reply to Irina TirdeaFrom: Irina Tirdea <[email protected]>
perf uses the glibc version of basename(), by defining _GNU_SOURCE, including string.h and not including libgen.h. The glibc version of basename is better than the POSIX version since it does not modify its argument.
Android has only one version of basename which is defined in libgen.h. This version is the same as the glibc version.
Error on Android:util/annotate.c: In function 'symbol__annotate_printf':util/annotate.c:503:3: error: implicit declaration of function 'basename' [-Werror=implicit-function-declaration]util/annotate.c:503:3: error: nested extern declaration of 'basename' [-Werror=nested-externs]util/annotate.c:503:14: error: assignment makes pointer from integer without a cast [-Werror]
On Android libgen.h should be included to define basename.
--- tools/perf/util/symbol.h | 3 +++ 1 file changed, 3 insertions(+)
tools/perf/util/symbol.h +3 -0
@@ -10,6 +10,9 @@#include <linux/rbtree.h> #include <stdio.h> #include <byteswap.h> +#if defined(__BIONIC__) +#include <libgen.h> +#endif #ifndef NO_LIBELF_SUPPORT #include <libelf.h>
Signature · 1 line
1.7.9.5
Re: [PATCH v2 05/12] perf tools: include basename for non-glibc systems
Quoted 30 lines · Irina Tirdea
From: Irina Tirdea <[email protected]>
perf uses the glibc version of
basename(), by defining_GNU_SOURCE, includingstring.hand not includinglibgen.h. The glibc version of basename is better than the POSIX version since it does not modify its argument.Android has only one version of basename which is defined in
libgen.h. This version is the same as the glibc version.Error on Android:
util/annotate.c: In function 'symbol__annotate_printf':util/annotate.c:503:3: error: implicit declaration of function 'basename' [-Werror=implicit-function-declaration]util/annotate.c:503:3: error: nested extern declaration of 'basename' [-Werror=nested-externs]util/annotate.c:503:14: error: assignment makes pointer from integer without a cast [-Werror]On Android
libgen.hshould be included to define basename.Signed-off-by Irina Tirdea <[email protected]>--- tools/perf/util/symbol.h | 3 +++ 1 file changed, 3 insertions(+)tools/perf/util/symbol.h +0
-0
tools/perf/util/symbol.h line 15
Quoted 6 lines
tools/perf/util/symbol.h +3
-0@@ -10,6 +10,9 @@#include <linux/rbtree.h> #include <stdio.h> #include <byteswap.h> +#if defined(__BIONIC__) +#include <libgen.h> +#endif
It's safe to include <libgen.h> on glibc Linux systems as well, no? So there's no need to check for __BIONIC__.
Re: [PATCH v2 05/12] perf tools: include basename for non-glibc systems
Quoted 2 lines · Pekka Enberg
It's safe to include <
libgen.h> on glibc Linux systems as well, no? So there's no need to check for__BIONIC__.
Theoretically, yes. In reality compile fails in multiple places. basename can modify the string passed to it and several places in perf are passing a string marked const. Oops. I'll fix those places and remove the BIONIC conditional for libgen.h
David
[tip:perf/core] perf tools: include basename for non-glibc systems
In reply to Irina TirdeaCommit-ID: b771a8306205f0261496e93574a71bc7106844dc Gitweb: http://git.kernel.org/tip/b771a8306205f0261496e93574a71bc7106844dc Author: Irina Tirdea <[email protected]> AuthorDate: Sat, 8 Sep 2012 03:43:17 +0300 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Fri, 7 Sep 2012 22:06:53 -0300
perf tools: include basename for non-glibc systems
perf uses the glibc version of basename(), by defining _GNU_SOURCE, including string.h and not including libgen.h. The glibc version of basename is better than the POSIX version since it does not modify its argument.
Android has only one version of basename which is defined in libgen.h. This version is the same as the glibc version.
Error on Android:util/annotate.c: In function 'symbol__annotate_printf':util/annotate.c:503:3: error: implicit declaration of function 'basename' [-Werror=implicit-function-declaration]util/annotate.c:503:3: error: nested extern declaration of 'basename' [-Werror=nested-externs]util/annotate.c:503:14: error: assignment makes pointer from integer without a cast [-Werror]
On Android libgen.h should be included to define basename.
--- tools/perf/util/symbol.h | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
tools/perf/util/symbol.h +3 -0
@@ -10,6 +10,9 @@#include <linux/rbtree.h> #include <stdio.h> #include <byteswap.h> +#if defined(__BIONIC__) +#include <libgen.h> +#endif #ifndef NO_LIBELF_SUPPORT #include <libelf.h>
PATCH v2 6/12 perf tools: fix missing winsize definition
In reply to Irina TirdeaFrom: Irina Tirdea <[email protected]>
In Android, struct winsize is not defined in the headers already included in help.c. This leads to a compile error.
Including termios.h fixes the compilation error since it defines struct winsize.
--- tools/perf/util/help.c | 1 + tools/perf/util/top.h | 1 + 2 files changed, 2 insertions(+)
tools/perf/util/help.c +1 -0
@@ -3,6 +3,7 @@#include "exec_cmd.h" #include "levenshtein.h" #include "help.h" +#include <termios.h> void add_cmdname (struct cmdnames *cmds,const char *name,size_t len) {
tools/perf/util/top.h +1 -0
@@ -5,6 +5,7 @@#include "types.h" #include <stddef.h> #include <stdbool.h> +#include <termios.h> struct perf_evlist ;struct perf_evsel ;
Signature · 1 line
1.7.9.5
[tip:perf/core] perf tools: fix missing winsize definition
Commit-ID: 57ec0a942d6855cd7a5711fcf4adb57c51259659 Gitweb: http://git.kernel.org/tip/57ec0a942d6855cd7a5711fcf4adb57c51259659 Author: Irina Tirdea <[email protected]> AuthorDate: Sat, 8 Sep 2012 03:43:18 +0300 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Fri, 7 Sep 2012 22:07:32 -0300
perf tools: fix missing winsize definition
In Android, struct winsize is not defined in the headers already included in help.c. This leads to a compile error.
Including termios.h fixes the compilation error since it defines struct winsize.
--- tools/perf/util/help.c | 1 + tools/perf/util/top.h | 1 + 2 files changed, 2 insertions(+), 0 deletions(-)
tools/perf/util/help.c +1 -0
@@ -3,6 +3,7 @@#include "exec_cmd.h" #include "levenshtein.h" #include "help.h" +#include <termios.h> void add_cmdname (struct cmdnames *cmds,const char *name,size_t len) {
tools/perf/util/top.h +1 -0
@@ -5,6 +5,7 @@#include "types.h" #include <stddef.h> #include <stdbool.h> +#include <termios.h> struct perf_evlist ;struct perf_evsel ;
PATCH v2 7/12 perf tools: include missing pthread.h header
In reply to Irina TirdeaFrom: Irina Tirdea <[email protected]>
pthread variables are used in some files without explicitely including pthread.h. This leads to compile errors on Android. e.g.: in annotate.h,
error: unknown type name 'pthread_mutex_t'
Including pthread.h explicitely in files that use it to have all definitions included.
--- tools/perf/perf.c | 1 + tools/perf/util/annotate.h | 1 + 2 files changed, 2 insertions(+)
tools/perf/perf.c +1 -0
@@ -14,6 +14,7 @@#include "util/run-command.h" #include "util/parse-events.h" #include "util/debugfs.h" +#include <pthread.h> const char perf_usage_string[] ="perf [--version] [--help] COMMAND [ARGS]" ;
tools/perf/util/annotate.h +1 -0
@@ -7,6 +7,7 @@#include "symbol.h" #include <linux/list.h> #include <linux/rbtree.h> +#include <pthread.h> struct ins ;
Signature · 1 line
1.7.9.5
[tip:perf/core] perf tools: include missing pthread.h header
Commit-ID: 27683dc5cc9286ace82b6c900ab794428ed5e487 Gitweb: http://git.kernel.org/tip/27683dc5cc9286ace82b6c900ab794428ed5e487 Author: Irina Tirdea <[email protected]> AuthorDate: Sat, 8 Sep 2012 03:43:19 +0300 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Fri, 7 Sep 2012 22:08:09 -0300
perf tools: include missing pthread.h header
pthread variables are used in some files without explicitely including pthread.h. This leads to compile errors on Android. e.g.: in annotate.h,
error: unknown type name 'pthread_mutex_t'
Including pthread.h explicitely in files that use it to have all definitions included.
--- tools/perf/perf.c | 1 + tools/perf/util/annotate.h | 1 + 2 files changed, 2 insertions(+), 0 deletions(-)
tools/perf/perf.c +1 -0
@@ -14,6 +14,7 @@#include "util/run-command.h" #include "util/parse-events.h" #include "util/debugfs.h" +#include <pthread.h> const char perf_usage_string[] ="perf [--version] [--help] COMMAND [ARGS]" ;
tools/perf/util/annotate.h +1 -0
@@ -7,6 +7,7 @@#include "symbol.h" #include <linux/list.h> #include <linux/rbtree.h> +#include <pthread.h> struct ins ;
PATCH v2 8/12 perf tools: fix no return in non-void function
In reply to Irina TirdeaFrom: Irina Tirdea <[email protected]>
thread_func in builtin-sched.c has an internal loop and never returns. The only return from this thread are BUG_ON calls in case return values are not 0.
The compiler on Android complains that the function needs to return a non-void value. Adding the noreturn function attribute to fix this error.
Error in Android:
target C: perf <= builtin-sched.c hardware/intel/linu/tools/perf/builtin-sched.c: In function 'thread_func':hardware/intel/linux/tools/perf/builtin-sched.c:476: error: no return statement in function returning non-void
--- tools/perf/builtin-sched.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/builtin-sched.c +1 -1
@@ -439,7 +439,7 @@ static u64 get_cpu_usage_nsec_self(int fd)return runtime; } -static void *thread_func (void *ctx) +static __attribute__ ((noreturn))void *thread_func (void *ctx) {struct task_desc *this_task = ctx;u64 cpu_usage_0, cpu_usage_1;
Signature · 1 line
1.7.9.5
PATCH v2 9/12 perf tools: replace mkostemp with mkstemp
In reply to Irina TirdeaFrom: Irina Tirdea <[email protected]>
mkostemp is only available in glibc. This leads to compile error in Android, since bionic is derived from BSD.
Replacing mkostemp with mkstemp. mkstemp is available on both glibc and bionic.
--- tools/perf/util/dso-test-data.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/dso-test-data.c +1 -1
@@ -23,7 +23,7 @@ static char *test_file(int size)int fd, i;unsigned char *buf; - fd =mkostemp (templ,O_CREAT |O_WRONLY |O_TRUNC ); + fd =mkstemp (templ); buf =malloc (size);if (!buf) {
Signature · 1 line
1.7.9.5
[tip:perf/core] perf tools: replace mkostemp with mkstemp
Commit-ID: 7b45f21c2e42f265f6fd469e43857e98e2fdf01c Gitweb: http://git.kernel.org/tip/7b45f21c2e42f265f6fd469e43857e98e2fdf01c Author: Irina Tirdea <[email protected]> AuthorDate: Sat, 8 Sep 2012 03:43:21 +0300 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Fri, 7 Sep 2012 22:10:44 -0300
perf tools: replace mkostemp with mkstemp
The mkostemp function is only available in glibc. This leads to compile error in Android, since bionic is derived from BSD.
Replacing mkostemp with mkstemp. mkstemp is available on both glibc and bionic.
--- tools/perf/util/dso-test-data.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
tools/perf/util/dso-test-data.c +1 -1
@@ -23,7 +23,7 @@ static char *test_file(int size)int fd, i;unsigned char *buf; - fd =mkostemp (templ,O_CREAT |O_WRONLY |O_TRUNC ); + fd =mkstemp (templ); buf =malloc (size);if (!buf) {
PATCH v2 10/12 tools lib traceevent: replace mempcpy with memcpy
In reply to Irina TirdeaFrom: Irina Tirdea <[email protected]>
mempcpy is not supported by bionic in Android
and will lead to compilation errors.
Replacing mempcpy with memcpy so it will work in Android.
--- tools/lib/traceevent/event-parse.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/lib/traceevent/event-parse.c +2 -2
@@ -4812,8 +4812,8 @@ int pevent_strerror(struct pevent *pevent, enum pevent_errno errnum, msg =strerror_r (errnum, buf, buflen);if (msg != buf) {size_t len =strlen (msg); -char *c =mempcpy (buf, msg,min (buflen-1 , len)); - *c ='\0' ; +memcpy (buf, msg,min (buflen -1 , len)); + *(buf +min (buflen -1 , len)) ='\0' ; }return 0 ; }
Signature · 1 line
1.7.9.5
[tip:perf/core] tools lib traceevent: replace mempcpy with memcpy
Commit-ID: 9612ef6716efc20fac0f57d59452cda4e6846bda Gitweb: http://git.kernel.org/tip/9612ef6716efc20fac0f57d59452cda4e6846bda Author: Irina Tirdea <[email protected]> AuthorDate: Sat, 8 Sep 2012 03:43:22 +0300 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Fri, 7 Sep 2012 22:11:20 -0300
tools lib traceevent: replace mempcpy with memcpy
The mempcpy function is not supported by bionic in Android and will lead to compilation errors.
Replacing mempcpy with memcpy so it will work in Android.
--- tools/lib/traceevent/event-parse.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
tools/lib/traceevent/event-parse.c +2 -2
@@ -4833,8 +4833,8 @@ int pevent_strerror(struct pevent *pevent, enum pevent_errno errnum, msg =strerror_r (errnum, buf, buflen);if (msg != buf) {size_t len =strlen (msg); -char *c =mempcpy (buf, msg,min (buflen-1 , len)); - *c ='\0' ; +memcpy (buf, msg,min (buflen -1 , len)); + *(buf +min (buflen -1 , len)) ='\0' ; }return 0 ; }
PATCH v2 11/12 perf tools: add NO_BACKTRACE for application self-debugging
In reply to Irina TirdeaFrom: Irina Tirdea <[email protected]>
perf has support for self-debugging by defining dump_stack function. This function uses backtrace and backtrace_symbols functions defined as GNU extensions.
In Android, bionic does not offer support for these functions and compilation will fail with the following error:
target C: libperf <= tools/perf/util/util.c tools/perf/util/util.c:4:22: fatal error: execinfo.h: No such file or directory compilation terminated.
Add a compile-time option (NO_BACKTRACE) to enable or disable self-debugging functionality in perf. This can also help in debugging since it offers the possibility to turn on/off printing the backtrace.
--- tools/perf/Makefile | 8 ++++++++ tools/perf/config/feature-tests.mak | 14 ++++++++++++++ tools/perf/util/util.c | 6 ++++++ 3 files changed, 28 insertions(+)
tools/perf/Makefile +8 -0
@@ -756,6 +756,14 @@ else endif endif +ifdef NO_BACKTRACE + BASIC_CFLAGS += -DNO_BACKTRACE +else + ifneq ($(call try-cc,$(SOURCE_BACKTRACE),),y) + BASIC_CFLAGS += -DNO_BACKTRACE + endif +endif + ifdef ASCIIDOC8 export ASCIIDOC8 endif
tools/perf/config/feature-tests.mak +14 -0
@@ -179,3 +179,17 @@ int main(void) } endef endif + +ifndef NO_BACKTRACE +define SOURCE_BACKTRACE +#include <execinfo.h> +#include <stdio.h> + +int main(void) +{ + backtrace(NULL, 0); + backtrace_symbols(NULL, 0); + return 0; +} +endef +endif
tools/perf/util/util.c +6 -0
@@ -1,7 +1,9 @@#include "../perf.h" #include "util.h" #include <sys/mman.h> +#ifndef NO_BACKTRACE #include <execinfo.h> +#endif #include <stdio.h> #include <stdlib.h>
@@ -163,6 +165,7 @@ size_t hex_width(u64 v) }/* Obtain a backtrace and print it to stdout. */ +#ifndef NO_BACKTRACE void dump_stack (void ) {void *array[16 ];
@@ -177,3 +180,6 @@ void dump_stack(void) free(strings); } +#else +void dump_stack (void ) {} +#endif
Signature · 1 line
1.7.9.5
[tip:perf/core] perf tools: add NO_BACKTRACE for application self-debugging
Commit-ID: c9f08bee50c71b06685ccff8110e56a7c05662b7 Gitweb: http://git.kernel.org/tip/c9f08bee50c71b06685ccff8110e56a7c05662b7 Author: Irina Tirdea <[email protected]> AuthorDate: Sat, 8 Sep 2012 03:43:23 +0300 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Fri, 7 Sep 2012 22:12:30 -0300
perf tools: add NO_BACKTRACE for application self-debugging
perf has support for self-debugging by defining dump_stack function. This function uses backtrace and backtrace_symbols functions defined as GNU extensions.
In Android, bionic does not offer support for these functions and compilation will fail with the following error:
target C: libperf <= tools/perf/util/util.c tools/perf/util/util.c:4:22: fatal error: execinfo.h: No such file or directory compilation terminated.
Add a compile-time option (NO_BACKTRACE) to enable or disable self-debugging functionality in perf. This can also help in debugging since it offers the possibility to turn on/off printing the backtrace.
--- tools/perf/Makefile | 8 ++++++++ tools/perf/config/feature-tests.mak | 14 ++++++++++++++ tools/perf/util/util.c | 6 ++++++ 3 files changed, 28 insertions(+), 0 deletions(-)
tools/perf/Makefile +8 -0
@@ -755,6 +755,14 @@ else endif endif +ifdef NO_BACKTRACE + BASIC_CFLAGS += -DNO_BACKTRACE +else + ifneq ($(call try-cc,$(SOURCE_BACKTRACE),),y) + BASIC_CFLAGS += -DNO_BACKTRACE + endif +endif + ifdef ASCIIDOC8 export ASCIIDOC8 endif
tools/perf/config/feature-tests.mak +14 -0
@@ -179,3 +179,17 @@ int main(void) } endef endif + +ifndef NO_BACKTRACE +define SOURCE_BACKTRACE +#include <execinfo.h> +#include <stdio.h> + +int main(void) +{ + backtrace(NULL, 0); + backtrace_symbols(NULL, 0); + return 0; +} +endef +endif
tools/perf/util/util.c +6 -0
@@ -1,7 +1,9 @@#include "../perf.h" #include "util.h" #include <sys/mman.h> +#ifndef NO_BACKTRACE #include <execinfo.h> +#endif #include <stdio.h> #include <stdlib.h>
@@ -163,6 +165,7 @@ size_t hex_width(u64 v) }/* Obtain a backtrace and print it to stdout. */ +#ifndef NO_BACKTRACE void dump_stack (void ) {void *array[16 ];
@@ -177,3 +180,6 @@ void dump_stack(void) free(strings); } +#else +void dump_stack (void ) {} +#endif
PATCH v2 12/12 perf tools: Use __maybe_used for unused variables
In reply to Irina TirdeaFrom: Irina Tirdea <[email protected]>
perf defines both __used and __unused variables to use for marking unused variables. The variable __used is defined to __attribute__((__unused__)), which contradicts the kernel definition to __attribute__((__used__)) for new gcc versions. On Android, __used is also defined in system headers and this leads to warnings like: warning: '__used__' attribute ignored
__unused is not defined in the kernel and is not a standard definition. If __unused is included everywhere instead of __used, this leads to conflicts with glibc headers, since glibc has a variables with this name in its headers.
The best approach is to use __maybe_unused, the definition used in the kernel for __attribute__((unused)). In this way there is only one definition in perf sources (instead of 2 definitions that point to the same thing: __used and __unused) and it works on both Linux and Android. This patch simply replaces all instances of __used and __unused with __maybe_unused.
--- tools/lib/traceevent/event-parse.c | 8 +- tools/lib/traceevent/event-parse.h | 4 +- tools/perf/bench/bench.h | 3 +- tools/perf/bench/mem-memcpy.c | 2 +- tools/perf/bench/mem-memset.c | 2 +- tools/perf/bench/sched-messaging.c | 2 +- tools/perf/bench/sched-pipe.c | 4 +- tools/perf/builtin-annotate.c | 2 +- tools/perf/builtin-bench.c | 2 +- tools/perf/builtin-buildid-cache.c | 7 +- tools/perf/builtin-buildid-list.c | 3 +- tools/perf/builtin-diff.c | 4 +- tools/perf/builtin-evlist.c | 2 +- tools/perf/builtin-help.c | 2 +- tools/perf/builtin-inject.c | 24 ++--- tools/perf/builtin-kmem.c | 22 ++--- tools/perf/builtin-kvm.c | 2 +- tools/perf/builtin-list.c | 2 +- tools/perf/builtin-lock.c | 4 +- tools/perf/builtin-probe.c | 24 ++--- tools/perf/builtin-record.c | 10 +-- tools/perf/builtin-report.c | 11 +-- tools/perf/builtin-sched.c | 67 +++++++------- tools/perf/builtin-script.c | 29 +++--- tools/perf/builtin-stat.c | 40 ++++++--- tools/perf/builtin-test.c | 9 +- tools/perf/builtin-timechart.c | 30 ++++--- tools/perf/builtin-top.c | 7 +- tools/perf/ui/browser.c | 7 +- tools/perf/ui/browsers/annotate.c | 6 +- tools/perf/ui/gtk/browser.c | 5 +- tools/perf/ui/gtk/setup.c | 2 +- tools/perf/ui/gtk/util.c | 4 +- tools/perf/ui/helpline.c | 2 +- tools/perf/ui/helpline.h | 8 +- tools/perf/ui/tui/setup.c | 4 +- tools/perf/util/alias.c | 3 +- tools/perf/util/annotate.c | 6 +- tools/perf/util/annotate.h | 13 +-- tools/perf/util/build-id.c | 11 +-- tools/perf/util/cache.h | 6 +- tools/perf/util/callchain.c | 6 +- tools/perf/util/cgroup.c | 4 +- tools/perf/util/config.c | 6 +- tools/perf/util/debug.h | 9 +- tools/perf/util/event.c | 19 ++-- tools/perf/util/header.c | 93 +++++++++++--------- tools/perf/util/help.c | 3 +- tools/perf/util/hist.c | 2 +- tools/perf/util/hist.h | 32 +++---- tools/perf/util/include/linux/compiler.h | 4 +- tools/perf/util/intlist.c | 4 +- tools/perf/util/map.h | 2 +- tools/perf/util/parse-events-test.c | 6 +- tools/perf/util/parse-events.c | 7 +- tools/perf/util/parse-events.l | 2 +- tools/perf/util/parse-events.y | 4 +- tools/perf/util/parse-options.c | 3 +- tools/perf/util/perf_regs.h | 2 +- tools/perf/util/pmu.y | 6 +- tools/perf/util/probe-event.c | 21 ++--- tools/perf/util/probe-finder.c | 4 +- tools/perf/util/python.c | 8 +- .../perf/util/scripting-engines/trace-event-perl.c | 8 +- .../util/scripting-engines/trace-event-python.c | 10 ++- tools/perf/util/session.c | 50 ++++++----- tools/perf/util/sort.c | 14 +-- tools/perf/util/symbol-minimal.c | 28 +++--- tools/perf/util/symbol.c | 2 +- tools/perf/util/symbol.h | 7 +- tools/perf/util/trace-event-parse.c | 4 +- tools/perf/util/trace-event-scripting.c | 33 +++---- tools/perf/util/unwind.c | 36 ++++---- tools/perf/util/unwind.h | 11 +-- tools/perf/util/wrapper.c | 3 +- 75 files changed, 474 insertions(+), 384 deletions(-)
tools/lib/traceevent/event-parse.c +5 -3
@@ -1824,7 +1824,7 @@ process_op(struct event_format *event, struct print_arg *arg, char **tok) }static enum event_type -process_entry(struct event_format *event __unused, struct print_arg *arg, +process_entry (struct event_format *event__maybe_unused ,struct print_arg *arg,char **tok) {enum event_type type;
@@ -2458,7 +2458,8 @@ process_paren(struct event_format *event, struct print_arg *arg, char **tok)static enum event_type -process_str(struct event_format *event __unused, struct print_arg *arg, char **tok) +process_str (struct event_format *event__maybe_unused ,struct print_arg *arg, +char **tok) {enum event_type type;char *token;
@@ -3653,7 +3654,8 @@ static void free_args(struct print_arg *args) }static char * -get_bprint_format(void *data, int size __unused, struct event_format *event) +get_bprint_format (void *data,int size__maybe_unused , +struct event_format *event) {struct pevent *pevent = event->pevent;unsigned long long addr;
tools/lib/traceevent/event-parse.h +2 -2
@@ -24,8 +24,8 @@#include <stdarg.h> #include <regex.h> -#ifndef __unused -#define __unused __attribute__ ((unused)) +#ifndef __maybe_unused +#define __maybe_unused __attribute__((unused))#endif /* ----------------------- trace_seq ----------------------- */
tools/perf/bench/bench.h +2 -1
@@ -3,7 +3,8 @@extern int bench_sched_messaging (int argc,const char **argv,const char *prefix);extern int bench_sched_pipe (int argc,const char **argv,const char *prefix); -extern int bench_mem_memcpy (int argc,const char **argv,const char *prefix__used ); +extern int bench_mem_memcpy (int argc,const char **argv, +const char *prefix__maybe_unused );extern int bench_mem_memset (int argc,const char **argv,const char *prefix);#define BENCH_FORMAT_DEFAULT_STR "default"
tools/perf/bench/mem-memcpy.c +1 -1
@@ -177,7 +177,7 @@ static double do_memcpy_gettimeofday(memcpy_t fn, size_t len, bool prefault) }while (0 ) int bench_mem_memcpy(int argc, const char **argv, - const char *prefix __used) + const char *prefix __maybe_unused) {int i;size_t len;
tools/perf/bench/mem-memset.c +1 -1
@@ -171,7 +171,7 @@ static double do_memset_gettimeofday(memset_t fn, size_t len, bool prefault) }while (0 ) int bench_mem_memset(int argc, const char **argv, - const char *prefix __used) + const char *prefix __maybe_unused) {int i;size_t len;
tools/perf/bench/sched-messaging.c +1 -1
@@ -267,7 +267,7 @@ static const char * const bench_sched_message_usage[] = { };int bench_sched_messaging (int argc,const char **argv, -const char *prefix__used ) +const char *prefix__maybe_unused ) {unsigned int i, total_children;struct timeval start, stop, diff;
tools/perf/bench/sched-pipe.c +2 -2
@@ -43,7 +43,7 @@ static const char * const bench_sched_pipe_usage[] = { };int bench_sched_pipe (int argc,const char **argv, -const char *prefix__used ) +const char *prefix__maybe_unused ) {int pipe_1[2 ], pipe_2[2 ];int m =0 , i;
@@ -55,7 +55,7 @@ int bench_sched_pipe(int argc, const char **argv,* discarding returned value of read(), write() * causes error in building environment for perf */ -int __used ret, wait_stat; +int __maybe_unused ret, wait_stat;pid_t pid, retpid; argc = parse_options(argc, argv, options,
tools/perf/builtin-annotate.c +1 -1
@@ -239,7 +239,7 @@ static const char * const annotate_usage[] = {NULL }; -int cmd_annotate (int argc,const char **argv,const char *prefix__used ) +int cmd_annotate (int argc,const char **argv,const char *prefix__maybe_unused ) {struct perf_annotate annotate = { .tool = {
tools/perf/builtin-bench.c +1 -1
@@ -173,7 +173,7 @@ static void all_subsystem(void)all_suite (&subsystems[i]); } -int cmd_bench (int argc,const char **argv,const char *prefix__used ) +int cmd_bench (int argc,const char **argv,const char *prefix__maybe_unused ) {int i, j, status =0 ;
tools/perf/builtin-buildid-cache.c +4 -3
@@ -50,8 +50,8 @@ static int build_id_cache__add_file(const char *filename, const char *debugdir)return err; } -static int build_id_cache__remove_file (const char *filename__used , -const char *debugdir__used ) +static int build_id_cache__remove_file (const char *filename__maybe_unused , +const char *debugdir__maybe_unused ) {u8 build_id[BUILD_ID_SIZE ];char sbuild_id[BUILD_ID_SIZE *2 +1 ];
@@ -119,7 +119,8 @@ static int __cmd_buildid_cache(void)return 0 ; } -int cmd_buildid_cache (int argc,const char **argv,const char *prefix__used ) +int cmd_buildid_cache (int argc,const char **argv, +const char *prefix__maybe_unused ) { argc =parse_options (argc, argv, buildid_cache_options, buildid_cache_usage,0 );
tools/perf/builtin-buildid-list.c +2 -1
@@ -103,7 +103,8 @@ static int __cmd_buildid_list(void)return perf_session__list_build_ids (); } -int cmd_buildid_list (int argc,const char **argv,const char *prefix__used ) +int cmd_buildid_list (int argc,const char **argv, +const char *prefix__maybe_unused ) { argc =parse_options (argc, argv, options, buildid_list_usage,0 );setup_pager ();
tools/perf/builtin-diff.c +2 -2
@@ -40,7 +40,7 @@ static int hists__add_entry(struct hists *self,static int diff__process_sample_event (struct perf_tool *tool,union perf_event *event,struct perf_sample *sample, -struct perf_evsel *evsel__used , +struct perf_evsel *evsel__maybe_unused ,struct machine *machine) { struct perf_diff *_diff = container_of(tool, struct perf_diff, tool);
@@ -213,7 +213,7 @@ static const struct option options[] = { OPT_END() }; -int cmd_diff (int argc,const char **argv,const char *prefix__used ) +int cmd_diff (int argc,const char **argv,const char *prefix__maybe_unused ) { sort_order = diff__default_sort_order; argc =parse_options (argc, argv, options, diff_usage,0 );
tools/perf/builtin-evlist.c +1 -1
@@ -113,7 +113,7 @@ static const char * const evlist_usage[] = { NULL }; -int cmd_evlist (int argc,const char **argv,const char *prefix__used ) +int cmd_evlist (int argc,const char **argv,const char *prefix__maybe_unused ) {struct perf_attr_details details = { .verbose = false, };const char *input_name =NULL ;
tools/perf/builtin-help.c +1 -1
@@ -426,7 +426,7 @@ static int show_html_page(const char *perf_cmd)return 0 ; } -int cmd_help (int argc,const char **argv,const char *prefix__used ) +int cmd_help (int argc,const char **argv,const char *prefix__maybe_unused ) {const char *alias;int rc =0 ;
tools/perf/builtin-inject.c +13 -11
@@ -17,9 +17,9 @@static char const *input_name ="-" ;static bool inject_build_ids; -static int perf_event__repipe_synth (struct perf_tool *tool__used , +static int perf_event__repipe_synth (struct perf_tool *tool__maybe_unused ,union perf_event *event, -struct machine *machine__used ) +struct machine *machine__maybe_unused ) {uint32_t size;void *buf = event;
@@ -40,7 +40,8 @@ static int perf_event__repipe_synth(struct perf_tool *tool __used,static int perf_event__repipe_op2_synth (struct perf_tool *tool,union perf_event *event, -struct perf_session *session__used ) +struct perf_session *session +__maybe_unused ) {return perf_event__repipe_synth (tool, event,NULL ); }
@@ -52,13 +53,14 @@ static int perf_event__repipe_event_type_synth(struct perf_tool *tool, }static int perf_event__repipe_tracing_data_synth (union perf_event *event, -struct perf_session *session__used ) +struct perf_session *session +__maybe_unused ) {return perf_event__repipe_synth (NULL , event,NULL ); }static int perf_event__repipe_attr (union perf_event *event, -struct perf_evlist **pevlist__used ) +struct perf_evlist **pevlist__maybe_unused ) {int ret; ret =perf_event__process_attr (event, pevlist);
@@ -70,7 +72,7 @@ static int perf_event__repipe_attr(union perf_event *event,static int perf_event__repipe (struct perf_tool *tool,union perf_event *event, -struct perf_sample *sample__used , +struct perf_sample *sample__maybe_unused ,struct machine *machine) {return perf_event__repipe_synth (tool, event, machine);
@@ -78,8 +80,8 @@ static int perf_event__repipe(struct perf_tool *tool,static int perf_event__repipe_sample (struct perf_tool *tool,union perf_event *event, -struct perf_sample *sample__used , -struct perf_evsel *evsel__used , +struct perf_sample *sample__maybe_unused , +struct perf_evsel *evsel__maybe_unused ,struct machine *machine) {return perf_event__repipe_synth (tool, event, machine);
@@ -163,7 +165,7 @@ static int dso__inject_build_id(struct dso *self, struct perf_tool *tool,static int perf_event__inject_buildid (struct perf_tool *tool,union perf_event *event,struct perf_sample *sample, -struct perf_evsel *evsel__used , +struct perf_evsel *evsel__maybe_unused ,struct machine *machine) {struct addr_location al;
@@ -224,7 +226,7 @@ struct perf_tool perf_inject = {extern volatile int session_done; -static void sig_handler (int sig __attribute__((__unused__))) +static void sig_handler (int sig__maybe_unused ) { session_done =1 ; }
@@ -267,7 +269,7 @@ static const struct option options[] = { OPT_END() }; -int cmd_inject (int argc,const char **argv,const char *prefix__used ) +int cmd_inject (int argc,const char **argv,const char *prefix__maybe_unused ) { argc =parse_options (argc, argv, options, report_usage,0 );
tools/perf/builtin-kmem.c +12 -10
@@ -298,7 +298,7 @@ static void perf_evsel__process_kmem_event(struct perf_evsel *evsel, } } -static int process_sample_event(struct perf_tool *tool __used, +static int process_sample_event(struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample, struct perf_evsel *evsel,
@@ -647,8 +647,8 @@ static int setup_sorting(struct list_head *sort_list, const char *arg)return 0 ; } -static int parse_sort_opt (const struct option *opt__used , -const char *arg,int unset__used ) +static int parse_sort_opt (const struct option *opt__maybe_unused , +const char *arg,int unset__maybe_unused ) {if (!arg)return -1 ;
@@ -661,22 +661,24 @@ static int parse_sort_opt(const struct option *opt __used,return 0 ; } -static int parse_caller_opt (const struct option *opt__used , -const char *arg__used ,int unset__used ) +static int parse_caller_opt (const struct option *opt__maybe_unused , +const char *arg__maybe_unused , +int unset__maybe_unused ) { caller_flag = (alloc_flag +1 );return 0 ; } -static int parse_alloc_opt (const struct option *opt__used , -const char *arg__used ,int unset__used ) +static int parse_alloc_opt (const struct option *opt__maybe_unused , +const char *arg__maybe_unused , +int unset__maybe_unused ) { alloc_flag = (caller_flag +1 );return 0 ; } -static int parse_line_opt (const struct option *opt__used , -const char *arg,int unset__used ) +static int parse_line_opt (const struct option *opt__maybe_unused , +const char *arg,int unset__maybe_unused ) {int lines;
@@ -746,7 +748,7 @@ static int __cmd_record(int argc, const char **argv)return cmd_record (i, rec_argv,NULL ); } -int cmd_kmem (int argc,const char **argv,const char *prefix__used ) +int cmd_kmem (int argc,const char **argv,const char *prefix__maybe_unused ) { argc =parse_options (argc, argv, kmem_options, kmem_usage,0 );
tools/perf/builtin-kvm.c +1 -1
@@ -102,7 +102,7 @@ static int __cmd_buildid_list(int argc, const char **argv)return cmd_buildid_list (i, rec_argv,NULL ); } -int cmd_kvm (int argc,const char **argv,const char *prefix__used ) +int cmd_kvm (int argc,const char **argv,const char *prefix__maybe_unused ) { perf_host =0 ; perf_guest =1 ;
tools/perf/builtin-list.c +1 -1
@@ -14,7 +14,7 @@#include "util/parse-events.h" #include "util/cache.h" -int cmd_list (int argc,const char **argv,const char *prefix__used ) +int cmd_list (int argc,const char **argv,const char *prefix__maybe_unused ) {setup_pager ();
tools/perf/builtin-lock.c +2 -2
@@ -870,7 +870,7 @@ static int dump_info(void)return rc; } -static int process_sample_event(struct perf_tool *tool __used, +static int process_sample_event(struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample, struct perf_evsel *evsel,
@@ -1020,7 +1020,7 @@ static int __cmd_record(int argc, const char **argv)return cmd_record (i, rec_argv,NULL ); } -int cmd_lock (int argc,const char **argv,const char *prefix__used ) +int cmd_lock (int argc,const char **argv,const char *prefix__maybe_unused ) {unsigned int i;int rc =0 ;
tools/perf/builtin-probe.c +12 -12
@@ -143,8 +143,8 @@ static int parse_probe_event_argv(int argc, const char **argv)return ret; } -static int opt_add_probe_event (const struct option *opt__used , -const char *str,int unset__used ) +static int opt_add_probe_event (const struct option *opt__maybe_unused , +const char *str,int unset__maybe_unused ) {if (str) { params.mod_events = true;
@@ -153,8 +153,8 @@ static int opt_add_probe_event(const struct option *opt __used,return 0 ; } -static int opt_del_probe_event (const struct option *opt__used , -const char *str,int unset__used ) +static int opt_del_probe_event (const struct option *opt__maybe_unused , +const char *str,int unset__maybe_unused ) {if (str) { params.mod_events = true;
@@ -166,7 +166,7 @@ static int opt_del_probe_event(const struct option *opt __used, }static int opt_set_target (const struct option *opt,const char *str, -int unset__used ) +int unset__maybe_unused ) {int ret = -ENOENT ;
@@ -188,8 +188,8 @@ static int opt_set_target(const struct option *opt, const char *str, }#ifdef DWARF_SUPPORT -static int opt_show_lines (const struct option *opt__used , -const char *str,int unset__used ) +static int opt_show_lines (const struct option *opt__maybe_unused , +const char *str,int unset__maybe_unused ) {int ret =0 ;
@@ -209,8 +209,8 @@ static int opt_show_lines(const struct option *opt __used,return ret; } -static int opt_show_vars (const struct option *opt__used , -const char *str,int unset__used ) +static int opt_show_vars (const struct option *opt__maybe_unused , +const char *str,int unset__maybe_unused ) {struct perf_probe_event *pev = ¶ms.events[params.nevents];int ret;
@@ -229,8 +229,8 @@ static int opt_show_vars(const struct option *opt __used, }#endif -static int opt_set_filter (const struct option *opt__used , -const char *str,int unset__used ) +static int opt_set_filter (const struct option *opt__maybe_unused , +const char *str,int unset__maybe_unused ) {const char *err;
@@ -327,7 +327,7 @@ static const struct option options[] = { OPT_END() }; -int cmd_probe (int argc,const char **argv,const char *prefix__used ) +int cmd_probe (int argc,const char **argv,const char *prefix__maybe_unused ) {int ret;
tools/perf/builtin-record.c +5 -5
@@ -92,8 +92,8 @@ static int write_output(struct perf_record *rec, void *buf, size_t size)static int process_synthesized_event (struct perf_tool *tool,union perf_event *event, -struct perf_sample *sample__used , -struct machine *machine__used ) +struct perf_sample *sample__maybe_unused , +struct machine *machine__maybe_unused ) { struct perf_record *rec = container_of(tool, struct perf_record, tool);if (write_output (rec, event, event->header.size) <0 )
@@ -159,7 +159,7 @@ static void sig_handler(int sig) signr = sig; } -static void perf_record__sig_exit (int exit_status__used ,void *arg) +static void perf_record__sig_exit (int exit_status__maybe_unused ,void *arg) {struct perf_record *rec = arg;int status;
@@ -827,7 +827,7 @@ static int get_stack_size(char *str, unsigned long *_size)#endif /* !NO_LIBUNWIND_SUPPORT */ static int -parse_callchain_opt (const struct option *opt__used ,const char *arg, +parse_callchain_opt (const struct option *opt__maybe_unused ,const char *arg,int unset) {struct perf_record *rec = (struct perf_record *)opt->value;
@@ -1003,7 +1003,7 @@ const struct option record_options[] = { OPT_END() }; -int cmd_record (int argc,const char **argv,const char *prefix__used ) +int cmd_record (int argc,const char **argv,const char *prefix__maybe_unused ) {int err = -ENOMEM ;struct perf_evsel *pos;
tools/perf/builtin-report.c +6 -5
@@ -223,9 +223,9 @@ static int process_sample_event(struct perf_tool *tool,static int process_read_event (struct perf_tool *tool,union perf_event *event, -struct perf_sample *sample__used , +struct perf_sample *sample__maybe_unused ,struct perf_evsel *evsel, -struct machine *machine__used ) +struct machine *machine__maybe_unused ) { struct perf_report *rep = container_of(tool, struct perf_report, tool);
@@ -287,7 +287,7 @@ static int perf_report__setup_sample_type(struct perf_report *rep)extern volatile int session_done; -static void sig_handler (int sig__used ) +static void sig_handler (int sig__maybe_unused ) { session_done =1 ; }
@@ -533,13 +533,14 @@ setup: }static int -parse_branch_mode (const struct option *opt__used ,const char *str__used ,int unset) +parse_branch_mode (const struct option *opt__maybe_unused , +const char *str__maybe_unused ,int unset) { sort__branch_mode = !unset;return 0 ; } -int cmd_report (int argc,const char **argv,const char *prefix__used ) +int cmd_report (int argc,const char **argv,const char *prefix__maybe_unused ) {struct perf_session *session;struct stat st;
tools/perf/builtin-sched.c +36 -31
193 lines not on this page · raw message
tools/perf/builtin-script.c +15 -14
@@ -430,9 +430,9 @@ static void process_event(union perf_event *event, struct perf_sample *sample,printf ("\n" ); } -static int default_start_script(const char *script __unused, - int argc __unused, - const char **argv __unused) +static int default_start_script (const char *script__maybe_unused , +int argc__maybe_unused , +const char **argv__maybe_unused ) {return 0 ; }
@@ -442,8 +442,8 @@ static int default_stop_script(void)return 0 ; } -static int default_generate_script(struct pevent *pevent __unused, - const char *outfile __unused) +static int default_generate_script (struct pevent *pevent__maybe_unused , +const char *outfile__maybe_unused ) {return 0 ; }
@@ -474,7 +474,7 @@ static int cleanup_scripting(void)static const char *input_name; -static int process_sample_event(struct perf_tool *tool __used, +static int process_sample_event(struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample, struct perf_evsel *evsel,
@@ -534,7 +534,7 @@ static struct perf_tool perf_script = {extern volatile int session_done; -static void sig_handler(int sig __unused) +static void sig_handler (int sig__maybe_unused ) { session_done =1 ; }
@@ -644,8 +644,8 @@ static void list_available_languages(void)fprintf (stderr,"\n" ); } -static int parse_scriptname (const struct option *opt__used , -const char *str,int unset__used ) +static int parse_scriptname (const struct option *opt__maybe_unused , +const char *str,int unset__maybe_unused ) {char spec[PATH_MAX ];const char *script, *ext;
@@ -690,8 +690,8 @@ static int parse_scriptname(const struct option *opt __used,return 0 ; } -static int parse_output_fields (const struct option *opt__used , -const char *arg,int unset__used ) +static int parse_output_fields (const struct option *opt__maybe_unused , +const char *arg,int unset__maybe_unused ) {char *tok;int i, imax =sizeof (all_output_options) /sizeof (struct output_option );
@@ -982,8 +982,9 @@ static char *get_script_root(struct dirent *script_dirent, const char *suffix)return script_root; } -static int list_available_scripts (const struct option *opt__used , -const char *s__used ,int unset__used ) +static int list_available_scripts (const struct option *opt__maybe_unused , +const char *s__maybe_unused , +int unset__maybe_unused ) {struct dirent *script_next, *lang_next, script_dirent, lang_dirent;char scripts_path[MAXPATHLEN ];
@@ -1172,7 +1173,7 @@ static int have_cmd(int argc, const char **argv)return 0 ; } -int cmd_script (int argc,const char **argv,const char *prefix__used ) +int cmd_script (int argc,const char **argv,const char *prefix__maybe_unused ) {char *rec_script_path =NULL ;char *rep_script_path =NULL ;
tools/perf/builtin-stat.c +28 -12
@@ -417,7 +417,7 @@ static int read_counter(struct perf_evsel *counter)return 0 ; } -static int run_perf_stat (int argc__used ,const char **argv) +static int run_perf_stat (int argc__maybe_unused ,const char **argv) {unsigned long long t0, t1;struct perf_evsel *counter, *first;
@@ -634,7 +634,9 @@ static const char *get_ratio_color(enum grc_type type, double ratio)return color; } -static void print_stalled_cycles_frontend (int cpu,struct perf_evsel *evsel__used ,double avg) +static void print_stalled_cycles_frontend (int cpu, +struct perf_evsel *evsel +__maybe_unused ,double avg) {double total, ratio =0.0 ;const char *color;
@@ -651,7 +653,9 @@ static void print_stalled_cycles_frontend(int cpu, struct perf_evsel *evsel __usfprintf (output," frontend cycles idle " ); } -static void print_stalled_cycles_backend (int cpu,struct perf_evsel *evsel__used ,double avg) +static void print_stalled_cycles_backend (int cpu, +struct perf_evsel *evsel +__maybe_unused ,double avg) {double total, ratio =0.0 ;const char *color;
@@ -668,7 +672,9 @@ static void print_stalled_cycles_backend(int cpu, struct perf_evsel *evsel __usefprintf (output," backend cycles idle " ); } -static void print_branch_misses (int cpu,struct perf_evsel *evsel__used ,double avg) +static void print_branch_misses (int cpu, +struct perf_evsel *evsel__maybe_unused , +double avg) {double total, ratio =0.0 ;const char *color;
@@ -685,7 +691,9 @@ static void print_branch_misses(int cpu, struct perf_evsel *evsel __used, doublefprintf (output," of all branches " ); } -static void print_l1_dcache_misses (int cpu,struct perf_evsel *evsel__used ,double avg) +static void print_l1_dcache_misses (int cpu, +struct perf_evsel *evsel__maybe_unused , +double avg) {double total, ratio =0.0 ;const char *color;
@@ -702,7 +710,9 @@ static void print_l1_dcache_misses(int cpu, struct perf_evsel *evsel __used, doufprintf (output," of all L1-dcache hits " ); } -static void print_l1_icache_misses (int cpu,struct perf_evsel *evsel__used ,double avg) +static void print_l1_icache_misses (int cpu, +struct perf_evsel *evsel__maybe_unused , +double avg) {double total, ratio =0.0 ;const char *color;
@@ -719,7 +729,9 @@ static void print_l1_icache_misses(int cpu, struct perf_evsel *evsel __used, doufprintf (output," of all L1-icache hits " ); } -static void print_dtlb_cache_misses (int cpu,struct perf_evsel *evsel__used ,double avg) +static void print_dtlb_cache_misses (int cpu, +struct perf_evsel *evsel__maybe_unused , +double avg) {double total, ratio =0.0 ;const char *color;
@@ -736,7 +748,9 @@ static void print_dtlb_cache_misses(int cpu, struct perf_evsel *evsel __used, dofprintf (output," of all dTLB cache hits " ); } -static void print_itlb_cache_misses (int cpu,struct perf_evsel *evsel__used ,double avg) +static void print_itlb_cache_misses (int cpu, +struct perf_evsel *evsel__maybe_unused , +double avg) {double total, ratio =0.0 ;const char *color;
@@ -753,7 +767,9 @@ static void print_itlb_cache_misses(int cpu, struct perf_evsel *evsel __used, dofprintf (output," of all iTLB cache hits " ); } -static void print_ll_cache_misses (int cpu,struct perf_evsel *evsel__used ,double avg) +static void print_ll_cache_misses (int cpu, +struct perf_evsel *evsel__maybe_unused , +double avg) {double total, ratio =0.0 ;const char *color;
@@ -1059,8 +1075,8 @@ static const char * const stat_usage[] = { NULL }; -static int stat__set_big_num (const struct option *opt__used , -const char *s__used ,int unset) +static int stat__set_big_num (const struct option *opt__maybe_unused , +const char *s__maybe_unused ,int unset) { big_num_opt = unset ?0 :1 ;return 0 ;
@@ -1154,7 +1170,7 @@ static int add_default_attributes(void)return perf_evlist__add_default_attrs (evsel_list, very_very_detailed_attrs); } -int cmd_stat (int argc,const char **argv,const char *prefix__used ) +int cmd_stat (int argc,const char **argv,const char *prefix__maybe_unused ) {struct perf_evsel *pos;int status = -ENOMEM ;
tools/perf/builtin-test.c +6 -3
@@ -18,7 +18,8 @@#include <sys/mman.h> -static int vmlinux_matches_kallsyms_filter (struct map *map__used ,struct symbol *sym) +static int vmlinux_matches_kallsyms_filter (struct map *map__maybe_unused , +struct symbol *sym) {bool *visited =symbol__priv (sym); *visited = true;
@@ -996,7 +997,9 @@ static u64 mmap_read_self(void *addr)/* * If the RDPMC instruction faults then signal this back to the test parent task: */ -static void segfault_handler (int sig__used ,siginfo_t *info__used ,void *uc__used ) +static void segfault_handler (int sig__maybe_unused , +siginfo_t *info__maybe_unused , +void *uc__maybe_unused ) {exit (-1 ); }
@@ -1313,7 +1316,7 @@ static int perf_test__list(int argc, const char **argv)return 0 ; } -int cmd_test (int argc,const char **argv,const char *prefix__used ) +int cmd_test (int argc,const char **argv,const char *prefix__maybe_unused ) {const char *const test_usage[] = {"perf test [<options>] [{list <test-name-fragment>|[<test-name-fragments>|<test-numbers>]}]" ,
tools/perf/builtin-timechart.c +16 -14
@@ -275,28 +275,28 @@ static int cpus_cstate_state[MAX_CPUS];static u64 cpus_pstate_start_times[MAX_CPUS ];static u64 cpus_pstate_state[MAX_CPUS ]; -static int process_comm_event (struct perf_tool *tool__used , +static int process_comm_event (struct perf_tool *tool__maybe_unused ,union perf_event *event, -struct perf_sample *sample__used , -struct machine *machine__used ) +struct perf_sample *sample__maybe_unused , +struct machine *machine__maybe_unused ) {pid_set_comm (event->comm.tid, event->comm.comm);return 0 ; } -static int process_fork_event (struct perf_tool *tool__used , +static int process_fork_event (struct perf_tool *tool__maybe_unused ,union perf_event *event, -struct perf_sample *sample__used , -struct machine *machine__used ) +struct perf_sample *sample__maybe_unused , +struct machine *machine__maybe_unused ) {pid_fork (event->fork.pid, event->fork.ppid, event->fork.time);return 0 ; } -static int process_exit_event (struct perf_tool *tool__used , +static int process_exit_event (struct perf_tool *tool__maybe_unused ,union perf_event *event, -struct perf_sample *sample__used , -struct machine *machine__used ) +struct perf_sample *sample__maybe_unused , +struct machine *machine__maybe_unused ) {pid_exit (event->fork.pid, event->fork.time);return 0 ;
@@ -491,11 +491,11 @@ static void sched_switch(int cpu, u64 timestamp, struct trace_entry *te) } -static int process_sample_event (struct perf_tool *tool__used , -union perf_event *event__used , +static int process_sample_event (struct perf_tool *tool__maybe_unused , +union perf_event *event__maybe_unused ,struct perf_sample *sample,struct perf_evsel *evsel, -struct machine *machine__used ) +struct machine *machine__maybe_unused ) {struct trace_entry *te;
@@ -1081,7 +1081,8 @@ static int __cmd_record(int argc, const char **argv) }static int -parse_process (const struct option *opt__used ,const char *arg,int __used unset) +parse_process (const struct option *opt__maybe_unused ,const char *arg, +int __maybe_unused unset) {if (arg)add_process_filter (arg);
@@ -1106,7 +1107,8 @@ static const struct option options[] = { }; -int cmd_timechart (int argc,const char **argv,const char *prefix__used ) +int cmd_timechart (int argc,const char **argv, +const char *prefix__maybe_unused ) { argc =parse_options (argc, argv, options, timechart_usage,PARSE_OPT_STOP_AT_NON_OPTION );
tools/perf/builtin-top.c +4 -3
@@ -95,7 +95,8 @@ static void perf_top__update_print_entries(struct perf_top *top) top->print_entries -=9 ; } -static void perf_top__sig_winch (int sig__used ,siginfo_t *info__used ,void *arg) +static void perf_top__sig_winch (int sig__maybe_unused , +siginfo_t *info__maybe_unused ,void *arg) {struct perf_top *top = arg;
@@ -663,7 +664,7 @@ static const char *skip_symbols[] = { NULL }; -static int symbol_filter (struct map *map__used ,struct symbol *sym) +static int symbol_filter (struct map *map__maybe_unused ,struct symbol *sym) {const char *name = sym->name;int i;
@@ -1163,7 +1164,7 @@ static const char * const top_usage[] = { NULL }; -int cmd_top (int argc,const char **argv,const char *prefix__used ) +int cmd_top (int argc,const char **argv,const char *prefix__maybe_unused ) {struct perf_evsel *pos;int status;
tools/perf/ui/browser.c +4 -3
@@ -269,7 +269,7 @@ int ui_browser__show(struct ui_browser *browser, const char *title,return err ?0 :-1 ; } -void ui_browser__hide (struct ui_browser *browser__used ) +void ui_browser__hide (struct ui_browser *browser__maybe_unused ) {pthread_mutex_lock (&ui__lock);ui_helpline__pop ();
@@ -518,7 +518,7 @@ static struct ui_browser__colorset {static int ui_browser__color_config (const char *var,const char *value, -void *data__used ) +void *data__maybe_unused ) {char *fg =NULL , *bg;int i;
@@ -602,7 +602,8 @@ void __ui_browser__vline(struct ui_browser *browser, unsigned int column,SLsmg_set_char_set (0 ); } -void ui_browser__write_graph (struct ui_browser *browser__used ,int graph) +void ui_browser__write_graph (struct ui_browser *browser__maybe_unused , +int graph) {SLsmg_set_char_set (1 );SLsmg_write_char (graph);
tools/perf/ui/browsers/annotate.c +4 -2
@@ -54,7 +54,8 @@ static inline struct browser_disasm_line *disasm_line__browser(struct disasm_linreturn (struct browser_disasm_line *)(dl +1 ); } -static bool disasm_line__filter (struct ui_browser *browser__used ,void *entry) +static bool disasm_line__filter (struct ui_browser *browser__maybe_unused , +void *entry) {if (annotate_browser__opts.hide_src_code) { struct disasm_line *dl = list_entry(entry, struct disasm_line, node);
@@ -928,7 +929,8 @@ static int annotate_config__cmp(const void *name, const void *cfgp)return strcmp (name, cfg->name); } -static int annotate__config (const char *var,const char *value,void *data__used ) +static int annotate__config (const char *var,const char *value, +void *data__maybe_unused ) {struct annotate__config *cfg;const char *name;
tools/perf/ui/gtk/browser.c +3 -2
@@ -168,8 +168,9 @@ static GtkWidget *perf_gtk__setup_statusbar(void)int perf_evlist__gtk_browse_hists (struct perf_evlist *evlist,const char *help, -void (*timer) (void *arg)__used , -void *arg__used ,int delay_secs__used ) +void (*timer) (void *arg)__maybe_unused , +void *arg__maybe_unused , +int delay_secs__maybe_unused ) {struct perf_evsel *pos;GtkWidget *vbox;
tools/perf/ui/gtk/setup.c +1 -1
@@ -11,7 +11,7 @@ int perf_gtk__init(void)return gtk_init_check (NULL ,NULL ) ?0 :-1 ; } -void perf_gtk__exit (bool wait_for_ok__used ) +void perf_gtk__exit (bool wait_for_ok__maybe_unused ) {if (!perf_gtk__is_active_context (pgctx))return ;
tools/perf/ui/gtk/util.c +2 -2
@@ -117,8 +117,8 @@ struct perf_error_ops perf_gtk_eops = {* For now, just add stubs for NO_NEWT=1 build. */ #ifdef NO_NEWT_SUPPORT -void ui_progress__update (u64 curr__used ,u64 total__used , -const char *title__used ) +void ui_progress__update (u64 curr__maybe_unused ,u64 total__maybe_unused , +const char *title__maybe_unused ) { }#endif
tools/perf/ui/helpline.c +1 -1
@@ -12,7 +12,7 @@ static void nop_helpline__pop(void) { } -static void nop_helpline__push (const char *msg__used ) +static void nop_helpline__push (const char *msg__maybe_unused ) { }
tools/perf/ui/helpline.h +4 -4
@@ -24,8 +24,8 @@ void ui_helpline__puts(const char *msg);extern char ui_helpline__current[512 ];#ifdef NO_NEWT_SUPPORT -static inline int ui_helpline__show_help (const char *format__used , -va_list ap__used ) +static inline int ui_helpline__show_help (const char *format__maybe_unused , +va_list ap__maybe_unused ) {return 0 ; }
@@ -35,8 +35,8 @@ int ui_helpline__show_help(const char *format, va_list ap);#endif /* NO_NEWT_SUPPORT */ #ifdef NO_GTK2_SUPPORT -static inline int perf_gtk__show_helpline (const char *format__used , -va_list ap__used ) +static inline int perf_gtk__show_helpline (const char *format__maybe_unused , +va_list ap__maybe_unused ) {return 0 ; }
tools/perf/ui/tui/setup.c +2 -2
@@ -26,7 +26,7 @@ void ui__refresh_dimensions(bool force) } } -static void ui__sigwinch (int sig__used ) +static void ui__sigwinch (int sig__maybe_unused ) { ui__need_resize =1 ; }
@@ -86,7 +86,7 @@ int ui__getch(int delay_secs)return SLkp_getkey (); } -static void newt_suspend (void *d__used ) +static void newt_suspend (void *d__maybe_unused ) {newtSuspend ();raise (SIGTSTP );
tools/perf/util/alias.c +2 -1
@@ -3,7 +3,8 @@static const char *alias_key;static char *alias_val; -static int alias_lookup_cb (const char *k,const char *v,void *cb__used ) +static int alias_lookup_cb (const char *k,const char *v, +void *cb__maybe_unused ) {if (!prefixcmp (k,"alias." ) && !strcmp (k+6 , alias_key)) {if (!v)
tools/perf/util/annotate.c +3 -3
@@ -313,8 +313,8 @@ static struct ins_ops dec_ops = { .scnprintf = dec__scnprintf, }; -static int nop__scnprintf (struct ins *ins__used ,char *bf,size_t size, -struct ins_operands *ops__used ) +static int nop__scnprintf (struct ins *ins__maybe_unused ,char *bf,size_t size, +struct ins_operands *ops__maybe_unused ) {return scnprintf (bf, size,"%-6.6s" ,"nop" ); }
@@ -416,7 +416,7 @@ static struct ins *ins__find(const char *name)return bsearch (name, instructions, nmemb,sizeof (struct ins ), ins__cmp); } -int symbol__annotate_init (struct map *map__used ,struct symbol *sym) +int symbol__annotate_init (struct map *map__maybe_unused ,struct symbol *sym) {struct annotation *notes =symbol__annotation (sym);pthread_mutex_init (¬es->lock,NULL );
tools/perf/util/annotate.h +7 -6
@@ -126,7 +126,7 @@ int symbol__alloc_hist(struct symbol *sym);void symbol__annotate_zero_histograms (struct symbol *sym);int symbol__annotate (struct symbol *sym,struct map *map,size_t privsize); -int symbol__annotate_init (struct map *map__used ,struct symbol *sym); +int symbol__annotate_init (struct map *map__maybe_unused ,struct symbol *sym);int symbol__annotate_printf (struct symbol *sym,struct map *map,int evidx,bool full_paths,int min_pcnt,int max_lines,int context);
@@ -139,11 +139,12 @@ int symbol__tty_annotate(struct symbol *sym, struct map *map, int evidx, int max_lines);#ifdef NO_NEWT_SUPPORT -static inline int symbol__tui_annotate (struct symbol *sym__used , -struct map *map__used , -int evidx__used , -void (*timer)(void *arg)__used , -void *arg__used ,int delay_secs__used ) +static inline int symbol__tui_annotate (struct symbol *sym__maybe_unused , +struct map *map__maybe_unused , +int evidx__maybe_unused , +void (*timer)(void *arg)__maybe_unused , +void *arg__maybe_unused , +int delay_secs__maybe_unused ) {return 0 ; }
tools/perf/util/build-id.c +6 -5
@@ -16,10 +16,10 @@#include "session.h" #include "tool.h" -static int build_id__mark_dso_hit (struct perf_tool *tool__used , +static int build_id__mark_dso_hit (struct perf_tool *tool__maybe_unused ,union perf_event *event, -struct perf_sample *sample__used , -struct perf_evsel *evsel__used , +struct perf_sample *sample__maybe_unused , +struct perf_evsel *evsel__maybe_unused ,struct machine *machine) {struct addr_location al;
@@ -41,9 +41,10 @@ static int build_id__mark_dso_hit(struct perf_tool *tool __used,return 0 ; } -static int perf_event__exit_del_thread (struct perf_tool *tool__used , +static int perf_event__exit_del_thread (struct perf_tool *tool__maybe_unused ,union perf_event *event, -struct perf_sample *sample__used , +struct perf_sample *sample +__maybe_unused ,struct machine *machine) {struct thread *thread =machine__findnew_thread (machine, event->fork.tid);
tools/perf/util/cache.h +3 -3
@@ -39,7 +39,7 @@ static inline void setup_browser(bool fallback_to_pager)if (fallback_to_pager) setup_pager(); } -static inline void exit_browser (bool wait_for_ok__used ) {} +static inline void exit_browser (bool wait_for_ok__maybe_unused ) {}#else void setup_browser (bool fallback_to_pager);void exit_browser (bool wait_for_ok);
@@ -49,7 +49,7 @@ static inline int ui__init(void) {return -1 ; } -static inline void ui__exit (bool wait_for_ok__used ) {} +static inline void ui__exit (bool wait_for_ok__maybe_unused ) {}#else int ui__init (void );void ui__exit (bool wait_for_ok);
@@ -60,7 +60,7 @@ static inline int perf_gtk__init(void) {return -1 ; } -static inline void perf_gtk__exit (bool wait_for_ok__used ) {} +static inline void perf_gtk__exit (bool wait_for_ok__maybe_unused ) {}#else int perf_gtk__init (void );void perf_gtk__exit (bool wait_for_ok);
tools/perf/util/callchain.c +3 -3
@@ -93,7 +93,7 @@ __sort_chain_flat(struct rb_root *rb_root, struct callchain_node *node,*/ static void sort_chain_flat (struct rb_root *rb_root,struct callchain_root *root, -u64 min_hit,struct callchain_param *param__used ) +u64 min_hit,struct callchain_param *param__maybe_unused ) {__sort_chain_flat (rb_root, &root->node, min_hit); }
@@ -115,7 +115,7 @@ static void __sort_chain_graph_abs(struct callchain_node *node,static void sort_chain_graph_abs (struct rb_root *rb_root,struct callchain_root *chain_root, -u64 min_hit,struct callchain_param *param__used ) +u64 min_hit,struct callchain_param *param__maybe_unused ) {__sort_chain_graph_abs (&chain_root->node, min_hit); rb_root->rb_node = chain_root->node.rb_root.rb_node;
@@ -140,7 +140,7 @@ static void __sort_chain_graph_rel(struct callchain_node *node,static void sort_chain_graph_rel (struct rb_root *rb_root,struct callchain_root *chain_root, -u64 min_hit__used ,struct callchain_param *param) +u64 min_hit__maybe_unused ,struct callchain_param *param) {__sort_chain_graph_rel (&chain_root->node, param->min_percent /100.0 ); rb_root->rb_node = chain_root->node.rb_root.rb_node;
tools/perf/util/cgroup.c +2 -2
@@ -138,8 +138,8 @@ void close_cgroup(struct cgroup_sel *cgrp) } } -int parse_cgroups (const struct option *opt__used ,const char *str, -int unset__used ) +int parse_cgroups (const struct option *opt__maybe_unused ,const char *str, +int unset__maybe_unused ) {struct perf_evlist *evlist = *(struct perf_evlist **)opt->value;const char *p, *e, *eos = str +strlen (str);
tools/perf/util/config.c +4 -2
@@ -342,13 +342,15 @@ const char *perf_config_dirname(const char *name, const char *value)return value; } -static int perf_default_core_config (const char *var__used ,const char *value__used ) +static int perf_default_core_config (const char *var__maybe_unused , +const char *value__maybe_unused ) {/* Add other config variables here. */ return 0 ; } -int perf_default_config (const char *var,const char *value,void *dummy__used ) +int perf_default_config (const char *var,const char *value, +void *dummy__maybe_unused ) {if (!prefixcmp (var,"core." ))return perf_default_core_config (var, value);
tools/perf/util/debug.h +5 -4
@@ -16,19 +16,20 @@ struct ui_progress;struct perf_error_ops ;#if defined(NO_NEWT_SUPPORT ) && defined(NO_GTK2_SUPPORT ) -static inline void ui_progress__update (u64 curr__used ,u64 total__used , -const char *title__used ) {} +static inline void ui_progress__update (u64 curr__maybe_unused , +u64 total__maybe_unused , +const char *title__maybe_unused ) {} #define ui__error(format, arg...) ui__warning(format, ##arg)static inline int -perf_error__register (struct perf_error_ops *eops__used ) +perf_error__register (struct perf_error_ops *eops__maybe_unused ) {return 0 ; }static inline int -perf_error__unregister (struct perf_error_ops *eops__used ) +perf_error__unregister (struct perf_error_ops *eops__maybe_unused ) {return 0 ; }
tools/perf/util/event.c +10 -9
@@ -514,9 +514,9 @@ size_t perf_event__fprintf_comm(union perf_event *event, FILE *fp)return fprintf (fp,": %s:%d\n" , event->comm.comm, event->comm.tid); } -int perf_event__process_comm (struct perf_tool *tool__used , +int perf_event__process_comm (struct perf_tool *tool__maybe_unused ,union perf_event *event, -struct perf_sample *sample__used , +struct perf_sample *sample__maybe_unused ,struct machine *machine) {struct thread *thread =machine__findnew_thread (machine, event->comm.tid);
@@ -532,10 +532,10 @@ int perf_event__process_comm(struct perf_tool *tool __used,return 0 ; } -int perf_event__process_lost (struct perf_tool *tool__used , +int perf_event__process_lost (struct perf_tool *tool__maybe_unused ,union perf_event *event, -struct perf_sample *sample__used , -struct machine *machine__used ) +struct perf_sample *sample__maybe_unused , +struct machine *machine__maybe_unused ) {dump_printf (": id:%" PRIu64": lost:%" PRIu64"\n" , event->lost.id, event->lost.lost);
@@ -555,7 +555,8 @@ static void perf_event__set_kernel_mmap_len(union perf_event *event, maps[MAP__FUNCTION ]->end = ~0ULL ; } -static int perf_event__process_kernel_mmap (struct perf_tool *tool__used , +static int perf_event__process_kernel_mmap (struct perf_tool *tool +__maybe_unused ,union perf_event *event,struct machine *machine) {
@@ -657,7 +658,7 @@ size_t perf_event__fprintf_mmap(union perf_event *event, FILE *fp)int perf_event__process_mmap (struct perf_tool *tool,union perf_event *event, -struct perf_sample *sample__used , +struct perf_sample *sample__maybe_unused ,struct machine *machine) {struct thread *thread;
@@ -701,9 +702,9 @@ size_t perf_event__fprintf_task(union perf_event *event, FILE *fp) event->fork.ppid, event->fork.ptid); } -int perf_event__process_task (struct perf_tool *tool__used , +int perf_event__process_task (struct perf_tool *tool__maybe_unused ,union perf_event *event, -struct perf_sample *sample__used , +struct perf_sample *sample__maybe_unused ,struct machine *machine) {struct thread *thread =machine__findnew_thread (machine, event->fork.tid);
tools/perf/util/header.c +50 -43
245 lines not on this page · raw message
tools/perf/util/help.c +2 -1
@@ -332,7 +332,8 @@ const char *help_unknown_cmd(const char *cmd)exit (1 ); } -int cmd_version (int argc__used ,const char **argv__used ,const char *prefix__used ) +int cmd_version (int argc__maybe_unused ,const char **argv__maybe_unused , +const char *prefix__maybe_unused ) {printf ("perf version %s\n" , perf_version_string);return 0 ;
tools/perf/util/hist.c +1 -1
@@ -394,7 +394,7 @@ void hist_entry__free(struct hist_entry *he)* collapse the histogram */ -static bool hists__collapse_insert_entry (struct hists *hists__used , +static bool hists__collapse_insert_entry (struct hists *hists__maybe_unused ,struct rb_root *root,struct hist_entry *he) {
tools/perf/util/hist.h +17 -15
@@ -119,20 +119,22 @@ struct perf_evlist;#ifdef NO_NEWT_SUPPORT static inline -int perf_evlist__tui_browse_hists (struct perf_evlist *evlist__used , -const char *help__used , -void (*timer)(void *arg)__used , -void *arg__used , -int refresh__used ) +int perf_evlist__tui_browse_hists (struct perf_evlist *evlist__maybe_unused , +const char *help__maybe_unused , +void (*timer)(void *arg)__maybe_unused , +void *arg__maybe_unused , +int refresh__maybe_unused ) {return 0 ; } -static inline int hist_entry__tui_annotate (struct hist_entry *self__used , -int evidx__used , -void (*timer)(void *arg)__used , -void *arg__used , -int delay_secs__used ) +static inline int hist_entry__tui_annotate (struct hist_entry *self +__maybe_unused , +int evidx__maybe_unused , +void (*timer)(void *arg) +__maybe_unused , +void *arg__maybe_unused , +int delay_secs__maybe_unused ) {return 0 ; }
@@ -150,11 +152,11 @@ int perf_evlist__tui_browse_hists(struct perf_evlist *evlist, const char *help,#ifdef NO_GTK2_SUPPORT static inline -int perf_evlist__gtk_browse_hists (struct perf_evlist *evlist__used , -const char *help__used , -void (*timer)(void *arg)__used , -void *arg__used , -int refresh__used ) +int perf_evlist__gtk_browse_hists (struct perf_evlist *evlist__maybe_unused , +const char *help__maybe_unused , +void (*timer)(void *arg)__maybe_unused , +void *arg__maybe_unused , +int refresh__maybe_unused ) {return 0 ; }
tools/perf/util/include/linux/compiler.h +3 -1
@@ -9,7 +9,9 @@#define __attribute_const__#endif -#define __used __attribute__((__unused__)) +#ifndef __maybe_unused +#define __maybe_unused __attribute__((unused)) +#endif #define __packed __attribute__((__packed__))#ifndef __force
tools/perf/util/intlist.c +2 -2
@@ -11,7 +11,7 @@#include "intlist.h" -static struct rb_node *intlist__node_new (struct rblist *rblist__used , +static struct rb_node *intlist__node_new (struct rblist *rblist__maybe_unused ,const void *entry) {int i = (int )((long )entry);
@@ -31,7 +31,7 @@ static void int_node__delete(struct int_node *ilist)free (ilist); } -static void intlist__node_delete (struct rblist *rblist__used , +static void intlist__node_delete (struct rblist *rblist__maybe_unused ,struct rb_node *rb_node) { struct int_node *node = container_of(rb_node, struct int_node, rb_node);
tools/perf/util/map.h +1 -1
@@ -96,7 +96,7 @@ static inline u64 map__unmap_ip(struct map *map, u64 ip)return ip + map->start - map->pgoff; } -static inline u64 identity__map_ip (struct map *map__used ,u64 ip) +static inline u64 identity__map_ip (struct map *map__maybe_unused ,u64 ip) {return ip; }
tools/perf/util/parse-events-test.c +3 -3
@@ -569,7 +569,7 @@ static int test__group2(struct perf_evlist *evlist)return 0 ; } -static int test__group3 (struct perf_evlist *evlist__used ) +static int test__group3 (struct perf_evlist *evlist__maybe_unused ) {struct perf_evsel *evsel, *leader;
@@ -648,7 +648,7 @@ static int test__group3(struct perf_evlist *evlist __used)return 0 ; } -static int test__group4 (struct perf_evlist *evlist__used ) +static int test__group4 (struct perf_evlist *evlist__maybe_unused ) {struct perf_evsel *evsel, *leader;
@@ -684,7 +684,7 @@ static int test__group4(struct perf_evlist *evlist __used)return 0 ; } -static int test__group5 (struct perf_evlist *evlist__used ) +static int test__group5 (struct perf_evlist *evlist__maybe_unused ) {struct perf_evsel *evsel, *leader;
tools/perf/util/parse-events.c +4 -3
@@ -807,7 +807,8 @@ int parse_events_terms(struct list_head *terms, const char *str)return ret; } -int parse_events (struct perf_evlist *evlist,const char *str,int unset__used ) +int parse_events (struct perf_evlist *evlist,const char *str, +int unset__maybe_unused ) {struct parse_events_data__events data = { .list =LIST_HEAD_INIT (data.list),
@@ -833,14 +834,14 @@ int parse_events(struct perf_evlist *evlist, const char *str, int unset __used) }int parse_events_option (const struct option *opt,const char *str, -int unset__used ) +int unset__maybe_unused ) {struct perf_evlist *evlist = *(struct perf_evlist **)opt->value;return parse_events (evlist, str, unset); }int parse_filter (const struct option *opt,const char *str, -int unset__used ) +int unset__maybe_unused ) {struct perf_evlist *evlist = *(struct perf_evlist **)opt->value;struct perf_evsel *last =NULL ;
tools/perf/util/parse-events.l +1 -1
@@ -207,7 +207,7 @@ r{num_raw_hex} { return raw(yyscanner); } %% -int parse_events_wrap(void *scanner __used) +int parse_events_wrap(void *scanner __maybe_unused) { return 1; }
tools/perf/util/parse-events.y +2 -2
@@ -391,7 +391,7 @@ sep_slash_dc: '/' | ':' | %% -void parse_events_error(void *data __used, void *scanner __used, - char const *msg __used) +void parse_events_error(void *data __maybe_unused, void *scanner __maybe_unused, + char const *msg __maybe_unused) { }
tools/perf/util/parse-options.c +2 -1
@@ -557,7 +557,8 @@ int parse_options_usage(const char * const *usagestr, } -int parse_opt_verbosity_cb (const struct option *opt,const char *arg__used , +int parse_opt_verbosity_cb (const struct option *opt, +const char *arg__maybe_unused ,int unset) {int *target = opt->value;
tools/perf/util/perf_regs.h +1 -1
@@ -6,7 +6,7 @@#else #define PERF_REGS_MASK 0 -static inline const char *perf_reg_name (int id__used ) +static inline const char *perf_reg_name (int id__maybe_unused ) {return NULL ; }
tools/perf/util/pmu.y +3 -3
@@ -86,8 +86,8 @@ PP_VALUE %% -void perf_pmu_error(struct list_head *list __used, - char *name __used, - char const *msg __used) +void perf_pmu_error(struct list_head *list __maybe_unused, + char *name __maybe_unused, + char const *msg __maybe_unused) { }
tools/perf/util/probe-event.c +11 -10
@@ -41,7 +41,7 @@#include "symbol.h" #include "thread.h" #include "debugfs.h" -#include "trace-event.h" /* For __unused */ +#include "trace-event.h" /* For __maybe_unused */ #include "probe-event.h" #include "probe-finder.h" #include "session.h"
@@ -647,8 +647,8 @@ static int kprobe_convert_to_perf_probe(struct probe_trace_point *tp, }static int try_to_find_probe_trace_events (struct perf_probe_event *pev, - struct probe_trace_event **tevs __unused, - int max_tevs __unused, const char *target) +struct probe_trace_event **tevs__maybe_unused , +int max_tevs__maybe_unused ,const char *target) {if (perf_probe_event_need_dwarf (pev)) {pr_warning ("Debuginfo-analysis is not supported.\n" );
@@ -661,17 +661,18 @@ static int try_to_find_probe_trace_events(struct perf_probe_event *pev,return 0 ; } -int show_line_range(struct line_range *lr __unused, const char *module __unused) +int show_line_range (struct line_range *lr__maybe_unused , +const char *module__maybe_unused ) {pr_warning ("Debuginfo-analysis is not supported.\n" );return -ENOSYS ; } -int show_available_vars(struct perf_probe_event *pevs __unused, - int npevs __unused, int max_vls __unused, - const char *module __unused, - struct strfilter *filter __unused, - bool externs __unused) +int show_available_vars (struct perf_probe_event *pevs__maybe_unused , +int npevs__maybe_unused ,int max_vls__maybe_unused , +const char *module__maybe_unused , +struct strfilter *filter__maybe_unused , +bool externs__maybe_unused ) {pr_warning ("Debuginfo-analysis is not supported.\n" );return -ENOSYS ;
@@ -2183,7 +2184,7 @@ static struct strfilter *available_func_filter;* If a symbol corresponds to a function with global binding and * matches filter return 0. For all others return 1. */ -static int filter_available_functions(struct map *map __unused, +static int filter_available_functions (struct map *map__maybe_unused ,struct symbol *sym) { if (sym->binding == STB_GLOBAL &&
tools/perf/util/probe-finder.c +2 -2
@@ -207,7 +207,7 @@ static int debuginfo__init_online_kernel_dwarf(struct debuginfo *self,#else /* With older elfutils, this just support kernel module... */ static int debuginfo__init_online_kernel_dwarf (struct debuginfo *self, -Dwarf_Addr addr__used ) +Dwarf_Addr addr__maybe_unused ) {const char *path =kernel_get_module_path ("kernel" );
@@ -1419,7 +1419,7 @@ static int line_range_add_line(const char *src, unsigned int lineno, }static int line_range_walk_cb (const char *fname,int lineno, -Dwarf_Addr addr__used , +Dwarf_Addr addr__maybe_unused ,void *data) {struct line_finder *lf = data;
tools/perf/util/python.c +5 -3
@@ -672,7 +672,7 @@ struct pyrf_evlist { };static int pyrf_evlist__init (struct pyrf_evlist *pevlist, -PyObject *args,PyObject *kwargs__used ) +PyObject *args,PyObject *kwargs__maybe_unused ) {PyObject *pcpus =NULL , *pthreads =NULL ;struct cpu_map *cpus;
@@ -733,7 +733,8 @@ static PyObject *pyrf_evlist__poll(struct pyrf_evlist *pevlist, }static PyObject *pyrf_evlist__get_pollfd (struct pyrf_evlist *pevlist, -PyObject *args__used ,PyObject *kwargs__used ) +PyObject *args__maybe_unused , +PyObject *kwargs__maybe_unused ) {struct perf_evlist *evlist = &pevlist->evlist;PyObject *list =PyList_New (0 );
@@ -765,7 +766,8 @@ free_list:static PyObject *pyrf_evlist__add (struct pyrf_evlist *pevlist, -PyObject *args,PyObject *kwargs__used ) +PyObject *args, +PyObject *kwargs__maybe_unused ) {struct perf_evlist *evlist = &pevlist->evlist;PyObject *pevsel;
tools/perf/util/scripting-engines/trace-event-perl.c +4 -4
@@ -257,10 +257,10 @@ static inline struct event_format *find_cache_event(struct perf_evsel *evsel)return event; } -static void perl_process_tracepoint(union perf_event *perf_event __unused, +static void perl_process_tracepoint (union perf_event *perf_event__maybe_unused ,struct perf_sample *sample,struct perf_evsel *evsel, - struct machine *machine __unused, +struct machine *machine__maybe_unused ,struct addr_location *al) {struct format_field *field;
@@ -349,8 +349,8 @@ static void perl_process_tracepoint(union perf_event *perf_event __unused,static void perl_process_event_generic (union perf_event *event,struct perf_sample *sample,struct perf_evsel *evsel, - struct machine *machine __unused, - struct addr_location *al __unused) +struct machine *machine__maybe_unused , +struct addr_location *al__maybe_unused ) { dSP;
tools/perf/util/scripting-engines/trace-event-python.c +6 -4
@@ -221,10 +221,11 @@ static inline struct event_format *find_cache_event(struct perf_evsel *evsel)return event; } -static void python_process_tracepoint(union perf_event *perf_event __unused, +static void python_process_tracepoint (union perf_event *perf_event +__maybe_unused ,struct perf_sample *sample,struct perf_evsel *evsel, - struct machine *machine __unused, +struct machine *machine__maybe_unused ,struct addr_location *al) {PyObject *handler, *retval, *context, *t, *obj, *dict =NULL ;
@@ -339,10 +340,11 @@ static void python_process_tracepoint(union perf_event *perf_event __unused,Py_DECREF (t); } -static void python_process_general_event(union perf_event *perf_event __unused, +static void python_process_general_event (union perf_event *perf_event +__maybe_unused ,struct perf_sample *sample,struct perf_evsel *evsel, - struct machine *machine __unused, +struct machine *machine__maybe_unused ,struct addr_location *al) {PyObject *handler, *retval, *t, *dict;
tools/perf/util/session.c +27 -23
111 lines not on this page · raw message
tools/perf/util/sort.c +9 -5
@@ -172,7 +172,7 @@ static int hist_entry__dso_snprintf(struct hist_entry *self, char *bf,static int _hist_entry__sym_snprintf (struct map *map,struct symbol *sym,u64 ip,char level,char *bf,size_t size, -unsigned int width__used ) +unsigned int width__maybe_unused ) {size_t ret =0 ;
@@ -207,7 +207,8 @@ struct sort_entry sort_dso = { };static int hist_entry__sym_snprintf (struct hist_entry *self,char *bf, -size_t size,unsigned int width__used ) +size_t size, +unsigned int width__maybe_unused ) {return _hist_entry__sym_snprintf (self->ms.map, self->ms.sym, self->ip, self->level, bf, size, width);
@@ -250,7 +251,8 @@ sort__srcline_cmp(struct hist_entry *left, struct hist_entry *right) }static int hist_entry__srcline_snprintf (struct hist_entry *self,char *bf, -size_t size,unsigned int width__used ) +size_t size, +unsigned int width__maybe_unused ) {FILE *fp;char cmd[PATH_MAX +2 ], *path = self->srcline, *nl;
@@ -399,7 +401,8 @@ sort__sym_to_cmp(struct hist_entry *left, struct hist_entry *right) }static int hist_entry__sym_from_snprintf (struct hist_entry *self,char *bf, -size_t size,unsigned int width__used ) +size_t size, +unsigned int width__maybe_unused ) {struct addr_map_symbol *from = &self->branch_info->from; return _hist_entry__sym_snprintf(from->map, from->sym, from->addr,
@@ -408,7 +411,8 @@ static int hist_entry__sym_from_snprintf(struct hist_entry *self, char *bf, }static int hist_entry__sym_to_snprintf (struct hist_entry *self,char *bf, -size_t size,unsigned int width__used ) +size_t size, +unsigned int width__maybe_unused ) {struct addr_map_symbol *to = &self->branch_info->to; return _hist_entry__sym_snprintf(to->map, to->sym, to->addr,
tools/perf/util/symbol-minimal.c +16 -12
@@ -69,8 +69,9 @@ static int read_build_id(void *note_data, size_t note_len, void *bf,return -1 ; } -int filename__read_debuglink (const char *filename__used , -char *debuglink__used ,size_t size__used ) +int filename__read_debuglink (const char *filename__maybe_unused , +char *debuglink__maybe_unused , +size_t size__maybe_unused ) {return -1 ; }
@@ -241,7 +242,8 @@ out:return ret; } -int symsrc__init (struct symsrc *ss,struct dso *dso__used ,const char *name, +int symsrc__init (struct symsrc *ss,struct dso *dso__maybe_unused , +const char *name,enum dso_binary_type type) {int fd =open (name,O_RDONLY );
@@ -260,13 +262,13 @@ out_close:return -1 ; } -bool symsrc__possibly_runtime (struct symsrc *ss__used ) +bool symsrc__possibly_runtime (struct symsrc *ss__maybe_unused ) {/* Assume all sym sources could be a runtime image. */ return true; } -bool symsrc__has_symtab (struct symsrc *ss__used ) +bool symsrc__has_symtab (struct symsrc *ss__maybe_unused ) {return false; }
@@ -277,17 +279,19 @@ void symsrc__destroy(struct symsrc *ss)close (ss->fd); } -int dso__synthesize_plt_symbols (struct dso *dso__used , -struct symsrc *ss__used , -struct map *map__used , -symbol_filter_t filter__used ) +int dso__synthesize_plt_symbols (struct dso *dso__maybe_unused , +struct symsrc *ss__maybe_unused , +struct map *map__maybe_unused , +symbol_filter_t filter__maybe_unused ) {return 0 ; } -int dso__load_sym (struct dso *dso,struct map *map__used ,struct symsrc *ss, -struct symsrc *runtime_ss__used , -symbol_filter_t filter__used ,int kmodule__used ) +int dso__load_sym (struct dso *dso,struct map *map__maybe_unused , +struct symsrc *ss, +struct symsrc *runtime_ss__maybe_unused , +symbol_filter_t filter__maybe_unused , +int kmodule__maybe_unused ) {unsigned char *build_id[BUILD_ID_SIZE ];
tools/perf/util/symbol.c +1 -1
@@ -1755,7 +1755,7 @@ struct process_args { };static int symbol__in_kernel (void *arg,const char *name, -char type__used ,u64 start) +char type__maybe_unused ,u64 start) {struct process_args *args = arg;
tools/perf/util/symbol.h +4 -3
@@ -23,14 +23,15 @@#ifdef HAVE_CPLUS_DEMANGLE extern char *cplus_demangle (const char *,int ); -static inline char *bfd_demangle (void __used *v,const char *c,int i) +static inline char *bfd_demangle (void __maybe_unused *v,const char *c,int i) {return cplus_demangle (c, i); }#else #ifdef NO_DEMANGLE -static inline char *bfd_demangle (void __used *v,const char __used *c, -int __used i) +static inline char *bfd_demangle (void __maybe_unused *v, +const char __maybe_unused *c, +int __maybe_unused i) {return NULL ; }
tools/perf/util/trace-event-parse.c +2 -2
@@ -221,7 +221,7 @@ void print_event(struct pevent *pevent, int cpu, void *data, int size, }void parse_proc_kallsyms (struct pevent *pevent, - char *file, unsigned int size __unused) +char *file,unsigned int size__maybe_unused ) {unsigned long long addr;char *func;
@@ -253,7 +253,7 @@ void parse_proc_kallsyms(struct pevent *pevent, }void parse_ftrace_printk (struct pevent *pevent, - char *file, unsigned int size __unused) +char *file,unsigned int size__maybe_unused ) {unsigned long long addr;char *printk;
tools/perf/util/trace-event-scripting.c +18 -15
@@ -35,11 +35,11 @@ static int stop_script_unsupported(void)return 0 ; } -static void process_event_unsupported(union perf_event *event __unused, - struct perf_sample *sample __unused, - struct perf_evsel *evsel __unused, - struct machine *machine __unused, - struct addr_location *al __unused) +static void process_event_unsupported (union perf_event *event__maybe_unused , +struct perf_sample *sample__maybe_unused , +struct perf_evsel *evsel__maybe_unused , +struct machine *machine__maybe_unused , +struct addr_location *al__maybe_unused ) { }
@@ -52,17 +52,19 @@ static void print_python_unsupported_msg(void) "\n etc.\n"); } -static int python_start_script_unsupported(const char *script __unused, - int argc __unused, - const char **argv __unused) +static int python_start_script_unsupported (const char *script__maybe_unused , +int argc__maybe_unused , +const char **argv__maybe_unused ) {print_python_unsupported_msg ();return -1 ; } -static int python_generate_script_unsupported(struct pevent *pevent __unused, - const char *outfile __unused) +static int python_generate_script_unsupported (struct pevent *pevent +__maybe_unused , +const char *outfile +__maybe_unused ) {print_python_unsupported_msg ();
@@ -114,17 +116,18 @@ static void print_perl_unsupported_msg(void) "\n etc.\n"); } -static int perl_start_script_unsupported(const char *script __unused, - int argc __unused, - const char **argv __unused) +static int perl_start_script_unsupported (const char *script__maybe_unused , +int argc__maybe_unused , +const char **argv__maybe_unused ) {print_perl_unsupported_msg ();return -1 ; } -static int perl_generate_script_unsupported(struct pevent *pevent __unused, - const char *outfile __unused) +static int perl_generate_script_unsupported (struct pevent *pevent +__maybe_unused , +const char *outfile__maybe_unused ) {print_perl_unsupported_msg ();
tools/perf/util/unwind.c +20 -16
@@ -307,32 +307,36 @@ find_proc_info(unw_addr_space_t as, unw_word_t ip, unw_proc_info_t *pi, need_unwind_info, arg); } -static int access_fpreg (unw_addr_space_t __used as,unw_regnum_t __used num, -unw_fpreg_t __used *val,int __used __write, -void __used *arg) +static int access_fpreg (unw_addr_space_t __maybe_unused as, +unw_regnum_t __maybe_unused num, +unw_fpreg_t __maybe_unused *val, +int __maybe_unused __write, +void __maybe_unused *arg) {pr_err ("unwind: access_fpreg unsupported\n" );return -UNW_EINVAL ; } -static int get_dyn_info_list_addr (unw_addr_space_t __used as, -unw_word_t __used *dil_addr, -void __used *arg) +static int get_dyn_info_list_addr (unw_addr_space_t __maybe_unused as, +unw_word_t __maybe_unused *dil_addr, +void __maybe_unused *arg) {return -UNW_ENOINFO ; } -static int resume (unw_addr_space_t __used as,unw_cursor_t __used *cu, -void __used *arg) +static int resume (unw_addr_space_t __maybe_unused as, +unw_cursor_t __maybe_unused *cu, +void __maybe_unused *arg) {pr_err ("unwind: resume unsupported\n" );return -UNW_EINVAL ; }static int -get_proc_name (unw_addr_space_t __used as,unw_word_t __used addr, -char __used *bufp,size_t __used buf_len, -unw_word_t __used *offp,void __used *arg) +get_proc_name (unw_addr_space_t __maybe_unused as, +unw_word_t __maybe_unused addr, +char __maybe_unused *bufp,size_t __maybe_unused buf_len, +unw_word_t __maybe_unused *offp,void __maybe_unused *arg) {pr_err ("unwind: get_proc_name unsupported\n" );return -UNW_EINVAL ;
@@ -377,7 +381,7 @@ static int reg_value(unw_word_t *valp, struct regs_dump *regs, int id,return 0 ; } -static int access_mem (unw_addr_space_t __used as, +static int access_mem (unw_addr_space_t __maybe_unused as,unw_word_t addr,unw_word_t *valp,int __write,void *arg) {
@@ -422,7 +426,7 @@ static int access_mem(unw_addr_space_t __used as,return 0 ; } -static int access_reg (unw_addr_space_t __used as, +static int access_reg (unw_addr_space_t __maybe_unused as,unw_regnum_t regnum,unw_word_t *valp,int __write,void *arg) {
@@ -454,9 +458,9 @@ static int access_reg(unw_addr_space_t __used as,return 0 ; } -static void put_unwind_info (unw_addr_space_t __used as, -unw_proc_info_t *pi__used , -void *arg__used ) +static void put_unwind_info (unw_addr_space_t __maybe_unused as, +unw_proc_info_t *pi__maybe_unused , +void *arg__maybe_unused ) {pr_debug ("unwind: put_unwind_info called\n" ); }
tools/perf/util/unwind.h +6 -5
@@ -22,11 +22,12 @@ int unwind__get_entries(unwind_entry_cb_t cb, void *arg,int unwind__arch_reg_id (int regnum);#else static inline int -unwind__get_entries (unwind_entry_cb_t cb__used ,void *arg__used , -struct machine *machine__used , -struct thread *thread__used , -u64 sample_uregs__used , -struct perf_sample *data__used ) +unwind__get_entries (unwind_entry_cb_t cb__maybe_unused , +void *arg__maybe_unused , +struct machine *machine__maybe_unused , +struct thread *thread__maybe_unused , +u64 sample_uregs__maybe_unused , +struct perf_sample *data__maybe_unused ) {return 0 ; }
tools/perf/util/wrapper.c +2 -1
@@ -7,7 +7,8 @@* There's no pack memory to release - but stay close to the Git * version so wrap this away: */ -static inline void release_pack_memory (size_t size__used ,int flag__used ) +static inline void release_pack_memory (size_t size__maybe_unused , +int flag__maybe_unused ) { }
Signature · 1 line
1.7.9.5
Em Sat, Sep 08, 2012 at 03:43:12AM +0300, Irina Tirdea escreveu:
Quoted 4 lines
This is version 2 for the patches to port perf to Android. With these patches perf compiles on latest Android tree (JellyBean).
The patches are on top of current perf/core branch of the tip tree.
Thanks, I applied 6 out of 12, will revisit each of them later with comments after I think a about them a bit more,
- Arnaldo