gdb/
authorJan Kratochvil <jan.kratochvil@redhat.com>
Sat, 23 May 2009 16:17:18 +0000 (16:17 +0000)
committerJan Kratochvil <jan.kratochvil@redhat.com>
Sat, 23 May 2009 16:17:18 +0000 (16:17 +0000)
Replace the savestring calls by xstrdup calls where possible.
* breakpoint.c (condition_command, set_raw_breakpoint)
(create_catchpoint, update_breakpoint_locations): Replace the
savestring calls by xstrdup calls where possible.
* buildsym.c (start_subfile, patch_subfile_names, record_debugformat)
(record_producer): Likewise.
* coffread.c (coff_start_symtab, complete_symtab): Likewise.
* corefile.c (set_gnutarget): Likewise.
* dbxread.c (add_new_header_file): Likewise.
* demangle.c (set_demangling_command, set_demangling_style): Likewise.
* event-top.c (push_prompt, pop_prompt, command_line_handler)
(set_async_prompt): Likewise.
* infcmd.c (set_inferior_io_terminal, attach_command_post_wait):
Likewise.
* language.c (set_language_command, _initialize_language): Likewise.
* linespec.c (decode_line_2): Likewise.
* rs6000-nat.c (add_vmap): Likewise.
* top.c (set_prompt, init_history, init_main): Likewise.
* tracepoint.c (stringify_collection_list): Likewise.
* varobj.c (varobj_create): Remove variable expr_len.  Replace the
savestring calls by xstrdup calls where possible.
(value_of_root, c_name_of_variable, c_describe_child): Replace the
savestring calls by xstrdup calls where possible.
* xcoffread.c (complete_symtab): Likewise.
* cli/cli-script.c (build_command_line, define_command): Likewise.
* cli/cli-setshow.c (do_setshow_command): Likewise.

18 files changed:
gdb/ChangeLog
gdb/breakpoint.c
gdb/buildsym.c
gdb/cli/cli-script.c
gdb/cli/cli-setshow.c
gdb/coffread.c
gdb/corefile.c
gdb/dbxread.c
gdb/demangle.c
gdb/event-top.c
gdb/infcmd.c
gdb/language.c
gdb/linespec.c
gdb/rs6000-nat.c
gdb/top.c
gdb/tracepoint.c
gdb/varobj.c
gdb/xcoffread.c

index da506329b8dc508d43fe06519d1144b7ff922ade..bcc9ab115dbde6e5018cb0056072a6c288f33ad0 100644 (file)
@@ -1,3 +1,32 @@
+2009-05-23  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+       Replace the savestring calls by xstrdup calls where possible.
+       * breakpoint.c (condition_command, set_raw_breakpoint)
+       (create_catchpoint, update_breakpoint_locations): Replace the
+       savestring calls by xstrdup calls where possible.
+       * buildsym.c (start_subfile, patch_subfile_names, record_debugformat)
+       (record_producer): Likewise.
+       * coffread.c (coff_start_symtab, complete_symtab): Likewise.
+       * corefile.c (set_gnutarget): Likewise.
+       * dbxread.c (add_new_header_file): Likewise.
+       * demangle.c (set_demangling_command, set_demangling_style): Likewise.
+       * event-top.c (push_prompt, pop_prompt, command_line_handler)
+       (set_async_prompt): Likewise.
+       * infcmd.c (set_inferior_io_terminal, attach_command_post_wait):
+       Likewise.
+       * language.c (set_language_command, _initialize_language): Likewise.
+       * linespec.c (decode_line_2): Likewise.
+       * rs6000-nat.c (add_vmap): Likewise.
+       * top.c (set_prompt, init_history, init_main): Likewise.
+       * tracepoint.c (stringify_collection_list): Likewise.
+       * varobj.c (varobj_create): Remove variable expr_len.  Replace the 
+       savestring calls by xstrdup calls where possible.
+       (value_of_root, c_name_of_variable, c_describe_child): Replace the
+       savestring calls by xstrdup calls where possible.
+       * xcoffread.c (complete_symtab): Likewise.
+       * cli/cli-script.c (build_command_line, define_command): Likewise.
+       * cli/cli-setshow.c (do_setshow_command): Likewise.
+
 2009-05-23  Jan Kratochvil  <jan.kratochvil@redhat.com>
 
        Remove already unreachable code.
index e36429da92f9bcbbbec575fc5a3eb19e8a4e097c..b5362e2c8ea861d0ada6929860ec0ea6ed7ccd47 100644 (file)
@@ -597,7 +597,7 @@ condition_command (char *arg, int from_tty)
            arg = p;
            /* I don't know if it matters whether this is the string the user
               typed in or the decompiled expression.  */
-           b->cond_string = savestring (arg, strlen (arg));
+           b->cond_string = xstrdup (arg);
            b->condition_not_parsed = 0;
            for (loc = b->loc; loc; loc = loc->next)
              {
@@ -4394,8 +4394,7 @@ set_raw_breakpoint (struct symtab_and_line sal, enum bptype bptype)
   if (sal.symtab == NULL)
     b->source_file = NULL;
   else
-    b->source_file = savestring (sal.symtab->filename,
-                                strlen (sal.symtab->filename));
+    b->source_file = xstrdup (sal.symtab->filename);
   b->loc->section = sal.section;
   b->line_number = sal.line;
 
@@ -4816,8 +4815,7 @@ create_catchpoint (int tempflag, char *cond_string,
   set_breakpoint_count (breakpoint_count + 1);
   b->number = breakpoint_count;
 
-  b->cond_string = (cond_string == NULL) ? 
-    NULL : savestring (cond_string, strlen (cond_string));
+  b->cond_string = (cond_string == NULL) ? NULL : xstrdup (cond_string);
   b->thread = -1;
   b->addr_string = NULL;
   b->enable_state = bp_enabled;
@@ -7490,9 +7488,7 @@ update_breakpoint_locations (struct breakpoint *b,
       if (sals.sals[i].symtab == NULL)
        b->source_file = NULL;
       else
-       b->source_file =
-         savestring (sals.sals[i].symtab->filename,
-                     strlen (sals.sals[i].symtab->filename));
+       b->source_file = xstrdup (sals.sals[i].symtab->filename);
 
       if (b->line_number == 0)
        b->line_number = sals.sals[i].line;
index 6de817f8b9f0cf40b901ae9a37d4b871d4e86f74..e0d8f0da7dd5267102ffebb4ca608142b4908018 100644 (file)
@@ -561,9 +561,8 @@ start_subfile (char *name, char *dirname)
   current_subfile = subfile;
 
   /* Save its name and compilation directory name */
-  subfile->name = (name == NULL) ? NULL : savestring (name, strlen (name));
-  subfile->dirname =
-    (dirname == NULL) ? NULL : savestring (dirname, strlen (dirname));
+  subfile->name = (name == NULL) ? NULL : xstrdup (name);
+  subfile->dirname = (dirname == NULL) ? NULL : xstrdup (dirname);
 
   /* Initialize line-number recording for this subfile.  */
   subfile->line_vector = NULL;
@@ -638,7 +637,7 @@ patch_subfile_names (struct subfile *subfile, char *name)
       && subfile->name[strlen (subfile->name) - 1] == '/')
     {
       subfile->dirname = subfile->name;
-      subfile->name = savestring (name, strlen (name));
+      subfile->name = xstrdup (name);
       last_source_file = name;
 
       /* Default the source language to whatever can be deduced from
@@ -1260,7 +1259,7 @@ hashname (char *name)
 void
 record_debugformat (char *format)
 {
-  current_subfile->debugformat = savestring (format, strlen (format));
+  current_subfile->debugformat = xstrdup (format);
 }
 
 void
@@ -1271,7 +1270,7 @@ record_producer (const char *producer)
   if (producer == NULL)
     return;
 
-  current_subfile->producer = savestring (producer, strlen (producer));
+  current_subfile->producer = xstrdup (producer);
 }
 
 /* Merge the first symbol list SRCLIST into the second symbol list
index d17e67a1af77073a1981edeb837a1f4ba9225ebe..054ce9084507379110a0e659b3fe3c07c7bbe349 100644 (file)
@@ -94,7 +94,7 @@ build_command_line (enum command_control_type type, char *args)
     = (struct command_line **) xmalloc (sizeof (struct command_line *)
                                        * cmd->body_count);
   memset (cmd->body_list, 0, sizeof (struct command_line *) * cmd->body_count);
-  cmd->line = savestring (args, strlen (args));
+  cmd->line = xstrdup (args);
 
   return cmd;
 }
@@ -1384,7 +1384,7 @@ define_command (char *comname, int from_tty)
        }
     }
 
-  comname = savestring (comname, strlen (comname));
+  comname = xstrdup (comname);
 
   /* If the rest of the commands will be case insensitive, this one
      should behave in the same manner. */
@@ -1400,7 +1400,7 @@ define_command (char *comname, int from_tty)
 
   newc = add_cmd (comname, class_user, user_defined_command,
                  (c && c->class == class_user)
-                 ? c->doc : savestring ("User-defined.", 13), list);
+                 ? c->doc : xstrdup ("User-defined."), list);
   newc->user_commands = cmds;
 
   /* If this new command is a hook, then mark both commands as being
index 206a55d8f0b4dbd68d038f885085dd4f7f58b957..851f042b6c38e95700b42838172b37f030bf52d9 100644 (file)
@@ -177,14 +177,14 @@ do_setshow_command (char *arg, int from_tty, struct cmd_list_element *c)
            arg = "";
          if (*(char **) c->var != NULL)
            xfree (*(char **) c->var);
-         *(char **) c->var = savestring (arg, strlen (arg));
+         *(char **) c->var = xstrdup (arg);
          break;
        case var_optional_filename:
          if (arg == NULL)
            arg = "";
          if (*(char **) c->var != NULL)
            xfree (*(char **) c->var);
-         *(char **) c->var = savestring (arg, strlen (arg));
+         *(char **) c->var = xstrdup (arg);
          break;
        case var_filename:
          if (arg == NULL)
index 30b7726ae26f4e94a6b1daf16409da8130553ca0..1e5cb56fe1a9c853659ba264670007bb3c10de51 100644 (file)
@@ -364,7 +364,7 @@ coff_start_symtab (char *name)
      this pointer into last_source_file and we put it in
      subfiles->name, which end_symtab frees; that's why
      it must be malloc'd.  */
-                savestring (name, strlen (name)),
+                xstrdup (name),
   /* We never know the directory name for COFF.  */
                 NULL,
   /* The start address is irrelevant, since we set
@@ -383,7 +383,7 @@ complete_symtab (char *name, CORE_ADDR start_addr, unsigned int size)
 {
   if (last_source_file != NULL)
     xfree (last_source_file);
-  last_source_file = savestring (name, strlen (name));
+  last_source_file = xstrdup (name);
   current_source_start_addr = start_addr;
   current_source_end_addr = start_addr + size;
 }
index e667183c61c3e45fd239a3277190b87d4fabb63d..e74630b3a2c5db652830d3b8c741da870b291855 100644 (file)
@@ -399,7 +399,7 @@ set_gnutarget (char *newtarget)
 {
   if (gnutarget_string != NULL)
     xfree (gnutarget_string);
-  gnutarget_string = savestring (newtarget, strlen (newtarget));
+  gnutarget_string = xstrdup (newtarget);
   set_gnutarget_command (NULL, 0, NULL);
 }
 
index be7376914927b02726f5c35585aa9c54288f1153..33a210497bcf09dd4c7b38a3d2c2f8d8a37b7f12 100644 (file)
@@ -395,7 +395,7 @@ add_new_header_file (char *name, int instance)
 
   i = N_HEADER_FILES (current_objfile)++;
   hfile = HEADER_FILES (current_objfile) + i;
-  hfile->name = savestring (name, strlen (name));
+  hfile->name = xstrdup (name);
   hfile->instance = instance;
   hfile->length = 10;
   hfile->vector
index 4a39ad966890c18bb07f30408d6b9a875caccd62..b5ccf8719aae21540facd328218f01dfc5317967 100644 (file)
@@ -125,8 +125,7 @@ set_demangling_command (char *ignore, int from_tty, struct cmd_list_element *c)
            {
              xfree (current_demangling_style_string);
              current_demangling_style_string =
-               savestring (dem->demangling_style_name,
-                           strlen (dem->demangling_style_name));
+               xstrdup (dem->demangling_style_name);
            }
        }
       if (current_demangling_style == unknown_demangling)
@@ -136,9 +135,7 @@ set_demangling_command (char *ignore, int from_tty, struct cmd_list_element *c)
             one as the default. */
          current_demangling_style = libiberty_demanglers[0].demangling_style;
          current_demangling_style_string =
-           savestring (
-              libiberty_demanglers[0].demangling_style_name,
-             strlen (libiberty_demanglers[0].demangling_style_name));
+           xstrdup (libiberty_demanglers[0].demangling_style_name);
          warning (_("`%s' style demangling chosen as the default."),
                   current_demangling_style_string);
        }
@@ -154,7 +151,7 @@ set_demangling_style (char *style)
     {
       xfree (current_demangling_style_string);
     }
-  current_demangling_style_string = savestring (style, strlen (style));
+  current_demangling_style_string = xstrdup (style);
   set_demangling_command ((char *) NULL, 0, (struct cmd_list_element *) NULL);
 }
 
index 31ebd4ea0042d87a3181267a4f4511c755de8c08..790cebff3105b64c5662cb44864b610ca4ab82de 100644 (file)
@@ -372,22 +372,22 @@ change_annotation_level (void)
 /* Pushes a new prompt on the prompt stack. Each prompt has three
    parts: prefix, prompt, suffix. Usually prefix and suffix are empty
    strings, except when the annotation level is 2. Memory is allocated
-   within savestring for the new prompt. */
+   within xstrdup for the new prompt. */
 void
 push_prompt (char *prefix, char *prompt, char *suffix)
 {
   the_prompts.top++;
-  PREFIX (0) = savestring (prefix, strlen (prefix));
+  PREFIX (0) = xstrdup (prefix);
 
   /* Note that this function is used by the set annotate 2
      command. This is why we take care of saving the old prompt
      in case a new one is not specified. */
   if (prompt)
-    PROMPT (0) = savestring (prompt, strlen (prompt));
+    PROMPT (0) = xstrdup (prompt);
   else
-    PROMPT (0) = savestring (PROMPT (-1), strlen (PROMPT (-1)));
+    PROMPT (0) = xstrdup (PROMPT (-1));
 
-  SUFFIX (0) = savestring (suffix, strlen (suffix));
+  SUFFIX (0) = xstrdup (suffix);
 }
 
 /* Pops the top of the prompt stack, and frees the memory allocated for it. */
@@ -404,7 +404,7 @@ pop_prompt (void)
     if (strcmp (PROMPT (0), PROMPT (-1)))
       {
        xfree (PROMPT (-1));
-       PROMPT (-1) = savestring (PROMPT (0), strlen (PROMPT (0)));
+       PROMPT (-1) = xstrdup (PROMPT (0));
       }
 
   xfree (PREFIX (0));
@@ -624,8 +624,7 @@ command_line_handler (char *rl)
     {
       p--;                     /* Put on top of '\'.  */
 
-      readline_input_state.linebuffer = savestring (linebuffer,
-                                                   strlen (linebuffer));
+      readline_input_state.linebuffer = xstrdup (linebuffer);
       readline_input_state.linebuffer_ptr = p;
 
       /* We will not invoke a execute_command if there is more
@@ -1063,7 +1062,7 @@ set_async_annotation_level (char *args, int from_tty, struct cmd_list_element *c
 void
 set_async_prompt (char *args, int from_tty, struct cmd_list_element *c)
 {
-  PROMPT (0) = savestring (new_async_prompt, strlen (new_async_prompt));
+  PROMPT (0) = xstrdup (new_async_prompt);
 }
 
 /* Set things up for readline to be invoked via the alternate
index 433b0b83d4cd6b609ee332f01b88bff525f6cfae..0ad117050c91edc2a2017d1616e2efe67fe79873 100644 (file)
@@ -178,7 +178,7 @@ set_inferior_io_terminal (const char *terminal_name)
   if (!terminal_name)
     inferior_io_terminal = NULL;
   else
-    inferior_io_terminal = savestring (terminal_name, strlen (terminal_name));
+    inferior_io_terminal = xstrdup (terminal_name);
 }
 
 const char *
@@ -2154,7 +2154,7 @@ attach_command_post_wait (char *args, int from_tty, int async_exec)
             filename.  Not much more we can do...)
           */
          if (!source_full_path_of (exec_file, &full_exec_path))
-           full_exec_path = savestring (exec_file, strlen (exec_file));
+           full_exec_path = xstrdup (exec_file);
 
          exec_file_attach (full_exec_path, from_tty);
          symbol_file_add_main (full_exec_path, from_tty);
index 6209d7fa1e7fe5a5cd15ee384ac6b390e40ca8cf..62eeb621f03b1419c24a84885215bd3487f54d4c 100644 (file)
@@ -215,7 +215,7 @@ local or auto    Automatic setting based on source file\n"));
 
   /* Reset the language (esp. the global string "language") to the 
      correct values. */
-  err_lang = savestring (language, strlen (language));
+  err_lang = xstrdup (language);
   make_cleanup (xfree, err_lang);      /* Free it after error */
   set_language (current_language->la_language);
   error (_("Unknown language `%s'."), err_lang);
@@ -1401,10 +1401,10 @@ For Fortran the default is off; for other languages the default is on."),
   add_language (&local_language_defn);
   add_language (&auto_language_defn);
 
-  language = savestring ("auto", strlen ("auto"));
-  type = savestring ("auto", strlen ("auto"));
-  range = savestring ("auto", strlen ("auto"));
-  case_sensitive = savestring ("auto",strlen ("auto"));
+  language = xstrdup ("auto");
+  type = xstrdup ("auto");
+  range = xstrdup ("auto");
+  case_sensitive = xstrdup ("auto");
 
   /* Have the above take effect */
   set_language (language_auto);
index 6579d42f0b1db765df92cebd00e27d0c3780b548..e2018e6a22e58b1df7b28e6215e343b5a2cc8dec 100644 (file)
@@ -587,7 +587,7 @@ See set/show multiple-symbol."));
                  if (canonical_arr[i] == NULL)
                    {
                      symname = SYMBOL_LINKAGE_NAME (sym_arr[i]);
-                     canonical_arr[i] = savestring (symname, strlen (symname));
+                     canonical_arr[i] = xstrdup (symname);
                    }
                }
            }
@@ -611,7 +611,7 @@ See set/show multiple-symbol."));
                {
                  symname = SYMBOL_LINKAGE_NAME (sym_arr[num]);
                  make_cleanup (xfree, symname);
-                 canonical_arr[i] = savestring (symname, strlen (symname));
+                 canonical_arr[i] = xstrdup (symname);
                }
              return_values.sals[i++] = values.sals[num];
              values.sals[num].pc = 0;
index ae2806de7948e0db905058c1470dae97e38ecb31..c1e3b4756e0ccf77ebcc69e10f843735880f48ac 100644 (file)
@@ -736,8 +736,8 @@ add_vmap (LdInfo *ldi)
 
   filename = LDI_FILENAME (ldi, arch64);
   mem = filename + strlen (filename) + 1;
-  mem = savestring (mem, strlen (mem));
-  objname = savestring (filename, strlen (filename));
+  mem = xstrdup (mem);
+  objname = xstrdup (filename);
 
   fd = LDI_FD (ldi, arch64);
   if (fd < 0)
index ba635eaa6493ffad196552f6d77515e953c3d7cd..7a10f7c647721d01fd5037b30c6aa9765fe58621 100644 (file)
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -1153,11 +1153,11 @@ void
 set_prompt (char *s)
 {
 /* ??rehrauer: I don't know why this fails, since it looks as though
-   assignments to prompt are wrapped in calls to savestring...
+   assignments to prompt are wrapped in calls to xstrdup...
    if (prompt != NULL)
    xfree (prompt);
  */
-  PROMPT (0) = savestring (s, strlen (s));
+  PROMPT (0) = xstrdup (s);
 }
 \f
 
@@ -1458,7 +1458,7 @@ init_history (void)
 
   tmpenv = getenv ("GDBHISTFILE");
   if (tmpenv)
-    history_filename = savestring (tmpenv, strlen (tmpenv));
+    history_filename = xstrdup (tmpenv);
   else if (!history_filename)
     {
       /* We include the current directory so that if the user changes
@@ -1516,13 +1516,13 @@ init_main (void)
      whatever the DEFAULT_PROMPT is.  */
   the_prompts.top = 0;
   PREFIX (0) = "";
-  PROMPT (0) = savestring (DEFAULT_PROMPT, strlen (DEFAULT_PROMPT));
+  PROMPT (0) = xstrdup (DEFAULT_PROMPT);
   SUFFIX (0) = "";
   /* Set things up for annotation_level > 1, if the user ever decides
      to use it.  */
   async_annotation_suffix = "prompt";
   /* Set the variable associated with the setshow prompt command.  */
-  new_async_prompt = savestring (PROMPT (0), strlen (PROMPT (0)));
+  new_async_prompt = xstrdup (PROMPT (0));
 
   /* If gdb was started with --annotate=2, this is equivalent to the
      user entering the command 'set annotate 2' at the gdb prompt, so
index 317d1238d3979fa33b22bae06bfde715bed4520d..af962a6645cd74aa6d20dc793c15afb20e554a6e 100644 (file)
@@ -938,7 +938,7 @@ stringify_collection_list (struct collection_list *list, char *string)
          sprintf (end, "%02X", list->regs_mask[i]);
          end += 2;
        }
-      (*str_list)[ndx] = savestring (temp_buf, end - temp_buf);
+      (*str_list)[ndx] = xstrdup (temp_buf);
       ndx++;
     }
   if (info_verbose)
index 54c2a02efdf3d75c0fc3730d1dc5923bf9c59381..e8556d78fd3d6f62d647a81657c5bbb644c38e26 100644 (file)
@@ -461,7 +461,6 @@ varobj_create (char *objname,
       char *p;
       enum varobj_languages lang;
       struct value *value = NULL;
-      int expr_len;
 
       /* Parse and evaluate the expression, filling in as much of the
          variable's data as possible.  */
@@ -512,10 +511,9 @@ varobj_create (char *objname,
 
       var->format = variable_default_display (var);
       var->root->valid_block = innermost_block;
-      expr_len = strlen (expression);
-      var->name = savestring (expression, expr_len);
+      var->name = xstrdup (expression);
       /* For a root var, the name and the expr are the same.  */
-      var->path_expr = savestring (expression, expr_len);
+      var->path_expr = xstrdup (expression);
 
       /* When the frame is different from the current frame, 
          we must select the appropriate frame before parsing
@@ -561,7 +559,7 @@ varobj_create (char *objname,
 
   if ((var != NULL) && (objname != NULL))
     {
-      var->obj_name = savestring (objname, strlen (objname));
+      var->obj_name = xstrdup (objname);
 
       /* If a varobj name is duplicated, the install will fail so
          we must clenup */
@@ -1765,8 +1763,7 @@ value_of_root (struct varobj **var_handle, int *type_changed)
        }
       else
        {
-         tmp_var->obj_name =
-           savestring (var->obj_name, strlen (var->obj_name));
+         tmp_var->obj_name = xstrdup (var->obj_name);
          varobj_delete (var, NULL, 0);
 
          install_variable (tmp_var);
@@ -2015,7 +2012,7 @@ c_number_of_children (struct varobj *var)
 static char *
 c_name_of_variable (struct varobj *parent)
 {
-  return savestring (parent->name, strlen (parent->name));
+  return xstrdup (parent->name);
 }
 
 /* Return the value of element TYPE_INDEX of a structure
@@ -2114,10 +2111,7 @@ c_describe_child (struct varobj *parent, int index,
     case TYPE_CODE_STRUCT:
     case TYPE_CODE_UNION:
       if (cname)
-       {
-         char *string = TYPE_FIELD_NAME (type, index);
-         *cname = savestring (string, strlen (string));
-       }
+       *cname = xstrdup (TYPE_FIELD_NAME (type, index));
 
       if (cvalue && value)
        {
index 9ae929f24d5bd60be9546a0d83db2b7d59525b0e..d26838c1f666b8a92bc6151d728d66b238dbff99 100644 (file)
@@ -831,8 +831,8 @@ enter_line_range (struct subfile *subfile, unsigned beginoffset, unsigned endoff
    text address for the file, and SIZE is the number of bytes of text.  */
 
 #define complete_symtab(name, start_addr) {    \
-  last_source_file = savestring (name, strlen (name)); \
-  last_source_start_addr = start_addr;                 \
+  last_source_file = xstrdup (name);           \
+  last_source_start_addr = start_addr;         \
 }
 
 
This page took 0.046011 seconds and 4 git commands to generate.