From: dje@google.com (Doug Evans)
To: gdb-patches@sourceware.org
Subject: [RFC] [python] Fix field list of typedef regression
Date: Sat, 29 Oct 2011 08:23:00 -0000 [thread overview]
Message-ID: <20111029081242.9FA26246191@ruffy.mtv.corp.google.com> (raw)
Hi.
This patch fixes a regression in the current tree.
The field list of a typedef went from the underlying field list
to an empty list.
Question: What's the right way to handle ref counting here?
2011-10-29 Doug Evans <dje@google.com>
* python/py-type.c (typy_fields_items): Call check_typedef.
testsuite/
* gdb.python/py-type.c (TS): New typedef.
(ts): New global.
* gdb.python/py-type.exp: Test field list of typedef.
Index: python/py-type.c
===================================================================
RCS file: /cvs/src/src/gdb/python/py-type.c,v
retrieving revision 1.27
diff -u -p -r1.27 py-type.c
--- python/py-type.c 27 Oct 2011 09:14:27 -0000 1.27
+++ python/py-type.c 29 Oct 2011 08:04:06 -0000
@@ -295,11 +295,24 @@ static PyObject *
typy_fields_items (PyObject *self, enum gdbpy_iter_kind kind)
{
PyObject *result = NULL, *iter = NULL;
-
+ volatile struct gdb_exception except;
+
+ TRY_CATCH (except, RETURN_MASK_ALL)
+ {
+ struct type *type = ((type_object *) self)->type;
+ struct type *checked_type = type;
+
+ CHECK_TYPEDEF (checked_type);
+ if (checked_type != type)
+ self = type_to_type_object (checked_type);
+ /* FIXME: reference counting of self? */
+ }
+ GDB_PY_HANDLE_EXCEPTION (except);
+
iter = typy_make_iter (self, kind);
if (iter == NULL)
return NULL;
-
+
result = PySequence_List (iter);
Py_DECREF (iter);
return result;
Index: testsuite/gdb.python/py-type.c
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.python/py-type.c,v
retrieving revision 1.5
diff -u -p -r1.5 py-type.c
--- testsuite/gdb.python/py-type.c 28 Sep 2011 20:06:01 -0000 1.5
+++ testsuite/gdb.python/py-type.c 29 Oct 2011 08:04:06 -0000
@@ -21,6 +21,9 @@ struct s
int b;
};
+typedef struct s TS;
+TS ts;
+
#ifdef __cplusplus
struct C
{
Index: testsuite/gdb.python/py-type.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.python/py-type.exp,v
retrieving revision 1.14
diff -u -p -r1.14 py-type.exp
--- testsuite/gdb.python/py-type.exp 28 Sep 2011 20:06:01 -0000 1.14
+++ testsuite/gdb.python/py-type.exp 29 Oct 2011 08:04:06 -0000
@@ -64,6 +64,10 @@ proc runto_bp {bp} {
proc test_fields {lang} {
global gdb_prompt
+ # .fields() of a typedef should still return the underlying field list
+ gdb_test "python print len(gdb.parse_and_eval('ts').type.fields())" "2" \
+ "$lang typedef field list"
+
if {$lang == "c++"} {
# Test usage with a class
gdb_py_test_silent_cmd "print c" "print value" 1
next reply other threads:[~2011-10-29 8:13 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-29 8:23 Doug Evans [this message]
2011-10-29 22:17 ` Tom Tromey
2011-11-10 18:52 ` [RFA] " Doug Evans
2011-11-10 19:11 ` Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20111029081242.9FA26246191@ruffy.mtv.corp.google.com \
--to=dje@google.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox