From patchwork Fri Jan 6 23:56:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Merey X-Patchwork-Id: 62825 Return-Path: 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 21AEF3858C1F for ; Fri, 6 Jan 2023 23:56:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 21AEF3858C1F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1673049397; bh=EAZvCvK7nzEJ4KdUxCKKvWpBcPosRpAjJ4UeC058op0=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=eKH191ZccnjjVtaeL+MPPXjOOXxlnkBfBBRaBs3FYuOyLq+/xCIhERXOt26mAOx1b FjFCrM0elxnXoW5iyeM+9ljjhkWzaEW/cEGPrUfPCfWRmiYZLkSeIyFWhYddAC2ZY3 Xne1C5lGZ6Sxrlv/JmGfXXxcIog8HBEBlVDRoXd4= 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.133.124]) by sourceware.org (Postfix) with ESMTPS id B82043858D35 for ; Fri, 6 Jan 2023 23:56:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B82043858D35 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-596-a-EjZh5RMZ61cgBaW3p0ew-1; Fri, 06 Jan 2023 18:56:12 -0500 X-MC-Unique: a-EjZh5RMZ61cgBaW3p0ew-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id F3A69801779 for ; Fri, 6 Jan 2023 23:56:11 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.34.83]) by smtp.corp.redhat.com (Postfix) with ESMTP id BDE9A492B00; Fri, 6 Jan 2023 23:56:11 +0000 (UTC) To: gdb-patches@sourceware.org Cc: Aaron Merey Subject: [PING*2][PATCH] gdb/linespec.c: Fix missing source file during breakpoint re-set Date: Fri, 6 Jan 2023 18:56:07 -0500 Message-Id: <20230106235607.498218-1-amerey@redhat.com> In-Reply-To: <20221021170720.27249-1-amerey@redhat.com> References: <20221021170720.27249-1-amerey@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.3 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-Patchwork-Original-From: Aaron Merey via Gdb-patches From: Aaron Merey Reply-To: Aaron Merey Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" Ping. I tweaked the testcase so that it applies to the master branch. Thanks, Aaron --- 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/testsuite/gdb.debuginfod/fetch_src_and_symbols.exp | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/gdb/linespec.c b/gdb/linespec.c index e9339c3338c..6db0f02e318 100644 --- a/gdb/linespec.c +++ b/gdb/linespec.c @@ -2283,13 +2283,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 6d5af1370b0..bfe6e639e4f 100644 --- a/gdb/testsuite/gdb.debuginfod/fetch_src_and_symbols.exp +++ b/gdb/testsuite/gdb.debuginfod/fetch_src_and_symbols.exp @@ -224,6 +224,15 @@ proc_with_prefix local_url { } { set lineno [gdb_get_line_number "Breakpoint here"] gdb_test "list $lineno" "return 0;\[^\r\n\]+Breakpoint here\\. .*" + # Verify that a breakpoint re-sets 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 "set cwd $debugdir" "" "file [file tail $binfile] cwd" + gdb_test_no_output "del breakpoint 1" + gdb_test "break $lineno" "Breakpoint 2 at.*file.*" + gdb_test "run" "Breakpoint 2.*" \ + "file [file tail $binfile] set breakpoint" + # GDB should now find the executable file. clean_restart gdb_test "core $::corefile" ".*return 0.*" "file [file tail $::corefile]" \