mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-08-01 08:54:44 +08:00
gdb
PR python/11915: * python/py-type.c (typy_array): New function. (type_object_methods): Add "array". gdb/doc PR python/11915: * gdb.texinfo (Types In Python): Document array method. gdb/testsuite PR python/11915: * gdb.python/py-type.exp (test_fields): Add tests for array.
This commit is contained in:
@ -1,3 +1,9 @@
|
|||||||
|
2010-08-23 Tom Tromey <tromey@redhat.com>
|
||||||
|
|
||||||
|
PR python/11915:
|
||||||
|
* python/py-type.c (typy_array): New function.
|
||||||
|
(type_object_methods): Add "array".
|
||||||
|
|
||||||
2010-08-20 Pedro Alves <pedro@codesourcery.com>
|
2010-08-20 Pedro Alves <pedro@codesourcery.com>
|
||||||
|
|
||||||
* python/python.c: Include "serial.h".
|
* python/python.c: Include "serial.h".
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
2010-08-23 Tom Tromey <tromey@redhat.com>
|
||||||
|
|
||||||
|
PR python/11915:
|
||||||
|
* gdb.texinfo (Types In Python): Document array method.
|
||||||
|
|
||||||
2010-08-18 Thiago Jung Bauermann <bauerman@br.ibm.com>
|
2010-08-18 Thiago Jung Bauermann <bauerman@br.ibm.com>
|
||||||
|
|
||||||
* gdb.texinfo (PowerPC Embedded): Mention support for the DVC register.
|
* gdb.texinfo (PowerPC Embedded): Mention support for the DVC register.
|
||||||
|
@ -20938,6 +20938,15 @@ but it can be @code{None} in some situations.
|
|||||||
@end table
|
@end table
|
||||||
@end defmethod
|
@end defmethod
|
||||||
|
|
||||||
|
@defmethod Type array @var{n1} @r{[}@var{n2}@r{]}
|
||||||
|
Return a new @code{gdb.Type} object which represents an array of this
|
||||||
|
type. If one argument is given, it is the inclusive upper bound of
|
||||||
|
the array; in this case the lower bound is zero. If two arguments are
|
||||||
|
given, the first argument is the lower bound of the array, and the
|
||||||
|
second argument is the upper bound of the array. An array's length
|
||||||
|
must not be negative, but the bounds can be.
|
||||||
|
@end defmethod
|
||||||
|
|
||||||
@defmethod Type const
|
@defmethod Type const
|
||||||
Return a new @code{gdb.Type} object which represents a
|
Return a new @code{gdb.Type} object which represents a
|
||||||
@code{const}-qualified variant of this type.
|
@code{const}-qualified variant of this type.
|
||||||
|
@ -262,6 +262,54 @@ typy_strip_typedefs (PyObject *self, PyObject *args)
|
|||||||
return type_to_type_object (check_typedef (type));
|
return type_to_type_object (check_typedef (type));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Return an array type. */
|
||||||
|
|
||||||
|
static PyObject *
|
||||||
|
typy_array (PyObject *self, PyObject *args)
|
||||||
|
{
|
||||||
|
int n1, n2;
|
||||||
|
PyObject *n2_obj = NULL;
|
||||||
|
struct type *array = NULL;
|
||||||
|
struct type *type = ((type_object *) self)->type;
|
||||||
|
volatile struct gdb_exception except;
|
||||||
|
|
||||||
|
if (! PyArg_ParseTuple (args, "i|O", &n1, &n2_obj))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
if (n2_obj)
|
||||||
|
{
|
||||||
|
if (!PyInt_Check (n2_obj))
|
||||||
|
{
|
||||||
|
PyErr_SetString (PyExc_RuntimeError,
|
||||||
|
_("Array bound must be an integer"));
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
n2 = (int) PyInt_AsLong (n2_obj);
|
||||||
|
if (PyErr_Occurred ())
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
n2 = n1;
|
||||||
|
n1 = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (n2 < n1)
|
||||||
|
{
|
||||||
|
PyErr_SetString (PyExc_ValueError,
|
||||||
|
_("Array length must not be negative"));
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
TRY_CATCH (except, RETURN_MASK_ALL)
|
||||||
|
{
|
||||||
|
array = lookup_array_range_type (type, n1, n2);
|
||||||
|
}
|
||||||
|
GDB_PY_HANDLE_EXCEPTION (except);
|
||||||
|
|
||||||
|
return type_to_type_object (array);
|
||||||
|
}
|
||||||
|
|
||||||
/* Return a Type object which represents a pointer to SELF. */
|
/* Return a Type object which represents a pointer to SELF. */
|
||||||
static PyObject *
|
static PyObject *
|
||||||
typy_pointer (PyObject *self, PyObject *args)
|
typy_pointer (PyObject *self, PyObject *args)
|
||||||
@ -836,6 +884,9 @@ static PyGetSetDef type_object_getset[] =
|
|||||||
|
|
||||||
static PyMethodDef type_object_methods[] =
|
static PyMethodDef type_object_methods[] =
|
||||||
{
|
{
|
||||||
|
{ "array", typy_array, METH_VARARGS,
|
||||||
|
"array (N) -> Type\n\
|
||||||
|
Return a type which represents an array of N objects of this type." },
|
||||||
{ "const", typy_const, METH_NOARGS,
|
{ "const", typy_const, METH_NOARGS,
|
||||||
"const () -> Type\n\
|
"const () -> Type\n\
|
||||||
Return a const variant of this type." },
|
Return a const variant of this type." },
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
2010-08-23 Tom Tromey <tromey@redhat.com>
|
||||||
|
|
||||||
|
PR python/11915:
|
||||||
|
* gdb.python/py-type.exp (test_fields): Add tests for array.
|
||||||
|
|
||||||
2010-08-23 Keith Seitz <keiths@redhat.com>
|
2010-08-23 Keith Seitz <keiths@redhat.com>
|
||||||
|
|
||||||
* gdb.dwarf2/dw2-double-set-die-type.S: DIE 0x51f does not
|
* gdb.dwarf2/dw2-double-set-die-type.S: DIE 0x51f does not
|
||||||
|
@ -97,6 +97,11 @@ proc test_fields {lang} {
|
|||||||
gdb_test "python fields = ar.type.fields()"
|
gdb_test "python fields = ar.type.fields()"
|
||||||
gdb_test "python print len(fields)" "1" "Check the number of fields"
|
gdb_test "python print len(fields)" "1" "Check the number of fields"
|
||||||
gdb_test "python print fields\[0\].type" "<range type>" "Check array field type"
|
gdb_test "python print fields\[0\].type" "<range type>" "Check array field type"
|
||||||
|
|
||||||
|
gdb_test "python print ar\[0\].cast(ar\[0\].type.array(1))" \
|
||||||
|
".1, 2." "cast to array with one argument"
|
||||||
|
gdb_test "python print ar\[0\].cast(ar\[0\].type.array(0, 1))" \
|
||||||
|
".1, 2." "cast to array with two arguments"
|
||||||
}
|
}
|
||||||
|
|
||||||
proc test_base_class {} {
|
proc test_base_class {} {
|
||||||
|
Reference in New Issue
Block a user