aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@polymtl.ca>2020-10-02 14:44:38 -0400
committerSimon Marchi <simon.marchi@efficios.com>2020-10-02 14:47:06 -0400
commitdb20ebdfae432f23def32f0b9bbf6e023c926235 (patch)
treeb11102a43affccf7bcb740972c51bc2c4212832e
parent2554f6f564097e4e3a4132d3af8ef78d588d13d1 (diff)
downloadbinutils-db20ebdfae432f23def32f0b9bbf6e023c926235.zip
binutils-db20ebdfae432f23def32f0b9bbf6e023c926235.tar.gz
binutils-db20ebdfae432f23def32f0b9bbf6e023c926235.tar.bz2
gdb: give names to async event/signal handlers
Assign names to async event/signal handlers. They will be used in debug messages when file handlers are invoked. Unlike in the previous patch, the names are not copied in the structure, since we don't need to (all names are string literals for the moment). gdb/ChangeLog: * async-event.h (create_async_signal_handler): Add name parameter. (create_async_event_handler): Likewise. * async-event.c (struct async_signal_handler) <name>: New field. (struct async_event_handler) <name>: New field. (create_async_signal_handler): Assign name. (create_async_event_handler): Assign name. * event-top.c (async_init_signals): Pass name when creating handler. * infrun.c (_initialize_infrun): Likewise. * record-btrace.c (record_btrace_push_target): Likewise. * record-full.c (record_full_open): Likewise. * remote-notif.c (remote_notif_state_allocate): Likewise. * remote.c (remote_target::open_1): Likewise. * tui/tui-win.c (tui_initialize_win): Likewise. Change-Id: Icd9d9f775542ae5fc2cd148c12f481e7885936d5
-rw-r--r--gdb/ChangeLog18
-rw-r--r--gdb/async-event.c20
-rw-r--r--gdb/async-event.h15
-rw-r--r--gdb/event-top.c14
-rw-r--r--gdb/infrun.c3
-rw-r--r--gdb/record-btrace.c2
-rw-r--r--gdb/record-full.c2
-rw-r--r--gdb/remote-notif.c2
-rw-r--r--gdb/remote.c3
-rw-r--r--gdb/tui/tui-win.c3
10 files changed, 59 insertions, 23 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 48caf1e..3b60116 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,23 @@
2020-10-02 Simon Marchi <simon.marchi@polymtl.ca>
+ * async-event.h (create_async_signal_handler): Add name
+ parameter.
+ (create_async_event_handler): Likewise.
+ * async-event.c (struct async_signal_handler) <name>: New field.
+ (struct async_event_handler) <name>: New field.
+ (create_async_signal_handler): Assign name.
+ (create_async_event_handler): Assign name.
+ * event-top.c (async_init_signals): Pass name when creating
+ handler.
+ * infrun.c (_initialize_infrun): Likewise.
+ * record-btrace.c (record_btrace_push_target): Likewise.
+ * record-full.c (record_full_open): Likewise.
+ * remote-notif.c (remote_notif_state_allocate): Likewise.
+ * remote.c (remote_target::open_1): Likewise.
+ * tui/tui-win.c (tui_initialize_win): Likewise.
+
+2020-10-02 Simon Marchi <simon.marchi@polymtl.ca>
+
* async-event.c (initialize_async_signal_handlers): Pass name to
add_file_handler
* event-top.c (ui_register_input_event_handler): Likewise.
diff --git a/gdb/async-event.c b/gdb/async-event.c
index e5cd63e..55be014 100644
--- a/gdb/async-event.c
+++ b/gdb/async-event.c
@@ -46,6 +46,9 @@ struct async_signal_handler
/* Argument to PROC. */
gdb_client_data client_data;
+
+ /* User-friendly name of this handler. */
+ const char *name;
};
/* PROC is a function to be invoked when the READY flag is set. This
@@ -68,6 +71,9 @@ struct async_event_handler
/* Argument to PROC. */
gdb_client_data client_data;
+
+ /* User-friendly name of this handler. */
+ const char *name;
};
/* All the async_signal_handlers gdb is interested in are kept onto
@@ -127,7 +133,8 @@ initialize_async_signal_handlers (void)
whenever the handler is invoked. */
async_signal_handler *
create_async_signal_handler (sig_handler_func * proc,
- gdb_client_data client_data)
+ gdb_client_data client_data,
+ const char *name)
{
async_signal_handler *async_handler_ptr;
@@ -136,6 +143,7 @@ create_async_signal_handler (sig_handler_func * proc,
async_handler_ptr->next_handler = NULL;
async_handler_ptr->proc = proc;
async_handler_ptr->client_data = client_data;
+ async_handler_ptr->name = name;
if (sighandler_list.first_handler == NULL)
sighandler_list.first_handler = async_handler_ptr;
else
@@ -236,13 +244,12 @@ delete_async_signal_handler (async_signal_handler ** async_handler_ptr)
(*async_handler_ptr) = NULL;
}
-/* Create an asynchronous event handler, allocating memory for it.
- Return a pointer to the newly created handler. PROC is the
- function to call with CLIENT_DATA argument whenever the handler is
- invoked. */
+/* See async-event.h. */
+
async_event_handler *
create_async_event_handler (async_event_handler_func *proc,
- gdb_client_data client_data)
+ gdb_client_data client_data,
+ const char *name)
{
async_event_handler *h;
@@ -251,6 +258,7 @@ create_async_event_handler (async_event_handler_func *proc,
h->next_handler = NULL;
h->proc = proc;
h->client_data = client_data;
+ h->name = name;
if (async_event_handler_list.first_handler == NULL)
async_event_handler_list.first_handler = h;
else
diff --git a/gdb/async-event.h b/gdb/async-event.h
index adf6dc8..8f279d6 100644
--- a/gdb/async-event.h
+++ b/gdb/async-event.h
@@ -27,8 +27,9 @@ typedef void (sig_handler_func) (gdb_client_data);
typedef void (async_event_handler_func) (gdb_client_data);
extern struct async_signal_handler *
- create_async_signal_handler (sig_handler_func *proc,
- gdb_client_data client_data);
+ create_async_signal_handler (sig_handler_func *proc,
+ gdb_client_data client_data,
+ const char *name);
extern void delete_async_signal_handler (struct async_signal_handler **);
/* Call the handler from HANDLER the next time through the event
@@ -48,10 +49,16 @@ extern void clear_async_signal_handler (struct async_signal_handler *handler);
and set PROC as its callback. CLIENT_DATA is passed as argument to
PROC upon its invocation. Returns a pointer to an opaque structure
used to mark as ready and to later delete this event source from
- the event loop. */
+ the event loop.
+
+ NAME is a user-friendly name for the handler, used in debug statements. The
+ name is not copied: its lifetime should be at least as long as that of the
+ handler. */
+
extern struct async_event_handler *
create_async_event_handler (async_event_handler_func *proc,
- gdb_client_data client_data);
+ gdb_client_data client_data,
+ const char *name);
/* Remove the event source pointed by HANDLER_PTR created by
CREATE_ASYNC_EVENT_HANDLER from the event loop, and release it. */
diff --git a/gdb/event-top.c b/gdb/event-top.c
index c96f104..fdce5de 100644
--- a/gdb/event-top.c
+++ b/gdb/event-top.c
@@ -916,10 +916,10 @@ async_init_signals (void)
signal (SIGINT, handle_sigint);
sigint_token =
- create_async_signal_handler (async_request_quit, NULL);
+ create_async_signal_handler (async_request_quit, NULL, "sigint");
signal (SIGTERM, handle_sigterm);
async_sigterm_token
- = create_async_signal_handler (async_sigterm_handler, NULL);
+ = create_async_signal_handler (async_sigterm_handler, NULL, "sigterm");
/* If SIGTRAP was set to SIG_IGN, then the SIG_IGN will get passed
to the inferior and breakpoints will be ignored. */
@@ -938,23 +938,23 @@ async_init_signals (void)
to SIG_DFL for us. */
signal (SIGQUIT, handle_sigquit);
sigquit_token =
- create_async_signal_handler (async_do_nothing, NULL);
+ create_async_signal_handler (async_do_nothing, NULL, "sigquit");
#endif
#ifdef SIGHUP
if (signal (SIGHUP, handle_sighup) != SIG_IGN)
sighup_token =
- create_async_signal_handler (async_disconnect, NULL);
+ create_async_signal_handler (async_disconnect, NULL, "sighup");
else
sighup_token =
- create_async_signal_handler (async_do_nothing, NULL);
+ create_async_signal_handler (async_do_nothing, NULL, "sighup");
#endif
signal (SIGFPE, handle_sigfpe);
sigfpe_token =
- create_async_signal_handler (async_float_handler, NULL);
+ create_async_signal_handler (async_float_handler, NULL, "sigfpe");
#ifdef SIGTSTP
sigtstp_token =
- create_async_signal_handler (async_sigtstp_handler, NULL);
+ create_async_signal_handler (async_sigtstp_handler, NULL, "sigtstp");
#endif
install_handle_sigsegv ();
diff --git a/gdb/infrun.c b/gdb/infrun.c
index a150585..0458c3a 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -9278,7 +9278,8 @@ _initialize_infrun ()
/* Register extra event sources in the event loop. */
infrun_async_inferior_event_token
- = create_async_event_handler (infrun_async_inferior_event_handler, NULL);
+ = create_async_event_handler (infrun_async_inferior_event_handler, NULL,
+ "infrun");
add_info ("signals", info_signals_command, _("\
What debugger does when program gets various signals.\n\
diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c
index 678984b..dd05b93 100644
--- a/gdb/record-btrace.c
+++ b/gdb/record-btrace.c
@@ -342,7 +342,7 @@ record_btrace_push_target (void)
record_btrace_async_inferior_event_handler
= create_async_event_handler (record_btrace_handle_async_inferior_event,
- NULL);
+ NULL, "record-btrace");
record_btrace_generating_corefile = 0;
format = btrace_format_short_string (record_btrace_conf.format);
diff --git a/gdb/record-full.c b/gdb/record-full.c
index c0fedfc..9a6187e 100644
--- a/gdb/record-full.c
+++ b/gdb/record-full.c
@@ -986,7 +986,7 @@ record_full_open (const char *name, int from_tty)
/* Register extra event sources in the event loop. */
record_full_async_inferior_event_token
= create_async_event_handler (record_full_async_inferior_event_handler,
- NULL);
+ NULL, "record-full");
record_full_init_record_breakpoints ();
diff --git a/gdb/remote-notif.c b/gdb/remote-notif.c
index 2e5f124..f18bc86 100644
--- a/gdb/remote-notif.c
+++ b/gdb/remote-notif.c
@@ -219,7 +219,7 @@ remote_notif_state_allocate (remote_target *remote)
notif_state->get_pending_events_token
= create_async_event_handler (remote_async_get_pending_events_handler,
- notif_state);
+ notif_state, "remote-notif");
return notif_state;
}
diff --git a/gdb/remote.c b/gdb/remote.c
index 1ef9b44..f951486 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -5605,7 +5605,8 @@ remote_target::open_1 (const char *name, int from_tty, int extended_p)
/* Register extra event sources in the event loop. */
rs->remote_async_inferior_event_token
- = create_async_event_handler (remote_async_inferior_event_handler, remote);
+ = create_async_event_handler (remote_async_inferior_event_handler, remote,
+ "remote");
rs->notif_state = remote_notif_state_allocate (remote);
/* Reset the target state; these things will be queried either by
diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index f906b0d..86c0fdb 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -576,7 +576,8 @@ tui_initialize_win (void)
{
#ifdef SIGWINCH
tui_sigwinch_token
- = create_async_signal_handler (tui_async_resize_screen, NULL);
+ = create_async_signal_handler (tui_async_resize_screen, NULL,
+ "tui-sigwinch");
{
#ifdef HAVE_SIGACTION