_EVENT_FIELDS_SET = _BV(6),
};
+enum loglevel {
+ LOGLEVEL_EMERG = 0,
+ LOGLEVEL_ALERT = 1,
+ LOGLEVEL_CRIT = 2,
+ LOGLEVEL_ERR = 3,
+ LOGLEVEL_WARNING = 4,
+ LOGLEVEL_NOTICE = 5,
+ LOGLEVEL_INFO = 6,
+ LOGLEVEL_DEBUG_SYSTEM = 7,
+ LOGLEVEL_DEBUG_PROGRAM = 8,
+ LOGLEVEL_DEBUG_PROCESS = 9,
+ LOGLEVEL_DEBUG_MODULE = 10,
+ LOGLEVEL_DEBUG_UNIT = 11,
+ LOGLEVEL_DEBUG_FUNCTION = 12,
+ LOGLEVEL_DEBUG_LINE = 13,
+ LOGLEVEL_DEBUG = 14,
+ _NR_LOGLEVELS = 15,
+};
+
/* Prefixes of type aliases */
#define _PREFIX_ALIAS 'a'
#define _PREFIX_ENUM 'e'
GHashTable *stream_classes;
};
+static
+const char *loglevel_str [] = {
+ [ LOGLEVEL_EMERG ] = "TRACE_EMERG",
+ [ LOGLEVEL_ALERT ] = "TRACE_ALERT",
+ [ LOGLEVEL_CRIT ] = "TRACE_CRIT",
+ [ LOGLEVEL_ERR ] = "TRACE_ERR",
+ [ LOGLEVEL_WARNING ] = "TRACE_WARNING",
+ [ LOGLEVEL_NOTICE ] = "TRACE_NOTICE",
+ [ LOGLEVEL_INFO ] = "TRACE_INFO",
+ [ LOGLEVEL_DEBUG_SYSTEM ] = "TRACE_DEBUG_SYSTEM",
+ [ LOGLEVEL_DEBUG_PROGRAM ] = "TRACE_DEBUG_PROGRAM",
+ [ LOGLEVEL_DEBUG_PROCESS ] = "TRACE_DEBUG_PROCESS",
+ [ LOGLEVEL_DEBUG_MODULE ] = "TRACE_DEBUG_MODULE",
+ [ LOGLEVEL_DEBUG_UNIT ] = "TRACE_DEBUG_UNIT",
+ [ LOGLEVEL_DEBUG_FUNCTION ] = "TRACE_DEBUG_FUNCTION",
+ [ LOGLEVEL_DEBUG_LINE ] = "TRACE_DEBUG_LINE",
+ [ LOGLEVEL_DEBUG ] = "TRACE_DEBUG",
+};
+
+static
+const char *print_loglevel(int64_t value)
+{
+ if (value < 0) {
+ return NULL;
+ }
+ if (value >= _NR_LOGLEVELS) {
+ return "<<UNKNOWN>>";
+ }
+ return loglevel_str[value];
+}
+
/**
* Creates a new declaration scope.
*
_SET(set, _EVENT_FIELDS_SET);
} else if (!strcmp(left, "loglevel")) {
- uint64_t loglevel;
+ uint64_t loglevel_value;
+ const char *loglevel_str;
+ struct bt_value *value_obj, *str_obj;
if (_IS_SET(set, _EVENT_LOGLEVEL_SET)) {
_PERROR_DUP_ATTR("loglevel",
}
ret = get_unary_unsigned(&node->u.ctf_expression.right,
- &loglevel);
+ &loglevel_value);
if (ret) {
_PERROR("%s", "unexpected unary expression for event declaration's \"loglevel\" attribute");
ret = -EINVAL;
goto error;
}
-
- // TODO: FIXME: set log level here
-
+ value_obj = bt_value_integer_create_init(loglevel_value);
+ if (!value_obj) {
+ _PERROR("%s", "cannot allocate memory for loglevel value object");
+ ret = -ENOMEM;
+ goto error;
+ }
+ if (bt_ctf_event_class_set_attribute(event_class,
+ "loglevel", value_obj) != BT_VALUE_STATUS_OK) {
+ _PERROR("%s", "cannot set loglevel value");
+ ret = -EINVAL;
+ bt_put(value_obj);
+ goto error;
+ }
+ loglevel_str = print_loglevel(loglevel_value);
+ if (loglevel_str) {
+ str_obj = bt_value_string_create_init(loglevel_str);
+ if (bt_ctf_event_class_set_attribute(event_class,
+ "loglevel_string", str_obj) != BT_VALUE_STATUS_OK) {
+ _PERROR("%s", "cannot set loglevel string");
+ ret = -EINVAL;
+ bt_put(str_obj);
+ goto error;
+ }
+ bt_put(str_obj);
+ }
+ bt_put(value_obj);
_SET(set, _EVENT_LOGLEVEL_SET);
} else if (!strcmp(left, "model.emf.uri")) {
char *right;
static
enum bt_component_status print_event_timestamp(struct text_component *text,
- struct bt_ctf_event *event)
+ struct bt_ctf_event *event, bool *start_line)
{
bool print_names = text->options.print_header_field_names;
enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
print_timestamp_wall(text, clock, event);
}
- fputs(print_names ? ", " : "] ", out);
+ if (!print_names)
+ fputs("] ", out);
+ *start_line = !print_names;
+
if (!text->options.print_delta_field) {
goto end;
}
bool print_names = text->options.print_header_field_names;
enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
struct bt_ctf_event_class *event_class = NULL;
+ struct bt_ctf_stream_class *stream_class = NULL;
+ struct bt_ctf_trace *trace_class = NULL;
event_class = bt_ctf_event_get_class(event);
if (!event_class) {
ret = BT_COMPONENT_STATUS_ERROR;
goto end;
}
+ stream_class = bt_ctf_event_class_get_stream_class(event_class);
+ if (!stream_class) {
+ ret = BT_COMPONENT_STATUS_ERROR;
+ goto end;
+ }
+ trace_class = bt_ctf_stream_class_get_trace(stream_class);
+ if (!trace_class) {
+ ret = BT_COMPONENT_STATUS_ERROR;
+ goto end;
+ }
if (!text->start_line) {
fputs(", ", text->out);
}
text->start_line = false;
- ret = print_event_timestamp(text, event);
+ ret = print_event_timestamp(text, event, &text->start_line);
if (ret != BT_COMPONENT_STATUS_OK) {
goto end;
}
+ if (text->options.print_trace_field) {
+ const char *name;
+
+ name = bt_ctf_trace_get_name(trace_class);
+ if (name) {
+ if (!text->start_line) {
+ fputs(", ", text->out);
+ }
+ text->start_line = false;
+ if (print_names) {
+ fputs("trace = ", text->out);
+ }
+ fprintf(text->out, "%s", name);
+ }
+ }
+ if (text->options.print_trace_hostname_field) {
+ struct bt_value *hostname_str;
+
+ hostname_str = bt_ctf_trace_get_environment_field_value_by_name(trace_class,
+ "hostname");
+ if (hostname_str) {
+ const char *str;
+
+ if (!text->start_line) {
+ fputs(", ", text->out);
+ }
+ text->start_line = false;
+ if (print_names) {
+ fputs("trace:hostname = ", text->out);
+ }
+ if (bt_value_string_get(hostname_str, &str)
+ == BT_VALUE_STATUS_OK) {
+ fprintf(text->out, "%s", str);
+ }
+ bt_put(hostname_str);
+ }
+ }
+ if (text->options.print_trace_domain_field) {
+ struct bt_value *domain_str;
+
+ domain_str = bt_ctf_trace_get_environment_field_value_by_name(trace_class,
+ "domain");
+ if (domain_str) {
+ const char *str;
+
+ if (!text->start_line) {
+ fputs(", ", text->out);
+ }
+ text->start_line = false;
+ if (print_names) {
+ fputs("trace:domain = ", text->out);
+ }
+ if (bt_value_string_get(domain_str, &str)
+ == BT_VALUE_STATUS_OK) {
+ fprintf(text->out, "%s", str);
+ }
+ bt_put(domain_str);
+ }
+ }
+ if (text->options.print_trace_procname_field) {
+ struct bt_value *procname_str;
+
+ procname_str = bt_ctf_trace_get_environment_field_value_by_name(trace_class,
+ "procname");
+ if (procname_str) {
+ const char *str;
+
+ if (!text->start_line) {
+ fputs(", ", text->out);
+ }
+ text->start_line = false;
+ if (print_names) {
+ fputs("trace:procname = ", text->out);
+ }
+ if (bt_value_string_get(procname_str, &str)
+ == BT_VALUE_STATUS_OK) {
+ fprintf(text->out, "%s", str);
+ }
+ bt_put(procname_str);
+ }
+ }
+ if (text->options.print_trace_vpid_field) {
+ struct bt_value *vpid_value;
+
+ vpid_value = bt_ctf_trace_get_environment_field_value_by_name(trace_class,
+ "vpid");
+ if (vpid_value) {
+ int64_t value;
+
+ if (!text->start_line) {
+ fputs(", ", text->out);
+ }
+ text->start_line = false;
+ if (print_names) {
+ fputs("trace:vpid = ", text->out);
+ }
+ if (bt_value_integer_get(vpid_value, &value)
+ == BT_VALUE_STATUS_OK) {
+ fprintf(text->out, "(%" PRId64 ")", value);
+ }
+ bt_put(vpid_value);
+ }
+ }
+ if (text->options.print_loglevel_field) {
+ struct bt_value *loglevel_str, *loglevel_value;
+
+ loglevel_str = bt_ctf_event_class_get_attribute_value_by_name(event_class,
+ "loglevel_string");
+ loglevel_value = bt_ctf_event_class_get_attribute_value_by_name(event_class,
+ "loglevel");
+ if (loglevel_str || loglevel_value) {
+ bool has_str = false;
+
+ if (!text->start_line) {
+ fputs(", ", text->out);
+ }
+ text->start_line = false;
+ if (print_names) {
+ fputs("loglevel = ", text->out);
+ }
+ if (loglevel_str) {
+ const char *str;
+
+ if (bt_value_string_get(loglevel_str, &str)
+ == BT_VALUE_STATUS_OK) {
+ fprintf(text->out, "%s", str);
+ has_str = true;
+ }
+ }
+ if (loglevel_value) {
+ int64_t value;
+
+ if (bt_value_integer_get(loglevel_value, &value)
+ == BT_VALUE_STATUS_OK) {
+ fprintf(text->out, "%s(%" PRId64 ")",
+ has_str ? " " : "", value);
+ }
+ }
+ bt_put(loglevel_str);
+ bt_put(loglevel_value);
+ }
+ }
+ if (text->options.print_emf_field) {
+ struct bt_value *uri_str;
+
+ uri_str = bt_ctf_event_class_get_attribute_value_by_name(event_class,
+ "model.emf.uri");
+ if (uri_str) {
+ if (!text->start_line) {
+ fputs(", ", text->out);
+ }
+ text->start_line = false;
+ if (print_names) {
+ fputs("model.emf.uri = ", text->out);
+ }
+ if (uri_str) {
+ const char *str;
+
+ if (bt_value_string_get(uri_str, &str)
+ == BT_VALUE_STATUS_OK) {
+ fprintf(text->out, "%s", str);
+ }
+ }
+ bt_put(uri_str);
+ }
+ }
+ if (text->options.print_callsite_field) {
+ if (!text->start_line) {
+ fputs(", ", text->out);
+ }
+ text->start_line = false;
+ if (print_names) {
+ fputs("callsite = ", text->out);
+ }
+ /* TODO */
+ }
+ if (!text->start_line) {
+ fputs(", ", text->out);
+ }
+ text->start_line = false;
if (print_names) {
fputs("name = ", text->out);
}
fputs(bt_ctf_event_class_get_name(event_class), text->out);
end:
+ bt_put(trace_class);
+ bt_put(stream_class);
bt_put(event_class);
return ret;
}