Perf completion will use perf list --raw-dump to get the events available for 
'-e'.
But currently, it does not work well.

Example:
        # perf stat -e kvmm[TAB]  Error: unknown option `raw-dump'

        usage: perf list [hw|sw|cache|tracepoint|pmu|event_glob]

Because perf-completion.sh use 'perf list --raw-dump' to get the all events, but
as we introduced the parse_options() for perf list. We will get a error when we
use --raw-dump option.

This patch add an hiden option raw_dump for perf list. Then the --raw-dump will
work well to get the all event names and it will not be noise in perf list -h.

Verification:
        # ./perf stat -e kvmmmu:[TAB]
        fast_page_fault           kvm_mmu_get_page          
kvm_mmu_paging_element    kvm_mmu_set_accessed_bit  kvm_mmu_sync_page         
kvm_mmu_walker_error
        handle_mmio_page_fault    kvm_mmu_pagetable_walk    
kvm_mmu_prepare_zap_page  kvm_mmu_set_dirty_bit     kvm_mmu_unsync_page       
mark_mmio_spte

Signed-off-by: Dongsheng Yang <yangds.f...@cn.fujitsu.com>
---
 tools/perf/builtin-list.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/tools/perf/builtin-list.c b/tools/perf/builtin-list.c
index 011195e..82d54b6 100644
--- a/tools/perf/builtin-list.c
+++ b/tools/perf/builtin-list.c
@@ -19,7 +19,9 @@
 int cmd_list(int argc, const char **argv, const char *prefix __maybe_unused)
 {
        int i;
+       bool raw_dump = false;
        const struct option list_options[] = {
+               OPT_BOOLEAN_HIDEN(0, "raw-dump", &raw_dump, NULL),
                OPT_END()
        };
        const char * const list_usage[] = {
@@ -30,6 +32,11 @@ int cmd_list(int argc, const char **argv, const char *prefix 
__maybe_unused)
        argc = parse_options(argc, argv, list_options, list_usage,
                             PARSE_OPT_STOP_AT_NON_OPTION);
 
+       if (raw_dump) {
+               print_events(NULL, true);
+               return 0;
+       }
+
        setup_pager();
 
        if (argc == 0) {
@@ -53,8 +60,6 @@ int cmd_list(int argc, const char **argv, const char *prefix 
__maybe_unused)
                        print_hwcache_events(NULL, false);
                else if (strcmp(argv[i], "pmu") == 0)
                        print_pmu_events(NULL, false);
-               else if (strcmp(argv[i], "--raw-dump") == 0)
-                       print_events(NULL, true);
                else {
                        char *sep = strchr(argv[i], ':'), *s;
                        int sep_idx;
-- 
1.8.2.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to