Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Subject: [PATCH] [gdb] Use shfmt on regformats/regdat.sh
Date: Fri, 28 Aug 2026 16:12:41 +0200	[thread overview]
Message-ID: <20260828141241.3921145-1-tdevries@suse.de> (raw)

Run shfmt [1] on gdb/regformats/regdat.sh:
...
$ shfmt \
    --language-dialect=posix \
    --indent=4 \
    --func-next-line \
    --space-redirects \
    --write \
    gdb/regformats/regdat.sh
...
followed by emacs whitespace-cleanup (because shfmt doesn't know about mixed
tab/spaces indentation).

Normalizes things like:
...
if true
then
...
to:
...
if true; then
...
as suggested by Simon [2].

Also:
- fixes up inconsistent indentation
- makes sure statements are on their own line
- removes double empty line
- minor whitespace changes:
  - do_read ()      -> do_read()
  - cat <<EOF       -> cat << EOF

[1] https://github.com/mvdan/sh
[2] https://sourceware.org/pipermail/gdb-patches/2026-August/229818.html
---
 gdb/regformats/regdat.sh | 149 +++++++++++++++++++--------------------
 1 file changed, 71 insertions(+), 78 deletions(-)

diff --git a/gdb/regformats/regdat.sh b/gdb/regformats/regdat.sh
index f93270ba0ca..0df4d07c44b 100755
--- a/gdb/regformats/regdat.sh
+++ b/gdb/regformats/regdat.sh
@@ -23,17 +23,14 @@ set -u
 # Format of the input files
 read="type entry"
 
-do_read ()
+do_read()
 {
     type=""
     entry=""
-    while read -r line
-    do
-	if test "${line}" = ""
-	then
+    while read -r line; do
+	if test "${line}" = ""; then
 	    continue
-	elif expr "${line}" : "#" > /dev/null
-	then
+	elif expr "${line}" : "#" > /dev/null; then
 	    continue
 	else
 
@@ -42,21 +39,20 @@ do_read ()
 	    # Work around this by eliminating ``::'' ....
 	    line="$(echo "${line}" | sed -e 's/::/: :/g' -e 's/::/: :/g')"
 
-	    OFS="${IFS}" ; IFS="[:]"
+	    OFS="${IFS}"
+	    IFS="[:]"
 	    # Word-splitting on read variable is required.
 	    # shellcheck disable=SC2086
-	    eval read ${read} <<EOF
+	    eval read ${read} << EOF
 ${line}
 EOF
 	    IFS="${OFS}"
 
 	    # .... and then going back through each field and strip out those
 	    # that ended up with just that space character.
-	    for r in ${read}
-	    do
+	    for r in ${read}; do
 		eval "rvalue=\$$r"
-		if test "${rvalue:-}" = " "
-		then
+		if test "${rvalue:-}" = " "; then
 		    eval "$r=''"
 		fi
 	    done
@@ -64,8 +60,7 @@ EOF
 	    break
 	fi
     done
-    if [ -n "${type}" ]
-    then
+    if [ -n "${type}" ]; then
 	true
     else
 	false
@@ -73,13 +68,13 @@ EOF
 }
 
 if test ! -r "$1"; then
-  echo "$0: Could not open $1." 1>&2
-  exit 1
+    echo "$0: Could not open $1." 1>&2
+    exit 1
 fi
 
-copyright ()
+copyright()
 {
-cat <<EOF
+    cat << EOF
 /* *INDENT-OFF* */ /* THIS FILE IS GENERATED */
 
 /* A register protocol for GDB, the GNU debugger.
@@ -105,7 +100,6 @@ cat <<EOF
 EOF
 }
 
-
 exec > new-"$3"
 copyright "$1"
 echo '#include "regdef.h"'
@@ -121,51 +115,50 @@ expedite=x
 feature=x
 osabi=unknown
 exec < "$1"
-while do_read
-do
-  if test "${type}" = "name"; then
-    name="${entry}"
-
-    echo "const_target_desc_up tdesc_${name};"
-    echo ""
-
-    # This is necessary for -Wmissing-declarations.
-    echo "void init_registers_${name} (void);"
-
-    echo "void"
-    echo "init_registers_${name} (void)"
-    echo "{"
-    echo "  target_desc_up result = allocate_target_description ();"
-    echo "  struct tdesc_feature *feature = tdesc_create_feature (result.get (), \"${name}\");"
-    continue
-  elif test "${type}" = "xmltarget"; then
-    xmltarget="${entry}"
-    continue
-  elif test "${type}" = "xmlarch"; then
-    xmlarch="${entry}"
-    continue
-  elif test "${type}" = "xmlosabi"; then
-    xmlosabi="${entry}"
-    continue
-  elif test "${type}" = "expedite"; then
-    expedite="${entry}"
-    continue
-  elif test "${type}" = "feature"; then
-    feature="${entry}"
-    continue
-  elif test "${type}" = "osabi"; then
-    osabi="${entry}"
-    continue
-  elif test "${name}" = x; then
-    echo "$0: $1 does not specify \`\`name''." 1>&2
-    exit 1
-  else
-    echo "  tdesc_create_reg (feature, \"${entry}\","
-    echo "  0, 0, NULL, ${type}, NULL);"
+while do_read; do
+    if test "${type}" = "name"; then
+	name="${entry}"
+
+	echo "const_target_desc_up tdesc_${name};"
+	echo ""
+
+	# This is necessary for -Wmissing-declarations.
+	echo "void init_registers_${name} (void);"
+
+	echo "void"
+	echo "init_registers_${name} (void)"
+	echo "{"
+	echo "  target_desc_up result = allocate_target_description ();"
+	echo "  struct tdesc_feature *feature = tdesc_create_feature (result.get (), \"${name}\");"
+	continue
+    elif test "${type}" = "xmltarget"; then
+	xmltarget="${entry}"
+	continue
+    elif test "${type}" = "xmlarch"; then
+	xmlarch="${entry}"
+	continue
+    elif test "${type}" = "xmlosabi"; then
+	xmlosabi="${entry}"
+	continue
+    elif test "${type}" = "expedite"; then
+	expedite="${entry}"
+	continue
+    elif test "${type}" = "feature"; then
+	feature="${entry}"
+	continue
+    elif test "${type}" = "osabi"; then
+	osabi="${entry}"
+	continue
+    elif test "${name}" = x; then
+	echo "$0: $1 does not specify \`\`name''." 1>&2
+	exit 1
+    else
+	echo "  tdesc_create_reg (feature, \"${entry}\","
+	echo "  0, 0, NULL, ${type}, NULL);"
 
-    offset=$((offset + type))
-    i=$((i + 1))
-  fi
+	offset=$((offset + type))
+	i=$((i + 1))
+    fi
 done
 
 echo
@@ -173,28 +166,28 @@ echo "static const char *expedite_regs_${name}[] = { \"$(echo "${expedite}" | se
 
 echo "#ifndef IN_PROCESS_AGENT"
 if test "${feature}" != x; then
-  echo "static const char *xmltarget_${name} = 0;"
-elif test "${xmltarget}" = x; then
-  if test "${xmlarch}" = x && test "${xmlosabi}" = x; then
     echo "static const char *xmltarget_${name} = 0;"
-  else
-    echo "static const char *xmltarget_${name} = \"@<target>\\"
-    if test "${xmlarch}" != x; then
-      echo "<architecture>${xmlarch}</architecture>\\"
-    fi
-    if test "${xmlosabi}" != x; then
-      echo "<osabi>${xmlosabi}</osabi>\\"
+elif test "${xmltarget}" = x; then
+    if test "${xmlarch}" = x && test "${xmlosabi}" = x; then
+	echo "static const char *xmltarget_${name} = 0;"
+    else
+	echo "static const char *xmltarget_${name} = \"@<target>\\"
+	if test "${xmlarch}" != x; then
+	    echo "<architecture>${xmlarch}</architecture>\\"
+	fi
+	if test "${xmlosabi}" != x; then
+	    echo "<osabi>${xmlosabi}</osabi>\\"
+	fi
+	echo "</target>\";"
     fi
-    echo "</target>\";"
-  fi
 else
-  echo "static const char *xmltarget_${name} = \"${xmltarget}\";"
+    echo "static const char *xmltarget_${name} = \"${xmltarget}\";"
 fi
 echo
 
 osabi_enum=$(grep "${osabi}" "$2" | sed 's/.*(\([^,]\+\),.*/GDB_OSABI_\1/')
 
-cat <<EOF
+cat << EOF
   result->xmltarget = xmltarget_${name};
 #endif
 

base-commit: 5d09165a3e9c8d32742fc764e98e927950f7b2f5
-- 
2.51.0


                 reply	other threads:[~2026-08-28 14:13 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20260828141241.3921145-1-tdevries@suse.de \
    --to=tdevries@suse.de \
    --cc=gdb-patches@sourceware.org \
    /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