[PATCH v4 0/2] utils: add v4l2-tracer utility

Deborah Brouwer
2022-11-30T18:24:15Z

Hi all - thank you very much for your reviews.

This is a patch series now to add Hans' patch
for tracing basic controls.

Changes since v3:
- fix clang-tidy warnings
- fix memory leaks in auto-generated code
- strings: check for nullptr before assignment
- remove unnecessary checks for nullptr before free()
- polling: check return value
- dynamic arrays: check memory allocation
- put format-specific info (h264) into a union
- add comment to the top of auto-generated files
- replace array with std::vector for media topology
- move debug/verbose options to helper functions
- fix auto-gen script to include a few extra controls

Changes since v2:
- remove duplication in entries for numbers/strings
- use media topology to find retrace devices
- add specific ioctls to trace
- in help msg change 'data' -> 'video frame data'
- trace mem_array with space after every byte
- add to trace files package version, SHA, date
- retracer also generates a JSON retrace file
- default trace format is "pretty"
- add a "compact" format option
- consolidate options for tracer/retracer
- remove mutex locks as unnecessary
- add more autogenerated functions
- add 'clean' command to remove fd/addresses

Changes since v1:
- auto-generate code from uAPI headers
- generated code adds some ability to trace
VP9/HEVC which compiles but still needs work
- generated code adds full support for MPEG2
- fix multiplanar decoding for vicodec
- change library name to libv4l2tracer
- update README
- expand help to show options
- remove extraneous files from gitignore

Example:

Trace an application decoding VP8:

v4l2-tracer trace gst-launch-1.0 -- filesrc
location=test-25fps.vp8 ! parsebin !
v4l2slvp8dec ! videocodectestsink

Or trace an application decoding FWHT:

v4l2-tracer trace v4l2-ctl -d3 --stream-mmap
--stream-out-mmap --stream-from-hdr
test-25fps.fwht --stream-to out.yuv

A trace file is generated: 71827_trace.json

Retrace the trace file:
v4l2-tracer retrace 71827_trace.json

Specify nodes if using a different driver:
v4l2-tracer -d0 -m0 retrace 71827_trace.json

A retrace file is generated: 71827_trace_retrace.json

Remove irrelevant differences (optional)
e.g. file descriptors and addresses:
v4l2-tracer clean 71827_trace.json
v4l2-tracer clean 71827_trace_retrace.json

Clean files are generated:
clean_71827_trace.json
clean_71827_trace_retrace.json

Use an application to compare the files:
kdiff3 clean_71827_trace.json clean_71827_trace_retrace.json

Deborah Brouwer (1):
utils: add v4l2-tracer utility

Hans Verkuil (1):
v4l2-tracer: add support for most basic controls

README | 8 +
configure.ac | 12 +
utils/Makefile.am | 5 +
utils/v4l2-tracer/.gitignore | 7 +
utils/v4l2-tracer/Makefile.am | 36 +
utils/v4l2-tracer/libv4l2tracer.cpp | 303 +++++
utils/v4l2-tracer/retrace-helper.cpp | 262 +++++
utils/v4l2-tracer/retrace.cpp | 1373 ++++++++++++++++++++++
utils/v4l2-tracer/retrace.h | 43 +
utils/v4l2-tracer/trace-helper.cpp | 500 ++++++++
utils/v4l2-tracer/trace.cpp | 603 ++++++++++
utils/v4l2-tracer/trace.h | 75 ++
utils/v4l2-tracer/v4l2-tracer-common.cpp | 476 ++++++++
utils/v4l2-tracer/v4l2-tracer-common.h | 79 ++
utils/v4l2-tracer/v4l2-tracer-gen.pl | 879 ++++++++++++++
utils/v4l2-tracer/v4l2-tracer.1.in | 111 ++
utils/v4l2-tracer/v4l2-tracer.cpp | 415 +++++++
17 files changed, 5187 insertions(+)
create mode 100644 utils/v4l2-tracer/.gitignore
create mode 100644 utils/v4l2-tracer/Makefile.am
create mode 100644 utils/v4l2-tracer/libv4l2tracer.cpp
create mode 100644 utils/v4l2-tracer/retrace-helper.cpp
create mode 100644 utils/v4l2-tracer/retrace.cpp
create mode 100644 utils/v4l2-tracer/retrace.h
create mode 100644 utils/v4l2-tracer/trace-helper.cpp
create mode 100644 utils/v4l2-tracer/trace.cpp
create mode 100644 utils/v4l2-tracer/trace.h
create mode 100644 utils/v4l2-tracer/v4l2-tracer-common.cpp
create mode 100644 utils/v4l2-tracer/v4l2-tracer-common.h
create mode 100755 utils/v4l2-tracer/v4l2-tracer-gen.pl
create mode 100644 utils/v4l2-tracer/v4l2-tracer.1.in
create mode 100644 utils/v4l2-tracer/v4l2-tracer.cpp

--
2.38.0