On Thu, May 29, 2014 at 07:46:35PM +0530, zubin.mit...@gmail.com wrote: > From: Zubin Mithra <zubin.mit...@gmail.com> > > * util.c (print_abspath): New function that converts > a relative to an absolute path. > * util.c (get_tracee_cwd): New function that finds > the current working directory of the tracee. > * (printpathn): Use print_abspath to print out links > if `-yy` flag is used. > > Signed-off-by: Zubin Mithra <zubin.mit...@gmail.com> > --- > defs.h | 2 ++ > util.c | 71 > +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--- > 2 files changed, 70 insertions(+), 3 deletions(-) > > diff --git a/defs.h b/defs.h > index 5381e60..25d845d 100644 > --- a/defs.h > +++ b/defs.h > @@ -631,6 +631,8 @@ extern const char *signame(int); > extern void pathtrace_select(const char *); > extern int pathtrace_match(struct tcb *); > extern int getfdpath(struct tcb *, int, char *, unsigned); > +extern int get_tracee_cwd(struct tcb *, char *); > +extern bool print_abspath(struct tcb *, char *, int); > > extern const char *xlookup(const struct xlat *, int); > > diff --git a/util.c b/util.c > index b1f1e90..68af3ae 100644 > --- a/util.c > +++ b/util.c > @@ -593,9 +593,17 @@ printpathn(struct tcb *tcp, long addr, int n) > n++; > outstr = alloca(4 * n); /* 4*(n-1) + 3 for quotes and NUL */ > string_quote(path, outstr, -1, n); > - tprints(outstr); > - if (!nul_seen) > - tprints("..."); > + if (show_fd_path == 2) { > + /* "..." is printed if the length of current working > + directory + length of outstr > 4096 */ > + if (print_abspath(tcp, outstr, nul_seen)) > + tprints("..."); > + } > + else { > + tprints(outstr); > + if (!nul_seen) > + tprints("..."); > + }
In this way only the original path will be string_quote'ed, and cwd will be left intact (try your code with strace -xx). What I suggest is simply to fetch cwd prefix, string_quote and print it right before the current outstr related code in printpathn. -- ldv
pgpssXSIrP7Ke.pgp
Description: PGP signature
------------------------------------------------------------------------------ Time is money. Stop wasting it! Get your web API in 5 minutes. www.restlet.com/download http://p.sf.net/sfu/restlet
_______________________________________________ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel