From: David Goulet Date: Wed, 1 Feb 2012 18:43:05 +0000 (-0500) Subject: Revert "Update loglevel ABI" X-Git-Tag: v2.0-pre19~22 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=69892bbba677a6695b216046d586e58bfa0f82c9;p=lttng-tools.git Revert "Update loglevel ABI" Segfault on lttng enable-event when no loglevel is specified. UST tests failed. This implementation forces a loglevel to each event which is fine however the default level is never set when no loglevel is specified. The internal UST ABI/API (used when lttng-ust is disabled) was not updated also making it fail when disablin the lttng-ust support. This broke too much stuff in lttng-tools so the commit is reverted and test must pass before commiting it again. lttng-ust HEAD will *NOT* work with lttng-tools head so stay on commit 939950af98d044a3b0632cad5293f91cb1493ef8 for UST. This reverts commit dad47fc4c65ec0acbfedc676895833b465d25cd6. Signed-off-by: David Goulet --- diff --git a/include/lttng/lttng.h b/include/lttng/lttng.h index 433d2d804..a791338c8 100644 --- a/include/lttng/lttng.h +++ b/include/lttng/lttng.h @@ -65,14 +65,7 @@ enum lttng_event_type { LTTNG_EVENT_FUNCTION_ENTRY = 3, LTTNG_EVENT_NOOP = 4, LTTNG_EVENT_SYSCALL = 5, -}; - -/* - * Loglevel information. - */ -enum lttng_loglevel_type { - LTTNG_EVENT_LOGLEVEL = 0, - LTTNG_EVENT_LOGLEVEL_ONLY = 1, + LTTNG_EVENT_TRACEPOINT_LOGLEVEL = 6, }; /* @@ -148,13 +141,10 @@ 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; /* for printing */ - + int64_t loglevel_value; + enum lttng_event_type type; 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 28962aaf7..f30dbde3f 100644 --- a/src/bin/lttng-sessiond/lttng-ust-abi.h +++ b/src/bin/lttng-sessiond/lttng-ust-abi.h @@ -22,11 +22,7 @@ enum lttng_ust_instrumentation { LTTNG_UST_TRACEPOINT = 0, LTTNG_UST_PROBE = 1, LTTNG_UST_FUNCTION = 2, -}; - -enum lttng_ust_loglevel_type { - LTTNG_UST_LOGLEVEL = 0, - LTTNG_UST_LOGLEVEL_ONLY = 1, + LTTNG_UST_TRACEPOINT_LOGLEVEL = 3, }; enum lttng_ust_output { @@ -49,12 +45,8 @@ struct lttng_ust_channel { }; struct lttng_ust_event { - 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 */ - + enum lttng_ust_instrumentation instrumentation; /* Per instrumentation type configuration */ union { } u; diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c index 8e4afb00b..8304de8be 100644 --- a/src/bin/lttng-sessiond/main.c +++ b/src/bin/lttng-sessiond/main.c @@ -2031,15 +2031,8 @@ static int list_lttng_ust_global_events(char *channel_name, case LTTNG_UST_FUNCTION: tmp[i].type = LTTNG_EVENT_FUNCTION; break; - } - 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; + case LTTNG_UST_TRACEPOINT_LOGLEVEL: + tmp[i].type = LTTNG_EVENT_TRACEPOINT_LOGLEVEL; break; } i++; diff --git a/src/bin/lttng-sessiond/trace-ust.c b/src/bin/lttng-sessiond/trace-ust.c index 0a90cac0e..0858f47d5 100644 --- a/src/bin/lttng-sessiond/trace-ust.c +++ b/src/bin/lttng-sessiond/trace-ust.c @@ -213,6 +213,9 @@ 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; @@ -222,22 +225,6 @@ 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 8e329a29f..39dd9ba36 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].type = LTTNG_UST_TRACEPOINT; tmp[count].loglevel_value = uiter.loglevel_value; + tmp[count].type = LTTNG_UST_TRACEPOINT; 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 0fa3e916c..3f30ab8ba 100644 --- a/src/bin/lttng/commands/enable_events.c +++ b/src/bin/lttng/commands/enable_events.c @@ -31,8 +31,6 @@ 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; @@ -55,8 +53,7 @@ enum { OPT_FUNCTION_ENTRY, OPT_SYSCALL, OPT_USERSPACE, - OPT_LOGLEVEL, - OPT_LOGLEVEL_ONLY, + OPT_TRACEPOINT_LOGLEVEL, OPT_LIST_OPTIONS, }; @@ -87,8 +84,7 @@ 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_STRING, 0, OPT_LOGLEVEL, 0, 0}, - {"loglevel-only", 0, POPT_ARG_STRING, 0, OPT_LOGLEVEL_ONLY, 0, 0}, + {"loglevel", 0, POPT_ARG_NONE, 0, OPT_TRACEPOINT_LOGLEVEL, 0, 0}, {"list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL}, {0, 0, 0, 0, 0, 0, 0} }; @@ -122,10 +118,7 @@ static void usage(FILE *ofp) fprintf(ofp, " e.g.:\n"); fprintf(ofp, " \"*\"\n"); fprintf(ofp, " \"app_component:na*\"\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, " --loglevel Tracepoint 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"); @@ -340,16 +333,6 @@ 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) { @@ -371,6 +354,12 @@ 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: @@ -379,10 +368,6 @@ 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; @@ -447,13 +432,8 @@ int cmd_enable_events(int argc, const char **argv) case OPT_USERSPACE: opt_userspace = 1; break; - 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); + case OPT_TRACEPOINT_LOGLEVEL: + opt_event_type = LTTNG_EVENT_TRACEPOINT_LOGLEVEL; 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 4b8a07c48..701ce83c0 100644 --- a/src/bin/lttng/commands/list.c +++ b/src/bin/lttng/commands/list.c @@ -179,9 +179,8 @@ 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, @@ -216,6 +215,11 @@ 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);