Skip to content

perf tools: get --list-cmds for subcommands

Ramkumar Ramachandra lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest5 patches 1 replyIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/5perf kvm: introduce --list-cmds for use by scriptstools/perf/builtin-kvm.c tools/perf/perf-completion.sh+35 -60 replies
2/5perf kmem: introduce --list-cmdstools/perf/builtin-kmem.c tools/perf/builtin-kvm.c tools/perf/perf-completion.sh +2 more+42 -300 replies
3/5perf lock: introduce --list-cmdstools/perf/builtin-lock.c tools/perf/perf-completion.sh+12 -60 replies
4/5perf mem: introduce --list-cmdstools/perf/builtin-mem.c tools/perf/perf-completion.sh+12 -70 replies
5/5perf sched: introduce --list-cmdstools/perf/builtin-sched.c tools/perf/perf-completion.sh+13 -60 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/5] perf tools: get --list-cmds for subcommands

Hi Arnaldo et al,

Quoted 15 lines · Arnaldo Carvalho de Melo

Don't do all those things open coded, introduce functions to print, concat, etc.

The best thing tho, since we have all those sub sub commands in things like 'perf kvm', 'perf bench', etc, we could have some parse_options_subcmd, and make the parse options machinery aware of this, so that it could receive an array of subcmds and when asked for --list-cmds, would print that sublist, etc, i.e. make sub cmds a first class citizen.

So I'd suggest that you first introduce functions for doing the concat to pass to the current infrastructure, so that we have what your patch provides, but prettified, then, as follow on patches, you could work on making the options parsing machinery aware of sub cmds.

Quoted 4 lines

Ah, and try not using fixed sized arrays, or at least verify that space is available, i.e. never use strcat, use strncat, better, take a look at tools/perf/util/strbuf.h, I guess you can use it to build the string for you in a safe way and expanding the buffer as needed, etc.

Okay, so here's a first cut. util.c/ util.h might not have been the best place to put the functions, but I couldn't think of a better place at the moment. The series isn't ideal, but I think it's getting close.

Thoughts?

Cc David Ahern <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>

Ramkumar Ramachandra (5):
perf kvm: introduce --list-cmds for use by scripts perf kmem: introduce --list-cmds
perf lock: introduce --list-cmds
perf mem: introduce --list-cmds
perf sched: introduce --list-cmds

 tools/perf/builtin-kmem.c     | 15 +++++++++++----
 tools/perf/builtin-kvm.c      | 16 +++++++++++-----
 tools/perf/builtin-lock.c     | 14 ++++++++++----
 tools/perf/builtin-mem.c      | 15 ++++++++++-----
 tools/perf/builtin-sched.c    | 15 +++++++++++----
 tools/perf/perf-completion.sh |  6 +++---
 tools/perf/util/util.c        | 24 ++++++++++++++++++++++++
 tools/perf/util/util.h        |  4 ++++
 8 files changed, 84 insertions(+), 25 deletions(-)
Signature · 1 line
1.8.5.2.227.g53f3478