X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=liblttng-ust%2Fltt-events.c;h=b0f4a50f8f04ab9b555b9107b7a1e5b0b05986ae;hb=67107619135ff344f0de2783ec2d48e558deaf9a;hp=52feeb08a7dad9c9bc9970a39197a586f9305612;hpb=457a6b5879a7dd8cdd1b5b22b20d028a59489159;p=lttng-ust.git diff --git a/liblttng-ust/ltt-events.c b/liblttng-ust/ltt-events.c index 52feeb08..b0f4a50f 100644 --- a/liblttng-ust/ltt-events.c +++ b/liblttng-ust/ltt-events.c @@ -10,11 +10,9 @@ #define _GNU_SOURCE #include -#include #include #include #include -#include #include #include #include @@ -22,6 +20,7 @@ #include #include #include +#include #include "clock.h" #include @@ -35,6 +34,8 @@ #include #include #include "error.h" +#include "compat.h" +#include "uuid.h" #include "tracepoint-internal.h" #include "ltt-tracer.h" @@ -260,8 +261,7 @@ int pending_probe_fix_events(const struct lttng_event_desc *desc) struct ltt_event *event; struct ltt_channel *chan; - event = e->event; - if (!ltt_loglevel_match(event->desc, + if (!ltt_loglevel_match(desc, e->loglevel_type, e->loglevel)) { continue; @@ -269,6 +269,7 @@ int pending_probe_fix_events(const struct lttng_event_desc *desc) if (strncmp(name, e->name, LTTNG_UST_SYM_NAME_LEN - 1)) { continue; } + event = e->event; chan = event->chan; assert(!event->desc); event->desc = desc; @@ -294,6 +295,7 @@ void synchronize_trace(void) struct ltt_session *ltt_session_create(void) { struct ltt_session *session; + int ret; session = zmalloc(sizeof(struct ltt_session)); if (!session) @@ -301,7 +303,10 @@ struct ltt_session *ltt_session_create(void) CDS_INIT_LIST_HEAD(&session->chan); CDS_INIT_LIST_HEAD(&session->events); CDS_INIT_LIST_HEAD(&session->wildcards); - uuid_generate(session->uuid); + ret = lttng_ust_uuid_generate(session->uuid); + if (ret != 0) { + session->uuid[0] = '\0'; + } cds_list_add(&session->list, &sessions); return session; } @@ -512,12 +517,18 @@ int ltt_event_create(struct ltt_channel *chan, */ if (event_param->instrumentation == LTTNG_UST_TRACEPOINT) { desc = ltt_event_get(event_param->name); - if (!ltt_loglevel_match(desc, - event_param->loglevel_type, - event_param->loglevel)) { - ret = -EPERM; - goto no_loglevel_match; + if (desc) { + if (!ltt_loglevel_match(desc, + event_param->loglevel_type, + event_param->loglevel)) { + ret = -EPERM; + goto no_loglevel_match; + } } + /* + * If descriptor is not there, it will be added to + * pending probes. + */ } event = zmalloc(sizeof(struct ltt_event)); if (!event) { @@ -869,6 +880,7 @@ int _ltt_event_metadata_statedump(struct ltt_session *session, struct ltt_event *event) { int ret = 0; + int loglevel = TRACE_DEFAULT; if (event->metadata_dumped || !CMM_ACCESS_ONCE(session->active)) return 0; @@ -891,13 +903,14 @@ int _ltt_event_metadata_statedump(struct ltt_session *session, if (ret) goto end; - if (event->desc->loglevel) { - ret = lttng_metadata_printf(session, - " loglevel = %d;\n", - *(*event->desc->loglevel)); - if (ret) - goto end; - } + if (event->desc->loglevel) + loglevel = *(*event->desc->loglevel); + + ret = lttng_metadata_printf(session, + " loglevel = %d;\n", + loglevel); + if (ret) + goto end; if (event->ctx) { ret = lttng_metadata_printf(session, @@ -1078,10 +1091,12 @@ static int _ltt_session_metadata_statedump(struct ltt_session *session) { unsigned char *uuid_c = session->uuid; - char uuid_s[37], clock_uuid_s[CLOCK_UUID_LEN]; + char uuid_s[LTTNG_UST_UUID_STR_LEN], + clock_uuid_s[LTTNG_UST_UUID_STR_LEN]; struct ltt_channel *chan; struct ltt_event *event; int ret = 0; + char procname[LTTNG_UST_PROCNAME_LEN] = ""; if (!CMM_ACCESS_ONCE(session->active)) return 0; @@ -1122,8 +1137,8 @@ int _ltt_session_metadata_statedump(struct ltt_session *session) lttng_alignof(uint16_t) * CHAR_BIT, lttng_alignof(uint32_t) * CHAR_BIT, lttng_alignof(uint64_t) * CHAR_BIT, - CTF_VERSION_MAJOR, - CTF_VERSION_MINOR, + CTF_SPEC_MAJOR, + CTF_SPEC_MINOR, uuid_s, #if (BYTE_ORDER == BIG_ENDIAN) "be" @@ -1134,6 +1149,28 @@ int _ltt_session_metadata_statedump(struct ltt_session *session) if (ret) goto end; + /* ignore error, just use empty string if error. */ + lttng_ust_getprocname(procname); + procname[LTTNG_UST_PROCNAME_LEN - 1] = '\0'; + ret = lttng_metadata_printf(session, + "env {\n" + " vpid = %d;\n" + " procname = \"%s\";\n" + " domain = \"ust\";\n" + " tracer_name = \"lttng-ust\";\n" + " tracer_major = %u;\n" + " tracer_minor = %u;\n" + " tracer_patchlevel = %u;\n" + "};\n\n", + (int) getpid(), + procname, + LTTNG_UST_MAJOR_VERSION, + LTTNG_UST_MINOR_VERSION, + LTTNG_UST_PATCHLEVEL_VERSION + ); + if (ret) + goto end; + ret = lttng_metadata_printf(session, "clock {\n" " name = %s;\n",