From patchwork Wed Sep 27 14:22:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 76766 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 7A7493861938 for ; Wed, 27 Sep 2023 14:22:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7A7493861938 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1695824563; bh=xXdVV19XEOQNZFTJ9C6xPgo4KpQOTE1+CO72pdQ9s0E=; 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=tMz5pPdAwE2uOtr4oSYlcmmOiTw9GSZlHBfpGz6S2dWMX2un69UvvxsHF+XhymUM/ 98NuxjJ6lSwTnNV3kgTnI4hrz5DBJ4H2a01SyR3/vT4uNu/i7ukjUYrtq517suI/8M Dv14lMpj+1pOHpE7hNfMA/uVtCbivGM7J2Zjvh10= 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 08DB53861807 for ; Wed, 27 Sep 2023 14:22:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 08DB53861807 Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-592-9VFJ7SSEOSm6dXNJ-4ublg-1; Wed, 27 Sep 2023 10:22:14 -0400 X-MC-Unique: 9VFJ7SSEOSm6dXNJ-4ublg-1 Received: by mail-qk1-f198.google.com with SMTP id af79cd13be357-774294bde69so861353085a.1 for ; Wed, 27 Sep 2023 07:22:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695824534; x=1696429334; 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:message-id:reply-to; bh=xXdVV19XEOQNZFTJ9C6xPgo4KpQOTE1+CO72pdQ9s0E=; b=G5oytxne2TyM4HZydffBJzrO28cOQE3D41iafZihiCZJ/uvV8lpaPEXJx9Q91G/eWt BApbk+uWYeGDLgUsCUTXY4eenJtNSLgX67q+AHdySKsMH+rVg7eIuyYgezxVpVT8UPJw E0GgjPF76WWKmeIegE4xtz7EILn9ZM9UXggBwvykg6TSNT8xw5rwXU54gz9wybwXgTRJ FJK0Qqo5m1YeBCH+Ij4NmF8WKhMMFsWpmkhtgp+C6BN/QQYiCbGdwquTnEL8Xinlw3Ea OK+hb7SZjju7JbtXM+LAWGvUe8L1/4SojxgzhQLlmrlJij3hUB8o54U23S41oPQ4zUlW rcdg== X-Gm-Message-State: AOJu0YyDHBkSqZBJoe+jttjeNKEoq2CzYo6aLxKrOLz80MwLDk1iIicJ gmxfLPPq5B5c5m8kB8W2SPBtAYMK5HlrtaTqoY5z3oEjUBLZOLl7uy6+phGrzr5Hata5UFF0R4d gWJqsl2Dork0uubFHTVz1w7v6ee3htt6A53pKZ1f+7xpzDC+Ak0uq7NvhRA0FgydGMbCJW5EcrI bL+qwP8Q== X-Received: by 2002:a05:620a:28ca:b0:767:ea44:daf9 with SMTP id l10-20020a05620a28ca00b00767ea44daf9mr6317245qkp.31.1695824533740; Wed, 27 Sep 2023 07:22:13 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFy9TkYrbhW2fEe92FNztBlUsMatOXvoivhYuKkXGvPn6C/+U5eubAIq/V7KAUiGpHVTHpliA== X-Received: by 2002:a05:620a:28ca:b0:767:ea44:daf9 with SMTP id l10-20020a05620a28ca00b00767ea44daf9mr6317210qkp.31.1695824533373; Wed, 27 Sep 2023 07:22:13 -0700 (PDT) Received: from localhost ([31.111.84.209]) by smtp.gmail.com with ESMTPSA id x2-20020a05620a14a200b007756e75b91bsm863828qkj.78.2023.09.27.07.22.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 07:22:13 -0700 (PDT) To: gdb-patches@sourceware.org Subject: [PATCH 2/5] gdb: use archive name in warning when appropriate Date: Wed, 27 Sep 2023 15:22:02 +0100 Message-Id: <0611bf29b93059df312acf56601cd45398e7dd0e.1695824275.git.aburgess@redhat.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.6 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_H3, RCVD_IN_MSPIKE_WL, 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.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Andrew Burgess via Gdb-patches From: Andrew Burgess Reply-To: Andrew Burgess Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" While working on some other patch I noticed that in reread_symbols there is a diagnostic message that can be printed, and in some cases we might use the wrong filename in the message. The code in question is checking to see if an objfile has changed on disk, we do this by stat-ing the on disk file and checking the mtime. If this file has been removed from disk then we print a message that the file has been removed, however, if the objfile is within an archive then we stat the archive itself, but then warn that the component within the archive has disappeared. I think it makes more sense to say that the archive has disappeared. The last related commit is this one: commit 02aeec7bde8ec8a04d14a5637e75f1c6ab899e23 Date: Tue Apr 27 21:01:30 2010 +0000 Check library name rather than member name when rereading symbols. Though this just makes the code to stat the archive unconditional, the code in question existed before this commit. However, the above commit doesn't include any tests, and seems to indicate that the problem being addressed was seen on Darwin. I'm not sure how to setup a test where GDB is using an objfile from within an archive, and so there's no tests for this commit... ... but if someone can let me know how I can setup a suitable test, please let me know and I'll try to get something working. --- gdb/symfile.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/gdb/symfile.c b/gdb/symfile.c index 19cf9c911f9..145621f3c67 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -2459,7 +2459,6 @@ reread_symbols (int from_tty) { long new_modtime; struct stat new_statbuf; - int res; std::vector new_objfiles; for (objfile *objfile : current_program_space->objfiles ()) @@ -2475,16 +2474,18 @@ reread_symbols (int from_tty) `ar', often called a `static library' on most systems, though a `shared library' on AIX is also an archive), then you should stat on the archive name, not member name. */ + const char *filename; if (objfile->obfd->my_archive) - res = stat (bfd_get_filename (objfile->obfd->my_archive), &new_statbuf); + filename = bfd_get_filename (objfile->obfd->my_archive); else - res = stat (objfile_name (objfile), &new_statbuf); + filename = objfile_name (objfile); + + int res = stat (filename, &new_statbuf); if (res != 0) { /* FIXME, should use print_sys_errmsg but it's not filtered. */ gdb_printf (_("`%ps' has disappeared; keeping its symbols.\n"), - styled_string (file_name_style.style (), - objfile_name (objfile))); + styled_string (file_name_style.style (), filename)); continue; } new_modtime = new_statbuf.st_mtime;