/* Perform non-arithmetic operations on values, for GDB.
- Copyright 1986, 87, 89, 91, 92, 93, 94, 95, 96, 97, 1998
- Free Software Foundation, Inc.
+ Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
+ 1996, 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
This file is part of GDB.
#include "demangle.h"
#include "language.h"
#include "gdbcmd.h"
+#include "regcache.h"
#include <errno.h>
#include "gdb_string.h"
void _initialize_valops (void);
-#define VALUE_SUBSTRING_START(VAL) VALUE_FRAME(VAL)
-
/* Flag for whether we want to abandon failed expression evals by default. */
#if 0
code2 == TYPE_CODE_ENUM ||
code2 == TYPE_CODE_RANGE))
{
- int ptr_bit = HOST_CHAR_BIT * TYPE_LENGTH (type);
+ /* TYPE_LENGTH (type) is the length of a pointer, but we really
+ want the length of an address! -- we are really dealing with
+ addresses (i.e., gdb representations) not pointers (i.e.,
+ target representations) here.
+
+ This allows things like "print *(int *)0x01000234" to work
+ without printing a misleading message -- which would
+ otherwise occur when dealing with a target having two byte
+ pointers and four byte addresses. */
+
+ int addr_bit = TARGET_ADDR_BIT;
+
LONGEST longest = value_as_long (arg2);
- if (ptr_bit < sizeof (LONGEST) * HOST_CHAR_BIT)
+ if (addr_bit < sizeof (LONGEST) * HOST_CHAR_BIT)
{
- if (longest >= ((LONGEST) 1 << ptr_bit)
- || longest <= -((LONGEST) 1 << ptr_bit))
+ if (longest >= ((LONGEST) 1 << addr_bit)
+ || longest <= -((LONGEST) 1 << addr_bit))
warning ("value truncated");
}
return value_from_longest (type, longest);
{
register struct type *type;
register value_ptr val;
- char raw_buffer[MAX_REGISTER_RAW_SIZE];
+ char *raw_buffer = (char*) alloca (MAX_REGISTER_RAW_SIZE);
int use_buffer = 0;
if (!toval->modifiable)
push_word (CORE_ADDR sp, ULONGEST word)
{
register int len = REGISTER_SIZE;
- char buffer[MAX_REGISTER_RAW_SIZE];
+ char *buffer = alloca (MAX_REGISTER_RAW_SIZE);
store_unsigned_integer (buffer, len, word);
if (INNER_THAN (1, 2))
{
/* stack grows downward */
sp -= aligned_len;
+ /* ... so the address of the thing we push is the
+ stack pointer after we push it. */
+ addr = sp;
}
else
{
/* The stack grows up, so the address of the thing
we push is the stack pointer before we push it. */
addr = sp;
- }
- /* Push the structure. */
- write_memory (sp, VALUE_CONTENTS_ALL (args[i]), len);
- if (INNER_THAN (1, 2))
- {
- /* The stack grows down, so the address of the thing
- we push is the stack pointer after we push it. */
- addr = sp;
- }
- else
- {
- /* stack grows upward */
sp += aligned_len;
}
+ /* Push the structure. */
+ write_memory (addr, VALUE_CONTENTS_ALL (args[i]), len);
/* The value we're going to pass is the address of the
thing we just pushed. */
/*args[i] = value_from_longest (lookup_pointer_type (value_type),
SAVE_DUMMY_FRAME_TOS (sp);
{
- char retbuf[REGISTER_BYTES];
+ char *retbuf = (char*) alloca (REGISTER_BYTES);
char *name;
struct symbol *symbol;
default:
break;
}
- free (parm_types);
+ xfree (parm_types);
if (overload_debug)
{
if (method)
else
{
*symp = oload_syms[oload_champ];
- free (func_name);
+ xfree (func_name);
}
return oload_incompatible ? 100 : (oload_non_standard ? 10 : 0);