Fix: add events with 0 field to field list
[lttng-ust.git] / liblttng-ust / ltt-events.c
index aafa126c47a064ff5e368af93236d7f66a4790d4..ab099e1aba89afedb6a9456c0768509277500a8c 100644 (file)
@@ -251,14 +251,15 @@ int pending_probe_fix_events(const struct lttng_event_desc *desc)
                                        sizeof(event_param.name));
                                /* 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);
                        }
                }
        }
@@ -295,6 +296,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;
 }
@@ -500,7 +503,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 */
@@ -548,7 +550,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.
@@ -653,6 +654,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);
 }
 
@@ -723,6 +726,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,
@@ -1020,7 +1026,7 @@ 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"
+               "       unsigned long events_discarded;\n"
                "       uint32_t content_size;\n"
                "       uint32_t packet_size;\n"
                "       uint32_t cpu_id;\n"
@@ -1109,6 +1115,7 @@ int _ltt_session_metadata_statedump(struct ltt_session *session)
        struct ltt_event *event;
        int ret = 0;
        char procname[LTTNG_UST_PROCNAME_LEN] = "";
+       char hostname[HOST_NAME_MAX];
 
        if (!CMM_ACCESS_ONCE(session->active))
                return 0;
@@ -1131,6 +1138,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"
@@ -1149,6 +1157,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,
@@ -1162,10 +1172,15 @@ int _ltt_session_metadata_statedump(struct ltt_session *session)
                goto end;
 
        /* ignore error, just use empty string if error. */
+       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"
@@ -1174,6 +1189,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,
@@ -1414,6 +1430,7 @@ void _remove_wildcard(struct session_wildcard *wildcard)
                cds_list_del(&wildcard->entry->list);
                free(wildcard->entry);
        }
+       free(wildcard->filter_bytecode);
        free(wildcard);
 }
 
This page took 0.024554 seconds and 4 git commands to generate.