xtensa: Properly strdup string when building reggroup
authorStafford Horne <shorne@gmail.com>
Tue, 15 Aug 2017 21:12:45 +0000 (06:12 +0900)
committerStafford Horne <shorne@gmail.com>
Tue, 15 Aug 2017 21:12:45 +0000 (06:12 +0900)
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.

gdb/ChangeLog
gdb/xtensa-tdep.c

index 94155f51d0c86b70e148844ac5c84f741d830241..51743e14e9dce8695c91dca3bdf0788ca05f2c15 100644 (file)
@@ -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
index f875f20d32b68abc37e3db37ab3e6053918536e5..bfb9ac6fa4adc3748b28ee54aab2945a3330ca1f 100644 (file)
@@ -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
This page took 0.030419 seconds and 4 git commands to generate.