From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 C0E673853825 for ; Fri, 21 Oct 2022 17:07:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C0E673853825 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-627-TEjbHljnPBSYk7hxq_JF-g-1; Fri, 21 Oct 2022 13:07:38 -0400 X-MC-Unique: TEjbHljnPBSYk7hxq_JF-g-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 12DE1185A7A8 for ; Fri, 21 Oct 2022 17:07:38 +0000 (UTC) Received: from localhost.localdomain (unknown [10.22.10.231]) by smtp.corp.redhat.com (Postfix) with ESMTP id B4054C15BA5; Fri, 21 Oct 2022 17:07:36 +0000 (UTC) From: Aaron Merey To: gdb-patches@sourceware.org Subject: [PATCH] gdb/linespec.c: Fix missing source file during breakpoint re-set Date: Fri, 21 Oct 2022 13:07:20 -0400 Message-Id: <20221021170720.27249-1-amerey@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 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=-11.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 Oct 2022 17:08:00 -0000 Ping. Reposting this patch with a couple tweaks suggested by Bruno. During breakpoint re-setting, the source_filename of an explicit_location_spec is used to lookup the symtabs associated with the breakpoint being re-set. This source_filename is compared with each known symtab filename in order to retrieve the breakpoint's symtabs. However the source_filename may have been originally copied from a symtab's fullname (the path where GDB found the source file) when the breakpoint was first created. If a breakpoint symtab's filename and fullname differ and there is no substitute-path rule that converts the fullname to the filename, this will cause a NOT_FOUND_ERROR to be thrown during re-setting. Fix this by using a symtab's filename to set the explicit_location_spec source_filename instead of the symtab's fullname. --- gdb/linespec.c | 4 ++-- .../gdb.debuginfod/fetch_src_and_symbols.exp | 11 +++++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/gdb/linespec.c b/gdb/linespec.c index 3db35998f7e..805c98ca201 100644 --- a/gdb/linespec.c +++ b/gdb/linespec.c @@ -2281,13 +2281,13 @@ convert_linespec_to_sals (struct linespec_state *state, linespec *ls) /* Make sure we have a filename for canonicalization. */ if (ls->explicit_loc.source_filename == NULL) { - const char *fullname = symtab_to_fullname (state->default_symtab); + const char *filename = state->default_symtab->filename; /* It may be more appropriate to keep DEFAULT_SYMTAB in its symtab form so that displaying SOURCE_FILENAME can follow the current FILENAME_DISPLAY_STRING setting. But as it is used only rarely it has been kept for code simplicity only in absolute form. */ - ls->explicit_loc.source_filename = xstrdup (fullname); + ls->explicit_loc.source_filename = xstrdup (filename); } } else diff --git a/gdb/testsuite/gdb.debuginfod/fetch_src_and_symbols.exp b/gdb/testsuite/gdb.debuginfod/fetch_src_and_symbols.exp index 9bffb3397ec..a6575f033e0 100644 --- a/gdb/testsuite/gdb.debuginfod/fetch_src_and_symbols.exp +++ b/gdb/testsuite/gdb.debuginfod/fetch_src_and_symbols.exp @@ -216,8 +216,15 @@ proc_with_prefix local_url { } { $enable_debuginfod_question "y" gdb_test_no_output "set substitute-path $outputdir /dev/null" \ "set substitute-path" - gdb_test "br main" "Breakpoint 1 at.*file.*" - gdb_test "l" ".*This program is distributed in the hope.*" + gdb_test "set cwd $debugdir" "" "file [file tail $binfile] cwd" + gdb_test "list 1" ".*This program is distributed in the hope.*" + + # Verify that breakpoints re-set correctly when the actual location + # of the source file in the debuginfod client cache differs from + # the contents of DW_AT_comp_dir and DW_AT_name. + gdb_test "break 25" "Breakpoint 1 at.*file.*" + gdb_test "run" "Breakpoint 1,.*" \ + "file [file tail $binfile] set breakpoint" # GDB should now find the executable file. clean_restart -- 2.37.3