OLD | NEW |
1 /* Event loop machinery for GDB, the GNU debugger. | 1 /* Event loop machinery for GDB, the GNU debugger. |
2 Copyright (C) 1999-2002, 2005-2012 Free Software Foundation, Inc. | 2 Copyright (C) 1999-2013 Free Software Foundation, Inc. |
3 Written by Elena Zannoni <ezannoni@cygnus.com> of Cygnus Solutions. | 3 Written by Elena Zannoni <ezannoni@cygnus.com> of Cygnus Solutions. |
4 | 4 |
5 This file is part of GDB. | 5 This file is part of GDB. |
6 | 6 |
7 This program is free software; you can redistribute it and/or modify | 7 This program is free software; you can redistribute it and/or modify |
8 it under the terms of the GNU General Public License as published by | 8 it under the terms of the GNU General Public License as published by |
9 the Free Software Foundation; either version 3 of the License, or | 9 the Free Software Foundation; either version 3 of the License, or |
10 (at your option) any later version. | 10 (at your option) any later version. |
11 | 11 |
12 This program is distributed in the hope that it will be useful, | 12 This program is distributed in the hope that it will be useful, |
13 but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 GNU General Public License for more details. | 15 GNU General Public License for more details. |
16 | 16 |
17 You should have received a copy of the GNU General Public License | 17 You should have received a copy of the GNU General Public License |
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */ | 18 along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
19 | 19 |
20 #include "defs.h" | 20 #include "defs.h" |
21 #include "event-loop.h" | 21 #include "event-loop.h" |
22 #include "event-top.h" | 22 #include "event-top.h" |
| 23 #include "queue.h" |
23 | 24 |
24 #ifdef HAVE_POLL | 25 #ifdef HAVE_POLL |
25 #if defined (HAVE_POLL_H) | 26 #if defined (HAVE_POLL_H) |
26 #include <poll.h> | 27 #include <poll.h> |
27 #elif defined (HAVE_SYS_POLL_H) | 28 #elif defined (HAVE_SYS_POLL_H) |
28 #include <sys/poll.h> | 29 #include <sys/poll.h> |
29 #endif | 30 #endif |
30 #endif | 31 #endif |
31 | 32 |
32 #include <sys/types.h> | 33 #include <sys/types.h> |
33 #include "gdb_string.h" | 34 #include <string.h> |
34 #include <errno.h> | 35 #include <errno.h> |
35 #include <sys/time.h> | 36 #include <sys/time.h> |
36 #include "exceptions.h" | 37 #include "exceptions.h" |
37 #include "gdb_assert.h" | 38 #include "gdb_assert.h" |
38 #include "gdb_select.h" | 39 #include "gdb_select.h" |
39 | 40 |
40 /* Tell create_file_handler what events we are interested in. | 41 /* Tell create_file_handler what events we are interested in. |
41 This is used by the select version of the event loop. */ | 42 This is used by the select version of the event loop. */ |
42 | 43 |
43 #define GDB_READABLE (1<<1) | 44 #define GDB_READABLE (1<<1) |
(...skipping 17 matching lines...) Expand all Loading... |
61 be called. We have 2 queues, one for file handlers that we listen | 62 be called. We have 2 queues, one for file handlers that we listen |
62 to in the event loop, and one for the file handlers+events that are | 63 to in the event loop, and one for the file handlers+events that are |
63 ready. The procedure PROC associated with each event is dependant | 64 ready. The procedure PROC associated with each event is dependant |
64 of the event source. In the case of monitored file descriptors, it | 65 of the event source. In the case of monitored file descriptors, it |
65 is always the same (handle_file_event). Its duty is to invoke the | 66 is always the same (handle_file_event). Its duty is to invoke the |
66 handler associated with the file descriptor whose state change | 67 handler associated with the file descriptor whose state change |
67 generated the event, plus doing other cleanups and such. In the | 68 generated the event, plus doing other cleanups and such. In the |
68 case of async signal handlers, it is | 69 case of async signal handlers, it is |
69 invoke_async_signal_handler. */ | 70 invoke_async_signal_handler. */ |
70 | 71 |
71 struct gdb_event | 72 typedef struct gdb_event |
72 { | 73 { |
73 /* Procedure to call to service this event. */ | 74 /* Procedure to call to service this event. */ |
74 event_handler_func *proc; | 75 event_handler_func *proc; |
75 | 76 |
76 /* Data to pass to the event handler. */ | 77 /* Data to pass to the event handler. */ |
77 event_data data; | 78 event_data data; |
78 | 79 } *gdb_event_p; |
79 /* Next in list of events or NULL. */ | |
80 struct gdb_event *next_event; | |
81 }; | |
82 | 80 |
83 /* Information about each file descriptor we register with the event | 81 /* Information about each file descriptor we register with the event |
84 loop. */ | 82 loop. */ |
85 | 83 |
86 typedef struct file_handler | 84 typedef struct file_handler |
87 { | 85 { |
88 int fd; /* File descriptor. */ | 86 int fd; /* File descriptor. */ |
89 int mask; /* Events we want to monitor: POLLIN, etc. */ | 87 int mask; /* Events we want to monitor: POLLIN, etc. */ |
90 int ready_mask; /* Events that have been seen since | 88 int ready_mask; /* Events that have been seen since |
91 the last time. */ | 89 the last time. */ |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 struct async_event_handler *next_handler; | 131 struct async_event_handler *next_handler; |
134 | 132 |
135 /* Function to call to do the work. */ | 133 /* Function to call to do the work. */ |
136 async_event_handler_func *proc; | 134 async_event_handler_func *proc; |
137 | 135 |
138 /* Argument to PROC. */ | 136 /* Argument to PROC. */ |
139 gdb_client_data client_data; | 137 gdb_client_data client_data; |
140 } | 138 } |
141 async_event_handler; | 139 async_event_handler; |
142 | 140 |
143 | 141 DECLARE_QUEUE_P(gdb_event_p); |
144 /* Event queue: | 142 DEFINE_QUEUE_P(gdb_event_p); |
145 - the first event in the queue is the head of the queue. | 143 static QUEUE(gdb_event_p) *event_queue = NULL; |
146 It will be the next to be serviced. | |
147 - the last event in the queue | |
148 | |
149 Events can be inserted at the front of the queue or at the end of | |
150 the queue. Events will be extracted from the queue for processing | |
151 starting from the head. Therefore, events inserted at the head of | |
152 the queue will be processed in a last in first out fashion, while | |
153 those inserted at the tail of the queue will be processed in a first | |
154 in first out manner. All the fields are NULL if the queue is | |
155 empty. */ | |
156 | |
157 static struct | |
158 { | |
159 gdb_event *first_event;» /* First pending event. */ | |
160 gdb_event *last_event;» /* Last pending event. */ | |
161 } | |
162 event_queue; | |
163 | 144 |
164 /* Gdb_notifier is just a list of file descriptors gdb is interested in. | 145 /* Gdb_notifier is just a list of file descriptors gdb is interested in. |
165 These are the input file descriptor, and the target file | 146 These are the input file descriptor, and the target file |
166 descriptor. We have two flavors of the notifier, one for platforms | 147 descriptor. We have two flavors of the notifier, one for platforms |
167 that have the POLL function, the other for those that don't, and | 148 that have the POLL function, the other for those that don't, and |
168 only support SELECT. Each of the elements in the gdb_notifier list is | 149 only support SELECT. Each of the elements in the gdb_notifier list is |
169 basically a description of what kind of events gdb is interested | 150 basically a description of what kind of events gdb is interested |
170 in, for each fd. */ | 151 in, for each fd. */ |
171 | 152 |
172 /* As of 1999-04-30 only the input file descriptor is registered with the | 153 /* As of 1999-04-30 only the input file descriptor is registered with the |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 async_event_handler *last_handler; | 245 async_event_handler *last_handler; |
265 } | 246 } |
266 async_event_handler_list; | 247 async_event_handler_list; |
267 | 248 |
268 static int invoke_async_signal_handlers (void); | 249 static int invoke_async_signal_handlers (void); |
269 static void create_file_handler (int fd, int mask, handler_func *proc, | 250 static void create_file_handler (int fd, int mask, handler_func *proc, |
270 gdb_client_data client_data); | 251 gdb_client_data client_data); |
271 static void handle_file_event (event_data data); | 252 static void handle_file_event (event_data data); |
272 static void check_async_event_handlers (void); | 253 static void check_async_event_handlers (void); |
273 static int gdb_wait_for_event (int); | 254 static int gdb_wait_for_event (int); |
error: old chunk mismatch |
None
OLD | NEW |