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# 22# ./update-linux.sh amd64-linux.xml.in 23# ./update-linux.sh i386-linux.xml.in -m32 24 25 26if [ $# -lt 1 ]; then 27 echo "file argument needed" 28 exit 1 29fi 30 31f="$1" 32shift 33 34if [ ! -f "$f" ]; then 35 echo "cannot find $f" 36 exit 1 37fi 38 39year=$(date +%Y) 40 41( 42 cat <<EOF 43<?xml version="1.0"?> 44<!-- Copyright (C) 2009-$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 <sys/syscall.h> 55 56 The file mentioned above belongs to the Linux Kernel. --> 57 58 59EOF 60 61 echo '<syscalls_info>' 62 63 echo '#include <sys/syscall.h>' \ 64 | gcc -E - -dD "$@" \ 65 | grep -E '#define __NR_' \ 66 | while read -r line; do 67 name=$(echo "$line" | awk '{print $2}' | sed 's/^__NR_//') 68 nr=$(echo "$line" | awk '{print $3}') 69 echo " <syscall name=\"$name\" number=\"$nr\"/>" 70 done 71 72 echo '</syscalls_info>' 73) > "$f" 74