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