aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/ChangeLog29
-rw-r--r--gdb/breakpoint.c12
-rw-r--r--gdb/buildsym.c11
-rw-r--r--gdb/cli/cli-script.c6
-rw-r--r--gdb/cli/cli-setshow.c4
-rw-r--r--gdb/coffread.c4
-rw-r--r--gdb/corefile.c2
-rw-r--r--gdb/dbxread.c2
-rw-r--r--gdb/demangle.c9
-rw-r--r--gdb/event-top.c17
-rw-r--r--gdb/infcmd.c4
-rw-r--r--gdb/language.c10
-rw-r--r--gdb/linespec.c4
-rw-r--r--gdb/rs6000-nat.c4
-rw-r--r--gdb/top.c10
-rw-r--r--gdb/tracepoint.c2
-rw-r--r--gdb/varobj.c18
-rw-r--r--gdb/xcoffread.c4
18 files changed, 83 insertions, 69 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index da50632..bcc9ab1 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,34 @@
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.
* varobj.c (varobj_get_handle): Fix comment when error is called.
All callers updated.
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index e36429d..b5362e2 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -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;
diff --git a/gdb/buildsym.c b/gdb/buildsym.c
index 6de817f..e0d8f0d 100644
--- a/gdb/buildsym.c
+++ b/gdb/buildsym.c
@@ -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
diff --git a/gdb/cli/cli-script.c b/gdb/cli/cli-script.c
index d17e67a..054ce90 100644
--- a/gdb/cli/cli-script.c
+++ b/gdb/cli/cli-script.c
@@ -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
diff --git a/gdb/cli/cli-setshow.c b/gdb/cli/cli-setshow.c
index 206a55d..851f042 100644
--- a/gdb/cli/cli-setshow.c
+++ b/gdb/cli/cli-setshow.c
@@ -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)
diff --git a/gdb/coffread.c b/gdb/coffread.c
index 30b7726..1e5cb56 100644
--- a/gdb/coffread.c
+++ b/gdb/coffread.c
@@ -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;
}
diff --git a/gdb/corefile.c b/gdb/corefile.c
index e667183..e74630b 100644
--- a/gdb/corefile.c
+++ b/gdb/corefile.c
@@ -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);
}
diff --git a/gdb/dbxread.c b/gdb/dbxread.c
index be73769..33a2104 100644
--- a/gdb/dbxread.c
+++ b/gdb/dbxread.c
@@ -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
diff --git a/gdb/demangle.c b/gdb/demangle.c
index 4a39ad9..b5ccf87 100644
--- a/gdb/demangle.c
+++ b/gdb/demangle.c
@@ -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);
}
diff --git a/gdb/event-top.c b/gdb/event-top.c
index 31ebd4e..790cebf 100644
--- a/gdb/event-top.c
+++ b/gdb/event-top.c
@@ -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
diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index 433b0b8..0ad1170 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -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);
diff --git a/gdb/language.c b/gdb/language.c
index 6209d7f..62eeb62 100644
--- a/gdb/language.c
+++ b/gdb/language.c
@@ -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);
diff --git a/gdb/linespec.c b/gdb/linespec.c
index 6579d42..e2018e6 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -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;
diff --git a/gdb/rs6000-nat.c b/gdb/rs6000-nat.c
index ae2806d..c1e3b47 100644
--- a/gdb/rs6000-nat.c
+++ b/gdb/rs6000-nat.c
@@ -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)
diff --git a/gdb/top.c b/gdb/top.c
index ba635ea..7a10f7c 100644
--- 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);
}
@@ -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
diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
index 317d123..af962a6 100644
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -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)
diff --git a/gdb/varobj.c b/gdb/varobj.c
index 54c2a02..e8556d7 100644
--- a/gdb/varobj.c
+++ b/gdb/varobj.c
@@ -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)
{
diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c
index 9ae929f..d26838c 100644
--- a/gdb/xcoffread.c
+++ b/gdb/xcoffread.c
@@ -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; \
}