mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-22 19:09:31 +08:00
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.
This commit is contained in:
@ -1,3 +1,8 @@
|
|||||||
|
2011-03-31 Tom Tromey <tromey@redhat.com>
|
||||||
|
|
||||||
|
* varobj.c (update_dynamic_varobj_children): Properly handle
|
||||||
|
errors from iterator.
|
||||||
|
|
||||||
2011-03-31 Jan Kratochvil <jan.kratochvil@redhat.com>
|
2011-03-31 Jan Kratochvil <jan.kratochvil@redhat.com>
|
||||||
|
|
||||||
* dwarf2read.c (dwarf2_name): Initialize DEMANGLED. Avoid demangling
|
* dwarf2read.c (dwarf2_name): Initialize DEMANGLED. Avoid demangling
|
||||||
|
@ -1,3 +1,10 @@
|
|||||||
|
2011-03-31 Tom Tromey <tromey@redhat.com>
|
||||||
|
|
||||||
|
* 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.
|
||||||
|
|
||||||
2011-03-29 Tom Tromey <tromey@redhat.com>
|
2011-03-29 Tom Tromey <tromey@redhat.com>
|
||||||
|
|
||||||
* gdb.cp/anon-struct.cc: New file.
|
* gdb.cp/anon-struct.cc: New file.
|
||||||
|
@ -274,4 +274,13 @@ mi_gdb_test "-var-set-visualizer nscont gdb.default_visualizer" \
|
|||||||
"\\^done" \
|
"\\^done" \
|
||||||
"choose default visualizer"
|
"choose default visualizer"
|
||||||
|
|
||||||
|
mi_gdb_test "python exception_flag = True" ""
|
||||||
|
|
||||||
|
mi_create_dynamic_varobj nstype2 nstype2 \
|
||||||
|
"create nstype2 varobj"
|
||||||
|
|
||||||
|
mi_list_varobj_children nstype2 {
|
||||||
|
{ {nstype2.<error at 0>} {<error at 0>} 6 {char \[6\]} }
|
||||||
|
} "list children after setting exception flag"
|
||||||
|
|
||||||
remote_file host delete ${remote_python_file}
|
remote_file host delete ${remote_python_file}
|
||||||
|
@ -212,7 +212,7 @@ main ()
|
|||||||
const struct string_repr cstring = { { "const string" } };
|
const struct string_repr cstring = { { "const string" } };
|
||||||
/* Clearing by being `static' could invoke an other GDB C++ bug. */
|
/* Clearing by being `static' could invoke an other GDB C++ bug. */
|
||||||
struct nullstr nullstr;
|
struct nullstr nullstr;
|
||||||
nostring_type nstype;
|
nostring_type nstype, nstype2;
|
||||||
struct ns ns, ns2;
|
struct ns ns, ns2;
|
||||||
struct lazystring estring, estring2;
|
struct lazystring estring, estring2;
|
||||||
|
|
||||||
@ -283,5 +283,7 @@ main ()
|
|||||||
nstype.elements[1] = 42;
|
nstype.elements[1] = 42;
|
||||||
nstype.len = 2;
|
nstype.len = 2;
|
||||||
|
|
||||||
|
nstype2 = nstype;
|
||||||
|
|
||||||
return 0; /* break to inspect struct and union */
|
return 0; /* break to inspect struct and union */
|
||||||
}
|
}
|
||||||
|
@ -53,6 +53,9 @@ class ContainerPrinter:
|
|||||||
def children(self):
|
def children(self):
|
||||||
return self._iterator(self.val['elements'], self.val['len'])
|
return self._iterator(self.val['elements'], self.val['len'])
|
||||||
|
|
||||||
|
# Flag to make NoStringContainerPrinter throw an exception.
|
||||||
|
exception_flag = False
|
||||||
|
|
||||||
# Test a printer where to_string is None
|
# Test a printer where to_string is None
|
||||||
class NoStringContainerPrinter:
|
class NoStringContainerPrinter:
|
||||||
class _iterator:
|
class _iterator:
|
||||||
@ -67,6 +70,8 @@ class NoStringContainerPrinter:
|
|||||||
def next(self):
|
def next(self):
|
||||||
if self.pointer == self.end:
|
if self.pointer == self.end:
|
||||||
raise StopIteration
|
raise StopIteration
|
||||||
|
if exception_flag:
|
||||||
|
raise gdb.MemoryError, 'hi bob'
|
||||||
result = self.pointer
|
result = self.pointer
|
||||||
self.pointer = self.pointer + 1
|
self.pointer = self.pointer + 1
|
||||||
return ('[%d]' % int (result - self.start), result.dereference())
|
return ('[%d]' % int (result - self.start), result.dereference())
|
||||||
|
52
gdb/varobj.c
52
gdb/varobj.c
@ -1026,6 +1026,7 @@ update_dynamic_varobj_children (struct varobj *var,
|
|||||||
for (; to < 0 || i < to + 1; ++i)
|
for (; to < 0 || i < to + 1; ++i)
|
||||||
{
|
{
|
||||||
PyObject *item;
|
PyObject *item;
|
||||||
|
int force_done = 0;
|
||||||
|
|
||||||
/* See if there was a leftover from last time. */
|
/* See if there was a leftover from last time. */
|
||||||
if (var->saved_item)
|
if (var->saved_item)
|
||||||
@ -1037,7 +1038,48 @@ update_dynamic_varobj_children (struct varobj *var,
|
|||||||
item = PyIter_Next (var->child_iter);
|
item = PyIter_Next (var->child_iter);
|
||||||
|
|
||||||
if (!item)
|
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. */
|
/* We don't want to push the extra child on any report list. */
|
||||||
if (to < 0 || i < to)
|
if (to < 0 || i < to)
|
||||||
@ -1051,7 +1093,10 @@ update_dynamic_varobj_children (struct varobj *var,
|
|||||||
inner = make_cleanup_py_decref (item);
|
inner = make_cleanup_py_decref (item);
|
||||||
|
|
||||||
if (!PyArg_ParseTuple (item, "sO", &name, &py_v))
|
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);
|
v = convert_value_from_python (py_v);
|
||||||
if (v == NULL)
|
if (v == NULL)
|
||||||
@ -1071,6 +1116,9 @@ update_dynamic_varobj_children (struct varobj *var,
|
|||||||
element. */
|
element. */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (force_done)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i < VEC_length (varobj_p, var->children))
|
if (i < VEC_length (varobj_p, var->children))
|
||||||
|
Reference in New Issue
Block a user