#include <sys/types.h>
#include <sys/stat.h>
+#include <ctype.h>
+
/* Microsoft C's stat.h doesn't define all the POSIX file modes. */
#ifndef S_IROTH
#define S_IROTH S_IREAD
static int mips_receive_packet (char *buff, int throw_error, int timeout);
-static CORE_ADDR mips_request (int cmd, CORE_ADDR addr,
- CORE_ADDR data, int *perr, int timeout,
- char *buff);
+static ULONGEST mips_request (int cmd, ULONGEST addr, ULONGEST data,
+ int *perr, int timeout, char *buff);
static void mips_initialize (void);
/* The number of garbage characters to accept when looking for an
SYN for the next packet. */
-static int mips_syn_garbage = 1050;
+static int mips_syn_garbage = 10;
/* The time to wait for a packet, in seconds. */
static int mips_receive_wait = 5;
{
/* Printing the character here lets the user of gdb see
what the program is outputting, if the debugging is
- being done on the console port. Don't use _filtered;
- we can't deal with a QUIT out of target_wait. */
- if (!mips_initializing || remote_debug > 0)
- {
- fputc_readable (ch, gdb_stdlog);
- gdb_flush (gdb_stdlog);
- }
+ being done on the console port. Don't use _filtered:
+ we can't deal with a QUIT out of target_wait and
+ buffered target output confuses the user. */
+ if (!mips_initializing || remote_debug > 0)
+ {
+ if (isprint (ch) || isspace (ch))
+ {
+ fputc_unfiltered (ch, gdb_stdtarg);
+ }
+ else
+ {
+ fputc_readable (ch, gdb_stdtarg);
+ }
+ gdb_flush (gdb_stdtarg);
+ }
+
+ /* Only count unprintable characters. */
+ if (! (isprint (ch) || isspace (ch)))
+ (*pgarbage) += 1;
- ++*pgarbage;
if (mips_syn_garbage > 0
&& *pgarbage > mips_syn_garbage)
mips_error ("Debug protocol failure: more than %d characters before a sync.",
occurs, it sets *PERR to 1 and sets errno according to what the
target board reports. */
-static CORE_ADDR
-mips_request (cmd, addr, data, perr, timeout, buff)
- int cmd;
- CORE_ADDR addr;
- CORE_ADDR data;
- int *perr;
- int timeout;
- char *buff;
+static ULONGEST
+mips_request (int cmd,
+ ULONGEST addr,
+ ULONGEST data,
+ int *perr,
+ int timeout,
+ char *buff)
{
char myBuff[DATA_MAXLEN + 1];
int len;
{
/* The DDB (NEC) and MiniRISC (LSI) versions of PMON exit immediately,
so we do not get a reply to this command: */
- mips_request ('x', (unsigned int) 0, (unsigned int) 0, NULL,
- mips_receive_wait, NULL);
+ mips_request ('x', 0, 0, NULL, mips_receive_wait, NULL);
mips_need_reply = 0;
if (!mips_expect (" break!"))
return -1;
}
else
- mips_request ('x', (unsigned int) 0, (unsigned int) 0, &err,
- mips_receive_wait, NULL);
+ mips_request ('x', 0, 0, &err, mips_receive_wait, NULL);
if (!mips_expect (mips_monitor_prompt))
return -1;
/* If this doesn't call error, we have connected; we don't care if
the request itself succeeds or fails. */
- mips_request ('r', (unsigned int) 0, (unsigned int) 0, &err,
- mips_receive_wait, NULL);
+ mips_request ('r', 0, 0, &err, mips_receive_wait, NULL);
set_current_frame (create_new_frame (read_fp (), read_pc ()));
select_frame (get_current_frame (), 0);
}
/* LSI PMON requires returns a reply packet "0x1 s 0x0 0x57f" after
a single step, so we wait for that. */
- mips_request (step ? 's' : 'c',
- (unsigned int) 1,
- (unsigned int) siggnal,
+ mips_request (step ? 's' : 'c', 1, siggnal,
mips_monitor == MON_LSI && step ? &err : (int *) NULL,
mips_receive_wait, NULL);
}
/* No timeout; we sit here as long as the program continues to execute. */
mips_wait_flag = 1;
- rstatus = mips_request ('\000', (unsigned int) 0, (unsigned int) 0, &err, -1,
- buff);
+ rstatus = mips_request ('\000', 0, 0, &err, -1, buff);
mips_wait_flag = 0;
if (err)
mips_error ("Remote failure: %s", safe_strerror (errno));
compiled without the 64bit register access commands. This
means we cannot get hold of the full register width. */
if (mips_monitor == MON_DDB)
- val = (unsigned) mips_request ('t', (unsigned int) pmon_reg,
- (unsigned int) 0, &err, mips_receive_wait, NULL);
+ val = (unsigned) mips_request ('t', pmon_reg, 0,
+ &err, mips_receive_wait, NULL);
else
- val = mips_request ('r', (unsigned int) pmon_reg,
- (unsigned int) 0, &err, mips_receive_wait, NULL);
+ val = mips_request ('r', pmon_reg, 0,
+ &err, mips_receive_wait, NULL);
if (err)
mips_error ("Can't read register %d: %s", regno,
safe_strerror (errno));
return;
}
- mips_request ('R', (unsigned int) mips_map_regno (regno),
+ mips_request ('R', mips_map_regno (regno),
read_register (regno),
&err, mips_receive_wait, NULL);
if (err)
unsigned int val;
int err;
- /* FIXME! addr was cast to uint! */
- val = mips_request ('d', addr, (unsigned int) 0, &err,
- mips_receive_wait, NULL);
+ val = mips_request ('d', addr, 0, &err, mips_receive_wait, NULL);
if (err)
{
/* Data space failed; try instruction space. */
- /* FIXME! addr was cast to uint! */
- val = mips_request ('i', addr, (unsigned int) 0, &err,
+ val = mips_request ('i', addr, 0, &err,
mips_receive_wait, NULL);
if (err)
mips_error ("Can't read address 0x%s: %s",
int err;
unsigned int oldcontents;
- oldcontents = mips_request ('D', addr, (unsigned int) val,
- &err,
+ oldcontents = mips_request ('D', addr, val, &err,
mips_receive_wait, NULL);
if (err)
{
/* Data space failed; try instruction space. */
- oldcontents = mips_request ('I', addr,
- (unsigned int) val, &err,
+ oldcontents = mips_request ('I', addr, val, &err,
mips_receive_wait, NULL);
if (err)
return errno;
for a longword, since it transfers values in ASCII. We want the
byte values, so we have to swap the longword values. */
+static int mask_address_p = 1;
+
static int
mips_xfer_memory (memaddr, myaddr, len, write, ignore)
CORE_ADDR memaddr;
int write;
struct target_ops *ignore;
{
- register int i;
+ int i;
+ CORE_ADDR addr;
+ int count;
+ char *buffer;
+ int status;
+
+ /* PMON targets do not cope well with 64 bit addresses. Mask the
+ value down to 32 bits. */
+ if (mask_address_p)
+ memaddr &= (CORE_ADDR) 0xffffffff;
+
/* Round starting address down to longword boundary. */
- register CORE_ADDR addr = memaddr & ~3;
+ addr = memaddr & ~3;
/* Round ending address up; get number of longwords that makes. */
- register int count = (((memaddr + len) - addr) + 3) / 4;
+ count = (((memaddr + len) - addr) + 3) / 4;
/* Allocate buffer of that many longwords. */
- register char *buffer = alloca (count * 4);
-
- int status;
+ buffer = alloca (count * 4);
if (write)
{
add_com ("pmon <command>", class_obscure, pmon_command,
"Send a packet to PMON (must be in debug mode).");
+
+ add_show_from_set (add_set_cmd ("mask-address", no_class,
+ var_boolean, &mask_address_p,
+ "Set zeroing of upper 32 bits of 64-bit addresses when talking to PMON targets.\n\
+Use \"on\" to enable the masking and \"off\" to disable it.\n",
+ &setlist),
+ &showlist);
}