Skip to content

Instantly share code, notes, and snippets.

@vincentbernat
Created September 1, 2016 11:08
Show Gist options
  • Save vincentbernat/93d21986c832146911af15b49b5d34ba to your computer and use it in GitHub Desktop.
Save vincentbernat/93d21986c832146911af15b49b5d34ba to your computer and use it in GitHub Desktop.
global closed_trace%
global closed_timestamp%
global closed_tid%
probe syscall.close {
if (target() != pid()) {
next
}
closed_trace[$fd] = ubacktrace()
closed_timestamp[$fd] = gettimeofday_us()
closed_tid[$fd] = tid()
}
probe syscall.read.return {
if (target() != pid()) {
next
}
if ($return == -9) {
now = gettimeofday_us()
printf("%s.%06d, read(%d) == -EBADF\n", ctime(now/1000000), now%1000000, $fd)
printf("%s\n", print_usyms(ubacktrace()))
printf("Closed in %d at %s.%06d:\n",
closed_tid[$fd],
ctime(closed_timestamp[$fd]/1000000), closed_timestamp[$fd]%1000000)
printf("%s\n", print_usyms(closed_trace[$fd]))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment