[PATCH v1] changing mmap flags and memfd_create flags to print abbreviated values under -Xraw

shankarapailoor shankarapailoor at gmail.com
Mon Nov 26 01:14:51 UTC 2018


Hi Dmitry,

>Unfortunately, on the way to this
mailing list something has converted all tabs to spaces, so I was not able
to apply it.

Sorry about that. My editor did that I think. I've run checkpatch.pl
and it seems to not have an issue now.

>I think we want to print the raw value in case of XLAT_STYLE_VERBOSE
as well as XLAT_STYLE_RAW, but, unlike XLAT_STYLE_RAW, in case of
XLAT_STYLE_VERBOSE we also want to print the symbolic representation.

Thanks for letting me know. I've attached an updated patch based on
the example you sent. Let me know what you think.

Thanks,
Shankara
On Sun, Nov 25, 2018 at 1:40 PM Dmitry V. Levin <ldv at altlinux.org> wrote:
>
> Hi,
>
> On Sun, Nov 25, 2018 at 07:35:10AM -0800, shankarapailoor wrote:
> > >From 214f62db7086664f13a03f03f4b632ad2aaf5dec Mon Sep 17 00:00:00 2001
> > From: Shankara Pailoor <shankarapailoor at gmail.com>
> > Date: Sat, 24 Nov 2018 15:46:38 -0800
> > Subject: [PATCH v1] changing mmap flags and memfd_create flags to print
> >  abbreviated values under -Xraw
>
> Thank you for submitting this patch.  Unfortunately, on the way to this
> mailing list something has converted all tabs to spaces, so I was not able
> to apply it.  Anyway, see my comments below.
>
> > ---
> >  mem.c          | 8 ++++++++
> >  memfd_create.c | 6 ++++++
> >  2 files changed, 14 insertions(+)
> >
> > diff --git a/mem.c b/mem.c
> > index 3e37da19..2665b453 100644
> > --- a/mem.c
> > +++ b/mem.c
> > @@ -76,12 +76,20 @@ SYS_FUNC(brk)
> >  static void
> >  print_mmap_flags(kernel_ulong_t flags)
> >  {
> > +    if (xlat_verbose(xlat_verbosity) == XLAT_STYLE_RAW) {
> > +        tprintf("%#llx", flags);
> > +        return;
> > +    }
>
> I think we want to print the raw value in case of XLAT_STYLE_VERBOSE
> as well as XLAT_STYLE_RAW, but, unlike XLAT_STYLE_RAW, in case of
> XLAT_STYLE_VERBOSE we also want to print the symbolic representation.
>
> See, for example, commit
> https://github.com/strace/strace/commit/92b04d4a22a632fd120eae81eb7ebc597e2a816a
>
> > +
> >      printxval64(mmap_flags, flags & MAP_TYPE, "MAP_???");
> >      flags &= ~MAP_TYPE;
> >
> >      const unsigned int mask = MAP_HUGE_MASK << MAP_HUGE_SHIFT;
> >      const unsigned int hugetlb_value = flags & mask;
> >
> > +    if (xlat_verbose(xlat_verbosity) == XLAT_STYLE_RAW)
> > +        return;
> > +
>
> This hunk doesn't look relevant here.
>
> >      flags &= ~mask;
> >      if (flags) {
> >          tprints("|");
> > diff --git a/memfd_create.c b/memfd_create.c
> > index 1f6a6d6d..375e2179 100644
> > --- a/memfd_create.c
> > +++ b/memfd_create.c
> > @@ -50,6 +50,12 @@ SYS_FUNC(memfd_create)
> >      unsigned int flags = tcp->u_arg[1];
> >      const unsigned int mask = MFD_HUGE_MASK << MFD_HUGE_SHIFT;
> >      const unsigned int hugetlb_value = flags & mask;
> > +
> > +    if (xlat_verbose(xlat_verbosity) == XLAT_STYLE_RAW) {
> > +        tprintf("%#llx", flags);
> > +        return RVAL_DECODED | RVAL_FD;
> > +    }
>
> The comment about print_mmap_flags applies here as well.
>
> > +
> >      flags &= ~mask;
> >
> >      if (flags || !hugetlb_value)
> > --
> > 2.17.1
> >
> > I wasn't sure if this patch was received through git send-email as I didn't
> > notice it in the archive. Apologies if I sent it twice.
>
> No, the patch that was sent using git-send-email hasn't reached
> the mailing list.
>
>
> --
> ldv
> --
> Strace-devel mailing list
> Strace-devel at lists.strace.io
> https://lists.strace.io/mailman/listinfo/strace-devel



-- 
Regards,
Shankara Pailoor
-------------- next part --------------
A non-text attachment was scrubbed...
Name: v1-0001-changing-mmap-and-memfd_create-to-print-raw-value.patch
Type: text/x-patch
Size: 2018 bytes
Desc: not available
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20181125/81adc9fc/attachment.bin>


More information about the Strace-devel mailing list