This is the mail archive of the gdb-patches@sourceware.cygnus.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[rfa/rfc/threads] Sligtly better cleanup, but where is that cleanup?


Hello,

The attached removes make_cleanup_func() from thread.c.  I _think_ it is
more robust than the old code - that was relying on the two functions:

	void foo (int);
and	void foo (void *);

using the same parameter passing mechanism.

However, I'm not 100% comfortable with it - it smashes an int into a
void*.  Further, I'm left puzzled as to where exactly the do_cleanups()
call for the two fixed make_cleanups() actually are.   I'm guessing that
there just happens to be a do_cleanups() call slightly further down the
stack.

	enjoy,
		Andrew
Mon May 22 16:20:31 2000  Andrew Cagney  <cagney@b1.cygnus.com>

	* thread.c (make_cleanup_restore_current_thread,
 	do_restore_current_thread_cleanup): New
 	functions.
	(thread_apply_all_command, thread_apply_command): Use.

Index: thread.c
===================================================================
RCS file: /cvs/src/src/gdb/thread.c,v
retrieving revision 1.1.1.11
diff -p -r1.1.1.11 thread.c
*** thread.c	2000/02/03 04:14:36	1.1.1.11
--- thread.c	2000/05/22 08:15:31
*************** restore_current_thread (pid)
*** 519,524 ****
--- 518,535 ----
      }
  }
  
+ static void
+ do_restore_current_thread_cleanup (void *arg)
+ {
+   restore_current_thread ((int) arg);
+ }
+ 
+ static struct cleanup *
+ make_cleanup_restore_current_thread (int tid)
+ {
+   return make_cleanup (do_restore_current_thread_cleanup, (void *) tid);
+ }
+ 
  /* 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:
*************** thread_apply_all_command (cmd, from_tty)
*** 539,546 ****
    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);
  
    for (tp = thread_list; tp; tp = tp->next)
      if (thread_alive (tp))
--- 550,556 ----
    if (cmd == NULL || *cmd == '\000')
      error ("Please specify a command following the thread ID list");
  
!   old_chain = make_cleanup_restore_current_thread (inferior_pid);
  
    for (tp = thread_list; tp; tp = tp->next)
      if (thread_alive (tp))
*************** thread_apply_command (tidlist, from_tty)
*** 575,582 ****
    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);
  
    while (tidlist < cmd)
      {
--- 585,591 ----
    if (*cmd == '\000')
      error ("Please specify a command following the thread ID list");
  
!   old_chain = make_cleanup_restore_current_thread (inferior_pid);
  
    while (tidlist < cmd)
      {

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]