/****************************************************************************** * stat_open.d * * Prints out open'ed files that were previously stat'ed. Dumps call stacks * too. * * Run like this: * * sudo dtrace -Zs stat_open.d * * adw at mozilla.com * August 2009 * *****************************************************************************/ #pragma D option quiet syscall::statfs:entry, syscall::lstat:entry, syscall::stat:entry, syscall::stat64:entry /execname == "firefox-bin"/ { this->path = copyinstr(arg0); self->stats[this->path] = 1; /* Uncomment to print all files stat'ed and the call stacks. */ /* printf("STAT %s %d %s", execname, pid, this->path); ustack(); printf("\n"); */ } syscall::open:entry, syscall::open_nocancel:entry /execname == "firefox-bin" && self->stats[copyinstr(arg0)]/ { this->path = copyinstr(arg0); printf("OPEN %s %d %s", execname, pid, this->path); ustack(); printf("\n"); } /** * Stop tracing when BrowserStartup() returns. */ javascript*:::function-return /copyinstr(arg2) == "BrowserStartup"/ { exit(0); }