diff options
author | Simon Marchi <simon.marchi@polymtl.ca> | 2020-10-02 14:45:52 -0400 |
---|---|---|
committer | Simon Marchi <simon.marchi@efficios.com> | 2020-10-02 14:46:56 -0400 |
commit | 2554f6f564097e4e3a4132d3af8ef78d588d13d1 (patch) | |
tree | 296af2f219dd484543ed7b43156cf347e4f6de36 /gdb | |
parent | a7aba2668a7b392182e296392d8e19516e1a6ec5 (diff) | |
download | gdb-2554f6f564097e4e3a4132d3af8ef78d588d13d1.zip gdb-2554f6f564097e4e3a4132d3af8ef78d588d13d1.tar.gz gdb-2554f6f564097e4e3a4132d3af8ef78d588d13d1.tar.bz2 |
gdb: give names to event loop file handlers
Assign names to event loop file handlers. They will be used in debug
messages when file handlers are invoked.
In GDB, each UI used to get its own unique number, until commit
cbe256847e19 ("Remove ui::num"). Re-introduce this field, and use it to
make a unique name for the handler.
I'm not too sure what goes on in ser-base.c, all I know is that it's
what is used when debugging remotely. I've just named the main handler
"serial". It would be good to have unique names there too. For instance
when debugging with two different remote connections, we'd ideally want
the handlers to have unique names. I didn't do it in this patch though.
gdb/ChangeLog:
* async-event.c (initialize_async_signal_handlers): Pass name to
add_file_handler
* event-top.c (ui_register_input_event_handler): Likewise.
* linux-nat.c (linux_nat_target::async): Likewise.
* run-on-main-thread.c (_initialize_run_on_main_thread):
Likewise
* ser-base.c (reschedule): Likewise.
(ser_base_async): Likewise.
* tui/tui-io.c: Likewise.
* top.h (struct ui) <num>: New field.
* top.c (highest_ui_num): New variable.
(ui::ui): Initialize num.
gdbserver/ChangeLog:
* linux-low.cc (linux_process_target::async): Pass name to
add_file_handler.
* remote-utils.cc (handle_accept_event): Likewise.
(remote_open): Likewise.
gdbsupport/ChangeLog:
* event-loop.h (add_file_handler): Add "name" parameter.
* event-loop.cc (struct file_handler) <name>: New field.
(create_file_handler): Add "name" parameter, assign it to file
handler.
(add_file_handler): Add "name" parameter.
Change-Id: I9f1545f73888ebb6778eb653a618ca44d105f92c
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/ChangeLog | 15 | ||||
-rw-r--r-- | gdb/async-event.c | 2 | ||||
-rw-r--r-- | gdb/event-top.c | 3 | ||||
-rw-r--r-- | gdb/linux-nat.c | 3 | ||||
-rw-r--r-- | gdb/run-on-main-thread.c | 3 | ||||
-rw-r--r-- | gdb/ser-base.c | 6 | ||||
-rw-r--r-- | gdb/top.c | 4 | ||||
-rw-r--r-- | gdb/top.h | 3 | ||||
-rw-r--r-- | gdb/tui/tui-io.c | 2 |
9 files changed, 33 insertions, 8 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 8788c60..48caf1e 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,20 @@ 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. + * linux-nat.c (linux_nat_target::async): Likewise. + * run-on-main-thread.c (_initialize_run_on_main_thread): + Likewise + * ser-base.c (reschedule): Likewise. + (ser_base_async): Likewise. + * tui/tui-io.c: Likewise. + * top.h (struct ui) <num>: New field. + * top.c (highest_ui_num): New variable. + (ui::ui): Initialize num. + +2020-10-02 Simon Marchi <simon.marchi@polymtl.ca> + * observable.h <inferior_created>: Remove parameters. Update all listeners. * inferior.h (post_create_inferior): Remove target parameter. diff --git a/gdb/async-event.c b/gdb/async-event.c index ffc0edc..e5cd63e 100644 --- a/gdb/async-event.c +++ b/gdb/async-event.c @@ -114,7 +114,7 @@ initialize_async_signal_handlers (void) async_signal_handlers_serial_event = make_serial_event (); add_file_handler (serial_event_fd (async_signal_handlers_serial_event), - async_signals_handler, NULL); + async_signals_handler, NULL, "async-signals"); } diff --git a/gdb/event-top.c b/gdb/event-top.c index ac0f370..c96f104 100644 --- a/gdb/event-top.c +++ b/gdb/event-top.c @@ -524,7 +524,8 @@ stdin_event_handler (int error, gdb_client_data client_data) void ui_register_input_event_handler (struct ui *ui) { - add_file_handler (ui->input_fd, stdin_event_handler, ui); + add_file_handler (ui->input_fd, stdin_event_handler, ui, + string_printf ("ui-%d", ui->num)); } /* See top.h. */ diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c index fbb5388..7b9b267 100644 --- a/gdb/linux-nat.c +++ b/gdb/linux-nat.c @@ -4123,7 +4123,8 @@ linux_nat_target::async (int enable) if (!linux_async_pipe (1)) { add_file_handler (linux_nat_event_pipe[0], - handle_target_event, NULL); + handle_target_event, NULL, + "linux-nat"); /* There may be pending events to handle. Tell the event loop to poll them. */ async_file_mark (); diff --git a/gdb/run-on-main-thread.c b/gdb/run-on-main-thread.c index 2cc93e4..1e7bb5f 100644 --- a/gdb/run-on-main-thread.c +++ b/gdb/run-on-main-thread.c @@ -94,5 +94,6 @@ void _initialize_run_on_main_thread () { runnable_event = make_serial_event (); - add_file_handler (serial_event_fd (runnable_event), run_events, nullptr); + add_file_handler (serial_event_fd (runnable_event), run_events, nullptr, + "run-on-main-thread"); } diff --git a/gdb/ser-base.c b/gdb/ser-base.c index 84ca8c6..cb503f6 100644 --- a/gdb/ser-base.c +++ b/gdb/ser-base.c @@ -83,7 +83,7 @@ reschedule (struct serial *scb) case NOTHING_SCHEDULED: if (scb->bufcnt == 0) { - add_file_handler (scb->fd, fd_event, scb); + add_file_handler (scb->fd, fd_event, scb, "serial"); next_state = FD_SCHEDULED; } else @@ -95,7 +95,7 @@ reschedule (struct serial *scb) if (scb->bufcnt == 0) { delete_timer (scb->async_state); - add_file_handler (scb->fd, fd_event, scb); + add_file_handler (scb->fd, fd_event, scb, "serial"); next_state = FD_SCHEDULED; } else @@ -597,7 +597,7 @@ ser_base_async (struct serial *scb, reschedule (scb); if (scb->error_fd != -1) - add_file_handler (scb->error_fd, handle_error_fd, scb); + add_file_handler (scb->error_fd, handle_error_fd, scb, "serial-error"); } else { @@ -270,10 +270,14 @@ void (*deprecated_call_command_hook) (struct cmd_list_element * c, void (*deprecated_context_hook) (int id); +/* The highest UI number ever assigned. */ +static int highest_ui_num; + /* See top.h. */ ui::ui (FILE *instream_, FILE *outstream_, FILE *errstream_) : next (nullptr), + num (++highest_ui_num), call_readline (nullptr), input_handler (nullptr), command_editing (0), @@ -65,6 +65,9 @@ struct ui /* Pointer to next in singly-linked list. */ struct ui *next; + /* Convenient handle (UI number). Unique across all UIs. */ + int num; + /* The UI's command line buffer. This is to used to accumulate input until we have a whole command line. */ struct buffer line_buffer; diff --git a/gdb/tui/tui-io.c b/gdb/tui/tui-io.c index 1a2764e..a4f9317 100644 --- a/gdb/tui/tui-io.c +++ b/gdb/tui/tui-io.c @@ -921,7 +921,7 @@ tui_initialize_io (void) (void) fcntl (tui_readline_pipe[0], F_SETFL, O_NDELAY); #endif #endif - add_file_handler (tui_readline_pipe[0], tui_readline_output, 0); + add_file_handler (tui_readline_pipe[0], tui_readline_output, 0, "tui"); #else tui_rl_outstream = stdout; #endif |