[PATCH v4 2/7] Use printpid in decoders

Dmitry V. Levin ldv at altlinux.org
Fri Jul 31 09:39:47 UTC 2020


On Fri, Jul 31, 2020 at 11:34:30AM +0200, Ákos Uzonyi wrote:
> On Fri, 31 Jul 2020 at 00:32, Dmitry V. Levin <ldv at altlinux.org> wrote:
> > On Mon, Jul 27, 2020 at 08:54:05PM +0200, Ákos Uzonyi wrote:
> > [...]
> > > @@ -74,6 +89,14 @@ print_fcntl(struct tcb *tcp)
> > >               printflags(fdflags, tcp->u_arg[2], "FD_???");
> > >               break;
> > >       case F_SETOWN:
> > > +             tprintf(", ");
> > > +             const int pid = tcp->u_arg[2];
> > > +             tprintf("%d", pid);
> > > +             if (pid < 0)
> > > +                     printpid_translation(tcp, -pid, PT_PGID);
> > > +             else
> > > +                     printpid_translation(tcp,  pid, PT_TGID);
> > > +             break;
> > >       case F_SETPIPE_SZ:
> > >               tprintf(", %" PRI_kld, tcp->u_arg[2]);
> > >               break;
> > [...]
> > > @@ -439,7 +439,14 @@ SYS_FUNC(sigprocmask)
> > >  SYS_FUNC(kill)
> > >  {
> > >       /* pid */
> > > -     tprintf("%d, ", (int) tcp->u_arg[0]);
> > > +     int pid = (int) tcp->u_arg[0];
> > > +     tprintf("%d", pid);
> > > +     if (pid > 0)
> > > +             printpid_translation(tcp, pid, PT_TGID);
> > > +     else if (pid < -1)
> > > +             printpid_translation(tcp, -pid, PT_PGID);
> > > +
> > > +     tprintf(", ");
> > >       /* signal */
> > >       printsignal(tcp->u_arg[1]);
> > >
> > [...]
> > > @@ -86,8 +86,13 @@ printwaitn(struct tcb *const tcp,
> > >                * for example, wait4(4294967295, ...) instead of -1
> > >                * in strace. We have to use int here, not long.
> > >                */
> > > -             int pid = tcp->u_arg[0];
> > > -             tprintf("%d, ", pid);
> > > +             int pid = (int) tcp->u_arg[0];
> > > +             tprintf("%d", pid);
> > > +             if (pid > 0)
> > > +                     printpid_translation(tcp, pid, PT_TGID);
> > > +             else if (pid < -1)
> > > +                     printpid_translation(tcp, -pid, PT_PGID);
> > > +             tprintf(", ");
> > >       } else {
> > >               int status;
> > >
> >
> > All these three cases have striking similarities which may warrant
> > a common function.
> 
> Indeed, thanks.
> It's a bit hard to come up with a good name for this function. Do you
> think "printpid_tgid_pgid" will be OK?

I'm fine with this name.


-- 
ldv


More information about the Strace-devel mailing list