This is the mail archive of the gdb-cvs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] XCNEW gdbarch_tdep in rl78 and rx


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=e6ddc3bfedb4665c9d4baa2c85037af25167cdf3

commit e6ddc3bfedb4665c9d4baa2c85037af25167cdf3
Author: Yao Qi <yao.qi@linaro.org>
Date:   Thu Apr 13 08:29:43 2017 +0100

    XCNEW gdbarch_tdep in rl78 and rx
    
    "struct gdbarch_tdep" is XNEW'ed in rl78 and rx, so the memory is not
    cleared.  As the result, tdep->rl78_psw_type is never initialized
    properly.
    
      struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
    
      if (tdep->rl78_psw_type == NULL)
        {
          tdep->rl78_psw_type = arch_flags_type (gdbarch,
    					     "builtin_type_rl78_psw", 1);
    
    The bug is found by my unit test in the following patch.
    
    gdb:
    
    2017-04-13  Yao Qi  <yao.qi@linaro.org>
    
    	* rl78-tdep.c (rl78_gdbarch_init): Use XCNEW instead of XNEW.
    	* rx-tdep.c (rx_gdbarch_init): Likewise.

Diff:
---
 gdb/ChangeLog   | 5 +++++
 gdb/rl78-tdep.c | 2 +-
 gdb/rx-tdep.c   | 2 +-
 3 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 315932e..58c4b5e 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2017-04-13  Yao Qi  <yao.qi@linaro.org>
+
+	* rl78-tdep.c (rl78_gdbarch_init): Use XCNEW instead of XNEW.
+	* rx-tdep.c (rx_gdbarch_init): Likewise.
+
 2017-04-13  Pedro Alves  <palves@redhat.com>
 
 	* breakpoint.h (struct breakpoint): Reindent.
diff --git a/gdb/rl78-tdep.c b/gdb/rl78-tdep.c
index 9f2193e..307a760 100644
--- a/gdb/rl78-tdep.c
+++ b/gdb/rl78-tdep.c
@@ -1412,7 +1412,7 @@ rl78_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 
   /* None found, create a new architecture from the information
      provided.  */
-  tdep = XNEW (struct gdbarch_tdep);
+  tdep = XCNEW (struct gdbarch_tdep);
   gdbarch = gdbarch_alloc (&info, tdep);
   tdep->elf_flags = elf_flags;
 
diff --git a/gdb/rx-tdep.c b/gdb/rx-tdep.c
index 7b66d6d..1a3d103 100644
--- a/gdb/rx-tdep.c
+++ b/gdb/rx-tdep.c
@@ -1101,7 +1101,7 @@ rx_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 
   /* None found, create a new architecture from the information
      provided.  */
-  tdep = XNEW (struct gdbarch_tdep);
+  tdep = XCNEW (struct gdbarch_tdep);
   gdbarch = gdbarch_alloc (&info, tdep);
   tdep->elf_flags = elf_flags;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]