~ubuntu-branches/ubuntu/trusty/linux-linaro-omap/trusty

« back to all changes in this revision

Viewing changes to tools/perf/util/parse-events.c

  • Committer: Package Import Robot
  • Author(s): John Rigby, John Rigby
  • Date: 2011-09-26 10:44:23 UTC
  • Revision ID: package-import@ubuntu.com-20110926104423-57i0gl3v99b3lkfg
Tags: 3.0.0-1007.9
[ John Rigby ]

Enable crypto modules and remove crypto-modules from
exclude-module files
LP: #826021

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
#define CSW(x) .type = PERF_TYPE_SOFTWARE, .config = PERF_COUNT_SW_##x
32
32
 
33
33
static struct event_symbol event_symbols[] = {
34
 
  { CHW(CPU_CYCLES),            "cpu-cycles",           "cycles"        },
35
 
  { CHW(INSTRUCTIONS),          "instructions",         ""              },
36
 
  { CHW(CACHE_REFERENCES),      "cache-references",     ""              },
37
 
  { CHW(CACHE_MISSES),          "cache-misses",         ""              },
38
 
  { CHW(BRANCH_INSTRUCTIONS),   "branch-instructions",  "branches"      },
39
 
  { CHW(BRANCH_MISSES),         "branch-misses",        ""              },
40
 
  { CHW(BUS_CYCLES),            "bus-cycles",           ""              },
 
34
  { CHW(CPU_CYCLES),                    "cpu-cycles",                   "cycles"                },
 
35
  { CHW(STALLED_CYCLES_FRONTEND),       "stalled-cycles-frontend",      "idle-cycles-frontend"  },
 
36
  { CHW(STALLED_CYCLES_BACKEND),        "stalled-cycles-backend",       "idle-cycles-backend"   },
 
37
  { CHW(INSTRUCTIONS),                  "instructions",                 ""                      },
 
38
  { CHW(CACHE_REFERENCES),              "cache-references",             ""                      },
 
39
  { CHW(CACHE_MISSES),                  "cache-misses",                 ""                      },
 
40
  { CHW(BRANCH_INSTRUCTIONS),           "branch-instructions",          "branches"              },
 
41
  { CHW(BRANCH_MISSES),                 "branch-misses",                ""                      },
 
42
  { CHW(BUS_CYCLES),                    "bus-cycles",                   ""                      },
41
43
 
42
 
  { CSW(CPU_CLOCK),             "cpu-clock",            ""              },
43
 
  { CSW(TASK_CLOCK),            "task-clock",           ""              },
44
 
  { CSW(PAGE_FAULTS),           "page-faults",          "faults"        },
45
 
  { CSW(PAGE_FAULTS_MIN),       "minor-faults",         ""              },
46
 
  { CSW(PAGE_FAULTS_MAJ),       "major-faults",         ""              },
47
 
  { CSW(CONTEXT_SWITCHES),      "context-switches",     "cs"            },
48
 
  { CSW(CPU_MIGRATIONS),        "cpu-migrations",       "migrations"    },
49
 
  { CSW(ALIGNMENT_FAULTS),      "alignment-faults",     ""              },
50
 
  { CSW(EMULATION_FAULTS),      "emulation-faults",     ""              },
 
44
  { CSW(CPU_CLOCK),                     "cpu-clock",                    ""                      },
 
45
  { CSW(TASK_CLOCK),                    "task-clock",                   ""                      },
 
46
  { CSW(PAGE_FAULTS),                   "page-faults",                  "faults"                },
 
47
  { CSW(PAGE_FAULTS_MIN),               "minor-faults",                 ""                      },
 
48
  { CSW(PAGE_FAULTS_MAJ),               "major-faults",                 ""                      },
 
49
  { CSW(CONTEXT_SWITCHES),              "context-switches",             "cs"                    },
 
50
  { CSW(CPU_MIGRATIONS),                "cpu-migrations",               "migrations"            },
 
51
  { CSW(ALIGNMENT_FAULTS),              "alignment-faults",             ""                      },
 
52
  { CSW(EMULATION_FAULTS),              "emulation-faults",             ""                      },
51
53
};
52
54
 
53
55
#define __PERF_EVENT_FIELD(config, name) \
54
56
        ((config & PERF_EVENT_##name##_MASK) >> PERF_EVENT_##name##_SHIFT)
55
57
 
56
 
#define PERF_EVENT_RAW(config)  __PERF_EVENT_FIELD(config, RAW)
 
58
#define PERF_EVENT_RAW(config)          __PERF_EVENT_FIELD(config, RAW)
57
59
#define PERF_EVENT_CONFIG(config)       __PERF_EVENT_FIELD(config, CONFIG)
58
 
#define PERF_EVENT_TYPE(config) __PERF_EVENT_FIELD(config, TYPE)
 
60
#define PERF_EVENT_TYPE(config)         __PERF_EVENT_FIELD(config, TYPE)
59
61
#define PERF_EVENT_ID(config)           __PERF_EVENT_FIELD(config, EVENT)
60
62
 
61
 
static const char *hw_event_names[] = {
 
63
static const char *hw_event_names[PERF_COUNT_HW_MAX] = {
62
64
        "cycles",
63
65
        "instructions",
64
66
        "cache-references",
66
68
        "branches",
67
69
        "branch-misses",
68
70
        "bus-cycles",
 
71
        "stalled-cycles-frontend",
 
72
        "stalled-cycles-backend",
69
73
};
70
74
 
71
 
static const char *sw_event_names[] = {
72
 
        "cpu-clock-msecs",
73
 
        "task-clock-msecs",
 
75
static const char *sw_event_names[PERF_COUNT_SW_MAX] = {
 
76
        "cpu-clock",
 
77
        "task-clock",
74
78
        "page-faults",
75
79
        "context-switches",
76
80
        "CPU-migrations",
307
311
 
308
312
        switch (type) {
309
313
        case PERF_TYPE_HARDWARE:
310
 
                if (config < PERF_COUNT_HW_MAX)
 
314
                if (config < PERF_COUNT_HW_MAX && hw_event_names[config])
311
315
                        return hw_event_names[config];
312
316
                return "unknown-hardware";
313
317
 
333
337
        }
334
338
 
335
339
        case PERF_TYPE_SOFTWARE:
336
 
                if (config < PERF_COUNT_SW_MAX)
 
340
                if (config < PERF_COUNT_SW_MAX && sw_event_names[config])
337
341
                        return sw_event_names[config];
338
342
                return "unknown-software";
339
343
 
648
652
        int n;
649
653
 
650
654
        n = strlen(event_symbols[i].symbol);
651
 
        if (!strncmp(str, event_symbols[i].symbol, n))
 
655
        if (!strncasecmp(str, event_symbols[i].symbol, n))
652
656
                return n;
653
657
 
654
658
        n = strlen(event_symbols[i].alias);
655
 
        if (n)
656
 
                if (!strncmp(str, event_symbols[i].alias, n))
 
659
        if (n) {
 
660
                if (!strncasecmp(str, event_symbols[i].alias, n))
657
661
                        return n;
 
662
        }
 
663
 
658
664
        return 0;
659
665
}
660
666
 
718
724
        return EVT_FAILED;
719
725
}
720
726
 
721
 
static enum event_result
 
727
static int
722
728
parse_event_modifier(const char **strp, struct perf_event_attr *attr)
723
729
{
724
730
        const char *str = *strp;
725
731
        int exclude = 0;
726
732
        int eu = 0, ek = 0, eh = 0, precise = 0;
727
733
 
 
734
        if (!*str)
 
735
                return 0;
 
736
 
 
737
        if (*str == ',')
 
738
                return 0;
 
739
 
728
740
        if (*str++ != ':')
729
 
                return 0;
 
741
                return -1;
 
742
 
730
743
        while (*str) {
731
744
                if (*str == 'u') {
732
745
                        if (!exclude)
747
760
 
748
761
                ++str;
749
762
        }
750
 
        if (str >= *strp + 2) {
751
 
                *strp = str;
752
 
                attr->exclude_user   = eu;
753
 
                attr->exclude_kernel = ek;
754
 
                attr->exclude_hv     = eh;
755
 
                attr->precise_ip     = precise;
756
 
                return 1;
757
 
        }
 
763
        if (str < *strp + 2)
 
764
                return -1;
 
765
 
 
766
        *strp = str;
 
767
 
 
768
        attr->exclude_user   = eu;
 
769
        attr->exclude_kernel = ek;
 
770
        attr->exclude_hv     = eh;
 
771
        attr->precise_ip     = precise;
 
772
 
758
773
        return 0;
759
774
}
760
775
 
797
812
        return EVT_FAILED;
798
813
 
799
814
modifier:
800
 
        parse_event_modifier(str, attr);
 
815
        if (parse_event_modifier(str, attr) < 0) {
 
816
                fprintf(stderr, "invalid event modifier: '%s'\n", *str);
 
817
                fprintf(stderr, "Run 'perf list' for a list of valid events and modifiers\n");
 
818
 
 
819
                return EVT_FAILED;
 
820
        }
801
821
 
802
822
        return ret;
803
823
}
912
932
 
913
933
                        snprintf(evt_path, MAXPATHLEN, "%s:%s",
914
934
                                 sys_dirent.d_name, evt_dirent.d_name);
915
 
                        printf("  %-42s [%s]\n", evt_path,
 
935
                        printf("  %-50s [%s]\n", evt_path,
916
936
                                event_type_descriptors[PERF_TYPE_TRACEPOINT]);
917
937
                }
918
938
                closedir(evt_dir);
977
997
                else
978
998
                        snprintf(name, sizeof(name), "%s", syms->symbol);
979
999
 
980
 
                printf("  %-42s [%s]\n", name,
 
1000
                printf("  %-50s [%s]\n", name,
981
1001
                        event_type_descriptors[type]);
982
1002
        }
983
1003
}
995
1015
                        for (i = 0; i < PERF_COUNT_HW_CACHE_RESULT_MAX; i++) {
996
1016
                                char *name = event_cache_name(type, op, i);
997
1017
 
998
 
                                if (event_glob != NULL && 
999
 
                                    !strglobmatch(name, event_glob))
 
1018
                                if (event_glob != NULL && !strglobmatch(name, event_glob))
1000
1019
                                        continue;
1001
1020
 
1002
 
                                printf("  %-42s [%s]\n", name,
 
1021
                                printf("  %-50s [%s]\n", name,
1003
1022
                                        event_type_descriptors[PERF_TYPE_HW_CACHE]);
1004
1023
                                ++printed;
1005
1024
                        }
1009
1028
        return printed;
1010
1029
}
1011
1030
 
 
1031
#define MAX_NAME_LEN 100
 
1032
 
1012
1033
/*
1013
1034
 * Print the help text for the event symbols:
1014
1035
 */
1015
1036
void print_events(const char *event_glob)
1016
1037
{
1017
 
        struct event_symbol *syms = event_symbols;
1018
1038
        unsigned int i, type, prev_type = -1, printed = 0, ntypes_printed = 0;
1019
 
        char name[40];
 
1039
        struct event_symbol *syms = event_symbols;
 
1040
        char name[MAX_NAME_LEN];
1020
1041
 
1021
1042
        printf("\n");
1022
1043
        printf("List of pre-defined events (to be used in -e):\n");
1036
1057
                        continue;
1037
1058
 
1038
1059
                if (strlen(syms->alias))
1039
 
                        sprintf(name, "%s OR %s", syms->symbol, syms->alias);
 
1060
                        snprintf(name, MAX_NAME_LEN, "%s OR %s", syms->symbol, syms->alias);
1040
1061
                else
1041
 
                        strcpy(name, syms->symbol);
1042
 
                printf("  %-42s [%s]\n", name,
 
1062
                        strncpy(name, syms->symbol, MAX_NAME_LEN);
 
1063
                printf("  %-50s [%s]\n", name,
1043
1064
                        event_type_descriptors[type]);
1044
1065
 
1045
1066
                prev_type = type;
1056
1077
                return;
1057
1078
 
1058
1079
        printf("\n");
1059
 
        printf("  %-42s [%s]\n",
 
1080
        printf("  %-50s [%s]\n",
1060
1081
                "rNNN (see 'perf list --help' on how to encode it)",
1061
1082
               event_type_descriptors[PERF_TYPE_RAW]);
1062
1083
        printf("\n");
1063
1084
 
1064
 
        printf("  %-42s [%s]\n",
 
1085
        printf("  %-50s [%s]\n",
1065
1086
                        "mem:<addr>[:access]",
1066
1087
                        event_type_descriptors[PERF_TYPE_BREAKPOINT]);
1067
1088
        printf("\n");