X-Git-Url: http://git.lttng.org/?a=blobdiff_plain;f=liblttng-ust%2Fltt-events.c;h=21e8f8ac023979decfd884cb1f92c3f667a09193;hb=refs%2Fheads%2Fcygwin-2.0-experimental;hp=2b06f3c0bcb50be40de644158372d25fed82e707;hpb=17ec046afa9b641b95951ca9594c3b7351d5e658;p=lttng-ust.git diff --git a/liblttng-ust/ltt-events.c b/liblttng-ust/ltt-events.c index 2b06f3c0..21e8f8ac 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 @@ -181,20 +179,20 @@ int add_pending_probe(struct ltt_event *event, const char *name, { struct cds_hlist_head *head; struct ust_pending_probe *e; - size_t name_len = strlen(name); + size_t name_len = strlen(name) + 1; uint32_t hash; - if (name_len > LTTNG_UST_SYM_NAME_LEN - 1) { - WARN("Truncating tracepoint name %s which exceeds size limits of %u chars", name, LTTNG_UST_SYM_NAME_LEN - 1); - name_len = LTTNG_UST_SYM_NAME_LEN - 1; + if (name_len > LTTNG_UST_SYM_NAME_LEN) { + WARN("Truncating tracepoint name %s which exceeds size limits of %u chars", name, LTTNG_UST_SYM_NAME_LEN); + name_len = LTTNG_UST_SYM_NAME_LEN; } - hash = jhash(name, name_len, 0); + hash = jhash(name, name_len - 1, 0); head = &pending_probe_table[hash & (PENDING_PROBE_HASH_SIZE - 1)]; e = zmalloc(sizeof(struct ust_pending_probe) + name_len); if (!e) return -ENOMEM; - memcpy(&e->name[0], name, name_len + 1); - e->name[name_len] = '\0'; + memcpy(&e->name[0], name, name_len); + e->name[name_len - 1] = '\0'; e->loglevel_type = loglevel_type; e->loglevel = loglevel; cds_hlist_add_head(&e->node, head); @@ -230,7 +228,7 @@ int pending_probe_fix_events(const struct lttng_event_desc *desc) const char *name = desc->name; int ret = 0; struct lttng_ust_event event_param; - size_t name_len = strlen(name); + size_t name_len = strlen(name) + 1; uint32_t hash; /* Wildcard */ @@ -248,9 +246,10 @@ 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, @@ -265,11 +264,11 @@ int pending_probe_fix_events(const struct lttng_event_desc *desc) } } - if (name_len > LTTNG_UST_SYM_NAME_LEN - 1) { - WARN("Truncating tracepoint name %s which exceeds size limits of %u chars", name, LTTNG_UST_SYM_NAME_LEN - 1); - name_len = LTTNG_UST_SYM_NAME_LEN - 1; + if (name_len > LTTNG_UST_SYM_NAME_LEN) { + WARN("Truncating tracepoint name %s which exceeds size limits of %u chars", name, LTTNG_UST_SYM_NAME_LEN); + name_len = LTTNG_UST_SYM_NAME_LEN; } - hash = jhash(name, name_len, 0); + hash = jhash(name, name_len - 1, 0); head = &pending_probe_table[hash & (PENDING_PROBE_HASH_SIZE - 1)]; cds_hlist_for_each_entry_safe(e, node, p, head, node) { struct ltt_event *event; @@ -309,6 +308,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 +316,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; } @@ -443,7 +446,8 @@ struct ltt_channel *ltt_channel_create(struct ltt_session *session, size_t subbuf_size, size_t num_subbuf, unsigned int switch_timer_interval, unsigned int read_timer_interval, - int **shm_fd, int **wait_fd, + int **shm_fd, char **shm_path, + int **wait_fd, char **wait_pipe_path, uint64_t **memory_map_size, struct ltt_channel *chan_priv_init) { @@ -467,8 +471,9 @@ struct ltt_channel *ltt_channel_create(struct ltt_session *session, */ chan = transport->ops.channel_create(transport_name, buf_addr, subbuf_size, num_subbuf, switch_timer_interval, - read_timer_interval, shm_fd, wait_fd, - memory_map_size, chan_priv_init); + read_timer_interval, shm_fd, shm_path, + wait_fd, wait_pipe_path, memory_map_size, + chan_priv_init); if (!chan) goto create_error; chan->enabled = 1; @@ -498,7 +503,7 @@ void _ltt_channel_destroy(struct ltt_channel *chan) */ int ltt_event_create(struct ltt_channel *chan, struct lttng_ust_event *event_param, - void *filter, + void (*filter)(struct ltt_event *event), struct ltt_event **_event) { const struct lttng_event_desc *desc = NULL; /* silence gcc */ @@ -1101,11 +1106,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[PROCNAME_LEN] = ""; + char procname[LTTNG_UST_PROCNAME_LEN] = ""; if (!CMM_ACCESS_ONCE(session->active)) return 0; @@ -1159,8 +1165,8 @@ 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'; + lttng_ust_getprocname(procname); + procname[LTTNG_UST_PROCNAME_LEN - 1] = '\0'; ret = lttng_metadata_printf(session, "env {\n" " vpid = %d;\n" @@ -1356,6 +1362,8 @@ struct session_wildcard *add_wildcard(struct ltt_channel *chan, if (!e) return ERR_PTR(-ENOMEM); memcpy(&e->name[0], event_param->name, name_len); + e->loglevel_type = event_param->loglevel_type; + e->loglevel = event_param->loglevel; cds_list_add(&e->list, &wildcard_list); CDS_INIT_LIST_HEAD(&e->session_list); }