Work around GCC 6.3.1 bug
[deliverable/binutils-gdb.git] / gdb / printcmd.c
index de1f76c2e33a76f1643159b268ced27b5e1b70be..77a05e5d9f2ec7a0083a2d3b8194fc0ecb4bd3b4 100644 (file)
@@ -1262,7 +1262,7 @@ output_command_const (const char *exp, int from_tty)
 }
 
 static void
-set_command (char *exp, int from_tty)
+set_command (const char *exp, int from_tty)
 {
   expression_up expr = parse_expression (exp);
 
@@ -1285,6 +1285,14 @@ set_command (char *exp, int from_tty)
   evaluate_expression (expr.get ());
 }
 
+/* Temporary non-const version of set_command.  */
+
+static void
+non_const_set_command (char *exp, int from_tty)
+{
+  set_command (exp, from_tty);
+}
+
 static void
 info_symbol_command (char *arg, int from_tty)
 {
@@ -1314,7 +1322,7 @@ info_symbol_command (char *arg, int from_tty)
            = lookup_minimal_symbol_by_pc_section (sect_addr, osect).minsym))
       {
        const char *obj_name, *mapped, *sec_name, *msym_name;
-       char *loc_string;
+       const char *loc_string;
        struct cleanup *old_chain;
 
        matches = 1;
@@ -1325,14 +1333,14 @@ info_symbol_command (char *arg, int from_tty)
 
        /* Don't print the offset if it is zero.
           We assume there's no need to handle i18n of "sym + offset".  */
+       std::string string_holder;
        if (offset)
-         loc_string = xstrprintf ("%s + %u", msym_name, offset);
+         {
+           string_holder = string_printf ("%s + %u", msym_name, offset);
+           loc_string = string_holder.c_str ();
+         }
        else
-         loc_string = xstrprintf ("%s", msym_name);
-
-       /* Use a cleanup to free loc_string in case the user quits
-          a pagination request inside printf_filtered.  */
-       old_chain = make_cleanup (xfree, loc_string);
+         loc_string = msym_name;
 
        gdb_assert (osect->objfile && objfile_name (osect->objfile));
        obj_name = objfile_name (osect->objfile);
@@ -1370,8 +1378,6 @@ info_symbol_command (char *arg, int from_tty)
            else
              printf_filtered (_("%s in section %s\n"),
                               loc_string, sec_name);
-
-       do_cleanups (old_chain);
       }
   }
   if (matches == 0)
@@ -1606,7 +1612,6 @@ static void
 x_command (char *exp, int from_tty)
 {
   struct format_data fmt;
-  struct cleanup *old_chain;
   struct value *val;
 
   fmt.format = last_format ? last_format : 'x';
@@ -2310,7 +2315,6 @@ printf_decfloat (struct ui_file *stream, const char *format,
   int dfp_len = 16;
   gdb_byte dec[16];
   struct type *dfp_type = NULL;
-  char decstr[MAX_DECIMAL_STRING];
 
   /* Points to the end of the string so that we can go back
      and check for DFP length modifiers.  */
@@ -2358,10 +2362,9 @@ printf_decfloat (struct ui_file *stream, const char *format,
 
   dfp_ptr = (gdb_byte *) value_contents (dfp_value);
 
-  decimal_to_string (dfp_ptr, dfp_len, byte_order, decstr);
-
-  /* Print the DFP value.  */
-  fprintf_filtered (stream, "%s", decstr);
+  /* Convert the value to a string and print it.  */
+  std::string str = decimal_to_string (dfp_ptr, dfp_len, byte_order);
+  fputs_filtered (str.c_str (), stream);
 #endif
 }
 
@@ -2754,7 +2757,7 @@ With a subcommand, this command modifies parts of the gdb environment.\n\
 You can see these environment settings with the \"show\" command."),
                  &setlist, "set ", 1, &cmdlist);
   if (dbx_commands)
-    add_com ("assign", class_vars, set_command, _("\
+    add_com ("assign", class_vars, non_const_set_command, _("\
 Evaluate expression EXP and assign result to variable VAR, using assignment\n\
 syntax appropriate for the current language (VAR = EXP or VAR := EXP for\n\
 example).  VAR may be a debugger \"convenience\" variable (names starting\n\
This page took 0.025288 seconds and 4 git commands to generate.