Skip to contentSkip to conversation

overlay: parse tracepoints from sysfs to figure out fields' location

PATCH Superseded Lionel Landwerlin 2 participants 2 messages Dec 19, 2017 Arm/Amlogic Meson SoC support

v1 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

PATCH 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.

---
 configure.ac                  |   5 ++
 overlay/gpu-perf.c            | 164 ++++++++++++++++++++++++++++++++++--------
 overlay/meson.build           |  11 ++-
 overlay/tracepoint_format.leg |  34 +++++++++
 4 files changed, 184 insertions(+), 30 deletions(-)
 create mode 100644 overlay/tracepoint_format.leg
configure.ac +5 -0
index 8740f7a4..87ca9f91 100644
@@ -151,6 +151,11 @@ else
 	enable_overlay_xlib="no"
 	enable_assembler="no"
 	BUILD_SHADER_DEBUGGER="no"
+
+	AC_CHECK_TOOL([LEG], [leg])
+	if test "x$LEG" != "xleg"; then
+		AC_MSG_ERROR([leg command missing, try : apt-get install peg])
+	fi
 fi
 AM_CONDITIONAL(BUILD_X86, [test "x$build_x86" = xyes])
 
overlay/gpu-perf.c +135 -29

231 lines not on this page · raw message

overlay/meson.build +10 -1
index afacff5e..6a5691dc 100644
@@ -14,6 +14,14 @@ gpu_overlay_src = [
 	'rc6.c',
 ]
 
+leg = find_program('leg', required : true)
+leg_gen = generator(leg,
+		    output : '@[email protected]',
+		    arguments : ['-o', '@OUTPUT@', '@INPUT@'])
+leg_file = leg_gen.process('tracepoint_format.leg')
+leg_lib = static_library('leg', leg_file)
+leg_inc = leg_lib.private_dir_include()
+
 xv = dependency('xv', required : false)
 x11 = dependency('x11', required : false)
 xext = dependency('xext', required : false)
@@ -53,8 +61,9 @@ gpu_overlay_src += 'kms/kms-overlay.c'
 
 if xrandr.found() and cairo.found()
 	executable('intel-gpu-overlay', gpu_overlay_src,
-			include_directories : inc,
+			include_directories : [inc, leg_inc],
 			c_args : gpu_overlay_cflags,
 			dependencies : gpu_overlay_deps,
+                        link_with : leg_lib,
 			install : true)
 endif
overlay/tracepoint_format.leg new file +34 -0
new file mode 100644
index 00000000..ea83db91
@@ -0,0 +1,34 @@
+TracepointFormat =
+    'name' ':' Space PropertyName EndLine
+    'ID' ':' Space Number EndLine
+    '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
#1 lore raw

✗ Fi.CI.BAT: failure for overlay: parse tracepoints from sysfs to figure out fields' location

== Series Details ==

== Series Details ==

Series: overlay: parse tracepoints from sysfs to figure out fields' location
URL : https://patchwork.freedesktop.org/series/35545/
State : failure

== Summary ==

IGT patchset build failed on latest successful build cfb711c046c22c3881d2334f0b43ec4eb0b9a5fc scripts/trace.pl: Auto-detect tracepoint field order

make all-recursive
Making all in lib
make all-recursive
Making all in .
Making all in tests
make[4]: Nothing to be done for 'all'.
Making all in man
make[2]: Nothing to be done for 'all'.
Making all in tools
Making all in null_state_gen
make[3]: Nothing to be done for 'all'.
Making all in registers
make[3]: Nothing to be done for 'all'.
make[3]: Nothing to be done for 'all-am'.
Making all in scripts
make[2]: Nothing to be done for 'all'.
Making all in benchmarks
Making all in wsim
make[3]: Nothing to be done for 'all'.
Making all in ezbench.d
make[3]: Nothing to be done for 'all'.
make[3]: Nothing to be done for 'all-am'.
Making all in include
Making all in .
make[3]: Nothing to be done for 'all-am'.
Making all in drm-uapi
make[3]: Nothing to be done for 'all'.
Making all in tests
Making all in intel-ci
make[3]: Nothing to be done for 'all'.
make[3]: Nothing to be done for 'all-am'.
Making all in assembler
make all-recursive
Making all in doc
make[4]: Nothing to be done for 'all'.
Making all in test
make[4]: Nothing to be done for 'all'.
make[4]: Nothing to be done for 'all-am'.
Making all in overlay
CC gpu-perf.o
gpu-perf.c:119:31: fatal error: tracepoint_format.h: No such file or directory

 #include "tracepoint_format.h"
                               ^

compilation terminated.
Makefile:595: recipe for target 'gpu-perf.o' failed make[2]: *** [gpu-perf.o] Error 1 Makefile:532: recipe for target 'all-recursive' failed make[1]: *** [all-recursive] Error 1 Makefile:464: recipe for target 'all' failed
make: *** [all] Error 2

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx