1#!/bin/sh 2 3# Copyright (C) 2022-2023 Free Software Foundation, Inc. 4# 5# This file is part of GDB. 6# 7# This program is free software; you can redistribute it and/or modify 8# it under the terms of the GNU General Public License as published by 9# the Free Software Foundation; either version 3 of the License, or 10# (at your option) any later version. 11# 12# This program is distributed in the hope that it will be useful, 13# but WITHOUT ANY WARRANTY; without even the implied warranty of 14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15# GNU General Public License for more details. 16# 17# You should have received a copy of the GNU General Public License 18# along with this program. If not, see <http://www.gnu.org/licenses/>. 19 20# Used to generate .xml.in files, like so: 21# $ ./update-linux-from-src.sh ~/linux-stable.git 22 23if [ $# -lt 1 ]; then 24 echo "dir argument needed" 25 exit 1 26fi 27 28d="$1" 29shift 30 31if [ ! -d "$d" ]; then 32 echo "cannot find $d" 33 exit 1 34fi 35 36pre () 37{ 38 f="$1" 39 40 year=$(date +%Y) 41 42 cat <<EOF 43<?xml version="1.0"?> 44<!-- Copyright (C) $start_date-$year Free Software Foundation, Inc. 45 46 Copying and distribution of this file, with or without modification, 47 are permitted in any medium without royalty provided the copyright 48 notice and this notice are preserved. --> 49 50<!DOCTYPE feature SYSTEM "gdb-syscalls.dtd"> 51 52<!-- This file was generated using the following file: 53 54 $f 55 56 The file mentioned above belongs to the Linux Kernel. --> 57 58 59EOF 60 61 echo '<syscalls_info>' 62} 63 64 65post () 66{ 67 echo '</syscalls_info>' 68} 69 70one () 71{ 72 f="$1" 73 abi="$2" 74 start_date="$3" 75 offset="$4" 76 77 pre "$f" "$start_date" 78 79 grep -v "^#" "$d/$f" \ 80 | awk '{print $2, $3, $1}' \ 81 | grep -E "^$abi" \ 82 | grep -E -v " (reserved|unused)[0-9]+ " \ 83 | awk "{printf \" <syscall name=\\\"%s\\\" number=\\\"%s\\\"/>\n\", \$2, \$3 + $offset}" 84 85 post 86} 87 88for f in *.in; do 89 start_date=2009 90 offset=0 91 92 case $f in 93 amd64-linux.xml.in) 94 t="arch/x86/entry/syscalls/syscall_64.tbl" 95 abi="(common|64)" 96 ;; 97 i386-linux.xml.in) 98 t="arch/x86/entry/syscalls/syscall_32.tbl" 99 abi=i386 100 ;; 101 ppc64-linux.xml.in) 102 t="arch/powerpc/kernel/syscalls/syscall.tbl" 103 abi="(common|64|nospu)" 104 ;; 105 ppc-linux.xml.in) 106 t="arch/powerpc/kernel/syscalls/syscall.tbl" 107 abi="(common|32|nospu)" 108 ;; 109 s390-linux.xml.in) 110 t="arch/s390/kernel/syscalls/syscall.tbl" 111 abi="(common|32)" 112 ;; 113 s390x-linux.xml.in) 114 t="arch/s390/kernel/syscalls/syscall.tbl" 115 abi="(common|64)" 116 ;; 117 sparc64-linux.xml.in) 118 t="arch/sparc/kernel/syscalls/syscall.tbl" 119 abi="(common|64)" 120 start_date="2010" 121 ;; 122 sparc-linux.xml.in) 123 t="arch/sparc/kernel/syscalls/syscall.tbl" 124 abi="(common|32)" 125 start_date="2010" 126 ;; 127 mips-n32-linux.xml.in) 128 t="arch/mips/kernel/syscalls/syscall_n32.tbl" 129 abi="n32" 130 start_date="2011" 131 offset=6000 132 ;; 133 mips-n64-linux.xml.in) 134 t="arch/mips/kernel/syscalls/syscall_n64.tbl" 135 abi="n64" 136 start_date="2011" 137 offset=5000 138 ;; 139 mips-o32-linux.xml.in) 140 t="arch/mips/kernel/syscalls/syscall_o32.tbl" 141 abi="o32" 142 start_date="2011" 143 offset=4000 144 ;; 145 bfin-linux.xml.in) 146 echo "Skipping $f, no longer supported" 147 continue 148 ;; 149 aarch64-linux.xml.in) 150 echo "Skipping $f, no syscall.tbl" 151 continue 152 ;; 153 arm-linux.xml.in) 154 echo "Skipping $f, use arm-linux.py instead" 155 continue 156 ;; 157 linux-defaults.xml.in) 158 continue 159 ;; 160 *) 161 echo "Don't know how to generate $f" 162 continue 163 ;; 164 esac 165 166 echo "Generating $f" 167 one "$t" "$abi" "$start_date" "$offset" > "$f" 168 169done 170