}
static inline
-const char *bt_common_scope_string(enum bt_field_path_scope scope)
+const char *bt_common_field_path_scope_string(enum bt_field_path_scope scope)
{
switch (scope) {
case BT_FIELD_PATH_SCOPE_PACKET_CONTEXT:
bt_common_abort();
}
+static inline
+const char *bt_common_field_location_scope_string(enum bt_field_location_scope scope)
+{
+ switch (scope) {
+ case BT_FIELD_LOCATION_SCOPE_PACKET_CONTEXT:
+ return "PACKET_CONTEXT";
+ case BT_FIELD_LOCATION_SCOPE_EVENT_COMMON_CONTEXT:
+ return "EVENT_COMMON_CONTEXT";
+ case BT_FIELD_LOCATION_SCOPE_EVENT_SPECIFIC_CONTEXT:
+ return "EVENT_SPECIFIC_CONTEXT";
+ case BT_FIELD_LOCATION_SCOPE_EVENT_PAYLOAD:
+ return "EVENT_PAYLOAD";
+ }
+
+ bt_common_abort();
+}
+
static inline
const char *bt_common_event_class_log_level_string(
enum bt_event_class_log_level level)
bt_common_abort();
};
+static inline
+GString *bt_common_field_path_string(struct bt_field_path *path)
+{
+ GString *str = g_string_new(NULL);
+ uint64_t i;
+
+ BT_ASSERT_DBG(path);
+
+ if (!str) {
+ goto end;
+ }
+
+ g_string_append_printf(str, "[%s", bt_common_field_path_scope_string(
+ bt_field_path_get_root_scope(path)));
+
+ for (i = 0; i < bt_field_path_get_item_count(path); i++) {
+ const struct bt_field_path_item *fp_item =
+ bt_field_path_borrow_item_by_index_const(path, i);
+
+ switch (bt_field_path_item_get_type(fp_item)) {
+ case BT_FIELD_PATH_ITEM_TYPE_INDEX:
+ g_string_append_printf(str, ", %" PRIu64,
+ bt_field_path_item_index_get_index(fp_item));
+ break;
+ case BT_FIELD_PATH_ITEM_TYPE_CURRENT_ARRAY_ELEMENT:
+ g_string_append(str, ", <CUR>");
+ break;
+ default:
+ bt_common_abort();
+ }
+ }
+
+ g_string_append(str, "]");
+
+end:
+ return str;
+}
+
static inline
const char *bt_common_logging_level_string(
enum bt_logging_level level)
#include "trace-ir/event.h"
#include "trace-ir/field-class.h"
#include "trace-ir/field.h"
+#include "trace-ir/field-location.h"
#include "trace-ir/field-path.h"
#include "trace-ir/packet.h"
#include "trace-ir/stream-class.h"
static inline void format_field_path(char **buf_ch, bool extended,
const char *prefix, const struct bt_field_path *field_path);
+static inline void format_field_location(char **buf_ch, bool extended ,
+ const char *prefix, const struct bt_field_location *field_location);
+
static inline void format_object(char **buf_ch, const char *prefix,
const struct bt_object *obj)
{
}
BUF_APPEND(", %spath=[%s",
- PRFIELD(bt_common_scope_string(field_path->root)));
+ PRFIELD(bt_common_field_path_scope_string(field_path->root)));
for (i = 0; i < bt_field_path_get_item_count(field_path); i++) {
const struct bt_field_path_item *fp_item =
BUF_APPEND("%s", "]");
}
+static inline void format_field_location(char **buf_ch, bool extended,
+ const char *prefix, const struct bt_field_location *field_location)
+{
+ uint64_t i;
+
+ BT_ASSERT(field_location->items);
+
+ BUF_APPEND(", %sitem-count=%u", PRFIELD(field_location->items->len));
+
+ if (!extended) {
+ return;
+ }
+
+ BUF_APPEND(", %sloc=[%s",
+ PRFIELD(bt_common_field_location_scope_string(field_location->scope)));
+
+ for (i = 0; i < bt_field_location_get_item_count(field_location); i++) {
+ const char *item =
+ bt_field_location_get_item_by_index (field_location, i);
+
+ BUF_APPEND(", %s", item);
+ break;
+ }
+
+ BUF_APPEND("%s", "]");
+}
+
static inline void format_trace_class(char **buf_ch, bool extended,
const char *prefix, const struct bt_trace_class *trace_class)
{
case 'P':
format_field_path(buf_ch, extended, prefix, obj);
break;
+ case 'L':
+ format_field_location(buf_ch, extended, prefix, obj);
+ break;
case 'E':
format_event_class(buf_ch, extended, prefix, obj);
break;