From 865a47ca2b93b208ba016f3c4fc00831ec7bfec6 Mon Sep 17 00:00:00 2001 From: Lionel Landwerlin Date: Mon, 18 Dec 2017 23:00:54 +0000 Subject: overlay: parse tracepoints from sysfs to figure out fields' location With changes going to drm-tip, the tracepoints field locations are going to change. This change introduces a tracepoint parser (using a peg parser) which lets us figure out field positions on the fly. v2: Fix automake build (Lionel) v3: Make overlay build conditional on peg (Petri) Make wait_end callback more readable (Chris) Drop tracepoint_id(), instead parsing from format file (Lionel) v4: Fix existing configure.ac issue with overlay build (Petri) v5: Silence unused function (Lionel) v6: Fix missing double quote in v4 (Lionel) Signed-off-by: Lionel Landwerlin Acked-by: Chris Wilson For the build system changes: Acked-by: Petri Latvala --- overlay/tracepoint_format.leg | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 overlay/tracepoint_format.leg (limited to 'overlay/tracepoint_format.leg') diff --git a/overlay/tracepoint_format.leg b/overlay/tracepoint_format.leg new file mode 100644 index 00000000..7a09149d --- /dev/null +++ b/overlay/tracepoint_format.leg @@ -0,0 +1,35 @@ +TracepointFmt = + 'name' ':' Space n:PropertyName EndLine + { free(v.string); } + 'ID:' Space v:Number EndLine + { yy->ctx.tp->event_id = v.integer; } + 'format:' EndLine + Field+ + 'print fmt:' [^.]* !. + +Field = Space (Property ';' Space)+ EndLine + { yy->ctx.tp->n_fields++; } + | EndLine + +Property = 'offset' ':' v:Number + { yy->ctx.tp->fields[yy->ctx.tp->n_fields].offset = v.integer; } + | 'size' ':' v:Number + { yy->ctx.tp->fields[yy->ctx.tp->n_fields].size = v.integer; } + | 'signed' ':' v:Number + { yy->ctx.tp->fields[yy->ctx.tp->n_fields].is_signed = v.integer != 0; } + | 'field' ':' v:PropertyValue + { snprintf(yy->ctx.tp->fields[yy->ctx.tp->n_fields].name, + sizeof(yy->ctx.tp->fields[yy->ctx.tp->n_fields].name), + "%s", strrchr(v.string, ' ') + 1); free(v.string); } + | n:PropertyName ':' v:PropertyValue + { free(n.string); free(v.string); } + +PropertyName = < [A-Za-z0-9_]+ > + { $$.string = strdup(yytext); } +PropertyValue = < [^;]+ > + { $$.string = strdup(yytext); } +Number = < [0-9]+ > + { $$.integer = atoi(yytext); } + +EndLine = [\n] +Space = [ \t]* -- cgit v1.2.3