Introduce --strace flag for system call tracing
This is similar to the --ftrace (c function call trace) flag, except
it's less noisy since it only logs system calls to stderr. Having this
flag is valuable because (1) system call tracing tells us a lot about
the behavior of complex programs and (2) it's usually very hard to get
system call tracing on various operating systems, e.g. strace, ktrace,
dtruss, truss, nttrace, etc. Especially on Apple platforms where even
with the special boot trick, debuggers still aren't guaranteed to work.
make -j8 o//examples
o//examples/hello.com --strace
This is enabled by default in MODE=, MODE=opt, and MODE=dbg. In MODE=dbg
extra information will be printed.
make -j8 MODE=dbg o/dbg/examples
o/dbg/examples/hello.com --strace |& less
This change also changes:
- Rename IsText() → _istext()
- Rename IsUtf8() → _isutf8()
- Fix madvise() on Windows NT
- Fix empty string case of inet_ntop()
- vfork() wrapper now saves and restores errno
- Update xsigaction() to yoink syscall support
2022-03-19 01:07:28 +00:00
|
|
|
#ifndef COSMOPOLITAN_LIBC_CALLS_STRACE_INTERNAL_H_
|
|
|
|
#define COSMOPOLITAN_LIBC_CALLS_STRACE_INTERNAL_H_
|
2022-08-11 19:13:18 +00:00
|
|
|
#include "libc/intrin/likely.h"
|
2022-05-18 23:41:29 +00:00
|
|
|
#include "libc/runtime/runtime.h"
|
Introduce --strace flag for system call tracing
This is similar to the --ftrace (c function call trace) flag, except
it's less noisy since it only logs system calls to stderr. Having this
flag is valuable because (1) system call tracing tells us a lot about
the behavior of complex programs and (2) it's usually very hard to get
system call tracing on various operating systems, e.g. strace, ktrace,
dtruss, truss, nttrace, etc. Especially on Apple platforms where even
with the special boot trick, debuggers still aren't guaranteed to work.
make -j8 o//examples
o//examples/hello.com --strace
This is enabled by default in MODE=, MODE=opt, and MODE=dbg. In MODE=dbg
extra information will be printed.
make -j8 MODE=dbg o/dbg/examples
o/dbg/examples/hello.com --strace |& less
This change also changes:
- Rename IsText() → _istext()
- Rename IsUtf8() → _isutf8()
- Fix madvise() on Windows NT
- Fix empty string case of inet_ntop()
- vfork() wrapper now saves and restores errno
- Update xsigaction() to yoink syscall support
2022-03-19 01:07:28 +00:00
|
|
|
|
2022-07-19 07:33:36 +00:00
|
|
|
#define _KERNTRACE 0 /* not configurable w/ flag yet */
|
2022-05-12 13:58:51 +00:00
|
|
|
#define _POLLTRACE 0 /* not configurable w/ flag yet */
|
2022-04-20 16:56:53 +00:00
|
|
|
#define _DATATRACE 1 /* not configurable w/ flag yet */
|
2022-05-25 18:31:08 +00:00
|
|
|
#define _NTTRACE 0 /* not configurable w/ flag yet */
|
2022-04-16 17:40:23 +00:00
|
|
|
|
2022-05-26 05:29:10 +00:00
|
|
|
#define STRACE_PROLOGUE "%rSYS %6P %'18T "
|
Introduce --strace flag for system call tracing
This is similar to the --ftrace (c function call trace) flag, except
it's less noisy since it only logs system calls to stderr. Having this
flag is valuable because (1) system call tracing tells us a lot about
the behavior of complex programs and (2) it's usually very hard to get
system call tracing on various operating systems, e.g. strace, ktrace,
dtruss, truss, nttrace, etc. Especially on Apple platforms where even
with the special boot trick, debuggers still aren't guaranteed to work.
make -j8 o//examples
o//examples/hello.com --strace
This is enabled by default in MODE=, MODE=opt, and MODE=dbg. In MODE=dbg
extra information will be printed.
make -j8 MODE=dbg o/dbg/examples
o/dbg/examples/hello.com --strace |& less
This change also changes:
- Rename IsText() → _istext()
- Rename IsUtf8() → _isutf8()
- Fix madvise() on Windows NT
- Fix empty string case of inet_ntop()
- vfork() wrapper now saves and restores errno
- Update xsigaction() to yoink syscall support
2022-03-19 01:07:28 +00:00
|
|
|
|
|
|
|
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
|
|
|
COSMOPOLITAN_C_START_
|
|
|
|
|
|
|
|
#ifdef SYSDEBUG
|
|
|
|
#define STRACE(FMT, ...) \
|
|
|
|
do { \
|
2022-05-29 15:14:55 +00:00
|
|
|
if (UNLIKELY(__strace > 0)) { \
|
2022-04-24 16:59:22 +00:00
|
|
|
__stracef(STRACE_PROLOGUE FMT "\n", ##__VA_ARGS__); \
|
Introduce --strace flag for system call tracing
This is similar to the --ftrace (c function call trace) flag, except
it's less noisy since it only logs system calls to stderr. Having this
flag is valuable because (1) system call tracing tells us a lot about
the behavior of complex programs and (2) it's usually very hard to get
system call tracing on various operating systems, e.g. strace, ktrace,
dtruss, truss, nttrace, etc. Especially on Apple platforms where even
with the special boot trick, debuggers still aren't guaranteed to work.
make -j8 o//examples
o//examples/hello.com --strace
This is enabled by default in MODE=, MODE=opt, and MODE=dbg. In MODE=dbg
extra information will be printed.
make -j8 MODE=dbg o/dbg/examples
o/dbg/examples/hello.com --strace |& less
This change also changes:
- Rename IsText() → _istext()
- Rename IsUtf8() → _isutf8()
- Fix madvise() on Windows NT
- Fix empty string case of inet_ntop()
- vfork() wrapper now saves and restores errno
- Update xsigaction() to yoink syscall support
2022-03-19 01:07:28 +00:00
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
#else
|
|
|
|
#define STRACE(FMT, ...) (void)0
|
|
|
|
#endif
|
|
|
|
|
2022-04-18 07:01:26 +00:00
|
|
|
#if defined(SYSDEBUG) && _DATATRACE
|
|
|
|
#define DATATRACE(FMT, ...) STRACE(FMT, ##__VA_ARGS__)
|
|
|
|
#else
|
|
|
|
#define DATATRACE(FMT, ...) (void)0
|
|
|
|
#endif
|
|
|
|
|
2022-04-16 17:40:23 +00:00
|
|
|
#if defined(SYSDEBUG) && _POLLTRACE
|
|
|
|
#define POLLTRACE(FMT, ...) STRACE(FMT, ##__VA_ARGS__)
|
|
|
|
#else
|
|
|
|
#define POLLTRACE(FMT, ...) (void)0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(SYSDEBUG) && _KERNTRACE
|
|
|
|
#define KERNTRACE(FMT, ...) STRACE(FMT, ##__VA_ARGS__)
|
|
|
|
#else
|
|
|
|
#define KERNTRACE(FMT, ...) (void)0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(SYSDEBUG) && _NTTRACE
|
|
|
|
#define NTTRACE(FMT, ...) STRACE(FMT, ##__VA_ARGS__)
|
|
|
|
#else
|
|
|
|
#define NTTRACE(FMT, ...) (void)0
|
|
|
|
#endif
|
|
|
|
|
Introduce --strace flag for system call tracing
This is similar to the --ftrace (c function call trace) flag, except
it's less noisy since it only logs system calls to stderr. Having this
flag is valuable because (1) system call tracing tells us a lot about
the behavior of complex programs and (2) it's usually very hard to get
system call tracing on various operating systems, e.g. strace, ktrace,
dtruss, truss, nttrace, etc. Especially on Apple platforms where even
with the special boot trick, debuggers still aren't guaranteed to work.
make -j8 o//examples
o//examples/hello.com --strace
This is enabled by default in MODE=, MODE=opt, and MODE=dbg. In MODE=dbg
extra information will be printed.
make -j8 MODE=dbg o/dbg/examples
o/dbg/examples/hello.com --strace |& less
This change also changes:
- Rename IsText() → _istext()
- Rename IsUtf8() → _isutf8()
- Fix madvise() on Windows NT
- Fix empty string case of inet_ntop()
- vfork() wrapper now saves and restores errno
- Update xsigaction() to yoink syscall support
2022-03-19 01:07:28 +00:00
|
|
|
void __stracef(const char *, ...);
|
|
|
|
|
|
|
|
COSMOPOLITAN_C_END_
|
|
|
|
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
|
|
|
#endif /* COSMOPOLITAN_LIBC_CALLS_STRACE_INTERNAL_H_ */
|