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 599353857738 for ; Sat, 16 Sep 2023 10:18:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 599353857738 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=1694859510; 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=UIvqNzS/LQCnCG2otzpw2EMXo9aDxeY+w9tnZF7xjQw=; b=Q4t/JzPrp3h6d6TxzDaj06LTrLzTAVGRmZOVH8704WCkMuzdALUuUSYysgqBsisEeApdyM sdRXe/Nsyb/k0eCp6sovJHgI6erUQm+waYBXzeQ6Gw7IQF/9nXJAKCFhLfThfEHWvMAV6o Jk/FmLJw+VDmt/fGJGKn1ehu4AZFfQo= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-594-AfFnwxMPNuKsKtixCeMpnA-1; Sat, 16 Sep 2023 06:18:26 -0400 X-MC-Unique: AfFnwxMPNuKsKtixCeMpnA-1 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-401d8873904so23957365e9.0 for ; Sat, 16 Sep 2023 03:18:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694859505; x=1695464305; 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=UIvqNzS/LQCnCG2otzpw2EMXo9aDxeY+w9tnZF7xjQw=; b=BAnYWypxluEPt4Y8OyIs4WgLfJIhgkCYMEmFkyUZ/2IeLYI9p5VPcoK3Kk6R8abMKl Np+NdbnRJtAjnlxlzY/w2zj9Agozt6RyfCZgPMHUp6kGNRb2HlDD35i3Gh4xstyiu1DG CQmfX3/nh44L0wCCaaK3t/pMggiVYQaarVg8+l4hHFLMVDPVQxD8Snv59B7XhMnAyY1V ByUptXpKGkjncaZMjaqsEihd8XwmPt97QZk2f7UC/dxnpaMz5O5B/dyy/KJwMWe/0ucr JQpsuwHppaPpaJuYH+sad1JSIWP1bNaFmXXECfXmoOGgDB5OtRs90bNFHZhrbyJ1FbPm 1poA== X-Gm-Message-State: AOJu0Yy+bSbduBuzhiNRQpBWeb0dulj46L4TlMu2xBh/6AiAyI061E8l LXpFQqnm+rV7x5GIMBTo5mcqZS5gCv8A/pzTOIHTIguwmjZv6KIRf0shrLYAmVIeq8LzPXtp+nx HkPH3wW3V9dALsYyw5gR+gbOXItlmDwa9jJC/kZAekltJDZtMwcc2GB813hswMCvN6dGN7rklfN Ov9+kmug== X-Received: by 2002:a05:6000:806:b0:320:82d:59a8 with SMTP id bt6-20020a056000080600b00320082d59a8mr212718wrb.62.1694859504734; Sat, 16 Sep 2023 03:18:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH3kD6rG4/1q2YOfLmwCMN0zH06FBf5mSAisvdHBYH0CHAWs+I8S690oSHTzRlnEZFPttViuw== X-Received: by 2002:a05:6000:806:b0:320:82d:59a8 with SMTP id bt6-20020a056000080600b00320082d59a8mr212710wrb.62.1694859504427; Sat, 16 Sep 2023 03:18:24 -0700 (PDT) Received: from localhost (92.40.218.107.threembb.co.uk. [92.40.218.107]) by smtp.gmail.com with ESMTPSA id k8-20020a5d5248000000b0031fc4c31d77sm6759053wrc.88.2023.09.16.03.18.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Sep 2023 03:18:24 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCH 4/9] gdb: remove one user of the executable changed observer Date: Sat, 16 Sep 2023 11:18:05 +0100 Message-Id: <5e9c1c90c7ba3adf0a7062285ec40617cd0ef14a.1694858967.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 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-10.2 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,RCVD_IN_SBL_CSS,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: My goal for the next few commits is to expose the executable_changed observable from the Python API. However, there is call to the executable_changed observable in the reread_symbols function (in symfile.c), and this doesn't actually correspond to the executable changing. My idea then, is to remove this use of the executable_changed observable, but, before I can do that, I need to check that nothing is going to break, and that requires my to think about the current users of this observable. One current user of executable_changed is in symtab.c. We add an executable_changed observer that calls: set_main_name (nullptr, language_unknown); to discard all information about the main function when the executable changes. However, changing the executable doesn't actually change the debug information. The debug information changes when the symbol-file changes, so I think this observer is in slightly the wrong place. The new_objfile observable is (unfortunately) overloaded, it is called when a new objfile is loaded, and also (when its argument is nullptr), when all debug information should be discarded. It turns out that there is already a new_objfile observer in symtab.c. I propose that, when the argument is nullptr (indicating all debug info should be discarded), that we should call set_main_name to discard the information about the main function. We can then remove the executable_changed observer from symtab.c. All tests still pass, and, in my local world, I added some debug printf calls, and I think we are still discarded the main information everywhere we need to. --- gdb/symtab.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/gdb/symtab.c b/gdb/symtab.c index c0c2454d967..2d446331ed1 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -100,6 +100,8 @@ static struct block_symbol enum block_enum block_index, const char *name, const domain_enum domain); +static void set_main_name (const char *name, enum language lang); + /* Type of the data stored on the program space. */ struct main_info @@ -1694,6 +1696,11 @@ symtab_new_objfile_observer (struct objfile *objfile) { /* Ideally we'd use OBJFILE->pspace, but OBJFILE may be NULL. */ symbol_cache_flush (current_program_space); + + /* When all objfiles have been removed (OBJFILE is nullptr), then forget + everything we know about the main function. */ + if (objfile == nullptr) + set_main_name (nullptr, language_unknown); } /* This module's 'free_objfile' observer. */ @@ -6329,15 +6336,6 @@ main_language (void) return info->language_of_main; } -/* Handle ``executable_changed'' events for the symtab module. */ - -static void -symtab_observer_executable_changed (void) -{ - /* NAME_OF_MAIN may no longer be the same, so reset it for now. */ - set_main_name (NULL, language_unknown); -} - /* Return 1 if the supplied producer string matches the ARM RealView compiler (armcc). */ @@ -7020,8 +7018,6 @@ the use of prologue scanners."), class_maintenance, 0, &maintenancelist); deprecate_cmd (c, "maintenancelist flush symbol-cache"); - gdb::observers::executable_changed.attach (symtab_observer_executable_changed, - "symtab"); gdb::observers::new_objfile.attach (symtab_new_objfile_observer, "symtab"); gdb::observers::free_objfile.attach (symtab_free_objfile_observer, "symtab"); } -- 2.25.4