* findvar.c, defs.h

({extract,store}_{signed_integer,unsigned_integer,address}):
	New routines to replace SWAP_TARGET_AND_HOST.
	All over: All uses of SWAP_TARGET_AND_HOST on integers replaced.
This commit is contained in:
Jim Kingdon 1993-07-10 01:35:53 +00:00
parent ec1c752b34
commit 34df79fc9d
16 changed files with 197 additions and 489 deletions

View file

@ -209,79 +209,28 @@ write_memory (memaddr, myaddr, len)
/* Read an integer from debugged memory, given address and number of bytes. */
long
LONGEST
read_memory_integer (memaddr, len)
CORE_ADDR memaddr;
int len;
{
char cbuf;
short sbuf;
int ibuf;
long lbuf;
char *buf;
if (len == sizeof (char))
{
read_memory (memaddr, &cbuf, len);
return cbuf;
}
if (len == sizeof (short))
{
read_memory (memaddr, (char *)&sbuf, len);
SWAP_TARGET_AND_HOST (&sbuf, sizeof (short));
return sbuf;
}
if (len == sizeof (int))
{
read_memory (memaddr, (char *)&ibuf, len);
SWAP_TARGET_AND_HOST (&ibuf, sizeof (int));
return ibuf;
}
if (len == sizeof (lbuf))
{
read_memory (memaddr, (char *)&lbuf, len);
SWAP_TARGET_AND_HOST (&lbuf, sizeof (lbuf));
return lbuf;
}
error ("Cannot handle integers of %d bytes.", len);
return -1; /* for lint */
buf = alloca (len);
read_memory (memaddr, buf, len);
return extract_signed_integer (buf, len);
}
unsigned long
unsigned LONGEST
read_memory_unsigned_integer (memaddr, len)
CORE_ADDR memaddr;
int len;
{
unsigned char cbuf;
unsigned short sbuf;
unsigned int ibuf;
unsigned long lbuf;
char *buf;
if (len == sizeof (char))
{
read_memory (memaddr, &cbuf, len);
return cbuf;
}
if (len == sizeof (short))
{
read_memory (memaddr, (char *)&sbuf, len);
SWAP_TARGET_AND_HOST (&sbuf, sizeof (short));
return sbuf;
}
if (len == sizeof (int))
{
read_memory (memaddr, (char *)&ibuf, len);
SWAP_TARGET_AND_HOST (&ibuf, sizeof (int));
return ibuf;
}
if (len == sizeof (lbuf))
{
read_memory (memaddr, (char *)&lbuf, len);
SWAP_TARGET_AND_HOST (&lbuf, sizeof (lbuf));
return lbuf;
}
error ("Cannot handle unsigned integers of %d bytes.", len);
return -1; /* for lint */
buf = alloca (len);
read_memory (memaddr, buf, len);
return extract_unsigned_integer (buf, len);
}
void