commit d68efc51bceae0ebcb0917fc3b90eb5af74ea76a from: Benjamin Stürz date: Sat Jun 15 21:25:51 2024 UTC print syscall name commit - 6341b1fd7700790ff5d9f19b1de17e265f09bb8f commit + d68efc51bceae0ebcb0917fc3b90eb5af74ea76a blob - 7561b6e0eb05ea6fb1dc507ec5e7b4d01c95d937 blob + 038e3eabdf2b72e8a0eb09c150efc3ad81ad0ebf --- Makefile +++ Makefile @@ -49,9 +49,8 @@ linurv: ${OBJ} src/ecall.o: src/syscalls.h -src/syscalls.h: src/syscalls.inc - sed 's/^\.set \(SYS_[a-z0-9_]*\), \([0-9]*\)$$/#define \1 \2/' \ - < src/syscalls.inc > $@ +src/syscalls.h: src/syscalls.inc src/gensyscalls.sh + sh src/gensyscalls.sh < src/syscalls.inc > $@ .c.o: ${CC} -c -o $@ $< ${CFLAGS} blob - 5d28e24ab091d568cf3e09a303a34ae3e489aa35 blob + 01b46c983168538311f45df9dc221aa051b068db --- src/ecall.c +++ src/ecall.c @@ -268,11 +268,14 @@ void ecall (void) const u64 a4 = cpu_get (14); const u64 a5 = cpu_get (15); const u64 a7 = cpu_get (17); + const char *name = NULL; + if (a7 <= SYS_debug) + name = syscall_names[a7]; eprintf ( - "ecall a7=%"PRIu64", a0=%"PRIu64", a1=%"PRIu64", a2=%"PRIu64", a3=%"PRIu64", a4=%"PRIu64", a5=%"PRIu64 "\n", - a7, a0, a1, a2, a3, a4, a5 + "ecall a7=%"PRIu64" [%s], a0=%"PRIu64", a1=%"PRIu64", a2=%"PRIu64", a3=%"PRIu64", a4=%"PRIu64", a5=%"PRIu64 "\n", + a7, name, a0, a1, a2, a3, a4, a5 ); int tmp, tmp2; blob - /dev/null blob + 8d4341c40dea91f83b07060d89ba9bcf2e135337 (mode 755) --- /dev/null +++ src/gensyscalls.sh @@ -0,0 +1,32 @@ +#!/bin/sh + +parse() { + sed '/^\(#.*\)\{0,\}$/d; s/^\.set SYS_\([^,]*\), \(.*\)$/\1=\2/' +} + +format() { + code=' +BEGIN { + print "/* !!! THIS FILE IS AUTOGENERATED !!! */\n"; +} + +/^[^=]+=[0-9]+$/ { + printf "#define SYS_%s %s\n", $1, $2; + syscalls[length(syscalls)+1] = $1; +} + +END { + print ""; + print "static const char *syscall_names[] = {"; + + for (i = 1; i <= length(syscalls); ++i) { + name = syscalls[i]; + printf "\t[SYS_%s] = \"%s\",\n", name, name; + } + + print "};"; +} +' + awk -F= "$code" +} +parse | format