diff options
author | Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> | 2021-04-22 17:22:39 +0200 |
---|---|---|
committer | Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> | 2021-04-22 17:22:39 +0200 |
commit | c4c493de2bbfc7414d0ec51f40f17cd7b1ff74f2 (patch) | |
tree | a92975d7b21a379e8add3781e6b5b4a18c17b3cf /gdb/infcmd.c | |
parent | 1194676e0be8d28a2ed631fe2b8d560409240ff0 (diff) | |
download | gdb-c4c493de2bbfc7414d0ec51f40f17cd7b1ff74f2.zip gdb-c4c493de2bbfc7414d0ec51f40f17cd7b1ff74f2.tar.gz gdb-c4c493de2bbfc7414d0ec51f40f17cd7b1ff74f2.tar.bz2 |
gdb/continuations: use lambdas instead of function pointers
Use lambdas and std::list to track inferior continuations. This is a
refactoring.
gdb/ChangeLog:
2021-04-22 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
* inferior.h (class inferior) <continuations>: Change the type
to be an std::list of std::function's.
Update the references and uses below.
* continuations.c (struct continuation): Delete.
(make_continuation): Delete.
(do_my_continuations_1): Delete.
(do_my_continuations): Delete.
(discard_my_continuations_1): Delete.
(discard_my_continuations): Delete.
(add_inferior_continuation): Update.
(do_all_inferior_continuations): Update.
(discard_all_inferior_continuations): Update.
* continuations.h (add_inferior_continuation): Update to take
an std::function as the parameter.
* infcmd.c (struct attach_command_continuation_args): Delete.
(attach_command_continuation): Delete.
(attach_command_continuation_free_args): Delete.
(attach_command): Update.
(notice_new_inferior): Update.
Diffstat (limited to 'gdb/infcmd.c')
-rw-r--r-- | gdb/infcmd.c | 45 |
1 files changed, 8 insertions, 37 deletions
diff --git a/gdb/infcmd.c b/gdb/infcmd.c index 5c3ee02..e06db49 100644 --- a/gdb/infcmd.c +++ b/gdb/infcmd.c @@ -2540,30 +2540,6 @@ attach_post_wait (int from_tty, enum attach_post_wait_mode mode) } } -struct attach_command_continuation_args -{ - int from_tty; - enum attach_post_wait_mode mode; -}; - -static void -attach_command_continuation (void *args) -{ - struct attach_command_continuation_args *a - = (struct attach_command_continuation_args *) args; - - attach_post_wait (a->from_tty, a->mode); -} - -static void -attach_command_continuation_free_args (void *args) -{ - struct attach_command_continuation_args *a - = (struct attach_command_continuation_args *) args; - - xfree (a); -} - /* "attach" command entry point. Takes a program started up outside of gdb and ``attaches'' to it. This stops it cold in its tracks and allows us to start debugging it. */ @@ -2661,8 +2637,6 @@ attach_command (const char *args, int from_tty) E.g. Mach 3 or GNU hurd. */ if (!target_attach_no_wait ()) { - struct attach_command_continuation_args *a; - /* Careful here. See comments in inferior.h. Basically some OSes don't ignore SIGSTOPs on continue requests anymore. We need a way for handle_inferior_event to reset the stop_signal @@ -2671,11 +2645,10 @@ attach_command (const char *args, int from_tty) inferior->control.stop_soon = STOP_QUIETLY_NO_SIGSTOP; /* Wait for stop. */ - a = XNEW (struct attach_command_continuation_args); - a->from_tty = from_tty; - a->mode = mode; - add_inferior_continuation (attach_command_continuation, a, - attach_command_continuation_free_args); + add_inferior_continuation ([=] () + { + attach_post_wait (from_tty, mode); + }); /* Let infrun consider waiting for events out of this target. */ @@ -2719,7 +2692,6 @@ notice_new_inferior (thread_info *thr, int leave_running, int from_tty) if (thr->executing) { - struct attach_command_continuation_args *a; struct inferior *inferior = current_inferior (); /* We're going to install breakpoints, and poke at memory, @@ -2730,11 +2702,10 @@ notice_new_inferior (thread_info *thr, int leave_running, int from_tty) inferior->control.stop_soon = STOP_QUIETLY_REMOTE; /* Wait for stop before proceeding. */ - a = XNEW (struct attach_command_continuation_args); - a->from_tty = from_tty; - a->mode = mode; - add_inferior_continuation (attach_command_continuation, a, - attach_command_continuation_free_args); + add_inferior_continuation ([=] () + { + attach_post_wait (from_tty, mode); + }); return; } |