1999-04-16 01:35:26 +00:00
|
|
|
|
/* Remote target communications for serial-line targets using SDS' protocol.
|
2002-01-19 03:32:43 +00:00
|
|
|
|
|
2006-01-24 22:09:28 +00:00
|
|
|
|
Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2004, 2006 Free Software
|
2002-01-19 03:32:43 +00:00
|
|
|
|
Foundation, Inc.
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
1999-07-07 20:19:36 +00:00
|
|
|
|
This file is part of GDB.
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
1999-07-07 20:19:36 +00:00
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
(at your option) any later version.
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
1999-07-07 20:19:36 +00:00
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
1999-07-07 20:19:36 +00:00
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with this program; if not, write to the Free Software
|
2005-12-17 22:34:03 +00:00
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
|
Boston, MA 02110-1301, USA. */
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
|
|
|
|
/* This interface was written by studying the behavior of the SDS
|
|
|
|
|
monitor on an ADS 821/860 board, and by consulting the
|
|
|
|
|
documentation of the monitor that is available on Motorola's web
|
|
|
|
|
site. -sts 8/13/97 */
|
|
|
|
|
|
|
|
|
|
#include "defs.h"
|
|
|
|
|
#include "gdb_string.h"
|
|
|
|
|
#include <fcntl.h>
|
|
|
|
|
#include "frame.h"
|
|
|
|
|
#include "inferior.h"
|
2005-01-12 Andrew Cagney <cagney@gnu.org>
* exceptions.h (enum return_reason, RETURN_MASK)
(RETURN_MASK_QUIT, RETURN_MASK_ERROR, RETURN_MASK_ALL)
(return_mask, throw_exception, catch_exceptions_ftype)
(catch_exceptions_with_msg, catch_errors_ftype, catch_errors)
(catch_command_errors_ftype, catch_command_errors): Move to
exceptions.h.
* exceptions.c, exceptions.h: New files.
* top.c: Do not include <setjmp.h>.
(SIGJMP_BUF, SIGSETJMP, SIGLONGJMP, catch_return)
(throw_exception, catcher, catch_exceptions)
(catch_exceptions_with_msg, struct catch_errors_args)
(do_catch_errors, catch_errors, struct captured_command_args)
(do_captured_command, catch_command_errors): Move to exceptions.c.
* wrapper.c, wince.c, win32-nat.c, utils.c: Include "exceptions.h".
* tui/tui-interp.c, top.c, thread.c, symmisc.c: Ditto.
* symfile-mem.c, stack.c, solib.c, rs6000-nat.c: Ditto.
* remote-sds.c, remote-mips.c, remote-fileio.c: Ditto.
* remote-e7000.c, objc-lang.c, ocd.c: Ditto.
* remote.c, nto-procfs.c, monitor.c, mi/mi-main.c: Ditto.
* main.c, m32r-rom.c, infrun.c, inf-loop.c: Ditto.
* hppa-hpux-tdep.c, frame.c, event-top.c, event-loop.c: Ditto.
* corelow.c, corefile.c, cli/cli-interp.c, breakpoint.c: Ditto.
* ada-valprint.c, ada-lang.c: Ditto.
* Makefile.in (HFILES_NO_SRCDIR, COMMON_OBS): Add exceptions.h and
exceptions.o. Update all dependencies.
2005-01-12 18:31:35 +00:00
|
|
|
|
#include "exceptions.h"
|
1999-04-16 01:35:26 +00:00
|
|
|
|
#include "bfd.h"
|
|
|
|
|
#include "symfile.h"
|
|
|
|
|
#include "target.h"
|
|
|
|
|
#include "gdbcmd.h"
|
|
|
|
|
#include "objfiles.h"
|
|
|
|
|
#include "gdb-stabs.h"
|
|
|
|
|
#include "gdbthread.h"
|
|
|
|
|
#include "gdbcore.h"
|
2001-03-01 01:39:22 +00:00
|
|
|
|
#include "regcache.h"
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
|
|
|
|
#include <signal.h>
|
|
|
|
|
#include "serial.h"
|
|
|
|
|
|
2000-05-28 01:12:42 +00:00
|
|
|
|
extern void _initialize_remote_sds (void);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
|
|
|
|
/* Declarations of local functions. */
|
|
|
|
|
|
2000-05-28 01:12:42 +00:00
|
|
|
|
static int sds_write_bytes (CORE_ADDR, char *, int);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2000-05-28 01:12:42 +00:00
|
|
|
|
static int sds_read_bytes (CORE_ADDR, char *, int);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2000-05-28 01:12:42 +00:00
|
|
|
|
static void sds_files_info (struct target_ops *ignore);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
* exec.c (xfer_memory): Add attrib argument.
* infptrace.c (child_xfer_memory): Likewise.
* monitor.c (monitor_xfer_memory): Likewise.
* remote-adapt.c (adapt_xfer_inferior_memory): Likewise.
* remote-array.c (array_xfer_memory): Likewise.
* remote-bug.c (bug_xfer_memory): Likewise.
* remote-e7000.c (e7000_xfer_inferior_memory): Likewise.
* remote-eb.c (eb_xfer_inferior_memory): Likewise.
* remote-es.c (es1800_xfer_inferior_memory): Likewise.
* remote-mips.c (mips_xfer_memory): Likewise.
* remote-mm.c (mm_xfer_inferior_memory): Likewise.
* remote-nindy.c (nindy_xfer_inferior_memory): Likewise.
* remote-os9k.c (rombug_xfer_inferior_memory): Likewise.
* remote-rdi.c (arm_rdi_xfer_memory): Likewise.
* remote-rdp.c (remote_rdp_xfer_inferior_memory): Likewise.
* remote-sds.c (sds_xfer_memory): Likewise.
* remote-sim.c (gdbsim_xfer_inferior_memory): Likewise.
* remote-st.c (st2000_xfer_inferior_memory): Likewise.
* remote-udi.c (udi_xfer_inferior_memory): Likewise.
* remote-vx.c (vx_xfer_memory): Likewise.
* remote.c (remote_xfer_memory): Likewise.
* target.c (debug_to_xfer_memory, do_xfer_memory): Likewise.
* target.h (child_xfer_memory, do_xfer_memory, xfer_memory): Likewise.
* target.h (#include "memattr.h"): Added.
(target_ops.to_xfer_memory): Add attrib argument.
* wince.c (_initialize_inftarg): Removed call to set_dcache_state.
* dcache.h (set_dcache_state): Removed declaration.
* dcache.c (set_dcache_state): Removed definition
* dcache.c: Update module comment, as dcache is now enabled and
disabled with memory region attributes instead of by the global
variable "remotecache". Add comment describing the interaction
between dcache and memory region attributes.
(dcache_xfer_memory): Add comment describing benefits of moving
cache writeback to a higher level.
(dcache_struct): Removed cache_has_stuff field. This was used to
record whether the cache had been accessed in order to invalidate
it when it was disabled. However, this is not needed because the
cache is write through and the code that enables, disables, and
deletes memory regions invalidate the cache. Add comment which
suggests that we could be more selective and only invalidate those
cache lines containing data from those memory regions.
(dcache_invalidate): Updated.
(dcache_xfer_memory): Updated.
(dcache_alloc): Don't abort() if dcache_enabled_p is clear.
(dcache_xfer_memory): Removed code that called do_xfer_memory() to
perform a uncached transfer if dcache_enabled_p was clear. This
function is now only called if caching is enabled for the memory
region.
(dcache_info): Always print cache info.
* target.c (do_xfer_memory): Add attrib argument.
(target_xfer_memory, target_xfer_memory_partial): Break transfer
into chunks defined by memory regions, pass region attributes to
do_xfer_memory().
* dcache.c (dcache_read_line, dcache_write_line): Likewise.
* Makefile.in (SFILES): Add memattr.c.
(COMMON_OBS): Add memattr.o.
(dcache.o): Add target.h to dependencies.
* memattr.c: New file.
* memattr.h: Likewise.
2001-01-23 22:48:56 +00:00
|
|
|
|
static int sds_xfer_memory (CORE_ADDR, char *, int, int,
|
|
|
|
|
struct mem_attrib *, struct target_ops *);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2000-05-28 01:12:42 +00:00
|
|
|
|
static void sds_prepare_to_store (void);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2000-05-28 01:12:42 +00:00
|
|
|
|
static void sds_fetch_registers (int);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2001-05-04 04:15:33 +00:00
|
|
|
|
static void sds_resume (ptid_t, int, enum target_signal);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2003-01-18 Andrew Cagney <ac131313@redhat.com>
* ada-valprint.c: Eliminate PTR.
* breakpoint.c, corelow.c, cris-tdep.c, dbxread.c: Ditto.
* defs.h, dve3900-rom.c, dwarf2read.c, dwarfread.c: Ditto.
* exec.c, hppa-tdep.c, hpread.c, infcmd.c, mdebugread.c: Ditto.
* objfiles.c, objfiles.h, ocd.c, remote-es.c: Ditto.
* remote-mips.c, remote-sds.c, remote-vx.c: Ditto.
* solib-svr4.c, solib.c, stack.c, symfile.c, symfile.h: Ditto.
* symmisc.c, v850ice.c, xcoffread.c, cli/cli-script.c: Ditto.
2003-01-18 15:55:53 +00:00
|
|
|
|
static int sds_start_remote (void *);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2000-05-28 01:12:42 +00:00
|
|
|
|
static void sds_open (char *, int);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2000-05-28 01:12:42 +00:00
|
|
|
|
static void sds_close (int);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2000-05-28 01:12:42 +00:00
|
|
|
|
static void sds_store_registers (int);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2000-05-28 01:12:42 +00:00
|
|
|
|
static void sds_mourn (void);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2000-05-28 01:12:42 +00:00
|
|
|
|
static void sds_load (char *, int);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2000-05-28 01:12:42 +00:00
|
|
|
|
static int getmessage (unsigned char *, int);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2000-05-28 01:12:42 +00:00
|
|
|
|
static int putmessage (unsigned char *, int);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2000-05-28 01:12:42 +00:00
|
|
|
|
static int sds_send (unsigned char *, int);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2000-05-28 01:12:42 +00:00
|
|
|
|
static int readchar (int);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2001-05-04 04:15:33 +00:00
|
|
|
|
static ptid_t sds_wait (ptid_t, struct target_waitstatus *);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2000-05-28 01:12:42 +00:00
|
|
|
|
static void sds_kill (void);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2000-05-28 01:12:42 +00:00
|
|
|
|
static int fromhex (int);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2000-05-28 01:12:42 +00:00
|
|
|
|
static void sds_detach (char *, int);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2000-05-28 01:12:42 +00:00
|
|
|
|
static void sds_interrupt (int);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2000-05-28 01:12:42 +00:00
|
|
|
|
static void sds_interrupt_twice (int);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2000-05-28 01:12:42 +00:00
|
|
|
|
static void interrupt_query (void);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2000-05-28 01:12:42 +00:00
|
|
|
|
static int read_frame (char *);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2000-05-28 01:12:42 +00:00
|
|
|
|
static int sds_insert_breakpoint (CORE_ADDR, char *);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2000-05-28 01:12:42 +00:00
|
|
|
|
static int sds_remove_breakpoint (CORE_ADDR, char *);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2000-05-28 01:12:42 +00:00
|
|
|
|
static void init_sds_ops (void);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2000-05-28 01:12:42 +00:00
|
|
|
|
static void sds_command (char *args, int from_tty);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
|
|
|
|
/* Define the target operations vector. */
|
|
|
|
|
|
|
|
|
|
static struct target_ops sds_ops;
|
|
|
|
|
|
|
|
|
|
/* This was 5 seconds, which is a long time to sit and wait.
|
|
|
|
|
Unless this is going though some terminal server or multiplexer or
|
|
|
|
|
other form of hairy serial connection, I would think 2 seconds would
|
|
|
|
|
be plenty. */
|
|
|
|
|
|
|
|
|
|
static int sds_timeout = 2;
|
|
|
|
|
|
|
|
|
|
/* Descriptor for I/O to remote machine. Initialize it to NULL so
|
|
|
|
|
that sds_open knows that we don't have a file open when the program
|
|
|
|
|
starts. */
|
|
|
|
|
|
2001-07-11 17:52:32 +00:00
|
|
|
|
static struct serial *sds_desc = NULL;
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
|
|
|
|
/* This limit comes from the monitor. */
|
|
|
|
|
|
|
|
|
|
#define PBUFSIZ 250
|
|
|
|
|
|
|
|
|
|
/* Maximum number of bytes to read/write at once. The value here
|
|
|
|
|
is chosen to fill up a packet (the headers account for the 32). */
|
|
|
|
|
#define MAXBUFBYTES ((PBUFSIZ-32)/2)
|
|
|
|
|
|
|
|
|
|
static int next_msg_id;
|
|
|
|
|
|
|
|
|
|
static int just_started;
|
|
|
|
|
|
|
|
|
|
static int message_pending;
|
|
|
|
|
|
1999-07-07 20:19:36 +00:00
|
|
|
|
|
1999-04-16 01:35:26 +00:00
|
|
|
|
/* Clean up connection to a remote debugger. */
|
|
|
|
|
|
|
|
|
|
static void
|
2000-07-30 01:48:28 +00:00
|
|
|
|
sds_close (int quitting)
|
1999-04-16 01:35:26 +00:00
|
|
|
|
{
|
|
|
|
|
if (sds_desc)
|
2001-07-15 20:34:14 +00:00
|
|
|
|
serial_close (sds_desc);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
sds_desc = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Stub for catch_errors. */
|
|
|
|
|
|
|
|
|
|
static int
|
2003-01-18 Andrew Cagney <ac131313@redhat.com>
* ada-valprint.c: Eliminate PTR.
* breakpoint.c, corelow.c, cris-tdep.c, dbxread.c: Ditto.
* defs.h, dve3900-rom.c, dwarf2read.c, dwarfread.c: Ditto.
* exec.c, hppa-tdep.c, hpread.c, infcmd.c, mdebugread.c: Ditto.
* objfiles.c, objfiles.h, ocd.c, remote-es.c: Ditto.
* remote-mips.c, remote-sds.c, remote-vx.c: Ditto.
* solib-svr4.c, solib.c, stack.c, symfile.c, symfile.h: Ditto.
* symmisc.c, v850ice.c, xcoffread.c, cli/cli-script.c: Ditto.
2003-01-18 15:55:53 +00:00
|
|
|
|
sds_start_remote (void *dummy)
|
1999-04-16 01:35:26 +00:00
|
|
|
|
{
|
2001-06-28 03:40:27 +00:00
|
|
|
|
int c;
|
1999-04-16 01:35:26 +00:00
|
|
|
|
unsigned char buf[200];
|
|
|
|
|
|
2000-09-01 00:12:10 +00:00
|
|
|
|
immediate_quit++; /* Allow user to interrupt it */
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
|
|
|
|
/* Ack any packet which the remote side has already sent. */
|
2001-07-15 20:34:14 +00:00
|
|
|
|
serial_write (sds_desc, "{#*\r\n", 5);
|
|
|
|
|
serial_write (sds_desc, "{#}\r\n", 5);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
|
|
|
|
while ((c = readchar (1)) >= 0)
|
|
|
|
|
printf_unfiltered ("%c", c);
|
|
|
|
|
printf_unfiltered ("\n");
|
|
|
|
|
|
|
|
|
|
next_msg_id = 251;
|
|
|
|
|
|
|
|
|
|
buf[0] = 26;
|
|
|
|
|
sds_send (buf, 1);
|
|
|
|
|
|
|
|
|
|
buf[0] = 0;
|
|
|
|
|
sds_send (buf, 1);
|
|
|
|
|
|
2000-09-01 00:12:10 +00:00
|
|
|
|
immediate_quit--;
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
|
|
|
|
start_remote (); /* Initialize gdb process mechanisms */
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Open a connection to a remote debugger.
|
|
|
|
|
NAME is the filename used for communication. */
|
|
|
|
|
|
|
|
|
|
static void
|
2000-07-30 01:48:28 +00:00
|
|
|
|
sds_open (char *name, int from_tty)
|
1999-04-16 01:35:26 +00:00
|
|
|
|
{
|
|
|
|
|
if (name == 0)
|
|
|
|
|
error ("To open a remote debug connection, you need to specify what serial\n\
|
|
|
|
|
device is attached to the remote system (e.g. /dev/ttya).");
|
|
|
|
|
|
|
|
|
|
target_preopen (from_tty);
|
|
|
|
|
|
|
|
|
|
unpush_target (&sds_ops);
|
|
|
|
|
|
2001-07-15 20:34:14 +00:00
|
|
|
|
sds_desc = serial_open (name);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
if (!sds_desc)
|
|
|
|
|
perror_with_name (name);
|
|
|
|
|
|
|
|
|
|
if (baud_rate != -1)
|
|
|
|
|
{
|
2001-07-15 20:34:14 +00:00
|
|
|
|
if (serial_setbaudrate (sds_desc, baud_rate))
|
1999-04-16 01:35:26 +00:00
|
|
|
|
{
|
2001-07-15 20:34:14 +00:00
|
|
|
|
serial_close (sds_desc);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
perror_with_name (name);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2001-07-15 20:34:14 +00:00
|
|
|
|
serial_raw (sds_desc);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
|
|
|
|
/* If there is something sitting in the buffer we might take it as a
|
|
|
|
|
response to a command, which would be bad. */
|
2001-07-15 20:34:14 +00:00
|
|
|
|
serial_flush_input (sds_desc);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
|
|
|
|
if (from_tty)
|
|
|
|
|
{
|
|
|
|
|
puts_filtered ("Remote debugging using ");
|
|
|
|
|
puts_filtered (name);
|
|
|
|
|
puts_filtered ("\n");
|
|
|
|
|
}
|
|
|
|
|
push_target (&sds_ops); /* Switch to using remote target now */
|
|
|
|
|
|
|
|
|
|
just_started = 1;
|
|
|
|
|
|
|
|
|
|
/* Start the remote connection; if error (0), discard this target.
|
|
|
|
|
In particular, if the user quits, be sure to discard it (we'd be
|
|
|
|
|
in an inconsistent state otherwise). */
|
1999-07-07 20:19:36 +00:00
|
|
|
|
if (!catch_errors (sds_start_remote, NULL,
|
1999-04-16 01:35:26 +00:00
|
|
|
|
"Couldn't establish connection to remote target\n",
|
|
|
|
|
RETURN_MASK_ALL))
|
|
|
|
|
pop_target ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* This takes a program previously attached to and detaches it. After
|
|
|
|
|
this is done, GDB can be used to debug some other program. We
|
|
|
|
|
better not have left any breakpoints in the target program or it'll
|
|
|
|
|
die when it hits one. */
|
|
|
|
|
|
|
|
|
|
static void
|
2000-07-30 01:48:28 +00:00
|
|
|
|
sds_detach (char *args, int from_tty)
|
1999-04-16 01:35:26 +00:00
|
|
|
|
{
|
|
|
|
|
char buf[PBUFSIZ];
|
|
|
|
|
|
|
|
|
|
if (args)
|
|
|
|
|
error ("Argument given to \"detach\" when remotely debugging.");
|
|
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
|
/* Tell the remote target to detach. */
|
|
|
|
|
strcpy (buf, "D");
|
|
|
|
|
sds_send (buf, 1);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
pop_target ();
|
|
|
|
|
if (from_tty)
|
|
|
|
|
puts_filtered ("Ending remote debugging.\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Convert hex digit A to a number. */
|
|
|
|
|
|
|
|
|
|
static int
|
2000-07-30 01:48:28 +00:00
|
|
|
|
fromhex (int a)
|
1999-04-16 01:35:26 +00:00
|
|
|
|
{
|
|
|
|
|
if (a >= '0' && a <= '9')
|
|
|
|
|
return a - '0';
|
|
|
|
|
else if (a >= 'a' && a <= 'f')
|
|
|
|
|
return a - 'a' + 10;
|
1999-07-07 20:19:36 +00:00
|
|
|
|
else
|
1999-04-16 01:35:26 +00:00
|
|
|
|
error ("Reply contains invalid hex digit %d", a);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int
|
2000-07-30 01:48:28 +00:00
|
|
|
|
tob64 (unsigned char *inbuf, char *outbuf, int len)
|
1999-04-16 01:35:26 +00:00
|
|
|
|
{
|
|
|
|
|
int i, sum;
|
|
|
|
|
char *p;
|
|
|
|
|
|
|
|
|
|
if (len % 3 != 0)
|
|
|
|
|
error ("bad length");
|
|
|
|
|
|
|
|
|
|
p = outbuf;
|
|
|
|
|
for (i = 0; i < len; i += 3)
|
|
|
|
|
{
|
|
|
|
|
/* Collect the next three bytes into a number. */
|
|
|
|
|
sum = ((long) *inbuf++) << 16;
|
1999-07-07 20:19:36 +00:00
|
|
|
|
sum |= ((long) *inbuf++) << 8;
|
1999-04-16 01:35:26 +00:00
|
|
|
|
sum |= ((long) *inbuf++);
|
|
|
|
|
|
|
|
|
|
/* Spit out 4 6-bit encodings. */
|
|
|
|
|
*p++ = ((sum >> 18) & 0x3f) + '0';
|
|
|
|
|
*p++ = ((sum >> 12) & 0x3f) + '0';
|
1999-07-07 20:19:36 +00:00
|
|
|
|
*p++ = ((sum >> 6) & 0x3f) + '0';
|
1999-04-16 01:35:26 +00:00
|
|
|
|
*p++ = (sum & 0x3f) + '0';
|
|
|
|
|
}
|
|
|
|
|
return (p - outbuf);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int
|
2000-07-30 01:48:28 +00:00
|
|
|
|
fromb64 (char *inbuf, char *outbuf, int len)
|
1999-04-16 01:35:26 +00:00
|
|
|
|
{
|
|
|
|
|
int i, sum;
|
|
|
|
|
|
|
|
|
|
if (len % 4 != 0)
|
|
|
|
|
error ("bad length");
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < len; i += 4)
|
|
|
|
|
{
|
|
|
|
|
/* Collect 4 6-bit digits. */
|
1999-07-07 20:19:36 +00:00
|
|
|
|
sum = (*inbuf++ - '0') << 18;
|
1999-04-16 01:35:26 +00:00
|
|
|
|
sum |= (*inbuf++ - '0') << 12;
|
1999-07-07 20:19:36 +00:00
|
|
|
|
sum |= (*inbuf++ - '0') << 6;
|
1999-04-16 01:35:26 +00:00
|
|
|
|
sum |= (*inbuf++ - '0');
|
|
|
|
|
|
|
|
|
|
/* Now take the resulting 24-bit number and get three bytes out
|
|
|
|
|
of it. */
|
|
|
|
|
*outbuf++ = (sum >> 16) & 0xff;
|
1999-07-07 20:19:36 +00:00
|
|
|
|
*outbuf++ = (sum >> 8) & 0xff;
|
1999-04-16 01:35:26 +00:00
|
|
|
|
*outbuf++ = sum & 0xff;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (len / 4) * 3;
|
|
|
|
|
}
|
|
|
|
|
|
1999-07-07 20:19:36 +00:00
|
|
|
|
|
1999-04-16 01:35:26 +00:00
|
|
|
|
/* Tell the remote machine to resume. */
|
|
|
|
|
|
|
|
|
|
static enum target_signal last_sent_signal = TARGET_SIGNAL_0;
|
|
|
|
|
int last_sent_step;
|
|
|
|
|
|
|
|
|
|
static void
|
2001-05-04 04:15:33 +00:00
|
|
|
|
sds_resume (ptid_t ptid, int step, enum target_signal siggnal)
|
1999-04-16 01:35:26 +00:00
|
|
|
|
{
|
|
|
|
|
unsigned char buf[PBUFSIZ];
|
|
|
|
|
|
|
|
|
|
last_sent_signal = siggnal;
|
|
|
|
|
last_sent_step = step;
|
|
|
|
|
|
|
|
|
|
buf[0] = (step ? 21 : 20);
|
1999-07-07 20:19:36 +00:00
|
|
|
|
buf[1] = 0; /* (should be signal?) */
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
|
|
|
|
sds_send (buf, 2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Send a message to target to halt it. Target will respond, and send
|
|
|
|
|
us a message pending notice. */
|
|
|
|
|
|
|
|
|
|
static void
|
2000-07-30 01:48:28 +00:00
|
|
|
|
sds_interrupt (int signo)
|
1999-04-16 01:35:26 +00:00
|
|
|
|
{
|
|
|
|
|
unsigned char buf[PBUFSIZ];
|
|
|
|
|
|
|
|
|
|
/* If this doesn't work, try more severe steps. */
|
|
|
|
|
signal (signo, sds_interrupt_twice);
|
1999-07-07 20:19:36 +00:00
|
|
|
|
|
1999-04-16 01:35:26 +00:00
|
|
|
|
if (remote_debug)
|
1999-07-07 17:31:57 +00:00
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "sds_interrupt called\n");
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
|
|
|
|
buf[0] = 25;
|
|
|
|
|
sds_send (buf, 1);
|
|
|
|
|
}
|
|
|
|
|
|
1999-07-07 20:19:36 +00:00
|
|
|
|
static void (*ofunc) ();
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
|
|
|
|
/* The user typed ^C twice. */
|
|
|
|
|
|
|
|
|
|
static void
|
2000-07-30 01:48:28 +00:00
|
|
|
|
sds_interrupt_twice (int signo)
|
1999-04-16 01:35:26 +00:00
|
|
|
|
{
|
|
|
|
|
signal (signo, ofunc);
|
1999-07-07 20:19:36 +00:00
|
|
|
|
|
1999-04-16 01:35:26 +00:00
|
|
|
|
interrupt_query ();
|
|
|
|
|
|
|
|
|
|
signal (signo, sds_interrupt);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Ask the user what to do when an interrupt is received. */
|
|
|
|
|
|
|
|
|
|
static void
|
2000-07-30 01:48:28 +00:00
|
|
|
|
interrupt_query (void)
|
1999-04-16 01:35:26 +00:00
|
|
|
|
{
|
|
|
|
|
target_terminal_ours ();
|
|
|
|
|
|
|
|
|
|
if (query ("Interrupted while waiting for the program.\n\
|
|
|
|
|
Give up (and stop debugging it)? "))
|
|
|
|
|
{
|
|
|
|
|
target_mourn_inferior ();
|
2005-01-19 21:15:44 +00:00
|
|
|
|
deprecated_throw_reason (RETURN_QUIT);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
target_terminal_inferior ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* If nonzero, ignore the next kill. */
|
|
|
|
|
int kill_kludge;
|
|
|
|
|
|
|
|
|
|
/* Wait until the remote machine stops, then return, storing status in
|
|
|
|
|
STATUS just as `wait' would. Returns "pid" (though it's not clear
|
|
|
|
|
what, if anything, that means in the case of this target). */
|
|
|
|
|
|
2001-05-04 04:15:33 +00:00
|
|
|
|
static ptid_t
|
|
|
|
|
sds_wait (ptid_t ptid, struct target_waitstatus *status)
|
1999-04-16 01:35:26 +00:00
|
|
|
|
{
|
|
|
|
|
unsigned char buf[PBUFSIZ];
|
|
|
|
|
int retlen;
|
|
|
|
|
|
|
|
|
|
status->kind = TARGET_WAITKIND_EXITED;
|
|
|
|
|
status->value.integer = 0;
|
|
|
|
|
|
|
|
|
|
ofunc = (void (*)()) signal (SIGINT, sds_interrupt);
|
|
|
|
|
|
|
|
|
|
signal (SIGINT, ofunc);
|
|
|
|
|
|
|
|
|
|
if (just_started)
|
|
|
|
|
{
|
|
|
|
|
just_started = 0;
|
|
|
|
|
status->kind = TARGET_WAITKIND_STOPPED;
|
2001-05-04 04:15:33 +00:00
|
|
|
|
return inferior_ptid;
|
1999-04-16 01:35:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
while (1)
|
|
|
|
|
{
|
|
|
|
|
getmessage (buf, 1);
|
|
|
|
|
|
|
|
|
|
if (message_pending)
|
|
|
|
|
{
|
|
|
|
|
buf[0] = 26;
|
|
|
|
|
retlen = sds_send (buf, 1);
|
|
|
|
|
if (remote_debug)
|
|
|
|
|
{
|
1999-07-07 17:31:57 +00:00
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "Signals: %02x%02x %02x %02x\n",
|
1999-04-26 18:34:20 +00:00
|
|
|
|
buf[0], buf[1],
|
1999-04-16 01:35:26 +00:00
|
|
|
|
buf[2], buf[3]);
|
|
|
|
|
}
|
|
|
|
|
message_pending = 0;
|
|
|
|
|
status->kind = TARGET_WAITKIND_STOPPED;
|
|
|
|
|
status->value.sig = TARGET_SIGNAL_TRAP;
|
|
|
|
|
goto got_status;
|
|
|
|
|
}
|
|
|
|
|
}
|
1999-07-07 20:19:36 +00:00
|
|
|
|
got_status:
|
2001-05-04 04:15:33 +00:00
|
|
|
|
return inferior_ptid;
|
1999-04-16 01:35:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static unsigned char sprs[16];
|
|
|
|
|
|
|
|
|
|
/* Read the remote registers into the block REGS. */
|
|
|
|
|
/* Currently we just read all the registers, so we don't use regno. */
|
|
|
|
|
|
|
|
|
|
static void
|
2000-07-30 01:48:28 +00:00
|
|
|
|
sds_fetch_registers (int regno)
|
1999-04-16 01:35:26 +00:00
|
|
|
|
{
|
|
|
|
|
unsigned char buf[PBUFSIZ];
|
|
|
|
|
int i, retlen;
|
2004-08-03 02:02:24 +00:00
|
|
|
|
char *regs = alloca (deprecated_register_bytes ());
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
|
|
|
|
/* Unimplemented registers read as all bits zero. */
|
2004-08-03 02:02:24 +00:00
|
|
|
|
memset (regs, 0, deprecated_register_bytes ());
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
|
|
|
|
buf[0] = 18;
|
|
|
|
|
buf[1] = 1;
|
|
|
|
|
buf[2] = 0;
|
|
|
|
|
retlen = sds_send (buf, 3);
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < 4 * 6; ++i)
|
|
|
|
|
regs[i + 4 * 32 + 8 * 32] = buf[i];
|
|
|
|
|
for (i = 0; i < 4 * 4; ++i)
|
|
|
|
|
sprs[i] = buf[i + 4 * 7];
|
|
|
|
|
|
|
|
|
|
buf[0] = 18;
|
|
|
|
|
buf[1] = 2;
|
|
|
|
|
buf[2] = 0;
|
|
|
|
|
retlen = sds_send (buf, 3);
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < retlen; i++)
|
|
|
|
|
regs[i] = buf[i];
|
|
|
|
|
|
|
|
|
|
/* (should warn about reply too short) */
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < NUM_REGS; i++)
|
2004-07-21 Andrew Cagney <cagney@gnu.org>
Use regcache_raw_supply instead of supply_register.
* regcache.h (supply_register): Delete declaration.
* regcache.c (supply_register): Delete function.
* wince.c (do_child_fetch_inferior_registers): Update.
* win32-nat.c (do_child_fetch_inferior_registers)
(fetch_elf_core_registers): Update.
* v850ice.c (v850ice_fetch_registers): Update.
* thread-db.c (thread_db_store_registers): Update.
* sol-thread.c (sol_thread_store_registers): Update.
* shnbsd-tdep.c (shnbsd_supply_reg): Update.
* rs6000-nat.c (fetch_register): Update.
* rom68k-rom.c (rom68k_supply_one_register): Update.
* remote.c (remote_wait, remote_async_wait): Update.
* remote-st.c (get_hex_regs): Update.
* remote-sim.c (gdbsim_fetch_register): Update.
* remote-sds.c (sds_fetch_registers): Update.
* remote-rdp.c (remote_rdp_fetch_register): Update.
* remote-rdi.c (arm_rdi_fetch_registers): Update.
* remote-mips.c (mips_wait, mips_fetch_registers): Update.
* remote-m32r-sdi.c (m32r_fetch_register): Update.
* remote-hms.c (init_hms_cmds): Update.
* remote-est.c (init_est_cmds): Update.
* remote-e7000.c (get_hex_regs, fetch_regs_from_dump)
(e7000_fetch_registers, sub2_from_pc, e7000_wait): Update.
* ppcnbsd-tdep.c (ppcnbsd_supply_reg, ppcnbsd_supply_fpreg): Update.
* ppc-linux-nat.c (fetch_altivec_register, fetch_spe_register)
(fetch_register, supply_vrregset, supply_vrregset)
(fetch_spe_registers): Update.
* ppc-bdm.c (bdm_ppc_fetch_registers): Update.
* monitor.c (monitor_supply_register): Update.
* mipsv4-nat.c (supply_gregset, supply_fpregset): Update.
* mipsnbsd-tdep.c (mipsnbsd_supply_reg)
(mipsnbsd_supply_fpreg): Update.
* mips-nat.c (fetch_inferior_registers)
(fetch_core_registers): Update.
* mips-linux-tdep.c (supply_32bit_reg, supply_gregset)
(supply_fpregset, mips64_supply_gregset)
(mips64_supply_fpregset): Update.
* m68klinux-nat.c (fetch_register, supply_gregset)
(supply_fpregset): Update.
* m68k-tdep.c (supply_gregset, supply_fpregset): Update.
* m32r-rom.c (init_m32r_cmds, init_mon2000_cmds): Update.
* lynx-nat.c (fetch_inferior_registers, fetch_core_registers): Update.
* irix5-nat.c (supply_gregset, supply_fpregset): Update.
* infptrace.c (fetch_register): Update.
* ia64-linux-nat.c (supply_gregset, supply_fpregset): Update.
* ia64-aix-nat.c (supply_gregset, supply_fpregset): Update.
* i386gnu-nat.c (fetch_fpregs, supply_gregset)
(gnu_fetch_registers, gnu_store_registers): Update.
* i386-nto-tdep.c (i386nto_supply_gregset): Update.
* i386-linux-nat.c (fetch_register, supply_gregset)
(dummy_sse_values): Update.
* hpux-thread.c (hpux_thread_fetch_registers): Update.
* hppah-nat.c (fetch_register): Update.
* hppa-linux-nat.c (fetch_register, supply_gregset)
(supply_fpregset): Update.
* go32-nat.c (fetch_register): Update.
* dve3900-rom.c (fetch_bitmapped_register)
(_initialize_r3900_rom): Update.
* cris-tdep.c (supply_gregset): Update.
* abug-rom.c (init_abug_cmds): Update.
* core-aout.c (fetch_core_registers): Update.
* armnbsd-nat.c (supply_gregset, supply_fparegset)
(fetch_register, fetch_fp_register): Update.
* arm-linux-nat.c (fetch_nwfpe_single, fetch_nwfpe_none)
(fetch_nwfpe_extended, fetch_fpregister, fetch_fpregs)
(fetch_register, fetch_regs, supply_gregset, supply_fpregset): Update.
* alphanbsd-tdep.c (fetch_core_registers): Update.
* alpha-tdep.c (alpha_supply_int_regs, alpha_supply_fp_regs): Update.
* alpha-nat.c (fetch_osf_core_registers)
(fetch_osf_core_registers, fetch_osf_core_registers): Update.
* aix-thread.c (supply_gprs64, supply_reg32, supply_fprs)
(supply_sprs64, supply_sprs32, fetch_regs_kernel_thread): Update.
2004-07-22 01:31:49 +00:00
|
|
|
|
regcache_raw_supply (current_regcache, i,
|
|
|
|
|
®s[DEPRECATED_REGISTER_BYTE (i)]);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Prepare to store registers. Since we may send them all, we have to
|
|
|
|
|
read out the ones we don't want to change first. */
|
|
|
|
|
|
1999-07-07 20:19:36 +00:00
|
|
|
|
static void
|
2000-07-30 01:48:28 +00:00
|
|
|
|
sds_prepare_to_store (void)
|
1999-04-16 01:35:26 +00:00
|
|
|
|
{
|
|
|
|
|
/* Make sure the entire registers array is valid. */
|
2004-08-03 02:02:24 +00:00
|
|
|
|
deprecated_read_register_bytes (0, (char *) NULL, deprecated_register_bytes ());
|
1999-04-16 01:35:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Store register REGNO, or all registers if REGNO == -1, from the contents
|
|
|
|
|
of REGISTERS. FIXME: ignores errors. */
|
|
|
|
|
|
|
|
|
|
static void
|
2000-07-30 01:48:28 +00:00
|
|
|
|
sds_store_registers (int regno)
|
1999-04-16 01:35:26 +00:00
|
|
|
|
{
|
|
|
|
|
unsigned char *p, buf[PBUFSIZ];
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
/* Store all the special-purpose registers. */
|
|
|
|
|
p = buf;
|
|
|
|
|
*p++ = 19;
|
|
|
|
|
*p++ = 1;
|
|
|
|
|
*p++ = 0;
|
|
|
|
|
*p++ = 0;
|
|
|
|
|
for (i = 0; i < 4 * 6; i++)
|
2002-11-14 Andrew Cagney <ac131313@redhat.com>
* regcache.h (deprecated_registers): Rename registers.
* a68v-nat.c, alpha-nat.c, arch-utils.c, core-sol2.c: Update.
* hp300ux-nat.c, hppab-nat.c, hppah-nat.c: Update.
* hppam3-nat.c, hpux-thread.c, i386gnu-nat.c: Update.
* ia64-aix-nat.c, ia64-linux-nat.c, ia64-tdep.c: Update.
* irix4-nat.c, irix5-nat.c, lynx-nat.c, m68k-tdep.c: Update.
* m68knbsd-nat.c, mips-linux-tdep.c, mipsm3-nat.c: Update.
* mipsv4-nat.c, ns32knbsd-nat.c, ppc-bdm.c: Update.
* ppc-sysv-tdep.c, ptx4-nat.c, regcache.c, remote-es.c: Update.
* remote-sds.c, remote-vx68.c, remote-vxmips.c: Update.
* remote-vxsparc.c, rs6000-tdep.c, sol-thread.c: Update.
* sparc-nat.c, sparc-tdep.c, sun3-nat.c, symm-nat.c: Update.
* v850ice.c: Update.
2002-11-14 20:37:29 +00:00
|
|
|
|
*p++ = deprecated_registers[i + 4 * 32 + 8 * 32];
|
1999-04-16 01:35:26 +00:00
|
|
|
|
for (i = 0; i < 4 * 1; i++)
|
|
|
|
|
*p++ = 0;
|
|
|
|
|
for (i = 0; i < 4 * 4; i++)
|
|
|
|
|
*p++ = sprs[i];
|
|
|
|
|
|
|
|
|
|
sds_send (buf, p - buf);
|
|
|
|
|
|
|
|
|
|
/* Store all the general-purpose registers. */
|
|
|
|
|
p = buf;
|
|
|
|
|
*p++ = 19;
|
|
|
|
|
*p++ = 2;
|
|
|
|
|
*p++ = 0;
|
|
|
|
|
*p++ = 0;
|
|
|
|
|
for (i = 0; i < 4 * 32; i++)
|
2002-11-14 Andrew Cagney <ac131313@redhat.com>
* regcache.h (deprecated_registers): Rename registers.
* a68v-nat.c, alpha-nat.c, arch-utils.c, core-sol2.c: Update.
* hp300ux-nat.c, hppab-nat.c, hppah-nat.c: Update.
* hppam3-nat.c, hpux-thread.c, i386gnu-nat.c: Update.
* ia64-aix-nat.c, ia64-linux-nat.c, ia64-tdep.c: Update.
* irix4-nat.c, irix5-nat.c, lynx-nat.c, m68k-tdep.c: Update.
* m68knbsd-nat.c, mips-linux-tdep.c, mipsm3-nat.c: Update.
* mipsv4-nat.c, ns32knbsd-nat.c, ppc-bdm.c: Update.
* ppc-sysv-tdep.c, ptx4-nat.c, regcache.c, remote-es.c: Update.
* remote-sds.c, remote-vx68.c, remote-vxmips.c: Update.
* remote-vxsparc.c, rs6000-tdep.c, sol-thread.c: Update.
* sparc-nat.c, sparc-tdep.c, sun3-nat.c, symm-nat.c: Update.
* v850ice.c: Update.
2002-11-14 20:37:29 +00:00
|
|
|
|
*p++ = deprecated_registers[i];
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
|
|
|
|
sds_send (buf, p - buf);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Write memory data directly to the remote machine. This does not
|
|
|
|
|
inform the data cache; the data cache uses this. MEMADDR is the
|
|
|
|
|
address in the remote memory space. MYADDR is the address of the
|
|
|
|
|
buffer in our space. LEN is the number of bytes.
|
|
|
|
|
|
|
|
|
|
Returns number of bytes transferred, or 0 for error. */
|
|
|
|
|
|
|
|
|
|
static int
|
2000-07-30 01:48:28 +00:00
|
|
|
|
sds_write_bytes (CORE_ADDR memaddr, char *myaddr, int len)
|
1999-04-16 01:35:26 +00:00
|
|
|
|
{
|
|
|
|
|
int max_buf_size; /* Max size of packet output buffer */
|
|
|
|
|
int origlen;
|
|
|
|
|
unsigned char buf[PBUFSIZ];
|
|
|
|
|
int todo;
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
/* Chop the transfer down if necessary */
|
|
|
|
|
|
|
|
|
|
max_buf_size = 150;
|
|
|
|
|
|
|
|
|
|
origlen = len;
|
|
|
|
|
while (len > 0)
|
|
|
|
|
{
|
|
|
|
|
todo = min (len, max_buf_size);
|
|
|
|
|
|
|
|
|
|
buf[0] = 13;
|
|
|
|
|
buf[1] = 0;
|
|
|
|
|
buf[2] = (int) (memaddr >> 24) & 0xff;
|
|
|
|
|
buf[3] = (int) (memaddr >> 16) & 0xff;
|
1999-07-07 20:19:36 +00:00
|
|
|
|
buf[4] = (int) (memaddr >> 8) & 0xff;
|
|
|
|
|
buf[5] = (int) (memaddr) & 0xff;
|
1999-04-16 01:35:26 +00:00
|
|
|
|
buf[6] = 1;
|
|
|
|
|
buf[7] = 0;
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < todo; i++)
|
|
|
|
|
buf[i + 8] = myaddr[i];
|
|
|
|
|
|
|
|
|
|
sds_send (buf, 8 + todo);
|
|
|
|
|
|
|
|
|
|
/* (should look at result) */
|
|
|
|
|
|
|
|
|
|
myaddr += todo;
|
|
|
|
|
memaddr += todo;
|
|
|
|
|
len -= todo;
|
|
|
|
|
}
|
|
|
|
|
return origlen;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Read memory data directly from the remote machine. This does not
|
|
|
|
|
use the data cache; the data cache uses this. MEMADDR is the
|
|
|
|
|
address in the remote memory space. MYADDR is the address of the
|
|
|
|
|
buffer in our space. LEN is the number of bytes.
|
|
|
|
|
|
|
|
|
|
Returns number of bytes transferred, or 0 for error. */
|
|
|
|
|
|
|
|
|
|
static int
|
2000-07-30 01:48:28 +00:00
|
|
|
|
sds_read_bytes (CORE_ADDR memaddr, char *myaddr, int len)
|
1999-04-16 01:35:26 +00:00
|
|
|
|
{
|
|
|
|
|
int max_buf_size; /* Max size of packet output buffer */
|
|
|
|
|
int origlen, retlen;
|
|
|
|
|
unsigned char buf[PBUFSIZ];
|
|
|
|
|
int todo;
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
/* Chop the transfer down if necessary */
|
|
|
|
|
|
|
|
|
|
max_buf_size = 150;
|
|
|
|
|
|
|
|
|
|
origlen = len;
|
|
|
|
|
while (len > 0)
|
|
|
|
|
{
|
|
|
|
|
todo = min (len, max_buf_size);
|
|
|
|
|
|
|
|
|
|
buf[0] = 12;
|
|
|
|
|
buf[1] = 0;
|
|
|
|
|
buf[2] = (int) (memaddr >> 24) & 0xff;
|
|
|
|
|
buf[3] = (int) (memaddr >> 16) & 0xff;
|
1999-07-07 20:19:36 +00:00
|
|
|
|
buf[4] = (int) (memaddr >> 8) & 0xff;
|
|
|
|
|
buf[5] = (int) (memaddr) & 0xff;
|
1999-04-16 01:35:26 +00:00
|
|
|
|
buf[6] = (int) (todo >> 8) & 0xff;
|
1999-07-07 20:19:36 +00:00
|
|
|
|
buf[7] = (int) (todo) & 0xff;
|
1999-04-16 01:35:26 +00:00
|
|
|
|
buf[8] = 1;
|
|
|
|
|
|
|
|
|
|
retlen = sds_send (buf, 9);
|
|
|
|
|
|
|
|
|
|
if (retlen - 2 != todo)
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Reply describes memory byte by byte. */
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < todo; i++)
|
|
|
|
|
myaddr[i] = buf[i + 2];
|
|
|
|
|
|
|
|
|
|
myaddr += todo;
|
|
|
|
|
memaddr += todo;
|
|
|
|
|
len -= todo;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return origlen;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Read or write LEN bytes from inferior memory at MEMADDR,
|
|
|
|
|
transferring to or from debugger address MYADDR. Write to inferior
|
|
|
|
|
if SHOULD_WRITE is nonzero. Returns length of data written or
|
2000-10-12 21:39:21 +00:00
|
|
|
|
read; 0 for error. TARGET is unused. */
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
|
|
|
|
static int
|
2000-10-12 21:39:21 +00:00
|
|
|
|
sds_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int should_write,
|
2002-01-19 03:32:43 +00:00
|
|
|
|
struct mem_attrib *attrib, struct target_ops *target)
|
1999-04-16 01:35:26 +00:00
|
|
|
|
{
|
2000-11-03 22:00:56 +00:00
|
|
|
|
int res;
|
|
|
|
|
|
|
|
|
|
if (should_write)
|
|
|
|
|
res = sds_write_bytes (memaddr, myaddr, len);
|
|
|
|
|
else
|
|
|
|
|
res = sds_read_bytes (memaddr, myaddr, len);
|
|
|
|
|
|
|
|
|
|
return res;
|
1999-04-16 01:35:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-07-07 20:19:36 +00:00
|
|
|
|
|
1999-04-16 01:35:26 +00:00
|
|
|
|
static void
|
2000-07-30 01:48:28 +00:00
|
|
|
|
sds_files_info (struct target_ops *ignore)
|
1999-04-16 01:35:26 +00:00
|
|
|
|
{
|
|
|
|
|
puts_filtered ("Debugging over a serial connection, using SDS protocol.\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Stuff for dealing with the packets which are part of this protocol.
|
|
|
|
|
See comment at top of file for details. */
|
|
|
|
|
|
|
|
|
|
/* Read a single character from the remote end, masking it down to 7 bits. */
|
|
|
|
|
|
|
|
|
|
static int
|
2000-07-30 01:48:28 +00:00
|
|
|
|
readchar (int timeout)
|
1999-04-16 01:35:26 +00:00
|
|
|
|
{
|
|
|
|
|
int ch;
|
|
|
|
|
|
2001-07-15 20:34:14 +00:00
|
|
|
|
ch = serial_readchar (sds_desc, timeout);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
|
|
|
|
if (remote_debug > 1 && ch >= 0)
|
1999-07-07 17:31:57 +00:00
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "%c(%x)", ch, ch);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
|
|
|
|
switch (ch)
|
|
|
|
|
{
|
|
|
|
|
case SERIAL_EOF:
|
|
|
|
|
error ("Remote connection closed");
|
|
|
|
|
case SERIAL_ERROR:
|
|
|
|
|
perror_with_name ("Remote communication error");
|
|
|
|
|
case SERIAL_TIMEOUT:
|
|
|
|
|
return ch;
|
|
|
|
|
default:
|
|
|
|
|
return ch & 0x7f;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* An SDS-style checksum is a sum of the bytes modulo 253. (Presumably
|
|
|
|
|
because 253, 254, and 255 are special flags in the protocol.) */
|
|
|
|
|
|
|
|
|
|
static int
|
2000-07-30 01:48:28 +00:00
|
|
|
|
compute_checksum (int csum, char *buf, int len)
|
1999-04-16 01:35:26 +00:00
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < len; ++i)
|
|
|
|
|
csum += (unsigned char) buf[i];
|
|
|
|
|
|
|
|
|
|
csum %= 253;
|
|
|
|
|
return csum;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Send the command in BUF to the remote machine, and read the reply
|
|
|
|
|
into BUF also. */
|
|
|
|
|
|
|
|
|
|
static int
|
2000-07-30 01:48:28 +00:00
|
|
|
|
sds_send (unsigned char *buf, int len)
|
1999-04-16 01:35:26 +00:00
|
|
|
|
{
|
|
|
|
|
putmessage (buf, len);
|
|
|
|
|
|
|
|
|
|
return getmessage (buf, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Send a message to the remote machine. */
|
|
|
|
|
|
|
|
|
|
static int
|
2000-07-30 01:48:28 +00:00
|
|
|
|
putmessage (unsigned char *buf, int len)
|
1999-04-16 01:35:26 +00:00
|
|
|
|
{
|
|
|
|
|
int i, enclen;
|
|
|
|
|
unsigned char csum = 0;
|
|
|
|
|
char buf2[PBUFSIZ], buf3[PBUFSIZ];
|
|
|
|
|
unsigned char header[3];
|
|
|
|
|
char *p;
|
|
|
|
|
|
|
|
|
|
/* Copy the packet into buffer BUF2, encapsulating it
|
|
|
|
|
and giving it a checksum. */
|
|
|
|
|
|
|
|
|
|
if (len > 170) /* Prosanity check */
|
2005-02-11 Andrew Cagney <cagney@gnu.org>
Mark up error_no_arg, query, perror_with_name, complaint, and
internal_error.
* breakpoint.c, cp-abi.c, cp-namespace.c, cp-support.c: Update.
* cris-tdep.c, dbxread.c, dictionary.c, dsrec.c: Update.
* dummy-frame.c, dve3900-rom.c, dwarf2-frame.c, dwarf2expr.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, event-loop.c: Update.
* exceptions.c, exec.c, f-lang.c, findvar.c, fork-child.c: Update.
* frame-unwind.c, frame.c, frv-linux-tdep.c, frv-tdep.c: Update.
* gdb_assert.h, gdbarch.c, gdbtypes.c, gnu-nat.c: Update.
* go32-nat.c, hppa-tdep.c, hppabsd-nat.c, hpread.c: Update.
* i386-linux-nat.c, i386-nat.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386fbsd-nat.c, inf-ptrace.c, inf-ttrace.c, infcall.c: Update.
* infcmd.c, inflow.c, infptrace.c, infrun.c, inftarg.c: Update.
* interps.c, language.c, linespec.c, linux-nat.c: Update.
* m32r-linux-nat.c, m68k-tdep.c, m68kbsd-nat.c: Update.
* m68klinux-nat.c, m88kbsd-nat.c, macroexp.c, macroscope.c: Update.
* macrotab.c, maint.c, mdebugread.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mips64obsd-nat.c: Update.
* mipsnbsd-nat.c, mn10300-tdep.c, monitor.c, nto-procfs.c: Update.
* objc-lang.c, objfiles.c, objfiles.h, ocd.c, osabi.c: Update.
* parse.c, ppc-bdm.c, ppc-linux-nat.c, ppc-sysv-tdep.c: Update.
* ppcnbsd-nat.c, ppcobsd-nat.c, printcmd.c, procfs.c: Update.
* regcache.c, reggroups.c, remote-e7000.c, remote-mips.c: Update.
* remote-rdp.c, remote-sds.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote.c, rs6000-nat.c, rs6000-tdep.c: Update.
* s390-nat.c, s390-tdep.c, sentinel-frame.c, serial.c: Update.
* sh-tdep.c, sh3-rom.c, sh64-tdep.c, shnbsd-nat.c: Update.
* solib-aix5.c, solib-svr4.c, solib.c, source.c: Update.
* sparc-nat.c, stabsread.c, stack.c, symfile.c, symtab.c: Update.
* symtab.h, target.c, tracepoint.c, ui-file.c, ui-out.c: Update.
* utils.c, valops.c, valprint.c, vax-nat.c, vaxbsd-nat.c: Update.
* win32-nat.c, xcoffread.c, xstormy16-tdep.c: Update.
* cli/cli-cmds.c, cli/cli-logging.c, cli/cli-script.c: Update.
* cli/cli-setshow.c, mi/mi-cmd-break.c, mi/mi-cmds.c: Update.
* mi/mi-console.c, mi/mi-getopt.c, mi/mi-out.c: Update.
* tui/tui-file.c, tui/tui-interp.c: Update.
2005-02-11 18:13:55 +00:00
|
|
|
|
internal_error (__FILE__, __LINE__, _("failed internal consistency check"));
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
|
|
|
|
if (remote_debug)
|
|
|
|
|
{
|
1999-07-07 17:31:57 +00:00
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "Message to send: \"");
|
1999-04-16 01:35:26 +00:00
|
|
|
|
for (i = 0; i < len; ++i)
|
1999-07-07 17:31:57 +00:00
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "%02x", buf[i]);
|
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "\"\n");
|
1999-04-16 01:35:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
p = buf2;
|
|
|
|
|
*p++ = '$';
|
|
|
|
|
|
|
|
|
|
if (len % 3 != 0)
|
|
|
|
|
{
|
|
|
|
|
buf[len] = '\0';
|
1999-07-07 20:19:36 +00:00
|
|
|
|
buf[len + 1] = '\0';
|
1999-04-16 01:35:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
header[1] = next_msg_id;
|
|
|
|
|
|
|
|
|
|
header[2] = len;
|
|
|
|
|
|
|
|
|
|
csum = compute_checksum (csum, buf, len);
|
|
|
|
|
csum = compute_checksum (csum, header + 1, 2);
|
|
|
|
|
|
|
|
|
|
header[0] = csum;
|
|
|
|
|
|
|
|
|
|
tob64 (header, p, 3);
|
|
|
|
|
p += 4;
|
|
|
|
|
enclen = tob64 (buf, buf3, ((len + 2) / 3) * 3);
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < enclen; ++i)
|
|
|
|
|
*p++ = buf3[i];
|
|
|
|
|
*p++ = '\r';
|
|
|
|
|
*p++ = '\n';
|
|
|
|
|
|
|
|
|
|
next_msg_id = (next_msg_id + 3) % 245;
|
|
|
|
|
|
|
|
|
|
/* Send it over and over until we get a positive ack. */
|
|
|
|
|
|
|
|
|
|
while (1)
|
|
|
|
|
{
|
|
|
|
|
if (remote_debug)
|
|
|
|
|
{
|
|
|
|
|
*p = '\0';
|
1999-07-07 17:31:57 +00:00
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "Sending encoded: \"%s\"", buf2);
|
|
|
|
|
fprintf_unfiltered (gdb_stdlog,
|
|
|
|
|
" (Checksum %d, id %d, length %d)\n",
|
|
|
|
|
header[0], header[1], header[2]);
|
|
|
|
|
gdb_flush (gdb_stdlog);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
}
|
2001-07-15 20:34:14 +00:00
|
|
|
|
if (serial_write (sds_desc, buf2, p - buf2))
|
1999-04-16 01:35:26 +00:00
|
|
|
|
perror_with_name ("putmessage: write failed");
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Come here after finding the start of the frame. Collect the rest
|
|
|
|
|
into BUF. Returns 0 on any error, 1 on success. */
|
|
|
|
|
|
|
|
|
|
static int
|
2000-07-30 01:48:28 +00:00
|
|
|
|
read_frame (char *buf)
|
1999-04-16 01:35:26 +00:00
|
|
|
|
{
|
|
|
|
|
char *bp;
|
|
|
|
|
int c;
|
|
|
|
|
|
|
|
|
|
bp = buf;
|
|
|
|
|
|
|
|
|
|
while (1)
|
|
|
|
|
{
|
|
|
|
|
c = readchar (sds_timeout);
|
|
|
|
|
|
|
|
|
|
switch (c)
|
|
|
|
|
{
|
|
|
|
|
case SERIAL_TIMEOUT:
|
|
|
|
|
if (remote_debug)
|
1999-07-07 17:31:57 +00:00
|
|
|
|
fputs_filtered ("Timeout in mid-message, retrying\n", gdb_stdlog);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
return 0;
|
|
|
|
|
case '$':
|
|
|
|
|
if (remote_debug)
|
1999-07-07 17:31:57 +00:00
|
|
|
|
fputs_filtered ("Saw new packet start in middle of old one\n",
|
|
|
|
|
gdb_stdlog);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
return 0; /* Start a new packet, count retries */
|
|
|
|
|
case '\r':
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case '\n':
|
|
|
|
|
{
|
|
|
|
|
*bp = '\000';
|
|
|
|
|
if (remote_debug)
|
1999-07-07 17:31:57 +00:00
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "Received encoded: \"%s\"\n",
|
1999-04-16 01:35:26 +00:00
|
|
|
|
buf);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
if (bp < buf + PBUFSIZ - 1)
|
|
|
|
|
{
|
|
|
|
|
*bp++ = c;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*bp = '\0';
|
|
|
|
|
puts_filtered ("Message too long: ");
|
|
|
|
|
puts_filtered (buf);
|
|
|
|
|
puts_filtered ("\n");
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Read a packet from the remote machine, with error checking,
|
|
|
|
|
and store it in BUF. BUF is expected to be of size PBUFSIZ.
|
|
|
|
|
If FOREVER, wait forever rather than timing out; this is used
|
|
|
|
|
while the target is executing user code. */
|
|
|
|
|
|
|
|
|
|
static int
|
2000-07-30 01:48:28 +00:00
|
|
|
|
getmessage (unsigned char *buf, int forever)
|
1999-04-16 01:35:26 +00:00
|
|
|
|
{
|
|
|
|
|
int c, c2, c3;
|
|
|
|
|
int tries;
|
|
|
|
|
int timeout;
|
|
|
|
|
int val, i, len, csum;
|
|
|
|
|
unsigned char header[3];
|
|
|
|
|
unsigned char inbuf[500];
|
|
|
|
|
|
|
|
|
|
strcpy (buf, "timeout");
|
|
|
|
|
|
|
|
|
|
if (forever)
|
|
|
|
|
{
|
|
|
|
|
timeout = watchdog > 0 ? watchdog : -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
|
timeout = sds_timeout;
|
|
|
|
|
|
|
|
|
|
#define MAX_TRIES 3
|
|
|
|
|
|
|
|
|
|
for (tries = 1; tries <= MAX_TRIES; tries++)
|
|
|
|
|
{
|
|
|
|
|
/* This can loop forever if the remote side sends us characters
|
1999-07-07 20:19:36 +00:00
|
|
|
|
continuously, but if it pauses, we'll get a zero from readchar
|
|
|
|
|
because of timeout. Then we'll count that as a retry. */
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
|
|
|
|
/* Note that we will only wait forever prior to the start of a packet.
|
1999-07-07 20:19:36 +00:00
|
|
|
|
After that, we expect characters to arrive at a brisk pace. They
|
|
|
|
|
should show up within sds_timeout intervals. */
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
c = readchar (timeout);
|
|
|
|
|
|
|
|
|
|
if (c == SERIAL_TIMEOUT)
|
|
|
|
|
{
|
|
|
|
|
if (forever) /* Watchdog went off. Kill the target. */
|
|
|
|
|
{
|
|
|
|
|
target_mourn_inferior ();
|
|
|
|
|
error ("Watchdog has expired. Target detached.\n");
|
|
|
|
|
}
|
|
|
|
|
if (remote_debug)
|
1999-07-07 17:31:57 +00:00
|
|
|
|
fputs_filtered ("Timed out.\n", gdb_stdlog);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
goto retry;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
while (c != '$' && c != '{');
|
|
|
|
|
|
|
|
|
|
/* We might have seen a "trigraph", a sequence of three characters
|
1999-07-07 20:19:36 +00:00
|
|
|
|
that indicate various sorts of communication state. */
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
|
|
|
|
if (c == '{')
|
|
|
|
|
{
|
|
|
|
|
/* Read the other two chars of the trigraph. */
|
|
|
|
|
c2 = readchar (timeout);
|
|
|
|
|
c3 = readchar (timeout);
|
|
|
|
|
if (remote_debug)
|
1999-07-07 17:31:57 +00:00
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "Trigraph %c%c%c received\n",
|
1999-04-16 01:35:26 +00:00
|
|
|
|
c, c2, c3);
|
|
|
|
|
if (c3 == '+')
|
|
|
|
|
{
|
|
|
|
|
message_pending = 1;
|
1999-07-07 20:19:36 +00:00
|
|
|
|
return 0; /*???? */
|
1999-04-16 01:35:26 +00:00
|
|
|
|
}
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
val = read_frame (inbuf);
|
|
|
|
|
|
|
|
|
|
if (val == 1)
|
|
|
|
|
{
|
|
|
|
|
fromb64 (inbuf, header, 4);
|
|
|
|
|
/* (should check out other bits) */
|
|
|
|
|
fromb64 (inbuf + 4, buf, strlen (inbuf) - 4);
|
|
|
|
|
|
|
|
|
|
len = header[2];
|
|
|
|
|
|
|
|
|
|
csum = 0;
|
|
|
|
|
csum = compute_checksum (csum, buf, len);
|
|
|
|
|
csum = compute_checksum (csum, header + 1, 2);
|
|
|
|
|
|
|
|
|
|
if (csum != header[0])
|
|
|
|
|
fprintf_unfiltered (gdb_stderr,
|
1999-07-07 20:19:36 +00:00
|
|
|
|
"Checksum mismatch: computed %d, received %d\n",
|
1999-04-16 01:35:26 +00:00
|
|
|
|
csum, header[0]);
|
|
|
|
|
|
|
|
|
|
if (header[2] == 0xff)
|
|
|
|
|
fprintf_unfiltered (gdb_stderr, "Requesting resend...\n");
|
|
|
|
|
|
|
|
|
|
if (remote_debug)
|
|
|
|
|
{
|
1999-07-07 17:31:57 +00:00
|
|
|
|
fprintf_unfiltered (gdb_stdlog,
|
1999-07-07 20:19:36 +00:00
|
|
|
|
"... (Got checksum %d, id %d, length %d)\n",
|
1999-04-16 01:35:26 +00:00
|
|
|
|
header[0], header[1], header[2]);
|
1999-07-07 17:31:57 +00:00
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "Message received: \"");
|
1999-04-16 01:35:26 +00:00
|
|
|
|
for (i = 0; i < len; ++i)
|
|
|
|
|
{
|
1999-07-07 17:31:57 +00:00
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "%02x", (unsigned char) buf[i]);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
}
|
1999-07-07 17:31:57 +00:00
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "\"\n");
|
1999-04-16 01:35:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* no ack required? */
|
|
|
|
|
return len;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Try the whole thing again. */
|
|
|
|
|
retry:
|
|
|
|
|
/* need to do something here */
|
2002-10-01 19:26:05 +00:00
|
|
|
|
;
|
1999-04-16 01:35:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* We have tried hard enough, and just can't receive the packet. Give up. */
|
|
|
|
|
|
|
|
|
|
printf_unfiltered ("Ignoring packet error, continuing...\n");
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2000-07-30 01:48:28 +00:00
|
|
|
|
sds_kill (void)
|
1999-04-16 01:35:26 +00:00
|
|
|
|
{
|
|
|
|
|
/* Don't try to do anything to the target. */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2000-07-30 01:48:28 +00:00
|
|
|
|
sds_mourn (void)
|
1999-04-16 01:35:26 +00:00
|
|
|
|
{
|
|
|
|
|
unpush_target (&sds_ops);
|
|
|
|
|
generic_mourn_inferior ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2004-05-25 14:58:31 +00:00
|
|
|
|
sds_create_inferior (char *exec_file, char *args, char **env, int from_tty)
|
1999-04-16 01:35:26 +00:00
|
|
|
|
{
|
2001-05-04 04:15:33 +00:00
|
|
|
|
inferior_ptid = pid_to_ptid (42000);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
|
|
|
|
/* Clean up from the last time we were running. */
|
|
|
|
|
clear_proceed_status ();
|
|
|
|
|
|
2006-01-24 22:09:28 +00:00
|
|
|
|
write_pc (bfd_get_start_address (exec_bfd));
|
1999-04-16 01:35:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2000-07-30 01:48:28 +00:00
|
|
|
|
sds_load (char *filename, int from_tty)
|
1999-04-16 01:35:26 +00:00
|
|
|
|
{
|
|
|
|
|
generic_load (filename, from_tty);
|
|
|
|
|
|
2001-05-04 04:15:33 +00:00
|
|
|
|
inferior_ptid = null_ptid;
|
1999-04-16 01:35:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* The SDS monitor has commands for breakpoint insertion, although it
|
|
|
|
|
it doesn't actually manage the breakpoints, it just returns the
|
|
|
|
|
replaced instruction back to the debugger. */
|
|
|
|
|
|
|
|
|
|
static int
|
2000-07-30 01:48:28 +00:00
|
|
|
|
sds_insert_breakpoint (CORE_ADDR addr, char *contents_cache)
|
1999-04-16 01:35:26 +00:00
|
|
|
|
{
|
|
|
|
|
int i, retlen;
|
|
|
|
|
unsigned char *p, buf[PBUFSIZ];
|
|
|
|
|
|
|
|
|
|
p = buf;
|
|
|
|
|
*p++ = 16;
|
|
|
|
|
*p++ = 0;
|
|
|
|
|
*p++ = (int) (addr >> 24) & 0xff;
|
|
|
|
|
*p++ = (int) (addr >> 16) & 0xff;
|
1999-07-07 20:19:36 +00:00
|
|
|
|
*p++ = (int) (addr >> 8) & 0xff;
|
|
|
|
|
*p++ = (int) (addr) & 0xff;
|
|
|
|
|
|
1999-04-16 01:35:26 +00:00
|
|
|
|
retlen = sds_send (buf, p - buf);
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < 4; ++i)
|
|
|
|
|
contents_cache[i] = buf[i + 2];
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int
|
2000-07-30 01:48:28 +00:00
|
|
|
|
sds_remove_breakpoint (CORE_ADDR addr, char *contents_cache)
|
1999-04-16 01:35:26 +00:00
|
|
|
|
{
|
|
|
|
|
int i, retlen;
|
|
|
|
|
unsigned char *p, buf[PBUFSIZ];
|
|
|
|
|
|
|
|
|
|
p = buf;
|
|
|
|
|
*p++ = 17;
|
|
|
|
|
*p++ = 0;
|
|
|
|
|
*p++ = (int) (addr >> 24) & 0xff;
|
|
|
|
|
*p++ = (int) (addr >> 16) & 0xff;
|
1999-07-07 20:19:36 +00:00
|
|
|
|
*p++ = (int) (addr >> 8) & 0xff;
|
|
|
|
|
*p++ = (int) (addr) & 0xff;
|
1999-04-16 01:35:26 +00:00
|
|
|
|
for (i = 0; i < 4; ++i)
|
|
|
|
|
*p++ = contents_cache[i];
|
|
|
|
|
|
|
|
|
|
retlen = sds_send (buf, p - buf);
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
1999-07-07 20:19:36 +00:00
|
|
|
|
static void
|
2000-07-30 01:48:28 +00:00
|
|
|
|
init_sds_ops (void)
|
1999-04-16 01:35:26 +00:00
|
|
|
|
{
|
|
|
|
|
sds_ops.to_shortname = "sds";
|
|
|
|
|
sds_ops.to_longname = "Remote serial target with SDS protocol";
|
|
|
|
|
sds_ops.to_doc = "Use a remote computer via a serial line; using the SDS protocol.\n\
|
|
|
|
|
Specify the serial device it is connected to (e.g. /dev/ttya).";
|
|
|
|
|
sds_ops.to_open = sds_open;
|
|
|
|
|
sds_ops.to_close = sds_close;
|
|
|
|
|
sds_ops.to_detach = sds_detach;
|
|
|
|
|
sds_ops.to_resume = sds_resume;
|
|
|
|
|
sds_ops.to_wait = sds_wait;
|
|
|
|
|
sds_ops.to_fetch_registers = sds_fetch_registers;
|
|
|
|
|
sds_ops.to_store_registers = sds_store_registers;
|
|
|
|
|
sds_ops.to_prepare_to_store = sds_prepare_to_store;
|
2004-10-08 20:30:00 +00:00
|
|
|
|
sds_ops.deprecated_xfer_memory = sds_xfer_memory;
|
1999-04-16 01:35:26 +00:00
|
|
|
|
sds_ops.to_files_info = sds_files_info;
|
|
|
|
|
sds_ops.to_insert_breakpoint = sds_insert_breakpoint;
|
|
|
|
|
sds_ops.to_remove_breakpoint = sds_remove_breakpoint;
|
|
|
|
|
sds_ops.to_kill = sds_kill;
|
|
|
|
|
sds_ops.to_load = sds_load;
|
|
|
|
|
sds_ops.to_create_inferior = sds_create_inferior;
|
|
|
|
|
sds_ops.to_mourn_inferior = sds_mourn;
|
|
|
|
|
sds_ops.to_stratum = process_stratum;
|
|
|
|
|
sds_ops.to_has_all_memory = 1;
|
|
|
|
|
sds_ops.to_has_memory = 1;
|
|
|
|
|
sds_ops.to_has_stack = 1;
|
|
|
|
|
sds_ops.to_has_registers = 1;
|
|
|
|
|
sds_ops.to_has_execution = 1;
|
|
|
|
|
sds_ops.to_magic = OPS_MAGIC;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Put a command string, in args, out to the monitor and display the
|
|
|
|
|
reply message. */
|
|
|
|
|
|
|
|
|
|
static void
|
2000-07-30 01:48:28 +00:00
|
|
|
|
sds_command (char *args, int from_tty)
|
1999-04-16 01:35:26 +00:00
|
|
|
|
{
|
|
|
|
|
char *p;
|
|
|
|
|
int i, len, retlen;
|
|
|
|
|
unsigned char buf[1000];
|
|
|
|
|
|
|
|
|
|
/* Convert hexadecimal chars into a byte buffer. */
|
|
|
|
|
p = args;
|
|
|
|
|
len = 0;
|
|
|
|
|
while (*p != '\0')
|
|
|
|
|
{
|
|
|
|
|
buf[len++] = fromhex (p[0]) * 16 + fromhex (p[1]);
|
|
|
|
|
if (p[1] == '\0')
|
|
|
|
|
break;
|
|
|
|
|
p += 2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
retlen = sds_send (buf, len);
|
|
|
|
|
|
|
|
|
|
printf_filtered ("Reply is ");
|
|
|
|
|
for (i = 0; i < retlen; ++i)
|
|
|
|
|
{
|
|
|
|
|
printf_filtered ("%02x", buf[i]);
|
1999-07-07 20:19:36 +00:00
|
|
|
|
}
|
1999-04-16 01:35:26 +00:00
|
|
|
|
printf_filtered ("\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2000-07-30 01:48:28 +00:00
|
|
|
|
_initialize_remote_sds (void)
|
1999-04-16 01:35:26 +00:00
|
|
|
|
{
|
|
|
|
|
init_sds_ops ();
|
|
|
|
|
add_target (&sds_ops);
|
|
|
|
|
|
2005-02-21 06:21:09 +00:00
|
|
|
|
add_setshow_integer_cmd ("sdstimeout", no_class, &sds_timeout, _("\
|
|
|
|
|
Set timeout value for sds read."), _("\
|
|
|
|
|
Show timeout value for sds read."), NULL,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL, /* FIXME: i18n: */
|
|
|
|
|
&setlist, &showlist);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
|
|
|
|
add_com ("sds", class_obscure, sds_command,
|
2005-02-15 Andrew Cagney <cagney@gnu.org>
Mark up add_com, add_info and add_prefix_cmd.
* breakpoint.c, cp-support.c, dcache.c, dwarf2read.c: Update.
* exec.c, f-valprint.c, frame.c, gcore.c, gnu-nat.c: Update.
* go32-nat.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update.
* kod.c, language.c, linux-nat.c, m32r-rom.c, macrocmd.c: Update.
* maint.c, memattr.c, mips-tdep.c, nto-procfs.c, objc-lang.c: Update.
* ocd.c, pa64solib.c, printcmd.c, procfs.c, regcache.c: Update.
* remote-e7000.c, remote-m32r-sdi.c, remote-mips.c: Update.
* remote-sds.c, remote-sim.c, remote-st.c, remote-utils.c: Update.
* remote.c, rs6000-tdep.c, ser-go32.c, serial.c: Update.
* sh-tdep.c, solib.c, somsolib.c, source.c, stack.c: Update.
* symfile.c, symtab.c, target.c, thread.c, top.c: Update.
* tracepoint.c, typeprint.c, utils.c, valprint.c: Update.
* win32-nat.c, xcoffsolib.c, cli/cli-cmds.c, cli/cli-dump.c: Update.
* cli/cli-logging.c, tui/tui-layout.c, tui/tui-regs.c: Update.
* tui/tui-stack.c, tui/tui-win.c: Update.
2005-02-15 15:49:28 +00:00
|
|
|
|
_("Send a command to the SDS monitor."));
|
1999-04-16 01:35:26 +00:00
|
|
|
|
}
|