Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Paul Koning <paulkoning@comcast.net>
To: Li Yu <raise.sail@gmail.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH v2] gdb/python: add missing handling for anonymous members of struct and union
Date: Sat, 01 Oct 2011 18:54:00 -0000	[thread overview]
Message-ID: <717C3E72-CC23-4894-963D-F74D4A72A8E5@comcast.net> (raw)
In-Reply-To: <CA+WLrf9+HLcN6-zFXx_=WW9AKrw4rHJ1sAZvpYWzs-Mz5rtC0Q@mail.gmail.com>


On Oct 1, 2011, at 10:01 AM, Li Yu wrote:

> 2011/9/30 Paul Koning <paulkoning@comcast.net>:
>> 
>> On Sep 30, 2011, at 6:12 AM, Li Yu wrote:
>> 
>>> ...
>> 
>> That whole chunk of code would be simpler and probably easier to understand if you wrote it as a recursion rather than a loop.  Something like:
>> 
>> restart:
>>  if (iter_obj->child)
>>    {
>>      result = typy_iterator_iternext (iter_obj->child);
>>      if (result != NULL)
>>         return result;
>>      Py_CLEAR (iter_obj->child);
>>    }
>> ...
>> If you use recursion, all this simply becomes Py_CLEAN (iter_obj->child);
>> 
> 
> I indeed do not like use recursion in any production code, because of it implies
> some problems, e.g. it may bring more function calls at runtime, which
> means much
> security risk and may use more memory, en, this just is my personal taste.
> 
> Of course, you must have more experience on gdb internals, if you decide to use
> recursion here, I will agree with you too and would like write a
> recursion implementation later.

I'm not all that experienced on gdb internals.  But, for example, you can see that the standard "ptype" command uses recursion.  If it's ok for regular gdb commands, it should be ok for this case.  The amount of stack space used isn't that high since the stack frames for the functions in question are pretty small.
> 
> I will leave about one week, see you later ~
> 
>>>   return NULL;
>>> }
>> 
>> You need to free iter_obj->child in the iterator destructor.
>> 
> 
> I think that Py_DEFREF(iter_obj->child) should be able to help us
> reclaim our allocated iterators here.

What I meant is that you don't have that code in typy_iterator_dealloc. 

	paul


  reply	other threads:[~2011-10-01 18:54 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-30 11:04 Li Yu
2011-09-30 16:15 ` Paul Koning
2011-10-01 14:01   ` Li Yu
2011-10-01 18:54     ` Paul Koning [this message]
2011-10-04 16:37 ` Tom Tromey
2011-10-04 18:05   ` Paul Koning
2011-10-04 20:24     ` Tom Tromey
2011-10-04 20:41       ` Paul Koning
2011-10-19 20:52         ` Tom Tromey
2011-10-19 20:59           ` Paul Koning
2011-10-20 18:49             ` Tom Tromey
2011-10-25 18:34               ` [RFA] Python: iterator for deep traversal of gdb.Type struct/union fields Paul Koning
2011-10-25 19:03                 ` Paul Koning
2011-10-25 20:16                   ` Eli Zaretskii
2011-10-26 17:14                     ` Paul Koning
2011-10-27 13:01                       ` Doug Evans
2011-10-27 14:52                         ` Paul_Koning
2011-10-27 19:57                           ` Tom Tromey
     [not found]                             ` <09787EF419216C41A903FD14EE5506DD030CF168FB@AUSX7MCPC103.AMER.DELL.COM>
2011-10-27 21:56                               ` Paul Koning
2011-10-27 22:14                                 ` Eli Zaretskii
2011-10-28 14:55                                   ` 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=717C3E72-CC23-4894-963D-F74D4A72A8E5@comcast.net \
    --to=paulkoning@comcast.net \
    --cc=gdb-patches@sourceware.org \
    --cc=raise.sail@gmail.com \
    /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