overlay: parse tracepoints from sysfs to figure out fields' location
PATCH v4 1/1 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)
Signed-off-by Lionel Landwerlin <[email protected]>
--- configure.ac | 9 ++- overlay/Makefile.am | 5 ++ overlay/gpu-perf.c | 163 ++++++++++++++++++++++++++++++++---------- overlay/meson.build | 15 +++- overlay/tracepoint_format.leg | 35 +++++++++ 5 files changed, 186 insertions(+), 41 deletions(-) create mode 100644 overlay/tracepoint_format.leg
configure.ac +8 -1
@@ -146,6 +146,13 @@ if test x"$build_x86" = xyes; then AS_IF([test x"$LEX" != "x:" -a x"$YACC" != xyacc], [enable_assembler=yes], [enable_assembler=no]) + + AC_CHECK_TOOL([LEG], [leg]) + if test "x$LEG" != "xleg"; then + AC_MSG_NOTICE([leg command missing, disabling overlay; try : apt-get install peg]) + enable_overlay_xvlib="no" + enable_overlay_xlib="no" + fi else enable_overlay_xvlib="no" enable_overlay_xlib="no"
@@ -158,7 +165,7 @@ AM_CONDITIONAL(BUILD_ASSEMBLER, [test "x$enable_assembler" = xyes]) AM_CONDITIONAL(BUILD_OVERLAY_XVLIB, [test "x$enable_overlay_xvlib" = xyes]) AM_CONDITIONAL(BUILD_OVERLAY_XLIB, [test "x$enable_overlay_xlib" = xyes]) -AM_CONDITIONAL(BUILD_OVERLAY, [test "x$enable_overlay_xlib" = xyes -o "x$enable_overlay_xvlib"]) +AM_CONDITIONAL(BUILD_OVERLAY, [test "x$enable_overlay_xlib" = xyes -o "x$enable_overlay_xvlib" = "xyes]) if test x$enable_overlay_xvlib = xyes; then AC_DEFINE(HAVE_OVERLAY_XVLIB, 1, [Enable XV backend]) fi
overlay/Makefile.am +5 -0
@@ -1,7 +1,12 @@ if BUILD_OVERLAY bin_PROGRAMS = intel-gpu-overlay + +BUILT_SOURCES = tracepoint_format.h endif +tracepoint_format.h: tracepoint_format.leg + $(LEG) -o $@ $< + AM_CPPFLAGS = -I. -I$(top_srcdir)/include/drm-uapi AM_CFLAGS = $(DRM_CFLAGS) $(PCIACCESS_CFLAGS) $(CWARNFLAGS) \ $(CAIRO_CFLAGS) $(OVERLAY_CFLAGS) $(WERROR_CFLAGS) -I$(srcdir)/../lib
overlay/gpu-perf.c +125 -38
225 lines not on this page · raw message
overlay/meson.build +13 -2
@@ -26,7 +26,7 @@ gpu_overlay_deps = [ realtime, math, cairo, pciaccess, libdrm, both_x11_src = '' -gpu_overlay_cflags = [] +gpu_overlay_cflags = [ '-g3', '-O0' ] if xv.found() and x11.found() and xext.found() and dri2proto.found() both_x11_src = 'x11/position.c' gpu_overlay_src += [
@@ -51,7 +51,18 @@ gpu_overlay_src += both_x11_src gpu_overlay_src += 'kms/kms-overlay.c' -if xrandr.found() and cairo.found() +leg = find_program('leg', required : false) +if leg.found() + leg_file = custom_target('tracepoint_format', + output: 'tracepoint_format.h', + input: 'tracepoint_format.leg', + command: [leg, '-P', '-o', '@OUTPUT@', '@INPUT@']) + gpu_overlay_src += leg_file +else + warning('leg command not found, disabling overlay; try : apt-get install peg') +endif + +if leg.found() and xrandr.found() and cairo.found() executable('intel-gpu-overlay', gpu_overlay_src, include_directories : inc, c_args : gpu_overlay_cflags,
overlay/tracepoint_format.leg new file +35 -0
@@ -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]*
Signature · 6 lines
2.15.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx