From: Tom de Vries Date: Mon, 9 Dec 2024 14:49:44 +0000 (+0100) Subject: [gdb/syscalls] Generate aarch64-linux.xml.in in update-linux-from-src.sh X-Git-Tag: gdb-16-branchpoint~157 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4f719a08a8a7c80dbac0854311516e299de178a6;p=thirdparty%2Fbinutils-gdb.git [gdb/syscalls] Generate aarch64-linux.xml.in in update-linux-from-src.sh Currently aarch64-linux.xml.in is skipped by update-linux-from-src.sh: ... $ ./update-linux-from-src.sh ~/upstream/linux-stable.git/ Skipping aarch64-linux.xml.in, no syscall.tbl ... $ ... and instead we use update-linux.sh. This works fine, but requires an aarch64 system with recent system headers, which makes it harder to pick up the latest changes in the linux kernel. Fix this by updating ./update-linux-from-src.sh to: - build the linux kernel headers for aarch64 - use update-linux.sh with those headers to generate aarch64-linux.xml.in. Regenerating aarch64-linux.xml.in using current trunk of linux-stable gives me these changes: ... + + + + ... which are the same changes I see for the other architectures. Note that the first step, building the linux kernel headers is a cross build and should work on any architecture. But the second step, update-linux.sh uses plain gcc rather than a cross-gcc, so there is scope for problems, but we seem to get away with this on x86_64-linux. So, while we could constrain this to only generate aarch64-linux.xml.in on aarch64-linux, I'm leaving this unconstrained. For aarch64-linux.xml.in, this doesn't matter much to me because I got an aarch64-linux system. But I don't have a longaarch system, and the same approach seems to work there. I'm leaving this for follow-up patch though. Tested on aarch64-linux and x86_64-linux. Verified with shellcheck. --- diff --git a/gdb/syscalls/update-linux-from-src.sh b/gdb/syscalls/update-linux-from-src.sh index d07cbbd9b44..35d78995eaa 100755 --- a/gdb/syscalls/update-linux-from-src.sh +++ b/gdb/syscalls/update-linux-from-src.sh @@ -20,6 +20,8 @@ # Used to generate .xml.in files, like so: # $ ./update-linux-from-src.sh ~/linux-stable.git +pwd=$(pwd -P) + parse_args () { if [ $# -lt 1 ]; then @@ -36,6 +38,51 @@ parse_args () fi } +gen_from_kernel_headers () +{ + local f + f="$1" + local arch + arch="$2" + + echo "Generating $f" + + local tmpdir + tmpdir=$(mktemp -d) + trap 'rm -Rf $tmpdir/*' EXIT + + local build + build="$tmpdir"/build + local install + install="$tmpdir"/install + local usr + usr="$install"/usr + local include + include="$usr"/include + + mkdir -p "$build" "$usr" + + ( + cd "$build" || exit 1 + + make \ + -f "$d"/Makefile \ + ARCH="$arch" \ + INSTALL_HDR_PATH="$usr" \ + headers_install \ + > "$build"/header_install.log \ + 2>&1 + + "$pwd"/update-linux.sh \ + "$pwd"/"$f" \ + -nostdinc \ + -isystem "$include" + ) + + trap '' EXIT + rm -Rf "$tmpdir" +} + pre () { local f @@ -274,7 +321,8 @@ regen () return ;; aarch64-linux.xml.in) - echo "Skipping $f, no syscall.tbl" + # No syscall.tbl. + gen_from_kernel_headers "$f" arm64 return ;; arm-linux.xml.in) diff --git a/gdb/syscalls/update-linux.sh b/gdb/syscalls/update-linux.sh index 066572cbec9..127d92192d1 100755 --- a/gdb/syscalls/update-linux.sh +++ b/gdb/syscalls/update-linux.sh @@ -67,7 +67,7 @@ EOF echo '' - echo '#include ' \ + echo '#include ' \ | gcc -E - -dD "$@" \ | grep -E '#define __NR_' \ | while read -r line; do