X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=liblttng-ust%2Fltt-events.c;h=7a7fd7efc07ba54b5baca467f3c82e6d0c23bf2c;hb=9ec6895c5633ed93c5acdf1e5b06f075fbd709d3;hp=1e058b206c066825f81358ad04724c408aa710c1;hpb=aa1419550b1157d1455b53d29aa7b0cfcccf8b07;p=lttng-ust.git diff --git a/liblttng-ust/ltt-events.c b/liblttng-ust/ltt-events.c index 1e058b20..7a7fd7ef 100644 --- a/liblttng-ust/ltt-events.c +++ b/liblttng-ust/ltt-events.c @@ -22,11 +22,9 @@ #define _GNU_SOURCE #include -#include #include #include #include -#include #include #include #include @@ -34,7 +32,7 @@ #include #include #include -#include +#include #include "clock.h" #include @@ -48,6 +46,8 @@ #include #include #include "error.h" +#include "compat.h" +#include "lttng-ust-uuid.h" #include "tracepoint-internal.h" #include "ltt-tracer.h" @@ -56,8 +56,6 @@ #include "../libringbuffer/shm.h" #include "jhash.h" -#define PROCNAME_LEN 17 - /* * The sessions mutex is the centralized mutex across UST tracing * control and probe registration. All operations within this file are @@ -248,19 +246,21 @@ int pending_probe_fix_events(const struct lttng_event_desc *desc) memcpy(&event_param, &sw->event_param, sizeof(event_param)); - memcpy(event_param.name, + strncpy(event_param.name, desc->name, sizeof(event_param.name)); + event_param.name[sizeof(event_param.name) - 1] = '\0'; /* create event */ ret = ltt_event_create(sw->chan, - &event_param, NULL, - &ev); + &event_param, &ev); if (ret) { DBG("Error creating event"); continue; } cds_list_add(&ev->wildcard_list, &sw->events); + lttng_filter_event_link_bytecode(ev, + sw->filter_bytecode); } } } @@ -297,6 +297,8 @@ int pending_probe_fix_events(const struct lttng_event_desc *desc) event->id = chan->free_event_id++; ret |= _ltt_event_metadata_statedump(chan->session, chan, event); + lttng_filter_event_link_bytecode(event, + event->filter_bytecode); } return ret; } @@ -309,6 +311,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) @@ -316,7 +319,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; } @@ -498,7 +504,6 @@ void _ltt_channel_destroy(struct ltt_channel *chan) */ int ltt_event_create(struct ltt_channel *chan, struct lttng_ust_event *event_param, - void *filter, struct ltt_event **_event) { const struct lttng_event_desc *desc = NULL; /* silence gcc */ @@ -546,7 +551,6 @@ int ltt_event_create(struct ltt_channel *chan, goto cache_error; } event->chan = chan; - event->filter = filter; /* * used_event_id counts the maximum number of event IDs that can * register if all probes register. @@ -651,6 +655,8 @@ void _ltt_event_destroy(struct ltt_event *event) } cds_list_del(&event->list); lttng_destroy_context(event->ctx); + free(event->filter_bytecode); + free(event->filter_data); free(event); } @@ -721,6 +727,9 @@ int _ltt_field_statedump(struct ltt_session *session, { int ret = 0; + if (field->nowrite) + return 0; + switch (field->type.atype) { case atype_integer: ret = lttng_metadata_printf(session, @@ -922,6 +931,14 @@ int _ltt_event_metadata_statedump(struct ltt_session *session, if (ret) goto end; + if (event->desc->u.ext.model_emf_uri) { + ret = lttng_metadata_printf(session, + " model.emf.uri = \"%s\";\n", + *(event->desc->u.ext.model_emf_uri)); + if (ret) + goto end; + } + if (event->ctx) { ret = lttng_metadata_printf(session, " context := struct {\n"); @@ -1018,9 +1035,9 @@ int _ltt_stream_packet_context_declare(struct ltt_session *session) "struct packet_context {\n" " uint64_clock_monotonic_t timestamp_begin;\n" " uint64_clock_monotonic_t timestamp_end;\n" - " uint32_t events_discarded;\n" - " uint32_t content_size;\n" - " uint32_t packet_size;\n" + " uint64_t content_size;\n" + " uint64_t packet_size;\n" + " unsigned long events_discarded;\n" " uint32_t cpu_id;\n" "};\n\n" ); @@ -1101,11 +1118,13 @@ 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[PROCNAME_LEN] = ""; + char procname[LTTNG_UST_PROCNAME_LEN] = ""; + char hostname[HOST_NAME_MAX]; if (!CMM_ACCESS_ONCE(session->active)) return 0; @@ -1128,6 +1147,7 @@ int _ltt_session_metadata_statedump(struct ltt_session *session) "typealias integer { size = 16; align = %u; signed = false; } := uint16_t;\n" "typealias integer { size = 32; align = %u; signed = false; } := uint32_t;\n" "typealias integer { size = 64; align = %u; signed = false; } := uint64_t;\n" + "typealias integer { size = %u; align = %u; signed = false; } := unsigned long;\n" "typealias integer { size = 5; align = 1; signed = false; } := uint5_t;\n" "typealias integer { size = 27; align = 1; signed = false; } := uint27_t;\n" "\n" @@ -1146,6 +1166,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, + sizeof(unsigned long) * CHAR_BIT, + lttng_alignof(unsigned long) * CHAR_BIT, CTF_SPEC_MAJOR, CTF_SPEC_MINOR, uuid_s, @@ -1159,10 +1181,15 @@ int _ltt_session_metadata_statedump(struct ltt_session *session) goto end; /* ignore error, just use empty string if error. */ - (void) prctl(PR_GET_NAME, (unsigned long) procname, 0, 0, 0); - procname[PROCNAME_LEN - 1] = '\0'; + hostname[0] = '\0'; + ret = gethostname(hostname, sizeof(hostname)); + if (ret && errno == ENAMETOOLONG) + hostname[HOST_NAME_MAX - 1] = '\0'; + lttng_ust_getprocname(procname); + procname[LTTNG_UST_PROCNAME_LEN - 1] = '\0'; ret = lttng_metadata_printf(session, "env {\n" + " hostname = \"%s\";\n" " vpid = %d;\n" " procname = \"%s\";\n" " domain = \"ust\";\n" @@ -1171,6 +1198,7 @@ int _ltt_session_metadata_statedump(struct ltt_session *session) " tracer_minor = %u;\n" " tracer_patchlevel = %u;\n" "};\n\n", + hostname, (int) getpid(), procname, LTTNG_UST_MAJOR_VERSION, @@ -1411,6 +1439,7 @@ void _remove_wildcard(struct session_wildcard *wildcard) cds_list_del(&wildcard->entry->list); free(wildcard->entry); } + free(wildcard->filter_bytecode); free(wildcard); } @@ -1478,7 +1507,7 @@ int ltt_wildcard_disable(struct session_wildcard *wildcard) */ void lttng_fixup_event_tls(void) { - unsigned char uuid[37]; + unsigned char uuid[LTTNG_UST_UUID_STR_LEN]; - (void) uuid_generate(uuid); + (void) lttng_ust_uuid_generate(uuid); }