- set_internalvar (lookup_internalvar ("__"), last_examine_value);
- }
-}
-\f
-/* Commands for printing types of things. */
-
-/* Print type of EXP, or last thing in value history if EXP == NULL.
- show is passed to type_print. */
-static void
-whatis_exp (exp, show)
- char *exp;
- int show;
-{
- struct expression *expr;
- register value val;
- register struct cleanup *old_chain;
-
- if (exp)
- {
- expr = parse_c_expression (exp);
- old_chain = make_cleanup (free_current_contents, &expr);
- val = evaluate_type (expr);
- }
- else
- val = access_value_history (0);
-
- printf_filtered ("type = ");
- type_print (VALUE_TYPE (val), "", stdout, show);
- printf_filtered ("\n");
-
- if (exp)
- do_cleanups (old_chain);
-}
-
-static void
-whatis_command (exp, from_tty)
- char *exp;
- int from_tty;
-{
- /* Most of the time users do not want to see all the fields
- in a structure. If they do they can use the "ptype" command.
- Hence the "-1" below. */
- whatis_exp (exp, -1);
-}
-
-/* TYPENAME is either the name of a type, or an expression. */
-static void
-ptype_command (typename, from_tty)
- char *typename;
- int from_tty;
-{
- register char *p = typename;
- register int len;
- register struct block *b
- = target_has_stack ? get_current_block () : 0;
- register struct type *type;
-
- if (typename == 0)
- {
- whatis_exp (typename, 1);
- return;
- }
-
- while (*p && *p != ' ' && *p != '\t') p++;
- len = p - typename;
- while (*p == ' ' || *p == '\t') p++;
-
- if (len == 6 && !strncmp (typename, "struct", 6))
- type = lookup_struct (p, b);
- else if (len == 5 && !strncmp (typename, "union", 5))
- type = lookup_union (p, b);
- else if (len == 4 && !strncmp (typename, "enum", 4))
- type = lookup_enum (p, b);
- else
- {
- type = lookup_typename (typename, b, 1);
- if (type == 0)
- {
- register struct symbol *sym
- = lookup_symbol (typename, b, STRUCT_NAMESPACE, 0,
- (struct symtab **)NULL);
- if (sym == 0)
- {
- whatis_exp (typename, 1 /* FIXME: right? */);
- return;
- }
- printf_filtered ("No type named %s, but there is a ",
- typename);
- switch (TYPE_CODE (SYMBOL_TYPE (sym)))
- {
- case TYPE_CODE_STRUCT:
- printf_filtered ("struct");
- break;
-
- case TYPE_CODE_UNION:
- printf_filtered ("union");
- break;
-
- case TYPE_CODE_ENUM:
- printf_filtered ("enum");
- break;
-
- default:
- printf_filtered ("(Internal error in gdb)");
- break;
- }
- printf_filtered (" %s. Type \"help ptype\".\n", typename);
- type = SYMBOL_TYPE (sym);
- }
- }
-
- type_print (type, "", stdout, 1);
- printf_filtered ("\n");
-}
-\f
-#if 0
-/* This is not necessary. Instead, decode_line_1 takes any variable,
- so "info line foo" is a close equivalent to "whereis foo". */
-static void
-whereis_command (var, from_tty)
- char *var;
- int from_tty;
-{
- struct symtab *s;
- struct symbol *sym;
-
- if (var == NULL)
- error_no_arg ("Variable name.");
-
- sym = lookup_symbol (var, get_selected_block (), VAR_NAMESPACE,
- NULL, &s);
-
- if (sym != NULL && s != NULL)
- printf_filtered ("Symbol \"%s\" is at line %d of file %s\n",
- var, sym->line, s->filename);
- else
- {
- if (lookup_misc_func (var) >= 0)
- printf_filtered ("Symbol \"%s\" is in a file compiled without -g.",
- var);