strace/Beobachtung des Shell-Befehls "date": Unterschied zwischen den Versionen

Aus Mikiwiki
Zur Navigation springen Zur Suche springen
Keine Bearbeitungszusammenfassung
Keine Bearbeitungszusammenfassung
 
(Eine dazwischenliegende Version desselben Benutzers wird nicht angezeigt)
Zeile 1: Zeile 1:
== Befehlsaufruf ==
Der folgende Befehl ruft [[strace]] für den Shell-Befehl [[date]] auf und protokolliert die Ausgabe in die Datei "logfile" im aktuellen Verzeichnis.
Der folgende Befehl ruft [[strace]] für den Shell-Befehl [[date]] auf und protokolliert die Ausgabe in die Datei "logfile" im aktuellen Verzeichnis.


  $ <b>strace -o logfile date</b>
  $ <b>strace -o logfile date</b>
== Ausgabe ==


Die Ausgabe lautet wie folgt und wurde hier der Einfachheit halber mit einer Zeilennummerierung versehen:
Die Ausgabe lautet wie folgt und wurde hier der Einfachheit halber mit einer Zeilennummerierung versehen:


{| class=wikitable width=100%
{| class=wikitable width=100%
| width=70% |
|  
<source lang="c" enclose=div>
<source lang="c" enclose=div>
   1 execve("/bin/date", ["date"], [/* 42 vars */]) = 0
   1 execve("/bin/date", ["date"], [/* 42 vars */]) = 0
Zeile 143: Zeile 147:
134 exit_group(0)                          = ?
134 exit_group(0)                          = ?
</source>
</source>
| bgcolor=white width=30% |
|}
|}


== Erklärung ==
=== Zeile 1 ===
Nach Aufruf von "strace date" ist zu sehen, dass die Programmdatei "/bin/date" über einen Systemaufruf von "execve()" gestartet wird.


=== Zeile 5 ===


Der Kernel überträgt dem Program Loader die Aufgabe, für das Laden der benötigten [[Systembibliotheken]] zu sorgen. Zuerst kommen dabei die in der Umgebungsvariablen "LD_PRELOAD" genannten Bibliotheken zum Zuge, als nächstes die in der Umgebungsvariable "LD_LIBRARY_PATH" angegebenen Verzeichnisse sowie der Cache des Program Loaders ("/etc/ld.so.cache").


=== Zeile 11, 18, 27 ===


"date" benötigt die Bibliotheken "librt.so.1", "libc.so.6" (also die [[Glibc]]) und "libpthread.so.0" - das kann auch das Programm [[ldd]] herausfinden:


  $ <b>ldd $(which date)</b>
  $ <b>ldd $(which date)</b>
Zeile 158: Zeile 170:
         /lib/ld-linux.so.2 (0x00abb000)
         /lib/ld-linux.so.2 (0x00abb000)


Nach Aufruf von "strace date" ist zu sehen, dass die Programmdatei "/bin/date" über einen Systemaufruf von "execve()" gestartet wird. Der Kernel überträgt dem Program Loader die Aufgabe, für das Laden der benötigten [[Systembibliotheken]] zu sorgen - "date" benötigt nur die Bibliothek "libc.so.6", also die [[Glibc]] - das kann auch das Programm [[ldd]] herausfinden.
=== Zeile 118 ===
 
Nach dem Laden und Initialisieren sämtlicher Bibliotheken ruft "date" den Systemaufruf "clock_gettime()" auf, um den aktuellen Zeitpunkt zu bestimmen.
 
=== Zeile 119-126 ===
 
Mit Hilfe der Zeitzonen-Daten kann "date" das Datum und die Uhrzeit ausgeben.
 
=== Zeile 130 ===


$ <b>strace date</b>
"date" schreibt den Text auf den mit dem Dateideskriptor 1 verbundenen Standardausgabekanal.
<pre>
execve("/bin/date", ["date"], [/* 41 vars */]) = 0
brk(0)                                  = 0x98bf000
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
mmap2(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7776000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY)      = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=83275, ...}) = 0
mmap2(NULL, 83275, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb7761000
close(3)                                = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("/lib/tls/i686/cmov/librt.so.1", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\300\30\0\0004\0\0\0"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0644, st_size=30684, ...}) = 0
mmap2(NULL, 33364, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x441000
mmap2(0x448000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x6) = 0x448000
close(3)                                = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("/lib/tls/i686/cmov/libc.so.6", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0000m\1\0004\0\0\0"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0755, st_size=1405508, ...}) = 0
mmap2(NULL, 1415592, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x531000
mprotect(0x684000, 4096, PROT_NONE)    = 0
mmap2(0x685000, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x153) = 0x685000
mmap2(0x688000, 10664, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x688000
close(3)                                = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("/lib/tls/i686/cmov/libpthread.so.0", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0 J\0\0004\0\0\0"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0755, st_size=117086, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7760000
mmap2(NULL, 98792, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x218000
mmap2(0x22d000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x14) = 0x22d000
mmap2(0x22f000, 4584, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x22f000
close(3)                                = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb775f000
set_thread_area({entry_number:-1 -> 6, base_addr:0xb775f6c0, limit:1048575, seg_32bit:1, contents:0, read_exec_only:0, limit_in_pages:1, seg_not_present:0, useable:1}) = 0
mprotect(0x22d000, 4096, PROT_READ)    = 0
mprotect(0x685000, 8192, PROT_READ)    = 0
mprotect(0x448000, 4096, PROT_READ)    = 0
mprotect(0x8057000, 4096, PROT_READ)    = 0
mprotect(0xd2a000, 4096, PROT_READ)    = 0
munmap(0xb7761000, 83275)              = 0
set_tid_address(0xb775f728)            = 10712
set_robust_list(0xb775f730, 0xc)        = 0
futex(0xbf9a4310, FUTEX_WAKE_PRIVATE, 1) = 0
futex(0xbf9a4310, FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME, 1, NULL, bf9a4320) = -1 EAGAIN (Resource temporarily  unavailable)
rt_sigaction(SIGRTMIN, {0x21c410, [], SA_SIGINFO}, NULL, 8) = 0
rt_sigaction(SIGRT_1, {0x21c8f0, [], SA_RESTART|SA_SIGINFO}, NULL, 8) = 0
rt_sigprocmask(SIG_UNBLOCK, [RTMIN RT_1], NULL, 8) = 0
getrlimit(RLIMIT_STACK, {rlim_cur=8192*1024, rlim_max=RLIM_INFINITY}) = 0
uname({sys="Linux", node="kanzler", ...}) = 0
brk(0)                                  = 0x98bf000
brk(0x98e0000)                          = 0x98e0000
open("/usr/lib/locale/locale-archive", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/locale.alias", O_RDONLY) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=2570, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7775000
read(3, "# Locale name alias data base.\n#"..., 4096) = 2570
read(3, "", 4096)                      = 0
close(3)                                = 0
munmap(0xb7775000, 4096)                = 0
open("/usr/lib/locale/de_CH.utf8/LC_IDENTIFICATION", O_RDONLY) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=353, ...}) = 0
mmap2(NULL, 353, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb7775000
close(3)                                = 0
open("/usr/lib/gconv/gconv-modules.cache", O_RDONLY) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=26048, ...}) = 0
mmap2(NULL, 26048, PROT_READ, MAP_SHARED, 3, 0) = 0xb776e000
close(3)                                = 0
futex(0x687a8c, FUTEX_WAKE_PRIVATE, 2147483647) = 0
open("/usr/lib/locale/de_CH.utf8/LC_MEASUREMENT", O_RDONLY) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=23, ...}) = 0
mmap2(NULL, 23, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb776d000
close(3)                                = 0
open("/usr/lib/locale/de_CH.utf8/LC_TELEPHONE", O_RDONLY) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=49, ...}) = 0
mmap2(NULL, 49, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb776c000
close(3)                                = 0
open("/usr/lib/locale/de_CH.utf8/LC_ADDRESS", O_RDONLY) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=127, ...}) = 0
mmap2(NULL, 127, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb776b000
open("/usr/lib/locale/de_CH.utf8/LC_NAME", O_RDONLY) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=62, ...}) = 0
mmap2(NULL, 62, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb776a000
close(3)                                = 0
open("/usr/lib/locale/de_CH.utf8/LC_PAPER", O_RDONLY) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=34, ...}) = 0
mmap2(NULL, 34, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb7769000
close(3)                                = 0
open("/usr/lib/locale/de_CH.utf8/LC_MESSAGES", O_RDONLY) = 3
fstat64(3, {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
close(3)                                = 0
open("/usr/lib/locale/de_CH.utf8/LC_MESSAGES/SYS_LC_MESSAGES", O_RDONLY) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=54, ...}) = 0
mmap2(NULL, 54, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb7768000
close(3)                                = 0
open("/usr/lib/locale/de_CH.utf8/LC_MONETARY", O_RDONLY) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=294, ...}) = 0
mmap2(NULL, 294, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb7767000
close(3)                                = 0
open("/usr/lib/locale/de_CH.utf8/LC_COLLATE", O_RDONLY) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=1170770, ...}) = 0
mmap2(NULL, 1170770, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb7641000
close(3)                                = 0
open("/usr/lib/locale/de_CH.utf8/LC_TIME", O_RDONLY) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=2382, ...}) = 0
mmap2(NULL, 2382, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb7766000
close(3)                                = 0
open("/usr/lib/locale/de_CH.utf8/LC_NUMERIC", O_RDONLY) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=54, ...}) = 0
mmap2(NULL, 54, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb7765000
close(3)                                = 0
open("/usr/lib/locale/de_CH.utf8/LC_CTYPE", O_RDONLY) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=256484, ...}) = 0
mmap2(NULL, 256484, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb7602000
close(3)                                = 0
clock_gettime(CLOCK_REALTIME, {1290902570, 373229098}) = 0
open("/etc/localtime", O_RDONLY)        = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=1892, ...}) = 0
fstat64(3, {st_mode=S_IFREG|0644, st_size=1892, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7601000
read(3, "TZif2\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\4\0\0\0\4\0\0\0\0"..., 4096) = 1892
_llseek(3, -28, [1864], SEEK_CUR)      = 0
read(3, "\nCET-1CEST,M3.5.0,M10.5.0/3\n", 4096) = 28
close(3)                                = 0
munmap(0xb7601000, 4096)                = 0
fstat64(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 2), ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7601000
write(1, "Son Nov 28 01:02:50 CET 2010\n", 29Son Nov 28 01:02:50 CET 2010
) = 29
close(1)                                = 0
munmap(0xb7601000, 4096)                = 0
close(2)                                = 0
exit_group(0)                          = ?
</pre>




{{cat|strace}}
{{cat|strace}}

Aktuelle Version vom 28. November 2010, 13:20 Uhr

Befehlsaufruf

Der folgende Befehl ruft strace für den Shell-Befehl date auf und protokolliert die Ausgabe in die Datei "logfile" im aktuellen Verzeichnis.

$ strace -o logfile date

Ausgabe

Die Ausgabe lautet wie folgt und wurde hier der Einfachheit halber mit einer Zeilennummerierung versehen:

  1 execve("/bin/date", ["date"], [/* 42 vars */]) = 0
  2 brk(0)                                  = 0x9383000
  3 access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
  4 mmap2(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb781c000
  5 access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
  6 open("/etc/ld.so.cache", O_RDONLY)      = 3
  7 fstat64(3, {st_mode=S_IFREG|0644, st_size=83275, ...}) = 0
  8 mmap2(NULL, 83275, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb7807000
  9 close(3)                                = 0
 10 access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
 11 open("/lib/tls/i686/cmov/librt.so.1", O_RDONLY) = 3
 12 read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\300\30\0\0004\0\0\0"..., 512) = 512
 13 fstat64(3, {st_mode=S_IFREG|0644, st_size=30684, ...}) = 0
 14 mmap2(NULL, 33364, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x823000
 15 mmap2(0x82a000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x6) = 0x82a000
 16 close(3)                                = 0
 17 access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
 18 open("/lib/tls/i686/cmov/libc.so.6", O_RDONLY) = 3
 19 read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0000m\1\0004\0\0\0"..., 512) = 512
 20 fstat64(3, {st_mode=S_IFREG|0755, st_size=1405508, ...}) = 0
 21 mmap2(NULL, 1415592, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x34c000
 22 mprotect(0x49f000, 4096, PROT_NONE)     = 0
 23 mmap2(0x4a0000, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x153) = 0x4a0000
 24 mmap2(0x4a3000, 10664, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x4a3000
 25 close(3)                                = 0
 26 access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
 27 open("/lib/tls/i686/cmov/libpthread.so.0", O_RDONLY) = 3
 28 read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0 J\0\0004\0\0\0"..., 512) = 512
 29 fstat64(3, {st_mode=S_IFREG|0755, st_size=117086, ...}) = 0
 30 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7806000
 31 mmap2(NULL, 98792, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x195000
 32 mmap2(0x1aa000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x14) = 0x1aa000
 33 mmap2(0x1ac000, 4584, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x1ac000
 34 close(3)                                = 0
 35 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7805000
 36 set_thread_area({entry_number:-1 -> 6, base_addr:0xb78056c0, limit:1048575, seg_32bit:1, contents:0, read_exec_only:0, limit_in_pages:1, seg_not_present:0, useable:1}) = 0
 37 mprotect(0x1aa000, 4096, PROT_READ)     = 0
 38 mprotect(0x4a0000, 8192, PROT_READ)     = 0
 39 mprotect(0x82a000, 4096, PROT_READ)     = 0
 40 mprotect(0x8057000, 4096, PROT_READ)    = 0
 41 mprotect(0xea6000, 4096, PROT_READ)     = 0
 42 munmap(0xb7807000, 83275)               = 0
 43 set_tid_address(0xb7805728)             = 1953
 44 set_robust_list(0xb7805730, 0xc)        = 0
 45 futex(0xbfcda4b0, FUTEX_WAKE_PRIVATE, 1) = 0
 46 futex(0xbfcda4b0, FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME, 1, NULL, bfcda4c0) = -1 EAGAIN (Resource temporarily unavailable)
 47 rt_sigaction(SIGRTMIN, {0x199410, [], SA_SIGINFO}, NULL, 8) = 0
 48 rt_sigaction(SIGRT_1, {0x1998f0, [], SA_RESTART|SA_SIGINFO}, NULL, 8) = 0
 49 rt_sigprocmask(SIG_UNBLOCK, [RTMIN RT_1], NULL, 8) = 0
 50 getrlimit(RLIMIT_STACK, {rlim_cur=8192*1024, rlim_max=RLIM_INFINITY}) = 0
 51 uname({sys="Linux", node="kanzler", ...}) = 0
 52 brk(0)                                  = 0x9383000
 53 brk(0x93a4000)                          = 0x93a4000
 54 open("/usr/lib/locale/locale-archive", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory)
 55 open("/usr/share/locale/locale.alias", O_RDONLY) = 3
 56 fstat64(3, {st_mode=S_IFREG|0644, st_size=2570, ...}) = 0
 57 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb781b000
 58 read(3, "# Locale name alias data base.\n#"..., 4096) = 2570
 59 read(3, "", 4096)                       = 0
 60 close(3)                                = 0
 61 munmap(0xb781b000, 4096)                = 0
 62 open("/usr/lib/locale/de_CH.utf8/LC_IDENTIFICATION", O_RDONLY) = 3
 63 fstat64(3, {st_mode=S_IFREG|0644, st_size=353, ...}) = 0
 64 mmap2(NULL, 353, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb781b000
 65 close(3)                                = 0
 66 open("/usr/lib/gconv/gconv-modules.cache", O_RDONLY) = 3
 67 fstat64(3, {st_mode=S_IFREG|0644, st_size=26048, ...}) = 0
 68 mmap2(NULL, 26048, PROT_READ, MAP_SHARED, 3, 0) = 0xb7814000
 69 close(3)                                = 0
 70 futex(0x4a2a8c, FUTEX_WAKE_PRIVATE, 2147483647) = 0
 71 open("/usr/lib/locale/de_CH.utf8/LC_MEASUREMENT", O_RDONLY) = 3
 72 fstat64(3, {st_mode=S_IFREG|0644, st_size=23, ...}) = 0
 73 mmap2(NULL, 23, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb7813000
 74 close(3)                                = 0
 75 open("/usr/lib/locale/de_CH.utf8/LC_TELEPHONE", O_RDONLY) = 3
 76 fstat64(3, {st_mode=S_IFREG|0644, st_size=49, ...}) = 0
 77 mmap2(NULL, 49, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb7812000
 78 close(3)                                = 0
 79 open("/usr/lib/locale/de_CH.utf8/LC_ADDRESS", O_RDONLY) = 3
 80 fstat64(3, {st_mode=S_IFREG|0644, st_size=127, ...}) = 0
 81 mmap2(NULL, 127, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb7811000
 82 close(3)                                = 0
 83 open("/usr/lib/locale/de_CH.utf8/LC_NAME", O_RDONLY) = 3
 84 fstat64(3, {st_mode=S_IFREG|0644, st_size=62, ...}) = 0
 85 mmap2(NULL, 62, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb7810000
 86 close(3)                                = 0
 87 open("/usr/lib/locale/de_CH.utf8/LC_PAPER", O_RDONLY) = 3
 88 fstat64(3, {st_mode=S_IFREG|0644, st_size=34, ...}) = 0
 89 mmap2(NULL, 34, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb780f000
 90 close(3)                                = 0
 91 open("/usr/lib/locale/de_CH.utf8/LC_MESSAGES", O_RDONLY) = 3
 92 fstat64(3, {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
 93 close(3)                                = 0
 94 open("/usr/lib/locale/de_CH.utf8/LC_MESSAGES/SYS_LC_MESSAGES", O_RDONLY) = 3
 95 fstat64(3, {st_mode=S_IFREG|0644, st_size=54, ...}) = 0
 96 mmap2(NULL, 54, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb780e000
 97 close(3)                                = 0
 98 open("/usr/lib/locale/de_CH.utf8/LC_MONETARY", O_RDONLY) = 3
 99 fstat64(3, {st_mode=S_IFREG|0644, st_size=294, ...}) = 0
100 mmap2(NULL, 294, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb780d000
101 close(3)                                = 0
102 open("/usr/lib/locale/de_CH.utf8/LC_COLLATE", O_RDONLY) = 3
103 fstat64(3, {st_mode=S_IFREG|0644, st_size=1170770, ...}) = 0
104 mmap2(NULL, 1170770, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb76e7000
105 close(3)                                = 0
106 open("/usr/lib/locale/de_CH.utf8/LC_TIME", O_RDONLY) = 3
107 fstat64(3, {st_mode=S_IFREG|0644, st_size=2382, ...}) = 0
108 mmap2(NULL, 2382, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb780c000
109 close(3)                                = 0
110 open("/usr/lib/locale/de_CH.utf8/LC_NUMERIC", O_RDONLY) = 3
111 fstat64(3, {st_mode=S_IFREG|0644, st_size=54, ...}) = 0
112 mmap2(NULL, 54, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb780b000
113 close(3)                                = 0
114 open("/usr/lib/locale/de_CH.utf8/LC_CTYPE", O_RDONLY) = 3
115 fstat64(3, {st_mode=S_IFREG|0644, st_size=256484, ...}) = 0
116 mmap2(NULL, 256484, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb76a8000
117 close(3)                                = 0
118 clock_gettime(CLOCK_REALTIME, {1290945848, 115169817}) = 0
119 open("/etc/localtime", O_RDONLY)        = 3
120 fstat64(3, {st_mode=S_IFREG|0644, st_size=1892, ...}) = 0
121 fstat64(3, {st_mode=S_IFREG|0644, st_size=1892, ...}) = 0
122 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb76a7000
123 read(3, "TZif2\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\4\0\0\0\4\0\0\0\0"..., 4096) = 1892
124 _llseek(3, -28, [1864], SEEK_CUR)       = 0
125 read(3, "\nCET-1CEST,M3.5.0,M10.5.0/3\n", 4096) = 28
126 close(3)                                = 0
127 munmap(0xb76a7000, 4096)                = 0
128 fstat64(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 1), ...}) = 0
129 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb76a7000
130 write(1, "Son Nov 28 13:04:08 CET 2010\n", 29) = 29
131 close(1)                                = 0
132 munmap(0xb76a7000, 4096)                = 0
133 close(2)                                = 0
134 exit_group(0)                           = ?

Erklärung

Zeile 1

Nach Aufruf von "strace date" ist zu sehen, dass die Programmdatei "/bin/date" über einen Systemaufruf von "execve()" gestartet wird.

Zeile 5

Der Kernel überträgt dem Program Loader die Aufgabe, für das Laden der benötigten Systembibliotheken zu sorgen. Zuerst kommen dabei die in der Umgebungsvariablen "LD_PRELOAD" genannten Bibliotheken zum Zuge, als nächstes die in der Umgebungsvariable "LD_LIBRARY_PATH" angegebenen Verzeichnisse sowie der Cache des Program Loaders ("/etc/ld.so.cache").

Zeile 11, 18, 27

"date" benötigt die Bibliotheken "librt.so.1", "libc.so.6" (also die Glibc) und "libpthread.so.0" - das kann auch das Programm ldd herausfinden:

$ ldd $(which date)
       linux-gate.so.1 =>  (0x00fd1000)
       librt.so.1 => /lib/tls/i686/cmov/librt.so.1 (0x00929000)
       libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0x00614000)
       libpthread.so.0 => /lib/tls/i686/cmov/libpthread.so.0 (0x00474000)
       /lib/ld-linux.so.2 (0x00abb000)

Zeile 118

Nach dem Laden und Initialisieren sämtlicher Bibliotheken ruft "date" den Systemaufruf "clock_gettime()" auf, um den aktuellen Zeitpunkt zu bestimmen.

Zeile 119-126

Mit Hilfe der Zeitzonen-Daten kann "date" das Datum und die Uhrzeit ausgeben.

Zeile 130

"date" schreibt den Text auf den mit dem Dateideskriptor 1 verbundenen Standardausgabekanal.