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 4ABB73858420 for ; Tue, 2 Jan 2024 11:43:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4ABB73858420 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 4ABB73858420 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704195840; cv=none; b=gyWbO8hDrLiqSQ1GvvoCV3OXoR2Abr9wmbejrAimmmpyflOVBtuQhYSXgnOMZPRChN80zGx3ACbHQ6bg+UuPL2ZDvuI752tPuMzD+VVctbKshlnkMa/9HBZjt7gYmp85Ui+u8I23SiIHJ8NnXfernpeZ7sMtVDcexAn65vWXFVA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704195840; c=relaxed/simple; bh=2Yx+oqu3KyDpRykKVpRff2jR8XtGBYnpJhwo66hK784=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=laiPJrdwfKhhQNP5Ef7plfvMIE4v5QUwMR9fYY4L7dtyeHNEe6sDhHDIEA6Z4vSrCeWawnmAERpWysXc9i2gsgYT2BXqyzPtHEvac0zlke59Wyoo+nRxw0M363kKztL/NHKgCcFCIBSVDeVJdQewhHxJU7fWEi7zGWHzboe2BsQ= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1704195836; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=gRGTQctwcxEpnbQ5JVDsqXESqZvkKRuUIL84FXtVuTk=; b=P6KGbTAaBxA78ZqHtzqmqwz7+BiPgf8VyI0bIf6m3N/4Ibg4LtbepI75crCdHkanluxhZF NHPk6AeDN01ZX/oREFsUJodyFPVIU5QaUf+qNQok7P27STLzpkKuFD/gf6lcEhcWygxt7m msXq/UPWJVqofrPEcXtQ8WkPy8gzueQ= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-586-4Fi9BnepNMmqDTK4XgUIlA-1; Tue, 02 Jan 2024 06:43:55 -0500 X-MC-Unique: 4Fi9BnepNMmqDTK4XgUIlA-1 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-3370de320d0so2535376f8f.1 for ; Tue, 02 Jan 2024 03:43:55 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704195834; x=1704800634; h=mime-version:message-id:date:references:in-reply-to:subject:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=gRGTQctwcxEpnbQ5JVDsqXESqZvkKRuUIL84FXtVuTk=; b=aBctbNTqyIYWpbcjNfWbQ4jgO8/9woTOtmcKqc/n3wqfr029U5PErvKlTcE1KWgnNA eyWJi0DRJh5n/e/IkFfgIKlHVKZdUDlyupENhErr83GoN0CF+6wI2DaB2g2kMlheMW+P rW7/5/rxXRJRgKtA2cN3xQZQwI6SlCyydgyfII2lyr1ur/uwpBM/9Kf6cj3+ZaWlOW9r xG53t9/cFIs4QqmjVWwzCxl8qBfFNPAjOESIUGGFIp0eDUtm8fJtHdNTgcdS2PcTj8eM L0YIg+++VTrHxQExFq0y4QyEhYkUcddCfyn3dIL4LUbQTBzD3CM9ZlAKuHbAJ2X3IPJD NJ5A== X-Gm-Message-State: AOJu0YygcrwlHSkl2Kk8mvaoFE/g3lTm/6C0kVvw9VR+6dyTYzOiBgou uIbLgoZxlRKZMCyOQglCqvbaKim0axLP9iMklwB1el1iFLSde9Zd7HRoi7QpxLqpz+7eiv+hZOF FNxQvWLDQgzg/z2H370Hvhb+boJmMJas4Mjz35LYph8nrDAoPNGykbjShVP0dEsxKxYTD65K0UV zeFhBuSXmN X-Received: by 2002:a5d:690e:0:b0:333:6457:4468 with SMTP id t14-20020a5d690e000000b0033364574468mr6158156wru.113.1704195833830; Tue, 02 Jan 2024 03:43:53 -0800 (PST) X-Google-Smtp-Source: AGHT+IH+UtNoStk3twFLcf3+jp2j1gchwJuE4WACggtFr8rjV/NaeQ851MAq49n96se0C9NExAxIsg== X-Received: by 2002:a5d:690e:0:b0:333:6457:4468 with SMTP id t14-20020a5d690e000000b0033364574468mr6158150wru.113.1704195833287; Tue, 02 Jan 2024 03:43:53 -0800 (PST) Received: from localhost (185.223.159.143.dyn.plus.net. [143.159.223.185]) by smtp.gmail.com with ESMTPSA id d17-20020adffbd1000000b0033719111458sm11482019wrs.36.2024.01.02.03.43.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jan 2024 03:43:53 -0800 (PST) From: Andrew Burgess To: insight@sourceware.org Subject: Ping: Re: [PATCH] switch away from using specify_exec_file_hook In-Reply-To: <6abeb45e97d9004ec331e94cf2089af00553de76.1702379379.git.aburgess@redhat.com> References: <6abeb45e97d9004ec331e94cf2089af00553de76.1702379379.git.aburgess@redhat.com> Date: Tue, 02 Jan 2024 11:43:52 +0000 Message-ID: <877cks9czr.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-13.5 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,T_SCC_BODY_TEXT_LINE 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! Thanks, Andrew Andrew Burgess writes: > I had a go at testing this patch using make check-gdb > TESTS="gdb.gdbtk/*.exp", but ran into numerous errors, I suspect that > the gdbtk testing has not been run in a while, and it certainly > doesn't appear to have kept up with changes to the GDB testsuite. > > If there's any particular testing that I should be running then just > let me know. > > Otherwise, if we could merge this patch, then we can remove a couple > of functions from GDB that are only used to support this one hook. > > --- > > Stop using specify_exec_file_hook to spot when the executable GDB is > debugging changes, and instead use gdb::observers::executable_changed. > > The specify_exec_file_hook would call a function with the name of the > executable as specified by the user, so long as the name of the > executable wasn't empty, e.g.: > > (gdb) file exec_name > > would call the hook with 'exec_name', while: > > (gdb) file > > would not call the hook at all. > > The observer I'm proposing we switch too is slightly different. The > observer is called with the program_space in which the executable > changed, even in the empty filename case. The observer also receives > a flag which indicates if GDB is loading a new executable, or is > loading the same executable because the on-disk file changed. > > To reduce the chance of breakage, within insight, if the new observer > function is called in the empty filename case I don't call into the > TCL code, this ensures the TCL code is only called in the same cases a > previously. > > The TCL code will be called with the full path to the executable > rather than the partial string the user specified, however, the TCL > code would (in some cases at least) look up the full executable path > anyway, so I don't think the change should have a negative impact. > > For now I'm ignoring the reload_p flag, that is, I call into the TCL > code both when the executable has completely changed, and when it's > the same executable filename, but the on-disk file changed, I think > this matches the behaviour before this patch. > > And finally, while looking at the TCL code, I spotted that a comment > in interface.tcl relating to this code was slightly out of date, I've > updated the comment. > --- > gdbtk/generic/gdbtk-hooks.c | 16 +++++++++++----- > gdbtk/library/interface.tcl | 2 +- > 2 files changed, 12 insertions(+), 6 deletions(-) > > diff --git a/gdbtk/generic/gdbtk-hooks.c b/gdbtk/generic/gdbtk-hooks.c > index 75e89e7..fe42e7d 100644 > --- a/gdbtk/generic/gdbtk-hooks.c > +++ b/gdbtk/generic/gdbtk-hooks.c > @@ -83,7 +83,7 @@ static void gdbtk_trace_start_stop (int, int); > static void gdbtk_attach (void); > static void gdbtk_detach (void); > static void gdbtk_file_changed (const char *); > -static void gdbtk_exec_file_display (const char *); > +static void gdbtk_executable_changed (program_space *, bool); > static void gdbtk_call_command (struct cmd_list_element *, const char *, int); > static void gdbtk_target_pre_wait (ptid_t ptid); > static void gdbtk_target_post_wait (ptid_t event_ptid); > @@ -140,6 +140,8 @@ gdbtk_add_hooks (void) > "gdbtk-hooks"); > gdb::observers::target_post_wait.attach (gdbtk_target_post_wait, > "gdbtk-hooks"); > + gdb::observers::executable_changed.attach (gdbtk_executable_changed, > + "gdbtk-hooks"); > > /* Hooks */ > deprecated_call_command_hook = gdbtk_call_command; > @@ -157,7 +159,6 @@ gdbtk_add_hooks (void) > deprecated_pre_add_symbol_hook = gdbtk_pre_add_symbol; > deprecated_post_add_symbol_hook = gdbtk_post_add_symbol; > deprecated_file_changed_hook = gdbtk_file_changed; > - specify_exec_file_hook (gdbtk_exec_file_display); > > deprecated_attach_hook = gdbtk_attach; > deprecated_detach_hook = gdbtk_detach; > @@ -732,11 +733,16 @@ gdbtk_file_changed (const char *filename) > gdbtk_two_elem_cmd ("gdbtk_tcl_file_changed", filename); > } > > -/* Called from exec_file_command */ > +/* Called from exec_file_attach when the executable changes. PSPACE is > + the program space in which the executable was changed. RELOAD_P is > + true if the executable didn't actually change, but instead GDB detected > + that the on-disk file change, so reloaded the current executable. */ > static void > -gdbtk_exec_file_display (const char *filename) > +gdbtk_executable_changed (program_space *pspace, bool reload_p) > { > - gdbtk_two_elem_cmd ("gdbtk_tcl_exec_file_display", filename); > + if (pspace->exec_filename.get () != nullptr) > + gdbtk_two_elem_cmd ("gdbtk_tcl_exec_file_display", > + pspace->exec_filename.get ()); > } > > /* Called from error_begin, this hook is used to warn the gui > diff --git a/gdbtk/library/interface.tcl b/gdbtk/library/interface.tcl > index c69e2f0..da0bcae 100644 > --- a/gdbtk/library/interface.tcl > +++ b/gdbtk/library/interface.tcl > @@ -798,7 +798,7 @@ proc gdbtk_tcl_file_changed {filename} { > > # ------------------------------------------------------------------ > # PROCEDURE: gdbtk_tcl_exec_file_display > -# This hook is called from exec_file_command. It's purpose > +# This hook is called from exec_file_attach. It's purpose > # is to setup the gui for a new file. Note that we cannot > # look for main, since this hook is called BEFORE we > # read symbols. If the user used the "file" command, > > base-commit: 0b35bf269b3625d05764ebaeec45b32a2ac03321 > -- > 2.25.4