2000-03-13 James Ingham <jingham@leda.cygnus.com>

Add support for a variable object that tries to evaluate itself in
	the currently selected frame, rather than in a fixed frame.

	* wrapper.c,h (gdb_parse_exp_1): Added a wrapper for
 	gdb_parse_exp_1.
	* varobj.h: Added USE_CURRENT_FRAME to varobj_type & changed def'n
	of varobj_create.
	* varobj.c (varobj_list): Return type indicates whether the
	variable's type has changed (for current frame variables).
	(varobj_update): Handle the case where the variable's type has
	changed.
	(delete_variable_1): Allow for deletion of variables that have not
	been installed yet.
	(new_root_variable): Initialize use_selected_frame variable.
	(value_of_root): This is where most of the work to handle "current
	frame" variables was added.  Most of the complexity involves
	handling the case where the type of the variable has changed.
	(varobj_create): Add a "type" argument, to tell if the
	variable is one of these "current frame" variables.  Also protect
	call to parse_exp_1 from long jumping.

	* mi-var-block.exp: The error report from varobj_create changed
	since I am now trapping parse_exp_1 errors.  Change the tests to
	match the new error message.
	* mi-var-child.exp: Ditto.
	* mi-var-cmd.exp: Ditto.

	* lib/gdb.exp: Fix the gdbtk_start routine to correctly find all
	the library directories.

	* gdbtk-varobj.c (variable_create): Pass the correct
	"how_specified" flag to the varobj_create routine.
This commit is contained in:
Jim Ingham
2000-03-13 21:51:46 +00:00
parent 271bb601c4
commit 73a93a3251
13 changed files with 351 additions and 101 deletions

View File

@ -34,20 +34,21 @@
extern int varobjdebug; /* defined in varobj.c */
static void varobj_update_one (struct varobj *var);
static int varobj_update_one (struct varobj *var);
/* VAROBJ operations */
enum mi_cmd_result
mi_cmd_var_create (char *command, char **argv, int argc)
{
CORE_ADDR frameaddr;
CORE_ADDR frameaddr = 0;
struct varobj *var;
char *name;
char *frame;
char *expr;
char *type;
struct cleanup *old_cleanups;
enum varobj_type var_type;
if (argc != 3)
{
@ -77,16 +78,21 @@ mi_cmd_var_create (char *command, char **argv, int argc)
error ("mi_cmd_var_create: name of object must begin with a letter");
if (strcmp (frame, "*") == 0)
frameaddr = -1;
var_type = USE_CURRENT_FRAME;
else if (strcmp (frame, "@") == 0)
var_type = USE_SELECTED_FRAME;
else
frameaddr = parse_and_eval_address (frame);
{
var_type = USE_SPECIFIED_FRAME;
frameaddr = parse_and_eval_address (frame);
}
if (varobjdebug)
fprintf_unfiltered (gdb_stdlog,
"Name=\"%s\", Frame=\"%s\" (0x%s), Expression=\"%s\"\n",
name, frame, paddr (frameaddr), expr);
var = varobj_create (name, expr, frameaddr);
var = varobj_create (name, expr, frameaddr, var_type);
if (var == NULL)
error ("mi_cmd_var_create: unable to create variable object");
@ -443,12 +449,14 @@ mi_cmd_var_update (char *command, char **argv, int argc)
varobj_update_one (var);
ui_out_list_end (uiout);
}
return MI_CMD_DONE;
return MI_CMD_DONE;
}
/* Helper for mi_cmd_var_update() */
/* Helper for mi_cmd_var_update() Returns 0 if the update for
the variable fails (usually because the variable is out of
scope), and 1 if it succeeds. */
static void
static int
varobj_update_one (struct varobj *var)
{
struct varobj **changelist;
@ -457,16 +465,41 @@ varobj_update_one (struct varobj *var)
nc = varobj_update (var, &changelist);
if (nc <= 0)
return;
cc = changelist;
while (*cc != NULL)
/* nc == 0 means that nothing has changed.
nc == -1 means that an error occured in updating the variable.
nc == -2 means the variable has changed type. */
if (nc == 0)
return 1;
else if (nc == -1)
{
ui_out_field_string (uiout, "name", varobj_get_objname (*cc));
cc++;
ui_out_field_string (uiout, "name", varobj_get_objname(var));
ui_out_field_string (uiout, "in_scope", "false");
return -1;
}
free (changelist);
else if (nc == -2)
{
ui_out_field_string (uiout, "name", varobj_get_objname (var));
ui_out_field_string (uiout, "in_scope", "true");
ui_out_field_string (uiout, "new_type", varobj_get_type(var));
ui_out_field_int (uiout, "new_num_children",
varobj_get_num_children(var));
}
else
{
cc = changelist;
while (*cc != NULL)
{
ui_out_field_string (uiout, "name", varobj_get_objname (*cc));
ui_out_field_string (uiout, "in_scope", "true");
ui_out_field_string (uiout, "type_changed", "false");
cc++;
}
free (changelist);
return 1;
}
return 1;
}
/* Local variables: */