logo

mstrace

Small Linux strace(1) implementationgit clone https://anongit.hacktivis.me/git/mstrace.git/

strsyscall.sh (638B)


  1. #!/bin/sh
  2. # SPDX-FileCopyrightText: 2024 Haelwenn (lanodan) Monnier <contact+mstrace@hacktivis.me>
  3. # SPDX-License-Identifier: MPL-2.0
  4. grep -F '#define SYS_' tmp_strsyscall.h | sort -n -k 3 -r | head -1 | if read op name num; then
  5. echo "\
  6. #define SYSCALLS_MAX $((num+1))
  7. extern const char *str_syscalls[SYSCALLS_MAX];" >|strsyscall.h
  8. fi
  9. cat <<'EOF'
  10. #include <sys/syscall.h>
  11. #include "strsyscall.h"
  12. const char *str_syscalls[SYSCALLS_MAX] = {
  13. EOF
  14. grep -F '#define SYS_' tmp_strsyscall.h | while read op name num; do
  15. name_short=${name//SYS_}
  16. printf '#ifdef %s\n\t[%s] = "%s",\n#endif\n' "$name" "$name" "${name//SYS_}"
  17. done
  18. echo '};'