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] xtensa: Properly strdup string when building reggroup


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

commit 9c3cc99930a08934e16b630e92a0d285a434f228
Author: Stafford Horne <shorne@gmail.com>
Date:   Wed Aug 16 06:12:45 2017 +0900

    xtensa: Properly strdup string when building reggroup
    
    I noticed this while looking at the reggroup intializations.  It seems
    for xtensa the "cpN" reggroup->name is getting assigned to the same text
    pointer for each iteration of XTENSA_MAX_COPROCESSOR.
    
    Note, internally reggroup_new() does not do any xstrdup().
    
    gdb/ChangeLog:
    2017-08-15  Stafford Horne  <shorne@gmail.com>
    
    	* xtensa-tdep.c (xtensa_init_reggroups): Use xstrdup for cpname.

Diff:
---
 gdb/ChangeLog     | 4 ++++
 gdb/xtensa-tdep.c | 6 +-----
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 94155f5..51743e1 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,7 @@
+2017-08-15  Stafford Horne  <shorne@gmail.com>
+
+	* xtensa-tdep.c (xtensa_init_reggroups): Use xstrdup for cpname.
+
 2017-08-15  Sergio Durigan Junior  <sergiodj@redhat.com>
 
 	PR gdb/21954
diff --git a/gdb/xtensa-tdep.c b/gdb/xtensa-tdep.c
index f875f20..bfb9ac6 100644
--- a/gdb/xtensa-tdep.c
+++ b/gdb/xtensa-tdep.c
@@ -740,17 +740,13 @@ static void
 xtensa_init_reggroups (void)
 {
   int i;
-  char cpname[] = "cp0";
 
   xtensa_ar_reggroup = reggroup_new ("ar", USER_REGGROUP);
   xtensa_user_reggroup = reggroup_new ("user", USER_REGGROUP);
   xtensa_vectra_reggroup = reggroup_new ("vectra", USER_REGGROUP);
 
   for (i = 0; i < XTENSA_MAX_COPROCESSOR; i++)
-    {
-      cpname[2] = '0' + i;
-      xtensa_cp[i] = reggroup_new (cpname, USER_REGGROUP);
-    }
+    xtensa_cp[i] = reggroup_new (xstrprintf ("cp%d", i), USER_REGGROUP);
 }
 
 static void


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