]> git.proxmox.com Git - rustc.git/blame - vendor/compiler_builtins/compiler-rt/utils/generate_netbsd_syscalls.awk
New upstream version 1.36.0+dfsg1
[rustc.git] / vendor / compiler_builtins / compiler-rt / utils / generate_netbsd_syscalls.awk
CommitLineData
8faf50e0
XL
1#!/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
258 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 }
303
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
314 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 }
343
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\" {")
458 pcmd("#define SYS_MAXSYSARGS " SYS_MAXSYSARGS)
459
460 for (i = 0; i < parsedsyscalls; i++) {
461
462 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")
499 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}
527
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);")
721 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);")
757 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 }
a1dfa0c6
XL
1467 } else if (syscall == "getsockopt2") {
1468 pcmd("/* TODO */")
8faf50e0
XL
1469 } else if (syscall == "fpathconf") {
1470 pcmd("/* Nothing to do */")
1471 } else if (syscall == "getrlimit") {
1472 if (mode == "pre") {
1473 pcmd("PRE_WRITE(rlp_, struct_rlimit_sz);")
1474 } else {
1475 pcmd("if (res == 0) {")
1476 pcmd(" POST_WRITE(rlp_, struct_rlimit_sz);")
1477 pcmd("}")
1478 }
1479 } else if (syscall == "setrlimit") {
1480 if (mode == "pre") {
1481 pcmd("PRE_READ(rlp_, struct_rlimit_sz);")
1482 } else {
1483 pcmd("if (res == 0) {")
1484 pcmd(" POST_READ(rlp_, struct_rlimit_sz);")
1485 pcmd("}")
1486 }
1487 } else if (syscall == "compat_12_getdirentries") {
1488 pcmd("/* TODO */")
1489 } else if (syscall == "mmap") {
1490 pcmd("/* Nothing to do */")
1491 } else if (syscall == "__syscall") {
1492 pcmd("/* Nothing to do */")
1493 } else if (syscall == "lseek") {
1494 pcmd("/* Nothing to do */")
1495 } else if (syscall == "truncate") {
1496 if (mode == "pre") {
1497 pcmd("const char *path = (const char *)path_;")
1498 pcmd("if (path) {")
1499 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
1500 pcmd("}")
1501 } else {
1502 pcmd("if (res == 0) {")
1503 pcmd(" const char *path = (const char *)path_;")
1504 pcmd(" if (path) {")
1505 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
1506 pcmd(" }")
1507 pcmd("}")
1508 }
1509 } else if (syscall == "ftruncate") {
1510 pcmd("/* Nothing to do */")
1511 } else if (syscall == "__sysctl") {
1512 if (mode == "pre") {
1513 pcmd("const int *name = (const int *)name_;")
1514 pcmd("if (name) {")
1515 pcmd(" PRE_READ(name, namelen_ * sizeof(*name));")
1516 pcmd("}")
1517 pcmd("if (newv_) {")
1518 pcmd(" PRE_READ(name, newlen_);")
1519 pcmd("}")
1520 } else {
1521 pcmd("if (res == 0) {")
1522 pcmd(" const int *name = (const int *)name_;")
1523 pcmd(" if (name) {")
1524 pcmd(" POST_READ(name, namelen_ * sizeof(*name));")
1525 pcmd(" }")
1526 pcmd(" if (newv_) {")
1527 pcmd(" POST_READ(name, newlen_);")
1528 pcmd(" }")
1529 pcmd("}")
1530 }
1531 } else if (syscall == "mlock") {
1532 pcmd("/* Nothing to do */")
1533 } else if (syscall == "munlock") {
1534 pcmd("/* Nothing to do */")
1535 } else if (syscall == "undelete") {
1536 if (mode == "pre") {
1537 pcmd("const char *path = (const char *)path_;")
1538 pcmd("if (path) {")
1539 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
1540 pcmd("}")
1541 } else {
1542 pcmd("if (res == 0) {")
1543 pcmd(" const char *path = (const char *)path_;")
1544 pcmd(" if (path) {")
1545 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
1546 pcmd(" }")
1547 pcmd("}")
1548 }
1549 } else if (syscall == "compat_50_futimes") {
1550 pcmd("/* TODO */")
1551 } else if (syscall == "getpgid") {
1552 pcmd("/* Nothing to do */")
1553 } else if (syscall == "reboot") {
1554 if (mode == "pre") {
1555 pcmd("const char *bootstr = (const char *)bootstr_;")
1556 pcmd("if (bootstr) {")
1557 pcmd(" PRE_READ(bootstr, __sanitizer::internal_strlen(bootstr) + 1);")
1558 pcmd("}")
1559 } else {
1560 pcmd("/* This call should never return */")
1561 pcmd("const char *bootstr = (const char *)bootstr_;")
1562 pcmd("if (bootstr) {")
1563 pcmd(" POST_READ(bootstr, __sanitizer::internal_strlen(bootstr) + 1);")
1564 pcmd("}")
1565 }
1566 } else if (syscall == "poll") {
1567 pcmd("/* Nothing to do */")
1568 } else if (syscall == "afssys") {
1569 pcmd("/* TODO */")
1570 } else if (syscall == "compat_14___semctl") {
1571 pcmd("/* TODO */")
1572 } else if (syscall == "semget") {
1573 pcmd("/* Nothing to do */")
1574 } else if (syscall == "semop") {
1575 if (mode == "pre") {
1576 pcmd("if (sops_) {")
1577 pcmd(" PRE_READ(sops_, nsops_ * struct_sembuf_sz);")
1578 pcmd("}")
1579 } else {
1580 pcmd("if (res == 0) {")
1581 pcmd(" if (sops_) {")
1582 pcmd(" POST_READ(sops_, nsops_ * struct_sembuf_sz);")
1583 pcmd(" }")
1584 pcmd("}")
1585 }
1586 } else if (syscall == "semconfig") {
1587 pcmd("/* Nothing to do */")
1588 } else if (syscall == "compat_14_msgctl") {
1589 pcmd("/* TODO */")
1590 } else if (syscall == "msgget") {
1591 pcmd("/* Nothing to do */")
1592 } else if (syscall == "msgsnd") {
1593 if (mode == "pre") {
1594 pcmd("if (msgp_) {")
1595 pcmd(" PRE_READ(msgp_, msgsz_);")
1596 pcmd("}")
1597 } else {
1598 pcmd("if (res == 0) {")
1599 pcmd(" if (msgp_) {")
1600 pcmd(" POST_READ(msgp_, msgsz_);")
1601 pcmd(" }")
1602 pcmd("}")
1603 }
1604 } else if (syscall == "msgrcv") {
1605 pcmd("/* Nothing to do */")
1606 } else if (syscall == "shmat") {
1607 pcmd("/* Nothing to do */")
1608 } else if (syscall == "compat_14_shmctl") {
1609 pcmd("/* TODO */")
1610 } else if (syscall == "shmdt") {
1611 pcmd("/* Nothing to do */")
1612 } else if (syscall == "shmget") {
1613 pcmd("/* Nothing to do */")
1614 } else if (syscall == "compat_50_clock_gettime") {
1615 pcmd("/* TODO */")
1616 } else if (syscall == "compat_50_clock_settime") {
1617 pcmd("/* TODO */")
1618 } else if (syscall == "compat_50_clock_getres") {
1619 pcmd("/* TODO */")
1620 } else if (syscall == "timer_create") {
1621 pcmd("/* Nothing to do */")
1622 } else if (syscall == "timer_delete") {
1623 pcmd("/* Nothing to do */")
1624 } else if (syscall == "compat_50_timer_settime") {
1625 pcmd("/* TODO */")
1626 } else if (syscall == "compat_50_timer_gettime") {
1627 pcmd("/* TODO */")
1628 } else if (syscall == "timer_getoverrun") {
1629 pcmd("/* Nothing to do */")
1630 } else if (syscall == "compat_50_nanosleep") {
1631 pcmd("/* TODO */")
1632 } else if (syscall == "fdatasync") {
1633 pcmd("/* Nothing to do */")
1634 } else if (syscall == "mlockall") {
1635 pcmd("/* Nothing to do */")
1636 } else if (syscall == "munlockall") {
1637 pcmd("/* Nothing to do */")
1638 } else if (syscall == "compat_50___sigtimedwait") {
1639 pcmd("/* TODO */")
1640 } else if (syscall == "sigqueueinfo") {
1641 if (mode == "pre") {
1642 pcmd("if (info_) {")
1643 pcmd(" PRE_READ(info_, siginfo_t_sz);")
1644 pcmd("}")
1645 }
1646 } else if (syscall == "modctl") {
1647 pcmd("/* TODO */")
1648 } else if (syscall == "_ksem_init") {
1649 pcmd("/* Nothing to do */")
1650 } else if (syscall == "_ksem_open") {
1651 if (mode == "pre") {
1652 pcmd("const char *name = (const char *)name_;")
1653 pcmd("if (name) {")
1654 pcmd(" PRE_READ(name, __sanitizer::internal_strlen(name) + 1);")
1655 pcmd("}")
1656 } else {
1657 pcmd("const char *name = (const char *)name_;")
1658 pcmd("if (name) {")
1659 pcmd(" POST_READ(name, __sanitizer::internal_strlen(name) + 1);")
1660 pcmd("}")
1661 }
1662 } else if (syscall == "_ksem_unlink") {
1663 if (mode == "pre") {
1664 pcmd("const char *name = (const char *)name_;")
1665 pcmd("if (name) {")
1666 pcmd(" PRE_READ(name, __sanitizer::internal_strlen(name) + 1);")
1667 pcmd("}")
1668 } else {
1669 pcmd("const char *name = (const char *)name_;")
1670 pcmd("if (name) {")
1671 pcmd(" POST_READ(name, __sanitizer::internal_strlen(name) + 1);")
1672 pcmd("}")
1673 }
1674 } else if (syscall == "_ksem_close") {
1675 pcmd("/* Nothing to do */")
1676 } else if (syscall == "_ksem_post") {
1677 pcmd("/* Nothing to do */")
1678 } else if (syscall == "_ksem_wait") {
1679 pcmd("/* Nothing to do */")
1680 } else if (syscall == "_ksem_trywait") {
1681 pcmd("/* Nothing to do */")
1682 } else if (syscall == "_ksem_getvalue") {
1683 pcmd("/* Nothing to do */")
1684 } else if (syscall == "_ksem_destroy") {
1685 pcmd("/* Nothing to do */")
1686 } else if (syscall == "_ksem_timedwait") {
1687 if (mode == "pre") {
1688 pcmd("if (abstime_) {")
1689 pcmd(" PRE_READ(abstime_, struct_timespec_sz);")
1690 pcmd("}")
1691 }
1692 } else if (syscall == "mq_open") {
1693 if (mode == "pre") {
1694 pcmd("const char *name = (const char *)name_;")
1695 pcmd("if (name) {")
1696 pcmd(" PRE_READ(name, __sanitizer::internal_strlen(name) + 1);")
1697 pcmd("}")
1698 } else {
1699 pcmd("const char *name = (const char *)name_;")
1700 pcmd("if (name) {")
1701 pcmd(" POST_READ(name, __sanitizer::internal_strlen(name) + 1);")
1702 pcmd("}")
1703 }
1704 } else if (syscall == "mq_close") {
1705 pcmd("/* Nothing to do */")
1706 } else if (syscall == "mq_unlink") {
1707 if (mode == "pre") {
1708 pcmd("const char *name = (const char *)name_;")
1709 pcmd("if (name) {")
1710 pcmd(" PRE_READ(name, __sanitizer::internal_strlen(name) + 1);")
1711 pcmd("}")
1712 } else {
1713 pcmd("const char *name = (const char *)name_;")
1714 pcmd("if (name) {")
1715 pcmd(" POST_READ(name, __sanitizer::internal_strlen(name) + 1);")
1716 pcmd("}")
1717 }
1718 } else if (syscall == "mq_getattr") {
1719 pcmd("/* Nothing to do */")
1720 } else if (syscall == "mq_setattr") {
1721 if (mode == "pre") {
1722 pcmd("if (mqstat_) {")
1723 pcmd(" PRE_READ(mqstat_, struct_mq_attr_sz);")
1724 pcmd("}")
1725 }
1726 } else if (syscall == "mq_notify") {
1727 if (mode == "pre") {
1728 pcmd("if (notification_) {")
1729 pcmd(" PRE_READ(notification_, struct_sigevent_sz);")
1730 pcmd("}")
1731 }
1732 } else if (syscall == "mq_send") {
1733 if (mode == "pre") {
1734 pcmd("if (msg_ptr_) {")
1735 pcmd(" PRE_READ(msg_ptr_, msg_len_);")
1736 pcmd("}")
1737 }
1738 } else if (syscall == "mq_receive") {
1739 pcmd("/* Nothing to do */")
1740 } else if (syscall == "compat_50_mq_timedsend") {
1741 pcmd("/* TODO */")
1742 } else if (syscall == "compat_50_mq_timedreceive") {
1743 pcmd("/* TODO */")
1744 } else if (syscall == "__posix_rename") {
1745 if (mode == "pre") {
1746 pcmd("const char *from = (const char *)from_;")
1747 pcmd("const char *to = (const char *)to_;")
1748 pcmd("if (from_) {")
1749 pcmd(" PRE_READ(from, __sanitizer::internal_strlen(from) + 1);")
1750 pcmd("}")
1751 pcmd("if (to) {")
1752 pcmd(" PRE_READ(to, __sanitizer::internal_strlen(to) + 1);")
1753 pcmd("}")
1754 } else {
1755 pcmd("const char *from = (const char *)from_;")
1756 pcmd("const char *to = (const char *)to_;")
1757 pcmd("if (from) {")
1758 pcmd(" POST_READ(from, __sanitizer::internal_strlen(from) + 1);")
1759 pcmd("}")
1760 pcmd("if (to) {")
1761 pcmd(" POST_READ(to, __sanitizer::internal_strlen(to) + 1);")
1762 pcmd("}")
1763 }
1764 } else if (syscall == "swapctl") {
1765 pcmd("/* TODO */")
1766 } else if (syscall == "compat_30_getdents") {
1767 pcmd("/* TODO */")
1768 } else if (syscall == "minherit") {
1769 pcmd("/* Nothing to do */")
1770 } else if (syscall == "lchmod") {
1771 if (mode == "pre") {
1772 pcmd("const char *path = (const char *)path_;")
1773 pcmd("if (path) {")
1774 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
1775 pcmd("}")
1776 } else {
1777 pcmd("const char *path = (const char *)path_;")
1778 pcmd("if (path) {")
1779 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
1780 pcmd("}")
1781 }
1782 } else if (syscall == "lchown") {
1783 if (mode == "pre") {
1784 pcmd("const char *path = (const char *)path_;")
1785 pcmd("if (path) {")
1786 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
1787 pcmd("}")
1788 } else {
1789 pcmd("const char *path = (const char *)path_;")
1790 pcmd("if (path) {")
1791 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
1792 pcmd("}")
1793 }
1794 } else if (syscall == "compat_50_lutimes") {
1795 pcmd("/* TODO */")
1796 } else if (syscall == "__msync13") {
1797 pcmd("/* Nothing to do */")
1798 } else if (syscall == "compat_30___stat13") {
1799 pcmd("/* TODO */")
1800 } else if (syscall == "compat_30___fstat13") {
1801 pcmd("/* TODO */")
1802 } else if (syscall == "compat_30___lstat13") {
1803 pcmd("/* TODO */")
1804 } else if (syscall == "__sigaltstack14") {
1805 if (mode == "pre") {
1806 pcmd("if (nss_) {")
1807 pcmd(" PRE_READ(nss_, struct_sigaltstack_sz);")
1808 pcmd("}")
1809 pcmd("if (oss_) {")
1810 pcmd(" PRE_READ(oss_, struct_sigaltstack_sz);")
1811 pcmd("}")
1812 }
1813 } else if (syscall == "__vfork14") {
1814 pcmd("/* Nothing to do */")
1815 } else if (syscall == "__posix_chown") {
1816 if (mode == "pre") {
1817 pcmd("const char *path = (const char *)path_;")
1818 pcmd("if (path) {")
1819 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
1820 pcmd("}")
1821 } else {
1822 pcmd("const char *path = (const char *)path_;")
1823 pcmd("if (path) {")
1824 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
1825 pcmd("}")
1826 }
1827 } else if (syscall == "__posix_fchown") {
1828 pcmd("/* Nothing to do */")
1829 } else if (syscall == "__posix_lchown") {
1830 if (mode == "pre") {
1831 pcmd("const char *path = (const char *)path_;")
1832 pcmd("if (path) {")
1833 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
1834 pcmd("}")
1835 } else {
1836 pcmd("const char *path = (const char *)path_;")
1837 pcmd("if (path) {")
1838 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
1839 pcmd("}")
1840 }
1841 } else if (syscall == "getsid") {
1842 pcmd("/* Nothing to do */")
1843 } else if (syscall == "__clone") {
1844 pcmd("/* Nothing to do */")
1845 } else if (syscall == "fktrace") {
1846 pcmd("/* Nothing to do */")
1847 } else if (syscall == "preadv") {
1848 pcmd("/* Nothing to do */")
1849 } else if (syscall == "pwritev") {
1850 pcmd("/* Nothing to do */")
1851 } else if (syscall == "compat_16___sigaction14") {
1852 pcmd("/* TODO */")
1853 } else if (syscall == "__sigpending14") {
1854 pcmd("/* Nothing to do */")
1855 } else if (syscall == "__sigprocmask14") {
1856 pcmd("/* Nothing to do */")
1857 } else if (syscall == "__sigsuspend14") {
1858 pcmd("if (set_) {")
1859 pcmd(" PRE_READ(set_, sizeof(__sanitizer_sigset_t));")
1860 pcmd("}")
1861 } else if (syscall == "compat_16___sigreturn14") {
1862 pcmd("/* TODO */")
1863 } else if (syscall == "__getcwd") {
1864 pcmd("/* Nothing to do */")
1865 } else if (syscall == "fchroot") {
1866 pcmd("/* Nothing to do */")
1867 } else if (syscall == "compat_30_fhopen") {
1868 pcmd("/* TODO */")
1869 } else if (syscall == "compat_30_fhstat") {
1870 pcmd("/* TODO */")
1871 } else if (syscall == "compat_20_fhstatfs") {
1872 pcmd("/* TODO */")
1873 } else if (syscall == "compat_50_____semctl13") {
1874 pcmd("/* TODO */")
1875 } else if (syscall == "compat_50___msgctl13") {
1876 pcmd("/* TODO */")
1877 } else if (syscall == "compat_50___shmctl13") {
1878 pcmd("/* TODO */")
1879 } else if (syscall == "lchflags") {
1880 if (mode == "pre") {
1881 pcmd("const char *path = (const char *)path_;")
1882 pcmd("if (path) {")
1883 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
1884 pcmd("}")
1885 } else {
1886 pcmd("const char *path = (const char *)path_;")
1887 pcmd("if (path) {")
1888 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
1889 pcmd("}")
1890 }
1891 } else if (syscall == "issetugid") {
1892 pcmd("/* Nothing to do */")
1893 } else if (syscall == "utrace") {
1894 if (mode == "pre") {
1895 pcmd("const char *label = (const char *)label_;")
1896 pcmd("if (label) {")
1897 pcmd(" PRE_READ(label, __sanitizer::internal_strlen(label) + 1);")
1898 pcmd("}")
1899 pcmd("if (addr_) {")
1900 pcmd(" PRE_READ(addr_, len_);")
1901 pcmd("}")
1902 } else {
1903 pcmd("const char *label = (const char *)label_;")
1904 pcmd("if (label) {")
1905 pcmd(" POST_READ(label, __sanitizer::internal_strlen(label) + 1);")
1906 pcmd("}")
1907 pcmd("if (addr_) {")
1908 pcmd(" POST_READ(addr_, len_);")
1909 pcmd("}")
1910 }
1911 } else if (syscall == "getcontext") {
1912 pcmd("/* Nothing to do */")
1913 } else if (syscall == "setcontext") {
1914 if (mode == "pre") {
1915 pcmd("if (ucp_) {")
1916 pcmd(" PRE_READ(ucp_, ucontext_t_sz);")
1917 pcmd("}")
1918 }
1919 } else if (syscall == "_lwp_create") {
1920 if (mode == "pre") {
1921 pcmd("if (ucp_) {")
1922 pcmd(" PRE_READ(ucp_, ucontext_t_sz);")
1923 pcmd("}")
1924 }
1925 } else if (syscall == "_lwp_exit") {
1926 pcmd("/* Nothing to do */")
1927 } else if (syscall == "_lwp_self") {
1928 pcmd("/* Nothing to do */")
1929 } else if (syscall == "_lwp_wait") {
1930 pcmd("/* Nothing to do */")
1931 } else if (syscall == "_lwp_suspend") {
1932 pcmd("/* Nothing to do */")
1933 } else if (syscall == "_lwp_continue") {
1934 pcmd("/* Nothing to do */")
1935 } else if (syscall == "_lwp_wakeup") {
1936 pcmd("/* Nothing to do */")
1937 } else if (syscall == "_lwp_getprivate") {
1938 pcmd("/* Nothing to do */")
1939 } else if (syscall == "_lwp_setprivate") {
1940 pcmd("/* Nothing to do */")
1941 } else if (syscall == "_lwp_kill") {
1942 pcmd("/* Nothing to do */")
1943 } else if (syscall == "_lwp_detach") {
1944 pcmd("/* Nothing to do */")
1945 } else if (syscall == "compat_50__lwp_park") {
1946 pcmd("/* TODO */")
1947 } else if (syscall == "_lwp_unpark") {
1948 pcmd("/* Nothing to do */")
1949 } else if (syscall == "_lwp_unpark_all") {
1950 if (mode == "pre") {
1951 pcmd("if (targets_) {")
1952 pcmd(" PRE_READ(targets_, ntargets_ * sizeof(__sanitizer_lwpid_t));")
1953 pcmd("}")
1954 }
1955 } else if (syscall == "_lwp_setname") {
1956 if (mode == "pre") {
1957 pcmd("const char *name = (const char *)name_;")
1958 pcmd("if (name) {")
1959 pcmd(" PRE_READ(name, __sanitizer::internal_strlen(name) + 1);")
1960 pcmd("}")
1961 } else {
1962 pcmd("const char *name = (const char *)name_;")
1963 pcmd("if (name) {")
1964 pcmd(" POST_READ(name, __sanitizer::internal_strlen(name) + 1);")
1965 pcmd("}")
1966 }
1967 } else if (syscall == "_lwp_getname") {
1968 pcmd("/* Nothing to do */")
1969 } else if (syscall == "_lwp_ctl") {
1970 pcmd("/* Nothing to do */")
1971 } else if (syscall == "compat_60_sa_register") {
1972 pcmd("/* TODO */")
1973 } else if (syscall == "compat_60_sa_stacks") {
1974 pcmd("/* TODO */")
1975 } else if (syscall == "compat_60_sa_enable") {
1976 pcmd("/* TODO */")
1977 } else if (syscall == "compat_60_sa_setconcurrency") {
1978 pcmd("/* TODO */")
1979 } else if (syscall == "compat_60_sa_yield") {
1980 pcmd("/* TODO */")
1981 } else if (syscall == "compat_60_sa_preempt") {
1982 pcmd("/* TODO */")
1983 } else if (syscall == "__sigaction_sigtramp") {
1984 pcmd("if (nsa_) {")
1985 pcmd(" PRE_READ(nsa_, sizeof(__sanitizer_sigaction));")
1986 pcmd("}")
8faf50e0
XL
1987 } else if (syscall == "rasctl") {
1988 pcmd("/* Nothing to do */")
1989 } else if (syscall == "kqueue") {
1990 pcmd("/* Nothing to do */")
1991 } else if (syscall == "compat_50_kevent") {
1992 pcmd("/* TODO */")
1993 } else if (syscall == "_sched_setparam") {
1994 pcmd("if (params_) {")
1995 pcmd(" PRE_READ(params_, struct_sched_param_sz);")
1996 pcmd("}")
1997 } else if (syscall == "_sched_getparam") {
1998 pcmd("/* Nothing to do */")
1999 } else if (syscall == "_sched_setaffinity") {
2000 pcmd("if (cpuset_) {")
2001 pcmd(" PRE_READ(cpuset_, size_);")
2002 pcmd("}")
2003 } else if (syscall == "_sched_getaffinity") {
2004 pcmd("/* Nothing to do */")
2005 } else if (syscall == "sched_yield") {
2006 pcmd("/* Nothing to do */")
2007 } else if (syscall == "_sched_protect") {
2008 pcmd("/* Nothing to do */")
2009 } else if (syscall == "fsync_range") {
2010 pcmd("/* Nothing to do */")
2011 } else if (syscall == "uuidgen") {
2012 pcmd("/* Nothing to do */")
2013 } else if (syscall == "getvfsstat") {
2014 pcmd("/* Nothing to do */")
2015 } else if (syscall == "statvfs1") {
2016 if (mode == "pre") {
2017 pcmd("const char *path = (const char *)path_;")
2018 pcmd("if (path) {")
2019 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
2020 pcmd("}")
2021 } else {
2022 pcmd("const char *path = (const char *)path_;")
2023 pcmd("if (path) {")
2024 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
2025 pcmd("}")
2026 }
2027 } else if (syscall == "fstatvfs1") {
2028 pcmd("/* Nothing to do */")
2029 } else if (syscall == "compat_30_fhstatvfs1") {
2030 pcmd("/* TODO */")
2031 } else if (syscall == "extattrctl") {
2032 if (mode == "pre") {
2033 pcmd("const char *path = (const char *)path_;")
2034 pcmd("if (path) {")
2035 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
2036 pcmd("}")
2037 } else {
2038 pcmd("const char *path = (const char *)path_;")
2039 pcmd("if (path) {")
2040 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
2041 pcmd("}")
2042 }
2043 } else if (syscall == "extattr_set_file") {
2044 if (mode == "pre") {
2045 pcmd("const char *path = (const char *)path_;")
2046 pcmd("if (path) {")
2047 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
2048 pcmd("}")
2049 } else {
2050 pcmd("const char *path = (const char *)path_;")
2051 pcmd("if (path) {")
2052 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
2053 pcmd("}")
2054 }
2055 } else if (syscall == "extattr_get_file") {
2056 if (mode == "pre") {
2057 pcmd("const char *path = (const char *)path_;")
2058 pcmd("if (path) {")
2059 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
2060 pcmd("}")
2061 } else {
2062 pcmd("const char *path = (const char *)path_;")
2063 pcmd("if (path) {")
2064 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
2065 pcmd("}")
2066 }
2067 } else if (syscall == "extattr_delete_file") {
2068 if (mode == "pre") {
2069 pcmd("const char *path = (const char *)path_;")
2070 pcmd("if (path) {")
2071 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
2072 pcmd("}")
2073 } else {
2074 pcmd("const char *path = (const char *)path_;")
2075 pcmd("if (path) {")
2076 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
2077 pcmd("}")
2078 }
2079 } else if (syscall == "extattr_set_fd") {
2080 pcmd("/* TODO */")
2081 } else if (syscall == "extattr_get_fd") {
2082 pcmd("/* TODO */")
2083 } else if (syscall == "extattr_delete_fd") {
2084 pcmd("/* TODO */")
2085 } else if (syscall == "extattr_set_link") {
2086 if (mode == "pre") {
2087 pcmd("const char *path = (const char *)path_;")
2088 pcmd("if (path) {")
2089 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
2090 pcmd("}")
2091 } else {
2092 pcmd("const char *path = (const char *)path_;")
2093 pcmd("if (path) {")
2094 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
2095 pcmd("}")
2096 }
2097 } else if (syscall == "extattr_get_link") {
2098 if (mode == "pre") {
2099 pcmd("const char *path = (const char *)path_;")
2100 pcmd("if (path) {")
2101 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
2102 pcmd("}")
2103 } else {
2104 pcmd("const char *path = (const char *)path_;")
2105 pcmd("if (path) {")
2106 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
2107 pcmd("}")
2108 }
2109 } else if (syscall == "extattr_delete_link") {
2110 if (mode == "pre") {
2111 pcmd("const char *path = (const char *)path_;")
2112 pcmd("if (path) {")
2113 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
2114 pcmd("}")
2115 } else {
2116 pcmd("const char *path = (const char *)path_;")
2117 pcmd("if (path) {")
2118 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
2119 pcmd("}")
2120 }
2121 } else if (syscall == "extattr_list_fd") {
2122 pcmd("/* TODO */")
2123 } else if (syscall == "extattr_list_file") {
2124 if (mode == "pre") {
2125 pcmd("const char *path = (const char *)path_;")
2126 pcmd("if (path) {")
2127 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
2128 pcmd("}")
2129 } else {
2130 pcmd("const char *path = (const char *)path_;")
2131 pcmd("if (path) {")
2132 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
2133 pcmd("}")
2134 }
2135 } else if (syscall == "extattr_list_link") {
2136 if (mode == "pre") {
2137 pcmd("const char *path = (const char *)path_;")
2138 pcmd("if (path) {")
2139 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
2140 pcmd("}")
2141 } else {
2142 pcmd("const char *path = (const char *)path_;")
2143 pcmd("if (path) {")
2144 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
2145 pcmd("}")
2146 }
2147 } else if (syscall == "compat_50_pselect") {
2148 pcmd("/* TODO */")
2149 } else if (syscall == "compat_50_pollts") {
2150 pcmd("/* TODO */")
2151 } else if (syscall == "setxattr") {
2152 if (mode == "pre") {
2153 pcmd("const char *path = (const char *)path_;")
2154 pcmd("if (path) {")
2155 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
2156 pcmd("}")
2157 } else {
2158 pcmd("const char *path = (const char *)path_;")
2159 pcmd("if (path) {")
2160 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
2161 pcmd("}")
2162 }
2163 } else if (syscall == "lsetxattr") {
2164 if (mode == "pre") {
2165 pcmd("const char *path = (const char *)path_;")
2166 pcmd("if (path) {")
2167 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
2168 pcmd("}")
2169 } else {
2170 pcmd("const char *path = (const char *)path_;")
2171 pcmd("if (path) {")
2172 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
2173 pcmd("}")
2174 }
2175 } else if (syscall == "fsetxattr") {
2176 pcmd("/* Nothing to do */")
2177 } else if (syscall == "getxattr") {
2178 if (mode == "pre") {
2179 pcmd("const char *path = (const char *)path_;")
2180 pcmd("if (path) {")
2181 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
2182 pcmd("}")
2183 } else {
2184 pcmd("const char *path = (const char *)path_;")
2185 pcmd("if (path) {")
2186 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
2187 pcmd("}")
2188 }
2189 } else if (syscall == "lgetxattr") {
2190 if (mode == "pre") {
2191 pcmd("const char *path = (const char *)path_;")
2192 pcmd("if (path) {")
2193 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
2194 pcmd("}")
2195 } else {
2196 pcmd("const char *path = (const char *)path_;")
2197 pcmd("if (path) {")
2198 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
2199 pcmd("}")
2200 }
2201 } else if (syscall == "fgetxattr") {
2202 pcmd("/* Nothing to do */")
2203 } else if (syscall == "listxattr") {
2204 if (mode == "pre") {
2205 pcmd("const char *path = (const char *)path_;")
2206 pcmd("if (path) {")
2207 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
2208 pcmd("}")
2209 } else {
2210 pcmd("const char *path = (const char *)path_;")
2211 pcmd("if (path) {")
2212 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
2213 pcmd("}")
2214 }
2215 } else if (syscall == "llistxattr") {
2216 if (mode == "pre") {
2217 pcmd("const char *path = (const char *)path_;")
2218 pcmd("if (path) {")
2219 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
2220 pcmd("}")
2221 } else {
2222 pcmd("const char *path = (const char *)path_;")
2223 pcmd("if (path) {")
2224 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
2225 pcmd("}")
2226 }
2227 } else if (syscall == "flistxattr") {
2228 pcmd("/* TODO */")
2229 } else if (syscall == "removexattr") {
2230 if (mode == "pre") {
2231 pcmd("const char *path = (const char *)path_;")
2232 pcmd("if (path) {")
2233 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
2234 pcmd("}")
2235 } else {
2236 pcmd("const char *path = (const char *)path_;")
2237 pcmd("if (path) {")
2238 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
2239 pcmd("}")
2240 }
2241 } else if (syscall == "lremovexattr") {
2242 if (mode == "pre") {
2243 pcmd("const char *path = (const char *)path_;")
2244 pcmd("if (path) {")
2245 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
2246 pcmd("}")
2247 } else {
2248 pcmd("const char *path = (const char *)path_;")
2249 pcmd("if (path) {")
2250 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
2251 pcmd("}")
2252 }
2253 } else if (syscall == "fremovexattr") {
2254 pcmd("/* TODO */")
2255 } else if (syscall == "compat_50___stat30") {
2256 pcmd("/* TODO */")
2257 } else if (syscall == "compat_50___fstat30") {
2258 pcmd("/* TODO */")
2259 } else if (syscall == "compat_50___lstat30") {
2260 pcmd("/* TODO */")
2261 } else if (syscall == "__getdents30") {
2262 pcmd("/* Nothing to do */")
2263 } else if (syscall == "posix_fadvise") {
2264 pcmd("/* Nothing to do */")
2265 } else if (syscall == "compat_30___fhstat30") {
2266 pcmd("/* TODO */")
2267 } else if (syscall == "compat_50___ntp_gettime30") {
2268 pcmd("/* TODO */")
2269 } else if (syscall == "__socket30") {
2270 pcmd("/* Nothing to do */")
2271 } else if (syscall == "__getfh30") {
2272 if (mode == "pre") {
2273 pcmd("const char *fname = (const char *)fname_;")
2274 pcmd("if (fname) {")
2275 pcmd(" PRE_READ(fname, __sanitizer::internal_strlen(fname) + 1);")
2276 pcmd("}")
2277 } else {
2278 pcmd("const char *fname = (const char *)fname_;")
2279 pcmd("if (res == 0) {")
2280 pcmd(" if (fname) {")
2281 pcmd(" POST_READ(fname, __sanitizer::internal_strlen(fname) + 1);")
2282 pcmd(" }")
2283 pcmd("}")
2284 }
2285 } else if (syscall == "__fhopen40") {
2286 if (mode == "pre") {
2287 pcmd("if (fhp_) {")
2288 pcmd(" PRE_READ(fhp_, fh_size_);")
2289 pcmd("}")
2290 }
2291 } else if (syscall == "__fhstatvfs140") {
2292 if (mode == "pre") {
2293 pcmd("if (fhp_) {")
2294 pcmd(" PRE_READ(fhp_, fh_size_);")
2295 pcmd("}")
2296 }
2297 } else if (syscall == "compat_50___fhstat40") {
2298 if (mode == "pre") {
2299 pcmd("if (fhp_) {")
2300 pcmd(" PRE_READ(fhp_, fh_size_);")
2301 pcmd("}")
2302 }
2303 } else if (syscall == "aio_cancel") {
2304 if (mode == "pre") {
2305 pcmd("if (aiocbp_) {")
2306 pcmd(" PRE_READ(aiocbp_, sizeof(struct __sanitizer_aiocb));")
2307 pcmd("}")
2308 }
2309 } else if (syscall == "aio_error") {
2310 if (mode == "pre") {
2311 pcmd("if (aiocbp_) {")
2312 pcmd(" PRE_READ(aiocbp_, sizeof(struct __sanitizer_aiocb));")
2313 pcmd("}")
2314 }
2315 } else if (syscall == "aio_fsync") {
2316 if (mode == "pre") {
2317 pcmd("if (aiocbp_) {")
2318 pcmd(" PRE_READ(aiocbp_, sizeof(struct __sanitizer_aiocb));")
2319 pcmd("}")
2320 }
2321 } else if (syscall == "aio_read") {
2322 if (mode == "pre") {
2323 pcmd("if (aiocbp_) {")
2324 pcmd(" PRE_READ(aiocbp_, sizeof(struct __sanitizer_aiocb));")
2325 pcmd("}")
2326 }
2327 } else if (syscall == "aio_return") {
2328 if (mode == "pre") {
2329 pcmd("if (aiocbp_) {")
2330 pcmd(" PRE_READ(aiocbp_, sizeof(struct __sanitizer_aiocb));")
2331 pcmd("}")
2332 }
2333 } else if (syscall == "compat_50_aio_suspend") {
2334 pcmd("/* TODO */")
2335 } else if (syscall == "aio_write") {
2336 if (mode == "pre") {
2337 pcmd("if (aiocbp_) {")
2338 pcmd(" PRE_READ(aiocbp_, sizeof(struct __sanitizer_aiocb));")
2339 pcmd("}")
2340 }
2341 } else if (syscall == "lio_listio") {
2342 pcmd("/* Nothing to do */")
2343 } else if (syscall == "__mount50") {
2344 if (mode == "pre") {
2345 pcmd("const char *type = (const char *)type_;")
2346 pcmd("const char *path = (const char *)path_;")
2347 pcmd("if (type) {")
2348 pcmd(" PRE_READ(type, __sanitizer::internal_strlen(type) + 1);")
2349 pcmd("}")
2350 pcmd("if (path) {")
2351 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
2352 pcmd("}")
2353 pcmd("if (data_) {")
2354 pcmd(" PRE_READ(data_, data_len_);")
2355 pcmd("}")
2356 } else {
2357 pcmd("const char *type = (const char *)type_;")
2358 pcmd("const char *path = (const char *)path_;")
2359 pcmd("if (type) {")
2360 pcmd(" POST_READ(type, __sanitizer::internal_strlen(type) + 1);")
2361 pcmd("}")
2362 pcmd("if (path) {")
2363 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
2364 pcmd("}")
2365 pcmd("if (data_) {")
2366 pcmd(" POST_READ(data_, data_len_);")
2367 pcmd("}")
2368 }
2369 } else if (syscall == "mremap") {
2370 pcmd("/* Nothing to do */")
2371 } else if (syscall == "pset_create") {
2372 pcmd("/* Nothing to do */")
2373 } else if (syscall == "pset_destroy") {
2374 pcmd("/* Nothing to do */")
2375 } else if (syscall == "pset_assign") {
2376 pcmd("/* Nothing to do */")
2377 } else if (syscall == "_pset_bind") {
2378 pcmd("/* Nothing to do */")
2379 } else if (syscall == "__posix_fadvise50") {
2380 pcmd("/* Nothing to do */")
2381 } else if (syscall == "__select50") {
2382 pcmd("/* Nothing to do */")
2383 } else if (syscall == "__gettimeofday50") {
2384 pcmd("/* Nothing to do */")
2385 } else if (syscall == "__settimeofday50") {
2386 if (mode == "pre") {
2387 pcmd("if (tv_) {")
2388 pcmd(" PRE_READ(tv_, timeval_sz);")
2389 pcmd("}")
2390 pcmd("if (tzp_) {")
2391 pcmd(" PRE_READ(tzp_, struct_timezone_sz);")
2392 pcmd("}")
2393 }
2394 } else if (syscall == "__utimes50") {
2395 if (mode == "pre") {
2396 pcmd("struct __sanitizer_timespec **tptr = (struct __sanitizer_timespec **)tptr_;")
2397 pcmd("const char *path = (const char *)path_;")
2398 pcmd("if (path) {")
2399 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
2400 pcmd("}")
2401 pcmd("if (tptr) {")
2402 pcmd(" PRE_READ(tptr[0], struct_timespec_sz);")
2403 pcmd(" PRE_READ(tptr[1], struct_timespec_sz);")
2404 pcmd("}")
2405 }
2406 } else if (syscall == "__adjtime50") {
2407 if (mode == "pre") {
2408 pcmd("if (delta_) {")
2409 pcmd(" PRE_READ(delta_, timeval_sz);")
2410 pcmd("}")
2411 }
2412 } else if (syscall == "__lfs_segwait50") {
2413 pcmd("/* TODO */")
2414 } else if (syscall == "__futimes50") {
2415 if (mode == "pre") {
2416 pcmd("struct __sanitizer_timespec **tptr = (struct __sanitizer_timespec **)tptr_;")
2417 pcmd("if (tptr) {")
2418 pcmd(" PRE_READ(tptr[0], struct_timespec_sz);")
2419 pcmd(" PRE_READ(tptr[1], struct_timespec_sz);")
2420 pcmd("}")
2421 }
2422 } else if (syscall == "__lutimes50") {
2423 if (mode == "pre") {
2424 pcmd("struct __sanitizer_timespec **tptr = (struct __sanitizer_timespec **)tptr_;")
2425 pcmd("const char *path = (const char *)path_;")
2426 pcmd("if (path) {")
2427 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
2428 pcmd("}")
2429 pcmd("if (tptr) {")
2430 pcmd(" PRE_READ(tptr[0], struct_timespec_sz);")
2431 pcmd(" PRE_READ(tptr[1], struct_timespec_sz);")
2432 pcmd("}")
2433 } else {
2434 pcmd("struct __sanitizer_timespec **tptr = (struct __sanitizer_timespec **)tptr_;")
2435 pcmd("const char *path = (const char *)path_;")
2436 pcmd("if (path) {")
2437 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
2438 pcmd("}")
2439 pcmd("if (tptr) {")
2440 pcmd(" POST_READ(tptr[0], struct_timespec_sz);")
2441 pcmd(" POST_READ(tptr[1], struct_timespec_sz);")
2442 pcmd("}")
2443 }
2444 } else if (syscall == "__setitimer50") {
2445 if (mode == "pre") {
2446 pcmd("struct __sanitizer_itimerval *itv = (struct __sanitizer_itimerval *)itv_;")
2447 pcmd("if (itv) {")
2448 pcmd(" PRE_READ(&itv->it_interval.tv_sec, sizeof(__sanitizer_time_t));")
2449 pcmd(" PRE_READ(&itv->it_interval.tv_usec, sizeof(__sanitizer_suseconds_t));")
2450 pcmd(" PRE_READ(&itv->it_value.tv_sec, sizeof(__sanitizer_time_t));")
2451 pcmd(" PRE_READ(&itv->it_value.tv_usec, sizeof(__sanitizer_suseconds_t));")
2452 pcmd("}")
2453 }
2454 } else if (syscall == "__getitimer50") {
2455 pcmd("/* Nothing to do */")
2456 } else if (syscall == "__clock_gettime50") {
2457 pcmd("/* Nothing to do */")
2458 } else if (syscall == "__clock_settime50") {
2459 if (mode == "pre") {
2460 pcmd("if (tp_) {")
2461 pcmd(" PRE_READ(tp_, struct_timespec_sz);")
2462 pcmd("}")
2463 }
2464 } else if (syscall == "__clock_getres50") {
2465 pcmd("/* Nothing to do */")
2466 } else if (syscall == "__nanosleep50") {
2467 if (mode == "pre") {
2468 pcmd("if (rqtp_) {")
2469 pcmd(" PRE_READ(rqtp_, struct_timespec_sz);")
2470 pcmd("}")
2471 }
2472 } else if (syscall == "____sigtimedwait50") {
2473 if (mode == "pre") {
2474 pcmd("if (set_) {")
2475 pcmd(" PRE_READ(set_, sizeof(__sanitizer_sigset_t));")
2476 pcmd("}")
2477 pcmd("if (timeout_) {")
2478 pcmd(" PRE_READ(timeout_, struct_timespec_sz);")
2479 pcmd("}")
2480 }
2481 } else if (syscall == "__mq_timedsend50") {
2482 if (mode == "pre") {
2483 pcmd("if (msg_ptr_) {")
2484 pcmd(" PRE_READ(msg_ptr_, msg_len_);")
2485 pcmd("}")
2486 pcmd("if (abs_timeout_) {")
2487 pcmd(" PRE_READ(abs_timeout_, struct_timespec_sz);")
2488 pcmd("}")
2489 }
2490 } else if (syscall == "__mq_timedreceive50") {
2491 if (mode == "pre") {
2492 pcmd("if (msg_ptr_) {")
2493 pcmd(" PRE_READ(msg_ptr_, msg_len_);")
2494 pcmd("}")
2495 pcmd("if (abs_timeout_) {")
2496 pcmd(" PRE_READ(abs_timeout_, struct_timespec_sz);")
2497 pcmd("}")
2498 }
2499 } else if (syscall == "compat_60__lwp_park") {
2500 pcmd("/* TODO */")
2501 } else if (syscall == "__kevent50") {
2502 if (mode == "pre") {
2503 pcmd("if (changelist_) {")
2504 pcmd(" PRE_READ(changelist_, nchanges_ * struct_kevent_sz);")
2505 pcmd("}")
2506 pcmd("if (timeout_) {")
2507 pcmd(" PRE_READ(timeout_, struct_timespec_sz);")
2508 pcmd("}")
2509 }
2510 } else if (syscall == "__pselect50") {
2511 if (mode == "pre") {
2512 pcmd("if (ts_) {")
2513 pcmd(" PRE_READ(ts_, struct_timespec_sz);")
2514 pcmd("}")
2515 pcmd("if (mask_) {")
2516 pcmd(" PRE_READ(mask_, sizeof(struct __sanitizer_sigset_t));")
2517 pcmd("}")
2518 }
2519 } else if (syscall == "__pollts50") {
2520 if (mode == "pre") {
2521 pcmd("if (ts_) {")
2522 pcmd(" PRE_READ(ts_, struct_timespec_sz);")
2523 pcmd("}")
2524 pcmd("if (mask_) {")
2525 pcmd(" PRE_READ(mask_, sizeof(struct __sanitizer_sigset_t));")
2526 pcmd("}")
2527 }
2528 } else if (syscall == "__aio_suspend50") {
2529 if (mode == "pre") {
2530 pcmd("int i;")
2531 pcmd("const struct aiocb * const *list = (const struct aiocb * const *)list_;")
2532 pcmd("if (list) {")
2533 pcmd(" for (i = 0; i < nent_; i++) {")
2534 pcmd(" if (list[i]) {")
2535 pcmd(" PRE_READ(list[i], sizeof(struct __sanitizer_aiocb));")
2536 pcmd(" }")
2537 pcmd(" }")
2538 pcmd("}")
2539 pcmd("if (timeout_) {")
2540 pcmd(" PRE_READ(timeout_, struct_timespec_sz);")
2541 pcmd("}")
2542 }
2543 } else if (syscall == "__stat50") {
2544 if (mode == "pre") {
2545 pcmd("const char *path = (const char *)path_;")
2546 pcmd("if (path) {")
2547 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
2548 pcmd("}")
2549 } else {
2550 pcmd("const char *path = (const char *)path_;")
2551 pcmd("if (res == 0) {")
2552 pcmd(" if (path) {")
2553 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
2554 pcmd(" }")
2555 pcmd("}")
2556 }
2557 } else if (syscall == "__fstat50") {
2558 pcmd("/* Nothing to do */")
2559 } else if (syscall == "__lstat50") {
2560 if (mode == "pre") {
2561 pcmd("const char *path = (const char *)path_;")
2562 pcmd("if (path) {")
2563 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
2564 pcmd("}")
2565 } else {
2566 pcmd("const char *path = (const char *)path_;")
2567 pcmd("if (res == 0) {")
2568 pcmd(" if (path) {")
2569 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
2570 pcmd(" }")
2571 pcmd("}")
2572 }
2573 } else if (syscall == "____semctl50") {
2574 pcmd("/* Nothing to do */")
2575 } else if (syscall == "__shmctl50") {
2576 pcmd("/* Nothing to do */")
2577 } else if (syscall == "__msgctl50") {
2578 pcmd("/* Nothing to do */")
2579 } else if (syscall == "__getrusage50") {
2580 pcmd("/* Nothing to do */")
2581 } else if (syscall == "__timer_settime50") {
2582 if (mode == "pre") {
2583 pcmd("struct __sanitizer_itimerval *value = (struct __sanitizer_itimerval *)value_;")
2584 pcmd("if (value) {")
2585 pcmd(" PRE_READ(&value->it_interval.tv_sec, sizeof(__sanitizer_time_t));")
2586 pcmd(" PRE_READ(&value->it_interval.tv_usec, sizeof(__sanitizer_suseconds_t));")
2587 pcmd(" PRE_READ(&value->it_value.tv_sec, sizeof(__sanitizer_time_t));")
2588 pcmd(" PRE_READ(&value->it_value.tv_usec, sizeof(__sanitizer_suseconds_t));")
2589 pcmd("}")
2590 } else {
2591 pcmd("struct __sanitizer_itimerval *value = (struct __sanitizer_itimerval *)value_;")
2592 pcmd("if (res == 0) {")
2593 pcmd(" if (value) {")
2594 pcmd(" POST_READ(&value->it_interval.tv_sec, sizeof(__sanitizer_time_t));")
2595 pcmd(" POST_READ(&value->it_interval.tv_usec, sizeof(__sanitizer_suseconds_t));")
2596 pcmd(" POST_READ(&value->it_value.tv_sec, sizeof(__sanitizer_time_t));")
2597 pcmd(" POST_READ(&value->it_value.tv_usec, sizeof(__sanitizer_suseconds_t));")
2598 pcmd(" }")
2599 pcmd("}")
2600 }
2601 } else if (syscall == "__timer_gettime50") {
2602 pcmd("/* Nothing to do */")
2603 } else if (syscall == "__ntp_gettime50") {
2604 pcmd("/* Nothing to do */")
2605 } else if (syscall == "__wait450") {
2606 pcmd("/* Nothing to do */")
2607 } else if (syscall == "__mknod50") {
2608 if (mode == "pre") {
2609 pcmd("const char *path = (const char *)path_;")
2610 pcmd("if (path) {")
2611 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
2612 pcmd("}")
2613 } else {
2614 pcmd("const char *path = (const char *)path_;")
2615 pcmd("if (res == 0) {")
2616 pcmd(" if (path) {")
2617 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
2618 pcmd(" }")
2619 pcmd("}")
2620 }
2621 } else if (syscall == "__fhstat50") {
2622 if (mode == "pre") {
2623 pcmd("if (fhp_) {")
2624 pcmd(" PRE_READ(fhp_, fh_size_);")
2625 pcmd("}")
2626 } else {
2627 pcmd("if (res == 0) {")
2628 pcmd(" if (fhp_) {")
2629 pcmd(" POST_READ(fhp_, fh_size_);")
2630 pcmd(" }")
2631 pcmd("}")
2632 }
2633 } else if (syscall == "pipe2") {
2634 pcmd("/* Nothing to do */")
2635 } else if (syscall == "dup3") {
2636 pcmd("/* Nothing to do */")
2637 } else if (syscall == "kqueue1") {
2638 pcmd("/* Nothing to do */")
2639 } else if (syscall == "paccept") {
2640 if (mode == "pre") {
2641 pcmd("if (mask_) {")
2642 pcmd(" PRE_READ(mask_, sizeof(__sanitizer_sigset_t));")
2643 pcmd("}")
2644 } else {
2645 pcmd("if (res >= 0) {")
2646 pcmd(" if (mask_) {")
2647 pcmd(" PRE_READ(mask_, sizeof(__sanitizer_sigset_t));")
2648 pcmd(" }")
2649 pcmd("}")
2650 }
2651 } else if (syscall == "linkat") {
2652 if (mode == "pre") {
2653 pcmd("const char *name1 = (const char *)name1_;")
2654 pcmd("const char *name2 = (const char *)name2_;")
2655 pcmd("if (name1) {")
2656 pcmd(" PRE_READ(name1, __sanitizer::internal_strlen(name1) + 1);")
2657 pcmd("}")
2658 pcmd("if (name2) {")
2659 pcmd(" PRE_READ(name2, __sanitizer::internal_strlen(name2) + 1);")
2660 pcmd("}")
2661 } else {
2662 pcmd("const char *name1 = (const char *)name1_;")
2663 pcmd("const char *name2 = (const char *)name2_;")
2664 pcmd("if (res == 0) {")
2665 pcmd(" if (name1) {")
2666 pcmd(" POST_READ(name1, __sanitizer::internal_strlen(name1) + 1);")
2667 pcmd(" }")
2668 pcmd(" if (name2) {")
2669 pcmd(" POST_READ(name2, __sanitizer::internal_strlen(name2) + 1);")
2670 pcmd(" }")
2671 pcmd("}")
2672 }
2673 } else if (syscall == "renameat") {
2674 if (mode == "pre") {
2675 pcmd("const char *from = (const char *)from_;")
2676 pcmd("const char *to = (const char *)to_;")
2677 pcmd("if (from) {")
2678 pcmd(" PRE_READ(from, __sanitizer::internal_strlen(from) + 1);")
2679 pcmd("}")
2680 pcmd("if (to) {")
2681 pcmd(" PRE_READ(to, __sanitizer::internal_strlen(to) + 1);")
2682 pcmd("}")
2683 } else {
2684 pcmd("const char *from = (const char *)from_;")
2685 pcmd("const char *to = (const char *)to_;")
2686 pcmd("if (res == 0) {")
2687 pcmd(" if (from) {")
2688 pcmd(" POST_READ(from, __sanitizer::internal_strlen(from) + 1);")
2689 pcmd(" }")
2690 pcmd(" if (to) {")
2691 pcmd(" POST_READ(to, __sanitizer::internal_strlen(to) + 1);")
2692 pcmd(" }")
2693 pcmd("}")
2694 }
2695 } else if (syscall == "mkfifoat") {
2696 if (mode == "pre") {
2697 pcmd("const char *path = (const char *)path_;")
2698 pcmd("if (path) {")
2699 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
2700 pcmd("}")
2701 } else {
2702 pcmd("const char *path = (const char *)path_;")
2703 pcmd("if (res == 0) {")
2704 pcmd(" if (path) {")
2705 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
2706 pcmd(" }")
2707 pcmd("}")
2708 }
2709 } else if (syscall == "mknodat") {
2710 if (mode == "pre") {
2711 pcmd("const char *path = (const char *)path_;")
2712 pcmd("if (path) {")
2713 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
2714 pcmd("}")
2715 } else {
2716 pcmd("const char *path = (const char *)path_;")
2717 pcmd("if (res == 0) {")
2718 pcmd(" if (path) {")
2719 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
2720 pcmd(" }")
2721 pcmd("}")
2722 }
2723 } else if (syscall == "mkdirat") {
2724 if (mode == "pre") {
2725 pcmd("const char *path = (const char *)path_;")
2726 pcmd("if (path) {")
2727 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
2728 pcmd("}")
2729 } else {
2730 pcmd("const char *path = (const char *)path_;")
2731 pcmd("if (res == 0) {")
2732 pcmd(" if (path) {")
2733 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
2734 pcmd(" }")
2735 pcmd("}")
2736 }
2737 } else if (syscall == "faccessat") {
2738 if (mode == "pre") {
2739 pcmd("const char *path = (const char *)path_;")
2740 pcmd("if (path) {")
2741 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
2742 pcmd("}")
2743 } else {
2744 pcmd("const char *path = (const char *)path_;")
2745 pcmd("if (res == 0) {")
2746 pcmd(" if (path) {")
2747 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
2748 pcmd(" }")
2749 pcmd("}")
2750 }
2751 } else if (syscall == "fchmodat") {
2752 if (mode == "pre") {
2753 pcmd("const char *path = (const char *)path_;")
2754 pcmd("if (path) {")
2755 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
2756 pcmd("}")
2757 } else {
2758 pcmd("const char *path = (const char *)path_;")
2759 pcmd("if (res == 0) {")
2760 pcmd(" if (path) {")
2761 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
2762 pcmd(" }")
2763 pcmd("}")
2764 }
2765 } else if (syscall == "fchownat") {
2766 if (mode == "pre") {
2767 pcmd("const char *path = (const char *)path_;")
2768 pcmd("if (path) {")
2769 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
2770 pcmd("}")
2771 } else {
2772 pcmd("const char *path = (const char *)path_;")
2773 pcmd("if (res == 0) {")
2774 pcmd(" if (path) {")
2775 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
2776 pcmd(" }")
2777 pcmd("}")
2778 }
2779 } else if (syscall == "fexecve") {
2780 pcmd("/* TODO */")
2781 } else if (syscall == "fstatat") {
2782 if (mode == "pre") {
2783 pcmd("const char *path = (const char *)path_;")
2784 pcmd("if (path) {")
2785 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
2786 pcmd("}")
2787 } else {
2788 pcmd("const char *path = (const char *)path_;")
2789 pcmd("if (path) {")
2790 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
2791 pcmd("}")
2792 }
2793 } else if (syscall == "utimensat") {
2794 if (mode == "pre") {
2795 pcmd("const char *path = (const char *)path_;")
2796 pcmd("if (path) {")
2797 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
2798 pcmd("}")
2799 pcmd("if (tptr_) {")
2800 pcmd(" PRE_READ(tptr_, struct_timespec_sz);")
2801 pcmd("}")
2802 } else {
2803 pcmd("const char *path = (const char *)path_;")
2804 pcmd("if (res > 0) {")
2805 pcmd(" if (path) {")
2806 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
2807 pcmd(" }")
2808 pcmd(" if (tptr_) {")
2809 pcmd(" POST_READ(tptr_, struct_timespec_sz);")
2810 pcmd(" }")
2811 pcmd("}")
2812 }
2813 } else if (syscall == "openat") {
2814 if (mode == "pre") {
2815 pcmd("const char *path = (const char *)path_;")
2816 pcmd("if (path) {")
2817 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
2818 pcmd("}")
2819 } else {
2820 pcmd("const char *path = (const char *)path_;")
2821 pcmd("if (res > 0) {")
2822 pcmd(" if (path) {")
2823 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
2824 pcmd(" }")
2825 pcmd("}")
2826 }
2827 } else if (syscall == "readlinkat") {
2828 if (mode == "pre") {
2829 pcmd("const char *path = (const char *)path_;")
2830 pcmd("if (path) {")
2831 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
2832 pcmd("}")
2833 } else {
2834 pcmd("const char *path = (const char *)path_;")
2835 pcmd("if (res > 0) {")
2836 pcmd(" if (path) {")
2837 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
2838 pcmd(" }")
2839 pcmd("}")
2840 }
2841 } else if (syscall == "symlinkat") {
2842 if (mode == "pre") {
2843 pcmd("const char *path1 = (const char *)path1_;")
2844 pcmd("const char *path2 = (const char *)path2_;")
2845 pcmd("if (path1) {")
2846 pcmd(" PRE_READ(path1, __sanitizer::internal_strlen(path1) + 1);")
2847 pcmd("}")
2848 pcmd("if (path2) {")
2849 pcmd(" PRE_READ(path2, __sanitizer::internal_strlen(path2) + 1);")
2850 pcmd("}")
2851 } else {
2852 pcmd("const char *path1 = (const char *)path1_;")
2853 pcmd("const char *path2 = (const char *)path2_;")
2854 pcmd("if (res == 0) {")
2855 pcmd(" if (path1) {")
2856 pcmd(" POST_READ(path1, __sanitizer::internal_strlen(path1) + 1);")
2857 pcmd(" }")
2858 pcmd(" if (path2) {")
2859 pcmd(" POST_READ(path2, __sanitizer::internal_strlen(path2) + 1);")
2860 pcmd(" }")
2861 pcmd("}")
2862 }
2863 } else if (syscall == "unlinkat") {
2864 if (mode == "pre") {
2865 pcmd("const char *path = (const char *)path_;")
2866 pcmd("if (path) {")
2867 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
2868 pcmd("}")
2869 } else {
2870 pcmd("const char *path = (const char *)path_;")
2871 pcmd("if (res == 0) {")
2872 pcmd(" if (path) {")
2873 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
2874 pcmd(" }")
2875 pcmd("}")
2876 }
2877 } else if (syscall == "futimens") {
2878 if (mode == "pre") {
2879 pcmd("struct __sanitizer_timespec **tptr = (struct __sanitizer_timespec **)tptr_;")
2880 pcmd("if (tptr) {")
2881 pcmd(" PRE_READ(tptr[0], struct_timespec_sz);")
2882 pcmd(" PRE_READ(tptr[1], struct_timespec_sz);")
2883 pcmd("}")
2884 } else {
2885 pcmd("struct __sanitizer_timespec **tptr = (struct __sanitizer_timespec **)tptr_;")
2886 pcmd("if (res == 0) {")
2887 pcmd(" if (tptr) {")
2888 pcmd(" POST_READ(tptr[0], struct_timespec_sz);")
2889 pcmd(" POST_READ(tptr[1], struct_timespec_sz);")
2890 pcmd(" }")
2891 pcmd("}")
2892 }
2893 } else if (syscall == "__quotactl") {
2894 if (mode == "pre") {
2895 pcmd("const char *path = (const char *)path_;")
2896 pcmd("if (path) {")
2897 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
2898 pcmd("}")
2899 } else {
2900 pcmd("const char *path = (const char *)path_;")
2901 pcmd("if (res == 0) {")
2902 pcmd(" if (path) {")
2903 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
2904 pcmd(" }")
2905 pcmd("}")
2906 }
2907 } else if (syscall == "posix_spawn") {
2908 if (mode == "pre") {
2909 pcmd("const char *path = (const char *)path_;")
2910 pcmd("if (path) {")
2911 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);")
2912 pcmd("}")
2913 } else {
2914 pcmd("const char *path = (const char *)path_;")
2915 pcmd("if (pid_) {")
2916 pcmd(" if (path) {")
2917 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);")
2918 pcmd(" }")
2919 pcmd("}")
2920 }
2921 } else if (syscall == "recvmmsg") {
2922 if (mode == "pre") {
2923 pcmd("if (timeout_) {")
2924 pcmd(" PRE_READ(timeout_, struct_timespec_sz);")
2925 pcmd("}")
2926 } else {
2927 pcmd("if (res >= 0) {")
2928 pcmd(" if (timeout_) {")
2929 pcmd(" POST_READ(timeout_, struct_timespec_sz);")
2930 pcmd(" }")
2931 pcmd("}")
2932 }
2933 } else if (syscall == "sendmmsg") {
2934 if (mode == "pre") {
2935 pcmd("struct __sanitizer_mmsghdr *mmsg = (struct __sanitizer_mmsghdr *)mmsg_;")
8faf50e0 2936 pcmd("if (mmsg) {")
a1dfa0c6 2937 pcmd(" PRE_READ(mmsg, sizeof(struct __sanitizer_mmsghdr) * (vlen_ > 1024 ? 1024 : vlen_));")
8faf50e0
XL
2938 pcmd("}")
2939 } else {
2940 pcmd("struct __sanitizer_mmsghdr *mmsg = (struct __sanitizer_mmsghdr *)mmsg_;")
8faf50e0
XL
2941 pcmd("if (res >= 0) {")
2942 pcmd(" if (mmsg) {")
a1dfa0c6 2943 pcmd(" POST_READ(mmsg, sizeof(struct __sanitizer_mmsghdr) * (vlen_ > 1024 ? 1024 : vlen_));")
8faf50e0
XL
2944 pcmd(" }")
2945 pcmd("}")
2946 }
2947 } else if (syscall == "clock_nanosleep") {
2948 if (mode == "pre") {
2949 pcmd("if (rqtp_) {")
2950 pcmd(" PRE_READ(rqtp_, struct_timespec_sz);")
2951 pcmd("}")
2952 } else {
2953 pcmd("if (rqtp_) {")
2954 pcmd(" POST_READ(rqtp_, struct_timespec_sz);")
2955 pcmd("}")
2956 }
2957 } else if (syscall == "___lwp_park60") {
2958 if (mode == "pre") {
2959 pcmd("if (ts_) {")
2960 pcmd(" PRE_READ(ts_, struct_timespec_sz);")
2961 pcmd("}")
2962 } else {
2963 pcmd("if (res == 0) {")
2964 pcmd(" if (ts_) {")
2965 pcmd(" POST_READ(ts_, struct_timespec_sz);")
2966 pcmd(" }")
2967 pcmd("}")
2968 }
2969 } else if (syscall == "posix_fallocate") {
2970 pcmd("/* Nothing to do */")
2971 } else if (syscall == "fdiscard") {
2972 pcmd("/* Nothing to do */")
2973 } else if (syscall == "wait6") {
2974 pcmd("/* Nothing to do */")
2975 } else if (syscall == "clock_getcpuclockid2") {
2976 pcmd("/* Nothing to do */")
2977 } else {
2978 print "Unrecognized syscall: " syscall
2979 abnormal_exit = 1
2980 exit 1
2981 }
2982}