reset, be sure to consider this use as well! */
unsigned int lazy : 1;
- /* If nonzero, this is the value of a variable which does not
- actually exist in the program. */
+ /* If nonzero, this is the value of a variable that does not
+ actually exist in the program. If nonzero, and LVAL is
+ lval_register, this is a register ($pc, $sp, etc., never a
+ program variable) that has not been saved in the frame. All
+ optimized-out values are treated pretty much the same, except
+ registers have a different string representation and related
+ error strings. */
unsigned int optimized_out : 1;
/* If value is a variable, is it initialized or not. */
/* Allocate the contents of VAL if it has not been allocated yet. */
-void
+static void
allocate_value_contents (struct value *val)
{
if (!val->contents)
return result;
}
+void
+error_value_optimized_out (void)
+{
+ error (_("value has been optimized out"));
+}
+
static void
require_not_optimized_out (const struct value *value)
{
if (value->optimized_out)
- error (_("value has been optimized out"));
+ {
+ if (value->lval == lval_register)
+ error (_("register has not been saved in frame"));
+ else
+ error_value_optimized_out ();
+ }
}
static void
return 0;
}
+/* Implementation of the convenience function $_isvoid. */
+
+static struct value *
+isvoid_internal_fn (struct gdbarch *gdbarch,
+ const struct language_defn *language,
+ void *cookie, int argc, struct value **argv)
+{
+ int ret;
+
+ if (argc != 1)
+ error (_("You must provide one argument for $_isvoid."));
+
+ ret = TYPE_CODE (value_type (argv[0])) == TYPE_CODE_VOID;
+
+ return value_from_longest (builtin_type (gdbarch)->builtin_int, ret);
+}
+
void
_initialize_values (void)
{
add_prefix_cmd ("function", no_class, function_command, _("\
Placeholder command for showing help on convenience functions."),
&functionlist, "function ", 0, &cmdlist);
+
+ add_internal_function ("_isvoid", _("\
+Check whether an expression is void.\n\
+Usage: $_isvoid (expression)\n\
+Return 1 if the expression is void, zero otherwise."),
+ isvoid_internal_fn, NULL);
}