syscall.tcl
6.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
#
# Copyright (C) 1996-1998 by the Board of Trustees
# of Leland Stanford Junior University.
#
# This file is part of the SimOS distribution.
# See LICENSE file for terms of the license.
# Write a trace of Linux system calls to the SimOS log.
#
# Warning: This currently only works on the X86 Linux
#
# Usage:
# source "syscall.tcl"
#
# traceSyscall $SYSCALL_TRACE_ON # Turns syscall tracing on
# traceSyscall $SYSCALL_TRACE_OFF # Turns syscall tracing off
#
set SYSCALL_VEC "int128"
set SYSCALL_NAME(0) "setup"
set SYSCALL_NAME(1) "exit"
set SYSCALL_NAME(2) "fork"
set SYSCALL_NAME(3) "read"
set SYSCALL_NAME(4) "write"
set SYSCALL_NAME(5) "open"
set SYSCALL_NAME(6) "close"
set SYSCALL_NAME(7) "waitpid"
set SYSCALL_NAME(8) "creat"
set SYSCALL_NAME(9) "link"
set SYSCALL_NAME(10) "unlink"
set SYSCALL_NAME(11) "execve"
set SYSCALL_NAME(12) "chdir"
set SYSCALL_NAME(13) "time"
set SYSCALL_NAME(14) "prev_mknod"
set SYSCALL_NAME(15) "chmod"
set SYSCALL_NAME(16) "chown"
set SYSCALL_NAME(17) "break"
set SYSCALL_NAME(18) "oldstat"
set SYSCALL_NAME(19) "lseek"
set SYSCALL_NAME(20) "getpid"
set SYSCALL_NAME(21) "mount"
set SYSCALL_NAME(22) "umount"
set SYSCALL_NAME(23) "setuid"
set SYSCALL_NAME(24) "getuid"
set SYSCALL_NAME(25) "stime"
set SYSCALL_NAME(26) "ptrace"
set SYSCALL_NAME(27) "alarm"
set SYSCALL_NAME(28) "oldfstat"
set SYSCALL_NAME(29) "pause"
set SYSCALL_NAME(30) "utime"
set SYSCALL_NAME(31) "stty"
set SYSCALL_NAME(32) "gtty"
set SYSCALL_NAME(33) "access"
set SYSCALL_NAME(34) "nice"
set SYSCALL_NAME(35) "ftime"
set SYSCALL_NAME(36) "sync"
set SYSCALL_NAME(37) "kill"
set SYSCALL_NAME(38) "rename"
set SYSCALL_NAME(39) "mkdir"
set SYSCALL_NAME(40) "rmdir"
set SYSCALL_NAME(41) "dup"
set SYSCALL_NAME(42) "pipe"
set SYSCALL_NAME(43) "times"
set SYSCALL_NAME(44) "prof"
set SYSCALL_NAME(45) "brk"
set SYSCALL_NAME(46) "setgid"
set SYSCALL_NAME(47) "getgid"
set SYSCALL_NAME(48) "signal"
set SYSCALL_NAME(49) "geteuid"
set SYSCALL_NAME(50) "getegid"
set SYSCALL_NAME(51) "acct"
set SYSCALL_NAME(52) "phys"
set SYSCALL_NAME(53) "lock"
set SYSCALL_NAME(54) "ioctl"
set SYSCALL_NAME(55) "fcntl"
set SYSCALL_NAME(56) "mpx"
set SYSCALL_NAME(57) "setpgid"
set SYSCALL_NAME(58) "ulimit"
set SYSCALL_NAME(59) "oldolduname"
set SYSCALL_NAME(60) "umask"
set SYSCALL_NAME(61) "chroot"
set SYSCALL_NAME(62) "prev_ustat"
set SYSCALL_NAME(63) "dup2"
set SYSCALL_NAME(64) "getppid"
set SYSCALL_NAME(65) "getpgrp"
set SYSCALL_NAME(66) "setsid"
set SYSCALL_NAME(67) "sigaction"
set SYSCALL_NAME(68) "siggetmask"
set SYSCALL_NAME(69) "sigsetmask"
set SYSCALL_NAME(70) "setreuid"
set SYSCALL_NAME(71) "setregid"
set SYSCALL_NAME(72) "sigsuspend"
set SYSCALL_NAME(73) "sigpending"
set SYSCALL_NAME(74) "sethostname"
set SYSCALL_NAME(75) "setrlimit"
set SYSCALL_NAME(76) "getrlimit"
set SYSCALL_NAME(77) "getrusage"
set SYSCALL_NAME(78) "gettimeofday"
set SYSCALL_NAME(79) "settimeofday"
set SYSCALL_NAME(80) "getgroups"
set SYSCALL_NAME(81) "setgroups"
set SYSCALL_NAME(82) "select"
set SYSCALL_NAME(83) "symlink"
set SYSCALL_NAME(84) "oldlstat"
set SYSCALL_NAME(85) "readlink"
set SYSCALL_NAME(86) "uselib"
set SYSCALL_NAME(87) "swapon"
set SYSCALL_NAME(88) "reboot"
set SYSCALL_NAME(89) "readdir"
set SYSCALL_NAME(90) "mmap"
set SYSCALL_NAME(91) "munmap"
set SYSCALL_NAME(92) "truncate"
set SYSCALL_NAME(93) "ftruncate"
set SYSCALL_NAME(94) "fchmod"
set SYSCALL_NAME(95) "fchown"
set SYSCALL_NAME(96) "getpriority"
set SYSCALL_NAME(97) "setpriority"
set SYSCALL_NAME(98) "profil"
set SYSCALL_NAME(99) "statfs"
set SYSCALL_NAME(100) "fstatfs"
set SYSCALL_NAME(101) "ioperm"
set SYSCALL_NAME(102) "socketcall"
set SYSCALL_NAME(103) "klog"
set SYSCALL_NAME(104) "setitimer"
set SYSCALL_NAME(105) "getitimer"
set SYSCALL_NAME(106) "prev_stat"
set SYSCALL_NAME(107) "prev_lstat"
set SYSCALL_NAME(108) "prev_fstat"
set SYSCALL_NAME(109) "olduname"
set SYSCALL_NAME(110) "iopl"
set SYSCALL_NAME(111) "vhangup"
set SYSCALL_NAME(112) "idle"
set SYSCALL_NAME(113) "vm86old"
set SYSCALL_NAME(114) "wait4"
set SYSCALL_NAME(115) "swapoff"
set SYSCALL_NAME(116) "sysinfo"
set SYSCALL_NAME(117) "ipc"
set SYSCALL_NAME(118) "fsync"
set SYSCALL_NAME(119) "sigreturn"
set SYSCALL_NAME(120) "clone"
set SYSCALL_NAME(121) "setdomainname"
set SYSCALL_NAME(122) "uname"
set SYSCALL_NAME(123) "modify_ldt"
set SYSCALL_NAME(124) "adjtimex"
set SYSCALL_NAME(125) "mprotect"
set SYSCALL_NAME(126) "sigprocmask"
set SYSCALL_NAME(127) "create_module"
set SYSCALL_NAME(128) "init_module"
set SYSCALL_NAME(129) "delete_module"
set SYSCALL_NAME(130) "get_kernel_syms"
set SYSCALL_NAME(131) "quotactl"
set SYSCALL_NAME(132) "getpgid"
set SYSCALL_NAME(133) "fchdir"
set SYSCALL_NAME(134) "bdflush"
set SYSCALL_NAME(135) "sysfs"
set SYSCALL_NAME(136) "personality"
set SYSCALL_NAME(137) "afs_syscall"
set SYSCALL_NAME(138) "setfsuid"
set SYSCALL_NAME(139) "setfsgid"
set SYSCALL_NAME(140) "_llseek"
set SYSCALL_NAME(141) "getdents"
set SYSCALL_NAME(142) "_newselect"
set SYSCALL_NAME(143) "flock"
set SYSCALL_NAME(144) "msync"
set SYSCALL_NAME(145) "readv"
set SYSCALL_NAME(146) "writev"
set SYSCALL_NAME(147) "getsid"
set SYSCALL_NAME(148) "fdatasync"
set SYSCALL_NAME(149) "_sysctl"
set SYSCALL_NAME(150) "mlock"
set SYSCALL_NAME(151) "munlock"
set SYSCALL_NAME(152) "mlockall"
set SYSCALL_NAME(153) "munlockall"
set SYSCALL_NAME(154) "sched_setparam"
set SYSCALL_NAME(155) "sched_getparam"
set SYSCALL_NAME(156) "sched_setscheduler"
set SYSCALL_NAME(157) "sched_getscheduler"
set SYSCALL_NAME(158) "sched_yield"
set SYSCALL_NAME(159) "sched_get_priority_max"
set SYSCALL_NAME(160) "sched_get_priority_min"
set SYSCALL_NAME(161) "sched_rr_get_interval"
set SYSCALL_NAME(162) "nanosleep"
set SYSCALL_NAME(163) "mremap"
set SYSCALL_NAME(164) "setresuid"
set SYSCALL_NAME(165) "getresuid"
set SYSCALL_NAME(166) "vm86"
set SYSCALL_NAME(167) "query_module"
set SYSCALL_NAME(168) "poll"
set traceSyscallHasDoneInit 0
proc traceSyscallInit {} {
global SYSCALL_VEC SYSCALL_NAME
global traceSyscallHasDoneInit
global syscallReturnEIP
annotation set vec $SYSCALL_VEC -tag SyscallTrace {
set _off 8
catch { set _ra $MEMORY([expr $esp + $_off]) } { set _ra
"INV" }
set _arg0 $ebx
set _arg1 $ecx
set _arg2 $edx
catch { set _name $SYSCALL_NAME([format "%u" $eax]) } { set _name [format "SYS%u" $eax] }
log "$CYCLES: SYSCALL @ $eip from $_ra : $_name ($_arg0, $_arg1, $_arg2)\n"
set syscallReturnEIP $eip
}
annotation set inst rfe -tag SyscallTrace {
if {$syscallReturnEIP == $eip} {
log "$CYCLES: SYSCALL_RETURN @ $eip eax = $eax\n"
}
set syscallReturnEIP -1
}
set traceSyscallHasDoneInit 1
set syscallReturnEIP -1
}
set SYSCALL_TRACE_ON 1
set SYSCALL_TRACE_OFF 0
proc traceSyscall {enableFlag} {
global traceSyscallHasDoneInit
if {$enableFlag} {
if {$traceSyscallHasDoneInit == 0} traceSyscallInit
annotation enable SyscallTrace
} else {
annotation disable SyscallTrace
}
}