aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorNamhyung Kim <namhyung.kim@lge.com>2012-09-28 05:31:59 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2012-09-28 20:07:36 -0400
commit29a0fc9b2b6084e7a8810481df62a0fa496d8957 (patch)
treeb14fcf9ba9c906ae969daa242057b391bd93ba81 /tools
parente4898336a1b4d8a259663d15b12f359b6c2887a2 (diff)
perf tools: Convert to LIBELF_SUPPORT
For building perf without libelf, we can set NO_LIBELF=1 as a argument of make. It then defines NO_LIBELF_SUPPORT macro for C code to do the proper handling. However it usually used in a negative semantics - e.g. #ifndef - so we saw double negations which can be misleading. Convert it to a positive form to make it more readable. Signed-off-by: Namhyung Kim <namhyung@kernel.org> Cc: Ingo Molnar <mingo@kernel.org> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/1348824728-14025-4-git-send-email-namhyung@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/Makefile7
-rw-r--r--tools/perf/builtin-inject.c2
-rw-r--r--tools/perf/perf.c2
-rwxr-xr-xtools/perf/util/generate-cmdlist.sh4
-rw-r--r--tools/perf/util/map.c2
-rw-r--r--tools/perf/util/symbol.h10
6 files changed, 13 insertions, 14 deletions
diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index 9cd49130f438..1df09175d8d4 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -503,8 +503,6 @@ ifneq ($(OUTPUT),)
503endif 503endif
504 504
505ifdef NO_LIBELF 505ifdef NO_LIBELF
506BASIC_CFLAGS += -DNO_LIBELF_SUPPORT
507
508EXTLIBS := $(filter-out -lelf,$(EXTLIBS)) 506EXTLIBS := $(filter-out -lelf,$(EXTLIBS))
509 507
510# Remove ELF/DWARF dependent codes 508# Remove ELF/DWARF dependent codes
@@ -519,9 +517,10 @@ BUILTIN_OBJS := $(filter-out $(OUTPUT)builtin-probe.o,$(BUILTIN_OBJS))
519LIB_OBJS += $(OUTPUT)util/symbol-minimal.o 517LIB_OBJS += $(OUTPUT)util/symbol-minimal.o
520 518
521else # NO_LIBELF 519else # NO_LIBELF
520BASIC_CFLAGS += -DLIBELF_SUPPORT
522 521
523ifneq ($(call try-cc,$(SOURCE_ELF_MMAP),$(FLAGS_COMMON)),y) 522ifeq ($(call try-cc,$(SOURCE_ELF_MMAP),$(FLAGS_COMMON)),y)
524 BASIC_CFLAGS += -DLIBELF_NO_MMAP 523 BASIC_CFLAGS += -DLIBELF_MMAP
525endif 524endif
526 525
527ifndef NO_DWARF 526ifndef NO_DWARF
diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c
index 1eaa6617c814..b5ab084233fa 100644
--- a/tools/perf/builtin-inject.c
+++ b/tools/perf/builtin-inject.c
@@ -194,7 +194,7 @@ static int perf_event__inject_buildid(struct perf_tool *tool,
194 * account this as unresolved. 194 * account this as unresolved.
195 */ 195 */
196 } else { 196 } else {
197#ifndef NO_LIBELF_SUPPORT 197#ifdef LIBELF_SUPPORT
198 pr_warning("no symbols found in %s, maybe " 198 pr_warning("no symbols found in %s, maybe "
199 "install a debug package?\n", 199 "install a debug package?\n",
200 al.map->dso->long_name); 200 al.map->dso->long_name);
diff --git a/tools/perf/perf.c b/tools/perf/perf.c
index fc2f770e3027..dacae4b8bcb4 100644
--- a/tools/perf/perf.c
+++ b/tools/perf/perf.c
@@ -48,7 +48,7 @@ static struct cmd_struct commands[] = {
48 { "version", cmd_version, 0 }, 48 { "version", cmd_version, 0 },
49 { "script", cmd_script, 0 }, 49 { "script", cmd_script, 0 },
50 { "sched", cmd_sched, 0 }, 50 { "sched", cmd_sched, 0 },
51#ifndef NO_LIBELF_SUPPORT 51#ifdef LIBELF_SUPPORT
52 { "probe", cmd_probe, 0 }, 52 { "probe", cmd_probe, 0 },
53#endif 53#endif
54 { "kmem", cmd_kmem, 0 }, 54 { "kmem", cmd_kmem, 0 },
diff --git a/tools/perf/util/generate-cmdlist.sh b/tools/perf/util/generate-cmdlist.sh
index 389590c1ad21..3ac38031d534 100755
--- a/tools/perf/util/generate-cmdlist.sh
+++ b/tools/perf/util/generate-cmdlist.sh
@@ -22,7 +22,7 @@ do
22 }' "Documentation/perf-$cmd.txt" 22 }' "Documentation/perf-$cmd.txt"
23done 23done
24 24
25echo "#ifndef NO_LIBELF_SUPPORT" 25echo "#ifdef LIBELF_SUPPORT"
26sed -n -e 's/^perf-\([^ ]*\)[ ].* full.*/\1/p' command-list.txt | 26sed -n -e 's/^perf-\([^ ]*\)[ ].* full.*/\1/p' command-list.txt |
27sort | 27sort |
28while read cmd 28while read cmd
@@ -35,5 +35,5 @@ do
35 p 35 p
36 }' "Documentation/perf-$cmd.txt" 36 }' "Documentation/perf-$cmd.txt"
37done 37done
38echo "#endif /* NO_LIBELF_SUPPORT */" 38echo "#endif /* LIBELF_SUPPORT */"
39echo "};" 39echo "};"
diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c
index ead5316b3f89..6109fa4d14cd 100644
--- a/tools/perf/util/map.c
+++ b/tools/perf/util/map.c
@@ -162,7 +162,7 @@ int map__load(struct map *self, symbol_filter_t filter)
162 pr_warning(", continuing without symbols\n"); 162 pr_warning(", continuing without symbols\n");
163 return -1; 163 return -1;
164 } else if (nr == 0) { 164 } else if (nr == 0) {
165#ifndef NO_LIBELF_SUPPORT 165#ifdef LIBELF_SUPPORT
166 const size_t len = strlen(name); 166 const size_t len = strlen(name);
167 const size_t real_len = len - sizeof(DSO__DELETED); 167 const size_t real_len = len - sizeof(DSO__DELETED);
168 168
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h
index b441b07172b7..8b6ef7fac745 100644
--- a/tools/perf/util/symbol.h
+++ b/tools/perf/util/symbol.h
@@ -12,7 +12,7 @@
12#include <byteswap.h> 12#include <byteswap.h>
13#include <libgen.h> 13#include <libgen.h>
14 14
15#ifndef NO_LIBELF_SUPPORT 15#ifdef LIBELF_SUPPORT
16#include <libelf.h> 16#include <libelf.h>
17#include <gelf.h> 17#include <gelf.h>
18#include <elf.h> 18#include <elf.h>
@@ -46,10 +46,10 @@ char *strxfrchar(char *s, char from, char to);
46 * libelf 0.8.x and earlier do not support ELF_C_READ_MMAP; 46 * libelf 0.8.x and earlier do not support ELF_C_READ_MMAP;
47 * for newer versions we can use mmap to reduce memory usage: 47 * for newer versions we can use mmap to reduce memory usage:
48 */ 48 */
49#ifdef LIBELF_NO_MMAP 49#ifdef LIBELF_MMAP
50# define PERF_ELF_C_READ_MMAP ELF_C_READ
51#else
52# define PERF_ELF_C_READ_MMAP ELF_C_READ_MMAP 50# define PERF_ELF_C_READ_MMAP ELF_C_READ_MMAP
51#else
52# define PERF_ELF_C_READ_MMAP ELF_C_READ
53#endif 53#endif
54 54
55#ifndef DMGL_PARAMS 55#ifndef DMGL_PARAMS
@@ -233,7 +233,7 @@ struct symsrc {
233 int fd; 233 int fd;
234 enum dso_binary_type type; 234 enum dso_binary_type type;
235 235
236#ifndef NO_LIBELF_SUPPORT 236#ifdef LIBELF_SUPPORT
237 Elf *elf; 237 Elf *elf;
238 GElf_Ehdr ehdr; 238 GElf_Ehdr ehdr;
239 239