From patchwork Thu Sep 28 14:00:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 76842 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 870763865C15 for ; Thu, 28 Sep 2023 14:01:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 870763865C15 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1695909684; bh=xXdVV19XEOQNZFTJ9C6xPgo4KpQOTE1+CO72pdQ9s0E=; 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=kciXBR2yhXgmdBh44mVI80p9orIFk+QxQYevbWzOM510KIhLQazpaTUqIZoII4Mx0 fvzNUXYqVj2/0KWkGcn8/YLF4plYy40TjyonO9u+WWeroX704B5eRAl7yw1nJKfoYS 5cVf+/5B0r+B/pjpa74JWZ4fDL7ZwD/ymyi6Hb08= 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 A622B38618FA for ; Thu, 28 Sep 2023 14:00:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A622B38618FA Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-577-4n8O-WGCMluhERU2tUrL4w-1; Thu, 28 Sep 2023 10:00:53 -0400 X-MC-Unique: 4n8O-WGCMluhERU2tUrL4w-1 Received: by mail-qv1-f72.google.com with SMTP id 6a1803df08f44-65afb74699eso179209246d6.3 for ; Thu, 28 Sep 2023 07:00:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695909653; x=1696514453; 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=A+/VIAZ/s0YG3LzeFVjx0IhFEEPVSox/wztqJVzC66PMu3tQTV/WRal+YHj8vO6Vin WKkPKDtq4IjYziHZa0FBZJEqmAUC2pv88BSImrEeDy5OfATsd48Fb7OoX1D2fykIkt2x 1QWS07d0YkIgj//QokOBRoyJXL+3nECVhexNlGZCJ/8OSL1t5atV2nI5IatI/VtOdQrC iLlYGZIo/5lnRk4YpHKPj5UKVqyQTjsCM2AzNvIiDLQ3ex29sSBzLY3ie0at0aIyEmaw 5mr7WzhrZnh0grj3spIZau8xIg3evEtLbR9TUnS+NY8iD8cwRpyJqOZdCeOGuFA7wh4c +brw== X-Gm-Message-State: AOJu0Yw9H5J7UlmimBe6Y9fa6nJBM28bSITd/vy39i0w48pp/Zo/9D/U p3Q9EoaWwNukp3GUrEk1r3+dGI46o5mMm7cOM+nP+L1kUA0PuN4k99LtXBX/hT88YRX0ji8o63C r//MpymVySjCUqOxXQGcRjM4Azqh6ZCNfoAGKWsalHTztvdlT1j0OjowHo1ouWul1g9Ez+a6S+i 5pkOxywQ== X-Received: by 2002:a0c:f087:0:b0:65b:a66:3109 with SMTP id g7-20020a0cf087000000b0065b0a663109mr1345640qvk.8.1695909653104; Thu, 28 Sep 2023 07:00:53 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHrJIlJ1IQOPrf2mY65wDCmu9mIP9xxxmOg4mdtyc+qBEp5ayN5fKBxrbCRmehcWj5nTd7TNQ== X-Received: by 2002:a0c:f087:0:b0:65b:a66:3109 with SMTP id g7-20020a0cf087000000b0065b0a663109mr1345596qvk.8.1695909652659; Thu, 28 Sep 2023 07:00:52 -0700 (PDT) Received: from localhost ([31.111.84.209]) by smtp.gmail.com with ESMTPSA id n6-20020a0ce486000000b0065cfb75fe81sm1332083qvl.67.2023.09.28.07.00.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Sep 2023 07:00:52 -0700 (PDT) To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCHv2 2/5] gdb: use archive name in warning when appropriate Date: Thu, 28 Sep 2023 15:00:41 +0100 Message-Id: <0611bf29b93059df312acf56601cd45398e7dd0e.1695909469.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_H4, 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;