17d62b00eSchristos#! /bin/sh 27d62b00eSchristos 3*6881a400Schristos# Copyright (C) 2020-2023 Free Software Foundation, Inc. 47d62b00eSchristos# 57d62b00eSchristos# This file is part of GDB. 67d62b00eSchristos# 77d62b00eSchristos# This program is free software; you can redistribute it and/or modify 87d62b00eSchristos# it under the terms of the GNU General Public License as published by 97d62b00eSchristos# the Free Software Foundation; either version 3 of the License, or 107d62b00eSchristos# (at your option) any later version. 117d62b00eSchristos# 127d62b00eSchristos# This program is distributed in the hope that it will be useful, 137d62b00eSchristos# but WITHOUT ANY WARRANTY; without even the implied warranty of 147d62b00eSchristos# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 157d62b00eSchristos# GNU General Public License for more details. 167d62b00eSchristos# 177d62b00eSchristos# You should have received a copy of the GNU General Public License 187d62b00eSchristos# along with this program. If not, see <http://www.gnu.org/licenses/>. 197d62b00eSchristos 207d62b00eSchristos# Usage: update-netbsd.sh <path-to-syscall.h> 217d62b00eSchristos# Update the netbsd.xml file. 227d62b00eSchristos# 237d62b00eSchristos# NetBSD uses the same list of system calls on all architectures. 247d62b00eSchristos# The list is defined in the sys/kern/syscalls.master file in the 257d62b00eSchristos# NetBSD source tree. This file is used as an input to generate 267d62b00eSchristos# several files that are also stored in NetBSD's source tree. This 277d62b00eSchristos# script parses one of those generated files (sys/sys/syscall.h) 287d62b00eSchristos# rather than syscalls.master as syscall.h is easier to parse. 297d62b00eSchristos 307d62b00eSchristosif [ $# -ne 1 ]; then 317d62b00eSchristos echo "Error: Path to syscall.h missing. Aborting." 32*6881a400Schristos echo "Usage: update-netbsd.sh <path-to-syscall.h>" 337d62b00eSchristos exit 1 347d62b00eSchristosfi 357d62b00eSchristos 367d62b00eSchristoscat > netbsd.xml.tmp <<EOF 377d62b00eSchristos<?xml version="1.0"?> <!-- THIS FILE IS GENERATED -*- buffer-read-only: t -*- --> 387d62b00eSchristos<!-- vi:set ro: --> 39*6881a400Schristos<!-- Copyright (C) 2020-2023 Free Software Foundation, Inc. 407d62b00eSchristos 417d62b00eSchristos Copying and distribution of this file, with or without modification, 427d62b00eSchristos are permitted in any medium without royalty provided the copyright 437d62b00eSchristos notice and this notice are preserved. --> 447d62b00eSchristos 457d62b00eSchristos<!DOCTYPE feature SYSTEM "gdb-syscalls.dtd"> 467d62b00eSchristos 477d62b00eSchristos<!-- This file was generated using the following file: 487d62b00eSchristos 497d62b00eSchristos /usr/src/sys/sys/syscall.h 507d62b00eSchristos 517d62b00eSchristos The file mentioned above belongs to the NetBSD Kernel. --> 527d62b00eSchristos 537d62b00eSchristos<syscalls_info> 547d62b00eSchristosEOF 557d62b00eSchristos 567d62b00eSchristosawk ' 577d62b00eSchristos/MAXSYSCALL/ || /_SYS_SYSCALL_H_/ || /MAXSYSARGS/ || /syscall/ || /NSYSENT/ { 587d62b00eSchristos next 597d62b00eSchristos} 607d62b00eSchristos/^#define/ { 617d62b00eSchristos sub(/^SYS_/,"",$2); 627d62b00eSchristos printf " <syscall name=\"%s\" number=\"%s\"", $2, $3 637d62b00eSchristos if (sub(/^netbsd[0-9]*_/,"",$2) != 0) 647d62b00eSchristos printf " alias=\"%s\"", $2 657d62b00eSchristos printf "/>\n" 667d62b00eSchristos} 677d62b00eSchristos/\/\* [0-9]* is obsolete [a-z_]* \*\// { 687d62b00eSchristos printf " <syscall name=\"%s\" number=\"%s\"/>\n", $5, $2 697d62b00eSchristos} 707d62b00eSchristos/\/\* [0-9]* is netbsd[0-9]* [a-z_]* \*\// { 717d62b00eSchristos printf " <syscall name=\"%s_%s\" number=\"%s\" alias=\"%s\"/>\n", $4, $5, $2, $5 727d62b00eSchristos}' "$1" >> netbsd.xml.tmp 737d62b00eSchristos 747d62b00eSchristoscat >> netbsd.xml.tmp <<EOF 757d62b00eSchristos</syscalls_info> 767d62b00eSchristosEOF 777d62b00eSchristos 787d62b00eSchristos../../move-if-change netbsd.xml.tmp netbsd.xml 79