From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id mmaIHsGZBmcqhAcAWB0awg (envelope-from ) for ; Wed, 09 Oct 2024 10:57:05 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=VZNhA0A1; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 663DD1E356; Wed, 9 Oct 2024 10:57:05 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-7.8 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_BLOCKED,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 210B61E354 for ; Wed, 9 Oct 2024 10:57:04 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5BA8138650D4 for ; Wed, 9 Oct 2024 14:57:03 +0000 (GMT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTP id D2FBE385DDDF for ; Wed, 9 Oct 2024 14:56:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D2FBE385DDDF Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org D2FBE385DDDF Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728485802; cv=none; b=PzYDxHj3oG3jBtzPRC1G9WhimosbhxedUZUxUCaAS0jadHOegvcxe8F3WRykcTr1mRp5IAC08k3meQt3PPU/len+sXcmFuWc+oD13v40Yt4lnRGEUvYTOex3+2/ouV68WpYqFtDT1WO4aAYzBdd1U78NK6AXWpNGkq+LKFkCsZc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728485802; c=relaxed/simple; bh=dH6QjtQ67awhWEs+w589w+rdNTP/Li0f2XUqfLxoy/0=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=pX4g9XT9LKYa6jvrQ3z9B+eUhzVZQKn0XWjez6JnrJinAHXA31PmX7CnD2pZLPiL4ir0KjQOo4Ig3GT/wO2/h6WE1doJDmyfibvZcwk7hEhBTCKBWgUtqChDMOCK7J8pnqWsMtFsGEcSu2iJmjwvFcAxzEpcCoYzjslGY+yfRyw= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728485799; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+GY5H+qyOYyaahezOtQzGSZlIZJtRBl6EnwGx6He/0c=; b=VZNhA0A16u/pKh6qtbZivjc92ZOb2JrVUpmwjOKa67T2Q9T6Z41ixR+ora2mDPG6M2ZNZ2 2lb8lGllUyDomtlN9en3G91uY++pXzXMl83U11jjOXEZfxL0JPJBL2IwJzfVbK655gJ/AN lN+CfckK4+gDjwW6f+hxkfeHtJLy1FU= Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-167-TddU9ygZN3yNNnWTZ82dpg-1; Wed, 09 Oct 2024 10:56:36 -0400 X-MC-Unique: TddU9ygZN3yNNnWTZ82dpg-1 Received: by mail-qv1-f72.google.com with SMTP id 6a1803df08f44-6cbc7185f75so19505186d6.3 for ; Wed, 09 Oct 2024 07:56:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728485796; x=1729090596; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=+GY5H+qyOYyaahezOtQzGSZlIZJtRBl6EnwGx6He/0c=; b=JVjbNQg4p4K04ZYq5qQ7Byzxs2zoE/kwkzq3igT+pNgp8l2GJzgreW685MrY7C6Xzh 00lWL9sidyEwV0LQcRGCEc/AFJVYsrCrGstB9Py1v9tHBdImbmOZNlAKG8zqK/QehEaG acZBozjEKfPg2ZwHZIcHpDpPr19dANhNcFCwcU+nQwp+PIJQmYbqYtvemLUY1Anno7gz O8nltkzMp6BLyoqten+6wPYyQG6z16Udvau5yY4AC4ldkNEN0sSobF+TE4sfFabV/WfY pfdrsctcQLJu/9tikb8ghAjaJ5ifmw99txL0Rppb925/bmmGXQMf8CYDLZ7XwK4yK7br C0xw== X-Forwarded-Encrypted: i=1; AJvYcCVBtNfjhy1vTDEmh7x6fPC67rFcsECrg3RNkXvS1kyEVDaZKGInQft3qJ2j3jN6ZSCklxMKVC5SUKo/RQ==@sourceware.org X-Gm-Message-State: AOJu0YwEGXAxBm1u9YSfhxHC7s9gQW7645VLMc+qCFYrNeHKscfJFBUB n1KtPkhU0USh0lZpK4w/myDrPYBUNp9cTUanbnm95IcmAHhlZT0I2Et6wcgiGymBKhAADe56T+/ rBBwb9DZBdTQ02siHwVTy8SWSx5xpuuA1TlfzE0+gx4x0URuA1V9ZWaSb6og= X-Received: by 2002:a05:6214:588f:b0:6cb:c70e:4e9 with SMTP id 6a1803df08f44-6cbc92e5c6fmr33771126d6.10.1728485796025; Wed, 09 Oct 2024 07:56:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHncTf84DKvDACcI7w881hIfGwnLhgSPAQTezzLse/PENKkoVJOFkANQEBJbU1Wm6BUpfA9zg== X-Received: by 2002:a05:6214:588f:b0:6cb:c70e:4e9 with SMTP id 6a1803df08f44-6cbc92e5c6fmr33770906d6.10.1728485795639; Wed, 09 Oct 2024 07:56:35 -0700 (PDT) Received: from ?IPV6:2804:14d:8084:92c5::1000? ([2804:14d:8084:92c5::1000]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6cbc83d9fc1sm10147256d6.1.2024.10.09.07.56.34 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 09 Oct 2024 07:56:35 -0700 (PDT) Message-ID: Date: Wed, 9 Oct 2024 11:56:33 -0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v5 5/5] gdb/testsuite: Test for a backtrace through object without debuginfo To: "Gerlicher, Klaus" , "gdb-patches@sourceware.org" Cc: Guinevere Larsen , Jan Kratochvil References: <20241001184235.3710608-1-guinevere@redhat.com> <20241001184235.3710608-6-guinevere@redhat.com> From: Guinevere Larsen In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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 On 10/3/24 3:58 AM, Gerlicher, Klaus wrote: > Hi Guienvere, > > Just one suggestion inline. > > Thanks > Klaus > >> -----Original Message----- >> From: Guinevere Larsen >> Sent: Tuesday, October 1, 2024 8:43 PM >> To: gdb-patches@sourceware.org >> Cc: Guinevere Larsen ; Jan Kratochvil >> >> Subject: [PATCH v5 5/5] gdb/testsuite: Test for a backtrace through object >> without debuginfo >> >> From: Guinevere Larsen >> >> Fedora has been carrying this test since back in the Project Archer >> days. A change back then caused GDB to stop being able to backtrace when >> only some of the object files had debug information. Even though the >> changed code never seems to have made its way into the main GDB project, >> I think it makes sense to bring the test along to ensure something like >> this doesn't pass unnoticed. >> >> Co-Authored-By: Jan Kratochvil >> --- >> .../backtrace-through-cu-nodebug-caller.c | 28 ++++++ >> .../backtrace-through-cu-nodebug-main.c | 32 +++++++ >> .../gdb.base/backtrace-through-cu-nodebug.exp | 90 >> +++++++++++++++++++ >> 3 files changed, 150 insertions(+) >> create mode 100644 gdb/testsuite/gdb.base/backtrace-through-cu- >> nodebug-caller.c >> create mode 100644 gdb/testsuite/gdb.base/backtrace-through-cu- >> nodebug-main.c >> create mode 100644 gdb/testsuite/gdb.base/backtrace-through-cu- >> nodebug.exp >> >> diff --git a/gdb/testsuite/gdb.base/backtrace-through-cu-nodebug-caller.c >> b/gdb/testsuite/gdb.base/backtrace-through-cu-nodebug-caller.c >> new file mode 100644 >> index 00000000000..3a63d72a468 >> --- /dev/null >> +++ b/gdb/testsuite/gdb.base/backtrace-through-cu-nodebug-caller.c >> @@ -0,0 +1,28 @@ >> +/* This testcase is part of GDB, the GNU debugger. >> + >> + Copyright 2005-2024 Free Software Foundation, Inc. >> + >> + This program is free software; you can redistribute it and/or modify >> + it under the terms of the GNU General Public License as published by >> + the Free Software Foundation; either version 3 of the License, or >> + (at your option) any later version. >> + >> + This program is distributed in the hope that it will be useful, >> + but WITHOUT ANY WARRANTY; without even the implied warranty of >> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >> + GNU General Public License for more details. >> + >> + You should have received a copy of the GNU General Public License >> + along with this program. If not, see . */ >> + >> +typedef int (*callback_t) (void); >> + >> +int >> +caller (callback_t callback) >> +{ >> + /* Ensure some frame content to push away the return address. */ >> + volatile const long one = 1; >> + >> + /* Modify the return value to prevent any tail-call optimization. */ >> + return (*callback) () - one; >> +} >> diff --git a/gdb/testsuite/gdb.base/backtrace-through-cu-nodebug-main.c >> b/gdb/testsuite/gdb.base/backtrace-through-cu-nodebug-main.c >> new file mode 100644 >> index 00000000000..3e7ac57a166 >> --- /dev/null >> +++ b/gdb/testsuite/gdb.base/backtrace-through-cu-nodebug-main.c >> @@ -0,0 +1,32 @@ >> +/* This testcase is part of GDB, the GNU debugger. >> + >> + Copyright 2005-2024 Free Software Foundation, Inc. >> + >> + This program is free software; you can redistribute it and/or modify >> + it under the terms of the GNU General Public License as published by >> + the Free Software Foundation; either version 3 of the License, or >> + (at your option) any later version. >> + >> + This program is distributed in the hope that it will be useful, >> + but WITHOUT ANY WARRANTY; without even the implied warranty of >> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >> + GNU General Public License for more details. >> + >> + You should have received a copy of the GNU General Public License >> + along with this program. If not, see . */ >> + >> +typedef int (*callback_t) (void); >> + >> +extern int caller (callback_t callback); >> + >> +int >> +callback (void) >> +{ >> + return 1; >> +} >> + >> +int >> +main (void) >> +{ >> + return caller (callback); >> +} >> diff --git a/gdb/testsuite/gdb.base/backtrace-through-cu-nodebug.exp >> b/gdb/testsuite/gdb.base/backtrace-through-cu-nodebug.exp >> new file mode 100644 >> index 00000000000..7951ab41141 >> --- /dev/null >> +++ b/gdb/testsuite/gdb.base/backtrace-through-cu-nodebug.exp >> @@ -0,0 +1,90 @@ >> +# Copyright 2010-2024 Free Software Foundation, Inc. >> + >> +# This program is free software; you can redistribute it and/or modify >> +# it under the terms of the GNU General Public License as published by >> +# the Free Software Foundation; either version 3 of the License, or >> +# (at your option) any later version. >> +# >> +# This program is distributed in the hope that it will be useful, >> +# but WITHOUT ANY WARRANTY; without even the implied warranty of >> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >> +# GNU General Public License for more details. >> +# >> +# You should have received a copy of the GNU General Public License >> +# along with this program. If not, see . >> + >> +# Test that GDB can generate accurate backtraces even if some of the stack >> +# trace goes through a function with no debug information. >> + >> +standard_testfile -caller.c -main.c >> +set objmainfile ${testfile}-main.o >> +set objcallerfile ${testfile}-caller.o >> + >> +# recompile the inferior with or without CFI information, then run the >> +# inferior until the point where the important test starts >> +# returns TRUE on an ERROR. >> +proc prepare_test {has_cfi} { >> + global srcdir subdir srcfile srcfile2 objmainfile objcallerfile binfile >> + if {$has_cfi} { >> + set extension "cfi" >> + if {[gdb_compile "${srcdir}/${subdir}/${srcfile}" ${objcallerfile} \ >> + object [list {additional_flags=-fomit-frame-pointer \ >> + -funwind-tables -fasynchronous-unwind-tables}]] != "" } { >> + untested "couldn't compile with cfi" >> + return true >> + } >> + } else { >> + set extension "no-cfi" >> + if {[gdb_compile "${srcdir}/${subdir}/${srcfile}" ${objcallerfile} \ >> + object [list {additional_flags=-fomit-frame-pointer \ >> + -fno-unwind-tables \ >> + -fno-asynchronous-unwind-tables}]] != "" } { >> + untested "couldn't compile without cfi" >> + return true >> + } >> + } >> + if {[gdb_compile "${objmainfile} ${objcallerfile}" \ >> + "${binfile}-${extension}" binfile {}] != ""} { >> + untested "couldn't link object files" >> + return true >> + } >> + >> + clean_restart "$binfile-${extension}" >> + >> + with_test_prefix "${extension}" { >> + >> + if ![runto callback] then { >> + fail "has_cfi=$has_cfi: Can't run to callback" >> + return true >> + } >> + gdb_test_no_output "maint frame-unwinder disable ARCH" >> + return false >> + } >> +} >> + >> +if {[gdb_compile "${srcdir}/${subdir}/${srcfile2}" ${objmainfile} \ >> + object {debug}] != "" } { >> + untested "couldn't compile main file" >> + return >> +} >> + >> +if { [prepare_test false] } { >> + untested ${testfile}.exp >> +} else { >> + gdb_test "bt" "frame_unwind_find_by_frame failed.*" \ >> + "verify unwind fail without CFI" >> +} >> + >> +if { [prepare_test true] } { >> + untested ${testfile}.exp >> +} else { >> + if { [istarget "arm*-*-*"] } { >> + setup_kfail backtrace/31950 *-*-* >> + } >> + # #0 callback () at ... >> + # #1 0x00000000004004e9 in caller () >> + # #2 0x00000000004004cd in main () at ... >> + gdb_test "bt" \ >> + "#0 +callback \[^\r\n\]+\r\n#1 \[^\r\n\]+ in caller \[^\r\n\]+\r\n#2 >> \[^\r\n\]+ in main \[^\r\n\]+" \ >> + "verify unwinding works for CFI without DIEs" >> +} > You could do below to reduce the line to under 80 cols, I wonder why we don't have this defined somewhere > globally like "hex" or "decimal", though it's not really used that often. > > set r {[^\r\n]+} > gdb_test "bt" "#0 +callback $r+\r\n#1 $r+ in caller $r+\r\n#2> $r+ in main $r+" Thanks for the suggestion! I think calling it "r" makes things pretty hard to read, especially with how often it is followed by \r. I called it "text" instead, which makes the line 84 lines, but much more readable IMO. > >> -- >> 2.46.2 >> > Intel Deutschland GmbH > Registered Address: Am Campeon 10, 85579 Neubiberg, Germany > Tel: +49 89 99 8853-0, www.intel.de > Managing Directors: Sean Fennelly, Jeffrey Schneiderman, Tiffany Doon Silva > Chairperson of the Supervisory Board: Nicole Lau > Registered Office: Munich > Commercial Register: Amtsgericht Muenchen HRB 186928 > -- Cheers, Guinevere Larsen She/Her/Hers