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.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 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673049373; 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=EAZvCvK7nzEJ4KdUxCKKvWpBcPosRpAjJ4UeC058op0=; b=cMdmPAsRjRffh//B95zYYXMRt+bC/XFHlcDX9UBxn3V48xNcCvZZiSWOaSsMfXoE2ypR4t 7TOJa/WzGFLKgfbCPnMBEYCHmsV0nbyHxusoV6MdzXm5HECahqkIZs1ed6ZB3ggP4Rx02M cCvnJxTxBYcA9Gem5s5oLzQdY0tj3hs= 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) From: Aaron Merey 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 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true 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 List-Id: 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]" \ -- 2.39.0