libbpf: Add x86-specific USDT arg spec parsing logic
authorAndrii Nakryiko <andrii@kernel.org>
Mon, 4 Apr 2022 23:42:00 +0000 (16:42 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Tue, 5 Apr 2022 20:16:08 +0000 (13:16 -0700)
commit4c59e584d1581b1bca143dda83d5c3e5baddbf20
treee039d83641ae7e9b1f6be18792ea6cbc72028ec9
parent999783c8bbda2e82390cb8c39ed9e3954cf51b82
libbpf: Add x86-specific USDT arg spec parsing logic

Add x86/x86_64-specific USDT argument specification parsing. Each
architecture will require their own logic, as all this is arch-specific
assembly-based notation. Architectures that libbpf doesn't support for
USDTs will pr_warn() with specific error and return -ENOTSUP.

We use sscanf() as a very powerful and easy to use string parser. Those
spaces in sscanf's format string mean "skip any whitespaces", which is
pretty nifty (and somewhat little known) feature.

All this was tested on little-endian architecture, so bit shifts are
probably off on big-endian, which our CI will hopefully prove.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Reviewed-by: Alan Maguire <alan.maguire@oracle.com>
Reviewed-by: Dave Marchevsky <davemarchevsky@fb.com>
Link: https://lore.kernel.org/bpf/20220404234202.331384-6-andrii@kernel.org
tools/lib/bpf/usdt.c