+ return 0;
+
+field_error:
+ free(new_ctx);
+ return ret;
+}
+
+int lttng_session_context_init(struct lttng_ctx **ctx)
+{
+ int ret;
+
+ ret = lttng_add_pthread_id_to_ctx(ctx);
+ if (ret) {
+ WARN("Cannot add context lttng_add_pthread_id_to_ctx");
+ goto error;
+ }
+ ret = lttng_add_vtid_to_ctx(ctx);
+ if (ret) {
+ WARN("Cannot add context lttng_add_vtid_to_ctx");
+ goto error;
+ }
+ ret = lttng_add_vpid_to_ctx(ctx);
+ if (ret) {
+ WARN("Cannot add context lttng_add_vpid_to_ctx");
+ goto error;
+ }
+ ret = lttng_add_procname_to_ctx(ctx);
+ if (ret) {
+ WARN("Cannot add context lttng_add_procname_to_ctx");
+ goto error;
+ }
+ ret = lttng_add_cpu_id_to_ctx(ctx);
+ if (ret) {
+ WARN("Cannot add context lttng_add_cpu_id_to_ctx");
+ goto error;
+ }
+ ret = lttng_add_cgroup_ns_to_ctx(ctx);
+ if (ret) {
+ WARN("Cannot add context lttng_add_cgroup_ns_to_ctx");
+ goto error;
+ }
+ ret = lttng_add_ipc_ns_to_ctx(ctx);
+ if (ret) {
+ WARN("Cannot add context lttng_add_ipc_ns_to_ctx");
+ goto error;
+ }
+ ret = lttng_add_mnt_ns_to_ctx(ctx);
+ if (ret) {
+ WARN("Cannot add context lttng_add_mnt_ns_to_ctx");
+ goto error;
+ }
+ ret = lttng_add_net_ns_to_ctx(ctx);
+ if (ret) {
+ WARN("Cannot add context lttng_add_net_ns_to_ctx");
+ goto error;
+ }
+ ret = lttng_add_pid_ns_to_ctx(ctx);
+ if (ret) {
+ WARN("Cannot add context lttng_add_pid_ns_to_ctx");
+ goto error;
+ }
+ ret = lttng_add_user_ns_to_ctx(ctx);
+ if (ret) {
+ WARN("Cannot add context lttng_add_user_ns_to_ctx");
+ goto error;
+ }
+ ret = lttng_add_uts_ns_to_ctx(ctx);
+ if (ret) {
+ WARN("Cannot add context lttng_add_uts_ns_to_ctx");
+ goto error;
+ }
+ ret = lttng_add_vuid_to_ctx(ctx);
+ if (ret) {
+ WARN("Cannot add context lttng_add_vuid_to_ctx");
+ goto error;
+ }
+ ret = lttng_add_veuid_to_ctx(ctx);
+ if (ret) {
+ WARN("Cannot add context lttng_add_veuid_to_ctx");
+ goto error;
+ }
+ ret = lttng_add_vsuid_to_ctx(ctx);
+ if (ret) {
+ WARN("Cannot add context lttng_add_vsuid_to_ctx");
+ goto error;
+ }
+ ret = lttng_add_vgid_to_ctx(ctx);
+ if (ret) {
+ WARN("Cannot add context lttng_add_vgid_to_ctx");
+ goto error;
+ }
+ ret = lttng_add_vegid_to_ctx(ctx);
+ if (ret) {
+ WARN("Cannot add context lttng_add_vegid_to_ctx");
+ goto error;
+ }
+ ret = lttng_add_vsgid_to_ctx(ctx);
+ if (ret) {
+ WARN("Cannot add context lttng_add_vsgid_to_ctx");
+ goto error;
+ }
+ lttng_context_update(*ctx);
+ return 0;
+
+error:
+ lttng_destroy_context(*ctx);
+ return ret;
+}
+
+/* For backward compatibility. Leave those exported symbols in place. */
+struct lttng_ctx *lttng_static_ctx;
+
+void lttng_context_init(void)
+{
+}
+
+void lttng_context_exit(void)
+{