*/
#define _LGPL_SOURCE
+#include <common/compat/time.hpp>
#include <ctype.h>
+#include <functional>
#include <popt.h>
+#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
-#include <common/compat/time.hpp>
-#include <unistd.h>
-#include <signal.h>
#include <sys/wait.h>
+#include <unistd.h>
+#include <unordered_map>
#include <common/mi-lttng.hpp>
static char *opt_ctrl_url;
static char *opt_data_url;
static char *opt_shm_path;
+static char *opt_trace_format;
static int opt_no_consumer;
static int opt_no_output;
static int opt_snapshot;
{"snapshot", 0, POPT_ARG_VAL, &opt_snapshot, 1, 0, 0},
{"live", 0, POPT_ARG_INT | POPT_ARGFLAG_OPTIONAL, 0, OPT_LIVE_TIMER, 0, 0},
{"shm-path", 0, POPT_ARG_STRING, &opt_shm_path, 0, 0, 0},
+ {"trace-format", 0, POPT_ARG_STRING, &opt_trace_format, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0}
};
ret = spawn_relayd(pathname, 0);
if (ret < 0) {
- lttng_session_descriptor_destroy(descriptor);
- descriptor = NULL;
+ goto error;
}
}
}
+
+ if (opt_trace_format) {
+ std::unordered_map<std::string,
+ std::function<struct lttng_trace_format_descriptor *()>>
+ factory = {
+ {"ctf1", lttng_trace_format_ctf_1_descriptor_create},
+ {"ctf2", lttng_trace_format_ctf_2_descriptor_create},
+ };
+
+ lttng_session_descriptor_status status;
+ lttng_trace_format_descriptor *trace_format_descriptor = nullptr;
+ std::string s_trace_format(opt_trace_format);
+
+ auto it = factory.find(s_trace_format);
+
+ if (it == factory.end()) {
+ ERR("Unknown trace format");
+ goto error;
+ }
+
+ trace_format_descriptor = it->second();
+ if (trace_format_descriptor == nullptr) {
+ ERR("Failed to create trace format descriptor for trace format %s",
+ opt_trace_format);
+ goto error;
+ }
+
+ status = lttng_session_descriptor_set_trace_format_descriptor(
+ descriptor, trace_format_descriptor);
+ lttng_trace_format_descriptor_destroy(trace_format_descriptor);
+ if (status != LTTNG_SESSION_DESCRIPTOR_STATUS_OK) {
+ ERR("Failed to set trace format descriptor");
+ goto error;
+ }
+ }
end:
free(uris);
return descriptor;
+error:
+ lttng_session_descriptor_destroy(descriptor);
+ descriptor = NULL;
+ goto end;
}
/*