PR python/12070:
* python/py-event.c (event_object_getset): New global. (event_object_type): Reference it. * python/py-type.c (field_object_getset): New global. (field_object_type): Reference it. * python/python-internal.h (gdb_py_generic_dict): Declare. * python/py-utils.c (gdb_py_generic_dict): New function. testsuite/gdb * gdb.python/py-events.py (exit_handler): Add test for 'dir'. * gdb.python/py-events.exp: Check 'dir' output. * gdb.python/py-type.exp (test_fields): Add test for 'dir'.
This commit is contained in:
parent
8544a1503d
commit
2e8265fd8b
9 changed files with 64 additions and 4 deletions
|
@ -1,3 +1,13 @@
|
||||||
|
2012-02-17 Tom Tromey <tromey@redhat.com>
|
||||||
|
|
||||||
|
PR python/12070:
|
||||||
|
* python/py-event.c (event_object_getset): New global.
|
||||||
|
(event_object_type): Reference it.
|
||||||
|
* python/py-type.c (field_object_getset): New global.
|
||||||
|
(field_object_type): Reference it.
|
||||||
|
* python/python-internal.h (gdb_py_generic_dict): Declare.
|
||||||
|
* python/py-utils.c (gdb_py_generic_dict): New function.
|
||||||
|
|
||||||
2012-02-17 Tristan Gingold <gingold@adacore.com>
|
2012-02-17 Tristan Gingold <gingold@adacore.com>
|
||||||
|
|
||||||
* solib-darwin.c (darwin_current_sos): Check magic and filetype
|
* solib-darwin.c (darwin_current_sos): Check magic and filetype
|
||||||
|
|
|
@ -132,6 +132,13 @@ evpy_emit_event (PyObject *event,
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static PyGetSetDef event_object_getset[] =
|
||||||
|
{
|
||||||
|
{ "__dict__", gdb_py_generic_dict, NULL,
|
||||||
|
"The __dict__ for this event.", &event_object_type },
|
||||||
|
{ NULL }
|
||||||
|
};
|
||||||
|
|
||||||
PyTypeObject event_object_type =
|
PyTypeObject event_object_type =
|
||||||
{
|
{
|
||||||
PyObject_HEAD_INIT (NULL)
|
PyObject_HEAD_INIT (NULL)
|
||||||
|
@ -164,7 +171,7 @@ PyTypeObject event_object_type =
|
||||||
0, /* tp_iternext */
|
0, /* tp_iternext */
|
||||||
0, /* tp_methods */
|
0, /* tp_methods */
|
||||||
0, /* tp_members */
|
0, /* tp_members */
|
||||||
0, /* tp_getset */
|
event_object_getset, /* tp_getset */
|
||||||
0, /* tp_base */
|
0, /* tp_base */
|
||||||
0, /* tp_dict */
|
0, /* tp_dict */
|
||||||
0, /* tp_descr_get */
|
0, /* tp_descr_get */
|
||||||
|
|
|
@ -1681,6 +1681,13 @@ static PyTypeObject type_object_type =
|
||||||
0, /* tp_new */
|
0, /* tp_new */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static PyGetSetDef field_object_getset[] =
|
||||||
|
{
|
||||||
|
{ "__dict__", gdb_py_generic_dict, NULL,
|
||||||
|
"The __dict__ for this field.", &field_object_type },
|
||||||
|
{ NULL }
|
||||||
|
};
|
||||||
|
|
||||||
static PyTypeObject field_object_type =
|
static PyTypeObject field_object_type =
|
||||||
{
|
{
|
||||||
PyObject_HEAD_INIT (NULL)
|
PyObject_HEAD_INIT (NULL)
|
||||||
|
@ -1713,7 +1720,7 @@ static PyTypeObject field_object_type =
|
||||||
0, /* tp_iternext */
|
0, /* tp_iternext */
|
||||||
0, /* tp_methods */
|
0, /* tp_methods */
|
||||||
0, /* tp_members */
|
0, /* tp_members */
|
||||||
0, /* tp_getset */
|
field_object_getset, /* tp_getset */
|
||||||
0, /* tp_base */
|
0, /* tp_base */
|
||||||
0, /* tp_dict */
|
0, /* tp_dict */
|
||||||
0, /* tp_descr_get */
|
0, /* tp_descr_get */
|
||||||
|
|
|
@ -373,3 +373,23 @@ gdb_py_int_as_long (PyObject *obj, long *result)
|
||||||
*result = PyInt_AsLong (obj);
|
*result = PyInt_AsLong (obj);
|
||||||
return ! (*result == -1 && PyErr_Occurred ());
|
return ! (*result == -1 && PyErr_Occurred ());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Generic implementation of the __dict__ attribute for objects that
|
||||||
|
have a dictionary. The CLOSURE argument should be the type object.
|
||||||
|
This only handles positive values for tp_dictoffset. */
|
||||||
|
|
||||||
|
PyObject *
|
||||||
|
gdb_py_generic_dict (PyObject *self, void *closure)
|
||||||
|
{
|
||||||
|
PyObject *result;
|
||||||
|
PyTypeObject *type_obj = closure;
|
||||||
|
char *raw_ptr;
|
||||||
|
|
||||||
|
raw_ptr = (char *) self + type_obj->tp_dictoffset;
|
||||||
|
result = * (PyObject **) raw_ptr;
|
||||||
|
|
||||||
|
Py_INCREF (result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
|
@ -342,4 +342,6 @@ PyObject *gdb_py_object_from_longest (LONGEST l);
|
||||||
PyObject *gdb_py_object_from_ulongest (ULONGEST l);
|
PyObject *gdb_py_object_from_ulongest (ULONGEST l);
|
||||||
int gdb_py_int_as_long (PyObject *, long *);
|
int gdb_py_int_as_long (PyObject *, long *);
|
||||||
|
|
||||||
|
PyObject *gdb_py_generic_dict (PyObject *self, void *closure);
|
||||||
|
|
||||||
#endif /* GDB_PYTHON_INTERNAL_H */
|
#endif /* GDB_PYTHON_INTERNAL_H */
|
||||||
|
|
|
@ -1,3 +1,9 @@
|
||||||
|
2012-02-17 Tom Tromey <tromey@redhat.com>
|
||||||
|
|
||||||
|
* gdb.python/py-events.py (exit_handler): Add test for 'dir'.
|
||||||
|
* gdb.python/py-events.exp: Check 'dir' output.
|
||||||
|
* gdb.python/py-type.exp (test_fields): Add test for 'dir'.
|
||||||
|
|
||||||
2012-02-17 Yao Qi <yao@codesourcery.com>
|
2012-02-17 Yao Qi <yao@codesourcery.com>
|
||||||
|
|
||||||
* gdb.trace/strace.exp (strace_info_marker): Test `info threads'.
|
* gdb.trace/strace.exp (strace_info_marker): Test `info threads'.
|
||||||
|
|
|
@ -85,10 +85,12 @@ delete_breakpoints
|
||||||
gdb_test "continue" ".*event type: continue.*
|
gdb_test "continue" ".*event type: continue.*
|
||||||
.*event type: exit.*
|
.*event type: exit.*
|
||||||
.*exit code: 12.*
|
.*exit code: 12.*
|
||||||
.*exit inf: 1.*" "Inferior 1 terminated."
|
.*exit inf: 1.*
|
||||||
|
dir ok: True.*" "Inferior 1 terminated."
|
||||||
|
|
||||||
gdb_test "inferior 2" ".*Switching to inferior 2.*"
|
gdb_test "inferior 2" ".*Switching to inferior 2.*"
|
||||||
gdb_test "continue" ".*event type: continue.*
|
gdb_test "continue" ".*event type: continue.*
|
||||||
.*event type: exit.*
|
.*event type: exit.*
|
||||||
.*exit code: 12.*
|
.*exit code: 12.*
|
||||||
.*exit inf: 2.*" "Inferior 2 terminated."
|
.*exit inf: 2.*
|
||||||
|
dir ok: True.*" "Inferior 2 terminated."
|
||||||
|
|
|
@ -44,6 +44,7 @@ def exit_handler (event):
|
||||||
print "event type: exit"
|
print "event type: exit"
|
||||||
print "exit code: %d" % (event.exit_code)
|
print "exit code: %d" % (event.exit_code)
|
||||||
print "exit inf: %d" % (event.inferior.num)
|
print "exit inf: %d" % (event.inferior.num)
|
||||||
|
print "dir ok: %s" % str('exit_code' in dir(event))
|
||||||
|
|
||||||
def continue_handler (event):
|
def continue_handler (event):
|
||||||
if (isinstance (event, gdb.ContinueEvent)):
|
if (isinstance (event, gdb.ContinueEvent)):
|
||||||
|
|
|
@ -86,6 +86,11 @@ proc test_fields {lang} {
|
||||||
gdb_test "python print fields\[0\].name" "a" "Check structure field a name"
|
gdb_test "python print fields\[0\].name" "a" "Check structure field a name"
|
||||||
gdb_test "python print fields\[1\].name" "b" "Check structure field b name"
|
gdb_test "python print fields\[1\].name" "b" "Check structure field b name"
|
||||||
|
|
||||||
|
# Regression test for
|
||||||
|
# http://sourceware.org/bugzilla/show_bug.cgi?id=12070.
|
||||||
|
gdb_test "python print 'type' in dir(fields\[0\])" "True" \
|
||||||
|
"Check that dir includes name"
|
||||||
|
|
||||||
# Test Python mapping behavior of gdb.Type for structs/classes
|
# Test Python mapping behavior of gdb.Type for structs/classes
|
||||||
gdb_test "python print len(st.type)" "2" "Check number of fields"
|
gdb_test "python print len(st.type)" "2" "Check number of fields"
|
||||||
gdb_test "python print st.type\['a'\].name" "a" "Check fields lookup by name"
|
gdb_test "python print st.type\['a'\].name" "a" "Check fields lookup by name"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue