From 0cda4f28041a221757fa2dfa8e91706e7a548090 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Wed, 1 Feb 2012 14:01:28 -0500 Subject: [PATCH] Revert "Revert "Update loglevel ABI"" This reverts commit 69892bbba677a6695b216046d586e58bfa0f82c9. Revert of revert, need to go forward for ABI change. Will fix problems in a following commit. Signed-off-by: Mathieu Desnoyers --- include/lttng/lttng.h | 16 ++++++++-- src/bin/lttng-sessiond/lttng-ust-abi.h | 12 ++++++-- src/bin/lttng-sessiond/main.c | 11 +++++-- src/bin/lttng-sessiond/trace-ust.c | 19 ++++++++++-- src/bin/lttng-sessiond/ust-app.c | 2 +- src/bin/lttng/commands/enable_events.c | 42 +++++++++++++++++++------- src/bin/lttng/commands/list.c | 8 ++--- 7 files changed, 82 insertions(+), 28 deletions(-) diff --git a/include/lttng/lttng.h b/include/lttng/lttng.h index a791338c8..433d2d804 100644 --- a/include/lttng/lttng.h +++ b/include/lttng/lttng.h @@ -65,7 +65,14 @@ enum lttng_event_type { LTTNG_EVENT_FUNCTION_ENTRY = 3, LTTNG_EVENT_NOOP = 4, LTTNG_EVENT_SYSCALL = 5, - LTTNG_EVENT_TRACEPOINT_LOGLEVEL = 6, +}; + +/* + * Loglevel information. + */ +enum lttng_loglevel_type { + LTTNG_EVENT_LOGLEVEL = 0, + LTTNG_EVENT_LOGLEVEL_ONLY = 1, }; /* @@ -141,10 +148,13 @@ struct lttng_event_function_attr { * Generic lttng event */ struct lttng_event { + enum lttng_event_type type; char name[LTTNG_SYMBOL_NAME_LEN]; + + enum lttng_loglevel_type loglevel_type; char loglevel[LTTNG_SYMBOL_NAME_LEN]; - int64_t loglevel_value; - enum lttng_event_type type; + int64_t loglevel_value; /* for printing */ + uint32_t enabled; pid_t pid; /* Per event type configuration */ diff --git a/src/bin/lttng-sessiond/lttng-ust-abi.h b/src/bin/lttng-sessiond/lttng-ust-abi.h index f30dbde3f..28962aaf7 100644 --- a/src/bin/lttng-sessiond/lttng-ust-abi.h +++ b/src/bin/lttng-sessiond/lttng-ust-abi.h @@ -22,7 +22,11 @@ enum lttng_ust_instrumentation { LTTNG_UST_TRACEPOINT = 0, LTTNG_UST_PROBE = 1, LTTNG_UST_FUNCTION = 2, - LTTNG_UST_TRACEPOINT_LOGLEVEL = 3, +}; + +enum lttng_ust_loglevel_type { + LTTNG_UST_LOGLEVEL = 0, + LTTNG_UST_LOGLEVEL_ONLY = 1, }; enum lttng_ust_output { @@ -45,8 +49,12 @@ struct lttng_ust_channel { }; struct lttng_ust_event { - char name[LTTNG_UST_SYM_NAME_LEN]; /* event name */ enum lttng_ust_instrumentation instrumentation; + char name[LTTNG_UST_SYM_NAME_LEN]; /* event name */ + + enum lttng_ust_loglevel_type loglevel_type; + char loglevel[LTTNG_UST_SYM_NAME_LEN]; /* loglevel name */ + /* Per instrumentation type configuration */ union { } u; diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c index 8304de8be..8e4afb00b 100644 --- a/src/bin/lttng-sessiond/main.c +++ b/src/bin/lttng-sessiond/main.c @@ -2031,8 +2031,15 @@ static int list_lttng_ust_global_events(char *channel_name, case LTTNG_UST_FUNCTION: tmp[i].type = LTTNG_EVENT_FUNCTION; break; - case LTTNG_UST_TRACEPOINT_LOGLEVEL: - tmp[i].type = LTTNG_EVENT_TRACEPOINT_LOGLEVEL; + } + strncpy(tmp[i].loglevel, uevent->attr.loglevel, LTTNG_SYMBOL_NAME_LEN); + tmp[i].loglevel[LTTNG_SYMBOL_NAME_LEN - 1] = '\0'; + switch (uevent->attr.loglevel_type) { + case LTTNG_UST_LOGLEVEL: + tmp[i].type = LTTNG_EVENT_LOGLEVEL; + break; + case LTTNG_UST_LOGLEVEL_ONLY: + tmp[i].type = LTTNG_EVENT_LOGLEVEL_ONLY; break; } i++; diff --git a/src/bin/lttng-sessiond/trace-ust.c b/src/bin/lttng-sessiond/trace-ust.c index 0858f47d5..0a90cac0e 100644 --- a/src/bin/lttng-sessiond/trace-ust.c +++ b/src/bin/lttng-sessiond/trace-ust.c @@ -213,9 +213,6 @@ struct ltt_ust_event *trace_ust_create_event(struct lttng_event *ev) case LTTNG_EVENT_TRACEPOINT: lue->attr.instrumentation = LTTNG_UST_TRACEPOINT; break; - case LTTNG_EVENT_TRACEPOINT_LOGLEVEL: - lue->attr.instrumentation = LTTNG_UST_TRACEPOINT_LOGLEVEL; - break; default: ERR("Unknown ust instrumentation type (%d)", ev->type); goto error_free_event; @@ -225,6 +222,22 @@ struct ltt_ust_event *trace_ust_create_event(struct lttng_event *ev) strncpy(lue->attr.name, ev->name, LTTNG_UST_SYM_NAME_LEN); lue->attr.name[LTTNG_UST_SYM_NAME_LEN - 1] = '\0'; + switch (ev->loglevel_type) { + case LTTNG_EVENT_LOGLEVEL: + lue->attr.loglevel_type = LTTNG_UST_LOGLEVEL; + break; + case LTTNG_EVENT_LOGLEVEL_ONLY: + lue->attr.loglevel_type = LTTNG_UST_LOGLEVEL_ONLY; + break; + default: + ERR("Unknown ust loglevel type (%d)", ev->type); + goto error_free_event; + } + + /* Copy loglevel name */ + strncpy(lue->attr.loglevel, ev->loglevel, LTTNG_UST_SYM_NAME_LEN); + lue->attr.loglevel[LTTNG_UST_SYM_NAME_LEN - 1] = '\0'; + /* Init node */ lttng_ht_node_init_str(&lue->node, lue->attr.name); /* Alloc context hash tables */ diff --git a/src/bin/lttng-sessiond/ust-app.c b/src/bin/lttng-sessiond/ust-app.c index 39dd9ba36..8e329a29f 100644 --- a/src/bin/lttng-sessiond/ust-app.c +++ b/src/bin/lttng-sessiond/ust-app.c @@ -1421,8 +1421,8 @@ int ust_app_list_events(struct lttng_event **events) } memcpy(tmp[count].name, uiter.name, LTTNG_UST_SYM_NAME_LEN); memcpy(tmp[count].loglevel, uiter.loglevel, LTTNG_UST_SYM_NAME_LEN); - tmp[count].loglevel_value = uiter.loglevel_value; tmp[count].type = LTTNG_UST_TRACEPOINT; + tmp[count].loglevel_value = uiter.loglevel_value; tmp[count].pid = app->key.pid; tmp[count].enabled = -1; count++; diff --git a/src/bin/lttng/commands/enable_events.c b/src/bin/lttng/commands/enable_events.c index 3f30ab8ba..0fa3e916c 100644 --- a/src/bin/lttng/commands/enable_events.c +++ b/src/bin/lttng/commands/enable_events.c @@ -31,6 +31,8 @@ static char *opt_event_list; static int opt_event_type; +static const char *opt_loglevel; +static int opt_loglevel_type; static int opt_kernel; static char *opt_session_name; static int opt_userspace; @@ -53,7 +55,8 @@ enum { OPT_FUNCTION_ENTRY, OPT_SYSCALL, OPT_USERSPACE, - OPT_TRACEPOINT_LOGLEVEL, + OPT_LOGLEVEL, + OPT_LOGLEVEL_ONLY, OPT_LIST_OPTIONS, }; @@ -84,7 +87,8 @@ static struct poptOption long_options[] = { {"function:entry", 0, POPT_ARG_STRING, &opt_function_entry_symbol, OPT_FUNCTION_ENTRY, 0, 0}, #endif {"syscall", 0, POPT_ARG_NONE, 0, OPT_SYSCALL, 0, 0}, - {"loglevel", 0, POPT_ARG_NONE, 0, OPT_TRACEPOINT_LOGLEVEL, 0, 0}, + {"loglevel", 0, POPT_ARG_STRING, 0, OPT_LOGLEVEL, 0, 0}, + {"loglevel-only", 0, POPT_ARG_STRING, 0, OPT_LOGLEVEL_ONLY, 0, 0}, {"list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL}, {0, 0, 0, 0, 0, 0, 0} }; @@ -118,7 +122,10 @@ static void usage(FILE *ofp) fprintf(ofp, " e.g.:\n"); fprintf(ofp, " \"*\"\n"); fprintf(ofp, " \"app_component:na*\"\n"); - fprintf(ofp, " --loglevel Tracepoint loglevel\n"); + fprintf(ofp, " --loglevel name\n"); + fprintf(ofp, " Tracepoint loglevel (range: 0 to loglevel)\n"); + fprintf(ofp, " --loglevel-only name\n"); + fprintf(ofp, " Tracepoint loglevel (only this loglevel)\n"); fprintf(ofp, " --probe [addr | symbol | symbol+offset]\n"); fprintf(ofp, " Dynamic probe.\n"); fprintf(ofp, " Addr and offset can be octal (0NNN...),\n"); @@ -333,6 +340,16 @@ static int enable_events(char *session_name) ret = CMD_UNDEFINED; goto error; } + + if (opt_loglevel[0] != '\0') { + MSG("Kernel loglevels are not supported."); + ret = CMD_UNDEFINED; + goto error; + } + + /* kernel loglevels not implemented */ + ev.loglevel_type = opt_loglevel_type; + ev.loglevel[0] = '\0'; } else if (opt_userspace) { /* User-space tracer action */ #if 0 if (opt_cmd_name != NULL || opt_pid) { @@ -354,12 +371,6 @@ static int enable_events(char *session_name) strncpy(ev.name, event_name, LTTNG_SYMBOL_NAME_LEN); ev.name[LTTNG_SYMBOL_NAME_LEN - 1] = '\0'; break; - case LTTNG_EVENT_TRACEPOINT_LOGLEVEL: - /* Copy name and type of the event */ - ev.type = LTTNG_EVENT_TRACEPOINT_LOGLEVEL; - strncpy(ev.name, event_name, LTTNG_SYMBOL_NAME_LEN); - ev.name[LTTNG_SYMBOL_NAME_LEN - 1] = '\0'; - break; case LTTNG_EVENT_PROBE: case LTTNG_EVENT_FUNCTION: case LTTNG_EVENT_FUNCTION_ENTRY: @@ -368,6 +379,10 @@ static int enable_events(char *session_name) ret = CMD_UNDEFINED; goto error; } + + ev.loglevel_type = opt_loglevel_type; + strncpy(ev.loglevel, opt_loglevel, LTTNG_SYMBOL_NAME_LEN); + ev.loglevel[LTTNG_SYMBOL_NAME_LEN - 1] = '\0'; } else { ERR("Please specify a tracer (-k/--kernel or -u/--userspace)"); goto error; @@ -432,8 +447,13 @@ int cmd_enable_events(int argc, const char **argv) case OPT_USERSPACE: opt_userspace = 1; break; - case OPT_TRACEPOINT_LOGLEVEL: - opt_event_type = LTTNG_EVENT_TRACEPOINT_LOGLEVEL; + case OPT_LOGLEVEL: + opt_loglevel_type = LTTNG_EVENT_LOGLEVEL; + opt_loglevel = poptGetOptArg(pc); + break; + case OPT_LOGLEVEL_ONLY: + opt_loglevel_type = LTTNG_EVENT_LOGLEVEL_ONLY; + opt_loglevel = poptGetOptArg(pc); break; case OPT_LIST_OPTIONS: list_cmd_options(stdout, long_options); diff --git a/src/bin/lttng/commands/list.c b/src/bin/lttng/commands/list.c index 701ce83c0..4b8a07c48 100644 --- a/src/bin/lttng/commands/list.c +++ b/src/bin/lttng/commands/list.c @@ -179,8 +179,9 @@ static void print_events(struct lttng_event *event) ret = snprintf(ll_value, LTTNG_SYMBOL_NAME_LEN, " (%lld)", (long long) event->loglevel_value); - if (ret < 0) + if (ret < 0) { ERR("snprintf error"); + } } MSG("%s%s%s%s%s%s (type: tracepoint)%s", indent6, event->name, @@ -215,11 +216,6 @@ static void print_events(struct lttng_event *event) MSG("%s (type: noop)%s", indent6, enabled_string(event->enabled)); break; - case LTTNG_EVENT_TRACEPOINT_LOGLEVEL: - MSG("%s%s (type: tracepoint loglevel)%s", indent6, - event->name, - enabled_string(event->enabled)); - break; case LTTNG_EVENT_ALL: /* We should never have "all" events in list. */ assert(0); -- 2.34.1