public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: Tom Tromey <tom@tromey.com>,
	Tom de Vries via Gdb-patches <gdb-patches@sourceware.org>
Cc: Simon Marchi <simark@simark.ca>
Subject: Re: [PATCH][gdb] Update syscalls/{amd64,i386}-linux.xml
Date: Tue, 10 May 2022 13:39:14 +0200	[thread overview]
Message-ID: <adc40e4d-bab5-e8dc-ffe0-a25fceffb228@suse.de> (raw)
In-Reply-To: <87levaipy7.fsf@tromey.com>

[-- Attachment #1: Type: text/plain, Size: 1166 bytes --]

On 5/9/22 19:19, Tom Tromey wrote:
>>>>>> "Tom" == Tom de Vries via Gdb-patches <gdb-patches@sourceware.org> writes:
> 
> Tom> diff --git a/gdb/syscalls/gen-header.py b/gdb/syscalls/gen-header.py
> 
> Tom> +<!-- Copyright (C) 2009-%s Free Software Foundation, Inc.
> 
> Tom> +"""
> Tom> +    % (time.strftime("%Y"), infname)
> 
> It seems like overkill to have a python script just for a "here
> document" and "date +%Y".
> 

Ack, fixed.

> Tom> +(
> Tom> +    python gen-header.py "<sys/syscall.h>"
> Tom> +
> Tom> +    tmp=$(mktemp)
> Tom> +
> Tom> +    echo '#include <sys/syscall.h>' \
> Tom> +	| gcc -E - -dD "$@" \
> Tom> +	| egrep '#define __NR_' \
> Tom> +		> $tmp
> Tom> +
> Tom> +    echo '<syscalls_info>'
> Tom> +
> Tom> +    while read line; do
> Tom> +	name=$(echo $line | awk '{print $2}' | sed 's/^__NR_//')
> Tom> +	nr=$(echo $line | awk '{print $3}')
> Tom> +	echo "  <syscall name=\"$name\" number=\"$nr\"/>"
> Tom> +    done < $tmp
> Tom> +
> Tom> +    echo '</syscalls_info>'
> 
> Alternatively doing the whole thing in Python would also be alright.

I've done things in bash for now, that's easier for me.

Any further comments?

Thanks,
- Tom

[-- Attachment #2: 0006-gdb-tdep-Improve-gdb-syscalls-update-linux.sh.patch --]
[-- Type: text/x-patch, Size: 2817 bytes --]

[gdb/tdep] Improve gdb/syscalls/update-linux.sh

Fix two things in update-linux.sh:
- remove use of unnecessary tmp file
- inline gen-header.py into update-linux.sh

Tested on x86_64-linux.

---
 gdb/syscalls/gen-header.py   | 32 --------------------------------
 gdb/syscalls/update-linux.sh | 33 +++++++++++++++++++++++----------
 2 files changed, 23 insertions(+), 42 deletions(-)

diff --git a/gdb/syscalls/gen-header.py b/gdb/syscalls/gen-header.py
deleted file mode 100644
index 78ccdddbff6..00000000000
--- a/gdb/syscalls/gen-header.py
+++ /dev/null
@@ -1,32 +0,0 @@
-# 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(
-    """\
-<?xml version="1.0"?>
-<!-- Copyright (C) 2009-%s 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.  -->
-
-<!DOCTYPE feature SYSTEM "gdb-syscalls.dtd">
-
-<!-- This file was generated using the following file:
-
-     %s
-
-     The file mentioned above belongs to the Linux Kernel.  -->
-
-"""
-    % (time.strftime("%Y"), infname)
-)
diff --git a/gdb/syscalls/update-linux.sh b/gdb/syscalls/update-linux.sh
index a6719077dc5..e26ec4e92cb 100755
--- a/gdb/syscalls/update-linux.sh
+++ b/gdb/syscalls/update-linux.sh
@@ -36,25 +36,38 @@ if [ ! -f "$f" ]; then
     exit 1
 fi
 
+year=$(date +%Y)
+
 (
-    python gen-header.py "<sys/syscall.h>"
+    cat <<EOF
+<?xml version="1.0"?>
+<!-- Copyright (C) 2009-$year Free Software Foundation, Inc.
 
-    tmp=$(mktemp)
+     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.  -->
 
-    echo '#include <sys/syscall.h>' \
-	| gcc -E - -dD "$@" \
-	| grep -E '#define __NR_' \
-		> "$tmp"
+<!DOCTYPE feature SYSTEM "gdb-syscalls.dtd">
+
+<!-- This file was generated using the following file:
+
+     <sys/syscall.h>
+
+     The file mentioned above belongs to the Linux Kernel.  -->
+
+
+EOF
 
     echo '<syscalls_info>'
 
-    while read -r line; do
+    echo '#include <sys/syscall.h>' \
+	| gcc -E - -dD "$@" \
+	| grep -E '#define __NR_' \
+	| while read -r line; do
 	name=$(echo "$line" | awk '{print $2}' | sed 's/^__NR_//')
 	nr=$(echo "$line" | awk '{print $3}')
 	echo "  <syscall name=\"$name\" number=\"$nr\"/>"
-    done < "$tmp"
+    done
 
     echo '</syscalls_info>'
-
-    rm -f "$tmp"
 ) > "$f"

  reply	other threads:[~2022-05-10 11:39 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-03 14:57 [PATCH][gdb/testsuite] Handle pipe2 syscall in gdb.base/catch-syscall.exp Tom de Vries
2022-05-05 11:47 ` [PATCH, v2][gdb/testsuite] " Tom de Vries
2022-05-05 11:49   ` [PATCH][gdb/tdep] Support catch syscall pipe2 for i386 Tom de Vries
2022-05-05 13:20     ` Simon Marchi
2022-05-09 10:26       ` [PATCH][gdb] Add gdb/syscalls/Makefile Tom de Vries
2022-05-09 14:41         ` Simon Marchi
2022-05-09 14:46           ` Tom de Vries
2022-05-09 10:39       ` [PATCH][gdb] Update syscalls/{amd64,i386}-linux.xml Tom de Vries
2022-05-09 14:48         ` Simon Marchi
2022-05-09 15:29           ` Tom de Vries
2022-05-09 15:40             ` Andreas Schwab
2022-05-09 15:42               ` Tom de Vries
2022-05-09 15:45                 ` Andreas Schwab
2022-05-09 16:04                   ` Tom de Vries
2022-05-09 17:19         ` Tom Tromey
2022-05-10 11:39           ` Tom de Vries [this message]
2022-05-12  9:00             ` Tom de Vries
2022-05-10 11:53         ` Tom de Vries
2022-05-16 16:07           ` Tom Tromey
2022-05-18  9:58             ` [committed][gdb/tdep] Add gdb/syscalls/update-linux-from-src.sh Tom de Vries
2022-05-05 13:23   ` [PATCH, v2][gdb/testsuite] Handle pipe2 syscall in gdb.base/catch-syscall.exp Simon Marchi
2022-05-09 10:18     ` Tom de Vries

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=adc40e4d-bab5-e8dc-ffe0-a25fceffb228@suse.de \
    --to=tdevries@suse.de \
    --cc=gdb-patches@sourceware.org \
    --cc=simark@simark.ca \
    --cc=tom@tromey.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).