Background
==========
The `tests/regression/kernel/test_callstack` test uses the PID tracker
to restrict what events end up in the trace. It does that by using the
following lttng command:
lttng untrack -s $SESSION_NAME --all --pid -k
Issue
=====
A regression was introduced along with the UID tracker patch series that
makes the above command fail silently and return status 1. The bug is in
the argument parsing function that assumes that the tracker option
(`--pid` in this case) would appear before the `--all` option.
Where the above command fails, the one below works as expected:
lttng untrack -s $SESSION_NAME --pid --all -k
Both ordering are valid and should be accepted.
Fix
===
When parsing the arguments, first record the fact that we encountered the
`--all` flag, and later check to what tracker it applies too.
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I85f7a2fa8d6f67056aeff8edf3d12508f5ae0879
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
#define _LGPL_SOURCE
#include <ctype.h>
#include <popt.h>
#define _LGPL_SOURCE
#include <ctype.h>
#include <popt.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int argc, const char **argv, const char *help_msg)
{
int opt, ret = 0, success = 1;
int argc, const char **argv, const char *help_msg)
{
int opt, ret = 0, success = 1;
+ bool opt_all_present = false;
enum cmd_error_code command_ret = CMD_SUCCESS;
static poptContext pc;
char *session_name = NULL;
enum cmd_error_code command_ret = CMD_SUCCESS;
static poptContext pc;
char *session_name = NULL;
type_state = STATE_VGID;
break;
case OPT_ALL:
type_state = STATE_VGID;
break;
case OPT_ALL:
- switch (type_state) {
- case STATE_PID:
- opt_pid.all = 1;
- break;
- case STATE_VPID:
- opt_vpid.all = 1;
- break;
- case STATE_UID:
- opt_uid.all = 1;
- break;
- case STATE_VUID:
- opt_vuid.all = 1;
- break;
- case STATE_GID:
- opt_gid.all = 1;
- break;
- case STATE_VGID:
- opt_vgid.all = 1;
- break;
- default:
- command_ret = CMD_ERROR;
- goto end;
- }
+ opt_all_present = true;
break;
default:
command_ret = CMD_UNDEFINED;
break;
default:
command_ret = CMD_UNDEFINED;
+ /*
+ * If the `--all` option is present set the appropriate tracker's `all`
+ * field.
+ */
+ if (opt_all_present) {
+ switch (type_state) {
+ case STATE_PID:
+ opt_pid.all = 1;
+ break;
+ case STATE_VPID:
+ opt_vpid.all = 1;
+ break;
+ case STATE_UID:
+ opt_uid.all = 1;
+ break;
+ case STATE_VUID:
+ opt_vuid.all = 1;
+ break;
+ case STATE_GID:
+ opt_gid.all = 1;
+ break;
+ case STATE_VGID:
+ opt_vgid.all = 1;
+ break;
+ default:
+ command_ret = CMD_ERROR;
+ goto end;
+ }
+ }
+
if (!opt_session_name) {
session_name = get_session_name();
if (session_name == NULL) {
if (!opt_session_name) {
session_name = get_session_name();
if (session_name == NULL) {
SESSION_NAME="tracker"
NR_ITER=100
NUM_GLOBAL_TESTS=2
SESSION_NAME="tracker"
NR_ITER=100
NUM_GLOBAL_TESTS=2
NUM_KERNEL_TESTS=462
NUM_TESTS=$((NUM_UST_TESTS+NUM_KERNEL_TESTS+NUM_GLOBAL_TESTS))
NUM_KERNEL_TESTS=462
NUM_TESTS=$((NUM_UST_TESTS+NUM_KERNEL_TESTS+NUM_GLOBAL_TESTS))
+# Both ordering of tracker type and `--all` are valid.
+test_event_track_untrack ust 0 "${EVENT_NAME}" "--vgid --all"
+test_event_track_untrack ust 0 "${EVENT_NAME}" "--all --vgid"
+
#vuid, vgid
# non-matching
#vuid, vgid
# non-matching