gdb: use gdb::byte_vector instead of std::vector<char> in core_target::get_core_regis...
authorSimon Marchi <simon.marchi@efficios.com>
Mon, 13 Jan 2020 23:12:08 +0000 (18:12 -0500)
committerSimon Marchi <simon.marchi@efficios.com>
Mon, 13 Jan 2020 23:12:08 +0000 (18:12 -0500)
Since the data held by the `contents` variable is arbitrary binary data,
it should have gdb_byte elements, not char elements.  Also, using
gdb::byte_vector is preferable, since it doesn't unnecessarily
zero-initialize the values.

Instead of adding a cast in the call to m_core_vec->core_read_registers,
I have changed core_read_registers' argument to be a gdb_byte* instead
of a char*.

gdb/ChangeLog:

* gdbcore.h (struct core_fns) <core_read_registers>: Change
core_reg_sect type to gdb_byte *.
* arm-nbsd-nat.c (fetch_elfcore_registers): Likewise.
* cris-tdep.c (fetch_core_registers): Likewise.
* corelow.c (core_target::get_core_register_section): Change
type of `contents` to gdb::byte_vector.

gdb/ChangeLog
gdb/arm-nbsd-nat.c
gdb/corelow.c
gdb/cris-tdep.c
gdb/gdbcore.h

index f966da85c8aa594b6910d572a32d43c8093805f7..2ec7a61c3b6580e370732e43040a810c1f573f8f 100644 (file)
@@ -1,3 +1,12 @@
+2020-01-13  Simon Marchi  <simon.marchi@efficios.com>
+
+       * gdbcore.h (struct core_fns) <core_read_registers>: Change
+       core_reg_sect type to gdb_byte *.
+       * arm-nbsd-nat.c (fetch_elfcore_registers): Likewise.
+       * cris-tdep.c (fetch_core_registers): Likewise.
+       * corelow.c (core_target::get_core_register_section): Change
+       type of `contents` to gdb::byte_vector.
+
 2020-01-13  Andrew Burgess  <andrew.burgess@embecosm.com>
 
        * tui/tui-wingeneral.c (box_win): Position the title in the center
index 1d058a99ac1a9fa8bc864f93bbbf1590b9e58f87..00f919194b9551d9a55c339ce6005e834fce0b81 100644 (file)
@@ -397,7 +397,7 @@ arm_nbsd_nat_target::store_registers (struct regcache *regcache, int regno)
 
 static void
 fetch_elfcore_registers (struct regcache *regcache,
-                        char *core_reg_sect, unsigned core_reg_size,
+                        gdb_byte *core_reg_sect, unsigned core_reg_size,
                         int which, CORE_ADDR ignore)
 {
   struct reg gregset;
index 0418ec2506af54a591a483b1f5ddd47c37d01583..5cd058d5993d51fd5abdcdbbf76b92c909b4881a 100644 (file)
@@ -621,7 +621,7 @@ core_target::get_core_register_section (struct regcache *regcache,
               section_name.c_str ());
     }
 
-  std::vector<char> contents (size);
+  gdb::byte_vector contents (size);
   if (!bfd_get_section_contents (core_bfd, section, contents.data (),
                                 (file_ptr) 0, size))
     {
index 22b4db917ca06c0037e341bfb3aa862c4094c8d9..6885d237f3a32c0e580b868d9a0319840b11f8a3 100644 (file)
@@ -3793,7 +3793,7 @@ cris_supply_gregset (struct regcache *regcache, cris_elf_gregset_t *gregsetp)
 
 static void
 fetch_core_registers (struct regcache *regcache,
-                     char *core_reg_sect, unsigned core_reg_size,
+                     gdb_byte *core_reg_sect, unsigned core_reg_size,
                       int which, CORE_ADDR reg_addr)
 {
   cris_elf_gregset_t gregset;
index 5b216e9c1c976d6b2481bb09b71c3365c47748a3..66e81dfe950f5a244d702eaa38a2d2fd89493d03 100644 (file)
@@ -213,7 +213,7 @@ struct core_fns
        address X is at location core_reg_sect+x+reg_addr.  */
 
     void (*core_read_registers) (struct regcache *regcache,
-                                char *core_reg_sect,
+                                gdb_byte *core_reg_sect,
                                 unsigned core_reg_size,
                                 int which, CORE_ADDR reg_addr);