From 6ecce94d4826f27539dcd85265a07ed6bd54f7ba Mon Sep 17 00:00:00 2001 From: Andrew Cagney Date: Wed, 7 Jun 2000 04:43:30 +0000 Subject: [PATCH] Purge last remaining make_cleanup_func. --- gdb/ChangeLog | 10 ++++++++++ gdb/TODO | 11 +++-------- gdb/defs.h | 7 ------- gdb/thread.c | 32 ++++++++++++++++++++++++++++---- 4 files changed, 41 insertions(+), 19 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 083c2ba679..5c2d7c3898 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,13 @@ +Mon Jun 5 18:44:14 2000 Andrew Cagney + + * thread.c (make_cleanup_restore_current_thread, + do_restore_current_thread_cleanup): New functions. + (thread_apply_all_command, thread_apply_command): Use. Call + do_cleanups when finished. + + * defs.h (make_cleanup_func): Delete typedef. + * TODO: Update. + Wed Jun 7 11:34:54 2000 Andrew Cagney * arch-utils.c (target_byte_order, target_byte_order_auto, diff --git a/gdb/TODO b/gdb/TODO index e5398c9d51..7fa33c8916 100644 --- a/gdb/TODO +++ b/gdb/TODO @@ -101,14 +101,6 @@ Eliminate all uses of PARAMS in GDB's source code. -- -Elimination of make_cleanup_func. (Andrew Cagney) - -make_cleanup_func elimination -http://sourceware.cygnus.com/ml/gdb-patches/2000-q1/msg00791.html -http://sourceware.cygnus.com/ml/gdb-patches/2000-q1/msg00814.html - --- - Fix copyright notices. Turns out that ``1998-2000'' isn't considered valid :-( @@ -143,6 +135,9 @@ file at a time. Elimination of ``(catch_errors_ftype *) func''. Like make_cleanup_func it isn't portable. +http://sourceware.cygnus.com/ml/gdb-patches/2000-q1/msg00791.html +http://sourceware.cygnus.com/ml/gdb-patches/2000-q1/msg00814.html + -- diff --git a/gdb/defs.h b/gdb/defs.h index 400f630b76..093358ff85 100644 --- a/gdb/defs.h +++ b/gdb/defs.h @@ -306,13 +306,6 @@ extern void discard_final_cleanups (struct cleanup *); extern void discard_exec_error_cleanups (struct cleanup *); extern void discard_my_cleanups (struct cleanup **, struct cleanup *); -/* DEPRECATED: cagney/2000-03-04: Do not use this typedef to cast - function pointers so that they match the argument to the various - cleanup functions. Post GDB 5.0, this typedef will be - deleted. [Editors note: cagney was the person that added most of - those type casts] */ -typedef void (*make_cleanup_func) (void *); - /* NOTE: cagney/2000-03-04: This typedef is strictly for the make_cleanup function declarations below. Do not use this typedef as a cast when passing functions into the make_cleanup() code. diff --git a/gdb/thread.c b/gdb/thread.c index 2c874703e3..38e74d45b1 100644 --- a/gdb/thread.c +++ b/gdb/thread.c @@ -519,6 +519,28 @@ restore_current_thread (pid) } } +struct current_thread_cleanup +{ + int inferior_pid; +}; + +static void +do_restore_current_thread_cleanup (void *arg) +{ + struct current_thread_cleanup *old = arg; + restore_current_thread (old->inferior_pid); + free (old); +} + +static struct cleanup * +make_cleanup_restore_current_thread (int inferior_pid) +{ + struct current_thread_cleanup *old + = xmalloc (sizeof (struct current_thread_cleanup)); + old->inferior_pid = inferior_pid; + return make_cleanup (do_restore_current_thread_cleanup, old); +} + /* Apply a GDB command to a list of threads. List syntax is a whitespace seperated list of numbers, or ranges, or the keyword `all'. Ranges consist of two numbers seperated by a hyphen. Examples: @@ -539,8 +561,7 @@ thread_apply_all_command (cmd, from_tty) if (cmd == NULL || *cmd == '\000') error ("Please specify a command following the thread ID list"); - old_chain = make_cleanup ((make_cleanup_func) restore_current_thread, - (void *) inferior_pid); + old_chain = make_cleanup_restore_current_thread (inferior_pid); for (tp = thread_list; tp; tp = tp->next) if (thread_alive (tp)) @@ -556,6 +577,8 @@ thread_apply_all_command (cmd, from_tty) #endif execute_command (cmd, from_tty); } + + do_cleanups (old_chain); } static void @@ -575,8 +598,7 @@ thread_apply_command (tidlist, from_tty) if (*cmd == '\000') error ("Please specify a command following the thread ID list"); - old_chain = make_cleanup ((make_cleanup_func) restore_current_thread, - (void *) inferior_pid); + old_chain = make_cleanup_restore_current_thread (inferior_pid); while (tidlist < cmd) { @@ -627,6 +649,8 @@ thread_apply_command (tidlist, from_tty) } } } + + do_cleanups (old_chain); } /* Switch to the specified thread. Will dispatch off to thread_apply_command