struct ui_out *uiout = current_uiout;
CORE_ADDR frameaddr = 0;
struct varobj *var;
- char *name;
char *frame;
char *expr;
- struct cleanup *old_cleanups;
enum varobj_type var_type;
if (argc != 3)
error (_("-var-create: Usage: NAME FRAME EXPRESSION."));
- name = xstrdup (argv[0]);
- /* Add cleanup for name. Must be free_current_contents as name can
- be reallocated. */
- old_cleanups = make_cleanup (free_current_contents, &name);
-
- frame = xstrdup (argv[1]);
- make_cleanup (xfree, frame);
-
- expr = xstrdup (argv[2]);
- make_cleanup (xfree, expr);
+ frame = argv[1];
+ expr = argv[2];
+ const char *name = argv[0];
+ std::string gen_name;
if (strcmp (name, "-") == 0)
{
- xfree (name);
- name = varobj_gen_name ();
+ gen_name = varobj_gen_name ();
+ name = gen_name.c_str ();
}
- else if (!isalpha (*name))
+ else if (!isalpha (name[0]))
error (_("-var-create: name of object must begin with a letter"));
if (strcmp (frame, "*") == 0)
if (varobjdebug)
fprintf_unfiltered (gdb_stdlog,
- "Name=\"%s\", Frame=\"%s\" (%s), Expression=\"%s\"\n",
+ "Name=\"%s\", Frame=\"%s\" (%s), Expression=\"%s\"\n",
name, frame, hex_string (frameaddr), expr);
var = varobj_create (name, expr, frameaddr, var_type);
print_varobj (var, PRINT_ALL_VALUES, 0 /* don't print expression */);
uiout->field_int ("has_more", varobj_has_more (var, 0));
-
- do_cleanups (old_cleanups);
}
void
struct varobj *var;
int numdel;
int children_only_p = 0;
- struct cleanup *old_cleanups;
struct ui_out *uiout = current_uiout;
if (argc < 1 || argc > 2)
error (_("-var-delete: Usage: [-c] EXPRESSION."));
- name = xstrdup (argv[0]);
- /* Add cleanup for name. Must be free_current_contents as name can
- be reallocated. */
- old_cleanups = make_cleanup (free_current_contents, &name);
+ name = argv[0];
/* If we have one single argument it cannot be '-c' or any string
starting with '-'. */
if (strcmp (name, "-c") != 0)
error (_("-var-delete: Invalid option."));
children_only_p = 1;
- do_cleanups (old_cleanups);
- name = xstrdup (argv[1]);
- old_cleanups = make_cleanup (free_current_contents, &name);
+ name = argv[1];
}
/* If we didn't error out, now NAME contains the name of the
numdel = varobj_delete (var, children_only_p);
uiout->field_int ("ndeleted", numdel);
-
- do_cleanups (old_cleanups);
}
/* Parse a string argument into a format value. */