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]

[patch] procfs.c and make_cleanup_func


Yawn :-)

	Andrew
Mon May 22 15:49:13 2000  Andrew Cagney  <cagney@b1.cygnus.com>

	* procfs.c (info_proc_cmd): Use make_cleanup_freeargv.
	(proc_iterate_over_mappings): Use make_cleanup_close.
	(proc_get_LDT_entry): Ditto.
	(do_closedir_cleanup): New function.
	(proc_update_threads): Use.
	(do_destroy_procinfo_cleanup): New function.
	(info_proc_cmd): Use.

Index: procfs.c
===================================================================
RCS file: /cvs/src/src/gdb/procfs.c,v
retrieving revision 1.11
diff -p -r1.11 procfs.c
*** procfs.c	2000/05/10 17:38:16	1.11
--- procfs.c	2000/05/22 06:16:13
*************** static procinfo *find_procinfo_or_die PA
*** 328,333 ****
--- 328,334 ----
  static procinfo *find_procinfo        PARAMS ((int pid, int tid));
  static procinfo *create_procinfo      PARAMS ((int pid, int tid));
  static void      destroy_procinfo     PARAMS ((procinfo *p));
+ static void do_destroy_procinfo_cleanup (void *);
  static void      dead_procinfo        PARAMS ((procinfo *p, 
  					       char *msg, int killp));
  static int       open_procinfo_files  PARAMS ((procinfo *p, int which));
*************** destroy_procinfo (pi)
*** 683,688 ****
--- 684,695 ----
      }
  }
  
+ static void
+ do_destroy_procinfo_cleanup (void *pi)
+ {
+   destroy_procinfo (pi);
+ }
+ 
  enum { NOKILL, KILL };
  
  /*
*************** proc_iterate_over_mappings (func)
*** 2633,2639 ****
      proc_error (pi, "proc_iterate_over_mappings (open)", __LINE__);
  
    /* Make sure it gets closed again.  */
!   make_cleanup ((make_cleanup_func) close, (void *) map_fd);
  
    /* Allocate space for mapping (lifetime only for this function). */
    map = alloca (sizeof (struct prmap));
--- 2640,2646 ----
      proc_error (pi, "proc_iterate_over_mappings (open)", __LINE__);
  
    /* Make sure it gets closed again.  */
!   make_cleanup_close (map_fd);
  
    /* Allocate space for mapping (lifetime only for this function). */
    map = alloca (sizeof (struct prmap));
*************** proc_get_LDT_entry (pi, key)
*** 2744,2750 ****
        return NULL;
      }
    /* Make sure it gets closed again! */
!   old_chain = make_cleanup ((make_cleanup_func) close, (void *) fd);
  
    /* Now 'read' thru the table, find a match and return it.  */
    while (read (fd, ldt_entry, sizeof (struct ssd)) == sizeof (struct ssd))
--- 2751,2757 ----
        return NULL;
      }
    /* Make sure it gets closed again! */
!   old_chain = make_cleanup_close (fd);
  
    /* Now 'read' thru the table, find a match and return it.  */
    while (read (fd, ldt_entry, sizeof (struct ssd)) == sizeof (struct ssd))
*************** proc_update_threads (pi)
*** 3013,3018 ****
--- 3020,3031 ----
  /*
   * Unixware and Solaris 6 (and later) version
   */
+ static void
+ do_closedir_cleanup (void *dir)
+ {
+   closedir (dir);
+ }
+ 
  int
  proc_update_threads (pi)
       procinfo *pi;
*************** proc_update_threads (pi)
*** 3051,3057 ****
    if ((dirp = opendir (pathname)) == NULL)
      proc_error (pi, "update_threads, opendir", __LINE__);
  
!   old_chain = make_cleanup ((make_cleanup_func) closedir, dirp);
    while ((direntry = readdir (dirp)) != NULL)
      if (direntry->d_name[0] != '.')		/* skip '.' and '..' */
        {
--- 3064,3070 ----
    if ((dirp = opendir (pathname)) == NULL)
      proc_error (pi, "update_threads, opendir", __LINE__);
  
!   old_chain = make_cleanup (do_closedir_cleanup, dirp);
    while ((direntry = readdir (dirp)) != NULL)
      if (direntry->d_name[0] != '.')		/* skip '.' and '..' */
        {
*************** info_proc_cmd (args, from_tty)
*** 5033,5039 ****
        if ((argv = buildargv (args)) == NULL)
  	nomem (0);
        else
! 	make_cleanup ((make_cleanup_func) freeargv, argv);
      }
    while (argv != NULL && *argv != NULL)
      {
--- 5046,5052 ----
        if ((argv = buildargv (args)) == NULL)
  	nomem (0);
        else
! 	make_cleanup_freeargv (argv);
      }
    while (argv != NULL && *argv != NULL)
      {
*************** info_proc_cmd (args, from_tty)
*** 5067,5073 ****
  	   /* No.  So open a procinfo for it, but 
  	      remember to close it again when finished.  */
  	   process = create_procinfo (pid, 0);
! 	   make_cleanup ((make_cleanup_func) destroy_procinfo, process);
  	   if (!open_procinfo_files (process, FD_CTL))
  	     proc_error (process, "info proc, open_procinfo_files", __LINE__);
  	 }
--- 5080,5086 ----
  	   /* No.  So open a procinfo for it, but 
  	      remember to close it again when finished.  */
  	   process = create_procinfo (pid, 0);
! 	   make_cleanup (do_destroy_procinfo_cleanup, process);
  	   if (!open_procinfo_files (process, FD_CTL))
  	     proc_error (process, "info proc, open_procinfo_files", __LINE__);
  	 }

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