tracefile: Deal with chdir and relative files.
This commit is contained in:
parent
671b08deca
commit
c326746053
|
@ -12,12 +12,20 @@ if(not ($opt::exists or $opt::nonexists or $opt::all)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
my @cmd = shell_quote(@ARGV);
|
my @cmd = shell_quote(@ARGV);
|
||||||
|
my $dir = ".";
|
||||||
|
|
||||||
open(IN, "-|", "strace -ff -e trace=file @cmd 2>&1") || die;
|
open(IN, "-|", "strace -ff -e trace=file @cmd 2>&1") || die;
|
||||||
while(<IN>) {
|
while(<IN>) {
|
||||||
|
if(/chdir."(([^\\"]|\\[\\"nt])*)".\s*=\s*0/) {
|
||||||
|
$dir = $1;
|
||||||
|
}
|
||||||
|
|
||||||
|
# [pid 30817] stat("transpose/100000files.tar.gz", {st_mode=S_IFREG|0644, st_size=140853248, ...}) = 0
|
||||||
if(s/^[^\"]+"(([^\\"]|\\[\\"nt])*)".*/$1/) {
|
if(s/^[^\"]+"(([^\\"]|\\[\\"nt])*)".*/$1/) {
|
||||||
# Matches the strace structure for a file
|
# Matches the strace structure for a file
|
||||||
my $file = shell_unquote($1);
|
my $file = shell_unquote($1);
|
||||||
|
# Relative to $dir
|
||||||
|
$file =~ s:^([^/]):$dir/$1:;
|
||||||
my $print = 0;
|
my $print = 0;
|
||||||
if($opt::all
|
if($opt::all
|
||||||
or
|
or
|
||||||
|
@ -29,7 +37,7 @@ while(<IN>) {
|
||||||
if($opt::unique and $seen{$file}++) {
|
if($opt::unique and $seen{$file}++) {
|
||||||
$print = 0;
|
$print = 0;
|
||||||
}
|
}
|
||||||
$print and print;
|
$print and print $file,"\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue