mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-07-30 05:14:18 +08:00
* 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:
71
gdb/core.c
71
gdb/core.c
@ -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
|
||||
|
Reference in New Issue
Block a user