This file is part of GDB.
-GDB is free software; you can redistribute it and/or modify
+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
-the Free Software Foundation; either version 1, or (at your option)
-any later version.
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
-GDB is distributed in the hope that it will be useful,
+This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
-along with GDB; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include <stdio.h>
#include "defs.h"
return 0;
}
- get_saved_register (myaddr, &optim, (CORE_ADDR) NULL, selected_frame,
+ get_saved_register (myaddr, &optim, (CORE_ADDR *) NULL, selected_frame,
regnum, (enum lval_type *)NULL);
return optim;
}
}
/* Read register REGNO into memory at MYADDR, which must be large enough
- for REGISTER_RAW_BYTES (REGNO). If the register is known to be the
- size of a CORE_ADDR or smaller, read_register can be used instead. */
+ for REGISTER_RAW_BYTES (REGNO). Target byte-order.
+ If the register is known to be the size of a CORE_ADDR or smaller,
+ read_register can be used instead. */
void
read_register_gen (regno, myaddr)
int regno;
/* Given a struct symbol for a variable,
and a stack frame id, read the value of the variable
and return a (pointer to a) struct value containing the value.
- If the variable cannot be found, return a zero pointer. */
+ If the variable cannot be found, return a zero pointer.
+ If FRAME is NULL, use the selected_frame. */
value
read_var_value (var, frame)
struct frame_info *fi;
struct type *type = SYMBOL_TYPE (var);
CORE_ADDR addr;
- int val;
register int len;
v = allocate_value (type);
switch (SYMBOL_CLASS (var))
{
case LOC_CONST:
- val = SYMBOL_VALUE (var);
- bcopy (&val, VALUE_CONTENTS_RAW (v), len);
+ bcopy (&SYMBOL_VALUE (var), VALUE_CONTENTS_RAW (v), len);
SWAP_TARGET_AND_HOST (VALUE_CONTENTS_RAW (v), len);
VALUE_LVAL (v) = not_lval;
return v;
return v;
case LOC_CONST_BYTES:
- addr = SYMBOL_VALUE_ADDRESS (var);
- bcopy (addr, VALUE_CONTENTS_RAW (v), len);
- VALUE_LVAL (v) = not_lval;
- return v;
+ {
+ char *bytes_addr;
+ bytes_addr = SYMBOL_VALUE_BYTES (var);
+ bcopy (bytes_addr, VALUE_CONTENTS_RAW (v), len);
+ VALUE_LVAL (v) = not_lval;
+ return v;
+ }
case LOC_STATIC:
case LOC_EXTERNAL:
case LOC_ARG:
fi = get_frame_info (frame);
+ if (fi == NULL)
+ return 0;
addr = FRAME_ARGS_ADDRESS (fi);
if (!addr) {
return 0;
case LOC_REF_ARG:
fi = get_frame_info (frame);
+ if (fi == NULL)
+ return 0;
addr = FRAME_ARGS_ADDRESS (fi);
if (!addr) {
return 0;
}
addr += SYMBOL_VALUE (var);
- addr = read_memory_integer (addr, sizeof (CORE_ADDR));
+ read_memory (addr, &addr, sizeof (CORE_ADDR));
break;
case LOC_LOCAL:
case LOC_LOCAL_ARG:
fi = get_frame_info (frame);
+ if (fi == NULL)
+ return 0;
addr = SYMBOL_VALUE (var) + FRAME_LOCALS_ADDRESS (fi);
break;
case LOC_REGISTER:
case LOC_REGPARM:
{
- struct block *b = get_frame_block (frame);
+ struct block *b;
+ if (frame == NULL)
+ return 0;
+ b = get_frame_block (frame);
+
v = value_from_register (type, SYMBOL_VALUE (var), frame);
- if (REG_STRUCT_HAS_ADDR(b->gcc_compile_flag)
+ if (REG_STRUCT_HAS_ADDR (BLOCK_GCC_COMPILED (b))
&& TYPE_CODE (type) == TYPE_CODE_STRUCT)
addr = *(CORE_ADDR *)VALUE_CONTENTS (v);
else
return v;
}
\f
-/* Given a struct symbol for a variable,
+/* Given a struct symbol for a variable or function,
and a stack frame id,
- return a (pointer to a) struct value containing the variable's address. */
+ return a (pointer to a) struct value containing the properly typed
+ address. */
value
locate_var_value (var, frame)
if (lazy_value == 0)
error ("Address of \"%s\" is unknown.", SYMBOL_NAME (var));
- if (VALUE_LAZY (lazy_value))
+ if (VALUE_LAZY (lazy_value)
+ || TYPE_CODE (type) == TYPE_CODE_FUNC)
{
addr = VALUE_ADDRESS (lazy_value);
{
char *buf = alloca (TYPE_LENGTH (type));
read_memory (addr, buf, TYPE_LENGTH (type));
- addr = unpack_long (type, buf);
+ addr = unpack_pointer (type, buf);
type = TYPE_TARGET_TYPE (type);
}
/* Address of an array is of the type of address of it's elements. */
+ /* FIXME, this is probably wrong now for ANSI C. */
result_type =
lookup_pointer_type (TYPE_CODE (type) == TYPE_CODE_ARRAY ?
TYPE_TARGET_TYPE (type) : type);