From 2554f6f564097e4e3a4132d3af8ef78d588d13d1 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Fri, 2 Oct 2020 14:45:52 -0400 Subject: 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) : 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) : New field. (create_file_handler): Add "name" parameter, assign it to file handler. (add_file_handler): Add "name" parameter. Change-Id: I9f1545f73888ebb6778eb653a618ca44d105f92c --- gdbsupport/event-loop.h | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'gdbsupport/event-loop.h') diff --git a/gdbsupport/event-loop.h b/gdbsupport/event-loop.h index 2eaaa0c..d7478b0 100644 --- a/gdbsupport/event-loop.h +++ b/gdbsupport/event-loop.h @@ -78,8 +78,18 @@ typedef void (timer_handler_func) (gdb_client_data); extern int gdb_do_one_event (void); extern void delete_file_handler (int fd); -extern void add_file_handler (int fd, handler_func *proc, - gdb_client_data client_data); + +/* Add a file handler/descriptor to the list of descriptors we are + interested in. + + FD is the file descriptor for the file/stream to be listened to. + + NAME is a user-friendly name for the handler. */ + +extern void add_file_handler (int fd, handler_func *proc, + gdb_client_data client_data, + std::string &&name); + extern int create_timer (int milliseconds, timer_handler_func *proc, gdb_client_data client_data); -- cgit v1.1