+int
+eal_trace_args_save(const char *optarg)
+{
+ struct trace *trace = trace_obj_get();
+ char *trace_args;
+ uint8_t nb_args;
+
+ nb_args = trace->args.nb_args;
+
+ if (nb_args >= TRACE_MAX_ARGS) {
+ trace_err("ignoring trace %s as limit exceeds", optarg);
+ return 0;
+ }
+
+ trace_args = calloc(1, (strlen(optarg) + 1));
+ if (trace_args == NULL) {
+ trace_err("fail to allocate memory for %s", optarg);
+ return -ENOMEM;
+ }
+
+ memcpy(trace_args, optarg, strlen(optarg));
+ trace->args.args[nb_args++] = trace_args;
+ trace->args.nb_args = nb_args;
+ return 0;
+}
+
+void
+eal_trace_args_free(void)
+{
+ struct trace *trace = trace_obj_get();
+ int i;
+
+ for (i = 0; i < trace->args.nb_args; i++) {
+ if (trace->args.args[i]) {
+ free((void *)trace->args.args[i]);
+ trace->args.args[i] = NULL;
+ }
+ }
+}
+
+int
+trace_args_apply(const char *arg)
+{
+ char *str;
+
+ str = strdup(arg);
+ if (str == NULL)
+ return -1;
+
+ if (rte_trace_regexp(str, true) < 0) {
+ trace_err("cannot enable trace for %s", str);
+ free(str);
+ return -1;
+ }
+
+ free(str);
+ return 0;
+}
+