[PATCH v1] print the raw kernel version when using -Xraw
Dmitry V. Levin
ldv at altlinux.org
Sat Dec 1 22:28:36 UTC 2018
On Sat, Dec 01, 2018 at 12:14:59PM -0800, shankarapailoor wrote:
> ---
> bpf.c | 20 ++++++++++++++++----
> 1 file changed, 16 insertions(+), 4 deletions(-)
>
> diff --git a/bpf.c b/bpf.c
> index e5dc4eeb..261c68be 100644
> --- a/bpf.c
> +++ b/bpf.c
> @@ -292,10 +292,22 @@ BEGIN_BPF_CMD_DECODER(BPF_PROG_LOAD)
> /* kern_version field was added in Linux commit v4.1-rc1~84^2~50. */
> if (len <= offsetof(struct BPF_PROG_LOAD_struct, kern_version))
> break;
> - tprintf(", kern_version=KERNEL_VERSION(%u, %u, %u)",
> - attr.kern_version >> 16,
> - (attr.kern_version >> 8) & 0xFF,
> - attr.kern_version & 0xFF);
> + if (xlat_verbose(xlat_verbosity) != XLAT_STYLE_ABBREV) {
> + tprintf(", kernel_version=%u", attr.kern_version);
> + if (xlat_verbose(xlat_verbosity) == XLAT_STYLE_VERBOSE) {
> + tprints(" /* ");
> + tprintf("KERNEL_VERSION(%u, %u, %u)",
> + attr.kern_version >> 16,
> + (attr.kern_version >> 8) & 0xFF,
> + attr.kern_version & 0xFF);
> + tprints("*/");
> + }
> + } else {
> + tprintf(", kern_version=KERNEL_VERSION(%u, %u, %u)",
> + attr.kern_version >> 16,
> + (attr.kern_version >> 8) & 0xFF,
> + attr.kern_version & 0xFF);
> + }
Please avoid unnecessary code duplication. I suggest adding a separate
function, e.g. print_kernel_version(uint32_t version), and moving the code
that prints "KERNEL_VERSION(%u, %u, %u)" to that function.
Also please add a test.
--
ldv
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20181202/8faf740d/attachment.bin>
More information about the Strace-devel
mailing list