From: Tiezhu Yang Date: Mon, 16 Dec 2024 07:03:02 +0000 (+0800) Subject: gdb: syscalls: Handle __NR3264_ prefixed syscall number X-Git-Tag: gdb-16-branchpoint~66 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c740c422eeacaef43475bbe2245470e6828cb9f8;p=thirdparty%2Fbinutils-gdb.git gdb: syscalls: Handle __NR3264_ prefixed syscall number In gdb commit a08dc2aa004b ("gdb: syscalls: Add loongarch-linux.xml.in"), we find: There exist some __NR3264_ prefixed syscall numbers, replace them with digital numbers according to /usr/include/asm-generic/unistd.h and sort them by syscall number manually, maybe we can modify the script to do it automatically in the future. It is time to do it now, just handle __NR3264_ prefixed syscall number automatically in the script update-linux.sh. By the way, a Linux kernel patch did the similar change [1]. [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=d6e1cc6b7220 Signed-off-by: Tiezhu Yang Approved-By: Tom de Vries --- diff --git a/gdb/syscalls/update-linux.sh b/gdb/syscalls/update-linux.sh index 127d92192d1..8248a962563 100755 --- a/gdb/syscalls/update-linux.sh +++ b/gdb/syscalls/update-linux.sh @@ -22,7 +22,6 @@ # ./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 @@ -67,12 +66,23 @@ EOF echo '' +# There are __NR_ and __NR3264_ prefixed syscall numbers, handle them +# automatically in this script. Here are the examples of the two types: +# +# #define __NR_io_setup 0 +# #define __NR3264_fcntl 25 + echo '#include ' \ | gcc -E - -dD "$@" \ - | grep -E '#define __NR_' \ + | grep -E '#define (__NR_|__NR3264_)' \ | while read -r line; do - name=$(echo "$line" | awk '{print $2}' | sed 's/^__NR_//') - nr=$(echo "$line" | awk '{print $3}') + line=$(echo "$line" | awk '$2 ~ "__NR" && $3 !~ "__NR3264_" { + sub("^#define __NR(3264)?_", ""); print | "sort -k2 -n"}') + if [ -z "$line" ]; then + continue + fi + name=$(echo "$line" | awk '{print $1}') + nr=$(echo "$line" | awk '{print $2}') echo " " done