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
|
|
|
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
|
|
|
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
|
|
|
╞══════════════════════════════════════════════════════════════════════════════╡
|
|
|
|
│ Copyright 2021 Justine Alexandra Roberts Tunney │
|
|
|
|
│ │
|
|
|
|
│ Permission to use, copy, modify, and/or distribute this software for │
|
|
|
|
│ any purpose with or without fee is hereby granted, provided that the │
|
|
|
|
│ above copyright notice and this permission notice appear in all copies. │
|
|
|
|
│ │
|
|
|
|
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
|
|
|
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
|
|
|
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
|
|
|
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
|
|
|
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
|
|
|
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
|
|
|
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
|
|
|
│ PERFORMANCE OF THIS SOFTWARE. │
|
|
|
|
╚─────────────────────────────────────────────────────────────────────────────*/
|
2022-03-25 14:11:44 +00:00
|
|
|
#include "libc/calls/calls.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
|
|
|
#include "libc/calls/strace.internal.h"
|
2022-03-25 14:11:44 +00:00
|
|
|
#include "libc/calls/struct/sigset.h"
|
2022-04-17 03:29:08 +00:00
|
|
|
#include "libc/calls/struct/termios.h"
|
|
|
|
#include "libc/calls/termios.h"
|
|
|
|
#include "libc/calls/ttydefaults.h"
|
2022-03-25 14:11:44 +00:00
|
|
|
#include "libc/dce.h"
|
2022-04-16 17:40:23 +00:00
|
|
|
#include "libc/dns/dns.h"
|
2022-04-17 03:29:08 +00:00
|
|
|
#include "libc/errno.h"
|
2022-04-15 06:39:48 +00:00
|
|
|
#include "libc/intrin/describeflags.internal.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
|
|
|
#include "libc/intrin/kprintf.h"
|
|
|
|
#include "libc/macros.internal.h"
|
2022-04-16 17:40:23 +00:00
|
|
|
#include "libc/nexgen32e/cpuid4.internal.h"
|
|
|
|
#include "libc/nexgen32e/kcpuids.h"
|
|
|
|
#include "libc/nexgen32e/x86feature.h"
|
|
|
|
#include "libc/nexgen32e/x86info.h"
|
2022-04-15 06:39:48 +00:00
|
|
|
#include "libc/nt/enum/startf.h"
|
|
|
|
#include "libc/nt/runtime.h"
|
|
|
|
#include "libc/nt/startupinfo.h"
|
|
|
|
#include "libc/nt/struct/ldrdatatableentry.h"
|
|
|
|
#include "libc/nt/struct/startupinfo.h"
|
|
|
|
#include "libc/nt/struct/teb.h"
|
2022-04-16 17:40:23 +00:00
|
|
|
#include "libc/runtime/internal.h"
|
|
|
|
#include "libc/runtime/memtrack.internal.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
|
|
|
#include "libc/runtime/runtime.h"
|
|
|
|
#include "libc/runtime/stack.h"
|
2022-03-25 14:11:44 +00:00
|
|
|
#include "libc/sock/internal.h"
|
|
|
|
#include "libc/sock/sock.h"
|
2022-04-24 16:59:22 +00:00
|
|
|
#include "libc/str/str.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
|
|
|
#include "libc/sysv/consts/auxv.h"
|
2022-03-25 14:11:44 +00:00
|
|
|
#include "libc/sysv/consts/f.h"
|
|
|
|
#include "libc/sysv/consts/poll.h"
|
|
|
|
#include "libc/sysv/consts/sig.h"
|
2022-04-17 03:29:08 +00:00
|
|
|
#include "libc/sysv/consts/termios.h"
|
2022-04-16 17:40:23 +00:00
|
|
|
#include "tool/decode/lib/idname.h"
|
|
|
|
#include "tool/decode/lib/x86idnames.h"
|
2022-03-25 14:11:44 +00:00
|
|
|
|
2022-04-24 16:59:22 +00:00
|
|
|
STATIC_YOINK("strerror"); // for kprintf()
|
2022-04-16 17:40:23 +00:00
|
|
|
STATIC_YOINK("strsignal"); // for kprintf()
|
|
|
|
|
|
|
|
#define PRINT(FMT, ...) \
|
|
|
|
do { \
|
|
|
|
kprintf(prologue); \
|
2022-04-24 16:59:22 +00:00
|
|
|
kprintf(FMT "\n", ##__VA_ARGS__); \
|
2022-04-16 17:40:23 +00:00
|
|
|
} while (0)
|
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
|
|
|
|
|
|
|
static const struct AuxiliaryValue {
|
|
|
|
const char *fmt;
|
|
|
|
long *id;
|
|
|
|
const char *name;
|
|
|
|
} kAuxiliaryValues[] = {
|
|
|
|
{"%-14p", &AT_EXECFD, "AT_EXECFD"},
|
|
|
|
{"%-14p", &AT_PHDR, "AT_PHDR"},
|
|
|
|
{"%-14p", &AT_PHENT, "AT_PHENT"},
|
|
|
|
{"%-14p", &AT_PHNUM, "AT_PHNUM"},
|
|
|
|
{"%-14p", &AT_PAGESZ, "AT_PAGESZ"},
|
|
|
|
{"%-14p", &AT_BASE, "AT_BASE"},
|
|
|
|
{"%-14p", &AT_ENTRY, "AT_ENTRY"},
|
|
|
|
{"%-14p", &AT_NOTELF, "AT_NOTELF"},
|
|
|
|
{"%-14d", &AT_UID, "AT_UID"},
|
|
|
|
{"%-14d", &AT_EUID, "AT_EUID"},
|
|
|
|
{"%-14d", &AT_GID, "AT_GID"},
|
|
|
|
{"%-14d", &AT_EGID, "AT_EGID"},
|
|
|
|
{"%-14d", &AT_CLKTCK, "AT_CLKTCK"},
|
|
|
|
{"%-14d", &AT_OSRELDATE, "AT_OSRELDATE"},
|
|
|
|
{"%-14p", &AT_PLATFORM, "AT_PLATFORM"},
|
|
|
|
{"%-14p", &AT_DCACHEBSIZE, "AT_DCACHEBSIZE"},
|
|
|
|
{"%-14p", &AT_ICACHEBSIZE, "AT_ICACHEBSIZE"},
|
|
|
|
{"%-14p", &AT_UCACHEBSIZE, "AT_UCACHEBSIZE"},
|
|
|
|
{"%-14p", &AT_SECURE, "AT_SECURE"},
|
|
|
|
{"%-14s", &AT_BASE_PLATFORM, "AT_BASE_PLATFORM"},
|
|
|
|
{"%-14p", &AT_RANDOM, "AT_RANDOM"},
|
|
|
|
{"%-14s", &AT_EXECFN, "AT_EXECFN"},
|
|
|
|
{"%-14p", &AT_SYSINFO_EHDR, "AT_SYSINFO_EHDR"},
|
|
|
|
{"%-14p", &AT_FLAGS, "AT_FLAGS"},
|
|
|
|
{"%-14p", &AT_HWCAP, "AT_HWCAP"},
|
|
|
|
{"%-14p", &AT_HWCAP2, "AT_HWCAP2"},
|
|
|
|
{"%-14p", &AT_STACKBASE, "AT_STACKBASE"},
|
|
|
|
{"%-14p", &AT_CANARY, "AT_CANARY"},
|
|
|
|
{"%-14p", &AT_CANARYLEN, "AT_CANARYLEN"},
|
|
|
|
{"%-14ld", &AT_NCPUS, "AT_NCPUS"},
|
|
|
|
{"%-14p", &AT_PAGESIZES, "AT_PAGESIZES"},
|
|
|
|
{"%-14d", &AT_PAGESIZESLEN, "AT_PAGESIZESLEN"},
|
|
|
|
{"%-14p", &AT_TIMEKEEP, "AT_TIMEKEEP"},
|
|
|
|
{"%-14p", &AT_STACKPROT, "AT_STACKPROT"},
|
|
|
|
{"%-14p", &AT_EHDRFLAGS, "AT_EHDRFLAGS"},
|
|
|
|
};
|
|
|
|
|
2022-04-16 17:40:23 +00:00
|
|
|
static const char *FindNameById(const struct IdName *names, unsigned long id) {
|
|
|
|
for (; names->name; names++) {
|
|
|
|
if (names->id == id) {
|
|
|
|
return names->name;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
static const struct AuxiliaryValue *DescribeAuxv(unsigned long x) {
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < ARRAYLEN(kAuxiliaryValues); ++i) {
|
|
|
|
if (*kAuxiliaryValues[i].id && x == *kAuxiliaryValues[i].id) {
|
|
|
|
return kAuxiliaryValues + i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2022-04-16 17:40:23 +00:00
|
|
|
/**
|
|
|
|
* Prints lots of information about this process, e.g.
|
|
|
|
*
|
|
|
|
* __printargs("");
|
|
|
|
*
|
|
|
|
* This is called automatically in MODE=dbg if `--strace` is used.
|
|
|
|
*
|
|
|
|
* @param prologue needs to be a .rodata kprintf string
|
|
|
|
*/
|
|
|
|
textstartup void __printargs(const char *prologue) {
|
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
|
|
|
long key;
|
|
|
|
char **env;
|
2022-03-25 14:11:44 +00:00
|
|
|
sigset_t ss;
|
2022-04-16 17:40:23 +00:00
|
|
|
unsigned i, n;
|
2022-05-14 11:33:58 +00:00
|
|
|
int e, x, flags;
|
2022-03-23 13:31:55 +00:00
|
|
|
uintptr_t *auxp;
|
2022-04-16 17:40:23 +00:00
|
|
|
struct utsname uts;
|
2022-04-17 03:29:08 +00:00
|
|
|
struct termios termios;
|
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
|
|
|
struct AuxiliaryValue *auxinfo;
|
2022-04-28 16:42:36 +00:00
|
|
|
union {
|
|
|
|
char path[PATH_MAX];
|
|
|
|
struct pollfd pfds[128];
|
|
|
|
} u;
|
|
|
|
|
2022-05-14 11:33:58 +00:00
|
|
|
__atomic_fetch_sub(&g_ftrace, 1, __ATOMIC_RELAXED);
|
|
|
|
__atomic_fetch_sub(&__strace, 1, __ATOMIC_RELAXED);
|
2022-04-17 03:29:08 +00:00
|
|
|
e = errno;
|
2022-04-16 17:40:23 +00:00
|
|
|
|
|
|
|
PRINT("");
|
|
|
|
PRINT("SYSTEM");
|
|
|
|
if (!uname(&uts)) {
|
|
|
|
kprintf(prologue);
|
|
|
|
kprintf(" %s", uts.nodename);
|
|
|
|
if (*uts.sysname) {
|
|
|
|
kprintf(" on %s", uts.sysname);
|
|
|
|
if (*uts.release) {
|
|
|
|
kprintf(" %s", uts.release);
|
|
|
|
}
|
|
|
|
}
|
2022-04-24 16:59:22 +00:00
|
|
|
kprintf("\n");
|
2022-04-16 17:40:23 +00:00
|
|
|
} else {
|
|
|
|
PRINT(" uname() failed %m");
|
|
|
|
}
|
|
|
|
|
|
|
|
PRINT("");
|
|
|
|
PRINT("MICROPROCESSOR");
|
|
|
|
kprintf(prologue);
|
|
|
|
kprintf(" %.*s%.*s%.*s", 4, &KCPUIDS(0H, EBX), 4, &KCPUIDS(0H, EDX), 4,
|
|
|
|
&KCPUIDS(0H, ECX));
|
|
|
|
if (getx86processormodel(kX86ProcessorModelKey)) {
|
|
|
|
kprintf(" %s",
|
|
|
|
FindNameById(kX86MarchNames,
|
|
|
|
getx86processormodel(kX86ProcessorModelKey)->march));
|
|
|
|
}
|
|
|
|
if (getx86processormodel(kX86ProcessorModelKey)) {
|
|
|
|
kprintf(" (%s Grade)",
|
|
|
|
FindNameById(kX86GradeNames,
|
|
|
|
getx86processormodel(kX86ProcessorModelKey)->grade));
|
|
|
|
}
|
2022-04-24 16:59:22 +00:00
|
|
|
kprintf("\n");
|
2022-04-16 17:40:23 +00:00
|
|
|
if ((x = KCPUIDS(16H, EAX) & 0x7fff)) {
|
|
|
|
kprintf(prologue);
|
|
|
|
kprintf(" %dmhz %s", x, "freq");
|
|
|
|
if ((x = KCPUIDS(16H, EBX) & 0x7fff)) {
|
|
|
|
kprintf(" / %dmhz %s", x, "turbo");
|
|
|
|
}
|
|
|
|
if ((x = KCPUIDS(16H, ECX) & 0x7fff)) {
|
|
|
|
kprintf(" / %dmhz %s", x, "bus");
|
|
|
|
}
|
2022-04-24 16:59:22 +00:00
|
|
|
kprintf("\n");
|
2022-04-16 17:40:23 +00:00
|
|
|
}
|
|
|
|
if (X86_HAVE(HYPERVISOR)) {
|
|
|
|
unsigned eax, ebx, ecx, edx;
|
|
|
|
asm("push\t%%rbx\n\t"
|
|
|
|
"cpuid\n\t"
|
|
|
|
"mov\t%%ebx,%1\n\t"
|
|
|
|
"pop\t%%rbx"
|
|
|
|
: "=a"(eax), "=rm"(ebx), "=c"(ecx), "=d"(edx)
|
|
|
|
: "0"(0x40000000), "2"(0));
|
|
|
|
PRINT(" Running inside %.4s%.4s%.4s (eax=%#x)", &ebx, &ecx, &edx, eax);
|
|
|
|
}
|
|
|
|
CPUID4_ITERATE(i, {
|
|
|
|
PRINT(" L%d%s%s %u-way %,u byte cache w/%s "
|
|
|
|
"%,u sets of %,u byte lines shared across %u threads%s",
|
|
|
|
CPUID4_CACHE_LEVEL,
|
2022-04-24 16:59:22 +00:00
|
|
|
CPUID4_CACHE_TYPE == 1 ? " data"
|
|
|
|
: CPUID4_CACHE_TYPE == 2 ? " code"
|
|
|
|
: "",
|
2022-04-16 17:40:23 +00:00
|
|
|
CPUID4_IS_FULLY_ASSOCIATIVE ? " fully-associative" : "",
|
|
|
|
CPUID4_WAYS_OF_ASSOCIATIVITY, CPUID4_CACHE_SIZE_IN_BYTES,
|
|
|
|
CPUID4_PHYSICAL_LINE_PARTITIONS > 1 ? " physically partitioned" : "",
|
|
|
|
CPUID4_NUMBER_OF_SETS, CPUID4_SYSTEM_COHERENCY_LINE_SIZE,
|
|
|
|
CPUID4_MAX_THREADS_SHARING_CACHE,
|
|
|
|
CPUID4_COMPLEX_INDEXING ? " complexly-indexed" : "");
|
|
|
|
});
|
|
|
|
kprintf(prologue);
|
|
|
|
kprintf(" ");
|
|
|
|
if (X86_HAVE(SSE3)) kprintf(" SSE3");
|
|
|
|
if (X86_HAVE(SSSE3)) kprintf(" SSSE3");
|
|
|
|
if (X86_HAVE(SSE4_2)) kprintf(" SSE4_2");
|
|
|
|
if (X86_HAVE(POPCNT)) kprintf(" POPCNT");
|
|
|
|
if (X86_HAVE(AVX)) kprintf(" AVX");
|
|
|
|
if (X86_HAVE(AVX2)) kprintf(" AVX2");
|
|
|
|
if (X86_HAVE(FMA)) kprintf(" FMA");
|
|
|
|
if (X86_HAVE(BMI)) kprintf(" BMI");
|
|
|
|
if (X86_HAVE(BMI2)) kprintf(" BMI2");
|
|
|
|
if (X86_HAVE(ADX)) kprintf(" ADX");
|
|
|
|
if (X86_HAVE(F16C)) kprintf(" F16C");
|
|
|
|
if (X86_HAVE(SHA)) kprintf(" SHA");
|
|
|
|
if (X86_HAVE(AES)) kprintf(" AES");
|
|
|
|
if (X86_HAVE(RDRND)) kprintf(" RDRND");
|
|
|
|
if (X86_HAVE(RDSEED)) kprintf(" RDSEED");
|
|
|
|
if (X86_HAVE(RDTSCP)) kprintf(" RDTSCP");
|
|
|
|
if (X86_HAVE(RDPID)) kprintf(" RDPID");
|
|
|
|
if (X86_HAVE(LA57)) kprintf(" LA57");
|
|
|
|
if (X86_HAVE(FSGSBASE)) kprintf(" FSGSBASE");
|
2022-04-24 16:59:22 +00:00
|
|
|
kprintf("\n");
|
2022-04-16 17:40:23 +00:00
|
|
|
|
|
|
|
PRINT("");
|
|
|
|
PRINT("FILE DESCRIPTORS");
|
2022-04-28 16:42:36 +00:00
|
|
|
for (i = 0; i < ARRAYLEN(u.pfds); ++i) {
|
|
|
|
u.pfds[i].fd = i;
|
|
|
|
u.pfds[i].events = POLLIN;
|
2022-04-16 17:40:23 +00:00
|
|
|
}
|
2022-04-28 16:42:36 +00:00
|
|
|
if ((n = poll(u.pfds, ARRAYLEN(u.pfds), 0)) != -1) {
|
|
|
|
for (i = 0; i < ARRAYLEN(u.pfds); ++i) {
|
|
|
|
if (i && (u.pfds[i].revents & POLLNVAL)) continue;
|
2022-04-23 01:55:28 +00:00
|
|
|
PRINT(" ☼ %d (revents=%#hx fcntl(F_GETFL)=%#x isatty()=%hhhd)", i,
|
2022-04-28 16:42:36 +00:00
|
|
|
u.pfds[i].revents, fcntl(i, F_GETFL), isatty(i));
|
2022-04-16 17:40:23 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
PRINT(" poll() returned %d %m", n);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!sigprocmask(SIG_BLOCK, 0, &ss)) {
|
|
|
|
PRINT("");
|
|
|
|
PRINT("SIGNALS {%#lx, %#lx}", ss.__bits[0], ss.__bits[1]);
|
|
|
|
if (ss.__bits[0] || ss.__bits[1]) {
|
|
|
|
for (i = 0; i < 32; ++i) {
|
|
|
|
if (ss.__bits[0] & (1u << i)) {
|
|
|
|
PRINT(" ☼ %G (%d) is masked", i + 1, i + 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
PRINT(" no signals blocked");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
PRINT("");
|
|
|
|
PRINT("SIGNALS");
|
|
|
|
PRINT(" error: sigprocmask() failed %m");
|
|
|
|
}
|
2022-03-25 14:11:44 +00:00
|
|
|
|
2022-04-15 06:39:48 +00:00
|
|
|
PRINT("");
|
2022-03-25 14:11:44 +00:00
|
|
|
PRINT("ARGUMENTS (%p)", __argv);
|
2022-04-16 17:40:23 +00:00
|
|
|
if (*__argv) {
|
|
|
|
for (i = 0; i < __argc; ++i) {
|
|
|
|
PRINT(" ☼ %s", __argv[i]);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
PRINT(" none");
|
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-03-25 14:11:44 +00:00
|
|
|
|
2022-04-15 06:39:48 +00:00
|
|
|
PRINT("");
|
2022-03-25 14:11:44 +00:00
|
|
|
PRINT("ENVIRONMENT (%p)", __envp);
|
2022-04-16 17:40:23 +00:00
|
|
|
if (*__envp) {
|
|
|
|
for (env = __envp; *env; ++env) {
|
|
|
|
PRINT(" ☼ %s", *env);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
PRINT(" none");
|
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-03-25 14:11:44 +00:00
|
|
|
|
2022-04-15 06:39:48 +00:00
|
|
|
PRINT("");
|
2022-03-25 14:11:44 +00:00
|
|
|
PRINT("AUXILIARY (%p)", __auxv);
|
2022-04-16 17:40:23 +00:00
|
|
|
if (*__auxv) {
|
|
|
|
if (*__auxv) {
|
|
|
|
for (auxp = __auxv; *auxp; auxp += 2) {
|
|
|
|
if ((auxinfo = DescribeAuxv(auxp[0]))) {
|
2022-04-28 16:42:36 +00:00
|
|
|
ksnprintf(u.path, sizeof(u.path), auxinfo->fmt, auxp[1]);
|
|
|
|
PRINT(" ☼ %16s[%4ld] = %s", auxinfo->name, auxp[0], u.path);
|
2022-04-16 17:40:23 +00:00
|
|
|
} else {
|
|
|
|
PRINT(" ☼ %16s[%4ld] = %014p", "unknown", auxp[0], auxp[1]);
|
|
|
|
}
|
|
|
|
}
|
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-04-16 17:40:23 +00:00
|
|
|
} else {
|
|
|
|
PRINT(" none");
|
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-03-25 14:11:44 +00:00
|
|
|
|
2022-04-15 06:39:48 +00:00
|
|
|
PRINT("");
|
2022-03-25 14:11:44 +00:00
|
|
|
PRINT("SPECIALS");
|
2022-04-16 17:40:23 +00:00
|
|
|
umask((i = umask(022)));
|
|
|
|
PRINT(" ☼ %s = %#o", "umask()", i);
|
|
|
|
PRINT(" ☼ %s = %d", "getpid()", getpid());
|
|
|
|
PRINT(" ☼ %s = %d", "getppid()", getppid());
|
|
|
|
PRINT(" ☼ %s = %d", "getpgrp()", getpgrp());
|
|
|
|
PRINT(" ☼ %s = %d", "getsid()", getsid(0));
|
|
|
|
PRINT(" ☼ %s = %d", "getuid()", getuid());
|
|
|
|
PRINT(" ☼ %s = %d", "geteuid()", geteuid());
|
|
|
|
PRINT(" ☼ %s = %d", "getgid()", getgid());
|
|
|
|
PRINT(" ☼ %s = %d", "getegid()", getegid());
|
2022-04-15 06:39:48 +00:00
|
|
|
PRINT(" ☼ %s = %#s", "kTmpPath", kTmpPath);
|
|
|
|
PRINT(" ☼ %s = %#s", "kNtSystemDirectory", kNtSystemDirectory);
|
|
|
|
PRINT(" ☼ %s = %#s", "kNtWindowsDirectory", kNtWindowsDirectory);
|
2022-04-26 04:16:05 +00:00
|
|
|
PRINT(" ☼ %s = %#s", "GetProgramExecutableName", GetProgramExecutableName());
|
|
|
|
PRINT(" ☼ %s = %#s", "GetInterpreterExecutableName",
|
2022-04-28 16:42:36 +00:00
|
|
|
GetInterpreterExecutableName(u.path, sizeof(u.path)));
|
2022-04-15 06:39:48 +00:00
|
|
|
PRINT(" ☼ %s = %p", "RSP", __builtin_frame_address(0));
|
|
|
|
PRINT(" ☼ %s = %p", "GetStackAddr()", GetStackAddr(0));
|
|
|
|
PRINT(" ☼ %s = %p", "GetStaticStackAddr(0)", GetStaticStackAddr(0));
|
|
|
|
PRINT(" ☼ %s = %p", "GetStackSize()", GetStackSize());
|
2022-03-25 14:11:44 +00:00
|
|
|
|
2022-04-16 17:40:23 +00:00
|
|
|
PRINT("");
|
|
|
|
PRINT("MEMTRACK");
|
|
|
|
PrintMemoryIntervals(2, &_mmi);
|
2022-03-25 14:11:44 +00:00
|
|
|
|
2022-04-17 03:29:08 +00:00
|
|
|
PRINT("");
|
|
|
|
PRINT("TERMIOS");
|
|
|
|
for (i = 0; i < 2; ++i) {
|
|
|
|
if (!tcgetattr(i, &termios)) {
|
|
|
|
PRINT(" - stdin");
|
|
|
|
kprintf(prologue);
|
|
|
|
kprintf(" c_iflag =");
|
|
|
|
if (termios.c_iflag & IGNBRK) kprintf(" IGNBRK");
|
|
|
|
if (termios.c_iflag & BRKINT) kprintf(" BRKINT");
|
|
|
|
if (termios.c_iflag & IGNPAR) kprintf(" IGNPAR");
|
|
|
|
if (termios.c_iflag & PARMRK) kprintf(" PARMRK");
|
|
|
|
if (termios.c_iflag & INPCK) kprintf(" INPCK");
|
|
|
|
if (termios.c_iflag & ISTRIP) kprintf(" ISTRIP");
|
|
|
|
if (termios.c_iflag & INLCR) kprintf(" INLCR");
|
|
|
|
if (termios.c_iflag & IGNCR) kprintf(" IGNCR");
|
|
|
|
if (termios.c_iflag & ICRNL) kprintf(" ICRNL");
|
|
|
|
if (termios.c_iflag & IXON) kprintf(" IXON");
|
|
|
|
if (termios.c_iflag & IXANY) kprintf(" IXANY");
|
|
|
|
if (termios.c_iflag & IXOFF) kprintf(" IXOFF");
|
|
|
|
if (termios.c_iflag & IMAXBEL) kprintf(" IMAXBEL");
|
|
|
|
if (termios.c_iflag & IUTF8) kprintf(" IUTF8");
|
|
|
|
if (termios.c_iflag & IUCLC) kprintf(" IUCLC");
|
2022-04-24 16:59:22 +00:00
|
|
|
kprintf("\n");
|
2022-04-17 03:29:08 +00:00
|
|
|
kprintf(prologue);
|
|
|
|
kprintf(" c_oflag =");
|
|
|
|
if (termios.c_oflag & OPOST) kprintf(" OPOST");
|
|
|
|
if (termios.c_oflag & ONLCR) kprintf(" ONLCR");
|
|
|
|
if (termios.c_oflag & OCRNL) kprintf(" OCRNL");
|
|
|
|
if (termios.c_oflag & ONOCR) kprintf(" ONOCR");
|
|
|
|
if (termios.c_oflag & ONLRET) kprintf(" ONLRET");
|
|
|
|
if (termios.c_oflag & OFILL) kprintf(" OFILL");
|
|
|
|
if (termios.c_oflag & OFDEL) kprintf(" OFDEL");
|
|
|
|
if (termios.c_oflag & OLCUC) kprintf(" OLCUC");
|
|
|
|
if ((termios.c_oflag & NLDLY) == NL0) {
|
|
|
|
kprintf(" NL0");
|
|
|
|
} else if ((termios.c_oflag & NLDLY) == NL1) {
|
|
|
|
kprintf(" NL1");
|
|
|
|
} else if ((termios.c_oflag & NLDLY) == NL2) {
|
|
|
|
kprintf(" NL2");
|
|
|
|
} else if ((termios.c_oflag & NLDLY) == NL3) {
|
|
|
|
kprintf(" NL3");
|
|
|
|
}
|
|
|
|
if ((termios.c_oflag & CRDLY) == CR0) {
|
|
|
|
kprintf(" CR0");
|
|
|
|
} else if ((termios.c_oflag & CRDLY) == CR1) {
|
|
|
|
kprintf(" CR1");
|
|
|
|
} else if ((termios.c_oflag & CRDLY) == CR2) {
|
|
|
|
kprintf(" CR2");
|
|
|
|
} else if ((termios.c_oflag & CRDLY) == CR3) {
|
|
|
|
kprintf(" CR3");
|
|
|
|
}
|
|
|
|
if ((termios.c_oflag & TABDLY) == TAB0) {
|
|
|
|
kprintf(" TAB0");
|
|
|
|
} else if ((termios.c_oflag & TABDLY) == TAB1) {
|
|
|
|
kprintf(" TAB1");
|
|
|
|
} else if ((termios.c_oflag & TABDLY) == TAB2) {
|
|
|
|
kprintf(" TAB2");
|
|
|
|
} else if ((termios.c_oflag & TABDLY) == TAB3) {
|
|
|
|
kprintf(" TAB3");
|
|
|
|
}
|
|
|
|
if ((termios.c_oflag & BSDLY) == BS0) {
|
|
|
|
kprintf(" BS0");
|
|
|
|
} else if ((termios.c_oflag & BSDLY) == BS1) {
|
|
|
|
kprintf(" BS1");
|
|
|
|
}
|
|
|
|
if ((termios.c_oflag & VTDLY) == VT0) {
|
|
|
|
kprintf(" VT0");
|
|
|
|
} else if ((termios.c_oflag & VTDLY) == VT1) {
|
|
|
|
kprintf(" VT1");
|
|
|
|
}
|
|
|
|
if ((termios.c_oflag & FFDLY) == FF0) {
|
|
|
|
kprintf(" FF0");
|
|
|
|
} else if ((termios.c_oflag & FFDLY) == FF1) {
|
|
|
|
kprintf(" FF1");
|
|
|
|
}
|
2022-04-24 16:59:22 +00:00
|
|
|
kprintf("\n");
|
2022-04-17 03:29:08 +00:00
|
|
|
kprintf(prologue);
|
|
|
|
kprintf(" c_cflag =");
|
|
|
|
if (termios.c_cflag & PARENB) kprintf(" PARENB");
|
|
|
|
if (termios.c_cflag & PARODD) kprintf(" PARODD");
|
2022-04-24 16:59:22 +00:00
|
|
|
if (termios.c_cflag & CSTOPB) kprintf(" CSTOPB");
|
|
|
|
if (termios.c_cflag & PARODD) kprintf(" PARODD");
|
2022-04-17 03:29:08 +00:00
|
|
|
if (termios.c_cflag & HUPCL) kprintf(" HUPCL");
|
2022-04-24 16:59:22 +00:00
|
|
|
if (termios.c_cflag & CREAD) kprintf(" CREAD");
|
2022-04-17 03:29:08 +00:00
|
|
|
if (termios.c_cflag & CLOCAL) kprintf(" CLOCAL");
|
|
|
|
if ((termios.c_cflag & CSIZE) == CS5) {
|
|
|
|
kprintf(" CS5");
|
|
|
|
} else if ((termios.c_cflag & CSIZE) == CS6) {
|
|
|
|
kprintf(" CS6");
|
|
|
|
} else if ((termios.c_cflag & CSIZE) == CS7) {
|
|
|
|
kprintf(" CS7");
|
|
|
|
} else if ((termios.c_cflag & CSIZE) == CS8) {
|
|
|
|
kprintf(" CS8");
|
|
|
|
}
|
2022-04-24 16:59:22 +00:00
|
|
|
kprintf("\n");
|
2022-04-17 03:29:08 +00:00
|
|
|
kprintf(prologue);
|
|
|
|
kprintf(" c_lflag =");
|
|
|
|
if (termios.c_lflag & ISIG) kprintf(" ISIG");
|
|
|
|
if (termios.c_lflag & ICANON) kprintf(" ICANON");
|
|
|
|
if (termios.c_lflag & ECHO) kprintf(" ECHO");
|
|
|
|
if (termios.c_lflag & ECHOE) kprintf(" ECHOE");
|
|
|
|
if (termios.c_lflag & ECHOK) kprintf(" ECHOK");
|
|
|
|
if (termios.c_lflag & ECHONL) kprintf(" ECHONL");
|
|
|
|
if (termios.c_lflag & NOFLSH) kprintf(" NOFLSH");
|
|
|
|
if (termios.c_lflag & TOSTOP) kprintf(" TOSTOP");
|
|
|
|
if (termios.c_lflag & IEXTEN) kprintf(" IEXTEN");
|
|
|
|
if (termios.c_lflag & ECHOCTL) kprintf(" ECHOCTL");
|
|
|
|
if (termios.c_lflag & ECHOPRT) kprintf(" ECHOPRT");
|
|
|
|
if (termios.c_lflag & ECHOKE) kprintf(" ECHOKE");
|
|
|
|
if (termios.c_lflag & FLUSHO) kprintf(" FLUSHO");
|
|
|
|
if (termios.c_lflag & PENDIN) kprintf(" PENDIN");
|
|
|
|
if (termios.c_lflag & XCASE) kprintf(" XCASE");
|
2022-04-24 16:59:22 +00:00
|
|
|
kprintf("\n");
|
2022-04-17 03:29:08 +00:00
|
|
|
PRINT(" c_ispeed = %u", termios.c_ispeed);
|
|
|
|
PRINT(" c_ospeed = %u", termios.c_ospeed);
|
2022-05-14 11:33:58 +00:00
|
|
|
PRINT(" c_cc[VMIN] = %d", termios.c_cc[VMIN]);
|
|
|
|
PRINT(" c_cc[VTIME] = %d", termios.c_cc[VTIME]);
|
2022-04-17 03:29:08 +00:00
|
|
|
PRINT(" c_cc[VINTR] = CTRL-%c", CTRL(termios.c_cc[VINTR]));
|
|
|
|
PRINT(" c_cc[VQUIT] = CTRL-%c", CTRL(termios.c_cc[VQUIT]));
|
|
|
|
PRINT(" c_cc[VERASE] = CTRL-%c", CTRL(termios.c_cc[VERASE]));
|
|
|
|
PRINT(" c_cc[VKILL] = CTRL-%c", CTRL(termios.c_cc[VKILL]));
|
|
|
|
PRINT(" c_cc[VEOF] = CTRL-%c", CTRL(termios.c_cc[VEOF]));
|
|
|
|
PRINT(" c_cc[VSTART] = CTRL-%c", CTRL(termios.c_cc[VSTART]));
|
|
|
|
PRINT(" c_cc[VSTOP] = CTRL-%c", CTRL(termios.c_cc[VSTOP]));
|
|
|
|
PRINT(" c_cc[VSUSP] = CTRL-%c", CTRL(termios.c_cc[VSUSP]));
|
|
|
|
PRINT(" c_cc[VEOL] = CTRL-%c", CTRL(termios.c_cc[VEOL]));
|
|
|
|
PRINT(" c_cc[VSWTC] = CTRL-%c", CTRL(termios.c_cc[VSWTC]));
|
|
|
|
PRINT(" c_cc[VREPRINT] = CTRL-%c", CTRL(termios.c_cc[VREPRINT]));
|
|
|
|
PRINT(" c_cc[VDISCARD] = CTRL-%c", CTRL(termios.c_cc[VDISCARD]));
|
|
|
|
PRINT(" c_cc[VWERASE] = CTRL-%c", CTRL(termios.c_cc[VWERASE]));
|
|
|
|
PRINT(" c_cc[VLNEXT] = CTRL-%c", CTRL(termios.c_cc[VLNEXT]));
|
|
|
|
PRINT(" c_cc[VEOL2] = CTRL-%c", CTRL(termios.c_cc[VEOL2]));
|
|
|
|
} else {
|
|
|
|
PRINT(" - tcgetattr(%d) failed %m", i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-15 06:39:48 +00:00
|
|
|
if (IsWindows()) {
|
|
|
|
struct NtStartupInfo startinfo;
|
|
|
|
GetStartupInfo(&startinfo);
|
|
|
|
|
|
|
|
PRINT("");
|
|
|
|
PRINT("GETSTARTUPINFO");
|
|
|
|
if (startinfo.lpDesktop)
|
|
|
|
PRINT(" ☼ %s = %#!hs", "lpDesktop", startinfo.lpDesktop);
|
|
|
|
if (startinfo.lpTitle) PRINT(" ☼ %s = %#!hs", "lpTitle", startinfo.lpTitle);
|
|
|
|
if (startinfo.dwX) PRINT(" ☼ %s = %u", "dwX", startinfo.dwX);
|
|
|
|
if (startinfo.dwY) PRINT(" ☼ %s = %u", "dwY", startinfo.dwY);
|
|
|
|
if (startinfo.dwXSize) PRINT(" ☼ %s = %u", "dwXSize", startinfo.dwXSize);
|
|
|
|
if (startinfo.dwYSize) PRINT(" ☼ %s = %u", "dwYSize", startinfo.dwYSize);
|
|
|
|
if (startinfo.dwXCountChars)
|
|
|
|
PRINT(" ☼ %s = %u", "dwXCountChars", startinfo.dwXCountChars);
|
|
|
|
if (startinfo.dwYCountChars)
|
|
|
|
PRINT(" ☼ %s = %u", "dwYCountChars", startinfo.dwYCountChars);
|
|
|
|
if (startinfo.dwFillAttribute)
|
|
|
|
PRINT(" ☼ %s = %u", "dwFillAttribute", startinfo.dwFillAttribute);
|
|
|
|
if (startinfo.dwFlags)
|
|
|
|
PRINT(" ☼ %s = %s", "dwFlags", DescribeNtStartFlags(startinfo.dwFlags));
|
|
|
|
if (startinfo.wShowWindow)
|
|
|
|
PRINT(" ☼ %s = %hu", "wShowWindow", startinfo.wShowWindow);
|
|
|
|
if (startinfo.cbReserved2)
|
|
|
|
PRINT(" ☼ %s = %hu", "cbReserved2", startinfo.cbReserved2);
|
|
|
|
if (startinfo.hStdInput)
|
|
|
|
PRINT(" ☼ %s = %ld", "hStdInput", startinfo.hStdInput);
|
|
|
|
if (startinfo.hStdOutput)
|
|
|
|
PRINT(" ☼ %s = %ld", "hStdOutput", startinfo.hStdOutput);
|
|
|
|
if (startinfo.hStdError)
|
|
|
|
PRINT(" ☼ %s = %ld", "hStdError", startinfo.hStdError);
|
|
|
|
|
|
|
|
PRINT("");
|
|
|
|
PRINT("STANDARD HANDLES");
|
|
|
|
PRINT(" ☼ %s = %ld", "GetStdHandle(kNtStdInputHandle)",
|
|
|
|
GetStdHandle(kNtStdInputHandle));
|
|
|
|
PRINT(" ☼ %s = %ld", "GetStdHandle(kNtStdOutputHandle)",
|
|
|
|
GetStdHandle(kNtStdOutputHandle));
|
|
|
|
PRINT(" ☼ %s = %ld", "GetStdHandle(kNtStdErrorHandle)",
|
|
|
|
GetStdHandle(kNtStdErrorHandle));
|
|
|
|
|
|
|
|
PRINT("");
|
|
|
|
PRINT("TEB");
|
|
|
|
PRINT(" ☼ gs:0x%02x %s = %p", 0x00, "NtGetSeh()", _NtGetSeh());
|
|
|
|
PRINT(" ☼ gs:0x%02x %s = %p", 0x08, "NtGetStackHigh()", _NtGetStackHigh());
|
|
|
|
PRINT(" ☼ gs:0x%02x %s = %p", 0x10, "NtGetStackLow()", _NtGetStackLow());
|
|
|
|
PRINT(" ☼ gs:0x%02x %s = %p", 0x18, "_NtGetSubsystemTib()",
|
|
|
|
_NtGetSubsystemTib());
|
|
|
|
PRINT(" ☼ gs:0x%02x %s = %p", 0x20, "NtGetFib()", _NtGetFib());
|
|
|
|
PRINT(" ☼ gs:0x%02x %s = %p", 0x30, "NtGetTeb()", NtGetTeb());
|
|
|
|
PRINT(" ☼ gs:0x%02x %s = %p", 0x38, "NtGetEnv()", _NtGetEnv());
|
|
|
|
PRINT(" ☼ gs:0x%02x %s = %p", 0x40, "NtGetPid()", NtGetPid());
|
|
|
|
PRINT(" ☼ gs:0x%02x %s = %p", 0x48, "NtGetTid()", NtGetTid());
|
|
|
|
PRINT(" ☼ gs:0x%02x %s = %p", 0x50, "NtGetRpc()", _NtGetRpc());
|
|
|
|
PRINT(" ☼ gs:0x%02x %s = %p", 0x58, "NtGetTls()", _NtGetTls());
|
|
|
|
PRINT(" ☼ gs:0x%02x %s = %p", 0x60, "NtGetPeb()", NtGetPeb());
|
|
|
|
PRINT(" ☼ gs:0x%02x %s = %p", 0x68, "NtGetErr()", NtGetErr());
|
|
|
|
|
|
|
|
PRINT("");
|
|
|
|
PRINT("DEPENDENCIES");
|
|
|
|
struct NtLinkedList *head = &NtGetPeb()->Ldr->InLoadOrderModuleList;
|
|
|
|
struct NtLinkedList *ldr = head->Next;
|
|
|
|
do {
|
|
|
|
const struct NtLdrDataTableEntry *dll =
|
|
|
|
(const struct NtLdrDataTableEntry *)ldr;
|
2022-04-16 17:40:23 +00:00
|
|
|
PRINT(" ☼ %.*!hs (%'zukb)", dll->FullDllName.Length,
|
|
|
|
dll->FullDllName.Data, dll->SizeOfImage / 1024);
|
2022-04-15 06:39:48 +00:00
|
|
|
} while ((ldr = ldr->Next) && ldr != head);
|
|
|
|
}
|
|
|
|
|
|
|
|
PRINT("");
|
2022-05-14 11:33:58 +00:00
|
|
|
__atomic_fetch_add(&__strace, 1, __ATOMIC_RELAXED);
|
|
|
|
__atomic_fetch_add(&g_ftrace, 1, __ATOMIC_RELAXED);
|
2022-04-17 03:29:08 +00:00
|
|
|
errno = e;
|
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
|
|
|
}
|