jacereda / fsatrace

Filesystem access tracer
ISC License
81 stars 12 forks source link

Tracking reads from non-existing files #33

Open snowleopard opened 5 years ago

snowleopard commented 5 years ago

First of all, thank you for the great tool!

It seems that fsatrace doesn't track reads from files that do not exist. For example, if the file 1.c does not exist then the command

fsatrace verwmdq 1.out -- gcc 1.c

does not list 1.c in the result 1.out, which is a problem for my use case. (Here is a blog post about my use case in case you are curious.)

Tested both on Windows and Linux.

How difficult would it be to add support for this?

jacereda commented 5 years ago

I think it would be quite easy. Maybe it could use a prefix to mark failed operations, like

!r|non-existing-path

I'll see how it goes.

jacereda commented 5 years ago

Can you try the report-failures branch?

jacereda commented 5 years ago

I only tested on Windows, most probably won't build on Unix.

snowleopard commented 5 years ago

@jacereda I've tried this on Windows but it doesn't seem to work. I tried both

fsatrace verwmdq 1.out -- gcc 1.c

and

fsatrace verwmdq! 1.out -- gcc 1.c

but 1.c was not listed in the result.

Here is the output:

argv[0]=gcc
argv[1]=1.c
composed=gcc "1.c"
gcc: error: 1.c: No such file or directory
gcc: fatal error: no input files
compilation terminated.
fsatrace.EXE(11324): error: command failed with code 1
original="D:\tools\fsatrace\fsatrace.EXE" verwmdq! 1.out -- gcc 1.c
argv[0]=gcc
argv[1]=1.c
composed=gcc "1.c"

... and 1.out:

r|C:\msys\mingw64\bin\gcc.exe
r|C:\WINDOWS\SYSTEM32\ntdll.dll
r|C:\WINDOWS\System32\KERNEL32.DLL
r|C:\WINDOWS\System32\KERNELBASE.dll
r|C:\WINDOWS\System32\msvcrt.dll
r|C:\msys\mingw64\bin\libwinpthread-1.dll
r|D:\tools\fsatrace\fsatrace64.dll
r|C:\WINDOWS\System32\PSAPI.DLL
r|C:\WINDOWS\System32\USER32.dll
r|C:\WINDOWS\System32\win32u.dll
r|C:\WINDOWS\System32\GDI32.dll
r|C:\WINDOWS\System32\gdi32full.dll
r|C:\WINDOWS\System32\msvcp_win.dll
r|C:\WINDOWS\System32\ucrtbase.dll
r|C:\WINDOWS\System32\IMM32.DLL
r|C:\WINDOWS\SYSTEM32\tzres.dll
jacereda commented 5 years ago

Can you try with the linux/mac version?

geo2a commented 5 years ago

Hi @jacereda, @snowleopard asked me to try it on linux and I can confirm that with a fresh build from the report-failures branch the tracking of missing files works:

$  fsatrace verwmdq! 1.out -- gcc 1.c
argv[0]=gcc
argv[1]=1.c
gcc: error: 1.c: No such file or directory
gcc: fatal error: no input files
compilation terminated.
fsatrace(24275): error: command failed with code 1
argv[0]=gcc
argv[1]=1.c

And now 1.out reports 1.c being missing as expected:

r|/usr/bin/gcc-5
!q|1.out;/snap/bin/gcc
!q|/home/geo2a/.ghc/gcc
!q|/home/geo2a/gems/bin/gcc
!q|/home/geo2a/.opam/coq-8.8/bin/gcc
!q|/home/geo2a/bin/gcc
!q|/home/geo2a/.local/bin/gcc
!q|/usr/local/sbin/gcc
!q|/usr/local/bin/gcc
!q|/usr/sbin/gcc
q|/usr/bin/gcc-5
!q|1.out;/snap/bin/gcc
!q|/home/geo2a/.ghc/gcc
!q|/home/geo2a/gems/bin/gcc
!q|/home/geo2a/.opam/coq-8.8/bin/gcc
!q|/home/geo2a/bin/gcc
!q|/home/geo2a/.local/bin/gcc
!q|/usr/local/sbin/gcc
!q|/usr/local/bin/gcc
!q|/usr/sbin/gcc
q|/usr/bin/gcc-5
*** !q|1.c ***
q|/usr/lib/gcc/x86_64-linux-gnu/5
!q|/usr/lib/gcc/x86_64-linux-gnu/5/specs
!q|/usr/lib/gcc/x86_64-linux-gnu/5/../../../../x86_64-linux-gnu/lib/x86_64-linux-gnu/5/specs
!q|/usr/lib/gcc/x86_64-linux-gnu/5/../../../../x86_64-linux-gnu/lib/specs
!q|/usr/lib/gcc/x86_64-linux-gnu/specs
q|/usr/lib/gcc/x86_64-linux-gnu/5
q|/usr/lib/gcc/x86_64-linux-gnu/5/lto-wrapper

Thanks!