@@ -15,6 +15,52 @@
#define _GNU_SOURCE
#include <string.h>
+static struct tep_format_field *__find_field(struct tep_event *event,
+ const char *name)
+{
+ struct tep_format_field **fields;
+
+ fields = tep_event_fields(event);
+ if (!fields)
+ return NULL;
+
+ for (int i = 0; fields[i]; i++) {
+ struct tep_format_field *f = fields[i];
+
+ if (strcmp(f->name, name) != 0)
+ continue;
+
+ return f;
+ }
+ return NULL;
+}
+
+unsigned char *cxl_get_field_data(struct tep_event *event,
+ struct tep_record *record, const char *name)
+{
+ struct tep_format_field *f;
+ int len;
+
+ f = __find_field(event, name);
+ if (!f)
+ return NULL;
+
+ return tep_get_field_raw(NULL, event, f->name, record, &len, 0);
+}
+
+char *cxl_get_field_string(struct tep_event *event, struct tep_record *record,
+ const char *name)
+{
+ struct tep_format_field *f;
+ int len;
+
+ f = __find_field(event, name);
+ if (!f)
+ return NULL;
+
+ return tep_get_field_raw(NULL, event, f->name, record, &len, 0);
+}
+
static struct json_object *num_to_json(void *num, int elem_size, unsigned long flags)
{
bool sign = flags & TEP_FIELD_IS_SIGNED;
@@ -25,5 +25,8 @@ int cxl_parse_events(struct tracefs_instance *inst, struct event_ctx *ectx);
int cxl_event_tracing_enable(struct tracefs_instance *inst, const char *system,
const char *event);
int cxl_event_tracing_disable(struct tracefs_instance *inst);
-
+char *cxl_get_field_string(struct tep_event *event, struct tep_record *record,
+ const char *name);
+unsigned char *cxl_get_field_data(struct tep_event *event,
+ struct tep_record *record, const char *name);
#endif