GDB (xrefs)

Classes | Macros | Typedefs | Functions | Variables
/tmp/gdb-8.1/gdb/event-loop.c File Reference
`#include "defs.h"`
`#include "event-loop.h"`
`#include "event-top.h"`
`#include "queue.h"`
`#include "ser-event.h"`
`#include <poll.h>`
`#include <sys/types.h>`
`#include "gdb_sys_time.h"`
`#include "gdb_select.h"`
`#include "observer.h"`
`#include "top.h"`

Go to the source code of this file.

## Classes
union | event_data
struct | gdb_event
struct | file_handler
struct | async_signal_handler
struct | async_event_handler
struct | gdb_timer

## Macros
#define | GDB_READABLE (1<<1)
#define | GDB_WRITABLE (1<<2)
#define | GDB_EXCEPTION (1<<3)
#define | USE_POLL 1

## Typedefs
typedef union event_data | event_data
typedef struct gdb_event | gdb_event
typedef void() | event_handler_func(event_data)
typedef struct gdb_event * | gdb_event_p
typedef struct file_handler | file_handler
typedef struct async_signal_handler | async_signal_handler
typedef struct async_event_handler | async_event_handler

## Functions
static int | invoke_async_signal_handlers (void)
static void | create_file_handler (int fd, int mask, handler_func *proc, gdb_client_data client_data)
static int | check_async_event_handlers (void)
static int | gdb_wait_for_event (int)
static int | update_wait_timeout (void)
static int | poll_timers (void)
static void | async_signals_handler (int error, gdb_client_data client_data)
void | initialize_async_signal_handlers (void)
int | gdb_do_one_event (void)
void | start_event_loop (void)
void | add_file_handler (int fd, handler_func *proc, gdb_client_data client_data)
static file_handler * | get_next_file_handler_to_handle_and_advance (void)
void | delete_file_handler (int fd)
static void | handle_file_event (file_handler *file_ptr, int ready_mask)
async_signal_handler * | create_async_signal_handler (sig_handler_func *proc, gdb_client_data client_data)
void | mark_async_signal_handler (async_signal_handler *async_handler_ptr)
void | clear_async_signal_handler (async_signal_handler *async_handler_ptr)
int | async_signal_handler_is_marked (async_signal_handler *async_handler_ptr)
void | delete_async_signal_handler (async_signal_handler **async_handler_ptr)
async_event_handler * | create_async_event_handler (async_event_handler_func *proc, gdb_client_data client_data)
void | mark_async_event_handler (async_event_handler *async_handler_ptr)
void | clear_async_event_handler (async_event_handler *async_handler_ptr)
void | delete_async_event_handler (async_event_handler **async_handler_ptr)
int | create_timer (int ms, timer_handler_func *proc, gdb_client_data client_data)
void | delete_timer (int id)
template<typename Duration >
static struct timeval | duration_cast_timeval (const Duration &d)

## Variables
static unsigned char | use_poll = USE_POLL
struct {
file_handler * first_file_handler
file_handler * next_file_handler
struct pollfd * poll_fds
int next_poll_fds_index
int poll_timeout
fd_set check_masks [3]
fd_set ready_masks [3]
int num_fds
struct timeval select_timeout
int timeout_valid
} | gdb_notifier
struct {
struct gdb_timer * first_timer
int num_timers
} | timer_list
struct {
async_signal_handler * first_handler
async_signal_handler * last_handler
} | sighandler_list
struct {
async_event_handler * first_handler
async_event_handler * last_handler
} | async_event_handler_list
static struct serial_event * | async_signal_handlers_serial_event

## Macro Definition Documentation

## ◆ GDB_EXCEPTION

#define GDB_EXCEPTION (1<<3)

Definition at line 45 of file event-loop.c.

Referenced by add_file_handler(), create_file_handler(), delete_file_handler(), gdb_wait_for_event(), and handle_file_event().

## ◆ GDB_READABLE

#define GDB_READABLE (1<<1)

Definition at line 43 of file event-loop.c.

Referenced by add_file_handler(), create_file_handler(), delete_file_handler(), and gdb_wait_for_event().

## ◆ GDB_WRITABLE

#define GDB_WRITABLE (1<<2)

Definition at line 44 of file event-loop.c.

Referenced by create_file_handler(), delete_file_handler(), and gdb_wait_for_event().

## ◆ USE_POLL

#define USE_POLL 1

Definition at line 153 of file event-loop.c.

## Typedef Documentation

## ◆ async_event_handler

typedef struct async_event_handler async_event_handler

## ◆ async_signal_handler

typedef struct async_signal_handler async_signal_handler

## ◆ event_data

typedef union event_data event_data

## ◆ event_handler_func

typedef void() event_handler_func(event_data)

Definition at line 55 of file event-loop.c.

## ◆ file_handler

typedef struct file_handler file_handler

## ◆ gdb_event

typedef struct gdb_event gdb_event

Definition at line 54 of file event-loop.c.

## ◆ gdb_event_p

typedef struct gdb_event * gdb_event_p

## Function Documentation

## ◆ add_file_handler()

void add_file_handler | ( | int | fd,
|  | handler_func * | proc,
|  | gdb_client_data | client_data
| ) |  |

Definition at line 413 of file event-loop.c.

References _, create_file_handler(), GDB_EXCEPTION, GDB_READABLE, internal_error(), and use_poll.

Referenced by gdbpy_initialize_events(), initialize_async_signal_handlers(), linux_nat_async(), reschedule(), ser_base_async(), tui_initialize_io(), and ui_register_input_event_handler().

## ◆ async_signal_handler_is_marked()

int async_signal_handler_is_marked | ( | async_signal_handler * | async_handler_ptr | ) |

Definition at line 938 of file event-loop.c.

References async_signal_handler::ready.

## ◆ async_signals_handler()

static void async_signals_handler | ( | int | error,
|  | gdb_client_data | client_data
| ) |  |
| static

Definition at line 274 of file event-loop.c.

Referenced by initialize_async_signal_handlers().

## ◆ check_async_event_handlers()

static int check_async_event_handlers | ( | void |  | ) |
| static

Definition at line 1053 of file event-loop.c.

References async_event_handler_list, async_event_handler::client_data, async_event_handler::next_handler, async_event_handler::proc, and async_event_handler::ready.

Referenced by gdb_do_one_event().

## ◆ clear_async_event_handler()

void clear_async_event_handler | ( | async_event_handler * | async_handler_ptr | ) |

Definition at line 1044 of file event-loop.c.

References async_event_handler::ready.

Referenced by infrun_async(), record_btrace_async(), record_full_async(), and remote_async().

## ◆ clear_async_signal_handler()

void clear_async_signal_handler | ( | async_signal_handler * | async_handler_ptr | ) |

Definition at line 930 of file event-loop.c.

References async_signal_handler::ready.

## ◆ create_async_event_handler()

async_event_handler* create_async_event_handler | ( | async_event_handler_func * | proc,
|  | gdb_client_data | client_data
| ) |  |

Definition at line 1013 of file event-loop.c.

References async_event_handler_list, async_event_handler::client_data, async_event_handler::next_handler, async_event_handler::proc, async_event_handler::ready, and XNEW.

Referenced by _initialize_infrun(), record_btrace_push_target(), record_full_open(), remote_notif_state_allocate(), and remote_open_1().

## ◆ create_async_signal_handler()

async_signal_handler* create_async_signal_handler | ( | sig_handler_func * | proc,
|  | gdb_client_data | client_data
| ) |  |

Definition at line 898 of file event-loop.c.

References async_signal_handler::client_data, async_signal_handler::next_handler, async_signal_handler::proc, async_signal_handler::ready, sighandler_list, and XNEW.

Referenced by async_init_signals(), and tui_initialize_win().

## ◆ create_file_handler()

static void create_file_handler | ( | int | fd,
|  | int | mask,
|  | handler_func * | proc,
|  | gdb_client_data | client_data
| ) |  |
| static

Definition at line 465 of file event-loop.c.

References _, file_handler::client_data, file_handler::fd, GDB_EXCEPTION, gdb_notifier, GDB_READABLE, GDB_WRITABLE, internal_error(), file_handler::mask, file_handler::next_file, file_handler::proc, file_handler::ready_mask, use_poll, XNEW, and xrealloc().

Referenced by add_file_handler().

## ◆ create_timer()

int create_timer | ( | int | ms,
|  | timer_handler_func * | proc,
|  | gdb_client_data | client_data
| ) |  |

Definition at line 1106 of file event-loop.c.

References gdb_timer::client_data, gdb_notifier, gdb_timer::next, gdb_timer::proc, gdb_timer::timer_id, timer_list, and gdb_timer::when.

Referenced by reschedule().

## ◆ delete_async_event_handler()

void delete_async_event_handler | ( | async_event_handler ** | async_handler_ptr | ) |

Definition at line 1075 of file event-loop.c.

References async_event_handler_list, gdb_assert, async_event_handler::next_handler, and xfree().

Referenced by record_btrace_close(), record_full_close(), remote_close(), and remote_notif_state_xfree().

## ◆ delete_async_signal_handler()

void delete_async_signal_handler | ( | async_signal_handler ** | async_handler_ptr | ) |

Definition at line 984 of file event-loop.c.

References gdb_assert, async_signal_handler::next_handler, sighandler_list, and xfree().

## ◆ delete_file_handler()

void delete_file_handler | ( | int | fd | ) |

Definition at line 564 of file event-loop.c.

References _, file_handler::fd, GDB_EXCEPTION, gdb_notifier, GDB_READABLE, GDB_WRITABLE, get_next_file_handler_to_handle_and_advance(), internal_error(), file_handler::mask, file_handler::next_file, use_poll, xfree(), and xmalloc().

Referenced by async_disable_stdin(), gdb_disable_readline(), linux_nat_async(), reschedule(), run_inferior_call(), ser_base_async(), ser_base_read_error_fd(), stdin_event_handler(), and ui_unregister_input_event_handler().

## ◆ delete_timer()

void delete_timer | ( | int | id | ) |

Definition at line 1156 of file event-loop.c.

References gdb_notifier, gdb_timer::next, gdb_timer::timer_id, and timer_list.

Referenced by reschedule(), and ser_base_async().

## ◆ duration_cast_timeval()

template<typename Duration >

static struct timeval duration_cast_timeval | ( | const Duration & | d | ) |
| static

Definition at line 1191 of file event-loop.c.

Referenced by update_wait_timeout().

## ◆ gdb_do_one_event()

int gdb_do_one_event | ( | void |  | ) |

Definition at line 295 of file event-loop.c.

References check_async_event_handlers(), gdb_wait_for_event(), internal_error(), invoke_async_signal_handlers(), and poll_timers().

Referenced by gdb_readline_wrapper(), start_event_loop(), and wait_sync_command_done().

## ◆ gdb_wait_for_event()

static int gdb_wait_for_event | ( | int | block | ) |
| static

Definition at line 746 of file event-loop.c.

References _, file_handler::fd, gdb_assert, GDB_EXCEPTION, gdb_flush(), gdb_notifier, GDB_READABLE, gdb_select(), gdb_stderr, gdb_stdout, GDB_WRITABLE, get_next_file_handler_to_handle_and_advance(), handle_file_event(), internal_error(), memset(), file_handler::next_file, perror_with_name(), select_timeout, update_wait_timeout(), and use_poll.

Referenced by gdb_do_one_event().

## ◆ get_next_file_handler_to_handle_and_advance()

static file_handler* get_next_file_handler_to_handle_and_advance | ( | void |  | ) |
| static

Definition at line 541 of file event-loop.c.

References gdb_assert, gdb_notifier, and file_handler::next_file.

Referenced by delete_file_handler(), and gdb_wait_for_event().

## ◆ handle_file_event()

static void handle_file_event | ( | file_handler * | file_ptr,
|  | int | ready_mask
| ) |  |
| static

Definition at line 672 of file event-loop.c.

References _, file_handler::client_data, file_handler::error, file_handler::fd, GDB_EXCEPTION, internal_error(), file_handler::mask, printf_unfiltered(), file_handler::proc, and use_poll.

Referenced by gdb_wait_for_event().

## ◆ initialize_async_signal_handlers()

void initialize_async_signal_handlers | ( | void |  | ) |

Definition at line 281 of file event-loop.c.

References add_file_handler(), async_signal_handlers_serial_event, async_signals_handler(), make_serial_event(), and serial_event_fd().

Referenced by async_init_signals().

## ◆ invoke_async_signal_handlers()

static int invoke_async_signal_handlers | ( | void |  | ) |
| static

Definition at line 947 of file event-loop.c.

References async_signal_handlers_serial_event, async_signal_handler::client_data, current_ui, main_ui, async_signal_handler::next_handler, async_signal_handler::proc, async_signal_handler::ready, serial_event_clear(), and sighandler_list.

Referenced by gdb_do_one_event().

## ◆ mark_async_event_handler()

void mark_async_event_handler | ( | async_event_handler * | async_handler_ptr | ) |

Definition at line 1036 of file event-loop.c.

References async_event_handler::ready.

Referenced by do_target_wait(), finish_step_over(), handle_notification(), infrun_async(), mark_infrun_async_event_handler(), proceed(), push_stop_reply(), queued_stop_reply(), record_btrace_async(), record_btrace_maybe_mark_async_event(), record_btrace_resume(), record_full_async(), remote_async(), remote_notif_stop_can_get_pending_events(), and remote_wait().

## ◆ mark_async_signal_handler()

void mark_async_signal_handler | ( | async_signal_handler * | async_handler_ptr | ) |

Definition at line 921 of file event-loop.c.

References async_signal_handlers_serial_event, async_signal_handler::ready, and serial_event_set().

Referenced by handle_sigfpe(), handle_sigint(), and handle_sigterm().

## ◆ poll_timers()

static int poll_timers | ( | void |  | ) |
| static

Definition at line 1259 of file event-loop.c.

References gdb_timer::client_data, gdb_timer::next, gdb_timer::proc, timer_list, and update_wait_timeout().

Referenced by gdb_do_one_event().

## ◆ start_event_loop()

void start_event_loop | ( | void |  | ) |

Definition at line 359 of file event-loop.c.

References after_char_processing_hook, async_enable_stdin(), CATCH, current_ui, END_CATCH, exception_print(), gdb_do_one_event(), gdb_stderr, observer_notify_command_error(), PROMPT_NEEDED, ui::prompt_state, RETURN_MASK_ALL, and TRY.

Referenced by captured_command_loop().

## ◆ update_wait_timeout()

static int update_wait_timeout | ( | void |  | ) |
| static

Definition at line 1207 of file event-loop.c.

References _, duration_cast_timeval(), gdb_notifier, internal_error(), timer_list, and use_poll.

Referenced by gdb_wait_for_event(), and poll_timers().

## Variable Documentation

## ◆ async_event_handler_list

struct { ... } async_event_handler_list

Referenced by check_async_event_handlers(), create_async_event_handler(), and delete_async_event_handler().

## ◆ async_signal_handlers_serial_event

struct serial_event* async_signal_handlers_serial_event
| static

Definition at line 269 of file event-loop.c.

Referenced by initialize_async_signal_handlers(), invoke_async_signal_handlers(), and mark_async_signal_handler().

## ◆ check_masks

fd_set check_masks[3]

Definition at line 194 of file event-loop.c.

## ◆ first_file_handler

file_handler* first_file_handler

Definition at line 168 of file event-loop.c.

## ◆ first_handler

async_event_handler* first_handler

Definition at line 239 of file event-loop.c.

## ◆ first_timer

struct gdb_timer* first_timer

Definition at line 227 of file event-loop.c.

## ◆ gdb_notifier

struct { ... } gdb_notifier

Referenced by create_file_handler(), create_timer(), delete_file_handler(), delete_timer(), gdb_wait_for_event(), get_next_file_handler_to_handle_and_advance(), and update_wait_timeout().

## ◆ last_handler

async_event_handler* last_handler

Definition at line 242 of file event-loop.c.

## ◆ next_file_handler

file_handler* next_file_handler

Definition at line 175 of file event-loop.c.

## ◆ next_poll_fds_index

int next_poll_fds_index

Definition at line 186 of file event-loop.c.

## ◆ num_fds

int num_fds

Definition at line 201 of file event-loop.c.

Referenced by ioscm_input_waiting().

## ◆ num_timers

int num_timers

Definition at line 230 of file event-loop.c.

## ◆ poll_fds

struct pollfd* poll_fds

Definition at line 179 of file event-loop.c.

## ◆ poll_timeout

int poll_timeout

Definition at line 189 of file event-loop.c.

## ◆ ready_masks

fd_set ready_masks[3]

Definition at line 197 of file event-loop.c.

## ◆ select_timeout

struct timeval select_timeout

Definition at line 204 of file event-loop.c.

Referenced by gdb_wait_for_event().

## ◆ sighandler_list

struct { ... } sighandler_list

Referenced by create_async_signal_handler(), delete_async_signal_handler(), and invoke_async_signal_handlers().

## ◆ timeout_valid

int timeout_valid

Definition at line 207 of file event-loop.c.

## ◆ timer_list

struct { ... } timer_list

Referenced by create_timer(), delete_timer(), poll_timers(), and update_wait_timeout().

## ◆ use_poll

unsigned char use_poll = USE_POLL
| static

Definition at line 158 of file event-loop.c.

Referenced by add_file_handler(), create_file_handler(), delete_file_handler(), gdb_wait_for_event(), handle_file_event(), ioscm_input_waiting(), and update_wait_timeout().