This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: [RFA] Move alloca(0) to wait_for_inferior() from registers_changed()


On 14-Dec-2000, Fernando Nasser wrote:

>The event loop (or the interpreter's loop for the ones not using the event loop)
>and the libgdb calls are the best places for those alloca(0).

There's already an alloca(0) in execute_command(), which is pretty close
to the bottom of at least the CLI and GDBTK interpreter loops.  Changing
that is beyond the scope of what I'm trying to accomplish with this patch.

>> Are you suggesting that alloca(0) be called somewhere other than the
>> bottom of the wait-for-inferior loop?

>I does not make much sense calling it from there.  It only cleans up
>things that are inner in the stack.  At that point, gdb is deep down in its
>stack so there are high chances that not much will be cleaned up.

The original alloca(0) in registers_changed() is even deeper in the stack,
so by your argument, it doesn't make much sense either.

But whoever added it thought it made sense because:

  1. GDB can perform an unbounded number of software watchpoint checks
     between two interpreter loop iterations.

  2. Therefore, libiberty's alloca can allocate an unbounded amount of
     heap memory between two interpreter loop iterations.

I don't understand why they chose registers_changed() as a
garbage-collection point.  I do understand why one might choose the loop
in wait_for_inferior(), though: it iterates once per software watchpoint
check.

I'm just trying to move that garbage collection to a location that's more
comprehensible, at least to me.

Nick

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]