This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[RFA] Move alloca(0) to wait_for_inferior() from registers_changed()
- To: gdb-patches at sources dot redhat dot com
- Subject: [RFA] Move alloca(0) to wait_for_inferior() from registers_changed()
- From: Nick Duffek <nsd at redhat dot com>
- Date: Mon, 13 Nov 2000 12:37:39 -0500
The appended patch moves an alloca (0) call from
registers_changed() in regcache.c to wait_for_inferior() in infrun.c.
The purpose of alloca (0) is to garbage-collect space freed by libiberty's
alloca implementation. It is important that this garbage collection
occur at regular intervals when the stack is shallow.
At the moment, regcache.c has this comment preceding the alloca (0) call:
/* Force cleanup of any alloca areas if using C alloca instead of
a builtin alloca. This particular call is used to clean up
areas allocated by low level target code which may build up
during lengthy interactions between gdb and the target before
gdb gives control to the user (ie watchpoints). */
It's not obvious that registers_changed() gets called regularly or at
shallow stack depths during interactions between gdb and the target.
But it is obvious that wait_for_inferior() loops regularly at shallow
stack depths during those interactions.
Therefore, it makes more sense to put the alloca (0) in the
wait_for_inferior() loop than in registers_changed().
ChangeLog entries:
* infrun.c (wait_for_inferior): Call alloca (0).
* regcache.c (registers_changed): Move alloca (0) call to
wait_for_inferior() loop.
Okay to apply?
Nick
[patch follows]
Index: gdb/infrun.c
===================================================================
diff -up gdb/infrun.c gdb/infrun.c
--- gdb/infrun.c Mon Nov 13 01:25:58 2000
+++ gdb/infrun.c Mon Nov 13 01:23:55 2000
@@ -1282,6 +1282,9 @@ wait_for_inferior (void)
while (1)
{
+ /* Garbage-collect libiberty's alloca() emulation. */
+ alloca (0);
+
if (target_wait_hook)
ecs->pid = target_wait_hook (ecs->waiton_pid, ecs->wp);
else
Index: gdb/regcache.c
===================================================================
diff -up gdb/regcache.c gdb/regcache.c
--- gdb/regcache.c Mon Nov 13 01:26:00 2000
+++ gdb/regcache.c Mon Nov 13 01:24:18 2000
@@ -295,13 +295,6 @@ registers_changed (void)
registers_pid = -1;
- /* Force cleanup of any alloca areas if using C alloca instead of
- a builtin alloca. This particular call is used to clean up
- areas allocated by low level target code which may build up
- during lengthy interactions between gdb and the target before
- gdb gives control to the user (ie watchpoints). */
- alloca (0);
-
for (i = 0; i < ARCH_NUM_REGS; i++)
register_valid[i] = 0;