Skip to content

Commit

Permalink
cxl/event_trace: parse arrays separately from strings
Browse files Browse the repository at this point in the history
Arrays are being parsed as strings based on a flag that seems like
it would be the differentiator, ARRAY and STRING, but it is not.

libtraceevent sets the flags for arrays and strings like this:
array:  TEP_FIELD_IS_[ARRAY | STRING]
string: TEP_FIELD_IS_[ARRAY | STRING | DYNAMIC]

Use TEP_FIELD_IS_DYNAMIC to discover the field type, otherwise arrays
get parsed as strings and 'cxl monitor' returns gobbledygook in the
array type fields.

This fixes the "data" field of cxl_generic_events and the "uuid" field
of cxl_poison.

That cxl_poison uuid format can be further improved by using the trace
type (__field_struct uuid_t) in the CXL kernel driver. The parser will
automatically pick up that new type, as illustrated in the "hdr_uuid"
of cxl_generic_media event trace above.

Signed-off-by: Alison Schofield <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Reviewed-by: Dave Jiang <[email protected]>
Signed-off-by: Vishal Verma <[email protected]>
  • Loading branch information
AlisonSchofield authored and stellarhopper committed Feb 29, 2024
1 parent bb97d6d commit ffbbb0b
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion cxl/event_trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,13 @@ static int cxl_event_to_json(struct tep_event *event, struct tep_record *record,
struct tep_format_field *f = fields[i];
int len;

if (f->flags & TEP_FIELD_IS_STRING) {
/*
* libtraceevent differentiates arrays and strings like this:
* array: TEP_FIELD_IS_[ARRAY | STRING]
* string: TEP_FIELD_IS_[ARRAY | STRING | DYNAMIC]
*/
if ((f->flags & TEP_FIELD_IS_STRING) &&
((f->flags & TEP_FIELD_IS_DYNAMIC))) {
char *str;

str = tep_get_field_raw(NULL, event, f->name, record, &len, 0);
Expand Down

0 comments on commit ffbbb0b

Please sign in to comment.