From f3c75b2cbe88aa1f637d08317614bbeb2cbeecea Mon Sep 17 00:00:00 2001 From: Tom de Vries Date: Mon, 9 May 2022 17:22:23 +0200 Subject: [PATCH] [gdb] Update syscalls/{amd64,i386}-linux.xml - Add a script syscalls/gen-header.py, based on syscalls/arm-linux.py. - Add a script syscalls/update-linux.sh (alongside update-freebsd.sh and update-netbsd.sh). - Use syscalls/update-linux.sh to update syscalls/{amd64,i386}-linux.xml.in. - Regenerate syscalls/{amd64,i386}-linux.xml using syscalls/Makefile. In gdb/syscalls/i386-linux.xml.in, updating has the following notable effect: ... - - - + + ... I've verified in ./arch/x86/entry/syscalls/syscall_32.tbl that the numbers are correct. Tested on x86_64-linux. --- gdb/syscalls/amd64-linux.xml | 69 ++++++++++++++++- gdb/syscalls/amd64-linux.xml.in | 70 +++++++++++++++++- gdb/syscalls/gen-header.py | 32 ++++++++ gdb/syscalls/i386-linux.xml | 126 +++++++++++++++++++++++++++++-- gdb/syscalls/i386-linux.xml.in | 127 ++++++++++++++++++++++++++++++-- gdb/syscalls/update-linux.sh | 60 +++++++++++++++ 6 files changed, 470 insertions(+), 14 deletions(-) create mode 100644 gdb/syscalls/gen-header.py create mode 100755 gdb/syscalls/update-linux.sh diff --git a/gdb/syscalls/amd64-linux.xml b/gdb/syscalls/amd64-linux.xml index 481431d3121..231308b72b7 100644 --- a/gdb/syscalls/amd64-linux.xml +++ b/gdb/syscalls/amd64-linux.xml @@ -6,8 +6,8 @@ are permitted in any medium without royalty provided the copyright notice and this notice are preserved. --> @@ -308,4 +308,69 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/gdb/syscalls/amd64-linux.xml.in b/gdb/syscalls/amd64-linux.xml.in index 3b0834b874b..404d445988e 100644 --- a/gdb/syscalls/amd64-linux.xml.in +++ b/gdb/syscalls/amd64-linux.xml.in @@ -8,11 +8,12 @@ + @@ -311,4 +312,69 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/gdb/syscalls/gen-header.py b/gdb/syscalls/gen-header.py new file mode 100644 index 00000000000..78ccdddbff6 --- /dev/null +++ b/gdb/syscalls/gen-header.py @@ -0,0 +1,32 @@ +# Copyright (C) 2013-2022 Free Software Foundation, Inc. + +# Copying and distribution of this file, with or without modification, +# are permitted in any medium without royalty provided the copyright +# notice and this notice are preserved. This file is offered as-is, +# without any warranty. + +import sys +import time + +infname = sys.argv[1] + +print( + """\ + + + + + + + +""" + % (time.strftime("%Y"), infname) +) diff --git a/gdb/syscalls/i386-linux.xml b/gdb/syscalls/i386-linux.xml index 4a7a2345186..c4b28111388 100644 --- a/gdb/syscalls/i386-linux.xml +++ b/gdb/syscalls/i386-linux.xml @@ -6,8 +6,8 @@ are permitted in any medium without royalty provided the copyright notice and this notice are preserved. --> @@ -231,9 +231,8 @@ - - - + + @@ -334,5 +333,122 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/gdb/syscalls/i386-linux.xml.in b/gdb/syscalls/i386-linux.xml.in index 13c4d1d99d4..549b59565f3 100644 --- a/gdb/syscalls/i386-linux.xml.in +++ b/gdb/syscalls/i386-linux.xml.in @@ -8,11 +8,12 @@ + @@ -234,9 +235,8 @@ - - - + + @@ -337,5 +337,122 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/gdb/syscalls/update-linux.sh b/gdb/syscalls/update-linux.sh new file mode 100755 index 00000000000..a6719077dc5 --- /dev/null +++ b/gdb/syscalls/update-linux.sh @@ -0,0 +1,60 @@ +#!/bin/sh + +# Copyright (C) 2022 Free Software Foundation, Inc. +# +# This file is part of GDB. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Used to generate .xml.in files, like so: +# +# ./update-linux.sh amd64-linux.xml.in +# ./update-linux.sh i386-linux.xml.in -m32 + + +if [ $# -lt 1 ]; then + echo "file argument needed" + exit 1 +fi + +f="$1" +shift + +if [ ! -f "$f" ]; then + echo "cannot find $f" + exit 1 +fi + +( + python gen-header.py "" + + tmp=$(mktemp) + + echo '#include ' \ + | gcc -E - -dD "$@" \ + | grep -E '#define __NR_' \ + > "$tmp" + + echo '' + + while read -r line; do + name=$(echo "$line" | awk '{print $2}' | sed 's/^__NR_//') + nr=$(echo "$line" | awk '{print $3}') + echo " " + done < "$tmp" + + echo '' + + rm -f "$tmp" +) > "$f" -- 2.30.2