From: Simon Marchi via Gdb-patches <gdb-patches@sourceware.org>
To: gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@efficios.com>
Subject: [PATCH 01/12] gdb: add inferior_execd observable
Date: Tue, 10 Nov 2020 16:46:03 -0500 [thread overview]
Message-ID: <20201110214614.2842615-2-simon.marchi@efficios.com> (raw)
In-Reply-To: <20201110214614.2842615-1-simon.marchi@efficios.com>
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 */* inferior */> inferior_created;
+/* The inferior INF has exec'ed a new executable file. */
+extern observable<struct inferior */* inf */> 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
next prev parent reply other threads:[~2020-11-10 21:46 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-10 21:46 [PATCH 00/12] Concurrent displaced stepping Simon Marchi via Gdb-patches
2020-11-10 21:46 ` Simon Marchi via Gdb-patches [this message]
2020-11-25 1:28 ` [PATCH 01/12] gdb: add inferior_execd observable Pedro Alves
2020-11-10 21:46 ` [PATCH 02/12] gdb: clear inferior displaced stepping state on exec Simon Marchi via Gdb-patches
2020-11-25 1:28 ` Pedro Alves
2020-12-01 4:27 ` Simon Marchi
2020-11-10 21:46 ` [PATCH 03/12] gdb: rename things related to step over chains Simon Marchi via Gdb-patches
2020-11-25 1:28 ` Pedro Alves
2020-11-25 13:16 ` Simon Marchi via Gdb-patches
2020-11-10 21:46 ` [PATCH 04/12] gdb: rename displaced_step_closure to displaced_step_copy_insn_closure Simon Marchi via Gdb-patches
2020-11-25 1:29 ` Pedro Alves
2020-11-10 21:46 ` [PATCH 05/12] gdb: rename displaced_step_fixup to displaced_step_finish Simon Marchi via Gdb-patches
2020-11-25 1:29 ` Pedro Alves
2020-11-10 21:46 ` [PATCH 06/12] gdb: introduce status enum for displaced step prepare/finish Simon Marchi via Gdb-patches
2020-11-11 23:36 ` Andrew Burgess
2020-11-25 13:17 ` Simon Marchi via Gdb-patches
2020-11-25 1:30 ` Pedro Alves
2020-11-25 13:20 ` Simon Marchi via Gdb-patches
2020-11-10 21:46 ` [PATCH 07/12] gdb: pass inferior to get_linux_inferior_data Simon Marchi via Gdb-patches
2020-11-25 1:30 ` Pedro Alves
2020-11-10 21:46 ` [PATCH 08/12] gdb: move displaced stepping types to displaced-stepping.{h, c} Simon Marchi via Gdb-patches
2020-11-25 1:30 ` Pedro Alves
2020-11-10 21:46 ` [PATCH 09/12] gdb: move displaced stepping logic to gdbarch, allow starting concurrent displaced steps Simon Marchi via Gdb-patches
2020-11-25 1:40 ` Pedro Alves
2020-11-25 19:29 ` Simon Marchi via Gdb-patches
2020-11-25 19:35 ` Simon Marchi
2020-11-26 14:25 ` Pedro Alves
2020-11-30 19:13 ` Simon Marchi via Gdb-patches
2020-11-26 14:24 ` Pedro Alves
2020-11-30 20:26 ` Simon Marchi
2020-11-10 21:46 ` [PATCH 10/12] gdb: change linux gdbarch data from post to pre-init Simon Marchi via Gdb-patches
2020-11-25 1:41 ` Pedro Alves
2020-11-10 21:46 ` [PATCH 11/12] gdb: make displaced stepping implementation capable of managing multiple buffers Simon Marchi via Gdb-patches
2020-11-25 1:41 ` Pedro Alves
2020-11-30 18:58 ` Simon Marchi
2020-11-30 19:01 ` Simon Marchi
2020-11-10 21:46 ` [PATCH 12/12] gdb: use two displaced step buffers on amd64/Linux Simon Marchi via Gdb-patches
2020-11-25 1:42 ` Pedro Alves
2020-11-25 6:26 ` Simon Marchi
2020-11-25 20:07 ` Simon Marchi
2020-11-25 20:56 ` Simon Marchi
2020-11-26 21:43 ` Simon Marchi
2020-11-26 22:34 ` Simon Marchi
2020-11-28 18:56 ` Pedro Alves
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201110214614.2842615-2-simon.marchi@efficios.com \
--to=gdb-patches@sourceware.org \
--cc=simon.marchi@efficios.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox