This is the mail archive of the
archer@sourceware.org
mailing list for the Archer project.
Re: [python] fully unify CLI and MI pretty printers
- From: Tom Tromey <tromey at redhat dot com>
- To: Vladimir Prus <vladimir at codesourcery dot com>
- Cc: archer at sourceware dot org
- Date: Mon, 17 Nov 2008 08:45:14 -0700
- Subject: Re: [python] fully unify CLI and MI pretty printers
- References: <m3fxm4eih4.fsf@fleche.redhat.com> <gevlnn$oop$1@ger.gmane.org>
- Reply-to: Tom Tromey <tromey at redhat dot com>
>>>>> "Vladimir" == Vladimir Prus <vladimir@codesourcery.com> writes:
Vladimir> I'm looking at this code:
[...]
Vladimir> I think that if type_changed is 1, then old varobj is
Vladimir> already deleted, new one is created and assigned to *varp,
Vladimir> and therefore the varobj already has the new type. And then,
Vladimir> value_type is equal to (*varp)->type, and there's no need to
Vladimir> add new parameter to install_default_visualizer.
I finally got back to this today.
Your analysis, no surprise, is correct. Thanks for looking at that
patch, and for your review.
I'm installing the appended.
Tom
2008-11-17 Tom Tromey <tromey@redhat.com>
* varobj.c (install_default_visualizer): Remove 'type' argument.
(varobj_create): Update.
(varobj_list_children): Likewise
(varobj_add_child): Likewise.
(varobj_update): Don't reinstall visualizer when type has
changed.
2008-11-17 Tom Tromey <tromey@redhat.com>
* gdb.python/python-prettyprint.c (do_nothing): New function.
(main): Call it.
diff --git a/gdb/testsuite/gdb.python/python-mi.exp b/gdb/testsuite/gdb.python/python-mi.exp
index 4d411b3..7cc15c3 100644
--- a/gdb/testsuite/gdb.python/python-mi.exp
+++ b/gdb/testsuite/gdb.python/python-mi.exp
@@ -27,7 +27,7 @@ if [mi_gdb_start] {
set testfile "python-prettyprint"
set srcfile ${testfile}.c
set binfile ${objdir}/${subdir}/${testfile}
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DMI}] != "" } {
untested mi2-var-child.exp
return -1
}
@@ -48,7 +48,7 @@ mi_gdb_test "python execfile ('${srcdir}/${subdir}/${testfile}.py')" ""
mi_continue_to_line [gdb_get_line_number {MI breakpoint here} ${testfile}.c] \
"step to breakpoint"
-mi_create_varobj container c "create container varobj"
+mi_create_floating_varobj container c "create container varobj"
mi_list_varobj_children container {
} "examine container children=0"
@@ -116,3 +116,9 @@ mi_list_varobj_children container {
{ {container.\[0\]} {\[0\]} 0 int }
{ {container.\[1\]} {\[1\]} 0 int }
} "list varobj children after resetting child range"
+
+mi_continue_to_line \
+ [gdb_get_line_number {Another MI breakpoint} ${testfile}.c] \
+ "step to second breakpoint"
+
+mi_varobj_update_with_type_change container int 0 "update after type change"
diff --git a/gdb/testsuite/gdb.python/python-prettyprint.c b/gdb/testsuite/gdb.python/python-prettyprint.c
index f99e6f9..f8c2435 100644
--- a/gdb/testsuite/gdb.python/python-prettyprint.c
+++ b/gdb/testsuite/gdb.python/python-prettyprint.c
@@ -107,6 +107,13 @@ void init_ss(struct ss *s, int a, int b)
init_s(&s->b, b);
}
+void do_nothing(void)
+{
+ int c;
+
+ c = 23; /* Another MI breakpoint */
+}
+
int
main ()
{
@@ -144,5 +151,9 @@ main ()
add_item (&c, 23); /* MI breakpoint here */
add_item (&c, 72);
+#ifdef MI
+ do_nothing ();
+#endif
+
return 0; /* break to inspect struct and union */
}
diff --git a/gdb/varobj.c b/gdb/varobj.c
index 0c5bf6f..eed4036 100644
--- a/gdb/varobj.c
+++ b/gdb/varobj.c
@@ -247,7 +247,7 @@ static char *cppop (struct cpstack **pstack);
static int install_new_value (struct varobj *var, struct value *value,
int initial);
-static void install_default_visualizer (struct varobj *var, struct type *type);
+static void install_default_visualizer (struct varobj *var);
/* Language-specific routines. */
@@ -603,7 +603,7 @@ varobj_create (char *objname,
}
}
- install_default_visualizer (var, var->type);
+ install_default_visualizer (var);
discard_cleanups (old_chain);
return var;
}
@@ -995,7 +995,7 @@ varobj_list_children (struct varobj *var)
name = name_of_child (var, i);
existing = create_child (var, i, name);
VEC_replace (varobj_p, var->children, i, existing);
- install_default_visualizer (existing, existing->type);
+ install_default_visualizer (existing);
}
}
@@ -1009,7 +1009,7 @@ varobj_add_child (struct varobj *var, const char *name, struct value *value)
VEC_length (varobj_p, var->children),
name, value);
VEC_safe_push (varobj_p, var->children, v);
- install_default_visualizer (v, v->type);
+ install_default_visualizer (v);
return v;
}
@@ -1427,7 +1427,7 @@ install_visualizer (struct varobj *var, PyObject *visualizer)
}
static void
-install_default_visualizer (struct varobj *var, struct type *type)
+install_default_visualizer (struct varobj *var)
{
#if HAVE_PYTHON
struct cleanup *cleanup;
@@ -1437,8 +1437,8 @@ install_default_visualizer (struct varobj *var, struct type *type)
state = PyGILState_Ensure ();
cleanup = make_cleanup_py_restore_gil (&state);
- if (type)
- constructor = gdbpy_get_varobj_pretty_printer (type);
+ if (var->type)
+ constructor = gdbpy_get_varobj_pretty_printer (var->type);
install_visualizer (var, constructor);
do_cleanups (cleanup);
@@ -1543,12 +1543,6 @@ VEC(varobj_update_result) *varobj_update (struct varobj **varp, int explicit)
new = value_of_root (varp, &type_changed);
r.varobj = *varp;
- /* Change the default visualizer, if needed, before installing
- the new value. This ensures that we instantiate the correct
- class. */
- if (type_changed)
- install_default_visualizer (*varp, value_type (new));
-
r.type_changed = type_changed;
if (install_new_value ((*varp), new, type_changed))
r.changed = 1;