lkml.org 
[lkml]   [2014]   [Apr]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 03/10] fixup! perf, tools: Add support for text descriptions of events and alias add
    Date
    From: Andi Kleen <ak@linux.intel.com>

    ---
    tools/perf/util/pmu.c | 48 ++++++++++++++++++++++++++++++++++++++++++++----
    1 file changed, 44 insertions(+), 4 deletions(-)

    diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
    index cc888d9..26311d9 100644
    --- a/tools/perf/util/pmu.c
    +++ b/tools/perf/util/pmu.c
    @@ -737,11 +737,51 @@ static char *format_alias_or(char *buf, int len, struct perf_pmu *pmu,
    return buf;
    }

    -static int cmp_string(const void *a, const void *b)
    +struct pair {
    + char *name;
    + char *desc;
    +};
    +
    +static int cmp_pair(const void *a, const void *b)
    +{
    + const struct pair *as = a;
    + const struct pair *bs = b;
    +
    + /* Put downloaded event list last */
    + if (!!as->desc != !!bs->desc)
    + return !!as->desc - !!bs->desc;
    + return strcmp(as->name, bs->name);
    +}
    +
    +static void wordwrap(char *s, int start, int max, int corr)
    +{
    + int column = start;
    + int n;
    +
    + while (*s) {
    + int wlen = strcspn(s, " \t");
    +
    + if (column + wlen >= max && column > start) {
    + printf("\n%*s", start, "");
    + column = start + corr;
    + }
    + n = printf("%s%.*s", column > start ? " " : "", wlen, s);
    + if (n <= 0)
    + break;
    + s += wlen;
    + column += n;
    + while (isspace(*s))
    + s++;
    + }
    +}
    +
    +static int get_columns(void)
    {
    - const char * const *as = a;
    - const char * const *bs = b;
    - return strcmp(*as, *bs);
    + /*
    + * Should ask the terminal with TIOCGWINSZ here, but we
    + * need the original fd before the pager.
    + */
    + return 79;
    }

    void print_pmu_events(const char *event_glob, bool name_only)
    --
    1.8.5.3


    \
     
     \ /
      Last update: 2014-04-17 00:01    [W:4.862 / U:0.020 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site