From: Kris Warkentin <kewarken@qnx.com>
To: gdb-patches@sources.redhat.com
Subject: [patch] clean up potential memory leak in thread.c
Date: Thu, 29 Sep 2005 17:16:00 -0000 [thread overview]
Message-ID: <433C21F1.9000903@qnx.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 496 bytes --]
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 <kewarken@qnx.com>
* 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.
[-- Attachment #2: tidinfo.diff --]
[-- Type: text/x-patch, Size: 2641 bytes --]
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);
}
next reply other threads:[~2005-09-29 17:16 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-09-29 17:16 Kris Warkentin [this message]
2005-10-02 20:19 ` Daniel Jacobowitz
2005-10-03 14:30 ` Kris Warkentin
2005-10-03 14:40 ` Daniel Jacobowitz
2005-10-03 15:15 ` Kris Warkentin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=433C21F1.9000903@qnx.com \
--to=kewarken@qnx.com \
--cc=gdb-patches@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox