#define _LGPL_SOURCE
#include <algorithm>
+#include <exception>
#include <inttypes.h>
#include <stdio.h>
#include <sys/stat.h>
const char *session_name;
struct ltt_session *new_session = NULL;
enum lttng_session_descriptor_status descriptor_status;
+ const lttng_trace_format_descriptor *trace_format_descriptor = NULL;
+ lttng::trace_format_descriptor::uptr trace_format_descriptor_ptr;
session_lock_list();
if (home_path) {
goto end;
}
- ret_code = session_create(session_name, creds->uid, creds->gid,
+ descriptor_status = lttng_session_descriptor_get_trace_format_descriptor(
+ descriptor, &trace_format_descriptor);
+ if (descriptor_status != LTTNG_SESSION_DESCRIPTOR_STATUS_OK) {
+ ret_code = LTTNG_ERR_INVALID;
+ goto end;
+ }
+
+ try {
+ trace_format_descriptor_ptr =
+ reinterpret_cast<const lttng::trace_format_descriptor *>(
+ trace_format_descriptor)
+ ->clone();
+ } catch (std::exception& e) {
+ ERR("%s", e.what());
+ ret_code = LTTNG_ERR_UNK;
+ goto end;
+ }
+
+ ret_code = session_create(session_name, creds->uid, creds->gid, trace_format_descriptor_ptr,
&new_session);
if (ret_code != LTTNG_OK) {
goto end;
* Create a new session and add it to the session list.
* Session list lock must be held by the caller.
*/
-enum lttng_error_code session_create(const char *name, uid_t uid, gid_t gid,
+enum lttng_error_code session_create(const char *name,
+ uid_t uid,
+ gid_t gid,
+ lttng::trace_format_descriptor::uptr& trace_format,
struct ltt_session **out_session)
{
int ret;
urcu_ref_init(&new_session->ref);
pthread_mutex_init(&new_session->lock, NULL);
+ new_session->trace_format = std::move(trace_format);
+
new_session->creation_time = time(NULL);
if (new_session->creation_time == (time_t) -1) {
PERROR("Failed to sample session creation time");
#define _LTT_SESSION_H
#include <limits.h>
+#include <memory>
#include <stdbool.h>
#include <urcu/list.h>
-#include <common/hashtable/hashtable.hpp>
#include <common/dynamic-array.hpp>
+#include <common/hashtable/hashtable.hpp>
#include <common/make-unique-wrapper.hpp>
#include <common/pthread-lock.hpp>
-#include <lttng/rotation.h>
#include <lttng/location.h>
#include <lttng/lttng-error.h>
+#include <lttng/rotation.h>
+#include <lttng/trace-format-descriptor-internal.hpp>
#include "snapshot.hpp"
#include "trace-kernel.hpp"
struct lttng_dynamic_array clear_notifiers {};
/* Session base path override. Set non-null. */
char *base_path{};
+ /* Trace output format */
+ lttng::trace_format_descriptor::sptr trace_format;
};
-enum lttng_error_code session_create(const char *name, uid_t uid, gid_t gid,
+enum lttng_error_code session_create(const char *name,
+ uid_t uid,
+ gid_t gid,
+ lttng::trace_format_descriptor::uptr& trace_format,
struct ltt_session **out_session);
void session_lock(struct ltt_session *session);
void session_unlock(struct ltt_session *session);
#include <bin/lttng-sessiond/ust-app.hpp>
#include <common/common.hpp>
#include <common/compat/errno.hpp>
+#include <common/make-unique.hpp>
#include <common/sessiond-comm/sessiond-comm.hpp>
#include <tap/tap.h>
int ret;
enum lttng_error_code ret_code;
struct ltt_session *session = NULL;
+ lttng::trace_format_descriptor::uptr trace_format_descriptor =
+ lttng::make_unique<lttng::trace_format_descriptor_ctf1>();
session_lock_list();
- ret_code = session_create(name, geteuid(), getegid(), &session);
+ ret_code = session_create(name, geteuid(), getegid(), trace_format_descriptor, &session);
session_put(session);
if (ret_code == LTTNG_OK) {
/* Validate */
ret = find_session_name(session_name);
if (ret < 0) {
- /* Success, -1 means that the sesion is NOT found */
+ /* Success, -1 means that the session is NOT found */
ret = 0;
} else {
/* Fail */
struct ltt_session *session = NULL;
enum lttng_error_code ret_code;
const char *expected_session_name_prefix = DEFAULT_SESSION_NAME;
+ lttng::trace_format_descriptor::uptr trace_format_descriptor =
+ lttng::make_unique<lttng::trace_format_descriptor_ctf1>();
session_lock_list();
- ret_code = session_create(NULL, geteuid(), getegid(), &session);
+ ret_code = session_create(NULL, geteuid(), getegid(), trace_format_descriptor, &session);
ok(ret_code == LTTNG_OK,
"Create session with a NULL name (auto-generate a name)");
if (!session) {