-\f
-/* Given a struct symbol for a variable or function,
- and a stack frame id,
- return a (pointer to a) struct value containing the properly typed
- address. */
-
-struct value *
-locate_var_value (struct symbol *var, struct frame_info *frame)
-{
- struct gdbarch *gdbarch = get_frame_arch (frame);
- CORE_ADDR addr = 0;
- struct type *type = SYMBOL_TYPE (var);
- struct value *lazy_value;
-
- /* Evaluate it first; if the result is a memory address, we're fine.
- Lazy evaluation pays off here. */
-
- lazy_value = read_var_value (var, frame);
- if (lazy_value == 0)
- error (_("Address of \"%s\" is unknown."), SYMBOL_PRINT_NAME (var));
-
- if (value_lazy (lazy_value)
- || TYPE_CODE (type) == TYPE_CODE_FUNC)
- {
- struct value *val;
-
- addr = VALUE_ADDRESS (lazy_value);
- val = value_from_pointer (lookup_pointer_type (type), addr);
- return val;
- }
-
- /* Not a memory address; check what the problem was. */
- switch (VALUE_LVAL (lazy_value))
- {
- case lval_register:
- gdb_assert (gdbarch_register_name
- (gdbarch, VALUE_REGNUM (lazy_value)) != NULL
- && *gdbarch_register_name
- (gdbarch, VALUE_REGNUM (lazy_value)) != '\0');
- error (_("Address requested for identifier "
- "\"%s\" which is in register $%s"),
- SYMBOL_PRINT_NAME (var),
- gdbarch_register_name (gdbarch, VALUE_REGNUM (lazy_value)));
- break;
-
- default:
- error (_("Can't take address of \"%s\" which isn't an lvalue."),
- SYMBOL_PRINT_NAME (var));
- break;
- }
- return 0; /* For lint -- never reached */
-}