This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[patch 7/8] Types GC [GC markers]
- From: Jan Kratochvil <jan dot kratochvil at redhat dot com>
- To: gdb-patches at sourceware dot org
- Date: Mon, 25 May 2009 10:04:04 +0200
- Subject: [patch 7/8] Types GC [GC markers]
Hi,
hook in several markers for the mark-and-sweep garbage collector.
Thanks,
Jan
gdb/
2009-05-25 Jan Kratochvil <jan.kratochvil@redhat.com>
* breakpoint.c: Include parser-defs.h.
(breakpoint_types_mark_used): New function.
(_initialize_breakpoint): Register breakpoint_types_mark_used observer.
* printcmd.c (print_types_mark_used): New function.
(_initialize_printcmd): Register print_types_mark_used observer.
* python/python-value.c: Include observer.h.
(python_types_mark_used): New function.
(gdbpy_initialize_values): Register python_types_mark_used observer.
* value.c (value_types_mark_used): New function.
(_initialize_values): Register value_types_mark_used observer.
---
gdb/breakpoint.c | 18 ++++++++++++++++++
gdb/printcmd.c | 17 +++++++++++++++++
gdb/python/python-value.c | 14 ++++++++++++++
gdb/value.c | 23 +++++++++++++++++++++++
4 files changed, 72 insertions(+), 0 deletions(-)
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 1235946..b64ee30 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -58,6 +58,7 @@
#include "top.h"
#include "wrapper.h"
#include "valprint.h"
+#include "parser-defs.h"
/* readline include files */
#include "readline/readline.h"
@@ -8586,6 +8587,22 @@ all_tracepoints ()
return tp_vec;
}
+/* Call type_mark_used for any TYPEs referenced from this GDB source file. */
+
+static void
+breakpoint_types_mark_used (void)
+{
+ struct breakpoint *b;
+
+ ALL_BREAKPOINTS (b)
+ {
+ if (b->exp)
+ exp_types_mark_used (b->exp);
+ if (b->val)
+ type_mark_used (value_type (b->val));
+ }
+}
+
/* This help string is used for the break, hbreak, tbreak and thbreak commands.
It is defined as a macro to prevent duplication.
@@ -9091,4 +9108,5 @@ inferior in all-stop mode, gdb behaves as if always-inserted mode is off."),
automatic_hardware_breakpoints = 1;
observer_attach_about_to_proceed (breakpoint_about_to_proceed);
+ observer_attach_mark_used (breakpoint_types_mark_used);
}
diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index 38b988c..c5ae2ed 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -1359,6 +1359,22 @@ x_command (char *exp, int from_tty)
set_internalvar (lookup_internalvar ("__"), last_examine_value);
}
}
+
+/* Call type_mark_used for any TYPEs referenced from this GDB source file. */
+
+static void
+print_types_mark_used (void)
+{
+ struct display *d;
+
+ if (last_examine_value)
+ type_mark_used (value_type (last_examine_value));
+
+ for (d = display_chain; d; d = d->next)
+ if (d->exp)
+ exp_types_mark_used (d->exp);
+}
+
/* Add an expression to the auto-display chain.
@@ -2664,4 +2680,5 @@ Show printing of source filename and line number with <symbol>."), NULL,
examine_w_type = init_type (TYPE_CODE_INT, 4, 0, "examine_w_type", NULL);
examine_g_type = init_type (TYPE_CODE_INT, 8, 0, "examine_g_type", NULL);
+ observer_attach_mark_used (print_types_mark_used);
}
diff --git a/gdb/python/python-value.c b/gdb/python/python-value.c
index 5faa281..3079928 100644
--- a/gdb/python/python-value.c
+++ b/gdb/python/python-value.c
@@ -25,6 +25,7 @@
#include "language.h"
#include "dfp.h"
#include "valprint.h"
+#include "observer.h"
/* List of all values which are currently exposed to Python. It is
maintained so that when an objfile is discarded, preserve_values
@@ -843,6 +844,17 @@ gdbpy_history (PyObject *self, PyObject *args)
return value_to_value_object (res_val);
}
+/* Call type_mark_used for any TYPEs referenced from this GDB source file. */
+
+static void
+python_types_mark_used (void)
+{
+ struct value *val;
+
+ for (val = values_in_python; val != NULL; val = value_next (val))
+ type_mark_used (value_type (val));
+}
+
void
gdbpy_initialize_values (void)
{
@@ -853,6 +865,8 @@ gdbpy_initialize_values (void)
PyModule_AddObject (gdb_module, "Value", (PyObject *) &value_object_type);
values_in_python = NULL;
+
+ observer_attach_mark_used (python_types_mark_used);
}
static PyGetSetDef value_object_getset[] = {
diff --git a/gdb/value.c b/gdb/value.c
index e6b99fc..2daa27d 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -1118,6 +1118,28 @@ call_internal_function (struct value *func, int argc, struct value **argv)
return (*ifn->handler) (ifn->cookie, argc, argv);
}
+/* Call type_mark_used for any TYPEs referenced from this GDB source file. */
+
+static void
+value_types_mark_used (void)
+{
+ struct internalvar *var;
+ struct value_history_chunk *chunk;
+
+ for (var = internalvars; var != NULL; var = var->next)
+ if (var->value)
+ type_mark_used (value_type (var->value));
+
+ for (chunk = value_history_chain; chunk != NULL; chunk = chunk->next)
+ {
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE (chunk->values); i++)
+ if (chunk->values[i])
+ type_mark_used (value_type (chunk->values[i]));
+ }
+}
+
/* The 'function' command. This does nothing -- it is just a
placeholder to let "help function NAME" work. This is also used as
the implementation of the sub-command that is created when
@@ -2052,4 +2074,5 @@ Placeholder command for showing help on convenience functions."),
TYPE_NAME (internal_fn_type) = "<internal function>";
observer_attach_objfile_unloading (preserve_values);
+ observer_attach_mark_used (value_types_mark_used);
}
--
1.6.2.2