Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Phil Muldoon <pmuldoon@redhat.com>
To: Paul Koning <paulkoning@comcast.net>
Cc: gdb-patches@sourceware.org
Subject: Re: Python: add field access by name and standard python mapping methods to gdb.Type
Date: Fri, 16 Sep 2011 14:57:00 -0000	[thread overview]
Message-ID: <m3vcss7cyf.fsf@redhat.com> (raw)
In-Reply-To: <0A6582A5-22D0-4284-AE41-DE92F544B650@comcast.net> (Paul Koning's	message of "Fri, 16 Sep 2011 10:54:50 -0400")

Paul Koning <paulkoning@comcast.net> writes:

> On Sep 16, 2011, at 6:45 AM, Phil Muldoon wrote:
>
>> Paul Koning <paulkoning@comcast.net> writes:
>> 
>>> ...
>> 
>>> +typy_getitem (PyObject *self, PyObject *key)
>>> +{
>>> +  struct type *type = ((type_object *) self)->type;
>>> +  char *field;
>>> +  int i;
>>> +  
>>> +  field = python_string_to_host_string (key);
>>> +  if (field == NULL)
>>> +    return NULL;
>>> +
>>> +  /* We want just fields of this type, not of base types, so instead of 
>>> +     using lookup_struct_elt_type, portions of that function are
>>> +     copied here.  */
>>> +
>>> +  for (;;)
>>> +    {
>>> +      CHECK_TYPEDEF (type);
>>> +      if (TYPE_CODE (type) != TYPE_CODE_PTR
>>> +	  && TYPE_CODE (type) != TYPE_CODE_REF)
>>> +	break;
>>> +      type = TYPE_TARGET_TYPE (type);
>>> +    }
>> 
>> This gives me pause, not because it is wrong, but because I wonder if
>> there is a possibility that this loop will never exit.  I presume it
>> will eventually find the base_type, just by continually walking the
>> TARGET_TYPE until it reaches bottom.  
>> 
>> Can you check how this is done in other parts of GDB (this must happen
>> quite often?).
>
> This code was directly lifted from lookup_struct_elt_type in gdbtypes.c  The same sort of thing occurs in a number of other places, as you expected.  For example, in c_value_of_variable in varobj.c, a similar loop shows up but that one just strips TYPE_CODE_REF, it does not look for TYPE_CODE_PTR.
>
> I can certainly make this a standard function, perhaps in gdbtypes.c.  Then I can also change other occurrences of this code pattern to call that, but I would not want to go use it for things that are similar but not identical (like the one in varobj.c I mentioned).  Should that be a separate patch?  It seems better that way.
>
> 	paul

Yeah that is fine.  Thanks for checking!

Cheers

Phil


  reply	other threads:[~2011-09-16 14:57 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-16  4:09 Paul Koning
2011-09-16  7:36 ` Eli Zaretskii
2011-09-16 10:47 ` Phil Muldoon
2011-09-16 14:57   ` Paul Koning
2011-09-16 14:57     ` Phil Muldoon [this message]
2011-09-16 15:41   ` Paul Koning
2011-09-23 17:21     ` Doug Evans
2011-09-26 17:15       ` [RFA] " Paul Koning
2011-09-28 19:25         ` Doug Evans
2011-09-28 20:41           ` Paul Koning
2011-10-04 15:14             ` Tom Tromey
2011-10-04 15:30               ` Paul Koning
2011-10-04 15:42                 ` Eli Zaretskii
2011-10-04 15:56                   ` Paul Koning
2011-11-04 17:42                     ` Doug Evans
2011-11-04 20:41                       ` Paul Koning
2011-11-04 23:05                         ` Doug Evans
2011-11-05 14:36                           ` Paul Koning
2011-11-05 21:04                             ` Doug Evans
2011-11-08 21:40                               ` [RFA] Python: raise exception on field-related gdb.Type methods if it's not struct or union Paul Koning
2011-11-09  0:29                                 ` Doug Evans
2011-11-09  1:53                                   ` Paul Koning
2011-11-09 18:10                                   ` Paul Koning
2011-11-15 19:01                                     ` [PING] " Paul Koning
2011-11-15 20:57                                       ` Doug Evans
2011-11-15 21:21                                         ` Paul Koning

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=m3vcss7cyf.fsf@redhat.com \
    --to=pmuldoon@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=paulkoning@comcast.net \
    /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