/* Implementation of the GDB variable objects API.
- Copyright 1999, 2000, 2001 Free Software Foundation, Inc.
+
+ Copyright 1999, 2000, 2001, 2005 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
frame = get_prev_frame (frame);
if (frame == NULL)
return NULL;
- if (FRAME_FP (frame) == frame_addr)
+ if (get_frame_base_address (frame) == frame_addr)
return frame;
}
}
/* Allow creator to specify context of variable */
if ((type == USE_CURRENT_FRAME) || (type == USE_SELECTED_FRAME))
- fi = selected_frame;
+ fi = deprecated_selected_frame;
else
/* FIXME: cagney/2002-11-23: This code should be doing a
lookup using the frame ID and not just the frame's
if (var->root->exp->elts[0].opcode == OP_TYPE)
{
do_cleanups (old_chain);
- fprintf_unfiltered (gdb_stderr,
- "Attempt to use a type name as an expression.");
+ fprintf_unfiltered (gdb_stderr, "Attempt to use a type name"
+ " as an expression.\n");
return NULL;
}
Since select_frame is so benign, just call it for all cases. */
if (fi != NULL)
{
- get_frame_id (fi, &var->root->frame);
- old_fi = selected_frame;
+ var->root->frame = get_frame_id (fi);
+ old_fi = deprecated_selected_frame;
select_frame (fi);
}
{
/* no error */
release_value (var->value);
- if (VALUE_LAZY (var->value))
+ if (value_lazy (var->value))
gdb_value_fetch_lazy (var->value);
}
else
var->value = evaluate_type (var->root->exp);
- var->type = VALUE_TYPE (var->value);
+ var->type = value_type (var->value);
/* Set language info */
lang = variable_language (var);
/* generate a name for this object */
id++;
- xasprintf (&obj_name, "var%d", id);
+ obj_name = xstrprintf ("var%d", id);
return obj_name;
}
/* To print the type, we simply create a zero ``struct value *'' and
cast it to our type. We then typeprint this variable. */
val = value_zero (var->type, not_lval);
- type_print (VALUE_TYPE (val), "", stb, -1);
+ type_print (value_type (val), "", stb, -1);
thetype = ui_file_xstrdup (stb, &length);
do_cleanups (old_chain);
/* Save the selected stack frame, since we will need to change it
in order to evaluate expressions. */
- get_frame_id (selected_frame, &old_fid);
+ old_fid = get_frame_id (deprecated_selected_frame);
/* Update the root variable. value_of_root can return NULL
if the variable is no longer around, i.e. we stepped out of
child->error = 1;
child->parent = parent;
child->root = parent->root;
- xasprintf (&childs_name, "%s.%s", parent->obj_name, name);
+ childs_name = xstrprintf ("%s.%s", parent->obj_name, name);
child->obj_name = childs_name;
install_variable (child);
var->root->lang = NULL;
var->root->exp = NULL;
var->root->valid_block = NULL;
- var->root->frame.base = 0;
- var->root->frame.pc = 0;
+ var->root->frame = null_frame_id;
var->root->use_selected_frame = 0;
var->root->rootvar = NULL;
return make_cleanup (do_free_variable_cleanup, var);
}
-/* This returns the type of the variable. This skips past typedefs
- and returns the real type of the variable. It also dereferences
- pointers and references.
+/* This returns the type of the variable. It also skips past typedefs
+ to return the real type of the variable.
NOTE: TYPE_TARGET_TYPE should NOT be used anywhere in this file
except within get_target_type and get_type. */
struct type *type;
type = var->type;
- while (type != NULL && TYPE_CODE (type) == TYPE_CODE_TYPEDEF)
- type = TYPE_TARGET_TYPE (type);
+ if (type != NULL)
+ type = check_typedef (type);
return type;
}
if (type != NULL)
{
type = TYPE_TARGET_TYPE (type);
- while (type != NULL && TYPE_CODE (type) == TYPE_CODE_TYPEDEF)
- type = TYPE_TARGET_TYPE (type);
+ if (type != NULL)
+ type = check_typedef (type);
}
return type;
value = (*parent->root->lang->value_of_child) (parent, index);
/* If we're being lazy, fetch the real value of the variable. */
- if (value != NULL && VALUE_LAZY (value))
+ if (value != NULL && value_lazy (value))
{
/* If we fail to fetch the value of the child, return
NULL so that callers notice that we're leaving an
/* If the child had no evaluation errors, var->value
will be non-NULL and contain a valid type. */
if (var->value != NULL)
- return VALUE_TYPE (var->value);
+ return value_type (var->value);
/* Otherwise, we must compute the type. */
return (*var->root->lang->type_of_child) (var->parent, var->index);
switch (TYPE_CODE (type))
{
case TYPE_CODE_ARRAY:
- xasprintf (&name, "%d", index);
+ name = xstrprintf ("%d", index);
break;
case TYPE_CODE_STRUCT:
break;
default:
- xasprintf (&name, "*%s", parent->name);
+ name = xstrprintf ("*%s", parent->name);
break;
}
break;
go on */
if (gdb_evaluate_expression (var->root->exp, &new_val))
{
- if (VALUE_LAZY (new_val))
+ if (value_lazy (new_val))
{
/* We need to catch errors because if
value_fetch_lazy fails we still want to continue
case TYPE_CODE_ARRAY:
{
char *number;
- xasprintf (&number, "[%d]", var->num_children);
+ number = xstrprintf ("[%d]", var->num_children);
return (number);
}
/* break; */
struct cleanup *old_chain = make_cleanup_ui_file_delete (stb);
char *thevalue;
- if (VALUE_LAZY (var->value))
+ if (value_lazy (var->value))
gdb_value_fetch_lazy (var->value);
- val_print (VALUE_TYPE (var->value),
- VALUE_CONTENTS_RAW (var->value), 0,
+ val_print (value_type (var->value),
+ value_contents_raw (var->value), 0,
VALUE_ADDRESS (var->value), stb,
format_code[(int) var->format], 1, 0, 0);
thevalue = ui_file_xstrdup (stb, &dummy);
{
struct value *temp = NULL;
- if (TYPE_CODE (VALUE_TYPE (parent->value)) == TYPE_CODE_PTR
- || TYPE_CODE (VALUE_TYPE (parent->value)) == TYPE_CODE_REF)
+ if (TYPE_CODE (value_type (parent->value)) == TYPE_CODE_PTR
+ || TYPE_CODE (value_type (parent->value)) == TYPE_CODE_REF)
{
if (!gdb_value_ind (parent->value, &temp))
return NULL;
varobj_table = xmalloc (sizeof_table);
memset (varobj_table, 0, sizeof_table);
- add_show_from_set (add_set_cmd ("debugvarobj", class_maintenance, var_zinteger, (char *) &varobjdebug, "Set varobj debugging.\n\
+ deprecated_add_show_from_set (add_set_cmd ("debugvarobj", class_maintenance, var_zinteger, (char *) &varobjdebug, "Set varobj debugging.\n\
When non-zero, varobj debugging is enabled.", &setlist),
&showlist);
}