source is not readily available since they do not need to be recompiled in order to trace them. Students, hackers and the overly-curious will find that a great deal can be learned about a system and its system calls by tracing even ordinary programs. And programmers will find that since system calls and signals are events that happen at the user/kernel interface, a close examination of this boundary is very useful for bug isolation, sanity checking and attempting to capture race conditions. Each line in the trace contains the system call name, followed by its arguments in parentheses and its return value. An example from stracing the command "cat /dev/null" is: open("/dev/null", O_RDONLY) = 3 Errors (typically a return value of -1) have the errno symbol and error string appended. open("/foo/bar", O_RDONLY) = -1 ENOENT (No such file or directory) Signals are printed as signal symbol and decoded siginfo structure. An excerpt from stracing and interrupting the command "sleep 666" is: sigsuspend([] <unfinished ...> --- SIGINT {si_signo=SIGINT, si_code=SI_USER, si_pid=...} --- +++ killed by SIGINT +++ If a system call is being executed and meanwhile another one is being called from a different thread/process then strace will try to preserve the order of those events and mark the ongoing call as being unfinished. When the call returns it will be marked as resumed. [pid 28772] select(4, [3], NULL, NULL, NULL <unfinished ...> [pid 28779] clock_gettime(CLOCK_REALTIME, {1130322148, 939977000}) = 0 [pid 28772] <... select resumed> ) = 1 (in [3]) Interruption of a (restartable) system call by a signal delivery is processed differently as kernel terminates the system call and also arranges its immediate reexecution after the signal handler completes. read(0, 0x7ffff72cf5cf, 1) = ? ERESTARTSYS (To be restarted) --- SIGALRM ... --- rt_sigreturn(0xe) = 0 read(0, "", 1) = 0 Arguments are printed in symbolic form with passion. This example shows the shell performing ">>xyzzy" output redirection: open("xyzzy", O_WRONLY|O_APPEND|O_CREAT, 0666) = 3 Here, the second and the third argument of open(2) are decoded by breaking down the flag argument into its three bitwise-OR constituents and printing the mode value in octal by tradition. Where the traditional or native usage differs from ANSI or POSIX, the latter forms are preferred. In some cases, strace output is proven to be more readable than the source. Structure pointers are dereferenced and the members are displayed as appropriate. In most cases, arguments are formatted in the most C-like fashion possible. For example, the essence of the com‐ mand "ls -l /dev/null" is captured as: lstat("/dev/null", {st_mode=S_IFCHR|0666, st_rdev=makedev(0x1, 0x3), ...}) = 0 Notice how the 'struct stat' argument is dereferenced and how each member is displayed symbolically. In particular, observe how the st_mode member is carefully decoded into a bitwise-OR of symbolic and numeric values. Also notice in this example that the first argument to lstat(2) is an input to the system call and the second argument is an output. Since output arguments are not modified if the system call fails, arguments may not always be dereferenced. For example, retrying the "ls -l" example with a non-existent file produces the following line: lstat("/foo/bar", 0xb004) = -1 ENOENT (No such file or directory) Manual page strace(1) line 17 (press h for help or q to quit)
kihei/i-01b77bb37a0d39570
by SadServersMore by SadServers
tracefs on /sys/kernel/tracing type tracefs (rw,nosuid,nodev,noexec,relatime) fusectl on /sys/fs/fuse/connections type fusectl (rw,nosuid,nodev,noexec,relatimconfigfs on /sys/kernel/config type configfs (rw,nosuid,nodev,noexec,relatime) /dev/nvme0n1p15 on /boot/efi type vfat (rw,relatime,fmask=0022,dmask=0022,codepaadmin@i-0b26d5501c20c30f7:~$ touch tmp admin@i-0b26d5501c20c30f7:~$ la bash: la: command not found admin@i-0b26d5501c20c30f7:~$ ls agent data datafile kihei tmp admin@i-0b26d5501c20c30f7:~$ rm tmp admin@i-0b26d5501c20c30f7:~$ mkdir temp admin@i-0b26d5501c20c30f7:~$ mv datafile temp/^C (reverse-i-search)`': ^C admin@i-0b26d5501c20c30f7:~$ sudo mount /dev/vg/lv ./temp admin@i-0b26d5501c20c30f7:~$ mv datafile temp/
kihei/i-0b26d5501c20c30f7 05:10
by SadServers28 root 20 0 0 0 0 S 0.0 0.0 0:00.01 kcompactd 29 root 25 5 0 0 0 S 0.0 0.0 0:00.00 ksmd 31 root 20 0 0 0 0 I 0.0 0.0 0:00.03 kworker/1 49 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 kintegrit 50 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 kblockd 51 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 blkcg_pun 52 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 kworker/1 53 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kswapd0
paris/i-0d640c7ecdbcdb8c4 03:28
by SadServerscloud-config.service loade cloud-final.service loade cloud-init-local.service loade cloud-init.service loade cron.service loade dbus.service loade flaskapp.service loade getty@tty1.service loade gotty.service loade ifup@ens5.service loade ifupdown-pre.service loade kmod-static-nodes.service loadeadmin@i-0c62597e9ba323b08:~$ nc localhost 5000 GET /