blob: 5e08900a17eebaca378ae5548e77043db2cef194 [file] [log] [blame]
Kamil Rytarowski39628a72018-02-15 02:43:02 +00001#!/usr/bin/awk -f
2
3#===-- generate_netbsd_syscalls.awk ----------------------------------------===#
4#
5# The LLVM Compiler Infrastructure
6#
7# This file is distributed under the University of Illinois Open Source
8# License. See LICENSE.TXT for details.
9#
10#===------------------------------------------------------------------------===#
11#
12# This file is a generator of:
13# - include/sanitizer/netbsd_syscall_hooks.h
14# - lib/sanitizer_common/sanitizer_syscalls_netbsd.inc
15#
16# This script accepts on the input syscalls.master by default located in the
17# /usr/src/sys/kern/syscalls.master path in the NetBSD distribution.
18#
19# NetBSD version 8.0.
20#
21#===------------------------------------------------------------------------===#
22
23BEGIN {
24 # harcode the script name
25 script_name = "generate_netbsd_syscalls.awk"
26 outputh = "../include/sanitizer/netbsd_syscall_hooks.h"
27 outputinc = "../lib/sanitizer_common/sanitizer_syscalls_netbsd.inc"
28
29 # assert that we are in the directory with scripts
30 in_utils = system("test -f " script_name " && exit 1 || exit 0")
31 if (in_utils == 0) {
32 usage()
33 }
34
35 # assert 1 argument passed
36 if (ARGC != 2) {
37 usage()
38 }
39
40 # assert argument is a valid file path to syscall.master
41 if (system("test -f " ARGV[1]) != 0) {
42 usage()
43 }
44
45 # sanity check that the path ends with "syscall.master"
46 if (ARGV[1] !~ /syscalls\.master$/) {
47 usage()
48 }
49
50 # accept overloading CLANGFORMAT from environment
51 clangformat = "clang-format"
52 if ("CLANGFORMAT" in ENVIRON) {
53 clangformat = ENVIRON["CLANGFORMAT"]
54 }
55
56 # parsing specific symbols
57 parsingheader=1
58
59 parsedsyscalls=0
60
61 # Hardcoded in algorithm
62 SYS_MAXSYSARGS=8
63}
64
65# Parse the RCS ID from syscall.master
66parsingheader == 1 && NR == 1 {
67 if (match($0, /\$[^$]+\$/)) {
68 # trim initial 'NetBSD: ' and trailing ' $'
69 syscallmasterversion = substr($0, RSTART + 9, RLENGTH - 11)
70 } else {
71 # wrong file?
72 usage()
73 }
74}
75
76# skip the following lines
77# - empty
78NF == 0 {
79 next
80}
81# - comment
82$1 == ";" {
83 next
84}
85
86# separator between the header and table with syscalls
87$0 == "%%" {
88 parsingheader = 0
89 next
90}
91
92# preserve 'if/elif/else/endif' C preprocessor as-is
93parsingheader == 0 && $0 ~ /^#/ {
94 if (parsedsyscalls in ifelifelseendif) {
95 ifelifelseendif[parsedsyscalls] = ifelifelseendif[parsedsyscalls] "\n" $0
96 } else {
97 ifelifelseendif[parsedsyscalls] = $0
98 }
99 next
100}
101
102# parsing of syscall definitions
103parsingheader == 0 && $1 ~ /^[0-9]+$/ {
104 # first join multiple lines into single one
105 while (sub(/\\$/, "")) {
106 getline line
107 $0 = $0 "" line
108 }
109
110 # Skip unwanted syscalls
111 skip=0
112 if ($0 ~ /OBSOL/ || $0 ~ /EXCL/ || $0 ~ /UNIMPL/) {
113 skip=1
114 }
115
116 # Compose the syscall name
117 # - compat?
118 compat=""
119 if (match($0, /COMPAT_[0-9]+/)) {
120 compat = tolower(substr($0, RSTART, RLENGTH))
121 }
122 # - alias name?
123 alias=""
124 if ($(NF) != "}" && !skip) {
125 alias = alias "" $(NF)
126 }
127 # - compat version?
128 compatver=""
129 if (match($0, /\|[0-9]+\|/)) {
130 compatver = tolower(substr($0, RSTART + 1, RLENGTH - 2))
131 }
132 # - basename?
133 basename=""
134 if (skip) {
135 basename = $1
136 } else {
137 if (match($0, /\|[_a-z0-9]+\(/)) {
138 basename = tolower(substr($0, RSTART + 1, RLENGTH - 2))
139 }
140 }
141
142 syscallname=""
143
144 if (skip) {
145 syscallname= syscallname "$"
146 }
147
148 if (length(compat) > 0) {
149 syscallname = syscallname "" compat "_"
150 }
151 if (length(alias) > 0) {
152 syscallname = syscallname "" alias
153 } else {
154 if (length(compatver) > 0) {
155 syscallname = syscallname "__" basename "" compatver
156 } else {
157 syscallname = syscallname "" basename
158 }
159 }
160
161 # Store the syscallname
162 syscalls[parsedsyscalls]=syscallname
163
164 # Extract syscall arguments
165 if (match($0, /\([^)]+\)/)) {
166 args = substr($0, RSTART + 1, RLENGTH - 2)
167
168 if (args == "void") {
169 syscallargs[parsedsyscalls] = "void"
170 syscallfullargs[parsedsyscalls] = "void"
171 } else {
172 # Normalize 'type * argument' to 'type *argument'
173 gsub("\\*[ \t]+", "*", args)
174
175 n = split(args, a, ",")
176
177 # Handle the first argument
178 match(a[1], /[*_a-z0-9\[\]]+$/)
179 syscallfullargs[parsedsyscalls] = substr(a[1], RSTART) "_"
180
181 gsub(".+[ *]", "", a[1])
182 syscallargs[parsedsyscalls] = a[1]
183
184 # Handle the rest of arguments
185 for (i = 2; i <= n; i++) {
186 match(a[i], /[*_a-zA-Z0-9\[\]]+$/)
187 fs = substr(a[i], RSTART)
188 if (fs ~ /\[/) {
189 sub(/\[/, "_[", fs)
190 } else {
191 fs = fs "_"
192 }
193 syscallfullargs[parsedsyscalls] = syscallfullargs[parsedsyscalls] "$" fs
194 gsub(".+[ *]", "", a[i])
195 syscallargs[parsedsyscalls] = syscallargs[parsedsyscalls] "$" a[i]
196 }
197
198 # Handle array arguments for syscall(2) and __syscall(2)
199 nargs = "arg0$arg1$arg2$arg3$arg4$arg5$arg6$arg7"
200 gsub(/args\[SYS_MAXSYSARGS\]/, nargs, syscallargs[parsedsyscalls])
201 }
202 }
203
204 parsedsyscalls++
205
206 # Done with this line
207 next
208}
209
210
211END {
212 # empty file?
213 if (NR < 1 && !abnormal_exit) {
214 usage()
215 }
216
217 # Handle abnormal exit
218 if (abnormal_exit) {
219 exit(abnormal_exit)
220 }
221
222 # Generate sanitizer_syscalls_netbsd.inc
223
224 # open pipe
225 cmd = clangformat " > " outputh
226
227 pcmd("//===-- netbsd_syscall_hooks.h --------------------------------------------===//")
228 pcmd("//")
229 pcmd("// The LLVM Compiler Infrastructure")
230 pcmd("//")
231 pcmd("// This file is distributed under the University of Illinois Open Source")
232 pcmd("// License. See LICENSE.TXT for details.")
233 pcmd("//")
234 pcmd("//===----------------------------------------------------------------------===//")
235 pcmd("//")
236 pcmd("// This file is a part of public sanitizer interface.")
237 pcmd("//")
238 pcmd("// System call handlers.")
239 pcmd("//")
240 pcmd("// Interface methods declared in this header implement pre- and post- syscall")
241 pcmd("// actions for the active sanitizer.")
242 pcmd("// Usage:")
243 pcmd("// __sanitizer_syscall_pre_getfoo(...args...);")
244 pcmd("// long long res = syscall(SYS_getfoo, ...args...);")
245 pcmd("// __sanitizer_syscall_post_getfoo(res, ...args...);")
246 pcmd("//")
247 pcmd("// DO NOT EDIT! THIS FILE HAS BEEN GENERATED!")
248 pcmd("//")
249 pcmd("// Generated with: " script_name)
250 pcmd("// Generated date: " strftime("%F"))
251 pcmd("// Generated from: " syscallmasterversion)
252 pcmd("//")
253 pcmd("//===----------------------------------------------------------------------===//")
254 pcmd("#ifndef SANITIZER_NETBSD_SYSCALL_HOOKS_H")
255 pcmd("#define SANITIZER_NETBSD_SYSCALL_HOOKS_H")
256 pcmd("")
257
Kamil Rytarowski7d15ab62018-02-15 15:15:45 +0000258 for (i = 0; i < parsedsyscalls; i++) {
259
260 if (i in ifelifelseendif) {
261 pcmd(ifelifelseendif[i])
262 }
263
264 sn = syscalls[i]
265
266 if (sn ~ /^\$/) {
267 pcmd("/* syscall " substr(sn,2) " has been skipped */")
268 continue
269 }
270
271 inargs = ""
272
273 if (syscallargs[i] != "void") {
274 inargs = syscallargs[i]
275 gsub(/\$/, ", ", inargs)
276 }
277
278 outargs = ""
279
280 if (syscallargs[i] != "void") {
281 outargs = "(long long)(" syscallargs[i] ")"
282 gsub(/\$/, "), (long long)(", outargs)
283 }
284
285 pcmd("#define __sanitizer_syscall_pre_" sn "(" inargs ") \\")
286 pcmd(" __sanitizer_syscall_pre_impl_" sn "(" outargs ")")
287
288 if (inargs == "") {
289 inargs = "res"
290 } else {
291 inargs = "res, " inargs
292 }
293
294 if (outargs == "") {
295 outargs = "res"
296 } else {
297 outargs = "res, " outargs
298 }
299
300 pcmd("#define __sanitizer_syscall_post_" sn "(" inargs ") \\")
301 pcmd(" __sanitizer_syscall_post_impl_" sn "(" outargs ")")
302 }
Kamil Rytarowski39628a72018-02-15 02:43:02 +0000303
304 pcmd("")
305 pcmd("#ifdef __cplusplus")
306 pcmd("extern \"C\" {")
307 pcmd("#endif")
308 pcmd("")
309 pcmd("// Private declarations. Do not call directly from user code. Use macros above.")
310 pcmd("")
311 pcmd("// DO NOT EDIT! THIS FILE HAS BEEN GENERATED!")
312 pcmd("")
313
Kamil Rytarowski7d15ab62018-02-15 15:15:45 +0000314 for (i = 0; i < parsedsyscalls; i++) {
315
316 if (i in ifelifelseendif) {
317 pcmd(ifelifelseendif[i])
318 }
319
320 sn = syscalls[i]
321
322 if (sn ~ /^\$/) {
323 pcmd("/* syscall " substr(sn,2) " has been skipped */")
324 continue
325 }
326
327 preargs = syscallargs[i]
328
329 if (preargs != "void") {
330 preargs = "long long " preargs
331 gsub(/\$/, ", long long ", preargs)
332 }
333
334 if (preargs == "void") {
335 postargs = "long long res"
336 } else {
337 postargs = "long long res, " preargs
338 }
339
340 pcmd("void __sanitizer_syscall_pre_impl_" sn "(" preargs ");")
341 pcmd("void __sanitizer_syscall_post_impl_" sn "(" postargs ");")
342 }
Kamil Rytarowski39628a72018-02-15 02:43:02 +0000343
344 pcmd("")
345 pcmd("#ifdef __cplusplus")
346 pcmd("} // extern \"C\"")
347 pcmd("#endif")
348
349 pcmd("")
350 pcmd("// DO NOT EDIT! THIS FILE HAS BEEN GENERATED!")
351 pcmd("")
352
353 pcmd("#endif // SANITIZER_NETBSD_SYSCALL_HOOKS_H")
354
355 close(cmd)
356
357 # Generate sanitizer_syscalls_netbsd.inc
358
359 # open pipe
360 cmd = clangformat " > " outputinc
361
362 pcmd("//===-- sanitizer_syscalls_netbsd.inc ---------------------------*- C++ -*-===//")
363 pcmd("//")
364 pcmd("// The LLVM Compiler Infrastructure")
365 pcmd("//")
366 pcmd("// This file is distributed under the University of Illinois Open Source")
367 pcmd("// License. See LICENSE.TXT for details.")
368 pcmd("//")
369 pcmd("//===----------------------------------------------------------------------===//")
370 pcmd("//")
371 pcmd("// Common syscalls handlers for tools like AddressSanitizer,")
372 pcmd("// ThreadSanitizer, MemorySanitizer, etc.")
373 pcmd("//")
374 pcmd("// This file should be included into the tool's interceptor file,")
375 pcmd("// which has to define it's own macros:")
376 pcmd("// COMMON_SYSCALL_PRE_READ_RANGE")
377 pcmd("// Called in prehook for regions that will be read by the kernel and")
378 pcmd("// must be initialized.")
379 pcmd("// COMMON_SYSCALL_PRE_WRITE_RANGE")
380 pcmd("// Called in prehook for regions that will be written to by the kernel")
381 pcmd("// and must be addressable. The actual write range may be smaller than")
382 pcmd("// reported in the prehook. See POST_WRITE_RANGE.")
383 pcmd("// COMMON_SYSCALL_POST_READ_RANGE")
384 pcmd("// Called in posthook for regions that were read by the kernel. Does")
385 pcmd("// not make much sense.")
386 pcmd("// COMMON_SYSCALL_POST_WRITE_RANGE")
387 pcmd("// Called in posthook for regions that were written to by the kernel")
388 pcmd("// and are now initialized.")
389 pcmd("// COMMON_SYSCALL_ACQUIRE(addr)")
390 pcmd("// Acquire memory visibility from addr.")
391 pcmd("// COMMON_SYSCALL_RELEASE(addr)")
392 pcmd("// Release memory visibility to addr.")
393 pcmd("// COMMON_SYSCALL_FD_CLOSE(fd)")
394 pcmd("// Called before closing file descriptor fd.")
395 pcmd("// COMMON_SYSCALL_FD_ACQUIRE(fd)")
396 pcmd("// Acquire memory visibility from fd.")
397 pcmd("// COMMON_SYSCALL_FD_RELEASE(fd)")
398 pcmd("// Release memory visibility to fd.")
399 pcmd("// COMMON_SYSCALL_PRE_FORK()")
400 pcmd("// Called before fork syscall.")
401 pcmd("// COMMON_SYSCALL_POST_FORK(long long res)")
402 pcmd("// Called after fork syscall.")
403 pcmd("//")
404 pcmd("// DO NOT EDIT! THIS FILE HAS BEEN GENERATED!")
405 pcmd("//")
406 pcmd("// Generated with: " script_name)
407 pcmd("// Generated date: " strftime("%F"))
408 pcmd("// Generated from: " syscallmasterversion)
409 pcmd("//")
410 pcmd("//===----------------------------------------------------------------------===//")
411 pcmd("")
412 pcmd("#include \"sanitizer_platform.h\"")
413 pcmd("#if SANITIZER_NETBSD")
414 pcmd("")
415 pcmd("#include \"sanitizer_libc.h\"")
416 pcmd("")
417 pcmd("#define PRE_SYSCALL(name) \\")
418 pcmd(" SANITIZER_INTERFACE_ATTRIBUTE void __sanitizer_syscall_pre_impl_##name")
419 pcmd("#define PRE_READ(p, s) COMMON_SYSCALL_PRE_READ_RANGE(p, s)")
420 pcmd("#define PRE_WRITE(p, s) COMMON_SYSCALL_PRE_WRITE_RANGE(p, s)")
421 pcmd("")
422 pcmd("#define POST_SYSCALL(name) \\")
423 pcmd(" SANITIZER_INTERFACE_ATTRIBUTE void __sanitizer_syscall_post_impl_##name")
424 pcmd("#define POST_READ(p, s) COMMON_SYSCALL_POST_READ_RANGE(p, s)")
425 pcmd("#define POST_WRITE(p, s) COMMON_SYSCALL_POST_WRITE_RANGE(p, s)")
426 pcmd("")
427 pcmd("#ifndef COMMON_SYSCALL_ACQUIRE")
428 pcmd("# define COMMON_SYSCALL_ACQUIRE(addr) ((void)(addr))")
429 pcmd("#endif")
430 pcmd("")
431 pcmd("#ifndef COMMON_SYSCALL_RELEASE")
432 pcmd("# define COMMON_SYSCALL_RELEASE(addr) ((void)(addr))")
433 pcmd("#endif")
434 pcmd("")
435 pcmd("#ifndef COMMON_SYSCALL_FD_CLOSE")
436 pcmd("# define COMMON_SYSCALL_FD_CLOSE(fd) ((void)(fd))")
437 pcmd("#endif")
438 pcmd("")
439 pcmd("#ifndef COMMON_SYSCALL_FD_ACQUIRE")
440 pcmd("# define COMMON_SYSCALL_FD_ACQUIRE(fd) ((void)(fd))")
441 pcmd("#endif")
442 pcmd("")
443 pcmd("#ifndef COMMON_SYSCALL_FD_RELEASE")
444 pcmd("# define COMMON_SYSCALL_FD_RELEASE(fd) ((void)(fd))")
445 pcmd("#endif")
446 pcmd("")
447 pcmd("#ifndef COMMON_SYSCALL_PRE_FORK")
448 pcmd("# define COMMON_SYSCALL_PRE_FORK() {}")
449 pcmd("#endif")
450 pcmd("")
451 pcmd("#ifndef COMMON_SYSCALL_POST_FORK")
452 pcmd("# define COMMON_SYSCALL_POST_FORK(res) {}")
453 pcmd("#endif")
454 pcmd("")
455 pcmd("// FIXME: do some kind of PRE_READ for all syscall arguments (int(s) and such).")
456 pcmd("")
457 pcmd("extern \"C\" {")
Kamil Rytarowski7d15ab62018-02-15 15:15:45 +0000458 pcmd("#define SYS_MAXSYSARGS " SYS_MAXSYSARGS)
Kamil Rytarowski39628a72018-02-15 02:43:02 +0000459
Kamil Rytarowski7d15ab62018-02-15 15:15:45 +0000460 for (i = 0; i < parsedsyscalls; i++) {
Kamil Rytarowski39628a72018-02-15 02:43:02 +0000461
Kamil Rytarowski7d15ab62018-02-15 15:15:45 +0000462 if (i in ifelifelseendif) {
463 pcmd(ifelifelseendif[i])
464 }
465
466 sn = syscalls[i]
467
468 if (sn ~ /^\$/) {
469 pcmd("/* syscall " substr(sn,2) " has been skipped */")
470 continue
471 }
472
473 preargs = syscallfullargs[i]
474
475 if (preargs != "void") {
476 preargs = "long long " preargs
477 gsub(/\$/, ", long long ", preargs)
478 gsub(/long long \*/, "void *", preargs)
479 }
480
481 if (preargs == "void") {
482 postargs = "long long res"
483 } else {
484 postargs = "long long res, " preargs
485 }
486
487 pcmd("PRE_SYSCALL(" sn ")(" preargs ")")
488 pcmd("{")
489 syscall_body(sn, "pre")
490 pcmd("}")
491
492 pcmd("POST_SYSCALL(" sn ")(" postargs ")")
493 pcmd("{")
494 syscall_body(sn, "post")
495 pcmd("}")
496 }
497
498 pcmd("#undef SYS_MAXSYSARGS")
Kamil Rytarowski39628a72018-02-15 02:43:02 +0000499 pcmd("} // extern \"C\"")
500 pcmd("")
501 pcmd("#undef PRE_SYSCALL")
502 pcmd("#undef PRE_READ")
503 pcmd("#undef PRE_WRITE")
504 pcmd("#undef POST_SYSCALL")
505 pcmd("#undef POST_READ")
506 pcmd("#undef POST_WRITE")
507 pcmd("")
508 pcmd("#endif // SANITIZER_NETBSD")
509
510 close(cmd)
511
512 # Hack for preprocessed code
513 system("sed -i 's,^ \\([^ ]\\), \\1,' " outputinc)
514}
515
516function usage()
517{
518 print "Usage: " script_name " syscalls.master"
519 abnormal_exit = 1
520 exit 1
521}
522
523function pcmd(string)
524{
525 print string | cmd
526}
Kamil Rytarowski7d15ab62018-02-15 15:15:45 +0000527
528function syscall_body(syscall, mode)
529{
530 # Hardcode sanitizing rules here
531 # These syscalls don't change often so they are hand coded
532 if (syscall == "syscall") {
533 pcmd("/* Nothing to do */")
534 } else if (syscall == "exit") {
535 pcmd("/* Nothing to do */")
536 } else if (syscall == "fork") {
537 if (mode == "pre") {
538 pcmd("COMMON_SYSCALL_PRE_FORK();")
539 } else {
540 pcmd("COMMON_SYSCALL_POST_FORK(res);")
541 }
542 } else if (syscall == "read") {
543 if (mode == "pre") {
544 pcmd("if (buf_) {")
545 pcmd(" PRE_WRITE(buf_, nbyte_);")
546 pcmd("}")
547 } else {
548 pcmd("if (res > 0) {")
549 pcmd(" POST_WRITE(buf_, res);")
550 pcmd("}")
551 }
552 } else if (syscall == "write") {
553 if (mode == "pre") {
554 pcmd("if (buf_) {")
555 pcmd(" PRE_READ(buf_, nbyte_);")
556 pcmd("}")
557 } else {
558 pcmd("if (res > 0) {")
559 pcmd(" POST_READ(buf_, res);")
560 pcmd("}")
561 }
562 } else if (syscall == "open") {
563 if (mode == "pre") {
564 pcmd("const char *path = (const char *)path_;")
565 pcmd("if (path) {")
566 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
567 pcmd("}")
568 } else {
569 pcmd("if (res > 0) {")
570 pcmd(" const char *path = (const char *)path_;")
571 pcmd(" if (path) {")
572 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
573 pcmd(" }")
574 pcmd("}")
575 }
576 } else if (syscall == "close") {
577 if (mode == "pre") {
578 pcmd("COMMON_SYSCALL_FD_CLOSE((int)fd_);")
579 } else {
580 pcmd("/* Nothing to do */")
581 }
582 } else if (syscall == "compat_50_wait4") {
583 pcmd("/* TODO */")
584 } else if (syscall == "compat_43_ocreat") {
585 pcmd("/* TODO */")
586 } else if (syscall == "link") {
587 if (mode == "pre") {
588 pcmd("const char *path = (const char *)path_;")
589 pcmd("const char *link = (const char *)link_;")
590 pcmd("if (path) {")
591 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
592 pcmd("}")
593 pcmd("if (link) {")
594 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(link) + 1);")
595 pcmd("}")
596 } else {
597 pcmd("if (res == 0) {")
598 pcmd(" const char *path = (const char *)path_;")
599 pcmd(" const char *link = (const char *)link_;")
600 pcmd(" if (path) {")
601 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
602 pcmd(" }")
603 pcmd(" if (link) {")
604 pcmd(" POST_READ(path, __sanitizer::internal_strlen(link) + 1);")
605 pcmd(" }")
606 pcmd("}")
607 }
608 } else if (syscall == "unlink") {
609 if (mode == "pre") {
610 pcmd("const char *path = (const char *)path_;")
611 pcmd("if (path) {")
612 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
613 pcmd("}")
614 } else {
615 pcmd("if (res == 0) {")
616 pcmd(" const char *path = (const char *)path_;")
617 pcmd(" if (path) {")
618 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
619 pcmd(" }")
620 pcmd("}")
621 }
622 } else if (syscall == "chdir") {
623 if (mode == "pre") {
624 pcmd("const char *path = (const char *)path_;")
625 pcmd("if (path) {")
626 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
627 pcmd("}")
628 } else {
629 pcmd("if (res == 0) {")
630 pcmd(" const char *path = (const char *)path_;")
631 pcmd(" if (path) {")
632 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
633 pcmd(" }")
634 pcmd("}")
635 }
636 } else if (syscall == "fchdir") {
637 pcmd("/* Nothing to do */")
638 } else if (syscall == "compat_50_mknod") {
639 pcmd("/* TODO */")
640 } else if (syscall == "chmod") {
641 if (mode == "pre") {
642 pcmd("const char *path = (const char *)path_;")
643 pcmd("if (path) {")
644 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
645 pcmd("}")
646 } else {
647 pcmd("if (res == 0) {")
648 pcmd(" const char *path = (const char *)path_;")
649 pcmd(" if (path) {")
650 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
651 pcmd(" }")
652 pcmd("}")
653 }
654 } else if (syscall == "chown") {
655 if (mode == "pre") {
656 pcmd("const char *path = (const char *)path_;")
657 pcmd("if (path) {")
658 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
659 pcmd("}")
660 } else {
661 pcmd("if (res == 0) {")
662 pcmd(" const char *path = (const char *)path_;")
663 pcmd(" if (path) {")
664 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
665 pcmd(" }")
666 pcmd("}")
667 }
668 } else if (syscall == "break") {
669 pcmd("/* Nothing to do */")
670 } else if (syscall == "compat_20_getfsstat") {
671 pcmd("/* TODO */")
672 } else if (syscall == "compat_43_olseek") {
673 pcmd("/* TODO */")
674 } else if (syscall == "getpid") {
675 pcmd("/* Nothing to do */")
676 } else if (syscall == "compat_40_mount") {
677 pcmd("/* TODO */")
678 } else if (syscall == "unmount") {
679 if (mode == "pre") {
680 pcmd("const char *path = (const char *)path_;")
681 pcmd("if (path) {")
682 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
683 pcmd("}")
684 } else {
685 pcmd("if (res == 0) {")
686 pcmd(" const char *path = (const char *)path_;")
687 pcmd(" if (path) {")
688 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
689 pcmd(" }")
690 pcmd("}")
691 }
692 } else if (syscall == "setuid") {
693 pcmd("/* Nothing to do */")
694 } else if (syscall == "getuid") {
695 pcmd("/* Nothing to do */")
696 } else if (syscall == "geteuid") {
697 pcmd("/* Nothing to do */")
698 } else if (syscall == "ptrace") {
699 if (mode == "pre") {
700 pcmd("if (req_ == ptrace_pt_io) {")
701 pcmd(" struct __sanitizer_ptrace_io_desc *addr = (struct __sanitizer_ptrace_io_desc *)addr_;")
702 pcmd(" PRE_READ(addr, struct_ptrace_ptrace_io_desc_struct_sz);")
703 pcmd(" if (addr->piod_op == ptrace_piod_write_d || addr->piod_op == ptrace_piod_write_i) {")
704 pcmd(" PRE_READ(addr->piod_addr, addr->piod_len);")
705 pcmd(" }")
706 pcmd(" if (addr->piod_op == ptrace_piod_read_d || addr->piod_op == ptrace_piod_read_i || addr->piod_op == ptrace_piod_read_auxv) {")
707 pcmd(" PRE_WRITE(addr->piod_addr, addr->piod_len);")
708 pcmd(" }")
709 pcmd("} else if (req_ == ptrace_pt_lwpinfo) {")
710 pcmd(" struct __sanitizer_ptrace_lwpinfo *addr = (struct __sanitizer_ptrace_lwpinfo *)addr_;")
711 pcmd(" PRE_READ(&addr->pl_lwpid, sizeof(__sanitizer_lwpid_t));")
712 pcmd(" PRE_WRITE(addr, struct_ptrace_ptrace_lwpinfo_struct_sz);")
713 pcmd("} else if (req_ == ptrace_pt_set_event_mask) {")
714 pcmd(" PRE_READ(addr_, struct_ptrace_ptrace_event_struct_sz);")
715 pcmd("} else if (req_ == ptrace_pt_get_event_mask) {")
716 pcmd(" PRE_WRITE(addr_, struct_ptrace_ptrace_event_struct_sz);")
717 pcmd("} else if (req_ == ptrace_pt_set_siginfo) {")
718 pcmd(" PRE_READ(addr_, struct_ptrace_ptrace_siginfo_struct_sz);")
719 pcmd("} else if (req_ == ptrace_pt_get_siginfo) {")
720 pcmd(" PRE_WRITE(addr_, struct_ptrace_ptrace_siginfo_struct_sz);")
Kamil Rytarowski7d15ab62018-02-15 15:15:45 +0000721 pcmd("} else if (req_ == ptrace_pt_setregs) {")
722 pcmd(" PRE_READ(addr_, struct_ptrace_reg_struct_sz);")
723 pcmd("} else if (req_ == ptrace_pt_getregs) {")
724 pcmd(" PRE_WRITE(addr_, struct_ptrace_reg_struct_sz);")
725 pcmd("} else if (req_ == ptrace_pt_setfpregs) {")
726 pcmd(" PRE_READ(addr_, struct_ptrace_fpreg_struct_sz);")
727 pcmd("} else if (req_ == ptrace_pt_getfpregs) {")
728 pcmd(" PRE_WRITE(addr_, struct_ptrace_fpreg_struct_sz);")
729 pcmd("} else if (req_ == ptrace_pt_setdbregs) {")
730 pcmd(" PRE_READ(addr_, struct_ptrace_dbreg_struct_sz);")
731 pcmd("} else if (req_ == ptrace_pt_getdbregs) {")
732 pcmd(" PRE_WRITE(addr_, struct_ptrace_dbreg_struct_sz);")
733 pcmd("}")
734 } else {
735 pcmd("if (res == 0) {")
736 pcmd(" if (req_ == ptrace_pt_io) {")
737 pcmd(" struct __sanitizer_ptrace_io_desc *addr = (struct __sanitizer_ptrace_io_desc *)addr_;")
738 pcmd(" POST_READ(addr, struct_ptrace_ptrace_io_desc_struct_sz);")
739 pcmd(" if (addr->piod_op == ptrace_piod_write_d || addr->piod_op == ptrace_piod_write_i) {")
740 pcmd(" POST_READ(addr->piod_addr, addr->piod_len);")
741 pcmd(" }")
742 pcmd(" if (addr->piod_op == ptrace_piod_read_d || addr->piod_op == ptrace_piod_read_i || addr->piod_op == ptrace_piod_read_auxv) {")
743 pcmd(" POST_WRITE(addr->piod_addr, addr->piod_len);")
744 pcmd(" }")
745 pcmd(" } else if (req_ == ptrace_pt_lwpinfo) {")
746 pcmd(" struct __sanitizer_ptrace_lwpinfo *addr = (struct __sanitizer_ptrace_lwpinfo *)addr_;")
747 pcmd(" POST_READ(&addr->pl_lwpid, sizeof(__sanitizer_lwpid_t));")
748 pcmd(" POST_WRITE(addr, struct_ptrace_ptrace_lwpinfo_struct_sz);")
749 pcmd(" } else if (req_ == ptrace_pt_set_event_mask) {")
750 pcmd(" POST_READ(addr_, struct_ptrace_ptrace_event_struct_sz);")
751 pcmd(" } else if (req_ == ptrace_pt_get_event_mask) {")
752 pcmd(" POST_WRITE(addr_, struct_ptrace_ptrace_event_struct_sz);")
753 pcmd(" } else if (req_ == ptrace_pt_set_siginfo) {")
754 pcmd(" POST_READ(addr_, struct_ptrace_ptrace_siginfo_struct_sz);")
755 pcmd(" } else if (req_ == ptrace_pt_get_siginfo) {")
756 pcmd(" POST_WRITE(addr_, struct_ptrace_ptrace_siginfo_struct_sz);")
Kamil Rytarowski7d15ab62018-02-15 15:15:45 +0000757 pcmd(" } else if (req_ == ptrace_pt_setregs) {")
758 pcmd(" POST_READ(addr_, struct_ptrace_reg_struct_sz);")
759 pcmd(" } else if (req_ == ptrace_pt_getregs) {")
760 pcmd(" POST_WRITE(addr_, struct_ptrace_reg_struct_sz);")
761 pcmd(" } else if (req_ == ptrace_pt_setfpregs) {")
762 pcmd(" POST_READ(addr_, struct_ptrace_fpreg_struct_sz);")
763 pcmd(" } else if (req_ == ptrace_pt_getfpregs) {")
764 pcmd(" POST_WRITE(addr_, struct_ptrace_fpreg_struct_sz);")
765 pcmd(" } else if (req_ == ptrace_pt_setdbregs) {")
766 pcmd(" POST_READ(addr_, struct_ptrace_dbreg_struct_sz);")
767 pcmd(" } else if (req_ == ptrace_pt_getdbregs) {")
768 pcmd(" POST_WRITE(addr_, struct_ptrace_dbreg_struct_sz);")
769 pcmd(" }")
770 pcmd("}")
771 }
772 } else if (syscall == "recvmsg") {
773 if (mode == "pre") {
774 pcmd("PRE_WRITE(msg_, sizeof(__sanitizer_msghdr));")
775 } else {
776 pcmd("if (res > 0) {")
777 pcmd(" POST_WRITE(msg_, sizeof(__sanitizer_msghdr));")
778 pcmd("}")
779 }
780 } else if (syscall == "sendmsg") {
781 if (mode == "pre") {
782 pcmd("PRE_READ(msg_, sizeof(__sanitizer_msghdr));")
783 } else {
784 pcmd("if (res > 0) {")
785 pcmd(" POST_READ(msg_, sizeof(__sanitizer_msghdr));")
786 pcmd("}")
787 }
788 } else if (syscall == "recvfrom") {
789 if (mode == "pre") {
790 pcmd("PRE_WRITE(buf_, len_);")
791 pcmd("PRE_WRITE(from_, struct_sockaddr_sz);")
792 pcmd("PRE_WRITE(fromlenaddr_, sizeof(__sanitizer_socklen_t));")
793 } else {
794 pcmd("if (res >= 0) {")
795 pcmd(" POST_WRITE(buf_, res);")
796 pcmd(" POST_WRITE(from_, struct_sockaddr_sz);")
797 pcmd(" POST_WRITE(fromlenaddr_, sizeof(__sanitizer_socklen_t));")
798 pcmd("}")
799 }
800 } else if (syscall == "accept") {
801 if (mode == "pre") {
802 pcmd("PRE_WRITE(name_, struct_sockaddr_sz);")
803 pcmd("PRE_WRITE(anamelen_, sizeof(__sanitizer_socklen_t));")
804 } else {
805 pcmd("if (res == 0) {")
806 pcmd(" POST_WRITE(name_, struct_sockaddr_sz);")
807 pcmd(" POST_WRITE(anamelen_, sizeof(__sanitizer_socklen_t));")
808 pcmd("}")
809 }
810 } else if (syscall == "getpeername") {
811 if (mode == "pre") {
812 pcmd("PRE_WRITE(asa_, struct_sockaddr_sz);")
813 pcmd("PRE_WRITE(alen_, sizeof(__sanitizer_socklen_t));")
814 } else {
815 pcmd("if (res == 0) {")
816 pcmd(" POST_WRITE(asa_, struct_sockaddr_sz);")
817 pcmd(" POST_WRITE(alen_, sizeof(__sanitizer_socklen_t));")
818 pcmd("}")
819 }
820 } else if (syscall == "getsockname") {
821 if (mode == "pre") {
822 pcmd("PRE_WRITE(asa_, struct_sockaddr_sz);")
823 pcmd("PRE_WRITE(alen_, sizeof(__sanitizer_socklen_t));")
824 } else {
825 pcmd("if (res == 0) {")
826 pcmd(" POST_WRITE(asa_, struct_sockaddr_sz);")
827 pcmd(" POST_WRITE(alen_, sizeof(__sanitizer_socklen_t));")
828 pcmd("}")
829 }
830 } else if (syscall == "access") {
831 if (mode == "pre") {
832 pcmd("const char *path = (const char *)path_;")
833 pcmd("if (path) {")
834 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
835 pcmd("}")
836 } else {
837 pcmd("if (res == 0) {")
838 pcmd(" const char *path = (const char *)path_;")
839 pcmd(" if (path) {")
840 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
841 pcmd(" }")
842 pcmd("}")
843 }
844 } else if (syscall == "chflags") {
845 if (mode == "pre") {
846 pcmd("const char *path = (const char *)path_;")
847 pcmd("if (path) {")
848 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
849 pcmd("}")
850 } else {
851 pcmd("if (res == 0) {")
852 pcmd(" const char *path = (const char *)path_;")
853 pcmd(" if (path) {")
854 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
855 pcmd(" }")
856 pcmd("}")
857 }
858 } else if (syscall == "fchflags") {
859 pcmd("/* Nothing to do */")
860 } else if (syscall == "sync") {
861 pcmd("/* Nothing to do */")
862 } else if (syscall == "kill") {
863 pcmd("/* Nothing to do */")
864 } else if (syscall == "compat_43_stat43") {
865 pcmd("/* TODO */")
866 } else if (syscall == "getppid") {
867 pcmd("/* Nothing to do */")
868 } else if (syscall == "compat_43_lstat43") {
869 pcmd("/* TODO */")
870 } else if (syscall == "dup") {
871 pcmd("/* Nothing to do */")
872 } else if (syscall == "pipe") {
873 pcmd("/* pipe returns two descriptors through two returned values */")
874 } else if (syscall == "getegid") {
875 pcmd("/* Nothing to do */")
876 } else if (syscall == "profil") {
877 if (mode == "pre") {
878 pcmd("if (samples_) {")
879 pcmd(" PRE_WRITE(samples_, size_);")
880 pcmd("}")
881 } else {
882 pcmd("if (res == 0) {")
883 pcmd(" if (samples_) {")
884 pcmd(" POST_WRITE(samples_, size_);")
885 pcmd(" }")
886 pcmd("}")
887 }
888 } else if (syscall == "ktrace") {
889 if (mode == "pre") {
890 pcmd("const char *fname = (const char *)fname_;")
891 pcmd("if (fname) {")
892 pcmd(" PRE_READ(fname, __sanitizer::internal_strlen(fname) + 1);")
893 pcmd("}")
894 } else {
895 pcmd("const char *fname = (const char *)fname_;")
896 pcmd("if (res == 0) {")
897 pcmd(" if (fname) {")
898 pcmd(" POST_READ(fname, __sanitizer::internal_strlen(fname) + 1);")
899 pcmd(" }")
900 pcmd("}")
901 }
902 } else if (syscall == "compat_13_sigaction13") {
903 pcmd("/* TODO */")
904 } else if (syscall == "getgid") {
905 pcmd("/* Nothing to do */")
906 } else if (syscall == "compat_13_sigprocmask13") {
907 pcmd("/* TODO */")
908 } else if (syscall == "__getlogin") {
909 if (mode == "pre") {
910 pcmd("if (namebuf_) {")
911 pcmd(" PRE_WRITE(namebuf_, namelen_);")
912 pcmd("}")
913 } else {
914 pcmd("if (res == 0) {")
915 pcmd(" if (namebuf_) {")
916 pcmd(" POST_WRITE(namebuf_, namelen_);")
917 pcmd(" }")
918 pcmd("}")
919 }
920 } else if (syscall == "__setlogin") {
921 if (mode == "pre") {
922 pcmd("const char *namebuf = (const char *)namebuf_;")
923 pcmd("if (namebuf) {")
924 pcmd(" PRE_READ(namebuf, __sanitizer::internal_strlen(namebuf) + 1);")
925 pcmd("}")
926 } else {
927 pcmd("if (res == 0) {")
928 pcmd(" const char *namebuf = (const char *)namebuf_;")
929 pcmd(" if (namebuf) {")
930 pcmd(" POST_READ(namebuf, __sanitizer::internal_strlen(namebuf) + 1);")
931 pcmd(" }")
932 pcmd("}")
933 }
934 } else if (syscall == "acct") {
935 if (mode == "pre") {
936 pcmd("const char *path = (const char *)path_;")
937 pcmd("if (path) {")
938 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
939 pcmd("}")
940 } else {
941 pcmd("if (res == 0) {")
942 pcmd(" const char *path = (const char *)path_;")
943 pcmd(" if (path) {")
944 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
945 pcmd(" }")
946 pcmd("}")
947 }
948 } else if (syscall == "compat_13_sigpending13") {
949 pcmd("/* TODO */")
950 } else if (syscall == "compat_13_sigaltstack13") {
951 pcmd("/* TODO */")
952 } else if (syscall == "ioctl") {
953 pcmd("/* Nothing to do */")
954 } else if (syscall == "compat_12_oreboot") {
955 pcmd("/* TODO */")
956 } else if (syscall == "revoke") {
957 if (mode == "pre") {
958 pcmd("const char *path = (const char *)path_;")
959 pcmd("if (path) {")
960 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
961 pcmd("}")
962 } else {
963 pcmd("if (res == 0) {")
964 pcmd(" const char *path = (const char *)path_;")
965 pcmd(" if (path) {")
966 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
967 pcmd(" }")
968 pcmd("}")
969 }
970 } else if (syscall == "symlink") {
971 if (mode == "pre") {
972 pcmd("const char *path = (const char *)path_;")
973 pcmd("const char *link = (const char *)link_;")
974 pcmd("if (path) {")
975 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
976 pcmd("}")
977 pcmd("if (link) {")
978 pcmd(" PRE_READ(link, __sanitizer::internal_strlen(link) + 1);")
979 pcmd("}")
980 } else {
981 pcmd("if (res == 0) {")
982 pcmd(" const char *path = (const char *)path_;")
983 pcmd(" const char *link = (const char *)link_;")
984 pcmd(" if (path) {")
985 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
986 pcmd(" }")
987 pcmd(" if (link) {")
988 pcmd(" POST_READ(link, __sanitizer::internal_strlen(link) + 1);")
989 pcmd(" }")
990 pcmd("}")
991 }
992 } else if (syscall == "readlink") {
993 if (mode == "pre") {
994 pcmd("const char *path = (const char *)path_;")
995 pcmd("if (path) {")
996 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
997 pcmd("}")
998 pcmd("if (buf_) {")
999 pcmd(" PRE_WRITE(buf_, count_);")
1000 pcmd("}")
1001 } else {
1002 pcmd("if (res > 0) {")
1003 pcmd(" const char *path = (const char *)path_;")
1004 pcmd(" if (path) {")
1005 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
1006 pcmd(" }")
1007 pcmd(" if (buf_) {")
1008 pcmd(" PRE_WRITE(buf_, res);")
1009 pcmd(" }")
1010 pcmd("}")
1011 }
1012 } else if (syscall == "execve") {
1013 if (mode == "pre") {
1014 pcmd("const char *path = (const char *)path_;")
1015 pcmd("char **argp = (char **)argp_;")
1016 pcmd("char **envp = (char **)envp_;")
1017 pcmd("if (path) {")
1018 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
1019 pcmd("}")
1020 pcmd("if (argp && argp[0]) {")
1021 pcmd(" char *a = argp[0];")
1022 pcmd(" while (a++) {")
1023 pcmd(" PRE_READ(a, __sanitizer::internal_strlen(a) + 1);")
1024 pcmd(" }")
1025 pcmd("}")
1026 pcmd("if (envp && envp[0]) {")
1027 pcmd(" char *e = envp[0];")
1028 pcmd(" while (e++) {")
1029 pcmd(" PRE_READ(e, __sanitizer::internal_strlen(e) + 1);")
1030 pcmd(" }")
1031 pcmd("}")
1032 } else {
1033 pcmd("/* If we are here, something went wrong */")
1034 pcmd("const char *path = (const char *)path_;")
1035 pcmd("char **argp = (char **)argp_;")
1036 pcmd("char **envp = (char **)envp_;")
1037 pcmd("if (path) {")
1038 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
1039 pcmd("}")
1040 pcmd("if (argp && argp[0]) {")
1041 pcmd(" char *a = argp[0];")
1042 pcmd(" while (a++) {")
1043 pcmd(" POST_READ(a, __sanitizer::internal_strlen(a) + 1);")
1044 pcmd(" }")
1045 pcmd("}")
1046 pcmd("if (envp && envp[0]) {")
1047 pcmd(" char *e = envp[0];")
1048 pcmd(" while (e++) {")
1049 pcmd(" POST_READ(e, __sanitizer::internal_strlen(e) + 1);")
1050 pcmd(" }")
1051 pcmd("}")
1052 }
1053 } else if (syscall == "umask") {
1054 pcmd("/* Nothing to do */")
1055 } else if (syscall == "chroot") {
1056 if (mode == "pre") {
1057 pcmd("const char *path = (const char *)path_;")
1058 pcmd("if (path) {")
1059 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
1060 pcmd("}")
1061 } else {
1062 pcmd("if (res == 0) {")
1063 pcmd(" const char *path = (const char *)path_;")
1064 pcmd(" if (path) {")
1065 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
1066 pcmd(" }")
1067 pcmd("}")
1068 }
1069 } else if (syscall == "compat_43_fstat43") {
1070 pcmd("/* TODO */")
1071 } else if (syscall == "compat_43_ogetkerninfo") {
1072 pcmd("/* TODO */")
1073 } else if (syscall == "compat_43_ogetpagesize") {
1074 pcmd("/* TODO */")
1075 } else if (syscall == "compat_12_msync") {
1076 pcmd("/* TODO */")
1077 } else if (syscall == "vfork") {
1078 pcmd("/* Nothing to do */")
1079 } else if (syscall == "compat_43_ommap") {
1080 pcmd("/* TODO */")
1081 } else if (syscall == "vadvise") {
1082 pcmd("/* Nothing to do */")
1083 } else if (syscall == "munmap") {
1084 pcmd("/* Nothing to do */")
1085 } else if (syscall == "mprotect") {
1086 pcmd("/* Nothing to do */")
1087 } else if (syscall == "madvise") {
1088 pcmd("/* Nothing to do */")
1089 } else if (syscall == "mincore") {
1090 pcmd("/* Nothing to do */")
1091 } else if (syscall == "getgroups") {
1092 if (mode == "pre") {
1093 pcmd("unsigned int *gidset = (unsigned int *)gidset_;")
1094 pcmd("if (gidset) {")
1095 pcmd(" PRE_WRITE(gidset, sizeof(*gidset) * gidsetsize_);")
1096 pcmd("}")
1097 } else {
1098 pcmd("if (res == 0) {")
1099 pcmd(" unsigned int *gidset = (unsigned int *)gidset_;")
1100 pcmd(" if (gidset) {")
1101 pcmd(" POST_WRITE(gidset, sizeof(*gidset) * gidsetsize_);")
1102 pcmd(" }")
1103 pcmd("}")
1104 }
1105 } else if (syscall == "setgroups") {
1106 if (mode == "pre") {
1107 pcmd("unsigned int *gidset = (unsigned int *)gidset_;")
1108 pcmd("if (gidset) {")
1109 pcmd(" PRE_READ(gidset, sizeof(*gidset) * gidsetsize_);")
1110 pcmd("}")
1111 } else {
1112 pcmd("if (res == 0) {")
1113 pcmd(" unsigned int *gidset = (unsigned int *)gidset_;")
1114 pcmd(" if (gidset) {")
1115 pcmd(" POST_READ(gidset, sizeof(*gidset) * gidsetsize_);")
1116 pcmd(" }")
1117 pcmd("}")
1118 }
1119 } else if (syscall == "getpgrp") {
1120 pcmd("/* Nothing to do */")
1121 } else if (syscall == "setpgid") {
1122 pcmd("/* Nothing to do */")
1123 } else if (syscall == "compat_50_setitimer") {
1124 pcmd("/* TODO */")
1125 } else if (syscall == "compat_43_owait") {
1126 pcmd("/* TODO */")
1127 } else if (syscall == "compat_12_oswapon") {
1128 pcmd("/* TODO */")
1129 } else if (syscall == "compat_50_getitimer") {
1130 pcmd("/* TODO */")
1131 } else if (syscall == "compat_43_ogethostname") {
1132 pcmd("/* TODO */")
1133 } else if (syscall == "compat_43_osethostname") {
1134 pcmd("/* TODO */")
1135 } else if (syscall == "compat_43_ogetdtablesize") {
1136 pcmd("/* TODO */")
1137 } else if (syscall == "dup2") {
1138 pcmd("/* Nothing to do */")
1139 } else if (syscall == "fcntl") {
1140 pcmd("/* Nothing to do */")
1141 } else if (syscall == "compat_50_select") {
1142 pcmd("/* TODO */")
1143 } else if (syscall == "fsync") {
1144 pcmd("/* Nothing to do */")
1145 } else if (syscall == "setpriority") {
1146 pcmd("/* Nothing to do */")
1147 } else if (syscall == "compat_30_socket") {
1148 pcmd("/* TODO */")
1149 } else if (syscall == "connect") {
1150 if (mode == "pre") {
1151 pcmd("PRE_READ(name_, namelen_);")
1152 } else {
1153 pcmd("if (res == 0) {")
1154 pcmd(" POST_READ(name_, namelen_);")
1155 pcmd("}")
1156 }
1157 } else if (syscall == "compat_43_oaccept") {
1158 pcmd("/* TODO */")
1159 } else if (syscall == "getpriority") {
1160 pcmd("/* Nothing to do */")
1161 } else if (syscall == "compat_43_osend") {
1162 pcmd("/* TODO */")
1163 } else if (syscall == "compat_43_orecv") {
1164 pcmd("/* TODO */")
1165 } else if (syscall == "compat_13_sigreturn13") {
1166 pcmd("/* TODO */")
1167 } else if (syscall == "bind") {
1168 if (mode == "pre") {
1169 pcmd("PRE_READ(name_, namelen_);")
1170 } else {
1171 pcmd("if (res == 0) {")
1172 pcmd(" PRE_READ(name_, namelen_);")
1173 pcmd("}")
1174 }
1175 } else if (syscall == "setsockopt") {
1176 if (mode == "pre") {
1177 pcmd("if (val_) {")
1178 pcmd(" PRE_READ(val_, valsize_);")
1179 pcmd("}")
1180 } else {
1181 pcmd("if (res == 0) {")
1182 pcmd(" if (val_) {")
1183 pcmd(" POST_READ(val_, valsize_);")
1184 pcmd(" }")
1185 pcmd("}")
1186 }
1187 } else if (syscall == "listen") {
1188 pcmd("/* Nothing to do */")
1189 } else if (syscall == "compat_43_osigvec") {
1190 pcmd("/* TODO */")
1191 } else if (syscall == "compat_43_osigblock") {
1192 pcmd("/* TODO */")
1193 } else if (syscall == "compat_43_osigsetmask") {
1194 pcmd("/* TODO */")
1195 } else if (syscall == "compat_13_sigsuspend13") {
1196 pcmd("/* TODO */")
1197 } else if (syscall == "compat_43_osigstack") {
1198 pcmd("/* TODO */")
1199 } else if (syscall == "compat_43_orecvmsg") {
1200 pcmd("/* TODO */")
1201 } else if (syscall == "compat_43_osendmsg") {
1202 pcmd("/* TODO */")
1203 } else if (syscall == "compat_50_gettimeofday") {
1204 pcmd("/* TODO */")
1205 } else if (syscall == "compat_50_getrusage") {
1206 pcmd("/* TODO */")
1207 } else if (syscall == "getsockopt") {
1208 pcmd("/* TODO */")
1209 } else if (syscall == "readv") {
1210 if (mode == "pre") {
1211 pcmd("struct __sanitizer_iovec *iovp = (struct __sanitizer_iovec *)iovp_;")
1212 pcmd("int i;")
1213 pcmd("if (iovp) {")
1214 pcmd(" PRE_READ(iovp, sizeof(struct __sanitizer_iovec) * iovcnt_);")
1215 pcmd(" for (i = 0; i < iovcnt_; i++) {")
1216 pcmd(" PRE_WRITE(iovp[i].iov_base, iovp[i].iov_len);")
1217 pcmd(" }")
1218 pcmd("}")
1219 } else {
1220 pcmd("struct __sanitizer_iovec *iovp = (struct __sanitizer_iovec *)iovp_;")
1221 pcmd("int i;")
1222 pcmd("uptr m, n = res;")
1223 pcmd("if (res > 0) {")
1224 pcmd(" if (iovp) {")
1225 pcmd(" POST_READ(iovp, sizeof(struct __sanitizer_iovec) * iovcnt_);")
1226 pcmd(" for (i = 0; i < iovcnt_ && n > 0; i++) {")
1227 pcmd(" m = n > iovp[i].iov_len ? iovp[i].iov_len : n;")
1228 pcmd(" POST_WRITE(iovp[i].iov_base, m);")
1229 pcmd(" n -= m;")
1230 pcmd(" }")
1231 pcmd(" }")
1232 pcmd("}")
1233 }
1234 } else if (syscall == "writev") {
1235 if (mode == "pre") {
1236 pcmd("struct __sanitizer_iovec *iovp = (struct __sanitizer_iovec *)iovp_;")
1237 pcmd("int i;")
1238 pcmd("if (iovp) {")
1239 pcmd(" PRE_READ(iovp, sizeof(struct __sanitizer_iovec) * iovcnt_);")
1240 pcmd(" for (i = 0; i < iovcnt_; i++) {")
1241 pcmd(" PRE_READ(iovp[i].iov_base, iovp[i].iov_len);")
1242 pcmd(" }")
1243 pcmd("}")
1244 } else {
1245 pcmd("struct __sanitizer_iovec *iovp = (struct __sanitizer_iovec *)iovp_;")
1246 pcmd("int i;")
1247 pcmd("uptr m, n = res;")
1248 pcmd("if (res > 0) {")
1249 pcmd(" if (iovp) {")
1250 pcmd(" POST_READ(iovp, sizeof(struct __sanitizer_iovec) * iovcnt_);")
1251 pcmd(" for (i = 0; i < iovcnt_ && n > 0; i++) {")
1252 pcmd(" m = n > iovp[i].iov_len ? iovp[i].iov_len : n;")
1253 pcmd(" POST_READ(iovp[i].iov_base, m);")
1254 pcmd(" n -= m;")
1255 pcmd(" }")
1256 pcmd(" }")
1257 pcmd("}")
1258 }
1259 } else if (syscall == "compat_50_settimeofday") {
1260 pcmd("/* TODO */")
1261 } else if (syscall == "fchown") {
1262 pcmd("/* Nothing to do */")
1263 } else if (syscall == "fchmod") {
1264 pcmd("/* Nothing to do */")
1265 } else if (syscall == "compat_43_orecvfrom") {
1266 pcmd("/* TODO */")
1267 } else if (syscall == "setreuid") {
1268 pcmd("/* Nothing to do */")
1269 } else if (syscall == "setregid") {
1270 pcmd("/* Nothing to do */")
1271 } else if (syscall == "rename") {
1272 if (mode == "pre") {
1273 pcmd("const char *from = (const char *)from_;")
1274 pcmd("const char *to = (const char *)to_;")
1275 pcmd("if (from) {")
1276 pcmd(" PRE_READ(from, __sanitizer::internal_strlen(from) + 1);")
1277 pcmd("}")
1278 pcmd("if (to) {")
1279 pcmd(" PRE_READ(to, __sanitizer::internal_strlen(to) + 1);")
1280 pcmd("}")
1281 } else {
1282 pcmd("if (res == 0) {")
1283 pcmd(" const char *from = (const char *)from_;")
1284 pcmd(" const char *to = (const char *)to_;")
1285 pcmd(" if (from) {")
1286 pcmd(" POST_READ(from, __sanitizer::internal_strlen(from) + 1);")
1287 pcmd(" }")
1288 pcmd(" if (to) {")
1289 pcmd(" POST_READ(to, __sanitizer::internal_strlen(to) + 1);")
1290 pcmd(" }")
1291 pcmd("}")
1292 }
1293 } else if (syscall == "compat_43_otruncate") {
1294 pcmd("/* TODO */")
1295 } else if (syscall == "compat_43_oftruncate") {
1296 pcmd("/* TODO */")
1297 } else if (syscall == "flock") {
1298 pcmd("/* Nothing to do */")
1299 } else if (syscall == "mkfifo") {
1300 if (mode == "pre") {
1301 pcmd("const char *path = (const char *)path_;")
1302 pcmd("if (path) {")
1303 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
1304 pcmd("}")
1305 } else {
1306 pcmd("if (res == 0) {")
1307 pcmd(" const char *path = (const char *)path_;")
1308 pcmd(" if (path) {")
1309 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
1310 pcmd(" }")
1311 pcmd("}")
1312 }
1313 } else if (syscall == "sendto") {
1314 if (mode == "pre") {
1315 pcmd("PRE_READ(buf_, len_);")
1316 pcmd("PRE_READ(to_, tolen_);")
1317 } else {
1318 pcmd("if (res >= 0) {")
1319 pcmd(" POST_READ(buf_, len_);")
1320 pcmd(" POST_READ(to_, tolen_);")
1321 pcmd("}")
1322 }
1323 } else if (syscall == "shutdown") {
1324 pcmd("/* Nothing to do */")
1325 } else if (syscall == "socketpair") {
1326 if (mode == "pre") {
1327 pcmd("PRE_WRITE(rsv_, 2 * sizeof(int));")
1328 } else {
1329 pcmd("if (res == 0) {")
1330 pcmd(" POST_WRITE(rsv_, 2 * sizeof(int));")
1331 pcmd("}")
1332 }
1333 } else if (syscall == "mkdir") {
1334 if (mode == "pre") {
1335 pcmd("const char *path = (const char *)path_;")
1336 pcmd("if (path) {")
1337 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
1338 pcmd("}")
1339 } else {
1340 pcmd("if (res == 0) {")
1341 pcmd(" const char *path = (const char *)path_;")
1342 pcmd(" if (path) {")
1343 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
1344 pcmd(" }")
1345 pcmd("}")
1346 }
1347 } else if (syscall == "rmdir") {
1348 if (mode == "pre") {
1349 pcmd("const char *path = (const char *)path_;")
1350 pcmd("if (path) {")
1351 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
1352 pcmd("}")
1353 } else {
1354 pcmd("if (res == 0) {")
1355 pcmd(" const char *path = (const char *)path_;")
1356 pcmd(" if (path) {")
1357 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
1358 pcmd(" }")
1359 pcmd("}")
1360 }
1361 } else if (syscall == "compat_50_utimes") {
1362 pcmd("/* TODO */")
1363 } else if (syscall == "compat_50_adjtime") {
1364 pcmd("/* TODO */")
1365 } else if (syscall == "compat_43_ogetpeername") {
1366 pcmd("/* TODO */")
1367 } else if (syscall == "compat_43_ogethostid") {
1368 pcmd("/* TODO */")
1369 } else if (syscall == "compat_43_osethostid") {
1370 pcmd("/* TODO */")
1371 } else if (syscall == "compat_43_ogetrlimit") {
1372 pcmd("/* TODO */")
1373 } else if (syscall == "compat_43_osetrlimit") {
1374 pcmd("/* TODO */")
1375 } else if (syscall == "compat_43_okillpg") {
1376 pcmd("/* TODO */")
1377 } else if (syscall == "setsid") {
1378 pcmd("/* Nothing to do */")
1379 } else if (syscall == "compat_50_quotactl") {
1380 pcmd("/* TODO */")
1381 } else if (syscall == "compat_43_oquota") {
1382 pcmd("/* TODO */")
1383 } else if (syscall == "compat_43_ogetsockname") {
1384 pcmd("/* TODO */")
1385 } else if (syscall == "nfssvc") {
1386 pcmd("/* Nothing to do */")
1387 } else if (syscall == "compat_43_ogetdirentries") {
1388 pcmd("/* TODO */")
1389 } else if (syscall == "compat_20_statfs") {
1390 pcmd("/* TODO */")
1391 } else if (syscall == "compat_20_fstatfs") {
1392 pcmd("/* TODO */")
1393 } else if (syscall == "compat_30_getfh") {
1394 pcmd("/* TODO */")
1395 } else if (syscall == "compat_09_ogetdomainname") {
1396 pcmd("/* TODO */")
1397 } else if (syscall == "compat_09_osetdomainname") {
1398 pcmd("/* TODO */")
1399 } else if (syscall == "compat_09_ouname") {
1400 pcmd("/* TODO */")
1401 } else if (syscall == "sysarch") {
1402 pcmd("/* TODO */")
1403 } else if (syscall == "compat_10_osemsys") {
1404 pcmd("/* TODO */")
1405 } else if (syscall == "compat_10_omsgsys") {
1406 pcmd("/* TODO */")
1407 } else if (syscall == "compat_10_oshmsys") {
1408 pcmd("/* TODO */")
1409 } else if (syscall == "pread") {
1410 if (mode == "pre") {
1411 pcmd("if (buf_) {")
1412 pcmd(" PRE_WRITE(buf_, nbyte_);")
1413 pcmd("}")
1414 } else {
1415 pcmd("if (res > 0) {")
1416 pcmd(" POST_WRITE(buf_, res);")
1417 pcmd("}")
1418 }
1419 } else if (syscall == "pwrite") {
1420 if (mode == "pre") {
1421 pcmd("if (buf_) {")
1422 pcmd(" PRE_READ(buf_, nbyte_);")
1423 pcmd("}")
1424 } else {
1425 pcmd("if (res > 0) {")
1426 pcmd(" POST_READ(buf_, res);")
1427 pcmd("}")
1428 }
1429 } else if (syscall == "compat_30_ntp_gettime") {
1430 pcmd("/* TODO */")
1431 } else if (syscall == "ntp_adjtime") {
1432 pcmd("/* Nothing to do */")
1433 } else if (syscall == "setgid") {
1434 pcmd("/* Nothing to do */")
1435 } else if (syscall == "setegid") {
1436 pcmd("/* Nothing to do */")
1437 } else if (syscall == "seteuid") {
1438 pcmd("/* Nothing to do */")
1439 } else if (syscall == "lfs_bmapv") {
1440 pcmd("/* TODO */")
1441 } else if (syscall == "lfs_markv") {
1442 pcmd("/* TODO */")
1443 } else if (syscall == "lfs_segclean") {
1444 pcmd("/* TODO */")
1445 } else if (syscall == "compat_50_lfs_segwait") {
1446 pcmd("/* TODO */")
1447 } else if (syscall == "compat_12_stat12") {
1448 pcmd("/* TODO */")
1449 } else if (syscall == "compat_12_fstat12") {
1450 pcmd("/* TODO */")
1451 } else if (syscall == "compat_12_lstat12") {
1452 pcmd("/* TODO */")
1453 } else if (syscall == "pathconf") {
1454 if (mode == "pre") {
1455 pcmd("const char *path = (const char *)path_;")
1456 pcmd("if (path) {")
1457 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
1458 pcmd("}")
1459 } else {
1460 pcmd("if (res != -1) {")
1461 pcmd(" const char *path = (const char *)path_;")
1462 pcmd(" if (path) {")
1463 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
1464 pcmd(" }")
1465 pcmd("}")
1466 }
1467 } else if (syscall == "fpathconf") {
1468 pcmd("/* Nothing to do */")
1469 } else if (syscall == "getrlimit") {
1470 if (mode == "pre") {
1471 pcmd("PRE_WRITE(rlp_, struct_rlimit_sz);")
1472 } else {
1473 pcmd("if (res == 0) {")
1474 pcmd(" POST_WRITE(rlp_, struct_rlimit_sz);")
1475 pcmd("}")
1476 }
1477 } else if (syscall == "setrlimit") {
1478 if (mode == "pre") {
1479 pcmd("PRE_READ(rlp_, struct_rlimit_sz);")
1480 } else {
1481 pcmd("if (res == 0) {")
1482 pcmd(" POST_READ(rlp_, struct_rlimit_sz);")
1483 pcmd("}")
1484 }
1485 } else if (syscall == "compat_12_getdirentries") {
1486 pcmd("/* TODO */")
1487 } else if (syscall == "mmap") {
1488 pcmd("/* Nothing to do */")
1489 } else if (syscall == "__syscall") {
1490 pcmd("/* Nothing to do */")
1491 } else if (syscall == "lseek") {
1492 pcmd("/* Nothing to do */")
1493 } else if (syscall == "truncate") {
1494 if (mode == "pre") {
1495 pcmd("const char *path = (const char *)path_;")
1496 pcmd("if (path) {")
1497 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
1498 pcmd("}")
1499 } else {
1500 pcmd("if (res == 0) {")
1501 pcmd(" const char *path = (const char *)path_;")
1502 pcmd(" if (path) {")
1503 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
1504 pcmd(" }")
1505 pcmd("}")
1506 }
1507 } else if (syscall == "ftruncate") {
1508 pcmd("/* Nothing to do */")
1509 } else if (syscall == "__sysctl") {
1510 if (mode == "pre") {
1511 pcmd("const int *name = (const int *)name_;")
1512 pcmd("if (name) {")
1513 pcmd(" PRE_READ(name, namelen_ * sizeof(*name));")
1514 pcmd("}")
1515 pcmd("if (newv_) {")
1516 pcmd(" PRE_READ(name, newlen_);")
1517 pcmd("}")
1518 } else {
1519 pcmd("if (res == 0) {")
1520 pcmd(" const int *name = (const int *)name_;")
1521 pcmd(" if (name) {")
1522 pcmd(" POST_READ(name, namelen_ * sizeof(*name));")
1523 pcmd(" }")
1524 pcmd(" if (newv_) {")
1525 pcmd(" POST_READ(name, newlen_);")
1526 pcmd(" }")
1527 pcmd("}")
1528 }
1529 } else if (syscall == "mlock") {
1530 pcmd("/* Nothing to do */")
1531 } else if (syscall == "munlock") {
1532 pcmd("/* Nothing to do */")
1533 } else if (syscall == "undelete") {
1534 if (mode == "pre") {
1535 pcmd("const char *path = (const char *)path_;")
1536 pcmd("if (path) {")
1537 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
1538 pcmd("}")
1539 } else {
1540 pcmd("if (res == 0) {")
1541 pcmd(" const char *path = (const char *)path_;")
1542 pcmd(" if (path) {")
1543 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
1544 pcmd(" }")
1545 pcmd("}")
1546 }
1547 } else if (syscall == "compat_50_futimes") {
1548 pcmd("/* TODO */")
1549 } else if (syscall == "getpgid") {
1550 pcmd("/* Nothing to do */")
1551 } else if (syscall == "reboot") {
1552 if (mode == "pre") {
1553 pcmd("const char *bootstr = (const char *)bootstr_;")
1554 pcmd("if (bootstr) {")
1555 pcmd(" PRE_READ(bootstr, __sanitizer::internal_strlen(bootstr) + 1);")
1556 pcmd("}")
1557 } else {
1558 pcmd("/* This call should never return */")
1559 pcmd("const char *bootstr = (const char *)bootstr_;")
1560 pcmd("if (bootstr) {")
1561 pcmd(" POST_READ(bootstr, __sanitizer::internal_strlen(bootstr) + 1);")
1562 pcmd("}")
1563 }
1564 } else if (syscall == "poll") {
1565 pcmd("/* Nothing to do */")
1566 } else if (syscall == "afssys") {
1567 pcmd("/* TODO */")
1568 } else if (syscall == "compat_14___semctl") {
1569 pcmd("/* TODO */")
1570 } else if (syscall == "semget") {
1571 pcmd("/* Nothing to do */")
1572 } else if (syscall == "semop") {
1573 if (mode == "pre") {
1574 pcmd("if (sops_) {")
1575 pcmd(" PRE_READ(sops_, nsops_ * struct_sembuf_sz);")
1576 pcmd("}")
1577 } else {
1578 pcmd("if (res == 0) {")
1579 pcmd(" if (sops_) {")
1580 pcmd(" POST_READ(sops_, nsops_ * struct_sembuf_sz);")
1581 pcmd(" }")
1582 pcmd("}")
1583 }
1584 } else if (syscall == "semconfig") {
1585 pcmd("/* Nothing to do */")
1586 } else if (syscall == "compat_14_msgctl") {
1587 pcmd("/* TODO */")
1588 } else if (syscall == "msgget") {
1589 pcmd("/* Nothing to do */")
1590 } else if (syscall == "msgsnd") {
1591 if (mode == "pre") {
1592 pcmd("if (msgp_) {")
1593 pcmd(" PRE_READ(msgp_, msgsz_);")
1594 pcmd("}")
1595 } else {
1596 pcmd("if (res == 0) {")
1597 pcmd(" if (msgp_) {")
1598 pcmd(" POST_READ(msgp_, msgsz_);")
1599 pcmd(" }")
1600 pcmd("}")
1601 }
1602 } else if (syscall == "msgrcv") {
1603 pcmd("/* Nothing to do */")
1604 } else if (syscall == "shmat") {
1605 pcmd("/* Nothing to do */")
1606 } else if (syscall == "compat_14_shmctl") {
1607 pcmd("/* TODO */")
1608 } else if (syscall == "shmdt") {
1609 pcmd("/* Nothing to do */")
1610 } else if (syscall == "shmget") {
1611 pcmd("/* Nothing to do */")
1612 } else if (syscall == "compat_50_clock_gettime") {
1613 pcmd("/* TODO */")
1614 } else if (syscall == "compat_50_clock_settime") {
1615 pcmd("/* TODO */")
1616 } else if (syscall == "compat_50_clock_getres") {
1617 pcmd("/* TODO */")
1618 } else if (syscall == "timer_create") {
1619 pcmd("/* Nothing to do */")
1620 } else if (syscall == "timer_delete") {
1621 pcmd("/* Nothing to do */")
1622 } else if (syscall == "compat_50_timer_settime") {
1623 pcmd("/* TODO */")
1624 } else if (syscall == "compat_50_timer_gettime") {
1625 pcmd("/* TODO */")
1626 } else if (syscall == "timer_getoverrun") {
1627 pcmd("/* Nothing to do */")
1628 } else if (syscall == "compat_50_nanosleep") {
1629 pcmd("/* TODO */")
1630 } else if (syscall == "fdatasync") {
1631 pcmd("/* Nothing to do */")
1632 } else if (syscall == "mlockall") {
1633 pcmd("/* Nothing to do */")
1634 } else if (syscall == "munlockall") {
1635 pcmd("/* Nothing to do */")
1636 } else if (syscall == "compat_50___sigtimedwait") {
1637 pcmd("/* TODO */")
1638 } else if (syscall == "sigqueueinfo") {
1639 if (mode == "pre") {
1640 pcmd("if (info_) {")
1641 pcmd(" PRE_READ(info_, siginfo_t_sz);")
1642 pcmd("}")
1643 }
1644 } else if (syscall == "modctl") {
1645 pcmd("/* TODO */")
1646 } else if (syscall == "_ksem_init") {
1647 pcmd("/* Nothing to do */")
1648 } else if (syscall == "_ksem_open") {
1649 if (mode == "pre") {
1650 pcmd("const char *name = (const char *)name_;")
1651 pcmd("if (name) {")
1652 pcmd(" PRE_READ(name, __sanitizer::internal_strlen(name) + 1);")
1653 pcmd("}")
1654 } else {
1655 pcmd("const char *name = (const char *)name_;")
1656 pcmd("if (name) {")
1657 pcmd(" POST_READ(name, __sanitizer::internal_strlen(name) + 1);")
1658 pcmd("}")
1659 }
1660 } else if (syscall == "_ksem_unlink") {
1661 if (mode == "pre") {
1662 pcmd("const char *name = (const char *)name_;")
1663 pcmd("if (name) {")
1664 pcmd(" PRE_READ(name, __sanitizer::internal_strlen(name) + 1);")
1665 pcmd("}")
1666 } else {
1667 pcmd("const char *name = (const char *)name_;")
1668 pcmd("if (name) {")
1669 pcmd(" POST_READ(name, __sanitizer::internal_strlen(name) + 1);")
1670 pcmd("}")
1671 }
1672 } else if (syscall == "_ksem_close") {
1673 pcmd("/* Nothing to do */")
1674 } else if (syscall == "_ksem_post") {
1675 pcmd("/* Nothing to do */")
1676 } else if (syscall == "_ksem_wait") {
1677 pcmd("/* Nothing to do */")
1678 } else if (syscall == "_ksem_trywait") {
1679 pcmd("/* Nothing to do */")
1680 } else if (syscall == "_ksem_getvalue") {
1681 pcmd("/* Nothing to do */")
1682 } else if (syscall == "_ksem_destroy") {
1683 pcmd("/* Nothing to do */")
1684 } else if (syscall == "_ksem_timedwait") {
1685 if (mode == "pre") {
1686 pcmd("if (abstime_) {")
1687 pcmd(" PRE_READ(abstime_, struct_timespec_sz);")
1688 pcmd("}")
1689 }
1690 } else if (syscall == "mq_open") {
1691 if (mode == "pre") {
1692 pcmd("const char *name = (const char *)name_;")
1693 pcmd("if (name) {")
1694 pcmd(" PRE_READ(name, __sanitizer::internal_strlen(name) + 1);")
1695 pcmd("}")
1696 } else {
1697 pcmd("const char *name = (const char *)name_;")
1698 pcmd("if (name) {")
1699 pcmd(" POST_READ(name, __sanitizer::internal_strlen(name) + 1);")
1700 pcmd("}")
1701 }
1702 } else if (syscall == "mq_close") {
1703 pcmd("/* Nothing to do */")
1704 } else if (syscall == "mq_unlink") {
1705 if (mode == "pre") {
1706 pcmd("const char *name = (const char *)name_;")
1707 pcmd("if (name) {")
1708 pcmd(" PRE_READ(name, __sanitizer::internal_strlen(name) + 1);")
1709 pcmd("}")
1710 } else {
1711 pcmd("const char *name = (const char *)name_;")
1712 pcmd("if (name) {")
1713 pcmd(" POST_READ(name, __sanitizer::internal_strlen(name) + 1);")
1714 pcmd("}")
1715 }
1716 } else if (syscall == "mq_getattr") {
1717 pcmd("/* Nothing to do */")
1718 } else if (syscall == "mq_setattr") {
1719 if (mode == "pre") {
1720 pcmd("if (mqstat_) {")
1721 pcmd(" PRE_READ(mqstat_, struct_mq_attr_sz);")
1722 pcmd("}")
1723 }
1724 } else if (syscall == "mq_notify") {
1725 if (mode == "pre") {
1726 pcmd("if (notification_) {")
1727 pcmd(" PRE_READ(notification_, struct_sigevent_sz);")
1728 pcmd("}")
1729 }
1730 } else if (syscall == "mq_send") {
1731 if (mode == "pre") {
1732 pcmd("if (msg_ptr_) {")
1733 pcmd(" PRE_READ(msg_ptr_, msg_len_);")
1734 pcmd("}")
1735 }
1736 } else if (syscall == "mq_receive") {
1737 pcmd("/* Nothing to do */")
1738 } else if (syscall == "compat_50_mq_timedsend") {
1739 pcmd("/* TODO */")
1740 } else if (syscall == "compat_50_mq_timedreceive") {
1741 pcmd("/* TODO */")
1742 } else if (syscall == "__posix_rename") {
1743 if (mode == "pre") {
1744 pcmd("const char *from = (const char *)from_;")
1745 pcmd("const char *to = (const char *)to_;")
1746 pcmd("if (from_) {")
1747 pcmd(" PRE_READ(from, __sanitizer::internal_strlen(from) + 1);")
1748 pcmd("}")
1749 pcmd("if (to) {")
1750 pcmd(" PRE_READ(to, __sanitizer::internal_strlen(to) + 1);")
1751 pcmd("}")
1752 } else {
1753 pcmd("const char *from = (const char *)from_;")
1754 pcmd("const char *to = (const char *)to_;")
1755 pcmd("if (from) {")
1756 pcmd(" POST_READ(from, __sanitizer::internal_strlen(from) + 1);")
1757 pcmd("}")
1758 pcmd("if (to) {")
1759 pcmd(" POST_READ(to, __sanitizer::internal_strlen(to) + 1);")
1760 pcmd("}")
1761 }
1762 } else if (syscall == "swapctl") {
1763 pcmd("/* TODO */")
1764 } else if (syscall == "compat_30_getdents") {
1765 pcmd("/* TODO */")
1766 } else if (syscall == "minherit") {
1767 pcmd("/* Nothing to do */")
1768 } else if (syscall == "lchmod") {
1769 if (mode == "pre") {
1770 pcmd("const char *path = (const char *)path_;")
1771 pcmd("if (path) {")
1772 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
1773 pcmd("}")
1774 } else {
1775 pcmd("const char *path = (const char *)path_;")
1776 pcmd("if (path) {")
1777 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
1778 pcmd("}")
1779 }
1780 } else if (syscall == "lchown") {
1781 if (mode == "pre") {
1782 pcmd("const char *path = (const char *)path_;")
1783 pcmd("if (path) {")
1784 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
1785 pcmd("}")
1786 } else {
1787 pcmd("const char *path = (const char *)path_;")
1788 pcmd("if (path) {")
1789 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
1790 pcmd("}")
1791 }
1792 } else if (syscall == "compat_50_lutimes") {
1793 pcmd("/* TODO */")
1794 } else if (syscall == "__msync13") {
1795 pcmd("/* Nothing to do */")
1796 } else if (syscall == "compat_30___stat13") {
1797 pcmd("/* TODO */")
1798 } else if (syscall == "compat_30___fstat13") {
1799 pcmd("/* TODO */")
1800 } else if (syscall == "compat_30___lstat13") {
1801 pcmd("/* TODO */")
1802 } else if (syscall == "__sigaltstack14") {
1803 if (mode == "pre") {
1804 pcmd("if (nss_) {")
1805 pcmd(" PRE_READ(nss_, struct_sigaltstack_sz);")
1806 pcmd("}")
1807 pcmd("if (oss_) {")
1808 pcmd(" PRE_READ(oss_, struct_sigaltstack_sz);")
1809 pcmd("}")
1810 }
1811 } else if (syscall == "__vfork14") {
1812 pcmd("/* Nothing to do */")
1813 } else if (syscall == "__posix_chown") {
1814 if (mode == "pre") {
1815 pcmd("const char *path = (const char *)path_;")
1816 pcmd("if (path) {")
1817 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
1818 pcmd("}")
1819 } else {
1820 pcmd("const char *path = (const char *)path_;")
1821 pcmd("if (path) {")
1822 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
1823 pcmd("}")
1824 }
1825 } else if (syscall == "__posix_fchown") {
1826 pcmd("/* Nothing to do */")
1827 } else if (syscall == "__posix_lchown") {
1828 if (mode == "pre") {
1829 pcmd("const char *path = (const char *)path_;")
1830 pcmd("if (path) {")
1831 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
1832 pcmd("}")
1833 } else {
1834 pcmd("const char *path = (const char *)path_;")
1835 pcmd("if (path) {")
1836 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
1837 pcmd("}")
1838 }
1839 } else if (syscall == "getsid") {
1840 pcmd("/* Nothing to do */")
1841 } else if (syscall == "__clone") {
1842 pcmd("/* Nothing to do */")
1843 } else if (syscall == "fktrace") {
1844 pcmd("/* Nothing to do */")
1845 } else if (syscall == "preadv") {
1846 pcmd("/* Nothing to do */")
1847 } else if (syscall == "pwritev") {
1848 pcmd("/* Nothing to do */")
1849 } else if (syscall == "compat_16___sigaction14") {
1850 pcmd("/* TODO */")
1851 } else if (syscall == "__sigpending14") {
1852 pcmd("/* Nothing to do */")
1853 } else if (syscall == "__sigprocmask14") {
1854 pcmd("/* Nothing to do */")
1855 } else if (syscall == "__sigsuspend14") {
1856 pcmd("if (set_) {")
1857 pcmd(" PRE_READ(set_, sizeof(__sanitizer_sigset_t));")
1858 pcmd("}")
1859 } else if (syscall == "compat_16___sigreturn14") {
1860 pcmd("/* TODO */")
1861 } else if (syscall == "__getcwd") {
1862 pcmd("/* Nothing to do */")
1863 } else if (syscall == "fchroot") {
1864 pcmd("/* Nothing to do */")
1865 } else if (syscall == "compat_30_fhopen") {
1866 pcmd("/* TODO */")
1867 } else if (syscall == "compat_30_fhstat") {
1868 pcmd("/* TODO */")
1869 } else if (syscall == "compat_20_fhstatfs") {
1870 pcmd("/* TODO */")
1871 } else if (syscall == "compat_50_____semctl13") {
1872 pcmd("/* TODO */")
1873 } else if (syscall == "compat_50___msgctl13") {
1874 pcmd("/* TODO */")
1875 } else if (syscall == "compat_50___shmctl13") {
1876 pcmd("/* TODO */")
1877 } else if (syscall == "lchflags") {
1878 if (mode == "pre") {
1879 pcmd("const char *path = (const char *)path_;")
1880 pcmd("if (path) {")
1881 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
1882 pcmd("}")
1883 } else {
1884 pcmd("const char *path = (const char *)path_;")
1885 pcmd("if (path) {")
1886 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
1887 pcmd("}")
1888 }
1889 } else if (syscall == "issetugid") {
1890 pcmd("/* Nothing to do */")
1891 } else if (syscall == "utrace") {
1892 if (mode == "pre") {
1893 pcmd("const char *label = (const char *)label_;")
1894 pcmd("if (label) {")
1895 pcmd(" PRE_READ(label, __sanitizer::internal_strlen(label) + 1);")
1896 pcmd("}")
1897 pcmd("if (addr_) {")
1898 pcmd(" PRE_READ(addr_, len_);")
1899 pcmd("}")
1900 } else {
1901 pcmd("const char *label = (const char *)label_;")
1902 pcmd("if (label) {")
1903 pcmd(" POST_READ(label, __sanitizer::internal_strlen(label) + 1);")
1904 pcmd("}")
1905 pcmd("if (addr_) {")
1906 pcmd(" POST_READ(addr_, len_);")
1907 pcmd("}")
1908 }
1909 } else if (syscall == "getcontext") {
1910 pcmd("/* Nothing to do */")
1911 } else if (syscall == "setcontext") {
1912 if (mode == "pre") {
1913 pcmd("if (ucp_) {")
1914 pcmd(" PRE_READ(ucp_, ucontext_t_sz);")
1915 pcmd("}")
1916 }
1917 } else if (syscall == "_lwp_create") {
1918 if (mode == "pre") {
1919 pcmd("if (ucp_) {")
1920 pcmd(" PRE_READ(ucp_, ucontext_t_sz);")
1921 pcmd("}")
1922 }
1923 } else if (syscall == "_lwp_exit") {
1924 pcmd("/* Nothing to do */")
1925 } else if (syscall == "_lwp_self") {
1926 pcmd("/* Nothing to do */")
1927 } else if (syscall == "_lwp_wait") {
1928 pcmd("/* Nothing to do */")
1929 } else if (syscall == "_lwp_suspend") {
1930 pcmd("/* Nothing to do */")
1931 } else if (syscall == "_lwp_continue") {
1932 pcmd("/* Nothing to do */")
1933 } else if (syscall == "_lwp_wakeup") {
1934 pcmd("/* Nothing to do */")
1935 } else if (syscall == "_lwp_getprivate") {
1936 pcmd("/* Nothing to do */")
1937 } else if (syscall == "_lwp_setprivate") {
1938 pcmd("/* Nothing to do */")
1939 } else if (syscall == "_lwp_kill") {
1940 pcmd("/* Nothing to do */")
1941 } else if (syscall == "_lwp_detach") {
1942 pcmd("/* Nothing to do */")
1943 } else if (syscall == "compat_50__lwp_park") {
1944 pcmd("/* TODO */")
1945 } else if (syscall == "_lwp_unpark") {
1946 pcmd("/* Nothing to do */")
1947 } else if (syscall == "_lwp_unpark_all") {
1948 if (mode == "pre") {
1949 pcmd("if (targets_) {")
1950 pcmd(" PRE_READ(targets_, ntargets_ * sizeof(__sanitizer_lwpid_t));")
1951 pcmd("}")
1952 }
1953 } else if (syscall == "_lwp_setname") {
1954 if (mode == "pre") {
1955 pcmd("const char *name = (const char *)name_;")
1956 pcmd("if (name) {")
1957 pcmd(" PRE_READ(name, __sanitizer::internal_strlen(name) + 1);")
1958 pcmd("}")
1959 } else {
1960 pcmd("const char *name = (const char *)name_;")
1961 pcmd("if (name) {")
1962 pcmd(" POST_READ(name, __sanitizer::internal_strlen(name) + 1);")
1963 pcmd("}")
1964 }
1965 } else if (syscall == "_lwp_getname") {
1966 pcmd("/* Nothing to do */")
1967 } else if (syscall == "_lwp_ctl") {
1968 pcmd("/* Nothing to do */")
1969 } else if (syscall == "compat_60_sa_register") {
1970 pcmd("/* TODO */")
1971 } else if (syscall == "compat_60_sa_stacks") {
1972 pcmd("/* TODO */")
1973 } else if (syscall == "compat_60_sa_enable") {
1974 pcmd("/* TODO */")
1975 } else if (syscall == "compat_60_sa_setconcurrency") {
1976 pcmd("/* TODO */")
1977 } else if (syscall == "compat_60_sa_yield") {
1978 pcmd("/* TODO */")
1979 } else if (syscall == "compat_60_sa_preempt") {
1980 pcmd("/* TODO */")
1981 } else if (syscall == "__sigaction_sigtramp") {
1982 pcmd("if (nsa_) {")
1983 pcmd(" PRE_READ(nsa_, sizeof(__sanitizer_sigaction));")
1984 pcmd("}")
1985 } else if (syscall == "pmc_get_info") {
1986 pcmd("/* TODO */")
1987 } else if (syscall == "pmc_control") {
1988 pcmd("/* TODO */")
1989 } else if (syscall == "rasctl") {
1990 pcmd("/* Nothing to do */")
1991 } else if (syscall == "kqueue") {
1992 pcmd("/* Nothing to do */")
1993 } else if (syscall == "compat_50_kevent") {
1994 pcmd("/* TODO */")
1995 } else if (syscall == "_sched_setparam") {
1996 pcmd("if (params_) {")
1997 pcmd(" PRE_READ(params_, struct_sched_param_sz);")
1998 pcmd("}")
1999 } else if (syscall == "_sched_getparam") {
2000 pcmd("/* Nothing to do */")
2001 } else if (syscall == "_sched_setaffinity") {
2002 pcmd("if (cpuset_) {")
2003 pcmd(" PRE_READ(cpuset_, size_);")
2004 pcmd("}")
2005 } else if (syscall == "_sched_getaffinity") {
2006 pcmd("/* Nothing to do */")
2007 } else if (syscall == "sched_yield") {
2008 pcmd("/* Nothing to do */")
2009 } else if (syscall == "_sched_protect") {
2010 pcmd("/* Nothing to do */")
2011 } else if (syscall == "fsync_range") {
2012 pcmd("/* Nothing to do */")
2013 } else if (syscall == "uuidgen") {
2014 pcmd("/* Nothing to do */")
2015 } else if (syscall == "getvfsstat") {
2016 pcmd("/* Nothing to do */")
2017 } else if (syscall == "statvfs1") {
2018 if (mode == "pre") {
2019 pcmd("const char *path = (const char *)path_;")
2020 pcmd("if (path) {")
2021 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
2022 pcmd("}")
2023 } else {
2024 pcmd("const char *path = (const char *)path_;")
2025 pcmd("if (path) {")
2026 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
2027 pcmd("}")
2028 }
2029 } else if (syscall == "fstatvfs1") {
2030 pcmd("/* Nothing to do */")
2031 } else if (syscall == "compat_30_fhstatvfs1") {
2032 pcmd("/* TODO */")
2033 } else if (syscall == "extattrctl") {
2034 if (mode == "pre") {
2035 pcmd("const char *path = (const char *)path_;")
2036 pcmd("if (path) {")
2037 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
2038 pcmd("}")
2039 } else {
2040 pcmd("const char *path = (const char *)path_;")
2041 pcmd("if (path) {")
2042 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
2043 pcmd("}")
2044 }
2045 } else if (syscall == "extattr_set_file") {
2046 if (mode == "pre") {
2047 pcmd("const char *path = (const char *)path_;")
2048 pcmd("if (path) {")
2049 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
2050 pcmd("}")
2051 } else {
2052 pcmd("const char *path = (const char *)path_;")
2053 pcmd("if (path) {")
2054 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
2055 pcmd("}")
2056 }
2057 } else if (syscall == "extattr_get_file") {
2058 if (mode == "pre") {
2059 pcmd("const char *path = (const char *)path_;")
2060 pcmd("if (path) {")
2061 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
2062 pcmd("}")
2063 } else {
2064 pcmd("const char *path = (const char *)path_;")
2065 pcmd("if (path) {")
2066 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
2067 pcmd("}")
2068 }
2069 } else if (syscall == "extattr_delete_file") {
2070 if (mode == "pre") {
2071 pcmd("const char *path = (const char *)path_;")
2072 pcmd("if (path) {")
2073 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
2074 pcmd("}")
2075 } else {
2076 pcmd("const char *path = (const char *)path_;")
2077 pcmd("if (path) {")
2078 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
2079 pcmd("}")
2080 }
2081 } else if (syscall == "extattr_set_fd") {
2082 pcmd("/* TODO */")
2083 } else if (syscall == "extattr_get_fd") {
2084 pcmd("/* TODO */")
2085 } else if (syscall == "extattr_delete_fd") {
2086 pcmd("/* TODO */")
2087 } else if (syscall == "extattr_set_link") {
2088 if (mode == "pre") {
2089 pcmd("const char *path = (const char *)path_;")
2090 pcmd("if (path) {")
2091 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
2092 pcmd("}")
2093 } else {
2094 pcmd("const char *path = (const char *)path_;")
2095 pcmd("if (path) {")
2096 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
2097 pcmd("}")
2098 }
2099 } else if (syscall == "extattr_get_link") {
2100 if (mode == "pre") {
2101 pcmd("const char *path = (const char *)path_;")
2102 pcmd("if (path) {")
2103 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
2104 pcmd("}")
2105 } else {
2106 pcmd("const char *path = (const char *)path_;")
2107 pcmd("if (path) {")
2108 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
2109 pcmd("}")
2110 }
2111 } else if (syscall == "extattr_delete_link") {
2112 if (mode == "pre") {
2113 pcmd("const char *path = (const char *)path_;")
2114 pcmd("if (path) {")
2115 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
2116 pcmd("}")
2117 } else {
2118 pcmd("const char *path = (const char *)path_;")
2119 pcmd("if (path) {")
2120 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
2121 pcmd("}")
2122 }
2123 } else if (syscall == "extattr_list_fd") {
2124 pcmd("/* TODO */")
2125 } else if (syscall == "extattr_list_file") {
2126 if (mode == "pre") {
2127 pcmd("const char *path = (const char *)path_;")
2128 pcmd("if (path) {")
2129 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
2130 pcmd("}")
2131 } else {
2132 pcmd("const char *path = (const char *)path_;")
2133 pcmd("if (path) {")
2134 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
2135 pcmd("}")
2136 }
2137 } else if (syscall == "extattr_list_link") {
2138 if (mode == "pre") {
2139 pcmd("const char *path = (const char *)path_;")
2140 pcmd("if (path) {")
2141 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
2142 pcmd("}")
2143 } else {
2144 pcmd("const char *path = (const char *)path_;")
2145 pcmd("if (path) {")
2146 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
2147 pcmd("}")
2148 }
2149 } else if (syscall == "compat_50_pselect") {
2150 pcmd("/* TODO */")
2151 } else if (syscall == "compat_50_pollts") {
2152 pcmd("/* TODO */")
2153 } else if (syscall == "setxattr") {
2154 if (mode == "pre") {
2155 pcmd("const char *path = (const char *)path_;")
2156 pcmd("if (path) {")
2157 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
2158 pcmd("}")
2159 } else {
2160 pcmd("const char *path = (const char *)path_;")
2161 pcmd("if (path) {")
2162 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
2163 pcmd("}")
2164 }
2165 } else if (syscall == "lsetxattr") {
2166 if (mode == "pre") {
2167 pcmd("const char *path = (const char *)path_;")
2168 pcmd("if (path) {")
2169 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
2170 pcmd("}")
2171 } else {
2172 pcmd("const char *path = (const char *)path_;")
2173 pcmd("if (path) {")
2174 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
2175 pcmd("}")
2176 }
2177 } else if (syscall == "fsetxattr") {
2178 pcmd("/* Nothing to do */")
2179 } else if (syscall == "getxattr") {
2180 if (mode == "pre") {
2181 pcmd("const char *path = (const char *)path_;")
2182 pcmd("if (path) {")
2183 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
2184 pcmd("}")
2185 } else {
2186 pcmd("const char *path = (const char *)path_;")
2187 pcmd("if (path) {")
2188 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
2189 pcmd("}")
2190 }
2191 } else if (syscall == "lgetxattr") {
2192 if (mode == "pre") {
2193 pcmd("const char *path = (const char *)path_;")
2194 pcmd("if (path) {")
2195 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
2196 pcmd("}")
2197 } else {
2198 pcmd("const char *path = (const char *)path_;")
2199 pcmd("if (path) {")
2200 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
2201 pcmd("}")
2202 }
2203 } else if (syscall == "fgetxattr") {
2204 pcmd("/* Nothing to do */")
2205 } else if (syscall == "listxattr") {
2206 if (mode == "pre") {
2207 pcmd("const char *path = (const char *)path_;")
2208 pcmd("if (path) {")
2209 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
2210 pcmd("}")
2211 } else {
2212 pcmd("const char *path = (const char *)path_;")
2213 pcmd("if (path) {")
2214 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
2215 pcmd("}")
2216 }
2217 } else if (syscall == "llistxattr") {
2218 if (mode == "pre") {
2219 pcmd("const char *path = (const char *)path_;")
2220 pcmd("if (path) {")
2221 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
2222 pcmd("}")
2223 } else {
2224 pcmd("const char *path = (const char *)path_;")
2225 pcmd("if (path) {")
2226 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
2227 pcmd("}")
2228 }
2229 } else if (syscall == "flistxattr") {
2230 pcmd("/* TODO */")
2231 } else if (syscall == "removexattr") {
2232 if (mode == "pre") {
2233 pcmd("const char *path = (const char *)path_;")
2234 pcmd("if (path) {")
2235 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
2236 pcmd("}")
2237 } else {
2238 pcmd("const char *path = (const char *)path_;")
2239 pcmd("if (path) {")
2240 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
2241 pcmd("}")
2242 }
2243 } else if (syscall == "lremovexattr") {
2244 if (mode == "pre") {
2245 pcmd("const char *path = (const char *)path_;")
2246 pcmd("if (path) {")
2247 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
2248 pcmd("}")
2249 } else {
2250 pcmd("const char *path = (const char *)path_;")
2251 pcmd("if (path) {")
2252 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
2253 pcmd("}")
2254 }
2255 } else if (syscall == "fremovexattr") {
2256 pcmd("/* TODO */")
2257 } else if (syscall == "compat_50___stat30") {
2258 pcmd("/* TODO */")
2259 } else if (syscall == "compat_50___fstat30") {
2260 pcmd("/* TODO */")
2261 } else if (syscall == "compat_50___lstat30") {
2262 pcmd("/* TODO */")
2263 } else if (syscall == "__getdents30") {
2264 pcmd("/* Nothing to do */")
2265 } else if (syscall == "posix_fadvise") {
2266 pcmd("/* Nothing to do */")
2267 } else if (syscall == "compat_30___fhstat30") {
2268 pcmd("/* TODO */")
2269 } else if (syscall == "compat_50___ntp_gettime30") {
2270 pcmd("/* TODO */")
2271 } else if (syscall == "__socket30") {
2272 pcmd("/* Nothing to do */")
2273 } else if (syscall == "__getfh30") {
2274 if (mode == "pre") {
2275 pcmd("const char *fname = (const char *)fname_;")
2276 pcmd("if (fname) {")
2277 pcmd(" PRE_READ(fname, __sanitizer::internal_strlen(fname) + 1);")
2278 pcmd("}")
2279 } else {
2280 pcmd("const char *fname = (const char *)fname_;")
2281 pcmd("if (res == 0) {")
2282 pcmd(" if (fname) {")
2283 pcmd(" POST_READ(fname, __sanitizer::internal_strlen(fname) + 1);")
2284 pcmd(" }")
2285 pcmd("}")
2286 }
2287 } else if (syscall == "__fhopen40") {
2288 if (mode == "pre") {
2289 pcmd("if (fhp_) {")
2290 pcmd(" PRE_READ(fhp_, fh_size_);")
2291 pcmd("}")
2292 }
2293 } else if (syscall == "__fhstatvfs140") {
2294 if (mode == "pre") {
2295 pcmd("if (fhp_) {")
2296 pcmd(" PRE_READ(fhp_, fh_size_);")
2297 pcmd("}")
2298 }
2299 } else if (syscall == "compat_50___fhstat40") {
2300 if (mode == "pre") {
2301 pcmd("if (fhp_) {")
2302 pcmd(" PRE_READ(fhp_, fh_size_);")
2303 pcmd("}")
2304 }
2305 } else if (syscall == "aio_cancel") {
2306 if (mode == "pre") {
2307 pcmd("if (aiocbp_) {")
2308 pcmd(" PRE_READ(aiocbp_, sizeof(struct __sanitizer_aiocb));")
2309 pcmd("}")
2310 }
2311 } else if (syscall == "aio_error") {
2312 if (mode == "pre") {
2313 pcmd("if (aiocbp_) {")
2314 pcmd(" PRE_READ(aiocbp_, sizeof(struct __sanitizer_aiocb));")
2315 pcmd("}")
2316 }
2317 } else if (syscall == "aio_fsync") {
2318 if (mode == "pre") {
2319 pcmd("if (aiocbp_) {")
2320 pcmd(" PRE_READ(aiocbp_, sizeof(struct __sanitizer_aiocb));")
2321 pcmd("}")
2322 }
2323 } else if (syscall == "aio_read") {
2324 if (mode == "pre") {
2325 pcmd("if (aiocbp_) {")
2326 pcmd(" PRE_READ(aiocbp_, sizeof(struct __sanitizer_aiocb));")
2327 pcmd("}")
2328 }
2329 } else if (syscall == "aio_return") {
2330 if (mode == "pre") {
2331 pcmd("if (aiocbp_) {")
2332 pcmd(" PRE_READ(aiocbp_, sizeof(struct __sanitizer_aiocb));")
2333 pcmd("}")
2334 }
2335 } else if (syscall == "compat_50_aio_suspend") {
2336 pcmd("/* TODO */")
2337 } else if (syscall == "aio_write") {
2338 if (mode == "pre") {
2339 pcmd("if (aiocbp_) {")
2340 pcmd(" PRE_READ(aiocbp_, sizeof(struct __sanitizer_aiocb));")
2341 pcmd("}")
2342 }
2343 } else if (syscall == "lio_listio") {
2344 pcmd("/* Nothing to do */")
2345 } else if (syscall == "__mount50") {
2346 if (mode == "pre") {
2347 pcmd("const char *type = (const char *)type_;")
2348 pcmd("const char *path = (const char *)path_;")
2349 pcmd("if (type) {")
2350 pcmd(" PRE_READ(type, __sanitizer::internal_strlen(type) + 1);")
2351 pcmd("}")
2352 pcmd("if (path) {")
2353 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
2354 pcmd("}")
2355 pcmd("if (data_) {")
2356 pcmd(" PRE_READ(data_, data_len_);")
2357 pcmd("}")
2358 } else {
2359 pcmd("const char *type = (const char *)type_;")
2360 pcmd("const char *path = (const char *)path_;")
2361 pcmd("if (type) {")
2362 pcmd(" POST_READ(type, __sanitizer::internal_strlen(type) + 1);")
2363 pcmd("}")
2364 pcmd("if (path) {")
2365 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
2366 pcmd("}")
2367 pcmd("if (data_) {")
2368 pcmd(" POST_READ(data_, data_len_);")
2369 pcmd("}")
2370 }
2371 } else if (syscall == "mremap") {
2372 pcmd("/* Nothing to do */")
2373 } else if (syscall == "pset_create") {
2374 pcmd("/* Nothing to do */")
2375 } else if (syscall == "pset_destroy") {
2376 pcmd("/* Nothing to do */")
2377 } else if (syscall == "pset_assign") {
2378 pcmd("/* Nothing to do */")
2379 } else if (syscall == "_pset_bind") {
2380 pcmd("/* Nothing to do */")
2381 } else if (syscall == "__posix_fadvise50") {
2382 pcmd("/* Nothing to do */")
2383 } else if (syscall == "__select50") {
2384 pcmd("/* Nothing to do */")
2385 } else if (syscall == "__gettimeofday50") {
2386 pcmd("/* Nothing to do */")
2387 } else if (syscall == "__settimeofday50") {
2388 if (mode == "pre") {
2389 pcmd("if (tv_) {")
2390 pcmd(" PRE_READ(tv_, timeval_sz);")
2391 pcmd("}")
2392 pcmd("if (tzp_) {")
2393 pcmd(" PRE_READ(tzp_, struct_timezone_sz);")
2394 pcmd("}")
2395 }
2396 } else if (syscall == "__utimes50") {
2397 if (mode == "pre") {
2398 pcmd("struct __sanitizer_timespec **tptr = (struct __sanitizer_timespec **)tptr_;")
2399 pcmd("const char *path = (const char *)path_;")
2400 pcmd("if (path) {")
2401 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
2402 pcmd("}")
2403 pcmd("if (tptr) {")
2404 pcmd(" PRE_READ(tptr[0], struct_timespec_sz);")
2405 pcmd(" PRE_READ(tptr[1], struct_timespec_sz);")
2406 pcmd("}")
2407 }
2408 } else if (syscall == "__adjtime50") {
2409 if (mode == "pre") {
2410 pcmd("if (delta_) {")
2411 pcmd(" PRE_READ(delta_, timeval_sz);")
2412 pcmd("}")
2413 }
2414 } else if (syscall == "__lfs_segwait50") {
2415 pcmd("/* TODO */")
2416 } else if (syscall == "__futimes50") {
2417 if (mode == "pre") {
2418 pcmd("struct __sanitizer_timespec **tptr = (struct __sanitizer_timespec **)tptr_;")
2419 pcmd("if (tptr) {")
2420 pcmd(" PRE_READ(tptr[0], struct_timespec_sz);")
2421 pcmd(" PRE_READ(tptr[1], struct_timespec_sz);")
2422 pcmd("}")
2423 }
2424 } else if (syscall == "__lutimes50") {
2425 if (mode == "pre") {
2426 pcmd("struct __sanitizer_timespec **tptr = (struct __sanitizer_timespec **)tptr_;")
2427 pcmd("const char *path = (const char *)path_;")
2428 pcmd("if (path) {")
2429 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
2430 pcmd("}")
2431 pcmd("if (tptr) {")
2432 pcmd(" PRE_READ(tptr[0], struct_timespec_sz);")
2433 pcmd(" PRE_READ(tptr[1], struct_timespec_sz);")
2434 pcmd("}")
2435 } else {
2436 pcmd("struct __sanitizer_timespec **tptr = (struct __sanitizer_timespec **)tptr_;")
2437 pcmd("const char *path = (const char *)path_;")
2438 pcmd("if (path) {")
2439 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
2440 pcmd("}")
2441 pcmd("if (tptr) {")
2442 pcmd(" POST_READ(tptr[0], struct_timespec_sz);")
2443 pcmd(" POST_READ(tptr[1], struct_timespec_sz);")
2444 pcmd("}")
2445 }
2446 } else if (syscall == "__setitimer50") {
2447 if (mode == "pre") {
2448 pcmd("struct __sanitizer_itimerval *itv = (struct __sanitizer_itimerval *)itv_;")
2449 pcmd("if (itv) {")
2450 pcmd(" PRE_READ(&itv->it_interval.tv_sec, sizeof(__sanitizer_time_t));")
2451 pcmd(" PRE_READ(&itv->it_interval.tv_usec, sizeof(__sanitizer_suseconds_t));")
2452 pcmd(" PRE_READ(&itv->it_value.tv_sec, sizeof(__sanitizer_time_t));")
2453 pcmd(" PRE_READ(&itv->it_value.tv_usec, sizeof(__sanitizer_suseconds_t));")
2454 pcmd("}")
2455 }
2456 } else if (syscall == "__getitimer50") {
2457 pcmd("/* Nothing to do */")
2458 } else if (syscall == "__clock_gettime50") {
2459 pcmd("/* Nothing to do */")
2460 } else if (syscall == "__clock_settime50") {
2461 if (mode == "pre") {
2462 pcmd("if (tp_) {")
2463 pcmd(" PRE_READ(tp_, struct_timespec_sz);")
2464 pcmd("}")
2465 }
2466 } else if (syscall == "__clock_getres50") {
2467 pcmd("/* Nothing to do */")
2468 } else if (syscall == "__nanosleep50") {
2469 if (mode == "pre") {
2470 pcmd("if (rqtp_) {")
2471 pcmd(" PRE_READ(rqtp_, struct_timespec_sz);")
2472 pcmd("}")
2473 }
2474 } else if (syscall == "____sigtimedwait50") {
2475 if (mode == "pre") {
2476 pcmd("if (set_) {")
2477 pcmd(" PRE_READ(set_, sizeof(__sanitizer_sigset_t));")
2478 pcmd("}")
2479 pcmd("if (timeout_) {")
2480 pcmd(" PRE_READ(timeout_, struct_timespec_sz);")
2481 pcmd("}")
2482 }
2483 } else if (syscall == "__mq_timedsend50") {
2484 if (mode == "pre") {
2485 pcmd("if (msg_ptr_) {")
2486 pcmd(" PRE_READ(msg_ptr_, msg_len_);")
2487 pcmd("}")
2488 pcmd("if (abs_timeout_) {")
2489 pcmd(" PRE_READ(abs_timeout_, struct_timespec_sz);")
2490 pcmd("}")
2491 }
2492 } else if (syscall == "__mq_timedreceive50") {
2493 if (mode == "pre") {
2494 pcmd("if (msg_ptr_) {")
2495 pcmd(" PRE_READ(msg_ptr_, msg_len_);")
2496 pcmd("}")
2497 pcmd("if (abs_timeout_) {")
2498 pcmd(" PRE_READ(abs_timeout_, struct_timespec_sz);")
2499 pcmd("}")
2500 }
2501 } else if (syscall == "compat_60__lwp_park") {
2502 pcmd("/* TODO */")
2503 } else if (syscall == "__kevent50") {
2504 if (mode == "pre") {
2505 pcmd("if (changelist_) {")
2506 pcmd(" PRE_READ(changelist_, nchanges_ * struct_kevent_sz);")
2507 pcmd("}")
2508 pcmd("if (timeout_) {")
2509 pcmd(" PRE_READ(timeout_, struct_timespec_sz);")
2510 pcmd("}")
2511 }
2512 } else if (syscall == "__pselect50") {
2513 if (mode == "pre") {
2514 pcmd("if (ts_) {")
2515 pcmd(" PRE_READ(ts_, struct_timespec_sz);")
2516 pcmd("}")
2517 pcmd("if (mask_) {")
2518 pcmd(" PRE_READ(mask_, sizeof(struct __sanitizer_sigset_t));")
2519 pcmd("}")
2520 }
2521 } else if (syscall == "__pollts50") {
2522 if (mode == "pre") {
2523 pcmd("if (ts_) {")
2524 pcmd(" PRE_READ(ts_, struct_timespec_sz);")
2525 pcmd("}")
2526 pcmd("if (mask_) {")
2527 pcmd(" PRE_READ(mask_, sizeof(struct __sanitizer_sigset_t));")
2528 pcmd("}")
2529 }
2530 } else if (syscall == "__aio_suspend50") {
2531 if (mode == "pre") {
2532 pcmd("int i;")
2533 pcmd("const struct aiocb * const *list = (const struct aiocb * const *)list_;")
2534 pcmd("if (list) {")
2535 pcmd(" for (i = 0; i < nent_; i++) {")
2536 pcmd(" if (list[i]) {")
2537 pcmd(" PRE_READ(list[i], sizeof(struct __sanitizer_aiocb));")
2538 pcmd(" }")
2539 pcmd(" }")
2540 pcmd("}")
2541 pcmd("if (timeout_) {")
2542 pcmd(" PRE_READ(timeout_, struct_timespec_sz);")
2543 pcmd("}")
2544 }
2545 } else if (syscall == "__stat50") {
2546 if (mode == "pre") {
2547 pcmd("const char *path = (const char *)path_;")
2548 pcmd("if (path) {")
2549 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
2550 pcmd("}")
2551 } else {
2552 pcmd("const char *path = (const char *)path_;")
2553 pcmd("if (res == 0) {")
2554 pcmd(" if (path) {")
2555 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
2556 pcmd(" }")
2557 pcmd("}")
2558 }
2559 } else if (syscall == "__fstat50") {
2560 pcmd("/* Nothing to do */")
2561 } else if (syscall == "__lstat50") {
2562 if (mode == "pre") {
2563 pcmd("const char *path = (const char *)path_;")
2564 pcmd("if (path) {")
2565 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
2566 pcmd("}")
2567 } else {
2568 pcmd("const char *path = (const char *)path_;")
2569 pcmd("if (res == 0) {")
2570 pcmd(" if (path) {")
2571 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
2572 pcmd(" }")
2573 pcmd("}")
2574 }
2575 } else if (syscall == "____semctl50") {
2576 pcmd("/* Nothing to do */")
2577 } else if (syscall == "__shmctl50") {
2578 pcmd("/* Nothing to do */")
2579 } else if (syscall == "__msgctl50") {
2580 pcmd("/* Nothing to do */")
2581 } else if (syscall == "__getrusage50") {
2582 pcmd("/* Nothing to do */")
2583 } else if (syscall == "__timer_settime50") {
2584 if (mode == "pre") {
2585 pcmd("struct __sanitizer_itimerval *value = (struct __sanitizer_itimerval *)value_;")
2586 pcmd("if (value) {")
2587 pcmd(" PRE_READ(&value->it_interval.tv_sec, sizeof(__sanitizer_time_t));")
2588 pcmd(" PRE_READ(&value->it_interval.tv_usec, sizeof(__sanitizer_suseconds_t));")
2589 pcmd(" PRE_READ(&value->it_value.tv_sec, sizeof(__sanitizer_time_t));")
2590 pcmd(" PRE_READ(&value->it_value.tv_usec, sizeof(__sanitizer_suseconds_t));")
2591 pcmd("}")
2592 } else {
2593 pcmd("struct __sanitizer_itimerval *value = (struct __sanitizer_itimerval *)value_;")
2594 pcmd("if (res == 0) {")
2595 pcmd(" if (value) {")
2596 pcmd(" POST_READ(&value->it_interval.tv_sec, sizeof(__sanitizer_time_t));")
2597 pcmd(" POST_READ(&value->it_interval.tv_usec, sizeof(__sanitizer_suseconds_t));")
2598 pcmd(" POST_READ(&value->it_value.tv_sec, sizeof(__sanitizer_time_t));")
2599 pcmd(" POST_READ(&value->it_value.tv_usec, sizeof(__sanitizer_suseconds_t));")
2600 pcmd(" }")
2601 pcmd("}")
2602 }
2603 } else if (syscall == "__timer_gettime50") {
2604 pcmd("/* Nothing to do */")
2605 } else if (syscall == "__ntp_gettime50") {
2606 pcmd("/* Nothing to do */")
2607 } else if (syscall == "__wait450") {
2608 pcmd("/* Nothing to do */")
2609 } else if (syscall == "__mknod50") {
2610 if (mode == "pre") {
2611 pcmd("const char *path = (const char *)path_;")
2612 pcmd("if (path) {")
2613 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
2614 pcmd("}")
2615 } else {
2616 pcmd("const char *path = (const char *)path_;")
2617 pcmd("if (res == 0) {")
2618 pcmd(" if (path) {")
2619 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
2620 pcmd(" }")
2621 pcmd("}")
2622 }
2623 } else if (syscall == "__fhstat50") {
2624 if (mode == "pre") {
2625 pcmd("if (fhp_) {")
2626 pcmd(" PRE_READ(fhp_, fh_size_);")
2627 pcmd("}")
2628 } else {
2629 pcmd("if (res == 0) {")
2630 pcmd(" if (fhp_) {")
2631 pcmd(" POST_READ(fhp_, fh_size_);")
2632 pcmd(" }")
2633 pcmd("}")
2634 }
2635 } else if (syscall == "pipe2") {
2636 pcmd("/* Nothing to do */")
2637 } else if (syscall == "dup3") {
2638 pcmd("/* Nothing to do */")
2639 } else if (syscall == "kqueue1") {
2640 pcmd("/* Nothing to do */")
2641 } else if (syscall == "paccept") {
2642 if (mode == "pre") {
2643 pcmd("if (mask_) {")
2644 pcmd(" PRE_READ(mask_, sizeof(__sanitizer_sigset_t));")
2645 pcmd("}")
2646 } else {
2647 pcmd("if (res >= 0) {")
2648 pcmd(" if (mask_) {")
2649 pcmd(" PRE_READ(mask_, sizeof(__sanitizer_sigset_t));")
2650 pcmd(" }")
2651 pcmd("}")
2652 }
2653 } else if (syscall == "linkat") {
2654 if (mode == "pre") {
2655 pcmd("const char *name1 = (const char *)name1_;")
2656 pcmd("const char *name2 = (const char *)name2_;")
2657 pcmd("if (name1) {")
2658 pcmd(" PRE_READ(name1, __sanitizer::internal_strlen(name1) + 1);")
2659 pcmd("}")
2660 pcmd("if (name2) {")
2661 pcmd(" PRE_READ(name2, __sanitizer::internal_strlen(name2) + 1);")
2662 pcmd("}")
2663 } else {
2664 pcmd("const char *name1 = (const char *)name1_;")
2665 pcmd("const char *name2 = (const char *)name2_;")
2666 pcmd("if (res == 0) {")
2667 pcmd(" if (name1) {")
2668 pcmd(" POST_READ(name1, __sanitizer::internal_strlen(name1) + 1);")
2669 pcmd(" }")
2670 pcmd(" if (name2) {")
2671 pcmd(" POST_READ(name2, __sanitizer::internal_strlen(name2) + 1);")
2672 pcmd(" }")
2673 pcmd("}")
2674 }
2675 } else if (syscall == "renameat") {
2676 if (mode == "pre") {
2677 pcmd("const char *from = (const char *)from_;")
2678 pcmd("const char *to = (const char *)to_;")
2679 pcmd("if (from) {")
2680 pcmd(" PRE_READ(from, __sanitizer::internal_strlen(from) + 1);")
2681 pcmd("}")
2682 pcmd("if (to) {")
2683 pcmd(" PRE_READ(to, __sanitizer::internal_strlen(to) + 1);")
2684 pcmd("}")
2685 } else {
2686 pcmd("const char *from = (const char *)from_;")
2687 pcmd("const char *to = (const char *)to_;")
2688 pcmd("if (res == 0) {")
2689 pcmd(" if (from) {")
2690 pcmd(" POST_READ(from, __sanitizer::internal_strlen(from) + 1);")
2691 pcmd(" }")
2692 pcmd(" if (to) {")
2693 pcmd(" POST_READ(to, __sanitizer::internal_strlen(to) + 1);")
2694 pcmd(" }")
2695 pcmd("}")
2696 }
2697 } else if (syscall == "mkfifoat") {
2698 if (mode == "pre") {
2699 pcmd("const char *path = (const char *)path_;")
2700 pcmd("if (path) {")
2701 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
2702 pcmd("}")
2703 } else {
2704 pcmd("const char *path = (const char *)path_;")
2705 pcmd("if (res == 0) {")
2706 pcmd(" if (path) {")
2707 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
2708 pcmd(" }")
2709 pcmd("}")
2710 }
2711 } else if (syscall == "mknodat") {
2712 if (mode == "pre") {
2713 pcmd("const char *path = (const char *)path_;")
2714 pcmd("if (path) {")
2715 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
2716 pcmd("}")
2717 } else {
2718 pcmd("const char *path = (const char *)path_;")
2719 pcmd("if (res == 0) {")
2720 pcmd(" if (path) {")
2721 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
2722 pcmd(" }")
2723 pcmd("}")
2724 }
2725 } else if (syscall == "mkdirat") {
2726 if (mode == "pre") {
2727 pcmd("const char *path = (const char *)path_;")
2728 pcmd("if (path) {")
2729 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
2730 pcmd("}")
2731 } else {
2732 pcmd("const char *path = (const char *)path_;")
2733 pcmd("if (res == 0) {")
2734 pcmd(" if (path) {")
2735 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
2736 pcmd(" }")
2737 pcmd("}")
2738 }
2739 } else if (syscall == "faccessat") {
2740 if (mode == "pre") {
2741 pcmd("const char *path = (const char *)path_;")
2742 pcmd("if (path) {")
2743 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
2744 pcmd("}")
2745 } else {
2746 pcmd("const char *path = (const char *)path_;")
2747 pcmd("if (res == 0) {")
2748 pcmd(" if (path) {")
2749 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
2750 pcmd(" }")
2751 pcmd("}")
2752 }
2753 } else if (syscall == "fchmodat") {
2754 if (mode == "pre") {
2755 pcmd("const char *path = (const char *)path_;")
2756 pcmd("if (path) {")
2757 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
2758 pcmd("}")
2759 } else {
2760 pcmd("const char *path = (const char *)path_;")
2761 pcmd("if (res == 0) {")
2762 pcmd(" if (path) {")
2763 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
2764 pcmd(" }")
2765 pcmd("}")
2766 }
2767 } else if (syscall == "fchownat") {
2768 if (mode == "pre") {
2769 pcmd("const char *path = (const char *)path_;")
2770 pcmd("if (path) {")
2771 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
2772 pcmd("}")
2773 } else {
2774 pcmd("const char *path = (const char *)path_;")
2775 pcmd("if (res == 0) {")
2776 pcmd(" if (path) {")
2777 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
2778 pcmd(" }")
2779 pcmd("}")
2780 }
2781 } else if (syscall == "fexecve") {
2782 pcmd("/* TODO */")
2783 } else if (syscall == "fstatat") {
2784 if (mode == "pre") {
2785 pcmd("const char *path = (const char *)path_;")
2786 pcmd("if (path) {")
2787 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
2788 pcmd("}")
2789 } else {
2790 pcmd("const char *path = (const char *)path_;")
2791 pcmd("if (path) {")
2792 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
2793 pcmd("}")
2794 }
2795 } else if (syscall == "utimensat") {
2796 if (mode == "pre") {
2797 pcmd("const char *path = (const char *)path_;")
2798 pcmd("if (path) {")
2799 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
2800 pcmd("}")
2801 pcmd("if (tptr_) {")
2802 pcmd(" PRE_READ(tptr_, struct_timespec_sz);")
2803 pcmd("}")
2804 } else {
2805 pcmd("const char *path = (const char *)path_;")
2806 pcmd("if (res > 0) {")
2807 pcmd(" if (path) {")
2808 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
2809 pcmd(" }")
2810 pcmd(" if (tptr_) {")
2811 pcmd(" POST_READ(tptr_, struct_timespec_sz);")
2812 pcmd(" }")
2813 pcmd("}")
2814 }
2815 } else if (syscall == "openat") {
2816 if (mode == "pre") {
2817 pcmd("const char *path = (const char *)path_;")
2818 pcmd("if (path) {")
2819 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
2820 pcmd("}")
2821 } else {
2822 pcmd("const char *path = (const char *)path_;")
2823 pcmd("if (res > 0) {")
2824 pcmd(" if (path) {")
2825 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
2826 pcmd(" }")
2827 pcmd("}")
2828 }
2829 } else if (syscall == "readlinkat") {
2830 if (mode == "pre") {
2831 pcmd("const char *path = (const char *)path_;")
2832 pcmd("if (path) {")
2833 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
2834 pcmd("}")
2835 } else {
2836 pcmd("const char *path = (const char *)path_;")
2837 pcmd("if (res > 0) {")
2838 pcmd(" if (path) {")
2839 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
2840 pcmd(" }")
2841 pcmd("}")
2842 }
2843 } else if (syscall == "symlinkat") {
2844 if (mode == "pre") {
2845 pcmd("const char *path1 = (const char *)path1_;")
2846 pcmd("const char *path2 = (const char *)path2_;")
2847 pcmd("if (path1) {")
2848 pcmd(" PRE_READ(path1, __sanitizer::internal_strlen(path1) + 1);")
2849 pcmd("}")
2850 pcmd("if (path2) {")
2851 pcmd(" PRE_READ(path2, __sanitizer::internal_strlen(path2) + 1);")
2852 pcmd("}")
2853 } else {
2854 pcmd("const char *path1 = (const char *)path1_;")
2855 pcmd("const char *path2 = (const char *)path2_;")
2856 pcmd("if (res == 0) {")
2857 pcmd(" if (path1) {")
2858 pcmd(" POST_READ(path1, __sanitizer::internal_strlen(path1) + 1);")
2859 pcmd(" }")
2860 pcmd(" if (path2) {")
2861 pcmd(" POST_READ(path2, __sanitizer::internal_strlen(path2) + 1);")
2862 pcmd(" }")
2863 pcmd("}")
2864 }
2865 } else if (syscall == "unlinkat") {
2866 if (mode == "pre") {
2867 pcmd("const char *path = (const char *)path_;")
2868 pcmd("if (path) {")
2869 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
2870 pcmd("}")
2871 } else {
2872 pcmd("const char *path = (const char *)path_;")
2873 pcmd("if (res == 0) {")
2874 pcmd(" if (path) {")
2875 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
2876 pcmd(" }")
2877 pcmd("}")
2878 }
2879 } else if (syscall == "futimens") {
2880 if (mode == "pre") {
2881 pcmd("struct __sanitizer_timespec **tptr = (struct __sanitizer_timespec **)tptr_;")
2882 pcmd("if (tptr) {")
2883 pcmd(" PRE_READ(tptr[0], struct_timespec_sz);")
2884 pcmd(" PRE_READ(tptr[1], struct_timespec_sz);")
2885 pcmd("}")
2886 } else {
2887 pcmd("struct __sanitizer_timespec **tptr = (struct __sanitizer_timespec **)tptr_;")
2888 pcmd("if (res == 0) {")
2889 pcmd(" if (tptr) {")
2890 pcmd(" POST_READ(tptr[0], struct_timespec_sz);")
2891 pcmd(" POST_READ(tptr[1], struct_timespec_sz);")
2892 pcmd(" }")
2893 pcmd("}")
2894 }
2895 } else if (syscall == "__quotactl") {
2896 if (mode == "pre") {
2897 pcmd("const char *path = (const char *)path_;")
2898 pcmd("if (path) {")
2899 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
2900 pcmd("}")
2901 } else {
2902 pcmd("const char *path = (const char *)path_;")
2903 pcmd("if (res == 0) {")
2904 pcmd(" if (path) {")
2905 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
2906 pcmd(" }")
2907 pcmd("}")
2908 }
2909 } else if (syscall == "posix_spawn") {
2910 if (mode == "pre") {
2911 pcmd("const char *path = (const char *)path_;")
2912 pcmd("if (path) {")
2913 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
2914 pcmd("}")
2915 } else {
2916 pcmd("const char *path = (const char *)path_;")
2917 pcmd("if (pid_) {")
2918 pcmd(" if (path) {")
2919 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
2920 pcmd(" }")
2921 pcmd("}")
2922 }
2923 } else if (syscall == "recvmmsg") {
2924 if (mode == "pre") {
2925 pcmd("if (timeout_) {")
2926 pcmd(" PRE_READ(timeout_, struct_timespec_sz);")
2927 pcmd("}")
2928 } else {
2929 pcmd("if (res >= 0) {")
2930 pcmd(" if (timeout_) {")
2931 pcmd(" POST_READ(timeout_, struct_timespec_sz);")
2932 pcmd(" }")
2933 pcmd("}")
2934 }
2935 } else if (syscall == "sendmmsg") {
2936 if (mode == "pre") {
2937 pcmd("struct __sanitizer_mmsghdr *mmsg = (struct __sanitizer_mmsghdr *)mmsg_;")
2938 pcmd("unsigned int vlen = (vlen_ > 1024 ? 1024 : vlen_);")
2939 pcmd("if (mmsg) {")
2940 pcmd(" PRE_READ(mmsg, sizeof(struct __sanitizer_mmsghdr) * vlen);")
2941 pcmd("}")
2942 } else {
2943 pcmd("struct __sanitizer_mmsghdr *mmsg = (struct __sanitizer_mmsghdr *)mmsg_;")
2944 pcmd("unsigned int vlen = (vlen_ > 1024 ? 1024 : vlen_);")
2945 pcmd("if (res >= 0) {")
2946 pcmd(" if (mmsg) {")
2947 pcmd(" POST_READ(mmsg, sizeof(struct __sanitizer_mmsghdr) * vlen);")
2948 pcmd(" }")
2949 pcmd("}")
2950 }
2951 } else if (syscall == "clock_nanosleep") {
2952 if (mode == "pre") {
2953 pcmd("if (rqtp_) {")
2954 pcmd(" PRE_READ(rqtp_, struct_timespec_sz);")
2955 pcmd("}")
2956 } else {
2957 pcmd("if (rqtp_) {")
2958 pcmd(" POST_READ(rqtp_, struct_timespec_sz);")
2959 pcmd("}")
2960 }
2961 } else if (syscall == "___lwp_park60") {
2962 if (mode == "pre") {
2963 pcmd("if (ts_) {")
2964 pcmd(" PRE_READ(ts_, struct_timespec_sz);")
2965 pcmd("}")
2966 } else {
2967 pcmd("if (res == 0) {")
2968 pcmd(" if (ts_) {")
2969 pcmd(" POST_READ(ts_, struct_timespec_sz);")
2970 pcmd(" }")
2971 pcmd("}")
2972 }
2973 } else if (syscall == "posix_fallocate") {
2974 pcmd("/* Nothing to do */")
2975 } else if (syscall == "fdiscard") {
2976 pcmd("/* Nothing to do */")
2977 } else if (syscall == "wait6") {
2978 pcmd("/* Nothing to do */")
2979 } else if (syscall == "clock_getcpuclockid2") {
2980 pcmd("/* Nothing to do */")
2981 } else {
2982 print "Unrecognized syscall: " syscall
2983 abnormal_exit = 1
2984 exit 1
2985 }
2986}