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 /gdbsupport | |
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 'gdbsupport')
-rw-r--r-- | gdbsupport/ChangeLog | 8 | ||||
-rw-r--r-- | gdbsupport/event-loop.cc | 32 | ||||
-rw-r--r-- | gdbsupport/event-loop.h | 14 |
3 files changed, 37 insertions, 17 deletions
diff --git a/gdbsupport/ChangeLog b/gdbsupport/ChangeLog index 216fad1..b54bfb9 100644 --- a/gdbsupport/ChangeLog +++ b/gdbsupport/ChangeLog @@ -1,3 +1,11 @@ +2020-10-02 Simon Marchi <simon.marchi@polymtl.ca> + + * 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. + 2020-10-01 Kamil Rytarowski <n54@gmx.com> * agent.cc (gdb_connect_sync_socket): Preinitialize addr with zeros. diff --git a/gdbsupport/event-loop.cc b/gdbsupport/event-loop.cc index 59436d4..0d78122 100644 --- a/gdbsupport/event-loop.cc +++ b/gdbsupport/event-loop.cc @@ -61,6 +61,9 @@ struct file_handler /* Argument to pass to proc. */ gdb_client_data client_data; + /* User-friendly name of this handler. Heap-allocated, owned by this.*/ + std::string *name; + /* Was an error detected on this fd? */ int error; @@ -160,7 +163,8 @@ static struct timer_list; static void create_file_handler (int fd, int mask, handler_func *proc, - gdb_client_data client_data); + gdb_client_data client_data, + std::string &&name); static int gdb_wait_for_event (int); static int update_wait_timeout (void); static int poll_timers (void); @@ -231,13 +235,11 @@ gdb_do_one_event (void) return 1; } - +/* See event-loop.h */ -/* Wrapper function for create_file_handler, so that the caller - doesn't have to know implementation details about the use of poll - vs. select. */ void -add_file_handler (int fd, handler_func * proc, gdb_client_data client_data) +add_file_handler (int fd, handler_func *proc, gdb_client_data client_data, + std::string &&name) { #ifdef HAVE_POLL struct pollfd fds; @@ -263,21 +265,18 @@ add_file_handler (int fd, handler_func * proc, gdb_client_data client_data) if (use_poll) { #ifdef HAVE_POLL - create_file_handler (fd, POLLIN, proc, client_data); + create_file_handler (fd, POLLIN, proc, client_data, std::move (name)); #else internal_error (__FILE__, __LINE__, _("use_poll without HAVE_POLL")); #endif } else - create_file_handler (fd, GDB_READABLE | GDB_EXCEPTION, - proc, client_data); + create_file_handler (fd, GDB_READABLE | GDB_EXCEPTION, + proc, client_data, std::move (name)); } -/* 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. +/* Helper for add_file_handler. For the poll case, MASK is a combination (OR) of POLLIN, POLLRDNORM, POLLRDBAND, POLLPRI, POLLOUT, POLLWRNORM, POLLWRBAND: @@ -289,8 +288,8 @@ add_file_handler (int fd, handler_func * proc, gdb_client_data client_data) occurs for FD. CLIENT_DATA is the argument to pass to PROC. */ static void -create_file_handler (int fd, int mask, handler_func * proc, - gdb_client_data client_data) +create_file_handler (int fd, int mask, handler_func * proc, + gdb_client_data client_data, std::string &&name) { file_handler *file_ptr; @@ -358,6 +357,7 @@ create_file_handler (int fd, int mask, handler_func * proc, file_ptr->proc = proc; file_ptr->client_data = client_data; file_ptr->mask = mask; + file_ptr->name = new std::string (std::move (name)); } /* Return the next file handler to handle, and advance to the next @@ -489,6 +489,8 @@ delete_file_handler (int fd) ; prev_ptr->next_file = file_ptr->next_file; } + + delete file_ptr->name; xfree (file_ptr); } 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); |