X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=gdb%2Fgdbserver%2Fserver.c;h=25c62aad830ad35daec6d9a36ceb77ea355169ca;hb=37991b4f52e7d13c586137f401ac65dec4aa732f;hp=e960c10d40266f71df3b70307691bdde59c9852e;hpb=32603266e5688718faad35b7502aa0b72a42764a;p=binutils-gdb.git diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c index e960c10d402..25c62aad830 100644 --- a/gdb/gdbserver/server.c +++ b/gdb/gdbserver/server.c @@ -43,6 +43,7 @@ #include "common/pathstuff.h" #include "common/selftest.h" +#include "common/scope-exit.h" #define require_running_or_return(BUF) \ if (!target_running ()) \ @@ -3545,17 +3546,16 @@ detach_or_kill_for_exit (void) /* Value that will be passed to exit(3) when gdbserver exits. */ static int exit_code; -/* Cleanup version of detach_or_kill_for_exit. */ +/* Wrapper for detach_or_kill_for_exit that catches and prints + errors. */ static void -detach_or_kill_for_exit_cleanup (void *ignore) +detach_or_kill_for_exit_cleanup () { - TRY { detach_or_kill_for_exit (); } - CATCH (exception, RETURN_MASK_ALL) { fflush (stdout); @@ -3832,7 +3832,8 @@ captured_main (int argc, char *argv[]) cs.last_status.value.integer = 0; cs.last_ptid = minus_one_ptid; } - make_cleanup (detach_or_kill_for_exit_cleanup, NULL); + + SCOPE_EXIT { detach_or_kill_for_exit_cleanup (); }; /* Don't report shared library events on the initial connection, even if some libraries are preloaded. Avoids the "stopped by