From 42a4fec513f11d4ff346f62fc0df3731ce9f7d59 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Fri, 4 Dec 2020 16:43:51 -0500 Subject: gdb: add inferior_execd observable 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/jit.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'gdb/jit.c') diff --git a/gdb/jit.c b/gdb/jit.c index fd24d53..9deeed7 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); -- cgit v1.1