|
@@ -1727,6 +1727,7 @@ static int parse_output_fields(const struct option *opt __maybe_unused,
|
|
int rc = 0;
|
|
int rc = 0;
|
|
char *str = strdup(arg);
|
|
char *str = strdup(arg);
|
|
int type = -1;
|
|
int type = -1;
|
|
|
|
+ enum { DEFAULT, SET, ADD, REMOVE } change = DEFAULT;
|
|
|
|
|
|
if (!str)
|
|
if (!str)
|
|
return -ENOMEM;
|
|
return -ENOMEM;
|
|
@@ -1772,6 +1773,10 @@ static int parse_output_fields(const struct option *opt __maybe_unused,
|
|
goto out;
|
|
goto out;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /* Don't override defaults for +- */
|
|
|
|
+ if (strchr(str, '+') || strchr(str, '-'))
|
|
|
|
+ goto parse;
|
|
|
|
+
|
|
if (output_set_by_user())
|
|
if (output_set_by_user())
|
|
pr_warning("Overriding previous field request for all events.\n");
|
|
pr_warning("Overriding previous field request for all events.\n");
|
|
|
|
|
|
@@ -1782,13 +1787,30 @@ static int parse_output_fields(const struct option *opt __maybe_unused,
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+parse:
|
|
for (tok = strtok_r(tok, ",", &strtok_saveptr); tok; tok = strtok_r(NULL, ",", &strtok_saveptr)) {
|
|
for (tok = strtok_r(tok, ",", &strtok_saveptr); tok; tok = strtok_r(NULL, ",", &strtok_saveptr)) {
|
|
|
|
+ if (*tok == '+') {
|
|
|
|
+ if (change == SET)
|
|
|
|
+ goto out_badmix;
|
|
|
|
+ change = ADD;
|
|
|
|
+ tok++;
|
|
|
|
+ } else if (*tok == '-') {
|
|
|
|
+ if (change == SET)
|
|
|
|
+ goto out_badmix;
|
|
|
|
+ change = REMOVE;
|
|
|
|
+ tok++;
|
|
|
|
+ } else {
|
|
|
|
+ if (change != SET && change != DEFAULT)
|
|
|
|
+ goto out_badmix;
|
|
|
|
+ change = SET;
|
|
|
|
+ }
|
|
|
|
+
|
|
for (i = 0; i < imax; ++i) {
|
|
for (i = 0; i < imax; ++i) {
|
|
if (strcmp(tok, all_output_options[i].str) == 0)
|
|
if (strcmp(tok, all_output_options[i].str) == 0)
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
if (i == imax && strcmp(tok, "flags") == 0) {
|
|
if (i == imax && strcmp(tok, "flags") == 0) {
|
|
- print_flags = true;
|
|
|
|
|
|
+ print_flags = change == REMOVE ? false : true;
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
if (i == imax) {
|
|
if (i == imax) {
|
|
@@ -1805,8 +1827,12 @@ static int parse_output_fields(const struct option *opt __maybe_unused,
|
|
if (output[j].invalid_fields & all_output_options[i].field) {
|
|
if (output[j].invalid_fields & all_output_options[i].field) {
|
|
pr_warning("\'%s\' not valid for %s events. Ignoring.\n",
|
|
pr_warning("\'%s\' not valid for %s events. Ignoring.\n",
|
|
all_output_options[i].str, event_type(j));
|
|
all_output_options[i].str, event_type(j));
|
|
- } else
|
|
|
|
- output[j].fields |= all_output_options[i].field;
|
|
|
|
|
|
+ } else {
|
|
|
|
+ if (change == REMOVE)
|
|
|
|
+ output[j].fields &= ~all_output_options[i].field;
|
|
|
|
+ else
|
|
|
|
+ output[j].fields |= all_output_options[i].field;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
if (output[type].invalid_fields & all_output_options[i].field) {
|
|
if (output[type].invalid_fields & all_output_options[i].field) {
|
|
@@ -1826,7 +1852,11 @@ static int parse_output_fields(const struct option *opt __maybe_unused,
|
|
"Events will not be displayed.\n", event_type(type));
|
|
"Events will not be displayed.\n", event_type(type));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ goto out;
|
|
|
|
|
|
|
|
+out_badmix:
|
|
|
|
+ fprintf(stderr, "Cannot mix +-field with overridden fields\n");
|
|
|
|
+ rc = -EINVAL;
|
|
out:
|
|
out:
|
|
free(str);
|
|
free(str);
|
|
return rc;
|
|
return rc;
|
|
@@ -2444,6 +2474,7 @@ int cmd_script(int argc, const char **argv)
|
|
symbol__config_symfs),
|
|
symbol__config_symfs),
|
|
OPT_CALLBACK('F', "fields", NULL, "str",
|
|
OPT_CALLBACK('F', "fields", NULL, "str",
|
|
"comma separated output fields prepend with 'type:'. "
|
|
"comma separated output fields prepend with 'type:'. "
|
|
|
|
+ "+field to add and -field to remove."
|
|
"Valid types: hw,sw,trace,raw. "
|
|
"Valid types: hw,sw,trace,raw. "
|
|
"Fields: comm,tid,pid,time,cpu,event,trace,ip,sym,dso,"
|
|
"Fields: comm,tid,pid,time,cpu,event,trace,ip,sym,dso,"
|
|
"addr,symoff,period,iregs,brstack,brstacksym,flags,"
|
|
"addr,symoff,period,iregs,brstack,brstacksym,flags,"
|