const char * const mi_lttng_element_event_field = "event_field";
const char * const mi_lttng_element_event_fields = "event_fields";
-/* String related to lttng_event_context */
-const char * const mi_lttng_context_type_perf_counter = "PERF_COUNTER";
-const char * const mi_lttng_context_type_perf_cpu_counter = "PERF_CPU_COUNTER";
-const char * const mi_lttng_context_type_perf_thread_counter = "PERF_THREAD_COUNTER";
-
/* String related to lttng_event_perf_counter_ctx */
-const char * const mi_lttng_element_perf_counter_context = "perf_counter_context";
+const char * const mi_lttng_element_perf_counter_context = "perf";
/* Strings related to pid */
const char * const mi_lttng_element_pid_id = "id";
}
}
-LTTNG_HIDDEN
+static
const char *mi_lttng_event_contexttype_string(enum lttng_event_context_type val)
{
switch (val) {
case LTTNG_EVENT_CONTEXT_PID:
return config_event_context_pid;
- case LTTNG_EVENT_CONTEXT_PERF_COUNTER:
- return mi_lttng_context_type_perf_counter;
- case LTTNG_EVENT_CONTEXT_PERF_THREAD_COUNTER:
- return mi_lttng_context_type_perf_thread_counter;
- case LTTNG_EVENT_CONTEXT_PERF_CPU_COUNTER:
- return mi_lttng_context_type_perf_cpu_counter;
case LTTNG_EVENT_CONTEXT_PROCNAME:
return config_event_context_procname;
case LTTNG_EVENT_CONTEXT_PRIO:
}
LTTNG_HIDDEN
-int mi_lttng_context(struct mi_writer *writer,
- struct lttng_event_context *context, int is_open)
+int mi_lttng_perf_counter_context(struct mi_writer *writer,
+ struct lttng_event_perf_counter_ctx *perf_context)
{
int ret;
- const char *type_string;
- struct lttng_event_perf_counter_ctx *perf_context;
- /* Open context */
- ret = mi_lttng_writer_open_element(writer , config_element_context);
+
+ /* Open perf_counter_context */
+ ret = mi_lttng_writer_open_element(writer,
+ mi_lttng_element_perf_counter_context);
if (ret) {
goto end;
}
- type_string = mi_lttng_event_contexttype_string(context->ctx);
- if (!type_string) {
- ret = -LTTNG_ERR_INVALID;
+ /* Type */
+ ret = mi_lttng_writer_write_element_unsigned_int(writer,
+ config_element_type, perf_context->type);
+ if (ret) {
goto end;
}
- /* Print context type */
- ret = mi_lttng_writer_write_element_string(writer, config_element_type,
- type_string);
-
- /* Special case for PERF_*_COUNTER
- * print the lttng_event_perf_counter_ctx*/
- switch (context->ctx) {
- case LTTNG_EVENT_CONTEXT_PERF_COUNTER:
- case LTTNG_EVENT_CONTEXT_PERF_THREAD_COUNTER:
- case LTTNG_EVENT_CONTEXT_PERF_CPU_COUNTER:
- perf_context = &context->u.perf_counter;
- ret = mi_lttng_perf_counter_context(writer, perf_context);
- if (ret) {
- goto end;
- }
- break;
- default:
- break;
+ /* Config */
+ ret = mi_lttng_writer_write_element_unsigned_int(writer,
+ config_element_config, perf_context->config);
+ if (ret) {
+ goto end;
}
- /* Close context */
- if (!is_open) {
- ret = mi_lttng_writer_close_element(writer);
+ /* Name of the perf counter */
+ ret = mi_lttng_writer_write_element_string(writer,
+ config_element_name, perf_context->name);
+ if (ret) {
+ goto end;
}
+ /* Close perf_counter_context */
+ ret = mi_lttng_writer_close_element(writer);
end:
return ret;
}
-LTTNG_HIDDEN
-int mi_lttng_perf_counter_context(struct mi_writer *writer,
- struct lttng_event_perf_counter_ctx *perf_context)
+static
+int mi_lttng_app_context(struct mi_writer *writer,
+ const char *provider_name, const char *ctx_name)
{
int ret;
- /* Open perf_counter_context */
+ /* Open app */
ret = mi_lttng_writer_open_element(writer,
- mi_lttng_element_perf_counter_context);
+ config_element_context_app);
if (ret) {
goto end;
}
- /* Type */
- ret = mi_lttng_writer_write_element_unsigned_int(writer,
- config_element_type, perf_context->type);
+ /* provider_name */
+ ret = mi_lttng_writer_write_element_string(writer,
+ config_element_context_app_provider_name,
+ provider_name);
if (ret) {
goto end;
}
- /* Config */
- ret = mi_lttng_writer_write_element_unsigned_int(writer,
- config_element_config, perf_context->config);
+ /* ctx_name */
+ ret = mi_lttng_writer_write_element_string(writer,
+ config_element_context_app_ctx_name, ctx_name);
if (ret) {
goto end;
}
- /* Name of the perf counter */
- ret = mi_lttng_writer_write_element_string(writer,
- config_element_name, perf_context->name);
+ /* Close app */
+ ret = mi_lttng_writer_close_element(writer);
+end:
+ return ret;
+}
+
+LTTNG_HIDDEN
+int mi_lttng_context(struct mi_writer *writer,
+ struct lttng_event_context *context, int is_open)
+{
+ int ret;
+
+ /* Open context */
+ ret = mi_lttng_writer_open_element(writer , config_element_context);
if (ret) {
goto end;
}
- /* Close perf_counter_context */
- ret = mi_lttng_writer_close_element(writer);
+ /* Special case for PERF_*_COUNTER
+ * print the lttng_event_perf_counter_ctx*/
+ switch (context->ctx) {
+ case LTTNG_EVENT_CONTEXT_PERF_COUNTER:
+ case LTTNG_EVENT_CONTEXT_PERF_THREAD_COUNTER:
+ case LTTNG_EVENT_CONTEXT_PERF_CPU_COUNTER:
+ {
+ struct lttng_event_perf_counter_ctx *perf_context =
+ &context->u.perf_counter;
+ ret = mi_lttng_perf_counter_context(writer, perf_context);
+ if (ret) {
+ goto end;
+ }
+ break;
+ }
+ case LTTNG_EVENT_CONTEXT_APP_CONTEXT:
+ {
+ ret = mi_lttng_app_context(writer,
+ context->u.app_ctx.provider_name,
+ context->u.app_ctx.ctx_name);
+ if (ret) {
+ goto end;
+ }
+ break;
+ }
+ default:
+ {
+ const char *type_string = mi_lttng_event_contexttype_string(
+ context->ctx);
+ if (!type_string) {
+ ret = -LTTNG_ERR_INVALID;
+ goto end;
+ }
+
+ /* Print context type */
+ ret = mi_lttng_writer_write_element_string(writer,
+ config_element_type, type_string);
+ break;
+ }
+ }
+
+ /* Close context */
+ if (!is_open) {
+ ret = mi_lttng_writer_close_element(writer);
+ }
+
end:
return ret;
}
/*
* Copyright (C) 2014 - Jonathan Rajotte <jonathan.r.julien@gmail.com>
* - Olivier Cotte <olivier.cotte@polymtl.ca>
+ * Copyright (C) 2016 - Jérémie Galarneau <jeremie.galarneau@efficios.com>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License, version 2 only, as
extern const char * const mi_lttng_element_event_field;
extern const char * const mi_lttng_element_event_fields;
-/* String related to lttng_event_context */
-extern const char * const mi_lttng_context_type_perf_counter;
-extern const char * const mi_lttng_context_type_perf_cpu_counter;
-extern const char * const mi_lttng_context_type_perf_thread_counter;
-
/* String related to lttng_event_perf_counter_ctx */
extern const char * const mi_lttng_element_perf_counter_context;
extern const char * const mi_lttng_element_snapshot_session_name;
extern const char * const mi_lttng_element_snapshots;
+/* String related to track/untrack command */
+const char * const mi_lttng_element_track_untrack_all_wildcard;
+
/* Utility string function */
const char *mi_lttng_loglevel_string(int value, enum lttng_domain_type domain);
const char *mi_lttng_logleveltype_string(enum lttng_loglevel_type value);
const char *mi_lttng_buffertype_string(enum lttng_buffer_type value);
const char *mi_lttng_calibratetype_string(enum lttng_calibrate_type val);
-/* String related to track/untrack command */
-const char * const mi_lttng_element_track_untrack_all_wildcard;
-
/*
* Create an instance of a machine interface writer.
*