mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-24 03:20:30 +00:00
Get Cosmopolitan into releasable state
A new rollup tool now exists for flattening out the headers in a way that works better for our purposes than cpp. A lot of the API clutter has been removed. APIs that aren't a sure thing in terms of general recommendation are now marked internal. There's now a smoke test for the amalgamation archive and gigantic header file. So we can now guarantee you can use this project on the easiest difficulty setting without the gigantic repository. A website is being created, which is currently a work in progress: https://justine.storage.googleapis.com/cosmopolitan/index.html
This commit is contained in:
parent
dba7552c1e
commit
ea0b5d9d1c
775 changed files with 6864 additions and 3963 deletions
|
@ -17,20 +17,22 @@
|
|||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/bits/safemacros.internal.h"
|
||||
#include "libc/bits/weaken.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/conv/itoa.h"
|
||||
#include "libc/log/asan.h"
|
||||
#include "libc/log/backtrace.h"
|
||||
#include "libc/log/asan.internal.h"
|
||||
#include "libc/log/backtrace.internal.h"
|
||||
#include "libc/log/log.h"
|
||||
#include "libc/mem/hook/hook.h"
|
||||
#include "libc/runtime/directmap.h"
|
||||
#include "libc/runtime/memtrack.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/consts/fileno.h"
|
||||
#include "libc/sysv/consts/map.h"
|
||||
#include "libc/sysv/consts/prot.h"
|
||||
#include "third_party/dlmalloc/dlmalloc.h"
|
||||
#include "third_party/dlmalloc/dlmalloc.internal.h"
|
||||
|
||||
STATIC_YOINK("_init_asan");
|
||||
|
||||
|
@ -147,7 +149,7 @@ static const char *__asan_describe_access_poison(int c) {
|
|||
|
||||
static noreturn void __asan_die(const char *msg, size_t size) {
|
||||
write(STDERR_FILENO, msg, size);
|
||||
die();
|
||||
__die();
|
||||
}
|
||||
|
||||
static char *__asan_report_start(char *p) {
|
||||
|
|
|
@ -17,17 +17,17 @@
|
|||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/bits/safemacros.h"
|
||||
#include "libc/bits/safemacros.internal.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/hefty/spawn.h"
|
||||
#include "libc/fmt/fmt.h"
|
||||
#include "libc/log/gdb.h"
|
||||
#include "libc/log/log.h"
|
||||
#include "libc/nexgen32e/stackframe.h"
|
||||
#include "libc/nexgen32e/vendor.h"
|
||||
#include "libc/nexgen32e/vendor.internal.h"
|
||||
#include "libc/paths.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/runtime/symbols.h"
|
||||
#include "libc/runtime/symbols.internal.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/consts/fileno.h"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_LOG_BACKTRACE_H_
|
||||
#define COSMOPOLITAN_LIBC_LOG_BACKTRACE_H_
|
||||
#include "libc/nexgen32e/stackframe.h"
|
||||
#include "libc/runtime/symbols.h"
|
||||
#include "libc/runtime/symbols.internal.h"
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
|
@ -18,19 +18,19 @@
|
|||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/alg/alg.h"
|
||||
#include "libc/alg/bisectcarleft.h"
|
||||
#include "libc/bits/safemacros.h"
|
||||
#include "libc/alg/bisectcarleft.internal.h"
|
||||
#include "libc/bits/safemacros.internal.h"
|
||||
#include "libc/bits/weaken.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/hefty/spawn.h"
|
||||
#include "libc/conv/conv.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/fmt/fmt.h"
|
||||
#include "libc/log/backtrace.h"
|
||||
#include "libc/log/backtrace.internal.h"
|
||||
#include "libc/log/log.h"
|
||||
#include "libc/nexgen32e/gc.h"
|
||||
#include "libc/nexgen32e/gc.internal.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/runtime/symbols.h"
|
||||
#include "libc/runtime/symbols.internal.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/consts/fileno.h"
|
||||
|
||||
|
@ -55,14 +55,14 @@ static int PrintBacktraceUsingAddr2line(int fd, const struct StackFrame *bp) {
|
|||
argv[i++] = "-a"; /* filter out w/ shell script wrapper for old versions */
|
||||
argv[i++] = "-pCife";
|
||||
argv[i++] = debugbin;
|
||||
garbage = weaken(g_garbage);
|
||||
garbage = weaken(__garbage);
|
||||
gi = garbage ? garbage->i : 0;
|
||||
for (frame = bp; frame && i < kBacktraceMaxFrames - 1; frame = frame->next) {
|
||||
addr = frame->addr;
|
||||
if (addr == weakaddr("CollectGarbage")) {
|
||||
if (addr == weakaddr("__gc")) {
|
||||
do {
|
||||
--gi;
|
||||
} while ((addr = garbage->p[gi].ret) == weakaddr("CollectGarbage"));
|
||||
} while ((addr = garbage->p[gi].ret) == weakaddr("__gc"));
|
||||
}
|
||||
argv[i++] = &buf[j];
|
||||
j += snprintf(&buf[j], 17, "%#x", addr - 1) + 1;
|
||||
|
|
|
@ -17,18 +17,18 @@
|
|||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/alg/bisectcarleft.h"
|
||||
#include "libc/alg/bisectcarleft.internal.h"
|
||||
#include "libc/assert.h"
|
||||
#include "libc/bits/weaken.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/conv/itoa.h"
|
||||
#include "libc/fmt/fmt.h"
|
||||
#include "libc/log/backtrace.h"
|
||||
#include "libc/log/backtrace.internal.h"
|
||||
#include "libc/macros.h"
|
||||
#include "libc/nexgen32e/gc.h"
|
||||
#include "libc/nexgen32e/gc.internal.h"
|
||||
#include "libc/nexgen32e/stackframe.h"
|
||||
#include "libc/runtime/missioncritical.h"
|
||||
#include "libc/runtime/symbols.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/runtime/symbols.internal.h"
|
||||
#include "libc/str/str.h"
|
||||
|
||||
/**
|
||||
|
@ -53,14 +53,14 @@ int PrintBacktraceUsingSymbols(int fd, const struct StackFrame *bp,
|
|||
const struct StackFrame *frame;
|
||||
if (!st) return -1;
|
||||
if (!bp) bp = __builtin_frame_address(0);
|
||||
garbage = weaken(g_garbage);
|
||||
garbage = weaken(__garbage);
|
||||
gi = garbage ? garbage->i : 0;
|
||||
for (frame = bp; frame; frame = frame->next) {
|
||||
addr = frame->addr;
|
||||
if (addr == weakaddr("CollectGarbage")) {
|
||||
if (addr == weakaddr("__gc")) {
|
||||
do {
|
||||
--gi;
|
||||
} while ((addr = garbage->p[gi].ret) == weakaddr("CollectGarbage"));
|
||||
} while ((addr = garbage->p[gi].ret) == weakaddr("__gc"));
|
||||
}
|
||||
p = buf;
|
||||
p = mempcpy(p, ibuf, uint64toarray_fixed16((intptr_t)frame, ibuf, 48));
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
#include "libc/nt/enum/filetype.h"
|
||||
#include "libc/nt/enum/version.h"
|
||||
#include "libc/nt/files.h"
|
||||
#include "libc/nt/pedef.h"
|
||||
#include "libc/nt/pedef.internal.h"
|
||||
#include "libc/nt/runtime.h"
|
||||
#include "libc/nt/struct/teb.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
|
|
|
@ -31,5 +31,5 @@ void __check_fail_aligned(unsigned bytes, uint64_t ptr) {
|
|||
if (!IsTiny()) memsummary(fileno(stderr));
|
||||
(dprintf)(fileno(stderr), "%s%d%s%#p\r\n", "error: pointer not ", bytes,
|
||||
"-byte aligned: ", ptr);
|
||||
die();
|
||||
__die();
|
||||
}
|
||||
|
|
|
@ -18,13 +18,13 @@
|
|||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/bits/bits.h"
|
||||
#include "libc/bits/safemacros.h"
|
||||
#include "libc/bits/safemacros.internal.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/fmt/fmt.h"
|
||||
#include "libc/log/check.h"
|
||||
#include "libc/log/color.h"
|
||||
#include "libc/log/color.internal.h"
|
||||
#include "libc/log/internal.h"
|
||||
#include "libc/log/log.h"
|
||||
#include "libc/runtime/memtrack.h"
|
||||
|
@ -81,6 +81,6 @@ relegated void __check_fail(const char *suffix, const char *opstr,
|
|||
PrintMemoryIntervals(STDERR_FILENO, &_mmi);
|
||||
}
|
||||
|
||||
die();
|
||||
__die();
|
||||
unreachable;
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#include "libc/errno.h"
|
||||
#include "libc/log/internal.h"
|
||||
#include "libc/log/log.h"
|
||||
#include "libc/runtime/missioncritical.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
|
||||
/**
|
||||
* Handles failure of CHECK_xx() macros in -DNDEBUG mode.
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/bits/safemacros.h"
|
||||
#include "libc/bits/safemacros.internal.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/log/log.h"
|
||||
#include "libc/mem/mem.h"
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/bits/bits.h"
|
||||
#include "libc/log/backtrace.h"
|
||||
#include "libc/log/backtrace.internal.h"
|
||||
#include "libc/log/log.h"
|
||||
#include "libc/runtime/internal.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
|
@ -28,7 +28,7 @@
|
|||
/**
|
||||
* Aborts process after printing details on its current state.
|
||||
*/
|
||||
relegated noreturn void die(void) {
|
||||
relegated noreturn void __die(void) {
|
||||
static bool once;
|
||||
if (!once) {
|
||||
once = true;
|
||||
|
|
|
@ -1,12 +1,20 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_LOG_GDB_H_
|
||||
#define COSMOPOLITAN_LIBC_LOG_GDB_H_
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/runtime/missioncritical.h"
|
||||
#include "libc/calls/wait4.h"
|
||||
#include "libc/sysv/consts/nr.h"
|
||||
#include "libc/sysv/consts/w.h"
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
/**
|
||||
* @fileoverview GDB Attach Support Code.
|
||||
*
|
||||
* The goal of these macros is to make the backtrace into the failing
|
||||
* code as short as possible. It also helps avoid GDB getting confused
|
||||
* about how we don't use its readability destroying unwind directives.
|
||||
*/
|
||||
|
||||
extern volatile int g_gdbsync;
|
||||
|
||||
int gdbexec(const char *);
|
||||
|
@ -15,21 +23,37 @@ int attachdebugger(intptr_t);
|
|||
#define attachdebugger(CONTINUE_TO_ADDR) /* shorten backtraces */ \
|
||||
SYNCHRONIZE_DEBUGGER((attachdebugger)(CONTINUE_TO_ADDR))
|
||||
|
||||
#define SYNCHRONIZE_DEBUGGER(PID) \
|
||||
({ \
|
||||
int Rc, Pid = (PID); \
|
||||
if (Pid != -1) { \
|
||||
while ((Rc = WAIT4(Pid, NULL, WNOHANG, NULL)) == 0) { \
|
||||
if (g_gdbsync) { \
|
||||
g_gdbsync = 0; \
|
||||
if (Rc > 0) Pid = 0; \
|
||||
break; \
|
||||
} else { \
|
||||
SCHED_YIELD(); \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
Pid; \
|
||||
#define SYNCHRONIZE_DEBUGGER(PID) \
|
||||
({ \
|
||||
int Rc, Pid = (PID); \
|
||||
if (Pid != -1) { \
|
||||
while ((Rc = __inline_wait4(Pid, NULL, WNOHANG, NULL)) == 0) { \
|
||||
if (g_gdbsync) { \
|
||||
g_gdbsync = 0; \
|
||||
if (Rc > 0) Pid = 0; \
|
||||
break; \
|
||||
} else { \
|
||||
sched_yield(); \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
Pid; \
|
||||
})
|
||||
|
||||
#define __inline_wait4(PID, OPT_OUT_WSTATUS, OPTIONS, OPT_OUT_RUSAGE) \
|
||||
({ \
|
||||
int64_t WaAx; \
|
||||
if (!IsWindows()) { \
|
||||
register void *Reg10 asm("r10") = (OPT_OUT_RUSAGE); \
|
||||
asm volatile("syscall" \
|
||||
: "=a"(WaAx) \
|
||||
: "0"(__NR_wait4), "D"(PID), "S"(OPT_OUT_WSTATUS), \
|
||||
"d"(OPTIONS), "r"(Reg10) \
|
||||
: "rcx", "r11", "cc", "memory"); \
|
||||
} else { \
|
||||
WaAx = wait4$nt(PID, OPT_OUT_WSTATUS, OPTIONS, OPT_OUT_RUSAGE); \
|
||||
} \
|
||||
WaAx; \
|
||||
})
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/bits/safemacros.h"
|
||||
#include "libc/bits/safemacros.internal.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/hefty/spawn.h"
|
||||
#include "libc/fmt/fmt.h"
|
||||
|
@ -25,7 +25,7 @@
|
|||
#include "libc/log/log.h"
|
||||
#include "libc/nexgen32e/stackframe.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/runtime/symbols.h"
|
||||
#include "libc/runtime/symbols.internal.h"
|
||||
|
||||
/**
|
||||
* Attachs GDB temporarilly, to do something like print a variable.
|
||||
|
|
|
@ -18,7 +18,8 @@
|
|||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/runtime/symbols.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/runtime/symbols.internal.h"
|
||||
|
||||
/**
|
||||
* Returns debug binary symbol table, as global singleton.
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/bits/safemacros.h"
|
||||
#include "libc/bits/safemacros.internal.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/termios.h"
|
||||
#include "libc/conv/conv.h"
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/bits/safemacros.h"
|
||||
#include "libc/bits/safemacros.internal.h"
|
||||
#include "libc/log/log.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/str/str.h"
|
||||
|
|
|
@ -34,7 +34,7 @@ typedef struct FILE FILE;
|
|||
extern FILE *g_logfile;
|
||||
|
||||
void perror(const char *) relegated; /* print the last system error */
|
||||
void die(void) relegated noreturn; /* print backtrace and abort() */
|
||||
void __die(void) relegated noreturn; /* print backtrace and abort() */
|
||||
void meminfo(int); /* shows malloc statistics &c. */
|
||||
void memsummary(int); /* light version of same thing */
|
||||
uint16_t getttycols(uint16_t);
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/bits/initializer.h"
|
||||
#include "libc/bits/initializer.internal.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
|
||||
FILE *g_logfile;
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "third_party/dlmalloc/dlmalloc.h"
|
||||
#include "third_party/dlmalloc/dlmalloc.internal.h"
|
||||
|
||||
STATIC_YOINK("ntoa");
|
||||
|
||||
|
|
|
@ -22,9 +22,10 @@
|
|||
#include "libc/calls/struct/utsname.h"
|
||||
#include "libc/calls/ucontext.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/fmt/fmt.h"
|
||||
#include "libc/log/backtrace.h"
|
||||
#include "libc/log/color.h"
|
||||
#include "libc/log/backtrace.internal.h"
|
||||
#include "libc/log/color.internal.h"
|
||||
#include "libc/log/gdb.h"
|
||||
#include "libc/log/internal.h"
|
||||
#include "libc/log/log.h"
|
||||
|
@ -126,7 +127,7 @@ relegated static void ShowGeneralRegisters(int fd, ucontext_t *ctx) {
|
|||
|
||||
relegated static void ShowSseRegisters(int fd, ucontext_t *ctx) {
|
||||
size_t i;
|
||||
write(fd, "\r\n", 2);
|
||||
write(fd, "\r\n\r\n", 4);
|
||||
for (i = 0; i < 8; ++i) {
|
||||
(dprintf)(fd, VEIL("r", "%s%-2zu %016lx%016lx %s%-2d %016lx%016lx\r\n"),
|
||||
"XMM", i + 0, ctx->fpustate.xmm[i + 0].u64[0],
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/errno.h"
|
||||
#include "libc/fmt/fmt.h"
|
||||
#include "libc/log/color.h"
|
||||
#include "libc/log/color.internal.h"
|
||||
#include "libc/log/internal.h"
|
||||
#include "libc/log/log.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
|
|
|
@ -1,58 +0,0 @@
|
|||
/*-*- 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 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/log/log.h"
|
||||
#include "libc/log/shadowargs.h"
|
||||
#include "libc/runtime/internal.h"
|
||||
#include "libc/runtime/symbols.h"
|
||||
|
||||
alignas(1) const
|
||||
char __shadowargs_slotnames[SHADOWARGS_SLOTS][SHADOWARGS_MAXNAME] = {
|
||||
"func", "%rsp", "%rdi", "%rsi", "%rdx", "%rcx", "%r8", "%r9",
|
||||
};
|
||||
alignas(64) struct ShadowArgs __shadowargs[SHADOWARGS_COUNT];
|
||||
unsigned __shadowargs_index;
|
||||
|
||||
nocallersavedregisters void __fentry__(uint64_t rdi, uint64_t rsi, uint64_t rdx,
|
||||
uint64_t rcx, uint64_t r8, uint64_t r9) {
|
||||
void *addr = __builtin_return_address(0);
|
||||
intptr_t frame = (intptr_t)__builtin_frame_address(0);
|
||||
unsigned i = __shadowargs_index;
|
||||
intptr_t lastframe = (intptr_t)__shadowargs[i].frame;
|
||||
if (frame < lastframe) {
|
||||
i--;
|
||||
i &= SHADOWARGS_COUNT - 1;
|
||||
} else if (frame > lastframe) {
|
||||
unsigned j = i;
|
||||
do {
|
||||
j++;
|
||||
j &= SHADOWARGS_COUNT - 1;
|
||||
} while (frame > (intptr_t)__shadowargs[j].frame && j != i);
|
||||
i = j;
|
||||
}
|
||||
__shadowargs[i].addr = addr;
|
||||
__shadowargs[i].frame = (void *)frame;
|
||||
__shadowargs[i].arg1 = rdi;
|
||||
__shadowargs[i].arg2 = rsi;
|
||||
__shadowargs[i].arg3 = rdx;
|
||||
__shadowargs[i].arg4 = rcx;
|
||||
__shadowargs[i].arg5 = r8;
|
||||
__shadowargs[i].arg6 = r9;
|
||||
__shadowargs_index = i;
|
||||
}
|
|
@ -1,53 +0,0 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=8 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#ifndef COSMOPOLITAN_LIBC_SHADOWARGS_H_
|
||||
#define COSMOPOLITAN_LIBC_SHADOWARGS_H_
|
||||
|
||||
#define SHADOWARGS_COUNT 32
|
||||
#define SHADOWARGS_SLOTS 8
|
||||
#define SHADOWARGS_MAXNAME 5
|
||||
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
struct ShadowArgs {
|
||||
union {
|
||||
unsigned long slots[SHADOWARGS_SLOTS];
|
||||
struct {
|
||||
void *addr;
|
||||
void *frame;
|
||||
unsigned long arg1;
|
||||
unsigned long arg2;
|
||||
unsigned long arg3;
|
||||
unsigned long arg4;
|
||||
unsigned long arg5;
|
||||
unsigned long arg6;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
hidden extern unsigned __shadowargs_index;
|
||||
hidden extern struct ShadowArgs __shadowargs[SHADOWARGS_COUNT];
|
||||
hidden extern const char __shadowargs_slotnames[SHADOWARGS_SLOTS]
|
||||
[SHADOWARGS_MAXNAME];
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_SHADOWARGS_H_ */
|
|
@ -24,14 +24,14 @@
|
|||
#include "libc/dce.h"
|
||||
#include "libc/log/internal.h"
|
||||
#include "libc/log/log.h"
|
||||
#include "libc/log/ubsan.h"
|
||||
#include "libc/log/ubsan.internal.h"
|
||||
#include "libc/macros.h"
|
||||
#include "libc/nt/signals.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/consts/sa.h"
|
||||
#include "libc/sysv/consts/sig.h"
|
||||
|
||||
STATIC_YOINK("die");
|
||||
STATIC_YOINK("__die");
|
||||
STATIC_YOINK("__ubsan_abort");
|
||||
|
||||
extern const unsigned char __oncrash_thunks[7][11];
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/log/color.h"
|
||||
#include "libc/log/color.internal.h"
|
||||
#include "libc/log/internal.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/sysv/consts/fileno.h"
|
||||
|
|
|
@ -17,8 +17,8 @@
|
|||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/log/color.h"
|
||||
#include "libc/runtime/missioncritical.h"
|
||||
#include "libc/log/color.internal.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
|
||||
/**
|
||||
|
|
|
@ -25,5 +25,5 @@ __check_fail_ndebug:
|
|||
mov %rsp,%rbp
|
||||
call ___check_fail_ndebug
|
||||
pop %rbp
|
||||
jmp die # fewer elements in backtrace
|
||||
jmp __die # fewer elements in backtrace
|
||||
.endfn __check_fail_ndebug,globl
|
||||
|
|
|
@ -22,9 +22,8 @@
|
|||
#include "libc/fmt/fmt.h"
|
||||
#include "libc/log/internal.h"
|
||||
#include "libc/log/log.h"
|
||||
#include "libc/log/ubsan.h"
|
||||
#include "libc/log/ubsan.internal.h"
|
||||
#include "libc/runtime/internal.h"
|
||||
#include "libc/runtime/missioncritical.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/str/str.h"
|
||||
|
@ -56,7 +55,7 @@ void __ubsan_abort(const struct UbsanSourceLocation *loc,
|
|||
if (IsDebuggerPresent(false)) DebugBreak();
|
||||
__start_fatal(loc->file, loc->line);
|
||||
fprintf(stderr, "%s\r\n", description);
|
||||
die();
|
||||
__die();
|
||||
unreachable;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/log/bsd.h"
|
||||
#include "libc/log/color.h"
|
||||
#include "libc/log/color.internal.h"
|
||||
#include "libc/log/internal.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/log/bsd.h"
|
||||
#include "libc/log/color.h"
|
||||
#include "libc/log/color.internal.h"
|
||||
#include "libc/log/internal.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
|
|
|
@ -116,7 +116,7 @@ void(vflogf)(unsigned level, const char *file, int line, FILE *f,
|
|||
if (level == kLogFatal) {
|
||||
__start_fatal(file, line);
|
||||
(dprintf)(STDERR_FILENO, "fatal error see logfile\r\n");
|
||||
die();
|
||||
__die();
|
||||
unreachable;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/log/bsd.h"
|
||||
#include "libc/log/color.h"
|
||||
#include "libc/log/color.internal.h"
|
||||
#include "libc/log/internal.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/log/bsd.h"
|
||||
#include "libc/log/color.h"
|
||||
#include "libc/log/color.internal.h"
|
||||
#include "libc/log/internal.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue