public inbox for gdb-testers@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] gdb: use std::vector instead of alloca in core_target::get_core_register_section
@ 2020-01-14  3:13 gdb-buildbot
  2020-01-14  3:15 ` Failures on Ubuntu-Aarch64-m64, branch master gdb-buildbot
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: gdb-buildbot @ 2020-01-14  3:13 UTC (permalink / raw)
  To: gdb-testers

*** TEST RESULTS FOR COMMIT d8b2f9e3330ae76e33679c2628a6196542f329ca ***

commit d8b2f9e3330ae76e33679c2628a6196542f329ca
Author:     Simon Marchi <simon.marchi@polymtl.ca>
AuthorDate: Mon Jan 13 14:32:52 2020 -0500
Commit:     Simon Marchi <simon.marchi@efficios.com>
CommitDate: Mon Jan 13 14:33:19 2020 -0500

    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.

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index ea5352dfd0..f190405198 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2020-01-13  Simon Marchi  <simon.marchi@polymtl.ca>
+
+	* corelow.c (core_target::get_core_register_section): Use
+	  std::vector instead of alloca.
+
 2020-01-13  Simon Marchi  <simon.marchi@efficios.com>
 
 	* warning.m4: Add -Wmissing-declarations to build_warnings.
diff --git a/gdb/corelow.c b/gdb/corelow.c
index f162a1b7de..0418ec2506 100644
--- a/gdb/corelow.c
+++ b/gdb/corelow.c
@@ -594,7 +594,6 @@ core_target::get_core_register_section (struct regcache *regcache,
 {
   struct bfd_section *section;
   bfd_size_type size;
-  char *contents;
   bool variable_size_section = (regset != NULL
 				&& regset->flags & REGSET_VARIABLE_SIZE);
 
@@ -622,9 +621,9 @@ core_target::get_core_register_section (struct regcache *regcache,
 	       section_name.c_str ());
     }
 
-  contents = (char *) alloca (size);
-  if (! bfd_get_section_contents (core_bfd, section, contents,
-				  (file_ptr) 0, size))
+  std::vector<char> contents (size);
+  if (!bfd_get_section_contents (core_bfd, section, contents.data (),
+				 (file_ptr) 0, size))
     {
       warning (_("Couldn't read %s registers from `%s' section in core file."),
 	       human_name, section_name.c_str ());
@@ -633,12 +632,12 @@ core_target::get_core_register_section (struct regcache *regcache,
 
   if (regset != NULL)
     {
-      regset->supply_regset (regset, regcache, -1, contents, size);
+      regset->supply_regset (regset, regcache, -1, contents.data (), size);
       return;
     }
 
   gdb_assert (m_core_vec != nullptr);
-  m_core_vec->core_read_registers (regcache, contents, size, which,
+  m_core_vec->core_read_registers (regcache, contents.data (), size, which,
 				   (CORE_ADDR) bfd_section_vma (section));
 }
 


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2020-01-16  4:50 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-14  3:13 [binutils-gdb] gdb: use std::vector instead of alloca in core_target::get_core_register_section gdb-buildbot
2020-01-14  3:15 ` Failures on Ubuntu-Aarch64-m64, branch master gdb-buildbot
2020-01-14  3:55 ` Failures on Ubuntu-Aarch64-native-extended-gdbserver-m64, " gdb-buildbot
2020-01-16  3:46 ` Failures on Fedora-x86_64-cc-with-index, " gdb-buildbot
2020-01-16  4:02 ` Failures on Fedora-i686, " gdb-buildbot
2020-01-16  4:35 ` Failures on Fedora-x86_64-m32, " gdb-buildbot
2020-01-16  4:45 ` Failures on Fedora-x86_64-m64, " gdb-buildbot
2020-01-16  4:46 ` Failures on Fedora-x86_64-native-gdbserver-m32, " gdb-buildbot
2020-01-16  4:50 ` Failures on Fedora-x86_64-native-extended-gdbserver-m32, " gdb-buildbot
2020-01-16  5:22 ` Failures on Fedora-x86_64-native-extended-gdbserver-m64, " gdb-buildbot
2020-01-16  5:35 ` Failures on Fedora-x86_64-native-gdbserver-m64, " gdb-buildbot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).