Remove alloca(0) calls

Message ID 20190611130131.19054-1-tromey@adacore.com
State New, archived
Headers

Commit Message

Tom Tromey June 11, 2019, 1:01 p.m. UTC
  PR gdb/24653 points out that a gcc snapshot will complain about the
calls to alloca(0) in gdb.

These calls are only needed when using the C alloca.  I'm inclined to
think that no current platform needs this, so this patch removes the
calls.

Let me know what you think.

gdb/ChangeLog
2019-06-11  Tom Tromey  <tromey@adacore.com>

	PR gdb/24653:
	* regcache.c (registers_changed): Don't call alloca.
	* top.c (execute_command): Don't call alloca.
---
 gdb/ChangeLog  | 6 ++++++
 gdb/regcache.c | 7 -------
 gdb/top.c      | 4 ----
 3 files changed, 6 insertions(+), 11 deletions(-)
  

Comments

Kevin Buettner June 11, 2019, 4:26 p.m. UTC | #1
On Tue, 11 Jun 2019 07:01:31 -0600
Tom Tromey <tromey@adacore.com> wrote:

> PR gdb/24653 points out that a gcc snapshot will complain about the
> calls to alloca(0) in gdb.
> 
> These calls are only needed when using the C alloca.  I'm inclined to
> think that no current platform needs this, so this patch removes the
> calls.
> 
> Let me know what you think.

I think that your patch should go in.

I too think that all modern platforms will have proper
(compiler-assisted) alloca support and won't need to resort to use of
the heap for implementation of alloca().

Kevin
  
Tom Tromey June 14, 2019, 1 p.m. UTC | #2
>> These calls are only needed when using the C alloca.  I'm inclined to
>> think that no current platform needs this, so this patch removes the
>> calls.
>> 
>> Let me know what you think.

Kevin> I think that your patch should go in.

Thanks, I'm going to push it now.

Tom
  

Patch

diff --git a/gdb/regcache.c b/gdb/regcache.c
index 6e3eee96631..323f0f5ab4e 100644
--- a/gdb/regcache.c
+++ b/gdb/regcache.c
@@ -454,13 +454,6 @@  void
 registers_changed (void)
 {
   registers_changed_ptid (minus_one_ptid);
-
-  /* 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);
 }
 
 void
diff --git a/gdb/top.c b/gdb/top.c
index 4f55d6af1e6..c645f3d455d 100644
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -560,10 +560,6 @@  execute_command (const char *p, int from_tty)
   auto cleanup_if_error = make_scope_exit (bpstat_clear_actions);
   scoped_value_mark cleanup = prepare_execute_command ();
 
-  /* Force cleanup of any alloca areas if using C alloca instead of
-     a builtin alloca.  */
-  alloca (0);
-
   /* This can happen when command_line_input hits end of file.  */
   if (p == NULL)
     {