perf tools: Makefile and related cleanups
Namhyung Kim
maintainercover perf tools: Makefile and related cleanups
Hi,
This is what I found during reading the Makefile. Main goal is using positive macro name to reduce confusing when dealing with #ifdef's.
You can get it from my tree too:
git.kernel.org/pub/scm/linux/kernel/git/namhyung/linux-perf.git perf/makefile
Any comments are welcome, thanks.
Namhyung
Namhyung Kim (12):
perf tools: Move libdw availability check before arch Makefile perf tools: Remove unused PYRF_OBJS variable on Makefile perf tools: Convert to LIBELF_SUPPORT
perf tools: Convert to LIBUNWIND_SUPPORT
perf tools: Convert to LIBAUDIT_SUPPORT
perf tools: Convert to NEWT_SUPPORT
perf tools: Convert to GTK2_SUPPORT
perf tools: Convert to LIBPERL_SUPPORT
perf tools: Convert to LIBPYTHON_SUPPORT
perf tools: Convert to DEMANGLE_SUPPORT
perf tools: Convert to BACKTRACE_SUPPORT
perf tools: Convert to HAVE_STRLCPY
tools/perf/Makefile | 114 ++++++++++++-------------------- tools/perf/builtin-inject.c | 2 +- tools/perf/builtin-record.c | 14 ++-- tools/perf/builtin-script.c | 4 +- tools/perf/perf.c | 4 +- tools/perf/ui/gtk/util.c | 2 +- tools/perf/ui/helpline.h | 18 ++--- tools/perf/util/annotate.h | 8 +-- tools/perf/util/cache.h | 38 ++++++----- tools/perf/util/debug.c | 2 +- tools/perf/util/debug.h | 17 ++--- tools/perf/util/generate-cmdlist.sh | 4 +- tools/perf/util/hist.h | 27 ++++---- tools/perf/util/map.c | 2 +- tools/perf/util/path.c | 2 +- tools/perf/util/perf_regs.h | 4 +- tools/perf/util/symbol.h | 29 ++++---- tools/perf/util/trace-event-scripting.c | 20 +++--- tools/perf/util/unwind.h | 4 +- tools/perf/util/util.c | 4 +- 20 files changed, 149 insertions(+), 170 deletions(-)
Signature · 1 line
1.7.11.4
Namhyung Kim
maintainerPATCH 3/12 perf tools: Convert to LIBELF_SUPPORT
From: Namhyung Kim <[email protected]>
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.
--- tools/perf/Makefile | 7 +++---- tools/perf/builtin-inject.c | 2 +- tools/perf/perf.c | 2 +- tools/perf/util/generate-cmdlist.sh | 4 ++-- tools/perf/util/map.c | 2 +- tools/perf/util/symbol.h | 10 +++++----- 6 files changed, 13 insertions(+), 14 deletions(-)
tools/perf/Makefile +3 -4
@@ -503,8 +503,6 @@ ifneq ($(OUTPUT),) endif ifdef NO_LIBELF -BASIC_CFLAGS += -DNO_LIBELF_SUPPORT - EXTLIBS := $(filter-out -lelf,$(EXTLIBS)) # Remove ELF/DWARF dependent codes
@@ -519,9 +517,10 @@ BUILTIN_OBJS := $(filter-out $(OUTPUT)builtin-probe.o,$(BUILTIN_OBJS)) LIB_OBJS += $(OUTPUT)util/symbol-minimal.o else # NO_LIBELF +BASIC_CFLAGS += -DLIBELF_SUPPORT -ifneq ($(call try-cc,$(SOURCE_ELF_MMAP),$(FLAGS_COMMON)),y) - BASIC_CFLAGS += -DLIBELF_NO_MMAP +ifeq ($(call try-cc,$(SOURCE_ELF_MMAP),$(FLAGS_COMMON)),y) + BASIC_CFLAGS += -DLIBELF_MMAP endif ifndef NO_DWARF
tools/perf/builtin-inject.c +1 -1
@@ -194,7 +194,7 @@ static int perf_event__inject_buildid(struct perf_tool *tool,* account this as unresolved. */ }else { -#ifndef NO_LIBELF_SUPPORT +#ifdef LIBELF_SUPPORT pr_warning ("no symbols found in %s, maybe " "install a debug package?\n" , al.map->dso->long_name);
tools/perf/perf.c +1 -1
@@ -48,7 +48,7 @@ static struct cmd_struct commands[] = { { "version", cmd_version, 0 }, { "script", cmd_script, 0 }, { "sched", cmd_sched, 0 }, -#ifndef NO_LIBELF_SUPPORT +#ifdef LIBELF_SUPPORT { "probe", cmd_probe, 0 }, #endif { "kmem", cmd_kmem, 0 },
tools/perf/util/generate-cmdlist.sh +2 -2
@@ -22,7 +22,7 @@ do }' "Documentation/perf-$cmd.txt" done -echo "#ifndef NO_LIBELF_SUPPORT" +echo "#ifdef LIBELF_SUPPORT" sed -n -e 's/^perf-\([^ ]*\)[ ].* full.*/\1/p' command-list.txt | sort | while read cmd
@@ -35,5 +35,5 @@ do p }' "Documentation/perf-$cmd.txt" done -echo "#endif /* NO_LIBELF_SUPPORT */" +echo "#endif /* LIBELF_SUPPORT */" echo "};"
tools/perf/util/map.c +1 -1
@@ -162,7 +162,7 @@ int map__load(struct map *self, symbol_filter_t filter)pr_warning (", continuing without symbols\n" );return -1 ; }else if (nr ==0 ) { -#ifndef NO_LIBELF_SUPPORT +#ifdef LIBELF_SUPPORT const size_t len =strlen (name);const size_t real_len = len -sizeof (DSO__DELETED );
tools/perf/util/symbol.h +5 -5
@@ -12,7 +12,7 @@#include <byteswap.h> #include <libgen.h> -#ifndef NO_LIBELF_SUPPORT +#ifdef LIBELF_SUPPORT #include <libelf.h> #include <gelf.h> #include <elf.h>
@@ -46,10 +46,10 @@ char *strxfrchar(char *s, char from, char to);* libelf 0.8.x and earlier do not support ELF_C_READ_MMAP; * for newer versions we can use mmap to reduce memory usage: */ -#ifdef LIBELF_NO_MMAP -# define PERF_ELF_C_READ_MMAP ELF_C_READ -#else +#ifdef LIBELF_MMAP # define PERF_ELF_C_READ_MMAP ELF_C_READ_MMAP +#else +# define PERF_ELF_C_READ_MMAP ELF_C_READ#endif #ifndef DMGL_PARAMS
@@ -233,7 +233,7 @@ struct symsrc {int fd;enum dso_binary_type type; -#ifndef NO_LIBELF_SUPPORT +#ifdef LIBELF_SUPPORT Elf *elf;GElf_Ehdr ehdr;
Signature · 1 line
1.7.11.4
Namhyung Kim
maintainerPATCH 6/12 perf tools: Convert to NEWT_SUPPORT
In reply to Namhyung KimFrom: Namhyung Kim <[email protected]>
For building perf without libnewt, we can set NO_NEWT=1 as a argument of make. It then defines NO_NEWT_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.
--- tools/perf/Makefile | 8 +++----- tools/perf/ui/gtk/util.c | 2 +- tools/perf/ui/helpline.h | 10 +++++----- tools/perf/util/annotate.h | 8 ++++---- tools/perf/util/cache.h | 12 ++++++------ tools/perf/util/debug.c | 2 +- tools/perf/util/debug.h | 6 +++--- tools/perf/util/hist.h | 18 +++++++++--------- 8 files changed, 32 insertions(+), 34 deletions(-)
tools/perf/Makefile +3 -5
@@ -554,16 +554,14 @@ ifndef NO_LIBAUDIT endif endif -ifdef NO_NEWT - BASIC_CFLAGS += -DNO_NEWT_SUPPORT -else +ifndef NO_NEWT FLAGS_NEWT=$(ALL_CFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) -lnewt ifneq ($(call try-cc,$(SOURCE_NEWT),$(FLAGS_NEWT)),y) msg := $(warning newt not found, disables TUI support. Please install newt-devel or libnewt-dev); - BASIC_CFLAGS += -DNO_NEWT_SUPPORT else # Fedora has /usr/include/slang/slang.h, but ubuntu /usr/include/slang.h BASIC_CFLAGS += -I/usr/include/slang + BASIC_CFLAGS += -DNEWT_SUPPORT EXTLIBS += -lnewt -lslang LIB_OBJS += $(OUTPUT)ui/setup.o LIB_OBJS += $(OUTPUT)ui/browser.o
@@ -603,7 +601,7 @@ else LIB_OBJS += $(OUTPUT)ui/gtk/util.o LIB_OBJS += $(OUTPUT)ui/gtk/helpline.o # Make sure that it'd be included only once. - ifneq ($(findstring -DNO_NEWT_SUPPORT,$(BASIC_CFLAGS)),) + ifeq ($(findstring -DNEWT_SUPPORT,$(BASIC_CFLAGS)),) LIB_OBJS += $(OUTPUT)ui/setup.o LIB_OBJS += $(OUTPUT)ui/util.o endif
tools/perf/ui/gtk/util.c +1 -1
@@ -116,7 +116,7 @@ struct perf_error_ops perf_gtk_eops = {* FIXME: Functions below should be implemented properly. * For now, just add stubs for NO_NEWT=1 build. */ -#ifdef NO_NEWT_SUPPORT +#ifndef NEWT_SUPPORT void ui_progress__update (u64 curr__maybe_unused ,u64 total__maybe_unused ,const char *title__maybe_unused ) {
tools/perf/ui/helpline.h +5 -5
@@ -23,16 +23,16 @@ void ui_helpline__puts(const char *msg);extern char ui_helpline__current[512 ]; -#ifdef NO_NEWT_SUPPORT +#ifdef NEWT_SUPPORT +extern char ui_helpline__last_msg[]; +int ui_helpline__show_help (const char *format,va_list ap); +#else static inline int ui_helpline__show_help (const char *format__maybe_unused ,va_list ap__maybe_unused ) {return 0 ; } -#else -extern char ui_helpline__last_msg[]; -int ui_helpline__show_help (const char *format,va_list ap); -#endif /* NO_NEWT_SUPPORT */ +#endif /* NEWT_SUPPORT */ #ifdef NO_GTK2_SUPPORT static inline int perf_gtk__show_helpline(const char *format __maybe_unused,
tools/perf/util/annotate.h +4 -4
@@ -138,7 +138,10 @@ int symbol__tty_annotate(struct symbol *sym, struct map *map, int evidx, bool print_lines, bool full_paths, int min_pcnt, int max_lines); -#ifdef NO_NEWT_SUPPORT +#ifdef NEWT_SUPPORT +int symbol__tui_annotate (struct symbol *sym,struct map *map,int evidx, +void (*timer)(void *arg),void *arg,int delay_secs); +#else static inline int symbol__tui_annotate(struct symbol *sym __maybe_unused, struct map *map __maybe_unused, int evidx __maybe_unused,
@@ -148,9 +151,6 @@ static inline int symbol__tui_annotate(struct symbol *sym __maybe_unused, {return 0 ; } -#else -int symbol__tui_annotate (struct symbol *sym,struct map *map,int evidx, -void (*timer)(void *arg),void *arg,int delay_secs);#endif extern const char *disassembler_style;
tools/perf/util/cache.h +6 -6
@@ -33,7 +33,7 @@ extern int pager_use_color;extern int use_browser; -#if defined(NO_NEWT_SUPPORT ) && defined(NO_GTK2_SUPPORT ) +#if !defined(NEWT_SUPPORT ) && defined(NO_GTK2_SUPPORT )static inline void setup_browser (bool fallback_to_pager) {if (fallback_to_pager)
@@ -44,15 +44,15 @@ static inline void exit_browser(bool wait_for_ok __maybe_unused) {}void setup_browser (bool fallback_to_pager);void exit_browser (bool wait_for_ok); -#ifdef NO_NEWT_SUPPORT +#ifdef NEWT_SUPPORT +int ui__init (void ); +void ui__exit (bool wait_for_ok); +#else static inline int ui__init (void ) {return -1 ; }static inline void ui__exit (bool wait_for_ok__maybe_unused ) {} -#else -int ui__init (void ); -void ui__exit (bool wait_for_ok);#endif #ifdef NO_GTK2_SUPPORT
@@ -65,7 +65,7 @@ static inline void perf_gtk__exit(bool wait_for_ok __maybe_unused) {}int perf_gtk__init (void );void perf_gtk__exit (bool wait_for_ok);#endif -#endif /* NO_NEWT_SUPPORT && NO_GTK2_SUPPORT */ +#endif /* !NEWT_SUPPORT && NO_GTK2_SUPPORT */ char *alias_lookup (const char *alias);int split_cmdline (char *cmdline,const char ***argv);
tools/perf/util/debug.c +1 -1
@@ -49,7 +49,7 @@ int dump_printf(const char *fmt, ...)return ret; } -#if defined(NO_NEWT_SUPPORT ) && defined(NO_GTK2_SUPPORT ) +#if !defined(NEWT_SUPPORT ) && defined(NO_GTK2_SUPPORT )int ui__warning (const char *format, ...) {va_list args;
tools/perf/util/debug.h +3 -3
@@ -15,7 +15,7 @@ void trace_event(union perf_event *event);struct ui_progress ;struct perf_error_ops ; -#if defined(NO_NEWT_SUPPORT ) && defined(NO_GTK2_SUPPORT ) +#if !defined(NEWT_SUPPORT ) && defined(NO_GTK2_SUPPORT )static inline void ui_progress__update (u64 curr__maybe_unused ,u64 total__maybe_unused ,const char *title__maybe_unused ) {}
@@ -34,13 +34,13 @@ perf_error__unregister(struct perf_error_ops *eops __maybe_unused) return 0; } -#else /* NO_NEWT_SUPPORT && NO_GTK2_SUPPORT */ +#else /* !NEWT_SUPPORT && NO_GTK2_SUPPORT */ #include "../ui/progress.h" int ui__error (const char *format, ...) __attribute__((format (printf,1 ,2 )));#include "../ui/util.h" -#endif /* NO_NEWT_SUPPORT && NO_GTK2_SUPPORT */ +#endif /* !NEWT_SUPPORT && NO_GTK2_SUPPORT */ int ui__warning (const char *format, ...) __attribute__((format (printf,1 ,2 )));int ui__error_paranoid (void );
tools/perf/util/hist.h +9 -9
@@ -154,7 +154,15 @@ int hist_entry__period_snprintf(struct perf_hpp *hpp, struct hist_entry *he,struct perf_evlist ; -#ifdef NO_NEWT_SUPPORT +#ifdef NEWT_SUPPORT +#include "../ui/keysyms.h" +int hist_entry__tui_annotate (struct hist_entry *he,int evidx, +void (*timer)(void *arg),void *arg,int delay_secs); + +int perf_evlist__tui_browse_hists (struct perf_evlist *evlist,const char *help, +void (*timer)(void *arg),void *arg, +int refresh); +#else static inline int perf_evlist__tui_browse_hists(struct perf_evlist *evlist __maybe_unused, const char *help __maybe_unused,
@@ -177,14 +185,6 @@ static inline int hist_entry__tui_annotate(struct hist_entry *self }#define K_LEFT -1#define K_RIGHT -2 -#else -#include "../ui/keysyms.h" -int hist_entry__tui_annotate (struct hist_entry *he,int evidx, -void (*timer)(void *arg),void *arg,int delay_secs); - -int perf_evlist__tui_browse_hists (struct perf_evlist *evlist,const char *help, -void (*timer)(void *arg),void *arg, -int refresh);#endif #ifdef NO_GTK2_SUPPORT
Signature · 1 line
1.7.11.4
Namhyung Kim
maintainerPATCH 7/12 perf tools: Convert to GTK2_SUPPORT
In reply to Namhyung KimFrom: Namhyung Kim <[email protected]>
For building perf without gtk+2, we can set NO_GTK2=1 as a argument of make. It then defines NO_GTK2_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.
--- tools/perf/Makefile | 6 ++---- tools/perf/ui/helpline.h | 8 ++++---- tools/perf/util/cache.h | 28 +++++++++++++++------------- tools/perf/util/debug.c | 2 +- tools/perf/util/debug.h | 17 +++++++++-------- tools/perf/util/hist.h | 11 +++++------ 6 files changed, 36 insertions(+), 36 deletions(-)
tools/perf/Makefile +2 -4
@@ -583,17 +583,15 @@ ifndef NO_NEWT endif endif -ifdef NO_GTK2 - BASIC_CFLAGS += -DNO_GTK2_SUPPORT -else +ifndef NO_GTK2 FLAGS_GTK2=$(ALL_CFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) $(shell pkg-config --libs --cflags gtk+-2.0 2>/dev/null) ifneq ($(call try-cc,$(SOURCE_GTK2),$(FLAGS_GTK2)),y) msg := $(warning GTK2 not found, disables GTK2 support. Please install gtk2-devel or libgtk2.0-dev); - BASIC_CFLAGS += -DNO_GTK2_SUPPORT else ifeq ($(call try-cc,$(SOURCE_GTK2_INFOBAR),$(FLAGS_GTK2)),y) BASIC_CFLAGS += -DHAVE_GTK_INFO_BAR endif + BASIC_CFLAGS += -DGTK2_SUPPORT BASIC_CFLAGS += $(shell pkg-config --cflags gtk+-2.0 2>/dev/null) EXTLIBS += $(shell pkg-config --libs gtk+-2.0 2>/dev/null) LIB_OBJS += $(OUTPUT)ui/gtk/browser.o
tools/perf/ui/helpline.h +4 -4
@@ -34,14 +34,14 @@ static inline int ui_helpline__show_help(const char *format __maybe_unused, }#endif /* NEWT_SUPPORT */ -#ifdef NO_GTK2_SUPPORT +#ifdef GTK2_SUPPORT +int perf_gtk__show_helpline (const char *format,va_list ap); +#else static inline int perf_gtk__show_helpline (const char *format__maybe_unused ,va_list ap__maybe_unused ) {return 0 ; } -#else -int perf_gtk__show_helpline (const char *format,va_list ap); -#endif /* NO_GTK2_SUPPORT */ +#endif /* GTK2_SUPPORT */ #endif /* _PERF_UI_HELPLINE_H_ */
tools/perf/util/cache.h +15 -13
@@ -33,14 +33,7 @@ extern int pager_use_color;extern int use_browser; -#if !defined(NEWT_SUPPORT ) && defined(NO_GTK2_SUPPORT ) -static inline void setup_browser (bool fallback_to_pager) -{ -if (fallback_to_pager) -setup_pager (); -} -static inline void exit_browser (bool wait_for_ok__maybe_unused ) {} -#else +#if defined(NEWT_SUPPORT ) || defined(GTK2_SUPPORT )void setup_browser (bool fallback_to_pager);void exit_browser (bool wait_for_ok);
@@ -55,17 +48,26 @@ static inline int ui__init(void)static inline void ui__exit (bool wait_for_ok__maybe_unused ) {}#endif -#ifdef NO_GTK2_SUPPORT +#ifdef GTK2_SUPPORT +int perf_gtk__init (void ); +void perf_gtk__exit (bool wait_for_ok); +#else static inline int perf_gtk__init (void ) {return -1 ; }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);#endif -#endif /* !NEWT_SUPPORT && NO_GTK2_SUPPORT */ + +#else /* NEWT_SUPPORT || GTK2_SUPPORT */ + +static inline void setup_browser (bool fallback_to_pager) +{ +if (fallback_to_pager) +setup_pager (); +} +static inline void exit_browser (bool wait_for_ok__maybe_unused ) {} +#endif /* NEWT_SUPPORT || GTK2_SUPPORT */ char *alias_lookup (const char *alias);int split_cmdline (char *cmdline,const char ***argv);
tools/perf/util/debug.c +1 -1
@@ -49,7 +49,7 @@ int dump_printf(const char *fmt, ...)return ret; } -#if !defined(NEWT_SUPPORT ) && defined(NO_GTK2_SUPPORT ) +#if !defined(NEWT_SUPPORT ) && !defined(GTK2_SUPPORT )int ui__warning (const char *format, ...) {va_list args;
tools/perf/util/debug.h +9 -8
@@ -15,7 +15,14 @@ void trace_event(union perf_event *event);struct ui_progress ;struct perf_error_ops ; -#if !defined(NEWT_SUPPORT ) && defined(NO_GTK2_SUPPORT ) +#if defined(NEWT_SUPPORT ) || defined(GTK2_SUPPORT ) + +#include "../ui/progress.h" +int ui__error (const char *format, ...) __attribute__((format (printf,1 ,2 ))); +#include "../ui/util.h" + +#else +static inline void ui_progress__update (u64 curr__maybe_unused ,u64 total__maybe_unused ,const char *title__maybe_unused ) {}
@@ -34,13 +41,7 @@ perf_error__unregister(struct perf_error_ops *eops __maybe_unused) return 0; } -#else /* !NEWT_SUPPORT && NO_GTK2_SUPPORT */ - -#include "../ui/progress.h" -int ui__error (const char *format, ...) __attribute__((format (printf,1 ,2 ))); -#include "../ui/util.h" - -#endif /* !NEWT_SUPPORT && NO_GTK2_SUPPORT */ +#endif /* NEWT_SUPPORT || GTK2_SUPPORT */ int ui__warning (const char *format, ...) __attribute__((format (printf,1 ,2 )));int ui__error_paranoid (void );
tools/perf/util/hist.h +5 -6
@@ -187,7 +187,11 @@ static inline int hist_entry__tui_annotate(struct hist_entry *self#define K_RIGHT -2#endif -#ifdef NO_GTK2_SUPPORT +#ifdef GTK2_SUPPORT +int perf_evlist__gtk_browse_hists (struct perf_evlist *evlist,const char *help, +void (*timer)(void *arg),void *arg, +int refresh); +#else static inline int perf_evlist__gtk_browse_hists(struct perf_evlist *evlist __maybe_unused, const char *help __maybe_unused,
@@ -197,11 +201,6 @@ int perf_evlist__gtk_browse_hists(struct perf_evlist *evlist __maybe_unused, {return 0 ; } - -#else -int perf_evlist__gtk_browse_hists (struct perf_evlist *evlist,const char *help, -void (*timer)(void *arg),void *arg, -int refresh);#endif unsigned int hists__sort_list_width (struct hists *self);
Signature · 1 line
1.7.11.4
Namhyung Kim
maintainerPATCH 12/12 perf tools: Convert to HAVE_STRLCPY
In reply to Namhyung KimFrom: Namhyung Kim <[email protected]>
For similar reason of previous patches, convert NO_STRLCPY to positive HAVE_STRLCPY.
--- tools/perf/Makefile | 8 +++----- tools/perf/util/cache.h | 2 +- tools/perf/util/path.c | 2 +- 3 files changed, 5 insertions(+), 7 deletions(-)
tools/perf/Makefile +3 -5
@@ -744,11 +744,9 @@ ifeq ($(NO_PERF_REGS),0) BASIC_CFLAGS += -DHAVE_PERF_REGS endif -ifdef NO_STRLCPY - BASIC_CFLAGS += -DNO_STRLCPY -else - ifneq ($(call try-cc,$(SOURCE_STRLCPY),),y) - BASIC_CFLAGS += -DNO_STRLCPY +ifndef NO_STRLCPY + ifeq ($(call try-cc,$(SOURCE_STRLCPY),),y) + BASIC_CFLAGS += -DHAVE_STRLCPY endif endif
tools/perf/util/cache.h +1 -1
@@ -107,7 +107,7 @@ extern char *perf_path(const char *fmt, ...) __attribute__((format (printf, 1, 2extern char *perf_pathdup (const char *fmt, ...) __attribute__((format (printf,1 ,2 ))); -#ifdef NO_STRLCPY +#ifndef HAVE_STRLCPY extern size_t strlcpy (char *dest,const char *src,size_t size);#endif
tools/perf/util/path.c +1 -1
@@ -22,7 +22,7 @@ static const char *get_perf_dir(void)return "." ; } -#ifdef NO_STRLCPY +#ifndef HAVE_STRLCPY size_t strlcpy (char *dest,const char *src,size_t size) {size_t ret =strlen (src);
Signature · 1 line
1.7.11.4
Namhyung Kim
maintainerPATCH 11/12 perf tools: Convert to BACKTRACE_SUPPORT
In reply to Namhyung KimFrom: Namhyung Kim <[email protected]>
For building perf without stack backtrace debug, we can set NO_BACKTRACE=1 as a argument of make. It then defines NO_BACKTRACE 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 and add _SUPPORT suffix for consistency.
--- tools/perf/Makefile | 8 ++++---- tools/perf/util/util.c | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-)
tools/perf/Makefile +4 -4
@@ -45,6 +45,8 @@ include config/utilities.mak # # Define NO_LIBUNWIND if you do not want libunwind dependency for dwarf # backtrace post unwind. +# +# Define NO_BACKTRACE if you do not want stack backtrace debug feature $(OUTPUT)PERF-VERSION-FILE: .FORCE-PERF-VERSION-FILE @$(SHELL_PATH) util/PERF-VERSION-GEN $(OUTPUT)
@@ -751,10 +753,8 @@ else endif ifdef NO_BACKTRACE - BASIC_CFLAGS += -DNO_BACKTRACE -else - ifneq ($(call try-cc,$(SOURCE_BACKTRACE),),y) - BASIC_CFLAGS += -DNO_BACKTRACE + ifeq ($(call try-cc,$(SOURCE_BACKTRACE),),y) + BASIC_CFLAGS += -DBACKTRACE_SUPPORT endif endif
tools/perf/util/util.c +2 -2
@@ -1,7 +1,7 @@#include "../perf.h" #include "util.h" #include <sys/mman.h> -#ifndef NO_BACKTRACE +#ifdef BACKTRACE_SUPPORT #include <execinfo.h> #endif #include <stdio.h>
@@ -165,7 +165,7 @@ size_t hex_width(u64 v) }/* Obtain a backtrace and print it to stdout. */ -#ifndef NO_BACKTRACE +#ifdef BACKTRACE_SUPPORT void dump_stack (void ) {void *array[16 ];
Signature · 1 line
1.7.11.4
Namhyung Kim
maintainerPATCH 10/12 perf tools: Convert to DEMANGLE_SUPPORT
In reply to Namhyung KimFrom: Namhyung Kim <[email protected]>
For building perf without name demangling, we can set NO_DEMANGLE=1 as a argument of make. It then defines NO_DEMANGLE 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.
Also add _SUPPORT suffix for consistency and make PACKAGE variable has a string value "perf".
--- tools/perf/Makefile | 12 +++++++----- tools/perf/util/symbol.h | 19 +++++++++++-------- 2 files changed, 18 insertions(+), 13 deletions(-)
tools/perf/Makefile +7 -5
@@ -696,36 +696,38 @@ else endif endif -ifdef NO_DEMANGLE - BASIC_CFLAGS += -DNO_DEMANGLE -else +ifndef NO_DEMANGLE ifdef HAVE_CPLUS_DEMANGLE EXTLIBS += -liberty + BASIC_CFLAGS += -DDEMANGLE_SUPPORT BASIC_CFLAGS += -DHAVE_CPLUS_DEMANGLE else - FLAGS_BFD=$(ALL_CFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) -DPACKAGE='perf' -lbfd + FLAGS_BFD=$(ALL_CFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) -DPACKAGE='"perf"' -lbfd has_bfd := $(call try-cc,$(SOURCE_BFD),$(FLAGS_BFD)) ifeq ($(has_bfd),y) EXTLIBS += -lbfd + BASIC_CFLAGS += -DDEMANGLE_SUPPORT else FLAGS_BFD_IBERTY=$(FLAGS_BFD) -liberty has_bfd_iberty := $(call try-cc,$(SOURCE_BFD),$(FLAGS_BFD_IBERTY)) ifeq ($(has_bfd_iberty),y) EXTLIBS += -lbfd -liberty + BASIC_CFLAGS += -DDEMANGLE_SUPPORT else FLAGS_BFD_IBERTY_Z=$(FLAGS_BFD_IBERTY) -lz has_bfd_iberty_z := $(call try-cc,$(SOURCE_BFD),$(FLAGS_BFD_IBERTY_Z)) ifeq ($(has_bfd_iberty_z),y) EXTLIBS += -lbfd -liberty -lz + BASIC_CFLAGS += -DDEMANGLE_SUPPORT else FLAGS_CPLUS_DEMANGLE=$(ALL_CFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) -liberty has_cplus_demangle := $(call try-cc,$(SOURCE_CPLUS_DEMANGLE),$(FLAGS_CPLUS_DEMANGLE)) ifeq ($(has_cplus_demangle),y) EXTLIBS += -liberty + BASIC_CFLAGS += -DDEMANGLE_SUPPORT BASIC_CFLAGS += -DHAVE_CPLUS_DEMANGLE else msg := $(warning No bfd.h/libbfd found, install binutils-dev[el]/zlib-static to gain symbol demangling) - BASIC_CFLAGS += -DNO_DEMANGLE endif endif endif
tools/perf/util/symbol.h +11 -8
@@ -18,26 +18,29 @@#include <elf.h> #endif -#ifdef HAVE_CPLUS_DEMANGLE +#ifdef DEMANGLE_SUPPORT + +# ifdef HAVE_CPLUS_DEMANGLE extern char *cplus_demangle (const char *,int );static inline char *bfd_demangle (void __maybe_unused *v,const char *c,int i) {return cplus_demangle (c, i); } -#else -#ifdef NO_DEMANGLE +# else /* HAVE_CPLUS_DEMANGLE */ +# define PACKAGE "perf" +# include <bfd.h> +# endif /* HAVE_CPLUS_DEMANGLE */ + +#else /* DEMANGLE_SUPPORT */ +static inline char *bfd_demangle (void __maybe_unused *v,const char __maybe_unused *c,int __maybe_unused i) {return NULL ; } -#else -#define PACKAGE 'perf' -#include <bfd.h> -#endif -#endif +#endif /* DEMANGLE_SUPPORT */ int hex2u64 (const char *ptr,u64 *val);char *strxfrchar (char *s,char from,char to);
Signature · 1 line
1.7.11.4
Namhyung Kim
maintainerPATCH 9/12 perf tools: Convert to LIBPYTHON_SUPPORT
In reply to Namhyung KimFrom: Namhyung Kim <[email protected]>
For building perf without python scripting, we can set NO_LIBPYTHON=1 as a argument of make. It then defines NO_LIBPYTHON 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. Also add _SUPPORT suffix for consistency.
--- tools/perf/Makefile | 2 +- tools/perf/builtin-script.c | 2 +- tools/perf/util/trace-event-scripting.c | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-)
tools/perf/Makefile +1 -1
@@ -624,7 +624,6 @@ endif disable-python = $(eval $(disable-python_code)) define disable-python_code - BASIC_CFLAGS += -DNO_LIBPYTHON $(if $(1),$(warning No $(1) was found)) $(warning Python support won't be built) endef
@@ -684,6 +683,7 @@ else $(warning $(and ,)) $(error $(and ,)) else + BASIC_CFLAGS += -DLIBPYTHON_SUPPORT ALL_LDFLAGS += $(PYTHON_EMBED_LDFLAGS) EXTLIBS += $(PYTHON_EMBED_LIBADD) LIB_OBJS += $(OUTPUT)util/scripting-engines/trace-event-python.o
tools/perf/builtin-script.c +1 -1
@@ -1061,7 +1061,7 @@ int find_scripts(char **scripts_array, char **scripts_path_array)if (strstr (lang_path,"perl" ))continue ;#endif -#ifdef NO_LIBPYTHON +#ifndef LIBPYTHON_SUPPORT if (strstr (lang_path,"python" ))continue ;#endif
tools/perf/util/trace-event-scripting.c +5 -5
@@ -93,17 +93,17 @@ static void register_python_scripting(struct scripting_ops *scripting_ops) scripting_context =malloc (sizeof (struct scripting_context )); } -#ifdef NO_LIBPYTHON +#ifdef LIBPYTHON_SUPPORT +extern struct scripting_ops python_scripting_ops; +void setup_python_scripting (void ) { -register_python_scripting (&python_scripting_unsupported_ops); +register_python_scripting (&python_scripting_ops); }#else -extern struct scripting_ops python_scripting_ops; -void setup_python_scripting (void ) { -register_python_scripting (&python_scripting_ops); +register_python_scripting (&python_scripting_unsupported_ops); }#endif
Signature · 1 line
1.7.11.4
Namhyung Kim
maintainerPATCH 8/12 perf tools: Convert to LIBPERL_SUPPORT
In reply to Namhyung KimFrom: Namhyung Kim <[email protected]>
For building perf without perf scripting, we can set NO_LIBPERL=1 as a argument of make. It then defines NO_LIBPERL 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.
Also add _SUPPORT suffix for consistency and fix a few of indentation in Makefile.
--- tools/perf/Makefile | 19 ++++++++----------- tools/perf/builtin-script.c | 2 +- tools/perf/util/trace-event-scripting.c | 10 +++++----- 3 files changed, 14 insertions(+), 17 deletions(-)
tools/perf/Makefile +8 -11
@@ -606,20 +606,17 @@ ifndef NO_GTK2 endif endif -ifdef NO_LIBPERL - BASIC_CFLAGS += -DNO_LIBPERL -else - PERL_EMBED_LDOPTS = $(shell perl -MExtUtils::Embed -e ldopts 2>/dev/null) - PERL_EMBED_LDFLAGS = $(call strip-libs,$(PERL_EMBED_LDOPTS)) - PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS)) +ifndef NO_LIBPERL + PERL_EMBED_LDOPTS = $(shell perl -MExtUtils::Embed -e ldopts 2>/dev/null) + PERL_EMBED_LDFLAGS = $(call strip-libs,$(PERL_EMBED_LDOPTS)) + PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS)) PERL_EMBED_CCOPTS = `perl -MExtUtils::Embed -e ccopts 2>/dev/null` FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS) - ifneq ($(call try-cc,$(SOURCE_PERL_EMBED),$(FLAGS_PERL_EMBED)),y) - BASIC_CFLAGS += -DNO_LIBPERL - else - ALL_LDFLAGS += $(PERL_EMBED_LDFLAGS) - EXTLIBS += $(PERL_EMBED_LIBADD) + ifeq ($(call try-cc,$(SOURCE_PERL_EMBED),$(FLAGS_PERL_EMBED)),y) + BASIC_CFLAGS += -DLIBPERL_SUPPPORT + ALL_LDFLAGS += $(PERL_EMBED_LDFLAGS) + EXTLIBS += $(PERL_EMBED_LIBADD) LIB_OBJS += $(OUTPUT)util/scripting-engines/trace-event-perl.o LIB_OBJS += $(OUTPUT)scripts/perl/Perf-Trace-Util/Context.o endif
tools/perf/builtin-script.c +1 -1
@@ -1057,7 +1057,7 @@ int find_scripts(char **scripts_array, char **scripts_path_array)for_each_lang (scripts_path, scripts_dir, lang_dirent, lang_next) {snprintf (lang_path,MAXPATHLEN ,"%s/%s" , scripts_path, lang_dirent.d_name); -#ifdef NO_LIBPERL +#ifndef LIBPERL_SUPPORT if (strstr (lang_path,"perl" ))continue ;#endif
tools/perf/util/trace-event-scripting.c +5 -5
@@ -156,16 +156,16 @@ static void register_perl_scripting(struct scripting_ops *scripting_ops) scripting_context =malloc (sizeof (struct scripting_context )); } -#ifdef NO_LIBPERL +#ifdef LIBPERL_SUPPORT +extern struct scripting_ops perl_scripting_ops; +void setup_perl_scripting (void ) { -register_perl_scripting (&perl_scripting_unsupported_ops); +register_perl_scripting (&perl_scripting_ops); }#else -extern struct scripting_ops perl_scripting_ops; -void setup_perl_scripting (void ) { -register_perl_scripting (&perl_scripting_ops); +register_perl_scripting (&perl_scripting_unsupported_ops); }#endif
Signature · 1 line
1.7.11.4
Namhyung Kim
maintainerPATCH 5/12 perf tools: Convert to LIBAUDIT_SUPPORT
In reply to Namhyung KimFrom: Namhyung Kim <[email protected]>
For building perf without libaudit, we can set NO_LIBAUDIT=1 as a argument of make. It then defines NO_LIBAUDIT_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.
--- tools/perf/Makefile | 6 ++---- tools/perf/perf.c | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-)
tools/perf/Makefile +2 -4
@@ -543,14 +543,12 @@ ifndef NO_LIBUNWIND LIB_OBJS += $(OUTPUT)util/unwind.o endif -ifdef NO_LIBAUDIT - BASIC_CFLAGS += -DNO_LIBAUDIT_SUPPORT -else +ifndef NO_LIBAUDIT FLAGS_LIBAUDIT = $(ALL_CFLAGS) $(ALL_LDFLAGS) -laudit ifneq ($(call try-cc,$(SOURCE_LIBAUDIT),$(FLAGS_LIBAUDIT)),y) msg := $(warning No libaudit.h found, disables 'trace' tool, please install audit-libs-devel or libaudit-dev); - BASIC_CFLAGS += -DNO_LIBAUDIT_SUPPORT else + BASIC_CFLAGS += -DLIBAUDIT_SUPPORT BUILTIN_OBJS += $(OUTPUT)builtin-trace.o EXTLIBS += -laudit endif
tools/perf/perf.c +1 -1
@@ -55,7 +55,7 @@ static struct cmd_struct commands[] = { { "lock", cmd_lock, 0 }, { "kvm", cmd_kvm, 0 }, { "test", cmd_test, 0 }, -#ifndef NO_LIBAUDIT_SUPPORT +#ifdef LIBAUDIT_SUPPORT { "trace", cmd_trace, 0 }, #endif { "inject", cmd_inject, 0 },
Signature · 1 line
1.7.11.4
Namhyung Kim
maintainerPATCH 4/12 perf tools: Convert to LIBUNWIND_SUPPORT
In reply to Namhyung KimFrom: Namhyung Kim <[email protected]>
For building perf without libunwind, we can set NO_LIBUNWIND=1 as a argument of make. It then defines NO_LIBUNWIND_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.
Also change NO_PERF_REGS macro to HAVE_PERF_REGS for the same reason.
--- tools/perf/Makefile | 8 +++----- tools/perf/builtin-record.c | 14 +++++++------- tools/perf/util/perf_regs.h | 4 ++-- tools/perf/util/unwind.h | 4 ++-- 4 files changed, 14 insertions(+), 16 deletions(-)
tools/perf/Makefile +3 -5
@@ -535,9 +535,8 @@ endif # PERF_HAVE_DWARF_REGS endif # NO_DWARF endif # NO_LIBELF -ifdef NO_LIBUNWIND - BASIC_CFLAGS += -DNO_LIBUNWIND_SUPPORT -else +ifndef NO_LIBUNWIND + BASIC_CFLAGS += -DLIBUNWIND_SUPPORT EXTLIBS += $(LIBUNWIND_LIBS) BASIC_CFLAGS := $(LIBUNWIND_CFLAGS) $(BASIC_CFLAGS) BASIC_LDFLAGS := $(LIBUNWIND_LDFLAGS) $(BASIC_LDFLAGS)
@@ -747,8 +746,7 @@ ifeq ($(NO_PERF_REGS),0) ifeq ($(ARCH),x86) LIB_H += arch/x86/include/perf_regs.h endif -else - BASIC_CFLAGS += -DNO_PERF_REGS + BASIC_CFLAGS += -DHAVE_PERF_REGS endif ifdef NO_STRLCPY
tools/perf/builtin-record.c +7 -7
@@ -33,11 +33,11 @@#define CALLCHAIN_HELP "do call-graph (stack chain/backtrace) recording: " -#ifdef NO_LIBUNWIND_SUPPORT -static char callchain_help[] =CALLCHAIN_HELP "[fp]" ; -#else +#ifdef LIBUNWIND_SUPPORT static unsigned long default_stack_dump_size =8192 ;static char callchain_help[] =CALLCHAIN_HELP "[fp] dwarf" ; +#else +static char callchain_help[] =CALLCHAIN_HELP "[fp]" ;#endif enum write_mode_t {
@@ -800,7 +800,7 @@ error:return ret; } -#ifndef NO_LIBUNWIND_SUPPORT +#ifdef LIBUNWIND_SUPPORT static int get_stack_size (char *str,unsigned long *_size) {char *endptr;
@@ -826,7 +826,7 @@ static int get_stack_size(char *str, unsigned long *_size) max_size, str);return -1 ; } -#endif /* !NO_LIBUNWIND_SUPPORT */ +#endif /* LIBUNWIND_SUPPORT */ static int parse_callchain_opt(const struct option *opt __maybe_unused, const char *arg,
@@ -865,7 +865,7 @@ parse_callchain_opt(const struct option *opt __maybe_unused, const char *arg, "needed for -g fp\n");break ; -#ifndef NO_LIBUNWIND_SUPPORT +#ifdef LIBUNWIND_SUPPORT /* Dwarf style */ }else if (!strncmp (name,"dwarf" ,sizeof ("dwarf" ))) { ret =0 ;
@@ -883,7 +883,7 @@ parse_callchain_opt(const struct option *opt __maybe_unused, const char *arg,if (!ret)pr_debug ("callchain: stack dump size %d\n" , rec->opts.stack_dump_size); -#endif /* !NO_LIBUNWIND_SUPPORT */ +#endif /* LIBUNWIND_SUPPORT */ }else {pr_err ("callchain: Unknown -g option " "value: %s\n" , arg);
tools/perf/util/perf_regs.h +2 -2
@@ -1,7 +1,7 @@#ifndef __PERF_REGS_H#define __PERF_REGS_H -#ifndef NO_PERF_REGS +#ifdef HAVE_PERF_REGS #include <perf_regs.h> #else #define PERF_REGS_MASK 0
@@ -10,5 +10,5 @@ static inline const char *perf_reg_name(int id __maybe_unused) {return NULL ; } -#endif /* NO_PERF_REGS */ +#endif /* HAVE_PERF_REGS */ #endif /* __PERF_REGS_H */
tools/perf/util/unwind.h +2 -2
@@ -13,7 +13,7 @@ struct unwind_entry {typedef int (*unwind_entry_cb_t )(struct unwind_entry *entry,void *arg); -#ifndef NO_LIBUNWIND_SUPPORT +#ifdef LIBUNWIND_SUPPORT int unwind__get_entries(unwind_entry_cb_t cb, void *arg, struct machine *machine, struct thread *thread,
@@ -31,5 +31,5 @@ unwind__get_entries(unwind_entry_cb_t cb __maybe_unused, {return 0 ; } -#endif /* NO_LIBUNWIND_SUPPORT */ +#endif /* LIBUNWIND_SUPPORT */ #endif /* __UNWIND_H */
Signature · 1 line
1.7.11.4
Namhyung Kim
maintainerPATCH 2/12 perf tools: Remove unused PYRF_OBJS variable on Makefile
In reply to Namhyung KimFrom: Namhyung Kim <[email protected]>
It seems that the PYRF_OBJS variable is not used anymore or has no effect at least. The util/setup.py tracks its dependency using util/python-ext-sources file and resulting objects are saved under python_ext_build/tmp/.
--- tools/perf/Makefile | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-)
tools/perf/Makefile +1 -15
@@ -185,7 +185,7 @@ strip-libs = $(filter-out -l%,$(1)) PYTHON_EXT_SRCS := $(shell grep -v ^\# util/python-ext-sources) PYTHON_EXT_DEPS := util/python-ext-sources util/setup.py -$(OUTPUT)python/perf.so: $(PYRF_OBJS) $(PYTHON_EXT_SRCS) $(PYTHON_EXT_DEPS) +$(OUTPUT)python/perf.so: $(PYTHON_EXT_SRCS) $(PYTHON_EXT_DEPS) $(QUIET_GEN)CFLAGS='$(BASIC_CFLAGS)' $(PYTHON_WORD) util/setup.py \ --quiet build_ext; \ mkdir -p $(OUTPUT)python && \
@@ -446,20 +446,6 @@ BUILTIN_OBJS += $(OUTPUT)builtin-inject.o PERFLIBS = $(LIB_FILE) $(LIBTRACEEVENT) -# Files needed for the python binding, perf.so -# pyrf is just an internal name needed for all those wrappers. -# This has to be in sync with what is in the 'sources' variable in -# tools/perf/util/setup.py - -PYRF_OBJS += $(OUTPUT)util/cpumap.o -PYRF_OBJS += $(OUTPUT)util/ctype.o -PYRF_OBJS += $(OUTPUT)util/evlist.o -PYRF_OBJS += $(OUTPUT)util/evsel.o -PYRF_OBJS += $(OUTPUT)util/python.o -PYRF_OBJS += $(OUTPUT)util/thread_map.o -PYRF_OBJS += $(OUTPUT)util/util.o -PYRF_OBJS += $(OUTPUT)util/xyarray.o - # # Platform specific tweaks #
Signature · 1 line
1.7.11.4
Namhyung Kim
maintainerPATCH 1/12 perf tools: Move libdw availability check before arch Makefile
In reply to Namhyung KimFrom: Namhyung Kim <[email protected]>
Since NO_DWARF is used in arch/$(ARCH)/Makefiles, it should be checked before including those files. It was moved by mistake during libelf dependency removal work by me, sorry.
--- tools/perf/Makefile | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
tools/perf/Makefile +7 -7
@@ -486,7 +486,13 @@ ifneq ($(call try-cc,$(SOURCE_LIBELF),$(FLAGS_LIBELF)),y) NO_DWARF := 1 NO_DEMANGLE := 1 endif -endif +else + FLAGS_DWARF=$(ALL_CFLAGS) -ldw -lelf $(ALL_LDFLAGS) $(EXTLIBS) + ifneq ($(call try-cc,$(SOURCE_DWARF),$(FLAGS_DWARF)),y) + msg := $(warning No libdw.h found or old libdw.h found or elfutils is older than 0.138, disables dwarf support. Please install new elfutils-devel/libdw-dev); + NO_DWARF := 1 + endif # Dwarf support +endif # SOURCE_LIBELF endif # NO_LIBELF ifndef NO_LIBUNWIND
@@ -532,12 +538,6 @@ ifneq ($(call try-cc,$(SOURCE_ELF_MMAP),$(FLAGS_COMMON)),y) BASIC_CFLAGS += -DLIBELF_NO_MMAP endif -FLAGS_DWARF=$(ALL_CFLAGS) -ldw -lelf $(ALL_LDFLAGS) $(EXTLIBS) -ifneq ($(call try-cc,$(SOURCE_DWARF),$(FLAGS_DWARF)),y) - msg := $(warning No libdw.h found or old libdw.h found or elfutils is older than 0.138, disables dwarf support. Please install new elfutils-devel/libdw-dev); - NO_DWARF := 1 -endif # Dwarf support - ifndef NO_DWARF ifeq ($(origin PERF_HAVE_DWARF_REGS), undefined) msg := $(warning DWARF register mappings have not been defined for architecture $(ARCH), DWARF support disabled);
Signature · 1 line
1.7.11.4
Re: [PATCH 11/12] perf tools: Convert to BACKTRACE_SUPPORT
In reply to Namhyung Kimtools/perf/Makefile else · line 755
Quoted 4 lines
tools/perf/Makefile +0
-0@@ -751,10 +753,8 @@ else endif ifdef NO_BACKTRACE
This should be changed to ifndef NO_BACKTRACE.
tools/perf/Makefile else · line 760
Quoted 9 lines
tools/perf/Makefile +2
-4- BASIC_CFLAGS += -DNO_BACKTRACE -else - ifneq ($(call try-cc,$(SOURCE_BACKTRACE),),y) - BASIC_CFLAGS += -DNO_BACKTRACE + ifeq ($(call try-cc,$(SOURCE_BACKTRACE),),y) + BASIC_CFLAGS += -DBACKTRACE_SUPPORT endif endif
Thanks,
Irina
Re: [PATCH 04/12] perf tools: Convert to LIBUNWIND_SUPPORT
In reply to Namhyung KimQuoted 8 lines · Namhyung Kim
From: Namhyung Kim <[email protected]>
For building perf without libunwind, we can set NO_LIBUNWIND=1 as a argument of make. It then defines
NO_LIBUNWIND_SUPPORTmacro 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.
Quoted 4 lines
Also change
NO_PERF_REGSmacro toHAVE_PERF_REGSfor the same reason.Cc Jiri Olsa <[email protected]>Signed-off-by Namhyung Kim <[email protected]>
Namhyung Kim
maintainerRe: [PATCH 11/12] perf tools: Convert to BACKTRACE_SUPPORT
In reply to Irina Tirdea2012-10-01 (월), 02:40 +0300, Irina Tirdea:
Quoted 4 lines
tools/perf/Makefile else · line 755
Quoted 4 lines
tools/perf/Makefile +0
-0@@ -751,10 +753,8 @@ else endif ifdef NO_BACKTRACE
Argh, right. Thanks for pointing it out. I double checked other ones too, and it seems that they don't have the problem.
Arnaldo, what do you want to do with this?
Thanks,
Namhyung
Re: [PATCH 11/12] perf tools: Convert to BACKTRACE_SUPPORT
Em Mon, Oct 01, 2012 at 10:54:33PM +0900, Namhyung Kim escreveu:
Quoted 10 lines
2012-10-01 (월), 02:40 +0300, Irina Tirdea:
Quoted 4 lines
tools/perf/Makefile else · line 755
Quoted 4 lines
tools/perf/Makefile +0
-0@@ -751,10 +753,8 @@ else endif ifdef NO_BACKTRACEArgh, right. Thanks for pointing it out. I double checked other ones too, and it seems that they don't have the problem.
Arnaldo, what do you want to do with this?
Just resubmit this one, I removed it from my local tree, where I have the others applied.
Quoted 3 lines
Thanks,
Namhyung
Namhyung Kim
maintainerPATCH v2 11/12 perf tools: Convert to BACKTRACE_SUPPORT
From: Namhyung Kim <[email protected]>
For building perf without stack backtrace debug, we can set NO_BACKTRACE=1 as a argument of make. It then defines NO_BACKTRACE 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 and add _SUPPORT suffix for consistency.
--- tools/perf/Makefile | 10 +++++----- tools/perf/util/util.c | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-)
tools/perf/Makefile +5 -5
@@ -45,6 +45,8 @@ include config/utilities.mak # # Define NO_LIBUNWIND if you do not want libunwind dependency for dwarf # backtrace post unwind. +# +# Define NO_BACKTRACE if you do not want stack backtrace debug feature $(OUTPUT)PERF-VERSION-FILE: .FORCE-PERF-VERSION-FILE @$(SHELL_PATH) util/PERF-VERSION-GEN $(OUTPUT)
@@ -750,11 +752,9 @@ else endif endif -ifdef NO_BACKTRACE - BASIC_CFLAGS += -DNO_BACKTRACE -else - ifneq ($(call try-cc,$(SOURCE_BACKTRACE),),y) - BASIC_CFLAGS += -DNO_BACKTRACE +ifndef NO_BACKTRACE + ifeq ($(call try-cc,$(SOURCE_BACKTRACE),),y) + BASIC_CFLAGS += -DBACKTRACE_SUPPORT endif endif
tools/perf/util/util.c +2 -2
@@ -1,7 +1,7 @@#include "../perf.h" #include "util.h" #include <sys/mman.h> -#ifndef NO_BACKTRACE +#ifdef BACKTRACE_SUPPORT #include <execinfo.h> #endif #include <stdio.h>
@@ -165,7 +165,7 @@ size_t hex_width(u64 v) }/* Obtain a backtrace and print it to stdout. */ -#ifndef NO_BACKTRACE +#ifdef BACKTRACE_SUPPORT void dump_stack (void ) {void *array[16 ];
Signature · 1 line
1.7.9.2
[tip:perf/urgent] perf tools: Move libdw availability check before arch Makefile
In reply to Namhyung KimCommit-ID: fee9e3732a377275a99b6f3c8b4e1f1569f17575 Gitweb: http://git.kernel.org/tip/fee9e3732a377275a99b6f3c8b4e1f1569f17575 Author: Namhyung Kim <[email protected]> AuthorDate: Fri, 28 Sep 2012 18:31:57 +0900 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Fri, 28 Sep 2012 21:07:36 -0300
perf tools: Move libdw availability check before arch Makefile
Since NO_DWARF is used in arch/$(ARCH)/Makefiles, it should be checked before including those files. It was moved by mistake during libelf dependency removal work by me, sorry.
--- tools/perf/Makefile | 14 +++++++------- 1 files changed, 7 insertions(+), 7 deletions(-)
tools/perf/Makefile +7 -7
@@ -486,7 +486,13 @@ ifneq ($(call try-cc,$(SOURCE_LIBELF),$(FLAGS_LIBELF)),y) NO_DWARF := 1 NO_DEMANGLE := 1 endif -endif +else + FLAGS_DWARF=$(ALL_CFLAGS) -ldw -lelf $(ALL_LDFLAGS) $(EXTLIBS) + ifneq ($(call try-cc,$(SOURCE_DWARF),$(FLAGS_DWARF)),y) + msg := $(warning No libdw.h found or old libdw.h found or elfutils is older than 0.138, disables dwarf support. Please install new elfutils-devel/libdw-dev); + NO_DWARF := 1 + endif # Dwarf support +endif # SOURCE_LIBELF endif # NO_LIBELF ifndef NO_LIBUNWIND
@@ -532,12 +538,6 @@ ifneq ($(call try-cc,$(SOURCE_ELF_MMAP),$(FLAGS_COMMON)),y) BASIC_CFLAGS += -DLIBELF_NO_MMAP endif -FLAGS_DWARF=$(ALL_CFLAGS) -ldw -lelf $(ALL_LDFLAGS) $(EXTLIBS) -ifneq ($(call try-cc,$(SOURCE_DWARF),$(FLAGS_DWARF)),y) - msg := $(warning No libdw.h found or old libdw.h found or elfutils is older than 0.138, disables dwarf support. Please install new elfutils-devel/libdw-dev); - NO_DWARF := 1 -endif # Dwarf support - ifndef NO_DWARF ifeq ($(origin PERF_HAVE_DWARF_REGS), undefined) msg := $(warning DWARF register mappings have not been defined for architecture $(ARCH), DWARF support disabled);
[tip:perf/urgent] perf tools: Remove unused PYRF_OBJS variable on Makefile
In reply to Namhyung KimCommit-ID: e4898336a1b4d8a259663d15b12f359b6c2887a2 Gitweb: http://git.kernel.org/tip/e4898336a1b4d8a259663d15b12f359b6c2887a2 Author: Namhyung Kim <[email protected]> AuthorDate: Fri, 28 Sep 2012 18:31:58 +0900 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Fri, 28 Sep 2012 21:07:36 -0300
perf tools: Remove unused PYRF_OBJS variable on Makefile
It seems that the PYRF_OBJS variable is not used anymore or has no effect at least. The util/setup.py tracks its dependency using util/python-ext-sources file and resulting objects are saved under python_ext_build/tmp/.
--- tools/perf/Makefile | 16 +--------------- 1 files changed, 1 insertions(+), 15 deletions(-)
tools/perf/Makefile +1 -15
@@ -185,7 +185,7 @@ strip-libs = $(filter-out -l%,$(1)) PYTHON_EXT_SRCS := $(shell grep -v ^\# util/python-ext-sources) PYTHON_EXT_DEPS := util/python-ext-sources util/setup.py -$(OUTPUT)python/perf.so: $(PYRF_OBJS) $(PYTHON_EXT_SRCS) $(PYTHON_EXT_DEPS) +$(OUTPUT)python/perf.so: $(PYTHON_EXT_SRCS) $(PYTHON_EXT_DEPS) $(QUIET_GEN)CFLAGS='$(BASIC_CFLAGS)' $(PYTHON_WORD) util/setup.py \ --quiet build_ext; \ mkdir -p $(OUTPUT)python && \
@@ -446,20 +446,6 @@ BUILTIN_OBJS += $(OUTPUT)builtin-inject.o PERFLIBS = $(LIB_FILE) $(LIBTRACEEVENT) -# Files needed for the python binding, perf.so -# pyrf is just an internal name needed for all those wrappers. -# This has to be in sync with what is in the 'sources' variable in -# tools/perf/util/setup.py - -PYRF_OBJS += $(OUTPUT)util/cpumap.o -PYRF_OBJS += $(OUTPUT)util/ctype.o -PYRF_OBJS += $(OUTPUT)util/evlist.o -PYRF_OBJS += $(OUTPUT)util/evsel.o -PYRF_OBJS += $(OUTPUT)util/python.o -PYRF_OBJS += $(OUTPUT)util/thread_map.o -PYRF_OBJS += $(OUTPUT)util/util.o -PYRF_OBJS += $(OUTPUT)util/xyarray.o - # # Platform specific tweaks #
[tip:perf/urgent] perf tools: Convert to LIBELF_SUPPORT
In reply to Namhyung KimCommit-ID: 29a0fc9b2b6084e7a8810481df62a0fa496d8957 Gitweb: http://git.kernel.org/tip/29a0fc9b2b6084e7a8810481df62a0fa496d8957 Author: Namhyung Kim <[email protected]> AuthorDate: Fri, 28 Sep 2012 18:31:59 +0900 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Fri, 28 Sep 2012 21:07:36 -0300
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.
--- tools/perf/Makefile | 7 +++---- tools/perf/builtin-inject.c | 2 +- tools/perf/perf.c | 2 +- tools/perf/util/generate-cmdlist.sh | 4 ++-- tools/perf/util/map.c | 2 +- tools/perf/util/symbol.h | 10 +++++----- 6 files changed, 13 insertions(+), 14 deletions(-)
tools/perf/Makefile +3 -4
@@ -503,8 +503,6 @@ ifneq ($(OUTPUT),) endif ifdef NO_LIBELF -BASIC_CFLAGS += -DNO_LIBELF_SUPPORT - EXTLIBS := $(filter-out -lelf,$(EXTLIBS)) # Remove ELF/DWARF dependent codes
@@ -519,9 +517,10 @@ BUILTIN_OBJS := $(filter-out $(OUTPUT)builtin-probe.o,$(BUILTIN_OBJS)) LIB_OBJS += $(OUTPUT)util/symbol-minimal.o else # NO_LIBELF +BASIC_CFLAGS += -DLIBELF_SUPPORT -ifneq ($(call try-cc,$(SOURCE_ELF_MMAP),$(FLAGS_COMMON)),y) - BASIC_CFLAGS += -DLIBELF_NO_MMAP +ifeq ($(call try-cc,$(SOURCE_ELF_MMAP),$(FLAGS_COMMON)),y) + BASIC_CFLAGS += -DLIBELF_MMAP endif ifndef NO_DWARF
tools/perf/builtin-inject.c +1 -1
@@ -194,7 +194,7 @@ static int perf_event__inject_buildid(struct perf_tool *tool,* account this as unresolved. */ }else { -#ifndef NO_LIBELF_SUPPORT +#ifdef LIBELF_SUPPORT pr_warning ("no symbols found in %s, maybe " "install a debug package?\n" , al.map->dso->long_name);
tools/perf/perf.c +1 -1
@@ -48,7 +48,7 @@ static struct cmd_struct commands[] = { { "version", cmd_version, 0 }, { "script", cmd_script, 0 }, { "sched", cmd_sched, 0 }, -#ifndef NO_LIBELF_SUPPORT +#ifdef LIBELF_SUPPORT { "probe", cmd_probe, 0 }, #endif { "kmem", cmd_kmem, 0 },
tools/perf/util/generate-cmdlist.sh +2 -2
@@ -22,7 +22,7 @@ do }' "Documentation/perf-$cmd.txt" done -echo "#ifndef NO_LIBELF_SUPPORT" +echo "#ifdef LIBELF_SUPPORT" sed -n -e 's/^perf-\([^ ]*\)[ ].* full.*/\1/p' command-list.txt | sort | while read cmd
@@ -35,5 +35,5 @@ do p }' "Documentation/perf-$cmd.txt" done -echo "#endif /* NO_LIBELF_SUPPORT */" +echo "#endif /* LIBELF_SUPPORT */" echo "};"
tools/perf/util/map.c +1 -1
@@ -162,7 +162,7 @@ int map__load(struct map *self, symbol_filter_t filter)pr_warning (", continuing without symbols\n" );return -1 ; }else if (nr ==0 ) { -#ifndef NO_LIBELF_SUPPORT +#ifdef LIBELF_SUPPORT const size_t len =strlen (name);const size_t real_len = len -sizeof (DSO__DELETED );
tools/perf/util/symbol.h +5 -5
@@ -12,7 +12,7 @@#include <byteswap.h> #include <libgen.h> -#ifndef NO_LIBELF_SUPPORT +#ifdef LIBELF_SUPPORT #include <libelf.h> #include <gelf.h> #include <elf.h>
@@ -46,10 +46,10 @@ char *strxfrchar(char *s, char from, char to);* libelf 0.8.x and earlier do not support ELF_C_READ_MMAP; * for newer versions we can use mmap to reduce memory usage: */ -#ifdef LIBELF_NO_MMAP -# define PERF_ELF_C_READ_MMAP ELF_C_READ -#else +#ifdef LIBELF_MMAP # define PERF_ELF_C_READ_MMAP ELF_C_READ_MMAP +#else +# define PERF_ELF_C_READ_MMAP ELF_C_READ#endif #ifndef DMGL_PARAMS
@@ -233,7 +233,7 @@ struct symsrc {int fd;enum dso_binary_type type; -#ifndef NO_LIBELF_SUPPORT +#ifdef LIBELF_SUPPORT Elf *elf;GElf_Ehdr ehdr;
[tip:perf/urgent] perf tools: Convert to LIBUNWIND_SUPPORT
In reply to Namhyung KimCommit-ID: 95485b1cda827e4db7102ad5fde1791087a0f4c5 Gitweb: http://git.kernel.org/tip/95485b1cda827e4db7102ad5fde1791087a0f4c5 Author: Namhyung Kim <[email protected]> AuthorDate: Fri, 28 Sep 2012 18:32:00 +0900 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Tue, 2 Oct 2012 17:56:01 -0300
perf tools: Convert to LIBUNWIND_SUPPORT
For building perf without libunwind, we can set NO_LIBUNWIND=1 as a argument of make. It then defines NO_LIBUNWIND_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.
Also change NO_PERF_REGS macro to HAVE_PERF_REGS for the same reason.
--- tools/perf/Makefile | 8 +++----- tools/perf/builtin-record.c | 14 +++++++------- tools/perf/util/perf_regs.h | 4 ++-- tools/perf/util/unwind.h | 4 ++-- 4 files changed, 14 insertions(+), 16 deletions(-)
tools/perf/Makefile +3 -5
@@ -535,9 +535,8 @@ endif # PERF_HAVE_DWARF_REGS endif # NO_DWARF endif # NO_LIBELF -ifdef NO_LIBUNWIND - BASIC_CFLAGS += -DNO_LIBUNWIND_SUPPORT -else +ifndef NO_LIBUNWIND + BASIC_CFLAGS += -DLIBUNWIND_SUPPORT EXTLIBS += $(LIBUNWIND_LIBS) BASIC_CFLAGS := $(LIBUNWIND_CFLAGS) $(BASIC_CFLAGS) BASIC_LDFLAGS := $(LIBUNWIND_LDFLAGS) $(BASIC_LDFLAGS)
@@ -747,8 +746,7 @@ ifeq ($(NO_PERF_REGS),0) ifeq ($(ARCH),x86) LIB_H += arch/x86/include/perf_regs.h endif -else - BASIC_CFLAGS += -DNO_PERF_REGS + BASIC_CFLAGS += -DHAVE_PERF_REGS endif ifdef NO_STRLCPY
tools/perf/builtin-record.c +7 -7
@@ -33,11 +33,11 @@#define CALLCHAIN_HELP "do call-graph (stack chain/backtrace) recording: " -#ifdef NO_LIBUNWIND_SUPPORT -static char callchain_help[] =CALLCHAIN_HELP "[fp]" ; -#else +#ifdef LIBUNWIND_SUPPORT static unsigned long default_stack_dump_size =8192 ;static char callchain_help[] =CALLCHAIN_HELP "[fp] dwarf" ; +#else +static char callchain_help[] =CALLCHAIN_HELP "[fp]" ;#endif enum write_mode_t {
@@ -800,7 +800,7 @@ error:return ret; } -#ifndef NO_LIBUNWIND_SUPPORT +#ifdef LIBUNWIND_SUPPORT static int get_stack_size (char *str,unsigned long *_size) {char *endptr;
@@ -826,7 +826,7 @@ static int get_stack_size(char *str, unsigned long *_size) max_size, str);return -1 ; } -#endif /* !NO_LIBUNWIND_SUPPORT */ +#endif /* LIBUNWIND_SUPPORT */ static int parse_callchain_opt(const struct option *opt __maybe_unused, const char *arg,
@@ -865,7 +865,7 @@ parse_callchain_opt(const struct option *opt __maybe_unused, const char *arg, "needed for -g fp\n");break ; -#ifndef NO_LIBUNWIND_SUPPORT +#ifdef LIBUNWIND_SUPPORT /* Dwarf style */ }else if (!strncmp (name,"dwarf" ,sizeof ("dwarf" ))) { ret =0 ;
@@ -883,7 +883,7 @@ parse_callchain_opt(const struct option *opt __maybe_unused, const char *arg,if (!ret)pr_debug ("callchain: stack dump size %d\n" , rec->opts.stack_dump_size); -#endif /* !NO_LIBUNWIND_SUPPORT */ +#endif /* LIBUNWIND_SUPPORT */ }else {pr_err ("callchain: Unknown -g option " "value: %s\n" , arg);
tools/perf/util/perf_regs.h +2 -2
@@ -1,7 +1,7 @@#ifndef __PERF_REGS_H#define __PERF_REGS_H -#ifndef NO_PERF_REGS +#ifdef HAVE_PERF_REGS #include <perf_regs.h> #else #define PERF_REGS_MASK 0
@@ -10,5 +10,5 @@ static inline const char *perf_reg_name(int id __maybe_unused) {return NULL ; } -#endif /* NO_PERF_REGS */ +#endif /* HAVE_PERF_REGS */ #endif /* __PERF_REGS_H */
tools/perf/util/unwind.h +2 -2
@@ -13,7 +13,7 @@ struct unwind_entry {typedef int (*unwind_entry_cb_t )(struct unwind_entry *entry,void *arg); -#ifndef NO_LIBUNWIND_SUPPORT +#ifdef LIBUNWIND_SUPPORT int unwind__get_entries(unwind_entry_cb_t cb, void *arg, struct machine *machine, struct thread *thread,
@@ -31,5 +31,5 @@ unwind__get_entries(unwind_entry_cb_t cb __maybe_unused, {return 0 ; } -#endif /* NO_LIBUNWIND_SUPPORT */ +#endif /* LIBUNWIND_SUPPORT */ #endif /* __UNWIND_H */
[tip:perf/urgent] perf tools: Convert to LIBAUDIT_SUPPORT
In reply to Namhyung KimCommit-ID: f315e16850d00ae5b19f11810bc00bf68cf3c24a Gitweb: http://git.kernel.org/tip/f315e16850d00ae5b19f11810bc00bf68cf3c24a Author: Namhyung Kim <[email protected]> AuthorDate: Fri, 28 Sep 2012 18:32:01 +0900 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Tue, 2 Oct 2012 18:36:21 -0300
perf tools: Convert to LIBAUDIT_SUPPORT
For building perf without libaudit, we can set NO_LIBAUDIT=1 as a argument of make. It then defines NO_LIBAUDIT_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.
--- tools/perf/Makefile | 6 ++---- tools/perf/perf.c | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-)
tools/perf/Makefile +2 -4
@@ -543,14 +543,12 @@ ifndef NO_LIBUNWIND LIB_OBJS += $(OUTPUT)util/unwind.o endif -ifdef NO_LIBAUDIT - BASIC_CFLAGS += -DNO_LIBAUDIT_SUPPORT -else +ifndef NO_LIBAUDIT FLAGS_LIBAUDIT = $(ALL_CFLAGS) $(ALL_LDFLAGS) -laudit ifneq ($(call try-cc,$(SOURCE_LIBAUDIT),$(FLAGS_LIBAUDIT)),y) msg := $(warning No libaudit.h found, disables 'trace' tool, please install audit-libs-devel or libaudit-dev); - BASIC_CFLAGS += -DNO_LIBAUDIT_SUPPORT else + BASIC_CFLAGS += -DLIBAUDIT_SUPPORT BUILTIN_OBJS += $(OUTPUT)builtin-trace.o EXTLIBS += -laudit endif
tools/perf/perf.c +1 -1
@@ -55,7 +55,7 @@ static struct cmd_struct commands[] = { { "lock", cmd_lock, 0 }, { "kvm", cmd_kvm, 0 }, { "test", cmd_test, 0 }, -#ifndef NO_LIBAUDIT_SUPPORT +#ifdef LIBAUDIT_SUPPORT { "trace", cmd_trace, 0 }, #endif { "inject", cmd_inject, 0 },
[tip:perf/urgent] perf tools: Convert to NEWT_SUPPORT
In reply to Namhyung KimCommit-ID: 1254b51e32649f2d34ec6b070ed36717c5a6b825 Gitweb: http://git.kernel.org/tip/1254b51e32649f2d34ec6b070ed36717c5a6b825 Author: Namhyung Kim <[email protected]> AuthorDate: Fri, 28 Sep 2012 18:32:02 +0900 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Tue, 2 Oct 2012 18:36:22 -0300
perf tools: Convert to NEWT_SUPPORT
For building perf without libnewt, we can set NO_NEWT=1 as a argument of make. It then defines NO_NEWT_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.
--- tools/perf/Makefile | 8 +++----- tools/perf/ui/gtk/util.c | 2 +- tools/perf/ui/helpline.h | 10 +++++----- tools/perf/util/annotate.h | 8 ++++---- tools/perf/util/cache.h | 12 ++++++------ tools/perf/util/debug.c | 2 +- tools/perf/util/debug.h | 6 +++--- tools/perf/util/hist.h | 18 +++++++++--------- 8 files changed, 32 insertions(+), 34 deletions(-)
tools/perf/Makefile +3 -5
@@ -554,16 +554,14 @@ ifndef NO_LIBAUDIT endif endif -ifdef NO_NEWT - BASIC_CFLAGS += -DNO_NEWT_SUPPORT -else +ifndef NO_NEWT FLAGS_NEWT=$(ALL_CFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) -lnewt ifneq ($(call try-cc,$(SOURCE_NEWT),$(FLAGS_NEWT)),y) msg := $(warning newt not found, disables TUI support. Please install newt-devel or libnewt-dev); - BASIC_CFLAGS += -DNO_NEWT_SUPPORT else # Fedora has /usr/include/slang/slang.h, but ubuntu /usr/include/slang.h BASIC_CFLAGS += -I/usr/include/slang + BASIC_CFLAGS += -DNEWT_SUPPORT EXTLIBS += -lnewt -lslang LIB_OBJS += $(OUTPUT)ui/setup.o LIB_OBJS += $(OUTPUT)ui/browser.o
@@ -603,7 +601,7 @@ else LIB_OBJS += $(OUTPUT)ui/gtk/util.o LIB_OBJS += $(OUTPUT)ui/gtk/helpline.o # Make sure that it'd be included only once. - ifneq ($(findstring -DNO_NEWT_SUPPORT,$(BASIC_CFLAGS)),) + ifeq ($(findstring -DNEWT_SUPPORT,$(BASIC_CFLAGS)),) LIB_OBJS += $(OUTPUT)ui/setup.o LIB_OBJS += $(OUTPUT)ui/util.o endif
tools/perf/ui/gtk/util.c +1 -1
@@ -116,7 +116,7 @@ struct perf_error_ops perf_gtk_eops = {* FIXME: Functions below should be implemented properly. * For now, just add stubs for NO_NEWT=1 build. */ -#ifdef NO_NEWT_SUPPORT +#ifndef NEWT_SUPPORT void ui_progress__update (u64 curr__maybe_unused ,u64 total__maybe_unused ,const char *title__maybe_unused ) {
tools/perf/ui/helpline.h +5 -5
@@ -23,16 +23,16 @@ void ui_helpline__puts(const char *msg);extern char ui_helpline__current[512 ]; -#ifdef NO_NEWT_SUPPORT +#ifdef NEWT_SUPPORT +extern char ui_helpline__last_msg[]; +int ui_helpline__show_help (const char *format,va_list ap); +#else static inline int ui_helpline__show_help (const char *format__maybe_unused ,va_list ap__maybe_unused ) {return 0 ; } -#else -extern char ui_helpline__last_msg[]; -int ui_helpline__show_help (const char *format,va_list ap); -#endif /* NO_NEWT_SUPPORT */ +#endif /* NEWT_SUPPORT */ #ifdef NO_GTK2_SUPPORT static inline int perf_gtk__show_helpline(const char *format __maybe_unused,
tools/perf/util/annotate.h +4 -4
@@ -138,7 +138,10 @@ int symbol__tty_annotate(struct symbol *sym, struct map *map, int evidx, bool print_lines, bool full_paths, int min_pcnt, int max_lines); -#ifdef NO_NEWT_SUPPORT +#ifdef NEWT_SUPPORT +int symbol__tui_annotate (struct symbol *sym,struct map *map,int evidx, +void (*timer)(void *arg),void *arg,int delay_secs); +#else static inline int symbol__tui_annotate(struct symbol *sym __maybe_unused, struct map *map __maybe_unused, int evidx __maybe_unused,
@@ -148,9 +151,6 @@ static inline int symbol__tui_annotate(struct symbol *sym __maybe_unused, {return 0 ; } -#else -int symbol__tui_annotate (struct symbol *sym,struct map *map,int evidx, -void (*timer)(void *arg),void *arg,int delay_secs);#endif extern const char *disassembler_style;
tools/perf/util/cache.h +6 -6
@@ -33,7 +33,7 @@ extern int pager_use_color;extern int use_browser; -#if defined(NO_NEWT_SUPPORT ) && defined(NO_GTK2_SUPPORT ) +#if !defined(NEWT_SUPPORT ) && defined(NO_GTK2_SUPPORT )static inline void setup_browser (bool fallback_to_pager) {if (fallback_to_pager)
@@ -44,15 +44,15 @@ static inline void exit_browser(bool wait_for_ok __maybe_unused) {}void setup_browser (bool fallback_to_pager);void exit_browser (bool wait_for_ok); -#ifdef NO_NEWT_SUPPORT +#ifdef NEWT_SUPPORT +int ui__init (void ); +void ui__exit (bool wait_for_ok); +#else static inline int ui__init (void ) {return -1 ; }static inline void ui__exit (bool wait_for_ok__maybe_unused ) {} -#else -int ui__init (void ); -void ui__exit (bool wait_for_ok);#endif #ifdef NO_GTK2_SUPPORT
@@ -65,7 +65,7 @@ static inline void perf_gtk__exit(bool wait_for_ok __maybe_unused) {}int perf_gtk__init (void );void perf_gtk__exit (bool wait_for_ok);#endif -#endif /* NO_NEWT_SUPPORT && NO_GTK2_SUPPORT */ +#endif /* !NEWT_SUPPORT && NO_GTK2_SUPPORT */ char *alias_lookup (const char *alias);int split_cmdline (char *cmdline,const char ***argv);
tools/perf/util/debug.c +1 -1
@@ -49,7 +49,7 @@ int dump_printf(const char *fmt, ...)return ret; } -#if defined(NO_NEWT_SUPPORT ) && defined(NO_GTK2_SUPPORT ) +#if !defined(NEWT_SUPPORT ) && defined(NO_GTK2_SUPPORT )int ui__warning (const char *format, ...) {va_list args;
tools/perf/util/debug.h +3 -3
@@ -15,7 +15,7 @@ void trace_event(union perf_event *event);struct ui_progress ;struct perf_error_ops ; -#if defined(NO_NEWT_SUPPORT ) && defined(NO_GTK2_SUPPORT ) +#if !defined(NEWT_SUPPORT ) && defined(NO_GTK2_SUPPORT )static inline void ui_progress__update (u64 curr__maybe_unused ,u64 total__maybe_unused ,const char *title__maybe_unused ) {}
@@ -34,13 +34,13 @@ perf_error__unregister(struct perf_error_ops *eops __maybe_unused) return 0; } -#else /* NO_NEWT_SUPPORT && NO_GTK2_SUPPORT */ +#else /* !NEWT_SUPPORT && NO_GTK2_SUPPORT */ #include "../ui/progress.h" int ui__error (const char *format, ...) __attribute__((format (printf,1 ,2 )));#include "../ui/util.h" -#endif /* NO_NEWT_SUPPORT && NO_GTK2_SUPPORT */ +#endif /* !NEWT_SUPPORT && NO_GTK2_SUPPORT */ int ui__warning (const char *format, ...) __attribute__((format (printf,1 ,2 )));int ui__error_paranoid (void );
tools/perf/util/hist.h +9 -9
@@ -154,7 +154,15 @@ int hist_entry__period_snprintf(struct perf_hpp *hpp, struct hist_entry *he,struct perf_evlist ; -#ifdef NO_NEWT_SUPPORT +#ifdef NEWT_SUPPORT +#include "../ui/keysyms.h" +int hist_entry__tui_annotate (struct hist_entry *he,int evidx, +void (*timer)(void *arg),void *arg,int delay_secs); + +int perf_evlist__tui_browse_hists (struct perf_evlist *evlist,const char *help, +void (*timer)(void *arg),void *arg, +int refresh); +#else static inline int perf_evlist__tui_browse_hists(struct perf_evlist *evlist __maybe_unused, const char *help __maybe_unused,
@@ -177,14 +185,6 @@ static inline int hist_entry__tui_annotate(struct hist_entry *self }#define K_LEFT -1#define K_RIGHT -2 -#else -#include "../ui/keysyms.h" -int hist_entry__tui_annotate (struct hist_entry *he,int evidx, -void (*timer)(void *arg),void *arg,int delay_secs); - -int perf_evlist__tui_browse_hists (struct perf_evlist *evlist,const char *help, -void (*timer)(void *arg),void *arg, -int refresh);#endif #ifdef NO_GTK2_SUPPORT
[tip:perf/urgent] perf tools: Convert to GTK2_SUPPORT
In reply to Namhyung KimCommit-ID: f9f526ecdc09a851f4f5567ebcf9bc553778f6c2 Gitweb: http://git.kernel.org/tip/f9f526ecdc09a851f4f5567ebcf9bc553778f6c2 Author: Namhyung Kim <[email protected]> AuthorDate: Fri, 28 Sep 2012 18:32:03 +0900 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Tue, 2 Oct 2012 18:36:23 -0300
perf tools: Convert to GTK2_SUPPORT
For building perf without gtk+2, we can set NO_GTK2=1 as a argument of make. It then defines NO_GTK2_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.
--- tools/perf/Makefile | 6 ++---- tools/perf/ui/helpline.h | 8 ++++---- tools/perf/util/cache.h | 28 +++++++++++++++------------- tools/perf/util/debug.c | 2 +- tools/perf/util/debug.h | 17 +++++++++-------- tools/perf/util/hist.h | 11 +++++------ 6 files changed, 36 insertions(+), 36 deletions(-)
tools/perf/Makefile +2 -4
@@ -583,17 +583,15 @@ ifndef NO_NEWT endif endif -ifdef NO_GTK2 - BASIC_CFLAGS += -DNO_GTK2_SUPPORT -else +ifndef NO_GTK2 FLAGS_GTK2=$(ALL_CFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) $(shell pkg-config --libs --cflags gtk+-2.0 2>/dev/null) ifneq ($(call try-cc,$(SOURCE_GTK2),$(FLAGS_GTK2)),y) msg := $(warning GTK2 not found, disables GTK2 support. Please install gtk2-devel or libgtk2.0-dev); - BASIC_CFLAGS += -DNO_GTK2_SUPPORT else ifeq ($(call try-cc,$(SOURCE_GTK2_INFOBAR),$(FLAGS_GTK2)),y) BASIC_CFLAGS += -DHAVE_GTK_INFO_BAR endif + BASIC_CFLAGS += -DGTK2_SUPPORT BASIC_CFLAGS += $(shell pkg-config --cflags gtk+-2.0 2>/dev/null) EXTLIBS += $(shell pkg-config --libs gtk+-2.0 2>/dev/null) LIB_OBJS += $(OUTPUT)ui/gtk/browser.o
tools/perf/ui/helpline.h +4 -4
@@ -34,14 +34,14 @@ static inline int ui_helpline__show_help(const char *format __maybe_unused, }#endif /* NEWT_SUPPORT */ -#ifdef NO_GTK2_SUPPORT +#ifdef GTK2_SUPPORT +int perf_gtk__show_helpline (const char *format,va_list ap); +#else static inline int perf_gtk__show_helpline (const char *format__maybe_unused ,va_list ap__maybe_unused ) {return 0 ; } -#else -int perf_gtk__show_helpline (const char *format,va_list ap); -#endif /* NO_GTK2_SUPPORT */ +#endif /* GTK2_SUPPORT */ #endif /* _PERF_UI_HELPLINE_H_ */
tools/perf/util/cache.h +15 -13
@@ -33,14 +33,7 @@ extern int pager_use_color;extern int use_browser; -#if !defined(NEWT_SUPPORT ) && defined(NO_GTK2_SUPPORT ) -static inline void setup_browser (bool fallback_to_pager) -{ -if (fallback_to_pager) -setup_pager (); -} -static inline void exit_browser (bool wait_for_ok__maybe_unused ) {} -#else +#if defined(NEWT_SUPPORT ) || defined(GTK2_SUPPORT )void setup_browser (bool fallback_to_pager);void exit_browser (bool wait_for_ok);
@@ -55,17 +48,26 @@ static inline int ui__init(void)static inline void ui__exit (bool wait_for_ok__maybe_unused ) {}#endif -#ifdef NO_GTK2_SUPPORT +#ifdef GTK2_SUPPORT +int perf_gtk__init (void ); +void perf_gtk__exit (bool wait_for_ok); +#else static inline int perf_gtk__init (void ) {return -1 ; }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);#endif -#endif /* !NEWT_SUPPORT && NO_GTK2_SUPPORT */ + +#else /* NEWT_SUPPORT || GTK2_SUPPORT */ + +static inline void setup_browser (bool fallback_to_pager) +{ +if (fallback_to_pager) +setup_pager (); +} +static inline void exit_browser (bool wait_for_ok__maybe_unused ) {} +#endif /* NEWT_SUPPORT || GTK2_SUPPORT */ char *alias_lookup (const char *alias);int split_cmdline (char *cmdline,const char ***argv);
tools/perf/util/debug.c +1 -1
@@ -49,7 +49,7 @@ int dump_printf(const char *fmt, ...)return ret; } -#if !defined(NEWT_SUPPORT ) && defined(NO_GTK2_SUPPORT ) +#if !defined(NEWT_SUPPORT ) && !defined(GTK2_SUPPORT )int ui__warning (const char *format, ...) {va_list args;
tools/perf/util/debug.h +9 -8
@@ -15,7 +15,14 @@ void trace_event(union perf_event *event);struct ui_progress ;struct perf_error_ops ; -#if !defined(NEWT_SUPPORT ) && defined(NO_GTK2_SUPPORT ) +#if defined(NEWT_SUPPORT ) || defined(GTK2_SUPPORT ) + +#include "../ui/progress.h" +int ui__error (const char *format, ...) __attribute__((format (printf,1 ,2 ))); +#include "../ui/util.h" + +#else +static inline void ui_progress__update (u64 curr__maybe_unused ,u64 total__maybe_unused ,const char *title__maybe_unused ) {}
@@ -34,13 +41,7 @@ perf_error__unregister(struct perf_error_ops *eops __maybe_unused) return 0; } -#else /* !NEWT_SUPPORT && NO_GTK2_SUPPORT */ - -#include "../ui/progress.h" -int ui__error (const char *format, ...) __attribute__((format (printf,1 ,2 ))); -#include "../ui/util.h" - -#endif /* !NEWT_SUPPORT && NO_GTK2_SUPPORT */ +#endif /* NEWT_SUPPORT || GTK2_SUPPORT */ int ui__warning (const char *format, ...) __attribute__((format (printf,1 ,2 )));int ui__error_paranoid (void );
tools/perf/util/hist.h +5 -6
@@ -187,7 +187,11 @@ static inline int hist_entry__tui_annotate(struct hist_entry *self#define K_RIGHT -2#endif -#ifdef NO_GTK2_SUPPORT +#ifdef GTK2_SUPPORT +int perf_evlist__gtk_browse_hists (struct perf_evlist *evlist,const char *help, +void (*timer)(void *arg),void *arg, +int refresh); +#else static inline int perf_evlist__gtk_browse_hists(struct perf_evlist *evlist __maybe_unused, const char *help __maybe_unused,
@@ -197,11 +201,6 @@ int perf_evlist__gtk_browse_hists(struct perf_evlist *evlist __maybe_unused, {return 0 ; } - -#else -int perf_evlist__gtk_browse_hists (struct perf_evlist *evlist,const char *help, -void (*timer)(void *arg),void *arg, -int refresh);#endif unsigned int hists__sort_list_width (struct hists *self);
[tip:perf/urgent] perf tools: Convert to HAVE_STRLCPY
In reply to Namhyung KimCommit-ID: d6e66832a710c0e6d1376e8d39ee108636a177e7 Gitweb: http://git.kernel.org/tip/d6e66832a710c0e6d1376e8d39ee108636a177e7 Author: Namhyung Kim <[email protected]> AuthorDate: Fri, 28 Sep 2012 18:32:08 +0900 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Tue, 2 Oct 2012 18:36:24 -0300
perf tools: Convert to HAVE_STRLCPY
For similar reason of previous patches, convert NO_STRLCPY to positive HAVE_STRLCPY.
--- tools/perf/Makefile | 8 +++----- tools/perf/util/cache.h | 2 +- tools/perf/util/path.c | 2 +- 3 files changed, 5 insertions(+), 7 deletions(-)
tools/perf/Makefile +3 -5
@@ -743,11 +743,9 @@ ifeq ($(NO_PERF_REGS),0) BASIC_CFLAGS += -DHAVE_PERF_REGS endif -ifdef NO_STRLCPY - BASIC_CFLAGS += -DNO_STRLCPY -else - ifneq ($(call try-cc,$(SOURCE_STRLCPY),),y) - BASIC_CFLAGS += -DNO_STRLCPY +ifndef NO_STRLCPY + ifeq ($(call try-cc,$(SOURCE_STRLCPY),),y) + BASIC_CFLAGS += -DHAVE_STRLCPY endif endif
tools/perf/util/cache.h +1 -1
@@ -107,7 +107,7 @@ extern char *perf_path(const char *fmt, ...) __attribute__((format (printf, 1, 2extern char *perf_pathdup (const char *fmt, ...) __attribute__((format (printf,1 ,2 ))); -#ifdef NO_STRLCPY +#ifndef HAVE_STRLCPY extern size_t strlcpy (char *dest,const char *src,size_t size);#endif
tools/perf/util/path.c +1 -1
@@ -22,7 +22,7 @@ static const char *get_perf_dir(void)return "." ; } -#ifdef NO_STRLCPY +#ifndef HAVE_STRLCPY size_t strlcpy (char *dest,const char *src,size_t size) {size_t ret =strlen (src);
[tip:perf/urgent] perf tools: Convert to BACKTRACE_SUPPORT
In reply to Namhyung KimCommit-ID: 4e34d9588b46f44a4dba718606913133f15e4b21 Gitweb: http://git.kernel.org/tip/4e34d9588b46f44a4dba718606913133f15e4b21 Author: Namhyung Kim <[email protected]> AuthorDate: Tue, 2 Oct 2012 01:32:51 +0900 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Tue, 2 Oct 2012 18:36:45 -0300
perf tools: Convert to BACKTRACE_SUPPORT
For building perf without stack backtrace debug, we can set NO_BACKTRACE=1 as a argument of make. It then defines NO_BACKTRACE 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 and add _SUPPORT suffix for consistency.
--- tools/perf/Makefile | 10 +++++----- tools/perf/util/util.c | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-)
tools/perf/Makefile +5 -5
@@ -45,6 +45,8 @@ include config/utilities.mak # # Define NO_LIBUNWIND if you do not want libunwind dependency for dwarf # backtrace post unwind. +# +# Define NO_BACKTRACE if you do not want stack backtrace debug feature $(OUTPUT)PERF-VERSION-FILE: .FORCE-PERF-VERSION-FILE @$(SHELL_PATH) util/PERF-VERSION-GEN $(OUTPUT)
@@ -749,11 +751,9 @@ ifndef NO_STRLCPY endif endif -ifdef NO_BACKTRACE - BASIC_CFLAGS += -DNO_BACKTRACE -else - ifneq ($(call try-cc,$(SOURCE_BACKTRACE),),y) - BASIC_CFLAGS += -DNO_BACKTRACE +ifndef NO_BACKTRACE + ifeq ($(call try-cc,$(SOURCE_BACKTRACE),),y) + BASIC_CFLAGS += -DBACKTRACE_SUPPORT endif endif
tools/perf/util/util.c +2 -2
@@ -1,7 +1,7 @@#include "../perf.h" #include "util.h" #include <sys/mman.h> -#ifndef NO_BACKTRACE +#ifdef BACKTRACE_SUPPORT #include <execinfo.h> #endif #include <stdio.h>
@@ -165,7 +165,7 @@ size_t hex_width(u64 v) }/* Obtain a backtrace and print it to stdout. */ -#ifndef NO_BACKTRACE +#ifdef BACKTRACE_SUPPORT void dump_stack (void ) {void *array[16 ];