cross platform debugging tools for windows updated

This commit is contained in:
Nicolas 2025-11-03 15:01:42 +01:00 committed by Nicolas Kruse
parent 1af2e4650a
commit ca25d39295
3 changed files with 73 additions and 18 deletions

View File

@ -1,7 +1,23 @@
call "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" x64
REM With Symbols:
cl /Zi /Od src\coparun\runmem.c src\coparun\coparun.c src\coparun\mem_man.c /Fe:bin\coparun.exe
echo ------------------------------
echo - Build runner for Windows...
cl /Zi /Od /DENABLE_BASIC_LOGGING src\coparun\runmem.c src\coparun\coparun.c src\coparun\mem_man.c /Fe:bin\coparun.exe
REM Optimized:
REM cl /O2 src\coparun\runmem.c src\coparun\coparun.c src\coparun\mem_man.c /Fe:bin\coparun.exe
echo ------------------------------
echo - Build stencils for Windows...
python stencils/generate_stencils.py --abi ms bin/stencils.c
REM copy stencils\stencil_helper.h bin\
wsl gcc -fno-pic -c bin/stencils.c -O3 -o src/copapy/obj/stencils_AMD64_O3.o
echo ------------------------------
echo - Build stencils for aarch64...
python stencils/generate_stencils.py bin/stencils.c
wsl aarch64-linux-gnu-gcc -fno-pic -c bin/stencils.c -O3 -o src/copapy/obj/stencils_aarch64_O3.o
echo ------------------------------
echo - Build runner for Aarch64...
wsl aarch64-linux-gnu-gcc -static -Wall -Wextra -Wconversion -Wsign-conversion -Wshadow -Wstrict-overflow -O3 -DENABLE_LOGGING src/coparun/runmem.c src/coparun/coparun.c src/coparun/mem_man.c -o bin/coparun-aarch64

View File

@ -1,3 +1,11 @@
python tools/make_example.py
python tools/extract_code.py "bin/test-aarch64.copapy" "bin/test-aarch64.copapy.bin"
wsl aarch64-linux-gnu-objdump -D -b binary -m aarch64 --adjust-vma=0x1000 bin/test-aarch64.copapy.bin
REM python tools/extract_code.py "bin/test.copapy" "bin/test.copapy.bin"
wsl qemu-aarch64 bin/coparun-aarch64 bin/test-aarch64.copapy bin/test-aarch64.copapy.bin
wsl aarch64-linux-gnu-objdump -D -b binary -m aarch64 --adjust-vma=0x5000 bin/test-aarch64.copapy.bin
python tools/extract_code.py "bin/test-aarch64.copapy" "bin/test-aarch64.copapy2.bin"
wsl aarch64-linux-gnu-objdump -D -b binary -m aarch64 --adjust-vma=0x5000 bin/test-aarch64.copapy2.bin
REM wsl objdump -D -b binary -m i386:x86-64 --adjust-vma=0x1000 bin/test.copapy.bin
REM wsl aarch64-linux-gnu-objdump -d -x src/copapy/obj/stencils_aarch64_O3.o

View File

@ -1,7 +1,30 @@
from copapy import variable
from copapy.backend import Write, compile_to_dag, stencil_db_from_package
import subprocess
import copapy as cp
from copapy._binwrite import Command
import os
if os.name == 'nt':
# On Windows wsl and qemu-user is required:
# sudo apt install qemu-user
qemu_command = ['wsl', 'qemu-aarch64',
'bin/coparun-aarch64',
'bin/test-aarch64.copapy',
'bin/test-aarch64.copapy.bin']
else:
qemu_command = ['qemu-aarch64',
'bin/coparun-aarch64',
'bin/test-aarch64.copapy',
'bin/test-aarch64.copapy.bin']
def run_command(command: list[str]) -> str:
result = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding='utf8', check=False)
assert result.returncode != 11, f"SIGSEGV (segmentation fault)\n -Error occurred: {result.stderr}\n -Output: {result.stdout}"
assert result.returncode == 0, f"\n -Error occurred: {result.stderr}\n -Output: {result.stdout}"
return result.stdout
def test_compile() -> None:
@ -45,8 +68,8 @@ def test_compile_aarch64() -> None:
c1 = variable(9.0)
#ret = [c1 / 4, c1 / -4, c1 // 4, c1 // -4, (c1 * -1) // 4]
ret = [c1 // 3.3 + 5]
#ret = [cp.sqrt(c1)]
#ret = [cp.sin(c1), cp.sqrt(c1) + 5]
ret = [cp.sqrt(c1)]
#c2 = cp._math.get_42()
#ret = [c2]
@ -56,27 +79,35 @@ def test_compile_aarch64() -> None:
dw, vars = compile_to_dag(out, sdb)
# run program command
dw.write_com(Command.RUN_PROG)
#dw.write_com(Command.RUN_PROG)
# read first 32 byte
dw.write_com(Command.READ_DATA)
dw.write_int(0)
dw.write_int(32)
#dw.write_com(Command.READ_DATA)
#dw.write_int(0)
#dw.write_int(32)
# read variables
for addr, lengths, _ in vars.values():
dw.write_com(Command.READ_DATA)
dw.write_int(addr)
dw.write_int(lengths)
#for addr, lengths, _ in vars.values():
# dw.write_com(Command.READ_DATA)
# dw.write_int(addr)
# dw.write_int(lengths)
dw.write_com(Command.END_COM)
#dw.write_com(Command.END_COM)
dw.write_com(Command.DUMP_CODE)
print('* Data to runner:')
dw.print()
dw.to_file('bin/test-aarch64.copapy')
result = run_command(qemu_command)
print('* Output from runner:\n--')
print(result)
print('--')
assert 'DUMP_CODE' in result
if __name__ == "__main__":
test_compile()
#test_compile_aarch64()
#test_compile()
test_compile_aarch64()