/* Remote debugging interface for boot monitors, for GDB.
- Copyright (C) 1990-2013 Free Software Foundation, Inc.
+ Copyright (C) 1990-2014 Free Software Foundation, Inc.
Contributed by Cygnus Support. Written by Rob Savoye for Cygnus.
Resurrected from the ashes by Stu Grossman.
#include "exceptions.h"
#include <signal.h>
#include <ctype.h>
-#include "gdb_string.h"
+#include <string.h>
#include <sys/types.h>
#include "command.h"
#include "serial.h"
static void monitor_interrupt_query (void);
static void monitor_interrupt_twice (int);
-static void monitor_stop (ptid_t);
+static void monitor_stop (struct target_ops *self, ptid_t);
static void monitor_dump_regs (struct regcache *regcache);
#if 0
if (current_monitor->stop)
{
- monitor_stop (inferior_ptid);
+ monitor_stop (targ_ops, inferior_ptid);
if ((current_monitor->flags & MO_NO_ECHO_ON_OPEN) == 0)
{
monitor_debug ("EXP Open echo\n");
control. */
void
-monitor_close (int quitting)
+monitor_close (struct target_ops *self)
{
if (monitor_desc)
serial_close (monitor_desc);
when you want to detach and do something else with your gdb. */
static void
-monitor_detach (struct target_ops *ops, char *args, int from_tty)
+monitor_detach (struct target_ops *ops, const char *args, int from_tty)
{
- pop_target (); /* calls monitor_close to do the real work. */
+ unpush_target (ops); /* calls monitor_close to do the real work. */
if (from_tty)
printf_unfiltered (_("Ending remote %s debugging\n"), target_shortname);
}
Give up (and stop debugging it)? ")))
{
target_mourn_inferior ();
- deprecated_throw_reason (RETURN_QUIT);
+ quit ();
}
target_terminal_inferior ();
debugged. */
static void
-monitor_prepare_to_store (struct regcache *regcache)
+monitor_prepare_to_store (struct target_ops *self, struct regcache *regcache)
{
/* Do nothing, since we can store individual regs. */
}
}
static int
-monitor_write_memory (CORE_ADDR memaddr, char *myaddr, int len)
+monitor_write_memory (CORE_ADDR memaddr, const gdb_byte *myaddr, int len)
{
enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ());
unsigned int val, hostval;
static int
-monitor_write_memory_bytes (CORE_ADDR memaddr, char *myaddr, int len)
+monitor_write_memory_bytes (CORE_ADDR memaddr, const gdb_byte *myaddr, int len)
{
unsigned char val;
int written = 0;
Which possably entails endian conversions. */
static int
-monitor_write_memory_longlongs (CORE_ADDR memaddr, char *myaddr, int len)
+monitor_write_memory_longlongs (CORE_ADDR memaddr, const gdb_byte *myaddr, int len)
{
static char hexstage[20]; /* At least 16 digits required, plus null. */
char *endstring;
long long value;
int written = 0;
- llptr = (unsigned long long *) myaddr;
+ llptr = (long long *) myaddr;
if (len == 0)
return 0;
monitor_printf (current_monitor->setmem.cmdll, memaddr);
monitor variations. */
static int
-monitor_write_memory_block (CORE_ADDR memaddr, char *myaddr, int len)
+monitor_write_memory_block (CORE_ADDR memaddr, const gdb_byte *myaddr, int len)
{
int written;
which can only read a single byte/word/etc. at a time. */
static int
-monitor_read_memory_single (CORE_ADDR memaddr, char *myaddr, int len)
+monitor_read_memory_single (CORE_ADDR memaddr, gdb_byte *myaddr, int len)
{
enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ());
unsigned int val;
than 16 bytes at a time. */
static int
-monitor_read_memory (CORE_ADDR memaddr, char *myaddr, int len)
+monitor_read_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len)
{
unsigned int val;
char buf[512];
return len;
}
-/* Transfer LEN bytes between target address MEMADDR and GDB address
- MYADDR. Returns 0 for success, errno code for failure. TARGET is
- unused. */
+/* Helper for monitor_xfer_partial that handles memory transfers.
+ Arguments are like target_xfer_partial. */
-static int
-monitor_xfer_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len, int write,
- struct mem_attrib *attrib, struct target_ops *target)
+static enum target_xfer_status
+monitor_xfer_memory (gdb_byte *readbuf, const gdb_byte *writebuf,
+ ULONGEST memaddr, ULONGEST len, ULONGEST *xfered_len)
{
int res;
- if (write)
+ if (writebuf != NULL)
{
if (current_monitor->flags & MO_HAS_BLOCKWRITES)
- res = monitor_write_memory_block(memaddr, myaddr, len);
+ res = monitor_write_memory_block (memaddr, writebuf, len);
else
- res = monitor_write_memory(memaddr, myaddr, len);
+ res = monitor_write_memory (memaddr, writebuf, len);
+ }
+ else
+ {
+ res = monitor_read_memory (memaddr, readbuf, len);
}
+
+ if (res <= 0)
+ return TARGET_XFER_E_IO;
else
{
- res = monitor_read_memory(memaddr, myaddr, len);
+ *xfered_len = (ULONGEST) res;
+ return TARGET_XFER_OK;
}
+}
- return res;
+/* Target to_xfer_partial implementation. */
+
+static enum target_xfer_status
+monitor_xfer_partial (struct target_ops *ops, enum target_object object,
+ const char *annex, gdb_byte *readbuf,
+ const gdb_byte *writebuf, ULONGEST offset, ULONGEST len,
+ ULONGEST *xfered_len)
+{
+ switch (object)
+ {
+ case TARGET_OBJECT_MEMORY:
+ return monitor_xfer_memory (readbuf, writebuf, offset, len, xfered_len);
+
+ default:
+ return TARGET_XFER_E_IO;
+ }
}
static void
/* Tell the monitor to add a breakpoint. */
static int
-monitor_insert_breakpoint (struct gdbarch *gdbarch,
+monitor_insert_breakpoint (struct target_ops *ops, struct gdbarch *gdbarch,
struct bp_target_info *bp_tgt)
{
CORE_ADDR addr = bp_tgt->placed_address;
/* Tell the monitor to remove a breakpoint. */
static int
-monitor_remove_breakpoint (struct gdbarch *gdbarch,
+monitor_remove_breakpoint (struct target_ops *ops, struct gdbarch *gdbarch,
struct bp_target_info *bp_tgt)
{
CORE_ADDR addr = bp_tgt->placed_address;
/* monitor_load -- download a file. */
static void
-monitor_load (char *args, int from_tty)
+monitor_load (struct target_ops *self, char *args, int from_tty)
{
CORE_ADDR load_offset = 0;
char **argv;
}
static void
-monitor_stop (ptid_t ptid)
+monitor_stop (struct target_ops *self, ptid_t ptid)
{
monitor_debug ("MON stop\n");
if ((current_monitor->flags & MO_SEND_BREAK_ON_STOP) != 0)
ourseleves here cause of a nasty echo. */
static void
-monitor_rcmd (char *command,
+monitor_rcmd (struct target_ops *self, char *command,
struct ui_file *outbuf)
{
char *p;
monitor_ops.to_fetch_registers = monitor_fetch_registers;
monitor_ops.to_store_registers = monitor_store_registers;
monitor_ops.to_prepare_to_store = monitor_prepare_to_store;
- monitor_ops.deprecated_xfer_memory = monitor_xfer_memory;
+ monitor_ops.to_xfer_partial = monitor_xfer_partial;
monitor_ops.to_files_info = monitor_files_info;
monitor_ops.to_insert_breakpoint = monitor_insert_breakpoint;
monitor_ops.to_remove_breakpoint = monitor_remove_breakpoint;