mirror of
git://repo.or.cz/tinycc.git
synced 2026-06-22 04:44:20 +08:00
Fix backtrace formatting and arm64 old-style calls
This commit is contained in:
parent
c24d95db09
commit
55acb9272e
22
.github/workflows/build.yml
vendored
22
.github/workflows/build.yml
vendored
@ -31,7 +31,11 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: make & test tcc (aarch64-osx)
|
||||
run: ./configure && make && make test -k
|
||||
run: |
|
||||
./configure
|
||||
make
|
||||
make test -k
|
||||
make -C tests/tests2 tests2.133
|
||||
|
||||
test-x86_64-win32:
|
||||
runs-on: windows-2025
|
||||
@ -63,6 +67,22 @@ jobs:
|
||||
.\tcc -I.. libtcc.dll -v ../tests/libtcc_test.c -o libtest.exe && .\libtest.exe
|
||||
.\tcc -I.. libtcc.dll -run ../tests/libtcc_test.c
|
||||
|
||||
test-x86_64-win32-clang64:
|
||||
runs-on: windows-2025
|
||||
timeout-minutes: 6
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: make & test tcc (x86_64-win32-clang64)
|
||||
shell: cmd
|
||||
run: |
|
||||
echo ::group:: setup msys clang64
|
||||
set MSYS2_PATH_TYPE=inherit
|
||||
set MSYSTEM=CLANG64
|
||||
set CHERE_INVOKING=yes
|
||||
C:\msys64\usr\bin\bash -l -c "pacman -S --noconfirm mingw-w64-clang-x86_64-clang"
|
||||
echo ::endgroup::
|
||||
C:\msys64\usr\bin\bash -l -c "./configure --cc=clang && make && make -C tests test3"
|
||||
|
||||
test-i386-win32:
|
||||
runs-on: windows-2025
|
||||
timeout-minutes: 6
|
||||
|
||||
@ -862,6 +862,13 @@ static unsigned long arm64_pcs_aux(int variadic, int n, CType **type, unsigned l
|
||||
unsigned long ns = 32; // next stack offset
|
||||
int i;
|
||||
|
||||
#if defined(TCC_TARGET_MACHO)
|
||||
/* Old-style / unprototyped calls must follow the variadic stack rules
|
||||
from the first argument on Darwin. */
|
||||
if (variadic < 0)
|
||||
nx = 8, nv = 8;
|
||||
#endif
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
int hfa = arm64_hfa(type[i], 0);
|
||||
int win_vararg_float = 0;
|
||||
|
||||
21
lib/bt-exe.c
21
lib/bt-exe.c
@ -63,25 +63,6 @@ void __bt_init(rt_context *p, int is_exe)
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
static const char *bt_backtrace_format(const char *fmt, char *skip, int *one)
|
||||
{
|
||||
const char *a, *b;
|
||||
|
||||
skip[0] = 0;
|
||||
if (fmt[0] == '^' && (b = strchr(a = fmt + 1, fmt[0]))) {
|
||||
size_t len = b - a;
|
||||
if (len >= 40)
|
||||
len = 39;
|
||||
memcpy(skip, a, len);
|
||||
skip[len] = 0;
|
||||
fmt = b + 1;
|
||||
}
|
||||
*one = 0;
|
||||
if (fmt[0] == '\001')
|
||||
++fmt, *one = 1;
|
||||
return fmt;
|
||||
}
|
||||
|
||||
static int bt_backtrace_msg(rt_frame *f, const char *fmt, const char *msg)
|
||||
{
|
||||
rt_context *rc, *rc2;
|
||||
@ -92,7 +73,7 @@ static int bt_backtrace_msg(rt_frame *f, const char *fmt, const char *msg)
|
||||
bt_info bi;
|
||||
addr_t (*getinfo)(rt_context*, addr_t, bt_info*);
|
||||
|
||||
bt_backtrace_format(fmt, skip, &one);
|
||||
rt_backtrace_format(fmt, skip, &one);
|
||||
|
||||
rt_wait_sem();
|
||||
rc = g_rc;
|
||||
|
||||
32
tccrun.c
32
tccrun.c
@ -730,6 +730,25 @@ static int rt_printf(const char *fmt, ...)
|
||||
return r;
|
||||
}
|
||||
|
||||
static const char *rt_backtrace_format(const char *fmt, char *skip, int *one)
|
||||
{
|
||||
const char *a, *b;
|
||||
|
||||
skip[0] = 0;
|
||||
if (fmt[0] == '^' && (b = strchr(a = fmt + 1, fmt[0]))) {
|
||||
size_t len = b - a;
|
||||
if (len >= 40)
|
||||
len = 39;
|
||||
memcpy(skip, a, len);
|
||||
skip[len] = 0;
|
||||
fmt = b + 1;
|
||||
}
|
||||
*one = 0;
|
||||
if (fmt[0] == '\001')
|
||||
++fmt, *one = 1;
|
||||
return fmt;
|
||||
}
|
||||
|
||||
static char *rt_elfsym(rt_context *rc, addr_t wanted_pc, addr_t *func_addr)
|
||||
{
|
||||
ElfW(Sym) *esym;
|
||||
@ -1168,20 +1187,11 @@ int _tcc_backtrace(rt_frame *f, const char *fmt, va_list ap)
|
||||
addr_t pc;
|
||||
char skip[40], msg[200];
|
||||
int i, level, ret, n, one;
|
||||
const char *a, *b;
|
||||
const char *a;
|
||||
bt_info bi;
|
||||
addr_t (*getinfo)(rt_context*, addr_t, bt_info*);
|
||||
|
||||
skip[0] = 0;
|
||||
/* If fmt is like "^file.c^..." then skip calls from 'file.c' */
|
||||
if (fmt[0] == '^' && (b = strchr(a = fmt + 1, fmt[0]))) {
|
||||
memcpy(skip, a, b - a), skip[b - a] = 0;
|
||||
fmt = b + 1;
|
||||
}
|
||||
one = 0;
|
||||
/* hack for bcheck.c:dprintf(): one level, no newline */
|
||||
if (fmt[0] == '\001')
|
||||
++fmt, one = 1;
|
||||
fmt = rt_backtrace_format(fmt, skip, &one);
|
||||
vsnprintf(msg, sizeof msg, fmt, ap);
|
||||
|
||||
rt_wait_sem();
|
||||
|
||||
@ -77,7 +77,7 @@ endif
|
||||
TCCTEST_REF = test.ref
|
||||
ifeq ($(ARCH)-$(TARGETOS),arm64-WIN32)
|
||||
TCCTEST_REF = test.ref.win32-arm64
|
||||
else ifeq ($(ARCH)-$(TARGETOS)-$(HOST_WIN_UCRT),x86_64-WIN32-yes)
|
||||
else ifeq ($(ARCH)-$(TARGETOS)-$(CC_NAME)-$(HOST_WIN_UCRT),x86_64-WIN32-clang-yes)
|
||||
# CLANG64/UCRT generates a different host reference than the msvcrt-backed TCC runtime.
|
||||
TCCTEST_REF = test.ref.win32-x86_64-ucrt
|
||||
endif
|
||||
|
||||
@ -61,7 +61,7 @@ void f2()
|
||||
void f1()
|
||||
{
|
||||
printf("* f1()\n"), fflush(stdout);
|
||||
tcc_backtrace("Hello from %s!", "f1");
|
||||
tcc_backtrace("^12345678901234567890123456789012345678901234567890^Hello from %s!", "f1");
|
||||
f2();
|
||||
}
|
||||
int main(int argc, char **argv)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user