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 F010D385700D for ; Sat, 16 Sep 2023 10:18:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F010D385700D 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=1694859513; 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=PXZdRK78jhWsd/2ZAKhAnPq0knojLvnB0saH1NCuXVo=; b=GSNcYplhZGm/yajM82XEpS9o86CxzzjJ/MERp49yhcaC+PMs2rNyGE5NEbAZWdLaayuT0q croPO42exy137VgSYSMkT44oWVVlBJG7Gxo70bFnmncpKhr5tM1qlmPHT9Ox5JL0l0bXCm /BQpd4tWa6CWC4XV6BGD5jIa1sCMh/w= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-678-a4kWyCfROMeAE0M2TU5dMg-1; Sat, 16 Sep 2023 06:18:32 -0400 X-MC-Unique: a4kWyCfROMeAE0M2TU5dMg-1 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-40472855114so19598885e9.0 for ; Sat, 16 Sep 2023 03:18:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694859511; x=1695464311; 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=PXZdRK78jhWsd/2ZAKhAnPq0knojLvnB0saH1NCuXVo=; b=ReBggit+9nqWRuRBnp9rymvoKUS9CnRax9CeZVrhlRprXH/MA263Olzd7MtyHz7a3c mF/fvu35ZCuQh7lO9QDpV95cgV0OsrSNn+n9MMvfnNv4QrGqH9CtvvulTcBWCBo6BDZl ONMLvYNf3aOZt8Ud/e7FpO/Kex9TzqxYnejIRfq3tT/UWVS0MEP4mwjFaTTLqrvTygly fNm8BYRBdMHvlLAYHIqk1PO+b+2z7KJCqkns8YU5uuvuYZ1lWynHNjfFVkUzl42dCGZz 5d3PebcHGchG4q2i4CVaez4pIdJQGUtRRPrn3VyUurv+X9Q2T8CeO0ayCu3WZ2Pbvx0R rSyg== X-Gm-Message-State: AOJu0YzgqNiqJDtgv/ahi4jdWQOfxQOlb2FIzeltO+ZxUiH6/nUHDo5A P+Lna+Jg7VT1bn5Vhe4/aFLHDLMRpHoBvokwbuEVeFb3Todqpift2IodehvcSfa5m4qyyesXC9f fbQk/m1A7RqTIgPYTxPuRnvyBDFnkIflJFzM7who6CzpxBAPlsn4lu8bVM9GYEIrF+EYNvmNTwC +02mJFOg== X-Received: by 2002:a7b:cc84:0:b0:3fb:b3aa:1c8a with SMTP id p4-20020a7bcc84000000b003fbb3aa1c8amr3496587wma.16.1694859510773; Sat, 16 Sep 2023 03:18:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHsmACtQcmMg/RYmE2ajtLGbIrB1os089f2x05wkDUXIkjKupCCS4nFJJlD8Re738z+VhYX3A== X-Received: by 2002:a7b:cc84:0:b0:3fb:b3aa:1c8a with SMTP id p4-20020a7bcc84000000b003fbb3aa1c8amr3496573wma.16.1694859510427; Sat, 16 Sep 2023 03:18:30 -0700 (PDT) Received: from localhost (92.40.218.107.threembb.co.uk. [92.40.218.107]) by smtp.gmail.com with ESMTPSA id m10-20020a7bcb8a000000b003fed7fa6c00sm9906634wmi.7.2023.09.16.03.18.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Sep 2023 03:18:30 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCH 7/9] gdb: pass more arguments to the executable_changed observer Date: Sat, 16 Sep 2023 11:18:08 +0100 Message-Id: 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.1 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: This commit continues the work of the previous few commits. My goal is to expose the executable_changed observer through the Python API as an event. At this point adding executable_changed as an event to the Python API is trivial, but before I do that I would like to add some additional arguments to the observable, which currently has no arguments at all. The new arguments I wish to add are: 1. The program_space in which the executable was changed, and 2. A boolean flag that will indicate if the executable changed to a whole new path, or if GDB just spotted that the executable changed on disk (e.g. the user recompiled the executable). In this commit I change the signature of the observable and then pass the arguments through at the one place where this observable is notified. As there are (currently) no users of this observable nothing else needs updating. In the next commit I'll add a listener for this observable in the Python code, and expose this as an event in the Python API. Additionally, with this change, it should be possible to update the insight debugger to make use of this observable rather than using the deprecated_exec_file_display_hook (as it currently does), which will then allow this hook to be removed from GDB. There should be no user visible changes after this commit. --- gdb/exec.c | 11 ++++++++++- gdb/observable.h | 18 +++++++++++++----- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/gdb/exec.c b/gdb/exec.c index 07759725711..a1396c2aa3d 100644 --- a/gdb/exec.c +++ b/gdb/exec.c @@ -501,7 +501,16 @@ exec_file_attach (const char *filename, int from_tty) } bfd_cache_close_all (); - gdb::observers::executable_changed.notify (); + + /* Are are loading the same executable? */ + bfd *prev_bfd = exec_bfd_holder.get (); + bfd *curr_bfd = current_program_space->exec_bfd (); + bool reload_p = (((prev_bfd != nullptr) == (curr_bfd != nullptr)) + && (prev_bfd == nullptr + || (strcmp (bfd_get_filename (prev_bfd), + bfd_get_filename (curr_bfd)) == 0))); + + gdb::observers::executable_changed.notify (current_program_space, reload_p); } /* Process the first arg in ARGS as the new exec file. diff --git a/gdb/observable.h b/gdb/observable.h index c0bafc51f14..e5305fa081e 100644 --- a/gdb/observable.h +++ b/gdb/observable.h @@ -31,6 +31,7 @@ struct inferior; struct process_stratum_target; struct target_ops; struct trace_state_variable; +struct program_space; namespace gdb { @@ -60,11 +61,18 @@ extern observable signal_received; /* The target's register contents have changed. */ extern observable target_changed; -/* The executable being debugged by GDB has changed: The user - decided to debug a different program, or the program he was - debugging has been modified since being loaded by the debugger - (by being recompiled, for instance). */ -extern observable<> executable_changed; +/* The executable being debugged by GDB in PSPACE has changed: The user + decided to debug a different program, or the program he was debugging + has been modified since being loaded by the debugger (by being + recompiled, for instance). The path to the new executable can be found + by examining PSPACE->exec_filename. + + When RELOAD is true the path to the executable hasn't changed, but the + file does appear to have changed, so GDB reloaded it, e.g. if the user + recompiled the executable. when RELOAD is false then the path to the + executable has not changed. */ +extern observable executable_changed; /* gdb has just connected to an inferior. For 'run', gdb calls this observer while the inferior is still stopped at the entry-point -- 2.25.4