perf tools: Fixes for some compile errors.
cover perf tools: Fixes for some compile errors.
Hi Arnaldo and all,
I met 3 compiling problems on my x86_32 machine, and these are the fixes, patch 1/3 only applies for perf/core branch of your git, while patch 2 applies to Linus' tree also. please review.
Thanks,
Feng
---
Feng Tang (3):
perf tools: Fix a compiling error in trace-event-perl.c for 32 bits
machine
Perf tools: Fix a compiling error in util/map.c
perf tools: Fix a misuse of for_each_set_bit() in session.c
tools/perf/util/map.c | 5 ++--- .../perf/util/scripting-engines/trace-event-perl.c | 2 +- tools/perf/util/session.c | 9 ++++----- 3 files changed, 7 insertions(+), 9 deletions(-)
PATCH 1/3 perf tools: Fix a compiling error in trace-event-perl.c for 32 bits machine
On my x86_32 mahcine, there is a compile error:
CC util/scripting-engines/trace-event-perl.o
cc1: warnings being treated as errors
util/scripting-engines/trace-event-perl.c: In function ‘perl_process_tracepoint’:
util/scripting-engines/trace-event-perl.c:285: error: format ‘%d’ expects type ‘int’, but argument 2 has type ‘__u64’
make: *** [util/scripting-engines/trace-event-perl.o] Error 1
Fix it by using the "%lld" for __u64.
--- .../perf/util/scripting-engines/trace-event-perl.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
tools/perf/util/scripting-engines/trace-event-perl.c +1 -1
@@ -282,7 +282,7 @@ static void perl_process_tracepoint(union perf_event *perf_event __unused, event =find_cache_event (evsel);if (!event) -die ("ug! no event found for type %d" , evsel->attr.config); +die ("ug! no event found for type %lld" , evsel->attr.config); pid =raw_field_value (event,"common_pid" , data);
Signature · 1 line
1.7.1
PATCH 2/3 Perf tools: Fix a compiling error in util/map.c
In reply to Feng TangThis patch fix a compile warning taken as error:
CC util/map.o
cc1: warnings being treated as errors
util/map.c: In function ‘map__fprintf_dsoname’:
util/map.c:240: error: ‘dsoname’ may be used uninitialized in this function
make: *** [util/map.o] Error 1
--- tools/perf/util/map.c | 5 ++--- 1 files changed, 2 insertions(+), 3 deletions(-)
tools/perf/util/map.c +2 -3
@@ -237,15 +237,14 @@ size_t map__fprintf(struct map *self, FILE *fp)size_t map__fprintf_dsoname (struct map *map,FILE *fp) { -const char *dsoname; +const char *dsoname ="[unknown]" ;if (map && map->dso && (map->dso->name || map->dso->long_name)) {if (symbol_conf.show_kernel_path && map->dso->long_name) dsoname = map->dso->long_name;else if (map->dso->name) dsoname = map->dso->name; - }else - dsoname ="[unknown]" ; + }return fprintf (fp,"%s" , dsoname); }
Signature · 1 line
1.7.1
PATCH 3/3 perf tools: Fix a misuse of for_each_set_bit() in session.c
In reply to Feng TangIn regs_dump__printf() it use for_each_set_bit() for bit ops by casting a (u64 *) to a (unsigned long *), this works for 64 bits machine, but will fail on 32 bits ones.
Fix it by using the raw bit comparing method.
--- tools/perf/util/session.c | 9 ++++----- 1 files changed, 4 insertions(+), 5 deletions(-)
tools/perf/util/session.c +4 -5
@@ -904,11 +904,10 @@ static void regs_dump__printf(u64 mask, u64 *regs) {unsigned rid, i =0 ; -for_each_set_bit (rid, (unsigned long *) &mask,sizeof (mask) *8 ) { -u64 val = regs[i++]; - -printf (".... %-5s 0x%" PRIx64"\n" , -perf_reg_name (rid), val); +for (rid =0 ; rid <64 ; rid++) { +if (mask & (1 << rid)) +printf (".... %-5s 0x%" PRIx64"\n" , +perf_reg_name (rid), regs[i++]); } }
Signature · 1 line
1.7.1
Namhyung Kim
maintainerRe: [PATCH 3/3] perf tools: Fix a misuse of for_each_set_bit() in session.c
Hi,
Quoted 5 lines · Feng Tang
In
regs_dump__printf()it usefor_each_set_bit()for bit ops by casting a (u64 *) to a (unsigned long *), this works for 64 bits machine, but will fail on 32 bits ones.Fix it by using the raw bit comparing method.
Did it really cause a build failure or a program error? If not, it looks better to keep using for_each_set_bit() interface. How about casting the @mask to (void *) ?
Thanks,
Namhyung
Quoted 25 lines
Signed-off-by Feng Tang <[email protected]>--- tools/perf/util/session.c | 9 ++++----- 1 files changed, 4 insertions(+), 5 deletions(-)tools/perf/util/session.c +4
-5@@ -904,11 +904,10 @@ static void regs_dump__printf(u64 mask, u64 *regs) {unsigned rid, i =0 ; -for_each_set_bit (rid, (unsigned long *) &mask,sizeof (mask) *8 ) { -u64 val = regs[i++]; - -printf (".... %-5s 0x%" PRIx64"\n" , -perf_reg_name (rid), val); +for (rid =0 ; rid <64 ; rid++) { +if (mask & (1 << rid)) +printf (".... %-5s 0x%" PRIx64"\n" , +perf_reg_name (rid), regs[i++]); } }
Re: [PATCH 3/3] perf tools: Fix a misuse of for_each_set_bit() in session.c
Hi,
Quoted 7 lines · On Mon, 27 Aug 2012 16:59:07 +0900 Namhyung Kim <[email protected]> wrote:
Hi,
Quoted 4 lines · Feng Tang
In
regs_dump__printf()it usefor_each_set_bit()for bit ops by casting a (u64 *) to a (unsigned long *), this works for 64 bits machine, but will fail on 32 bits ones.
Quoted 5 lines
Quoted 1 line
Fix it by using the raw bit comparing method.
Did it really cause a build failure or a program error? If not, it looks better to keep using
for_each_set_bit()interface. How about casting the @mask to (void *) ?
It's a compile error:
cc1: warnings being treated as errorsutil/session.c: In function ‘perf_session_deliver_event’:util/include/linux/bitops.h:104: error: dereferencing pointer ‘p’ does break strict-aliasing rules util/include/linux/bitops.h:96: error: dereferencing pointer ‘p’ does break strict-aliasing rules util/session.c:907: note: initialized from hereutil/include/linux/bitops.h:96: note: initialized from here
make: *** [util/session.o] Error 1
make: *** Waiting for unfinished jobs....
Casting the @mask to (void *) still sees the same error
Thanks,
Feng
Re: [PATCH 1/3] perf tools: Fix a compiling error in trace-event-perl.c for 32 bits machine
In reply to Feng TangEm Mon, Aug 27, 2012 at 03:38:25PM +0800, Feng Tang escreveu:
Quoted 20 lines
On my
x86_32mahcine, there is a compile error:CC
util/scripting-engines/trace-event-perl.o
cc1: warnings being treated as errors
util/scripting-engines/trace-event-perl.c: In function ‘perl_process_tracepoint’:
util/scripting-engines/trace-event-perl.c:285: error: format ‘%d’ expects type ‘int’, but argument 2 has type ‘__u64’
make: *** [util/scripting-engines/trace-event-perl.o] Error 1Fix it by using the "%lld" for
__u64.Signed-off-by Feng Tang <[email protected]>--- .../perf/util/scripting-engines/trace-event-perl.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)tools/perf/util/scripting-engines/trace-event-perl.c +0
-0
tools/perf/util/scripting-engines/trace-event-perl.c static void perl_process_tracepoint(union perf_event *perf_event __unused, · line 285
Quoted 5 lines
tools/perf/util/scripting-engines/trace-event-perl.c +1
-1@@ -282,7 +282,7 @@ static void perl_process_tracepoint(union perf_event *perf_event __unused, event =find_cache_event (evsel);if (!event) -die ("ug! no event found for type %d" , evsel->attr.config); +die ("ug! no event found for type %lld" , evsel->attr.config);
Please use PRIu64 instead, like in:
grep PRIu64 tools/perf/*/*.c
Quoted 4 lines
tools/perf/util/scripting-engines/trace-event-perl.c +0
-0pid =raw_field_value (event,"common_pid" , data);Signature · 1 line
1.7.1
PATCH v2 1/3 perf tools: Fix a compiling error in trace-event-perl.c for 32 bits machine
Quoted 1 line
From
8e2fe258906fc83869be10a1b4a40ef9acc4a2a6Mon Sep 17 00:00:00 2001
From: Feng Tang <[email protected]>
Date: Mon, 27 Aug 2012 14:01:33 +0800
Subject: [PATCH 1/3] perf tools: Fix a compiling error in trace-event-perl.c for 32 bits machine
On my x86_32 mahcine, there is a compile error:
CC util/scripting-engines/trace-event-perl.o
cc1: warnings being treated as errors
util/scripting-engines/trace-event-perl.c: In function ‘perl_process_tracepoint’:
util/scripting-engines/trace-event-perl.c:285: error: format ‘%d’ expects type ‘int’, but argument 2 has type ‘__u64’
make: *** [util/scripting-engines/trace-event-perl.o] Error 1
Fix it by using the "%PRIu64" for __u64.
v2: use PRIu64 as suggested by Arnaldo.
--- .../perf/util/scripting-engines/trace-event-perl.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
tools/perf/util/scripting-engines/trace-event-perl.c +1 -1
@@ -282,7 +282,7 @@ static void perl_process_tracepoint(union perf_event *perf_event __unused, event =find_cache_event (evsel);if (!event) -die ("ug! no event found for type %d" , evsel->attr.config); +die ("ug! no event found for type %" PRIu64, evsel->attr.config); pid =raw_field_value (event,"common_pid" , data);
Signature · 1 line
1.7.1
[tip:perf/core] perf tools: Fix a compiling error in trace-event-perl.c for 32 bits machine
Commit-ID: b1ab1bd1921536c2a97adb888effeff4370a3246 Gitweb: http://git.kernel.org/tip/b1ab1bd1921536c2a97adb888effeff4370a3246 Author: Feng Tang <[email protected]> AuthorDate: Thu, 20 Sep 2012 08:30:21 -0300 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Thu, 20 Sep 2012 08:30:21 -0300
perf tools: Fix a compiling error in trace-event-perl.c for 32 bits machine
On my x86_32 mahcine, there is a compile error:
CC util/scripting-engines/trace-event-perl.o
cc1: warnings being treated as errors util/scripting-engines/trace-event-perl.c: In function perl_process_tracepoint:
util/scripting-engines/trace-event-perl.c:285: error: format expects type 'int', but argument 2 has type '__u64'
make: *** [util/scripting-engines/trace-event-perl.o] Error 1
Fix it by using the "%PRIu64" for __u64.
v2: use PRIu64 as suggested by Arnaldo.
--- .../perf/util/scripting-engines/trace-event-perl.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
tools/perf/util/scripting-engines/trace-event-perl.c +1 -1
@@ -282,7 +282,7 @@ static void perl_process_tracepoint(union perf_event *perf_event __maybe_unused, event =find_cache_event (evsel);if (!event) -die ("ug! no event found for type %d" , evsel->attr.config); +die ("ug! no event found for type %" PRIu64, evsel->attr.config); pid =raw_field_value (event,"common_pid" , data);
[tip:perf/core] perf tools: Fix a compiling error in util/map.c
In reply to Feng TangCommit-ID: 8f28f19a87cb48d13570ba774a3e85776eb36bb4 Gitweb: http://git.kernel.org/tip/8f28f19a87cb48d13570ba774a3e85776eb36bb4 Author: Feng Tang <[email protected]> AuthorDate: Mon, 27 Aug 2012 15:38:26 +0800 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Thu, 20 Sep 2012 08:36:34 -0300
perf tools: Fix a compiling error in util/map.c
This patch fix a compile warning taken as error:
CC util/map.o
cc1: warnings being treated as errors
util/map.c: In function ‘map__fprintf_dsoname’:
util/map.c:240: error: ‘dsoname’ may be used uninitialized in this function
make: *** [util/map.o] Error 1
--- tools/perf/util/map.c | 5 ++--- 1 files changed, 2 insertions(+), 3 deletions(-)
tools/perf/util/map.c +2 -3
@@ -243,15 +243,14 @@ size_t map__fprintf(struct map *self, FILE *fp)size_t map__fprintf_dsoname (struct map *map,FILE *fp) { -const char *dsoname; +const char *dsoname ="[unknown]" ;if (map && map->dso && (map->dso->name || map->dso->long_name)) {if (symbol_conf.show_kernel_path && map->dso->long_name) dsoname = map->dso->long_name;else if (map->dso->name) dsoname = map->dso->name; - }else - dsoname ="[unknown]" ; + }return fprintf (fp,"%s" , dsoname); }
Re: [PATCH 3/3] perf tools: Fix a misuse of for_each_set_bit() in session.c
In reply to Feng TangQuoted 11 lines · Feng Tang
It's a compile error:
cc1: warnings being treated as errors
util/session.c: In function ‘perf_session_deliver_event’:util/include/linux/bitops.h:104: error:
dereferencing pointer ‘p’ does break strict-aliasing rulesutil/include/linux/bitops.h:96: error: dereferencing pointer ‘p’ does break strict-aliasing rulesutil/session.c:907: note: initialized from hereutil/include/linux/bitops.h:96: note: initialized from here make:
*** [util/session.o] Error 1
make: *** Waiting for unfinished jobs....
Quoted 4 lines
Casting the @mask to (void *) still sees the same error
Thanks,
Feng
We (ELRepo) are seeing the same error while building kernel 3.7 for RHEL 6.3 on a 32-bit system. The perf package would build fine if we run rpmbuild with the 'i686' target specified on a 64-bit system.
http://elrepo.org/bugs/view.php?id=335
Akemi