update-netbsd.sh 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #! /bin/sh
  2. # Copyright (C) 2020-2022 Free Software Foundation, Inc.
  3. #
  4. # This file is part of GDB.
  5. #
  6. # This program is free software; you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License as published by
  8. # the Free Software Foundation; either version 3 of the License, or
  9. # (at your option) any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License
  17. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. # Usage: update-netbsd.sh <path-to-syscall.h>
  19. # Update the netbsd.xml file.
  20. #
  21. # NetBSD uses the same list of system calls on all architectures.
  22. # The list is defined in the sys/kern/syscalls.master file in the
  23. # NetBSD source tree. This file is used as an input to generate
  24. # several files that are also stored in NetBSD's source tree. This
  25. # script parses one of those generated files (sys/sys/syscall.h)
  26. # rather than syscalls.master as syscall.h is easier to parse.
  27. if [ $# -ne 1 ]; then
  28. echo "Error: Path to syscall.h missing. Aborting."
  29. echo "Usage: update-netbsd.sh <path-to-syscall.h>"
  30. exit 1
  31. fi
  32. cat > netbsd.xml.tmp <<EOF
  33. <?xml version="1.0"?> <!-- THIS FILE IS GENERATED -*- buffer-read-only: t -*- -->
  34. <!-- vi:set ro: -->
  35. <!-- Copyright (C) 2020-2022 Free Software Foundation, Inc.
  36. Copying and distribution of this file, with or without modification,
  37. are permitted in any medium without royalty provided the copyright
  38. notice and this notice are preserved. -->
  39. <!DOCTYPE feature SYSTEM "gdb-syscalls.dtd">
  40. <!-- This file was generated using the following file:
  41. /usr/src/sys/sys/syscall.h
  42. The file mentioned above belongs to the NetBSD Kernel. -->
  43. <syscalls_info>
  44. EOF
  45. awk '
  46. /MAXSYSCALL/ || /_SYS_SYSCALL_H_/ || /MAXSYSARGS/ || /syscall/ || /NSYSENT/ {
  47. next
  48. }
  49. /^#define/ {
  50. sub(/^SYS_/,"",$2);
  51. printf " <syscall name=\"%s\" number=\"%s\"", $2, $3
  52. if (sub(/^netbsd[0-9]*_/,"",$2) != 0)
  53. printf " alias=\"%s\"", $2
  54. printf "/>\n"
  55. }
  56. /\/\* [0-9]* is obsolete [a-z_]* \*\// {
  57. printf " <syscall name=\"%s\" number=\"%s\"/>\n", $5, $2
  58. }
  59. /\/\* [0-9]* is netbsd[0-9]* [a-z_]* \*\// {
  60. printf " <syscall name=\"%s_%s\" number=\"%s\" alias=\"%s\"/>\n", $4, $5, $2, $5
  61. }' "$1" >> netbsd.xml.tmp
  62. cat >> netbsd.xml.tmp <<EOF
  63. </syscalls_info>
  64. EOF
  65. ../../move-if-change netbsd.xml.tmp netbsd.xml