[PATCH v3 1/4] gdb: syscalls: Handle __NR3264_ prefixed syscall number
Tiezhu Yang
yangtiezhu@loongson.cn
Mon Dec 16 07:03:02 GMT 2024
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 <yangtiezhu@loongson.cn>
---
gdb/syscalls/update-linux.sh | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
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 '<syscalls_info>'
+# 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 <asm/unistd.h>' \
| 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 " <syscall name=\"$name\" number=\"$nr\"/>"
done
--
2.42.0
More information about the Gdb-patches
mailing list