diff options
author | Tom Tromey <tromey@redhat.com> | 2011-03-31 19:59:26 +0000 |
---|---|---|
committer | Tom Tromey <tromey@redhat.com> | 2011-03-31 19:59:26 +0000 |
commit | a4c8e8068824062a43759f22ff0d22efe8996b82 (patch) | |
tree | 872b7851c93ed4310172483496fc607fbd33014c /gdb/varobj.c | |
parent | df5c6c503133136c5d6e5c5eea6f43d276a8eda0 (diff) | |
download | gdb-a4c8e8068824062a43759f22ff0d22efe8996b82.zip gdb-a4c8e8068824062a43759f22ff0d22efe8996b82.tar.gz gdb-a4c8e8068824062a43759f22ff0d22efe8996b82.tar.bz2 |
gdb
* varobj.c (update_dynamic_varobj_children): Properly handle
errors from iterator.
gdb/testsuite
* gdb.python/py-prettyprint.py (exception_flag): New global.
(NoStringContainerPrinter._iterator.next): Check it.
* gdb.python/py-prettyprint.c (main): New variable nstype2.
* gdb.python/py-mi.exp: Set exception_flag and do more tests.
Diffstat (limited to 'gdb/varobj.c')
-rw-r--r-- | gdb/varobj.c | 52 |
1 files changed, 50 insertions, 2 deletions
diff --git a/gdb/varobj.c b/gdb/varobj.c index 124909a..bfb3851 100644 --- a/gdb/varobj.c +++ b/gdb/varobj.c @@ -1026,6 +1026,7 @@ update_dynamic_varobj_children (struct varobj *var, for (; to < 0 || i < to + 1; ++i) { PyObject *item; + int force_done = 0; /* See if there was a leftover from last time. */ if (var->saved_item) @@ -1037,7 +1038,48 @@ update_dynamic_varobj_children (struct varobj *var, item = PyIter_Next (var->child_iter); if (!item) - break; + { + /* Normal end of iteration. */ + if (!PyErr_Occurred ()) + break; + + /* If we got a memory error, just use the text as the + item. */ + if (PyErr_ExceptionMatches (gdbpy_gdb_memory_error)) + { + PyObject *type, *value, *trace; + char *name_str, *value_str; + + PyErr_Fetch (&type, &value, &trace); + value_str = gdbpy_exception_to_string (type, value); + Py_XDECREF (type); + Py_XDECREF (value); + Py_XDECREF (trace); + if (!value_str) + { + gdbpy_print_stack (); + break; + } + + name_str = xstrprintf ("<error at %d>", i); + item = Py_BuildValue ("(ss)", name_str, value_str); + xfree (name_str); + xfree (value_str); + if (!item) + { + gdbpy_print_stack (); + break; + } + + force_done = 1; + } + else + { + /* Any other kind of error. */ + gdbpy_print_stack (); + break; + } + } /* We don't want to push the extra child on any report list. */ if (to < 0 || i < to) @@ -1051,7 +1093,10 @@ update_dynamic_varobj_children (struct varobj *var, inner = make_cleanup_py_decref (item); if (!PyArg_ParseTuple (item, "sO", &name, &py_v)) - error (_("Invalid item from the child list")); + { + gdbpy_print_stack (); + error (_("Invalid item from the child list")); + } v = convert_value_from_python (py_v); if (v == NULL) @@ -1071,6 +1116,9 @@ update_dynamic_varobj_children (struct varobj *var, element. */ break; } + + if (force_done) + break; } if (i < VEC_length (varobj_p, var->children)) |