diff mbox series

[v2,4/4] trace-cmd reset: Add bash tab completion for -B and -k

Message ID 20241014123136.3890807-5-metin.kaya@arm.com (mailing list archive)
State Accepted
Commit bbea061f69dab3a55dc5c077bf89a02f8f08cb6a
Headers show
Series trace-cmd reset: Add option to preserve specific events | expand

Commit Message

Metin Kaya Oct. 14, 2024, 12:31 p.m. UTC
Implement the placeholder for tab completion of "trace-cmd reset".

Apparently trace-cmd.bash already has support for instance buffers
lookup (which is show_instances()). Employ it for -B option.

Regarding -k option, show the list of dynamic event types to ease
trace-cmd user's job.

Signed-off-by: Metin Kaya <metin.kaya@arm.com>
---
 tracecmd/trace-cmd.bash | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)
diff mbox series

Patch

diff --git a/tracecmd/trace-cmd.bash b/tracecmd/trace-cmd.bash
index 66bd6f4b..01a75578 100644
--- a/tracecmd/trace-cmd.bash
+++ b/tracecmd/trace-cmd.bash
@@ -215,6 +215,33 @@  __trace_cmd_report_complete()
     esac
 }
 
+dynevent_options()
+{
+    local cur="$1"
+    local opts=("kprobe" "kretprobe" "uprobe" "uretprobe" "eprobe" "synth" "all")
+    COMPREPLY=( $(compgen -W "${opts[*]}" -- "${cur}") )
+}
+
+__trace_cmd_reset_complete()
+{
+    local prev=$1
+    local cur=$2
+    shift 2
+    local words=("$@")
+
+    case "$prev" in
+        -B)
+            show_instances "$cur"
+            ;;
+        -k)
+            dynevent_options "$cur"
+            ;;
+        *)
+            cmd_options reset "$cur"
+            ;;
+    esac
+}
+
 __trace_cmd_dump_complete()
 {
     local prev=$1
@@ -329,6 +356,10 @@  _trace_cmd_complete()
 	    __trace_cmd_report_complete "${prev}" "${cur}" ${words[@]}
 	    return 0
 	    ;;
+	reset)
+	    __trace_cmd_reset_complete "${prev}" "${cur}" "${words[@]}"
+	    return 0
+	    ;;
 	dump)
 	    __trace_cmd_dump_complete "${prev}" "${cur}" ${words[@]}
 	    return 0