From nobody Mon May 11 08:30:27 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 677CAC433F5 for ; Sat, 9 Apr 2022 18:04:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242952AbiDISGF (ORCPT ); Sat, 9 Apr 2022 14:06:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57908 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233305AbiDISGA (ORCPT ); Sat, 9 Apr 2022 14:06:00 -0400 Received: from mail-io1-xd2a.google.com (mail-io1-xd2a.google.com [IPv6:2607:f8b0:4864:20::d2a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 43AEB94 for ; Sat, 9 Apr 2022 11:03:52 -0700 (PDT) Received: by mail-io1-xd2a.google.com with SMTP id g21so14179785iom.13 for ; Sat, 09 Apr 2022 11:03:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=mUG6QiQTmHfwgnDwUso5dIAM47XXDf7ghDlvuJZskMg=; b=HS3dzFtie/5Nyl5rwdbRdpbcwvuu/y1rpDazlF5GPV09aPpwT/ehBSkg6SZexjHnza dOapUYQtTICQQSZWinlzmucupskGQrRjlyet5Rc5ZW1+GX2AwCy4Hx6exsPrlXuW+Fvi aQnuEM2N8mb7x2WOIrGNmV3VtKBGMQ51dtAMvKrOEeD0Xn54uxWExsw82JQiyrik/jYe ulwQCLZX8t67W+Ol3TerRyx3hTfNAaEelr7Z+kihIQvpgP3CXXMfPiXHqzQ42ooW0VIM QSSJJqPpM4y88IVtwVfUmZiYWYtnlcHR/6LO+WY4RP5IQOZNCGEFIQDeSo2WspK887t+ ZRPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=mUG6QiQTmHfwgnDwUso5dIAM47XXDf7ghDlvuJZskMg=; b=kgt5KzlJSVuZMuJYzTljprToqxxl6ywjFlBCY9HdoRQ7sZWE2uC1Ra3em+yU57c7cH Q1LoK/ZRSOplEloHjEL52wW2ka8YetymDv3aAHidb0pzxQ6QPwLda6N0DHbipfi7Y8cA /ncuHwdsHWJ7mu1sRNKM0wwYVqYCIRiPbXXlKghk52w5WFYccxvFKo4ATrPoSmlibSj+ havFOvurJGjAdCGjzImksbIaCy1JJE/B9deIxHz9SN95cujn64BTb3lWZGn6DSYmNV0T wMsuSoDsr/wxJz4cKTZqt5/drQERcbHZ0+FB6Q2sSfGoubi6jtKkYif8s83IYIIZ4S+s i/gA== X-Gm-Message-State: AOAM531KmwGjmTEOweFB4jSJerag+8SgXU3q8zdACV1FAn20Sa38Ifyc rvQZTlHbPmM78R5tbGvT8KmVzurBft3cASsbQw4= X-Google-Smtp-Source: ABdhPJz5IDX6IYiWakCJ7dXBepfl1RZ9dG5b0DCHXZir0DSkpbDhDr1LS6KVoI8RipCrEhQYTkdUrg== X-Received: by 2002:a6b:f217:0:b0:64c:de54:4e8d with SMTP id q23-20020a6bf217000000b0064cde544e8dmr10563946ioh.48.1649527431633; Sat, 09 Apr 2022 11:03:51 -0700 (PDT) Received: from localhost (ec2-13-59-0-164.us-east-2.compute.amazonaws.com. [13.59.0.164]) by smtp.gmail.com with UTF8SMTPSA id w2-20020a92c882000000b002c81bffee08sm15706695ilo.55.2022.04.09.11.03.49 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 09 Apr 2022 11:03:51 -0700 (PDT) From: Schspa Shi To: swboyd@chromium.org, akpm@linux-foundation.org Cc: schspa@gmail.com, linux-kernel@vger.kernel.org Subject: [PATCH] scripts/decode_stacktrace.sh: support old bash version Date: Sun, 10 Apr 2022 02:03:32 +0800 Message-Id: <20220409180331.24047-1-schspa@gmail.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Old bash version don't support associative array variables. Avoid to use associative array variables to avoid error. Without this, old bash version will report error as fellowing [ 15.954042] Kernel panic - not syncing: sysrq triggered crash [ 15.955252] CPU: 1 PID: 167 Comm: sh Not tainted 5.18.0-rc1-00208-gb7d07= 5db2fd5 #4 [ 15.956472] Hardware name: Hobot J5 Virtual development board (DT) [ 15.957856] Call trace: ./scripts/decode_stacktrace.sh: line 128: ,dump_backtrace: syntax error: op= erand expected (error token is ",dump_backtrace") Signed-off-by: Schspa Shi --- scripts/decode_stacktrace.sh | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/scripts/decode_stacktrace.sh b/scripts/decode_stacktrace.sh index 5fbad61fe490..7075e26ab2c4 100755 --- a/scripts/decode_stacktrace.sh +++ b/scripts/decode_stacktrace.sh @@ -45,8 +45,13 @@ else fi fi =20 -declare -A cache -declare -A modcache +declare aarray_support=3Dtrue +declare -A cache 2>/dev/null +if [[ $? !=3D 0 ]]; then + aarray_support=3Dfalse +else + declare -A modcache +fi =20 find_module() { if [[ -n $debuginfod ]] ; then @@ -97,7 +102,7 @@ parse_symbol() { =20 if [[ $module =3D=3D "" ]] ; then local objfile=3D$vmlinux - elif [[ "${modcache[$module]+isset}" =3D=3D "isset" ]]; then + elif [[ $aarray_support =3D=3D true && "${modcache[$module]+isset}" =3D= =3D "isset" ]]; then local objfile=3D${modcache[$module]} else local objfile=3D$(find_module) @@ -105,7 +110,9 @@ parse_symbol() { echo "WARNING! Modules path isn't set, but is needed to parse this symb= ol" >&2 return fi - modcache[$module]=3D$objfile + if [[ $aarray_support =3D=3D true ]]; then + modcache[$module]=3D$objfile + fi fi =20 # Remove the englobing parenthesis @@ -125,7 +132,7 @@ parse_symbol() { # Use 'nm vmlinux' to figure out the base address of said symbol. # It's actually faster to call it every time than to load it # all into bash. - if [[ "${cache[$module,$name]+isset}" =3D=3D "isset" ]]; then + if [[ $aarray_support =3D=3D true && "${cache[$module,$name]+isset}" =3D= =3D "isset" ]]; then local base_addr=3D${cache[$module,$name]} else local base_addr=3D$(nm "$objfile" 2>/dev/null | awk '$3 =3D=3D "'$name'"= && ($2 =3D=3D "t" || $2 =3D=3D "T") {print $1; exit}') @@ -133,7 +140,9 @@ parse_symbol() { # address not found return fi - cache[$module,$name]=3D"$base_addr" + if [[ $aarray_support =3D=3D true ]]; then + cache[$module,$name]=3D"$base_addr" + fi fi # Let's start doing the math to get the exact address into the # symbol. First, strip out the symbol total length. @@ -149,11 +158,13 @@ parse_symbol() { =20 # Pass it to addr2line to get filename and line number # Could get more than one result - if [[ "${cache[$module,$address]+isset}" =3D=3D "isset" ]]; then + if [[ $aarray_support =3D=3D true && "${cache[$module,$address]+isset}" = =3D=3D "isset" ]]; then local code=3D${cache[$module,$address]} else local code=3D$(${CROSS_COMPILE}addr2line -i -e "$objfile" "$address" 2>/= dev/null) - cache[$module,$address]=3D$code + if [[ $aarray_support =3D=3D true ]]; then + cache[$module,$address]=3D$code + fi fi =20 # addr2line doesn't return a proper error code if it fails, so --=20 2.24.3 (Apple Git-128)