From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: gdb-patches@sourceware.org
Subject: [patch] [5/5] Types reference counting [value_history_cleanup]
Date: Sat, 11 Apr 2009 10:22:00 -0000 [thread overview]
Message-ID: <20090411102237.GF32624@host0.dyn.jankratochvil.net> (raw)
Hi,
this patch brings no new functionality. It could be enabled only during some
--enable-debug builds but there is currently no such configure option.
Found it caught some bugs during the development (by trying to double-free some
types). It can be also used to verify there are no types leaks.
Thanks,
Jan
gdb/
2009-04-11 Jan Kratochvil <jan.kratochvil@redhat.com>
* value.c (value_history_cleanup): New function.
(_initialize_values): Setup a value_history_cleanup final call.
diff --git a/gdb/value.c b/gdb/value.c
index 9c08a41..12a5662 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -852,6 +852,25 @@ show_values (char *num_exp, int from_tty)
num_exp[1] = '\0';
}
}
+
+/* Sanity check for memory leaks and proper types reference counting. */
+
+static void
+value_history_cleanup (void *unused)
+{
+ while (value_history_chain)
+ {
+ struct value_history_chunk *chunk = value_history_chain;
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE (chunk->values); i++)
+ value_free (chunk->values[i]);
+
+ value_history_chain = chunk->next;
+ xfree (chunk);
+ }
+ value_history_count = 0;
+}
\f
/* Internal variables. These are variables within the debugger
that hold values assigned by debugger commands.
@@ -2049,4 +2068,6 @@ Placeholder command for showing help on convenience functions."),
TYPE_CODE (internal_fn_type) = TYPE_CODE_INTERNAL_FUNCTION;
TYPE_LENGTH (internal_fn_type) = sizeof (struct internal_function *);
TYPE_NAME (internal_fn_type) = "<internal function>";
+
+ make_final_cleanup (value_history_cleanup, NULL);
}
next reply other threads:[~2009-04-11 10:22 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-11 10:22 Jan Kratochvil [this message]
2009-04-13 12:44 ` Jan Kratochvil
2009-04-16 22:09 ` Tom Tromey
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=20090411102237.GF32624@host0.dyn.jankratochvil.net \
--to=jan.kratochvil@redhat.com \
--cc=gdb-patches@sourceware.org \
/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