From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id UMyaLy0Kq1+VGAAAWB0awg (envelope-from ) for ; Tue, 10 Nov 2020 16:46:21 -0500 Received: by simark.ca (Postfix, from userid 112) id B90D11F08E; Tue, 10 Nov 2020 16:46:21 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 802201E58E for ; Tue, 10 Nov 2020 16:46:20 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D8BEE3986834; Tue, 10 Nov 2020 21:46:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D8BEE3986834 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1605044779; bh=9bgxOqLOZGlwkQahFTiXEo/vU0l7PG0KZdIdUg8n6YY=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=R2pHD+uUeb75BaPtvvkLlcmWNuNogu0DO56r8yaxq/vH9bJ7wK7L6B5M5H3821cO4 FXNvnYTBjBP9MOshsk+fY/DYEHx81wZv61Glch4y5A/KM/2SwHRzJVFo14zmd/pWKv ogFuAAg4gaYqCyQzwRkhvfPAa5y8DAVmAjCplMKA= Received: from barracuda.ebox.ca (barracuda.ebox.ca [96.127.255.19]) by sourceware.org (Postfix) with ESMTPS id BD5BC3840C16 for ; Tue, 10 Nov 2020 21:46:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org BD5BC3840C16 X-ASG-Debug-ID: 1605044775-0c856e6cd571440001-fS2M51 Received: from smtp.ebox.ca (smtp.ebox.ca [96.127.255.82]) by barracuda.ebox.ca with ESMTP id s9EIHyTqDnZZ02Ks (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 10 Nov 2020 16:46:15 -0500 (EST) X-Barracuda-Envelope-From: simon.marchi@efficios.com X-Barracuda-RBL-Trusted-Forwarder: 96.127.255.82 Received: from epycamd.internal.efficios.com (192-222-181-218.qc.cable.ebox.net [192.222.181.218]) by smtp.ebox.ca (Postfix) with ESMTP id 95C26441D64; Tue, 10 Nov 2020 16:46:15 -0500 (EST) X-Barracuda-RBL-IP: 192.222.181.218 X-Barracuda-Effective-Source-IP: 192-222-181-218.qc.cable.ebox.net[192.222.181.218] X-Barracuda-Apparent-Source-IP: 192.222.181.218 To: gdb-patches@sourceware.org Subject: [PATCH 01/12] gdb: add inferior_execd observable Date: Tue, 10 Nov 2020 16:46:03 -0500 X-ASG-Orig-Subj: [PATCH 01/12] gdb: add inferior_execd observable Message-Id: <20201110214614.2842615-2-simon.marchi@efficios.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201110214614.2842615-1-simon.marchi@efficios.com> References: <20201110214614.2842615-1-simon.marchi@efficios.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Barracuda-Connect: smtp.ebox.ca[96.127.255.82] X-Barracuda-Start-Time: 1605044775 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://96.127.255.19:443/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at ebox.ca X-Barracuda-Scan-Msg-Size: 5003 X-Barracuda-BRTS-Status: 1 X-Barracuda-Spam-Score: 0.00 X-Barracuda-Spam-Status: No, SCORE=0.00 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=8.0 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.85785 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Simon Marchi via Gdb-patches Reply-To: Simon Marchi Cc: Simon Marchi Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" I want to add another action (clearing displaced stepping state) that happens when an inferior execs. I think it would be cleaner to have an observer for this event, rather than have infrun know about each other sub-component. Replace the calls to solib_create_inferior_hook and jit_inferior_created_hook in follow_exec by observers. gdb/ChangeLog: * observable.h (inferior_execd): Declare new observable. * observable.c (inferior_execd): Declare new observable. * infrun.c (follow_exec): Notify inferior_execd observer. * jit.c (jit_inferior_created_hook): Make static. (_initialize_jit): Register inferior_execd observer. * jit.h (jit_inferior_created_hook): Remove declaration. * solib.c (_initialize_solib): Register inferior_execd observer. Change-Id: I000cce00094e23baa67df693d912646b6ae38e44 --- gdb/infrun.c | 4 +--- gdb/jit.c | 9 +++++++-- gdb/jit.h | 7 ------- gdb/observable.c | 1 + gdb/observable.h | 3 +++ gdb/solib.c | 4 ++++ 6 files changed, 16 insertions(+), 12 deletions(-) diff --git a/gdb/infrun.c b/gdb/infrun.c index 990f40aa626..d59f6945285 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -1222,9 +1222,7 @@ follow_exec (ptid_t ptid, const char *exec_file_target) registers. */ target_find_description (); - solib_create_inferior_hook (0); - - jit_inferior_created_hook (inf); + gdb::observers::inferior_execd.notify (inf); breakpoint_re_set (); diff --git a/gdb/jit.c b/gdb/jit.c index fd24d539159..9deeed7ab59 100644 --- a/gdb/jit.c +++ b/gdb/jit.c @@ -49,6 +49,7 @@ static const char jit_break_name[] = "__jit_debug_register_code"; static const char jit_descriptor_name[] = "__jit_debug_descriptor"; +static void jit_inferior_created_hook (inferior *inf); static void jit_inferior_exit_hook (struct inferior *inf); /* An unwinder is registered for every gdbarch. This key is used to @@ -1230,9 +1231,12 @@ jit_inferior_init (inferior *inf) } } -/* See jit.h. */ +/* Looks for the descriptor and registration symbols and breakpoints + the registration function. If it finds both, it registers all the + already JITed code. If it has already found the symbols, then it + doesn't try again. */ -void +static void jit_inferior_created_hook (inferior *inf) { jit_inferior_init (inf); @@ -1337,6 +1341,7 @@ _initialize_jit () &setdebuglist, &showdebuglist); gdb::observers::inferior_created.attach (jit_inferior_created_hook); + gdb::observers::inferior_execd.attach (jit_inferior_created_hook); gdb::observers::inferior_exit.attach (jit_inferior_exit_hook); gdb::observers::breakpoint_deleted.attach (jit_breakpoint_deleted); diff --git a/gdb/jit.h b/gdb/jit.h index 6f972a6e077..96938060733 100644 --- a/gdb/jit.h +++ b/gdb/jit.h @@ -103,13 +103,6 @@ struct jited_objfile_data CORE_ADDR addr; }; -/* Looks for the descriptor and registration symbols and breakpoints - the registration function. If it finds both, it registers all the - already JITed code. If it has already found the symbols, then it - doesn't try again. */ - -extern void jit_inferior_created_hook (inferior *inf); - /* Re-establish the jit breakpoint(s). */ extern void jit_breakpoint_re_set (void); diff --git a/gdb/observable.c b/gdb/observable.c index 81aa392cc21..231f955fa26 100644 --- a/gdb/observable.c +++ b/gdb/observable.c @@ -43,6 +43,7 @@ DEFINE_OBSERVABLE (command_error); DEFINE_OBSERVABLE (target_changed); DEFINE_OBSERVABLE (executable_changed); DEFINE_OBSERVABLE (inferior_created); +DEFINE_OBSERVABLE (inferior_execd); DEFINE_OBSERVABLE (record_changed); DEFINE_OBSERVABLE (solib_loaded); DEFINE_OBSERVABLE (solib_unloaded); diff --git a/gdb/observable.h b/gdb/observable.h index 9114b28d04f..1dce6746ff3 100644 --- a/gdb/observable.h +++ b/gdb/observable.h @@ -89,6 +89,9 @@ extern observable<> executable_changed; information on the inferior has been printed. */ extern observable inferior_created; +/* The inferior INF has exec'ed a new executable file. */ +extern observable inferior_execd; + /* The status of process record for inferior inferior in gdb has changed. The process record is started if STARTED is true, and the process record is stopped if STARTED is false. diff --git a/gdb/solib.c b/gdb/solib.c index b11c6f38900..1f6e91599a5 100644 --- a/gdb/solib.c +++ b/gdb/solib.c @@ -1557,6 +1557,10 @@ _initialize_solib () solib_data = gdbarch_data_register_pre_init (solib_init); gdb::observers::free_objfile.attach (remove_user_added_objfile); + gdb::observers::inferior_execd.attach ([] (inferior *inf) + { + solib_create_inferior_hook (0); + }); add_com ("sharedlibrary", class_files, sharedlibrary_command, _("Load shared object library symbols for files matching REGEXP.")); -- 2.28.0