0

I saw so many links showing that the strace is listing gettimeofday as a syscall in its output, but in my case I feel like it is getting broken down to other calls. Am i missing anything ?

I am running in VM on linux 4.4 kernel and ubuntu 16.04

root@ak-dev-1:~# cat trial.c && gcc trial.c && strace -c ./a.out
#include <stdio.h>
#include <sys/time.h>
#include <unistd.h>

int main() {
    struct timeval tv;
    gettimeofday(&tv, NULL);
    printf("%lu.%lu\n", tv.tv_sec, tv.tv_usec);
}
1584465316.623916
% time     seconds  usecs/call     calls    errors syscall
------ ----------- ----------- --------- --------- ----------------
  0.00    0.000000           0         1           read
  0.00    0.000000           0         1           write
  0.00    0.000000           0         2           open
  0.00    0.000000           0         2           close
  0.00    0.000000           0         3           fstat
  0.00    0.000000           0         7           mmap
  0.00    0.000000           0         4           mprotect
  0.00    0.000000           0         1           munmap
  0.00    0.000000           0         3           brk
  0.00    0.000000           0         3         3 access
  0.00    0.000000           0         1           execve
  0.00    0.000000           0         1           arch_prctl
------ ----------- ----------- --------- --------- ----------------
100.00    0.000000                    29         3 total


root@ak-dev-1:~# uname -a
Linux ak-dev-1 4.4.0-137-generic #163-Ubuntu SMP Mon Sep 24 13:14:43 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
  • 3
    Does this answer your question? [Anyone can understand how gettimeofday works?](https://stackoverflow.com/questions/7266813/anyone-can-understand-how-gettimeofday-works) or [Does gettimeofday() on macOS use a system call?](https://stackoverflow.com/questions/40967594/does-gettimeofday-on-macos-use-a-system-call) (although the latter does not apply to linux) – walnut Mar 17 '20 at 17:22
  • use ltrace, its not a direct syscall anymore. – tomgalpin Mar 17 '20 at 17:24
  • Thanks a lot guys. The link was useful to understand stuffs. And ltrace did the trick for me. – Aravindhan Krishnan Mar 18 '20 at 06:14

0 Answers0