[PATCH v1] print the raw kernel version when using -Xraw
shankarapailoor
shankarapailoor at gmail.com
Sun Dec 2 23:14:52 UTC 2018
> Also please add a test.
Would you suggest I add a new file that just tests PROG_LOAD or update
bpf.c? If I do the latter, will I need to make sure that all the
output from all the other tests are properly parsed under
-Xraw/verbose/?
Regards,
Shankara
On Sat, Dec 1, 2018 at 2:28 PM Dmitry V. Levin <ldv at altlinux.org> wrote:
>
> 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
> --
> Strace-devel mailing list
> Strace-devel at lists.strace.io
> https://lists.strace.io/mailman/listinfo/strace-devel
--
Regards,
Shankara Pailoor
More information about the Strace-devel
mailing list