From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 993 invoked by alias); 29 Sep 2005 17:16:43 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 962 invoked by uid 22791); 29 Sep 2005 17:16:32 -0000 Received: from qnxmail.qnx.com (HELO nimbus.ott.qnx.com) (209.226.137.76) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Thu, 29 Sep 2005 17:16:32 +0000 Received: from [10.42.102.101] (10.42.102.101 [10.42.102.101]) by nimbus.ott.qnx.com with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2653.13) id TX9QTDDR; Thu, 29 Sep 2005 13:16:31 -0400 Message-ID: <433C21F1.9000903@qnx.com> Date: Thu, 29 Sep 2005 17:16:00 -0000 From: Kris Warkentin User-Agent: Mozilla Thunderbird 0.8 (X11/20040913) MIME-Version: 1.0 To: gdb-patches@sources.redhat.com Subject: [patch] clean up potential memory leak in thread.c Content-Type: multipart/mixed; boundary="------------080102050205020707020302" X-SW-Source: 2005-09/txt/msg00291.txt.bz2 This is a multi-part message in MIME format. --------------080102050205020707020302 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 496 Got rid of a 'FIXME' by implementing a target hook for cleaning up private thread info. Look kosher? cheers, Kris 2005-09-29 Kris Warkentin * target.h (struct target_ops): Add new to_delete_extra_thread_info hook and define target_delete_extra_thread_info macro. * target.c (update_current_target): INHERIT and de_fault above target function. * thread.c (free_thread): Call target_delete_extra_thread_info before freeing private thread data. --------------080102050205020707020302 Content-Type: text/x-patch; name="tidinfo.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="tidinfo.diff" Content-length: 2641 Index: target.h =================================================================== RCS file: /cvs/src/src/gdb/target.h,v retrieving revision 1.76 diff -u -r1.76 target.h --- target.h 4 Sep 2005 16:18:20 -0000 1.76 +++ target.h 29 Sep 2005 16:56:31 -0000 @@ -53,6 +53,7 @@ #include "symtab.h" #include "dcache.h" #include "memattr.h" +#include "gdbthread.h" enum strata { @@ -374,6 +375,7 @@ void (*to_find_new_threads) (void); char *(*to_pid_to_str) (ptid_t); char *(*to_extra_thread_info) (struct thread_info *); + void (*to_delete_extra_thread_info) (struct private_thread_info *); void (*to_stop) (void); void (*to_rcmd) (char *command, struct ui_file *output); struct symtab_and_line *(*to_enable_exception_callback) (enum @@ -923,6 +925,11 @@ #define target_extra_thread_info(TP) \ (current_target.to_extra_thread_info (TP)) +/* Free any data held in private thread info. The private_thread_info + structure is freed by the caller. */ +#define target_delete_extra_thread_info(P) \ + (current_target.to_delete_extra_thread_info (P)) + /* * New Objfile Event Hook: * Index: target.c =================================================================== RCS file: /cvs/src/src/gdb/target.c,v retrieving revision 1.111 diff -u -r1.111 target.c --- target.c 4 Sep 2005 16:18:20 -0000 1.111 +++ target.c 29 Sep 2005 16:56:31 -0000 @@ -434,6 +434,7 @@ INHERIT (to_find_new_threads, t); INHERIT (to_pid_to_str, t); INHERIT (to_extra_thread_info, t); + INHERIT (to_delete_extra_thread_info, t); INHERIT (to_stop, t); /* Do not inherit to_xfer_partial. */ INHERIT (to_rcmd, t); @@ -608,6 +609,9 @@ de_fault (to_extra_thread_info, (char *(*) (struct thread_info *)) return_zero); + de_fault (to_delete_extra_thread_info, + (void (*) (struct private_thread_info *)) + target_ignore); de_fault (to_stop, (void (*) (void)) target_ignore); Index: thread.c =================================================================== RCS file: /cvs/src/src/gdb/thread.c,v retrieving revision 1.46 diff -u -r1.46 thread.c --- thread.c 15 Feb 2005 15:49:22 -0000 1.46 +++ thread.c 29 Sep 2005 16:56:32 -0000 @@ -91,10 +91,11 @@ if (tp->step_resume_breakpoint) delete_breakpoint (tp->step_resume_breakpoint); - /* FIXME: do I ever need to call the back-end to give it a - chance at this private data before deleting the thread? */ if (tp->private) - xfree (tp->private); + { + target_delete_extra_thread_info(tp->private); + xfree (tp->private); + } xfree (tp); } --------------080102050205020707020302--