1 /* Event loop machinery for GDB, the GNU debugger.
2 Copyright (C) 1999-2022 Free Software Foundation, Inc.
3 Written by Elena Zannoni <ezannoni@cygnus.com> of Cygnus Solutions.
5 This file is part of GDB.
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
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
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/>. */
20 #include "gdbsupport/common-defs.h"
21 #include "gdbsupport/event-loop.h"
26 #if defined (HAVE_POLL_H)
28 #elif defined (HAVE_SYS_POLL_H)
33 #include <sys/types.h>
34 #include "gdbsupport/gdb_sys_time.h"
35 #include "gdbsupport/gdb_select.h"
37 /* See event-loop.h. */
39 debug_event_loop_kind debug_event_loop
;
41 /* Tell create_file_handler what events we are interested in.
42 This is used by the select version of the event loop. */
44 #define GDB_READABLE (1<<1)
45 #define GDB_WRITABLE (1<<2)
46 #define GDB_EXCEPTION (1<<3)
48 /* Information about each file descriptor we register with the event
53 /* File descriptor. */
56 /* Events we want to monitor: POLLIN, etc. */
59 /* Events that have been seen since the last time. */
62 /* Procedure to call when fd is ready. */
65 /* Argument to pass to proc. */
66 gdb_client_data client_data
;
68 /* User-friendly name of this handler. */
71 /* If set, this file descriptor is used for a user interface. */
74 /* Was an error detected on this fd? */
77 /* Next registered file descriptor. */
78 struct file_handler
*next_file
;
81 /* Do we use poll or select ? */
86 #endif /* HAVE_POLL */
88 static unsigned char use_poll
= USE_POLL
;
95 /* Gdb_notifier is just a list of file descriptors gdb is interested in.
96 These are the input file descriptor, and the target file
97 descriptor. We have two flavors of the notifier, one for platforms
98 that have the POLL function, the other for those that don't, and
99 only support SELECT. Each of the elements in the gdb_notifier list is
100 basically a description of what kind of events gdb is interested
105 /* Ptr to head of file handler list. */
106 file_handler
*first_file_handler
;
108 /* Next file handler to handle, for the select variant. To level
109 the fairness across event sources, we serve file handlers in a
110 round-robin-like fashion. The number and order of the polled
111 file handlers may change between invocations, but this is good
113 file_handler
*next_file_handler
;
116 /* Ptr to array of pollfd structures. */
117 struct pollfd
*poll_fds
;
119 /* Next file descriptor to handle, for the poll variant. To level
120 the fairness across event sources, we poll the file descriptors
121 in a round-robin-like fashion. The number and order of the
122 polled file descriptors may change between invocations, but
123 this is good enough. */
124 int next_poll_fds_index
;
126 /* Timeout in milliseconds for calls to poll(). */
130 /* Masks to be used in the next call to select.
131 Bits are set in response to calls to create_file_handler. */
132 fd_set check_masks
[3];
134 /* What file descriptors were found ready by select. */
135 fd_set ready_masks
[3];
137 /* Number of file descriptors to monitor (for poll). */
138 /* Number of valid bits (highest fd value + 1) (for select). */
141 /* Time structure for calls to select(). */
142 struct timeval select_timeout
;
144 /* Flag to tell whether the timeout should be used. */
149 /* Structure associated with a timer. PROC will be executed at the
150 first occasion after WHEN. */
153 std::chrono::steady_clock::time_point when
;
155 struct gdb_timer
*next
;
156 timer_handler_func
*proc
; /* Function to call to do the work. */
157 gdb_client_data client_data
; /* Argument to async_handler_func. */
160 /* List of currently active timers. It is sorted in order of
161 increasing timers. */
164 /* Pointer to first in timer list. */
165 struct gdb_timer
*first_timer
;
167 /* Id of the last timer created. */
172 static void create_file_handler (int fd
, int mask
, handler_func
*proc
,
173 gdb_client_data client_data
,
174 std::string
&&name
, bool is_ui
);
175 static int gdb_wait_for_event (int);
176 static int update_wait_timeout (void);
177 static int poll_timers (void);
179 /* Process one high level event. If nothing is ready at this time,
180 wait for something to happen (via gdb_wait_for_event), then process
181 it. Returns >0 if something was done otherwise returns <0 (this
182 can happen if there are no event sources to wait for). */
185 gdb_do_one_event (void)
187 static int event_source_head
= 0;
188 const int number_of_sources
= 3;
191 /* First let's see if there are any asynchronous signal handlers
192 that are ready. These would be the result of invoking any of the
194 if (invoke_async_signal_handlers ())
197 /* To level the fairness across event sources, we poll them in a
198 round-robin fashion. */
199 for (current
= 0; current
< number_of_sources
; current
++)
203 switch (event_source_head
)
206 /* Are any timers that are ready? */
207 res
= poll_timers ();
210 /* Are there events already waiting to be collected on the
211 monitored file descriptors? */
212 res
= gdb_wait_for_event (0);
215 /* Are there any asynchronous event handlers ready? */
216 res
= check_async_event_handlers ();
219 internal_error (__FILE__
, __LINE__
,
220 "unexpected event_source_head %d",
225 if (event_source_head
== number_of_sources
)
226 event_source_head
= 0;
232 /* Block waiting for a new event. If gdb_wait_for_event returns -1,
233 we should get out because this means that there are no event
234 sources left. This will make the event loop stop, and the
237 if (gdb_wait_for_event (1) < 0)
240 /* If gdb_wait_for_event has returned 1, it means that one event has
241 been handled. We break out of the loop. */
245 /* See event-loop.h */
248 add_file_handler (int fd
, handler_func
*proc
, gdb_client_data client_data
,
249 std::string
&&name
, bool is_ui
)
258 /* Check to see if poll () is usable. If not, we'll switch to
259 use select. This can happen on systems like
260 m68k-motorola-sys, `poll' cannot be used to wait for `stdin'.
261 On m68k-motorola-sysv, tty's are not stream-based and not
265 if (poll (&fds
, 1, 0) == 1 && (fds
.revents
& POLLNVAL
))
268 internal_error (__FILE__
, __LINE__
,
269 _("use_poll without HAVE_POLL"));
270 #endif /* HAVE_POLL */
275 create_file_handler (fd
, POLLIN
, proc
, client_data
, std::move (name
),
278 internal_error (__FILE__
, __LINE__
,
279 _("use_poll without HAVE_POLL"));
283 create_file_handler (fd
, GDB_READABLE
| GDB_EXCEPTION
,
284 proc
, client_data
, std::move (name
), is_ui
);
287 /* Helper for add_file_handler.
289 For the poll case, MASK is a combination (OR) of POLLIN,
290 POLLRDNORM, POLLRDBAND, POLLPRI, POLLOUT, POLLWRNORM, POLLWRBAND:
291 these are the events we are interested in. If any of them occurs,
292 proc should be called.
294 For the select case, MASK is a combination of READABLE, WRITABLE,
295 EXCEPTION. PROC is the procedure that will be called when an event
296 occurs for FD. CLIENT_DATA is the argument to pass to PROC. */
299 create_file_handler (int fd
, int mask
, handler_func
* proc
,
300 gdb_client_data client_data
, std::string
&&name
,
303 file_handler
*file_ptr
;
305 /* Do we already have a file handler for this file? (We may be
306 changing its associated procedure). */
307 for (file_ptr
= gdb_notifier
.first_file_handler
; file_ptr
!= NULL
;
308 file_ptr
= file_ptr
->next_file
)
310 if (file_ptr
->fd
== fd
)
314 /* It is a new file descriptor. Add it to the list. Otherwise, just
315 change the data associated with it. */
316 if (file_ptr
== NULL
)
318 file_ptr
= new file_handler
;
320 file_ptr
->ready_mask
= 0;
321 file_ptr
->next_file
= gdb_notifier
.first_file_handler
;
322 gdb_notifier
.first_file_handler
= file_ptr
;
327 gdb_notifier
.num_fds
++;
328 if (gdb_notifier
.poll_fds
)
329 gdb_notifier
.poll_fds
=
330 (struct pollfd
*) xrealloc (gdb_notifier
.poll_fds
,
331 (gdb_notifier
.num_fds
332 * sizeof (struct pollfd
)));
334 gdb_notifier
.poll_fds
=
335 XNEW (struct pollfd
);
336 (gdb_notifier
.poll_fds
+ gdb_notifier
.num_fds
- 1)->fd
= fd
;
337 (gdb_notifier
.poll_fds
+ gdb_notifier
.num_fds
- 1)->events
= mask
;
338 (gdb_notifier
.poll_fds
+ gdb_notifier
.num_fds
- 1)->revents
= 0;
340 internal_error (__FILE__
, __LINE__
,
341 _("use_poll without HAVE_POLL"));
342 #endif /* HAVE_POLL */
346 if (mask
& GDB_READABLE
)
347 FD_SET (fd
, &gdb_notifier
.check_masks
[0]);
349 FD_CLR (fd
, &gdb_notifier
.check_masks
[0]);
351 if (mask
& GDB_WRITABLE
)
352 FD_SET (fd
, &gdb_notifier
.check_masks
[1]);
354 FD_CLR (fd
, &gdb_notifier
.check_masks
[1]);
356 if (mask
& GDB_EXCEPTION
)
357 FD_SET (fd
, &gdb_notifier
.check_masks
[2]);
359 FD_CLR (fd
, &gdb_notifier
.check_masks
[2]);
361 if (gdb_notifier
.num_fds
<= fd
)
362 gdb_notifier
.num_fds
= fd
+ 1;
366 file_ptr
->proc
= proc
;
367 file_ptr
->client_data
= client_data
;
368 file_ptr
->mask
= mask
;
369 file_ptr
->name
= std::move (name
);
370 file_ptr
->is_ui
= is_ui
;
373 /* Return the next file handler to handle, and advance to the next
374 file handler, wrapping around if the end of the list is
377 static file_handler
*
378 get_next_file_handler_to_handle_and_advance (void)
380 file_handler
*curr_next
;
382 /* The first time around, this is still NULL. */
383 if (gdb_notifier
.next_file_handler
== NULL
)
384 gdb_notifier
.next_file_handler
= gdb_notifier
.first_file_handler
;
386 curr_next
= gdb_notifier
.next_file_handler
;
387 gdb_assert (curr_next
!= NULL
);
390 gdb_notifier
.next_file_handler
= curr_next
->next_file
;
391 /* Wrap around, if necessary. */
392 if (gdb_notifier
.next_file_handler
== NULL
)
393 gdb_notifier
.next_file_handler
= gdb_notifier
.first_file_handler
;
398 /* Remove the file descriptor FD from the list of monitored fd's:
399 i.e. we don't care anymore about events on the FD. */
401 delete_file_handler (int fd
)
403 file_handler
*file_ptr
, *prev_ptr
= NULL
;
407 struct pollfd
*new_poll_fds
;
410 /* Find the entry for the given file. */
412 for (file_ptr
= gdb_notifier
.first_file_handler
; file_ptr
!= NULL
;
413 file_ptr
= file_ptr
->next_file
)
415 if (file_ptr
->fd
== fd
)
419 if (file_ptr
== NULL
)
425 /* Create a new poll_fds array by copying every fd's information
426 but the one we want to get rid of. */
428 new_poll_fds
= (struct pollfd
*)
429 xmalloc ((gdb_notifier
.num_fds
- 1) * sizeof (struct pollfd
));
431 for (i
= 0, j
= 0; i
< gdb_notifier
.num_fds
; i
++)
433 if ((gdb_notifier
.poll_fds
+ i
)->fd
!= fd
)
435 (new_poll_fds
+ j
)->fd
= (gdb_notifier
.poll_fds
+ i
)->fd
;
436 (new_poll_fds
+ j
)->events
= (gdb_notifier
.poll_fds
+ i
)->events
;
437 (new_poll_fds
+ j
)->revents
438 = (gdb_notifier
.poll_fds
+ i
)->revents
;
442 xfree (gdb_notifier
.poll_fds
);
443 gdb_notifier
.poll_fds
= new_poll_fds
;
444 gdb_notifier
.num_fds
--;
446 internal_error (__FILE__
, __LINE__
,
447 _("use_poll without HAVE_POLL"));
448 #endif /* HAVE_POLL */
452 if (file_ptr
->mask
& GDB_READABLE
)
453 FD_CLR (fd
, &gdb_notifier
.check_masks
[0]);
454 if (file_ptr
->mask
& GDB_WRITABLE
)
455 FD_CLR (fd
, &gdb_notifier
.check_masks
[1]);
456 if (file_ptr
->mask
& GDB_EXCEPTION
)
457 FD_CLR (fd
, &gdb_notifier
.check_masks
[2]);
459 /* Find current max fd. */
461 if ((fd
+ 1) == gdb_notifier
.num_fds
)
463 gdb_notifier
.num_fds
--;
464 for (i
= gdb_notifier
.num_fds
; i
; i
--)
466 if (FD_ISSET (i
- 1, &gdb_notifier
.check_masks
[0])
467 || FD_ISSET (i
- 1, &gdb_notifier
.check_masks
[1])
468 || FD_ISSET (i
- 1, &gdb_notifier
.check_masks
[2]))
471 gdb_notifier
.num_fds
= i
;
475 /* Deactivate the file descriptor, by clearing its mask,
476 so that it will not fire again. */
480 /* If this file handler was going to be the next one to be handled,
481 advance to the next's next, if any. */
482 if (gdb_notifier
.next_file_handler
== file_ptr
)
484 if (file_ptr
->next_file
== NULL
485 && file_ptr
== gdb_notifier
.first_file_handler
)
486 gdb_notifier
.next_file_handler
= NULL
;
488 get_next_file_handler_to_handle_and_advance ();
491 /* Get rid of the file handler in the file handler list. */
492 if (file_ptr
== gdb_notifier
.first_file_handler
)
493 gdb_notifier
.first_file_handler
= file_ptr
->next_file
;
496 for (prev_ptr
= gdb_notifier
.first_file_handler
;
497 prev_ptr
->next_file
!= file_ptr
;
498 prev_ptr
= prev_ptr
->next_file
)
500 prev_ptr
->next_file
= file_ptr
->next_file
;
506 /* Handle the given event by calling the procedure associated to the
507 corresponding file handler. */
510 handle_file_event (file_handler
*file_ptr
, int ready_mask
)
519 /* With poll, the ready_mask could have any of three events
520 set to 1: POLLHUP, POLLERR, POLLNVAL. These events
521 cannot be used in the requested event mask (events), but
522 they can be returned in the return mask (revents). We
523 need to check for those event too, and add them to the
524 mask which will be passed to the handler. */
526 /* See if the desired events (mask) match the received
527 events (ready_mask). */
532 /* POLLHUP means EOF, but can be combined with POLLIN to
533 signal more data to read. */
534 error_mask
= POLLHUP
| POLLERR
| POLLNVAL
;
535 mask
= ready_mask
& (file_ptr
->mask
| error_mask
);
537 if ((mask
& (POLLERR
| POLLNVAL
)) != 0)
539 /* Work in progress. We may need to tell somebody
540 what kind of error we had. */
542 warning (_("Error detected on fd %d"), file_ptr
->fd
);
544 warning (_("Invalid or non-`poll'able fd %d"),
551 internal_error (__FILE__
, __LINE__
,
552 _("use_poll without HAVE_POLL"));
553 #endif /* HAVE_POLL */
557 if (ready_mask
& GDB_EXCEPTION
)
559 warning (_("Exception condition detected on fd %d"),
565 mask
= ready_mask
& file_ptr
->mask
;
568 /* If there was a match, then call the handler. */
571 event_loop_ui_debug_printf (file_ptr
->is_ui
,
572 "invoking fd file handler `%s`",
573 file_ptr
->name
.c_str ());
574 file_ptr
->proc (file_ptr
->error
, file_ptr
->client_data
);
580 /* Wait for new events on the monitored file descriptors. Run the
581 event handler if the first descriptor that is detected by the poll.
582 If BLOCK and if there are no events, this function will block in
583 the call to poll. Return 1 if an event was handled. Return -1 if
584 there are no file descriptors to monitor. Return 1 if an event was
585 handled, otherwise returns 0. */
588 gdb_wait_for_event (int block
)
590 file_handler
*file_ptr
;
593 /* Make sure all output is done before getting another event. */
596 if (gdb_notifier
.num_fds
== 0)
600 update_wait_timeout ();
608 timeout
= gdb_notifier
.timeout_valid
? gdb_notifier
.poll_timeout
: -1;
612 num_found
= poll (gdb_notifier
.poll_fds
,
613 (unsigned long) gdb_notifier
.num_fds
, timeout
);
615 /* Don't print anything if we get out of poll because of a
617 if (num_found
== -1 && errno
!= EINTR
)
618 perror_with_name (("poll"));
620 internal_error (__FILE__
, __LINE__
,
621 _("use_poll without HAVE_POLL"));
622 #endif /* HAVE_POLL */
626 struct timeval select_timeout
;
627 struct timeval
*timeout_p
;
630 timeout_p
= gdb_notifier
.timeout_valid
631 ? &gdb_notifier
.select_timeout
: NULL
;
634 memset (&select_timeout
, 0, sizeof (select_timeout
));
635 timeout_p
= &select_timeout
;
638 gdb_notifier
.ready_masks
[0] = gdb_notifier
.check_masks
[0];
639 gdb_notifier
.ready_masks
[1] = gdb_notifier
.check_masks
[1];
640 gdb_notifier
.ready_masks
[2] = gdb_notifier
.check_masks
[2];
641 num_found
= gdb_select (gdb_notifier
.num_fds
,
642 &gdb_notifier
.ready_masks
[0],
643 &gdb_notifier
.ready_masks
[1],
644 &gdb_notifier
.ready_masks
[2],
647 /* Clear the masks after an error from select. */
650 FD_ZERO (&gdb_notifier
.ready_masks
[0]);
651 FD_ZERO (&gdb_notifier
.ready_masks
[1]);
652 FD_ZERO (&gdb_notifier
.ready_masks
[2]);
654 /* Dont print anything if we got a signal, let gdb handle
657 perror_with_name (("select"));
661 /* Avoid looking at poll_fds[i]->revents if no event fired. */
665 /* Run event handlers. We always run just one handler and go back
666 to polling, in case a handler changes the notifier list. Since
667 events for sources we haven't consumed yet wake poll/select
668 immediately, no event is lost. */
670 /* To level the fairness across event descriptors, we handle them in
671 a round-robin-like fashion. The number and order of descriptors
672 may change between invocations, but this is good enough. */
681 if (gdb_notifier
.next_poll_fds_index
>= gdb_notifier
.num_fds
)
682 gdb_notifier
.next_poll_fds_index
= 0;
683 i
= gdb_notifier
.next_poll_fds_index
++;
685 gdb_assert (i
< gdb_notifier
.num_fds
);
686 if ((gdb_notifier
.poll_fds
+ i
)->revents
)
690 for (file_ptr
= gdb_notifier
.first_file_handler
;
692 file_ptr
= file_ptr
->next_file
)
694 if (file_ptr
->fd
== (gdb_notifier
.poll_fds
+ i
)->fd
)
697 gdb_assert (file_ptr
!= NULL
);
699 mask
= (gdb_notifier
.poll_fds
+ i
)->revents
;
700 handle_file_event (file_ptr
, mask
);
703 internal_error (__FILE__
, __LINE__
,
704 _("use_poll without HAVE_POLL"));
705 #endif /* HAVE_POLL */
709 /* See comment about even source fairness above. */
714 file_ptr
= get_next_file_handler_to_handle_and_advance ();
716 if (FD_ISSET (file_ptr
->fd
, &gdb_notifier
.ready_masks
[0]))
717 mask
|= GDB_READABLE
;
718 if (FD_ISSET (file_ptr
->fd
, &gdb_notifier
.ready_masks
[1]))
719 mask
|= GDB_WRITABLE
;
720 if (FD_ISSET (file_ptr
->fd
, &gdb_notifier
.ready_masks
[2]))
721 mask
|= GDB_EXCEPTION
;
725 handle_file_event (file_ptr
, mask
);
731 /* Create a timer that will expire in MS milliseconds from now. When
732 the timer is ready, PROC will be executed. At creation, the timer
733 is added to the timers queue. This queue is kept sorted in order
734 of increasing timers. Return a handle to the timer struct. */
737 create_timer (int ms
, timer_handler_func
*proc
,
738 gdb_client_data client_data
)
740 using namespace std::chrono
;
741 struct gdb_timer
*timer_ptr
, *timer_index
, *prev_timer
;
743 steady_clock::time_point time_now
= steady_clock::now ();
745 timer_ptr
= new gdb_timer ();
746 timer_ptr
->when
= time_now
+ milliseconds (ms
);
747 timer_ptr
->proc
= proc
;
748 timer_ptr
->client_data
= client_data
;
749 timer_list
.num_timers
++;
750 timer_ptr
->timer_id
= timer_list
.num_timers
;
752 /* Now add the timer to the timer queue, making sure it is sorted in
753 increasing order of expiration. */
755 for (timer_index
= timer_list
.first_timer
;
757 timer_index
= timer_index
->next
)
759 if (timer_index
->when
> timer_ptr
->when
)
763 if (timer_index
== timer_list
.first_timer
)
765 timer_ptr
->next
= timer_list
.first_timer
;
766 timer_list
.first_timer
= timer_ptr
;
771 for (prev_timer
= timer_list
.first_timer
;
772 prev_timer
->next
!= timer_index
;
773 prev_timer
= prev_timer
->next
)
776 prev_timer
->next
= timer_ptr
;
777 timer_ptr
->next
= timer_index
;
780 gdb_notifier
.timeout_valid
= 0;
781 return timer_ptr
->timer_id
;
784 /* There is a chance that the creator of the timer wants to get rid of
785 it before it expires. */
787 delete_timer (int id
)
789 struct gdb_timer
*timer_ptr
, *prev_timer
= NULL
;
791 /* Find the entry for the given timer. */
793 for (timer_ptr
= timer_list
.first_timer
; timer_ptr
!= NULL
;
794 timer_ptr
= timer_ptr
->next
)
796 if (timer_ptr
->timer_id
== id
)
800 if (timer_ptr
== NULL
)
802 /* Get rid of the timer in the timer list. */
803 if (timer_ptr
== timer_list
.first_timer
)
804 timer_list
.first_timer
= timer_ptr
->next
;
807 for (prev_timer
= timer_list
.first_timer
;
808 prev_timer
->next
!= timer_ptr
;
809 prev_timer
= prev_timer
->next
)
811 prev_timer
->next
= timer_ptr
->next
;
815 gdb_notifier
.timeout_valid
= 0;
818 /* Convert a std::chrono duration to a struct timeval. */
820 template<typename Duration
>
821 static struct timeval
822 duration_cast_timeval (const Duration
&d
)
824 using namespace std::chrono
;
825 seconds sec
= duration_cast
<seconds
> (d
);
826 microseconds msec
= duration_cast
<microseconds
> (d
- sec
);
829 tv
.tv_sec
= sec
.count ();
830 tv
.tv_usec
= msec
.count ();
834 /* Update the timeout for the select() or poll(). Returns true if the
835 timer has already expired, false otherwise. */
838 update_wait_timeout (void)
840 if (timer_list
.first_timer
!= NULL
)
842 using namespace std::chrono
;
843 steady_clock::time_point time_now
= steady_clock::now ();
844 struct timeval timeout
;
846 if (timer_list
.first_timer
->when
< time_now
)
848 /* It expired already. */
854 steady_clock::duration d
= timer_list
.first_timer
->when
- time_now
;
855 timeout
= duration_cast_timeval (d
);
858 /* Update the timeout for select/ poll. */
862 gdb_notifier
.poll_timeout
= timeout
.tv_sec
* 1000;
864 internal_error (__FILE__
, __LINE__
,
865 _("use_poll without HAVE_POLL"));
866 #endif /* HAVE_POLL */
870 gdb_notifier
.select_timeout
.tv_sec
= timeout
.tv_sec
;
871 gdb_notifier
.select_timeout
.tv_usec
= timeout
.tv_usec
;
873 gdb_notifier
.timeout_valid
= 1;
875 if (timer_list
.first_timer
->when
< time_now
)
879 gdb_notifier
.timeout_valid
= 0;
884 /* Check whether a timer in the timers queue is ready. If a timer is
885 ready, call its handler and return. Update the timeout for the
886 select() or poll() as well. Return 1 if an event was handled,
887 otherwise returns 0.*/
892 if (update_wait_timeout ())
894 struct gdb_timer
*timer_ptr
= timer_list
.first_timer
;
895 timer_handler_func
*proc
= timer_ptr
->proc
;
896 gdb_client_data client_data
= timer_ptr
->client_data
;
898 /* Get rid of the timer from the beginning of the list. */
899 timer_list
.first_timer
= timer_ptr
->next
;
901 /* Delete the timer before calling the callback, not after, in
902 case the callback itself decides to try deleting the timer
906 /* Call the procedure associated with that timer. */
907 (proc
) (client_data
);