Merge branch 'perf/rename' into perf/core
authorIngo Molnar <mingo@elte.hu>
Wed, 1 Dec 2010 08:18:12 +0000 (09:18 +0100)
committerIngo Molnar <mingo@elte.hu>
Wed, 1 Dec 2010 08:22:19 +0000 (09:22 +0100)
Merge reason: This is an older commit under testing that was not pushed yet - merge it.

Also fix up the merge in command-list.txt.

Signed-off-by: Ingo Molnar <mingo@elte.hu>
Acked-by: Tom Zanussi <tzanussi@gmail.com>
1  2 
tools/perf/Makefile
tools/perf/builtin-script.c
tools/perf/command-list.txt

diff --combined tools/perf/Makefile
@@@ -185,10 -185,7 +185,10 @@@ ifeq ($(ARCH),i386
          ARCH := x86
  endif
  ifeq ($(ARCH),x86_64)
 +      RAW_ARCH := x86_64
          ARCH := x86
 +      ARCH_CFLAGS := -DARCH_X86_64
 +      ARCH_INCLUDE = ../../arch/x86/lib/memcpy_64.S
  endif
  
  # CFLAGS and LDFLAGS are for the users to override from the command line.
@@@ -378,7 -375,6 +378,7 @@@ LIB_H += util/include/linux/prefetch.
  LIB_H += util/include/linux/rbtree.h
  LIB_H += util/include/linux/string.h
  LIB_H += util/include/linux/types.h
 +LIB_H += util/include/linux/linkage.h
  LIB_H += util/include/asm/asm-offsets.h
  LIB_H += util/include/asm/bug.h
  LIB_H += util/include/asm/byteorder.h
@@@ -387,8 -383,6 +387,8 @@@ LIB_H += util/include/asm/swab.
  LIB_H += util/include/asm/system.h
  LIB_H += util/include/asm/uaccess.h
  LIB_H += util/include/dwarf-regs.h
 +LIB_H += util/include/asm/dwarf2.h
 +LIB_H += util/include/asm/cpufeature.h
  LIB_H += perf.h
  LIB_H += util/cache.h
  LIB_H += util/callchain.h
@@@ -423,7 -417,6 +423,7 @@@ LIB_H += util/probe-finder.
  LIB_H += util/probe-event.h
  LIB_H += util/pstack.h
  LIB_H += util/cpumap.h
 +LIB_H += $(ARCH_INCLUDE)
  
  LIB_OBJS += $(OUTPUT)util/abspath.o
  LIB_OBJS += $(OUTPUT)util/alias.o
@@@ -479,9 -472,6 +479,9 @@@ BUILTIN_OBJS += $(OUTPUT)builtin-bench.
  # Benchmark modules
  BUILTIN_OBJS += $(OUTPUT)bench/sched-messaging.o
  BUILTIN_OBJS += $(OUTPUT)bench/sched-pipe.o
 +ifeq ($(RAW_ARCH),x86_64)
 +BUILTIN_OBJS += $(OUTPUT)bench/mem-memcpy-x86-64-asm.o
 +endif
  BUILTIN_OBJS += $(OUTPUT)bench/mem-memcpy.o
  
  BUILTIN_OBJS += $(OUTPUT)builtin-diff.o
@@@ -495,7 -485,7 +495,7 @@@ BUILTIN_OBJS += $(OUTPUT)builtin-report
  BUILTIN_OBJS += $(OUTPUT)builtin-stat.o
  BUILTIN_OBJS += $(OUTPUT)builtin-timechart.o
  BUILTIN_OBJS += $(OUTPUT)builtin-top.o
- BUILTIN_OBJS += $(OUTPUT)builtin-trace.o
+ BUILTIN_OBJS += $(OUTPUT)builtin-script.o
  BUILTIN_OBJS += $(OUTPUT)builtin-probe.o
  BUILTIN_OBJS += $(OUTPUT)builtin-kmem.o
  BUILTIN_OBJS += $(OUTPUT)builtin-lock.o
@@@ -517,7 -507,7 +517,7 @@@ PERFLIBS = $(LIB_FILE
  -include config.mak
  
  ifndef NO_DWARF
 -FLAGS_DWARF=$(ALL_CFLAGS) -I/usr/include/elfutils -ldw -lelf $(ALL_LDFLAGS) $(EXTLIBS)
 +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
@@@ -564,7 -554,7 +564,7 @@@ ifndef NO_DWAR
  ifeq ($(origin PERF_HAVE_DWARF_REGS), undefined)
        msg := $(warning DWARF register mappings have not been defined for architecture $(ARCH), DWARF support disabled);
  else
 -      BASIC_CFLAGS += -I/usr/include/elfutils -DDWARF_SUPPORT
 +      BASIC_CFLAGS += -DDWARF_SUPPORT
        EXTLIBS += -lelf -ldw
        LIB_OBJS += $(OUTPUT)util/probe-finder.o
  endif # PERF_HAVE_DWARF_REGS
@@@ -908,7 -898,6 +908,7 @@@ BASIC_CFLAGS += -DSHA1_HEADER='$(SHA1_H
  LIB_OBJS += $(COMPAT_OBJS)
  
  ALL_CFLAGS += $(BASIC_CFLAGS)
 +ALL_CFLAGS += $(ARCH_CFLAGS)
  ALL_LDFLAGS += $(BASIC_LDFLAGS)
  
  export TAR INSTALL DESTDIR SHELL_PATH
@@@ -56,7 -56,7 +56,7 @@@ static void setup_scripting(void
  
  static int cleanup_scripting(void)
  {
-       pr_debug("\nperf trace script stopped\n");
+       pr_debug("\nperf script stopped\n");
  
        return scripting_ops->stop_script();
  }
@@@ -137,7 -137,7 +137,7 @@@ static void sig_handler(int sig __unuse
        session_done = 1;
  }
  
- static int __cmd_trace(struct perf_session *session)
+ static int __cmd_script(struct perf_session *session)
  {
        int ret;
  
@@@ -247,7 -247,7 +247,7 @@@ static void list_available_languages(vo
  
        fprintf(stderr, "\n");
        fprintf(stderr, "Scripting language extensions (used in "
-               "perf trace -s [spec:]script.[spec]):\n\n");
+               "perf script -s [spec:]script.[spec]):\n\n");
  
        list_for_each_entry(s, &script_specs, node)
                fprintf(stderr, "  %-42s [%s]\n", s->spec, s->ops->name);
@@@ -301,34 -301,17 +301,34 @@@ static int parse_scriptname(const struc
        return 0;
  }
  
 -#define for_each_lang(scripts_dir, lang_dirent, lang_next)            \
 +/* Helper function for filesystems that return a dent->d_type DT_UNKNOWN */
 +static int is_directory(const char *base_path, const struct dirent *dent)
 +{
 +      char path[PATH_MAX];
 +      struct stat st;
 +
 +      sprintf(path, "%s/%s", base_path, dent->d_name);
 +      if (stat(path, &st))
 +              return 0;
 +
 +      return S_ISDIR(st.st_mode);
 +}
 +
 +#define for_each_lang(scripts_path, scripts_dir, lang_dirent, lang_next)\
        while (!readdir_r(scripts_dir, &lang_dirent, &lang_next) &&     \
               lang_next)                                               \
 -              if (lang_dirent.d_type == DT_DIR &&                     \
 +              if ((lang_dirent.d_type == DT_DIR ||                    \
 +                   (lang_dirent.d_type == DT_UNKNOWN &&               \
 +                    is_directory(scripts_path, &lang_dirent))) &&     \
                    (strcmp(lang_dirent.d_name, ".")) &&                \
                    (strcmp(lang_dirent.d_name, "..")))
  
 -#define for_each_script(lang_dir, script_dirent, script_next)         \
 +#define for_each_script(lang_path, lang_dir, script_dirent, script_next)\
        while (!readdir_r(lang_dir, &script_dirent, &script_next) &&    \
               script_next)                                             \
 -              if (script_dirent.d_type != DT_DIR)
 +              if (script_dirent.d_type != DT_DIR &&                   \
 +                  (script_dirent.d_type != DT_UNKNOWN ||              \
 +                   !is_directory(lang_path, &script_dirent)))
  
  
  #define RECORD_SUFFIX                 "-record"
@@@ -483,14 -466,14 +483,14 @@@ static int list_available_scripts(cons
        if (!scripts_dir)
                return -1;
  
 -      for_each_lang(scripts_dir, lang_dirent, lang_next) {
 +      for_each_lang(scripts_path, scripts_dir, lang_dirent, lang_next) {
                snprintf(lang_path, MAXPATHLEN, "%s/%s/bin", scripts_path,
                         lang_dirent.d_name);
                lang_dir = opendir(lang_path);
                if (!lang_dir)
                        continue;
  
 -              for_each_script(lang_dir, script_dirent, script_next) {
 +              for_each_script(lang_path, lang_dir, script_dirent, script_next) {
                        script_root = strdup(script_dirent.d_name);
                        str = ends_with(script_root, REPORT_SUFFIX);
                        if (str) {
@@@ -531,14 -514,14 +531,14 @@@ static char *get_script_path(const cha
        if (!scripts_dir)
                return NULL;
  
 -      for_each_lang(scripts_dir, lang_dirent, lang_next) {
 +      for_each_lang(scripts_path, scripts_dir, lang_dirent, lang_next) {
                snprintf(lang_path, MAXPATHLEN, "%s/%s/bin", scripts_path,
                         lang_dirent.d_name);
                lang_dir = opendir(lang_path);
                if (!lang_dir)
                        continue;
  
 -              for_each_script(lang_dir, script_dirent, script_next) {
 +              for_each_script(lang_path, lang_dir, script_dirent, script_next) {
                        __script_root = strdup(script_dirent.d_name);
                        str = ends_with(__script_root, suffix);
                        if (str) {
@@@ -586,12 -569,12 +586,12 @@@ out
        return n_args;
  }
  
- static const char * const trace_usage[] = {
-       "perf trace [<options>]",
-       "perf trace [<options>] record <script> [<record-options>] <command>",
-       "perf trace [<options>] report <script> [script-args]",
-       "perf trace [<options>] <script> [<record-options>] <command>",
-       "perf trace [<options>] <top-script> [script-args]",
+ static const char * const script_usage[] = {
+       "perf script [<options>]",
+       "perf script [<options>] record <script> [<record-options>] <command>",
+       "perf script [<options>] report <script> [script-args]",
+       "perf script [<options>] <script> [<record-options>] <command>",
+       "perf script [<options>] <top-script> [script-args]",
        NULL
  };
  
@@@ -608,7 -591,7 +608,7 @@@ static const struct option options[] = 
                     "script file name (lang:script name, script name, or *)",
                     parse_scriptname),
        OPT_STRING('g', "gen-script", &generate_script_lang, "lang",
-                  "generate perf-trace.xx script in specified language"),
+                  "generate perf-script.xx script in specified language"),
        OPT_STRING('i', "input", &input_name, "file",
                    "input file name"),
        OPT_BOOLEAN('d', "debug-mode", &debug_mode,
@@@ -631,7 -614,7 +631,7 @@@ static bool have_cmd(int argc, const ch
        return argc != 0;
  }
  
- int cmd_trace(int argc, const char **argv, const char *prefix __used)
+ int cmd_script(int argc, const char **argv, const char *prefix __used)
  {
        char *rec_script_path = NULL;
        char *rep_script_path = NULL;
  
        setup_scripting();
  
-       argc = parse_options(argc, argv, options, trace_usage,
+       argc = parse_options(argc, argv, options, script_usage,
                             PARSE_OPT_STOP_AT_NON_OPTION);
  
        if (argc > 1 && !strncmp(argv[0], "rec", strlen("rec"))) {
                if (!rep_script_path) {
                        fprintf(stderr,
                                "Please specify a valid report script"
-                               "(see 'perf trace -l' for listing)\n");
+                               "(see 'perf script -l' for listing)\n");
                        return -1;
                }
        }
  
                if (!rec_script_path && !rep_script_path) {
                        fprintf(stderr, " Couldn't find script %s\n\n See perf"
-                               " trace -l for available scripts.\n", argv[0]);
-                       usage_with_options(trace_usage, options);
+                               " script -l for available scripts.\n", argv[0]);
+                       usage_with_options(script_usage, options);
                }
  
                if (is_top_script(argv[0])) {
                        rec_args = (argc - 1) - rep_args;
                        if (rec_args < 0) {
                                fprintf(stderr, " %s script requires options."
-                                       "\n\n See perf trace -l for available "
+                                       "\n\n See perf script -l for available "
                                        "scripts and options.\n", argv[0]);
-                               usage_with_options(trace_usage, options);
+                               usage_with_options(script_usage, options);
                        }
                }
  
                        return -1;
                }
  
-               err = scripting_ops->generate_script("perf-trace");
+               err = scripting_ops->generate_script("perf-script");
                goto out;
        }
  
                err = scripting_ops->start_script(script_name, argc, argv);
                if (err)
                        goto out;
-               pr_debug("perf trace started with script %s\n\n", script_name);
+               pr_debug("perf script started with script %s\n\n", script_name);
        }
  
-       err = __cmd_trace(session);
+       err = __cmd_script(session);
  
        perf_session__delete(session);
        cleanup_scripting();
@@@ -16,7 -16,7 +16,7 @@@ perf-report                   mainporcelain commo
  perf-stat                     mainporcelain common
  perf-timechart                        mainporcelain common
  perf-top                      mainporcelain common
--perf-trace                    mainporcelain common
++perf-script                   mainporcelain common
  perf-probe                    mainporcelain common
  perf-kmem                     mainporcelain common
  perf-lock                     mainporcelain common