Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH 0/3] [gdb] Three gdb_buildall.sh fixes
@ 2026-08-30 18:12 Tom de Vries
  2026-08-30 18:12 ` [PATCH 1/3] [gdb] Use --data-directory in gdb_buildall.sh Tom de Vries
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Tom de Vries @ 2026-08-30 18:12 UTC (permalink / raw)
  To: gdb-patches

This series contains three patches related to gdb/gdb_buildall.sh.

The first fixes an error.

The second fixes a warning.

The last makes it shellcheck-clean.

Tested on aarch64-linux by running:
...
$ rm -Rf build-all
$ mkdir build-all
$ bash ./src/gdb/gdb_buildall.sh \
      -j 9 \
      --bfd64 \
      src \
      build-all
...

Tom de Vries (3):
  [gdb] Use --data-directory in gdb_buildall.sh
  [gdb] Fix warnings in gdb_buildall.sh
  [gdb] Make gdb_buildall.sh shellcheck-clean

 gdb/contrib/shellcheck.sh |  1 -
 gdb/gdb_buildall.sh       | 82 +++++++++++++++++++++------------------
 2 files changed, 44 insertions(+), 39 deletions(-)


base-commit: 85a9f9eafebd99447e70e608246bc1d275e44d37
-- 
2.51.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/3] [gdb] Use --data-directory in gdb_buildall.sh
  2026-08-30 18:12 [PATCH 0/3] [gdb] Three gdb_buildall.sh fixes Tom de Vries
@ 2026-08-30 18:12 ` Tom de Vries
  2026-08-30 18:12 ` [PATCH 2/3] [gdb] Fix warnings " Tom de Vries
  2026-08-30 18:12 ` [PATCH 3/3] [gdb] Make gdb_buildall.sh shellcheck-clean Tom de Vries
  2 siblings, 0 replies; 5+ messages in thread
From: Tom de Vries @ 2026-08-30 18:12 UTC (permalink / raw)
  To: gdb-patches

I tried to run gdb/gdb_buildall.sh, but ran into errors due to
gdb being used without --data-directory option.

Add this.
---
 gdb/gdb_buildall.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gdb/gdb_buildall.sh b/gdb/gdb_buildall.sh
index 1b82455ed0e..65935ae10b2 100644
--- a/gdb/gdb_buildall.sh
+++ b/gdb/gdb_buildall.sh
@@ -202,7 +202,7 @@ cat <<EOF > arch
 set architecture
 quit
 EOF
-./gdb/gdb --batch -nx -x arch 2>&1 | cat > gdb_archs
+./gdb/gdb --data-directory gdb/data-directory --batch -nx -x arch 2>&1 | cat > gdb_archs
 tail -n 1 gdb_archs | sed 's/auto./\n/g' | sed 's/,/\n/g' |  sed 's/Requires an argument. Valid arguments are/\n/g' | sed '/^[ ]*$/d' > arch
 mv arch gdb_archs
 
@@ -226,7 +226,7 @@ EOF
   log_file=$target.log
   log_file=${log_file//:/_}
   echo -n "... ${target}"
-  ./gdb/gdb -batch -nx -x x 2>&1 | cat > $log_file
+  ./gdb/gdb --data-directory gdb/data-directory -batch -nx -x x 2>&1 | cat > $log_file
   # Check GDBs results
   if test ! -s $log_file
   then
-- 
2.51.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 2/3] [gdb] Fix warnings in gdb_buildall.sh
  2026-08-30 18:12 [PATCH 0/3] [gdb] Three gdb_buildall.sh fixes Tom de Vries
  2026-08-30 18:12 ` [PATCH 1/3] [gdb] Use --data-directory in gdb_buildall.sh Tom de Vries
@ 2026-08-30 18:12 ` Tom de Vries
  2026-08-30 18:12 ` [PATCH 3/3] [gdb] Make gdb_buildall.sh shellcheck-clean Tom de Vries
  2 siblings, 0 replies; 5+ messages in thread
From: Tom de Vries @ 2026-08-30 18:12 UTC (permalink / raw)
  To: gdb-patches

I ran into these warnings with gdb/gdb_buildall.sh:
...
./src/gdb/gdb_buildall.sh: line 27: warning: setlocale: LC_ALL: \
  cannot change locale (c): No such file or directory
./src/gdb/gdb_buildall.sh: line 27: warning: setlocale: LC_ALL: \
  cannot change locale (c): No such file or directory
...

Fix this by using 'C' instead of 'c'.
---
 gdb/gdb_buildall.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gdb/gdb_buildall.sh b/gdb/gdb_buildall.sh
index 65935ae10b2..57211ca887a 100644
--- a/gdb/gdb_buildall.sh
+++ b/gdb/gdb_buildall.sh
@@ -23,8 +23,8 @@
 # Based on gdb_mbuild.sh from Richard Earnshaw.
 
 
-LANG=c ; export LANG
-LC_ALL=c ; export LC_ALL
+LANG=C ; export LANG
+LC_ALL=C ; export LC_ALL
 
 # Prints a usage message.
 usage()
-- 
2.51.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 3/3] [gdb] Make gdb_buildall.sh shellcheck-clean
  2026-08-30 18:12 [PATCH 0/3] [gdb] Three gdb_buildall.sh fixes Tom de Vries
  2026-08-30 18:12 ` [PATCH 1/3] [gdb] Use --data-directory in gdb_buildall.sh Tom de Vries
  2026-08-30 18:12 ` [PATCH 2/3] [gdb] Fix warnings " Tom de Vries
@ 2026-08-30 18:12 ` Tom de Vries
  2026-08-31  7:45   ` Tom de Vries
  2 siblings, 1 reply; 5+ messages in thread
From: Tom de Vries @ 2026-08-30 18:12 UTC (permalink / raw)
  To: gdb-patches

Make gdb_buildall.sh shellcheck-clean:
- add missing quoting
- use $()
- use bash instead of sh to allow non-POSIX features
- use makejobs="$1" instead of makejobs="-j $1"
- use read -r
- add missing definition of gdbopts and simopts
- use '' for trap argument
---
 gdb/contrib/shellcheck.sh |  1 -
 gdb/gdb_buildall.sh       | 76 +++++++++++++++++++++------------------
 2 files changed, 41 insertions(+), 36 deletions(-)

diff --git a/gdb/contrib/shellcheck.sh b/gdb/contrib/shellcheck.sh
index a3e80a553f4..7dd896218f3 100755
--- a/gdb/contrib/shellcheck.sh
+++ b/gdb/contrib/shellcheck.sh
@@ -45,7 +45,6 @@ for f in "$@"; do
 	    | gdb/config/djgpp/djconfig.sh \
 	    | gdb/contrib/cc-with-tweaks.sh \
 	    | gdb/contrib/gdb-add-index.sh \
-	    | gdb/gdb_buildall.sh \
 	    | gdb/gdb_mbuild.sh \
 	    | gdb/testsuite/lib/pdtrace.in)
 	    # Skip unclean files.
diff --git a/gdb/gdb_buildall.sh b/gdb/gdb_buildall.sh
index 57211ca887a..7de2c2e8fa0 100644
--- a/gdb/gdb_buildall.sh
+++ b/gdb/gdb_buildall.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 
 # Build script to build GDB with all targets enabled.
 
@@ -63,7 +63,7 @@ do
       # Number of parallel make jobs.
       shift
       test $# -ge 1 || usage
-      makejobs="-j $1"
+      makejobs="$1"
       ;;
       --clean )
 	# Shall the build directory be deleted after processing?
@@ -97,8 +97,8 @@ fi
 ### Environment.
 
 # Convert these to absolute directory paths.
-srcdir=`cd $1 && /bin/pwd` || exit 1
-builddir=`cd $2 && /bin/pwd` || exit 1
+srcdir=$(cd "$1" && /bin/pwd) || exit 1
+builddir=$(cd "$2" && /bin/pwd) || exit 1
 # Version of make to use
 make=${MAKE:-make}
 MAKE=${make}
@@ -108,9 +108,9 @@ ulimit -c 0
 
 # Just make sure we're in the right directory.
 maintainers=${srcdir}/gdb/MAINTAINERS
-if [ ! -r ${maintainers} ]
+if [ ! -r "${maintainers}" ]
 then
-    echo Maintainers file ${maintainers} not found
+    echo "Maintainers file ${maintainers} not found"
     exit 1
 fi
 
@@ -125,15 +125,15 @@ dir=${builddir}/ALL
 if ${force}
 then
   echo ... forcing rebuild
-  rm -rf ${dir}
+  rm -rf "${dir}"
 fi
 
 # Did the previous configure attempt fail?  If it did restart from scratch
-if test -d ${dir} -a ! -r ${dir}/Makefile
+if test -d "${dir}" -a ! -r "${dir}/Makefile"
 then
   echo ... removing partially configured
-  rm -rf ${dir}
-  if test -d ${dir}
+  rm -rf "${dir}"
+  if test -d "${dir}"
   then
     echo "... ERROR: Unable to remove directory ${dir}"
     exit 1
@@ -141,27 +141,33 @@ then
 fi
 
 # Create build directory.
-mkdir -p ${dir}
-cd ${dir} || exit 1
+mkdir -p "${dir}"
+cd "${dir}" || exit 1
 
 # Configure GDB.
 if test ! -r Makefile
 then
+  # Set custom gdb/sim build warnings here.  The code using these two vars
+  # seems be copied from gdb_mbuild.sh, where they are set from --target lines
+  # in MAINTAINERS.
+  gdbopts=""
+  simopts=""
+
   # Default SIMOPTS to GDBOPTS.
   test -z "${simopts}" && simopts="${gdbopts}"
 
   # The config options.
   __build="--enable-targets=all"
-  __enable_gdb_build_warnings=`test -z "${gdbopts}" \
-    || echo "--enable-gdb-build-warnings=${gdbopts}"`
-  __enable_sim_build_warnings=`test -z "${simopts}" \
-    || echo "--enable-sim-build-warnings=${simopts}"`
+  __enable_gdb_build_warnings=$(test -z "${gdbopts}" \
+    || echo "--enable-gdb-build-warnings=${gdbopts}")
+  __enable_sim_build_warnings=$(test -z "${simopts}" \
+    || echo "--enable-sim-build-warnings=${simopts}")
   __configure="${srcdir}/configure \
     ${__build} ${bfd_flag}\
     ${__enable_gdb_build_warnings} \
     ${__enable_sim_build_warnings}"
-  echo ... ${__configure}
-  trap "echo Removing partially configured ${dir} directory ...; rm -rf ${dir}; exit 1" 1 2 15
+  echo "... ${__configure}"
+  trap 'echo Removing partially configured ${dir} directory ...; rm -rf ${dir}; exit 1' 1 2 15
   ${__configure} > Config.log 2>&1
   trap "exit 1"  1 2 15
 
@@ -178,8 +184,8 @@ fi
 gdb_bin="gdb/gdb"
 if test ! -x gdb/gdb -a ! -x gdb/gdb.exe
 then
-  echo ... ${make} ${makejobs}
-  ( ${make} ${makejobs} all-gdb || rm -f gdb/gdb gdb/gdb.exe
+  echo "... ${make} ${makejobs:+-j $makejobs}"
+  ( "${make}" ${makejobs:+-j $makejobs} all-gdb || rm -f gdb/gdb gdb/gdb.exe
   ) > Build.log 2>&1
 
   # If the build fails, exit.
@@ -208,15 +214,15 @@ mv arch gdb_archs
 
 if test "${targexp}" != ""
 then
-  alltarg=`cat gdb_archs | grep ${targexp}`
+  alltarg=$(cat gdb_archs | grep "${targexp}")
 else
-  alltarg=`cat gdb_archs`
+  alltarg=$(cat gdb_archs)
 fi
 rm -f gdb_archs
 
 # Test all architectures available in ALLTARG
 echo "maint print architecture for"
-echo "$alltarg" | while read target
+echo "$alltarg" | while read -r target
 do
   cat <<EOF > x
 set architecture ${target}
@@ -226,14 +232,14 @@ EOF
   log_file=$target.log
   log_file=${log_file//:/_}
   echo -n "... ${target}"
-  ./gdb/gdb --data-directory gdb/data-directory -batch -nx -x x 2>&1 | cat > $log_file
+  ./gdb/gdb --data-directory gdb/data-directory -batch -nx -x x 2>&1 | cat > "$log_file"
   # Check GDBs results
-  if test ! -s $log_file
+  if test ! -s "$log_file"
   then
-    echo " ERR: gdb printed no output" | tee -a $log_file
-  elif test `grep -o internal-error $log_file | tail -n 1`
+    echo " ERR: gdb printed no output" | tee -a "$log_file"
+  elif test "$(grep -o internal-error "$log_file" | tail -n 1)"
   then
-    echo " ERR: gdb panic" | tee -a $log_file
+    echo " ERR: gdb panic" | tee -a "$log_file"
   else
     echo " OK"
   fi
@@ -241,20 +247,20 @@ EOF
   # Create a sed script that cleans up the output from GDB.
   rm -f mbuild.sed
   # Rules to replace <0xNNNN> with the corresponding function's name.
-  sed -n -e '/<0x0*>/d' -e 's/^.*<0x\([0-9a-f]*\)>.*$/0x\1/p' $log_file \
+  sed -n -e '/<0x0*>/d' -e 's/^.*<0x\([0-9a-f]*\)>.*$/0x\1/p' "$log_file" \
   | sort -u \
-  | while read addr
+  | while read -r addr
   do
-    func="`addr2line -f -e ./$gdb_bin -s ${addr} | sed -n -e 1p`"
+    func="$(addr2line -f -e ./$gdb_bin -s "${addr}" | sed -n -e 1p)"
     echo "s/<${addr}>/<${func}>/g"
   done >> mbuild.sed
   # Rules to strip the leading paths off of file names.
   echo 's/"\/.*\/gdb\//"gdb\//g' >> mbuild.sed
   # Run the script.
-  sed -f mbuild.sed $log_file > Mbuild.log
+  sed -f mbuild.sed "$log_file" > Mbuild.log
 
-  mv Mbuild.log ${builddir}/$log_file
-  rm -rf $log_file x mbuild.sed
+  mv Mbuild.log "${builddir}/$log_file"
+  rm -rf "$log_file" x mbuild.sed
 done
 echo "done."
 
@@ -262,7 +268,7 @@ echo "done."
 if ${clean}
 then
   echo "cleaning up $dir"
-  rm -rf ${dir}
+  rm -rf "${dir}"
 fi
 
 exit 0
-- 
2.51.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 3/3] [gdb] Make gdb_buildall.sh shellcheck-clean
  2026-08-30 18:12 ` [PATCH 3/3] [gdb] Make gdb_buildall.sh shellcheck-clean Tom de Vries
@ 2026-08-31  7:45   ` Tom de Vries
  0 siblings, 0 replies; 5+ messages in thread
From: Tom de Vries @ 2026-08-31  7:45 UTC (permalink / raw)
  To: gdb-patches

On 8/30/26 8:12 PM, Tom de Vries wrote:
> +  alltarg=$(cat gdb_archs | grep "${targexp}")

While working on gdb_mbuild.sh I realized that this is wrong.

It does grep "-e foo -e bar" instead of grep -e foo -e bar.

I've fixed this in a v2 using arrays ( 
https://sourceware.org/pipermail/gdb-patches/2026-August/229851.html ).

Thanks,
- Tom

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-08-31  7:46 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-30 18:12 [PATCH 0/3] [gdb] Three gdb_buildall.sh fixes Tom de Vries
2026-08-30 18:12 ` [PATCH 1/3] [gdb] Use --data-directory in gdb_buildall.sh Tom de Vries
2026-08-30 18:12 ` [PATCH 2/3] [gdb] Fix warnings " Tom de Vries
2026-08-30 18:12 ` [PATCH 3/3] [gdb] Make gdb_buildall.sh shellcheck-clean Tom de Vries
2026-08-31  7:45   ` Tom de Vries

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox