From: Mathieu Desnoyers Date: Thu, 26 May 2011 00:33:50 +0000 (-0400) Subject: Don't print context metadata if empty X-Git-Tag: v2.0-pre1~83 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=b9074a1bbba0f037e3000044cc4935a3c6e82c97;p=lttng-modules.git Don't print context metadata if empty Signed-off-by: Mathieu Desnoyers --- diff --git a/ltt-events.c b/ltt-events.c index 6171c1c5..f98ef309 100644 --- a/ltt-events.c +++ b/ltt-events.c @@ -575,20 +575,30 @@ int _ltt_event_metadata_statedump(struct ltt_session *session, "event {\n" " name = %s;\n" " id = %u;\n" - " stream_id = %u;\n" - " context := struct {\n", + " stream_id = %u;\n", event->desc->name, event->id, event->chan->id); if (ret) goto end; + if (event->ctx) { + ret = lttng_metadata_printf(session, + " context := struct {\n"); + if (ret) + goto end; + } ret = _ltt_context_metadata_statedump(session, event->ctx); if (ret) goto end; + if (event->ctx) { + ret = lttng_metadata_printf(session, + " };\n"); + if (ret) + goto end; + } ret = lttng_metadata_printf(session, - " };\n" " fields := struct {\n" ); if (ret) @@ -630,22 +640,31 @@ int _ltt_channel_metadata_statedump(struct ltt_session *session, "stream {\n" " id = %u;\n" " event.header := %s;\n" - " packet.context := struct packet_context;\n" - " event.context := {\n", + " packet.context := struct packet_context;\n", chan->id, chan->header_type == 1 ? "struct event_header_compact" : "struct event_header_large"); if (ret) goto end; + if (chan->ctx) { + ret = lttng_metadata_printf(session, + " event.context := struct {\n"); + if (ret) + goto end; + } ret = _ltt_context_metadata_statedump(session, chan->ctx); if (ret) goto end; + if (chan->ctx) { + ret = lttng_metadata_printf(session, + " };\n"); + if (ret) + goto end; + } ret = lttng_metadata_printf(session, - " };\n" - "};\n\n" - ); + "};\n\n"); chan->metadata_dumped = 1; end: