gdb: use std::vector instead of alloca in core_target::get_core_register_section
authorSimon Marchi <simon.marchi@polymtl.ca>
Mon, 13 Jan 2020 19:32:52 +0000 (14:32 -0500)
committerSimon Marchi <simon.marchi@efficios.com>
Mon, 13 Jan 2020 19:33:19 +0000 (14:33 -0500)
commitd8b2f9e3330ae76e33679c2628a6196542f329ca
tree85915b47e7adcea2989620b907b366562bc88634
parentc0bd321d770f3829d5dba3abb2e47443197a2e23
gdb: use std::vector instead of alloca in core_target::get_core_register_section

As I was trying to compile gdb for an m68k host, I got this error:

  CXX    corelow.o
In file included from /binutils-gdb/gdb/gdbsupport/common-defs.h:120,
                 from /binutils-gdb/gdb/defs.h:28,
                 from /binutils-gdb/gdb/corelow.c:20:
/binutils-gdb/gdb/corelow.c: In member function 'void core_target::get_core_register_section(regcache*, const regset*, const char*, int, int, const char*, bool)':
/binutils-gdb/gdb/../include/libiberty.h:727:36: error: 'alloca' bound is unknown [-Werror=alloca-larger-than=]
  727 | # define alloca(x) __builtin_alloca(x)
      |                    ~~~~~~~~~~~~~~~~^~~
/binutils-gdb/gdb/corelow.c:625:23: note: in expansion of macro 'alloca'
  625 |   contents = (char *) alloca (size);
      |                       ^~~~~~

We are using alloca to hold the contents of a the core register
sections.  These sections are typically fairly small, but there is no
realy guarantee, so I think it would be more reasonable to just use
dynamic allocation here.

gdb/ChangeLog:

* corelow.c (core_target::get_core_register_section): Use
  std::vector instead of alloca.
gdb/ChangeLog
gdb/corelow.c