Hi Zubin,

On Sun, Aug 24, 2014 at 09:22:12PM +0200, Zubin Mithra wrote:
[...]
> --- a/defs.h
> +++ b/defs.h
> @@ -679,7 +679,9 @@ extern void printstr(struct tcb *, long, long);
>  extern void printnum(struct tcb *, long, const char *);
>  extern void printnum_int(struct tcb *, long, const char *);
>  extern void printpath(struct tcb *, long);
> +extern void printpathat(struct tcb *, int, long);
>  extern void printpathn(struct tcb *, long, int);
> +extern void printpathnat(struct tcb *, int, long, int);

I suppose we could do without printpathnat.

> --- a/strace.c
> +++ b/strace.c
> @@ -204,6 +204,7 @@ usage: strace [-CdffhiqrtttTvVxxy] [-I n] [-e expr]...\n\
>                -p pid... / [-D] [-E var=val]... [-u username] PROG [ARGS]\n\
>     or: strace -c[df] [-I n] [-e expr]... [-O overhead] [-S sortby]\n\
>                -p pid... / [-D] [-E var=val]... [-u username] PROG [ARGS]\n\
> +-A -- print absolute paths instead of relative paths everywhere\n\
>  -c -- count time, calls, and errors for each syscall and report summary\n\
>  -C -- like -c but also print regular output\n\
>  -w -- summarise syscall latency (default is system time)\n\
> @@ -1678,6 +1679,7 @@ init(int argc, char *argv[])
>  #ifdef USE_LIBUNWIND
>               "k"
>  #endif
> +             "A"
>               "D"
>               "a:e:o:O:p:s:S:u:E:P:I:")) != EOF) {
>               switch (c) {

show_abs_path has to be defined and initialized.

> diff --git a/util.c b/util.c
> index 6d70623..e5a29b2 100644
> --- a/util.c
> +++ b/util.c
> @@ -405,7 +405,8 @@ printfd(struct tcb *tcp, int fd)
>  {
>       char path[PATH_MAX + 1];
> 
> 
> -     if (show_fd_path && getfdpath(tcp, fd, path, sizeof(path)) >= 0)
> +     if ((show_fd_path || show_abs_path) &&
> +         getfdpath(tcp, fd, path, sizeof(path)) >= 0)
>               tprintf("%d<%s>", fd, path);
>       else
>               tprintf("%d", fd);
> @@ -590,12 +591,8 @@ print_tracee_cwd(struct tcb *tcp)
>       return false;
>  }
> 
> 
> -/*
> - * Print path string specified by address `addr' and length `n'.
> - * If path length exceeds `n', append `...' to the output.
> - */
>  void
> -printpathn(struct tcb *tcp, long addr, int n)
> +printpath_common(struct tcb *tcp, int fd, long addr, int n)
>  {
>       char path[MAXPATHLEN + 1];
>       int nul_seen;
> @@ -618,13 +615,28 @@ printpathn(struct tcb *tcp, long addr, int n)
>               bool prefix_printed = false;
> 
> 
>               path[n] = '\0';
> -             if (show_fd_path > 1 && *path && *path != '/')
> +
> +             /* If the call comes from `printpathn' and -y is used */
> +             if (fd == -1 && show_fd_path && *path && *path != '/')
>                       prefix_printed = print_tracee_cwd(tcp);
> +
> +             /* If the call comes from `printpathnat' and -A is used */
> +             else if (show_abs_path && *path && *path != '/') {
> +                     if (fd == AT_FDCWD)
> +                             prefix_printed = print_tracee_cwd(tcp);
> +                     else {
> +                             char path[PATH_MAX + 1];
> +                             getfdpath(tcp, fd, path, sizeof(path));
> +                             tprintf("\"%s/", path);
> +                             prefix_printed = 1;
> +                     }
> +             }
> +

print_tracee_cwd() prints a quoted string, while getfdpath() returns
a raw string.


-- 
ldv

Attachment: pgpoYIlVx1Z5B.pgp
Description: PGP signature

------------------------------------------------------------------------------
Slashdot TV.  
Video for Nerds.  Stuff that matters.
http://tv.slashdot.org/
_______________________________________________
Strace-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/strace-devel

Reply via email to