From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id rVy4I5Wq4WYkpicAWB0awg (envelope-from ) for ; Wed, 11 Sep 2024 10:35:01 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=lUymL3ZN; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 736971E353; Wed, 11 Sep 2024 10:35:01 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-11.8 required=5.0 tests=ARC_SIGNED,ARC_VALID, BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI,RCVD_IN_VALIDITY_CERTIFIED,RCVD_IN_VALIDITY_RPBL, RCVD_IN_VALIDITY_SAFE,URIBL_BLOCKED,URIBL_DBL_BLOCKED_OPENDNS autolearn=ham autolearn_force=no version=4.0.0 Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (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 BCD721E08F for ; Wed, 11 Sep 2024 10:35:00 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 115CD385841C for ; Wed, 11 Sep 2024 14:35:00 +0000 (GMT) Received: from mail-il1-x136.google.com (mail-il1-x136.google.com [IPv6:2607:f8b0:4864:20::136]) by sourceware.org (Postfix) with ESMTPS id 75C8C3858C98 for ; Wed, 11 Sep 2024 14:34:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 75C8C3858C98 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 75C8C3858C98 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::136 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1726065278; cv=none; b=D4tF0aXsvMa3+UlyLsf8hm0LYE1fz3SJVWEcn2F1PXihH1Zv+XUfmoyBtkTvZ89I+kU/6jUzT4OAWZ93ckVBgZn7p6S6bX6tuIgSmETGZsGNpm8Mf5d1ZhzCZGvqJmfZ889T4BX0aE6PRhltrGQh5B4UdLSsp/9i6sYSBg+eAsM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1726065278; c=relaxed/simple; bh=0aTcBpQOM5OJ4535A6jSs5Z7xWvyD3THHKF/j7vdd9A=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=H5T09FTv2bibXTUYVUkgmFMf1lOsOvJzzlOecb6sma/zdUEN4JidvNCnB/unNEkwZvElVHLC3/4N8pRrMdlqjUW3SGYumJYMORzhRkaO4x2mj69NFGFSDoMlFYpHcCn3re8BWQZIQDk2GRcQa7gdUu2vOxgnXI5B9xZBt44IzvA= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-il1-x136.google.com with SMTP id e9e14a558f8ab-39f4fed788bso25974595ab.3 for ; Wed, 11 Sep 2024 07:34:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1726065276; x=1726670076; darn=sourceware.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=cIkPNoenf8xsnvVst6yMvTnABU2HbUlIFGQ/pBL/0JY=; b=lUymL3ZNnYFAfF+u4DrGEo++AKm9+tvYgt8Kud39IIjhG67pUh//Nh+nR9XYhOTfXI 4c3j3QPjoiBTvkIkdiDq8bKqh0AyB4RikG+j1nisFoI5ZOszHMy5+82V25dF9HvdDaAD TPKco4ZuT3hMUgyoMWD0GWKT0RjOFHJELoNg1w9YKi7e1zkOIwvceFNTY77WPZjZp415 xzeYl+a/FajOeoHb2feaiSIoDaWnrE8VNxJ5Q2ProbFMZ93+51CZryXHgZFpm31VooFe tR7GuB+4uLrbyF5pW+Fu1RcnPgf9dYbpB6XoO2Rnpdlw6B2GiFJZtJUNkZKaIW1YqE0t 2Daw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726065276; x=1726670076; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=cIkPNoenf8xsnvVst6yMvTnABU2HbUlIFGQ/pBL/0JY=; b=B9ZQVj+2Ozu3h1IilQS7bItm3cTqtcRGDMI0gnz+FdjhdIfCO66cQ53jnmw5ao3m0K cQgYtEoryMRBs7mLxsGmu2xY9C6eFVHJWuFDtQG7uSTbEgrJRz/uSMnxHFsRdKRIr8Uj NtYlVa7bXtDo9NWE/qjoYXaQd4AtSMXNgbgQDGxkmNGcNZhMJ4bFTzBzorsBUT0AkbIQ S/siXDCeZv+qE2Fgip1dciT6Tuxn5TybyCcV93ybKdgXHCakPyoOiFKw3ZNhm3DcBokP iYC75DcpCf/o+LOTBAGO0GUI9AuRpM2C7A1ZyJFPf0Halqujddb4ng2of7eA5d8vEuQV dOOg== X-Gm-Message-State: AOJu0Yyg7l2O27u/JtC4aL4tAcGQiOUbrrgP8/zPDI7fkx8GsRbpc+dy YYIU0uxGsZ6Dp0ZKRxvCBDwuZgJktUNyTCtZTTwAOf2SRqGqNWZD3MsC/YdOkSppyqOxS3mWoHE TUA== X-Google-Smtp-Source: AGHT+IG7sqELPYipYRY9ac12v3/TvgW60gpZwu52ZqoBr5+J4XrrTYhV4N0YZtPXwMJANdvYftWbHg== X-Received: by 2002:a05:6e02:1786:b0:3a0:463d:ce1e with SMTP id e9e14a558f8ab-3a04f08be16mr241628135ab.12.1726065275680; Wed, 11 Sep 2024 07:34:35 -0700 (PDT) Received: from localhost.localdomain (97-118-34-56.hlrn.qwest.net. [97.118.34.56]) by smtp.gmail.com with ESMTPSA id e9e14a558f8ab-3a05900e602sm26599055ab.70.2024.09.11.07.34.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Sep 2024 07:34:35 -0700 (PDT) From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH] Fix quoting in gdb-add-index.sh Date: Wed, 11 Sep 2024 08:34:26 -0600 Message-ID: <20240911143426.3040211-1-tromey@adacore.com> X-Mailer: git-send-email 2.45.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 When the filename quoting change was merged into the AdaCore tree, we saw a regression in a test setup that uses the DWARF 5 index (that is running gdb-add-index), and a filename with a space in it. Initially I thought this was a change in the 'file' command -- but looking again, I found out that 'file' has worked this way for a while, and our immediate error was caused by the (documented) change to "save gdb-index". While I'm not sure why this test was working previously, it seems to me that gdb-add-index.sh requires a change to quote the arguments to "file" and "save gdb-index". While working on this, though, it seemed to me that multiple other spots needed quoting for the script to work correctly. And, I was unable to get quoting working correctly in the objcopy calls, so I split it into multiple different invocations. --- gdb/contrib/gdb-add-index.sh | 39 +++++++++++++++++------------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/gdb/contrib/gdb-add-index.sh b/gdb/contrib/gdb-add-index.sh index 80bc4956358..bd5a8f75973 100755 --- a/gdb/contrib/gdb-add-index.sh +++ b/gdb/contrib/gdb-add-index.sh @@ -113,7 +113,7 @@ trap "rm -f $tmp_files" 0 $GDB --batch -nx -iex 'set auto-load no' \ -iex 'set debuginfod enabled off' \ - -ex "file $file" -ex "save gdb-index $dwarf5 $dir" || { + -ex "file '$file'" -ex "save gdb-index $dwarf5 '$dir'" || { # Just in case. status=$? echo "$myname: gdb error generating index for $file" 1>&2 @@ -143,35 +143,32 @@ handle_file () index="$index5" section=".debug_names" fi - debugstradd=false - debugstrupdate=false if test -s "$debugstr"; then if ! $OBJCOPY --dump-section .debug_str="$debugstrmerge" "$fpath" \ - /dev/null 2>$debugstrerr; then - cat >&2 $debugstrerr + /dev/null 2> "$debugstrerr"; then + cat >&2 "$debugstrerr" exit 1 fi + cat "$debugstr" >>"$debugstrmerge" if grep -q "can't dump section '.debug_str' - it does not exist" \ - $debugstrerr; then - debugstradd=true + "$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" else - debugstrupdate=true - cat >&2 $debugstrerr + $OBJCOPY --add-section $section="$index" \ + --set-section-flags $section=readonly \ + --update-section .debug_str="$debugstrmerge" \ + "$fpath" "$fpath" fi - cat "$debugstr" >>"$debugstrmerge" + else + $OBJCOPY --add-section $section="$index" \ + --set-section-flags $section=readonly \ + "$fpath" "$fpath" fi - $OBJCOPY --add-section $section="$index" \ - --set-section-flags $section=readonly \ - $(if $debugstradd; then \ - echo --add-section .debug_str="$debugstrmerge"; \ - echo --set-section-flags .debug_str=readonly; \ - fi; \ - if $debugstrupdate; then \ - echo --update-section .debug_str="$debugstrmerge"; \ - fi) \ - "$fpath" "$fpath" - status=$? else echo "$myname: No index was created for $fpath" 1>&2 -- 2.45.0