From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id kYsFDFsimGqR9x4AWB0awg (envelope-from ) for ; Wed, 02 Sep 2026 09:19:23 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=viRDYCAT; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=ZVbQgQ8l; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=xlDqfuzz; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=wYdqNXzl; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 293161E033; Wed, 02 Sep 2026 09:19:23 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [IPv6:2620:52:6:3111::32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 57E3B1E033 for ; Wed, 02 Sep 2026 09:19:19 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6375F4BA23C1 for ; Wed, 2 Sep 2026 13:19:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6375F4BA23C1 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=viRDYCAT; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=ZVbQgQ8l; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=xlDqfuzz; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=wYdqNXzl Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2a07:de40:b251:101:10:150:64:1]) by sourceware.org (Postfix) with ESMTPS id 2DCEB4BA2E39 for ; Wed, 2 Sep 2026 13:17:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2DCEB4BA2E39 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 2DCEB4BA2E39 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2a07:de40:b251:101:10:150:64:1 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1788355070; cv=none; b=DzvN7j033lvLWj/83VI0d4q1YG2rU9ZEpQ4FFAJbzy4MHuaXim12tPCCIGjtaT7nBSB/8Kq1ptB+dh/Xh2IJVpAgDwUaRVfPOGxk/poi7/Sb1N2FwVlMrUJFm1u9bvgrsRRvuAEe3p2nyXmaLKKG2JJCBhPkCaX2jBpTVpkN9ks= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1788355070; c=relaxed/simple; bh=BB7ZD5pI9vwiLX3uMJFr0owFnjSXZNjHRXURkAXD7L4=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:From: To:Subject:Date:Message-ID:MIME-Version; b=APWZrKhqaupzDeYhOLuajnhWODySia9bfSJIDCIIBkmJ9GBrkK205KG5HjnE4+3cTHduwfKcotLrArY1nwCg8lZMVrg6zfPWJdCRZSRiq0mu7Y2tteSd6aVZ4A222kxx9jLCue8lRKVP6xR5g+Ziupp74xcp0nTAcxDTLzZj6Rk= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=viRDYCAT; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=ZVbQgQ8l; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=xlDqfuzz; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=wYdqNXzl DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2DCEB4BA2E39 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id AFAD321C83 for ; Wed, 2 Sep 2026 13:17:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1788355064; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ucJ5rKVPaD8Yj5vAB6p4shRpUwp0dk5tQz4T6qTidlU=; b=viRDYCATto+r3ZnnWf19IN07BmQNBmNbQXzBzSm6//oRPkQ8uWw2yubasAXy6/olBdCz8x ulpLTWoIrP+qEX4GFOY5A6lhmuxHe/kbIHsnXqMTyhWxJK+uY+4jX+Yk6JrykB7D0ToVqJ YFjJKaU+yqu/vOOZQlsl60fVpJ4h5Nw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1788355064; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ucJ5rKVPaD8Yj5vAB6p4shRpUwp0dk5tQz4T6qTidlU=; b=ZVbQgQ8lLt+KBdZX5oMnJ242Jv5tcIliVt9zJX+4aE+L0ed1KMfBpsjc6JBtPruuyn1MZT UJjVghbxALHsjuAw== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=xlDqfuzz; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=wYdqNXzl DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1788355060; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ucJ5rKVPaD8Yj5vAB6p4shRpUwp0dk5tQz4T6qTidlU=; b=xlDqfuzzEu86v/+3TmvQJFkLf4tysDo9m67I1UCM4abNh48aYDhrF3NGHlWqwAi7+7Klaa Q6EG0PUPTPqr9MrrHDQesEbIkApLqm+YEGl7xwURE8f9ZSrSmobaogOjL+IvHOYH2goqUk u6WqSJnBh/VG0sAe9oFaaXrApfXbdaE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1788355060; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ucJ5rKVPaD8Yj5vAB6p4shRpUwp0dk5tQz4T6qTidlU=; b=wYdqNXzl6QKVMC+23wsqui4zGIBPemjlgASa6BxIlIOQVCC0LdYmcAJA4JTrxU+SUnQACa Kz4922bDGY+c4rDg== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 7652013869 for ; Wed, 2 Sep 2026 13:17:40 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id QBJvG/QhmGqQTAAAD6G6ig (envelope-from ) for ; Wed, 02 Sep 2026 13:17:40 +0000 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [RFC 2/3] [pre-commit] Enable shfmt Date: Wed, 2 Sep 2026 15:17:38 +0200 Message-ID: <20260902131739.2125928-3-tdevries@suse.de> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260902131739.2125928-1-tdevries@suse.de> References: <20260902131739.2125928-1-tdevries@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Action: no action X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Queue-Id: AFAD321C83 X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FROM_EQ_ENVFROM(0.00)[]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; PREVIOUSLY_DELIVERED(0.00)[gdb-patches@sourceware.org]; RCVD_TLS_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim,suse.de:mid,imap1.dmz-prg2.suse.org:rdns,imap1.dmz-prg2.suse.org:helo]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; TO_DN_NONE(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; MIME_TRACE(0.00)[0:+]; DKIM_TRACE(0.00)[suse.de:+] X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org The result of enabling the shfmt hook and running: ... $ pre-commit run shfmt --all-files ... and fixing: ... gdb/gdb_buildall.sh:227:22: search and replace is a bash/mksh/zsh feature; \ tried parsing as posix (parsed as posix via -ln=auto) ... by using bash instead of sh in gdb/gdb_buildall.sh. --- .pre-commit-config.yaml | 2 - gdb/contrib/cc-with-tweaks.sh | 80 +++++---- gdb/contrib/check-file-mode.sh | 16 +- gdb/contrib/check-gnu-style-pre-commit.sh | 5 +- gdb/contrib/gdb-add-index.sh | 104 ++++++------ gdb/contrib/shellcheck.sh | 6 +- gdb/contrib/shfmt.sh | 8 +- gdb/contrib/words.sh | 20 +-- gdb/doc/makeinfo-wrapper.sh | 14 +- gdb/gcore-1.in | 141 +++++++-------- gdb/gdb_buildall.sh | 123 ++++++-------- gdb/gdb_mbuild.sh | 179 +++++++++----------- gdb/gstack-1.in | 25 +-- gdb/po/gdbtext | 23 +-- gdb/syscalls/update-freebsd.sh | 12 +- gdb/syscalls/update-linux-defaults.sh | 29 ++-- gdb/syscalls/update-linux-from-src.sh | 25 ++- gdb/syscalls/update-linux.sh | 26 +-- gdb/syscalls/update-netbsd.sh | 12 +- gdb/testsuite/lib/dg-add-core-file-count.sh | 6 +- gdb/testsuite/lib/notty-wrap | 2 +- gdb/testsuite/make-check-all.sh | 22 +-- 22 files changed, 428 insertions(+), 452 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2d2b5e38ca1..6f88c188c4e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -123,8 +123,6 @@ repos: entry: gdb/contrib/shfmt.sh files: *gdb_files args: [] - # Disabled. - stages: [manual] # Local hooks. - repo: local diff --git a/gdb/contrib/cc-with-tweaks.sh b/gdb/contrib/cc-with-tweaks.sh index 047c748e165..215848c5eb7 100755 --- a/gdb/contrib/cc-with-tweaks.sh +++ b/gdb/contrib/cc-with-tweaks.sh @@ -53,16 +53,12 @@ myname=cc-with-tweaks.sh mydir=$(dirname "$0") -if [ -z "$GDB" ] -then - if [ -f ./gdb ] - then +if [ -z "$GDB" ]; then + if [ -f ./gdb ]; then GDB="./gdb -data-directory data-directory" - elif [ -f ../gdb ] - then + elif [ -f ../gdb ]; then GDB="../gdb -data-directory ../data-directory" - elif [ -f ../../gdb ] - then + elif [ -f ../../gdb ]; then GDB="../../gdb -data-directory ../../data-directory" else echo "$myname: unable to find usable gdb" >&2 @@ -100,10 +96,16 @@ while [ $# -gt 0 ]; do -Z) want_objcopy_compress=true ;; -z) want_dwz=true ;; -i) want_index=true ;; - -n) want_index=true; index_options=-dwarf-5;; + -n) + want_index=true + index_options=-dwarf-5 + ;; -c) want_index_cache=true ;; -m) want_multi=true ;; - -5) want_multi=true; dwz_5flag=-5 ;; + -5) + want_multi=true + dwz_5flag=-5 + ;; -p) want_dwp=true ;; -l) want_gnu_debuglink=true ;; *) break ;; @@ -111,12 +113,9 @@ while [ $# -gt 0 ]; do shift done -if [ "$want_index" = true ] -then - if [ -z "$GDB_ADD_INDEX" ] - then - if [ -f "$mydir/gdb-add-index.sh" ] - then +if [ "$want_index" = true ]; then + if [ -z "$GDB_ADD_INDEX" ]; then + if [ -f "$mydir/gdb-add-index.sh" ]; then GDB_ADD_INDEX="$mydir/gdb-add-index.sh" else echo "$myname: unable to find usable contrib/gdb-add-index.sh" >&2 @@ -125,10 +124,8 @@ then fi fi -for arg in "$@" -do - if [ "$next_is_output_file" = "yes" ] - then +for arg in "$@"; do + if [ "$next_is_output_file" = "yes" ]; then output_file="$arg" next_is_output_file=no continue @@ -146,14 +143,12 @@ do esac done -if [ "$next_is_output_file" = "yes" ] -then +if [ "$next_is_output_file" = "yes" ]; then echo "$myname: Unable to find output file" >&2 exit 1 fi -if [ "$have_link" = "no" ] -then +if [ "$have_link" = "no" ]; then "$@" exit $? fi @@ -164,13 +159,12 @@ output_dir="${output_file%/*}" "$@" rc=$? [ $rc != 0 ] && exit $rc -if [ ! -f "$output_file" ] -then +if [ ! -f "$output_file" ]; then echo "$myname: Internal error: $output_file missing." >&2 exit 1 fi -get_tmpdir () +get_tmpdir() { subdir="$1" if [ "$subdir" = "" ]; then @@ -217,9 +211,9 @@ fi if [ "$want_index_cache" = true ]; then $GDB -q -batch \ - -ex "set index-cache directory $INDEX_CACHE_DIR" \ - -ex "set index-cache enabled on" \ - -ex "file $output_file" + -ex "set index-cache directory $INDEX_CACHE_DIR" \ + -ex "set index-cache enabled on" \ + -ex "file $output_file" rc=$? [ $rc != 0 ] && exit $rc fi @@ -233,8 +227,10 @@ if [ "$want_dwz" = true ] || [ "$want_multi" = true ]; then dwz_version_major=${dwz_version//\.*/} dwz_version_minor=${dwz_version//*\./} if [ "$dwz_version_major" -lt "$dwz_version_major_required" ] \ - || { [ "$dwz_version_major" -eq "$dwz_version_major_required" ] \ - && [ "$dwz_version_minor" -lt "$dwz_version_minor_required" ]; }; then + || { + [ "$dwz_version_major" -eq "$dwz_version_major_required" ] \ + && [ "$dwz_version_minor" -lt "$dwz_version_minor_required" ] + }; then detected="$dwz_version_major.$dwz_version_minor" required="$dwz_version_major_required.$dwz_version_minor_required" echo "$myname: dwz version $detected detected, version $required or higher required" @@ -284,14 +280,14 @@ fi if [ "$want_dwp" = true ]; then mapfile -t dwo_files \ - < \ - <($READELF -wi "${output_file}" \ - | grep _dwo_name \ - | sed -e 's/^.*: //' \ - | sort \ - | uniq) + < \ + <($READELF -wi "${output_file}" \ + | grep _dwo_name \ + | sed -e 's/^.*: //' \ + | sort \ + | uniq) rc=0 - if [ ${#dwo_files[@]} -ne 0 ]; then + if [ ${#dwo_files[@]} -ne 0 ]; then $DWP -o "${output_file}.dwp" "${dwo_files[@]}" > /dev/null rc=$? [ $rc != 0 ] && exit $rc @@ -311,11 +307,11 @@ if [ "$want_gnu_debuglink" = true ]; then # Create stripped and debug versions of output_file. strip "${STRIP_ARGS_STRIP_DEBUG[@]}" "${output_file}" \ - -o "${stripped_file}" + -o "${stripped_file}" rc=$? [ $rc != 0 ] && exit $rc strip "${STRIP_ARGS_KEEP_DEBUG[@]}" "${output_file}" \ - -o "${debug_file}" + -o "${debug_file}" rc=$? [ $rc != 0 ] && exit $rc @@ -329,7 +325,7 @@ if [ "$want_gnu_debuglink" = true ]; then # Overwrite output_file with stripped version containing # .gnu_debuglink to debug_file. $OBJCOPY --add-gnu-debuglink="$link" "${stripped_file}" \ - "${output_file}" + "${output_file}" ) rc=$? [ $rc != 0 ] && exit $rc diff --git a/gdb/contrib/check-file-mode.sh b/gdb/contrib/check-file-mode.sh index 5a9b0e89fbe..4d611a08545 100755 --- a/gdb/contrib/check-file-mode.sh +++ b/gdb/contrib/check-file-mode.sh @@ -20,14 +20,14 @@ set -o pipefail no_exec_files=() for f in "$@"; do case $f in - */*.py \ - | */*.sh \ - | */configure \ - | gdb/gstack-1.in \ - | gdb/gcore-1.in \ - | gdb/po/gdbtext \ - | gdb/make-init-c \ - | gdb/testsuite/lib/notty-wrap ) + */*.py | \ + */*.sh | \ + */configure | \ + gdb/gstack-1.in | \ + gdb/gcore-1.in | \ + gdb/po/gdbtext | \ + gdb/make-init-c | \ + gdb/testsuite/lib/notty-wrap) continue ;; *) diff --git a/gdb/contrib/check-gnu-style-pre-commit.sh b/gdb/contrib/check-gnu-style-pre-commit.sh index f072e7b56ed..026cefa0296 100755 --- a/gdb/contrib/check-gnu-style-pre-commit.sh +++ b/gdb/contrib/check-gnu-style-pre-commit.sh @@ -16,7 +16,10 @@ set -e -scriptdir=$(cd "$(dirname "$0")" || exit 1; pwd -P) +scriptdir=$( + cd "$(dirname "$0")" || exit 1 + pwd -P +) tmp="" diff --git a/gdb/contrib/gdb-add-index.sh b/gdb/contrib/gdb-add-index.sh index 49f50a20e3e..e493fbd0eb5 100755 --- a/gdb/contrib/gdb-add-index.sh +++ b/gdb/contrib/gdb-add-index.sh @@ -27,16 +27,19 @@ VERSION="@VERSION@" myname="${0##*/}" -print_usage() { +print_usage() +{ prefix="Usage: $myname" echo "$prefix [-h|--help] [-v|--version] [--dwarf-5] FILENAME" } -print_try_help() { +print_try_help() +{ echo "Try '$myname --help' for more information." } -print_help() { +print_help() +{ print_usage echo echo "Add a .gdb_index section to FILENAME to facilitate faster debug" @@ -48,7 +51,8 @@ print_help() { echo " instead of .gdb_index." } -print_version() { +print_version() +{ echo "GNU gdb-add-index (${PKGVERSION}) ${VERSION}" } @@ -56,33 +60,33 @@ dwarf5="" # Parse options. until -opt=$1 -case ${opt} in - --dwarf-5 | -dwarf-5) - dwarf5="-dwarf-5" - ;; - - --help | -help | -h) - print_help - exit 0 - ;; - - --version | -version | -v) - print_version - exit 0 - ;; - - -?*) - print_try_help 1>&2 - exit 2 - ;; - - *) - # No arguments remaining. - ;; -esac -# Break from loop if the first character of OPT is not '-'. -[ "x$(printf %.1s "$opt")" != "x-" ] + opt=$1 + case ${opt} in + --dwarf-5 | -dwarf-5) + dwarf5="-dwarf-5" + ;; + + --help | -help | -h) + print_help + exit 0 + ;; + + --version | -version | -v) + print_version + exit 0 + ;; + + -?*) + print_try_help 1>&2 + exit 2 + ;; + + *) + # No arguments remaining. + ;; + esac + # Break from loop if the first character of OPT is not '-'. + [ "x$(printf %.1s "$opt")" != "x-" ] do shift done @@ -95,7 +99,7 @@ fi file="$1" if test -L "$file"; then - if ! command -v readlink >/dev/null 2>&1; then + if ! command -v readlink > /dev/null 2>&1; then echo "$myname: 'readlink' missing. Failed to follow symlink $1." 1>&2 exit 1 fi @@ -133,9 +137,9 @@ test "$dir" = "$file" && dir="." dwz_file="" if $READELF -S "$file" | grep -q " \.gnu_debugaltlink "; then dwz_file=$($READELF --string-dump=.gnu_debugaltlink "$file" \ - | grep -A1 "'\.gnu_debugaltlink':" \ - | tail -n +2 \ - | sed 's/.*]//') + | grep -A1 "'\.gnu_debugaltlink':" \ + | tail -n +2 \ + | sed 's/.*]//') dwz_file=$(echo $dwz_file) if $READELF -S "$dwz_file" | grep -E -q " \.(gdb_index|debug_names) "; then # Already has an index, skip it. @@ -143,7 +147,7 @@ if $READELF -S "$file" | grep -q " \.gnu_debugaltlink "; then fi fi -set_files () +set_files() { fpath="$1" @@ -183,7 +187,7 @@ $GDB --batch -nx -iex 'set auto-load no' \ # already stripped binary, it's a no-op. status=0 -handle_file () +handle_file() { fpath="$1" @@ -202,35 +206,35 @@ handle_file () fi if test -s "$debugstr"; then if ! $OBJCOPY --dump-section .debug_str="$debugstrmerge" "$fpath" \ - /dev/null 2> "$debugstrerr"; then + /dev/null 2> "$debugstrerr"; then cat >&2 "$debugstrerr" exit 1 fi - cat "$debugstr" >>"$debugstrmerge" + cat "$debugstr" >> "$debugstrmerge" if grep -q "can't dump section '.debug_str' - it does not exist" \ - "$debugstrerr"; then + "$debugstrerr"; then $OBJCOPY --add-section $section="$index" \ - --set-section-flags $section=readonly \ - --add-section .debug_str="$debugstrmerge" \ - --set-section-flags .debug_str=readonly \ - "$fpath" "$fpath" + --set-section-flags $section=readonly \ + --add-section .debug_str="$debugstrmerge" \ + --set-section-flags .debug_str=readonly \ + "$fpath" "$fpath" else $OBJCOPY --add-section $section="$index" \ - --set-section-flags $section=readonly \ - --update-section .debug_str="$debugstrmerge" \ - "$fpath" "$fpath" + --set-section-flags $section=readonly \ + --update-section .debug_str="$debugstrmerge" \ + "$fpath" "$fpath" fi else $OBJCOPY --add-section $section="$index" \ - --set-section-flags $section=readonly \ - "$fpath" "$fpath" + --set-section-flags $section=readonly \ + "$fpath" "$fpath" fi status=$? else echo "$myname: No index was created for $fpath" 1>&2 echo "$myname: [Was there no debuginfo? Was there already an index?]" \ - 1>&2 + 1>&2 fi } diff --git a/gdb/contrib/shellcheck.sh b/gdb/contrib/shellcheck.sh index 6f5634ce38e..e7c92f317f4 100755 --- a/gdb/contrib/shellcheck.sh +++ b/gdb/contrib/shellcheck.sh @@ -41,9 +41,9 @@ for f in "$@"; do # Skip generated files. continue ;; - gdb/contrib/gdb-add-index.sh \ - | gdb/gdb_buildall.sh \ - | gdb/gdb_mbuild.sh ) + gdb/contrib/gdb-add-index.sh | \ + gdb/gdb_buildall.sh | \ + gdb/gdb_mbuild.sh) # Skip unclean files. continue ;; diff --git a/gdb/contrib/shfmt.sh b/gdb/contrib/shfmt.sh index 9cdf863b4d1..0f1cf332b2a 100755 --- a/gdb/contrib/shfmt.sh +++ b/gdb/contrib/shfmt.sh @@ -22,10 +22,10 @@ for f in "$@"; do # Mixed 2/4 indentation. continue ;; - gdb/config/djgpp/djconfig.sh \ - | gdb/contrib/expect-read1.sh \ - | gdb/features/feature_to_c.sh \ - | gdb/gdb_buildall.sh ) + gdb/config/djgpp/djconfig.sh | \ + gdb/contrib/expect-read1.sh | \ + gdb/features/feature_to_c.sh | \ + gdb/gdb_buildall.sh) f2=("${f2[@]}" "$f") ;; *) diff --git a/gdb/contrib/words.sh b/gdb/contrib/words.sh index a96142a3232..f6ff6ff791d 100755 --- a/gdb/contrib/words.sh +++ b/gdb/contrib/words.sh @@ -56,7 +56,7 @@ while [ $# -gt 0 ]; do c=true shift ;; - --freq|-f) + --freq | -f) minfreq=$2 maxfreq=$2 shift 2 @@ -76,7 +76,7 @@ while [ $# -gt 0 ]; do shift 2 ;; *) - break; + break ;; esac done @@ -89,7 +89,7 @@ fi awkfile=$(mktemp) trap 'rm -f "$awkfile"' EXIT -cat > "$awkfile" < "$awkfile" << EOF BEGIN { in_comment=0 } @@ -128,17 +128,17 @@ else cat "$@" fi \ | sed \ - -e 's/[!"?;:%^$~#{}`&=@,. \t\/_()|<>\+\*-]/\n/g' \ - -e 's/\[/\n/g' \ - -e 's/\]/\n/g' \ - -e "s/'/\n/g" \ - -e 's/[0-9][0-9]*/\n/g' \ - -e 's/[ \t]*//g' \ + -e 's/[!"?;:%^$~#{}`&=@,. \t\/_()|<>\+\*-]/\n/g' \ + -e 's/\[/\n/g' \ + -e 's/\]/\n/g' \ + -e "s/'/\n/g" \ + -e 's/[0-9][0-9]*/\n/g' \ + -e 's/[ \t]*//g' \ | tr '[:upper:]' '[:lower:]' \ | sort \ | uniq -c \ | awk "{ if (($minfreq == 0 || $minfreq <= \$1) \ - && ($maxfreq == 0 || \$1 <= $maxfreq)) { print \$0; } }" \ + && ($maxfreq == 0 || \$1 <= $maxfreq)) { print \$0; } }" \ | awk '{ print length($0) " " $0; }' \ | sort -n -r \ | cut -d ' ' -f 2- diff --git a/gdb/doc/makeinfo-wrapper.sh b/gdb/doc/makeinfo-wrapper.sh index 7ad63bca3bc..752da77ed3f 100755 --- a/gdb/doc/makeinfo-wrapper.sh +++ b/gdb/doc/makeinfo-wrapper.sh @@ -23,11 +23,11 @@ prog="$3" shift 3 major=$("$prog" --version \ - | grep "GNU texinfo" \ - | sed 's/^.* \([0-9][0-9]*\)\.[0-9][0-9]*\(.*\)\?$/\1/') + | grep "GNU texinfo" \ + | sed 's/^.* \([0-9][0-9]*\)\.[0-9][0-9]*\(.*\)\?$/\1/') minor=$("$prog" --version \ - | grep "GNU texinfo" \ - | sed 's/^.* [0-9][0-9]*\.\([0-9][0-9]*\)\(.*\)\?$/\1/') + | grep "GNU texinfo" \ + | sed 's/^.* [0-9][0-9]*\.\([0-9][0-9]*\)\(.*\)\?$/\1/') if [ "$major" = "" ] || [ "$major" = "" ]; then echo "Cannot determine makeinfo version for $prog. Info documentation will not be build." @@ -35,8 +35,10 @@ if [ "$major" = "" ] || [ "$major" = "" ]; then fi if [ "$major" -lt "$required_major" ] \ - || { [ "$major" -eq "$required_major" ] \ - && [ "$minor" -lt "$required_minor" ]; }; then + || { + [ "$major" -eq "$required_major" ] \ + && [ "$minor" -lt "$required_minor" ] + }; then echo "$prog is too old, have $major.$minor, require $required_major.$required_minor. Info documentation will not be build." exit fi diff --git a/gdb/gcore-1.in b/gdb/gcore-1.in index 2d3071d0ec5..a025e1c6690 100755 --- a/gdb/gcore-1.in +++ b/gdb/gcore-1.in @@ -36,7 +36,8 @@ data_directory= # The GDB binary to run. gdb_binary= -print_usage() { +print_usage() +{ prefix="Usage: $0" padding=$(printf '%*s' ${#prefix}) @@ -45,11 +46,13 @@ print_usage() { echo "$padding pid1 [pid2...pidN]" } -print_try_help() { +print_try_help() +{ echo "Try '$0 --help' for more information." } -print_help() { +print_help() +{ print_usage echo echo "Create a core file of a running program using GDB." @@ -65,7 +68,8 @@ print_help() { echo " to GDB." } -print_version() { +print_version() +{ echo "GNU gcore (${PKGVERSION}) ${VERSION}" } @@ -77,23 +81,23 @@ while getopts vhao:g:d:-: OPT; do fi case "$OPT" in - a) - case "$(uname -s)" in - Linux) - use_coredump_filter="off" - dump_excluded_mappings="on" - ;; - esac - ;; - o) - prefix=$OPTARG - ;; - g) - gdb_binary="$OPTARG" - ;; - d) - data_directory="$OPTARG" - ;; + a) + case "$(uname -s)" in + Linux) + use_coredump_filter="off" + dump_excluded_mappings="on" + ;; + esac + ;; + o) + prefix=$OPTARG + ;; + g) + gdb_binary="$OPTARG" + ;; + d) + data_directory="$OPTARG" + ;; h | help) print_help exit 0 @@ -107,21 +111,20 @@ while getopts vhao:g:d:-: OPT; do print_try_help 1>&2 exit 2 ;; - *) + *) # Unknown single character options are handled by the \? # case above. This is formatted to match the error # getopts gives for an unknown single character option. echo "$0: illegal option -- $OPT" 1>&2 print_try_help 1>&2 exit 2 - ;; + ;; esac done -shift $((OPTIND-1)) +shift $((OPTIND - 1)) -if [ "$#" -eq "0" ] -then +if [ "$#" -eq "0" ]; then print_usage 1>&2 exit 1 fi @@ -130,31 +133,31 @@ fi # called. binary_path=$(dirname "$0") -if test "$binary_path" = . ; then - # We got "." back as a path. This means the user executed - # the gcore script locally (i.e. ./gcore) or called the - # script via a shell interpreter (i.e. sh gcore). - binary_basename=$(basename "$0") - - # If the gcore script was called like "sh gcore" and the script - # lives in the current directory, "which" will not give us "gcore". - # So first we check if the script is in the current directory - # before using the output of "which". - if test -f "$binary_basename" ; then - # We have a local gcore script in ".". This covers the case of - # doing "./gcore" or "sh gcore". - binary_path="." - else - # The gcore script was not found in ".", which means the script - # was called from somewhere else in $PATH by "sh gcore". - # Extract the correct path now. - binary_path_from_env=$(which "$0") - binary_path=$(dirname "$binary_path_from_env") - fi +if test "$binary_path" = .; then + # We got "." back as a path. This means the user executed + # the gcore script locally (i.e. ./gcore) or called the + # script via a shell interpreter (i.e. sh gcore). + binary_basename=$(basename "$0") + + # If the gcore script was called like "sh gcore" and the script + # lives in the current directory, "which" will not give us "gcore". + # So first we check if the script is in the current directory + # before using the output of "which". + if test -f "$binary_basename"; then + # We have a local gcore script in ".". This covers the case of + # doing "./gcore" or "sh gcore". + binary_path="." + else + # The gcore script was not found in ".", which means the script + # was called from somewhere else in $PATH by "sh gcore". + # Extract the correct path now. + binary_path_from_env=$(which "$0") + binary_path=$(dirname "$binary_path_from_env") + fi fi if [ -z "$gdb_binary" ]; then - gdb_binary="$binary_path/@GDB_TRANSFORM_NAME@" + gdb_binary="$binary_path/@GDB_TRANSFORM_NAME@" fi gdb_binary_basename=$(basename "$gdb_binary") @@ -162,34 +165,32 @@ gdb_binary_basename=$(basename "$gdb_binary") # Check if the GDB binary is in the expected path. If not, just # quit with a message. if [ ! -f "$gdb_binary" ]; then - echo "gcore: GDB binary ($gdb_binary) not found" - exit 1 + echo "gcore: GDB binary ($gdb_binary) not found" + exit 1 fi # Initialise return code. rc=0 # Loop through pids -for pid in "$@" -do - # `. # 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() { - cat < ... ] Options: @@ -56,49 +57,47 @@ force=false targexp="" bfd_flag="" clean=false -while test $# -gt 0 -do +while test $# -gt 0; do case "$1" in - -j ) + -j) # Number of parallel make jobs. shift test $# -ge 1 || usage makejobs="-j $1" ;; - --clean ) - # Shall the build directory be deleted after processing? - clean=true - ;; - -e ) + --clean) + # Shall the build directory be deleted after processing? + clean=true + ;; + -e) # A regular expression for selecting targets shift test $# -ge 1 || usage targexp="${targexp} -e ${1}" ;; - --force ) + --force) # Force a rebuild - force=true ; + force=true ;; --bfd64) # Enable 64-bit BFD bfd_flag="--enable-64-bit-bfd" ;; - -* ) usage ;; + -*) usage ;; *) break ;; esac shift done -if test $# -ne 2 -then +if test $# -ne 2; then usage 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,33 +107,28 @@ ulimit -c 0 # Just make sure we're in the right directory. maintainers=${srcdir}/gdb/MAINTAINERS -if [ ! -r ${maintainers} ] -then - echo Maintainers file ${maintainers} not found - exit 1 +if [ ! -r ${maintainers} ]; then + echo Maintainers file ${maintainers} not found + exit 1 fi - # Build GDB with all targets enabled. echo "Starting gdb_buildall.sh ..." -trap "exit 1" 1 2 15 +trap "exit 1" 1 2 15 dir=${builddir}/ALL # Should a scratch rebuild be forced, for perhaps the entire build be skipped? -if ${force} -then +if ${force}; then echo ... forcing rebuild rm -rf ${dir} fi # Did the previous configure attempt fail? If it did restart from scratch -if test -d ${dir} -a ! -r ${dir}/Makefile -then +if test -d ${dir} -a ! -r ${dir}/Makefile; then echo ... removing partially configured rm -rf ${dir} - if test -d ${dir} - then + if test -d ${dir}; then echo "... ERROR: Unable to remove directory ${dir}" exit 1 fi @@ -145,17 +139,16 @@ mkdir -p ${dir} cd ${dir} || exit 1 # Configure GDB. -if test ! -r Makefile -then +if test ! -r Makefile; then # 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} \ @@ -163,11 +156,10 @@ then 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 + trap "exit 1" 1 2 15 # Without Makefile GDB won't build. - if test ! -r Makefile - then + if test ! -r Makefile; then echo "... CONFIG ERROR: GDB couldn't be configured " | tee -a Config.log echo "... CONFIG ERROR: see Config.log for details " exit 1 @@ -176,49 +168,44 @@ fi # Build GDB, if not built. gdb_bin="gdb/gdb" -if test ! -x gdb/gdb -a ! -x gdb/gdb.exe -then +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 + ( + ${make} ${makejobs} all-gdb || rm -f gdb/gdb gdb/gdb.exe ) > Build.log 2>&1 # If the build fails, exit. - if test ! -x gdb/gdb -a ! -x gdb/gdb.exe - then + if test ! -x gdb/gdb -a ! -x gdb/gdb.exe; then echo "... BUILD ERROR: GDB couldn't be compiled " | tee -a Build.log echo "... BUILD ERROR: see Build.log for details " exit 1 fi - if test -x gdb/gdb.exe - then + if test -x gdb/gdb.exe; then gdb_bin="gdb/gdb.exe" fi fi - # Retrieve a list of settable architectures by invoking "set architecture" # without parameters. -cat < arch +cat << EOF > arch set architecture quit EOF ./gdb/gdb --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 +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 -if test "${targexp}" != "" -then - alltarg=`cat gdb_archs | grep ${targexp}` +if test "${targexp}" != ""; then + 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 -do - cat < x +echo "$alltarg" | while read target; do + cat << EOF > x set architecture ${target} maint print architecture quit @@ -228,11 +215,9 @@ EOF echo -n "... ${target}" ./gdb/gdb -batch -nx -x x 2>&1 | cat > $log_file # Check GDBs results - if test ! -s $log_file - then + 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` - then + elif test $(grep -o internal-error $log_file | tail -n 1); then echo " ERR: gdb panic" | tee -a $log_file else echo " OK" @@ -242,12 +227,11 @@ EOF 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 \ - | sort -u \ - | while read addr - do - func="`addr2line -f -e ./$gdb_bin -s ${addr} | sed -n -e 1p`" - echo "s/<${addr}>/<${func}>/g" - done >> mbuild.sed + | sort -u \ + | while read addr; do + 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. @@ -259,8 +243,7 @@ done echo "done." # Clean up build directory if necessary. -if ${clean} -then +if ${clean}; then echo "cleaning up $dir" rm -rf ${dir} fi diff --git a/gdb/gdb_mbuild.sh b/gdb/gdb_mbuild.sh index 44def191dc8..0f33bcd216e 100755 --- a/gdb/gdb_mbuild.sh +++ b/gdb/gdb_mbuild.sh @@ -22,12 +22,14 @@ # Make certain that the script is not running in an internationalized # environment. -LANG=c ; export LANG -LC_ALL=c ; export LC_ALL +LANG=c +export LANG +LC_ALL=c +export LC_ALL usage() { - cat < ... ] Options: -j Run in parallel. Passed to make. @@ -43,8 +45,8 @@ Usage: gdb_mbuild.sh [ ... ] Environment variables examined (with default if not defined): MAKE (make)" EOF - exit 1; -cat < Run builds in parallel. On a single cpu machine, 1 is recommended. NOTYET @@ -59,63 +61,60 @@ force=false targexp="" verbose=0 keep=false -while test $# -gt 0 -do +while test $# -gt 0; do case "$1" in - -j ) - # Number of parallel make jobs. - shift - test $# -ge 1 || usage - makejobs="-j $1" - ;; - -b | -c ) - # Number of builds to fire off in parallel. - shift - test $# -ge 1 || usage - maxbuilds=$1 - ;; - -k ) - # Should we soldier on after the first build fails? - keepgoing=-k - ;; - --keep ) - keep=true - ;; - -e ) - # A regular expression for selecting targets - shift - test $# -ge 1 || usage - targexp="${targexp} -e ${1}" - ;; - -f ) - # Force a rebuild - force=true ; - ;; - -v ) - # Be more, and more, and more, verbose - verbose=`expr ${verbose} + 1` - ;; - -* ) usage ;; - *) break ;; + -j) + # Number of parallel make jobs. + shift + test $# -ge 1 || usage + makejobs="-j $1" + ;; + -b | -c) + # Number of builds to fire off in parallel. + shift + test $# -ge 1 || usage + maxbuilds=$1 + ;; + -k) + # Should we soldier on after the first build fails? + keepgoing=-k + ;; + --keep) + keep=true + ;; + -e) + # A regular expression for selecting targets + shift + test $# -ge 1 || usage + targexp="${targexp} -e ${1}" + ;; + -f) + # Force a rebuild + force=true + ;; + -v) + # Be more, and more, and more, verbose + verbose=$(expr ${verbose} + 1) + ;; + -*) usage ;; + *) break ;; esac shift done - ### COMMAND LINE PARAMETERS -if test $# -ne 2 -then +if test $# -ne 2; then usage fi # Convert these to absolute directory paths. # Where the sources live -srcdir=`cd $1 && /bin/pwd` || exit 1 +srcdir=$(cd $1 && /bin/pwd) || exit 1 # Where the builds occur -builddir=`cd $2 && /bin/pwd` || exit 1 +builddir=$(cd $2 && /bin/pwd) || exit 1 ### ENVIRONMENT PARAMETERS @@ -124,17 +123,15 @@ make=${MAKE:-make} MAKE=${make} export MAKE - # Where to look for the list of targets to test maintainers=${srcdir}/gdb/MAINTAINERS -if [ ! -r ${maintainers} ] -then +if [ ! -r ${maintainers} ]; then echo Maintainers file ${maintainers} not found exit 1 fi # Get the list of targets and the build options -alltarg=`cat ${maintainers} | tr -s '[\t]' '[ ]' | sed -n ' +alltarg=$(cat ${maintainers} | tr -s '[\t]' '[ ]' | sed -n ' /^[ ]*[-a-z0-9\.]*[ ]*[(]*--target=.*/ !d s/^.*--target=// s/).*$// @@ -150,26 +147,23 @@ h b loop :end p -' | if test "${targexp}" = "" -then +' | if test "${targexp}" = ""; then grep -v -e broken -e OBSOLETE else grep ${targexp} -fi` - +fi) # Usage: fail . Should the build # fail? If the test is true, and we don't want to keep going, print # the message and shoot everything in sight and abort the build. -fail () +fail() { - msg="$1" ; shift - if test "$@" - then + msg="$1" + shift + if test "$@"; then echo "${target}: ${msg}" - if test "${keepgoing}" != "" - then + if test "${keepgoing}" != ""; then #exit 1 return 1 else @@ -179,45 +173,37 @@ fail () fi } - # Usage: log . Write standard input to and # stdout (if verbose >= level). -log () +log() { - if test ${verbose} -ge $1 - then + if test ${verbose} -ge $1; then tee $2 else cat > $2 fi } - - # Warn the user of what is coming, print the list of targets echo "$alltarg" echo "" - # For each target, configure, build and test it. -echo "$alltarg" | while read target gdbopts simopts -do +echo "$alltarg" | while read target gdbopts simopts; do - trap "exit 1" 1 2 15 + trap "exit 1" 1 2 15 dir=${builddir}/${target} # Should a scratch rebuild be forced, for perhaps the entire # build be skipped? - if ${force} - then + if ${force}; then echo forcing ${target} ... rm -rf ${dir} - elif test -f ${dir} - then + elif test -f ${dir}; then echo "${target}" continue else @@ -227,12 +213,10 @@ do # Did the previous configure attempt fail? If it did # restart from scratch. - if test -d ${dir} -a ! -r ${dir}/Makefile - then + if test -d ${dir} -a ! -r ${dir}/Makefile; then echo ... removing partially configured ${target} rm -rf ${dir} - if test -d ${dir} - then + if test -d ${dir}; then echo "${target}: unable to remove directory ${dir}" exit 1 fi @@ -246,16 +230,15 @@ do # Configure, if not already. Should this go back to being # separate and done in parallel? - if test ! -r Makefile - then + if test ! -r Makefile; then # Default SIMOPTS to GDBOPTS. test -z "${simopts}" && simopts="${gdbopts}" # The config options __target="--target=${target}" - __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 \ ${__target} \ ${__enable_gdb_build_warnings} \ @@ -263,20 +246,20 @@ do echo ... ${__configure} trap "echo Removing partially configured ${dir} directory ...; rm -rf ${dir}; exit 1" 1 2 15 ${__configure} 2>&1 | log 2 Config.log - trap "exit 1" 1 2 15 + trap "exit 1" 1 2 15 fi fail "configure failed" ! -r Makefile # Build, if not built. - if test ! -x gdb/gdb -a ! -x gdb/gdb.exe - then + if test ! -x gdb/gdb -a ! -x gdb/gdb.exe; then # Iff the build fails remove the final build target so that # the follow-on code knows things failed. Stops the follow-on # code thinking that a failed rebuild succeeded (executable # left around from previous build). echo ... ${make} ${keepgoing} ${makejobs} ${target} - ( ${make} ${keepgoing} ${makejobs} all-gdb || rm -f gdb/gdb gdb/gdb.exe + ( + ${make} ${keepgoing} ${makejobs} all-gdb || rm -f gdb/gdb gdb/gdb.exe ) 2>&1 | log 1 Build.log fi fail "compile failed" ! -x gdb/gdb -a ! -x gdb/gdb.exe @@ -285,7 +268,7 @@ do echo ... run ${target} rm -f core gdb.core ${dir}/gdb/x - cat < x + cat << EOF > x maint print architecture quit EOF @@ -302,13 +285,12 @@ EOF # Rules to replace <0xNNNN> with the corresponding function's # name. sed -n -e '/<0x0*>/d' -e 's/^.*<0x\([0-9a-f]*\)>.*$/0x\1/p' Gdb.log \ - | sort -u \ - | while read addr - do - func="`addr2line -f -e ./gdb/gdb -s ${addr} | sed -n -e 1p`" - test ${verbose} -gt 0 && echo "${addr} ${func}" 1>&2 - echo "s/<${addr}>/<${func}>/g" - done >> mbuild.sed + | sort -u \ + | while read addr; do + func="$(addr2line -f -e ./gdb/gdb -s ${addr} | sed -n -e 1p)" + test ${verbose} -gt 0 && echo "${addr} ${func}" 1>&2 + 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 @@ -319,8 +301,7 @@ EOF cd ${builddir} - if ${keep} - then + if ${keep}; then : else rm -f ${target}.tmp diff --git a/gdb/gstack-1.in b/gdb/gstack-1.in index 9079e70a746..eb631a36a77 100755 --- a/gdb/gstack-1.in +++ b/gdb/gstack-1.in @@ -40,15 +40,18 @@ if [ ! -x "$AWK" ]; then exit 2 fi -function print_usage() { +function print_usage() +{ echo "Usage: $0 [-h|--help] [-v|--version] PID" } -function print_try_help() { +function print_try_help() +{ echo "Try '$0 --help' for more information." } -function print_help() { +function print_help() +{ print_usage echo "Print a stack trace of a running program" echo @@ -56,7 +59,8 @@ function print_help() { echo " -v, --version Print version information then exit." } -function print_version() { +function print_version() +{ echo "GNU gstack (${PKGVERSION}) ${VERSION}" } @@ -80,7 +84,8 @@ while getopts hv-: OPT; do \?) # getopts has already output an error message. print_try_help 1>&2 - exit 2 ;; + exit 2 + ;; *) echo "$0: unrecognized option '--$OPT'" 1>&2 print_try_help 1>&2 @@ -88,7 +93,7 @@ while getopts hv-: OPT; do ;; esac done -shift $((OPTIND-1)) +shift $((OPTIND - 1)) # The sole remaining argument should be the PID of the process # whose backtrace is desired. @@ -99,7 +104,8 @@ fi PID=$1 -awk_script=$(cat << EOF +awk_script=$( + cat << EOF BEGIN { first=1 attach_okay=0 @@ -129,11 +135,11 @@ if (attach_okay == 0) exit 2 } EOF - ) +) # Run GDB and remove some unwanted noise. # shellcheck disable=SC2086 -"$GDB" --quiet -nx $GDBARGS < ..." 1>&2 exit 0 fi -xgettext=$1 ; shift -package=$1 ; shift +xgettext=$1 +shift +package=$1 +shift -find_files () +find_files() { for d in "$@"; do ( cd "$d" find -- * \ - -name '*-stub.c' -prune -o \ - -name 'testsuite' -prune -o \ - -name 'init.c' -prune -o \ - -name '*.[hc]' -print -o \ - -name '*.cc' -print + -name '*-stub.c' -prune -o \ + -name 'testsuite' -prune -o \ + -name 'init.c' -prune -o \ + -name '*.[hc]' -print -o \ + -name '*.cc' -print ) done } -run_xgettext () +run_xgettext() { # Transform: # "$@" == "arg1" "arg2" ... diff --git a/gdb/syscalls/update-freebsd.sh b/gdb/syscalls/update-freebsd.sh index e91817cf9f3..7b6c38e045c 100755 --- a/gdb/syscalls/update-freebsd.sh +++ b/gdb/syscalls/update-freebsd.sh @@ -28,14 +28,14 @@ # rather than syscalls.master as syscall.h is easier to parse. if [ $# -ne 1 ]; then - echo "Error: Path to syscall.h missing. Aborting." - echo "Usage: update-freebsd.sh " - exit 1 + echo "Error: Path to syscall.h missing. Aborting." + echo "Usage: update-freebsd.sh " + exit 1 fi year=$(date +%Y) -cat > freebsd.xml.tmp < freebsd.xml.tmp << EOF