aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom de Vries <tdevries@suse.de>2024-11-26 09:49:29 +0100
committerTom de Vries <tdevries@suse.de>2024-11-26 09:49:29 +0100
commiteb522d6d1325c6604716e7f3fd70d351400ee541 (patch)
tree3622bff8b5f3064736791ba6b69d6f8875d21964
parent587769010743eb8eac8b4373218486875a11cb69 (diff)
downloadbinutils-eb522d6d1325c6604716e7f3fd70d351400ee541.zip
binutils-eb522d6d1325c6604716e7f3fd70d351400ee541.tar.gz
binutils-eb522d6d1325c6604716e7f3fd70d351400ee541.tar.bz2
[gdb/syscalls] Improve update-linux-from-src.sh
Some improvements in gdb/syscalls/update-linux-from-src.sh: - use bash instead of sh - use local to distinguish between local and global vars (which brings to light that pre uses the global rather than the local start_date) - factor out main and parse_args - factor out regen - iterate over *.xml.in instead of *.in Tested on aarch64-linux. Verified with shellcheck.
-rwxr-xr-xgdb/syscalls/update-linux-from-src.sh73
1 files changed, 52 insertions, 21 deletions
diff --git a/gdb/syscalls/update-linux-from-src.sh b/gdb/syscalls/update-linux-from-src.sh
index 21c921a..b6985ba 100755
--- a/gdb/syscalls/update-linux-from-src.sh
+++ b/gdb/syscalls/update-linux-from-src.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
# Copyright (C) 2022-2024 Free Software Foundation, Inc.
#
@@ -20,23 +20,30 @@
# Used to generate .xml.in files, like so:
# $ ./update-linux-from-src.sh ~/linux-stable.git
-if [ $# -lt 1 ]; then
- echo "dir argument needed"
- exit 1
-fi
-
-d="$1"
-shift
-
-if [ ! -d "$d" ]; then
- echo "cannot find $d"
- exit 1
-fi
+parse_args ()
+{
+ if [ $# -lt 1 ]; then
+ echo "dir argument needed"
+ exit 1
+ fi
+
+ d="$1"
+ shift
+
+ if [ ! -d "$d" ]; then
+ echo "cannot find $d"
+ exit 1
+ fi
+}
pre ()
{
+ local f
f="$1"
+ local start_date
+ start_date="$2"
+ local year
year=$(date +%Y)
cat <<EOF
@@ -69,9 +76,13 @@ post ()
one ()
{
+ local f
f="$1"
+ local abi
abi="$2"
+ local start_date
start_date="$3"
+ local offset
offset="$4"
pre "$f" "$start_date"
@@ -85,10 +96,18 @@ one ()
post
}
-for f in *.in; do
+regen ()
+{
+ local f
+ f="$1"
+
+ local start_date
start_date=2009
+ local offset
offset=0
+ local t
+ local abi
case $f in
amd64-linux.xml.in)
t="arch/x86/entry/syscalls/syscall_64.tbl"
@@ -144,30 +163,42 @@ for f in *.in; do
;;
bfin-linux.xml.in)
echo "Skipping $f, no longer supported"
- continue
+ return
;;
aarch64-linux.xml.in)
echo "Skipping $f, no syscall.tbl"
- continue
+ return
;;
arm-linux.xml.in)
echo "Skipping $f, use arm-linux.py instead"
- continue
+ return
;;
loongarch-linux.xml.in)
echo "Skipping $f, no syscall.tbl"
- continue
+ return
;;
linux-defaults.xml.in)
- continue
+ return
;;
*)
echo "Don't know how to generate $f"
- continue
+ return
;;
esac
echo "Generating $f"
one "$t" "$abi" "$start_date" "$offset" > "$f"
+}
+
+main ()
+{
+ # Set global d.
+ parse_args "$@"
+
+ local f
+ for f in *.xml.in; do
+ regen "$f"
+ done
+}
-done
+main "$@"