| Message ID | 337887b9594348c5880b7adbc0850e72e319e857.1664721741.git.aburgess@redhat.com |
|---|---|
| State | Superseded |
| Headers |
Return-Path: <gdb-patches-bounces+patchwork=sourceware.org@sourceware.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 707BF385841F for <patchwork@sourceware.org>; Sun, 2 Oct 2022 14:44:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 707BF385841F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1664721867; bh=U8aBV/WZVAaEpBNnxwM4rzanhS4ZQB/B2FAktv605Jg=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=OH7tRO41wNrWp0+NMh59M8VHL7Y0mA6UQuRSJqe3rrGtqe2WgUxiNhB9F6Wbf7TTU d/5H0RC5Hs0MEhdkswLjH57S7Gdkq2QRd+njxxTB1hsTjzTOpCBt8xASGSHHQeg4BP hS0pN1yvGNgTPQKe7vb/DlthZlKjOSJXCLljXInw= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 9A7193858C2C for <gdb-patches@sourceware.org>; Sun, 2 Oct 2022 14:44:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9A7193858C2C Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-643-VbxFZheMMxWMLf895aXKTA-1; Sun, 02 Oct 2022 10:44:02 -0400 X-MC-Unique: VbxFZheMMxWMLf895aXKTA-1 Received: by mail-wm1-f70.google.com with SMTP id n32-20020a05600c3ba000b003b5054c71faso7647801wms.9 for <gdb-patches@sourceware.org>; Sun, 02 Oct 2022 07:44:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=U8aBV/WZVAaEpBNnxwM4rzanhS4ZQB/B2FAktv605Jg=; b=xm14/p4AnXc39eZisJHxErL1TMADnby+FQV95b5mjm1njdb4nRL8LsU/FjQy8AVa7e SOufyYtIStu2f1wpQgtymz+VcO2pOjOePdTPhfJVdEJEV2B3zhYBCMEMNRVV4X/Gwp/K vIUr1o4uuiRIeuGlNDULBJzCv/PFL681MXJvJb7aw6UuAMJA3iXEVcTZJa/mLmqEhcxc jljy4/tzUHfzyTfdZcmlEPTmAdEgiqUjmVMP4zegQ9tMqxdO+3YBl7FpAkoCPG2YQ9NZ w1SusSViLIOX1TmLeWqZLZJ6RJO/T3p0mDw4rxejzsS/QEnPAoiDYnOs0vCZ76NzB4j7 0uJg== X-Gm-Message-State: ACrzQf0TbqFRINCcgeO8VKQwHu5xqA645rjI9WfoTgwjgGa6OH8lZaUX vEA3FjE/e7nnOdGYgHmFsQBIu60qaG+fokQcnf2K/D8L8dTxc25L1Nsn287Yd+zYlIg9XMMfEtr cxvJQ09YImL/7HDfb5vCS+g0VUxQiZ5CuNFOBeEI0QY/DFd6KlQ0q0lic9Mwl+b0TUGy05cJxSQ == X-Received: by 2002:a05:6000:1561:b0:22a:72a1:e3f1 with SMTP id 1-20020a056000156100b0022a72a1e3f1mr11109400wrz.456.1664721840602; Sun, 02 Oct 2022 07:44:00 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6yrmb/sR7TTblEVttA7bLMmsvHwqeXJPyL6bZCfc/F0QAeaw+w1iUSdV4jMOnJJcLc1CcZuQ== X-Received: by 2002:a05:6000:1561:b0:22a:72a1:e3f1 with SMTP id 1-20020a056000156100b0022a72a1e3f1mr11109392wrz.456.1664721840349; Sun, 02 Oct 2022 07:44:00 -0700 (PDT) Received: from localhost (52.72.115.87.dyn.plus.net. [87.115.72.52]) by smtp.gmail.com with ESMTPSA id h40-20020a05600c49a800b003b49ab8ff53sm8424200wmp.8.2022.10.02.07.43.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 Oct 2022 07:44:00 -0700 (PDT) To: gdb-patches@sourceware.org Subject: [PATCH 1/2] gdb/testsuite: avoid creating files in gdb/testsuite directory Date: Sun, 2 Oct 2022 15:43:56 +0100 Message-Id: <337887b9594348c5880b7adbc0850e72e319e857.1664721741.git.aburgess@redhat.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <cover.1664721741.git.aburgess@redhat.com> References: <cover.1664721741.git.aburgess@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-10.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list <gdb-patches.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/gdb-patches>, <mailto:gdb-patches-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/gdb-patches/> List-Post: <mailto:gdb-patches@sourceware.org> List-Help: <mailto:gdb-patches-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/gdb-patches>, <mailto:gdb-patches-request@sourceware.org?subject=subscribe> From: Andrew Burgess via Gdb-patches <gdb-patches@sourceware.org> Reply-To: Andrew Burgess <aburgess@redhat.com> Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" <gdb-patches-bounces+patchwork=sourceware.org@sourceware.org> |
| Series |
Cleanup testsuite temporary files
|
|
Commit Message
Andrew Burgess
Oct. 2, 2022, 2:43 p.m. UTC
I spotted that the test gdb.dwarf2/dw2-using-debug-str.exp was creating an output file (called debug_str_section) in the root build/gdb/testsuite directory instead of using the build/gdb/testsuite/output/gdb.dwarf2/dw2-using-debug-str/ directory. This is a result of not using standard_output_file in the test script. With this commit the file is now placed in the expected output directory. The test still passes for me. --- gdb/testsuite/gdb.dwarf2/dw2-using-debug-str.exp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
Comments
Hi Andrew, On Sun, Oct 02, 2022 at 03:43:56PM +0100, Andrew Burgess via Gdb-patches wrote: > I spotted that the test gdb.dwarf2/dw2-using-debug-str.exp was > creating an output file (called debug_str_section) in the root > build/gdb/testsuite directory instead of using the > build/gdb/testsuite/output/gdb.dwarf2/dw2-using-debug-str/ directory. > > This is a result of not using standard_output_file in the test > script. > > With this commit the file is now placed in the expected output > directory. The test still passes for me. > --- > gdb/testsuite/gdb.dwarf2/dw2-using-debug-str.exp | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/gdb/testsuite/gdb.dwarf2/dw2-using-debug-str.exp b/gdb/testsuite/gdb.dwarf2/dw2-using-debug-str.exp > index d27554f2f89..729961c99b5 100644 > --- a/gdb/testsuite/gdb.dwarf2/dw2-using-debug-str.exp > +++ b/gdb/testsuite/gdb.dwarf2/dw2-using-debug-str.exp > @@ -105,7 +105,8 @@ gdb_test "p global_var" " = \\{aa = 0, bb = 0, cc = 0\\}" > # cc-with-dwz-m.exp and cc-with-gnu-debuglink.exp. Handle this by > # skipping the remainder of the test-case. > set debug_str_section "${binfile}-debug-str" > -set args "--dump-section .debug_str=debug_str_section $binfile" > +set debug_str_file [standard_output_file "debug_str_section"] > +set args "--dump-section .debug_str=${debug_str_file} $binfile" Just above your change, there is the following line: set debug_str_section "${binfile}-debug-str" I believe that the original intent was to use this as output file name, but the '$' was use in the set args line. It looks to me that the change should be: -set args "--dump-section .debug_str=debug_str_section $binfile" +set args "--dump-section .debug_str=$debug_str_section $binfile" If you prefer your change, the `set debug_str_section` line should be removed. Best, Lancelot. > set result [remote_exec host "[gdb_find_objcopy] $args"] > set status [lindex $result 0] > set output [lindex $result 1] > -- > 2.25.4 >
Lancelot SIX <lsix@lancelotsix.com> writes: > Hi Andrew, > > On Sun, Oct 02, 2022 at 03:43:56PM +0100, Andrew Burgess via Gdb-patches wrote: >> I spotted that the test gdb.dwarf2/dw2-using-debug-str.exp was >> creating an output file (called debug_str_section) in the root >> build/gdb/testsuite directory instead of using the >> build/gdb/testsuite/output/gdb.dwarf2/dw2-using-debug-str/ directory. >> >> This is a result of not using standard_output_file in the test >> script. >> >> With this commit the file is now placed in the expected output >> directory. The test still passes for me. >> --- >> gdb/testsuite/gdb.dwarf2/dw2-using-debug-str.exp | 3 ++- >> 1 file changed, 2 insertions(+), 1 deletion(-) >> >> diff --git a/gdb/testsuite/gdb.dwarf2/dw2-using-debug-str.exp b/gdb/testsuite/gdb.dwarf2/dw2-using-debug-str.exp >> index d27554f2f89..729961c99b5 100644 >> --- a/gdb/testsuite/gdb.dwarf2/dw2-using-debug-str.exp >> +++ b/gdb/testsuite/gdb.dwarf2/dw2-using-debug-str.exp >> @@ -105,7 +105,8 @@ gdb_test "p global_var" " = \\{aa = 0, bb = 0, cc = 0\\}" >> # cc-with-dwz-m.exp and cc-with-gnu-debuglink.exp. Handle this by >> # skipping the remainder of the test-case. >> set debug_str_section "${binfile}-debug-str" >> -set args "--dump-section .debug_str=debug_str_section $binfile" >> +set debug_str_file [standard_output_file "debug_str_section"] >> +set args "--dump-section .debug_str=${debug_str_file} $binfile" > > Just above your change, there is the following line: > > set debug_str_section "${binfile}-debug-str" > > I believe that the original intent was to use this as output file name, > but the '$' was use in the set args line. > > It looks to me that the change should be: > > -set args "--dump-section .debug_str=debug_str_section $binfile" > +set args "--dump-section .debug_str=$debug_str_section $binfile" > > If you prefer your change, the `set debug_str_section` line should be > removed. Good spot. Updated patch below. Thanks, Andrew --- commit 8e855f184d30f17a7bd0638f6cb8ee211be789e2 Author: Andrew Burgess <aburgess@redhat.com> Date: Sun Oct 2 15:18:15 2022 +0100 gdb/testsuite: avoid creating files in gdb/testsuite directory I spotted that the test gdb.dwarf2/dw2-using-debug-str.exp was creating an output file called debug_str_section in the root build/gdb/testsuite directory instead of using the build/gdb/testsuite/output/gdb.dwarf2/dw2-using-debug-str/ directory. This appears to be caused by a missing '$' character. We setup a variable debug_str_section which contains a path within the output directory, but then when we build the objcopy command we use 'debug_str_section' without a '$' prefix, as a result, we create the debug_str_section file. This commit adds the missing '$', the file is now created in the output directory. diff --git a/gdb/testsuite/gdb.dwarf2/dw2-using-debug-str.exp b/gdb/testsuite/gdb.dwarf2/dw2-using-debug-str.exp index d27554f2f89..4d1c49044d5 100644 --- a/gdb/testsuite/gdb.dwarf2/dw2-using-debug-str.exp +++ b/gdb/testsuite/gdb.dwarf2/dw2-using-debug-str.exp @@ -105,7 +105,7 @@ gdb_test "p global_var" " = \\{aa = 0, bb = 0, cc = 0\\}" # cc-with-dwz-m.exp and cc-with-gnu-debuglink.exp. Handle this by # skipping the remainder of the test-case. set debug_str_section "${binfile}-debug-str" -set args "--dump-section .debug_str=debug_str_section $binfile" +set args "--dump-section .debug_str=${debug_str_section} $binfile" set result [remote_exec host "[gdb_find_objcopy] $args"] set status [lindex $result 0] set output [lindex $result 1]
On 2022-10-03 5:06 p.m., Andrew Burgess via Gdb-patches wrote: > Lancelot SIX <lsix@lancelotsix.com> writes: > >> Just above your change, there is the following line: >> >> set debug_str_section "${binfile}-debug-str" >> >> I believe that the original intent was to use this as output file name, >> but the '$' was use in the set args line. >> >> It looks to me that the change should be: >> >> -set args "--dump-section .debug_str=debug_str_section $binfile" >> +set args "--dump-section .debug_str=$debug_str_section $binfile" >> >> If you prefer your change, the `set debug_str_section` line should be >> removed. > > Good spot. > > Updated patch below. I'm glad you guys found this alternative approach. I was going to suggest to see if we could avoid changing directory, the "cd" approach IMO should be avoided if possible. The reason is that when you change gdb's directory to the test's output dir, if GDB crashes and produces a core on teardown, then that core will end up in the test's output directory, and thus won't be noticed by the spurious core detection, i.e., won't be signaled in gdb.sum.
Pedro Alves <pedro@palves.net> writes: > On 2022-10-03 5:06 p.m., Andrew Burgess via Gdb-patches wrote: >> Lancelot SIX <lsix@lancelotsix.com> writes: >> > >>> Just above your change, there is the following line: >>> >>> set debug_str_section "${binfile}-debug-str" >>> >>> I believe that the original intent was to use this as output file name, >>> but the '$' was use in the set args line. >>> >>> It looks to me that the change should be: >>> >>> -set args "--dump-section .debug_str=debug_str_section $binfile" >>> +set args "--dump-section .debug_str=$debug_str_section $binfile" >>> >>> If you prefer your change, the `set debug_str_section` line should be >>> removed. >> >> Good spot. >> >> Updated patch below. > > I'm glad you guys found this alternative approach. I was going to suggest > to see if we could avoid changing directory, the "cd" approach IMO should be > avoided if possible. The reason is that when you change gdb's directory to > the test's output dir, if GDB crashes and produces a core on teardown, then that core will > end up in the test's output directory, and thus won't be noticed by the spurious core > detection, i.e., won't be signaled in gdb.sum. Unfortunately, there were two temporary file issues, the first of these never used 'cd', and that's the one Lancelot commented on, and I've updated. The second patch, which is still on the table right now, uses 'cd'. However, I'll take your comment as feedback on patch 2/2 and see if I can come up with a better fix. Thanks, Andrew
Pedro Alves <pedro@palves.net> writes: > On 2022-10-03 5:06 p.m., Andrew Burgess via Gdb-patches wrote: >> Lancelot SIX <lsix@lancelotsix.com> writes: >> > >>> Just above your change, there is the following line: >>> >>> set debug_str_section "${binfile}-debug-str" >>> >>> I believe that the original intent was to use this as output file name, >>> but the '$' was use in the set args line. >>> >>> It looks to me that the change should be: >>> >>> -set args "--dump-section .debug_str=debug_str_section $binfile" >>> +set args "--dump-section .debug_str=$debug_str_section $binfile" >>> >>> If you prefer your change, the `set debug_str_section` line should be >>> removed. >> >> Good spot. >> >> Updated patch below. > > I'm glad you guys found this alternative approach. I was going to suggest > to see if we could avoid changing directory, the "cd" approach IMO should be > avoided if possible. The reason is that when you change gdb's directory to > the test's output dir, if GDB crashes and produces a core on teardown, then that core will > end up in the test's output directory, and thus won't be noticed by the spurious core > detection, i.e., won't be signaled in gdb.sum. What if I added a mechanism to lib/gdb.exp that allowed for something like: with_change_gdb_directory $some_directory { # A set of tests here... } and had the with_change_gdb_directory proc check that GDB was still running at the end of the block. This way, when the test script ends, and GDB is shutdown, we will always be back in the original directory, so a crash on teardown will be spotted (via the coredump). And if GDB crashes during the inner block, then yes, the coredump will be in the "wrong" place, but we should be guaranteed to see a test failure. Would something like this be acceptable? My other idea is to have 'maint selftest' take an extra argument like: (gdb) maint selftest --temp-directory /path/to/directory which would then be used by the individual tests when creating temporary files. Thoughts? Thanks, Andrew
On 2022-10-04 10:08 a.m., Andrew Burgess wrote: > Pedro Alves <pedro@palves.net> writes: >> I'm glad you guys found this alternative approach. I was going to suggest >> to see if we could avoid changing directory, the "cd" approach IMO should be >> avoided if possible. The reason is that when you change gdb's directory to >> the test's output dir, if GDB crashes and produces a core on teardown, then that core will >> end up in the test's output directory, and thus won't be noticed by the spurious core >> detection, i.e., won't be signaled in gdb.sum. > > What if I added a mechanism to lib/gdb.exp that allowed for something > like: > > with_change_gdb_directory $some_directory { > # A set of tests here... > } > > and had the with_change_gdb_directory proc check that GDB was still > running at the end of the block. > > This way, when the test script ends, and GDB is shutdown, we will always > be back in the original directory, so a crash on teardown will be > spotted (via the coredump). > > And if GDB crashes during the inner block, then yes, the coredump will > be in the "wrong" place, but we should be guaranteed to see a test > failure. > > Would something like this be acceptable? Yes, I think that is sufficient in practice. I'm happy with that. Thanks, Pedro Alves > > My other idea is to have 'maint selftest' take an extra argument like: > > (gdb) maint selftest --temp-directory /path/to/directory > > which would then be used by the individual tests when creating temporary > files. > > Thoughts? > > Thanks, > Andrew >
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-using-debug-str.exp b/gdb/testsuite/gdb.dwarf2/dw2-using-debug-str.exp index d27554f2f89..729961c99b5 100644 --- a/gdb/testsuite/gdb.dwarf2/dw2-using-debug-str.exp +++ b/gdb/testsuite/gdb.dwarf2/dw2-using-debug-str.exp @@ -105,7 +105,8 @@ gdb_test "p global_var" " = \\{aa = 0, bb = 0, cc = 0\\}" # cc-with-dwz-m.exp and cc-with-gnu-debuglink.exp. Handle this by # skipping the remainder of the test-case. set debug_str_section "${binfile}-debug-str" -set args "--dump-section .debug_str=debug_str_section $binfile" +set debug_str_file [standard_output_file "debug_str_section"] +set args "--dump-section .debug_str=${debug_str_file} $binfile" set result [remote_exec host "[gdb_find_objcopy] $args"] set status [lindex $result 0] set output [lindex $result 1]