From: Chaosheng Qu <[email protected]>
Subject: [PATCH] rtla: reject -e, --filter and --trigger without --trace
To: Steven Rostedt <[email protected]>
Cc: Tomas Glozar <[email protected]>,
    [email protected],
    [email protected]

-e, --filter and --trigger configure events of the trace instance that
--trace creates, and trace_events_enable() is only called from inside the
block that --trace or --on-end trace enters.  Without either of them the
options are parsed, stored in params->events and then never looked at
again: rtla runs to completion and exits 0, so the user is left believing
the events were enabled.

  # rtla osnoise top -e sched:sched_switch -d 1s
  ... runs for a second, exit 0, no trace file, event never enabled

  # rtla osnoise top -e nosuchsys:nosuchevent -d 1s
  ... exit 0, the typo goes unnoticed

Reject the combination instead.  This does not change what happens when
--trace is given: an invalid event still fails with "Error enabling
event", and a valid one still works.

Signed-off-by: Chaosheng Qu <[email protected]>
---
diff --git a/tools/tracing/rtla/src/common.c b/tools/tracing/rtla/src/common.c
--- a/tools/tracing/rtla/src/common.c
+++ b/tools/tracing/rtla/src/common.c
@@ -203,6 +203,19 @@
        }
 
 
+       /*
+        * -e, --filter and --trigger configure events of the trace instance
+        * that --trace creates.  Without it there is no instance to put them
+        * in, and they used to be dropped without a word.
+        */
+       if (params->events &&
+           !params->threshold_actions.present[ACTION_TRACE_OUTPUT] &&
+           !params->end_actions.present[ACTION_TRACE_OUTPUT]) {
+               err_msg("-e, --filter and --trigger need --trace or --on-end 
trace\n");
+               retval = 1;
+               goto out_free;
+       }
+
        if (params->threshold_actions.present[ACTION_TRACE_OUTPUT] ||
            params->end_actions.present[ACTION_TRACE_OUTPUT]) {
                tool->record = osnoise_init_trace_tool(ops->tracer);


Reply via email to