+2002-01-06 Andrew Cagney <ac131313@redhat.com>
+
+ * MAINTAINERS: Mark a29k target as obsolete.
+ * Makefile.in (a29k-tdep.o, remote-adapt.o, remote-eb.o)
+ (remote-mm.o, remote-udi.o): Obsolete. Remove references in
+ comments.
+ * NEWS: Note that a29k targets are obsolete.
+ * a29k-tdep.c: Mark as obsolete.
+ * configure.tgt: Mark a29k-*-aout*, a29k-*-coff*, a29k-*-elf*,
+ a29k-*-ebmon*, a29k-*-kern*, a29k-*-none*, a29k-*-udi* and
+ a29k-*-vxworks* targets as obsolete.
+ * remote-adapt.c: Obsolete.
+ * remote-eb.c: Obsolete.
+ * remote-mm.c: Obsolete.
+ * remote-udi.c: Obsolete.
+ * config/a29k/a29k-udi.mt: Obsolete.
+ * config/a29k/a29k.mt: Obsolete.
+ * config/a29k/tm-a29k.h: Obsolete.
+ * config/a29k/tm-vx29k.h: Obsolete.
+ * config/a29k/vx29k.mt: Obsolete.
+
2002-01-05 Andrew Cagney <ac131313@redhat.com>
* rs6000-tdep.c (rs6000_do_registers_info): Replace BIG_ENDIAN
host maintainer when resolving build issues. The Target/Architecture
maintainer works with the native maintainer when resolving API issues.
- a29k (--target=a29k-amd-udi broken)
- Maintenance only
+ a29k OBSOLETE
alpha --target=alpha-dec-osf4.0a -Werror
Maintenance only
# We do this by grepping through sources. If that turns out to be too slow,
# maybe we could just require every .o file to have an initialization routine
-# of a given name (remote-udi.o -> _initialize_remote_udi, etc.).
+# of a given name (top.o -> _initialize_top, etc.).
#
# Formatting conventions: The name of the _initialize_* routines must start
# in column zero, and must not be inside #if.
udr.o: $(srcdir)/29k-share/udi/udr.c $(udiheaders)
$(CC) -c $(INTERNAL_CFLAGS) $(srcdir)/29k-share/udi/udr.c
-a29k-tdep.o: a29k-tdep.c $(gdbcmd_h) $(gdbcore_h) $(inferior_h) $(defs_h) \
- $(regcache_h)
+# OBSOLETE a29k-tdep.o: a29k-tdep.c $(gdbcmd_h) $(gdbcore_h) $(inferior_h) $(defs_h) \
+# OBSOLETE $(regcache_h)
a68v-nat.o: a68v-nat.c $(defs_h) $(gdbcore_h) $(inferior_h) \
$(regcache_h)
proc-service.o: proc-service.c $(defs_h) $(inferior_h) gdb_proc_service.h \
$(symtab_h) $(target_h) gregset.h
-remote-adapt.o: remote-adapt.c $(defs_h) $(gdbcore_h) \
- $(inferior_h) $(target_h) $(terminal_h) $(gdb_string_h) $(regcache_h)
+# OBSOLETE remote-adapt.o: remote-adapt.c $(defs_h) $(gdbcore_h) \
+# OBSOLETE $(inferior_h) $(target_h) $(terminal_h) $(gdb_string_h) $(regcache_h)
remote-array.o: remote-array.c $(defs_h) $(gdbcore_h) $(target_h) \
$(gdb_string_h) $(command_h) $(serial_h) $(monitor_h) $(remote_utils_h) \
remote-e7000.o: remote-e7000.c $(defs_h) $(gdbcore_h) $(target_h) \
$(serial_h) $(gdb_string_h) $(regcache_h)
-remote-eb.o: remote-eb.c $(srcdir)/config/a29k/tm-a29k.h \
- $(defs_h) $(gdbcore_h) $(inferior_h) $(symfile_h) $(target_h) \
- $(terminal_h) $(gdb_string_h) $(regcache_h)
+# OBSOLETE remote-eb.o: remote-eb.c $(srcdir)/config/a29k/tm-a29k.h \
+# OBSOLETE $(defs_h) $(gdbcore_h) $(inferior_h) $(symfile_h) $(target_h) \
+# OBSOLETE $(terminal_h) $(gdb_string_h) $(regcache_h)
remote-es.o: remote-es.c $(bfd_h) $(command_h) $(defs_h) \
$(inferior_h) $(remote_utils_h) $(terminal_h) $(gdb_string_h) \
$(gdbcore_h) $(inferior_h) $(serial_h) $(symfile_h) $(target_h) \
$(regcache_h)
-remote-mm.o: remote-mm.c $(bfd_h) $(defs_h) $(inferior_h) \
- minimon.h $(target_h) $(terminal_h) $(gdb_string_h) $(regcache_h)
+# OBSOLETE remote-mm.o: remote-mm.c $(bfd_h) $(defs_h) $(inferior_h) \
+# OBSOLETE minimon.h $(target_h) $(terminal_h) $(gdb_string_h) $(regcache_h)
remote-nindy.o: remote-nindy.c $(floatformat_h) $(command_h) \
$(defs_h) $(gdbcore_h) $(inferior_h) \
remote-st.o: remote-st.c $(defs_h) $(gdbcore_h) $(serial_h) \
$(target_h) $(gdb_string_h) $(regcache_h)
-remote-udi.o: remote-udi.c $(bfd_h) $(defs_h) $(gdbcmd_h) \
- $(inferior_h) $(target_h) $(terminal_h) $(udiheaders) $(gdb_string_h) \
- $(regcache_h)
+# OBSOLETE remote-udi.o: remote-udi.c $(bfd_h) $(defs_h) $(gdbcmd_h) \
+# OBSOLETE $(inferior_h) $(target_h) $(terminal_h) $(udiheaders) $(gdb_string_h) \
+# OBSOLETE $(regcache_h)
remote-vx.o: remote-vx.c $(complaints_h) $(defs_h) $(gdbcmd_h) \
$(gdbcore_h) $(inferior_h) $(target_h) vx-share/dbgRpcLib.h \
Sanyo XStormy16 xstormy16-elf
+* OBSOLETE configurations and files
+
+Configurations that have been declared obsolete in this release have
+been commented out. Unless there is activity to revive these
+configurations, the next release of GDB will have their sources
+permanently REMOVED.
+
+AMD 29k family via UDI a29k-amd-udi, udi29k
+A29K VxWorks a29k-*-vxworks
+AMD 29000 embedded, using EBMON a29k-none-none
+AMD 29000 embedded with COFF a29k-none-coff
+AMD 29000 embedded with a.out a29k-none-aout
+
+
* REMOVED configurations and files
TI TMS320C80 tic80-*-*
-/* Target-machine dependent code for the AMD 29000
- Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000,
- 2001
- Free Software Foundation, Inc.
- Contributed by Cygnus Support. Written by Jim Kingdon.
-
- This file is part of GDB.
-
- 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.
-
- 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.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA. */
-
-#include "defs.h"
-#include "gdbcore.h"
-#include "frame.h"
-#include "value.h"
-#include "symtab.h"
-#include "inferior.h"
-#include "gdbcmd.h"
-#include "regcache.h"
-
-/* If all these bits in an instruction word are zero, it is a "tag word"
- which precedes a function entry point and gives stack traceback info.
- This used to be defined as 0xff000000, but that treated 0x00000deb as
- a tag word, while it is really used as a breakpoint. */
-#define TAGWORD_ZERO_MASK 0xff00f800
-
-extern CORE_ADDR text_start; /* FIXME, kludge... */
-
-/* The user-settable top of the register stack in virtual memory. We
- won't attempt to access any stored registers above this address, if set
- nonzero. */
-
-static CORE_ADDR rstack_high_address = UINT_MAX;
-
-
-/* Should call_function allocate stack space for a struct return? */
-/* On the a29k objects over 16 words require the caller to allocate space. */
-int
-a29k_use_struct_convention (int gcc_p, struct type *type)
-{
- return (TYPE_LENGTH (type) > 16 * 4);
-}
-
-
-/* Structure to hold cached info about function prologues. */
-
-struct prologue_info
-{
- CORE_ADDR pc; /* First addr after fn prologue */
- unsigned rsize, msize; /* register stack frame size, mem stack ditto */
- unsigned mfp_used:1; /* memory frame pointer used */
- unsigned rsize_valid:1; /* Validity bits for the above */
- unsigned msize_valid:1;
- unsigned mfp_valid:1;
-};
-
-/* Examine the prologue of a function which starts at PC. Return
- the first addess past the prologue. If MSIZE is non-NULL, then
- set *MSIZE to the memory stack frame size. If RSIZE is non-NULL,
- then set *RSIZE to the register stack frame size (not including
- incoming arguments and the return address & frame pointer stored
- with them). If no prologue is found, *RSIZE is set to zero.
- If no prologue is found, or a prologue which doesn't involve
- allocating a memory stack frame, then set *MSIZE to zero.
-
- Note that both msize and rsize are in bytes. This is not consistent
- with the _User's Manual_ with respect to rsize, but it is much more
- convenient.
-
- If MFP_USED is non-NULL, *MFP_USED is set to nonzero if a memory
- frame pointer is being used. */
-
-CORE_ADDR
-examine_prologue (CORE_ADDR pc, unsigned *rsize, unsigned *msize, int *mfp_used)
-{
- long insn;
- CORE_ADDR p = pc;
- struct minimal_symbol *msymbol = lookup_minimal_symbol_by_pc (pc);
- struct prologue_info *mi = 0;
-
- if (msymbol != NULL)
- mi = (struct prologue_info *) msymbol->info;
-
- if (mi != 0)
- {
- int valid = 1;
- if (rsize != NULL)
- {
- *rsize = mi->rsize;
- valid &= mi->rsize_valid;
- }
- if (msize != NULL)
- {
- *msize = mi->msize;
- valid &= mi->msize_valid;
- }
- if (mfp_used != NULL)
- {
- *mfp_used = mi->mfp_used;
- valid &= mi->mfp_valid;
- }
- if (valid)
- return mi->pc;
- }
-
- if (rsize != NULL)
- *rsize = 0;
- if (msize != NULL)
- *msize = 0;
- if (mfp_used != NULL)
- *mfp_used = 0;
-
- /* Prologue must start with subtracting a constant from gr1.
- Normally this is sub gr1,gr1,<rsize * 4>. */
- insn = read_memory_integer (p, 4);
- if ((insn & 0xffffff00) != 0x25010100)
- {
- /* If the frame is large, instead of a single instruction it
- might be a pair of instructions:
- const <reg>, <rsize * 4>
- sub gr1,gr1,<reg>
- */
- int reg;
- /* Possible value for rsize. */
- unsigned int rsize0;
-
- if ((insn & 0xff000000) != 0x03000000)
- {
- p = pc;
- goto done;
- }
- reg = (insn >> 8) & 0xff;
- rsize0 = (((insn >> 8) & 0xff00) | (insn & 0xff));
- p += 4;
- insn = read_memory_integer (p, 4);
- if ((insn & 0xffffff00) != 0x24010100
- || (insn & 0xff) != reg)
- {
- p = pc;
- goto done;
- }
- if (rsize != NULL)
- *rsize = rsize0;
- }
- else
- {
- if (rsize != NULL)
- *rsize = (insn & 0xff);
- }
- p += 4;
-
- /* Next instruction ought to be asgeu V_SPILL,gr1,rab.
- * We don't check the vector number to allow for kernel debugging. The
- * kernel will use a different trap number.
- * If this insn is missing, we just keep going; Metaware R2.3u compiler
- * generates prologue that intermixes initializations and puts the asgeu
- * way down.
- */
- insn = read_memory_integer (p, 4);
- if ((insn & 0xff00ffff) == (0x5e000100 | RAB_HW_REGNUM))
- {
- p += 4;
- }
-
- /* Next instruction usually sets the frame pointer (lr1) by adding
- <size * 4> from gr1. However, this can (and high C does) be
- deferred until anytime before the first function call. So it is
- OK if we don't see anything which sets lr1.
- To allow for alternate register sets (gcc -mkernel-registers) the msp
- register number is a compile time constant. */
-
- /* Normally this is just add lr1,gr1,<size * 4>. */
- insn = read_memory_integer (p, 4);
- if ((insn & 0xffffff00) == 0x15810100)
- p += 4;
- else
- {
- /* However, for large frames it can be
- const <reg>, <size *4>
- add lr1,gr1,<reg>
- */
- int reg;
- CORE_ADDR q;
-
- if ((insn & 0xff000000) == 0x03000000)
- {
- reg = (insn >> 8) & 0xff;
- q = p + 4;
- insn = read_memory_integer (q, 4);
- if ((insn & 0xffffff00) == 0x14810100
- && (insn & 0xff) == reg)
- p = q;
- }
- }
-
- /* Next comes "add lr{<rsize-1>},msp,0", but only if a memory
- frame pointer is in use. We just check for add lr<anything>,msp,0;
- we don't check this rsize against the first instruction, and
- we don't check that the trace-back tag indicates a memory frame pointer
- is in use.
- To allow for alternate register sets (gcc -mkernel-registers) the msp
- register number is a compile time constant.
-
- The recommended instruction is actually "sll lr<whatever>,msp,0".
- We check for that, too. Originally Jim Kingdon's code seemed
- to be looking for a "sub" instruction here, but the mask was set
- up to lose all the time. */
- insn = read_memory_integer (p, 4);
- if (((insn & 0xff80ffff) == (0x15800000 | (MSP_HW_REGNUM << 8))) /* add */
- || ((insn & 0xff80ffff) == (0x81800000 | (MSP_HW_REGNUM << 8)))) /* sll */
- {
- p += 4;
- if (mfp_used != NULL)
- *mfp_used = 1;
- }
-
- /* Next comes a subtraction from msp to allocate a memory frame,
- but only if a memory frame is
- being used. We don't check msize against the trace-back tag.
-
- To allow for alternate register sets (gcc -mkernel-registers) the msp
- register number is a compile time constant.
-
- Normally this is just
- sub msp,msp,<msize>
- */
- insn = read_memory_integer (p, 4);
- if ((insn & 0xffffff00) ==
- (0x25000000 | (MSP_HW_REGNUM << 16) | (MSP_HW_REGNUM << 8)))
- {
- p += 4;
- if (msize != NULL)
- *msize = insn & 0xff;
- }
- else
- {
- /* For large frames, instead of a single instruction it might
- be
-
- const <reg>, <msize>
- consth <reg>, <msize> ; optional
- sub msp,msp,<reg>
- */
- int reg;
- unsigned msize0;
- CORE_ADDR q = p;
-
- if ((insn & 0xff000000) == 0x03000000)
- {
- reg = (insn >> 8) & 0xff;
- msize0 = ((insn >> 8) & 0xff00) | (insn & 0xff);
- q += 4;
- insn = read_memory_integer (q, 4);
- /* Check for consth. */
- if ((insn & 0xff000000) == 0x02000000
- && (insn & 0x0000ff00) == reg)
- {
- msize0 |= (insn << 8) & 0xff000000;
- msize0 |= (insn << 16) & 0x00ff0000;
- q += 4;
- insn = read_memory_integer (q, 4);
- }
- /* Check for sub msp,msp,<reg>. */
- if ((insn & 0xffffff00) ==
- (0x24000000 | (MSP_HW_REGNUM << 16) | (MSP_HW_REGNUM << 8))
- && (insn & 0xff) == reg)
- {
- p = q + 4;
- if (msize != NULL)
- *msize = msize0;
- }
- }
- }
-
- /* Next instruction might be asgeu V_SPILL,gr1,rab.
- * We don't check the vector number to allow for kernel debugging. The
- * kernel will use a different trap number.
- * Metaware R2.3u compiler
- * generates prologue that intermixes initializations and puts the asgeu
- * way down after everything else.
- */
- insn = read_memory_integer (p, 4);
- if ((insn & 0xff00ffff) == (0x5e000100 | RAB_HW_REGNUM))
- {
- p += 4;
- }
-
-done:
- if (msymbol != NULL)
- {
- if (mi == 0)
- {
- /* Add a new cache entry. */
- mi = (struct prologue_info *) xmalloc (sizeof (struct prologue_info));
- msymbol->info = (char *) mi;
- mi->rsize_valid = 0;
- mi->msize_valid = 0;
- mi->mfp_valid = 0;
- }
- /* else, cache entry exists, but info is incomplete. */
- mi->pc = p;
- if (rsize != NULL)
- {
- mi->rsize = *rsize;
- mi->rsize_valid = 1;
- }
- if (msize != NULL)
- {
- mi->msize = *msize;
- mi->msize_valid = 1;
- }
- if (mfp_used != NULL)
- {
- mi->mfp_used = *mfp_used;
- mi->mfp_valid = 1;
- }
- }
- return p;
-}
-
-/* Advance PC across any function entry prologue instructions
- to reach some "real" code. */
-
-CORE_ADDR
-a29k_skip_prologue (CORE_ADDR pc)
-{
- return examine_prologue (pc, NULL, NULL, NULL);
-}
-
-/*
- * Examine the one or two word tag at the beginning of a function.
- * The tag word is expect to be at 'p', if it is not there, we fail
- * by returning 0. The documentation for the tag word was taken from
- * page 7-15 of the 29050 User's Manual. We are assuming that the
- * m bit is in bit 22 of the tag word, which seems to be the agreed upon
- * convention today (1/15/92).
- * msize is return in bytes.
- */
-
-static int /* 0/1 - failure/success of finding the tag word */
-examine_tag (CORE_ADDR p, int *is_trans, int *argcount, unsigned *msize,
- int *mfp_used)
-{
- unsigned int tag1, tag2;
-
- tag1 = read_memory_integer (p, 4);
- if ((tag1 & TAGWORD_ZERO_MASK) != 0) /* Not a tag word */
- return 0;
- if (tag1 & (1 << 23)) /* A two word tag */
- {
- tag2 = read_memory_integer (p - 4, 4);
- if (msize)
- *msize = tag2 * 2;
- }
- else
- /* A one word tag */
- {
- if (msize)
- *msize = tag1 & 0x7ff;
- }
- if (is_trans)
- *is_trans = ((tag1 & (1 << 21)) ? 1 : 0);
- /* Note that this includes the frame pointer and the return address
- register, so the actual number of registers of arguments is two less.
- argcount can be zero, however, sometimes, for strange assembler
- routines. */
- if (argcount)
- *argcount = (tag1 >> 16) & 0x1f;
- if (mfp_used)
- *mfp_used = ((tag1 & (1 << 22)) ? 1 : 0);
- return 1;
-}
-
-/* Initialize the frame. In addition to setting "extra" frame info,
- we also set ->frame because we use it in a nonstandard way, and ->pc
- because we need to know it to get the other stuff. See the diagram
- of stacks and the frame cache in tm-a29k.h for more detail. */
-
-static void
-init_frame_info (int innermost_frame, struct frame_info *frame)
-{
- CORE_ADDR p;
- long insn;
- unsigned rsize;
- unsigned msize;
- int mfp_used, trans;
- struct symbol *func;
-
- p = frame->pc;
-
- if (innermost_frame)
- frame->frame = read_register (GR1_REGNUM);
- else
- frame->frame = frame->next->frame + frame->next->rsize;
-
-#if 0 /* CALL_DUMMY_LOCATION == ON_STACK */
- This wont work;
-#else
- if (PC_IN_CALL_DUMMY (p, 0, 0))
-#endif
- {
- frame->rsize = DUMMY_FRAME_RSIZE;
- /* This doesn't matter since we never try to get locals or args
- from a dummy frame. */
- frame->msize = 0;
- /* Dummy frames always use a memory frame pointer. */
- frame->saved_msp =
- read_register_stack_integer (frame->frame + DUMMY_FRAME_RSIZE - 4, 4);
- frame->flags |= (TRANSPARENT_FRAME | MFP_USED);
- return;
- }
-
- func = find_pc_function (p);
- if (func != NULL)
- p = BLOCK_START (SYMBOL_BLOCK_VALUE (func));
- else
- {
- /* Search backward to find the trace-back tag. However,
- do not trace back beyond the start of the text segment
- (just as a sanity check to avoid going into never-never land). */
-#if 1
- while (p >= text_start
- && ((insn = read_memory_integer (p, 4)) & TAGWORD_ZERO_MASK) != 0)
- p -= 4;
-#else /* 0 */
- char pat[4] =
- {0, 0, 0, 0};
- char mask[4];
- char insn_raw[4];
- store_unsigned_integer (mask, 4, TAGWORD_ZERO_MASK);
- /* Enable this once target_search is enabled and tested. */
- target_search (4, pat, mask, p, -4, text_start, p + 1, &p, &insn_raw);
- insn = extract_unsigned_integer (insn_raw, 4);
-#endif /* 0 */
-
- if (p < text_start)
- {
- /* Couldn't find the trace-back tag.
- Something strange is going on. */
- frame->saved_msp = 0;
- frame->rsize = 0;
- frame->msize = 0;
- frame->flags = TRANSPARENT_FRAME;
- return;
- }
- else
- /* Advance to the first word of the function, i.e. the word
- after the trace-back tag. */
- p += 4;
- }
-
- /* We've found the start of the function.
- Try looking for a tag word that indicates whether there is a
- memory frame pointer and what the memory stack allocation is.
- If one doesn't exist, try using a more exhaustive search of
- the prologue. */
-
- if (examine_tag (p - 4, &trans, (int *) NULL, &msize, &mfp_used)) /* Found good tag */
- examine_prologue (p, &rsize, 0, 0);
- else /* No tag try prologue */
- examine_prologue (p, &rsize, &msize, &mfp_used);
-
- frame->rsize = rsize;
- frame->msize = msize;
- frame->flags = 0;
- if (mfp_used)
- frame->flags |= MFP_USED;
- if (trans)
- frame->flags |= TRANSPARENT_FRAME;
- if (innermost_frame)
- {
- frame->saved_msp = read_register (MSP_REGNUM) + msize;
- }
- else
- {
- if (mfp_used)
- frame->saved_msp =
- read_register_stack_integer (frame->frame + rsize - 4, 4);
- else
- frame->saved_msp = frame->next->saved_msp + msize;
- }
-}
-
-void
-init_extra_frame_info (struct frame_info *frame)
-{
- if (frame->next == 0)
- /* Assume innermost frame. May produce strange results for "info frame"
- but there isn't any way to tell the difference. */
- init_frame_info (1, frame);
- else
- {
- /* We're in get_prev_frame.
- Take care of everything in init_frame_pc. */
- ;
- }
-}
-
-void
-init_frame_pc (int fromleaf, struct frame_info *frame)
-{
- frame->pc = (fromleaf ? SAVED_PC_AFTER_CALL (frame->next) :
- frame->next ? FRAME_SAVED_PC (frame->next) : read_pc ());
- init_frame_info (fromleaf, frame);
-}
-\f
-/* Local variables (i.e. LOC_LOCAL) are on the memory stack, with their
- offsets being relative to the memory stack pointer (high C) or
- saved_msp (gcc). */
-
-CORE_ADDR
-frame_locals_address (struct frame_info *fi)
-{
- if (fi->flags & MFP_USED)
- return fi->saved_msp;
- else
- return fi->saved_msp - fi->msize;
-}
-\f
-/* Routines for reading the register stack. The caller gets to treat
- the register stack as a uniform stack in memory, from address $gr1
- straight through $rfb and beyond. */
-
-/* Analogous to read_memory except the length is understood to be 4.
- Also, myaddr can be NULL (meaning don't bother to read), and
- if actual_mem_addr is non-NULL, store there the address that it
- was fetched from (or if from a register the offset within
- registers). Set *LVAL to lval_memory or lval_register, depending
- on where it came from. The contents written into MYADDR are in
- target format. */
-void
-read_register_stack (CORE_ADDR memaddr, char *myaddr,
- CORE_ADDR *actual_mem_addr, enum lval_type *lval)
-{
- long rfb = read_register (RFB_REGNUM);
- long rsp = read_register (RSP_REGNUM);
-
- /* If we don't do this 'info register' stops in the middle. */
- if (memaddr >= rstack_high_address)
- {
- /* a bogus value */
- static char val[] =
- {~0, ~0, ~0, ~0};
- /* It's in a local register, but off the end of the stack. */
- int regnum = (memaddr - rsp) / 4 + LR0_REGNUM;
- if (myaddr != NULL)
- {
- /* Provide bogusness */
- memcpy (myaddr, val, 4);
- }
- supply_register (regnum, val); /* More bogusness */
- if (lval != NULL)
- *lval = lval_register;
- if (actual_mem_addr != NULL)
- *actual_mem_addr = REGISTER_BYTE (regnum);
- }
- /* If it's in the part of the register stack that's in real registers,
- get the value from the registers. If it's anywhere else in memory
- (e.g. in another thread's saved stack), skip this part and get
- it from real live memory. */
- else if (memaddr < rfb && memaddr >= rsp)
- {
- /* It's in a register. */
- int regnum = (memaddr - rsp) / 4 + LR0_REGNUM;
- if (regnum > LR0_REGNUM + 127)
- error ("Attempt to read register stack out of range.");
- if (myaddr != NULL)
- read_register_gen (regnum, myaddr);
- if (lval != NULL)
- *lval = lval_register;
- if (actual_mem_addr != NULL)
- *actual_mem_addr = REGISTER_BYTE (regnum);
- }
- else
- {
- /* It's in the memory portion of the register stack. */
- if (myaddr != NULL)
- read_memory (memaddr, myaddr, 4);
- if (lval != NULL)
- *lval = lval_memory;
- if (actual_mem_addr != NULL)
- *actual_mem_addr = memaddr;
- }
-}
-
-/* Analogous to read_memory_integer
- except the length is understood to be 4. */
-long
-read_register_stack_integer (CORE_ADDR memaddr, int len)
-{
- char buf[4];
- read_register_stack (memaddr, buf, NULL, NULL);
- return extract_signed_integer (buf, 4);
-}
-
-/* Copy 4 bytes from GDB memory at MYADDR into inferior memory
- at MEMADDR and put the actual address written into in
- *ACTUAL_MEM_ADDR. */
-static void
-write_register_stack (CORE_ADDR memaddr, char *myaddr,
- CORE_ADDR *actual_mem_addr)
-{
- long rfb = read_register (RFB_REGNUM);
- long rsp = read_register (RSP_REGNUM);
- /* If we don't do this 'info register' stops in the middle. */
- if (memaddr >= rstack_high_address)
- {
- /* It's in a register, but off the end of the stack. */
- if (actual_mem_addr != NULL)
- *actual_mem_addr = 0;
- }
- else if (memaddr < rfb)
- {
- /* It's in a register. */
- int regnum = (memaddr - rsp) / 4 + LR0_REGNUM;
- if (regnum < LR0_REGNUM || regnum > LR0_REGNUM + 127)
- error ("Attempt to read register stack out of range.");
- if (myaddr != NULL)
- write_register (regnum, *(long *) myaddr);
- if (actual_mem_addr != NULL)
- *actual_mem_addr = 0;
- }
- else
- {
- /* It's in the memory portion of the register stack. */
- if (myaddr != NULL)
- write_memory (memaddr, myaddr, 4);
- if (actual_mem_addr != NULL)
- *actual_mem_addr = memaddr;
- }
-}
-\f
-/* Find register number REGNUM relative to FRAME and put its
- (raw) contents in *RAW_BUFFER. Set *OPTIMIZED if the variable
- was optimized out (and thus can't be fetched). If the variable
- was fetched from memory, set *ADDRP to where it was fetched from,
- otherwise it was fetched from a register.
-
- The argument RAW_BUFFER must point to aligned memory. */
-
-void
-a29k_get_saved_register (char *raw_buffer, int *optimized, CORE_ADDR *addrp,
- struct frame_info *frame, int regnum,
- enum lval_type *lvalp)
-{
- struct frame_info *fi;
- CORE_ADDR addr;
- enum lval_type lval;
-
- if (!target_has_registers)
- error ("No registers.");
-
- /* Probably now redundant with the target_has_registers check. */
- if (frame == 0)
- return;
-
- /* Once something has a register number, it doesn't get optimized out. */
- if (optimized != NULL)
- *optimized = 0;
- if (regnum == RSP_REGNUM)
- {
- if (raw_buffer != NULL)
- {
- store_address (raw_buffer, REGISTER_RAW_SIZE (regnum), frame->frame);
- }
- if (lvalp != NULL)
- *lvalp = not_lval;
- return;
- }
- else if (regnum == PC_REGNUM && frame->next != NULL)
- {
- if (raw_buffer != NULL)
- {
- store_address (raw_buffer, REGISTER_RAW_SIZE (regnum), frame->pc);
- }
-
- /* Not sure we have to do this. */
- if (lvalp != NULL)
- *lvalp = not_lval;
-
- return;
- }
- else if (regnum == MSP_REGNUM)
- {
- if (raw_buffer != NULL)
- {
- if (frame->next != NULL)
- {
- store_address (raw_buffer, REGISTER_RAW_SIZE (regnum),
- frame->next->saved_msp);
- }
- else
- read_register_gen (MSP_REGNUM, raw_buffer);
- }
- /* The value may have been computed, not fetched. */
- if (lvalp != NULL)
- *lvalp = not_lval;
- return;
- }
- else if (regnum < LR0_REGNUM || regnum >= LR0_REGNUM + 128)
- {
- /* These registers are not saved over procedure calls,
- so just print out the current values. */
- if (raw_buffer != NULL)
- read_register_gen (regnum, raw_buffer);
- if (lvalp != NULL)
- *lvalp = lval_register;
- if (addrp != NULL)
- *addrp = REGISTER_BYTE (regnum);
- return;
- }
-
- addr = frame->frame + (regnum - LR0_REGNUM) * 4;
- if (raw_buffer != NULL)
- read_register_stack (addr, raw_buffer, &addr, &lval);
- if (lvalp != NULL)
- *lvalp = lval;
- if (addrp != NULL)
- *addrp = addr;
-}
-\f
-
-/* Discard from the stack the innermost frame,
- restoring all saved registers. */
-
-void
-pop_frame (void)
-{
- struct frame_info *frame = get_current_frame ();
- CORE_ADDR rfb = read_register (RFB_REGNUM);
- CORE_ADDR gr1 = frame->frame + frame->rsize;
- CORE_ADDR lr1;
- CORE_ADDR original_lr0;
- int must_fix_lr0 = 0;
- int i;
-
- /* If popping a dummy frame, need to restore registers. */
- if (PC_IN_CALL_DUMMY (read_register (PC_REGNUM),
- read_register (SP_REGNUM),
- FRAME_FP (frame)))
- {
- int lrnum = LR0_REGNUM + DUMMY_ARG / 4;
- for (i = 0; i < DUMMY_SAVE_SR128; ++i)
- write_register (SR_REGNUM (i + 128), read_register (lrnum++));
- for (i = 0; i < DUMMY_SAVE_SR160; ++i)
- write_register (SR_REGNUM (i + 160), read_register (lrnum++));
- for (i = 0; i < DUMMY_SAVE_GREGS; ++i)
- write_register (RETURN_REGNUM + i, read_register (lrnum++));
- /* Restore the PCs and prepare to restore LR0. */
- write_register (PC_REGNUM, read_register (lrnum++));
- write_register (NPC_REGNUM, read_register (lrnum++));
- write_register (PC2_REGNUM, read_register (lrnum++));
- original_lr0 = read_register (lrnum++);
- must_fix_lr0 = 1;
- }
-
- /* Restore the memory stack pointer. */
- write_register (MSP_REGNUM, frame->saved_msp);
- /* Restore the register stack pointer. */
- write_register (GR1_REGNUM, gr1);
-
- /* If we popped a dummy frame, restore lr0 now that gr1 has been restored. */
- if (must_fix_lr0)
- write_register (LR0_REGNUM, original_lr0);
-
- /* Check whether we need to fill registers. */
- lr1 = read_register (LR0_REGNUM + 1);
- if (lr1 > rfb)
- {
- /* Fill. */
- int num_bytes = lr1 - rfb;
- int i;
- long word;
-
- write_register (RAB_REGNUM, read_register (RAB_REGNUM) + num_bytes);
- write_register (RFB_REGNUM, lr1);
- for (i = 0; i < num_bytes; i += 4)
- {
- /* Note: word is in host byte order. */
- word = read_memory_integer (rfb + i, 4);
- write_register (LR0_REGNUM + ((rfb - gr1) % 0x80) + i / 4, word);
- }
- }
- flush_cached_frames ();
-}
-
-/* Push an empty stack frame, to record the current PC, etc. */
-
-void
-push_dummy_frame (void)
-{
- long w;
- CORE_ADDR rab, gr1;
- CORE_ADDR msp = read_register (MSP_REGNUM);
- int lrnum, i;
- CORE_ADDR original_lr0;
-
- /* Read original lr0 before changing gr1. This order isn't really needed
- since GDB happens to have a snapshot of all the regs and doesn't toss
- it when gr1 is changed. But it's The Right Thing To Do. */
- original_lr0 = read_register (LR0_REGNUM);
-
- /* Allocate the new frame. */
- gr1 = read_register (GR1_REGNUM) - DUMMY_FRAME_RSIZE;
- write_register (GR1_REGNUM, gr1);
-
-#ifdef VXWORKS_TARGET
- /* We force re-reading all registers to get the new local registers set
- after gr1 has been modified. This fix is due to the lack of single
- register read/write operation in the RPC interface between VxGDB and
- VxWorks. This really must be changed ! */
-
- vx_read_register (-1);
-
-#endif /* VXWORK_TARGET */
-
- rab = read_register (RAB_REGNUM);
- if (gr1 < rab)
- {
- /* We need to spill registers. */
- int num_bytes = rab - gr1;
- CORE_ADDR rfb = read_register (RFB_REGNUM);
- int i;
- long word;
-
- write_register (RFB_REGNUM, rfb - num_bytes);
- write_register (RAB_REGNUM, gr1);
- for (i = 0; i < num_bytes; i += 4)
- {
- /* Note: word is in target byte order. */
- read_register_gen (LR0_REGNUM + i / 4, (char *) &word);
- write_memory (rfb - num_bytes + i, (char *) &word, 4);
- }
- }
-
- /* There are no arguments in to the dummy frame, so we don't need
- more than rsize plus the return address and lr1. */
- write_register (LR0_REGNUM + 1, gr1 + DUMMY_FRAME_RSIZE + 2 * 4);
-
- /* Set the memory frame pointer. */
- write_register (LR0_REGNUM + DUMMY_FRAME_RSIZE / 4 - 1, msp);
-
- /* Allocate arg_slop. */
- write_register (MSP_REGNUM, msp - 16 * 4);
-
- /* Save registers. */
- lrnum = LR0_REGNUM + DUMMY_ARG / 4;
- for (i = 0; i < DUMMY_SAVE_SR128; ++i)
- write_register (lrnum++, read_register (SR_REGNUM (i + 128)));
- for (i = 0; i < DUMMY_SAVE_SR160; ++i)
- write_register (lrnum++, read_register (SR_REGNUM (i + 160)));
- for (i = 0; i < DUMMY_SAVE_GREGS; ++i)
- write_register (lrnum++, read_register (RETURN_REGNUM + i));
- /* Save the PCs and LR0. */
- write_register (lrnum++, read_register (PC_REGNUM));
- write_register (lrnum++, read_register (NPC_REGNUM));
- write_register (lrnum++, read_register (PC2_REGNUM));
-
- /* Why are we saving LR0? What would clobber it? (the dummy frame should
- be below it on the register stack, no?). */
- write_register (lrnum++, original_lr0);
-}
-
-
-
-/*
- This routine takes three arguments and makes the cached frames look
- as if these arguments defined a frame on the cache. This allows the
- rest of `info frame' to extract the important arguments without much
- difficulty. Since an individual frame on the 29K is determined by
- three values (FP, PC, and MSP), we really need all three to do a
- good job. */
-
-struct frame_info *
-setup_arbitrary_frame (int argc, CORE_ADDR *argv)
-{
- struct frame_info *frame;
-
- if (argc != 3)
- error ("AMD 29k frame specifications require three arguments: rsp pc msp");
-
- frame = create_new_frame (argv[0], argv[1]);
-
- if (!frame)
- internal_error (__FILE__, __LINE__,
- "create_new_frame returned invalid frame id");
-
- /* Creating a new frame munges the `frame' value from the current
- GR1, so we restore it again here. FIXME, untangle all this
- 29K frame stuff... */
- frame->frame = argv[0];
-
- /* Our MSP is in argv[2]. It'd be intelligent if we could just
- save this value in the FRAME. But the way it's set up (FIXME),
- we must save our caller's MSP. We compute that by adding our
- memory stack frame size to our MSP. */
- frame->saved_msp = argv[2] + frame->msize;
-
- return frame;
-}
-
-int
-gdb_print_insn_a29k (bfd_vma memaddr, disassemble_info *info)
-{
- if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG)
- return print_insn_big_a29k (memaddr, info);
- else
- return print_insn_little_a29k (memaddr, info);
-}
-
-enum a29k_processor_types processor_type = a29k_unknown;
-
-void
-a29k_get_processor_type (void)
-{
- unsigned int cfg_reg = (unsigned int) read_register (CFG_REGNUM);
-
- /* Most of these don't have freeze mode. */
- processor_type = a29k_no_freeze_mode;
-
- switch ((cfg_reg >> 28) & 0xf)
- {
- case 0:
- fprintf_filtered (gdb_stderr, "Remote debugging an Am29000");
- break;
- case 1:
- fprintf_filtered (gdb_stderr, "Remote debugging an Am29005");
- break;
- case 2:
- fprintf_filtered (gdb_stderr, "Remote debugging an Am29050");
- processor_type = a29k_freeze_mode;
- break;
- case 3:
- fprintf_filtered (gdb_stderr, "Remote debugging an Am29035");
- break;
- case 4:
- fprintf_filtered (gdb_stderr, "Remote debugging an Am29030");
- break;
- case 5:
- fprintf_filtered (gdb_stderr, "Remote debugging an Am2920*");
- break;
- case 6:
- fprintf_filtered (gdb_stderr, "Remote debugging an Am2924*");
- break;
- case 7:
- fprintf_filtered (gdb_stderr, "Remote debugging an Am29040");
- break;
- default:
- fprintf_filtered (gdb_stderr, "Remote debugging an unknown Am29k\n");
- /* Don't bother to print the revision. */
- return;
- }
- fprintf_filtered (gdb_stderr, " revision %c\n", 'A' + ((cfg_reg >> 24) & 0x0f));
-}
-
-#ifdef GET_LONGJMP_TARGET
-/* Figure out where the longjmp will land. We expect that we have just entered
- longjmp and haven't yet setup the stack frame, so the args are still in the
- output regs. lr2 (LR2_REGNUM) points at the jmp_buf structure from which we
- extract the pc (JB_PC) that we will land at. The pc is copied into ADDR.
- This routine returns true on success */
-
-int
-get_longjmp_target (CORE_ADDR *pc)
-{
- CORE_ADDR jb_addr;
- char buf[sizeof (CORE_ADDR)];
-
- jb_addr = read_register (LR2_REGNUM);
-
- if (target_read_memory (jb_addr + JB_PC * JB_ELEMENT_SIZE, (char *) buf,
- sizeof (CORE_ADDR)))
- return 0;
-
- *pc = extract_address ((PTR) buf, sizeof (CORE_ADDR));
- return 1;
-}
-#endif /* GET_LONGJMP_TARGET */
-
-void
-_initialize_a29k_tdep (void)
-{
- extern CORE_ADDR text_end;
-
- tm_print_insn = gdb_print_insn_a29k;
-
- /* FIXME, there should be a way to make a CORE_ADDR variable settable. */
- add_show_from_set
- (add_set_cmd ("rstack_high_address", class_support, var_uinteger,
- (char *) &rstack_high_address,
- "Set top address in memory of the register stack.\n\
-Attempts to access registers saved above this address will be ignored\n\
-or will produce the value -1.", &setlist),
- &showlist);
-
- /* FIXME, there should be a way to make a CORE_ADDR variable settable. */
- add_show_from_set
- (add_set_cmd ("call_scratch_address", class_support, var_uinteger,
- (char *) &text_end,
- "Set address in memory where small amounts of RAM can be used\n\
-when making function calls into the inferior.", &setlist),
- &showlist);
-}
+/* OBSOLETE /* Target-machine dependent code for the AMD 29000 */
+/* OBSOLETE Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, */
+/* OBSOLETE 2001 */
+/* OBSOLETE Free Software Foundation, Inc. */
+/* OBSOLETE Contributed by Cygnus Support. Written by Jim Kingdon. */
+/* OBSOLETE */
+/* OBSOLETE This file is part of GDB. */
+/* OBSOLETE */
+/* OBSOLETE This program is free software; you can redistribute it and/or modify */
+/* OBSOLETE it under the terms of the GNU General Public License as published by */
+/* OBSOLETE the Free Software Foundation; either version 2 of the License, or */
+/* OBSOLETE (at your option) any later version. */
+/* OBSOLETE */
+/* OBSOLETE This program is distributed in the hope that it will be useful, */
+/* OBSOLETE but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* OBSOLETE MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* OBSOLETE GNU General Public License for more details. */
+/* OBSOLETE */
+/* OBSOLETE You should have received a copy of the GNU General Public License */
+/* OBSOLETE along with this program; if not, write to the Free Software */
+/* OBSOLETE Foundation, Inc., 59 Temple Place - Suite 330, */
+/* OBSOLETE Boston, MA 02111-1307, USA. */ */
+/* OBSOLETE */
+/* OBSOLETE #include "defs.h" */
+/* OBSOLETE #include "gdbcore.h" */
+/* OBSOLETE #include "frame.h" */
+/* OBSOLETE #include "value.h" */
+/* OBSOLETE #include "symtab.h" */
+/* OBSOLETE #include "inferior.h" */
+/* OBSOLETE #include "gdbcmd.h" */
+/* OBSOLETE #include "regcache.h" */
+/* OBSOLETE */
+/* OBSOLETE /* If all these bits in an instruction word are zero, it is a "tag word" */
+/* OBSOLETE which precedes a function entry point and gives stack traceback info. */
+/* OBSOLETE This used to be defined as 0xff000000, but that treated 0x00000deb as */
+/* OBSOLETE a tag word, while it is really used as a breakpoint. */ */
+/* OBSOLETE #define TAGWORD_ZERO_MASK 0xff00f800 */
+/* OBSOLETE */
+/* OBSOLETE extern CORE_ADDR text_start; /* FIXME, kludge... */ */
+/* OBSOLETE */
+/* OBSOLETE /* The user-settable top of the register stack in virtual memory. We */
+/* OBSOLETE won't attempt to access any stored registers above this address, if set */
+/* OBSOLETE nonzero. */ */
+/* OBSOLETE */
+/* OBSOLETE static CORE_ADDR rstack_high_address = UINT_MAX; */
+/* OBSOLETE */
+/* OBSOLETE */
+/* OBSOLETE /* Should call_function allocate stack space for a struct return? */ */
+/* OBSOLETE /* On the a29k objects over 16 words require the caller to allocate space. */ */
+/* OBSOLETE int */
+/* OBSOLETE a29k_use_struct_convention (int gcc_p, struct type *type) */
+/* OBSOLETE { */
+/* OBSOLETE return (TYPE_LENGTH (type) > 16 * 4); */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE */
+/* OBSOLETE /* Structure to hold cached info about function prologues. */ */
+/* OBSOLETE */
+/* OBSOLETE struct prologue_info */
+/* OBSOLETE { */
+/* OBSOLETE CORE_ADDR pc; /* First addr after fn prologue */ */
+/* OBSOLETE unsigned rsize, msize; /* register stack frame size, mem stack ditto */ */
+/* OBSOLETE unsigned mfp_used:1; /* memory frame pointer used */ */
+/* OBSOLETE unsigned rsize_valid:1; /* Validity bits for the above */ */
+/* OBSOLETE unsigned msize_valid:1; */
+/* OBSOLETE unsigned mfp_valid:1; */
+/* OBSOLETE }; */
+/* OBSOLETE */
+/* OBSOLETE /* Examine the prologue of a function which starts at PC. Return */
+/* OBSOLETE the first addess past the prologue. If MSIZE is non-NULL, then */
+/* OBSOLETE set *MSIZE to the memory stack frame size. If RSIZE is non-NULL, */
+/* OBSOLETE then set *RSIZE to the register stack frame size (not including */
+/* OBSOLETE incoming arguments and the return address & frame pointer stored */
+/* OBSOLETE with them). If no prologue is found, *RSIZE is set to zero. */
+/* OBSOLETE If no prologue is found, or a prologue which doesn't involve */
+/* OBSOLETE allocating a memory stack frame, then set *MSIZE to zero. */
+/* OBSOLETE */
+/* OBSOLETE Note that both msize and rsize are in bytes. This is not consistent */
+/* OBSOLETE with the _User's Manual_ with respect to rsize, but it is much more */
+/* OBSOLETE convenient. */
+/* OBSOLETE */
+/* OBSOLETE If MFP_USED is non-NULL, *MFP_USED is set to nonzero if a memory */
+/* OBSOLETE frame pointer is being used. */ */
+/* OBSOLETE */
+/* OBSOLETE CORE_ADDR */
+/* OBSOLETE examine_prologue (CORE_ADDR pc, unsigned *rsize, unsigned *msize, int *mfp_used) */
+/* OBSOLETE { */
+/* OBSOLETE long insn; */
+/* OBSOLETE CORE_ADDR p = pc; */
+/* OBSOLETE struct minimal_symbol *msymbol = lookup_minimal_symbol_by_pc (pc); */
+/* OBSOLETE struct prologue_info *mi = 0; */
+/* OBSOLETE */
+/* OBSOLETE if (msymbol != NULL) */
+/* OBSOLETE mi = (struct prologue_info *) msymbol->info; */
+/* OBSOLETE */
+/* OBSOLETE if (mi != 0) */
+/* OBSOLETE { */
+/* OBSOLETE int valid = 1; */
+/* OBSOLETE if (rsize != NULL) */
+/* OBSOLETE { */
+/* OBSOLETE *rsize = mi->rsize; */
+/* OBSOLETE valid &= mi->rsize_valid; */
+/* OBSOLETE } */
+/* OBSOLETE if (msize != NULL) */
+/* OBSOLETE { */
+/* OBSOLETE *msize = mi->msize; */
+/* OBSOLETE valid &= mi->msize_valid; */
+/* OBSOLETE } */
+/* OBSOLETE if (mfp_used != NULL) */
+/* OBSOLETE { */
+/* OBSOLETE *mfp_used = mi->mfp_used; */
+/* OBSOLETE valid &= mi->mfp_valid; */
+/* OBSOLETE } */
+/* OBSOLETE if (valid) */
+/* OBSOLETE return mi->pc; */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE if (rsize != NULL) */
+/* OBSOLETE *rsize = 0; */
+/* OBSOLETE if (msize != NULL) */
+/* OBSOLETE *msize = 0; */
+/* OBSOLETE if (mfp_used != NULL) */
+/* OBSOLETE *mfp_used = 0; */
+/* OBSOLETE */
+/* OBSOLETE /* Prologue must start with subtracting a constant from gr1. */
+/* OBSOLETE Normally this is sub gr1,gr1,<rsize * 4>. */ */
+/* OBSOLETE insn = read_memory_integer (p, 4); */
+/* OBSOLETE if ((insn & 0xffffff00) != 0x25010100) */
+/* OBSOLETE { */
+/* OBSOLETE /* If the frame is large, instead of a single instruction it */
+/* OBSOLETE might be a pair of instructions: */
+/* OBSOLETE const <reg>, <rsize * 4> */
+/* OBSOLETE sub gr1,gr1,<reg> */
+/* OBSOLETE */ */
+/* OBSOLETE int reg; */
+/* OBSOLETE /* Possible value for rsize. */ */
+/* OBSOLETE unsigned int rsize0; */
+/* OBSOLETE */
+/* OBSOLETE if ((insn & 0xff000000) != 0x03000000) */
+/* OBSOLETE { */
+/* OBSOLETE p = pc; */
+/* OBSOLETE goto done; */
+/* OBSOLETE } */
+/* OBSOLETE reg = (insn >> 8) & 0xff; */
+/* OBSOLETE rsize0 = (((insn >> 8) & 0xff00) | (insn & 0xff)); */
+/* OBSOLETE p += 4; */
+/* OBSOLETE insn = read_memory_integer (p, 4); */
+/* OBSOLETE if ((insn & 0xffffff00) != 0x24010100 */
+/* OBSOLETE || (insn & 0xff) != reg) */
+/* OBSOLETE { */
+/* OBSOLETE p = pc; */
+/* OBSOLETE goto done; */
+/* OBSOLETE } */
+/* OBSOLETE if (rsize != NULL) */
+/* OBSOLETE *rsize = rsize0; */
+/* OBSOLETE } */
+/* OBSOLETE else */
+/* OBSOLETE { */
+/* OBSOLETE if (rsize != NULL) */
+/* OBSOLETE *rsize = (insn & 0xff); */
+/* OBSOLETE } */
+/* OBSOLETE p += 4; */
+/* OBSOLETE */
+/* OBSOLETE /* Next instruction ought to be asgeu V_SPILL,gr1,rab. */
+/* OBSOLETE * We don't check the vector number to allow for kernel debugging. The */
+/* OBSOLETE * kernel will use a different trap number. */
+/* OBSOLETE * If this insn is missing, we just keep going; Metaware R2.3u compiler */
+/* OBSOLETE * generates prologue that intermixes initializations and puts the asgeu */
+/* OBSOLETE * way down. */
+/* OBSOLETE */ */
+/* OBSOLETE insn = read_memory_integer (p, 4); */
+/* OBSOLETE if ((insn & 0xff00ffff) == (0x5e000100 | RAB_HW_REGNUM)) */
+/* OBSOLETE { */
+/* OBSOLETE p += 4; */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* Next instruction usually sets the frame pointer (lr1) by adding */
+/* OBSOLETE <size * 4> from gr1. However, this can (and high C does) be */
+/* OBSOLETE deferred until anytime before the first function call. So it is */
+/* OBSOLETE OK if we don't see anything which sets lr1. */
+/* OBSOLETE To allow for alternate register sets (gcc -mkernel-registers) the msp */
+/* OBSOLETE register number is a compile time constant. */ */
+/* OBSOLETE */
+/* OBSOLETE /* Normally this is just add lr1,gr1,<size * 4>. */ */
+/* OBSOLETE insn = read_memory_integer (p, 4); */
+/* OBSOLETE if ((insn & 0xffffff00) == 0x15810100) */
+/* OBSOLETE p += 4; */
+/* OBSOLETE else */
+/* OBSOLETE { */
+/* OBSOLETE /* However, for large frames it can be */
+/* OBSOLETE const <reg>, <size *4> */
+/* OBSOLETE add lr1,gr1,<reg> */
+/* OBSOLETE */ */
+/* OBSOLETE int reg; */
+/* OBSOLETE CORE_ADDR q; */
+/* OBSOLETE */
+/* OBSOLETE if ((insn & 0xff000000) == 0x03000000) */
+/* OBSOLETE { */
+/* OBSOLETE reg = (insn >> 8) & 0xff; */
+/* OBSOLETE q = p + 4; */
+/* OBSOLETE insn = read_memory_integer (q, 4); */
+/* OBSOLETE if ((insn & 0xffffff00) == 0x14810100 */
+/* OBSOLETE && (insn & 0xff) == reg) */
+/* OBSOLETE p = q; */
+/* OBSOLETE } */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* Next comes "add lr{<rsize-1>},msp,0", but only if a memory */
+/* OBSOLETE frame pointer is in use. We just check for add lr<anything>,msp,0; */
+/* OBSOLETE we don't check this rsize against the first instruction, and */
+/* OBSOLETE we don't check that the trace-back tag indicates a memory frame pointer */
+/* OBSOLETE is in use. */
+/* OBSOLETE To allow for alternate register sets (gcc -mkernel-registers) the msp */
+/* OBSOLETE register number is a compile time constant. */
+/* OBSOLETE */
+/* OBSOLETE The recommended instruction is actually "sll lr<whatever>,msp,0". */
+/* OBSOLETE We check for that, too. Originally Jim Kingdon's code seemed */
+/* OBSOLETE to be looking for a "sub" instruction here, but the mask was set */
+/* OBSOLETE up to lose all the time. */ */
+/* OBSOLETE insn = read_memory_integer (p, 4); */
+/* OBSOLETE if (((insn & 0xff80ffff) == (0x15800000 | (MSP_HW_REGNUM << 8))) /* add */ */
+/* OBSOLETE || ((insn & 0xff80ffff) == (0x81800000 | (MSP_HW_REGNUM << 8)))) /* sll */ */
+/* OBSOLETE { */
+/* OBSOLETE p += 4; */
+/* OBSOLETE if (mfp_used != NULL) */
+/* OBSOLETE *mfp_used = 1; */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* Next comes a subtraction from msp to allocate a memory frame, */
+/* OBSOLETE but only if a memory frame is */
+/* OBSOLETE being used. We don't check msize against the trace-back tag. */
+/* OBSOLETE */
+/* OBSOLETE To allow for alternate register sets (gcc -mkernel-registers) the msp */
+/* OBSOLETE register number is a compile time constant. */
+/* OBSOLETE */
+/* OBSOLETE Normally this is just */
+/* OBSOLETE sub msp,msp,<msize> */
+/* OBSOLETE */ */
+/* OBSOLETE insn = read_memory_integer (p, 4); */
+/* OBSOLETE if ((insn & 0xffffff00) == */
+/* OBSOLETE (0x25000000 | (MSP_HW_REGNUM << 16) | (MSP_HW_REGNUM << 8))) */
+/* OBSOLETE { */
+/* OBSOLETE p += 4; */
+/* OBSOLETE if (msize != NULL) */
+/* OBSOLETE *msize = insn & 0xff; */
+/* OBSOLETE } */
+/* OBSOLETE else */
+/* OBSOLETE { */
+/* OBSOLETE /* For large frames, instead of a single instruction it might */
+/* OBSOLETE be */
+/* OBSOLETE */
+/* OBSOLETE const <reg>, <msize> */
+/* OBSOLETE consth <reg>, <msize> ; optional */
+/* OBSOLETE sub msp,msp,<reg> */
+/* OBSOLETE */ */
+/* OBSOLETE int reg; */
+/* OBSOLETE unsigned msize0; */
+/* OBSOLETE CORE_ADDR q = p; */
+/* OBSOLETE */
+/* OBSOLETE if ((insn & 0xff000000) == 0x03000000) */
+/* OBSOLETE { */
+/* OBSOLETE reg = (insn >> 8) & 0xff; */
+/* OBSOLETE msize0 = ((insn >> 8) & 0xff00) | (insn & 0xff); */
+/* OBSOLETE q += 4; */
+/* OBSOLETE insn = read_memory_integer (q, 4); */
+/* OBSOLETE /* Check for consth. */ */
+/* OBSOLETE if ((insn & 0xff000000) == 0x02000000 */
+/* OBSOLETE && (insn & 0x0000ff00) == reg) */
+/* OBSOLETE { */
+/* OBSOLETE msize0 |= (insn << 8) & 0xff000000; */
+/* OBSOLETE msize0 |= (insn << 16) & 0x00ff0000; */
+/* OBSOLETE q += 4; */
+/* OBSOLETE insn = read_memory_integer (q, 4); */
+/* OBSOLETE } */
+/* OBSOLETE /* Check for sub msp,msp,<reg>. */ */
+/* OBSOLETE if ((insn & 0xffffff00) == */
+/* OBSOLETE (0x24000000 | (MSP_HW_REGNUM << 16) | (MSP_HW_REGNUM << 8)) */
+/* OBSOLETE && (insn & 0xff) == reg) */
+/* OBSOLETE { */
+/* OBSOLETE p = q + 4; */
+/* OBSOLETE if (msize != NULL) */
+/* OBSOLETE *msize = msize0; */
+/* OBSOLETE } */
+/* OBSOLETE } */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* Next instruction might be asgeu V_SPILL,gr1,rab. */
+/* OBSOLETE * We don't check the vector number to allow for kernel debugging. The */
+/* OBSOLETE * kernel will use a different trap number. */
+/* OBSOLETE * Metaware R2.3u compiler */
+/* OBSOLETE * generates prologue that intermixes initializations and puts the asgeu */
+/* OBSOLETE * way down after everything else. */
+/* OBSOLETE */ */
+/* OBSOLETE insn = read_memory_integer (p, 4); */
+/* OBSOLETE if ((insn & 0xff00ffff) == (0x5e000100 | RAB_HW_REGNUM)) */
+/* OBSOLETE { */
+/* OBSOLETE p += 4; */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE done: */
+/* OBSOLETE if (msymbol != NULL) */
+/* OBSOLETE { */
+/* OBSOLETE if (mi == 0) */
+/* OBSOLETE { */
+/* OBSOLETE /* Add a new cache entry. */ */
+/* OBSOLETE mi = (struct prologue_info *) xmalloc (sizeof (struct prologue_info)); */
+/* OBSOLETE msymbol->info = (char *) mi; */
+/* OBSOLETE mi->rsize_valid = 0; */
+/* OBSOLETE mi->msize_valid = 0; */
+/* OBSOLETE mi->mfp_valid = 0; */
+/* OBSOLETE } */
+/* OBSOLETE /* else, cache entry exists, but info is incomplete. */ */
+/* OBSOLETE mi->pc = p; */
+/* OBSOLETE if (rsize != NULL) */
+/* OBSOLETE { */
+/* OBSOLETE mi->rsize = *rsize; */
+/* OBSOLETE mi->rsize_valid = 1; */
+/* OBSOLETE } */
+/* OBSOLETE if (msize != NULL) */
+/* OBSOLETE { */
+/* OBSOLETE mi->msize = *msize; */
+/* OBSOLETE mi->msize_valid = 1; */
+/* OBSOLETE } */
+/* OBSOLETE if (mfp_used != NULL) */
+/* OBSOLETE { */
+/* OBSOLETE mi->mfp_used = *mfp_used; */
+/* OBSOLETE mi->mfp_valid = 1; */
+/* OBSOLETE } */
+/* OBSOLETE } */
+/* OBSOLETE return p; */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* Advance PC across any function entry prologue instructions */
+/* OBSOLETE to reach some "real" code. */ */
+/* OBSOLETE */
+/* OBSOLETE CORE_ADDR */
+/* OBSOLETE a29k_skip_prologue (CORE_ADDR pc) */
+/* OBSOLETE { */
+/* OBSOLETE return examine_prologue (pc, NULL, NULL, NULL); */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* */
+/* OBSOLETE * Examine the one or two word tag at the beginning of a function. */
+/* OBSOLETE * The tag word is expect to be at 'p', if it is not there, we fail */
+/* OBSOLETE * by returning 0. The documentation for the tag word was taken from */
+/* OBSOLETE * page 7-15 of the 29050 User's Manual. We are assuming that the */
+/* OBSOLETE * m bit is in bit 22 of the tag word, which seems to be the agreed upon */
+/* OBSOLETE * convention today (1/15/92). */
+/* OBSOLETE * msize is return in bytes. */
+/* OBSOLETE */ */
+/* OBSOLETE */
+/* OBSOLETE static int /* 0/1 - failure/success of finding the tag word */ */
+/* OBSOLETE examine_tag (CORE_ADDR p, int *is_trans, int *argcount, unsigned *msize, */
+/* OBSOLETE int *mfp_used) */
+/* OBSOLETE { */
+/* OBSOLETE unsigned int tag1, tag2; */
+/* OBSOLETE */
+/* OBSOLETE tag1 = read_memory_integer (p, 4); */
+/* OBSOLETE if ((tag1 & TAGWORD_ZERO_MASK) != 0) /* Not a tag word */ */
+/* OBSOLETE return 0; */
+/* OBSOLETE if (tag1 & (1 << 23)) /* A two word tag */ */
+/* OBSOLETE { */
+/* OBSOLETE tag2 = read_memory_integer (p - 4, 4); */
+/* OBSOLETE if (msize) */
+/* OBSOLETE *msize = tag2 * 2; */
+/* OBSOLETE } */
+/* OBSOLETE else */
+/* OBSOLETE /* A one word tag */ */
+/* OBSOLETE { */
+/* OBSOLETE if (msize) */
+/* OBSOLETE *msize = tag1 & 0x7ff; */
+/* OBSOLETE } */
+/* OBSOLETE if (is_trans) */
+/* OBSOLETE *is_trans = ((tag1 & (1 << 21)) ? 1 : 0); */
+/* OBSOLETE /* Note that this includes the frame pointer and the return address */
+/* OBSOLETE register, so the actual number of registers of arguments is two less. */
+/* OBSOLETE argcount can be zero, however, sometimes, for strange assembler */
+/* OBSOLETE routines. */ */
+/* OBSOLETE if (argcount) */
+/* OBSOLETE *argcount = (tag1 >> 16) & 0x1f; */
+/* OBSOLETE if (mfp_used) */
+/* OBSOLETE *mfp_used = ((tag1 & (1 << 22)) ? 1 : 0); */
+/* OBSOLETE return 1; */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* Initialize the frame. In addition to setting "extra" frame info, */
+/* OBSOLETE we also set ->frame because we use it in a nonstandard way, and ->pc */
+/* OBSOLETE because we need to know it to get the other stuff. See the diagram */
+/* OBSOLETE of stacks and the frame cache in tm-a29k.h for more detail. */ */
+/* OBSOLETE */
+/* OBSOLETE static void */
+/* OBSOLETE init_frame_info (int innermost_frame, struct frame_info *frame) */
+/* OBSOLETE { */
+/* OBSOLETE CORE_ADDR p; */
+/* OBSOLETE long insn; */
+/* OBSOLETE unsigned rsize; */
+/* OBSOLETE unsigned msize; */
+/* OBSOLETE int mfp_used, trans; */
+/* OBSOLETE struct symbol *func; */
+/* OBSOLETE */
+/* OBSOLETE p = frame->pc; */
+/* OBSOLETE */
+/* OBSOLETE if (innermost_frame) */
+/* OBSOLETE frame->frame = read_register (GR1_REGNUM); */
+/* OBSOLETE else */
+/* OBSOLETE frame->frame = frame->next->frame + frame->next->rsize; */
+/* OBSOLETE */
+/* OBSOLETE #if 0 /* CALL_DUMMY_LOCATION == ON_STACK */ */
+/* OBSOLETE This wont work; */
+/* OBSOLETE #else */
+/* OBSOLETE if (PC_IN_CALL_DUMMY (p, 0, 0)) */
+/* OBSOLETE #endif */
+/* OBSOLETE { */
+/* OBSOLETE frame->rsize = DUMMY_FRAME_RSIZE; */
+/* OBSOLETE /* This doesn't matter since we never try to get locals or args */
+/* OBSOLETE from a dummy frame. */ */
+/* OBSOLETE frame->msize = 0; */
+/* OBSOLETE /* Dummy frames always use a memory frame pointer. */ */
+/* OBSOLETE frame->saved_msp = */
+/* OBSOLETE read_register_stack_integer (frame->frame + DUMMY_FRAME_RSIZE - 4, 4); */
+/* OBSOLETE frame->flags |= (TRANSPARENT_FRAME | MFP_USED); */
+/* OBSOLETE return; */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE func = find_pc_function (p); */
+/* OBSOLETE if (func != NULL) */
+/* OBSOLETE p = BLOCK_START (SYMBOL_BLOCK_VALUE (func)); */
+/* OBSOLETE else */
+/* OBSOLETE { */
+/* OBSOLETE /* Search backward to find the trace-back tag. However, */
+/* OBSOLETE do not trace back beyond the start of the text segment */
+/* OBSOLETE (just as a sanity check to avoid going into never-never land). */ */
+/* OBSOLETE #if 1 */
+/* OBSOLETE while (p >= text_start */
+/* OBSOLETE && ((insn = read_memory_integer (p, 4)) & TAGWORD_ZERO_MASK) != 0) */
+/* OBSOLETE p -= 4; */
+/* OBSOLETE #else /* 0 */ */
+/* OBSOLETE char pat[4] = */
+/* OBSOLETE {0, 0, 0, 0}; */
+/* OBSOLETE char mask[4]; */
+/* OBSOLETE char insn_raw[4]; */
+/* OBSOLETE store_unsigned_integer (mask, 4, TAGWORD_ZERO_MASK); */
+/* OBSOLETE /* Enable this once target_search is enabled and tested. */ */
+/* OBSOLETE target_search (4, pat, mask, p, -4, text_start, p + 1, &p, &insn_raw); */
+/* OBSOLETE insn = extract_unsigned_integer (insn_raw, 4); */
+/* OBSOLETE #endif /* 0 */ */
+/* OBSOLETE */
+/* OBSOLETE if (p < text_start) */
+/* OBSOLETE { */
+/* OBSOLETE /* Couldn't find the trace-back tag. */
+/* OBSOLETE Something strange is going on. */ */
+/* OBSOLETE frame->saved_msp = 0; */
+/* OBSOLETE frame->rsize = 0; */
+/* OBSOLETE frame->msize = 0; */
+/* OBSOLETE frame->flags = TRANSPARENT_FRAME; */
+/* OBSOLETE return; */
+/* OBSOLETE } */
+/* OBSOLETE else */
+/* OBSOLETE /* Advance to the first word of the function, i.e. the word */
+/* OBSOLETE after the trace-back tag. */ */
+/* OBSOLETE p += 4; */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* We've found the start of the function. */
+/* OBSOLETE Try looking for a tag word that indicates whether there is a */
+/* OBSOLETE memory frame pointer and what the memory stack allocation is. */
+/* OBSOLETE If one doesn't exist, try using a more exhaustive search of */
+/* OBSOLETE the prologue. */ */
+/* OBSOLETE */
+/* OBSOLETE if (examine_tag (p - 4, &trans, (int *) NULL, &msize, &mfp_used)) /* Found good tag */ */
+/* OBSOLETE examine_prologue (p, &rsize, 0, 0); */
+/* OBSOLETE else /* No tag try prologue */ */
+/* OBSOLETE examine_prologue (p, &rsize, &msize, &mfp_used); */
+/* OBSOLETE */
+/* OBSOLETE frame->rsize = rsize; */
+/* OBSOLETE frame->msize = msize; */
+/* OBSOLETE frame->flags = 0; */
+/* OBSOLETE if (mfp_used) */
+/* OBSOLETE frame->flags |= MFP_USED; */
+/* OBSOLETE if (trans) */
+/* OBSOLETE frame->flags |= TRANSPARENT_FRAME; */
+/* OBSOLETE if (innermost_frame) */
+/* OBSOLETE { */
+/* OBSOLETE frame->saved_msp = read_register (MSP_REGNUM) + msize; */
+/* OBSOLETE } */
+/* OBSOLETE else */
+/* OBSOLETE { */
+/* OBSOLETE if (mfp_used) */
+/* OBSOLETE frame->saved_msp = */
+/* OBSOLETE read_register_stack_integer (frame->frame + rsize - 4, 4); */
+/* OBSOLETE else */
+/* OBSOLETE frame->saved_msp = frame->next->saved_msp + msize; */
+/* OBSOLETE } */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE void */
+/* OBSOLETE init_extra_frame_info (struct frame_info *frame) */
+/* OBSOLETE { */
+/* OBSOLETE if (frame->next == 0) */
+/* OBSOLETE /* Assume innermost frame. May produce strange results for "info frame" */
+/* OBSOLETE but there isn't any way to tell the difference. */ */
+/* OBSOLETE init_frame_info (1, frame); */
+/* OBSOLETE else */
+/* OBSOLETE { */
+/* OBSOLETE /* We're in get_prev_frame. */
+/* OBSOLETE Take care of everything in init_frame_pc. */ */
+/* OBSOLETE ; */
+/* OBSOLETE } */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE void */
+/* OBSOLETE init_frame_pc (int fromleaf, struct frame_info *frame) */
+/* OBSOLETE { */
+/* OBSOLETE frame->pc = (fromleaf ? SAVED_PC_AFTER_CALL (frame->next) : */
+/* OBSOLETE frame->next ? FRAME_SAVED_PC (frame->next) : read_pc ()); */
+/* OBSOLETE init_frame_info (fromleaf, frame); */
+/* OBSOLETE } */
+/* OBSOLETE \f */
+/* OBSOLETE /* Local variables (i.e. LOC_LOCAL) are on the memory stack, with their */
+/* OBSOLETE offsets being relative to the memory stack pointer (high C) or */
+/* OBSOLETE saved_msp (gcc). */ */
+/* OBSOLETE */
+/* OBSOLETE CORE_ADDR */
+/* OBSOLETE frame_locals_address (struct frame_info *fi) */
+/* OBSOLETE { */
+/* OBSOLETE if (fi->flags & MFP_USED) */
+/* OBSOLETE return fi->saved_msp; */
+/* OBSOLETE else */
+/* OBSOLETE return fi->saved_msp - fi->msize; */
+/* OBSOLETE } */
+/* OBSOLETE \f */
+/* OBSOLETE /* Routines for reading the register stack. The caller gets to treat */
+/* OBSOLETE the register stack as a uniform stack in memory, from address $gr1 */
+/* OBSOLETE straight through $rfb and beyond. */ */
+/* OBSOLETE */
+/* OBSOLETE /* Analogous to read_memory except the length is understood to be 4. */
+/* OBSOLETE Also, myaddr can be NULL (meaning don't bother to read), and */
+/* OBSOLETE if actual_mem_addr is non-NULL, store there the address that it */
+/* OBSOLETE was fetched from (or if from a register the offset within */
+/* OBSOLETE registers). Set *LVAL to lval_memory or lval_register, depending */
+/* OBSOLETE on where it came from. The contents written into MYADDR are in */
+/* OBSOLETE target format. */ */
+/* OBSOLETE void */
+/* OBSOLETE read_register_stack (CORE_ADDR memaddr, char *myaddr, */
+/* OBSOLETE CORE_ADDR *actual_mem_addr, enum lval_type *lval) */
+/* OBSOLETE { */
+/* OBSOLETE long rfb = read_register (RFB_REGNUM); */
+/* OBSOLETE long rsp = read_register (RSP_REGNUM); */
+/* OBSOLETE */
+/* OBSOLETE /* If we don't do this 'info register' stops in the middle. */ */
+/* OBSOLETE if (memaddr >= rstack_high_address) */
+/* OBSOLETE { */
+/* OBSOLETE /* a bogus value */ */
+/* OBSOLETE static char val[] = */
+/* OBSOLETE {~0, ~0, ~0, ~0}; */
+/* OBSOLETE /* It's in a local register, but off the end of the stack. */ */
+/* OBSOLETE int regnum = (memaddr - rsp) / 4 + LR0_REGNUM; */
+/* OBSOLETE if (myaddr != NULL) */
+/* OBSOLETE { */
+/* OBSOLETE /* Provide bogusness */ */
+/* OBSOLETE memcpy (myaddr, val, 4); */
+/* OBSOLETE } */
+/* OBSOLETE supply_register (regnum, val); /* More bogusness */ */
+/* OBSOLETE if (lval != NULL) */
+/* OBSOLETE *lval = lval_register; */
+/* OBSOLETE if (actual_mem_addr != NULL) */
+/* OBSOLETE *actual_mem_addr = REGISTER_BYTE (regnum); */
+/* OBSOLETE } */
+/* OBSOLETE /* If it's in the part of the register stack that's in real registers, */
+/* OBSOLETE get the value from the registers. If it's anywhere else in memory */
+/* OBSOLETE (e.g. in another thread's saved stack), skip this part and get */
+/* OBSOLETE it from real live memory. */ */
+/* OBSOLETE else if (memaddr < rfb && memaddr >= rsp) */
+/* OBSOLETE { */
+/* OBSOLETE /* It's in a register. */ */
+/* OBSOLETE int regnum = (memaddr - rsp) / 4 + LR0_REGNUM; */
+/* OBSOLETE if (regnum > LR0_REGNUM + 127) */
+/* OBSOLETE error ("Attempt to read register stack out of range."); */
+/* OBSOLETE if (myaddr != NULL) */
+/* OBSOLETE read_register_gen (regnum, myaddr); */
+/* OBSOLETE if (lval != NULL) */
+/* OBSOLETE *lval = lval_register; */
+/* OBSOLETE if (actual_mem_addr != NULL) */
+/* OBSOLETE *actual_mem_addr = REGISTER_BYTE (regnum); */
+/* OBSOLETE } */
+/* OBSOLETE else */
+/* OBSOLETE { */
+/* OBSOLETE /* It's in the memory portion of the register stack. */ */
+/* OBSOLETE if (myaddr != NULL) */
+/* OBSOLETE read_memory (memaddr, myaddr, 4); */
+/* OBSOLETE if (lval != NULL) */
+/* OBSOLETE *lval = lval_memory; */
+/* OBSOLETE if (actual_mem_addr != NULL) */
+/* OBSOLETE *actual_mem_addr = memaddr; */
+/* OBSOLETE } */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* Analogous to read_memory_integer */
+/* OBSOLETE except the length is understood to be 4. */ */
+/* OBSOLETE long */
+/* OBSOLETE read_register_stack_integer (CORE_ADDR memaddr, int len) */
+/* OBSOLETE { */
+/* OBSOLETE char buf[4]; */
+/* OBSOLETE read_register_stack (memaddr, buf, NULL, NULL); */
+/* OBSOLETE return extract_signed_integer (buf, 4); */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* Copy 4 bytes from GDB memory at MYADDR into inferior memory */
+/* OBSOLETE at MEMADDR and put the actual address written into in */
+/* OBSOLETE *ACTUAL_MEM_ADDR. */ */
+/* OBSOLETE static void */
+/* OBSOLETE write_register_stack (CORE_ADDR memaddr, char *myaddr, */
+/* OBSOLETE CORE_ADDR *actual_mem_addr) */
+/* OBSOLETE { */
+/* OBSOLETE long rfb = read_register (RFB_REGNUM); */
+/* OBSOLETE long rsp = read_register (RSP_REGNUM); */
+/* OBSOLETE /* If we don't do this 'info register' stops in the middle. */ */
+/* OBSOLETE if (memaddr >= rstack_high_address) */
+/* OBSOLETE { */
+/* OBSOLETE /* It's in a register, but off the end of the stack. */ */
+/* OBSOLETE if (actual_mem_addr != NULL) */
+/* OBSOLETE *actual_mem_addr = 0; */
+/* OBSOLETE } */
+/* OBSOLETE else if (memaddr < rfb) */
+/* OBSOLETE { */
+/* OBSOLETE /* It's in a register. */ */
+/* OBSOLETE int regnum = (memaddr - rsp) / 4 + LR0_REGNUM; */
+/* OBSOLETE if (regnum < LR0_REGNUM || regnum > LR0_REGNUM + 127) */
+/* OBSOLETE error ("Attempt to read register stack out of range."); */
+/* OBSOLETE if (myaddr != NULL) */
+/* OBSOLETE write_register (regnum, *(long *) myaddr); */
+/* OBSOLETE if (actual_mem_addr != NULL) */
+/* OBSOLETE *actual_mem_addr = 0; */
+/* OBSOLETE } */
+/* OBSOLETE else */
+/* OBSOLETE { */
+/* OBSOLETE /* It's in the memory portion of the register stack. */ */
+/* OBSOLETE if (myaddr != NULL) */
+/* OBSOLETE write_memory (memaddr, myaddr, 4); */
+/* OBSOLETE if (actual_mem_addr != NULL) */
+/* OBSOLETE *actual_mem_addr = memaddr; */
+/* OBSOLETE } */
+/* OBSOLETE } */
+/* OBSOLETE \f */
+/* OBSOLETE /* Find register number REGNUM relative to FRAME and put its */
+/* OBSOLETE (raw) contents in *RAW_BUFFER. Set *OPTIMIZED if the variable */
+/* OBSOLETE was optimized out (and thus can't be fetched). If the variable */
+/* OBSOLETE was fetched from memory, set *ADDRP to where it was fetched from, */
+/* OBSOLETE otherwise it was fetched from a register. */
+/* OBSOLETE */
+/* OBSOLETE The argument RAW_BUFFER must point to aligned memory. */ */
+/* OBSOLETE */
+/* OBSOLETE void */
+/* OBSOLETE a29k_get_saved_register (char *raw_buffer, int *optimized, CORE_ADDR *addrp, */
+/* OBSOLETE struct frame_info *frame, int regnum, */
+/* OBSOLETE enum lval_type *lvalp) */
+/* OBSOLETE { */
+/* OBSOLETE struct frame_info *fi; */
+/* OBSOLETE CORE_ADDR addr; */
+/* OBSOLETE enum lval_type lval; */
+/* OBSOLETE */
+/* OBSOLETE if (!target_has_registers) */
+/* OBSOLETE error ("No registers."); */
+/* OBSOLETE */
+/* OBSOLETE /* Probably now redundant with the target_has_registers check. */ */
+/* OBSOLETE if (frame == 0) */
+/* OBSOLETE return; */
+/* OBSOLETE */
+/* OBSOLETE /* Once something has a register number, it doesn't get optimized out. */ */
+/* OBSOLETE if (optimized != NULL) */
+/* OBSOLETE *optimized = 0; */
+/* OBSOLETE if (regnum == RSP_REGNUM) */
+/* OBSOLETE { */
+/* OBSOLETE if (raw_buffer != NULL) */
+/* OBSOLETE { */
+/* OBSOLETE store_address (raw_buffer, REGISTER_RAW_SIZE (regnum), frame->frame); */
+/* OBSOLETE } */
+/* OBSOLETE if (lvalp != NULL) */
+/* OBSOLETE *lvalp = not_lval; */
+/* OBSOLETE return; */
+/* OBSOLETE } */
+/* OBSOLETE else if (regnum == PC_REGNUM && frame->next != NULL) */
+/* OBSOLETE { */
+/* OBSOLETE if (raw_buffer != NULL) */
+/* OBSOLETE { */
+/* OBSOLETE store_address (raw_buffer, REGISTER_RAW_SIZE (regnum), frame->pc); */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* Not sure we have to do this. */ */
+/* OBSOLETE if (lvalp != NULL) */
+/* OBSOLETE *lvalp = not_lval; */
+/* OBSOLETE */
+/* OBSOLETE return; */
+/* OBSOLETE } */
+/* OBSOLETE else if (regnum == MSP_REGNUM) */
+/* OBSOLETE { */
+/* OBSOLETE if (raw_buffer != NULL) */
+/* OBSOLETE { */
+/* OBSOLETE if (frame->next != NULL) */
+/* OBSOLETE { */
+/* OBSOLETE store_address (raw_buffer, REGISTER_RAW_SIZE (regnum), */
+/* OBSOLETE frame->next->saved_msp); */
+/* OBSOLETE } */
+/* OBSOLETE else */
+/* OBSOLETE read_register_gen (MSP_REGNUM, raw_buffer); */
+/* OBSOLETE } */
+/* OBSOLETE /* The value may have been computed, not fetched. */ */
+/* OBSOLETE if (lvalp != NULL) */
+/* OBSOLETE *lvalp = not_lval; */
+/* OBSOLETE return; */
+/* OBSOLETE } */
+/* OBSOLETE else if (regnum < LR0_REGNUM || regnum >= LR0_REGNUM + 128) */
+/* OBSOLETE { */
+/* OBSOLETE /* These registers are not saved over procedure calls, */
+/* OBSOLETE so just print out the current values. */ */
+/* OBSOLETE if (raw_buffer != NULL) */
+/* OBSOLETE read_register_gen (regnum, raw_buffer); */
+/* OBSOLETE if (lvalp != NULL) */
+/* OBSOLETE *lvalp = lval_register; */
+/* OBSOLETE if (addrp != NULL) */
+/* OBSOLETE *addrp = REGISTER_BYTE (regnum); */
+/* OBSOLETE return; */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE addr = frame->frame + (regnum - LR0_REGNUM) * 4; */
+/* OBSOLETE if (raw_buffer != NULL) */
+/* OBSOLETE read_register_stack (addr, raw_buffer, &addr, &lval); */
+/* OBSOLETE if (lvalp != NULL) */
+/* OBSOLETE *lvalp = lval; */
+/* OBSOLETE if (addrp != NULL) */
+/* OBSOLETE *addrp = addr; */
+/* OBSOLETE } */
+/* OBSOLETE \f */
+/* OBSOLETE */
+/* OBSOLETE /* Discard from the stack the innermost frame, */
+/* OBSOLETE restoring all saved registers. */ */
+/* OBSOLETE */
+/* OBSOLETE void */
+/* OBSOLETE pop_frame (void) */
+/* OBSOLETE { */
+/* OBSOLETE struct frame_info *frame = get_current_frame (); */
+/* OBSOLETE CORE_ADDR rfb = read_register (RFB_REGNUM); */
+/* OBSOLETE CORE_ADDR gr1 = frame->frame + frame->rsize; */
+/* OBSOLETE CORE_ADDR lr1; */
+/* OBSOLETE CORE_ADDR original_lr0; */
+/* OBSOLETE int must_fix_lr0 = 0; */
+/* OBSOLETE int i; */
+/* OBSOLETE */
+/* OBSOLETE /* If popping a dummy frame, need to restore registers. */ */
+/* OBSOLETE if (PC_IN_CALL_DUMMY (read_register (PC_REGNUM), */
+/* OBSOLETE read_register (SP_REGNUM), */
+/* OBSOLETE FRAME_FP (frame))) */
+/* OBSOLETE { */
+/* OBSOLETE int lrnum = LR0_REGNUM + DUMMY_ARG / 4; */
+/* OBSOLETE for (i = 0; i < DUMMY_SAVE_SR128; ++i) */
+/* OBSOLETE write_register (SR_REGNUM (i + 128), read_register (lrnum++)); */
+/* OBSOLETE for (i = 0; i < DUMMY_SAVE_SR160; ++i) */
+/* OBSOLETE write_register (SR_REGNUM (i + 160), read_register (lrnum++)); */
+/* OBSOLETE for (i = 0; i < DUMMY_SAVE_GREGS; ++i) */
+/* OBSOLETE write_register (RETURN_REGNUM + i, read_register (lrnum++)); */
+/* OBSOLETE /* Restore the PCs and prepare to restore LR0. */ */
+/* OBSOLETE write_register (PC_REGNUM, read_register (lrnum++)); */
+/* OBSOLETE write_register (NPC_REGNUM, read_register (lrnum++)); */
+/* OBSOLETE write_register (PC2_REGNUM, read_register (lrnum++)); */
+/* OBSOLETE original_lr0 = read_register (lrnum++); */
+/* OBSOLETE must_fix_lr0 = 1; */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* Restore the memory stack pointer. */ */
+/* OBSOLETE write_register (MSP_REGNUM, frame->saved_msp); */
+/* OBSOLETE /* Restore the register stack pointer. */ */
+/* OBSOLETE write_register (GR1_REGNUM, gr1); */
+/* OBSOLETE */
+/* OBSOLETE /* If we popped a dummy frame, restore lr0 now that gr1 has been restored. */ */
+/* OBSOLETE if (must_fix_lr0) */
+/* OBSOLETE write_register (LR0_REGNUM, original_lr0); */
+/* OBSOLETE */
+/* OBSOLETE /* Check whether we need to fill registers. */ */
+/* OBSOLETE lr1 = read_register (LR0_REGNUM + 1); */
+/* OBSOLETE if (lr1 > rfb) */
+/* OBSOLETE { */
+/* OBSOLETE /* Fill. */ */
+/* OBSOLETE int num_bytes = lr1 - rfb; */
+/* OBSOLETE int i; */
+/* OBSOLETE long word; */
+/* OBSOLETE */
+/* OBSOLETE write_register (RAB_REGNUM, read_register (RAB_REGNUM) + num_bytes); */
+/* OBSOLETE write_register (RFB_REGNUM, lr1); */
+/* OBSOLETE for (i = 0; i < num_bytes; i += 4) */
+/* OBSOLETE { */
+/* OBSOLETE /* Note: word is in host byte order. */ */
+/* OBSOLETE word = read_memory_integer (rfb + i, 4); */
+/* OBSOLETE write_register (LR0_REGNUM + ((rfb - gr1) % 0x80) + i / 4, word); */
+/* OBSOLETE } */
+/* OBSOLETE } */
+/* OBSOLETE flush_cached_frames (); */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* Push an empty stack frame, to record the current PC, etc. */ */
+/* OBSOLETE */
+/* OBSOLETE void */
+/* OBSOLETE push_dummy_frame (void) */
+/* OBSOLETE { */
+/* OBSOLETE long w; */
+/* OBSOLETE CORE_ADDR rab, gr1; */
+/* OBSOLETE CORE_ADDR msp = read_register (MSP_REGNUM); */
+/* OBSOLETE int lrnum, i; */
+/* OBSOLETE CORE_ADDR original_lr0; */
+/* OBSOLETE */
+/* OBSOLETE /* Read original lr0 before changing gr1. This order isn't really needed */
+/* OBSOLETE since GDB happens to have a snapshot of all the regs and doesn't toss */
+/* OBSOLETE it when gr1 is changed. But it's The Right Thing To Do. */ */
+/* OBSOLETE original_lr0 = read_register (LR0_REGNUM); */
+/* OBSOLETE */
+/* OBSOLETE /* Allocate the new frame. */ */
+/* OBSOLETE gr1 = read_register (GR1_REGNUM) - DUMMY_FRAME_RSIZE; */
+/* OBSOLETE write_register (GR1_REGNUM, gr1); */
+/* OBSOLETE */
+/* OBSOLETE #ifdef VXWORKS_TARGET */
+/* OBSOLETE /* We force re-reading all registers to get the new local registers set */
+/* OBSOLETE after gr1 has been modified. This fix is due to the lack of single */
+/* OBSOLETE register read/write operation in the RPC interface between VxGDB and */
+/* OBSOLETE VxWorks. This really must be changed ! */ */
+/* OBSOLETE */
+/* OBSOLETE vx_read_register (-1); */
+/* OBSOLETE */
+/* OBSOLETE #endif /* VXWORK_TARGET */ */
+/* OBSOLETE */
+/* OBSOLETE rab = read_register (RAB_REGNUM); */
+/* OBSOLETE if (gr1 < rab) */
+/* OBSOLETE { */
+/* OBSOLETE /* We need to spill registers. */ */
+/* OBSOLETE int num_bytes = rab - gr1; */
+/* OBSOLETE CORE_ADDR rfb = read_register (RFB_REGNUM); */
+/* OBSOLETE int i; */
+/* OBSOLETE long word; */
+/* OBSOLETE */
+/* OBSOLETE write_register (RFB_REGNUM, rfb - num_bytes); */
+/* OBSOLETE write_register (RAB_REGNUM, gr1); */
+/* OBSOLETE for (i = 0; i < num_bytes; i += 4) */
+/* OBSOLETE { */
+/* OBSOLETE /* Note: word is in target byte order. */ */
+/* OBSOLETE read_register_gen (LR0_REGNUM + i / 4, (char *) &word); */
+/* OBSOLETE write_memory (rfb - num_bytes + i, (char *) &word, 4); */
+/* OBSOLETE } */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* There are no arguments in to the dummy frame, so we don't need */
+/* OBSOLETE more than rsize plus the return address and lr1. */ */
+/* OBSOLETE write_register (LR0_REGNUM + 1, gr1 + DUMMY_FRAME_RSIZE + 2 * 4); */
+/* OBSOLETE */
+/* OBSOLETE /* Set the memory frame pointer. */ */
+/* OBSOLETE write_register (LR0_REGNUM + DUMMY_FRAME_RSIZE / 4 - 1, msp); */
+/* OBSOLETE */
+/* OBSOLETE /* Allocate arg_slop. */ */
+/* OBSOLETE write_register (MSP_REGNUM, msp - 16 * 4); */
+/* OBSOLETE */
+/* OBSOLETE /* Save registers. */ */
+/* OBSOLETE lrnum = LR0_REGNUM + DUMMY_ARG / 4; */
+/* OBSOLETE for (i = 0; i < DUMMY_SAVE_SR128; ++i) */
+/* OBSOLETE write_register (lrnum++, read_register (SR_REGNUM (i + 128))); */
+/* OBSOLETE for (i = 0; i < DUMMY_SAVE_SR160; ++i) */
+/* OBSOLETE write_register (lrnum++, read_register (SR_REGNUM (i + 160))); */
+/* OBSOLETE for (i = 0; i < DUMMY_SAVE_GREGS; ++i) */
+/* OBSOLETE write_register (lrnum++, read_register (RETURN_REGNUM + i)); */
+/* OBSOLETE /* Save the PCs and LR0. */ */
+/* OBSOLETE write_register (lrnum++, read_register (PC_REGNUM)); */
+/* OBSOLETE write_register (lrnum++, read_register (NPC_REGNUM)); */
+/* OBSOLETE write_register (lrnum++, read_register (PC2_REGNUM)); */
+/* OBSOLETE */
+/* OBSOLETE /* Why are we saving LR0? What would clobber it? (the dummy frame should */
+/* OBSOLETE be below it on the register stack, no?). */ */
+/* OBSOLETE write_register (lrnum++, original_lr0); */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE */
+/* OBSOLETE */
+/* OBSOLETE /* */
+/* OBSOLETE This routine takes three arguments and makes the cached frames look */
+/* OBSOLETE as if these arguments defined a frame on the cache. This allows the */
+/* OBSOLETE rest of `info frame' to extract the important arguments without much */
+/* OBSOLETE difficulty. Since an individual frame on the 29K is determined by */
+/* OBSOLETE three values (FP, PC, and MSP), we really need all three to do a */
+/* OBSOLETE good job. */ */
+/* OBSOLETE */
+/* OBSOLETE struct frame_info * */
+/* OBSOLETE setup_arbitrary_frame (int argc, CORE_ADDR *argv) */
+/* OBSOLETE { */
+/* OBSOLETE struct frame_info *frame; */
+/* OBSOLETE */
+/* OBSOLETE if (argc != 3) */
+/* OBSOLETE error ("AMD 29k frame specifications require three arguments: rsp pc msp"); */
+/* OBSOLETE */
+/* OBSOLETE frame = create_new_frame (argv[0], argv[1]); */
+/* OBSOLETE */
+/* OBSOLETE if (!frame) */
+/* OBSOLETE internal_error (__FILE__, __LINE__, */
+/* OBSOLETE "create_new_frame returned invalid frame id"); */
+/* OBSOLETE */
+/* OBSOLETE /* Creating a new frame munges the `frame' value from the current */
+/* OBSOLETE GR1, so we restore it again here. FIXME, untangle all this */
+/* OBSOLETE 29K frame stuff... */ */
+/* OBSOLETE frame->frame = argv[0]; */
+/* OBSOLETE */
+/* OBSOLETE /* Our MSP is in argv[2]. It'd be intelligent if we could just */
+/* OBSOLETE save this value in the FRAME. But the way it's set up (FIXME), */
+/* OBSOLETE we must save our caller's MSP. We compute that by adding our */
+/* OBSOLETE memory stack frame size to our MSP. */ */
+/* OBSOLETE frame->saved_msp = argv[2] + frame->msize; */
+/* OBSOLETE */
+/* OBSOLETE return frame; */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE int */
+/* OBSOLETE gdb_print_insn_a29k (bfd_vma memaddr, disassemble_info *info) */
+/* OBSOLETE { */
+/* OBSOLETE if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG) */
+/* OBSOLETE return print_insn_big_a29k (memaddr, info); */
+/* OBSOLETE else */
+/* OBSOLETE return print_insn_little_a29k (memaddr, info); */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE enum a29k_processor_types processor_type = a29k_unknown; */
+/* OBSOLETE */
+/* OBSOLETE void */
+/* OBSOLETE a29k_get_processor_type (void) */
+/* OBSOLETE { */
+/* OBSOLETE unsigned int cfg_reg = (unsigned int) read_register (CFG_REGNUM); */
+/* OBSOLETE */
+/* OBSOLETE /* Most of these don't have freeze mode. */ */
+/* OBSOLETE processor_type = a29k_no_freeze_mode; */
+/* OBSOLETE */
+/* OBSOLETE switch ((cfg_reg >> 28) & 0xf) */
+/* OBSOLETE { */
+/* OBSOLETE case 0: */
+/* OBSOLETE fprintf_filtered (gdb_stderr, "Remote debugging an Am29000"); */
+/* OBSOLETE break; */
+/* OBSOLETE case 1: */
+/* OBSOLETE fprintf_filtered (gdb_stderr, "Remote debugging an Am29005"); */
+/* OBSOLETE break; */
+/* OBSOLETE case 2: */
+/* OBSOLETE fprintf_filtered (gdb_stderr, "Remote debugging an Am29050"); */
+/* OBSOLETE processor_type = a29k_freeze_mode; */
+/* OBSOLETE break; */
+/* OBSOLETE case 3: */
+/* OBSOLETE fprintf_filtered (gdb_stderr, "Remote debugging an Am29035"); */
+/* OBSOLETE break; */
+/* OBSOLETE case 4: */
+/* OBSOLETE fprintf_filtered (gdb_stderr, "Remote debugging an Am29030"); */
+/* OBSOLETE break; */
+/* OBSOLETE case 5: */
+/* OBSOLETE fprintf_filtered (gdb_stderr, "Remote debugging an Am2920*"); */
+/* OBSOLETE break; */
+/* OBSOLETE case 6: */
+/* OBSOLETE fprintf_filtered (gdb_stderr, "Remote debugging an Am2924*"); */
+/* OBSOLETE break; */
+/* OBSOLETE case 7: */
+/* OBSOLETE fprintf_filtered (gdb_stderr, "Remote debugging an Am29040"); */
+/* OBSOLETE break; */
+/* OBSOLETE default: */
+/* OBSOLETE fprintf_filtered (gdb_stderr, "Remote debugging an unknown Am29k\n"); */
+/* OBSOLETE /* Don't bother to print the revision. */ */
+/* OBSOLETE return; */
+/* OBSOLETE } */
+/* OBSOLETE fprintf_filtered (gdb_stderr, " revision %c\n", 'A' + ((cfg_reg >> 24) & 0x0f)); */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE #ifdef GET_LONGJMP_TARGET */
+/* OBSOLETE /* Figure out where the longjmp will land. We expect that we have just entered */
+/* OBSOLETE longjmp and haven't yet setup the stack frame, so the args are still in the */
+/* OBSOLETE output regs. lr2 (LR2_REGNUM) points at the jmp_buf structure from which we */
+/* OBSOLETE extract the pc (JB_PC) that we will land at. The pc is copied into ADDR. */
+/* OBSOLETE This routine returns true on success */ */
+/* OBSOLETE */
+/* OBSOLETE int */
+/* OBSOLETE get_longjmp_target (CORE_ADDR *pc) */
+/* OBSOLETE { */
+/* OBSOLETE CORE_ADDR jb_addr; */
+/* OBSOLETE char buf[sizeof (CORE_ADDR)]; */
+/* OBSOLETE */
+/* OBSOLETE jb_addr = read_register (LR2_REGNUM); */
+/* OBSOLETE */
+/* OBSOLETE if (target_read_memory (jb_addr + JB_PC * JB_ELEMENT_SIZE, (char *) buf, */
+/* OBSOLETE sizeof (CORE_ADDR))) */
+/* OBSOLETE return 0; */
+/* OBSOLETE */
+/* OBSOLETE *pc = extract_address ((PTR) buf, sizeof (CORE_ADDR)); */
+/* OBSOLETE return 1; */
+/* OBSOLETE } */
+/* OBSOLETE #endif /* GET_LONGJMP_TARGET */ */
+/* OBSOLETE */
+/* OBSOLETE void */
+/* OBSOLETE _initialize_a29k_tdep (void) */
+/* OBSOLETE { */
+/* OBSOLETE extern CORE_ADDR text_end; */
+/* OBSOLETE */
+/* OBSOLETE tm_print_insn = gdb_print_insn_a29k; */
+/* OBSOLETE */
+/* OBSOLETE /* FIXME, there should be a way to make a CORE_ADDR variable settable. */ */
+/* OBSOLETE add_show_from_set */
+/* OBSOLETE (add_set_cmd ("rstack_high_address", class_support, var_uinteger, */
+/* OBSOLETE (char *) &rstack_high_address, */
+/* OBSOLETE "Set top address in memory of the register stack.\n\ */
+/* OBSOLETE Attempts to access registers saved above this address will be ignored\n\ */
+/* OBSOLETE or will produce the value -1.", &setlist), */
+/* OBSOLETE &showlist); */
+/* OBSOLETE */
+/* OBSOLETE /* FIXME, there should be a way to make a CORE_ADDR variable settable. */ */
+/* OBSOLETE add_show_from_set */
+/* OBSOLETE (add_set_cmd ("call_scratch_address", class_support, var_uinteger, */
+/* OBSOLETE (char *) &text_end, */
+/* OBSOLETE "Set address in memory where small amounts of RAM can be used\n\ */
+/* OBSOLETE when making function calls into the inferior.", &setlist), */
+/* OBSOLETE &showlist); */
+/* OBSOLETE } */
-# Target: AMD 29000 on EB29K board over a serial line
-TDEPFILES= a29k-tdep.o remote-udi.o udip2soc.o udr.o udi2go32.o
-TM_FILE= tm-a29k.h
-
-MT_CFLAGS = $(HOST_IPC)
+# OBSOLETE # Target: AMD 29000 on EB29K board over a serial line
+# OBSOLETE TDEPFILES= a29k-tdep.o remote-udi.o udip2soc.o udr.o udi2go32.o
+# OBSOLETE TM_FILE= tm-a29k.h
+# OBSOLETE
+# OBSOLETE MT_CFLAGS = $(HOST_IPC)
-# Target: AMD 29000
-TDEPFILES= a29k-tdep.o remote-eb.o remote-adapt.o
-TM_FILE= tm-a29k.h
-
-MT_CFLAGS = -DNO_HIF_SUPPORT
+# OBSOLETE # Target: AMD 29000
+# OBSOLETE TDEPFILES= a29k-tdep.o remote-eb.o remote-adapt.o
+# OBSOLETE TM_FILE= tm-a29k.h
+# OBSOLETE
+# OBSOLETE MT_CFLAGS = -DNO_HIF_SUPPORT
-/* Parameters for target machine AMD 29000, for GDB, the GNU debugger.
- Copyright 1990, 1991, 1993, 1994, 1995, 1996, 1998, 1999, 2000,
- 2001 Free Software Foundation, Inc.
- Contributed by Cygnus Support. Written by Jim Kingdon.
-
- This file is part of GDB.
-
- 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.
-
- 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.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA. */
-
-#include "regcache.h"
-
-/* Parameters for an EB29K (a board which plugs into a PC and is
- accessed through EBMON software running on the PC, which we
- use as we'd use a remote stub (see remote-eb.c).
-
- If gdb is ported to other a29k machines/systems, the
- machine/system-specific parts should be removed from this file (a
- la tm-m68k.h). */
-
-/* Byte order is configurable, but this machine runs big-endian. */
-#define TARGET_BYTE_ORDER BFD_ENDIAN_BIG
-
-/* Floating point uses IEEE representations. */
-#define IEEE_FLOAT (1)
-
-/* Recognize our magic number. */
-#define BADMAG(x) ((x).f_magic != 0572)
-
-/* Offset from address of function to start of its code.
- Zero on most machines. */
-
-#define FUNCTION_START_OFFSET 0
-
-/* Advance PC across any function entry prologue instructions
- to reach some "real" code. */
-
-#define SKIP_PROLOGUE(pc) (a29k_skip_prologue (pc))
-CORE_ADDR a29k_skip_prologue ();
-
-/* Immediately after a function call, return the saved pc.
- Can't go through the frames for this because on some machines
- the new frame is not set up until the new function executes
- some instructions. */
-
-#define SAVED_PC_AFTER_CALL(frame) ((frame->flags & TRANSPARENT_FRAME) \
- ? read_register (TPC_REGNUM) \
- : read_register (LR0_REGNUM))
-
-/* Stack grows downward. */
-
-#define INNER_THAN(lhs,rhs) ((lhs) < (rhs))
-
-/* Stack must be aligned on 32-bit boundaries when synthesizing
- function calls. */
-
-#define STACK_ALIGN(ADDR) (((ADDR) + 3) & ~3)
-
-/* Sequence of bytes for breakpoint instruction. */
-/* ASNEQ 0x50, gr1, gr1
- The trap number 0x50 is chosen arbitrarily.
- We let the command line (or previously included files) override this
- setting. */
-#ifndef BREAKPOINT
-#if TARGET_BYTE_ORDER == BFD_ENDIAN_BIG
-#define BREAKPOINT {0x72, 0x50, 0x01, 0x01}
-#else /* Target is little-endian. */
-#define BREAKPOINT {0x01, 0x01, 0x50, 0x72}
-#endif /* Target is little-endian. */
-#endif /* BREAKPOINT */
-
-/* Amount PC must be decremented by after a breakpoint.
- This is often the number of bytes in BREAKPOINT
- but not always. */
-
-#define DECR_PC_AFTER_BREAK 0
-
-/* Say how long (ordinary) registers are. This is a piece of bogosity
- used in push_word and a few other places; REGISTER_RAW_SIZE is the
- real way to know how big a register is. */
-
-#define REGISTER_SIZE 4
-
-/* Allow the register declarations here to be overridden for remote
- kernel debugging. */
-#if !defined (REGISTER_NAMES)
-
-/* Number of machine registers */
-
-#define NUM_REGS 205
-
-/* Initializer for an array of names of registers.
- There should be NUM_REGS strings in this initializer.
-
- FIXME, add floating point registers and support here.
-
- Also note that this list does not attempt to deal with kernel
- debugging (in which the first 32 registers are gr64-gr95). */
-
-#define REGISTER_NAMES \
-{"gr96", "gr97", "gr98", "gr99", "gr100", "gr101", "gr102", "gr103", "gr104", \
- "gr105", "gr106", "gr107", "gr108", "gr109", "gr110", "gr111", "gr112", \
- "gr113", "gr114", "gr115", "gr116", "gr117", "gr118", "gr119", "gr120", \
- "gr121", "gr122", "gr123", "gr124", "gr125", "gr126", "gr127", \
- "lr0", "lr1", "lr2", "lr3", "lr4", "lr5", "lr6", "lr7", "lr8", "lr9", \
- "lr10", "lr11", "lr12", "lr13", "lr14", "lr15", "lr16", "lr17", "lr18", \
- "lr19", "lr20", "lr21", "lr22", "lr23", "lr24", "lr25", "lr26", "lr27", \
- "lr28", "lr29", "lr30", "lr31", "lr32", "lr33", "lr34", "lr35", "lr36", \
- "lr37", "lr38", "lr39", "lr40", "lr41", "lr42", "lr43", "lr44", "lr45", \
- "lr46", "lr47", "lr48", "lr49", "lr50", "lr51", "lr52", "lr53", "lr54", \
- "lr55", "lr56", "lr57", "lr58", "lr59", "lr60", "lr61", "lr62", "lr63", \
- "lr64", "lr65", "lr66", "lr67", "lr68", "lr69", "lr70", "lr71", "lr72", \
- "lr73", "lr74", "lr75", "lr76", "lr77", "lr78", "lr79", "lr80", "lr81", \
- "lr82", "lr83", "lr84", "lr85", "lr86", "lr87", "lr88", "lr89", "lr90", \
- "lr91", "lr92", "lr93", "lr94", "lr95", "lr96", "lr97", "lr98", "lr99", \
- "lr100", "lr101", "lr102", "lr103", "lr104", "lr105", "lr106", "lr107", \
- "lr108", "lr109", "lr110", "lr111", "lr112", "lr113", "lr114", "lr115", \
- "lr116", "lr117", "lr118", "lr119", "lr120", "lr121", "lr122", "lr123", \
- "lr124", "lr125", "lr126", "lr127", \
- "AI0", "AI1", "AI2", "AI3", "AI4", "AI5", "AI6", "AI7", "AI8", "AI9", \
- "AI10", "AI11", "AI12", "AI13", "AI14", "AI15", "FP", \
- "bp", "fc", "cr", "q", \
- "vab", "ops", "cps", "cfg", "cha", "chd", "chc", "rbp", "tmc", "tmr", \
- "pc0", "pc1", "pc2", "mmu", "lru", "fpe", "inte", "fps", "exo", "gr1", \
- "alu", "ipc", "ipa", "ipb" }
-
-/*
- * Converts an sdb register number to an internal gdb register number.
- * Currently under epi, gr96->0...gr127->31...lr0->32...lr127->159, or...
- * gr64->0...gr95->31, lr0->32...lr127->159.
- */
-#define SDB_REG_TO_REGNUM(value) \
- (((value) >= 96 && (value) <= 127) ? ((value) - 96) : \
- ((value) >= 128 && (value) <= 255) ? ((value) - 128 + LR0_REGNUM) : \
- (value))
-
-/*
- * Provide the processor register numbers of some registers that are
- * expected/written in instructions that might change under different
- * register sets. Namely, gcc can compile (-mkernel-registers) so that
- * it uses gr64-gr95 in stead of gr96-gr127.
- */
-#define MSP_HW_REGNUM 125 /* gr125 */
-#define RAB_HW_REGNUM 126 /* gr126 */
-
-/* Convert Processor Special register #x to REGISTER_NAMES register # */
-#define SR_REGNUM(x) \
- ((x) < 15 ? VAB_REGNUM + (x) \
- : (x) >= 128 && (x) < 131 ? IPC_REGNUM + (x) - 128 \
- : (x) == 131 ? Q_REGNUM \
- : (x) == 132 ? ALU_REGNUM \
- : (x) >= 133 && (x) < 136 ? BP_REGNUM + (x) - 133 \
- : (x) >= 160 && (x) < 163 ? FPE_REGNUM + (x) - 160 \
- : (x) == 164 ? EXO_REGNUM \
- : (error ("Internal error in SR_REGNUM"), 0))
-#define GR96_REGNUM 0
-
-/* Define the return register separately, so it can be overridden for
- kernel procedure calling conventions. */
-#define RETURN_REGNUM GR96_REGNUM
-#define GR1_REGNUM 200
-/* This needs to be the memory stack pointer, not the register stack pointer,
- to make call_function work right. */
-#define SP_REGNUM MSP_REGNUM
-#define FP_REGNUM 33 /* lr1 */
-
-/* Return register for transparent calling convention (gr122). */
-#define TPC_REGNUM (122 - 96 + GR96_REGNUM)
-
-/* Large Return Pointer (gr123). */
-#define LRP_REGNUM (123 - 96 + GR96_REGNUM)
-
-/* Static link pointer (gr124). */
-#define SLP_REGNUM (124 - 96 + GR96_REGNUM)
-
-/* Memory Stack Pointer (gr125). */
-#define MSP_REGNUM (125 - 96 + GR96_REGNUM)
-
-/* Register allocate bound (gr126). */
-#define RAB_REGNUM (126 - 96 + GR96_REGNUM)
-
-/* Register Free Bound (gr127). */
-#define RFB_REGNUM (127 - 96 + GR96_REGNUM)
-
-/* Register Stack Pointer. */
-#define RSP_REGNUM GR1_REGNUM
-#define LR0_REGNUM 32
-#define BP_REGNUM 177
-#define FC_REGNUM 178
-#define CR_REGNUM 179
-#define Q_REGNUM 180
-#define VAB_REGNUM 181
-#define OPS_REGNUM (VAB_REGNUM + 1)
-#define CPS_REGNUM (VAB_REGNUM + 2)
-#define CFG_REGNUM (VAB_REGNUM + 3)
-#define CHA_REGNUM (VAB_REGNUM + 4)
-#define CHD_REGNUM (VAB_REGNUM + 5)
-#define CHC_REGNUM (VAB_REGNUM + 6)
-#define RBP_REGNUM (VAB_REGNUM + 7)
-#define TMC_REGNUM (VAB_REGNUM + 8)
-#define TMR_REGNUM (VAB_REGNUM + 9)
-#define NPC_REGNUM (VAB_REGNUM + 10) /* pc0 */
-#define PC_REGNUM (VAB_REGNUM + 11) /* pc1 */
-#define PC2_REGNUM (VAB_REGNUM + 12)
-#define MMU_REGNUM (VAB_REGNUM + 13)
-#define LRU_REGNUM (VAB_REGNUM + 14)
-#define FPE_REGNUM (VAB_REGNUM + 15)
-#define INTE_REGNUM (VAB_REGNUM + 16)
-#define FPS_REGNUM (VAB_REGNUM + 17)
-#define EXO_REGNUM (VAB_REGNUM + 18)
-/* gr1 is defined above as 200 = VAB_REGNUM + 19 */
-#define ALU_REGNUM (VAB_REGNUM + 20)
-#define PS_REGNUM ALU_REGNUM
-#define IPC_REGNUM (VAB_REGNUM + 21)
-#define IPA_REGNUM (VAB_REGNUM + 22)
-#define IPB_REGNUM (VAB_REGNUM + 23)
-
-#endif /* !defined(REGISTER_NAMES) */
-
-/* Total amount of space needed to store our copies of the machine's
- register state, the array `registers'. */
-#define REGISTER_BYTES (NUM_REGS * 4)
-
-/* Index within `registers' of the first byte of the space for
- register N. */
-#define REGISTER_BYTE(N) ((N)*4)
-
-/* Number of bytes of storage in the actual machine representation
- for register N. */
-
-/* All regs are 4 bytes. */
-
-#define REGISTER_RAW_SIZE(N) (4)
-
-/* Number of bytes of storage in the program's representation
- for register N. */
-
-/* All regs are 4 bytes. */
-
-#define REGISTER_VIRTUAL_SIZE(N) (4)
-
-/* Largest value REGISTER_RAW_SIZE can have. */
-
-#define MAX_REGISTER_RAW_SIZE (4)
-
-/* Largest value REGISTER_VIRTUAL_SIZE can have. */
-
-#define MAX_REGISTER_VIRTUAL_SIZE (4)
-
-/* Return the GDB type object for the "standard" data type
- of data in register N. */
-
-#define REGISTER_VIRTUAL_TYPE(N) \
- (((N) == PC_REGNUM || (N) == LRP_REGNUM || (N) == SLP_REGNUM \
- || (N) == MSP_REGNUM || (N) == RAB_REGNUM || (N) == RFB_REGNUM \
- || (N) == GR1_REGNUM || (N) == FP_REGNUM || (N) == LR0_REGNUM \
- || (N) == NPC_REGNUM || (N) == PC2_REGNUM) \
- ? lookup_pointer_type (builtin_type_void) : builtin_type_int)
-\f
-/* Store the address of the place in which to copy the structure the
- subroutine will return. This is called from call_function. */
-/* On the a29k the LRP points to the part of the structure beyond the first
- 16 words. */
-#define STORE_STRUCT_RETURN(ADDR, SP) \
- write_register (LRP_REGNUM, (ADDR) + 16 * 4);
-
-/* Should call_function allocate stack space for a struct return? */
-/* On the a29k objects over 16 words require the caller to allocate space. */
-extern use_struct_convention_fn a29k_use_struct_convention;
-#define USE_STRUCT_CONVENTION(gcc_p, type) a29k_use_struct_convention (gcc_p, type)
-
-/* Extract from an array REGBUF containing the (raw) register state
- a function return value of type TYPE, and copy that, in virtual format,
- into VALBUF. */
-
-#define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \
- { \
- int reg_length = TYPE_LENGTH (TYPE); \
- if (reg_length > 16 * 4) \
- { \
- reg_length = 16 * 4; \
- read_memory (*((int *)(REGBUF) + LRP_REGNUM), (VALBUF) + 16 * 4, \
- TYPE_LENGTH (TYPE) - 16 * 4); \
- } \
- memcpy ((VALBUF), ((int *)(REGBUF))+RETURN_REGNUM, reg_length); \
- }
-
-/* Write into appropriate registers a function return value
- of type TYPE, given in virtual format. */
-
-#define STORE_RETURN_VALUE(TYPE,VALBUF) \
- { \
- int reg_length = TYPE_LENGTH (TYPE); \
- if (reg_length > 16 * 4) \
- { \
- reg_length = 16 * 4; \
- write_memory (read_register (LRP_REGNUM), \
- (char *)(VALBUF) + 16 * 4, \
- TYPE_LENGTH (TYPE) - 16 * 4); \
- } \
- write_register_bytes (REGISTER_BYTE (RETURN_REGNUM), (char *)(VALBUF), \
- TYPE_LENGTH (TYPE)); \
- }
-\f/* *INDENT-OFF* */
-/* The a29k user's guide documents well what the stacks look like.
- But what isn't so clear there is how this interracts with the
- symbols, or with GDB.
- In the following saved_msp, saved memory stack pointer (which functions
- as a memory frame pointer), means either
- a register containing the memory frame pointer or, in the case of
- functions with fixed size memory frames (i.e. those who don't use
- alloca()), the result of the calculation msp + msize.
-
- LOC_ARG, LOC_LOCAL - For GCC, these are relative to saved_msp.
- For high C, these are relative to msp (making alloca impossible).
- LOC_REGISTER, LOC_REGPARM - The register number is the number at the
- time the function is running (after the prologue), or in the case
- of LOC_REGPARM, may be a register number in the range 160-175.
-
- The compilers do things like store an argument into memory, and then put out
- a LOC_ARG for it, or put it into global registers and put out a
- LOC_REGPARM. Thus is it important to execute the first line of
- code (i.e. the line of the open brace, i.e. the prologue) of a function
- before trying to print arguments or anything.
-
- The following diagram attempts to depict what is going on in memory
- (see also the _a29k user's guide_) and also how that interacts with
- GDB frames. We arbitrarily pick fci->frame to point the same place
- as the register stack pointer; since we set it ourself in
- INIT_EXTRA_FRAME_INFO, and access it only through the FRAME_*
- macros, it doesn't really matter exactly how we
- do it. However, note that FRAME_FP is used in two ways in GDB:
- (1) as a "magic cookie" which uniquely identifies frames (even over
- calls to the inferior), (2) (in PC_IN_CALL_DUMMY [ON_STACK])
- as the value of SP_REGNUM before the dummy frame was pushed. These
- two meanings would be incompatible for the a29k if we defined
- CALL_DUMMY_LOCATION == ON_STACK (but we don't, so don't worry about it).
- Also note that "lr1" below, while called a frame pointer
- in the user's guide, has only one function: To determine whether
- registers need to be filled in the function epilogue.
-
- Consider the code:
- < call bar>
- loc1: . . .
- bar: sub gr1,gr1,rsize_b
- . . .
- add mfp,msp,0
- sub msp,msp,msize_b
- . . .
- < call foo >
- loc2: . . .
- foo: sub gr1,gr1,rsize_f
- . . .
- add mfp,msp,0
- sub msp,msp,msize_f
- . . .
- loc3: < suppose the inferior stops here >
-
- memory stack register stack
- | | |____________|
- | | |____loc1____|
- +------->|___________| | | ^
- | | ^ | | locals_b | |
- | | | | |____________| |
- | | | | | | | rsize_b
- | | | msize_b | | args_to_f | |
- | | | | |____________| |
- | | | | |____lr1_____| V
- | | V | |____loc2____|<----------------+
- | +--->|___________|<---------mfp | ^ |
- | | | ^ | | locals_f | | |
- | | | | msize_f | |____________| | |
- | | | | | | | | rsize_f |
- | | | V | | args | | |
- | | |___________|<msp |____________| | |
- | | |_____lr1____| V |
- | | |___garbage__| <- gr1 <----+ |
- | | | |
- | | | |
- | | pc=loc3 | |
- | | | |
- | | | |
- | | frame cache | |
- | | |_________________| | |
- | | |rsize=rsize_b | | |
- | | |msize=msize_b | | |
- +---|--------saved_msp | | |
- | |frame------------------------------------|---+
- | |pc=loc2 | |
- | |_________________| |
- | |rsize=rsize_f | |
- | |msize=msize_f | |
- +--------saved_msp | |
- |frame------------------------------------+
- |pc=loc3 |
- |_________________|
-
- So, is that sufficiently confusing? Welcome to the 29000.
- Notes:
- * The frame for foo uses a memory frame pointer but the frame for
- bar does not. In the latter case the saved_msp is
- computed by adding msize to the saved_msp of the
- next frame.
- * msize is in the frame cache only for high C's sake. */
-/* *INDENT-ON* */
-
-
-void read_register_stack ();
-long read_register_stack_integer ();
-\f
-#define FRAME_INIT_SAVED_REGS(fi) /*no-op */
-
-#define EXTRA_FRAME_INFO \
- CORE_ADDR saved_msp; \
- unsigned int rsize; \
- unsigned int msize; \
- unsigned char flags;
-
-/* Bits for flags in EXTRA_FRAME_INFO */
-#define TRANSPARENT_FRAME 0x1 /* This is a transparent frame */
-#define MFP_USED 0x2 /* A memory frame pointer is used */
-
-/* Because INIT_FRAME_PC gets passed fromleaf, that's where we init
- not only ->pc and ->frame, but all the extra stuff, when called from
- get_prev_frame, that is. */
-#define INIT_EXTRA_FRAME_INFO(fromleaf, fci) init_extra_frame_info(fci)
-void init_extra_frame_info ();
-
-#define INIT_FRAME_PC(fromleaf, fci) init_frame_pc(fromleaf, fci)
-void init_frame_pc ();
-\f
-
-/* FRAME_CHAIN takes a FRAME
- and produces the frame's chain-pointer.
-
- However, if FRAME_CHAIN_VALID returns zero,
- it means the given frame is the outermost one and has no caller. */
-
-/* On the a29k, the nominal address of a frame is the address on the
- register stack of the return address (the one next to the incoming
- arguments, not down at the bottom so nominal address == stack pointer).
-
- GDB expects "nominal address" to equal contents of FP_REGNUM,
- at least when it comes time to create the innermost frame.
- However, that doesn't work for us, so when creating the innermost
- frame we set ->frame ourselves in INIT_EXTRA_FRAME_INFO. */
-
-/* These are mostly dummies for the a29k because INIT_FRAME_PC
- sets prev->frame instead. */
-/* If rsize is zero, we must be at end of stack (or otherwise hosed).
- If we don't check rsize, we loop forever if we see rsize == 0. */
-#define FRAME_CHAIN(thisframe) \
- ((thisframe)->rsize == 0 \
- ? 0 \
- : (thisframe)->frame + (thisframe)->rsize)
-
-/* Determine if the frame has a 'previous' and back-traceable frame. */
-#define FRAME_IS_UNCHAINED(frame) ((frame)->flags & TRANSPARENT_FRAME)
-
-/* Find the previous frame of a transparent routine.
- * For now lets not try and trace through a transparent routine (we might
- * have to assume that all transparent routines are traps).
- */
-#define FIND_PREV_UNCHAINED_FRAME(frame) 0
-
-/* Define other aspects of the stack frame. */
-
-/* An expression that tells us whether the function invocation represented
- by FI does not have a frame on the stack associated with it. */
-#define FRAMELESS_FUNCTION_INVOCATION(FI) \
- (frameless_look_for_prologue (FI))
-
-/* Saved pc (i.e. return address). */
-#define FRAME_SAVED_PC(fraim) \
- (read_register_stack_integer ((fraim)->frame + (fraim)->rsize, 4))
-
-/* Local variables (i.e. LOC_LOCAL) are on the memory stack, with their
- offsets being relative to the memory stack pointer (high C) or
- saved_msp (gcc). */
-
-#define FRAME_LOCALS_ADDRESS(fi) frame_locals_address (fi)
-extern CORE_ADDR frame_locals_address ();
-
-/* Return number of args passed to a frame.
- Can return -1, meaning no way to tell. */
-/* We tried going to the effort of finding the tags word and getting
- the argcount field from it, to support debugging assembler code.
- Problem was, the "argcount" field never did hold the argument
- count. */
-#define FRAME_NUM_ARGS(fi) (-1)
-
-#define FRAME_ARGS_ADDRESS(fi) FRAME_LOCALS_ADDRESS (fi)
-
-/* Return number of bytes at start of arglist that are not really args. */
-
-#define FRAME_ARGS_SKIP 0
-
-/* Provide our own get_saved_register. HAVE_REGISTER_WINDOWS is insufficient
- because registers get renumbered on the a29k without getting saved. */
-
-struct frame_info;
-void a29k_get_saved_register (char *raw_buffer, int *optimized,
- CORE_ADDR * addrp, struct frame_info *frame,
- int regnum, enum lval_type *lvalp);
-#define GET_SAVED_REGISTER(raw_buffer, optimized, addrp, frame, regnum, lval) \
- a29k_get_saved_register (raw_buffer, optimized, addrp, frame, regnum, lval)
-\f
-/* Call function stuff. */
-/* *INDENT-OFF* */
-/* The dummy frame looks like this (see also the general frame picture
- above):
-
- register stack
-
- | | frame for function
- | locals_sproc | executing at time
- |________________| of call_function.
- | | We must not disturb
- | args_out_sproc | it.
- memory stack |________________|
- |____lr1_sproc___|<-+
- | | |__retaddr_sproc_| | <-- gr1 (at start)
- |____________|<-msp 0 <-----------mfp_dummy_____| |
- | | (at start) | save regs | |
- | arg_slop | | pc0,pc1 | |
- | | | pc2,lr0 sproc | |
- | (16 words) | | gr96-gr124 | |
- |____________|<-msp 1--after | sr160-sr162 | |
- | | PUSH_DUMMY_FRAME| sr128-sr135 | |
- | struct ret | |________________| |
- | 17+ | | | |
- |____________|<- lrp | args_out_dummy | |
- | struct ret | | (16 words) | |
- | 16 | |________________| |
- | (16 words) | |____lr1_dummy___|--+
- |____________|<- msp 2--after |_retaddr_dummy__|<- gr1 after
- | | struct ret | | PUSH_DUMMY_FRAME
- | margs17+ | area allocated | locals_inf |
- | | |________________| called
- |____________|<- msp 4--when | | function's
- | | inf called | args_out_inf | frame (set up
- | margs16 | |________________| by called
- | (16 words) | |_____lr1_inf____| function).
- |____________|<- msp 3--after | . |
- | | args pushed | . |
- | | | . |
- | |
-
- arg_slop: This area is so that when the call dummy adds 16 words to
- the msp, it won't end up larger than mfp_dummy (it is needed in the
- case where margs and struct_ret do not add up to at least 16 words).
- struct ret: This area is allocated by GDB if the return value is more
- than 16 words. struct ret_16 is not used on the a29k.
- margs: Pushed by GDB. The call dummy copies the first 16 words to
- args_out_dummy.
- retaddr_sproc: Contains the PC at the time we call the function.
- set by PUSH_DUMMY_FRAME and read by POP_FRAME.
- retaddr_dummy: This points to a breakpoint instruction in the dummy. */
-/* *INDENT-ON* */
-\f
-
-
-/* Rsize for dummy frame, in bytes. */
-
-/* Bytes for outgoing args, lr1, and retaddr. */
-#define DUMMY_ARG (2 * 4 + 16 * 4)
-
-/* Number of special registers (sr128-) to save. */
-#define DUMMY_SAVE_SR128 8
-/* Number of special registers (sr160-) to save. */
-#define DUMMY_SAVE_SR160 3
-/* Number of general (gr96- or gr64-) registers to save. */
-#define DUMMY_SAVE_GREGS 29
-
-#define DUMMY_FRAME_RSIZE \
-(4 /* mfp_dummy */ \
- + 4 * 4 /* pc0, pc1, pc2, lr0 */ \
- + DUMMY_SAVE_GREGS * 4 \
- + DUMMY_SAVE_SR160 * 4 \
- + DUMMY_SAVE_SR128 * 4 \
- + DUMMY_ARG \
- + 4 /* pad to doubleword */ )
-
-/* Push an empty stack frame, to record the current PC, etc. */
-
-#define PUSH_DUMMY_FRAME push_dummy_frame()
-extern void push_dummy_frame ();
-
-/* Discard from the stack the innermost frame,
- restoring all saved registers. */
-
-#define POP_FRAME pop_frame()
-extern void pop_frame ();
-
-/* This sequence of words is the instructions
- mtsrim cr, 15
- loadm 0, 0, lr2, msp ; load first 16 words of arguments into registers
- add msp, msp, 16 * 4 ; point to the remaining arguments
- CONST_INSN:
- const lr0,inf ; (replaced by half of target addr)
- consth lr0,inf ; (replaced by other half of target addr)
- calli lr0, lr0
- aseq 0x40,gr1,gr1 ; nop
- BREAKPT_INSN:
- asneq 0x50,gr1,gr1 ; breakpoint (replaced by local breakpoint insn)
- */
-
-#error "This file is broken. GDB does not define HOST_BYTE_ORDER."
-#if TARGET_BYTE_ORDER == HOST_BYTE_ORDER
-#define BS(const) const
-#else
-#define BS(const) (((const) & 0xff) << 24) | \
- (((const) & 0xff00) << 8) | \
- (((const) & 0xff0000) >> 8) | \
- (((const) & 0xff000000) >> 24)
-#endif
-
-/* Position of the "const" and blkt instructions within CALL_DUMMY in bytes. */
-#define CONST_INSN (3 * 4)
-#define BREAKPT_INSN (7 * 4)
-#define CALL_DUMMY { \
- BS(0x0400870f),\
- BS(0x36008200|(MSP_HW_REGNUM)), \
- BS(0x15000040|(MSP_HW_REGNUM<<8)|(MSP_HW_REGNUM<<16)), \
- BS(0x03ff80ff), \
- BS(0x02ff80ff), \
- BS(0xc8008080), \
- BS(0x70400101), \
- BS(0x72500101)}
-#define CALL_DUMMY_LENGTH (8 * 4)
-
-#define CALL_DUMMY_START_OFFSET 0 /* Start execution at beginning of dummy */
-
-/* Helper macro for FIX_CALL_DUMMY. WORDP is a long * which points to a
- word in target byte order; bits 0-7 and 16-23 of *WORDP are replaced with
- bits 0-7 and 8-15 of DATA (which is in host byte order). */
-
-#if TARGET_BYTE_ORDER == BFD_ENDIAN_BIG
-#define STUFF_I16(WORDP, DATA) \
- { \
- *((char *)(WORDP) + 3) = ((DATA) & 0xff);\
- *((char *)(WORDP) + 1) = (((DATA) >> 8) & 0xff);\
- }
-#else /* Target is little endian. */
-#define STUFF_I16(WORDP, DATA) \
- {
-*(char *) (WORDP) = ((DATA) & 0xff);
-*((char *) (WORDP) + 2) = (((DATA) >> 8) & 0xff);
-}
-#endif /* Target is little endian. */
-
-/* Insert the specified number of args and function address
- into a call sequence of the above form stored at DUMMYNAME. */
-
-/* Currently this stuffs in the address of the function that we are calling.
- Since different a29k systems use different breakpoint instructions, it
- also stuffs BREAKPOINT in the right place (to avoid having to
- duplicate CALL_DUMMY in each tm-*.h file). */
-
-#define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, args, type, gcc_p) \
- {\
- STUFF_I16((char *)dummyname + CONST_INSN, fun); \
- STUFF_I16((char *)dummyname + CONST_INSN + 4, fun >> 16); \
- /* FIXME memcpy ((char *)(dummyname) + BREAKPT_INSN, break_insn, 4); */ \
- }
-
-/* a29k architecture has separate data & instruction memories -- wired to
- different pins on the chip -- and can't execute the data memory.
- Also, there should be space after text_end;
- we won't get a SIGSEGV or scribble on data space. */
-
-#define CALL_DUMMY_LOCATION AFTER_TEXT_END
-
-/* Because of this, we need (as a kludge) to know the addresses of the
- text section. */
-
-#define NEED_TEXT_START_END 1
-
-/* How to translate register numbers in the .stab's into gdb's internal register
- numbers. We don't translate them, but we warn if an invalid register
- number is seen. Note that FIXME, we use the value "sym" as an implicit
- argument in printing the error message. It happens to be available where
- this macro is used. (This macro definition appeared in a late revision
- of gdb-3.91.6 and is not well tested. Also, it should be a "complaint".) */
-
-#define STAB_REG_TO_REGNUM(num) \
- (((num) > LR0_REGNUM + 127) \
- ? fprintf(stderr, \
- "Invalid register number %d in symbol table entry for %s\n", \
- (num), SYMBOL_SOURCE_NAME (sym)), (num) \
- : (num))
-
-extern enum a29k_processor_types
-{
- a29k_unknown,
-
- /* Bit 0x400 of the CPS does *not* identify freeze mode, i.e. 29000,
- 29030, etc. */
- a29k_no_freeze_mode,
-
- /* Bit 0x400 of the CPS does identify freeze mode, i.e. 29050. */
- a29k_freeze_mode
-}
-processor_type;
-
-/* We need three arguments for a general frame specification for the
- "frame" or "info frame" command. */
-
-#define SETUP_ARBITRARY_FRAME(argc, argv) setup_arbitrary_frame (argc, argv)
-extern struct frame_info *setup_arbitrary_frame (int, CORE_ADDR *);
+/* OBSOLETE /* Parameters for target machine AMD 29000, for GDB, the GNU debugger. */
+/* OBSOLETE Copyright 1990, 1991, 1993, 1994, 1995, 1996, 1998, 1999, 2000, */
+/* OBSOLETE 2001 Free Software Foundation, Inc. */
+/* OBSOLETE Contributed by Cygnus Support. Written by Jim Kingdon. */
+/* OBSOLETE */
+/* OBSOLETE This file is part of GDB. */
+/* OBSOLETE */
+/* OBSOLETE This program is free software; you can redistribute it and/or modify */
+/* OBSOLETE it under the terms of the GNU General Public License as published by */
+/* OBSOLETE the Free Software Foundation; either version 2 of the License, or */
+/* OBSOLETE (at your option) any later version. */
+/* OBSOLETE */
+/* OBSOLETE This program is distributed in the hope that it will be useful, */
+/* OBSOLETE but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* OBSOLETE MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* OBSOLETE GNU General Public License for more details. */
+/* OBSOLETE */
+/* OBSOLETE You should have received a copy of the GNU General Public License */
+/* OBSOLETE along with this program; if not, write to the Free Software */
+/* OBSOLETE Foundation, Inc., 59 Temple Place - Suite 330, */
+/* OBSOLETE Boston, MA 02111-1307, USA. */ */
+/* OBSOLETE */
+/* OBSOLETE #include "regcache.h" */
+/* OBSOLETE */
+/* OBSOLETE /* Parameters for an EB29K (a board which plugs into a PC and is */
+/* OBSOLETE accessed through EBMON software running on the PC, which we */
+/* OBSOLETE use as we'd use a remote stub (see remote-eb.c). */
+/* OBSOLETE */
+/* OBSOLETE If gdb is ported to other a29k machines/systems, the */
+/* OBSOLETE machine/system-specific parts should be removed from this file (a */
+/* OBSOLETE la tm-m68k.h). */ */
+/* OBSOLETE */
+/* OBSOLETE /* Byte order is configurable, but this machine runs big-endian. */ */
+/* OBSOLETE #define TARGET_BYTE_ORDER BFD_ENDIAN_BIG */
+/* OBSOLETE */
+/* OBSOLETE /* Floating point uses IEEE representations. */ */
+/* OBSOLETE #define IEEE_FLOAT (1) */
+/* OBSOLETE */
+/* OBSOLETE /* Recognize our magic number. */ */
+/* OBSOLETE #define BADMAG(x) ((x).f_magic != 0572) */
+/* OBSOLETE */
+/* OBSOLETE /* Offset from address of function to start of its code. */
+/* OBSOLETE Zero on most machines. */ */
+/* OBSOLETE */
+/* OBSOLETE #define FUNCTION_START_OFFSET 0 */
+/* OBSOLETE */
+/* OBSOLETE /* Advance PC across any function entry prologue instructions */
+/* OBSOLETE to reach some "real" code. */ */
+/* OBSOLETE */
+/* OBSOLETE #define SKIP_PROLOGUE(pc) (a29k_skip_prologue (pc)) */
+/* OBSOLETE CORE_ADDR a29k_skip_prologue (); */
+/* OBSOLETE */
+/* OBSOLETE /* Immediately after a function call, return the saved pc. */
+/* OBSOLETE Can't go through the frames for this because on some machines */
+/* OBSOLETE the new frame is not set up until the new function executes */
+/* OBSOLETE some instructions. */ */
+/* OBSOLETE */
+/* OBSOLETE #define SAVED_PC_AFTER_CALL(frame) ((frame->flags & TRANSPARENT_FRAME) \ */
+/* OBSOLETE ? read_register (TPC_REGNUM) \ */
+/* OBSOLETE : read_register (LR0_REGNUM)) */
+/* OBSOLETE */
+/* OBSOLETE /* Stack grows downward. */ */
+/* OBSOLETE */
+/* OBSOLETE #define INNER_THAN(lhs,rhs) ((lhs) < (rhs)) */
+/* OBSOLETE */
+/* OBSOLETE /* Stack must be aligned on 32-bit boundaries when synthesizing */
+/* OBSOLETE function calls. */ */
+/* OBSOLETE */
+/* OBSOLETE #define STACK_ALIGN(ADDR) (((ADDR) + 3) & ~3) */
+/* OBSOLETE */
+/* OBSOLETE /* Sequence of bytes for breakpoint instruction. */ */
+/* OBSOLETE /* ASNEQ 0x50, gr1, gr1 */
+/* OBSOLETE The trap number 0x50 is chosen arbitrarily. */
+/* OBSOLETE We let the command line (or previously included files) override this */
+/* OBSOLETE setting. */ */
+/* OBSOLETE #ifndef BREAKPOINT */
+/* OBSOLETE #if TARGET_BYTE_ORDER == BFD_ENDIAN_BIG */
+/* OBSOLETE #define BREAKPOINT {0x72, 0x50, 0x01, 0x01} */
+/* OBSOLETE #else /* Target is little-endian. */ */
+/* OBSOLETE #define BREAKPOINT {0x01, 0x01, 0x50, 0x72} */
+/* OBSOLETE #endif /* Target is little-endian. */ */
+/* OBSOLETE #endif /* BREAKPOINT */ */
+/* OBSOLETE */
+/* OBSOLETE /* Amount PC must be decremented by after a breakpoint. */
+/* OBSOLETE This is often the number of bytes in BREAKPOINT */
+/* OBSOLETE but not always. */ */
+/* OBSOLETE */
+/* OBSOLETE #define DECR_PC_AFTER_BREAK 0 */
+/* OBSOLETE */
+/* OBSOLETE /* Say how long (ordinary) registers are. This is a piece of bogosity */
+/* OBSOLETE used in push_word and a few other places; REGISTER_RAW_SIZE is the */
+/* OBSOLETE real way to know how big a register is. */ */
+/* OBSOLETE */
+/* OBSOLETE #define REGISTER_SIZE 4 */
+/* OBSOLETE */
+/* OBSOLETE /* Allow the register declarations here to be overridden for remote */
+/* OBSOLETE kernel debugging. */ */
+/* OBSOLETE #if !defined (REGISTER_NAMES) */
+/* OBSOLETE */
+/* OBSOLETE /* Number of machine registers */ */
+/* OBSOLETE */
+/* OBSOLETE #define NUM_REGS 205 */
+/* OBSOLETE */
+/* OBSOLETE /* Initializer for an array of names of registers. */
+/* OBSOLETE There should be NUM_REGS strings in this initializer. */
+/* OBSOLETE */
+/* OBSOLETE FIXME, add floating point registers and support here. */
+/* OBSOLETE */
+/* OBSOLETE Also note that this list does not attempt to deal with kernel */
+/* OBSOLETE debugging (in which the first 32 registers are gr64-gr95). */ */
+/* OBSOLETE */
+/* OBSOLETE #define REGISTER_NAMES \ */
+/* OBSOLETE {"gr96", "gr97", "gr98", "gr99", "gr100", "gr101", "gr102", "gr103", "gr104", \ */
+/* OBSOLETE "gr105", "gr106", "gr107", "gr108", "gr109", "gr110", "gr111", "gr112", \ */
+/* OBSOLETE "gr113", "gr114", "gr115", "gr116", "gr117", "gr118", "gr119", "gr120", \ */
+/* OBSOLETE "gr121", "gr122", "gr123", "gr124", "gr125", "gr126", "gr127", \ */
+/* OBSOLETE "lr0", "lr1", "lr2", "lr3", "lr4", "lr5", "lr6", "lr7", "lr8", "lr9", \ */
+/* OBSOLETE "lr10", "lr11", "lr12", "lr13", "lr14", "lr15", "lr16", "lr17", "lr18", \ */
+/* OBSOLETE "lr19", "lr20", "lr21", "lr22", "lr23", "lr24", "lr25", "lr26", "lr27", \ */
+/* OBSOLETE "lr28", "lr29", "lr30", "lr31", "lr32", "lr33", "lr34", "lr35", "lr36", \ */
+/* OBSOLETE "lr37", "lr38", "lr39", "lr40", "lr41", "lr42", "lr43", "lr44", "lr45", \ */
+/* OBSOLETE "lr46", "lr47", "lr48", "lr49", "lr50", "lr51", "lr52", "lr53", "lr54", \ */
+/* OBSOLETE "lr55", "lr56", "lr57", "lr58", "lr59", "lr60", "lr61", "lr62", "lr63", \ */
+/* OBSOLETE "lr64", "lr65", "lr66", "lr67", "lr68", "lr69", "lr70", "lr71", "lr72", \ */
+/* OBSOLETE "lr73", "lr74", "lr75", "lr76", "lr77", "lr78", "lr79", "lr80", "lr81", \ */
+/* OBSOLETE "lr82", "lr83", "lr84", "lr85", "lr86", "lr87", "lr88", "lr89", "lr90", \ */
+/* OBSOLETE "lr91", "lr92", "lr93", "lr94", "lr95", "lr96", "lr97", "lr98", "lr99", \ */
+/* OBSOLETE "lr100", "lr101", "lr102", "lr103", "lr104", "lr105", "lr106", "lr107", \ */
+/* OBSOLETE "lr108", "lr109", "lr110", "lr111", "lr112", "lr113", "lr114", "lr115", \ */
+/* OBSOLETE "lr116", "lr117", "lr118", "lr119", "lr120", "lr121", "lr122", "lr123", \ */
+/* OBSOLETE "lr124", "lr125", "lr126", "lr127", \ */
+/* OBSOLETE "AI0", "AI1", "AI2", "AI3", "AI4", "AI5", "AI6", "AI7", "AI8", "AI9", \ */
+/* OBSOLETE "AI10", "AI11", "AI12", "AI13", "AI14", "AI15", "FP", \ */
+/* OBSOLETE "bp", "fc", "cr", "q", \ */
+/* OBSOLETE "vab", "ops", "cps", "cfg", "cha", "chd", "chc", "rbp", "tmc", "tmr", \ */
+/* OBSOLETE "pc0", "pc1", "pc2", "mmu", "lru", "fpe", "inte", "fps", "exo", "gr1", \ */
+/* OBSOLETE "alu", "ipc", "ipa", "ipb" } */
+/* OBSOLETE */
+/* OBSOLETE /* */
+/* OBSOLETE * Converts an sdb register number to an internal gdb register number. */
+/* OBSOLETE * Currently under epi, gr96->0...gr127->31...lr0->32...lr127->159, or... */
+/* OBSOLETE * gr64->0...gr95->31, lr0->32...lr127->159. */
+/* OBSOLETE */ */
+/* OBSOLETE #define SDB_REG_TO_REGNUM(value) \ */
+/* OBSOLETE (((value) >= 96 && (value) <= 127) ? ((value) - 96) : \ */
+/* OBSOLETE ((value) >= 128 && (value) <= 255) ? ((value) - 128 + LR0_REGNUM) : \ */
+/* OBSOLETE (value)) */
+/* OBSOLETE */
+/* OBSOLETE /* */
+/* OBSOLETE * Provide the processor register numbers of some registers that are */
+/* OBSOLETE * expected/written in instructions that might change under different */
+/* OBSOLETE * register sets. Namely, gcc can compile (-mkernel-registers) so that */
+/* OBSOLETE * it uses gr64-gr95 in stead of gr96-gr127. */
+/* OBSOLETE */ */
+/* OBSOLETE #define MSP_HW_REGNUM 125 /* gr125 */ */
+/* OBSOLETE #define RAB_HW_REGNUM 126 /* gr126 */ */
+/* OBSOLETE */
+/* OBSOLETE /* Convert Processor Special register #x to REGISTER_NAMES register # */ */
+/* OBSOLETE #define SR_REGNUM(x) \ */
+/* OBSOLETE ((x) < 15 ? VAB_REGNUM + (x) \ */
+/* OBSOLETE : (x) >= 128 && (x) < 131 ? IPC_REGNUM + (x) - 128 \ */
+/* OBSOLETE : (x) == 131 ? Q_REGNUM \ */
+/* OBSOLETE : (x) == 132 ? ALU_REGNUM \ */
+/* OBSOLETE : (x) >= 133 && (x) < 136 ? BP_REGNUM + (x) - 133 \ */
+/* OBSOLETE : (x) >= 160 && (x) < 163 ? FPE_REGNUM + (x) - 160 \ */
+/* OBSOLETE : (x) == 164 ? EXO_REGNUM \ */
+/* OBSOLETE : (error ("Internal error in SR_REGNUM"), 0)) */
+/* OBSOLETE #define GR96_REGNUM 0 */
+/* OBSOLETE */
+/* OBSOLETE /* Define the return register separately, so it can be overridden for */
+/* OBSOLETE kernel procedure calling conventions. */ */
+/* OBSOLETE #define RETURN_REGNUM GR96_REGNUM */
+/* OBSOLETE #define GR1_REGNUM 200 */
+/* OBSOLETE /* This needs to be the memory stack pointer, not the register stack pointer, */
+/* OBSOLETE to make call_function work right. */ */
+/* OBSOLETE #define SP_REGNUM MSP_REGNUM */
+/* OBSOLETE #define FP_REGNUM 33 /* lr1 */ */
+/* OBSOLETE */
+/* OBSOLETE /* Return register for transparent calling convention (gr122). */ */
+/* OBSOLETE #define TPC_REGNUM (122 - 96 + GR96_REGNUM) */
+/* OBSOLETE */
+/* OBSOLETE /* Large Return Pointer (gr123). */ */
+/* OBSOLETE #define LRP_REGNUM (123 - 96 + GR96_REGNUM) */
+/* OBSOLETE */
+/* OBSOLETE /* Static link pointer (gr124). */ */
+/* OBSOLETE #define SLP_REGNUM (124 - 96 + GR96_REGNUM) */
+/* OBSOLETE */
+/* OBSOLETE /* Memory Stack Pointer (gr125). */ */
+/* OBSOLETE #define MSP_REGNUM (125 - 96 + GR96_REGNUM) */
+/* OBSOLETE */
+/* OBSOLETE /* Register allocate bound (gr126). */ */
+/* OBSOLETE #define RAB_REGNUM (126 - 96 + GR96_REGNUM) */
+/* OBSOLETE */
+/* OBSOLETE /* Register Free Bound (gr127). */ */
+/* OBSOLETE #define RFB_REGNUM (127 - 96 + GR96_REGNUM) */
+/* OBSOLETE */
+/* OBSOLETE /* Register Stack Pointer. */ */
+/* OBSOLETE #define RSP_REGNUM GR1_REGNUM */
+/* OBSOLETE #define LR0_REGNUM 32 */
+/* OBSOLETE #define BP_REGNUM 177 */
+/* OBSOLETE #define FC_REGNUM 178 */
+/* OBSOLETE #define CR_REGNUM 179 */
+/* OBSOLETE #define Q_REGNUM 180 */
+/* OBSOLETE #define VAB_REGNUM 181 */
+/* OBSOLETE #define OPS_REGNUM (VAB_REGNUM + 1) */
+/* OBSOLETE #define CPS_REGNUM (VAB_REGNUM + 2) */
+/* OBSOLETE #define CFG_REGNUM (VAB_REGNUM + 3) */
+/* OBSOLETE #define CHA_REGNUM (VAB_REGNUM + 4) */
+/* OBSOLETE #define CHD_REGNUM (VAB_REGNUM + 5) */
+/* OBSOLETE #define CHC_REGNUM (VAB_REGNUM + 6) */
+/* OBSOLETE #define RBP_REGNUM (VAB_REGNUM + 7) */
+/* OBSOLETE #define TMC_REGNUM (VAB_REGNUM + 8) */
+/* OBSOLETE #define TMR_REGNUM (VAB_REGNUM + 9) */
+/* OBSOLETE #define NPC_REGNUM (VAB_REGNUM + 10) /* pc0 */ */
+/* OBSOLETE #define PC_REGNUM (VAB_REGNUM + 11) /* pc1 */ */
+/* OBSOLETE #define PC2_REGNUM (VAB_REGNUM + 12) */
+/* OBSOLETE #define MMU_REGNUM (VAB_REGNUM + 13) */
+/* OBSOLETE #define LRU_REGNUM (VAB_REGNUM + 14) */
+/* OBSOLETE #define FPE_REGNUM (VAB_REGNUM + 15) */
+/* OBSOLETE #define INTE_REGNUM (VAB_REGNUM + 16) */
+/* OBSOLETE #define FPS_REGNUM (VAB_REGNUM + 17) */
+/* OBSOLETE #define EXO_REGNUM (VAB_REGNUM + 18) */
+/* OBSOLETE /* gr1 is defined above as 200 = VAB_REGNUM + 19 */ */
+/* OBSOLETE #define ALU_REGNUM (VAB_REGNUM + 20) */
+/* OBSOLETE #define PS_REGNUM ALU_REGNUM */
+/* OBSOLETE #define IPC_REGNUM (VAB_REGNUM + 21) */
+/* OBSOLETE #define IPA_REGNUM (VAB_REGNUM + 22) */
+/* OBSOLETE #define IPB_REGNUM (VAB_REGNUM + 23) */
+/* OBSOLETE */
+/* OBSOLETE #endif /* !defined(REGISTER_NAMES) */ */
+/* OBSOLETE */
+/* OBSOLETE /* Total amount of space needed to store our copies of the machine's */
+/* OBSOLETE register state, the array `registers'. */ */
+/* OBSOLETE #define REGISTER_BYTES (NUM_REGS * 4) */
+/* OBSOLETE */
+/* OBSOLETE /* Index within `registers' of the first byte of the space for */
+/* OBSOLETE register N. */ */
+/* OBSOLETE #define REGISTER_BYTE(N) ((N)*4) */
+/* OBSOLETE */
+/* OBSOLETE /* Number of bytes of storage in the actual machine representation */
+/* OBSOLETE for register N. */ */
+/* OBSOLETE */
+/* OBSOLETE /* All regs are 4 bytes. */ */
+/* OBSOLETE */
+/* OBSOLETE #define REGISTER_RAW_SIZE(N) (4) */
+/* OBSOLETE */
+/* OBSOLETE /* Number of bytes of storage in the program's representation */
+/* OBSOLETE for register N. */ */
+/* OBSOLETE */
+/* OBSOLETE /* All regs are 4 bytes. */ */
+/* OBSOLETE */
+/* OBSOLETE #define REGISTER_VIRTUAL_SIZE(N) (4) */
+/* OBSOLETE */
+/* OBSOLETE /* Largest value REGISTER_RAW_SIZE can have. */ */
+/* OBSOLETE */
+/* OBSOLETE #define MAX_REGISTER_RAW_SIZE (4) */
+/* OBSOLETE */
+/* OBSOLETE /* Largest value REGISTER_VIRTUAL_SIZE can have. */ */
+/* OBSOLETE */
+/* OBSOLETE #define MAX_REGISTER_VIRTUAL_SIZE (4) */
+/* OBSOLETE */
+/* OBSOLETE /* Return the GDB type object for the "standard" data type */
+/* OBSOLETE of data in register N. */ */
+/* OBSOLETE */
+/* OBSOLETE #define REGISTER_VIRTUAL_TYPE(N) \ */
+/* OBSOLETE (((N) == PC_REGNUM || (N) == LRP_REGNUM || (N) == SLP_REGNUM \ */
+/* OBSOLETE || (N) == MSP_REGNUM || (N) == RAB_REGNUM || (N) == RFB_REGNUM \ */
+/* OBSOLETE || (N) == GR1_REGNUM || (N) == FP_REGNUM || (N) == LR0_REGNUM \ */
+/* OBSOLETE || (N) == NPC_REGNUM || (N) == PC2_REGNUM) \ */
+/* OBSOLETE ? lookup_pointer_type (builtin_type_void) : builtin_type_int) */
+/* OBSOLETE \f */
+/* OBSOLETE /* Store the address of the place in which to copy the structure the */
+/* OBSOLETE subroutine will return. This is called from call_function. */ */
+/* OBSOLETE /* On the a29k the LRP points to the part of the structure beyond the first */
+/* OBSOLETE 16 words. */ */
+/* OBSOLETE #define STORE_STRUCT_RETURN(ADDR, SP) \ */
+/* OBSOLETE write_register (LRP_REGNUM, (ADDR) + 16 * 4); */
+/* OBSOLETE */
+/* OBSOLETE /* Should call_function allocate stack space for a struct return? */ */
+/* OBSOLETE /* On the a29k objects over 16 words require the caller to allocate space. */ */
+/* OBSOLETE extern use_struct_convention_fn a29k_use_struct_convention; */
+/* OBSOLETE #define USE_STRUCT_CONVENTION(gcc_p, type) a29k_use_struct_convention (gcc_p, type) */
+/* OBSOLETE */
+/* OBSOLETE /* Extract from an array REGBUF containing the (raw) register state */
+/* OBSOLETE a function return value of type TYPE, and copy that, in virtual format, */
+/* OBSOLETE into VALBUF. */ */
+/* OBSOLETE */
+/* OBSOLETE #define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \ */
+/* OBSOLETE { \ */
+/* OBSOLETE int reg_length = TYPE_LENGTH (TYPE); \ */
+/* OBSOLETE if (reg_length > 16 * 4) \ */
+/* OBSOLETE { \ */
+/* OBSOLETE reg_length = 16 * 4; \ */
+/* OBSOLETE read_memory (*((int *)(REGBUF) + LRP_REGNUM), (VALBUF) + 16 * 4, \ */
+/* OBSOLETE TYPE_LENGTH (TYPE) - 16 * 4); \ */
+/* OBSOLETE } \ */
+/* OBSOLETE memcpy ((VALBUF), ((int *)(REGBUF))+RETURN_REGNUM, reg_length); \ */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* Write into appropriate registers a function return value */
+/* OBSOLETE of type TYPE, given in virtual format. */ */
+/* OBSOLETE */
+/* OBSOLETE #define STORE_RETURN_VALUE(TYPE,VALBUF) \ */
+/* OBSOLETE { \ */
+/* OBSOLETE int reg_length = TYPE_LENGTH (TYPE); \ */
+/* OBSOLETE if (reg_length > 16 * 4) \ */
+/* OBSOLETE { \ */
+/* OBSOLETE reg_length = 16 * 4; \ */
+/* OBSOLETE write_memory (read_register (LRP_REGNUM), \ */
+/* OBSOLETE (char *)(VALBUF) + 16 * 4, \ */
+/* OBSOLETE TYPE_LENGTH (TYPE) - 16 * 4); \ */
+/* OBSOLETE } \ */
+/* OBSOLETE write_register_bytes (REGISTER_BYTE (RETURN_REGNUM), (char *)(VALBUF), \ */
+/* OBSOLETE TYPE_LENGTH (TYPE)); \ */
+/* OBSOLETE } */
+/* OBSOLETE \f/* *INDENT-OFF* */ */
+/* OBSOLETE /* The a29k user's guide documents well what the stacks look like. */
+/* OBSOLETE But what isn't so clear there is how this interracts with the */
+/* OBSOLETE symbols, or with GDB. */
+/* OBSOLETE In the following saved_msp, saved memory stack pointer (which functions */
+/* OBSOLETE as a memory frame pointer), means either */
+/* OBSOLETE a register containing the memory frame pointer or, in the case of */
+/* OBSOLETE functions with fixed size memory frames (i.e. those who don't use */
+/* OBSOLETE alloca()), the result of the calculation msp + msize. */
+/* OBSOLETE */
+/* OBSOLETE LOC_ARG, LOC_LOCAL - For GCC, these are relative to saved_msp. */
+/* OBSOLETE For high C, these are relative to msp (making alloca impossible). */
+/* OBSOLETE LOC_REGISTER, LOC_REGPARM - The register number is the number at the */
+/* OBSOLETE time the function is running (after the prologue), or in the case */
+/* OBSOLETE of LOC_REGPARM, may be a register number in the range 160-175. */
+/* OBSOLETE */
+/* OBSOLETE The compilers do things like store an argument into memory, and then put out */
+/* OBSOLETE a LOC_ARG for it, or put it into global registers and put out a */
+/* OBSOLETE LOC_REGPARM. Thus is it important to execute the first line of */
+/* OBSOLETE code (i.e. the line of the open brace, i.e. the prologue) of a function */
+/* OBSOLETE before trying to print arguments or anything. */
+/* OBSOLETE */
+/* OBSOLETE The following diagram attempts to depict what is going on in memory */
+/* OBSOLETE (see also the _a29k user's guide_) and also how that interacts with */
+/* OBSOLETE GDB frames. We arbitrarily pick fci->frame to point the same place */
+/* OBSOLETE as the register stack pointer; since we set it ourself in */
+/* OBSOLETE INIT_EXTRA_FRAME_INFO, and access it only through the FRAME_* */
+/* OBSOLETE macros, it doesn't really matter exactly how we */
+/* OBSOLETE do it. However, note that FRAME_FP is used in two ways in GDB: */
+/* OBSOLETE (1) as a "magic cookie" which uniquely identifies frames (even over */
+/* OBSOLETE calls to the inferior), (2) (in PC_IN_CALL_DUMMY [ON_STACK]) */
+/* OBSOLETE as the value of SP_REGNUM before the dummy frame was pushed. These */
+/* OBSOLETE two meanings would be incompatible for the a29k if we defined */
+/* OBSOLETE CALL_DUMMY_LOCATION == ON_STACK (but we don't, so don't worry about it). */
+/* OBSOLETE Also note that "lr1" below, while called a frame pointer */
+/* OBSOLETE in the user's guide, has only one function: To determine whether */
+/* OBSOLETE registers need to be filled in the function epilogue. */
+/* OBSOLETE */
+/* OBSOLETE Consider the code: */
+/* OBSOLETE < call bar> */
+/* OBSOLETE loc1: . . . */
+/* OBSOLETE bar: sub gr1,gr1,rsize_b */
+/* OBSOLETE . . . */
+/* OBSOLETE add mfp,msp,0 */
+/* OBSOLETE sub msp,msp,msize_b */
+/* OBSOLETE . . . */
+/* OBSOLETE < call foo > */
+/* OBSOLETE loc2: . . . */
+/* OBSOLETE foo: sub gr1,gr1,rsize_f */
+/* OBSOLETE . . . */
+/* OBSOLETE add mfp,msp,0 */
+/* OBSOLETE sub msp,msp,msize_f */
+/* OBSOLETE . . . */
+/* OBSOLETE loc3: < suppose the inferior stops here > */
+/* OBSOLETE */
+/* OBSOLETE memory stack register stack */
+/* OBSOLETE | | |____________| */
+/* OBSOLETE | | |____loc1____| */
+/* OBSOLETE +------->|___________| | | ^ */
+/* OBSOLETE | | ^ | | locals_b | | */
+/* OBSOLETE | | | | |____________| | */
+/* OBSOLETE | | | | | | | rsize_b */
+/* OBSOLETE | | | msize_b | | args_to_f | | */
+/* OBSOLETE | | | | |____________| | */
+/* OBSOLETE | | | | |____lr1_____| V */
+/* OBSOLETE | | V | |____loc2____|<----------------+ */
+/* OBSOLETE | +--->|___________|<---------mfp | ^ | */
+/* OBSOLETE | | | ^ | | locals_f | | | */
+/* OBSOLETE | | | | msize_f | |____________| | | */
+/* OBSOLETE | | | | | | | | rsize_f | */
+/* OBSOLETE | | | V | | args | | | */
+/* OBSOLETE | | |___________|<msp |____________| | | */
+/* OBSOLETE | | |_____lr1____| V | */
+/* OBSOLETE | | |___garbage__| <- gr1 <----+ | */
+/* OBSOLETE | | | | */
+/* OBSOLETE | | | | */
+/* OBSOLETE | | pc=loc3 | | */
+/* OBSOLETE | | | | */
+/* OBSOLETE | | | | */
+/* OBSOLETE | | frame cache | | */
+/* OBSOLETE | | |_________________| | | */
+/* OBSOLETE | | |rsize=rsize_b | | | */
+/* OBSOLETE | | |msize=msize_b | | | */
+/* OBSOLETE +---|--------saved_msp | | | */
+/* OBSOLETE | |frame------------------------------------|---+ */
+/* OBSOLETE | |pc=loc2 | | */
+/* OBSOLETE | |_________________| | */
+/* OBSOLETE | |rsize=rsize_f | | */
+/* OBSOLETE | |msize=msize_f | | */
+/* OBSOLETE +--------saved_msp | | */
+/* OBSOLETE |frame------------------------------------+ */
+/* OBSOLETE |pc=loc3 | */
+/* OBSOLETE |_________________| */
+/* OBSOLETE */
+/* OBSOLETE So, is that sufficiently confusing? Welcome to the 29000. */
+/* OBSOLETE Notes: */
+/* OBSOLETE * The frame for foo uses a memory frame pointer but the frame for */
+/* OBSOLETE bar does not. In the latter case the saved_msp is */
+/* OBSOLETE computed by adding msize to the saved_msp of the */
+/* OBSOLETE next frame. */
+/* OBSOLETE * msize is in the frame cache only for high C's sake. */ */
+/* OBSOLETE /* *INDENT-ON* */ */
+/* OBSOLETE */
+/* OBSOLETE */
+/* OBSOLETE void read_register_stack (); */
+/* OBSOLETE long read_register_stack_integer (); */
+/* OBSOLETE \f */
+/* OBSOLETE #define FRAME_INIT_SAVED_REGS(fi) /*no-op */ */
+/* OBSOLETE */
+/* OBSOLETE #define EXTRA_FRAME_INFO \ */
+/* OBSOLETE CORE_ADDR saved_msp; \ */
+/* OBSOLETE unsigned int rsize; \ */
+/* OBSOLETE unsigned int msize; \ */
+/* OBSOLETE unsigned char flags; */
+/* OBSOLETE */
+/* OBSOLETE /* Bits for flags in EXTRA_FRAME_INFO */ */
+/* OBSOLETE #define TRANSPARENT_FRAME 0x1 /* This is a transparent frame */ */
+/* OBSOLETE #define MFP_USED 0x2 /* A memory frame pointer is used */ */
+/* OBSOLETE */
+/* OBSOLETE /* Because INIT_FRAME_PC gets passed fromleaf, that's where we init */
+/* OBSOLETE not only ->pc and ->frame, but all the extra stuff, when called from */
+/* OBSOLETE get_prev_frame, that is. */ */
+/* OBSOLETE #define INIT_EXTRA_FRAME_INFO(fromleaf, fci) init_extra_frame_info(fci) */
+/* OBSOLETE void init_extra_frame_info (); */
+/* OBSOLETE */
+/* OBSOLETE #define INIT_FRAME_PC(fromleaf, fci) init_frame_pc(fromleaf, fci) */
+/* OBSOLETE void init_frame_pc (); */
+/* OBSOLETE \f */
+/* OBSOLETE */
+/* OBSOLETE /* FRAME_CHAIN takes a FRAME */
+/* OBSOLETE and produces the frame's chain-pointer. */
+/* OBSOLETE */
+/* OBSOLETE However, if FRAME_CHAIN_VALID returns zero, */
+/* OBSOLETE it means the given frame is the outermost one and has no caller. */ */
+/* OBSOLETE */
+/* OBSOLETE /* On the a29k, the nominal address of a frame is the address on the */
+/* OBSOLETE register stack of the return address (the one next to the incoming */
+/* OBSOLETE arguments, not down at the bottom so nominal address == stack pointer). */
+/* OBSOLETE */
+/* OBSOLETE GDB expects "nominal address" to equal contents of FP_REGNUM, */
+/* OBSOLETE at least when it comes time to create the innermost frame. */
+/* OBSOLETE However, that doesn't work for us, so when creating the innermost */
+/* OBSOLETE frame we set ->frame ourselves in INIT_EXTRA_FRAME_INFO. */ */
+/* OBSOLETE */
+/* OBSOLETE /* These are mostly dummies for the a29k because INIT_FRAME_PC */
+/* OBSOLETE sets prev->frame instead. */ */
+/* OBSOLETE /* If rsize is zero, we must be at end of stack (or otherwise hosed). */
+/* OBSOLETE If we don't check rsize, we loop forever if we see rsize == 0. */ */
+/* OBSOLETE #define FRAME_CHAIN(thisframe) \ */
+/* OBSOLETE ((thisframe)->rsize == 0 \ */
+/* OBSOLETE ? 0 \ */
+/* OBSOLETE : (thisframe)->frame + (thisframe)->rsize) */
+/* OBSOLETE */
+/* OBSOLETE /* Determine if the frame has a 'previous' and back-traceable frame. */ */
+/* OBSOLETE #define FRAME_IS_UNCHAINED(frame) ((frame)->flags & TRANSPARENT_FRAME) */
+/* OBSOLETE */
+/* OBSOLETE /* Find the previous frame of a transparent routine. */
+/* OBSOLETE * For now lets not try and trace through a transparent routine (we might */
+/* OBSOLETE * have to assume that all transparent routines are traps). */
+/* OBSOLETE */ */
+/* OBSOLETE #define FIND_PREV_UNCHAINED_FRAME(frame) 0 */
+/* OBSOLETE */
+/* OBSOLETE /* Define other aspects of the stack frame. */ */
+/* OBSOLETE */
+/* OBSOLETE /* An expression that tells us whether the function invocation represented */
+/* OBSOLETE by FI does not have a frame on the stack associated with it. */ */
+/* OBSOLETE #define FRAMELESS_FUNCTION_INVOCATION(FI) \ */
+/* OBSOLETE (frameless_look_for_prologue (FI)) */
+/* OBSOLETE */
+/* OBSOLETE /* Saved pc (i.e. return address). */ */
+/* OBSOLETE #define FRAME_SAVED_PC(fraim) \ */
+/* OBSOLETE (read_register_stack_integer ((fraim)->frame + (fraim)->rsize, 4)) */
+/* OBSOLETE */
+/* OBSOLETE /* Local variables (i.e. LOC_LOCAL) are on the memory stack, with their */
+/* OBSOLETE offsets being relative to the memory stack pointer (high C) or */
+/* OBSOLETE saved_msp (gcc). */ */
+/* OBSOLETE */
+/* OBSOLETE #define FRAME_LOCALS_ADDRESS(fi) frame_locals_address (fi) */
+/* OBSOLETE extern CORE_ADDR frame_locals_address (); */
+/* OBSOLETE */
+/* OBSOLETE /* Return number of args passed to a frame. */
+/* OBSOLETE Can return -1, meaning no way to tell. */ */
+/* OBSOLETE /* We tried going to the effort of finding the tags word and getting */
+/* OBSOLETE the argcount field from it, to support debugging assembler code. */
+/* OBSOLETE Problem was, the "argcount" field never did hold the argument */
+/* OBSOLETE count. */ */
+/* OBSOLETE #define FRAME_NUM_ARGS(fi) (-1) */
+/* OBSOLETE */
+/* OBSOLETE #define FRAME_ARGS_ADDRESS(fi) FRAME_LOCALS_ADDRESS (fi) */
+/* OBSOLETE */
+/* OBSOLETE /* Return number of bytes at start of arglist that are not really args. */ */
+/* OBSOLETE */
+/* OBSOLETE #define FRAME_ARGS_SKIP 0 */
+/* OBSOLETE */
+/* OBSOLETE /* Provide our own get_saved_register. HAVE_REGISTER_WINDOWS is insufficient */
+/* OBSOLETE because registers get renumbered on the a29k without getting saved. */ */
+/* OBSOLETE */
+/* OBSOLETE struct frame_info; */
+/* OBSOLETE void a29k_get_saved_register (char *raw_buffer, int *optimized, */
+/* OBSOLETE CORE_ADDR * addrp, struct frame_info *frame, */
+/* OBSOLETE int regnum, enum lval_type *lvalp); */
+/* OBSOLETE #define GET_SAVED_REGISTER(raw_buffer, optimized, addrp, frame, regnum, lval) \ */
+/* OBSOLETE a29k_get_saved_register (raw_buffer, optimized, addrp, frame, regnum, lval) */
+/* OBSOLETE \f */
+/* OBSOLETE /* Call function stuff. */ */
+/* OBSOLETE /* *INDENT-OFF* */ */
+/* OBSOLETE /* The dummy frame looks like this (see also the general frame picture */
+/* OBSOLETE above): */
+/* OBSOLETE */
+/* OBSOLETE register stack */
+/* OBSOLETE */
+/* OBSOLETE | | frame for function */
+/* OBSOLETE | locals_sproc | executing at time */
+/* OBSOLETE |________________| of call_function. */
+/* OBSOLETE | | We must not disturb */
+/* OBSOLETE | args_out_sproc | it. */
+/* OBSOLETE memory stack |________________| */
+/* OBSOLETE |____lr1_sproc___|<-+ */
+/* OBSOLETE | | |__retaddr_sproc_| | <-- gr1 (at start) */
+/* OBSOLETE |____________|<-msp 0 <-----------mfp_dummy_____| | */
+/* OBSOLETE | | (at start) | save regs | | */
+/* OBSOLETE | arg_slop | | pc0,pc1 | | */
+/* OBSOLETE | | | pc2,lr0 sproc | | */
+/* OBSOLETE | (16 words) | | gr96-gr124 | | */
+/* OBSOLETE |____________|<-msp 1--after | sr160-sr162 | | */
+/* OBSOLETE | | PUSH_DUMMY_FRAME| sr128-sr135 | | */
+/* OBSOLETE | struct ret | |________________| | */
+/* OBSOLETE | 17+ | | | | */
+/* OBSOLETE |____________|<- lrp | args_out_dummy | | */
+/* OBSOLETE | struct ret | | (16 words) | | */
+/* OBSOLETE | 16 | |________________| | */
+/* OBSOLETE | (16 words) | |____lr1_dummy___|--+ */
+/* OBSOLETE |____________|<- msp 2--after |_retaddr_dummy__|<- gr1 after */
+/* OBSOLETE | | struct ret | | PUSH_DUMMY_FRAME */
+/* OBSOLETE | margs17+ | area allocated | locals_inf | */
+/* OBSOLETE | | |________________| called */
+/* OBSOLETE |____________|<- msp 4--when | | function's */
+/* OBSOLETE | | inf called | args_out_inf | frame (set up */
+/* OBSOLETE | margs16 | |________________| by called */
+/* OBSOLETE | (16 words) | |_____lr1_inf____| function). */
+/* OBSOLETE |____________|<- msp 3--after | . | */
+/* OBSOLETE | | args pushed | . | */
+/* OBSOLETE | | | . | */
+/* OBSOLETE | | */
+/* OBSOLETE */
+/* OBSOLETE arg_slop: This area is so that when the call dummy adds 16 words to */
+/* OBSOLETE the msp, it won't end up larger than mfp_dummy (it is needed in the */
+/* OBSOLETE case where margs and struct_ret do not add up to at least 16 words). */
+/* OBSOLETE struct ret: This area is allocated by GDB if the return value is more */
+/* OBSOLETE than 16 words. struct ret_16 is not used on the a29k. */
+/* OBSOLETE margs: Pushed by GDB. The call dummy copies the first 16 words to */
+/* OBSOLETE args_out_dummy. */
+/* OBSOLETE retaddr_sproc: Contains the PC at the time we call the function. */
+/* OBSOLETE set by PUSH_DUMMY_FRAME and read by POP_FRAME. */
+/* OBSOLETE retaddr_dummy: This points to a breakpoint instruction in the dummy. */ */
+/* OBSOLETE /* *INDENT-ON* */ */
+/* OBSOLETE \f */
+/* OBSOLETE */
+/* OBSOLETE */
+/* OBSOLETE /* Rsize for dummy frame, in bytes. */ */
+/* OBSOLETE */
+/* OBSOLETE /* Bytes for outgoing args, lr1, and retaddr. */ */
+/* OBSOLETE #define DUMMY_ARG (2 * 4 + 16 * 4) */
+/* OBSOLETE */
+/* OBSOLETE /* Number of special registers (sr128-) to save. */ */
+/* OBSOLETE #define DUMMY_SAVE_SR128 8 */
+/* OBSOLETE /* Number of special registers (sr160-) to save. */ */
+/* OBSOLETE #define DUMMY_SAVE_SR160 3 */
+/* OBSOLETE /* Number of general (gr96- or gr64-) registers to save. */ */
+/* OBSOLETE #define DUMMY_SAVE_GREGS 29 */
+/* OBSOLETE */
+/* OBSOLETE #define DUMMY_FRAME_RSIZE \ */
+/* OBSOLETE (4 /* mfp_dummy */ \ */
+/* OBSOLETE + 4 * 4 /* pc0, pc1, pc2, lr0 */ \ */
+/* OBSOLETE + DUMMY_SAVE_GREGS * 4 \ */
+/* OBSOLETE + DUMMY_SAVE_SR160 * 4 \ */
+/* OBSOLETE + DUMMY_SAVE_SR128 * 4 \ */
+/* OBSOLETE + DUMMY_ARG \ */
+/* OBSOLETE + 4 /* pad to doubleword */ ) */
+/* OBSOLETE */
+/* OBSOLETE /* Push an empty stack frame, to record the current PC, etc. */ */
+/* OBSOLETE */
+/* OBSOLETE #define PUSH_DUMMY_FRAME push_dummy_frame() */
+/* OBSOLETE extern void push_dummy_frame (); */
+/* OBSOLETE */
+/* OBSOLETE /* Discard from the stack the innermost frame, */
+/* OBSOLETE restoring all saved registers. */ */
+/* OBSOLETE */
+/* OBSOLETE #define POP_FRAME pop_frame() */
+/* OBSOLETE extern void pop_frame (); */
+/* OBSOLETE */
+/* OBSOLETE /* This sequence of words is the instructions */
+/* OBSOLETE mtsrim cr, 15 */
+/* OBSOLETE loadm 0, 0, lr2, msp ; load first 16 words of arguments into registers */
+/* OBSOLETE add msp, msp, 16 * 4 ; point to the remaining arguments */
+/* OBSOLETE CONST_INSN: */
+/* OBSOLETE const lr0,inf ; (replaced by half of target addr) */
+/* OBSOLETE consth lr0,inf ; (replaced by other half of target addr) */
+/* OBSOLETE calli lr0, lr0 */
+/* OBSOLETE aseq 0x40,gr1,gr1 ; nop */
+/* OBSOLETE BREAKPT_INSN: */
+/* OBSOLETE asneq 0x50,gr1,gr1 ; breakpoint (replaced by local breakpoint insn) */
+/* OBSOLETE */ */
+/* OBSOLETE */
+/* OBSOLETE #error "This file is broken. GDB does not define HOST_BYTE_ORDER." */
+/* OBSOLETE #if TARGET_BYTE_ORDER == HOST_BYTE_ORDER */
+/* OBSOLETE #define BS(const) const */
+/* OBSOLETE #else */
+/* OBSOLETE #define BS(const) (((const) & 0xff) << 24) | \ */
+/* OBSOLETE (((const) & 0xff00) << 8) | \ */
+/* OBSOLETE (((const) & 0xff0000) >> 8) | \ */
+/* OBSOLETE (((const) & 0xff000000) >> 24) */
+/* OBSOLETE #endif */
+/* OBSOLETE */
+/* OBSOLETE /* Position of the "const" and blkt instructions within CALL_DUMMY in bytes. */ */
+/* OBSOLETE #define CONST_INSN (3 * 4) */
+/* OBSOLETE #define BREAKPT_INSN (7 * 4) */
+/* OBSOLETE #define CALL_DUMMY { \ */
+/* OBSOLETE BS(0x0400870f),\ */
+/* OBSOLETE BS(0x36008200|(MSP_HW_REGNUM)), \ */
+/* OBSOLETE BS(0x15000040|(MSP_HW_REGNUM<<8)|(MSP_HW_REGNUM<<16)), \ */
+/* OBSOLETE BS(0x03ff80ff), \ */
+/* OBSOLETE BS(0x02ff80ff), \ */
+/* OBSOLETE BS(0xc8008080), \ */
+/* OBSOLETE BS(0x70400101), \ */
+/* OBSOLETE BS(0x72500101)} */
+/* OBSOLETE #define CALL_DUMMY_LENGTH (8 * 4) */
+/* OBSOLETE */
+/* OBSOLETE #define CALL_DUMMY_START_OFFSET 0 /* Start execution at beginning of dummy */ */
+/* OBSOLETE */
+/* OBSOLETE /* Helper macro for FIX_CALL_DUMMY. WORDP is a long * which points to a */
+/* OBSOLETE word in target byte order; bits 0-7 and 16-23 of *WORDP are replaced with */
+/* OBSOLETE bits 0-7 and 8-15 of DATA (which is in host byte order). */ */
+/* OBSOLETE */
+/* OBSOLETE #if TARGET_BYTE_ORDER == BFD_ENDIAN_BIG */
+/* OBSOLETE #define STUFF_I16(WORDP, DATA) \ */
+/* OBSOLETE { \ */
+/* OBSOLETE *((char *)(WORDP) + 3) = ((DATA) & 0xff);\ */
+/* OBSOLETE *((char *)(WORDP) + 1) = (((DATA) >> 8) & 0xff);\ */
+/* OBSOLETE } */
+/* OBSOLETE #else /* Target is little endian. */ */
+/* OBSOLETE #define STUFF_I16(WORDP, DATA) \ */
+/* OBSOLETE { */
+/* OBSOLETE *(char *) (WORDP) = ((DATA) & 0xff); */
+/* OBSOLETE *((char *) (WORDP) + 2) = (((DATA) >> 8) & 0xff); */
+/* OBSOLETE } */
+/* OBSOLETE #endif /* Target is little endian. */ */
+/* OBSOLETE */
+/* OBSOLETE /* Insert the specified number of args and function address */
+/* OBSOLETE into a call sequence of the above form stored at DUMMYNAME. */ */
+/* OBSOLETE */
+/* OBSOLETE /* Currently this stuffs in the address of the function that we are calling. */
+/* OBSOLETE Since different a29k systems use different breakpoint instructions, it */
+/* OBSOLETE also stuffs BREAKPOINT in the right place (to avoid having to */
+/* OBSOLETE duplicate CALL_DUMMY in each tm-*.h file). */ */
+/* OBSOLETE */
+/* OBSOLETE #define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, args, type, gcc_p) \ */
+/* OBSOLETE {\ */
+/* OBSOLETE STUFF_I16((char *)dummyname + CONST_INSN, fun); \ */
+/* OBSOLETE STUFF_I16((char *)dummyname + CONST_INSN + 4, fun >> 16); \ */
+/* OBSOLETE /* FIXME memcpy ((char *)(dummyname) + BREAKPT_INSN, break_insn, 4); */ \ */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* a29k architecture has separate data & instruction memories -- wired to */
+/* OBSOLETE different pins on the chip -- and can't execute the data memory. */
+/* OBSOLETE Also, there should be space after text_end; */
+/* OBSOLETE we won't get a SIGSEGV or scribble on data space. */ */
+/* OBSOLETE */
+/* OBSOLETE #define CALL_DUMMY_LOCATION AFTER_TEXT_END */
+/* OBSOLETE */
+/* OBSOLETE /* Because of this, we need (as a kludge) to know the addresses of the */
+/* OBSOLETE text section. */ */
+/* OBSOLETE */
+/* OBSOLETE #define NEED_TEXT_START_END 1 */
+/* OBSOLETE */
+/* OBSOLETE /* How to translate register numbers in the .stab's into gdb's internal register */
+/* OBSOLETE numbers. We don't translate them, but we warn if an invalid register */
+/* OBSOLETE number is seen. Note that FIXME, we use the value "sym" as an implicit */
+/* OBSOLETE argument in printing the error message. It happens to be available where */
+/* OBSOLETE this macro is used. (This macro definition appeared in a late revision */
+/* OBSOLETE of gdb-3.91.6 and is not well tested. Also, it should be a "complaint".) */ */
+/* OBSOLETE */
+/* OBSOLETE #define STAB_REG_TO_REGNUM(num) \ */
+/* OBSOLETE (((num) > LR0_REGNUM + 127) \ */
+/* OBSOLETE ? fprintf(stderr, \ */
+/* OBSOLETE "Invalid register number %d in symbol table entry for %s\n", \ */
+/* OBSOLETE (num), SYMBOL_SOURCE_NAME (sym)), (num) \ */
+/* OBSOLETE : (num)) */
+/* OBSOLETE */
+/* OBSOLETE extern enum a29k_processor_types */
+/* OBSOLETE { */
+/* OBSOLETE a29k_unknown, */
+/* OBSOLETE */
+/* OBSOLETE /* Bit 0x400 of the CPS does *not* identify freeze mode, i.e. 29000, */
+/* OBSOLETE 29030, etc. */ */
+/* OBSOLETE a29k_no_freeze_mode, */
+/* OBSOLETE */
+/* OBSOLETE /* Bit 0x400 of the CPS does identify freeze mode, i.e. 29050. */ */
+/* OBSOLETE a29k_freeze_mode */
+/* OBSOLETE } */
+/* OBSOLETE processor_type; */
+/* OBSOLETE */
+/* OBSOLETE /* We need three arguments for a general frame specification for the */
+/* OBSOLETE "frame" or "info frame" command. */ */
+/* OBSOLETE */
+/* OBSOLETE #define SETUP_ARBITRARY_FRAME(argc, argv) setup_arbitrary_frame (argc, argv) */
+/* OBSOLETE extern struct frame_info *setup_arbitrary_frame (int, CORE_ADDR *); */
-/* Target machine description for VxWorks on the 29k, for GDB, the GNU debugger.
- Copyright 1994, 1995, 1998, 1999, 2000 Free Software Foundation, Inc.
- Contributed by Cygnus Support.
-
- This file is part of GDB.
-
- 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.
-
- 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.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA. */
-
-#include "regcache.h"
-#include "value.h"
-#include "a29k/tm-a29k.h"
-#include "tm-vxworks.h"
-
-/* Number of registers in a ptrace_getregs call. */
-
-#define VX_NUM_REGS (NUM_REGS)
-
-/* Number of registers in a ptrace_getfpregs call. */
-
-/* #define VX_SIZE_FPREGS */
-
-/* This is almost certainly the wrong place for this: */
-#define LR2_REGNUM 34
-\f
-
-/* Vxworks has its own CALL_DUMMY since it manages breakpoints in the kernel */
-
-#undef CALL_DUMMY
-
-/* Replace the breakpoint instruction in the CALL_DUMMY with a nop.
- For Vxworks, the breakpoint is set and deleted by calls to
- CALL_DUMMY_BREAK_SET and CALL_DUMMY_BREAK_DELETE. */
-
-#error "This file is broken. GDB does not define HOST_BYTE_ORDER."
-#if TARGET_BYTE_ORDER == HOST_BYTE_ORDER
-#define CALL_DUMMY {0x0400870f,\
- 0x36008200|(MSP_HW_REGNUM), \
- 0x15000040|(MSP_HW_REGNUM<<8)|(MSP_HW_REGNUM<<16), \
- 0x03ff80ff, 0x02ff80ff, 0xc8008080, 0x70400101, 0x70400101}
-#else /* Byte order differs. */
-#define CALL_DUMMY {0x0f870004,\
- 0x00820036|(MSP_HW_REGNUM << 24), \
- 0x40000015|(MSP_HW_REGNUM<<8)|(MSP_HW_REGNUM<<16), \
- 0xff80ff03, 0xff80ff02, 0x808000c8, 0x01014070, 0x01014070}
-#endif /* Byte order differs. */
-
-
-/* For the basic CALL_DUMMY definitions, see "tm-29k.h." We use the
- same CALL_DUMMY code, but define FIX_CALL_DUMMY (and related macros)
- locally to handle remote debugging of VxWorks targets. The difference
- is in the setting and clearing of the breakpoint at the end of the
- CALL_DUMMY code fragment; under VxWorks, we can't simply insert a
- breakpoint instruction into the code, since that would interfere with
- the breakpoint management mechanism on the target.
- Note that CALL_DUMMY is a piece of code that is used to call any C function
- thru VxGDB */
-
-/* The offset of the instruction within the CALL_DUMMY code where we
- want the inferior to stop after the function call has completed.
- call_function_by_hand () sets a breakpoint here (via CALL_DUMMY_BREAK_SET),
- which POP_FRAME later deletes (via CALL_DUMMY_BREAK_DELETE). */
-
-#define CALL_DUMMY_STOP_OFFSET (7 * 4)
-
-/* The offset of the first instruction of the CALL_DUMMY code fragment
- relative to the frame pointer for a dummy frame. This is equal to
- the size of the CALL_DUMMY plus the arg_slop area size (see the diagram
- in "tm-29k.h"). */
-/* PAD : the arg_slop area size doesn't appear to me to be useful since, the
- call dummy code no longer modify the msp. See below. This must be checked. */
-
-#define CALL_DUMMY_OFFSET_IN_FRAME (CALL_DUMMY_LENGTH + 16 * 4)
-
-/* Insert the specified number of args and function address
- into a CALL_DUMMY sequence stored at DUMMYNAME, replace the third
- instruction (add msp, msp, 16*4) with a nop, and leave the final nop.
- We can't keep using a CALL_DUMMY that modify the msp since, for VxWorks,
- CALL_DUMMY is stored in the Memory Stack. Adding 16 words to the msp
- would then make possible for the inferior to overwrite the CALL_DUMMY code,
- thus creating a lot of trouble when exiting the inferior to come back in
- a CALL_DUMMY code that no longer exists... Furthermore, ESF are also stored
- from the msp in the memory stack. If msp is set higher than the dummy code,
- an ESF may clobber this code. */
-
-#if TARGET_BYTE_ORDER == BFD_ENDIAN_BIG
-#define NOP_INSTR 0x70400101
-#else /* Target is little endian */
-#define NOP_INSTR 0x01014070
-#endif
-
-#undef FIX_CALL_DUMMY
-#define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, args, type, gcc_p) \
- { \
- *(int *)((char *)dummyname + 8) = NOP_INSTR; \
- STUFF_I16((char *)dummyname + CONST_INSN, fun); \
- STUFF_I16((char *)dummyname + CONST_INSN + 4, fun >> 16); \
- }
-
-/* For VxWorks, CALL_DUMMY must be stored in the stack of the task that is
- being debugged and executed "in the context of" this task */
-
-#undef CALL_DUMMY_LOCATION
-#define CALL_DUMMY_LOCATION ON_STACK
-
-/* Set or delete a breakpoint at the location within a CALL_DUMMY code
- fragment where we want the target program to stop after the function
- call is complete. CALL_DUMMY_ADDR is the address of the first
- instruction in the CALL_DUMMY. DUMMY_FRAME_ADDR is the value of the
- frame pointer in the dummy frame.
-
- NOTE: in the both of the following definitions, we take advantage of
- knowledge of the implementation of the target breakpoint operation,
- in that we pass a null pointer as the second argument. It seems
- reasonable to assume that any target requiring the use of
- CALL_DUMMY_BREAK_{SET,DELETE} will not store the breakpoint
- shadow contents in GDB; in any case, this assumption is vaild
- for all VxWorks-related targets. */
-
-#define CALL_DUMMY_BREAK_SET(call_dummy_addr) \
- target_insert_breakpoint ((call_dummy_addr) + CALL_DUMMY_STOP_OFFSET, \
- (char *) 0)
-
-#define CALL_DUMMY_BREAK_DELETE(dummy_frame_addr) \
- target_remove_breakpoint ((dummy_frame_addr) - (CALL_DUMMY_OFFSET_IN_FRAME \
- - CALL_DUMMY_STOP_OFFSET), \
- (char *) 0)
-
-/* Return nonzero if the pc is executing within a CALL_DUMMY frame. */
-
-#define PC_IN_CALL_DUMMY(pc, sp, frame_address) \
- ((pc) >= (sp) \
- && (pc) <= (sp) + CALL_DUMMY_OFFSET_IN_FRAME + CALL_DUMMY_LENGTH)
-
-/* Defining this prevents us from trying to pass a structure-valued argument
- to a function called via the CALL_DUMMY mechanism. This is not handled
- properly in call_function_by_hand (), and the fix might require re-writing
- the CALL_DUMMY handling for all targets (at least, a clean solution
- would probably require this). Arguably, this should go in "tm-29k.h"
- rather than here. */
-
-#define STRUCT_VAL_ARGS_UNSUPPORTED
-
-#define BKPT_OFFSET (7 * 4)
-#define BKPT_INSTR 0x72500101
-
-#undef FIX_CALL_DUMMY
-#define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, args, type, gcc_p) \
- {\
- STUFF_I16((char *)dummyname + CONST_INSN, fun);\
- STUFF_I16((char *)dummyname + CONST_INSN + 4, fun >> 16);\
- *(int *)((char *)dummyname + BKPT_OFFSET) = BKPT_INSTR;\
- }
-\f
-
-/* Offsets into jmp_buf. They are derived from VxWorks' REG_SET struct
- (see VxWorks' setjmp.h). Note that Sun2, Sun3 and SunOS4 and VxWorks have
- different REG_SET structs, hence different layouts for the jmp_buf struct.
- Only JB_PC is needed for getting the saved PC value. */
-
-#define JB_ELEMENT_SIZE 4 /* size of each element in jmp_buf */
-#define JB_PC 3 /* offset of pc (pc1) in jmp_buf */
-
-/* Figure out where the longjmp will land. We expect that we have just entered
- longjmp and haven't yet setup the stack frame, so the args are still in the
- output regs. lr2 (LR2_REGNUM) points at the jmp_buf structure from which we
- extract the pc (JB_PC) that we will land at. The pc is copied into ADDR.
- This routine returns true on success */
-
-#define GET_LONGJMP_TARGET(ADDR) get_longjmp_target(ADDR)
-extern int get_longjmp_target (CORE_ADDR *);
-
-/* VxWorks adjusts the PC after a breakpoint has been hit. */
-
-#undef DECR_PC_AFTER_BREAK
-#define DECR_PC_AFTER_BREAK 0
-
-/* Do whatever promotions are appropriate on a value being returned
- from a function. VAL is the user-supplied value, and FUNC_TYPE
- is the return type of the function if known, else 0.
-
- For the Am29k, as far as I understand, if the function return type is known,
- cast the value to that type; otherwise, ensure that integer return values
- fill all of gr96.
-
- This definition really belongs in "tm-29k.h", since it applies
- to most Am29K-based systems; but once moved into that file, it might
- need to be redefined for all Am29K-based targets that also redefine
- STORE_RETURN_VALUE. For now, to be safe, we define it here. */
-
-#define PROMOTE_RETURN_VALUE(val, func_type) \
- do { \
- if (func_type) \
- val = value_cast (func_type, val); \
- if ((TYPE_CODE (VALUE_TYPE (val)) == TYPE_CODE_INT \
- || TYPE_CODE (VALUE_TYPE (val)) == TYPE_CODE_ENUM) \
- && TYPE_LENGTH (VALUE_TYPE (val)) < REGISTER_RAW_SIZE (0)) \
- val = value_cast (builtin_type_int, val); \
- } while (0)
-
-extern int vx29k_frame_chain_valid (CORE_ADDR, struct frame_info *);
-#define FRAME_CHAIN_VALID(chain, thisframe) vx29k_frame_chain_valid (chain, thisframe)
-
-extern CORE_ADDR frame_saved_call_site ();
-
-#undef PREPARE_TO_INIT_FRAME_INFO
-#define PREPARE_TO_INIT_FRAME_INFO(fci) do { \
- long current_msp = read_register (MSP_REGNUM); \
- if (PC_IN_CALL_DUMMY (fci->pc, current_msp, 0)) \
- { \
- fci->rsize = DUMMY_FRAME_RSIZE; \
- fci->msize = 0; \
- fci->saved_msp = \
- read_register_stack_integer (fci->frame + DUMMY_FRAME_RSIZE - 4, 4); \
- fci->flags |= (TRANSPARENT|MFP_USED); \
- return; \
- } \
- } while (0)
+/* OBSOLETE /* Target machine description for VxWorks on the 29k, for GDB, the GNU debugger. */
+/* OBSOLETE Copyright 1994, 1995, 1998, 1999, 2000 Free Software Foundation, Inc. */
+/* OBSOLETE Contributed by Cygnus Support. */
+/* OBSOLETE */
+/* OBSOLETE This file is part of GDB. */
+/* OBSOLETE */
+/* OBSOLETE This program is free software; you can redistribute it and/or modify */
+/* OBSOLETE it under the terms of the GNU General Public License as published by */
+/* OBSOLETE the Free Software Foundation; either version 2 of the License, or */
+/* OBSOLETE (at your option) any later version. */
+/* OBSOLETE */
+/* OBSOLETE This program is distributed in the hope that it will be useful, */
+/* OBSOLETE but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* OBSOLETE MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* OBSOLETE GNU General Public License for more details. */
+/* OBSOLETE */
+/* OBSOLETE You should have received a copy of the GNU General Public License */
+/* OBSOLETE along with this program; if not, write to the Free Software */
+/* OBSOLETE Foundation, Inc., 59 Temple Place - Suite 330, */
+/* OBSOLETE Boston, MA 02111-1307, USA. */ */
+/* OBSOLETE */
+/* OBSOLETE #include "regcache.h" */
+/* OBSOLETE #include "value.h" */
+/* OBSOLETE #include "a29k/tm-a29k.h" */
+/* OBSOLETE #include "tm-vxworks.h" */
+/* OBSOLETE */
+/* OBSOLETE /* Number of registers in a ptrace_getregs call. */ */
+/* OBSOLETE */
+/* OBSOLETE #define VX_NUM_REGS (NUM_REGS) */
+/* OBSOLETE */
+/* OBSOLETE /* Number of registers in a ptrace_getfpregs call. */ */
+/* OBSOLETE */
+/* OBSOLETE /* #define VX_SIZE_FPREGS */ */
+/* OBSOLETE */
+/* OBSOLETE /* This is almost certainly the wrong place for this: */ */
+/* OBSOLETE #define LR2_REGNUM 34 */
+/* OBSOLETE \f */
+/* OBSOLETE */
+/* OBSOLETE /* Vxworks has its own CALL_DUMMY since it manages breakpoints in the kernel */ */
+/* OBSOLETE */
+/* OBSOLETE #undef CALL_DUMMY */
+/* OBSOLETE */
+/* OBSOLETE /* Replace the breakpoint instruction in the CALL_DUMMY with a nop. */
+/* OBSOLETE For Vxworks, the breakpoint is set and deleted by calls to */
+/* OBSOLETE CALL_DUMMY_BREAK_SET and CALL_DUMMY_BREAK_DELETE. */ */
+/* OBSOLETE */
+/* OBSOLETE #error "This file is broken. GDB does not define HOST_BYTE_ORDER." */
+/* OBSOLETE #if TARGET_BYTE_ORDER == HOST_BYTE_ORDER */
+/* OBSOLETE #define CALL_DUMMY {0x0400870f,\ */
+/* OBSOLETE 0x36008200|(MSP_HW_REGNUM), \ */
+/* OBSOLETE 0x15000040|(MSP_HW_REGNUM<<8)|(MSP_HW_REGNUM<<16), \ */
+/* OBSOLETE 0x03ff80ff, 0x02ff80ff, 0xc8008080, 0x70400101, 0x70400101} */
+/* OBSOLETE #else /* Byte order differs. */ */
+/* OBSOLETE #define CALL_DUMMY {0x0f870004,\ */
+/* OBSOLETE 0x00820036|(MSP_HW_REGNUM << 24), \ */
+/* OBSOLETE 0x40000015|(MSP_HW_REGNUM<<8)|(MSP_HW_REGNUM<<16), \ */
+/* OBSOLETE 0xff80ff03, 0xff80ff02, 0x808000c8, 0x01014070, 0x01014070} */
+/* OBSOLETE #endif /* Byte order differs. */ */
+/* OBSOLETE */
+/* OBSOLETE */
+/* OBSOLETE /* For the basic CALL_DUMMY definitions, see "tm-29k.h." We use the */
+/* OBSOLETE same CALL_DUMMY code, but define FIX_CALL_DUMMY (and related macros) */
+/* OBSOLETE locally to handle remote debugging of VxWorks targets. The difference */
+/* OBSOLETE is in the setting and clearing of the breakpoint at the end of the */
+/* OBSOLETE CALL_DUMMY code fragment; under VxWorks, we can't simply insert a */
+/* OBSOLETE breakpoint instruction into the code, since that would interfere with */
+/* OBSOLETE the breakpoint management mechanism on the target. */
+/* OBSOLETE Note that CALL_DUMMY is a piece of code that is used to call any C function */
+/* OBSOLETE thru VxGDB */ */
+/* OBSOLETE */
+/* OBSOLETE /* The offset of the instruction within the CALL_DUMMY code where we */
+/* OBSOLETE want the inferior to stop after the function call has completed. */
+/* OBSOLETE call_function_by_hand () sets a breakpoint here (via CALL_DUMMY_BREAK_SET), */
+/* OBSOLETE which POP_FRAME later deletes (via CALL_DUMMY_BREAK_DELETE). */ */
+/* OBSOLETE */
+/* OBSOLETE #define CALL_DUMMY_STOP_OFFSET (7 * 4) */
+/* OBSOLETE */
+/* OBSOLETE /* The offset of the first instruction of the CALL_DUMMY code fragment */
+/* OBSOLETE relative to the frame pointer for a dummy frame. This is equal to */
+/* OBSOLETE the size of the CALL_DUMMY plus the arg_slop area size (see the diagram */
+/* OBSOLETE in "tm-29k.h"). */ */
+/* OBSOLETE /* PAD : the arg_slop area size doesn't appear to me to be useful since, the */
+/* OBSOLETE call dummy code no longer modify the msp. See below. This must be checked. */ */
+/* OBSOLETE */
+/* OBSOLETE #define CALL_DUMMY_OFFSET_IN_FRAME (CALL_DUMMY_LENGTH + 16 * 4) */
+/* OBSOLETE */
+/* OBSOLETE /* Insert the specified number of args and function address */
+/* OBSOLETE into a CALL_DUMMY sequence stored at DUMMYNAME, replace the third */
+/* OBSOLETE instruction (add msp, msp, 16*4) with a nop, and leave the final nop. */
+/* OBSOLETE We can't keep using a CALL_DUMMY that modify the msp since, for VxWorks, */
+/* OBSOLETE CALL_DUMMY is stored in the Memory Stack. Adding 16 words to the msp */
+/* OBSOLETE would then make possible for the inferior to overwrite the CALL_DUMMY code, */
+/* OBSOLETE thus creating a lot of trouble when exiting the inferior to come back in */
+/* OBSOLETE a CALL_DUMMY code that no longer exists... Furthermore, ESF are also stored */
+/* OBSOLETE from the msp in the memory stack. If msp is set higher than the dummy code, */
+/* OBSOLETE an ESF may clobber this code. */ */
+/* OBSOLETE */
+/* OBSOLETE #if TARGET_BYTE_ORDER == BFD_ENDIAN_BIG */
+/* OBSOLETE #define NOP_INSTR 0x70400101 */
+/* OBSOLETE #else /* Target is little endian */ */
+/* OBSOLETE #define NOP_INSTR 0x01014070 */
+/* OBSOLETE #endif */
+/* OBSOLETE */
+/* OBSOLETE #undef FIX_CALL_DUMMY */
+/* OBSOLETE #define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, args, type, gcc_p) \ */
+/* OBSOLETE { \ */
+/* OBSOLETE *(int *)((char *)dummyname + 8) = NOP_INSTR; \ */
+/* OBSOLETE STUFF_I16((char *)dummyname + CONST_INSN, fun); \ */
+/* OBSOLETE STUFF_I16((char *)dummyname + CONST_INSN + 4, fun >> 16); \ */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* For VxWorks, CALL_DUMMY must be stored in the stack of the task that is */
+/* OBSOLETE being debugged and executed "in the context of" this task */ */
+/* OBSOLETE */
+/* OBSOLETE #undef CALL_DUMMY_LOCATION */
+/* OBSOLETE #define CALL_DUMMY_LOCATION ON_STACK */
+/* OBSOLETE */
+/* OBSOLETE /* Set or delete a breakpoint at the location within a CALL_DUMMY code */
+/* OBSOLETE fragment where we want the target program to stop after the function */
+/* OBSOLETE call is complete. CALL_DUMMY_ADDR is the address of the first */
+/* OBSOLETE instruction in the CALL_DUMMY. DUMMY_FRAME_ADDR is the value of the */
+/* OBSOLETE frame pointer in the dummy frame. */
+/* OBSOLETE */
+/* OBSOLETE NOTE: in the both of the following definitions, we take advantage of */
+/* OBSOLETE knowledge of the implementation of the target breakpoint operation, */
+/* OBSOLETE in that we pass a null pointer as the second argument. It seems */
+/* OBSOLETE reasonable to assume that any target requiring the use of */
+/* OBSOLETE CALL_DUMMY_BREAK_{SET,DELETE} will not store the breakpoint */
+/* OBSOLETE shadow contents in GDB; in any case, this assumption is vaild */
+/* OBSOLETE for all VxWorks-related targets. */ */
+/* OBSOLETE */
+/* OBSOLETE #define CALL_DUMMY_BREAK_SET(call_dummy_addr) \ */
+/* OBSOLETE target_insert_breakpoint ((call_dummy_addr) + CALL_DUMMY_STOP_OFFSET, \ */
+/* OBSOLETE (char *) 0) */
+/* OBSOLETE */
+/* OBSOLETE #define CALL_DUMMY_BREAK_DELETE(dummy_frame_addr) \ */
+/* OBSOLETE target_remove_breakpoint ((dummy_frame_addr) - (CALL_DUMMY_OFFSET_IN_FRAME \ */
+/* OBSOLETE - CALL_DUMMY_STOP_OFFSET), \ */
+/* OBSOLETE (char *) 0) */
+/* OBSOLETE */
+/* OBSOLETE /* Return nonzero if the pc is executing within a CALL_DUMMY frame. */ */
+/* OBSOLETE */
+/* OBSOLETE #define PC_IN_CALL_DUMMY(pc, sp, frame_address) \ */
+/* OBSOLETE ((pc) >= (sp) \ */
+/* OBSOLETE && (pc) <= (sp) + CALL_DUMMY_OFFSET_IN_FRAME + CALL_DUMMY_LENGTH) */
+/* OBSOLETE */
+/* OBSOLETE /* Defining this prevents us from trying to pass a structure-valued argument */
+/* OBSOLETE to a function called via the CALL_DUMMY mechanism. This is not handled */
+/* OBSOLETE properly in call_function_by_hand (), and the fix might require re-writing */
+/* OBSOLETE the CALL_DUMMY handling for all targets (at least, a clean solution */
+/* OBSOLETE would probably require this). Arguably, this should go in "tm-29k.h" */
+/* OBSOLETE rather than here. */ */
+/* OBSOLETE */
+/* OBSOLETE #define STRUCT_VAL_ARGS_UNSUPPORTED */
+/* OBSOLETE */
+/* OBSOLETE #define BKPT_OFFSET (7 * 4) */
+/* OBSOLETE #define BKPT_INSTR 0x72500101 */
+/* OBSOLETE */
+/* OBSOLETE #undef FIX_CALL_DUMMY */
+/* OBSOLETE #define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, args, type, gcc_p) \ */
+/* OBSOLETE {\ */
+/* OBSOLETE STUFF_I16((char *)dummyname + CONST_INSN, fun);\ */
+/* OBSOLETE STUFF_I16((char *)dummyname + CONST_INSN + 4, fun >> 16);\ */
+/* OBSOLETE *(int *)((char *)dummyname + BKPT_OFFSET) = BKPT_INSTR;\ */
+/* OBSOLETE } */
+/* OBSOLETE \f */
+/* OBSOLETE */
+/* OBSOLETE /* Offsets into jmp_buf. They are derived from VxWorks' REG_SET struct */
+/* OBSOLETE (see VxWorks' setjmp.h). Note that Sun2, Sun3 and SunOS4 and VxWorks have */
+/* OBSOLETE different REG_SET structs, hence different layouts for the jmp_buf struct. */
+/* OBSOLETE Only JB_PC is needed for getting the saved PC value. */ */
+/* OBSOLETE */
+/* OBSOLETE #define JB_ELEMENT_SIZE 4 /* size of each element in jmp_buf */ */
+/* OBSOLETE #define JB_PC 3 /* offset of pc (pc1) in jmp_buf */ */
+/* OBSOLETE */
+/* OBSOLETE /* Figure out where the longjmp will land. We expect that we have just entered */
+/* OBSOLETE longjmp and haven't yet setup the stack frame, so the args are still in the */
+/* OBSOLETE output regs. lr2 (LR2_REGNUM) points at the jmp_buf structure from which we */
+/* OBSOLETE extract the pc (JB_PC) that we will land at. The pc is copied into ADDR. */
+/* OBSOLETE This routine returns true on success */ */
+/* OBSOLETE */
+/* OBSOLETE #define GET_LONGJMP_TARGET(ADDR) get_longjmp_target(ADDR) */
+/* OBSOLETE extern int get_longjmp_target (CORE_ADDR *); */
+/* OBSOLETE */
+/* OBSOLETE /* VxWorks adjusts the PC after a breakpoint has been hit. */ */
+/* OBSOLETE */
+/* OBSOLETE #undef DECR_PC_AFTER_BREAK */
+/* OBSOLETE #define DECR_PC_AFTER_BREAK 0 */
+/* OBSOLETE */
+/* OBSOLETE /* Do whatever promotions are appropriate on a value being returned */
+/* OBSOLETE from a function. VAL is the user-supplied value, and FUNC_TYPE */
+/* OBSOLETE is the return type of the function if known, else 0. */
+/* OBSOLETE */
+/* OBSOLETE For the Am29k, as far as I understand, if the function return type is known, */
+/* OBSOLETE cast the value to that type; otherwise, ensure that integer return values */
+/* OBSOLETE fill all of gr96. */
+/* OBSOLETE */
+/* OBSOLETE This definition really belongs in "tm-29k.h", since it applies */
+/* OBSOLETE to most Am29K-based systems; but once moved into that file, it might */
+/* OBSOLETE need to be redefined for all Am29K-based targets that also redefine */
+/* OBSOLETE STORE_RETURN_VALUE. For now, to be safe, we define it here. */ */
+/* OBSOLETE */
+/* OBSOLETE #define PROMOTE_RETURN_VALUE(val, func_type) \ */
+/* OBSOLETE do { \ */
+/* OBSOLETE if (func_type) \ */
+/* OBSOLETE val = value_cast (func_type, val); \ */
+/* OBSOLETE if ((TYPE_CODE (VALUE_TYPE (val)) == TYPE_CODE_INT \ */
+/* OBSOLETE || TYPE_CODE (VALUE_TYPE (val)) == TYPE_CODE_ENUM) \ */
+/* OBSOLETE && TYPE_LENGTH (VALUE_TYPE (val)) < REGISTER_RAW_SIZE (0)) \ */
+/* OBSOLETE val = value_cast (builtin_type_int, val); \ */
+/* OBSOLETE } while (0) */
+/* OBSOLETE */
+/* OBSOLETE extern int vx29k_frame_chain_valid (CORE_ADDR, struct frame_info *); */
+/* OBSOLETE #define FRAME_CHAIN_VALID(chain, thisframe) vx29k_frame_chain_valid (chain, thisframe) */
+/* OBSOLETE */
+/* OBSOLETE extern CORE_ADDR frame_saved_call_site (); */
+/* OBSOLETE */
+/* OBSOLETE #undef PREPARE_TO_INIT_FRAME_INFO */
+/* OBSOLETE #define PREPARE_TO_INIT_FRAME_INFO(fci) do { \ */
+/* OBSOLETE long current_msp = read_register (MSP_REGNUM); \ */
+/* OBSOLETE if (PC_IN_CALL_DUMMY (fci->pc, current_msp, 0)) \ */
+/* OBSOLETE { \ */
+/* OBSOLETE fci->rsize = DUMMY_FRAME_RSIZE; \ */
+/* OBSOLETE fci->msize = 0; \ */
+/* OBSOLETE fci->saved_msp = \ */
+/* OBSOLETE read_register_stack_integer (fci->frame + DUMMY_FRAME_RSIZE - 4, 4); \ */
+/* OBSOLETE fci->flags |= (TRANSPARENT|MFP_USED); \ */
+/* OBSOLETE return; \ */
+/* OBSOLETE } \ */
+/* OBSOLETE } while (0) */
-# Target: AMD 29k running VxWorks
-TDEPFILES= a29k-tdep.o remote-vx.o remote-vx29k.o xdr_ld.o xdr_ptrace.o xdr_rdb.o
-TM_FILE= tm-vx29k.h
-MT_CFLAGS = -DNO_HIF_SUPPORT
+# OBSOLETE # Target: AMD 29k running VxWorks
+# OBSOLETE TDEPFILES= a29k-tdep.o remote-vx.o remote-vx29k.o xdr_ld.o xdr_ptrace.o xdr_rdb.o
+# OBSOLETE TM_FILE= tm-vx29k.h
+# OBSOLETE MT_CFLAGS = -DNO_HIF_SUPPORT
-/* Remote debugging interface for AMD 290*0 Adapt Monitor Version 2.1d18.
- Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000,
- 2001 Free Software Foundation, Inc.
- Contributed by David Wood at New York University (wood@lab.ultra.nyu.edu).
- Adapted from work done at Cygnus Support in remote-eb.c.
-
- This file is part of GDB.
-
- 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.
-
- 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.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA. */
-
-/* This is like remote.c but is for an esoteric situation--
- having a 29k board attached to an Adapt inline monitor.
- The monitor is connected via serial line to a unix machine
- running gdb.
-
- 3/91 - developed on Sun3 OS 4.1, by David Wood
- o - I can't get binary coff to load.
- o - I can't get 19200 baud rate to work.
- 7/91 o - Freeze mode tracing can be done on a 29050. */
-
-
-
-#include "defs.h"
-#include "gdb_string.h"
-#include "inferior.h"
-#include "value.h"
-#include <ctype.h>
-#include <fcntl.h>
-#include <signal.h>
-#include <errno.h>
-#include "terminal.h"
-#include "target.h"
-#include "gdbcore.h"
-#include "regcache.h"
-
-/* This processor is getting rusty but I am trying to keep it
- up to date at least with data structure changes.
- Activate this block to compile just this file.
- */
-#define COMPILE_CHECK 0
-#if COMPILE_CHECK
-#define Q_REGNUM 0
-#define VAB_REGNUM 0
-#define CPS_REGNUM 0
-#define IPA_REGNUM 0
-#define IPB_REGNUM 0
-#define GR1_REGNUM 0
-#define LR0_REGNUM 0
-#define IPC_REGNUM 0
-#define CR_REGNUM 0
-#define BP_REGNUM 0
-#define FC_REGNUM 0
-#define INTE_REGNUM 0
-#define EXO_REGNUM 0
-#define GR96_REGNUM 0
-#define NPC_REGNUM
-#define FPE_REGNUM 0
-#define PC2_REGNUM 0
-#define FPS_REGNUM 0
-#define ALU_REGNUM 0
-#define LRU_REGNUM 0
-#define TERMINAL int
-#define RAW 1
-#define ANYP 1
-extern int a29k_freeze_mode;
-extern int processor_type;
-extern char *processor_name;
-#endif
-
-/* External data declarations */
-extern int stop_soon_quietly; /* for wait_for_inferior */
-
-/* Forward data declarations */
-extern struct target_ops adapt_ops; /* Forward declaration */
-
-/* Forward function declarations */
-static void adapt_fetch_registers ();
-static void adapt_store_registers ();
-static void adapt_close ();
-static int adapt_clear_breakpoints ();
-
-#define FREEZE_MODE (read_register(CPS_REGNUM) && 0x400)
-#define USE_SHADOW_PC ((processor_type == a29k_freeze_mode) && FREEZE_MODE)
-
-/* Can't seem to get binary coff working */
-#define ASCII_COFF /* Adapt will be downloaded with ascii coff */
-
-/* FIXME: Replace with `set remotedebug'. */
-#define LOG_FILE "adapt.log"
-#if defined (LOG_FILE)
-FILE *log_file = NULL;
-#endif
-
-static int timeout = 5;
-static char *dev_name;
-
-/* Descriptor for I/O to remote machine. Initialize it to -1 so that
- adapt_open knows that we don't have a file open when the program
- starts. */
-int adapt_desc = -1;
-
-/* stream which is fdopen'd from adapt_desc. Only valid when
- adapt_desc != -1. */
-FILE *adapt_stream;
-
-#define ON 1
-#define OFF 0
-static void
-rawmode (int desc, int turnon)
-{
-
- TERMINAL sg;
-
- if (desc < 0)
- return;
-
- ioctl (desc, TIOCGETP, &sg);
-
- if (turnon)
- {
-#ifdef HAVE_TERMIO
- sg.c_lflag &= ~(ICANON);
-#else
- sg.sg_flags |= RAW;
-#endif
- }
- else
- {
-#ifdef HAVE_TERMIO
- sg.c_lflag |= ICANON;
-#else
- sg.sg_flags &= ~(RAW);
-#endif
- }
- ioctl (desc, TIOCSETP, &sg);
-}
-
-/* Suck up all the input from the adapt */
-slurp_input (void)
-{
- char buf[8];
-
-#ifdef HAVE_TERMIO
- /* termio does the timeout for us. */
- while (read (adapt_desc, buf, 8) > 0);
-#else
- alarm (timeout);
- while (read (adapt_desc, buf, 8) > 0);
- alarm (0);
-#endif
-}
-
-/* Read a character from the remote system, doing all the fancy
- timeout stuff. */
-static int
-readchar (void)
-{
- char buf;
-
- buf = '\0';
-#ifdef HAVE_TERMIO
- /* termio does the timeout for us. */
- read (adapt_desc, &buf, 1);
-#else
- alarm (timeout);
- if (read (adapt_desc, &buf, 1) < 0)
- {
- if (errno == EINTR)
- error ("Timeout reading from remote system.");
- else
- perror_with_name ("remote");
- }
- alarm (0);
-#endif
-
- if (buf == '\0')
- error ("Timeout reading from remote system.");
-#if defined (LOG_FILE)
- putc (buf & 0x7f, log_file);
-#endif
- return buf & 0x7f;
-}
-
-/* Keep discarding input from the remote system, until STRING is found.
- Let the user break out immediately. */
-static void
-expect (char *string)
-{
- char *p = string;
-
- fflush (adapt_stream);
- immediate_quit++;
- while (1)
- {
- if (readchar () == *p)
- {
- p++;
- if (*p == '\0')
- {
- immediate_quit--;
- return;
- }
- }
- else
- p = string;
- }
-}
-
-/* Keep discarding input until we see the adapt prompt.
-
- The convention for dealing with the prompt is that you
- o give your command
- o *then* wait for the prompt.
-
- Thus the last thing that a procedure does with the serial line
- will be an expect_prompt(). Exception: adapt_resume does not
- wait for the prompt, because the terminal is being handed over
- to the inferior. However, the next thing which happens after that
- is a adapt_wait which does wait for the prompt.
- Note that this includes abnormal exit, e.g. error(). This is
- necessary to prevent getting into states from which we can't
- recover. */
-static void
-expect_prompt (void)
-{
-#if defined (LOG_FILE)
- /* This is a convenient place to do this. The idea is to do it often
- enough that we never lose much data if we terminate abnormally. */
- fflush (log_file);
-#endif
- fflush (adapt_stream);
- expect ("\n# ");
-}
-
-/* Get a hex digit from the remote system & return its value.
- If ignore_space is nonzero, ignore spaces (not newline, tab, etc). */
-static int
-get_hex_digit (int ignore_space)
-{
- int ch;
- while (1)
- {
- ch = readchar ();
- if (ch >= '0' && ch <= '9')
- return ch - '0';
- else if (ch >= 'A' && ch <= 'F')
- return ch - 'A' + 10;
- else if (ch >= 'a' && ch <= 'f')
- return ch - 'a' + 10;
- else if (ch == ' ' && ignore_space)
- ;
- else
- {
- expect_prompt ();
- error ("Invalid hex digit from remote system.");
- }
- }
-}
-
-/* Get a byte from adapt_desc and put it in *BYT. Accept any number
- leading spaces. */
-static void
-get_hex_byte (char *byt)
-{
- int val;
-
- val = get_hex_digit (1) << 4;
- val |= get_hex_digit (0);
- *byt = val;
-}
-
-/* Read a 32-bit hex word from the adapt, preceded by a space */
-static long
-get_hex_word (void)
-{
- long val;
- int j;
-
- val = 0;
- for (j = 0; j < 8; j++)
- val = (val << 4) + get_hex_digit (j == 0);
- return val;
-}
-/* Get N 32-bit hex words from remote, each preceded by a space
- and put them in registers starting at REGNO. */
-static void
-get_hex_regs (int n, int regno)
-{
- long val;
- while (n--)
- {
- val = get_hex_word ();
- supply_register (regno++, (char *) &val);
- }
-}
-/* Called when SIGALRM signal sent due to alarm() timeout. */
-#ifndef HAVE_TERMIO
-
-volatile int n_alarms;
-
-void
-adapt_timer (void)
-{
-#if 0
- if (kiodebug)
- printf ("adapt_timer called\n");
-#endif
- n_alarms++;
-}
-#endif
-
-/* malloc'd name of the program on the remote system. */
-static char *prog_name = NULL;
-
-/* Number of SIGTRAPs we need to simulate. That is, the next
- NEED_ARTIFICIAL_TRAP calls to adapt_wait should just return
- SIGTRAP without actually waiting for anything. */
-
-static int need_artificial_trap = 0;
-
-void
-adapt_kill (char *arg, int from_tty)
-{
- fprintf (adapt_stream, "K");
- fprintf (adapt_stream, "\r");
- expect_prompt ();
-}
-/*
- * Download a file specified in 'args', to the adapt.
- * FIXME: Assumes the file to download is a binary coff file.
- */
-static void
-adapt_load (char *args, int fromtty)
-{
- FILE *fp;
- int n;
- char buffer[1024];
-
- if (!adapt_stream)
- {
- printf_filtered ("Adapt not open. Use 'target' command to open adapt\n");
- return;
- }
-
- /* OK, now read in the file. Y=read, C=COFF, T=dTe port
- 0=start address. */
-
-#ifdef ASCII_COFF /* Ascii coff */
- fprintf (adapt_stream, "YA T,0\r");
- fflush (adapt_stream); /* Just in case */
- /* FIXME: should check args for only 1 argument */
- sprintf (buffer, "cat %s | btoa > /tmp/#adapt-btoa", args);
- system (buffer);
- fp = fopen ("/tmp/#adapt-btoa", "r");
- rawmode (adapt_desc, OFF);
- while (n = fread (buffer, 1, 1024, fp))
- {
- do
- {
- n -= write (adapt_desc, buffer, n);
- }
- while (n > 0);
- if (n < 0)
- {
- perror ("writing ascii coff");
- break;
- }
- }
- fclose (fp);
- rawmode (adapt_desc, ON);
- system ("rm /tmp/#adapt-btoa");
-#else /* Binary coff - can't get it to work . */
- fprintf (adapt_stream, "YC T,0\r");
- fflush (adapt_stream); /* Just in case */
- if (!(fp = fopen (args, "r")))
- {
- printf_filtered ("Can't open %s\n", args);
- return;
- }
- while (n = fread (buffer, 1, 512, fp))
- {
- do
- {
- n -= write (adapt_desc, buffer, n);
- }
- while (n > 0);
- if (n < 0)
- {
- perror ("writing ascii coff");
- break;
- }
- }
- fclose (fp);
-#endif
- expect_prompt (); /* Skip garbage that comes out */
- fprintf (adapt_stream, "\r");
- expect_prompt ();
-}
-
-/* This is called not only when we first attach, but also when the
- user types "run" after having attached. */
-void
-adapt_create_inferior (char *execfile, char *args, char **env)
-{
- int entry_pt;
-
- if (args && *args)
- error ("Can't pass arguments to remote adapt process.");
-
- if (execfile == 0 || exec_bfd == 0)
- error ("No executable file specified");
-
- entry_pt = (int) bfd_get_start_address (exec_bfd);
-
- if (adapt_stream)
- {
- adapt_kill (NULL, NULL);
- adapt_clear_breakpoints ();
- init_wait_for_inferior ();
- /* Clear the input because what the adapt sends back is different
- * depending on whether it was running or not.
- */
- slurp_input (); /* After this there should be a prompt */
- fprintf (adapt_stream, "\r");
- expect_prompt ();
- printf_filtered ("Do you want to download '%s' (y/n)? [y] : ", prog_name);
- {
- char buffer[10];
- gets (buffer);
- if (*buffer != 'n')
- {
- adapt_load (prog_name, 0);
- }
- }
-
-#ifdef NOTDEF
- /* Set the PC and wait for a go/cont */
- fprintf (adapt_stream, "G %x,N\r", entry_pt);
- printf_filtered ("Now use the 'continue' command to start.\n");
- expect_prompt ();
-#else
- insert_breakpoints (); /* Needed to get correct instruction in cache */
- proceed (entry_pt, TARGET_SIGNAL_DEFAULT, 0);
-#endif
-
- }
- else
- {
- printf_filtered ("Adapt not open yet.\n");
- }
-}
-
-/* Translate baud rates from integers to damn B_codes. Unix should
- have outgrown this crap years ago, but even POSIX wouldn't buck it. */
-
-#ifndef B19200
-#define B19200 EXTA
-#endif
-#ifndef B38400
-#define B38400 EXTB
-#endif
-
-static struct
-{
- int rate, damn_b;
-}
-baudtab[] =
-{
- {
- 0, B0
- }
- ,
- {
- 50, B50
- }
- ,
- {
- 75, B75
- }
- ,
- {
- 110, B110
- }
- ,
- {
- 134, B134
- }
- ,
- {
- 150, B150
- }
- ,
- {
- 200, B200
- }
- ,
- {
- 300, B300
- }
- ,
- {
- 600, B600
- }
- ,
- {
- 1200, B1200
- }
- ,
- {
- 1800, B1800
- }
- ,
- {
- 2400, B2400
- }
- ,
- {
- 4800, B4800
- }
- ,
- {
- 9600, B9600
- }
- ,
- {
- 19200, B19200
- }
- ,
- {
- 38400, B38400
- }
- ,
- {
- -1, -1
- }
- ,
-};
-
-static int
-damn_b (int rate)
-{
- int i;
-
- for (i = 0; baudtab[i].rate != -1; i++)
- if (rate == baudtab[i].rate)
- return baudtab[i].damn_b;
- return B38400; /* Random */
-}
-
-
-/* Open a connection to a remote debugger.
- NAME is the filename used for communication, then a space,
- then the baud rate.
- */
-
-static int baudrate = 9600;
-static void
-adapt_open (char *name, int from_tty)
-{
- TERMINAL sg;
- unsigned int prl;
- char *p;
-
- /* Find the first whitespace character, it separates dev_name from
- prog_name. */
- if (name == 0)
- goto erroid;
-
- for (p = name;
- *p != '\0' && !isspace (*p); p++)
- ;
- if (*p == '\0')
- erroid:
- error ("\
-Please include the name of the device for the serial port,\n\
-the baud rate, and the name of the program to run on the remote system.");
- dev_name = (char *) xmalloc (p - name + 1);
- strncpy (dev_name, name, p - name);
- dev_name[p - name] = '\0';
-
- /* Skip over the whitespace after dev_name */
- for (; isspace (*p); p++)
- /*EMPTY */ ;
-
- if (1 != sscanf (p, "%d ", &baudrate))
- goto erroid;
-
- /* Skip the number and then the spaces */
- for (; isdigit (*p); p++)
- /*EMPTY */ ;
- for (; isspace (*p); p++)
- /*EMPTY */ ;
-
- if (prog_name != NULL)
- xfree (prog_name);
- prog_name = savestring (p, strlen (p));
-
- adapt_close (0);
-
- adapt_desc = open (dev_name, O_RDWR);
- if (adapt_desc < 0)
- perror_with_name (dev_name);
- ioctl (adapt_desc, TIOCGETP, &sg);
-#if ! defined(COMPILE_CHECK)
-#ifdef HAVE_TERMIO
- sg.c_cc[VMIN] = 0; /* read with timeout. */
- sg.c_cc[VTIME] = timeout * 10;
- sg.c_lflag &= ~(ICANON | ECHO);
- sg.c_cflag = (sg.c_cflag & ~CBAUD) | damn_b (baudrate);
-#else
- sg.sg_ispeed = damn_b (baudrate);
- sg.sg_ospeed = damn_b (baudrate);
- sg.sg_flags |= RAW | ANYP;
- sg.sg_flags &= ~ECHO;
-#endif
-
- ioctl (adapt_desc, TIOCSETP, &sg);
- adapt_stream = fdopen (adapt_desc, "r+");
-#endif /* compile_check */
- push_target (&adapt_ops);
-
-#ifndef HAVE_TERMIO
-#ifndef NO_SIGINTERRUPT
- /* Cause SIGALRM's to make reads fail with EINTR instead of resuming
- the read. */
- if (siginterrupt (SIGALRM, 1) != 0)
- perror ("adapt_open: error in siginterrupt");
-#endif
-
- /* Set up read timeout timer. */
- if ((void (*)) signal (SIGALRM, adapt_timer) == (void (*)) -1)
- perror ("adapt_open: error in signal");
-#endif
-
-#if defined (LOG_FILE)
- log_file = fopen (LOG_FILE, "w");
- if (log_file == NULL)
- perror_with_name (LOG_FILE);
-#endif
-
- /* Put this port into NORMAL mode, send the 'normal' character */
- write (adapt_desc, "\ 1", 1); /* Control A */
- write (adapt_desc, "\r", 1);
- expect_prompt ();
-
- /* Hello? Are you there? */
- write (adapt_desc, "\r", 1);
-
- expect_prompt ();
-
- /* Clear any break points */
- adapt_clear_breakpoints ();
-
- /* Print out some stuff, letting the user now what's going on */
- printf_filtered ("Connected to an Adapt via %s.\n", dev_name);
- /* FIXME: can this restriction be removed? */
- printf_filtered ("Remote debugging using virtual addresses works only\n");
- printf_filtered ("\twhen virtual addresses map 1:1 to physical addresses.\n");
- if (processor_type != a29k_freeze_mode)
- {
- fprintf_filtered (gdb_stderr,
- "Freeze-mode debugging not available, and can only be done on an A29050.\n");
- }
-}
-
-/* Close out all files and local state before this target loses control. */
-
-static void
-adapt_close (int quitting)
-{
-
- /* Clear any break points */
- adapt_clear_breakpoints ();
-
- /* Put this port back into REMOTE mode */
- if (adapt_stream)
- {
- fflush (adapt_stream);
- sleep (1); /* Let any output make it all the way back */
- write (adapt_desc, "R\r", 2);
- }
-
- /* Due to a bug in Unix, fclose closes not only the stdio stream,
- but also the file descriptor. So we don't actually close
- adapt_desc. */
- if (adapt_stream)
- fclose (adapt_stream); /* This also closes adapt_desc */
- if (adapt_desc >= 0)
- /* close (adapt_desc); */
-
- /* Do not try to close adapt_desc again, later in the program. */
- adapt_stream = NULL;
- adapt_desc = -1;
-
-#if defined (LOG_FILE)
- if (log_file)
- {
- if (ferror (log_file))
- printf_filtered ("Error writing log file.\n");
- if (fclose (log_file) != 0)
- printf_filtered ("Error closing log file.\n");
- log_file = NULL;
- }
-#endif
-}
-
-/* Attach to the target that is already loaded and possibly running */
-static void
-adapt_attach (char *args, int from_tty)
-{
-
- if (from_tty)
- printf_filtered ("Attaching to remote program %s.\n", prog_name);
-
- /* Send the adapt a kill. It is ok if it is not already running */
- fprintf (adapt_stream, "K\r");
- fflush (adapt_stream);
- expect_prompt (); /* Slurp the echo */
-}
-
-
-/* Terminate the open connection to the remote debugger.
- Use this when you want to detach and do something else
- with your gdb. */
-void
-adapt_detach (char *args, int from_tty)
-{
-
- if (adapt_stream)
- { /* Send it on its way (tell it to continue) */
- adapt_clear_breakpoints ();
- fprintf (adapt_stream, "G\r");
- }
-
- pop_target (); /* calls adapt_close to do the real work */
- if (from_tty)
- printf_filtered ("Ending remote %s debugging\n", target_shortname);
-}
-
-/* Tell the remote machine to resume. */
-
-void
-adapt_resume (ptid_t ptid, int step, enum target_signal sig)
-{
- if (step)
- {
- write (adapt_desc, "t 1,s\r", 6);
- /* Wait for the echo. */
- expect ("t 1,s\r\n");
- /* Then comes a line containing the instruction we stepped to. */
- expect ("@");
- /* Then we get the prompt. */
- expect_prompt ();
-
- /* Force the next adapt_wait to return a trap. Not doing anything
- about I/O from the target means that the user has to type
- "continue" to see any. FIXME, this should be fixed. */
- need_artificial_trap = 1;
- }
- else
- {
- write (adapt_desc, "G\r", 2);
- /* Swallow the echo. */
- expect_prompt ();
- }
-}
-
-/* Wait until the remote machine stops, then return,
- storing status in STATUS just as `wait' would. */
-
-ptid_t
-adapt_wait (ptid_t ptid, struct target_waitstatus *status)
-{
- /* Strings to look for. '?' means match any single character.
- Note that with the algorithm we use, the initial character
- of the string cannot recur in the string, or we will not
- find some cases of the string in the input. */
-
- static char bpt[] = "@";
- /* It would be tempting to look for "\n[__exit + 0x8]\n"
- but that requires loading symbols with "yc i" and even if
- we did do that we don't know that the file has symbols. */
- static char exitmsg[] = "@????????I JMPTI GR121,LR0";
- char *bp = bpt;
- char *ep = exitmsg;
-
- /* Large enough for either sizeof (bpt) or sizeof (exitmsg) chars. */
- char swallowed[50];
- /* Current position in swallowed. */
- char *swallowed_p = swallowed;
-
- int ch;
- int ch_handled;
- int old_timeout = timeout;
- int old_immediate_quit = immediate_quit;
-
- status->kind = TARGET_WAITKIND_EXITED;
- status->value.integer = 0;
-
- if (need_artificial_trap != 0)
- {
- status->kind = TARGET_WAITKIND_STOPPED;
- status->value.sig = TARGET_SIGNAL_TRAP;
- need_artificial_trap--;
- return inferior_ptid;
- }
-
- timeout = 0; /* Don't time out -- user program is running. */
- immediate_quit = 1; /* Helps ability to QUIT */
- while (1)
- {
- QUIT; /* Let user quit and leave process running */
- ch_handled = 0;
- ch = readchar ();
- if (ch == *bp)
- {
- bp++;
- if (*bp == '\0')
- break;
- ch_handled = 1;
-
- *swallowed_p++ = ch;
- }
- else
- bp = bpt;
- if (ch == *ep || *ep == '?')
- {
- ep++;
- if (*ep == '\0')
- break;
-
- if (!ch_handled)
- *swallowed_p++ = ch;
- ch_handled = 1;
- }
- else
- ep = exitmsg;
- if (!ch_handled)
- {
- char *p;
- /* Print out any characters which have been swallowed. */
- for (p = swallowed; p < swallowed_p; ++p)
- putc (*p, stdout);
- swallowed_p = swallowed;
- putc (ch, stdout);
- }
- }
- expect_prompt ();
- if (*bp == '\0')
- {
- status->kind = TARGET_WAITKIND_STOPPED;
- status->value.sig = TARGET_SIGNAL_TRAP;
- }
- else
- {
- status->kind = TARGET_WAITKIND_EXITED;
- status->value.integer = 0;
- }
- timeout = old_timeout;
- immediate_quit = old_immediate_quit;
- return inferior_ptid;
-}
-
-/* Return the name of register number REGNO
- in the form input and output by adapt.
-
- Returns a pointer to a static buffer containing the answer. */
-static char *
-get_reg_name (int regno)
-{
- static char buf[80];
- if (regno >= GR96_REGNUM && regno < GR96_REGNUM + 32)
- sprintf (buf, "GR%03d", regno - GR96_REGNUM + 96);
-#if defined(GR64_REGNUM)
- else if (regno >= GR64_REGNUM && regno < GR64_REGNUM + 32)
- sprintf (buf, "GR%03d", regno - GR64_REGNUM + 64);
-#endif
- else if (regno >= LR0_REGNUM && regno < LR0_REGNUM + 128)
- sprintf (buf, "LR%03d", regno - LR0_REGNUM);
- else if (regno == Q_REGNUM)
- strcpy (buf, "SR131");
- else if (regno >= BP_REGNUM && regno <= CR_REGNUM)
- sprintf (buf, "SR%03d", regno - BP_REGNUM + 133);
- else if (regno == ALU_REGNUM)
- strcpy (buf, "SR132");
- else if (regno >= IPC_REGNUM && regno <= IPB_REGNUM)
- sprintf (buf, "SR%03d", regno - IPC_REGNUM + 128);
- else if (regno >= VAB_REGNUM && regno <= LRU_REGNUM)
- {
- /* When a 29050 is in freeze-mode, read shadow pcs instead */
- if ((regno >= NPC_REGNUM && regno <= PC2_REGNUM) && USE_SHADOW_PC)
- sprintf (buf, "SR%03d", regno - NPC_REGNUM + 20);
- else
- sprintf (buf, "SR%03d", regno - VAB_REGNUM);
- }
- else if (regno == GR1_REGNUM)
- strcpy (buf, "GR001");
- return buf;
-}
-
-/* Read the remote registers. */
-
-static void
-adapt_fetch_registers (void)
-{
- int reg_index;
- int regnum_index;
- char tempbuf[10];
- int sreg_buf[16];
- int i, j;
-
-/*
- * Global registers
- */
-#if defined(GR64_REGNUM)
- write (adapt_desc, "dw gr64,gr95\r", 13);
- for (reg_index = 64, regnum_index = GR64_REGNUM;
- reg_index < 96;
- reg_index += 4, regnum_index += 4)
- {
- sprintf (tempbuf, "GR%03d ", reg_index);
- expect (tempbuf);
- get_hex_regs (4, regnum_index);
- expect ("\n");
- }
-#endif
- write (adapt_desc, "dw gr96,gr127\r", 14);
- for (reg_index = 96, regnum_index = GR96_REGNUM;
- reg_index < 128;
- reg_index += 4, regnum_index += 4)
- {
- sprintf (tempbuf, "GR%03d ", reg_index);
- expect (tempbuf);
- get_hex_regs (4, regnum_index);
- expect ("\n");
- }
-
-/*
- * Local registers
- */
- for (i = 0; i < 128; i += 32)
- {
- /* The PC has a tendency to hang if we get these
- all in one fell swoop ("dw lr0,lr127"). */
- sprintf (tempbuf, "dw lr%d\r", i);
- write (adapt_desc, tempbuf, strlen (tempbuf));
- for (reg_index = i, regnum_index = LR0_REGNUM + i;
- reg_index < i + 32;
- reg_index += 4, regnum_index += 4)
- {
- sprintf (tempbuf, "LR%03d ", reg_index);
- expect (tempbuf);
- get_hex_regs (4, regnum_index);
- expect ("\n");
- }
- }
-
-/*
- * Special registers
- */
- sprintf (tempbuf, "dw sr0\r");
- write (adapt_desc, tempbuf, strlen (tempbuf));
- for (i = 0; i < 4; i++)
- { /* SR0 - SR14 */
- sprintf (tempbuf, "SR%3d", i * 4);
- expect (tempbuf);
- for (j = 0; j < (i == 3 ? 3 : 4); j++)
- sreg_buf[i * 4 + j] = get_hex_word ();
- }
- expect_prompt ();
- /*
- * Read the pcs individually if we are in freeze mode.
- * See get_reg_name(), it translates the register names for the pcs to
- * the names of the shadow pcs.
- */
- if (USE_SHADOW_PC)
- {
- sreg_buf[10] = read_register (NPC_REGNUM); /* pc0 */
- sreg_buf[11] = read_register (PC_REGNUM); /* pc1 */
- sreg_buf[12] = read_register (PC2_REGNUM); /* pc2 */
- }
- for (i = 0; i < 14; i++) /* Supply vab -> lru */
- supply_register (VAB_REGNUM + i, (char *) &sreg_buf[i]);
- sprintf (tempbuf, "dw sr128\r");
- write (adapt_desc, tempbuf, strlen (tempbuf));
- for (i = 0; i < 2; i++)
- { /* SR128 - SR135 */
- sprintf (tempbuf, "SR%3d", 128 + i * 4);
- expect (tempbuf);
- for (j = 0; j < 4; j++)
- sreg_buf[i * 4 + j] = get_hex_word ();
- }
- expect_prompt ();
- supply_register (IPC_REGNUM, (char *) &sreg_buf[0]);
- supply_register (IPA_REGNUM, (char *) &sreg_buf[1]);
- supply_register (IPB_REGNUM, (char *) &sreg_buf[2]);
- supply_register (Q_REGNUM, (char *) &sreg_buf[3]);
- /* Skip ALU */
- supply_register (BP_REGNUM, (char *) &sreg_buf[5]);
- supply_register (FC_REGNUM, (char *) &sreg_buf[6]);
- supply_register (CR_REGNUM, (char *) &sreg_buf[7]);
-
- /* There doesn't seem to be any way to get these. */
- {
- int val = -1;
- supply_register (FPE_REGNUM, (char *) &val);
- supply_register (INTE_REGNUM, (char *) &val);
- supply_register (FPS_REGNUM, (char *) &val);
- supply_register (EXO_REGNUM, (char *) &val);
- }
-
- write (adapt_desc, "dw gr1,gr1\r", 11);
- expect ("GR001 ");
- get_hex_regs (1, GR1_REGNUM);
- expect_prompt ();
-}
-
-/* Fetch register REGNO, or all registers if REGNO is -1.
- */
-static void
-adapt_fetch_register (int regno)
-{
- if (regno == -1)
- adapt_fetch_registers ();
- else
- {
- char *name = get_reg_name (regno);
- fprintf (adapt_stream, "dw %s,%s\r", name, name);
- expect (name);
- expect (" ");
- get_hex_regs (1, regno);
- expect_prompt ();
- }
-}
-
-/* Store the remote registers from the contents of the block REGS. */
-
-static void
-adapt_store_registers (void)
-{
- int i, j;
-
- fprintf (adapt_stream, "s gr1,%x\r", read_register (GR1_REGNUM));
- expect_prompt ();
-
-#if defined(GR64_REGNUM)
- for (j = 0; j < 32; j += 16)
- {
- fprintf (adapt_stream, "s gr%d,", j + 64);
- for (i = 0; i < 15; ++i)
- fprintf (adapt_stream, "%x,", read_register (GR64_REGNUM + j + i));
- fprintf (adapt_stream, "%x\r", read_register (GR64_REGNUM + j + 15));
- expect_prompt ();
- }
-#endif
- for (j = 0; j < 32; j += 16)
- {
- fprintf (adapt_stream, "s gr%d,", j + 96);
- for (i = 0; i < 15; ++i)
- fprintf (adapt_stream, "%x,", read_register (GR96_REGNUM + j + i));
- fprintf (adapt_stream, "%x\r", read_register (GR96_REGNUM + j + 15));
- expect_prompt ();
- }
-
- for (j = 0; j < 128; j += 16)
- {
- fprintf (adapt_stream, "s lr%d,", j);
- for (i = 0; i < 15; ++i)
- fprintf (adapt_stream, "%x,", read_register (LR0_REGNUM + j + i));
- fprintf (adapt_stream, "%x\r", read_register (LR0_REGNUM + j + 15));
- expect_prompt ();
- }
-
- fprintf (adapt_stream, "s sr128,%x,%x,%x\r", read_register (IPC_REGNUM),
- read_register (IPA_REGNUM), read_register (IPB_REGNUM));
- expect_prompt ();
- fprintf (adapt_stream, "s sr133,%x,%x,%x\r", read_register (BP_REGNUM),
- read_register (FC_REGNUM), read_register (CR_REGNUM));
- expect_prompt ();
- fprintf (adapt_stream, "s sr131,%x\r", read_register (Q_REGNUM));
- expect_prompt ();
- fprintf (adapt_stream, "s sr0,");
- for (i = 0; i < 7; ++i)
- fprintf (adapt_stream, "%x,", read_register (VAB_REGNUM + i));
- expect_prompt ();
- fprintf (adapt_stream, "s sr7,");
- for (i = 7; i < 14; ++i)
- fprintf (adapt_stream, "%x,", read_register (VAB_REGNUM + i));
- expect_prompt ();
-}
-
-/* Store register REGNO, or all if REGNO == -1.
- Return errno value. */
-void
-adapt_store_register (int regno)
-{
- /* printf("adapt_store_register() called.\n"); fflush(stdout); /* */
- if (regno == -1)
- adapt_store_registers ();
- else
- {
- char *name = get_reg_name (regno);
- fprintf (adapt_stream, "s %s,%x\r", name, read_register (regno));
- /* Setting GR1 changes the numbers of all the locals, so
- invalidate the register cache. Do this *after* calling
- read_register, because we want read_register to return the
- value that write_register has just stuffed into the registers
- array, not the value of the register fetched from the
- inferior. */
- if (regno == GR1_REGNUM)
- registers_changed ();
- expect_prompt ();
- }
-}
-
-/* Get ready to modify the registers array. On machines which store
- individual registers, this doesn't need to do anything. On machines
- which store all the registers in one fell swoop, this makes sure
- that registers contains all the registers from the program being
- debugged. */
-
-void
-adapt_prepare_to_store (void)
-{
- /* Do nothing, since we can store individual regs */
-}
-
-static CORE_ADDR
-translate_addr (CORE_ADDR addr)
-{
-#if defined(KERNEL_DEBUGGING)
- /* Check for a virtual address in the kernel */
- /* Assume physical address of ublock is in paddr_u register */
- if (addr >= UVADDR)
- {
- /* PADDR_U register holds the physical address of the ublock */
- CORE_ADDR i = (CORE_ADDR) read_register (PADDR_U_REGNUM);
- return (i + addr - (CORE_ADDR) UVADDR);
- }
- else
- {
- return (addr);
- }
-#else
- return (addr);
-#endif
-}
-
-
-/* FIXME! Merge these two. */
-int
-adapt_xfer_inferior_memory (CORE_ADDR memaddr, char *myaddr, int len, int write,
- struct mem_attrib *attrib ATTRIBUTE_UNUSED,
- struct target_ops *target ATTRIBUTE_UNUSED)
-{
-
- memaddr = translate_addr (memaddr);
-
- if (write)
- return adapt_write_inferior_memory (memaddr, myaddr, len);
- else
- return adapt_read_inferior_memory (memaddr, myaddr, len);
-}
-
-void
-adapt_files_info (void)
-{
- printf_filtered ("\tAttached to %s at %d baud and running program %s\n",
- dev_name, baudrate, prog_name);
- printf_filtered ("\ton an %s processor.\n", processor_name[processor_type]);
-}
-
-/* Copy LEN bytes of data from debugger memory at MYADDR
- to inferior's memory at MEMADDR. Returns errno value.
- * sb/sh instructions don't work on unaligned addresses, when TU=1.
- */
-int
-adapt_write_inferior_memory (CORE_ADDR memaddr, char *myaddr, int len)
-{
- int i;
- unsigned int cps;
-
- /* Turn TU bit off so we can do 'sb' commands */
- cps = read_register (CPS_REGNUM);
- if (cps & 0x00000800)
- write_register (CPS_REGNUM, cps & ~(0x00000800));
-
- for (i = 0; i < len; i++)
- {
- if ((i % 16) == 0)
- fprintf (adapt_stream, "sb %x,", memaddr + i);
- if ((i % 16) == 15 || i == len - 1)
- {
- fprintf (adapt_stream, "%x\r", ((unsigned char *) myaddr)[i]);
- expect_prompt ();
- }
- else
- fprintf (adapt_stream, "%x,", ((unsigned char *) myaddr)[i]);
- }
- /* Restore the old value of cps if the TU bit was on */
- if (cps & 0x00000800)
- write_register (CPS_REGNUM, cps);
- return len;
-}
-
-/* Read LEN bytes from inferior memory at MEMADDR. Put the result
- at debugger address MYADDR. Returns errno value. */
-int
-adapt_read_inferior_memory (CORE_ADDR memaddr, char *myaddr, int len)
-{
- int i;
-
- /* Number of bytes read so far. */
- int count;
-
- /* Starting address of this pass. */
- unsigned long startaddr;
-
- /* Number of bytes to read in this pass. */
- int len_this_pass;
-
- /* Note that this code works correctly if startaddr is just less
- than UINT_MAX (well, really CORE_ADDR_MAX if there was such a
- thing). That is, something like
- adapt_read_bytes (CORE_ADDR_MAX - 4, foo, 4)
- works--it never adds len to memaddr and gets 0. */
- /* However, something like
- adapt_read_bytes (CORE_ADDR_MAX - 3, foo, 4)
- doesn't need to work. Detect it and give up if there's an attempt
- to do that. */
-
- if (((memaddr - 1) + len) < memaddr)
- return EIO;
-
- startaddr = memaddr;
- count = 0;
- while (count < len)
- {
- len_this_pass = 16;
- if ((startaddr % 16) != 0)
- len_this_pass -= startaddr % 16;
- if (len_this_pass > (len - count))
- len_this_pass = (len - count);
-
- fprintf (adapt_stream, "db %x,%x\r", startaddr,
- (startaddr - 1) + len_this_pass);
-
-#ifdef NOTDEF /* Why do this */
- expect ("\n");
- /* Look for 8 hex digits. */
- i = 0;
- while (1)
- {
- if (isxdigit (readchar ()))
- ++i;
- else
- {
- expect_prompt ();
- error ("Hex digit expected from remote system.");
- }
- if (i >= 8)
- break;
- }
-#endif /* NOTDEF */
-
- expect (" ");
-
- for (i = 0; i < len_this_pass; i++)
- get_hex_byte (&myaddr[count++]);
-
- expect_prompt ();
-
- startaddr += len_this_pass;
- }
- return count;
-}
-
-#define MAX_BREAKS 8
-static int num_brkpts = 0;
-
-/* Insert a breakpoint at ADDR. SAVE is normally the address of the
- pattern buffer where the instruction that the breakpoint overwrites
- is saved. It is unused here since the Adapt Monitor is responsible
- for saving/restoring the original instruction. */
-
-static int
-adapt_insert_breakpoint (CORE_ADDR addr, char *save)
-{
- if (num_brkpts < MAX_BREAKS)
- {
- num_brkpts++;
- fprintf (adapt_stream, "B %x", addr);
- fprintf (adapt_stream, "\r");
- expect_prompt ();
- return (0); /* Success */
- }
- else
- {
- fprintf_filtered (gdb_stderr,
- "Too many break points, break point not installed\n");
- return (1); /* Failure */
- }
-
-}
-
-/* Remove a breakpoint at ADDR. SAVE is normally the previously
- saved pattern, but is unused here as the Adapt Monitor is
- responsible for saving/restoring instructions. */
-
-static int
-adapt_remove_breakpoint (CORE_ADDR addr, char *save)
-{
- if (num_brkpts > 0)
- {
- num_brkpts--;
- fprintf (adapt_stream, "BR %x", addr);
- fprintf (adapt_stream, "\r");
- fflush (adapt_stream);
- expect_prompt ();
- }
- return (0);
-}
-
-/* Clear the adapts notion of what the break points are */
-static int
-adapt_clear_breakpoints (void)
-{
- if (adapt_stream)
- {
- fprintf (adapt_stream, "BR"); /* Clear all break points */
- fprintf (adapt_stream, "\r");
- fflush (adapt_stream);
- expect_prompt ();
- }
- num_brkpts = 0;
-}
-static void
-adapt_mourn (void)
-{
- adapt_clear_breakpoints ();
- pop_target (); /* Pop back to no-child state */
- generic_mourn_inferior ();
-}
-
-/* Display everthing we read in from the adapt until we match/see the
- * specified string
- */
-static int
-display_until (char *str)
-{
- int i = 0, j, c;
-
- while (c = readchar ())
- {
- if (c == str[i])
- {
- i++;
- if (i == strlen (str))
- return;
- }
- else
- {
- if (i)
- {
- for (j = 0; j < i; j++) /* Put everthing we matched */
- putchar (str[j]);
- i = 0;
- }
- putchar (c);
- }
- }
-
-}
-
-
-/* Put a command string, in args, out to the adapt. The adapt is assumed to
- be in raw mode, all writing/reading done through adapt_desc.
- Ouput from the adapt is placed on the users terminal until the
- prompt from the adapt is seen.
- FIXME: Can't handle commands that take input. */
-
-void
-adapt_com (char *args, int fromtty)
-{
- if (!adapt_stream)
- {
- printf_filtered ("Adapt not open. Use the 'target' command to open.\n");
- return;
- }
-
- /* Clear all input so only command relative output is displayed */
- slurp_input ();
-
- switch (islower (args[0]) ? toupper (args[0]) : args[0])
- {
- default:
- printf_filtered ("Unknown/Unimplemented adapt command '%s'\n", args);
- break;
- case 'G': /* Go, begin execution */
- write (adapt_desc, args, strlen (args));
- write (adapt_desc, "\r", 1);
- expect_prompt ();
- break;
- case 'B': /* Break points, B or BR */
- case 'C': /* Check current 29k status (running/halted) */
- case 'D': /* Display data/registers */
- case 'I': /* Input from i/o space */
- case 'J': /* Jam an instruction */
- case 'K': /* Kill, stop execution */
- case 'L': /* Disassemble */
- case 'O': /* Output to i/o space */
- case 'T': /* Trace */
- case 'P': /* Pulse an input line */
- case 'X': /* Examine special purpose registers */
- case 'Z': /* Display trace buffer */
- write (adapt_desc, args, strlen (args));
- write (adapt_desc, "\r", 1);
- expect (args); /* Don't display the command */
- display_until ("# ");
- break;
- /* Begin commands that take input in the form 'c x,y[,z...]' */
- case 'S': /* Set memory or register */
- if (strchr (args, ','))
- { /* Assume it is properly formatted */
- write (adapt_desc, args, strlen (args));
- write (adapt_desc, "\r", 1);
- expect_prompt ();
- }
- break;
- }
-}
-
-/* Define the target subroutine names */
-
-struct target_ops adapt_ops;
-
-static void
-init_adapt_ops (void)
-{
- adapt_ops.to_shortname = "adapt";
- adapt_ops.to_longname = "Remote AMD `Adapt' target";
- adapt_ops.to_doc = "Remote debug an AMD 290*0 using an `Adapt' monitor via RS232";
- adapt_ops.to_open = adapt_open;
- adapt_ops.to_close = adapt_close;
- adapt_ops.to_attach = adapt_attach;
- adapt_ops.to_post_attach = NULL;
- adapt_ops.to_require_attach = NULL;
- adapt_ops.to_detach = adapt_detach;
- adapt_ops.to_require_detach = NULL;
- adapt_ops.to_resume = adapt_resume;
- adapt_ops.to_wait = adapt_wait;
- adapt_ops.to_post_wait = NULL;
- adapt_ops.to_fetch_registers = adapt_fetch_register;
- adapt_ops.to_store_registers = adapt_store_register;
- adapt_ops.to_prepare_to_store = adapt_prepare_to_store;
- adapt_ops.to_xfer_memory = adapt_xfer_inferior_memory;
- adapt_ops.to_files_info = adapt_files_info;
- adapt_ops.to_insert_breakpoint = adapt_insert_breakpoint;
- adapt_ops.to_remove_breakpoint = adapt_remove_breakpoint;
- adapt_ops.to_terminal_init = 0;
- adapt_ops.to_terminal_inferior = 0;
- adapt_ops.to_terminal_ours_for_output = 0;
- adapt_ops.to_terminal_ours = 0;
- adapt_ops.to_terminal_info = 0;
- adapt_ops.to_kill = adapt_kill;
- adapt_ops.to_load = adapt_load;
- adapt_ops.to_lookup_symbol = 0;
- adapt_ops.to_create_inferior = adapt_create_inferior;
- adapt_ops.to_post_startup_inferior = NULL;
- adapt_ops.to_acknowledge_created_inferior = NULL;
- adapt_ops.to_clone_and_follow_inferior = NULL;
- adapt_ops.to_post_follow_inferior_by_clone = NULL;
- adapt_ops.to_insert_fork_catchpoint = NULL;
- adapt_ops.to_remove_fork_catchpoint = NULL;
- adapt_ops.to_insert_vfork_catchpoint = NULL;
- adapt_ops.to_remove_vfork_catchpoint = NULL;
- adapt_ops.to_has_forked = NULL;
- adapt_ops.to_has_vforked = NULL;
- adapt_ops.to_can_follow_vfork_prior_to_exec = NULL;
- adapt_ops.to_post_follow_vfork = NULL;
- adapt_ops.to_insert_exec_catchpoint = NULL;
- adapt_ops.to_remove_exec_catchpoint = NULL;
- adapt_ops.to_has_execd = NULL;
- adapt_ops.to_reported_exec_events_per_exec_call = NULL;
- adapt_ops.to_has_exited = NULL;
- adapt_ops.to_mourn_inferior = adapt_mourn;
- adapt_ops.to_can_run = 0;
- adapt_ops.to_notice_signals = 0;
- adapt_ops.to_thread_alive = 0;
- adapt_ops.to_stop = 0; /* process_stratum; */
- adapt_ops.to_pid_to_exec_file = NULL;
- adapt_ops.to_stratum = 0;
- adapt_ops.DONT_USE = 0;
- adapt_ops.to_has_all_memory = 1;
- adapt_ops.to_has_memory = 1;
- adapt_ops.to_has_stack = 1;
- adapt_ops.to_has_registers = 1;
- adapt_ops.to_has_execution = 0;
- adapt_ops.to_sections = 0;
- adapt_ops.to_sections_end = 0;
- adapt_ops.to_magic = OPS_MAGIC;
-} /* init_adapt_ops */
-
-void
-_initialize_remote_adapt (void)
-{
- init_adapt_ops ();
- add_target (&adapt_ops);
- add_com ("adapt <command>", class_obscure, adapt_com,
- "Send a command to the AMD Adapt remote monitor.");
-}
+/* OBSOLETE /* Remote debugging interface for AMD 290*0 Adapt Monitor Version 2.1d18. */
+/* OBSOLETE Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, */
+/* OBSOLETE 2001 Free Software Foundation, Inc. */
+/* OBSOLETE Contributed by David Wood at New York University (wood@lab.ultra.nyu.edu). */
+/* OBSOLETE Adapted from work done at Cygnus Support in remote-eb.c. */
+/* OBSOLETE */
+/* OBSOLETE This file is part of GDB. */
+/* OBSOLETE */
+/* OBSOLETE This program is free software; you can redistribute it and/or modify */
+/* OBSOLETE it under the terms of the GNU General Public License as published by */
+/* OBSOLETE the Free Software Foundation; either version 2 of the License, or */
+/* OBSOLETE (at your option) any later version. */
+/* OBSOLETE */
+/* OBSOLETE This program is distributed in the hope that it will be useful, */
+/* OBSOLETE but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* OBSOLETE MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* OBSOLETE GNU General Public License for more details. */
+/* OBSOLETE */
+/* OBSOLETE You should have received a copy of the GNU General Public License */
+/* OBSOLETE along with this program; if not, write to the Free Software */
+/* OBSOLETE Foundation, Inc., 59 Temple Place - Suite 330, */
+/* OBSOLETE Boston, MA 02111-1307, USA. */ */
+/* OBSOLETE */
+/* OBSOLETE /* This is like remote.c but is for an esoteric situation-- */
+/* OBSOLETE having a 29k board attached to an Adapt inline monitor. */
+/* OBSOLETE The monitor is connected via serial line to a unix machine */
+/* OBSOLETE running gdb. */
+/* OBSOLETE */
+/* OBSOLETE 3/91 - developed on Sun3 OS 4.1, by David Wood */
+/* OBSOLETE o - I can't get binary coff to load. */
+/* OBSOLETE o - I can't get 19200 baud rate to work. */
+/* OBSOLETE 7/91 o - Freeze mode tracing can be done on a 29050. */ */
+/* OBSOLETE */
+/* OBSOLETE */
+/* OBSOLETE */
+/* OBSOLETE #include "defs.h" */
+/* OBSOLETE #include "gdb_string.h" */
+/* OBSOLETE #include "inferior.h" */
+/* OBSOLETE #include "value.h" */
+/* OBSOLETE #include <ctype.h> */
+/* OBSOLETE #include <fcntl.h> */
+/* OBSOLETE #include <signal.h> */
+/* OBSOLETE #include <errno.h> */
+/* OBSOLETE #include "terminal.h" */
+/* OBSOLETE #include "target.h" */
+/* OBSOLETE #include "gdbcore.h" */
+/* OBSOLETE #include "regcache.h" */
+/* OBSOLETE */
+/* OBSOLETE /* This processor is getting rusty but I am trying to keep it */
+/* OBSOLETE up to date at least with data structure changes. */
+/* OBSOLETE Activate this block to compile just this file. */
+/* OBSOLETE */ */
+/* OBSOLETE #define COMPILE_CHECK 0 */
+/* OBSOLETE #if COMPILE_CHECK */
+/* OBSOLETE #define Q_REGNUM 0 */
+/* OBSOLETE #define VAB_REGNUM 0 */
+/* OBSOLETE #define CPS_REGNUM 0 */
+/* OBSOLETE #define IPA_REGNUM 0 */
+/* OBSOLETE #define IPB_REGNUM 0 */
+/* OBSOLETE #define GR1_REGNUM 0 */
+/* OBSOLETE #define LR0_REGNUM 0 */
+/* OBSOLETE #define IPC_REGNUM 0 */
+/* OBSOLETE #define CR_REGNUM 0 */
+/* OBSOLETE #define BP_REGNUM 0 */
+/* OBSOLETE #define FC_REGNUM 0 */
+/* OBSOLETE #define INTE_REGNUM 0 */
+/* OBSOLETE #define EXO_REGNUM 0 */
+/* OBSOLETE #define GR96_REGNUM 0 */
+/* OBSOLETE #define NPC_REGNUM */
+/* OBSOLETE #define FPE_REGNUM 0 */
+/* OBSOLETE #define PC2_REGNUM 0 */
+/* OBSOLETE #define FPS_REGNUM 0 */
+/* OBSOLETE #define ALU_REGNUM 0 */
+/* OBSOLETE #define LRU_REGNUM 0 */
+/* OBSOLETE #define TERMINAL int */
+/* OBSOLETE #define RAW 1 */
+/* OBSOLETE #define ANYP 1 */
+/* OBSOLETE extern int a29k_freeze_mode; */
+/* OBSOLETE extern int processor_type; */
+/* OBSOLETE extern char *processor_name; */
+/* OBSOLETE #endif */
+/* OBSOLETE */
+/* OBSOLETE /* External data declarations */ */
+/* OBSOLETE extern int stop_soon_quietly; /* for wait_for_inferior */ */
+/* OBSOLETE */
+/* OBSOLETE /* Forward data declarations */ */
+/* OBSOLETE extern struct target_ops adapt_ops; /* Forward declaration */ */
+/* OBSOLETE */
+/* OBSOLETE /* Forward function declarations */ */
+/* OBSOLETE static void adapt_fetch_registers (); */
+/* OBSOLETE static void adapt_store_registers (); */
+/* OBSOLETE static void adapt_close (); */
+/* OBSOLETE static int adapt_clear_breakpoints (); */
+/* OBSOLETE */
+/* OBSOLETE #define FREEZE_MODE (read_register(CPS_REGNUM) && 0x400) */
+/* OBSOLETE #define USE_SHADOW_PC ((processor_type == a29k_freeze_mode) && FREEZE_MODE) */
+/* OBSOLETE */
+/* OBSOLETE /* Can't seem to get binary coff working */ */
+/* OBSOLETE #define ASCII_COFF /* Adapt will be downloaded with ascii coff */ */
+/* OBSOLETE */
+/* OBSOLETE /* FIXME: Replace with `set remotedebug'. */ */
+/* OBSOLETE #define LOG_FILE "adapt.log" */
+/* OBSOLETE #if defined (LOG_FILE) */
+/* OBSOLETE FILE *log_file = NULL; */
+/* OBSOLETE #endif */
+/* OBSOLETE */
+/* OBSOLETE static int timeout = 5; */
+/* OBSOLETE static char *dev_name; */
+/* OBSOLETE */
+/* OBSOLETE /* Descriptor for I/O to remote machine. Initialize it to -1 so that */
+/* OBSOLETE adapt_open knows that we don't have a file open when the program */
+/* OBSOLETE starts. */ */
+/* OBSOLETE int adapt_desc = -1; */
+/* OBSOLETE */
+/* OBSOLETE /* stream which is fdopen'd from adapt_desc. Only valid when */
+/* OBSOLETE adapt_desc != -1. */ */
+/* OBSOLETE FILE *adapt_stream; */
+/* OBSOLETE */
+/* OBSOLETE #define ON 1 */
+/* OBSOLETE #define OFF 0 */
+/* OBSOLETE static void */
+/* OBSOLETE rawmode (int desc, int turnon) */
+/* OBSOLETE { */
+/* OBSOLETE */
+/* OBSOLETE TERMINAL sg; */
+/* OBSOLETE */
+/* OBSOLETE if (desc < 0) */
+/* OBSOLETE return; */
+/* OBSOLETE */
+/* OBSOLETE ioctl (desc, TIOCGETP, &sg); */
+/* OBSOLETE */
+/* OBSOLETE if (turnon) */
+/* OBSOLETE { */
+/* OBSOLETE #ifdef HAVE_TERMIO */
+/* OBSOLETE sg.c_lflag &= ~(ICANON); */
+/* OBSOLETE #else */
+/* OBSOLETE sg.sg_flags |= RAW; */
+/* OBSOLETE #endif */
+/* OBSOLETE } */
+/* OBSOLETE else */
+/* OBSOLETE { */
+/* OBSOLETE #ifdef HAVE_TERMIO */
+/* OBSOLETE sg.c_lflag |= ICANON; */
+/* OBSOLETE #else */
+/* OBSOLETE sg.sg_flags &= ~(RAW); */
+/* OBSOLETE #endif */
+/* OBSOLETE } */
+/* OBSOLETE ioctl (desc, TIOCSETP, &sg); */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* Suck up all the input from the adapt */ */
+/* OBSOLETE slurp_input (void) */
+/* OBSOLETE { */
+/* OBSOLETE char buf[8]; */
+/* OBSOLETE */
+/* OBSOLETE #ifdef HAVE_TERMIO */
+/* OBSOLETE /* termio does the timeout for us. */ */
+/* OBSOLETE while (read (adapt_desc, buf, 8) > 0); */
+/* OBSOLETE #else */
+/* OBSOLETE alarm (timeout); */
+/* OBSOLETE while (read (adapt_desc, buf, 8) > 0); */
+/* OBSOLETE alarm (0); */
+/* OBSOLETE #endif */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* Read a character from the remote system, doing all the fancy */
+/* OBSOLETE timeout stuff. */ */
+/* OBSOLETE static int */
+/* OBSOLETE readchar (void) */
+/* OBSOLETE { */
+/* OBSOLETE char buf; */
+/* OBSOLETE */
+/* OBSOLETE buf = '\0'; */
+/* OBSOLETE #ifdef HAVE_TERMIO */
+/* OBSOLETE /* termio does the timeout for us. */ */
+/* OBSOLETE read (adapt_desc, &buf, 1); */
+/* OBSOLETE #else */
+/* OBSOLETE alarm (timeout); */
+/* OBSOLETE if (read (adapt_desc, &buf, 1) < 0) */
+/* OBSOLETE { */
+/* OBSOLETE if (errno == EINTR) */
+/* OBSOLETE error ("Timeout reading from remote system."); */
+/* OBSOLETE else */
+/* OBSOLETE perror_with_name ("remote"); */
+/* OBSOLETE } */
+/* OBSOLETE alarm (0); */
+/* OBSOLETE #endif */
+/* OBSOLETE */
+/* OBSOLETE if (buf == '\0') */
+/* OBSOLETE error ("Timeout reading from remote system."); */
+/* OBSOLETE #if defined (LOG_FILE) */
+/* OBSOLETE putc (buf & 0x7f, log_file); */
+/* OBSOLETE #endif */
+/* OBSOLETE return buf & 0x7f; */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* Keep discarding input from the remote system, until STRING is found. */
+/* OBSOLETE Let the user break out immediately. */ */
+/* OBSOLETE static void */
+/* OBSOLETE expect (char *string) */
+/* OBSOLETE { */
+/* OBSOLETE char *p = string; */
+/* OBSOLETE */
+/* OBSOLETE fflush (adapt_stream); */
+/* OBSOLETE immediate_quit++; */
+/* OBSOLETE while (1) */
+/* OBSOLETE { */
+/* OBSOLETE if (readchar () == *p) */
+/* OBSOLETE { */
+/* OBSOLETE p++; */
+/* OBSOLETE if (*p == '\0') */
+/* OBSOLETE { */
+/* OBSOLETE immediate_quit--; */
+/* OBSOLETE return; */
+/* OBSOLETE } */
+/* OBSOLETE } */
+/* OBSOLETE else */
+/* OBSOLETE p = string; */
+/* OBSOLETE } */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* Keep discarding input until we see the adapt prompt. */
+/* OBSOLETE */
+/* OBSOLETE The convention for dealing with the prompt is that you */
+/* OBSOLETE o give your command */
+/* OBSOLETE o *then* wait for the prompt. */
+/* OBSOLETE */
+/* OBSOLETE Thus the last thing that a procedure does with the serial line */
+/* OBSOLETE will be an expect_prompt(). Exception: adapt_resume does not */
+/* OBSOLETE wait for the prompt, because the terminal is being handed over */
+/* OBSOLETE to the inferior. However, the next thing which happens after that */
+/* OBSOLETE is a adapt_wait which does wait for the prompt. */
+/* OBSOLETE Note that this includes abnormal exit, e.g. error(). This is */
+/* OBSOLETE necessary to prevent getting into states from which we can't */
+/* OBSOLETE recover. */ */
+/* OBSOLETE static void */
+/* OBSOLETE expect_prompt (void) */
+/* OBSOLETE { */
+/* OBSOLETE #if defined (LOG_FILE) */
+/* OBSOLETE /* This is a convenient place to do this. The idea is to do it often */
+/* OBSOLETE enough that we never lose much data if we terminate abnormally. */ */
+/* OBSOLETE fflush (log_file); */
+/* OBSOLETE #endif */
+/* OBSOLETE fflush (adapt_stream); */
+/* OBSOLETE expect ("\n# "); */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* Get a hex digit from the remote system & return its value. */
+/* OBSOLETE If ignore_space is nonzero, ignore spaces (not newline, tab, etc). */ */
+/* OBSOLETE static int */
+/* OBSOLETE get_hex_digit (int ignore_space) */
+/* OBSOLETE { */
+/* OBSOLETE int ch; */
+/* OBSOLETE while (1) */
+/* OBSOLETE { */
+/* OBSOLETE ch = readchar (); */
+/* OBSOLETE if (ch >= '0' && ch <= '9') */
+/* OBSOLETE return ch - '0'; */
+/* OBSOLETE else if (ch >= 'A' && ch <= 'F') */
+/* OBSOLETE return ch - 'A' + 10; */
+/* OBSOLETE else if (ch >= 'a' && ch <= 'f') */
+/* OBSOLETE return ch - 'a' + 10; */
+/* OBSOLETE else if (ch == ' ' && ignore_space) */
+/* OBSOLETE ; */
+/* OBSOLETE else */
+/* OBSOLETE { */
+/* OBSOLETE expect_prompt (); */
+/* OBSOLETE error ("Invalid hex digit from remote system."); */
+/* OBSOLETE } */
+/* OBSOLETE } */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* Get a byte from adapt_desc and put it in *BYT. Accept any number */
+/* OBSOLETE leading spaces. */ */
+/* OBSOLETE static void */
+/* OBSOLETE get_hex_byte (char *byt) */
+/* OBSOLETE { */
+/* OBSOLETE int val; */
+/* OBSOLETE */
+/* OBSOLETE val = get_hex_digit (1) << 4; */
+/* OBSOLETE val |= get_hex_digit (0); */
+/* OBSOLETE *byt = val; */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* Read a 32-bit hex word from the adapt, preceded by a space */ */
+/* OBSOLETE static long */
+/* OBSOLETE get_hex_word (void) */
+/* OBSOLETE { */
+/* OBSOLETE long val; */
+/* OBSOLETE int j; */
+/* OBSOLETE */
+/* OBSOLETE val = 0; */
+/* OBSOLETE for (j = 0; j < 8; j++) */
+/* OBSOLETE val = (val << 4) + get_hex_digit (j == 0); */
+/* OBSOLETE return val; */
+/* OBSOLETE } */
+/* OBSOLETE /* Get N 32-bit hex words from remote, each preceded by a space */
+/* OBSOLETE and put them in registers starting at REGNO. */ */
+/* OBSOLETE static void */
+/* OBSOLETE get_hex_regs (int n, int regno) */
+/* OBSOLETE { */
+/* OBSOLETE long val; */
+/* OBSOLETE while (n--) */
+/* OBSOLETE { */
+/* OBSOLETE val = get_hex_word (); */
+/* OBSOLETE supply_register (regno++, (char *) &val); */
+/* OBSOLETE } */
+/* OBSOLETE } */
+/* OBSOLETE /* Called when SIGALRM signal sent due to alarm() timeout. */ */
+/* OBSOLETE #ifndef HAVE_TERMIO */
+/* OBSOLETE */
+/* OBSOLETE volatile int n_alarms; */
+/* OBSOLETE */
+/* OBSOLETE void */
+/* OBSOLETE adapt_timer (void) */
+/* OBSOLETE { */
+/* OBSOLETE #if 0 */
+/* OBSOLETE if (kiodebug) */
+/* OBSOLETE printf ("adapt_timer called\n"); */
+/* OBSOLETE #endif */
+/* OBSOLETE n_alarms++; */
+/* OBSOLETE } */
+/* OBSOLETE #endif */
+/* OBSOLETE */
+/* OBSOLETE /* malloc'd name of the program on the remote system. */ */
+/* OBSOLETE static char *prog_name = NULL; */
+/* OBSOLETE */
+/* OBSOLETE /* Number of SIGTRAPs we need to simulate. That is, the next */
+/* OBSOLETE NEED_ARTIFICIAL_TRAP calls to adapt_wait should just return */
+/* OBSOLETE SIGTRAP without actually waiting for anything. */ */
+/* OBSOLETE */
+/* OBSOLETE static int need_artificial_trap = 0; */
+/* OBSOLETE */
+/* OBSOLETE void */
+/* OBSOLETE adapt_kill (char *arg, int from_tty) */
+/* OBSOLETE { */
+/* OBSOLETE fprintf (adapt_stream, "K"); */
+/* OBSOLETE fprintf (adapt_stream, "\r"); */
+/* OBSOLETE expect_prompt (); */
+/* OBSOLETE } */
+/* OBSOLETE /* */
+/* OBSOLETE * Download a file specified in 'args', to the adapt. */
+/* OBSOLETE * FIXME: Assumes the file to download is a binary coff file. */
+/* OBSOLETE */ */
+/* OBSOLETE static void */
+/* OBSOLETE adapt_load (char *args, int fromtty) */
+/* OBSOLETE { */
+/* OBSOLETE FILE *fp; */
+/* OBSOLETE int n; */
+/* OBSOLETE char buffer[1024]; */
+/* OBSOLETE */
+/* OBSOLETE if (!adapt_stream) */
+/* OBSOLETE { */
+/* OBSOLETE printf_filtered ("Adapt not open. Use 'target' command to open adapt\n"); */
+/* OBSOLETE return; */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* OK, now read in the file. Y=read, C=COFF, T=dTe port */
+/* OBSOLETE 0=start address. */ */
+/* OBSOLETE */
+/* OBSOLETE #ifdef ASCII_COFF /* Ascii coff */ */
+/* OBSOLETE fprintf (adapt_stream, "YA T,0\r"); */
+/* OBSOLETE fflush (adapt_stream); /* Just in case */ */
+/* OBSOLETE /* FIXME: should check args for only 1 argument */ */
+/* OBSOLETE sprintf (buffer, "cat %s | btoa > /tmp/#adapt-btoa", args); */
+/* OBSOLETE system (buffer); */
+/* OBSOLETE fp = fopen ("/tmp/#adapt-btoa", "r"); */
+/* OBSOLETE rawmode (adapt_desc, OFF); */
+/* OBSOLETE while (n = fread (buffer, 1, 1024, fp)) */
+/* OBSOLETE { */
+/* OBSOLETE do */
+/* OBSOLETE { */
+/* OBSOLETE n -= write (adapt_desc, buffer, n); */
+/* OBSOLETE } */
+/* OBSOLETE while (n > 0); */
+/* OBSOLETE if (n < 0) */
+/* OBSOLETE { */
+/* OBSOLETE perror ("writing ascii coff"); */
+/* OBSOLETE break; */
+/* OBSOLETE } */
+/* OBSOLETE } */
+/* OBSOLETE fclose (fp); */
+/* OBSOLETE rawmode (adapt_desc, ON); */
+/* OBSOLETE system ("rm /tmp/#adapt-btoa"); */
+/* OBSOLETE #else /* Binary coff - can't get it to work . */ */
+/* OBSOLETE fprintf (adapt_stream, "YC T,0\r"); */
+/* OBSOLETE fflush (adapt_stream); /* Just in case */ */
+/* OBSOLETE if (!(fp = fopen (args, "r"))) */
+/* OBSOLETE { */
+/* OBSOLETE printf_filtered ("Can't open %s\n", args); */
+/* OBSOLETE return; */
+/* OBSOLETE } */
+/* OBSOLETE while (n = fread (buffer, 1, 512, fp)) */
+/* OBSOLETE { */
+/* OBSOLETE do */
+/* OBSOLETE { */
+/* OBSOLETE n -= write (adapt_desc, buffer, n); */
+/* OBSOLETE } */
+/* OBSOLETE while (n > 0); */
+/* OBSOLETE if (n < 0) */
+/* OBSOLETE { */
+/* OBSOLETE perror ("writing ascii coff"); */
+/* OBSOLETE break; */
+/* OBSOLETE } */
+/* OBSOLETE } */
+/* OBSOLETE fclose (fp); */
+/* OBSOLETE #endif */
+/* OBSOLETE expect_prompt (); /* Skip garbage that comes out */ */
+/* OBSOLETE fprintf (adapt_stream, "\r"); */
+/* OBSOLETE expect_prompt (); */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* This is called not only when we first attach, but also when the */
+/* OBSOLETE user types "run" after having attached. */ */
+/* OBSOLETE void */
+/* OBSOLETE adapt_create_inferior (char *execfile, char *args, char **env) */
+/* OBSOLETE { */
+/* OBSOLETE int entry_pt; */
+/* OBSOLETE */
+/* OBSOLETE if (args && *args) */
+/* OBSOLETE error ("Can't pass arguments to remote adapt process."); */
+/* OBSOLETE */
+/* OBSOLETE if (execfile == 0 || exec_bfd == 0) */
+/* OBSOLETE error ("No executable file specified"); */
+/* OBSOLETE */
+/* OBSOLETE entry_pt = (int) bfd_get_start_address (exec_bfd); */
+/* OBSOLETE */
+/* OBSOLETE if (adapt_stream) */
+/* OBSOLETE { */
+/* OBSOLETE adapt_kill (NULL, NULL); */
+/* OBSOLETE adapt_clear_breakpoints (); */
+/* OBSOLETE init_wait_for_inferior (); */
+/* OBSOLETE /* Clear the input because what the adapt sends back is different */
+/* OBSOLETE * depending on whether it was running or not. */
+/* OBSOLETE */ */
+/* OBSOLETE slurp_input (); /* After this there should be a prompt */ */
+/* OBSOLETE fprintf (adapt_stream, "\r"); */
+/* OBSOLETE expect_prompt (); */
+/* OBSOLETE printf_filtered ("Do you want to download '%s' (y/n)? [y] : ", prog_name); */
+/* OBSOLETE { */
+/* OBSOLETE char buffer[10]; */
+/* OBSOLETE gets (buffer); */
+/* OBSOLETE if (*buffer != 'n') */
+/* OBSOLETE { */
+/* OBSOLETE adapt_load (prog_name, 0); */
+/* OBSOLETE } */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE #ifdef NOTDEF */
+/* OBSOLETE /* Set the PC and wait for a go/cont */ */
+/* OBSOLETE fprintf (adapt_stream, "G %x,N\r", entry_pt); */
+/* OBSOLETE printf_filtered ("Now use the 'continue' command to start.\n"); */
+/* OBSOLETE expect_prompt (); */
+/* OBSOLETE #else */
+/* OBSOLETE insert_breakpoints (); /* Needed to get correct instruction in cache */ */
+/* OBSOLETE proceed (entry_pt, TARGET_SIGNAL_DEFAULT, 0); */
+/* OBSOLETE #endif */
+/* OBSOLETE */
+/* OBSOLETE } */
+/* OBSOLETE else */
+/* OBSOLETE { */
+/* OBSOLETE printf_filtered ("Adapt not open yet.\n"); */
+/* OBSOLETE } */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* Translate baud rates from integers to damn B_codes. Unix should */
+/* OBSOLETE have outgrown this crap years ago, but even POSIX wouldn't buck it. */ */
+/* OBSOLETE */
+/* OBSOLETE #ifndef B19200 */
+/* OBSOLETE #define B19200 EXTA */
+/* OBSOLETE #endif */
+/* OBSOLETE #ifndef B38400 */
+/* OBSOLETE #define B38400 EXTB */
+/* OBSOLETE #endif */
+/* OBSOLETE */
+/* OBSOLETE static struct */
+/* OBSOLETE { */
+/* OBSOLETE int rate, damn_b; */
+/* OBSOLETE } */
+/* OBSOLETE baudtab[] = */
+/* OBSOLETE { */
+/* OBSOLETE { */
+/* OBSOLETE 0, B0 */
+/* OBSOLETE } */
+/* OBSOLETE , */
+/* OBSOLETE { */
+/* OBSOLETE 50, B50 */
+/* OBSOLETE } */
+/* OBSOLETE , */
+/* OBSOLETE { */
+/* OBSOLETE 75, B75 */
+/* OBSOLETE } */
+/* OBSOLETE , */
+/* OBSOLETE { */
+/* OBSOLETE 110, B110 */
+/* OBSOLETE } */
+/* OBSOLETE , */
+/* OBSOLETE { */
+/* OBSOLETE 134, B134 */
+/* OBSOLETE } */
+/* OBSOLETE , */
+/* OBSOLETE { */
+/* OBSOLETE 150, B150 */
+/* OBSOLETE } */
+/* OBSOLETE , */
+/* OBSOLETE { */
+/* OBSOLETE 200, B200 */
+/* OBSOLETE } */
+/* OBSOLETE , */
+/* OBSOLETE { */
+/* OBSOLETE 300, B300 */
+/* OBSOLETE } */
+/* OBSOLETE , */
+/* OBSOLETE { */
+/* OBSOLETE 600, B600 */
+/* OBSOLETE } */
+/* OBSOLETE , */
+/* OBSOLETE { */
+/* OBSOLETE 1200, B1200 */
+/* OBSOLETE } */
+/* OBSOLETE , */
+/* OBSOLETE { */
+/* OBSOLETE 1800, B1800 */
+/* OBSOLETE } */
+/* OBSOLETE , */
+/* OBSOLETE { */
+/* OBSOLETE 2400, B2400 */
+/* OBSOLETE } */
+/* OBSOLETE , */
+/* OBSOLETE { */
+/* OBSOLETE 4800, B4800 */
+/* OBSOLETE } */
+/* OBSOLETE , */
+/* OBSOLETE { */
+/* OBSOLETE 9600, B9600 */
+/* OBSOLETE } */
+/* OBSOLETE , */
+/* OBSOLETE { */
+/* OBSOLETE 19200, B19200 */
+/* OBSOLETE } */
+/* OBSOLETE , */
+/* OBSOLETE { */
+/* OBSOLETE 38400, B38400 */
+/* OBSOLETE } */
+/* OBSOLETE , */
+/* OBSOLETE { */
+/* OBSOLETE -1, -1 */
+/* OBSOLETE } */
+/* OBSOLETE , */
+/* OBSOLETE }; */
+/* OBSOLETE */
+/* OBSOLETE static int */
+/* OBSOLETE damn_b (int rate) */
+/* OBSOLETE { */
+/* OBSOLETE int i; */
+/* OBSOLETE */
+/* OBSOLETE for (i = 0; baudtab[i].rate != -1; i++) */
+/* OBSOLETE if (rate == baudtab[i].rate) */
+/* OBSOLETE return baudtab[i].damn_b; */
+/* OBSOLETE return B38400; /* Random */ */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE */
+/* OBSOLETE /* Open a connection to a remote debugger. */
+/* OBSOLETE NAME is the filename used for communication, then a space, */
+/* OBSOLETE then the baud rate. */
+/* OBSOLETE */ */
+/* OBSOLETE */
+/* OBSOLETE static int baudrate = 9600; */
+/* OBSOLETE static void */
+/* OBSOLETE adapt_open (char *name, int from_tty) */
+/* OBSOLETE { */
+/* OBSOLETE TERMINAL sg; */
+/* OBSOLETE unsigned int prl; */
+/* OBSOLETE char *p; */
+/* OBSOLETE */
+/* OBSOLETE /* Find the first whitespace character, it separates dev_name from */
+/* OBSOLETE prog_name. */ */
+/* OBSOLETE if (name == 0) */
+/* OBSOLETE goto erroid; */
+/* OBSOLETE */
+/* OBSOLETE for (p = name; */
+/* OBSOLETE *p != '\0' && !isspace (*p); p++) */
+/* OBSOLETE ; */
+/* OBSOLETE if (*p == '\0') */
+/* OBSOLETE erroid: */
+/* OBSOLETE error ("\ */
+/* OBSOLETE Please include the name of the device for the serial port,\n\ */
+/* OBSOLETE the baud rate, and the name of the program to run on the remote system."); */
+/* OBSOLETE dev_name = (char *) xmalloc (p - name + 1); */
+/* OBSOLETE strncpy (dev_name, name, p - name); */
+/* OBSOLETE dev_name[p - name] = '\0'; */
+/* OBSOLETE */
+/* OBSOLETE /* Skip over the whitespace after dev_name */ */
+/* OBSOLETE for (; isspace (*p); p++) */
+/* OBSOLETE /*EMPTY */ ; */
+/* OBSOLETE */
+/* OBSOLETE if (1 != sscanf (p, "%d ", &baudrate)) */
+/* OBSOLETE goto erroid; */
+/* OBSOLETE */
+/* OBSOLETE /* Skip the number and then the spaces */ */
+/* OBSOLETE for (; isdigit (*p); p++) */
+/* OBSOLETE /*EMPTY */ ; */
+/* OBSOLETE for (; isspace (*p); p++) */
+/* OBSOLETE /*EMPTY */ ; */
+/* OBSOLETE */
+/* OBSOLETE if (prog_name != NULL) */
+/* OBSOLETE xfree (prog_name); */
+/* OBSOLETE prog_name = savestring (p, strlen (p)); */
+/* OBSOLETE */
+/* OBSOLETE adapt_close (0); */
+/* OBSOLETE */
+/* OBSOLETE adapt_desc = open (dev_name, O_RDWR); */
+/* OBSOLETE if (adapt_desc < 0) */
+/* OBSOLETE perror_with_name (dev_name); */
+/* OBSOLETE ioctl (adapt_desc, TIOCGETP, &sg); */
+/* OBSOLETE #if ! defined(COMPILE_CHECK) */
+/* OBSOLETE #ifdef HAVE_TERMIO */
+/* OBSOLETE sg.c_cc[VMIN] = 0; /* read with timeout. */ */
+/* OBSOLETE sg.c_cc[VTIME] = timeout * 10; */
+/* OBSOLETE sg.c_lflag &= ~(ICANON | ECHO); */
+/* OBSOLETE sg.c_cflag = (sg.c_cflag & ~CBAUD) | damn_b (baudrate); */
+/* OBSOLETE #else */
+/* OBSOLETE sg.sg_ispeed = damn_b (baudrate); */
+/* OBSOLETE sg.sg_ospeed = damn_b (baudrate); */
+/* OBSOLETE sg.sg_flags |= RAW | ANYP; */
+/* OBSOLETE sg.sg_flags &= ~ECHO; */
+/* OBSOLETE #endif */
+/* OBSOLETE */
+/* OBSOLETE ioctl (adapt_desc, TIOCSETP, &sg); */
+/* OBSOLETE adapt_stream = fdopen (adapt_desc, "r+"); */
+/* OBSOLETE #endif /* compile_check */ */
+/* OBSOLETE push_target (&adapt_ops); */
+/* OBSOLETE */
+/* OBSOLETE #ifndef HAVE_TERMIO */
+/* OBSOLETE #ifndef NO_SIGINTERRUPT */
+/* OBSOLETE /* Cause SIGALRM's to make reads fail with EINTR instead of resuming */
+/* OBSOLETE the read. */ */
+/* OBSOLETE if (siginterrupt (SIGALRM, 1) != 0) */
+/* OBSOLETE perror ("adapt_open: error in siginterrupt"); */
+/* OBSOLETE #endif */
+/* OBSOLETE */
+/* OBSOLETE /* Set up read timeout timer. */ */
+/* OBSOLETE if ((void (*)) signal (SIGALRM, adapt_timer) == (void (*)) -1) */
+/* OBSOLETE perror ("adapt_open: error in signal"); */
+/* OBSOLETE #endif */
+/* OBSOLETE */
+/* OBSOLETE #if defined (LOG_FILE) */
+/* OBSOLETE log_file = fopen (LOG_FILE, "w"); */
+/* OBSOLETE if (log_file == NULL) */
+/* OBSOLETE perror_with_name (LOG_FILE); */
+/* OBSOLETE #endif */
+/* OBSOLETE */
+/* OBSOLETE /* Put this port into NORMAL mode, send the 'normal' character */ */
+/* OBSOLETE write (adapt_desc, "\ 1", 1); /* Control A */ */
+/* OBSOLETE write (adapt_desc, "\r", 1); */
+/* OBSOLETE expect_prompt (); */
+/* OBSOLETE */
+/* OBSOLETE /* Hello? Are you there? */ */
+/* OBSOLETE write (adapt_desc, "\r", 1); */
+/* OBSOLETE */
+/* OBSOLETE expect_prompt (); */
+/* OBSOLETE */
+/* OBSOLETE /* Clear any break points */ */
+/* OBSOLETE adapt_clear_breakpoints (); */
+/* OBSOLETE */
+/* OBSOLETE /* Print out some stuff, letting the user now what's going on */ */
+/* OBSOLETE printf_filtered ("Connected to an Adapt via %s.\n", dev_name); */
+/* OBSOLETE /* FIXME: can this restriction be removed? */ */
+/* OBSOLETE printf_filtered ("Remote debugging using virtual addresses works only\n"); */
+/* OBSOLETE printf_filtered ("\twhen virtual addresses map 1:1 to physical addresses.\n"); */
+/* OBSOLETE if (processor_type != a29k_freeze_mode) */
+/* OBSOLETE { */
+/* OBSOLETE fprintf_filtered (gdb_stderr, */
+/* OBSOLETE "Freeze-mode debugging not available, and can only be done on an A29050.\n"); */
+/* OBSOLETE } */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* Close out all files and local state before this target loses control. */ */
+/* OBSOLETE */
+/* OBSOLETE static void */
+/* OBSOLETE adapt_close (int quitting) */
+/* OBSOLETE { */
+/* OBSOLETE */
+/* OBSOLETE /* Clear any break points */ */
+/* OBSOLETE adapt_clear_breakpoints (); */
+/* OBSOLETE */
+/* OBSOLETE /* Put this port back into REMOTE mode */ */
+/* OBSOLETE if (adapt_stream) */
+/* OBSOLETE { */
+/* OBSOLETE fflush (adapt_stream); */
+/* OBSOLETE sleep (1); /* Let any output make it all the way back */ */
+/* OBSOLETE write (adapt_desc, "R\r", 2); */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* Due to a bug in Unix, fclose closes not only the stdio stream, */
+/* OBSOLETE but also the file descriptor. So we don't actually close */
+/* OBSOLETE adapt_desc. */ */
+/* OBSOLETE if (adapt_stream) */
+/* OBSOLETE fclose (adapt_stream); /* This also closes adapt_desc */ */
+/* OBSOLETE if (adapt_desc >= 0) */
+/* OBSOLETE /* close (adapt_desc); */ */
+/* OBSOLETE */
+/* OBSOLETE /* Do not try to close adapt_desc again, later in the program. */ */
+/* OBSOLETE adapt_stream = NULL; */
+/* OBSOLETE adapt_desc = -1; */
+/* OBSOLETE */
+/* OBSOLETE #if defined (LOG_FILE) */
+/* OBSOLETE if (log_file) */
+/* OBSOLETE { */
+/* OBSOLETE if (ferror (log_file)) */
+/* OBSOLETE printf_filtered ("Error writing log file.\n"); */
+/* OBSOLETE if (fclose (log_file) != 0) */
+/* OBSOLETE printf_filtered ("Error closing log file.\n"); */
+/* OBSOLETE log_file = NULL; */
+/* OBSOLETE } */
+/* OBSOLETE #endif */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* Attach to the target that is already loaded and possibly running */ */
+/* OBSOLETE static void */
+/* OBSOLETE adapt_attach (char *args, int from_tty) */
+/* OBSOLETE { */
+/* OBSOLETE */
+/* OBSOLETE if (from_tty) */
+/* OBSOLETE printf_filtered ("Attaching to remote program %s.\n", prog_name); */
+/* OBSOLETE */
+/* OBSOLETE /* Send the adapt a kill. It is ok if it is not already running */ */
+/* OBSOLETE fprintf (adapt_stream, "K\r"); */
+/* OBSOLETE fflush (adapt_stream); */
+/* OBSOLETE expect_prompt (); /* Slurp the echo */ */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE */
+/* OBSOLETE /* Terminate the open connection to the remote debugger. */
+/* OBSOLETE Use this when you want to detach and do something else */
+/* OBSOLETE with your gdb. */ */
+/* OBSOLETE void */
+/* OBSOLETE adapt_detach (char *args, int from_tty) */
+/* OBSOLETE { */
+/* OBSOLETE */
+/* OBSOLETE if (adapt_stream) */
+/* OBSOLETE { /* Send it on its way (tell it to continue) */ */
+/* OBSOLETE adapt_clear_breakpoints (); */
+/* OBSOLETE fprintf (adapt_stream, "G\r"); */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE pop_target (); /* calls adapt_close to do the real work */ */
+/* OBSOLETE if (from_tty) */
+/* OBSOLETE printf_filtered ("Ending remote %s debugging\n", target_shortname); */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* Tell the remote machine to resume. */ */
+/* OBSOLETE */
+/* OBSOLETE void */
+/* OBSOLETE adapt_resume (ptid_t ptid, int step, enum target_signal sig) */
+/* OBSOLETE { */
+/* OBSOLETE if (step) */
+/* OBSOLETE { */
+/* OBSOLETE write (adapt_desc, "t 1,s\r", 6); */
+/* OBSOLETE /* Wait for the echo. */ */
+/* OBSOLETE expect ("t 1,s\r\n"); */
+/* OBSOLETE /* Then comes a line containing the instruction we stepped to. */ */
+/* OBSOLETE expect ("@"); */
+/* OBSOLETE /* Then we get the prompt. */ */
+/* OBSOLETE expect_prompt (); */
+/* OBSOLETE */
+/* OBSOLETE /* Force the next adapt_wait to return a trap. Not doing anything */
+/* OBSOLETE about I/O from the target means that the user has to type */
+/* OBSOLETE "continue" to see any. FIXME, this should be fixed. */ */
+/* OBSOLETE need_artificial_trap = 1; */
+/* OBSOLETE } */
+/* OBSOLETE else */
+/* OBSOLETE { */
+/* OBSOLETE write (adapt_desc, "G\r", 2); */
+/* OBSOLETE /* Swallow the echo. */ */
+/* OBSOLETE expect_prompt (); */
+/* OBSOLETE } */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* Wait until the remote machine stops, then return, */
+/* OBSOLETE storing status in STATUS just as `wait' would. */ */
+/* OBSOLETE */
+/* OBSOLETE ptid_t */
+/* OBSOLETE adapt_wait (ptid_t ptid, struct target_waitstatus *status) */
+/* OBSOLETE { */
+/* OBSOLETE /* Strings to look for. '?' means match any single character. */
+/* OBSOLETE Note that with the algorithm we use, the initial character */
+/* OBSOLETE of the string cannot recur in the string, or we will not */
+/* OBSOLETE find some cases of the string in the input. */ */
+/* OBSOLETE */
+/* OBSOLETE static char bpt[] = "@"; */
+/* OBSOLETE /* It would be tempting to look for "\n[__exit + 0x8]\n" */
+/* OBSOLETE but that requires loading symbols with "yc i" and even if */
+/* OBSOLETE we did do that we don't know that the file has symbols. */ */
+/* OBSOLETE static char exitmsg[] = "@????????I JMPTI GR121,LR0"; */
+/* OBSOLETE char *bp = bpt; */
+/* OBSOLETE char *ep = exitmsg; */
+/* OBSOLETE */
+/* OBSOLETE /* Large enough for either sizeof (bpt) or sizeof (exitmsg) chars. */ */
+/* OBSOLETE char swallowed[50]; */
+/* OBSOLETE /* Current position in swallowed. */ */
+/* OBSOLETE char *swallowed_p = swallowed; */
+/* OBSOLETE */
+/* OBSOLETE int ch; */
+/* OBSOLETE int ch_handled; */
+/* OBSOLETE int old_timeout = timeout; */
+/* OBSOLETE int old_immediate_quit = immediate_quit; */
+/* OBSOLETE */
+/* OBSOLETE status->kind = TARGET_WAITKIND_EXITED; */
+/* OBSOLETE status->value.integer = 0; */
+/* OBSOLETE */
+/* OBSOLETE if (need_artificial_trap != 0) */
+/* OBSOLETE { */
+/* OBSOLETE status->kind = TARGET_WAITKIND_STOPPED; */
+/* OBSOLETE status->value.sig = TARGET_SIGNAL_TRAP; */
+/* OBSOLETE need_artificial_trap--; */
+/* OBSOLETE return inferior_ptid; */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE timeout = 0; /* Don't time out -- user program is running. */ */
+/* OBSOLETE immediate_quit = 1; /* Helps ability to QUIT */ */
+/* OBSOLETE while (1) */
+/* OBSOLETE { */
+/* OBSOLETE QUIT; /* Let user quit and leave process running */ */
+/* OBSOLETE ch_handled = 0; */
+/* OBSOLETE ch = readchar (); */
+/* OBSOLETE if (ch == *bp) */
+/* OBSOLETE { */
+/* OBSOLETE bp++; */
+/* OBSOLETE if (*bp == '\0') */
+/* OBSOLETE break; */
+/* OBSOLETE ch_handled = 1; */
+/* OBSOLETE */
+/* OBSOLETE *swallowed_p++ = ch; */
+/* OBSOLETE } */
+/* OBSOLETE else */
+/* OBSOLETE bp = bpt; */
+/* OBSOLETE if (ch == *ep || *ep == '?') */
+/* OBSOLETE { */
+/* OBSOLETE ep++; */
+/* OBSOLETE if (*ep == '\0') */
+/* OBSOLETE break; */
+/* OBSOLETE */
+/* OBSOLETE if (!ch_handled) */
+/* OBSOLETE *swallowed_p++ = ch; */
+/* OBSOLETE ch_handled = 1; */
+/* OBSOLETE } */
+/* OBSOLETE else */
+/* OBSOLETE ep = exitmsg; */
+/* OBSOLETE if (!ch_handled) */
+/* OBSOLETE { */
+/* OBSOLETE char *p; */
+/* OBSOLETE /* Print out any characters which have been swallowed. */ */
+/* OBSOLETE for (p = swallowed; p < swallowed_p; ++p) */
+/* OBSOLETE putc (*p, stdout); */
+/* OBSOLETE swallowed_p = swallowed; */
+/* OBSOLETE putc (ch, stdout); */
+/* OBSOLETE } */
+/* OBSOLETE } */
+/* OBSOLETE expect_prompt (); */
+/* OBSOLETE if (*bp == '\0') */
+/* OBSOLETE { */
+/* OBSOLETE status->kind = TARGET_WAITKIND_STOPPED; */
+/* OBSOLETE status->value.sig = TARGET_SIGNAL_TRAP; */
+/* OBSOLETE } */
+/* OBSOLETE else */
+/* OBSOLETE { */
+/* OBSOLETE status->kind = TARGET_WAITKIND_EXITED; */
+/* OBSOLETE status->value.integer = 0; */
+/* OBSOLETE } */
+/* OBSOLETE timeout = old_timeout; */
+/* OBSOLETE immediate_quit = old_immediate_quit; */
+/* OBSOLETE return inferior_ptid; */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* Return the name of register number REGNO */
+/* OBSOLETE in the form input and output by adapt. */
+/* OBSOLETE */
+/* OBSOLETE Returns a pointer to a static buffer containing the answer. */ */
+/* OBSOLETE static char * */
+/* OBSOLETE get_reg_name (int regno) */
+/* OBSOLETE { */
+/* OBSOLETE static char buf[80]; */
+/* OBSOLETE if (regno >= GR96_REGNUM && regno < GR96_REGNUM + 32) */
+/* OBSOLETE sprintf (buf, "GR%03d", regno - GR96_REGNUM + 96); */
+/* OBSOLETE #if defined(GR64_REGNUM) */
+/* OBSOLETE else if (regno >= GR64_REGNUM && regno < GR64_REGNUM + 32) */
+/* OBSOLETE sprintf (buf, "GR%03d", regno - GR64_REGNUM + 64); */
+/* OBSOLETE #endif */
+/* OBSOLETE else if (regno >= LR0_REGNUM && regno < LR0_REGNUM + 128) */
+/* OBSOLETE sprintf (buf, "LR%03d", regno - LR0_REGNUM); */
+/* OBSOLETE else if (regno == Q_REGNUM) */
+/* OBSOLETE strcpy (buf, "SR131"); */
+/* OBSOLETE else if (regno >= BP_REGNUM && regno <= CR_REGNUM) */
+/* OBSOLETE sprintf (buf, "SR%03d", regno - BP_REGNUM + 133); */
+/* OBSOLETE else if (regno == ALU_REGNUM) */
+/* OBSOLETE strcpy (buf, "SR132"); */
+/* OBSOLETE else if (regno >= IPC_REGNUM && regno <= IPB_REGNUM) */
+/* OBSOLETE sprintf (buf, "SR%03d", regno - IPC_REGNUM + 128); */
+/* OBSOLETE else if (regno >= VAB_REGNUM && regno <= LRU_REGNUM) */
+/* OBSOLETE { */
+/* OBSOLETE /* When a 29050 is in freeze-mode, read shadow pcs instead */ */
+/* OBSOLETE if ((regno >= NPC_REGNUM && regno <= PC2_REGNUM) && USE_SHADOW_PC) */
+/* OBSOLETE sprintf (buf, "SR%03d", regno - NPC_REGNUM + 20); */
+/* OBSOLETE else */
+/* OBSOLETE sprintf (buf, "SR%03d", regno - VAB_REGNUM); */
+/* OBSOLETE } */
+/* OBSOLETE else if (regno == GR1_REGNUM) */
+/* OBSOLETE strcpy (buf, "GR001"); */
+/* OBSOLETE return buf; */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* Read the remote registers. */ */
+/* OBSOLETE */
+/* OBSOLETE static void */
+/* OBSOLETE adapt_fetch_registers (void) */
+/* OBSOLETE { */
+/* OBSOLETE int reg_index; */
+/* OBSOLETE int regnum_index; */
+/* OBSOLETE char tempbuf[10]; */
+/* OBSOLETE int sreg_buf[16]; */
+/* OBSOLETE int i, j; */
+/* OBSOLETE */
+/* OBSOLETE /* */
+/* OBSOLETE * Global registers */
+/* OBSOLETE */ */
+/* OBSOLETE #if defined(GR64_REGNUM) */
+/* OBSOLETE write (adapt_desc, "dw gr64,gr95\r", 13); */
+/* OBSOLETE for (reg_index = 64, regnum_index = GR64_REGNUM; */
+/* OBSOLETE reg_index < 96; */
+/* OBSOLETE reg_index += 4, regnum_index += 4) */
+/* OBSOLETE { */
+/* OBSOLETE sprintf (tempbuf, "GR%03d ", reg_index); */
+/* OBSOLETE expect (tempbuf); */
+/* OBSOLETE get_hex_regs (4, regnum_index); */
+/* OBSOLETE expect ("\n"); */
+/* OBSOLETE } */
+/* OBSOLETE #endif */
+/* OBSOLETE write (adapt_desc, "dw gr96,gr127\r", 14); */
+/* OBSOLETE for (reg_index = 96, regnum_index = GR96_REGNUM; */
+/* OBSOLETE reg_index < 128; */
+/* OBSOLETE reg_index += 4, regnum_index += 4) */
+/* OBSOLETE { */
+/* OBSOLETE sprintf (tempbuf, "GR%03d ", reg_index); */
+/* OBSOLETE expect (tempbuf); */
+/* OBSOLETE get_hex_regs (4, regnum_index); */
+/* OBSOLETE expect ("\n"); */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* */
+/* OBSOLETE * Local registers */
+/* OBSOLETE */ */
+/* OBSOLETE for (i = 0; i < 128; i += 32) */
+/* OBSOLETE { */
+/* OBSOLETE /* The PC has a tendency to hang if we get these */
+/* OBSOLETE all in one fell swoop ("dw lr0,lr127"). */ */
+/* OBSOLETE sprintf (tempbuf, "dw lr%d\r", i); */
+/* OBSOLETE write (adapt_desc, tempbuf, strlen (tempbuf)); */
+/* OBSOLETE for (reg_index = i, regnum_index = LR0_REGNUM + i; */
+/* OBSOLETE reg_index < i + 32; */
+/* OBSOLETE reg_index += 4, regnum_index += 4) */
+/* OBSOLETE { */
+/* OBSOLETE sprintf (tempbuf, "LR%03d ", reg_index); */
+/* OBSOLETE expect (tempbuf); */
+/* OBSOLETE get_hex_regs (4, regnum_index); */
+/* OBSOLETE expect ("\n"); */
+/* OBSOLETE } */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* */
+/* OBSOLETE * Special registers */
+/* OBSOLETE */ */
+/* OBSOLETE sprintf (tempbuf, "dw sr0\r"); */
+/* OBSOLETE write (adapt_desc, tempbuf, strlen (tempbuf)); */
+/* OBSOLETE for (i = 0; i < 4; i++) */
+/* OBSOLETE { /* SR0 - SR14 */ */
+/* OBSOLETE sprintf (tempbuf, "SR%3d", i * 4); */
+/* OBSOLETE expect (tempbuf); */
+/* OBSOLETE for (j = 0; j < (i == 3 ? 3 : 4); j++) */
+/* OBSOLETE sreg_buf[i * 4 + j] = get_hex_word (); */
+/* OBSOLETE } */
+/* OBSOLETE expect_prompt (); */
+/* OBSOLETE /* */
+/* OBSOLETE * Read the pcs individually if we are in freeze mode. */
+/* OBSOLETE * See get_reg_name(), it translates the register names for the pcs to */
+/* OBSOLETE * the names of the shadow pcs. */
+/* OBSOLETE */ */
+/* OBSOLETE if (USE_SHADOW_PC) */
+/* OBSOLETE { */
+/* OBSOLETE sreg_buf[10] = read_register (NPC_REGNUM); /* pc0 */ */
+/* OBSOLETE sreg_buf[11] = read_register (PC_REGNUM); /* pc1 */ */
+/* OBSOLETE sreg_buf[12] = read_register (PC2_REGNUM); /* pc2 */ */
+/* OBSOLETE } */
+/* OBSOLETE for (i = 0; i < 14; i++) /* Supply vab -> lru */ */
+/* OBSOLETE supply_register (VAB_REGNUM + i, (char *) &sreg_buf[i]); */
+/* OBSOLETE sprintf (tempbuf, "dw sr128\r"); */
+/* OBSOLETE write (adapt_desc, tempbuf, strlen (tempbuf)); */
+/* OBSOLETE for (i = 0; i < 2; i++) */
+/* OBSOLETE { /* SR128 - SR135 */ */
+/* OBSOLETE sprintf (tempbuf, "SR%3d", 128 + i * 4); */
+/* OBSOLETE expect (tempbuf); */
+/* OBSOLETE for (j = 0; j < 4; j++) */
+/* OBSOLETE sreg_buf[i * 4 + j] = get_hex_word (); */
+/* OBSOLETE } */
+/* OBSOLETE expect_prompt (); */
+/* OBSOLETE supply_register (IPC_REGNUM, (char *) &sreg_buf[0]); */
+/* OBSOLETE supply_register (IPA_REGNUM, (char *) &sreg_buf[1]); */
+/* OBSOLETE supply_register (IPB_REGNUM, (char *) &sreg_buf[2]); */
+/* OBSOLETE supply_register (Q_REGNUM, (char *) &sreg_buf[3]); */
+/* OBSOLETE /* Skip ALU */ */
+/* OBSOLETE supply_register (BP_REGNUM, (char *) &sreg_buf[5]); */
+/* OBSOLETE supply_register (FC_REGNUM, (char *) &sreg_buf[6]); */
+/* OBSOLETE supply_register (CR_REGNUM, (char *) &sreg_buf[7]); */
+/* OBSOLETE */
+/* OBSOLETE /* There doesn't seem to be any way to get these. */ */
+/* OBSOLETE { */
+/* OBSOLETE int val = -1; */
+/* OBSOLETE supply_register (FPE_REGNUM, (char *) &val); */
+/* OBSOLETE supply_register (INTE_REGNUM, (char *) &val); */
+/* OBSOLETE supply_register (FPS_REGNUM, (char *) &val); */
+/* OBSOLETE supply_register (EXO_REGNUM, (char *) &val); */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE write (adapt_desc, "dw gr1,gr1\r", 11); */
+/* OBSOLETE expect ("GR001 "); */
+/* OBSOLETE get_hex_regs (1, GR1_REGNUM); */
+/* OBSOLETE expect_prompt (); */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* Fetch register REGNO, or all registers if REGNO is -1. */
+/* OBSOLETE */ */
+/* OBSOLETE static void */
+/* OBSOLETE adapt_fetch_register (int regno) */
+/* OBSOLETE { */
+/* OBSOLETE if (regno == -1) */
+/* OBSOLETE adapt_fetch_registers (); */
+/* OBSOLETE else */
+/* OBSOLETE { */
+/* OBSOLETE char *name = get_reg_name (regno); */
+/* OBSOLETE fprintf (adapt_stream, "dw %s,%s\r", name, name); */
+/* OBSOLETE expect (name); */
+/* OBSOLETE expect (" "); */
+/* OBSOLETE get_hex_regs (1, regno); */
+/* OBSOLETE expect_prompt (); */
+/* OBSOLETE } */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* Store the remote registers from the contents of the block REGS. */ */
+/* OBSOLETE */
+/* OBSOLETE static void */
+/* OBSOLETE adapt_store_registers (void) */
+/* OBSOLETE { */
+/* OBSOLETE int i, j; */
+/* OBSOLETE */
+/* OBSOLETE fprintf (adapt_stream, "s gr1,%x\r", read_register (GR1_REGNUM)); */
+/* OBSOLETE expect_prompt (); */
+/* OBSOLETE */
+/* OBSOLETE #if defined(GR64_REGNUM) */
+/* OBSOLETE for (j = 0; j < 32; j += 16) */
+/* OBSOLETE { */
+/* OBSOLETE fprintf (adapt_stream, "s gr%d,", j + 64); */
+/* OBSOLETE for (i = 0; i < 15; ++i) */
+/* OBSOLETE fprintf (adapt_stream, "%x,", read_register (GR64_REGNUM + j + i)); */
+/* OBSOLETE fprintf (adapt_stream, "%x\r", read_register (GR64_REGNUM + j + 15)); */
+/* OBSOLETE expect_prompt (); */
+/* OBSOLETE } */
+/* OBSOLETE #endif */
+/* OBSOLETE for (j = 0; j < 32; j += 16) */
+/* OBSOLETE { */
+/* OBSOLETE fprintf (adapt_stream, "s gr%d,", j + 96); */
+/* OBSOLETE for (i = 0; i < 15; ++i) */
+/* OBSOLETE fprintf (adapt_stream, "%x,", read_register (GR96_REGNUM + j + i)); */
+/* OBSOLETE fprintf (adapt_stream, "%x\r", read_register (GR96_REGNUM + j + 15)); */
+/* OBSOLETE expect_prompt (); */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE for (j = 0; j < 128; j += 16) */
+/* OBSOLETE { */
+/* OBSOLETE fprintf (adapt_stream, "s lr%d,", j); */
+/* OBSOLETE for (i = 0; i < 15; ++i) */
+/* OBSOLETE fprintf (adapt_stream, "%x,", read_register (LR0_REGNUM + j + i)); */
+/* OBSOLETE fprintf (adapt_stream, "%x\r", read_register (LR0_REGNUM + j + 15)); */
+/* OBSOLETE expect_prompt (); */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE fprintf (adapt_stream, "s sr128,%x,%x,%x\r", read_register (IPC_REGNUM), */
+/* OBSOLETE read_register (IPA_REGNUM), read_register (IPB_REGNUM)); */
+/* OBSOLETE expect_prompt (); */
+/* OBSOLETE fprintf (adapt_stream, "s sr133,%x,%x,%x\r", read_register (BP_REGNUM), */
+/* OBSOLETE read_register (FC_REGNUM), read_register (CR_REGNUM)); */
+/* OBSOLETE expect_prompt (); */
+/* OBSOLETE fprintf (adapt_stream, "s sr131,%x\r", read_register (Q_REGNUM)); */
+/* OBSOLETE expect_prompt (); */
+/* OBSOLETE fprintf (adapt_stream, "s sr0,"); */
+/* OBSOLETE for (i = 0; i < 7; ++i) */
+/* OBSOLETE fprintf (adapt_stream, "%x,", read_register (VAB_REGNUM + i)); */
+/* OBSOLETE expect_prompt (); */
+/* OBSOLETE fprintf (adapt_stream, "s sr7,"); */
+/* OBSOLETE for (i = 7; i < 14; ++i) */
+/* OBSOLETE fprintf (adapt_stream, "%x,", read_register (VAB_REGNUM + i)); */
+/* OBSOLETE expect_prompt (); */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* Store register REGNO, or all if REGNO == -1. */
+/* OBSOLETE Return errno value. */ */
+/* OBSOLETE void */
+/* OBSOLETE adapt_store_register (int regno) */
+/* OBSOLETE { */
+/* OBSOLETE /* printf("adapt_store_register() called.\n"); fflush(stdout); /* */ */
+/* OBSOLETE if (regno == -1) */
+/* OBSOLETE adapt_store_registers (); */
+/* OBSOLETE else */
+/* OBSOLETE { */
+/* OBSOLETE char *name = get_reg_name (regno); */
+/* OBSOLETE fprintf (adapt_stream, "s %s,%x\r", name, read_register (regno)); */
+/* OBSOLETE /* Setting GR1 changes the numbers of all the locals, so */
+/* OBSOLETE invalidate the register cache. Do this *after* calling */
+/* OBSOLETE read_register, because we want read_register to return the */
+/* OBSOLETE value that write_register has just stuffed into the registers */
+/* OBSOLETE array, not the value of the register fetched from the */
+/* OBSOLETE inferior. */ */
+/* OBSOLETE if (regno == GR1_REGNUM) */
+/* OBSOLETE registers_changed (); */
+/* OBSOLETE expect_prompt (); */
+/* OBSOLETE } */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* Get ready to modify the registers array. On machines which store */
+/* OBSOLETE individual registers, this doesn't need to do anything. On machines */
+/* OBSOLETE which store all the registers in one fell swoop, this makes sure */
+/* OBSOLETE that registers contains all the registers from the program being */
+/* OBSOLETE debugged. */ */
+/* OBSOLETE */
+/* OBSOLETE void */
+/* OBSOLETE adapt_prepare_to_store (void) */
+/* OBSOLETE { */
+/* OBSOLETE /* Do nothing, since we can store individual regs */ */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE static CORE_ADDR */
+/* OBSOLETE translate_addr (CORE_ADDR addr) */
+/* OBSOLETE { */
+/* OBSOLETE #if defined(KERNEL_DEBUGGING) */
+/* OBSOLETE /* Check for a virtual address in the kernel */ */
+/* OBSOLETE /* Assume physical address of ublock is in paddr_u register */ */
+/* OBSOLETE if (addr >= UVADDR) */
+/* OBSOLETE { */
+/* OBSOLETE /* PADDR_U register holds the physical address of the ublock */ */
+/* OBSOLETE CORE_ADDR i = (CORE_ADDR) read_register (PADDR_U_REGNUM); */
+/* OBSOLETE return (i + addr - (CORE_ADDR) UVADDR); */
+/* OBSOLETE } */
+/* OBSOLETE else */
+/* OBSOLETE { */
+/* OBSOLETE return (addr); */
+/* OBSOLETE } */
+/* OBSOLETE #else */
+/* OBSOLETE return (addr); */
+/* OBSOLETE #endif */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE */
+/* OBSOLETE /* FIXME! Merge these two. */ */
+/* OBSOLETE int */
+/* OBSOLETE adapt_xfer_inferior_memory (CORE_ADDR memaddr, char *myaddr, int len, int write, */
+/* OBSOLETE struct mem_attrib *attrib ATTRIBUTE_UNUSED, */
+/* OBSOLETE struct target_ops *target ATTRIBUTE_UNUSED) */
+/* OBSOLETE { */
+/* OBSOLETE */
+/* OBSOLETE memaddr = translate_addr (memaddr); */
+/* OBSOLETE */
+/* OBSOLETE if (write) */
+/* OBSOLETE return adapt_write_inferior_memory (memaddr, myaddr, len); */
+/* OBSOLETE else */
+/* OBSOLETE return adapt_read_inferior_memory (memaddr, myaddr, len); */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE void */
+/* OBSOLETE adapt_files_info (void) */
+/* OBSOLETE { */
+/* OBSOLETE printf_filtered ("\tAttached to %s at %d baud and running program %s\n", */
+/* OBSOLETE dev_name, baudrate, prog_name); */
+/* OBSOLETE printf_filtered ("\ton an %s processor.\n", processor_name[processor_type]); */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* Copy LEN bytes of data from debugger memory at MYADDR */
+/* OBSOLETE to inferior's memory at MEMADDR. Returns errno value. */
+/* OBSOLETE * sb/sh instructions don't work on unaligned addresses, when TU=1. */
+/* OBSOLETE */ */
+/* OBSOLETE int */
+/* OBSOLETE adapt_write_inferior_memory (CORE_ADDR memaddr, char *myaddr, int len) */
+/* OBSOLETE { */
+/* OBSOLETE int i; */
+/* OBSOLETE unsigned int cps; */
+/* OBSOLETE */
+/* OBSOLETE /* Turn TU bit off so we can do 'sb' commands */ */
+/* OBSOLETE cps = read_register (CPS_REGNUM); */
+/* OBSOLETE if (cps & 0x00000800) */
+/* OBSOLETE write_register (CPS_REGNUM, cps & ~(0x00000800)); */
+/* OBSOLETE */
+/* OBSOLETE for (i = 0; i < len; i++) */
+/* OBSOLETE { */
+/* OBSOLETE if ((i % 16) == 0) */
+/* OBSOLETE fprintf (adapt_stream, "sb %x,", memaddr + i); */
+/* OBSOLETE if ((i % 16) == 15 || i == len - 1) */
+/* OBSOLETE { */
+/* OBSOLETE fprintf (adapt_stream, "%x\r", ((unsigned char *) myaddr)[i]); */
+/* OBSOLETE expect_prompt (); */
+/* OBSOLETE } */
+/* OBSOLETE else */
+/* OBSOLETE fprintf (adapt_stream, "%x,", ((unsigned char *) myaddr)[i]); */
+/* OBSOLETE } */
+/* OBSOLETE /* Restore the old value of cps if the TU bit was on */ */
+/* OBSOLETE if (cps & 0x00000800) */
+/* OBSOLETE write_register (CPS_REGNUM, cps); */
+/* OBSOLETE return len; */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* Read LEN bytes from inferior memory at MEMADDR. Put the result */
+/* OBSOLETE at debugger address MYADDR. Returns errno value. */ */
+/* OBSOLETE int */
+/* OBSOLETE adapt_read_inferior_memory (CORE_ADDR memaddr, char *myaddr, int len) */
+/* OBSOLETE { */
+/* OBSOLETE int i; */
+/* OBSOLETE */
+/* OBSOLETE /* Number of bytes read so far. */ */
+/* OBSOLETE int count; */
+/* OBSOLETE */
+/* OBSOLETE /* Starting address of this pass. */ */
+/* OBSOLETE unsigned long startaddr; */
+/* OBSOLETE */
+/* OBSOLETE /* Number of bytes to read in this pass. */ */
+/* OBSOLETE int len_this_pass; */
+/* OBSOLETE */
+/* OBSOLETE /* Note that this code works correctly if startaddr is just less */
+/* OBSOLETE than UINT_MAX (well, really CORE_ADDR_MAX if there was such a */
+/* OBSOLETE thing). That is, something like */
+/* OBSOLETE adapt_read_bytes (CORE_ADDR_MAX - 4, foo, 4) */
+/* OBSOLETE works--it never adds len to memaddr and gets 0. */ */
+/* OBSOLETE /* However, something like */
+/* OBSOLETE adapt_read_bytes (CORE_ADDR_MAX - 3, foo, 4) */
+/* OBSOLETE doesn't need to work. Detect it and give up if there's an attempt */
+/* OBSOLETE to do that. */ */
+/* OBSOLETE */
+/* OBSOLETE if (((memaddr - 1) + len) < memaddr) */
+/* OBSOLETE return EIO; */
+/* OBSOLETE */
+/* OBSOLETE startaddr = memaddr; */
+/* OBSOLETE count = 0; */
+/* OBSOLETE while (count < len) */
+/* OBSOLETE { */
+/* OBSOLETE len_this_pass = 16; */
+/* OBSOLETE if ((startaddr % 16) != 0) */
+/* OBSOLETE len_this_pass -= startaddr % 16; */
+/* OBSOLETE if (len_this_pass > (len - count)) */
+/* OBSOLETE len_this_pass = (len - count); */
+/* OBSOLETE */
+/* OBSOLETE fprintf (adapt_stream, "db %x,%x\r", startaddr, */
+/* OBSOLETE (startaddr - 1) + len_this_pass); */
+/* OBSOLETE */
+/* OBSOLETE #ifdef NOTDEF /* Why do this */ */
+/* OBSOLETE expect ("\n"); */
+/* OBSOLETE /* Look for 8 hex digits. */ */
+/* OBSOLETE i = 0; */
+/* OBSOLETE while (1) */
+/* OBSOLETE { */
+/* OBSOLETE if (isxdigit (readchar ())) */
+/* OBSOLETE ++i; */
+/* OBSOLETE else */
+/* OBSOLETE { */
+/* OBSOLETE expect_prompt (); */
+/* OBSOLETE error ("Hex digit expected from remote system."); */
+/* OBSOLETE } */
+/* OBSOLETE if (i >= 8) */
+/* OBSOLETE break; */
+/* OBSOLETE } */
+/* OBSOLETE #endif /* NOTDEF */ */
+/* OBSOLETE */
+/* OBSOLETE expect (" "); */
+/* OBSOLETE */
+/* OBSOLETE for (i = 0; i < len_this_pass; i++) */
+/* OBSOLETE get_hex_byte (&myaddr[count++]); */
+/* OBSOLETE */
+/* OBSOLETE expect_prompt (); */
+/* OBSOLETE */
+/* OBSOLETE startaddr += len_this_pass; */
+/* OBSOLETE } */
+/* OBSOLETE return count; */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE #define MAX_BREAKS 8 */
+/* OBSOLETE static int num_brkpts = 0; */
+/* OBSOLETE */
+/* OBSOLETE /* Insert a breakpoint at ADDR. SAVE is normally the address of the */
+/* OBSOLETE pattern buffer where the instruction that the breakpoint overwrites */
+/* OBSOLETE is saved. It is unused here since the Adapt Monitor is responsible */
+/* OBSOLETE for saving/restoring the original instruction. */ */
+/* OBSOLETE */
+/* OBSOLETE static int */
+/* OBSOLETE adapt_insert_breakpoint (CORE_ADDR addr, char *save) */
+/* OBSOLETE { */
+/* OBSOLETE if (num_brkpts < MAX_BREAKS) */
+/* OBSOLETE { */
+/* OBSOLETE num_brkpts++; */
+/* OBSOLETE fprintf (adapt_stream, "B %x", addr); */
+/* OBSOLETE fprintf (adapt_stream, "\r"); */
+/* OBSOLETE expect_prompt (); */
+/* OBSOLETE return (0); /* Success */ */
+/* OBSOLETE } */
+/* OBSOLETE else */
+/* OBSOLETE { */
+/* OBSOLETE fprintf_filtered (gdb_stderr, */
+/* OBSOLETE "Too many break points, break point not installed\n"); */
+/* OBSOLETE return (1); /* Failure */ */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* Remove a breakpoint at ADDR. SAVE is normally the previously */
+/* OBSOLETE saved pattern, but is unused here as the Adapt Monitor is */
+/* OBSOLETE responsible for saving/restoring instructions. */ */
+/* OBSOLETE */
+/* OBSOLETE static int */
+/* OBSOLETE adapt_remove_breakpoint (CORE_ADDR addr, char *save) */
+/* OBSOLETE { */
+/* OBSOLETE if (num_brkpts > 0) */
+/* OBSOLETE { */
+/* OBSOLETE num_brkpts--; */
+/* OBSOLETE fprintf (adapt_stream, "BR %x", addr); */
+/* OBSOLETE fprintf (adapt_stream, "\r"); */
+/* OBSOLETE fflush (adapt_stream); */
+/* OBSOLETE expect_prompt (); */
+/* OBSOLETE } */
+/* OBSOLETE return (0); */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* Clear the adapts notion of what the break points are */ */
+/* OBSOLETE static int */
+/* OBSOLETE adapt_clear_breakpoints (void) */
+/* OBSOLETE { */
+/* OBSOLETE if (adapt_stream) */
+/* OBSOLETE { */
+/* OBSOLETE fprintf (adapt_stream, "BR"); /* Clear all break points */ */
+/* OBSOLETE fprintf (adapt_stream, "\r"); */
+/* OBSOLETE fflush (adapt_stream); */
+/* OBSOLETE expect_prompt (); */
+/* OBSOLETE } */
+/* OBSOLETE num_brkpts = 0; */
+/* OBSOLETE } */
+/* OBSOLETE static void */
+/* OBSOLETE adapt_mourn (void) */
+/* OBSOLETE { */
+/* OBSOLETE adapt_clear_breakpoints (); */
+/* OBSOLETE pop_target (); /* Pop back to no-child state */ */
+/* OBSOLETE generic_mourn_inferior (); */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* Display everthing we read in from the adapt until we match/see the */
+/* OBSOLETE * specified string */
+/* OBSOLETE */ */
+/* OBSOLETE static int */
+/* OBSOLETE display_until (char *str) */
+/* OBSOLETE { */
+/* OBSOLETE int i = 0, j, c; */
+/* OBSOLETE */
+/* OBSOLETE while (c = readchar ()) */
+/* OBSOLETE { */
+/* OBSOLETE if (c == str[i]) */
+/* OBSOLETE { */
+/* OBSOLETE i++; */
+/* OBSOLETE if (i == strlen (str)) */
+/* OBSOLETE return; */
+/* OBSOLETE } */
+/* OBSOLETE else */
+/* OBSOLETE { */
+/* OBSOLETE if (i) */
+/* OBSOLETE { */
+/* OBSOLETE for (j = 0; j < i; j++) /* Put everthing we matched */ */
+/* OBSOLETE putchar (str[j]); */
+/* OBSOLETE i = 0; */
+/* OBSOLETE } */
+/* OBSOLETE putchar (c); */
+/* OBSOLETE } */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE */
+/* OBSOLETE /* Put a command string, in args, out to the adapt. The adapt is assumed to */
+/* OBSOLETE be in raw mode, all writing/reading done through adapt_desc. */
+/* OBSOLETE Ouput from the adapt is placed on the users terminal until the */
+/* OBSOLETE prompt from the adapt is seen. */
+/* OBSOLETE FIXME: Can't handle commands that take input. */ */
+/* OBSOLETE */
+/* OBSOLETE void */
+/* OBSOLETE adapt_com (char *args, int fromtty) */
+/* OBSOLETE { */
+/* OBSOLETE if (!adapt_stream) */
+/* OBSOLETE { */
+/* OBSOLETE printf_filtered ("Adapt not open. Use the 'target' command to open.\n"); */
+/* OBSOLETE return; */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* Clear all input so only command relative output is displayed */ */
+/* OBSOLETE slurp_input (); */
+/* OBSOLETE */
+/* OBSOLETE switch (islower (args[0]) ? toupper (args[0]) : args[0]) */
+/* OBSOLETE { */
+/* OBSOLETE default: */
+/* OBSOLETE printf_filtered ("Unknown/Unimplemented adapt command '%s'\n", args); */
+/* OBSOLETE break; */
+/* OBSOLETE case 'G': /* Go, begin execution */ */
+/* OBSOLETE write (adapt_desc, args, strlen (args)); */
+/* OBSOLETE write (adapt_desc, "\r", 1); */
+/* OBSOLETE expect_prompt (); */
+/* OBSOLETE break; */
+/* OBSOLETE case 'B': /* Break points, B or BR */ */
+/* OBSOLETE case 'C': /* Check current 29k status (running/halted) */ */
+/* OBSOLETE case 'D': /* Display data/registers */ */
+/* OBSOLETE case 'I': /* Input from i/o space */ */
+/* OBSOLETE case 'J': /* Jam an instruction */ */
+/* OBSOLETE case 'K': /* Kill, stop execution */ */
+/* OBSOLETE case 'L': /* Disassemble */ */
+/* OBSOLETE case 'O': /* Output to i/o space */ */
+/* OBSOLETE case 'T': /* Trace */ */
+/* OBSOLETE case 'P': /* Pulse an input line */ */
+/* OBSOLETE case 'X': /* Examine special purpose registers */ */
+/* OBSOLETE case 'Z': /* Display trace buffer */ */
+/* OBSOLETE write (adapt_desc, args, strlen (args)); */
+/* OBSOLETE write (adapt_desc, "\r", 1); */
+/* OBSOLETE expect (args); /* Don't display the command */ */
+/* OBSOLETE display_until ("# "); */
+/* OBSOLETE break; */
+/* OBSOLETE /* Begin commands that take input in the form 'c x,y[,z...]' */ */
+/* OBSOLETE case 'S': /* Set memory or register */ */
+/* OBSOLETE if (strchr (args, ',')) */
+/* OBSOLETE { /* Assume it is properly formatted */ */
+/* OBSOLETE write (adapt_desc, args, strlen (args)); */
+/* OBSOLETE write (adapt_desc, "\r", 1); */
+/* OBSOLETE expect_prompt (); */
+/* OBSOLETE } */
+/* OBSOLETE break; */
+/* OBSOLETE } */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* Define the target subroutine names */ */
+/* OBSOLETE */
+/* OBSOLETE struct target_ops adapt_ops; */
+/* OBSOLETE */
+/* OBSOLETE static void */
+/* OBSOLETE init_adapt_ops (void) */
+/* OBSOLETE { */
+/* OBSOLETE adapt_ops.to_shortname = "adapt"; */
+/* OBSOLETE adapt_ops.to_longname = "Remote AMD `Adapt' target"; */
+/* OBSOLETE adapt_ops.to_doc = "Remote debug an AMD 290*0 using an `Adapt' monitor via RS232"; */
+/* OBSOLETE adapt_ops.to_open = adapt_open; */
+/* OBSOLETE adapt_ops.to_close = adapt_close; */
+/* OBSOLETE adapt_ops.to_attach = adapt_attach; */
+/* OBSOLETE adapt_ops.to_post_attach = NULL; */
+/* OBSOLETE adapt_ops.to_require_attach = NULL; */
+/* OBSOLETE adapt_ops.to_detach = adapt_detach; */
+/* OBSOLETE adapt_ops.to_require_detach = NULL; */
+/* OBSOLETE adapt_ops.to_resume = adapt_resume; */
+/* OBSOLETE adapt_ops.to_wait = adapt_wait; */
+/* OBSOLETE adapt_ops.to_post_wait = NULL; */
+/* OBSOLETE adapt_ops.to_fetch_registers = adapt_fetch_register; */
+/* OBSOLETE adapt_ops.to_store_registers = adapt_store_register; */
+/* OBSOLETE adapt_ops.to_prepare_to_store = adapt_prepare_to_store; */
+/* OBSOLETE adapt_ops.to_xfer_memory = adapt_xfer_inferior_memory; */
+/* OBSOLETE adapt_ops.to_files_info = adapt_files_info; */
+/* OBSOLETE adapt_ops.to_insert_breakpoint = adapt_insert_breakpoint; */
+/* OBSOLETE adapt_ops.to_remove_breakpoint = adapt_remove_breakpoint; */
+/* OBSOLETE adapt_ops.to_terminal_init = 0; */
+/* OBSOLETE adapt_ops.to_terminal_inferior = 0; */
+/* OBSOLETE adapt_ops.to_terminal_ours_for_output = 0; */
+/* OBSOLETE adapt_ops.to_terminal_ours = 0; */
+/* OBSOLETE adapt_ops.to_terminal_info = 0; */
+/* OBSOLETE adapt_ops.to_kill = adapt_kill; */
+/* OBSOLETE adapt_ops.to_load = adapt_load; */
+/* OBSOLETE adapt_ops.to_lookup_symbol = 0; */
+/* OBSOLETE adapt_ops.to_create_inferior = adapt_create_inferior; */
+/* OBSOLETE adapt_ops.to_post_startup_inferior = NULL; */
+/* OBSOLETE adapt_ops.to_acknowledge_created_inferior = NULL; */
+/* OBSOLETE adapt_ops.to_clone_and_follow_inferior = NULL; */
+/* OBSOLETE adapt_ops.to_post_follow_inferior_by_clone = NULL; */
+/* OBSOLETE adapt_ops.to_insert_fork_catchpoint = NULL; */
+/* OBSOLETE adapt_ops.to_remove_fork_catchpoint = NULL; */
+/* OBSOLETE adapt_ops.to_insert_vfork_catchpoint = NULL; */
+/* OBSOLETE adapt_ops.to_remove_vfork_catchpoint = NULL; */
+/* OBSOLETE adapt_ops.to_has_forked = NULL; */
+/* OBSOLETE adapt_ops.to_has_vforked = NULL; */
+/* OBSOLETE adapt_ops.to_can_follow_vfork_prior_to_exec = NULL; */
+/* OBSOLETE adapt_ops.to_post_follow_vfork = NULL; */
+/* OBSOLETE adapt_ops.to_insert_exec_catchpoint = NULL; */
+/* OBSOLETE adapt_ops.to_remove_exec_catchpoint = NULL; */
+/* OBSOLETE adapt_ops.to_has_execd = NULL; */
+/* OBSOLETE adapt_ops.to_reported_exec_events_per_exec_call = NULL; */
+/* OBSOLETE adapt_ops.to_has_exited = NULL; */
+/* OBSOLETE adapt_ops.to_mourn_inferior = adapt_mourn; */
+/* OBSOLETE adapt_ops.to_can_run = 0; */
+/* OBSOLETE adapt_ops.to_notice_signals = 0; */
+/* OBSOLETE adapt_ops.to_thread_alive = 0; */
+/* OBSOLETE adapt_ops.to_stop = 0; /* process_stratum; */ */
+/* OBSOLETE adapt_ops.to_pid_to_exec_file = NULL; */
+/* OBSOLETE adapt_ops.to_stratum = 0; */
+/* OBSOLETE adapt_ops.DONT_USE = 0; */
+/* OBSOLETE adapt_ops.to_has_all_memory = 1; */
+/* OBSOLETE adapt_ops.to_has_memory = 1; */
+/* OBSOLETE adapt_ops.to_has_stack = 1; */
+/* OBSOLETE adapt_ops.to_has_registers = 1; */
+/* OBSOLETE adapt_ops.to_has_execution = 0; */
+/* OBSOLETE adapt_ops.to_sections = 0; */
+/* OBSOLETE adapt_ops.to_sections_end = 0; */
+/* OBSOLETE adapt_ops.to_magic = OPS_MAGIC; */
+/* OBSOLETE } /* init_adapt_ops */ */
+/* OBSOLETE */
+/* OBSOLETE void */
+/* OBSOLETE _initialize_remote_adapt (void) */
+/* OBSOLETE { */
+/* OBSOLETE init_adapt_ops (); */
+/* OBSOLETE add_target (&adapt_ops); */
+/* OBSOLETE add_com ("adapt <command>", class_obscure, adapt_com, */
+/* OBSOLETE "Send a command to the AMD Adapt remote monitor."); */
+/* OBSOLETE } */
-/* Remote debugging interface for AMD 29000 EBMON on IBM PC, for GDB.
- Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1998, 1999, 2000, 2001
- Free Software Foundation, Inc.
- Contributed by Cygnus Support. Written by Jim Kingdon for Cygnus.
-
- This file is part of GDB.
-
- 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.
-
- 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.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA. */
-
-/* This is like remote.c but is for an esoteric situation--
- having a a29k board in a PC hooked up to a unix machine with
- a serial line, and running ctty com1 on the PC, through which
- the unix machine can run ebmon. Not to mention that the PC
- has PC/NFS, so it can access the same executables that gdb can,
- over the net in real time. */
-
-#include "defs.h"
-#include "gdb_string.h"
-#include "regcache.h"
-
-#include "inferior.h"
-#include "bfd.h"
-#include "symfile.h"
-#include "value.h"
-#include <ctype.h>
-#include <fcntl.h>
-#include <signal.h>
-#include <errno.h>
-#include "terminal.h"
-#include "target.h"
-#include "gdbcore.h"
-
-extern struct target_ops eb_ops; /* Forward declaration */
-
-static void eb_close ();
-
-#define LOG_FILE "eb.log"
-#if defined (LOG_FILE)
-FILE *log_file;
-#endif
-
-static int timeout = 24;
-
-/* Descriptor for I/O to remote machine. Initialize it to -1 so that
- eb_open knows that we don't have a file open when the program
- starts. */
-int eb_desc = -1;
-
-/* stream which is fdopen'd from eb_desc. Only valid when
- eb_desc != -1. */
-FILE *eb_stream;
-
-/* Read a character from the remote system, doing all the fancy
- timeout stuff. */
-static int
-readchar (void)
-{
- char buf;
-
- buf = '\0';
-#ifdef HAVE_TERMIO
- /* termio does the timeout for us. */
- read (eb_desc, &buf, 1);
-#else
- alarm (timeout);
- if (read (eb_desc, &buf, 1) < 0)
- {
- if (errno == EINTR)
- error ("Timeout reading from remote system.");
- else
- perror_with_name ("remote");
- }
- alarm (0);
-#endif
-
- if (buf == '\0')
- error ("Timeout reading from remote system.");
-#if defined (LOG_FILE)
- putc (buf & 0x7f, log_file);
-#endif
- return buf & 0x7f;
-}
-
-/* Keep discarding input from the remote system, until STRING is found.
- Let the user break out immediately. */
-static void
-expect (char *string)
-{
- char *p = string;
-
- immediate_quit++;
- while (1)
- {
- if (readchar () == *p)
- {
- p++;
- if (*p == '\0')
- {
- immediate_quit--;
- return;
- }
- }
- else
- p = string;
- }
-}
-
-/* Keep discarding input until we see the ebmon prompt.
-
- The convention for dealing with the prompt is that you
- o give your command
- o *then* wait for the prompt.
-
- Thus the last thing that a procedure does with the serial line
- will be an expect_prompt(). Exception: eb_resume does not
- wait for the prompt, because the terminal is being handed over
- to the inferior. However, the next thing which happens after that
- is a eb_wait which does wait for the prompt.
- Note that this includes abnormal exit, e.g. error(). This is
- necessary to prevent getting into states from which we can't
- recover. */
-static void
-expect_prompt (void)
-{
-#if defined (LOG_FILE)
- /* This is a convenient place to do this. The idea is to do it often
- enough that we never lose much data if we terminate abnormally. */
- fflush (log_file);
-#endif
- expect ("\n# ");
-}
-
-/* Get a hex digit from the remote system & return its value.
- If ignore_space is nonzero, ignore spaces (not newline, tab, etc). */
-static int
-get_hex_digit (int ignore_space)
-{
- int ch;
- while (1)
- {
- ch = readchar ();
- if (ch >= '0' && ch <= '9')
- return ch - '0';
- else if (ch >= 'A' && ch <= 'F')
- return ch - 'A' + 10;
- else if (ch >= 'a' && ch <= 'f')
- return ch - 'a' + 10;
- else if (ch == ' ' && ignore_space)
- ;
- else
- {
- expect_prompt ();
- error ("Invalid hex digit from remote system.");
- }
- }
-}
-
-/* Get a byte from eb_desc and put it in *BYT. Accept any number
- leading spaces. */
-static void
-get_hex_byte (char *byt)
-{
- int val;
-
- val = get_hex_digit (1) << 4;
- val |= get_hex_digit (0);
- *byt = val;
-}
-
-/* Get N 32-bit words from remote, each preceded by a space,
- and put them in registers starting at REGNO. */
-static void
-get_hex_regs (int n, int regno)
-{
- long val;
- int i;
-
- for (i = 0; i < n; i++)
- {
- int j;
-
- val = 0;
- for (j = 0; j < 8; j++)
- val = (val << 4) + get_hex_digit (j == 0);
- supply_register (regno++, (char *) &val);
- }
-}
-
-/* Called when SIGALRM signal sent due to alarm() timeout. */
-#ifndef HAVE_TERMIO
-
-volatile int n_alarms;
-
-void
-eb_timer (void)
-{
-#if 0
- if (kiodebug)
- printf ("eb_timer called\n");
-#endif
- n_alarms++;
-}
-#endif
-
-/* malloc'd name of the program on the remote system. */
-static char *prog_name = NULL;
-
-/* Nonzero if we have loaded the file ("yc") and not yet issued a "gi"
- command. "gi" is supposed to happen exactly once for each "yc". */
-static int need_gi = 0;
-
-/* Number of SIGTRAPs we need to simulate. That is, the next
- NEED_ARTIFICIAL_TRAP calls to eb_wait should just return
- SIGTRAP without actually waiting for anything. */
-
-static int need_artificial_trap = 0;
-
-/* This is called not only when we first attach, but also when the
- user types "run" after having attached. */
-static void
-eb_create_inferior (char *execfile, char *args, char **env)
-{
- int entry_pt;
-
- if (args && *args)
- error ("Can't pass arguments to remote EBMON process");
-
- if (execfile == 0 || exec_bfd == 0)
- error ("No executable file specified");
-
- entry_pt = (int) bfd_get_start_address (exec_bfd);
-
- {
- /* OK, now read in the file. Y=read, C=COFF, D=no symbols
- 0=start address, %s=filename. */
-
- fprintf (eb_stream, "YC D,0:%s", prog_name);
-
- if (args != NULL)
- fprintf (eb_stream, " %s", args);
-
- fprintf (eb_stream, "\n");
- fflush (eb_stream);
-
- expect_prompt ();
-
- need_gi = 1;
- }
-
-/* The "process" (board) is already stopped awaiting our commands, and
- the program is already downloaded. We just set its PC and go. */
-
- clear_proceed_status ();
-
- /* Tell wait_for_inferior that we've started a new process. */
- init_wait_for_inferior ();
-
- /* Set up the "saved terminal modes" of the inferior
- based on what modes we are starting it with. */
- target_terminal_init ();
-
- /* Install inferior's terminal modes. */
- target_terminal_inferior ();
-
- /* insert_step_breakpoint (); FIXME, do we need this? */
- proceed ((CORE_ADDR) entry_pt, TARGET_SIGNAL_DEFAULT, 0); /* Let 'er rip... */
-}
-
-/* Translate baud rates from integers to damn B_codes. Unix should
- have outgrown this crap years ago, but even POSIX wouldn't buck it. */
-
-#ifndef B19200
-#define B19200 EXTA
-#endif
-#ifndef B38400
-#define B38400 EXTB
-#endif
-
-struct
-{
- int rate, damn_b;
-}
-baudtab[] =
-{
- {
- 0, B0
- }
- ,
- {
- 50, B50
- }
- ,
- {
- 75, B75
- }
- ,
- {
- 110, B110
- }
- ,
- {
- 134, B134
- }
- ,
- {
- 150, B150
- }
- ,
- {
- 200, B200
- }
- ,
- {
- 300, B300
- }
- ,
- {
- 600, B600
- }
- ,
- {
- 1200, B1200
- }
- ,
- {
- 1800, B1800
- }
- ,
- {
- 2400, B2400
- }
- ,
- {
- 4800, B4800
- }
- ,
- {
- 9600, B9600
- }
- ,
- {
- 19200, B19200
- }
- ,
- {
- 38400, B38400
- }
- ,
- {
- -1, -1
- }
- ,
-};
-
-int
-damn_b (int rate)
-{
- int i;
-
- for (i = 0; baudtab[i].rate != -1; i++)
- if (rate == baudtab[i].rate)
- return baudtab[i].damn_b;
- return B38400; /* Random */
-}
-
-
-/* Open a connection to a remote debugger.
- NAME is the filename used for communication, then a space,
- then the name of the program as we should name it to EBMON. */
-
-static int baudrate = 9600;
-static char *dev_name;
-void
-eb_open (char *name, int from_tty)
-{
- TERMINAL sg;
-
- char *p;
-
- target_preopen (from_tty);
-
- /* Find the first whitespace character, it separates dev_name from
- prog_name. */
- if (name == 0)
- goto erroid;
-
- for (p = name;
- *p != '\0' && !isspace (*p); p++)
- ;
- if (*p == '\0')
- erroid:
- error ("\
-Please include the name of the device for the serial port,\n\
-the baud rate, and the name of the program to run on the remote system.");
- dev_name = alloca (p - name + 1);
- strncpy (dev_name, name, p - name);
- dev_name[p - name] = '\0';
-
- /* Skip over the whitespace after dev_name */
- for (; isspace (*p); p++)
- /*EMPTY */ ;
-
- if (1 != sscanf (p, "%d ", &baudrate))
- goto erroid;
-
- /* Skip the number and then the spaces */
- for (; isdigit (*p); p++)
- /*EMPTY */ ;
- for (; isspace (*p); p++)
- /*EMPTY */ ;
-
- if (prog_name != NULL)
- xfree (prog_name);
- prog_name = savestring (p, strlen (p));
-
- eb_close (0);
-
- eb_desc = open (dev_name, O_RDWR);
- if (eb_desc < 0)
- perror_with_name (dev_name);
- ioctl (eb_desc, TIOCGETP, &sg);
-#ifdef HAVE_TERMIO
- sg.c_cc[VMIN] = 0; /* read with timeout. */
- sg.c_cc[VTIME] = timeout * 10;
- sg.c_lflag &= ~(ICANON | ECHO);
- sg.c_cflag = (sg.c_cflag & ~CBAUD) | damn_b (baudrate);
-#else
- sg.sg_ispeed = damn_b (baudrate);
- sg.sg_ospeed = damn_b (baudrate);
- sg.sg_flags |= RAW | ANYP;
- sg.sg_flags &= ~ECHO;
-#endif
-
- ioctl (eb_desc, TIOCSETP, &sg);
- eb_stream = fdopen (eb_desc, "r+");
-
- push_target (&eb_ops);
- if (from_tty)
- printf ("Remote %s debugging %s using %s\n", target_shortname,
- prog_name, dev_name);
-
-#ifndef HAVE_TERMIO
-#ifndef NO_SIGINTERRUPT
- /* Cause SIGALRM's to make reads fail with EINTR instead of resuming
- the read. */
- if (siginterrupt (SIGALRM, 1) != 0)
- perror ("eb_open: error in siginterrupt");
-#endif
-
- /* Set up read timeout timer. */
- if ((void (*)) signal (SIGALRM, eb_timer) == (void (*)) -1)
- perror ("eb_open: error in signal");
-#endif
-
-#if defined (LOG_FILE)
- log_file = fopen (LOG_FILE, "w");
- if (log_file == NULL)
- perror_with_name (LOG_FILE);
-#endif
-
- /* Hello? Are you there? */
- write (eb_desc, "\n", 1);
-
- expect_prompt ();
-}
-
-/* Close out all files and local state before this target loses control. */
-
-static void
-eb_close (int quitting)
-{
-
- /* Due to a bug in Unix, fclose closes not only the stdio stream,
- but also the file descriptor. So we don't actually close
- eb_desc. */
- if (eb_stream)
- fclose (eb_stream); /* This also closes eb_desc */
- if (eb_desc >= 0)
- /* close (eb_desc); */
-
- /* Do not try to close eb_desc again, later in the program. */
- eb_stream = NULL;
- eb_desc = -1;
-
-#if defined (LOG_FILE)
- if (log_file)
- {
- if (ferror (log_file))
- printf ("Error writing log file.\n");
- if (fclose (log_file) != 0)
- printf ("Error closing log file.\n");
- }
-#endif
-}
-
-/* Terminate the open connection to the remote debugger.
- Use this when you want to detach and do something else
- with your gdb. */
-void
-eb_detach (int from_tty)
-{
- pop_target (); /* calls eb_close to do the real work */
- if (from_tty)
- printf ("Ending remote %s debugging\n", target_shortname);
-}
-
-/* Tell the remote machine to resume. */
-
-void
-eb_resume (ptid_t ptid, int step, enum target_signal sig)
-{
- if (step)
- {
- write (eb_desc, "t 1,s\n", 6);
- /* Wait for the echo. */
- expect ("t 1,s\r");
- /* Then comes a line containing the instruction we stepped to. */
- expect ("\n@");
- /* Then we get the prompt. */
- expect_prompt ();
-
- /* Force the next eb_wait to return a trap. Not doing anything
- about I/O from the target means that the user has to type
- "continue" to see any. This should be fixed. */
- need_artificial_trap = 1;
- }
- else
- {
- if (need_gi)
- {
- need_gi = 0;
- write (eb_desc, "gi\n", 3);
-
- /* Swallow the echo of "gi". */
- expect ("gi\r");
- }
- else
- {
- write (eb_desc, "GR\n", 3);
- /* Swallow the echo. */
- expect ("GR\r");
- }
- }
-}
-
-/* Wait until the remote machine stops, then return,
- storing status in STATUS just as `wait' would. */
-
-ptid_t
-eb_wait (ptid_t ptid, struct target_waitstatus *status)
-{
- /* Strings to look for. '?' means match any single character.
- Note that with the algorithm we use, the initial character
- of the string cannot recur in the string, or we will not
- find some cases of the string in the input. */
-
- static char bpt[] = "Invalid interrupt taken - #0x50 - ";
- /* It would be tempting to look for "\n[__exit + 0x8]\n"
- but that requires loading symbols with "yc i" and even if
- we did do that we don't know that the file has symbols. */
- static char exitmsg[] = "\n@????????I JMPTI GR121,LR0";
- char *bp = bpt;
- char *ep = exitmsg;
-
- /* Large enough for either sizeof (bpt) or sizeof (exitmsg) chars. */
- char swallowed[50];
- /* Current position in swallowed. */
- char *swallowed_p = swallowed;
-
- int ch;
- int ch_handled;
-
- int old_timeout = timeout;
-
- status->kind = TARGET_WAITKIND_EXITED;
- status->value.integer = 0;
-
- if (need_artificial_trap != 0)
- {
- status->kind = TARGET_WAITKIND_STOPPED;
- status->value.sig = TARGET_SIGNAL_TRAP;
- need_artificial_trap--;
- return 0;
- }
-
- timeout = 0; /* Don't time out -- user program is running. */
- while (1)
- {
- ch_handled = 0;
- ch = readchar ();
- if (ch == *bp)
- {
- bp++;
- if (*bp == '\0')
- break;
- ch_handled = 1;
-
- *swallowed_p++ = ch;
- }
- else
- bp = bpt;
-
- if (ch == *ep || *ep == '?')
- {
- ep++;
- if (*ep == '\0')
- break;
-
- if (!ch_handled)
- *swallowed_p++ = ch;
- ch_handled = 1;
- }
- else
- ep = exitmsg;
-
- if (!ch_handled)
- {
- char *p;
-
- /* Print out any characters which have been swallowed. */
- for (p = swallowed; p < swallowed_p; ++p)
- putc (*p, stdout);
- swallowed_p = swallowed;
-
- putc (ch, stdout);
- }
- }
- expect_prompt ();
- if (*bp == '\0')
- {
- status->kind = TARGET_WAITKIND_STOPPED;
- status->value.sig = TARGET_SIGNAL_TRAP;
- }
- else
- {
- status->kind = TARGET_WAITKIND_EXITED;
- status->value.integer = 0;
- }
- timeout = old_timeout;
-
- return 0;
-}
-
-/* Return the name of register number REGNO
- in the form input and output by EBMON.
-
- Returns a pointer to a static buffer containing the answer. */
-static char *
-get_reg_name (int regno)
-{
- static char buf[80];
- if (regno >= GR96_REGNUM && regno < GR96_REGNUM + 32)
- sprintf (buf, "GR%03d", regno - GR96_REGNUM + 96);
- else if (regno >= LR0_REGNUM && regno < LR0_REGNUM + 128)
- sprintf (buf, "LR%03d", regno - LR0_REGNUM);
- else if (regno == Q_REGNUM)
- strcpy (buf, "SR131");
- else if (regno >= BP_REGNUM && regno <= CR_REGNUM)
- sprintf (buf, "SR%03d", regno - BP_REGNUM + 133);
- else if (regno == ALU_REGNUM)
- strcpy (buf, "SR132");
- else if (regno >= IPC_REGNUM && regno <= IPB_REGNUM)
- sprintf (buf, "SR%03d", regno - IPC_REGNUM + 128);
- else if (regno >= VAB_REGNUM && regno <= LRU_REGNUM)
- sprintf (buf, "SR%03d", regno - VAB_REGNUM);
- else if (regno == GR1_REGNUM)
- strcpy (buf, "GR001");
- return buf;
-}
-
-/* Read the remote registers into the block REGS. */
-
-static void
-eb_fetch_registers (void)
-{
- int reg_index;
- int regnum_index;
- char tempbuf[10];
- int i;
-
-#if 0
- /* This should not be necessary, because one is supposed to read the
- registers only when the inferior is stopped (at least with
- ptrace() and why not make it the same for remote?). */
- /* ^A is the "normal character" used to make sure we are talking to EBMON
- and not to the program being debugged. */
- write (eb_desc, "\001\n");
- expect_prompt ();
-#endif
-
- write (eb_desc, "dw gr96,gr127\n", 14);
- for (reg_index = 96, regnum_index = GR96_REGNUM;
- reg_index < 128;
- reg_index += 4, regnum_index += 4)
- {
- sprintf (tempbuf, "GR%03d ", reg_index);
- expect (tempbuf);
- get_hex_regs (4, regnum_index);
- expect ("\n");
- }
-
- for (i = 0; i < 128; i += 32)
- {
- /* The PC has a tendency to hang if we get these
- all in one fell swoop ("dw lr0,lr127"). */
- sprintf (tempbuf, "dw lr%d\n", i);
- write (eb_desc, tempbuf, strlen (tempbuf));
- for (reg_index = i, regnum_index = LR0_REGNUM + i;
- reg_index < i + 32;
- reg_index += 4, regnum_index += 4)
- {
- sprintf (tempbuf, "LR%03d ", reg_index);
- expect (tempbuf);
- get_hex_regs (4, regnum_index);
- expect ("\n");
- }
- }
-
- write (eb_desc, "dw sr133,sr133\n", 15);
- expect ("SR133 ");
- get_hex_regs (1, BP_REGNUM);
- expect ("\n");
-
- write (eb_desc, "dw sr134,sr134\n", 15);
- expect ("SR134 ");
- get_hex_regs (1, FC_REGNUM);
- expect ("\n");
-
- write (eb_desc, "dw sr135,sr135\n", 15);
- expect ("SR135 ");
- get_hex_regs (1, CR_REGNUM);
- expect ("\n");
-
- write (eb_desc, "dw sr131,sr131\n", 15);
- expect ("SR131 ");
- get_hex_regs (1, Q_REGNUM);
- expect ("\n");
-
- write (eb_desc, "dw sr0,sr14\n", 12);
- for (reg_index = 0, regnum_index = VAB_REGNUM;
- regnum_index <= LRU_REGNUM;
- regnum_index += 4, reg_index += 4)
- {
- sprintf (tempbuf, "SR%03d ", reg_index);
- expect (tempbuf);
- get_hex_regs (reg_index == 12 ? 3 : 4, regnum_index);
- expect ("\n");
- }
-
- /* There doesn't seem to be any way to get these. */
- {
- int val = -1;
- supply_register (FPE_REGNUM, (char *) &val);
- supply_register (INTE_REGNUM, (char *) &val);
- supply_register (FPS_REGNUM, (char *) &val);
- supply_register (EXO_REGNUM, (char *) &val);
- }
-
- write (eb_desc, "dw gr1,gr1\n", 11);
- expect ("GR001 ");
- get_hex_regs (1, GR1_REGNUM);
- expect_prompt ();
-}
-
-/* Fetch register REGNO, or all registers if REGNO is -1.
- Returns errno value. */
-void
-eb_fetch_register (int regno)
-{
- if (regno == -1)
- eb_fetch_registers ();
- else
- {
- char *name = get_reg_name (regno);
- fprintf (eb_stream, "dw %s,%s\n", name, name);
- expect (name);
- expect (" ");
- get_hex_regs (1, regno);
- expect_prompt ();
- }
- return;
-}
-
-/* Store the remote registers from the contents of the block REGS. */
-
-static void
-eb_store_registers (void)
-{
- int i, j;
- fprintf (eb_stream, "s gr1,%x\n", read_register (GR1_REGNUM));
- expect_prompt ();
-
- for (j = 0; j < 32; j += 16)
- {
- fprintf (eb_stream, "s gr%d,", j + 96);
- for (i = 0; i < 15; ++i)
- fprintf (eb_stream, "%x,", read_register (GR96_REGNUM + j + i));
- fprintf (eb_stream, "%x\n", read_register (GR96_REGNUM + j + 15));
- expect_prompt ();
- }
-
- for (j = 0; j < 128; j += 16)
- {
- fprintf (eb_stream, "s lr%d,", j);
- for (i = 0; i < 15; ++i)
- fprintf (eb_stream, "%x,", read_register (LR0_REGNUM + j + i));
- fprintf (eb_stream, "%x\n", read_register (LR0_REGNUM + j + 15));
- expect_prompt ();
- }
-
- fprintf (eb_stream, "s sr133,%x,%x,%x\n", read_register (BP_REGNUM),
- read_register (FC_REGNUM), read_register (CR_REGNUM));
- expect_prompt ();
- fprintf (eb_stream, "s sr131,%x\n", read_register (Q_REGNUM));
- expect_prompt ();
- fprintf (eb_stream, "s sr0,");
- for (i = 0; i < 11; ++i)
- fprintf (eb_stream, "%x,", read_register (VAB_REGNUM + i));
- fprintf (eb_stream, "%x\n", read_register (VAB_REGNUM + 11));
- expect_prompt ();
-}
-
-/* Store register REGNO, or all if REGNO == 0.
- Return errno value. */
-void
-eb_store_register (int regno)
-{
- if (regno == -1)
- eb_store_registers ();
- else
- {
- char *name = get_reg_name (regno);
- fprintf (eb_stream, "s %s,%x\n", name, read_register (regno));
- /* Setting GR1 changes the numbers of all the locals, so
- invalidate the register cache. Do this *after* calling
- read_register, because we want read_register to return the
- value that write_register has just stuffed into the registers
- array, not the value of the register fetched from the
- inferior. */
- if (regno == GR1_REGNUM)
- registers_changed ();
- expect_prompt ();
- }
-}
-
-/* Get ready to modify the registers array. On machines which store
- individual registers, this doesn't need to do anything. On machines
- which store all the registers in one fell swoop, this makes sure
- that registers contains all the registers from the program being
- debugged. */
-
-void
-eb_prepare_to_store (void)
-{
- /* Do nothing, since we can store individual regs */
-}
-
-/* Transfer LEN bytes between GDB address MYADDR and target address
- MEMADDR. If WRITE is non-zero, transfer them to the target,
- otherwise transfer them from the target. TARGET is unused.
-
- Returns the number of bytes transferred. */
-
-int
-eb_xfer_inferior_memory (CORE_ADDR memaddr, char *myaddr, int len, int write,
- struct mem_attrib *attrib ATTRIBUTE_UNUSED,
- struct target_ops *target ATTRIBUTE_UNUSED)
-{
- if (write)
- return eb_write_inferior_memory (memaddr, myaddr, len);
- else
- return eb_read_inferior_memory (memaddr, myaddr, len);
-}
-
-void
-eb_files_info (void)
-{
- printf ("\tAttached to %s at %d baud and running program %s.\n",
- dev_name, baudrate, prog_name);
-}
-
-/* Copy LEN bytes of data from debugger memory at MYADDR
- to inferior's memory at MEMADDR. Returns length moved. */
-int
-eb_write_inferior_memory (CORE_ADDR memaddr, char *myaddr, int len)
-{
- int i;
-
- for (i = 0; i < len; i++)
- {
- if ((i % 16) == 0)
- fprintf (eb_stream, "sb %x,", memaddr + i);
- if ((i % 16) == 15 || i == len - 1)
- {
- fprintf (eb_stream, "%x\n", ((unsigned char *) myaddr)[i]);
- expect_prompt ();
- }
- else
- fprintf (eb_stream, "%x,", ((unsigned char *) myaddr)[i]);
- }
- return len;
-}
-
-/* Read LEN bytes from inferior memory at MEMADDR. Put the result
- at debugger address MYADDR. Returns length moved. */
-int
-eb_read_inferior_memory (CORE_ADDR memaddr, char *myaddr, int len)
-{
- int i;
-
- /* Number of bytes read so far. */
- int count;
-
- /* Starting address of this pass. */
- unsigned long startaddr;
-
- /* Number of bytes to read in this pass. */
- int len_this_pass;
-
- /* Note that this code works correctly if startaddr is just less
- than UINT_MAX (well, really CORE_ADDR_MAX if there was such a
- thing). That is, something like
- eb_read_bytes (CORE_ADDR_MAX - 4, foo, 4)
- works--it never adds len to memaddr and gets 0. */
- /* However, something like
- eb_read_bytes (CORE_ADDR_MAX - 3, foo, 4)
- doesn't need to work. Detect it and give up if there's an attempt
- to do that. */
- if (((memaddr - 1) + len) < memaddr)
- {
- errno = EIO;
- return 0;
- }
-
- startaddr = memaddr;
- count = 0;
- while (count < len)
- {
- len_this_pass = 16;
- if ((startaddr % 16) != 0)
- len_this_pass -= startaddr % 16;
- if (len_this_pass > (len - count))
- len_this_pass = (len - count);
-
- fprintf (eb_stream, "db %x,%x\n", startaddr,
- (startaddr - 1) + len_this_pass);
- expect ("\n");
-
- /* Look for 8 hex digits. */
- i = 0;
- while (1)
- {
- if (isxdigit (readchar ()))
- ++i;
- else
- {
- expect_prompt ();
- error ("Hex digit expected from remote system.");
- }
- if (i >= 8)
- break;
- }
-
- expect (" ");
-
- for (i = 0; i < len_this_pass; i++)
- get_hex_byte (&myaddr[count++]);
-
- expect_prompt ();
-
- startaddr += len_this_pass;
- }
- return len;
-}
-
-static void
-eb_kill (char *args, int from_tty)
-{
- return; /* Ignore attempts to kill target system */
-}
-
-/* Clean up when a program exits.
-
- The program actually lives on in the remote processor's RAM, and may be
- run again without a download. Don't leave it full of breakpoint
- instructions. */
-
-void
-eb_mourn_inferior (void)
-{
- remove_breakpoints ();
- unpush_target (&eb_ops);
- generic_mourn_inferior (); /* Do all the proper things now */
-}
-/* Define the target subroutine names */
-
-struct target_ops eb_ops;
-
-static void
-init_eb_ops (void)
-{
- eb_ops.to_shortname = "amd-eb";
- eb_ops.to_longname = "Remote serial AMD EBMON target";
- eb_ops.to_doc = "Use a remote computer running EBMON connected by a serial line.\n\
-Arguments are the name of the device for the serial line,\n\
-the speed to connect at in bits per second, and the filename of the\n\
-executable as it exists on the remote computer. For example,\n\
-target amd-eb /dev/ttya 9600 demo",
- eb_ops.to_open = eb_open;
- eb_ops.to_close = eb_close;
- eb_ops.to_attach = 0;
- eb_ops.to_post_attach = NULL;
- eb_ops.to_require_attach = NULL;
- eb_ops.to_detach = eb_detach;
- eb_ops.to_require_detach = NULL;
- eb_ops.to_resume = eb_resume;
- eb_ops.to_wait = eb_wait;
- eb_ops.to_post_wait = NULL;
- eb_ops.to_fetch_registers = eb_fetch_register;
- eb_ops.to_store_registers = eb_store_register;
- eb_ops.to_prepare_to_store = eb_prepare_to_store;
- eb_ops.to_xfer_memory = eb_xfer_inferior_memory;
- eb_ops.to_files_info = eb_files_info;
- eb_ops.to_insert_breakpoint = 0;
- eb_ops.to_remove_breakpoint = 0; /* Breakpoints */
- eb_ops.to_terminal_init = 0;
- eb_ops.to_terminal_inferior = 0;
- eb_ops.to_terminal_ours_for_output = 0;
- eb_ops.to_terminal_ours = 0;
- eb_ops.to_terminal_info = 0; /* Terminal handling */
- eb_ops.to_kill = eb_kill;
- eb_ops.to_load = generic_load; /* load */
- eb_ops.to_lookup_symbol = 0; /* lookup_symbol */
- eb_ops.to_create_inferior = eb_create_inferior;
- eb_ops.to_post_startup_inferior = NULL;
- eb_ops.to_acknowledge_created_inferior = NULL;
- eb_ops.to_clone_and_follow_inferior = NULL;
- eb_ops.to_post_follow_inferior_by_clone = NULL;
- eb_ops.to_insert_fork_catchpoint = NULL;
- eb_ops.to_remove_fork_catchpoint = NULL;
- eb_ops.to_insert_vfork_catchpoint = NULL;
- eb_ops.to_remove_vfork_catchpoint = NULL;
- eb_ops.to_has_forked = NULL;
- eb_ops.to_has_vforked = NULL;
- eb_ops.to_can_follow_vfork_prior_to_exec = NULL;
- eb_ops.to_post_follow_vfork = NULL;
- eb_ops.to_insert_exec_catchpoint = NULL;
- eb_ops.to_remove_exec_catchpoint = NULL;
- eb_ops.to_has_execd = NULL;
- eb_ops.to_reported_exec_events_per_exec_call = NULL;
- eb_ops.to_has_exited = NULL;
- eb_ops.to_mourn_inferior = eb_mourn_inferior;
- eb_ops.to_can_run = 0; /* can_run */
- eb_ops.to_notice_signals = 0; /* notice_signals */
- eb_ops.to_thread_alive = 0; /* thread-alive */
- eb_ops.to_stop = 0; /* to_stop */
- eb_ops.to_pid_to_exec_file = NULL;
- eb_ops.to_stratum = process_stratum;
- eb_ops.DONT_USE = 0; /* next */
- eb_ops.to_has_all_memory = 1;
- eb_ops.to_has_memory = 1;
- eb_ops.to_has_stack = 1;
- eb_ops.to_has_registers = 1;
- eb_ops.to_has_execution = 1; /* all mem, mem, stack, regs, exec */
- eb_ops.to_sections = 0; /* sections */
- eb_ops.to_sections_end = 0; /* sections end */
- eb_ops.to_magic = OPS_MAGIC; /* Always the last thing */
-};
-
-void
-_initialize_remote_eb (void)
-{
- init_eb_ops ();
- add_target (&eb_ops);
-}
+/* OBSOLETE /* Remote debugging interface for AMD 29000 EBMON on IBM PC, for GDB. */
+/* OBSOLETE Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1998, 1999, 2000, 2001 */
+/* OBSOLETE Free Software Foundation, Inc. */
+/* OBSOLETE Contributed by Cygnus Support. Written by Jim Kingdon for Cygnus. */
+/* OBSOLETE */
+/* OBSOLETE This file is part of GDB. */
+/* OBSOLETE */
+/* OBSOLETE This program is free software; you can redistribute it and/or modify */
+/* OBSOLETE it under the terms of the GNU General Public License as published by */
+/* OBSOLETE the Free Software Foundation; either version 2 of the License, or */
+/* OBSOLETE (at your option) any later version. */
+/* OBSOLETE */
+/* OBSOLETE This program is distributed in the hope that it will be useful, */
+/* OBSOLETE but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* OBSOLETE MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* OBSOLETE GNU General Public License for more details. */
+/* OBSOLETE */
+/* OBSOLETE You should have received a copy of the GNU General Public License */
+/* OBSOLETE along with this program; if not, write to the Free Software */
+/* OBSOLETE Foundation, Inc., 59 Temple Place - Suite 330, */
+/* OBSOLETE Boston, MA 02111-1307, USA. */ */
+/* OBSOLETE */
+/* OBSOLETE /* This is like remote.c but is for an esoteric situation-- */
+/* OBSOLETE having a a29k board in a PC hooked up to a unix machine with */
+/* OBSOLETE a serial line, and running ctty com1 on the PC, through which */
+/* OBSOLETE the unix machine can run ebmon. Not to mention that the PC */
+/* OBSOLETE has PC/NFS, so it can access the same executables that gdb can, */
+/* OBSOLETE over the net in real time. */ */
+/* OBSOLETE */
+/* OBSOLETE #include "defs.h" */
+/* OBSOLETE #include "gdb_string.h" */
+/* OBSOLETE #include "regcache.h" */
+/* OBSOLETE */
+/* OBSOLETE #include "inferior.h" */
+/* OBSOLETE #include "bfd.h" */
+/* OBSOLETE #include "symfile.h" */
+/* OBSOLETE #include "value.h" */
+/* OBSOLETE #include <ctype.h> */
+/* OBSOLETE #include <fcntl.h> */
+/* OBSOLETE #include <signal.h> */
+/* OBSOLETE #include <errno.h> */
+/* OBSOLETE #include "terminal.h" */
+/* OBSOLETE #include "target.h" */
+/* OBSOLETE #include "gdbcore.h" */
+/* OBSOLETE */
+/* OBSOLETE extern struct target_ops eb_ops; /* Forward declaration */ */
+/* OBSOLETE */
+/* OBSOLETE static void eb_close (); */
+/* OBSOLETE */
+/* OBSOLETE #define LOG_FILE "eb.log" */
+/* OBSOLETE #if defined (LOG_FILE) */
+/* OBSOLETE FILE *log_file; */
+/* OBSOLETE #endif */
+/* OBSOLETE */
+/* OBSOLETE static int timeout = 24; */
+/* OBSOLETE */
+/* OBSOLETE /* Descriptor for I/O to remote machine. Initialize it to -1 so that */
+/* OBSOLETE eb_open knows that we don't have a file open when the program */
+/* OBSOLETE starts. */ */
+/* OBSOLETE int eb_desc = -1; */
+/* OBSOLETE */
+/* OBSOLETE /* stream which is fdopen'd from eb_desc. Only valid when */
+/* OBSOLETE eb_desc != -1. */ */
+/* OBSOLETE FILE *eb_stream; */
+/* OBSOLETE */
+/* OBSOLETE /* Read a character from the remote system, doing all the fancy */
+/* OBSOLETE timeout stuff. */ */
+/* OBSOLETE static int */
+/* OBSOLETE readchar (void) */
+/* OBSOLETE { */
+/* OBSOLETE char buf; */
+/* OBSOLETE */
+/* OBSOLETE buf = '\0'; */
+/* OBSOLETE #ifdef HAVE_TERMIO */
+/* OBSOLETE /* termio does the timeout for us. */ */
+/* OBSOLETE read (eb_desc, &buf, 1); */
+/* OBSOLETE #else */
+/* OBSOLETE alarm (timeout); */
+/* OBSOLETE if (read (eb_desc, &buf, 1) < 0) */
+/* OBSOLETE { */
+/* OBSOLETE if (errno == EINTR) */
+/* OBSOLETE error ("Timeout reading from remote system."); */
+/* OBSOLETE else */
+/* OBSOLETE perror_with_name ("remote"); */
+/* OBSOLETE } */
+/* OBSOLETE alarm (0); */
+/* OBSOLETE #endif */
+/* OBSOLETE */
+/* OBSOLETE if (buf == '\0') */
+/* OBSOLETE error ("Timeout reading from remote system."); */
+/* OBSOLETE #if defined (LOG_FILE) */
+/* OBSOLETE putc (buf & 0x7f, log_file); */
+/* OBSOLETE #endif */
+/* OBSOLETE return buf & 0x7f; */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* Keep discarding input from the remote system, until STRING is found. */
+/* OBSOLETE Let the user break out immediately. */ */
+/* OBSOLETE static void */
+/* OBSOLETE expect (char *string) */
+/* OBSOLETE { */
+/* OBSOLETE char *p = string; */
+/* OBSOLETE */
+/* OBSOLETE immediate_quit++; */
+/* OBSOLETE while (1) */
+/* OBSOLETE { */
+/* OBSOLETE if (readchar () == *p) */
+/* OBSOLETE { */
+/* OBSOLETE p++; */
+/* OBSOLETE if (*p == '\0') */
+/* OBSOLETE { */
+/* OBSOLETE immediate_quit--; */
+/* OBSOLETE return; */
+/* OBSOLETE } */
+/* OBSOLETE } */
+/* OBSOLETE else */
+/* OBSOLETE p = string; */
+/* OBSOLETE } */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* Keep discarding input until we see the ebmon prompt. */
+/* OBSOLETE */
+/* OBSOLETE The convention for dealing with the prompt is that you */
+/* OBSOLETE o give your command */
+/* OBSOLETE o *then* wait for the prompt. */
+/* OBSOLETE */
+/* OBSOLETE Thus the last thing that a procedure does with the serial line */
+/* OBSOLETE will be an expect_prompt(). Exception: eb_resume does not */
+/* OBSOLETE wait for the prompt, because the terminal is being handed over */
+/* OBSOLETE to the inferior. However, the next thing which happens after that */
+/* OBSOLETE is a eb_wait which does wait for the prompt. */
+/* OBSOLETE Note that this includes abnormal exit, e.g. error(). This is */
+/* OBSOLETE necessary to prevent getting into states from which we can't */
+/* OBSOLETE recover. */ */
+/* OBSOLETE static void */
+/* OBSOLETE expect_prompt (void) */
+/* OBSOLETE { */
+/* OBSOLETE #if defined (LOG_FILE) */
+/* OBSOLETE /* This is a convenient place to do this. The idea is to do it often */
+/* OBSOLETE enough that we never lose much data if we terminate abnormally. */ */
+/* OBSOLETE fflush (log_file); */
+/* OBSOLETE #endif */
+/* OBSOLETE expect ("\n# "); */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* Get a hex digit from the remote system & return its value. */
+/* OBSOLETE If ignore_space is nonzero, ignore spaces (not newline, tab, etc). */ */
+/* OBSOLETE static int */
+/* OBSOLETE get_hex_digit (int ignore_space) */
+/* OBSOLETE { */
+/* OBSOLETE int ch; */
+/* OBSOLETE while (1) */
+/* OBSOLETE { */
+/* OBSOLETE ch = readchar (); */
+/* OBSOLETE if (ch >= '0' && ch <= '9') */
+/* OBSOLETE return ch - '0'; */
+/* OBSOLETE else if (ch >= 'A' && ch <= 'F') */
+/* OBSOLETE return ch - 'A' + 10; */
+/* OBSOLETE else if (ch >= 'a' && ch <= 'f') */
+/* OBSOLETE return ch - 'a' + 10; */
+/* OBSOLETE else if (ch == ' ' && ignore_space) */
+/* OBSOLETE ; */
+/* OBSOLETE else */
+/* OBSOLETE { */
+/* OBSOLETE expect_prompt (); */
+/* OBSOLETE error ("Invalid hex digit from remote system."); */
+/* OBSOLETE } */
+/* OBSOLETE } */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* Get a byte from eb_desc and put it in *BYT. Accept any number */
+/* OBSOLETE leading spaces. */ */
+/* OBSOLETE static void */
+/* OBSOLETE get_hex_byte (char *byt) */
+/* OBSOLETE { */
+/* OBSOLETE int val; */
+/* OBSOLETE */
+/* OBSOLETE val = get_hex_digit (1) << 4; */
+/* OBSOLETE val |= get_hex_digit (0); */
+/* OBSOLETE *byt = val; */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* Get N 32-bit words from remote, each preceded by a space, */
+/* OBSOLETE and put them in registers starting at REGNO. */ */
+/* OBSOLETE static void */
+/* OBSOLETE get_hex_regs (int n, int regno) */
+/* OBSOLETE { */
+/* OBSOLETE long val; */
+/* OBSOLETE int i; */
+/* OBSOLETE */
+/* OBSOLETE for (i = 0; i < n; i++) */
+/* OBSOLETE { */
+/* OBSOLETE int j; */
+/* OBSOLETE */
+/* OBSOLETE val = 0; */
+/* OBSOLETE for (j = 0; j < 8; j++) */
+/* OBSOLETE val = (val << 4) + get_hex_digit (j == 0); */
+/* OBSOLETE supply_register (regno++, (char *) &val); */
+/* OBSOLETE } */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* Called when SIGALRM signal sent due to alarm() timeout. */ */
+/* OBSOLETE #ifndef HAVE_TERMIO */
+/* OBSOLETE */
+/* OBSOLETE volatile int n_alarms; */
+/* OBSOLETE */
+/* OBSOLETE void */
+/* OBSOLETE eb_timer (void) */
+/* OBSOLETE { */
+/* OBSOLETE #if 0 */
+/* OBSOLETE if (kiodebug) */
+/* OBSOLETE printf ("eb_timer called\n"); */
+/* OBSOLETE #endif */
+/* OBSOLETE n_alarms++; */
+/* OBSOLETE } */
+/* OBSOLETE #endif */
+/* OBSOLETE */
+/* OBSOLETE /* malloc'd name of the program on the remote system. */ */
+/* OBSOLETE static char *prog_name = NULL; */
+/* OBSOLETE */
+/* OBSOLETE /* Nonzero if we have loaded the file ("yc") and not yet issued a "gi" */
+/* OBSOLETE command. "gi" is supposed to happen exactly once for each "yc". */ */
+/* OBSOLETE static int need_gi = 0; */
+/* OBSOLETE */
+/* OBSOLETE /* Number of SIGTRAPs we need to simulate. That is, the next */
+/* OBSOLETE NEED_ARTIFICIAL_TRAP calls to eb_wait should just return */
+/* OBSOLETE SIGTRAP without actually waiting for anything. */ */
+/* OBSOLETE */
+/* OBSOLETE static int need_artificial_trap = 0; */
+/* OBSOLETE */
+/* OBSOLETE /* This is called not only when we first attach, but also when the */
+/* OBSOLETE user types "run" after having attached. */ */
+/* OBSOLETE static void */
+/* OBSOLETE eb_create_inferior (char *execfile, char *args, char **env) */
+/* OBSOLETE { */
+/* OBSOLETE int entry_pt; */
+/* OBSOLETE */
+/* OBSOLETE if (args && *args) */
+/* OBSOLETE error ("Can't pass arguments to remote EBMON process"); */
+/* OBSOLETE */
+/* OBSOLETE if (execfile == 0 || exec_bfd == 0) */
+/* OBSOLETE error ("No executable file specified"); */
+/* OBSOLETE */
+/* OBSOLETE entry_pt = (int) bfd_get_start_address (exec_bfd); */
+/* OBSOLETE */
+/* OBSOLETE { */
+/* OBSOLETE /* OK, now read in the file. Y=read, C=COFF, D=no symbols */
+/* OBSOLETE 0=start address, %s=filename. */ */
+/* OBSOLETE */
+/* OBSOLETE fprintf (eb_stream, "YC D,0:%s", prog_name); */
+/* OBSOLETE */
+/* OBSOLETE if (args != NULL) */
+/* OBSOLETE fprintf (eb_stream, " %s", args); */
+/* OBSOLETE */
+/* OBSOLETE fprintf (eb_stream, "\n"); */
+/* OBSOLETE fflush (eb_stream); */
+/* OBSOLETE */
+/* OBSOLETE expect_prompt (); */
+/* OBSOLETE */
+/* OBSOLETE need_gi = 1; */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* The "process" (board) is already stopped awaiting our commands, and */
+/* OBSOLETE the program is already downloaded. We just set its PC and go. */ */
+/* OBSOLETE */
+/* OBSOLETE clear_proceed_status (); */
+/* OBSOLETE */
+/* OBSOLETE /* Tell wait_for_inferior that we've started a new process. */ */
+/* OBSOLETE init_wait_for_inferior (); */
+/* OBSOLETE */
+/* OBSOLETE /* Set up the "saved terminal modes" of the inferior */
+/* OBSOLETE based on what modes we are starting it with. */ */
+/* OBSOLETE target_terminal_init (); */
+/* OBSOLETE */
+/* OBSOLETE /* Install inferior's terminal modes. */ */
+/* OBSOLETE target_terminal_inferior (); */
+/* OBSOLETE */
+/* OBSOLETE /* insert_step_breakpoint (); FIXME, do we need this? */ */
+/* OBSOLETE proceed ((CORE_ADDR) entry_pt, TARGET_SIGNAL_DEFAULT, 0); /* Let 'er rip... */ */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* Translate baud rates from integers to damn B_codes. Unix should */
+/* OBSOLETE have outgrown this crap years ago, but even POSIX wouldn't buck it. */ */
+/* OBSOLETE */
+/* OBSOLETE #ifndef B19200 */
+/* OBSOLETE #define B19200 EXTA */
+/* OBSOLETE #endif */
+/* OBSOLETE #ifndef B38400 */
+/* OBSOLETE #define B38400 EXTB */
+/* OBSOLETE #endif */
+/* OBSOLETE */
+/* OBSOLETE struct */
+/* OBSOLETE { */
+/* OBSOLETE int rate, damn_b; */
+/* OBSOLETE } */
+/* OBSOLETE baudtab[] = */
+/* OBSOLETE { */
+/* OBSOLETE { */
+/* OBSOLETE 0, B0 */
+/* OBSOLETE } */
+/* OBSOLETE , */
+/* OBSOLETE { */
+/* OBSOLETE 50, B50 */
+/* OBSOLETE } */
+/* OBSOLETE , */
+/* OBSOLETE { */
+/* OBSOLETE 75, B75 */
+/* OBSOLETE } */
+/* OBSOLETE , */
+/* OBSOLETE { */
+/* OBSOLETE 110, B110 */
+/* OBSOLETE } */
+/* OBSOLETE , */
+/* OBSOLETE { */
+/* OBSOLETE 134, B134 */
+/* OBSOLETE } */
+/* OBSOLETE , */
+/* OBSOLETE { */
+/* OBSOLETE 150, B150 */
+/* OBSOLETE } */
+/* OBSOLETE , */
+/* OBSOLETE { */
+/* OBSOLETE 200, B200 */
+/* OBSOLETE } */
+/* OBSOLETE , */
+/* OBSOLETE { */
+/* OBSOLETE 300, B300 */
+/* OBSOLETE } */
+/* OBSOLETE , */
+/* OBSOLETE { */
+/* OBSOLETE 600, B600 */
+/* OBSOLETE } */
+/* OBSOLETE , */
+/* OBSOLETE { */
+/* OBSOLETE 1200, B1200 */
+/* OBSOLETE } */
+/* OBSOLETE , */
+/* OBSOLETE { */
+/* OBSOLETE 1800, B1800 */
+/* OBSOLETE } */
+/* OBSOLETE , */
+/* OBSOLETE { */
+/* OBSOLETE 2400, B2400 */
+/* OBSOLETE } */
+/* OBSOLETE , */
+/* OBSOLETE { */
+/* OBSOLETE 4800, B4800 */
+/* OBSOLETE } */
+/* OBSOLETE , */
+/* OBSOLETE { */
+/* OBSOLETE 9600, B9600 */
+/* OBSOLETE } */
+/* OBSOLETE , */
+/* OBSOLETE { */
+/* OBSOLETE 19200, B19200 */
+/* OBSOLETE } */
+/* OBSOLETE , */
+/* OBSOLETE { */
+/* OBSOLETE 38400, B38400 */
+/* OBSOLETE } */
+/* OBSOLETE , */
+/* OBSOLETE { */
+/* OBSOLETE -1, -1 */
+/* OBSOLETE } */
+/* OBSOLETE , */
+/* OBSOLETE }; */
+/* OBSOLETE */
+/* OBSOLETE int */
+/* OBSOLETE damn_b (int rate) */
+/* OBSOLETE { */
+/* OBSOLETE int i; */
+/* OBSOLETE */
+/* OBSOLETE for (i = 0; baudtab[i].rate != -1; i++) */
+/* OBSOLETE if (rate == baudtab[i].rate) */
+/* OBSOLETE return baudtab[i].damn_b; */
+/* OBSOLETE return B38400; /* Random */ */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE */
+/* OBSOLETE /* Open a connection to a remote debugger. */
+/* OBSOLETE NAME is the filename used for communication, then a space, */
+/* OBSOLETE then the name of the program as we should name it to EBMON. */ */
+/* OBSOLETE */
+/* OBSOLETE static int baudrate = 9600; */
+/* OBSOLETE static char *dev_name; */
+/* OBSOLETE void */
+/* OBSOLETE eb_open (char *name, int from_tty) */
+/* OBSOLETE { */
+/* OBSOLETE TERMINAL sg; */
+/* OBSOLETE */
+/* OBSOLETE char *p; */
+/* OBSOLETE */
+/* OBSOLETE target_preopen (from_tty); */
+/* OBSOLETE */
+/* OBSOLETE /* Find the first whitespace character, it separates dev_name from */
+/* OBSOLETE prog_name. */ */
+/* OBSOLETE if (name == 0) */
+/* OBSOLETE goto erroid; */
+/* OBSOLETE */
+/* OBSOLETE for (p = name; */
+/* OBSOLETE *p != '\0' && !isspace (*p); p++) */
+/* OBSOLETE ; */
+/* OBSOLETE if (*p == '\0') */
+/* OBSOLETE erroid: */
+/* OBSOLETE error ("\ */
+/* OBSOLETE Please include the name of the device for the serial port,\n\ */
+/* OBSOLETE the baud rate, and the name of the program to run on the remote system."); */
+/* OBSOLETE dev_name = alloca (p - name + 1); */
+/* OBSOLETE strncpy (dev_name, name, p - name); */
+/* OBSOLETE dev_name[p - name] = '\0'; */
+/* OBSOLETE */
+/* OBSOLETE /* Skip over the whitespace after dev_name */ */
+/* OBSOLETE for (; isspace (*p); p++) */
+/* OBSOLETE /*EMPTY */ ; */
+/* OBSOLETE */
+/* OBSOLETE if (1 != sscanf (p, "%d ", &baudrate)) */
+/* OBSOLETE goto erroid; */
+/* OBSOLETE */
+/* OBSOLETE /* Skip the number and then the spaces */ */
+/* OBSOLETE for (; isdigit (*p); p++) */
+/* OBSOLETE /*EMPTY */ ; */
+/* OBSOLETE for (; isspace (*p); p++) */
+/* OBSOLETE /*EMPTY */ ; */
+/* OBSOLETE */
+/* OBSOLETE if (prog_name != NULL) */
+/* OBSOLETE xfree (prog_name); */
+/* OBSOLETE prog_name = savestring (p, strlen (p)); */
+/* OBSOLETE */
+/* OBSOLETE eb_close (0); */
+/* OBSOLETE */
+/* OBSOLETE eb_desc = open (dev_name, O_RDWR); */
+/* OBSOLETE if (eb_desc < 0) */
+/* OBSOLETE perror_with_name (dev_name); */
+/* OBSOLETE ioctl (eb_desc, TIOCGETP, &sg); */
+/* OBSOLETE #ifdef HAVE_TERMIO */
+/* OBSOLETE sg.c_cc[VMIN] = 0; /* read with timeout. */ */
+/* OBSOLETE sg.c_cc[VTIME] = timeout * 10; */
+/* OBSOLETE sg.c_lflag &= ~(ICANON | ECHO); */
+/* OBSOLETE sg.c_cflag = (sg.c_cflag & ~CBAUD) | damn_b (baudrate); */
+/* OBSOLETE #else */
+/* OBSOLETE sg.sg_ispeed = damn_b (baudrate); */
+/* OBSOLETE sg.sg_ospeed = damn_b (baudrate); */
+/* OBSOLETE sg.sg_flags |= RAW | ANYP; */
+/* OBSOLETE sg.sg_flags &= ~ECHO; */
+/* OBSOLETE #endif */
+/* OBSOLETE */
+/* OBSOLETE ioctl (eb_desc, TIOCSETP, &sg); */
+/* OBSOLETE eb_stream = fdopen (eb_desc, "r+"); */
+/* OBSOLETE */
+/* OBSOLETE push_target (&eb_ops); */
+/* OBSOLETE if (from_tty) */
+/* OBSOLETE printf ("Remote %s debugging %s using %s\n", target_shortname, */
+/* OBSOLETE prog_name, dev_name); */
+/* OBSOLETE */
+/* OBSOLETE #ifndef HAVE_TERMIO */
+/* OBSOLETE #ifndef NO_SIGINTERRUPT */
+/* OBSOLETE /* Cause SIGALRM's to make reads fail with EINTR instead of resuming */
+/* OBSOLETE the read. */ */
+/* OBSOLETE if (siginterrupt (SIGALRM, 1) != 0) */
+/* OBSOLETE perror ("eb_open: error in siginterrupt"); */
+/* OBSOLETE #endif */
+/* OBSOLETE */
+/* OBSOLETE /* Set up read timeout timer. */ */
+/* OBSOLETE if ((void (*)) signal (SIGALRM, eb_timer) == (void (*)) -1) */
+/* OBSOLETE perror ("eb_open: error in signal"); */
+/* OBSOLETE #endif */
+/* OBSOLETE */
+/* OBSOLETE #if defined (LOG_FILE) */
+/* OBSOLETE log_file = fopen (LOG_FILE, "w"); */
+/* OBSOLETE if (log_file == NULL) */
+/* OBSOLETE perror_with_name (LOG_FILE); */
+/* OBSOLETE #endif */
+/* OBSOLETE */
+/* OBSOLETE /* Hello? Are you there? */ */
+/* OBSOLETE write (eb_desc, "\n", 1); */
+/* OBSOLETE */
+/* OBSOLETE expect_prompt (); */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* Close out all files and local state before this target loses control. */ */
+/* OBSOLETE */
+/* OBSOLETE static void */
+/* OBSOLETE eb_close (int quitting) */
+/* OBSOLETE { */
+/* OBSOLETE */
+/* OBSOLETE /* Due to a bug in Unix, fclose closes not only the stdio stream, */
+/* OBSOLETE but also the file descriptor. So we don't actually close */
+/* OBSOLETE eb_desc. */ */
+/* OBSOLETE if (eb_stream) */
+/* OBSOLETE fclose (eb_stream); /* This also closes eb_desc */ */
+/* OBSOLETE if (eb_desc >= 0) */
+/* OBSOLETE /* close (eb_desc); */ */
+/* OBSOLETE */
+/* OBSOLETE /* Do not try to close eb_desc again, later in the program. */ */
+/* OBSOLETE eb_stream = NULL; */
+/* OBSOLETE eb_desc = -1; */
+/* OBSOLETE */
+/* OBSOLETE #if defined (LOG_FILE) */
+/* OBSOLETE if (log_file) */
+/* OBSOLETE { */
+/* OBSOLETE if (ferror (log_file)) */
+/* OBSOLETE printf ("Error writing log file.\n"); */
+/* OBSOLETE if (fclose (log_file) != 0) */
+/* OBSOLETE printf ("Error closing log file.\n"); */
+/* OBSOLETE } */
+/* OBSOLETE #endif */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* Terminate the open connection to the remote debugger. */
+/* OBSOLETE Use this when you want to detach and do something else */
+/* OBSOLETE with your gdb. */ */
+/* OBSOLETE void */
+/* OBSOLETE eb_detach (int from_tty) */
+/* OBSOLETE { */
+/* OBSOLETE pop_target (); /* calls eb_close to do the real work */ */
+/* OBSOLETE if (from_tty) */
+/* OBSOLETE printf ("Ending remote %s debugging\n", target_shortname); */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* Tell the remote machine to resume. */ */
+/* OBSOLETE */
+/* OBSOLETE void */
+/* OBSOLETE eb_resume (ptid_t ptid, int step, enum target_signal sig) */
+/* OBSOLETE { */
+/* OBSOLETE if (step) */
+/* OBSOLETE { */
+/* OBSOLETE write (eb_desc, "t 1,s\n", 6); */
+/* OBSOLETE /* Wait for the echo. */ */
+/* OBSOLETE expect ("t 1,s\r"); */
+/* OBSOLETE /* Then comes a line containing the instruction we stepped to. */ */
+/* OBSOLETE expect ("\n@"); */
+/* OBSOLETE /* Then we get the prompt. */ */
+/* OBSOLETE expect_prompt (); */
+/* OBSOLETE */
+/* OBSOLETE /* Force the next eb_wait to return a trap. Not doing anything */
+/* OBSOLETE about I/O from the target means that the user has to type */
+/* OBSOLETE "continue" to see any. This should be fixed. */ */
+/* OBSOLETE need_artificial_trap = 1; */
+/* OBSOLETE } */
+/* OBSOLETE else */
+/* OBSOLETE { */
+/* OBSOLETE if (need_gi) */
+/* OBSOLETE { */
+/* OBSOLETE need_gi = 0; */
+/* OBSOLETE write (eb_desc, "gi\n", 3); */
+/* OBSOLETE */
+/* OBSOLETE /* Swallow the echo of "gi". */ */
+/* OBSOLETE expect ("gi\r"); */
+/* OBSOLETE } */
+/* OBSOLETE else */
+/* OBSOLETE { */
+/* OBSOLETE write (eb_desc, "GR\n", 3); */
+/* OBSOLETE /* Swallow the echo. */ */
+/* OBSOLETE expect ("GR\r"); */
+/* OBSOLETE } */
+/* OBSOLETE } */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* Wait until the remote machine stops, then return, */
+/* OBSOLETE storing status in STATUS just as `wait' would. */ */
+/* OBSOLETE */
+/* OBSOLETE ptid_t */
+/* OBSOLETE eb_wait (ptid_t ptid, struct target_waitstatus *status) */
+/* OBSOLETE { */
+/* OBSOLETE /* Strings to look for. '?' means match any single character. */
+/* OBSOLETE Note that with the algorithm we use, the initial character */
+/* OBSOLETE of the string cannot recur in the string, or we will not */
+/* OBSOLETE find some cases of the string in the input. */ */
+/* OBSOLETE */
+/* OBSOLETE static char bpt[] = "Invalid interrupt taken - #0x50 - "; */
+/* OBSOLETE /* It would be tempting to look for "\n[__exit + 0x8]\n" */
+/* OBSOLETE but that requires loading symbols with "yc i" and even if */
+/* OBSOLETE we did do that we don't know that the file has symbols. */ */
+/* OBSOLETE static char exitmsg[] = "\n@????????I JMPTI GR121,LR0"; */
+/* OBSOLETE char *bp = bpt; */
+/* OBSOLETE char *ep = exitmsg; */
+/* OBSOLETE */
+/* OBSOLETE /* Large enough for either sizeof (bpt) or sizeof (exitmsg) chars. */ */
+/* OBSOLETE char swallowed[50]; */
+/* OBSOLETE /* Current position in swallowed. */ */
+/* OBSOLETE char *swallowed_p = swallowed; */
+/* OBSOLETE */
+/* OBSOLETE int ch; */
+/* OBSOLETE int ch_handled; */
+/* OBSOLETE */
+/* OBSOLETE int old_timeout = timeout; */
+/* OBSOLETE */
+/* OBSOLETE status->kind = TARGET_WAITKIND_EXITED; */
+/* OBSOLETE status->value.integer = 0; */
+/* OBSOLETE */
+/* OBSOLETE if (need_artificial_trap != 0) */
+/* OBSOLETE { */
+/* OBSOLETE status->kind = TARGET_WAITKIND_STOPPED; */
+/* OBSOLETE status->value.sig = TARGET_SIGNAL_TRAP; */
+/* OBSOLETE need_artificial_trap--; */
+/* OBSOLETE return 0; */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE timeout = 0; /* Don't time out -- user program is running. */ */
+/* OBSOLETE while (1) */
+/* OBSOLETE { */
+/* OBSOLETE ch_handled = 0; */
+/* OBSOLETE ch = readchar (); */
+/* OBSOLETE if (ch == *bp) */
+/* OBSOLETE { */
+/* OBSOLETE bp++; */
+/* OBSOLETE if (*bp == '\0') */
+/* OBSOLETE break; */
+/* OBSOLETE ch_handled = 1; */
+/* OBSOLETE */
+/* OBSOLETE *swallowed_p++ = ch; */
+/* OBSOLETE } */
+/* OBSOLETE else */
+/* OBSOLETE bp = bpt; */
+/* OBSOLETE */
+/* OBSOLETE if (ch == *ep || *ep == '?') */
+/* OBSOLETE { */
+/* OBSOLETE ep++; */
+/* OBSOLETE if (*ep == '\0') */
+/* OBSOLETE break; */
+/* OBSOLETE */
+/* OBSOLETE if (!ch_handled) */
+/* OBSOLETE *swallowed_p++ = ch; */
+/* OBSOLETE ch_handled = 1; */
+/* OBSOLETE } */
+/* OBSOLETE else */
+/* OBSOLETE ep = exitmsg; */
+/* OBSOLETE */
+/* OBSOLETE if (!ch_handled) */
+/* OBSOLETE { */
+/* OBSOLETE char *p; */
+/* OBSOLETE */
+/* OBSOLETE /* Print out any characters which have been swallowed. */ */
+/* OBSOLETE for (p = swallowed; p < swallowed_p; ++p) */
+/* OBSOLETE putc (*p, stdout); */
+/* OBSOLETE swallowed_p = swallowed; */
+/* OBSOLETE */
+/* OBSOLETE putc (ch, stdout); */
+/* OBSOLETE } */
+/* OBSOLETE } */
+/* OBSOLETE expect_prompt (); */
+/* OBSOLETE if (*bp == '\0') */
+/* OBSOLETE { */
+/* OBSOLETE status->kind = TARGET_WAITKIND_STOPPED; */
+/* OBSOLETE status->value.sig = TARGET_SIGNAL_TRAP; */
+/* OBSOLETE } */
+/* OBSOLETE else */
+/* OBSOLETE { */
+/* OBSOLETE status->kind = TARGET_WAITKIND_EXITED; */
+/* OBSOLETE status->value.integer = 0; */
+/* OBSOLETE } */
+/* OBSOLETE timeout = old_timeout; */
+/* OBSOLETE */
+/* OBSOLETE return 0; */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* Return the name of register number REGNO */
+/* OBSOLETE in the form input and output by EBMON. */
+/* OBSOLETE */
+/* OBSOLETE Returns a pointer to a static buffer containing the answer. */ */
+/* OBSOLETE static char * */
+/* OBSOLETE get_reg_name (int regno) */
+/* OBSOLETE { */
+/* OBSOLETE static char buf[80]; */
+/* OBSOLETE if (regno >= GR96_REGNUM && regno < GR96_REGNUM + 32) */
+/* OBSOLETE sprintf (buf, "GR%03d", regno - GR96_REGNUM + 96); */
+/* OBSOLETE else if (regno >= LR0_REGNUM && regno < LR0_REGNUM + 128) */
+/* OBSOLETE sprintf (buf, "LR%03d", regno - LR0_REGNUM); */
+/* OBSOLETE else if (regno == Q_REGNUM) */
+/* OBSOLETE strcpy (buf, "SR131"); */
+/* OBSOLETE else if (regno >= BP_REGNUM && regno <= CR_REGNUM) */
+/* OBSOLETE sprintf (buf, "SR%03d", regno - BP_REGNUM + 133); */
+/* OBSOLETE else if (regno == ALU_REGNUM) */
+/* OBSOLETE strcpy (buf, "SR132"); */
+/* OBSOLETE else if (regno >= IPC_REGNUM && regno <= IPB_REGNUM) */
+/* OBSOLETE sprintf (buf, "SR%03d", regno - IPC_REGNUM + 128); */
+/* OBSOLETE else if (regno >= VAB_REGNUM && regno <= LRU_REGNUM) */
+/* OBSOLETE sprintf (buf, "SR%03d", regno - VAB_REGNUM); */
+/* OBSOLETE else if (regno == GR1_REGNUM) */
+/* OBSOLETE strcpy (buf, "GR001"); */
+/* OBSOLETE return buf; */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* Read the remote registers into the block REGS. */ */
+/* OBSOLETE */
+/* OBSOLETE static void */
+/* OBSOLETE eb_fetch_registers (void) */
+/* OBSOLETE { */
+/* OBSOLETE int reg_index; */
+/* OBSOLETE int regnum_index; */
+/* OBSOLETE char tempbuf[10]; */
+/* OBSOLETE int i; */
+/* OBSOLETE */
+/* OBSOLETE #if 0 */
+/* OBSOLETE /* This should not be necessary, because one is supposed to read the */
+/* OBSOLETE registers only when the inferior is stopped (at least with */
+/* OBSOLETE ptrace() and why not make it the same for remote?). */ */
+/* OBSOLETE /* ^A is the "normal character" used to make sure we are talking to EBMON */
+/* OBSOLETE and not to the program being debugged. */ */
+/* OBSOLETE write (eb_desc, "\001\n"); */
+/* OBSOLETE expect_prompt (); */
+/* OBSOLETE #endif */
+/* OBSOLETE */
+/* OBSOLETE write (eb_desc, "dw gr96,gr127\n", 14); */
+/* OBSOLETE for (reg_index = 96, regnum_index = GR96_REGNUM; */
+/* OBSOLETE reg_index < 128; */
+/* OBSOLETE reg_index += 4, regnum_index += 4) */
+/* OBSOLETE { */
+/* OBSOLETE sprintf (tempbuf, "GR%03d ", reg_index); */
+/* OBSOLETE expect (tempbuf); */
+/* OBSOLETE get_hex_regs (4, regnum_index); */
+/* OBSOLETE expect ("\n"); */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE for (i = 0; i < 128; i += 32) */
+/* OBSOLETE { */
+/* OBSOLETE /* The PC has a tendency to hang if we get these */
+/* OBSOLETE all in one fell swoop ("dw lr0,lr127"). */ */
+/* OBSOLETE sprintf (tempbuf, "dw lr%d\n", i); */
+/* OBSOLETE write (eb_desc, tempbuf, strlen (tempbuf)); */
+/* OBSOLETE for (reg_index = i, regnum_index = LR0_REGNUM + i; */
+/* OBSOLETE reg_index < i + 32; */
+/* OBSOLETE reg_index += 4, regnum_index += 4) */
+/* OBSOLETE { */
+/* OBSOLETE sprintf (tempbuf, "LR%03d ", reg_index); */
+/* OBSOLETE expect (tempbuf); */
+/* OBSOLETE get_hex_regs (4, regnum_index); */
+/* OBSOLETE expect ("\n"); */
+/* OBSOLETE } */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE write (eb_desc, "dw sr133,sr133\n", 15); */
+/* OBSOLETE expect ("SR133 "); */
+/* OBSOLETE get_hex_regs (1, BP_REGNUM); */
+/* OBSOLETE expect ("\n"); */
+/* OBSOLETE */
+/* OBSOLETE write (eb_desc, "dw sr134,sr134\n", 15); */
+/* OBSOLETE expect ("SR134 "); */
+/* OBSOLETE get_hex_regs (1, FC_REGNUM); */
+/* OBSOLETE expect ("\n"); */
+/* OBSOLETE */
+/* OBSOLETE write (eb_desc, "dw sr135,sr135\n", 15); */
+/* OBSOLETE expect ("SR135 "); */
+/* OBSOLETE get_hex_regs (1, CR_REGNUM); */
+/* OBSOLETE expect ("\n"); */
+/* OBSOLETE */
+/* OBSOLETE write (eb_desc, "dw sr131,sr131\n", 15); */
+/* OBSOLETE expect ("SR131 "); */
+/* OBSOLETE get_hex_regs (1, Q_REGNUM); */
+/* OBSOLETE expect ("\n"); */
+/* OBSOLETE */
+/* OBSOLETE write (eb_desc, "dw sr0,sr14\n", 12); */
+/* OBSOLETE for (reg_index = 0, regnum_index = VAB_REGNUM; */
+/* OBSOLETE regnum_index <= LRU_REGNUM; */
+/* OBSOLETE regnum_index += 4, reg_index += 4) */
+/* OBSOLETE { */
+/* OBSOLETE sprintf (tempbuf, "SR%03d ", reg_index); */
+/* OBSOLETE expect (tempbuf); */
+/* OBSOLETE get_hex_regs (reg_index == 12 ? 3 : 4, regnum_index); */
+/* OBSOLETE expect ("\n"); */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* There doesn't seem to be any way to get these. */ */
+/* OBSOLETE { */
+/* OBSOLETE int val = -1; */
+/* OBSOLETE supply_register (FPE_REGNUM, (char *) &val); */
+/* OBSOLETE supply_register (INTE_REGNUM, (char *) &val); */
+/* OBSOLETE supply_register (FPS_REGNUM, (char *) &val); */
+/* OBSOLETE supply_register (EXO_REGNUM, (char *) &val); */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE write (eb_desc, "dw gr1,gr1\n", 11); */
+/* OBSOLETE expect ("GR001 "); */
+/* OBSOLETE get_hex_regs (1, GR1_REGNUM); */
+/* OBSOLETE expect_prompt (); */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* Fetch register REGNO, or all registers if REGNO is -1. */
+/* OBSOLETE Returns errno value. */ */
+/* OBSOLETE void */
+/* OBSOLETE eb_fetch_register (int regno) */
+/* OBSOLETE { */
+/* OBSOLETE if (regno == -1) */
+/* OBSOLETE eb_fetch_registers (); */
+/* OBSOLETE else */
+/* OBSOLETE { */
+/* OBSOLETE char *name = get_reg_name (regno); */
+/* OBSOLETE fprintf (eb_stream, "dw %s,%s\n", name, name); */
+/* OBSOLETE expect (name); */
+/* OBSOLETE expect (" "); */
+/* OBSOLETE get_hex_regs (1, regno); */
+/* OBSOLETE expect_prompt (); */
+/* OBSOLETE } */
+/* OBSOLETE return; */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* Store the remote registers from the contents of the block REGS. */ */
+/* OBSOLETE */
+/* OBSOLETE static void */
+/* OBSOLETE eb_store_registers (void) */
+/* OBSOLETE { */
+/* OBSOLETE int i, j; */
+/* OBSOLETE fprintf (eb_stream, "s gr1,%x\n", read_register (GR1_REGNUM)); */
+/* OBSOLETE expect_prompt (); */
+/* OBSOLETE */
+/* OBSOLETE for (j = 0; j < 32; j += 16) */
+/* OBSOLETE { */
+/* OBSOLETE fprintf (eb_stream, "s gr%d,", j + 96); */
+/* OBSOLETE for (i = 0; i < 15; ++i) */
+/* OBSOLETE fprintf (eb_stream, "%x,", read_register (GR96_REGNUM + j + i)); */
+/* OBSOLETE fprintf (eb_stream, "%x\n", read_register (GR96_REGNUM + j + 15)); */
+/* OBSOLETE expect_prompt (); */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE for (j = 0; j < 128; j += 16) */
+/* OBSOLETE { */
+/* OBSOLETE fprintf (eb_stream, "s lr%d,", j); */
+/* OBSOLETE for (i = 0; i < 15; ++i) */
+/* OBSOLETE fprintf (eb_stream, "%x,", read_register (LR0_REGNUM + j + i)); */
+/* OBSOLETE fprintf (eb_stream, "%x\n", read_register (LR0_REGNUM + j + 15)); */
+/* OBSOLETE expect_prompt (); */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE fprintf (eb_stream, "s sr133,%x,%x,%x\n", read_register (BP_REGNUM), */
+/* OBSOLETE read_register (FC_REGNUM), read_register (CR_REGNUM)); */
+/* OBSOLETE expect_prompt (); */
+/* OBSOLETE fprintf (eb_stream, "s sr131,%x\n", read_register (Q_REGNUM)); */
+/* OBSOLETE expect_prompt (); */
+/* OBSOLETE fprintf (eb_stream, "s sr0,"); */
+/* OBSOLETE for (i = 0; i < 11; ++i) */
+/* OBSOLETE fprintf (eb_stream, "%x,", read_register (VAB_REGNUM + i)); */
+/* OBSOLETE fprintf (eb_stream, "%x\n", read_register (VAB_REGNUM + 11)); */
+/* OBSOLETE expect_prompt (); */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* Store register REGNO, or all if REGNO == 0. */
+/* OBSOLETE Return errno value. */ */
+/* OBSOLETE void */
+/* OBSOLETE eb_store_register (int regno) */
+/* OBSOLETE { */
+/* OBSOLETE if (regno == -1) */
+/* OBSOLETE eb_store_registers (); */
+/* OBSOLETE else */
+/* OBSOLETE { */
+/* OBSOLETE char *name = get_reg_name (regno); */
+/* OBSOLETE fprintf (eb_stream, "s %s,%x\n", name, read_register (regno)); */
+/* OBSOLETE /* Setting GR1 changes the numbers of all the locals, so */
+/* OBSOLETE invalidate the register cache. Do this *after* calling */
+/* OBSOLETE read_register, because we want read_register to return the */
+/* OBSOLETE value that write_register has just stuffed into the registers */
+/* OBSOLETE array, not the value of the register fetched from the */
+/* OBSOLETE inferior. */ */
+/* OBSOLETE if (regno == GR1_REGNUM) */
+/* OBSOLETE registers_changed (); */
+/* OBSOLETE expect_prompt (); */
+/* OBSOLETE } */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* Get ready to modify the registers array. On machines which store */
+/* OBSOLETE individual registers, this doesn't need to do anything. On machines */
+/* OBSOLETE which store all the registers in one fell swoop, this makes sure */
+/* OBSOLETE that registers contains all the registers from the program being */
+/* OBSOLETE debugged. */ */
+/* OBSOLETE */
+/* OBSOLETE void */
+/* OBSOLETE eb_prepare_to_store (void) */
+/* OBSOLETE { */
+/* OBSOLETE /* Do nothing, since we can store individual regs */ */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* Transfer LEN bytes between GDB address MYADDR and target address */
+/* OBSOLETE MEMADDR. If WRITE is non-zero, transfer them to the target, */
+/* OBSOLETE otherwise transfer them from the target. TARGET is unused. */
+/* OBSOLETE */
+/* OBSOLETE Returns the number of bytes transferred. */ */
+/* OBSOLETE */
+/* OBSOLETE int */
+/* OBSOLETE eb_xfer_inferior_memory (CORE_ADDR memaddr, char *myaddr, int len, int write, */
+/* OBSOLETE struct mem_attrib *attrib ATTRIBUTE_UNUSED, */
+/* OBSOLETE struct target_ops *target ATTRIBUTE_UNUSED) */
+/* OBSOLETE { */
+/* OBSOLETE if (write) */
+/* OBSOLETE return eb_write_inferior_memory (memaddr, myaddr, len); */
+/* OBSOLETE else */
+/* OBSOLETE return eb_read_inferior_memory (memaddr, myaddr, len); */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE void */
+/* OBSOLETE eb_files_info (void) */
+/* OBSOLETE { */
+/* OBSOLETE printf ("\tAttached to %s at %d baud and running program %s.\n", */
+/* OBSOLETE dev_name, baudrate, prog_name); */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* Copy LEN bytes of data from debugger memory at MYADDR */
+/* OBSOLETE to inferior's memory at MEMADDR. Returns length moved. */ */
+/* OBSOLETE int */
+/* OBSOLETE eb_write_inferior_memory (CORE_ADDR memaddr, char *myaddr, int len) */
+/* OBSOLETE { */
+/* OBSOLETE int i; */
+/* OBSOLETE */
+/* OBSOLETE for (i = 0; i < len; i++) */
+/* OBSOLETE { */
+/* OBSOLETE if ((i % 16) == 0) */
+/* OBSOLETE fprintf (eb_stream, "sb %x,", memaddr + i); */
+/* OBSOLETE if ((i % 16) == 15 || i == len - 1) */
+/* OBSOLETE { */
+/* OBSOLETE fprintf (eb_stream, "%x\n", ((unsigned char *) myaddr)[i]); */
+/* OBSOLETE expect_prompt (); */
+/* OBSOLETE } */
+/* OBSOLETE else */
+/* OBSOLETE fprintf (eb_stream, "%x,", ((unsigned char *) myaddr)[i]); */
+/* OBSOLETE } */
+/* OBSOLETE return len; */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* Read LEN bytes from inferior memory at MEMADDR. Put the result */
+/* OBSOLETE at debugger address MYADDR. Returns length moved. */ */
+/* OBSOLETE int */
+/* OBSOLETE eb_read_inferior_memory (CORE_ADDR memaddr, char *myaddr, int len) */
+/* OBSOLETE { */
+/* OBSOLETE int i; */
+/* OBSOLETE */
+/* OBSOLETE /* Number of bytes read so far. */ */
+/* OBSOLETE int count; */
+/* OBSOLETE */
+/* OBSOLETE /* Starting address of this pass. */ */
+/* OBSOLETE unsigned long startaddr; */
+/* OBSOLETE */
+/* OBSOLETE /* Number of bytes to read in this pass. */ */
+/* OBSOLETE int len_this_pass; */
+/* OBSOLETE */
+/* OBSOLETE /* Note that this code works correctly if startaddr is just less */
+/* OBSOLETE than UINT_MAX (well, really CORE_ADDR_MAX if there was such a */
+/* OBSOLETE thing). That is, something like */
+/* OBSOLETE eb_read_bytes (CORE_ADDR_MAX - 4, foo, 4) */
+/* OBSOLETE works--it never adds len to memaddr and gets 0. */ */
+/* OBSOLETE /* However, something like */
+/* OBSOLETE eb_read_bytes (CORE_ADDR_MAX - 3, foo, 4) */
+/* OBSOLETE doesn't need to work. Detect it and give up if there's an attempt */
+/* OBSOLETE to do that. */ */
+/* OBSOLETE if (((memaddr - 1) + len) < memaddr) */
+/* OBSOLETE { */
+/* OBSOLETE errno = EIO; */
+/* OBSOLETE return 0; */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE startaddr = memaddr; */
+/* OBSOLETE count = 0; */
+/* OBSOLETE while (count < len) */
+/* OBSOLETE { */
+/* OBSOLETE len_this_pass = 16; */
+/* OBSOLETE if ((startaddr % 16) != 0) */
+/* OBSOLETE len_this_pass -= startaddr % 16; */
+/* OBSOLETE if (len_this_pass > (len - count)) */
+/* OBSOLETE len_this_pass = (len - count); */
+/* OBSOLETE */
+/* OBSOLETE fprintf (eb_stream, "db %x,%x\n", startaddr, */
+/* OBSOLETE (startaddr - 1) + len_this_pass); */
+/* OBSOLETE expect ("\n"); */
+/* OBSOLETE */
+/* OBSOLETE /* Look for 8 hex digits. */ */
+/* OBSOLETE i = 0; */
+/* OBSOLETE while (1) */
+/* OBSOLETE { */
+/* OBSOLETE if (isxdigit (readchar ())) */
+/* OBSOLETE ++i; */
+/* OBSOLETE else */
+/* OBSOLETE { */
+/* OBSOLETE expect_prompt (); */
+/* OBSOLETE error ("Hex digit expected from remote system."); */
+/* OBSOLETE } */
+/* OBSOLETE if (i >= 8) */
+/* OBSOLETE break; */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE expect (" "); */
+/* OBSOLETE */
+/* OBSOLETE for (i = 0; i < len_this_pass; i++) */
+/* OBSOLETE get_hex_byte (&myaddr[count++]); */
+/* OBSOLETE */
+/* OBSOLETE expect_prompt (); */
+/* OBSOLETE */
+/* OBSOLETE startaddr += len_this_pass; */
+/* OBSOLETE } */
+/* OBSOLETE return len; */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE static void */
+/* OBSOLETE eb_kill (char *args, int from_tty) */
+/* OBSOLETE { */
+/* OBSOLETE return; /* Ignore attempts to kill target system */ */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* Clean up when a program exits. */
+/* OBSOLETE */
+/* OBSOLETE The program actually lives on in the remote processor's RAM, and may be */
+/* OBSOLETE run again without a download. Don't leave it full of breakpoint */
+/* OBSOLETE instructions. */ */
+/* OBSOLETE */
+/* OBSOLETE void */
+/* OBSOLETE eb_mourn_inferior (void) */
+/* OBSOLETE { */
+/* OBSOLETE remove_breakpoints (); */
+/* OBSOLETE unpush_target (&eb_ops); */
+/* OBSOLETE generic_mourn_inferior (); /* Do all the proper things now */ */
+/* OBSOLETE } */
+/* OBSOLETE /* Define the target subroutine names */ */
+/* OBSOLETE */
+/* OBSOLETE struct target_ops eb_ops; */
+/* OBSOLETE */
+/* OBSOLETE static void */
+/* OBSOLETE init_eb_ops (void) */
+/* OBSOLETE { */
+/* OBSOLETE eb_ops.to_shortname = "amd-eb"; */
+/* OBSOLETE eb_ops.to_longname = "Remote serial AMD EBMON target"; */
+/* OBSOLETE eb_ops.to_doc = "Use a remote computer running EBMON connected by a serial line.\n\ */
+/* OBSOLETE Arguments are the name of the device for the serial line,\n\ */
+/* OBSOLETE the speed to connect at in bits per second, and the filename of the\n\ */
+/* OBSOLETE executable as it exists on the remote computer. For example,\n\ */
+/* OBSOLETE target amd-eb /dev/ttya 9600 demo", */
+/* OBSOLETE eb_ops.to_open = eb_open; */
+/* OBSOLETE eb_ops.to_close = eb_close; */
+/* OBSOLETE eb_ops.to_attach = 0; */
+/* OBSOLETE eb_ops.to_post_attach = NULL; */
+/* OBSOLETE eb_ops.to_require_attach = NULL; */
+/* OBSOLETE eb_ops.to_detach = eb_detach; */
+/* OBSOLETE eb_ops.to_require_detach = NULL; */
+/* OBSOLETE eb_ops.to_resume = eb_resume; */
+/* OBSOLETE eb_ops.to_wait = eb_wait; */
+/* OBSOLETE eb_ops.to_post_wait = NULL; */
+/* OBSOLETE eb_ops.to_fetch_registers = eb_fetch_register; */
+/* OBSOLETE eb_ops.to_store_registers = eb_store_register; */
+/* OBSOLETE eb_ops.to_prepare_to_store = eb_prepare_to_store; */
+/* OBSOLETE eb_ops.to_xfer_memory = eb_xfer_inferior_memory; */
+/* OBSOLETE eb_ops.to_files_info = eb_files_info; */
+/* OBSOLETE eb_ops.to_insert_breakpoint = 0; */
+/* OBSOLETE eb_ops.to_remove_breakpoint = 0; /* Breakpoints */ */
+/* OBSOLETE eb_ops.to_terminal_init = 0; */
+/* OBSOLETE eb_ops.to_terminal_inferior = 0; */
+/* OBSOLETE eb_ops.to_terminal_ours_for_output = 0; */
+/* OBSOLETE eb_ops.to_terminal_ours = 0; */
+/* OBSOLETE eb_ops.to_terminal_info = 0; /* Terminal handling */ */
+/* OBSOLETE eb_ops.to_kill = eb_kill; */
+/* OBSOLETE eb_ops.to_load = generic_load; /* load */ */
+/* OBSOLETE eb_ops.to_lookup_symbol = 0; /* lookup_symbol */ */
+/* OBSOLETE eb_ops.to_create_inferior = eb_create_inferior; */
+/* OBSOLETE eb_ops.to_post_startup_inferior = NULL; */
+/* OBSOLETE eb_ops.to_acknowledge_created_inferior = NULL; */
+/* OBSOLETE eb_ops.to_clone_and_follow_inferior = NULL; */
+/* OBSOLETE eb_ops.to_post_follow_inferior_by_clone = NULL; */
+/* OBSOLETE eb_ops.to_insert_fork_catchpoint = NULL; */
+/* OBSOLETE eb_ops.to_remove_fork_catchpoint = NULL; */
+/* OBSOLETE eb_ops.to_insert_vfork_catchpoint = NULL; */
+/* OBSOLETE eb_ops.to_remove_vfork_catchpoint = NULL; */
+/* OBSOLETE eb_ops.to_has_forked = NULL; */
+/* OBSOLETE eb_ops.to_has_vforked = NULL; */
+/* OBSOLETE eb_ops.to_can_follow_vfork_prior_to_exec = NULL; */
+/* OBSOLETE eb_ops.to_post_follow_vfork = NULL; */
+/* OBSOLETE eb_ops.to_insert_exec_catchpoint = NULL; */
+/* OBSOLETE eb_ops.to_remove_exec_catchpoint = NULL; */
+/* OBSOLETE eb_ops.to_has_execd = NULL; */
+/* OBSOLETE eb_ops.to_reported_exec_events_per_exec_call = NULL; */
+/* OBSOLETE eb_ops.to_has_exited = NULL; */
+/* OBSOLETE eb_ops.to_mourn_inferior = eb_mourn_inferior; */
+/* OBSOLETE eb_ops.to_can_run = 0; /* can_run */ */
+/* OBSOLETE eb_ops.to_notice_signals = 0; /* notice_signals */ */
+/* OBSOLETE eb_ops.to_thread_alive = 0; /* thread-alive */ */
+/* OBSOLETE eb_ops.to_stop = 0; /* to_stop */ */
+/* OBSOLETE eb_ops.to_pid_to_exec_file = NULL; */
+/* OBSOLETE eb_ops.to_stratum = process_stratum; */
+/* OBSOLETE eb_ops.DONT_USE = 0; /* next */ */
+/* OBSOLETE eb_ops.to_has_all_memory = 1; */
+/* OBSOLETE eb_ops.to_has_memory = 1; */
+/* OBSOLETE eb_ops.to_has_stack = 1; */
+/* OBSOLETE eb_ops.to_has_registers = 1; */
+/* OBSOLETE eb_ops.to_has_execution = 1; /* all mem, mem, stack, regs, exec */ */
+/* OBSOLETE eb_ops.to_sections = 0; /* sections */ */
+/* OBSOLETE eb_ops.to_sections_end = 0; /* sections end */ */
+/* OBSOLETE eb_ops.to_magic = OPS_MAGIC; /* Always the last thing */ */
+/* OBSOLETE }; */
+/* OBSOLETE */
+/* OBSOLETE void */
+/* OBSOLETE _initialize_remote_eb (void) */
+/* OBSOLETE { */
+/* OBSOLETE init_eb_ops (); */
+/* OBSOLETE add_target (&eb_ops); */
+/* OBSOLETE } */
-/* Remote debugging interface for Am290*0 running MiniMON monitor, for GDB.
- Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000,
- 2001 Free Software Foundation, Inc.
- Originally written by Daniel Mann at AMD.
-
- This file is part of GDB.
-
- 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.
-
- 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.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA. */
-
-/* This is like remote.c but ecpects MiniMON to be running on the Am29000
- target hardware.
- - David Wood (wood@lab.ultra.nyu.edu) at New York University adapted this
- file to gdb 3.95. I was unable to get this working on sun3os4
- with termio, only with sgtty. Because we are only attempting to
- use this module to debug our kernel, which is already loaded when
- gdb is started up, I did not code up the file downloading facilities.
- As a result this module has only the stubs to download files.
- You should get tagged at compile time if you need to make any
- changes/additions. */
-
-#include "defs.h"
-#include "inferior.h"
-#include "value.h"
-#include <ctype.h>
-#include <fcntl.h>
-#include <signal.h>
-#include <errno.h>
-#include "gdb_string.h"
-#include "terminal.h"
-#include "minimon.h"
-#include "target.h"
-#include "regcache.h"
-
-/* Offset of member MEMBER in a struct of type TYPE. */
-#define offsetof(TYPE, MEMBER) ((int) &((TYPE *)0)->MEMBER)
-
-#define DRAIN_INPUT() (msg_recv_serial((union msg_t*)0))
-
-extern int stop_soon_quietly; /* for wait_for_inferior */
-
-static void mm_resume (ptid_t ptid, int step, enum target_signal sig)
-static void mm_fetch_registers ();
-static int fetch_register ();
-static void mm_store_registers ();
-static int store_register ();
-static int regnum_to_srnum ();
-static void mm_close ();
-static char *msg_str ();
-static char *error_msg_str ();
-static int expect_msg ();
-static void init_target_mm ();
-static int mm_memory_space ();
-
-#define FREEZE_MODE (read_register(CPS_REGNUM) && 0x400)
-#define USE_SHADOW_PC ((processor_type == a29k_freeze_mode) && FREEZE_MODE)
-
-/* FIXME: Replace with `set remotedebug'. */
-#define LLOG_FILE "minimon.log"
-#if defined (LOG_FILE)
-FILE *log_file;
-#endif
-
-/*
- * Size of message buffers. I couldn't get memory reads to work when
- * the byte_count was larger than 512 (it may be a baud rate problem).
- */
-#define BUFER_SIZE 512
-/*
- * Size of data area in message buffer on the TARGET (remote system).
- */
-#define MAXDATA_T (target_config.max_msg_size - \
- offsetof(struct write_r_msg_t,data[0]))
-/*
- * Size of data area in message buffer on the HOST (gdb).
- */
-#define MAXDATA_H (BUFER_SIZE - offsetof(struct write_r_msg_t,data[0]))
-/*
- * Defined as the minimum size of data areas of the two message buffers
- */
-#define MAXDATA (MAXDATA_H < MAXDATA_T ? MAXDATA_H : MAXDATA_T)
-
-static char out_buf[BUFER_SIZE];
-static char in_buf[BUFER_SIZE];
-
-int msg_recv_serial ();
-int msg_send_serial ();
-
-#define MAX_RETRIES 5000
-extern struct target_ops mm_ops; /* Forward declaration */
-struct config_msg_t target_config; /* HIF needs this */
-union msg_t *out_msg_buf = (union msg_t *) out_buf;
-union msg_t *in_msg_buf = (union msg_t *) in_buf;
-
-static int timeout = 5;
-
-/* Descriptor for I/O to remote machine. Initialize it to -1 so that
- mm_open knows that we don't have a file open when the program
- starts. */
-int mm_desc = -1;
-
-/* stream which is fdopen'd from mm_desc. Only valid when
- mm_desc != -1. */
-FILE *mm_stream;
-
-/* Called when SIGALRM signal sent due to alarm() timeout. */
-#ifndef HAVE_TERMIO
-
-volatile int n_alarms;
-
-static void
-mm_timer (void)
-{
-#if 0
- if (kiodebug)
- printf ("mm_timer called\n");
-#endif
- n_alarms++;
-}
-#endif /* HAVE_TERMIO */
-
-/* malloc'd name of the program on the remote system. */
-static char *prog_name = NULL;
-
-
-/* Number of SIGTRAPs we need to simulate. That is, the next
- NEED_ARTIFICIAL_TRAP calls to mm_wait should just return
- SIGTRAP without actually waiting for anything. */
-
-/**************************************************** REMOTE_CREATE_INFERIOR */
-/* This is called not only when we first attach, but also when the
- user types "run" after having attached. */
-static void
-mm_create_inferior (char *execfile, char *args, char **env)
-{
-#define MAX_TOKENS 25
-#define BUFFER_SIZE 256
- int token_count;
- int result;
- char *token[MAX_TOKENS];
- char cmd_line[BUFFER_SIZE];
-
- if (args && *args)
- error ("Can't pass arguments to remote mm process (yet).");
-
- if (execfile == 0 /* || exec_bfd == 0 */ )
- error ("No executable file specified");
-
- if (!mm_stream)
- {
- printf ("Minimon not open yet.\n");
- return;
- }
-
- /* On ultra3 (NYU) we assume the kernel is already running so there is
- no file to download.
- FIXME: Fixed required here -> load your program, possibly with mm_load().
- */
- printf_filtered ("\n\
-Assuming you are at NYU debuging a kernel, i.e., no need to download.\n\n");
-
- /* We will get a task spawn event immediately. */
- init_wait_for_inferior ();
- clear_proceed_status ();
- stop_soon_quietly = 1;
- proceed (-1, TARGET_SIGNAL_DEFAULT, 0);
- normal_stop ();
-}
-/**************************************************** REMOTE_MOURN_INFERIOR */
-static void
-mm_mourn (void)
-{
- pop_target (); /* Pop back to no-child state */
- generic_mourn_inferior ();
-}
-
-/********************************************************************** damn_b
-*/
-/* Translate baud rates from integers to damn B_codes. Unix should
- have outgrown this crap years ago, but even POSIX wouldn't buck it. */
-
-#ifndef B19200
-#define B19200 EXTA
-#endif
-#ifndef B38400
-#define B38400 EXTB
-#endif
-
-static struct
-{
- int rate, damn_b;
-}
-baudtab[] =
-{
- {
- 0, B0
- }
- ,
- {
- 50, B50
- }
- ,
- {
- 75, B75
- }
- ,
- {
- 110, B110
- }
- ,
- {
- 134, B134
- }
- ,
- {
- 150, B150
- }
- ,
- {
- 200, B200
- }
- ,
- {
- 300, B300
- }
- ,
- {
- 600, B600
- }
- ,
- {
- 1200, B1200
- }
- ,
- {
- 1800, B1800
- }
- ,
- {
- 2400, B2400
- }
- ,
- {
- 4800, B4800
- }
- ,
- {
- 9600, B9600
- }
- ,
- {
- 19200, B19200
- }
- ,
- {
- 38400, B38400
- }
- ,
- {
- -1, -1
- }
- ,
-};
-
-static int
-damn_b (int rate)
-{
- int i;
-
- for (i = 0; baudtab[i].rate != -1; i++)
- if (rate == baudtab[i].rate)
- return baudtab[i].damn_b;
- return B38400; /* Random */
-}
-
-
-/***************************************************************** REMOTE_OPEN
-** Open a connection to remote minimon.
- NAME is the filename used for communication, then a space,
- then the baud rate.
- 'target adapt /dev/ttya 9600 [prognam]' for example.
- */
-
-static char *dev_name;
-int baudrate = 9600;
-static void
-mm_open (char *name, int from_tty)
-{
- TERMINAL sg;
- unsigned int prl;
- char *p;
-
- /* Find the first whitespace character, it separates dev_name from
- prog_name. */
- for (p = name;
- p && *p && !isspace (*p); p++)
- ;
- if (p == 0 || *p == '\0')
- erroid:
- error ("Usage : <command> <serial-device> <baud-rate> [progname]");
- dev_name = (char *) xmalloc (p - name + 1);
- strncpy (dev_name, name, p - name);
- dev_name[p - name] = '\0';
-
- /* Skip over the whitespace after dev_name */
- for (; isspace (*p); p++)
- /*EMPTY */ ;
-
- if (1 != sscanf (p, "%d ", &baudrate))
- goto erroid;
-
- /* Skip the number and then the spaces */
- for (; isdigit (*p); p++)
- /*EMPTY */ ;
- for (; isspace (*p); p++)
- /*EMPTY */ ;
-
- if (prog_name != NULL)
- xfree (prog_name);
- prog_name = savestring (p, strlen (p));
-
-
- if (mm_desc >= 0)
- close (mm_desc);
-
- mm_desc = open (dev_name, O_RDWR);
- if (mm_desc < 0)
- perror_with_name (dev_name);
- ioctl (mm_desc, TIOCGETP, &sg);
-#ifdef HAVE_TERMIO
- sg.c_cc[VMIN] = 0; /* read with timeout. */
- sg.c_cc[VTIME] = timeout * 10;
- sg.c_lflag &= ~(ICANON | ECHO);
- sg.c_cflag = (sg.c_cflag & ~CBAUD) | damn_b (baudrate);
-#else
- sg.sg_ispeed = damn_b (baudrate);
- sg.sg_ospeed = damn_b (baudrate);
- sg.sg_flags |= RAW;
- sg.sg_flags |= ANYP;
- sg.sg_flags &= ~ECHO;
-#endif
-
-
- ioctl (mm_desc, TIOCSETP, &sg);
- mm_stream = fdopen (mm_desc, "r+");
-
- push_target (&mm_ops);
-
-#ifndef HAVE_TERMIO
-#ifndef NO_SIGINTERRUPT
- /* Cause SIGALRM's to make reads fail with EINTR instead of resuming
- the read. */
- if (siginterrupt (SIGALRM, 1) != 0)
- perror ("mm_open: error in siginterrupt");
-#endif
-
- /* Set up read timeout timer. */
- if ((void (*)) signal (SIGALRM, mm_timer) == (void (*)) -1)
- perror ("mm_open: error in signal");
-#endif
-
-#if defined (LOG_FILE)
- log_file = fopen (LOG_FILE, "w");
- if (log_file == NULL)
- perror_with_name (LOG_FILE);
-#endif
- /*
- ** Initialize target configuration structure (global)
- */
- DRAIN_INPUT ();
- out_msg_buf->config_req_msg.code = CONFIG_REQ;
- out_msg_buf->config_req_msg.length = 4 * 0;
- msg_send_serial (out_msg_buf); /* send config request message */
-
- expect_msg (CONFIG, in_msg_buf, 1);
-
- a29k_get_processor_type ();
-
- /* Print out some stuff, letting the user now what's going on */
- printf_filtered ("Connected to MiniMon via %s.\n", dev_name);
- /* FIXME: can this restriction be removed? */
- printf_filtered ("Remote debugging using virtual addresses works only\n");
- printf_filtered ("\twhen virtual addresses map 1:1 to physical addresses.\n")
- ;
- if (processor_type != a29k_freeze_mode)
- {
- fprintf_filtered (gdb_stderr,
- "Freeze-mode debugging not available, and can only be done on an A29050.\n");
- }
-
- target_config.code = CONFIG;
- target_config.length = 0;
- target_config.processor_id = in_msg_buf->config_msg.processor_id;
- target_config.version = in_msg_buf->config_msg.version;
- target_config.I_mem_start = in_msg_buf->config_msg.I_mem_start;
- target_config.I_mem_size = in_msg_buf->config_msg.I_mem_size;
- target_config.D_mem_start = in_msg_buf->config_msg.D_mem_start;
- target_config.D_mem_size = in_msg_buf->config_msg.D_mem_size;
- target_config.ROM_start = in_msg_buf->config_msg.ROM_start;
- target_config.ROM_size = in_msg_buf->config_msg.ROM_size;
- target_config.max_msg_size = in_msg_buf->config_msg.max_msg_size;
- target_config.max_bkpts = in_msg_buf->config_msg.max_bkpts;
- target_config.coprocessor = in_msg_buf->config_msg.coprocessor;
- target_config.reserved = in_msg_buf->config_msg.reserved;
- if (from_tty)
- {
- printf ("Connected to MiniMON :\n");
- printf (" Debugcore version %d.%d\n",
- 0x0f & (target_config.version >> 4),
- 0x0f & (target_config.version));
- printf (" Configuration version %d.%d\n",
- 0x0f & (target_config.version >> 12),
- 0x0f & (target_config.version >> 8));
- printf (" Message system version %d.%d\n",
- 0x0f & (target_config.version >> 20),
- 0x0f & (target_config.version >> 16));
- printf (" Communication driver version %d.%d\n",
- 0x0f & (target_config.version >> 28),
- 0x0f & (target_config.version >> 24));
- }
-
- /* Leave the target running...
- * The above message stopped the target in the dbg core (MiniMon),
- * so restart the target out of MiniMon,
- */
- out_msg_buf->go_msg.code = GO;
- out_msg_buf->go_msg.length = 0;
- msg_send_serial (out_msg_buf);
- /* No message to expect after a GO */
-}
-
-/**************************************************************** REMOTE_CLOSE
-** Close the open connection to the minimon debugger.
- Use this when you want to detach and do something else
- with your gdb. */
-static void
-mm_close ( /*FIXME: how is quitting used */
- int quitting)
-{
- if (mm_desc < 0)
- error ("Can't close remote connection: not debugging remotely.");
-
- /* We should never get here if there isn't something valid in
- mm_desc and mm_stream.
-
- Due to a bug in Unix, fclose closes not only the stdio stream,
- but also the file descriptor. So we don't actually close
- mm_desc. */
- DRAIN_INPUT ();
- fclose (mm_stream);
- /* close (mm_desc); */
-
- /* Do not try to close mm_desc again, later in the program. */
- mm_stream = NULL;
- mm_desc = -1;
-
-#if defined (LOG_FILE)
- if (ferror (log_file))
- printf ("Error writing log file.\n");
- if (fclose (log_file) != 0)
- printf ("Error closing log file.\n");
-#endif
-
- printf ("Ending remote debugging\n");
-}
-
-/************************************************************* REMOTE_ATACH */
-/* Attach to a program that is already loaded and running
- * Upon exiting the process's execution is stopped.
- */
-static void
-mm_attach (char *args, int from_tty)
-{
-
- if (!mm_stream)
- error ("MiniMon not opened yet, use the 'target minimon' command.\n");
-
- if (from_tty)
- printf ("Attaching to remote program %s...\n", prog_name);
-
- /* Make sure the target is currently running, it is supposed to be. */
- /* FIXME: is it ok to send MiniMon a BREAK if it is already stopped in
- * the dbg core. If so, we don't need to send this GO.
- */
- out_msg_buf->go_msg.code = GO;
- out_msg_buf->go_msg.length = 0;
- msg_send_serial (out_msg_buf);
- sleep (2); /* At the worst it will stop, receive a message, continue */
-
- /* Send the mm a break. */
- out_msg_buf->break_msg.code = BREAK;
- out_msg_buf->break_msg.length = 0;
- msg_send_serial (out_msg_buf);
-}
-/********************************************************** REMOTE_DETACH */
-/* Terminate the open connection to the remote debugger.
- Use this when you want to detach and do something else
- with your gdb. Leave remote process running (with no breakpoints set). */
-static void
-mm_detach (char *args, int from_tty)
-{
- remove_breakpoints (); /* Just in case there were any left in */
- out_msg_buf->go_msg.code = GO;
- out_msg_buf->go_msg.length = 0;
- msg_send_serial (out_msg_buf);
- pop_target (); /* calls mm_close to do the real work */
-}
-
-
-/*************************************************************** REMOTE_RESUME
-** Tell the remote machine to resume. */
-
-static void
-mm_resume (ptid_t ptid, int step, enum target_signal sig)
-{
- if (sig != TARGET_SIGNAL_0)
- warning ("Can't send signals to a remote MiniMon system.");
-
- if (step)
- {
- out_msg_buf->step_msg.code = STEP;
- out_msg_buf->step_msg.length = 1 * 4;
- out_msg_buf->step_msg.count = 1; /* step 1 instruction */
- msg_send_serial (out_msg_buf);
- }
- else
- {
- out_msg_buf->go_msg.code = GO;
- out_msg_buf->go_msg.length = 0;
- msg_send_serial (out_msg_buf);
- }
-}
-
-/***************************************************************** REMOTE_WAIT
-** Wait until the remote machine stops, then return,
- storing status in STATUS just as `wait' would. */
-
-static ptid_t
-mm_wait (ptid_t ptid, struct target_waitstatus *status)
-{
- int i, result;
- int old_timeout = timeout;
- int old_immediate_quit = immediate_quit;
-
- status->kind = TARGET_WAITKIND_EXITED;
- status->value.integer = 0;
-
-/* wait for message to arrive. It should be:
- - A HIF service request.
- - A HIF exit service request.
- - A CHANNEL0_ACK.
- - A CHANNEL1 request.
- - a debugcore HALT message.
- HIF services must be responded too, and while-looping continued.
- If the target stops executing, mm_wait() should return.
- */
- timeout = 0; /* Wait indefinetly for a message */
- immediate_quit = 1; /* Helps ability to QUIT */
- while (1)
- {
- while (msg_recv_serial (in_msg_buf))
- {
- QUIT; /* Let user quit if they want */
- }
- switch (in_msg_buf->halt_msg.code)
- {
- case HIF_CALL:
- i = in_msg_buf->hif_call_rtn_msg.service_number;
- result = service_HIF (in_msg_buf);
- if (i == 1) /* EXIT */
- goto exit;
- if (result)
- printf ("Warning: failure during HIF service %d\n", i);
- break;
- case CHANNEL0_ACK:
- service_HIF (in_msg_buf);
- break;
- case CHANNEL1:
- i = in_msg_buf->channel1_msg.length;
- in_msg_buf->channel1_msg.data[i] = '\0';
- printf ("%s", in_msg_buf->channel1_msg.data);
- gdb_flush (gdb_stdout);
- /* Send CHANNEL1_ACK message */
- out_msg_buf->channel1_ack_msg.code = CHANNEL1_ACK;
- out_msg_buf->channel1_ack_msg.length = 0;
- result = msg_send_serial (out_msg_buf);
- break;
- case HALT:
- goto halted;
- default:
- goto halted;
- }
- }
-halted:
- /* FIXME, these printfs should not be here. This is a source level
- debugger, guys! */
- if (in_msg_buf->halt_msg.trap_number == 0)
- {
- printf ("Am290*0 received vector number %d (break point)\n",
- in_msg_buf->halt_msg.trap_number);
- status->kind = TARGET_WAITKIND_STOPPED;
- status->value.sig = TARGET_SIGNAL_TRAP;
- }
- else if (in_msg_buf->halt_msg.trap_number == 1)
- {
- printf ("Am290*0 received vector number %d\n",
- in_msg_buf->halt_msg.trap_number);
- status->kind = TARGET_WAITKIND_STOPPED;
- status->value.sig = TARGET_SIGNAL_BUS;
- }
- else if (in_msg_buf->halt_msg.trap_number == 3
- || in_msg_buf->halt_msg.trap_number == 4)
- {
- printf ("Am290*0 received vector number %d\n",
- in_msg_buf->halt_msg.trap_number);
- status->kind = TARGET_WAITKIND_STOPPED;
- status->value.sig = TARGET_SIGNAL_FPE;
- }
- else if (in_msg_buf->halt_msg.trap_number == 5)
- {
- printf ("Am290*0 received vector number %d\n",
- in_msg_buf->halt_msg.trap_number);
- status->kind = TARGET_WAITKIND_STOPPED;
- status->value.sig = TARGET_SIGNAL_ILL;
- }
- else if (in_msg_buf->halt_msg.trap_number >= 6
- && in_msg_buf->halt_msg.trap_number <= 11)
- {
- printf ("Am290*0 received vector number %d\n",
- in_msg_buf->halt_msg.trap_number);
- status->kind = TARGET_WAITKIND_STOPPED;
- status->value.sig = TARGET_SIGNAL_SEGV;
- }
- else if (in_msg_buf->halt_msg.trap_number == 12
- || in_msg_buf->halt_msg.trap_number == 13)
- {
- printf ("Am290*0 received vector number %d\n",
- in_msg_buf->halt_msg.trap_number);
- status->kind = TARGET_WAITKIND_STOPPED;
- status->value.sig = TARGET_SIGNAL_ILL;
- }
- else if (in_msg_buf->halt_msg.trap_number == 14)
- {
- printf ("Am290*0 received vector number %d\n",
- in_msg_buf->halt_msg.trap_number);
- status->kind = TARGET_WAITKIND_STOPPED;
- status->value.sig = TARGET_SIGNAL_ALRM;
- }
- else if (in_msg_buf->halt_msg.trap_number == 15)
- {
- status->kind = TARGET_WAITKIND_STOPPED;
- status->value.sig = TARGET_SIGNAL_TRAP;
- }
- else if (in_msg_buf->halt_msg.trap_number >= 16
- && in_msg_buf->halt_msg.trap_number <= 21)
- {
- printf ("Am290*0 received vector number %d\n",
- in_msg_buf->halt_msg.trap_number);
- status->kind = TARGET_WAITKIND_STOPPED;
- status->value.sig = TARGET_SIGNAL_INT;
- }
- else if (in_msg_buf->halt_msg.trap_number == 22)
- {
- printf ("Am290*0 received vector number %d\n",
- in_msg_buf->halt_msg.trap_number);
- status->kind = TARGET_WAITKIND_STOPPED;
- status->value.sig = TARGET_SIGNAL_ILL;
- } /* BREAK message was sent */
- else if (in_msg_buf->halt_msg.trap_number == 75)
- {
- status->kind = TARGET_WAITKIND_STOPPED;
- status->value.sig = TARGET_SIGNAL_TRAP;
- }
- else
- exit:
- {
- status->kind = TARGET_WAITKIND_EXITED;
- status->value.integer = 0;
- }
-
- timeout = old_timeout; /* Restore original timeout value */
- immediate_quit = old_immediate_quit;
- return inferior_ptid;
-}
-
-/******************************************************* REMOTE_FETCH_REGISTERS
- * Read a remote register 'regno'.
- * If regno==-1 then read all the registers.
- */
-static void
-mm_fetch_registers (int regno)
-{
- INT32 *data_p;
-
- if (regno >= 0)
- {
- fetch_register (regno);
- return;
- }
-
-/* Gr1/rsp */
- out_msg_buf->read_req_msg.byte_count = 4 * 1;
- out_msg_buf->read_req_msg.memory_space = GLOBAL_REG;
- out_msg_buf->read_req_msg.address = 1;
- msg_send_serial (out_msg_buf);
- expect_msg (READ_ACK, in_msg_buf, 1);
- data_p = &(in_msg_buf->read_r_ack_msg.data[0]);
- supply_register (GR1_REGNUM, data_p);
-
-#if defined(GR64_REGNUM) /* Read gr64-127 */
-/* Global Registers gr64-gr95 */
- out_msg_buf->read_req_msg.code = READ_REQ;
- out_msg_buf->read_req_msg.length = 4 * 3;
- out_msg_buf->read_req_msg.byte_count = 4 * 32;
- out_msg_buf->read_req_msg.memory_space = GLOBAL_REG;
- out_msg_buf->read_req_msg.address = 64;
- msg_send_serial (out_msg_buf);
- expect_msg (READ_ACK, in_msg_buf, 1);
- data_p = &(in_msg_buf->read_r_ack_msg.data[0]);
-
- for (regno = GR64_REGNUM; regno < GR64_REGNUM + 32; regno++)
- {
- supply_register (regno, data_p++);
- }
-#endif /* GR64_REGNUM */
-
-/* Global Registers gr96-gr127 */
- out_msg_buf->read_req_msg.code = READ_REQ;
- out_msg_buf->read_req_msg.length = 4 * 3;
- out_msg_buf->read_req_msg.byte_count = 4 * 32;
- out_msg_buf->read_req_msg.memory_space = GLOBAL_REG;
- out_msg_buf->read_req_msg.address = 96;
- msg_send_serial (out_msg_buf);
- expect_msg (READ_ACK, in_msg_buf, 1);
- data_p = &(in_msg_buf->read_r_ack_msg.data[0]);
-
- for (regno = GR96_REGNUM; regno < GR96_REGNUM + 32; regno++)
- {
- supply_register (regno, data_p++);
- }
-
-/* Local Registers */
- out_msg_buf->read_req_msg.byte_count = 4 * (128);
- out_msg_buf->read_req_msg.memory_space = LOCAL_REG;
- out_msg_buf->read_req_msg.address = 0;
- msg_send_serial (out_msg_buf);
- expect_msg (READ_ACK, in_msg_buf, 1);
- data_p = &(in_msg_buf->read_r_ack_msg.data[0]);
-
- for (regno = LR0_REGNUM; regno < LR0_REGNUM + 128; regno++)
- {
- supply_register (regno, data_p++);
- }
-
-/* Protected Special Registers */
- out_msg_buf->read_req_msg.byte_count = 4 * 15;
- out_msg_buf->read_req_msg.memory_space = SPECIAL_REG;
- out_msg_buf->read_req_msg.address = 0;
- msg_send_serial (out_msg_buf);
- expect_msg (READ_ACK, in_msg_buf, 1);
- data_p = &(in_msg_buf->read_r_ack_msg.data[0]);
-
- for (regno = 0; regno <= 14; regno++)
- {
- supply_register (SR_REGNUM (regno), data_p++);
- }
- if (USE_SHADOW_PC)
- { /* Let regno_to_srnum() handle the register number */
- fetch_register (NPC_REGNUM);
- fetch_register (PC_REGNUM);
- fetch_register (PC2_REGNUM);
- }
-
-/* Unprotected Special Registers */
- out_msg_buf->read_req_msg.byte_count = 4 * 8;
- out_msg_buf->read_req_msg.memory_space = SPECIAL_REG;
- out_msg_buf->read_req_msg.address = 128;
- msg_send_serial (out_msg_buf);
- expect_msg (READ_ACK, in_msg_buf, 1);
- data_p = &(in_msg_buf->read_r_ack_msg.data[0]);
-
- for (regno = 128; regno <= 135; regno++)
- {
- supply_register (SR_REGNUM (regno), data_p++);
- }
-
- /* There doesn't seem to be any way to get these. */
- {
- int val = -1;
- supply_register (FPE_REGNUM, &val);
- supply_register (INTE_REGNUM, &val);
- supply_register (FPS_REGNUM, &val);
- supply_register (EXO_REGNUM, &val);
- }
-}
-
-
-/****************************************************** REMOTE_STORE_REGISTERS
- * Store register regno into the target.
- * If regno==-1 then store all the registers.
- * Result is 0 for success, -1 for failure.
- */
-
-static void
-mm_store_registers (int regno)
-{
- int result;
-
- if (regno >= 0)
- {
- store_register (regno);
- return;
- }
-
- result = 0;
-
- out_msg_buf->write_r_msg.code = WRITE_REQ;
-
-/* Gr1/rsp */
- out_msg_buf->write_r_msg.byte_count = 4 * 1;
- out_msg_buf->write_r_msg.length = 3 * 4 + out_msg_buf->write_r_msg.byte_count;
- out_msg_buf->write_r_msg.memory_space = GLOBAL_REG;
- out_msg_buf->write_r_msg.address = 1;
- out_msg_buf->write_r_msg.data[0] = read_register (GR1_REGNUM);
-
- msg_send_serial (out_msg_buf);
- if (!expect_msg (WRITE_ACK, in_msg_buf, 1))
- {
- result = -1;
- }
-
-#if defined(GR64_REGNUM)
-/* Global registers gr64-gr95 */
- out_msg_buf->write_r_msg.byte_count = 4 * (32);
- out_msg_buf->write_r_msg.length = 3 * 4 + out_msg_buf->write_r_msg.byte_count;
- out_msg_buf->write_r_msg.address = 64;
-
- for (regno = GR64_REGNUM; regno < GR64_REGNUM + 32; regno++)
- {
- out_msg_buf->write_r_msg.data[regno - GR64_REGNUM] = read_register (regno);
- }
- msg_send_serial (out_msg_buf);
- if (!expect_msg (WRITE_ACK, in_msg_buf, 1))
- {
- result = -1;
- }
-#endif /* GR64_REGNUM */
-
-/* Global registers gr96-gr127 */
- out_msg_buf->write_r_msg.byte_count = 4 * (32);
- out_msg_buf->write_r_msg.length = 3 * 4 + out_msg_buf->write_r_msg.byte_count;
- out_msg_buf->write_r_msg.address = 96;
- for (regno = GR96_REGNUM; regno < GR96_REGNUM + 32; regno++)
- {
- out_msg_buf->write_r_msg.data[regno - GR96_REGNUM] = read_register (regno);
- }
- msg_send_serial (out_msg_buf);
- if (!expect_msg (WRITE_ACK, in_msg_buf, 1))
- {
- result = -1;
- }
-
-/* Local Registers */
- out_msg_buf->write_r_msg.memory_space = LOCAL_REG;
- out_msg_buf->write_r_msg.byte_count = 4 * 128;
- out_msg_buf->write_r_msg.length = 3 * 4 + out_msg_buf->write_r_msg.byte_count;
- out_msg_buf->write_r_msg.address = 0;
-
- for (regno = LR0_REGNUM; regno < LR0_REGNUM + 128; regno++)
- {
- out_msg_buf->write_r_msg.data[regno - LR0_REGNUM] = read_register (regno);
- }
- msg_send_serial (out_msg_buf);
- if (!expect_msg (WRITE_ACK, in_msg_buf, 1))
- {
- result = -1;
- }
-
-/* Protected Special Registers */
- /* VAB through TMR */
- out_msg_buf->write_r_msg.memory_space = SPECIAL_REG;
- out_msg_buf->write_r_msg.byte_count = 4 * 10;
- out_msg_buf->write_r_msg.length = 3 * 4 + out_msg_buf->write_r_msg.byte_count;
- out_msg_buf->write_r_msg.address = 0;
- for (regno = 0; regno <= 9; regno++) /* VAB through TMR */
- out_msg_buf->write_r_msg.data[regno] = read_register (SR_REGNUM (regno));
- msg_send_serial (out_msg_buf);
- if (!expect_msg (WRITE_ACK, in_msg_buf, 1))
- {
- result = -1;
- }
-
- /* PC0, PC1, PC2 possibly as shadow registers */
- out_msg_buf->write_r_msg.byte_count = 4 * 3;
- out_msg_buf->write_r_msg.length = 3 * 4 + out_msg_buf->write_r_msg.byte_count;
- for (regno = 10; regno <= 12; regno++) /* LRU and MMU */
- out_msg_buf->write_r_msg.data[regno - 10] = read_register (SR_REGNUM (regno));
- if (USE_SHADOW_PC)
- out_msg_buf->write_r_msg.address = 20; /* SPC0 */
- else
- out_msg_buf->write_r_msg.address = 10; /* PC0 */
- msg_send_serial (out_msg_buf);
- if (!expect_msg (WRITE_ACK, in_msg_buf, 1))
- {
- result = -1;
- }
-
- /* LRU and MMU */
- out_msg_buf->write_r_msg.byte_count = 4 * 2;
- out_msg_buf->write_r_msg.length = 3 * 4 + out_msg_buf->write_r_msg.byte_count;
- out_msg_buf->write_r_msg.address = 13;
- for (regno = 13; regno <= 14; regno++) /* LRU and MMU */
- out_msg_buf->write_r_msg.data[regno - 13] = read_register (SR_REGNUM (regno));
- msg_send_serial (out_msg_buf);
- if (!expect_msg (WRITE_ACK, in_msg_buf, 1))
- {
- result = -1;
- }
-
-/* Unprotected Special Registers */
- out_msg_buf->write_r_msg.byte_count = 4 * 8;
- out_msg_buf->write_r_msg.length = 3 * 4 + out_msg_buf->write_r_msg.byte_count;
- out_msg_buf->write_r_msg.address = 128;
- for (regno = 128; regno <= 135; regno++)
- out_msg_buf->write_r_msg.data[regno - 128] = read_register (SR_REGNUM (regno));
- msg_send_serial (out_msg_buf);
- if (!expect_msg (WRITE_ACK, in_msg_buf, 1))
- {
- result = -1;
- }
-
- registers_changed ();
-}
-
-/*************************************************** REMOTE_PREPARE_TO_STORE */
-/* Get ready to modify the registers array. On machines which store
- individual registers, this doesn't need to do anything. On machines
- which store all the registers in one fell swoop, this makes sure
- that registers contains all the registers from the program being
- debugged. */
-
-static void
-mm_prepare_to_store (void)
-{
- /* Do nothing, since we can store individual regs */
-}
-
-/******************************************************* REMOTE_XFER_MEMORY */
-static CORE_ADDR
-translate_addr (CORE_ADDR addr)
-{
-#if defined(KERNEL_DEBUGGING)
- /* Check for a virtual address in the kernel */
- /* Assume physical address of ublock is in paddr_u register */
- /* FIXME: doesn't work for user virtual addresses */
- if (addr >= UVADDR)
- {
- /* PADDR_U register holds the physical address of the ublock */
- CORE_ADDR i = (CORE_ADDR) read_register (PADDR_U_REGNUM);
- return (i + addr - (CORE_ADDR) UVADDR);
- }
- else
- {
- return (addr);
- }
-#else
- return (addr);
-#endif
-}
-
-/******************************************************* REMOTE_FILES_INFO */
-static void
-mm_files_info (void)
-{
- printf ("\tAttached to %s at %d baud and running program %s.\n",
- dev_name, baudrate, prog_name);
-}
-
-/************************************************* REMOTE_INSERT_BREAKPOINT */
-static int
-mm_insert_breakpoint (CORE_ADDR addr, char *contents_cache)
-{
- out_msg_buf->bkpt_set_msg.code = BKPT_SET;
- out_msg_buf->bkpt_set_msg.length = 4 * 4;
- out_msg_buf->bkpt_set_msg.memory_space = I_MEM;
- out_msg_buf->bkpt_set_msg.bkpt_addr = (ADDR32) addr;
- out_msg_buf->bkpt_set_msg.pass_count = 1;
- out_msg_buf->bkpt_set_msg.bkpt_type = -1; /* use illop for 29000 */
- msg_send_serial (out_msg_buf);
- if (expect_msg (BKPT_SET_ACK, in_msg_buf, 1))
- {
- return 0; /* Success */
- }
- else
- {
- return 1; /* Failure */
- }
-}
-
-/************************************************* REMOTE_DELETE_BREAKPOINT */
-static int
-mm_remove_breakpoint (CORE_ADDR addr, char *contents_cache)
-{
- out_msg_buf->bkpt_rm_msg.code = BKPT_RM;
- out_msg_buf->bkpt_rm_msg.length = 4 * 3;
- out_msg_buf->bkpt_rm_msg.memory_space = I_MEM;
- out_msg_buf->bkpt_rm_msg.bkpt_addr = (ADDR32) addr;
- msg_send_serial (out_msg_buf);
- if (expect_msg (BKPT_RM_ACK, in_msg_buf, 1))
- {
- return 0; /* Success */
- }
- else
- {
- return 1; /* Failure */
- }
-}
-
-
-/******************************************************* REMOTE_KILL */
-static void
-mm_kill (char *arg, int from_tty)
-{
- char buf[4];
-
-#if defined(KERNEL_DEBUGGING)
- /* We don't ever kill the kernel */
- if (from_tty)
- {
- printf ("Kernel not killed, but left in current state.\n");
- printf ("Use detach to leave kernel running.\n");
- }
-#else
- out_msg_buf->break_msg.code = BREAK;
- out_msg_buf->bkpt_set_msg.length = 4 * 0;
- expect_msg (HALT, in_msg_buf, from_tty);
- if (from_tty)
- {
- printf ("Target has been stopped.");
- printf ("Would you like to do a hardware reset (y/n) [n] ");
- fgets (buf, 3, stdin);
- if (buf[0] == 'y')
- {
- out_msg_buf->reset_msg.code = RESET;
- out_msg_buf->bkpt_set_msg.length = 4 * 0;
- expect_msg (RESET_ACK, in_msg_buf, from_tty);
- printf ("Target has been reset.");
- }
- }
- pop_target ();
-#endif
-}
-
-
-
-/***************************************************************************/
-/*
- * Load a program into the target.
- */
-static void
-mm_load (char *arg_string, int from_tty)
-{
- dont_repeat ();
-
-#if defined(KERNEL_DEBUGGING)
- printf ("The kernel had better be loaded already! Loading not done.\n");
-#else
- if (arg_string == 0)
- error ("The load command takes a file name");
-
- arg_string = tilde_expand (arg_string);
- make_cleanup (xfree, arg_string);
- QUIT;
- immediate_quit++;
- error ("File loading is not yet supported for MiniMon.");
- /* FIXME, code to load your file here... */
- /* You may need to do an init_target_mm() */
- /* init_target_mm(?,?,?,?,?,?,?,?); */
- immediate_quit--;
- /* symbol_file_add (arg_string, from_tty, text_addr, 0, 0); */
-#endif
-
-}
-
-/************************************************ REMOTE_WRITE_INFERIOR_MEMORY
-** Copy LEN bytes of data from debugger memory at MYADDR
- to inferior's memory at MEMADDR. Returns number of bytes written. */
-static int
-mm_write_inferior_memory (CORE_ADDR memaddr, char *myaddr, int len)
-{
- int i, nwritten;
-
- out_msg_buf->write_req_msg.code = WRITE_REQ;
- out_msg_buf->write_req_msg.memory_space = mm_memory_space (memaddr);
-
- nwritten = 0;
- while (nwritten < len)
- {
- int num_to_write = len - nwritten;
- if (num_to_write > MAXDATA)
- num_to_write = MAXDATA;
- for (i = 0; i < num_to_write; i++)
- out_msg_buf->write_req_msg.data[i] = myaddr[i + nwritten];
- out_msg_buf->write_req_msg.byte_count = num_to_write;
- out_msg_buf->write_req_msg.length = 3 * 4 + num_to_write;
- out_msg_buf->write_req_msg.address = memaddr + nwritten;
- msg_send_serial (out_msg_buf);
-
- if (expect_msg (WRITE_ACK, in_msg_buf, 1))
- {
- nwritten += in_msg_buf->write_ack_msg.byte_count;
- }
- else
- {
- break;
- }
- }
- return (nwritten);
-}
-
-/************************************************* REMOTE_READ_INFERIOR_MEMORY
-** Read LEN bytes from inferior memory at MEMADDR. Put the result
- at debugger address MYADDR. Returns number of bytes read. */
-static int
-mm_read_inferior_memory (CORE_ADDR memaddr, char *myaddr, int len)
-{
- int i, nread;
-
- out_msg_buf->read_req_msg.code = READ_REQ;
- out_msg_buf->read_req_msg.memory_space = mm_memory_space (memaddr);
-
- nread = 0;
- while (nread < len)
- {
- int num_to_read = (len - nread);
- if (num_to_read > MAXDATA)
- num_to_read = MAXDATA;
- out_msg_buf->read_req_msg.byte_count = num_to_read;
- out_msg_buf->read_req_msg.length = 3 * 4 + num_to_read;
- out_msg_buf->read_req_msg.address = memaddr + nread;
- msg_send_serial (out_msg_buf);
-
- if (expect_msg (READ_ACK, in_msg_buf, 1))
- {
- for (i = 0; i < in_msg_buf->read_ack_msg.byte_count; i++)
- myaddr[i + nread] = in_msg_buf->read_ack_msg.data[i];
- nread += in_msg_buf->read_ack_msg.byte_count;
- }
- else
- {
- break;
- }
- }
- return (nread);
-}
-
-/* FIXME! Merge these two. */
-static int
-mm_xfer_inferior_memory (CORE_ADDR memaddr, char *myaddr, int len, int write,
- struct mem_attrib *attrib ATTRIBUTE_UNUSED,
- struct target_ops *target ATTRIBUTE_UNUSED)
-{
-
- memaddr = translate_addr (memaddr);
-
- if (write)
- return mm_write_inferior_memory (memaddr, myaddr, len);
- else
- return mm_read_inferior_memory (memaddr, myaddr, len);
-}
-
-
-/********************************************************** MSG_SEND_SERIAL
-** This function is used to send a message over the
-** serial line.
-**
-** If the message is successfully sent, a zero is
-** returned. If the message was not sendable, a -1
-** is returned. This function blocks. That is, it
-** does not return until the message is completely
-** sent, or until an error is encountered.
-**
-*/
-
-int
-msg_send_serial (union msg_t *msg_ptr)
-{
- INT32 message_size;
- int byte_count;
- int result;
- char c;
-
- /* Send message header */
- byte_count = 0;
- message_size = msg_ptr->generic_msg.length + (2 * sizeof (INT32));
- do
- {
- c = *((char *) msg_ptr + byte_count);
- result = write (mm_desc, &c, 1);
- if (result == 1)
- {
- byte_count = byte_count + 1;
- }
- }
- while ((byte_count < message_size));
-
- return (0);
-} /* end msg_send_serial() */
-
-/********************************************************** MSG_RECV_SERIAL
-** This function is used to receive a message over a
-** serial line.
-**
-** If the message is waiting in the buffer, a zero is
-** returned and the buffer pointed to by msg_ptr is filled
-** in. If no message was available, a -1 is returned.
-** If timeout==0, wait indefinetly for a character.
-**
-*/
-
-int
-msg_recv_serial (union msg_t *msg_ptr)
-{
- static INT32 length = 0;
- static INT32 byte_count = 0;
- int result;
- char c;
- if (msg_ptr == 0) /* re-sync request */
- {
- length = 0;
- byte_count = 0;
-#ifdef HAVE_TERMIO
- /* The timeout here is the prevailing timeout set with VTIME */
- ->"timeout==0 semantics not supported"
- read (mm_desc, in_buf, BUFER_SIZE);
-#else
- alarm (1);
- read (mm_desc, in_buf, BUFER_SIZE);
- alarm (0);
-#endif
- return (0);
- }
- /* Receive message */
-#ifdef HAVE_TERMIO
-/* Timeout==0, help support the mm_wait() routine */
- ->"timeout==0 semantics not supported (and its nice if they are)"
- result = read (mm_desc, &c, 1);
-#else
- alarm (timeout);
- result = read (mm_desc, &c, 1);
- alarm (0);
-#endif
- if (result < 0)
- {
- if (errno == EINTR)
- {
- error ("Timeout reading from remote system.");
- }
- else
- perror_with_name ("remote");
- }
- else if (result == 1)
- {
- *((char *) msg_ptr + byte_count) = c;
- byte_count = byte_count + 1;
- }
-
- /* Message header received. Save message length. */
- if (byte_count == (2 * sizeof (INT32)))
- length = msg_ptr->generic_msg.length;
-
- if (byte_count >= (length + (2 * sizeof (INT32))))
- {
- /* Message received */
- byte_count = 0;
- return (0);
- }
- else
- return (-1);
-
-} /* end msg_recv_serial() */
-
-/********************************************************************* KBD_RAW
-** This function is used to put the keyboard in "raw"
-** mode for BSD Unix. The original status is saved
-** so that it may be restored later.
-*/
-TERMINAL kbd_tbuf;
-
-int
-kbd_raw (void)
-{
- int result;
- TERMINAL tbuf;
-
- /* Get keyboard termio (to save to restore original modes) */
-#ifdef HAVE_TERMIO
- result = ioctl (0, TCGETA, &kbd_tbuf);
-#else
- result = ioctl (0, TIOCGETP, &kbd_tbuf);
-#endif
- if (result == -1)
- return (errno);
-
- /* Get keyboard TERMINAL (for modification) */
-#ifdef HAVE_TERMIO
- result = ioctl (0, TCGETA, &tbuf);
-#else
- result = ioctl (0, TIOCGETP, &tbuf);
-#endif
- if (result == -1)
- return (errno);
-
- /* Set up new parameters */
-#ifdef HAVE_TERMIO
- tbuf.c_iflag = tbuf.c_iflag &
- ~(INLCR | ICRNL | IUCLC | ISTRIP | IXON | BRKINT);
- tbuf.c_lflag = tbuf.c_lflag & ~(ICANON | ISIG | ECHO);
- tbuf.c_cc[4] = 0; /* MIN */
- tbuf.c_cc[5] = 0; /* TIME */
-#else
- /* FIXME: not sure if this is correct (matches HAVE_TERMIO). */
- tbuf.sg_flags |= RAW;
- tbuf.sg_flags |= ANYP;
- tbuf.sg_flags &= ~ECHO;
-#endif
-
- /* Set keyboard termio to new mode (RAW) */
-#ifdef HAVE_TERMIO
- result = ioctl (0, TCSETAF, &tbuf);
-#else
- result = ioctl (0, TIOCSETP, &tbuf);
-#endif
- if (result == -1)
- return (errno);
-
- return (0);
-} /* end kbd_raw() */
-
-
-
-/***************************************************************** KBD_RESTORE
-** This function is used to put the keyboard back in the
-** mode it was in before kbk_raw was called. Note that
-** kbk_raw() must have been called at least once before
-** kbd_restore() is called.
-*/
-
-int
-kbd_restore (void)
-{
- int result;
-
- /* Set keyboard termio to original mode */
-#ifdef HAVE_TERMIO
- result = ioctl (0, TCSETAF, &kbd_tbuf);
-#else
- result = ioctl (0, TIOCGETP, &kbd_tbuf);
-#endif
-
- if (result == -1)
- return (errno);
-
- return (0);
-} /* end kbd_cooked() */
-
-
-/*****************************************************************************/
-/* Fetch a single register indicatated by 'regno'.
- * Returns 0/-1 on success/failure.
- */
-static int
-fetch_register (int regno)
-{
- int result;
- out_msg_buf->read_req_msg.code = READ_REQ;
- out_msg_buf->read_req_msg.length = 4 * 3;
- out_msg_buf->read_req_msg.byte_count = 4;
-
- if (regno == GR1_REGNUM)
- {
- out_msg_buf->read_req_msg.memory_space = GLOBAL_REG;
- out_msg_buf->read_req_msg.address = 1;
- }
- else if (regno >= GR96_REGNUM && regno < GR96_REGNUM + 32)
- {
- out_msg_buf->read_req_msg.memory_space = GLOBAL_REG;
- out_msg_buf->read_req_msg.address = (regno - GR96_REGNUM) + 96;
- }
-#if defined(GR64_REGNUM)
- else if (regno >= GR64_REGNUM && regno < GR64_REGNUM + 32)
- {
- out_msg_buf->read_req_msg.memory_space = GLOBAL_REG;
- out_msg_buf->read_req_msg.address = (regno - GR64_REGNUM) + 64;
- }
-#endif /* GR64_REGNUM */
- else if (regno >= LR0_REGNUM && regno < LR0_REGNUM + 128)
- {
- out_msg_buf->read_req_msg.memory_space = LOCAL_REG;
- out_msg_buf->read_req_msg.address = (regno - LR0_REGNUM);
- }
- else if (regno >= FPE_REGNUM && regno <= EXO_REGNUM)
- {
- int val = -1;
- supply_register (160 + (regno - FPE_REGNUM), &val);
- return 0; /* Pretend Success */
- }
- else
- {
- out_msg_buf->read_req_msg.memory_space = SPECIAL_REG;
- out_msg_buf->read_req_msg.address = regnum_to_srnum (regno);
- }
-
- msg_send_serial (out_msg_buf);
-
- if (expect_msg (READ_ACK, in_msg_buf, 1))
- {
- supply_register (regno, &(in_msg_buf->read_r_ack_msg.data[0]));
- result = 0;
- }
- else
- {
- result = -1;
- }
- return result;
-}
-/*****************************************************************************/
-/* Store a single register indicated by 'regno'.
- * Returns 0/-1 on success/failure.
- */
-static int
-store_register (int regno)
-{
- int result;
-
- out_msg_buf->write_req_msg.code = WRITE_REQ;
- out_msg_buf->write_req_msg.length = 4 * 4;
- out_msg_buf->write_req_msg.byte_count = 4;
- out_msg_buf->write_r_msg.data[0] = read_register (regno);
-
- if (regno == GR1_REGNUM)
- {
- out_msg_buf->write_req_msg.memory_space = GLOBAL_REG;
- out_msg_buf->write_req_msg.address = 1;
- /* Setting GR1 changes the numbers of all the locals, so invalidate the
- * register cache. Do this *after* calling read_register, because we want
- * read_register to return the value that write_register has just stuffed
- * into the registers array, not the value of the register fetched from
- * the inferior.
- */
- registers_changed ();
- }
-#if defined(GR64_REGNUM)
- else if (regno >= GR64_REGNUM && regno < GR64_REGNUM + 32)
- {
- out_msg_buf->write_req_msg.memory_space = GLOBAL_REG;
- out_msg_buf->write_req_msg.address = (regno - GR64_REGNUM) + 64;
- }
-#endif /* GR64_REGNUM */
- else if (regno >= GR96_REGNUM && regno < GR96_REGNUM + 32)
- {
- out_msg_buf->write_req_msg.memory_space = GLOBAL_REG;
- out_msg_buf->write_req_msg.address = (regno - GR96_REGNUM) + 96;
- }
- else if (regno >= LR0_REGNUM && regno < LR0_REGNUM + 128)
- {
- out_msg_buf->write_req_msg.memory_space = LOCAL_REG;
- out_msg_buf->write_req_msg.address = (regno - LR0_REGNUM);
- }
- else if (regno >= FPE_REGNUM && regno <= EXO_REGNUM)
- {
- return 0; /* Pretend Success */
- }
- else
- /* An unprotected or protected special register */
- {
- out_msg_buf->write_req_msg.memory_space = SPECIAL_REG;
- out_msg_buf->write_req_msg.address = regnum_to_srnum (regno);
- }
-
- msg_send_serial (out_msg_buf);
-
- if (expect_msg (WRITE_ACK, in_msg_buf, 1))
- {
- result = 0;
- }
- else
- {
- result = -1;
- }
- return result;
-}
-/****************************************************************************/
-/*
- * Convert a gdb special register number to a 29000 special register number.
- */
-static int
-regnum_to_srnum (int regno)
-{
- switch (regno)
- {
- case VAB_REGNUM:
- return (0);
- case OPS_REGNUM:
- return (1);
- case CPS_REGNUM:
- return (2);
- case CFG_REGNUM:
- return (3);
- case CHA_REGNUM:
- return (4);
- case CHD_REGNUM:
- return (5);
- case CHC_REGNUM:
- return (6);
- case RBP_REGNUM:
- return (7);
- case TMC_REGNUM:
- return (8);
- case TMR_REGNUM:
- return (9);
- case NPC_REGNUM:
- return (USE_SHADOW_PC ? (20) : (10));
- case PC_REGNUM:
- return (USE_SHADOW_PC ? (21) : (11));
- case PC2_REGNUM:
- return (USE_SHADOW_PC ? (22) : (12));
- case MMU_REGNUM:
- return (13);
- case LRU_REGNUM:
- return (14);
- case IPC_REGNUM:
- return (128);
- case IPA_REGNUM:
- return (129);
- case IPB_REGNUM:
- return (130);
- case Q_REGNUM:
- return (131);
- case ALU_REGNUM:
- return (132);
- case BP_REGNUM:
- return (133);
- case FC_REGNUM:
- return (134);
- case CR_REGNUM:
- return (135);
- case FPE_REGNUM:
- return (160);
- case INTE_REGNUM:
- return (161);
- case FPS_REGNUM:
- return (162);
- case EXO_REGNUM:
- return (164);
- default:
- return (255); /* Failure ? */
- }
-}
-/****************************************************************************/
-/*
- * Initialize the target debugger (minimon only).
- */
-static void
-init_target_mm (ADDR32 tstart, ADDR32 tend, ADDR32 dstart, ADDR32 dend,
- ADDR32 entry, INT32 ms_size, INT32 rs_size, ADDR32 arg_start)
-{
- out_msg_buf->init_msg.code = INIT;
- out_msg_buf->init_msg.length = sizeof (struct init_msg_t) - 2 * sizeof (INT32);
- out_msg_buf->init_msg.text_start = tstart;
- out_msg_buf->init_msg.text_end = tend;
- out_msg_buf->init_msg.data_start = dstart;
- out_msg_buf->init_msg.data_end = dend;
- out_msg_buf->init_msg.entry_point = entry;
- out_msg_buf->init_msg.mem_stack_size = ms_size;
- out_msg_buf->init_msg.reg_stack_size = rs_size;
- out_msg_buf->init_msg.arg_start = arg_start;
- msg_send_serial (out_msg_buf);
- expect_msg (INIT_ACK, in_msg_buf, 1);
-}
-/****************************************************************************/
-/*
- * Return a pointer to a string representing the given message code.
- * Not all messages are represented here, only the ones that we expect
- * to be called with.
- */
-static char *
-msg_str (INT32 code)
-{
- static char cbuf[32];
-
- switch (code)
- {
- case BKPT_SET_ACK:
- sprintf (cbuf, "%s (%d)", "BKPT_SET_ACK", code);
- break;
- case BKPT_RM_ACK:
- sprintf (cbuf, "%s (%d)", "BKPT_RM_ACK", code);
- break;
- case INIT_ACK:
- sprintf (cbuf, "%s (%d)", "INIT_ACK", code);
- break;
- case READ_ACK:
- sprintf (cbuf, "%s (%d)", "READ_ACK", code);
- break;
- case WRITE_ACK:
- sprintf (cbuf, "%s (%d)", "WRITE_ACK", code);
- break;
- case ERROR:
- sprintf (cbuf, "%s (%d)", "ERROR", code);
- break;
- case HALT:
- sprintf (cbuf, "%s (%d)", "HALT", code);
- break;
- default:
- sprintf (cbuf, "UNKNOWN (%d)", code);
- break;
- }
- return (cbuf);
-}
-/****************************************************************************/
-/*
- * Selected (not all of them) error codes that we might get.
- */
-static char *
-error_msg_str (INT32 code)
-{
- static char cbuf[50];
-
- switch (code)
- {
- case EMFAIL:
- return ("EMFAIL: unrecoverable error");
- case EMBADADDR:
- return ("EMBADADDR: Illegal address");
- case EMBADREG:
- return ("EMBADREG: Illegal register ");
- case EMACCESS:
- return ("EMACCESS: Could not access memory");
- case EMBADMSG:
- return ("EMBADMSG: Unknown message type");
- case EMMSG2BIG:
- return ("EMMSG2BIG: Message to large");
- case EMNOSEND:
- return ("EMNOSEND: Could not send message");
- case EMNORECV:
- return ("EMNORECV: Could not recv message");
- case EMRESET:
- return ("EMRESET: Could not RESET target");
- case EMCONFIG:
- return ("EMCONFIG: Could not get target CONFIG");
- case EMSTATUS:
- return ("EMSTATUS: Could not get target STATUS");
- case EMREAD:
- return ("EMREAD: Could not READ target memory");
- case EMWRITE:
- return ("EMWRITE: Could not WRITE target memory");
- case EMBKPTSET:
- return ("EMBKPTSET: Could not set breakpoint");
- case EMBKPTRM:
- return ("EMBKPTRM: Could not remove breakpoint");
- case EMBKPTSTAT:
- return ("EMBKPTSTAT: Could not get breakpoint status");
- case EMBKPTNONE:
- return ("EMBKPTNONE: All breakpoints in use");
- case EMBKPTUSED:
- return ("EMBKPTUSED: Breakpoints already in use");
- case EMINIT:
- return ("EMINIT: Could not init target memory");
- case EMGO:
- return ("EMGO: Could not start execution");
- case EMSTEP:
- return ("EMSTEP: Could not single step");
- case EMBREAK:
- return ("EMBREAK: Could not BREAK");
- case EMCOMMERR:
- return ("EMCOMMERR: Communication error");
- default:
- sprintf (cbuf, "error number %d", code);
- break;
- } /* end switch */
-
- return (cbuf);
-}
-/****************************************************************************/
-
-/* Receive a message, placing it in MSG_BUF, and expect it to be of
- type MSGCODE. If an error occurs, a non-zero FROM_TTY indicates
- that the message should be printed.
-
- Return 0 for failure, 1 for success. */
-
-static int
-expect_msg (INT32 msgcode, union msg_t *msg_buf, int from_tty)
-{
- int retries = 0;
- while (msg_recv_serial (msg_buf) && (retries++ < MAX_RETRIES));
- if (retries >= MAX_RETRIES)
- {
- printf ("Expected msg %s, ", msg_str (msgcode));
- printf ("no message received!\n");
- return (0); /* Failure */
- }
-
- if (msg_buf->generic_msg.code != msgcode)
- {
- if (from_tty)
- {
- printf ("Expected msg %s, ", msg_str (msgcode));
- printf ("got msg %s\n", msg_str (msg_buf->generic_msg.code));
- if (msg_buf->generic_msg.code == ERROR)
- printf ("%s\n", error_msg_str (msg_buf->error_msg.error_code));
- }
- return (0); /* Failure */
- }
- return (1); /* Success */
-}
-/****************************************************************************/
-/*
- * Determine the MiniMon memory space qualifier based on the addr.
- * FIXME: Can't distinguis I_ROM/D_ROM.
- * FIXME: Doesn't know anything about I_CACHE/D_CACHE.
- */
-static int
-mm_memory_space (CORE_ADDR *addr)
-{
- ADDR32 tstart = target_config.I_mem_start;
- ADDR32 tend = tstart + target_config.I_mem_size;
- ADDR32 dstart = target_config.D_mem_start;
- ADDR32 dend = tstart + target_config.D_mem_size;
- ADDR32 rstart = target_config.ROM_start;
- ADDR32 rend = tstart + target_config.ROM_size;
-
- if (((ADDR32) addr >= tstart) && ((ADDR32) addr < tend))
- {
- return I_MEM;
- }
- else if (((ADDR32) addr >= dstart) && ((ADDR32) addr < dend))
- {
- return D_MEM;
- }
- else if (((ADDR32) addr >= rstart) && ((ADDR32) addr < rend))
- {
- /* FIXME: how do we determine between D_ROM and I_ROM */
- return D_ROM;
- }
- else /* FIXME: what do me do now? */
- return D_MEM; /* Hmmm! */
-}
-
-/****************************************************************************/
-/*
- * Define the target subroutine names
- */
-struct target_ops mm_ops;
-
-static void
-init_mm_ops (void)
-{
- mm_ops.to_shortname = "minimon";
- mm_ops.to_longname = "Remote AMD/Minimon target";
- mm_ops.to_doc = "Remote debug an AMD 290*0 using the MiniMon dbg core on the target";
- mm_ops.to_open = mm_open;
- mm_ops.to_close = mm_close;
- mm_ops.to_attach = mm_attach;
- mm_ops.to_post_attach = NULL;
- mm_ops.to_require_attach = NULL;
- mm_ops.to_detach = mm_detach;
- mm_ops.to_require_detach = NULL;
- mm_ops.to_resume = mm_resume;
- mm_ops.to_wait = mm_wait;
- mm_ops.to_post_wait = NULL;
- mm_ops.to_fetch_registers = mm_fetch_registers;
- mm_ops.to_store_registers = mm_store_registers;
- mm_ops.to_prepare_to_store = mm_prepare_to_store;
- mm_ops.to_xfer_memory = mm_xfer_inferior_memory;
- mm_ops.to_files_info = mm_files_info;
- mm_ops.to_insert_breakpoint = mm_insert_breakpoint;
- mm_ops.to_remove_breakpoint = mm_remove_breakpoint;
- mm_ops.to_terminal_init = 0;
- mm_ops.to_terminal_inferior = 0;
- mm_ops.to_terminal_ours_for_output = 0;
- mm_ops.to_terminal_ours = 0;
- mm_ops.to_terminal_info = 0;
- mm_ops.to_kill = mm_kill;
- mm_ops.to_load = mm_load;
- mm_ops.to_lookup_symbol = 0;
- mm_ops.to_create_inferior = mm_create_inferior;
- mm_ops.to_post_startup_inferior = NULL;
- mm_ops.to_acknowledge_created_inferior = NULL;
- mm_ops.to_clone_and_follow_inferior = NULL;
- mm_ops.to_post_follow_inferior_by_clone = NULL;
- mm_ops.to_insert_fork_catchpoint = NULL;
- mm_ops.to_remove_fork_catchpoint = NULL;
- mm_ops.to_insert_vfork_catchpoint = NULL;
- mm_ops.to_remove_vfork_catchpoint = NULL;
- mm_ops.to_has_forked = NULL;
- mm_ops.to_has_vforked = NULL;
- mm_ops.to_can_follow_vfork_prior_to_exec = NULL;
- mm_ops.to_post_follow_vfork = NULL;
- mm_ops.to_insert_exec_catchpoint = NULL;
- mm_ops.to_remove_exec_catchpoint = NULL;
- mm_ops.to_has_execd = NULL;
- mm_ops.to_reported_exec_events_per_exec_call = NULL;
- mm_ops.to_has_exited = NULL;
- mm_ops.to_mourn_inferior = mm_mourn;
- mm_ops.to_can_run = 0;
- mm_ops.to_notice_signals = 0;
- mm_ops.to_thread_alive = 0;
- mm_ops.to_stop = 0;
- mm_ops.to_pid_to_exec_file = NULL;
- mm_ops.to_stratum = process_stratum;
- mm_ops.DONT_USE = 0;
- mm_ops.to_has_all_memory = 1;
- mm_ops.to_has_memory = 1;
- mm_ops.to_has_stack = 1;
- mm_ops.to_has_registers = 1;
- mm_ops.to_has_execution = 1;
- mm_ops.to_sections = 0;
- mm_ops.to_sections_end = 0;
- mm_ops.to_magic = OPS_MAGIC;
-};
-
-void
-_initialize_remote_mm (void)
-{
- init_mm_ops ();
- add_target (&mm_ops);
-}
-
-#ifdef NO_HIF_SUPPORT
-service_HIF (union msg_t *msg)
-{
- return (0); /* Emulate a failure */
-}
-#endif
+/* OBSOLETE /* Remote debugging interface for Am290*0 running MiniMON monitor, for GDB. */
+/* OBSOLETE Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, */
+/* OBSOLETE 2001 Free Software Foundation, Inc. */
+/* OBSOLETE Originally written by Daniel Mann at AMD. */
+/* OBSOLETE */
+/* OBSOLETE This file is part of GDB. */
+/* OBSOLETE */
+/* OBSOLETE This program is free software; you can redistribute it and/or modify */
+/* OBSOLETE it under the terms of the GNU General Public License as published by */
+/* OBSOLETE the Free Software Foundation; either version 2 of the License, or */
+/* OBSOLETE (at your option) any later version. */
+/* OBSOLETE */
+/* OBSOLETE This program is distributed in the hope that it will be useful, */
+/* OBSOLETE but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* OBSOLETE MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* OBSOLETE GNU General Public License for more details. */
+/* OBSOLETE */
+/* OBSOLETE You should have received a copy of the GNU General Public License */
+/* OBSOLETE along with this program; if not, write to the Free Software */
+/* OBSOLETE Foundation, Inc., 59 Temple Place - Suite 330, */
+/* OBSOLETE Boston, MA 02111-1307, USA. */ */
+/* OBSOLETE */
+/* OBSOLETE /* This is like remote.c but ecpects MiniMON to be running on the Am29000 */
+/* OBSOLETE target hardware. */
+/* OBSOLETE - David Wood (wood@lab.ultra.nyu.edu) at New York University adapted this */
+/* OBSOLETE file to gdb 3.95. I was unable to get this working on sun3os4 */
+/* OBSOLETE with termio, only with sgtty. Because we are only attempting to */
+/* OBSOLETE use this module to debug our kernel, which is already loaded when */
+/* OBSOLETE gdb is started up, I did not code up the file downloading facilities. */
+/* OBSOLETE As a result this module has only the stubs to download files. */
+/* OBSOLETE You should get tagged at compile time if you need to make any */
+/* OBSOLETE changes/additions. */ */
+/* OBSOLETE */
+/* OBSOLETE #include "defs.h" */
+/* OBSOLETE #include "inferior.h" */
+/* OBSOLETE #include "value.h" */
+/* OBSOLETE #include <ctype.h> */
+/* OBSOLETE #include <fcntl.h> */
+/* OBSOLETE #include <signal.h> */
+/* OBSOLETE #include <errno.h> */
+/* OBSOLETE #include "gdb_string.h" */
+/* OBSOLETE #include "terminal.h" */
+/* OBSOLETE #include "minimon.h" */
+/* OBSOLETE #include "target.h" */
+/* OBSOLETE #include "regcache.h" */
+/* OBSOLETE */
+/* OBSOLETE /* Offset of member MEMBER in a struct of type TYPE. */ */
+/* OBSOLETE #define offsetof(TYPE, MEMBER) ((int) &((TYPE *)0)->MEMBER) */
+/* OBSOLETE */
+/* OBSOLETE #define DRAIN_INPUT() (msg_recv_serial((union msg_t*)0)) */
+/* OBSOLETE */
+/* OBSOLETE extern int stop_soon_quietly; /* for wait_for_inferior */ */
+/* OBSOLETE */
+/* OBSOLETE static void mm_resume (ptid_t ptid, int step, enum target_signal sig) */
+/* OBSOLETE static void mm_fetch_registers (); */
+/* OBSOLETE static int fetch_register (); */
+/* OBSOLETE static void mm_store_registers (); */
+/* OBSOLETE static int store_register (); */
+/* OBSOLETE static int regnum_to_srnum (); */
+/* OBSOLETE static void mm_close (); */
+/* OBSOLETE static char *msg_str (); */
+/* OBSOLETE static char *error_msg_str (); */
+/* OBSOLETE static int expect_msg (); */
+/* OBSOLETE static void init_target_mm (); */
+/* OBSOLETE static int mm_memory_space (); */
+/* OBSOLETE */
+/* OBSOLETE #define FREEZE_MODE (read_register(CPS_REGNUM) && 0x400) */
+/* OBSOLETE #define USE_SHADOW_PC ((processor_type == a29k_freeze_mode) && FREEZE_MODE) */
+/* OBSOLETE */
+/* OBSOLETE /* FIXME: Replace with `set remotedebug'. */ */
+/* OBSOLETE #define LLOG_FILE "minimon.log" */
+/* OBSOLETE #if defined (LOG_FILE) */
+/* OBSOLETE FILE *log_file; */
+/* OBSOLETE #endif */
+/* OBSOLETE */
+/* OBSOLETE /* */
+/* OBSOLETE * Size of message buffers. I couldn't get memory reads to work when */
+/* OBSOLETE * the byte_count was larger than 512 (it may be a baud rate problem). */
+/* OBSOLETE */ */
+/* OBSOLETE #define BUFER_SIZE 512 */
+/* OBSOLETE /* */
+/* OBSOLETE * Size of data area in message buffer on the TARGET (remote system). */
+/* OBSOLETE */ */
+/* OBSOLETE #define MAXDATA_T (target_config.max_msg_size - \ */
+/* OBSOLETE offsetof(struct write_r_msg_t,data[0])) */
+/* OBSOLETE /* */
+/* OBSOLETE * Size of data area in message buffer on the HOST (gdb). */
+/* OBSOLETE */ */
+/* OBSOLETE #define MAXDATA_H (BUFER_SIZE - offsetof(struct write_r_msg_t,data[0])) */
+/* OBSOLETE /* */
+/* OBSOLETE * Defined as the minimum size of data areas of the two message buffers */
+/* OBSOLETE */ */
+/* OBSOLETE #define MAXDATA (MAXDATA_H < MAXDATA_T ? MAXDATA_H : MAXDATA_T) */
+/* OBSOLETE */
+/* OBSOLETE static char out_buf[BUFER_SIZE]; */
+/* OBSOLETE static char in_buf[BUFER_SIZE]; */
+/* OBSOLETE */
+/* OBSOLETE int msg_recv_serial (); */
+/* OBSOLETE int msg_send_serial (); */
+/* OBSOLETE */
+/* OBSOLETE #define MAX_RETRIES 5000 */
+/* OBSOLETE extern struct target_ops mm_ops; /* Forward declaration */ */
+/* OBSOLETE struct config_msg_t target_config; /* HIF needs this */ */
+/* OBSOLETE union msg_t *out_msg_buf = (union msg_t *) out_buf; */
+/* OBSOLETE union msg_t *in_msg_buf = (union msg_t *) in_buf; */
+/* OBSOLETE */
+/* OBSOLETE static int timeout = 5; */
+/* OBSOLETE */
+/* OBSOLETE /* Descriptor for I/O to remote machine. Initialize it to -1 so that */
+/* OBSOLETE mm_open knows that we don't have a file open when the program */
+/* OBSOLETE starts. */ */
+/* OBSOLETE int mm_desc = -1; */
+/* OBSOLETE */
+/* OBSOLETE /* stream which is fdopen'd from mm_desc. Only valid when */
+/* OBSOLETE mm_desc != -1. */ */
+/* OBSOLETE FILE *mm_stream; */
+/* OBSOLETE */
+/* OBSOLETE /* Called when SIGALRM signal sent due to alarm() timeout. */ */
+/* OBSOLETE #ifndef HAVE_TERMIO */
+/* OBSOLETE */
+/* OBSOLETE volatile int n_alarms; */
+/* OBSOLETE */
+/* OBSOLETE static void */
+/* OBSOLETE mm_timer (void) */
+/* OBSOLETE { */
+/* OBSOLETE #if 0 */
+/* OBSOLETE if (kiodebug) */
+/* OBSOLETE printf ("mm_timer called\n"); */
+/* OBSOLETE #endif */
+/* OBSOLETE n_alarms++; */
+/* OBSOLETE } */
+/* OBSOLETE #endif /* HAVE_TERMIO */ */
+/* OBSOLETE */
+/* OBSOLETE /* malloc'd name of the program on the remote system. */ */
+/* OBSOLETE static char *prog_name = NULL; */
+/* OBSOLETE */
+/* OBSOLETE */
+/* OBSOLETE /* Number of SIGTRAPs we need to simulate. That is, the next */
+/* OBSOLETE NEED_ARTIFICIAL_TRAP calls to mm_wait should just return */
+/* OBSOLETE SIGTRAP without actually waiting for anything. */ */
+/* OBSOLETE */
+/* OBSOLETE /**************************************************** REMOTE_CREATE_INFERIOR */ */
+/* OBSOLETE /* This is called not only when we first attach, but also when the */
+/* OBSOLETE user types "run" after having attached. */ */
+/* OBSOLETE static void */
+/* OBSOLETE mm_create_inferior (char *execfile, char *args, char **env) */
+/* OBSOLETE { */
+/* OBSOLETE #define MAX_TOKENS 25 */
+/* OBSOLETE #define BUFFER_SIZE 256 */
+/* OBSOLETE int token_count; */
+/* OBSOLETE int result; */
+/* OBSOLETE char *token[MAX_TOKENS]; */
+/* OBSOLETE char cmd_line[BUFFER_SIZE]; */
+/* OBSOLETE */
+/* OBSOLETE if (args && *args) */
+/* OBSOLETE error ("Can't pass arguments to remote mm process (yet)."); */
+/* OBSOLETE */
+/* OBSOLETE if (execfile == 0 /* || exec_bfd == 0 */ ) */
+/* OBSOLETE error ("No executable file specified"); */
+/* OBSOLETE */
+/* OBSOLETE if (!mm_stream) */
+/* OBSOLETE { */
+/* OBSOLETE printf ("Minimon not open yet.\n"); */
+/* OBSOLETE return; */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* On ultra3 (NYU) we assume the kernel is already running so there is */
+/* OBSOLETE no file to download. */
+/* OBSOLETE FIXME: Fixed required here -> load your program, possibly with mm_load(). */
+/* OBSOLETE */ */
+/* OBSOLETE printf_filtered ("\n\ */
+/* OBSOLETE Assuming you are at NYU debuging a kernel, i.e., no need to download.\n\n"); */
+/* OBSOLETE */
+/* OBSOLETE /* We will get a task spawn event immediately. */ */
+/* OBSOLETE init_wait_for_inferior (); */
+/* OBSOLETE clear_proceed_status (); */
+/* OBSOLETE stop_soon_quietly = 1; */
+/* OBSOLETE proceed (-1, TARGET_SIGNAL_DEFAULT, 0); */
+/* OBSOLETE normal_stop (); */
+/* OBSOLETE } */
+/* OBSOLETE /**************************************************** REMOTE_MOURN_INFERIOR */ */
+/* OBSOLETE static void */
+/* OBSOLETE mm_mourn (void) */
+/* OBSOLETE { */
+/* OBSOLETE pop_target (); /* Pop back to no-child state */ */
+/* OBSOLETE generic_mourn_inferior (); */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /********************************************************************** damn_b */
+/* OBSOLETE */ */
+/* OBSOLETE /* Translate baud rates from integers to damn B_codes. Unix should */
+/* OBSOLETE have outgrown this crap years ago, but even POSIX wouldn't buck it. */ */
+/* OBSOLETE */
+/* OBSOLETE #ifndef B19200 */
+/* OBSOLETE #define B19200 EXTA */
+/* OBSOLETE #endif */
+/* OBSOLETE #ifndef B38400 */
+/* OBSOLETE #define B38400 EXTB */
+/* OBSOLETE #endif */
+/* OBSOLETE */
+/* OBSOLETE static struct */
+/* OBSOLETE { */
+/* OBSOLETE int rate, damn_b; */
+/* OBSOLETE } */
+/* OBSOLETE baudtab[] = */
+/* OBSOLETE { */
+/* OBSOLETE { */
+/* OBSOLETE 0, B0 */
+/* OBSOLETE } */
+/* OBSOLETE , */
+/* OBSOLETE { */
+/* OBSOLETE 50, B50 */
+/* OBSOLETE } */
+/* OBSOLETE , */
+/* OBSOLETE { */
+/* OBSOLETE 75, B75 */
+/* OBSOLETE } */
+/* OBSOLETE , */
+/* OBSOLETE { */
+/* OBSOLETE 110, B110 */
+/* OBSOLETE } */
+/* OBSOLETE , */
+/* OBSOLETE { */
+/* OBSOLETE 134, B134 */
+/* OBSOLETE } */
+/* OBSOLETE , */
+/* OBSOLETE { */
+/* OBSOLETE 150, B150 */
+/* OBSOLETE } */
+/* OBSOLETE , */
+/* OBSOLETE { */
+/* OBSOLETE 200, B200 */
+/* OBSOLETE } */
+/* OBSOLETE , */
+/* OBSOLETE { */
+/* OBSOLETE 300, B300 */
+/* OBSOLETE } */
+/* OBSOLETE , */
+/* OBSOLETE { */
+/* OBSOLETE 600, B600 */
+/* OBSOLETE } */
+/* OBSOLETE , */
+/* OBSOLETE { */
+/* OBSOLETE 1200, B1200 */
+/* OBSOLETE } */
+/* OBSOLETE , */
+/* OBSOLETE { */
+/* OBSOLETE 1800, B1800 */
+/* OBSOLETE } */
+/* OBSOLETE , */
+/* OBSOLETE { */
+/* OBSOLETE 2400, B2400 */
+/* OBSOLETE } */
+/* OBSOLETE , */
+/* OBSOLETE { */
+/* OBSOLETE 4800, B4800 */
+/* OBSOLETE } */
+/* OBSOLETE , */
+/* OBSOLETE { */
+/* OBSOLETE 9600, B9600 */
+/* OBSOLETE } */
+/* OBSOLETE , */
+/* OBSOLETE { */
+/* OBSOLETE 19200, B19200 */
+/* OBSOLETE } */
+/* OBSOLETE , */
+/* OBSOLETE { */
+/* OBSOLETE 38400, B38400 */
+/* OBSOLETE } */
+/* OBSOLETE , */
+/* OBSOLETE { */
+/* OBSOLETE -1, -1 */
+/* OBSOLETE } */
+/* OBSOLETE , */
+/* OBSOLETE }; */
+/* OBSOLETE */
+/* OBSOLETE static int */
+/* OBSOLETE damn_b (int rate) */
+/* OBSOLETE { */
+/* OBSOLETE int i; */
+/* OBSOLETE */
+/* OBSOLETE for (i = 0; baudtab[i].rate != -1; i++) */
+/* OBSOLETE if (rate == baudtab[i].rate) */
+/* OBSOLETE return baudtab[i].damn_b; */
+/* OBSOLETE return B38400; /* Random */ */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE */
+/* OBSOLETE /***************************************************************** REMOTE_OPEN */
+/* OBSOLETE ** Open a connection to remote minimon. */
+/* OBSOLETE NAME is the filename used for communication, then a space, */
+/* OBSOLETE then the baud rate. */
+/* OBSOLETE 'target adapt /dev/ttya 9600 [prognam]' for example. */
+/* OBSOLETE */ */
+/* OBSOLETE */
+/* OBSOLETE static char *dev_name; */
+/* OBSOLETE int baudrate = 9600; */
+/* OBSOLETE static void */
+/* OBSOLETE mm_open (char *name, int from_tty) */
+/* OBSOLETE { */
+/* OBSOLETE TERMINAL sg; */
+/* OBSOLETE unsigned int prl; */
+/* OBSOLETE char *p; */
+/* OBSOLETE */
+/* OBSOLETE /* Find the first whitespace character, it separates dev_name from */
+/* OBSOLETE prog_name. */ */
+/* OBSOLETE for (p = name; */
+/* OBSOLETE p && *p && !isspace (*p); p++) */
+/* OBSOLETE ; */
+/* OBSOLETE if (p == 0 || *p == '\0') */
+/* OBSOLETE erroid: */
+/* OBSOLETE error ("Usage : <command> <serial-device> <baud-rate> [progname]"); */
+/* OBSOLETE dev_name = (char *) xmalloc (p - name + 1); */
+/* OBSOLETE strncpy (dev_name, name, p - name); */
+/* OBSOLETE dev_name[p - name] = '\0'; */
+/* OBSOLETE */
+/* OBSOLETE /* Skip over the whitespace after dev_name */ */
+/* OBSOLETE for (; isspace (*p); p++) */
+/* OBSOLETE /*EMPTY */ ; */
+/* OBSOLETE */
+/* OBSOLETE if (1 != sscanf (p, "%d ", &baudrate)) */
+/* OBSOLETE goto erroid; */
+/* OBSOLETE */
+/* OBSOLETE /* Skip the number and then the spaces */ */
+/* OBSOLETE for (; isdigit (*p); p++) */
+/* OBSOLETE /*EMPTY */ ; */
+/* OBSOLETE for (; isspace (*p); p++) */
+/* OBSOLETE /*EMPTY */ ; */
+/* OBSOLETE */
+/* OBSOLETE if (prog_name != NULL) */
+/* OBSOLETE xfree (prog_name); */
+/* OBSOLETE prog_name = savestring (p, strlen (p)); */
+/* OBSOLETE */
+/* OBSOLETE */
+/* OBSOLETE if (mm_desc >= 0) */
+/* OBSOLETE close (mm_desc); */
+/* OBSOLETE */
+/* OBSOLETE mm_desc = open (dev_name, O_RDWR); */
+/* OBSOLETE if (mm_desc < 0) */
+/* OBSOLETE perror_with_name (dev_name); */
+/* OBSOLETE ioctl (mm_desc, TIOCGETP, &sg); */
+/* OBSOLETE #ifdef HAVE_TERMIO */
+/* OBSOLETE sg.c_cc[VMIN] = 0; /* read with timeout. */ */
+/* OBSOLETE sg.c_cc[VTIME] = timeout * 10; */
+/* OBSOLETE sg.c_lflag &= ~(ICANON | ECHO); */
+/* OBSOLETE sg.c_cflag = (sg.c_cflag & ~CBAUD) | damn_b (baudrate); */
+/* OBSOLETE #else */
+/* OBSOLETE sg.sg_ispeed = damn_b (baudrate); */
+/* OBSOLETE sg.sg_ospeed = damn_b (baudrate); */
+/* OBSOLETE sg.sg_flags |= RAW; */
+/* OBSOLETE sg.sg_flags |= ANYP; */
+/* OBSOLETE sg.sg_flags &= ~ECHO; */
+/* OBSOLETE #endif */
+/* OBSOLETE */
+/* OBSOLETE */
+/* OBSOLETE ioctl (mm_desc, TIOCSETP, &sg); */
+/* OBSOLETE mm_stream = fdopen (mm_desc, "r+"); */
+/* OBSOLETE */
+/* OBSOLETE push_target (&mm_ops); */
+/* OBSOLETE */
+/* OBSOLETE #ifndef HAVE_TERMIO */
+/* OBSOLETE #ifndef NO_SIGINTERRUPT */
+/* OBSOLETE /* Cause SIGALRM's to make reads fail with EINTR instead of resuming */
+/* OBSOLETE the read. */ */
+/* OBSOLETE if (siginterrupt (SIGALRM, 1) != 0) */
+/* OBSOLETE perror ("mm_open: error in siginterrupt"); */
+/* OBSOLETE #endif */
+/* OBSOLETE */
+/* OBSOLETE /* Set up read timeout timer. */ */
+/* OBSOLETE if ((void (*)) signal (SIGALRM, mm_timer) == (void (*)) -1) */
+/* OBSOLETE perror ("mm_open: error in signal"); */
+/* OBSOLETE #endif */
+/* OBSOLETE */
+/* OBSOLETE #if defined (LOG_FILE) */
+/* OBSOLETE log_file = fopen (LOG_FILE, "w"); */
+/* OBSOLETE if (log_file == NULL) */
+/* OBSOLETE perror_with_name (LOG_FILE); */
+/* OBSOLETE #endif */
+/* OBSOLETE /* */
+/* OBSOLETE ** Initialize target configuration structure (global) */
+/* OBSOLETE */ */
+/* OBSOLETE DRAIN_INPUT (); */
+/* OBSOLETE out_msg_buf->config_req_msg.code = CONFIG_REQ; */
+/* OBSOLETE out_msg_buf->config_req_msg.length = 4 * 0; */
+/* OBSOLETE msg_send_serial (out_msg_buf); /* send config request message */ */
+/* OBSOLETE */
+/* OBSOLETE expect_msg (CONFIG, in_msg_buf, 1); */
+/* OBSOLETE */
+/* OBSOLETE a29k_get_processor_type (); */
+/* OBSOLETE */
+/* OBSOLETE /* Print out some stuff, letting the user now what's going on */ */
+/* OBSOLETE printf_filtered ("Connected to MiniMon via %s.\n", dev_name); */
+/* OBSOLETE /* FIXME: can this restriction be removed? */ */
+/* OBSOLETE printf_filtered ("Remote debugging using virtual addresses works only\n"); */
+/* OBSOLETE printf_filtered ("\twhen virtual addresses map 1:1 to physical addresses.\n") */
+/* OBSOLETE ; */
+/* OBSOLETE if (processor_type != a29k_freeze_mode) */
+/* OBSOLETE { */
+/* OBSOLETE fprintf_filtered (gdb_stderr, */
+/* OBSOLETE "Freeze-mode debugging not available, and can only be done on an A29050.\n"); */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE target_config.code = CONFIG; */
+/* OBSOLETE target_config.length = 0; */
+/* OBSOLETE target_config.processor_id = in_msg_buf->config_msg.processor_id; */
+/* OBSOLETE target_config.version = in_msg_buf->config_msg.version; */
+/* OBSOLETE target_config.I_mem_start = in_msg_buf->config_msg.I_mem_start; */
+/* OBSOLETE target_config.I_mem_size = in_msg_buf->config_msg.I_mem_size; */
+/* OBSOLETE target_config.D_mem_start = in_msg_buf->config_msg.D_mem_start; */
+/* OBSOLETE target_config.D_mem_size = in_msg_buf->config_msg.D_mem_size; */
+/* OBSOLETE target_config.ROM_start = in_msg_buf->config_msg.ROM_start; */
+/* OBSOLETE target_config.ROM_size = in_msg_buf->config_msg.ROM_size; */
+/* OBSOLETE target_config.max_msg_size = in_msg_buf->config_msg.max_msg_size; */
+/* OBSOLETE target_config.max_bkpts = in_msg_buf->config_msg.max_bkpts; */
+/* OBSOLETE target_config.coprocessor = in_msg_buf->config_msg.coprocessor; */
+/* OBSOLETE target_config.reserved = in_msg_buf->config_msg.reserved; */
+/* OBSOLETE if (from_tty) */
+/* OBSOLETE { */
+/* OBSOLETE printf ("Connected to MiniMON :\n"); */
+/* OBSOLETE printf (" Debugcore version %d.%d\n", */
+/* OBSOLETE 0x0f & (target_config.version >> 4), */
+/* OBSOLETE 0x0f & (target_config.version)); */
+/* OBSOLETE printf (" Configuration version %d.%d\n", */
+/* OBSOLETE 0x0f & (target_config.version >> 12), */
+/* OBSOLETE 0x0f & (target_config.version >> 8)); */
+/* OBSOLETE printf (" Message system version %d.%d\n", */
+/* OBSOLETE 0x0f & (target_config.version >> 20), */
+/* OBSOLETE 0x0f & (target_config.version >> 16)); */
+/* OBSOLETE printf (" Communication driver version %d.%d\n", */
+/* OBSOLETE 0x0f & (target_config.version >> 28), */
+/* OBSOLETE 0x0f & (target_config.version >> 24)); */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* Leave the target running... */
+/* OBSOLETE * The above message stopped the target in the dbg core (MiniMon), */
+/* OBSOLETE * so restart the target out of MiniMon, */
+/* OBSOLETE */ */
+/* OBSOLETE out_msg_buf->go_msg.code = GO; */
+/* OBSOLETE out_msg_buf->go_msg.length = 0; */
+/* OBSOLETE msg_send_serial (out_msg_buf); */
+/* OBSOLETE /* No message to expect after a GO */ */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /**************************************************************** REMOTE_CLOSE */
+/* OBSOLETE ** Close the open connection to the minimon debugger. */
+/* OBSOLETE Use this when you want to detach and do something else */
+/* OBSOLETE with your gdb. */ */
+/* OBSOLETE static void */
+/* OBSOLETE mm_close ( /*FIXME: how is quitting used */ */
+/* OBSOLETE int quitting) */
+/* OBSOLETE { */
+/* OBSOLETE if (mm_desc < 0) */
+/* OBSOLETE error ("Can't close remote connection: not debugging remotely."); */
+/* OBSOLETE */
+/* OBSOLETE /* We should never get here if there isn't something valid in */
+/* OBSOLETE mm_desc and mm_stream. */
+/* OBSOLETE */
+/* OBSOLETE Due to a bug in Unix, fclose closes not only the stdio stream, */
+/* OBSOLETE but also the file descriptor. So we don't actually close */
+/* OBSOLETE mm_desc. */ */
+/* OBSOLETE DRAIN_INPUT (); */
+/* OBSOLETE fclose (mm_stream); */
+/* OBSOLETE /* close (mm_desc); */ */
+/* OBSOLETE */
+/* OBSOLETE /* Do not try to close mm_desc again, later in the program. */ */
+/* OBSOLETE mm_stream = NULL; */
+/* OBSOLETE mm_desc = -1; */
+/* OBSOLETE */
+/* OBSOLETE #if defined (LOG_FILE) */
+/* OBSOLETE if (ferror (log_file)) */
+/* OBSOLETE printf ("Error writing log file.\n"); */
+/* OBSOLETE if (fclose (log_file) != 0) */
+/* OBSOLETE printf ("Error closing log file.\n"); */
+/* OBSOLETE #endif */
+/* OBSOLETE */
+/* OBSOLETE printf ("Ending remote debugging\n"); */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /************************************************************* REMOTE_ATACH */ */
+/* OBSOLETE /* Attach to a program that is already loaded and running */
+/* OBSOLETE * Upon exiting the process's execution is stopped. */
+/* OBSOLETE */ */
+/* OBSOLETE static void */
+/* OBSOLETE mm_attach (char *args, int from_tty) */
+/* OBSOLETE { */
+/* OBSOLETE */
+/* OBSOLETE if (!mm_stream) */
+/* OBSOLETE error ("MiniMon not opened yet, use the 'target minimon' command.\n"); */
+/* OBSOLETE */
+/* OBSOLETE if (from_tty) */
+/* OBSOLETE printf ("Attaching to remote program %s...\n", prog_name); */
+/* OBSOLETE */
+/* OBSOLETE /* Make sure the target is currently running, it is supposed to be. */ */
+/* OBSOLETE /* FIXME: is it ok to send MiniMon a BREAK if it is already stopped in */
+/* OBSOLETE * the dbg core. If so, we don't need to send this GO. */
+/* OBSOLETE */ */
+/* OBSOLETE out_msg_buf->go_msg.code = GO; */
+/* OBSOLETE out_msg_buf->go_msg.length = 0; */
+/* OBSOLETE msg_send_serial (out_msg_buf); */
+/* OBSOLETE sleep (2); /* At the worst it will stop, receive a message, continue */ */
+/* OBSOLETE */
+/* OBSOLETE /* Send the mm a break. */ */
+/* OBSOLETE out_msg_buf->break_msg.code = BREAK; */
+/* OBSOLETE out_msg_buf->break_msg.length = 0; */
+/* OBSOLETE msg_send_serial (out_msg_buf); */
+/* OBSOLETE } */
+/* OBSOLETE /********************************************************** REMOTE_DETACH */ */
+/* OBSOLETE /* Terminate the open connection to the remote debugger. */
+/* OBSOLETE Use this when you want to detach and do something else */
+/* OBSOLETE with your gdb. Leave remote process running (with no breakpoints set). */ */
+/* OBSOLETE static void */
+/* OBSOLETE mm_detach (char *args, int from_tty) */
+/* OBSOLETE { */
+/* OBSOLETE remove_breakpoints (); /* Just in case there were any left in */ */
+/* OBSOLETE out_msg_buf->go_msg.code = GO; */
+/* OBSOLETE out_msg_buf->go_msg.length = 0; */
+/* OBSOLETE msg_send_serial (out_msg_buf); */
+/* OBSOLETE pop_target (); /* calls mm_close to do the real work */ */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE */
+/* OBSOLETE /*************************************************************** REMOTE_RESUME */
+/* OBSOLETE ** Tell the remote machine to resume. */ */
+/* OBSOLETE */
+/* OBSOLETE static void */
+/* OBSOLETE mm_resume (ptid_t ptid, int step, enum target_signal sig) */
+/* OBSOLETE { */
+/* OBSOLETE if (sig != TARGET_SIGNAL_0) */
+/* OBSOLETE warning ("Can't send signals to a remote MiniMon system."); */
+/* OBSOLETE */
+/* OBSOLETE if (step) */
+/* OBSOLETE { */
+/* OBSOLETE out_msg_buf->step_msg.code = STEP; */
+/* OBSOLETE out_msg_buf->step_msg.length = 1 * 4; */
+/* OBSOLETE out_msg_buf->step_msg.count = 1; /* step 1 instruction */ */
+/* OBSOLETE msg_send_serial (out_msg_buf); */
+/* OBSOLETE } */
+/* OBSOLETE else */
+/* OBSOLETE { */
+/* OBSOLETE out_msg_buf->go_msg.code = GO; */
+/* OBSOLETE out_msg_buf->go_msg.length = 0; */
+/* OBSOLETE msg_send_serial (out_msg_buf); */
+/* OBSOLETE } */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /***************************************************************** REMOTE_WAIT */
+/* OBSOLETE ** Wait until the remote machine stops, then return, */
+/* OBSOLETE storing status in STATUS just as `wait' would. */ */
+/* OBSOLETE */
+/* OBSOLETE static ptid_t */
+/* OBSOLETE mm_wait (ptid_t ptid, struct target_waitstatus *status) */
+/* OBSOLETE { */
+/* OBSOLETE int i, result; */
+/* OBSOLETE int old_timeout = timeout; */
+/* OBSOLETE int old_immediate_quit = immediate_quit; */
+/* OBSOLETE */
+/* OBSOLETE status->kind = TARGET_WAITKIND_EXITED; */
+/* OBSOLETE status->value.integer = 0; */
+/* OBSOLETE */
+/* OBSOLETE /* wait for message to arrive. It should be: */
+/* OBSOLETE - A HIF service request. */
+/* OBSOLETE - A HIF exit service request. */
+/* OBSOLETE - A CHANNEL0_ACK. */
+/* OBSOLETE - A CHANNEL1 request. */
+/* OBSOLETE - a debugcore HALT message. */
+/* OBSOLETE HIF services must be responded too, and while-looping continued. */
+/* OBSOLETE If the target stops executing, mm_wait() should return. */
+/* OBSOLETE */ */
+/* OBSOLETE timeout = 0; /* Wait indefinetly for a message */ */
+/* OBSOLETE immediate_quit = 1; /* Helps ability to QUIT */ */
+/* OBSOLETE while (1) */
+/* OBSOLETE { */
+/* OBSOLETE while (msg_recv_serial (in_msg_buf)) */
+/* OBSOLETE { */
+/* OBSOLETE QUIT; /* Let user quit if they want */ */
+/* OBSOLETE } */
+/* OBSOLETE switch (in_msg_buf->halt_msg.code) */
+/* OBSOLETE { */
+/* OBSOLETE case HIF_CALL: */
+/* OBSOLETE i = in_msg_buf->hif_call_rtn_msg.service_number; */
+/* OBSOLETE result = service_HIF (in_msg_buf); */
+/* OBSOLETE if (i == 1) /* EXIT */ */
+/* OBSOLETE goto exit; */
+/* OBSOLETE if (result) */
+/* OBSOLETE printf ("Warning: failure during HIF service %d\n", i); */
+/* OBSOLETE break; */
+/* OBSOLETE case CHANNEL0_ACK: */
+/* OBSOLETE service_HIF (in_msg_buf); */
+/* OBSOLETE break; */
+/* OBSOLETE case CHANNEL1: */
+/* OBSOLETE i = in_msg_buf->channel1_msg.length; */
+/* OBSOLETE in_msg_buf->channel1_msg.data[i] = '\0'; */
+/* OBSOLETE printf ("%s", in_msg_buf->channel1_msg.data); */
+/* OBSOLETE gdb_flush (gdb_stdout); */
+/* OBSOLETE /* Send CHANNEL1_ACK message */ */
+/* OBSOLETE out_msg_buf->channel1_ack_msg.code = CHANNEL1_ACK; */
+/* OBSOLETE out_msg_buf->channel1_ack_msg.length = 0; */
+/* OBSOLETE result = msg_send_serial (out_msg_buf); */
+/* OBSOLETE break; */
+/* OBSOLETE case HALT: */
+/* OBSOLETE goto halted; */
+/* OBSOLETE default: */
+/* OBSOLETE goto halted; */
+/* OBSOLETE } */
+/* OBSOLETE } */
+/* OBSOLETE halted: */
+/* OBSOLETE /* FIXME, these printfs should not be here. This is a source level */
+/* OBSOLETE debugger, guys! */ */
+/* OBSOLETE if (in_msg_buf->halt_msg.trap_number == 0) */
+/* OBSOLETE { */
+/* OBSOLETE printf ("Am290*0 received vector number %d (break point)\n", */
+/* OBSOLETE in_msg_buf->halt_msg.trap_number); */
+/* OBSOLETE status->kind = TARGET_WAITKIND_STOPPED; */
+/* OBSOLETE status->value.sig = TARGET_SIGNAL_TRAP; */
+/* OBSOLETE } */
+/* OBSOLETE else if (in_msg_buf->halt_msg.trap_number == 1) */
+/* OBSOLETE { */
+/* OBSOLETE printf ("Am290*0 received vector number %d\n", */
+/* OBSOLETE in_msg_buf->halt_msg.trap_number); */
+/* OBSOLETE status->kind = TARGET_WAITKIND_STOPPED; */
+/* OBSOLETE status->value.sig = TARGET_SIGNAL_BUS; */
+/* OBSOLETE } */
+/* OBSOLETE else if (in_msg_buf->halt_msg.trap_number == 3 */
+/* OBSOLETE || in_msg_buf->halt_msg.trap_number == 4) */
+/* OBSOLETE { */
+/* OBSOLETE printf ("Am290*0 received vector number %d\n", */
+/* OBSOLETE in_msg_buf->halt_msg.trap_number); */
+/* OBSOLETE status->kind = TARGET_WAITKIND_STOPPED; */
+/* OBSOLETE status->value.sig = TARGET_SIGNAL_FPE; */
+/* OBSOLETE } */
+/* OBSOLETE else if (in_msg_buf->halt_msg.trap_number == 5) */
+/* OBSOLETE { */
+/* OBSOLETE printf ("Am290*0 received vector number %d\n", */
+/* OBSOLETE in_msg_buf->halt_msg.trap_number); */
+/* OBSOLETE status->kind = TARGET_WAITKIND_STOPPED; */
+/* OBSOLETE status->value.sig = TARGET_SIGNAL_ILL; */
+/* OBSOLETE } */
+/* OBSOLETE else if (in_msg_buf->halt_msg.trap_number >= 6 */
+/* OBSOLETE && in_msg_buf->halt_msg.trap_number <= 11) */
+/* OBSOLETE { */
+/* OBSOLETE printf ("Am290*0 received vector number %d\n", */
+/* OBSOLETE in_msg_buf->halt_msg.trap_number); */
+/* OBSOLETE status->kind = TARGET_WAITKIND_STOPPED; */
+/* OBSOLETE status->value.sig = TARGET_SIGNAL_SEGV; */
+/* OBSOLETE } */
+/* OBSOLETE else if (in_msg_buf->halt_msg.trap_number == 12 */
+/* OBSOLETE || in_msg_buf->halt_msg.trap_number == 13) */
+/* OBSOLETE { */
+/* OBSOLETE printf ("Am290*0 received vector number %d\n", */
+/* OBSOLETE in_msg_buf->halt_msg.trap_number); */
+/* OBSOLETE status->kind = TARGET_WAITKIND_STOPPED; */
+/* OBSOLETE status->value.sig = TARGET_SIGNAL_ILL; */
+/* OBSOLETE } */
+/* OBSOLETE else if (in_msg_buf->halt_msg.trap_number == 14) */
+/* OBSOLETE { */
+/* OBSOLETE printf ("Am290*0 received vector number %d\n", */
+/* OBSOLETE in_msg_buf->halt_msg.trap_number); */
+/* OBSOLETE status->kind = TARGET_WAITKIND_STOPPED; */
+/* OBSOLETE status->value.sig = TARGET_SIGNAL_ALRM; */
+/* OBSOLETE } */
+/* OBSOLETE else if (in_msg_buf->halt_msg.trap_number == 15) */
+/* OBSOLETE { */
+/* OBSOLETE status->kind = TARGET_WAITKIND_STOPPED; */
+/* OBSOLETE status->value.sig = TARGET_SIGNAL_TRAP; */
+/* OBSOLETE } */
+/* OBSOLETE else if (in_msg_buf->halt_msg.trap_number >= 16 */
+/* OBSOLETE && in_msg_buf->halt_msg.trap_number <= 21) */
+/* OBSOLETE { */
+/* OBSOLETE printf ("Am290*0 received vector number %d\n", */
+/* OBSOLETE in_msg_buf->halt_msg.trap_number); */
+/* OBSOLETE status->kind = TARGET_WAITKIND_STOPPED; */
+/* OBSOLETE status->value.sig = TARGET_SIGNAL_INT; */
+/* OBSOLETE } */
+/* OBSOLETE else if (in_msg_buf->halt_msg.trap_number == 22) */
+/* OBSOLETE { */
+/* OBSOLETE printf ("Am290*0 received vector number %d\n", */
+/* OBSOLETE in_msg_buf->halt_msg.trap_number); */
+/* OBSOLETE status->kind = TARGET_WAITKIND_STOPPED; */
+/* OBSOLETE status->value.sig = TARGET_SIGNAL_ILL; */
+/* OBSOLETE } /* BREAK message was sent */ */
+/* OBSOLETE else if (in_msg_buf->halt_msg.trap_number == 75) */
+/* OBSOLETE { */
+/* OBSOLETE status->kind = TARGET_WAITKIND_STOPPED; */
+/* OBSOLETE status->value.sig = TARGET_SIGNAL_TRAP; */
+/* OBSOLETE } */
+/* OBSOLETE else */
+/* OBSOLETE exit: */
+/* OBSOLETE { */
+/* OBSOLETE status->kind = TARGET_WAITKIND_EXITED; */
+/* OBSOLETE status->value.integer = 0; */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE timeout = old_timeout; /* Restore original timeout value */ */
+/* OBSOLETE immediate_quit = old_immediate_quit; */
+/* OBSOLETE return inferior_ptid; */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /******************************************************* REMOTE_FETCH_REGISTERS */
+/* OBSOLETE * Read a remote register 'regno'. */
+/* OBSOLETE * If regno==-1 then read all the registers. */
+/* OBSOLETE */ */
+/* OBSOLETE static void */
+/* OBSOLETE mm_fetch_registers (int regno) */
+/* OBSOLETE { */
+/* OBSOLETE INT32 *data_p; */
+/* OBSOLETE */
+/* OBSOLETE if (regno >= 0) */
+/* OBSOLETE { */
+/* OBSOLETE fetch_register (regno); */
+/* OBSOLETE return; */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* Gr1/rsp */ */
+/* OBSOLETE out_msg_buf->read_req_msg.byte_count = 4 * 1; */
+/* OBSOLETE out_msg_buf->read_req_msg.memory_space = GLOBAL_REG; */
+/* OBSOLETE out_msg_buf->read_req_msg.address = 1; */
+/* OBSOLETE msg_send_serial (out_msg_buf); */
+/* OBSOLETE expect_msg (READ_ACK, in_msg_buf, 1); */
+/* OBSOLETE data_p = &(in_msg_buf->read_r_ack_msg.data[0]); */
+/* OBSOLETE supply_register (GR1_REGNUM, data_p); */
+/* OBSOLETE */
+/* OBSOLETE #if defined(GR64_REGNUM) /* Read gr64-127 */ */
+/* OBSOLETE /* Global Registers gr64-gr95 */ */
+/* OBSOLETE out_msg_buf->read_req_msg.code = READ_REQ; */
+/* OBSOLETE out_msg_buf->read_req_msg.length = 4 * 3; */
+/* OBSOLETE out_msg_buf->read_req_msg.byte_count = 4 * 32; */
+/* OBSOLETE out_msg_buf->read_req_msg.memory_space = GLOBAL_REG; */
+/* OBSOLETE out_msg_buf->read_req_msg.address = 64; */
+/* OBSOLETE msg_send_serial (out_msg_buf); */
+/* OBSOLETE expect_msg (READ_ACK, in_msg_buf, 1); */
+/* OBSOLETE data_p = &(in_msg_buf->read_r_ack_msg.data[0]); */
+/* OBSOLETE */
+/* OBSOLETE for (regno = GR64_REGNUM; regno < GR64_REGNUM + 32; regno++) */
+/* OBSOLETE { */
+/* OBSOLETE supply_register (regno, data_p++); */
+/* OBSOLETE } */
+/* OBSOLETE #endif /* GR64_REGNUM */ */
+/* OBSOLETE */
+/* OBSOLETE /* Global Registers gr96-gr127 */ */
+/* OBSOLETE out_msg_buf->read_req_msg.code = READ_REQ; */
+/* OBSOLETE out_msg_buf->read_req_msg.length = 4 * 3; */
+/* OBSOLETE out_msg_buf->read_req_msg.byte_count = 4 * 32; */
+/* OBSOLETE out_msg_buf->read_req_msg.memory_space = GLOBAL_REG; */
+/* OBSOLETE out_msg_buf->read_req_msg.address = 96; */
+/* OBSOLETE msg_send_serial (out_msg_buf); */
+/* OBSOLETE expect_msg (READ_ACK, in_msg_buf, 1); */
+/* OBSOLETE data_p = &(in_msg_buf->read_r_ack_msg.data[0]); */
+/* OBSOLETE */
+/* OBSOLETE for (regno = GR96_REGNUM; regno < GR96_REGNUM + 32; regno++) */
+/* OBSOLETE { */
+/* OBSOLETE supply_register (regno, data_p++); */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* Local Registers */ */
+/* OBSOLETE out_msg_buf->read_req_msg.byte_count = 4 * (128); */
+/* OBSOLETE out_msg_buf->read_req_msg.memory_space = LOCAL_REG; */
+/* OBSOLETE out_msg_buf->read_req_msg.address = 0; */
+/* OBSOLETE msg_send_serial (out_msg_buf); */
+/* OBSOLETE expect_msg (READ_ACK, in_msg_buf, 1); */
+/* OBSOLETE data_p = &(in_msg_buf->read_r_ack_msg.data[0]); */
+/* OBSOLETE */
+/* OBSOLETE for (regno = LR0_REGNUM; regno < LR0_REGNUM + 128; regno++) */
+/* OBSOLETE { */
+/* OBSOLETE supply_register (regno, data_p++); */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* Protected Special Registers */ */
+/* OBSOLETE out_msg_buf->read_req_msg.byte_count = 4 * 15; */
+/* OBSOLETE out_msg_buf->read_req_msg.memory_space = SPECIAL_REG; */
+/* OBSOLETE out_msg_buf->read_req_msg.address = 0; */
+/* OBSOLETE msg_send_serial (out_msg_buf); */
+/* OBSOLETE expect_msg (READ_ACK, in_msg_buf, 1); */
+/* OBSOLETE data_p = &(in_msg_buf->read_r_ack_msg.data[0]); */
+/* OBSOLETE */
+/* OBSOLETE for (regno = 0; regno <= 14; regno++) */
+/* OBSOLETE { */
+/* OBSOLETE supply_register (SR_REGNUM (regno), data_p++); */
+/* OBSOLETE } */
+/* OBSOLETE if (USE_SHADOW_PC) */
+/* OBSOLETE { /* Let regno_to_srnum() handle the register number */ */
+/* OBSOLETE fetch_register (NPC_REGNUM); */
+/* OBSOLETE fetch_register (PC_REGNUM); */
+/* OBSOLETE fetch_register (PC2_REGNUM); */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* Unprotected Special Registers */ */
+/* OBSOLETE out_msg_buf->read_req_msg.byte_count = 4 * 8; */
+/* OBSOLETE out_msg_buf->read_req_msg.memory_space = SPECIAL_REG; */
+/* OBSOLETE out_msg_buf->read_req_msg.address = 128; */
+/* OBSOLETE msg_send_serial (out_msg_buf); */
+/* OBSOLETE expect_msg (READ_ACK, in_msg_buf, 1); */
+/* OBSOLETE data_p = &(in_msg_buf->read_r_ack_msg.data[0]); */
+/* OBSOLETE */
+/* OBSOLETE for (regno = 128; regno <= 135; regno++) */
+/* OBSOLETE { */
+/* OBSOLETE supply_register (SR_REGNUM (regno), data_p++); */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* There doesn't seem to be any way to get these. */ */
+/* OBSOLETE { */
+/* OBSOLETE int val = -1; */
+/* OBSOLETE supply_register (FPE_REGNUM, &val); */
+/* OBSOLETE supply_register (INTE_REGNUM, &val); */
+/* OBSOLETE supply_register (FPS_REGNUM, &val); */
+/* OBSOLETE supply_register (EXO_REGNUM, &val); */
+/* OBSOLETE } */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE */
+/* OBSOLETE /****************************************************** REMOTE_STORE_REGISTERS */
+/* OBSOLETE * Store register regno into the target. */
+/* OBSOLETE * If regno==-1 then store all the registers. */
+/* OBSOLETE * Result is 0 for success, -1 for failure. */
+/* OBSOLETE */ */
+/* OBSOLETE */
+/* OBSOLETE static void */
+/* OBSOLETE mm_store_registers (int regno) */
+/* OBSOLETE { */
+/* OBSOLETE int result; */
+/* OBSOLETE */
+/* OBSOLETE if (regno >= 0) */
+/* OBSOLETE { */
+/* OBSOLETE store_register (regno); */
+/* OBSOLETE return; */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE result = 0; */
+/* OBSOLETE */
+/* OBSOLETE out_msg_buf->write_r_msg.code = WRITE_REQ; */
+/* OBSOLETE */
+/* OBSOLETE /* Gr1/rsp */ */
+/* OBSOLETE out_msg_buf->write_r_msg.byte_count = 4 * 1; */
+/* OBSOLETE out_msg_buf->write_r_msg.length = 3 * 4 + out_msg_buf->write_r_msg.byte_count; */
+/* OBSOLETE out_msg_buf->write_r_msg.memory_space = GLOBAL_REG; */
+/* OBSOLETE out_msg_buf->write_r_msg.address = 1; */
+/* OBSOLETE out_msg_buf->write_r_msg.data[0] = read_register (GR1_REGNUM); */
+/* OBSOLETE */
+/* OBSOLETE msg_send_serial (out_msg_buf); */
+/* OBSOLETE if (!expect_msg (WRITE_ACK, in_msg_buf, 1)) */
+/* OBSOLETE { */
+/* OBSOLETE result = -1; */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE #if defined(GR64_REGNUM) */
+/* OBSOLETE /* Global registers gr64-gr95 */ */
+/* OBSOLETE out_msg_buf->write_r_msg.byte_count = 4 * (32); */
+/* OBSOLETE out_msg_buf->write_r_msg.length = 3 * 4 + out_msg_buf->write_r_msg.byte_count; */
+/* OBSOLETE out_msg_buf->write_r_msg.address = 64; */
+/* OBSOLETE */
+/* OBSOLETE for (regno = GR64_REGNUM; regno < GR64_REGNUM + 32; regno++) */
+/* OBSOLETE { */
+/* OBSOLETE out_msg_buf->write_r_msg.data[regno - GR64_REGNUM] = read_register (regno); */
+/* OBSOLETE } */
+/* OBSOLETE msg_send_serial (out_msg_buf); */
+/* OBSOLETE if (!expect_msg (WRITE_ACK, in_msg_buf, 1)) */
+/* OBSOLETE { */
+/* OBSOLETE result = -1; */
+/* OBSOLETE } */
+/* OBSOLETE #endif /* GR64_REGNUM */ */
+/* OBSOLETE */
+/* OBSOLETE /* Global registers gr96-gr127 */ */
+/* OBSOLETE out_msg_buf->write_r_msg.byte_count = 4 * (32); */
+/* OBSOLETE out_msg_buf->write_r_msg.length = 3 * 4 + out_msg_buf->write_r_msg.byte_count; */
+/* OBSOLETE out_msg_buf->write_r_msg.address = 96; */
+/* OBSOLETE for (regno = GR96_REGNUM; regno < GR96_REGNUM + 32; regno++) */
+/* OBSOLETE { */
+/* OBSOLETE out_msg_buf->write_r_msg.data[regno - GR96_REGNUM] = read_register (regno); */
+/* OBSOLETE } */
+/* OBSOLETE msg_send_serial (out_msg_buf); */
+/* OBSOLETE if (!expect_msg (WRITE_ACK, in_msg_buf, 1)) */
+/* OBSOLETE { */
+/* OBSOLETE result = -1; */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* Local Registers */ */
+/* OBSOLETE out_msg_buf->write_r_msg.memory_space = LOCAL_REG; */
+/* OBSOLETE out_msg_buf->write_r_msg.byte_count = 4 * 128; */
+/* OBSOLETE out_msg_buf->write_r_msg.length = 3 * 4 + out_msg_buf->write_r_msg.byte_count; */
+/* OBSOLETE out_msg_buf->write_r_msg.address = 0; */
+/* OBSOLETE */
+/* OBSOLETE for (regno = LR0_REGNUM; regno < LR0_REGNUM + 128; regno++) */
+/* OBSOLETE { */
+/* OBSOLETE out_msg_buf->write_r_msg.data[regno - LR0_REGNUM] = read_register (regno); */
+/* OBSOLETE } */
+/* OBSOLETE msg_send_serial (out_msg_buf); */
+/* OBSOLETE if (!expect_msg (WRITE_ACK, in_msg_buf, 1)) */
+/* OBSOLETE { */
+/* OBSOLETE result = -1; */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* Protected Special Registers */ */
+/* OBSOLETE /* VAB through TMR */ */
+/* OBSOLETE out_msg_buf->write_r_msg.memory_space = SPECIAL_REG; */
+/* OBSOLETE out_msg_buf->write_r_msg.byte_count = 4 * 10; */
+/* OBSOLETE out_msg_buf->write_r_msg.length = 3 * 4 + out_msg_buf->write_r_msg.byte_count; */
+/* OBSOLETE out_msg_buf->write_r_msg.address = 0; */
+/* OBSOLETE for (regno = 0; regno <= 9; regno++) /* VAB through TMR */ */
+/* OBSOLETE out_msg_buf->write_r_msg.data[regno] = read_register (SR_REGNUM (regno)); */
+/* OBSOLETE msg_send_serial (out_msg_buf); */
+/* OBSOLETE if (!expect_msg (WRITE_ACK, in_msg_buf, 1)) */
+/* OBSOLETE { */
+/* OBSOLETE result = -1; */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* PC0, PC1, PC2 possibly as shadow registers */ */
+/* OBSOLETE out_msg_buf->write_r_msg.byte_count = 4 * 3; */
+/* OBSOLETE out_msg_buf->write_r_msg.length = 3 * 4 + out_msg_buf->write_r_msg.byte_count; */
+/* OBSOLETE for (regno = 10; regno <= 12; regno++) /* LRU and MMU */ */
+/* OBSOLETE out_msg_buf->write_r_msg.data[regno - 10] = read_register (SR_REGNUM (regno)); */
+/* OBSOLETE if (USE_SHADOW_PC) */
+/* OBSOLETE out_msg_buf->write_r_msg.address = 20; /* SPC0 */ */
+/* OBSOLETE else */
+/* OBSOLETE out_msg_buf->write_r_msg.address = 10; /* PC0 */ */
+/* OBSOLETE msg_send_serial (out_msg_buf); */
+/* OBSOLETE if (!expect_msg (WRITE_ACK, in_msg_buf, 1)) */
+/* OBSOLETE { */
+/* OBSOLETE result = -1; */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* LRU and MMU */ */
+/* OBSOLETE out_msg_buf->write_r_msg.byte_count = 4 * 2; */
+/* OBSOLETE out_msg_buf->write_r_msg.length = 3 * 4 + out_msg_buf->write_r_msg.byte_count; */
+/* OBSOLETE out_msg_buf->write_r_msg.address = 13; */
+/* OBSOLETE for (regno = 13; regno <= 14; regno++) /* LRU and MMU */ */
+/* OBSOLETE out_msg_buf->write_r_msg.data[regno - 13] = read_register (SR_REGNUM (regno)); */
+/* OBSOLETE msg_send_serial (out_msg_buf); */
+/* OBSOLETE if (!expect_msg (WRITE_ACK, in_msg_buf, 1)) */
+/* OBSOLETE { */
+/* OBSOLETE result = -1; */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* Unprotected Special Registers */ */
+/* OBSOLETE out_msg_buf->write_r_msg.byte_count = 4 * 8; */
+/* OBSOLETE out_msg_buf->write_r_msg.length = 3 * 4 + out_msg_buf->write_r_msg.byte_count; */
+/* OBSOLETE out_msg_buf->write_r_msg.address = 128; */
+/* OBSOLETE for (regno = 128; regno <= 135; regno++) */
+/* OBSOLETE out_msg_buf->write_r_msg.data[regno - 128] = read_register (SR_REGNUM (regno)); */
+/* OBSOLETE msg_send_serial (out_msg_buf); */
+/* OBSOLETE if (!expect_msg (WRITE_ACK, in_msg_buf, 1)) */
+/* OBSOLETE { */
+/* OBSOLETE result = -1; */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE registers_changed (); */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /*************************************************** REMOTE_PREPARE_TO_STORE */ */
+/* OBSOLETE /* Get ready to modify the registers array. On machines which store */
+/* OBSOLETE individual registers, this doesn't need to do anything. On machines */
+/* OBSOLETE which store all the registers in one fell swoop, this makes sure */
+/* OBSOLETE that registers contains all the registers from the program being */
+/* OBSOLETE debugged. */ */
+/* OBSOLETE */
+/* OBSOLETE static void */
+/* OBSOLETE mm_prepare_to_store (void) */
+/* OBSOLETE { */
+/* OBSOLETE /* Do nothing, since we can store individual regs */ */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /******************************************************* REMOTE_XFER_MEMORY */ */
+/* OBSOLETE static CORE_ADDR */
+/* OBSOLETE translate_addr (CORE_ADDR addr) */
+/* OBSOLETE { */
+/* OBSOLETE #if defined(KERNEL_DEBUGGING) */
+/* OBSOLETE /* Check for a virtual address in the kernel */ */
+/* OBSOLETE /* Assume physical address of ublock is in paddr_u register */ */
+/* OBSOLETE /* FIXME: doesn't work for user virtual addresses */ */
+/* OBSOLETE if (addr >= UVADDR) */
+/* OBSOLETE { */
+/* OBSOLETE /* PADDR_U register holds the physical address of the ublock */ */
+/* OBSOLETE CORE_ADDR i = (CORE_ADDR) read_register (PADDR_U_REGNUM); */
+/* OBSOLETE return (i + addr - (CORE_ADDR) UVADDR); */
+/* OBSOLETE } */
+/* OBSOLETE else */
+/* OBSOLETE { */
+/* OBSOLETE return (addr); */
+/* OBSOLETE } */
+/* OBSOLETE #else */
+/* OBSOLETE return (addr); */
+/* OBSOLETE #endif */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /******************************************************* REMOTE_FILES_INFO */ */
+/* OBSOLETE static void */
+/* OBSOLETE mm_files_info (void) */
+/* OBSOLETE { */
+/* OBSOLETE printf ("\tAttached to %s at %d baud and running program %s.\n", */
+/* OBSOLETE dev_name, baudrate, prog_name); */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /************************************************* REMOTE_INSERT_BREAKPOINT */ */
+/* OBSOLETE static int */
+/* OBSOLETE mm_insert_breakpoint (CORE_ADDR addr, char *contents_cache) */
+/* OBSOLETE { */
+/* OBSOLETE out_msg_buf->bkpt_set_msg.code = BKPT_SET; */
+/* OBSOLETE out_msg_buf->bkpt_set_msg.length = 4 * 4; */
+/* OBSOLETE out_msg_buf->bkpt_set_msg.memory_space = I_MEM; */
+/* OBSOLETE out_msg_buf->bkpt_set_msg.bkpt_addr = (ADDR32) addr; */
+/* OBSOLETE out_msg_buf->bkpt_set_msg.pass_count = 1; */
+/* OBSOLETE out_msg_buf->bkpt_set_msg.bkpt_type = -1; /* use illop for 29000 */ */
+/* OBSOLETE msg_send_serial (out_msg_buf); */
+/* OBSOLETE if (expect_msg (BKPT_SET_ACK, in_msg_buf, 1)) */
+/* OBSOLETE { */
+/* OBSOLETE return 0; /* Success */ */
+/* OBSOLETE } */
+/* OBSOLETE else */
+/* OBSOLETE { */
+/* OBSOLETE return 1; /* Failure */ */
+/* OBSOLETE } */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /************************************************* REMOTE_DELETE_BREAKPOINT */ */
+/* OBSOLETE static int */
+/* OBSOLETE mm_remove_breakpoint (CORE_ADDR addr, char *contents_cache) */
+/* OBSOLETE { */
+/* OBSOLETE out_msg_buf->bkpt_rm_msg.code = BKPT_RM; */
+/* OBSOLETE out_msg_buf->bkpt_rm_msg.length = 4 * 3; */
+/* OBSOLETE out_msg_buf->bkpt_rm_msg.memory_space = I_MEM; */
+/* OBSOLETE out_msg_buf->bkpt_rm_msg.bkpt_addr = (ADDR32) addr; */
+/* OBSOLETE msg_send_serial (out_msg_buf); */
+/* OBSOLETE if (expect_msg (BKPT_RM_ACK, in_msg_buf, 1)) */
+/* OBSOLETE { */
+/* OBSOLETE return 0; /* Success */ */
+/* OBSOLETE } */
+/* OBSOLETE else */
+/* OBSOLETE { */
+/* OBSOLETE return 1; /* Failure */ */
+/* OBSOLETE } */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE */
+/* OBSOLETE /******************************************************* REMOTE_KILL */ */
+/* OBSOLETE static void */
+/* OBSOLETE mm_kill (char *arg, int from_tty) */
+/* OBSOLETE { */
+/* OBSOLETE char buf[4]; */
+/* OBSOLETE */
+/* OBSOLETE #if defined(KERNEL_DEBUGGING) */
+/* OBSOLETE /* We don't ever kill the kernel */ */
+/* OBSOLETE if (from_tty) */
+/* OBSOLETE { */
+/* OBSOLETE printf ("Kernel not killed, but left in current state.\n"); */
+/* OBSOLETE printf ("Use detach to leave kernel running.\n"); */
+/* OBSOLETE } */
+/* OBSOLETE #else */
+/* OBSOLETE out_msg_buf->break_msg.code = BREAK; */
+/* OBSOLETE out_msg_buf->bkpt_set_msg.length = 4 * 0; */
+/* OBSOLETE expect_msg (HALT, in_msg_buf, from_tty); */
+/* OBSOLETE if (from_tty) */
+/* OBSOLETE { */
+/* OBSOLETE printf ("Target has been stopped."); */
+/* OBSOLETE printf ("Would you like to do a hardware reset (y/n) [n] "); */
+/* OBSOLETE fgets (buf, 3, stdin); */
+/* OBSOLETE if (buf[0] == 'y') */
+/* OBSOLETE { */
+/* OBSOLETE out_msg_buf->reset_msg.code = RESET; */
+/* OBSOLETE out_msg_buf->bkpt_set_msg.length = 4 * 0; */
+/* OBSOLETE expect_msg (RESET_ACK, in_msg_buf, from_tty); */
+/* OBSOLETE printf ("Target has been reset."); */
+/* OBSOLETE } */
+/* OBSOLETE } */
+/* OBSOLETE pop_target (); */
+/* OBSOLETE #endif */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE */
+/* OBSOLETE */
+/* OBSOLETE /***************************************************************************/ */
+/* OBSOLETE /* */
+/* OBSOLETE * Load a program into the target. */
+/* OBSOLETE */ */
+/* OBSOLETE static void */
+/* OBSOLETE mm_load (char *arg_string, int from_tty) */
+/* OBSOLETE { */
+/* OBSOLETE dont_repeat (); */
+/* OBSOLETE */
+/* OBSOLETE #if defined(KERNEL_DEBUGGING) */
+/* OBSOLETE printf ("The kernel had better be loaded already! Loading not done.\n"); */
+/* OBSOLETE #else */
+/* OBSOLETE if (arg_string == 0) */
+/* OBSOLETE error ("The load command takes a file name"); */
+/* OBSOLETE */
+/* OBSOLETE arg_string = tilde_expand (arg_string); */
+/* OBSOLETE make_cleanup (xfree, arg_string); */
+/* OBSOLETE QUIT; */
+/* OBSOLETE immediate_quit++; */
+/* OBSOLETE error ("File loading is not yet supported for MiniMon."); */
+/* OBSOLETE /* FIXME, code to load your file here... */ */
+/* OBSOLETE /* You may need to do an init_target_mm() */ */
+/* OBSOLETE /* init_target_mm(?,?,?,?,?,?,?,?); */ */
+/* OBSOLETE immediate_quit--; */
+/* OBSOLETE /* symbol_file_add (arg_string, from_tty, text_addr, 0, 0); */ */
+/* OBSOLETE #endif */
+/* OBSOLETE */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /************************************************ REMOTE_WRITE_INFERIOR_MEMORY */
+/* OBSOLETE ** Copy LEN bytes of data from debugger memory at MYADDR */
+/* OBSOLETE to inferior's memory at MEMADDR. Returns number of bytes written. */ */
+/* OBSOLETE static int */
+/* OBSOLETE mm_write_inferior_memory (CORE_ADDR memaddr, char *myaddr, int len) */
+/* OBSOLETE { */
+/* OBSOLETE int i, nwritten; */
+/* OBSOLETE */
+/* OBSOLETE out_msg_buf->write_req_msg.code = WRITE_REQ; */
+/* OBSOLETE out_msg_buf->write_req_msg.memory_space = mm_memory_space (memaddr); */
+/* OBSOLETE */
+/* OBSOLETE nwritten = 0; */
+/* OBSOLETE while (nwritten < len) */
+/* OBSOLETE { */
+/* OBSOLETE int num_to_write = len - nwritten; */
+/* OBSOLETE if (num_to_write > MAXDATA) */
+/* OBSOLETE num_to_write = MAXDATA; */
+/* OBSOLETE for (i = 0; i < num_to_write; i++) */
+/* OBSOLETE out_msg_buf->write_req_msg.data[i] = myaddr[i + nwritten]; */
+/* OBSOLETE out_msg_buf->write_req_msg.byte_count = num_to_write; */
+/* OBSOLETE out_msg_buf->write_req_msg.length = 3 * 4 + num_to_write; */
+/* OBSOLETE out_msg_buf->write_req_msg.address = memaddr + nwritten; */
+/* OBSOLETE msg_send_serial (out_msg_buf); */
+/* OBSOLETE */
+/* OBSOLETE if (expect_msg (WRITE_ACK, in_msg_buf, 1)) */
+/* OBSOLETE { */
+/* OBSOLETE nwritten += in_msg_buf->write_ack_msg.byte_count; */
+/* OBSOLETE } */
+/* OBSOLETE else */
+/* OBSOLETE { */
+/* OBSOLETE break; */
+/* OBSOLETE } */
+/* OBSOLETE } */
+/* OBSOLETE return (nwritten); */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /************************************************* REMOTE_READ_INFERIOR_MEMORY */
+/* OBSOLETE ** Read LEN bytes from inferior memory at MEMADDR. Put the result */
+/* OBSOLETE at debugger address MYADDR. Returns number of bytes read. */ */
+/* OBSOLETE static int */
+/* OBSOLETE mm_read_inferior_memory (CORE_ADDR memaddr, char *myaddr, int len) */
+/* OBSOLETE { */
+/* OBSOLETE int i, nread; */
+/* OBSOLETE */
+/* OBSOLETE out_msg_buf->read_req_msg.code = READ_REQ; */
+/* OBSOLETE out_msg_buf->read_req_msg.memory_space = mm_memory_space (memaddr); */
+/* OBSOLETE */
+/* OBSOLETE nread = 0; */
+/* OBSOLETE while (nread < len) */
+/* OBSOLETE { */
+/* OBSOLETE int num_to_read = (len - nread); */
+/* OBSOLETE if (num_to_read > MAXDATA) */
+/* OBSOLETE num_to_read = MAXDATA; */
+/* OBSOLETE out_msg_buf->read_req_msg.byte_count = num_to_read; */
+/* OBSOLETE out_msg_buf->read_req_msg.length = 3 * 4 + num_to_read; */
+/* OBSOLETE out_msg_buf->read_req_msg.address = memaddr + nread; */
+/* OBSOLETE msg_send_serial (out_msg_buf); */
+/* OBSOLETE */
+/* OBSOLETE if (expect_msg (READ_ACK, in_msg_buf, 1)) */
+/* OBSOLETE { */
+/* OBSOLETE for (i = 0; i < in_msg_buf->read_ack_msg.byte_count; i++) */
+/* OBSOLETE myaddr[i + nread] = in_msg_buf->read_ack_msg.data[i]; */
+/* OBSOLETE nread += in_msg_buf->read_ack_msg.byte_count; */
+/* OBSOLETE } */
+/* OBSOLETE else */
+/* OBSOLETE { */
+/* OBSOLETE break; */
+/* OBSOLETE } */
+/* OBSOLETE } */
+/* OBSOLETE return (nread); */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* FIXME! Merge these two. */ */
+/* OBSOLETE static int */
+/* OBSOLETE mm_xfer_inferior_memory (CORE_ADDR memaddr, char *myaddr, int len, int write, */
+/* OBSOLETE struct mem_attrib *attrib ATTRIBUTE_UNUSED, */
+/* OBSOLETE struct target_ops *target ATTRIBUTE_UNUSED) */
+/* OBSOLETE { */
+/* OBSOLETE */
+/* OBSOLETE memaddr = translate_addr (memaddr); */
+/* OBSOLETE */
+/* OBSOLETE if (write) */
+/* OBSOLETE return mm_write_inferior_memory (memaddr, myaddr, len); */
+/* OBSOLETE else */
+/* OBSOLETE return mm_read_inferior_memory (memaddr, myaddr, len); */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE */
+/* OBSOLETE /********************************************************** MSG_SEND_SERIAL */
+/* OBSOLETE ** This function is used to send a message over the */
+/* OBSOLETE ** serial line. */
+/* OBSOLETE ** */
+/* OBSOLETE ** If the message is successfully sent, a zero is */
+/* OBSOLETE ** returned. If the message was not sendable, a -1 */
+/* OBSOLETE ** is returned. This function blocks. That is, it */
+/* OBSOLETE ** does not return until the message is completely */
+/* OBSOLETE ** sent, or until an error is encountered. */
+/* OBSOLETE ** */
+/* OBSOLETE */ */
+/* OBSOLETE */
+/* OBSOLETE int */
+/* OBSOLETE msg_send_serial (union msg_t *msg_ptr) */
+/* OBSOLETE { */
+/* OBSOLETE INT32 message_size; */
+/* OBSOLETE int byte_count; */
+/* OBSOLETE int result; */
+/* OBSOLETE char c; */
+/* OBSOLETE */
+/* OBSOLETE /* Send message header */ */
+/* OBSOLETE byte_count = 0; */
+/* OBSOLETE message_size = msg_ptr->generic_msg.length + (2 * sizeof (INT32)); */
+/* OBSOLETE do */
+/* OBSOLETE { */
+/* OBSOLETE c = *((char *) msg_ptr + byte_count); */
+/* OBSOLETE result = write (mm_desc, &c, 1); */
+/* OBSOLETE if (result == 1) */
+/* OBSOLETE { */
+/* OBSOLETE byte_count = byte_count + 1; */
+/* OBSOLETE } */
+/* OBSOLETE } */
+/* OBSOLETE while ((byte_count < message_size)); */
+/* OBSOLETE */
+/* OBSOLETE return (0); */
+/* OBSOLETE } /* end msg_send_serial() */ */
+/* OBSOLETE */
+/* OBSOLETE /********************************************************** MSG_RECV_SERIAL */
+/* OBSOLETE ** This function is used to receive a message over a */
+/* OBSOLETE ** serial line. */
+/* OBSOLETE ** */
+/* OBSOLETE ** If the message is waiting in the buffer, a zero is */
+/* OBSOLETE ** returned and the buffer pointed to by msg_ptr is filled */
+/* OBSOLETE ** in. If no message was available, a -1 is returned. */
+/* OBSOLETE ** If timeout==0, wait indefinetly for a character. */
+/* OBSOLETE ** */
+/* OBSOLETE */ */
+/* OBSOLETE */
+/* OBSOLETE int */
+/* OBSOLETE msg_recv_serial (union msg_t *msg_ptr) */
+/* OBSOLETE { */
+/* OBSOLETE static INT32 length = 0; */
+/* OBSOLETE static INT32 byte_count = 0; */
+/* OBSOLETE int result; */
+/* OBSOLETE char c; */
+/* OBSOLETE if (msg_ptr == 0) /* re-sync request */ */
+/* OBSOLETE { */
+/* OBSOLETE length = 0; */
+/* OBSOLETE byte_count = 0; */
+/* OBSOLETE #ifdef HAVE_TERMIO */
+/* OBSOLETE /* The timeout here is the prevailing timeout set with VTIME */ */
+/* OBSOLETE ->"timeout==0 semantics not supported" */
+/* OBSOLETE read (mm_desc, in_buf, BUFER_SIZE); */
+/* OBSOLETE #else */
+/* OBSOLETE alarm (1); */
+/* OBSOLETE read (mm_desc, in_buf, BUFER_SIZE); */
+/* OBSOLETE alarm (0); */
+/* OBSOLETE #endif */
+/* OBSOLETE return (0); */
+/* OBSOLETE } */
+/* OBSOLETE /* Receive message */ */
+/* OBSOLETE #ifdef HAVE_TERMIO */
+/* OBSOLETE /* Timeout==0, help support the mm_wait() routine */ */
+/* OBSOLETE ->"timeout==0 semantics not supported (and its nice if they are)" */
+/* OBSOLETE result = read (mm_desc, &c, 1); */
+/* OBSOLETE #else */
+/* OBSOLETE alarm (timeout); */
+/* OBSOLETE result = read (mm_desc, &c, 1); */
+/* OBSOLETE alarm (0); */
+/* OBSOLETE #endif */
+/* OBSOLETE if (result < 0) */
+/* OBSOLETE { */
+/* OBSOLETE if (errno == EINTR) */
+/* OBSOLETE { */
+/* OBSOLETE error ("Timeout reading from remote system."); */
+/* OBSOLETE } */
+/* OBSOLETE else */
+/* OBSOLETE perror_with_name ("remote"); */
+/* OBSOLETE } */
+/* OBSOLETE else if (result == 1) */
+/* OBSOLETE { */
+/* OBSOLETE *((char *) msg_ptr + byte_count) = c; */
+/* OBSOLETE byte_count = byte_count + 1; */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* Message header received. Save message length. */ */
+/* OBSOLETE if (byte_count == (2 * sizeof (INT32))) */
+/* OBSOLETE length = msg_ptr->generic_msg.length; */
+/* OBSOLETE */
+/* OBSOLETE if (byte_count >= (length + (2 * sizeof (INT32)))) */
+/* OBSOLETE { */
+/* OBSOLETE /* Message received */ */
+/* OBSOLETE byte_count = 0; */
+/* OBSOLETE return (0); */
+/* OBSOLETE } */
+/* OBSOLETE else */
+/* OBSOLETE return (-1); */
+/* OBSOLETE */
+/* OBSOLETE } /* end msg_recv_serial() */ */
+/* OBSOLETE */
+/* OBSOLETE /********************************************************************* KBD_RAW */
+/* OBSOLETE ** This function is used to put the keyboard in "raw" */
+/* OBSOLETE ** mode for BSD Unix. The original status is saved */
+/* OBSOLETE ** so that it may be restored later. */
+/* OBSOLETE */ */
+/* OBSOLETE TERMINAL kbd_tbuf; */
+/* OBSOLETE */
+/* OBSOLETE int */
+/* OBSOLETE kbd_raw (void) */
+/* OBSOLETE { */
+/* OBSOLETE int result; */
+/* OBSOLETE TERMINAL tbuf; */
+/* OBSOLETE */
+/* OBSOLETE /* Get keyboard termio (to save to restore original modes) */ */
+/* OBSOLETE #ifdef HAVE_TERMIO */
+/* OBSOLETE result = ioctl (0, TCGETA, &kbd_tbuf); */
+/* OBSOLETE #else */
+/* OBSOLETE result = ioctl (0, TIOCGETP, &kbd_tbuf); */
+/* OBSOLETE #endif */
+/* OBSOLETE if (result == -1) */
+/* OBSOLETE return (errno); */
+/* OBSOLETE */
+/* OBSOLETE /* Get keyboard TERMINAL (for modification) */ */
+/* OBSOLETE #ifdef HAVE_TERMIO */
+/* OBSOLETE result = ioctl (0, TCGETA, &tbuf); */
+/* OBSOLETE #else */
+/* OBSOLETE result = ioctl (0, TIOCGETP, &tbuf); */
+/* OBSOLETE #endif */
+/* OBSOLETE if (result == -1) */
+/* OBSOLETE return (errno); */
+/* OBSOLETE */
+/* OBSOLETE /* Set up new parameters */ */
+/* OBSOLETE #ifdef HAVE_TERMIO */
+/* OBSOLETE tbuf.c_iflag = tbuf.c_iflag & */
+/* OBSOLETE ~(INLCR | ICRNL | IUCLC | ISTRIP | IXON | BRKINT); */
+/* OBSOLETE tbuf.c_lflag = tbuf.c_lflag & ~(ICANON | ISIG | ECHO); */
+/* OBSOLETE tbuf.c_cc[4] = 0; /* MIN */ */
+/* OBSOLETE tbuf.c_cc[5] = 0; /* TIME */ */
+/* OBSOLETE #else */
+/* OBSOLETE /* FIXME: not sure if this is correct (matches HAVE_TERMIO). */ */
+/* OBSOLETE tbuf.sg_flags |= RAW; */
+/* OBSOLETE tbuf.sg_flags |= ANYP; */
+/* OBSOLETE tbuf.sg_flags &= ~ECHO; */
+/* OBSOLETE #endif */
+/* OBSOLETE */
+/* OBSOLETE /* Set keyboard termio to new mode (RAW) */ */
+/* OBSOLETE #ifdef HAVE_TERMIO */
+/* OBSOLETE result = ioctl (0, TCSETAF, &tbuf); */
+/* OBSOLETE #else */
+/* OBSOLETE result = ioctl (0, TIOCSETP, &tbuf); */
+/* OBSOLETE #endif */
+/* OBSOLETE if (result == -1) */
+/* OBSOLETE return (errno); */
+/* OBSOLETE */
+/* OBSOLETE return (0); */
+/* OBSOLETE } /* end kbd_raw() */ */
+/* OBSOLETE */
+/* OBSOLETE */
+/* OBSOLETE */
+/* OBSOLETE /***************************************************************** KBD_RESTORE */
+/* OBSOLETE ** This function is used to put the keyboard back in the */
+/* OBSOLETE ** mode it was in before kbk_raw was called. Note that */
+/* OBSOLETE ** kbk_raw() must have been called at least once before */
+/* OBSOLETE ** kbd_restore() is called. */
+/* OBSOLETE */ */
+/* OBSOLETE */
+/* OBSOLETE int */
+/* OBSOLETE kbd_restore (void) */
+/* OBSOLETE { */
+/* OBSOLETE int result; */
+/* OBSOLETE */
+/* OBSOLETE /* Set keyboard termio to original mode */ */
+/* OBSOLETE #ifdef HAVE_TERMIO */
+/* OBSOLETE result = ioctl (0, TCSETAF, &kbd_tbuf); */
+/* OBSOLETE #else */
+/* OBSOLETE result = ioctl (0, TIOCGETP, &kbd_tbuf); */
+/* OBSOLETE #endif */
+/* OBSOLETE */
+/* OBSOLETE if (result == -1) */
+/* OBSOLETE return (errno); */
+/* OBSOLETE */
+/* OBSOLETE return (0); */
+/* OBSOLETE } /* end kbd_cooked() */ */
+/* OBSOLETE */
+/* OBSOLETE */
+/* OBSOLETE /*****************************************************************************/ */
+/* OBSOLETE /* Fetch a single register indicatated by 'regno'. */
+/* OBSOLETE * Returns 0/-1 on success/failure. */
+/* OBSOLETE */ */
+/* OBSOLETE static int */
+/* OBSOLETE fetch_register (int regno) */
+/* OBSOLETE { */
+/* OBSOLETE int result; */
+/* OBSOLETE out_msg_buf->read_req_msg.code = READ_REQ; */
+/* OBSOLETE out_msg_buf->read_req_msg.length = 4 * 3; */
+/* OBSOLETE out_msg_buf->read_req_msg.byte_count = 4; */
+/* OBSOLETE */
+/* OBSOLETE if (regno == GR1_REGNUM) */
+/* OBSOLETE { */
+/* OBSOLETE out_msg_buf->read_req_msg.memory_space = GLOBAL_REG; */
+/* OBSOLETE out_msg_buf->read_req_msg.address = 1; */
+/* OBSOLETE } */
+/* OBSOLETE else if (regno >= GR96_REGNUM && regno < GR96_REGNUM + 32) */
+/* OBSOLETE { */
+/* OBSOLETE out_msg_buf->read_req_msg.memory_space = GLOBAL_REG; */
+/* OBSOLETE out_msg_buf->read_req_msg.address = (regno - GR96_REGNUM) + 96; */
+/* OBSOLETE } */
+/* OBSOLETE #if defined(GR64_REGNUM) */
+/* OBSOLETE else if (regno >= GR64_REGNUM && regno < GR64_REGNUM + 32) */
+/* OBSOLETE { */
+/* OBSOLETE out_msg_buf->read_req_msg.memory_space = GLOBAL_REG; */
+/* OBSOLETE out_msg_buf->read_req_msg.address = (regno - GR64_REGNUM) + 64; */
+/* OBSOLETE } */
+/* OBSOLETE #endif /* GR64_REGNUM */ */
+/* OBSOLETE else if (regno >= LR0_REGNUM && regno < LR0_REGNUM + 128) */
+/* OBSOLETE { */
+/* OBSOLETE out_msg_buf->read_req_msg.memory_space = LOCAL_REG; */
+/* OBSOLETE out_msg_buf->read_req_msg.address = (regno - LR0_REGNUM); */
+/* OBSOLETE } */
+/* OBSOLETE else if (regno >= FPE_REGNUM && regno <= EXO_REGNUM) */
+/* OBSOLETE { */
+/* OBSOLETE int val = -1; */
+/* OBSOLETE supply_register (160 + (regno - FPE_REGNUM), &val); */
+/* OBSOLETE return 0; /* Pretend Success */ */
+/* OBSOLETE } */
+/* OBSOLETE else */
+/* OBSOLETE { */
+/* OBSOLETE out_msg_buf->read_req_msg.memory_space = SPECIAL_REG; */
+/* OBSOLETE out_msg_buf->read_req_msg.address = regnum_to_srnum (regno); */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE msg_send_serial (out_msg_buf); */
+/* OBSOLETE */
+/* OBSOLETE if (expect_msg (READ_ACK, in_msg_buf, 1)) */
+/* OBSOLETE { */
+/* OBSOLETE supply_register (regno, &(in_msg_buf->read_r_ack_msg.data[0])); */
+/* OBSOLETE result = 0; */
+/* OBSOLETE } */
+/* OBSOLETE else */
+/* OBSOLETE { */
+/* OBSOLETE result = -1; */
+/* OBSOLETE } */
+/* OBSOLETE return result; */
+/* OBSOLETE } */
+/* OBSOLETE /*****************************************************************************/ */
+/* OBSOLETE /* Store a single register indicated by 'regno'. */
+/* OBSOLETE * Returns 0/-1 on success/failure. */
+/* OBSOLETE */ */
+/* OBSOLETE static int */
+/* OBSOLETE store_register (int regno) */
+/* OBSOLETE { */
+/* OBSOLETE int result; */
+/* OBSOLETE */
+/* OBSOLETE out_msg_buf->write_req_msg.code = WRITE_REQ; */
+/* OBSOLETE out_msg_buf->write_req_msg.length = 4 * 4; */
+/* OBSOLETE out_msg_buf->write_req_msg.byte_count = 4; */
+/* OBSOLETE out_msg_buf->write_r_msg.data[0] = read_register (regno); */
+/* OBSOLETE */
+/* OBSOLETE if (regno == GR1_REGNUM) */
+/* OBSOLETE { */
+/* OBSOLETE out_msg_buf->write_req_msg.memory_space = GLOBAL_REG; */
+/* OBSOLETE out_msg_buf->write_req_msg.address = 1; */
+/* OBSOLETE /* Setting GR1 changes the numbers of all the locals, so invalidate the */
+/* OBSOLETE * register cache. Do this *after* calling read_register, because we want */
+/* OBSOLETE * read_register to return the value that write_register has just stuffed */
+/* OBSOLETE * into the registers array, not the value of the register fetched from */
+/* OBSOLETE * the inferior. */
+/* OBSOLETE */ */
+/* OBSOLETE registers_changed (); */
+/* OBSOLETE } */
+/* OBSOLETE #if defined(GR64_REGNUM) */
+/* OBSOLETE else if (regno >= GR64_REGNUM && regno < GR64_REGNUM + 32) */
+/* OBSOLETE { */
+/* OBSOLETE out_msg_buf->write_req_msg.memory_space = GLOBAL_REG; */
+/* OBSOLETE out_msg_buf->write_req_msg.address = (regno - GR64_REGNUM) + 64; */
+/* OBSOLETE } */
+/* OBSOLETE #endif /* GR64_REGNUM */ */
+/* OBSOLETE else if (regno >= GR96_REGNUM && regno < GR96_REGNUM + 32) */
+/* OBSOLETE { */
+/* OBSOLETE out_msg_buf->write_req_msg.memory_space = GLOBAL_REG; */
+/* OBSOLETE out_msg_buf->write_req_msg.address = (regno - GR96_REGNUM) + 96; */
+/* OBSOLETE } */
+/* OBSOLETE else if (regno >= LR0_REGNUM && regno < LR0_REGNUM + 128) */
+/* OBSOLETE { */
+/* OBSOLETE out_msg_buf->write_req_msg.memory_space = LOCAL_REG; */
+/* OBSOLETE out_msg_buf->write_req_msg.address = (regno - LR0_REGNUM); */
+/* OBSOLETE } */
+/* OBSOLETE else if (regno >= FPE_REGNUM && regno <= EXO_REGNUM) */
+/* OBSOLETE { */
+/* OBSOLETE return 0; /* Pretend Success */ */
+/* OBSOLETE } */
+/* OBSOLETE else */
+/* OBSOLETE /* An unprotected or protected special register */ */
+/* OBSOLETE { */
+/* OBSOLETE out_msg_buf->write_req_msg.memory_space = SPECIAL_REG; */
+/* OBSOLETE out_msg_buf->write_req_msg.address = regnum_to_srnum (regno); */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE msg_send_serial (out_msg_buf); */
+/* OBSOLETE */
+/* OBSOLETE if (expect_msg (WRITE_ACK, in_msg_buf, 1)) */
+/* OBSOLETE { */
+/* OBSOLETE result = 0; */
+/* OBSOLETE } */
+/* OBSOLETE else */
+/* OBSOLETE { */
+/* OBSOLETE result = -1; */
+/* OBSOLETE } */
+/* OBSOLETE return result; */
+/* OBSOLETE } */
+/* OBSOLETE /****************************************************************************/ */
+/* OBSOLETE /* */
+/* OBSOLETE * Convert a gdb special register number to a 29000 special register number. */
+/* OBSOLETE */ */
+/* OBSOLETE static int */
+/* OBSOLETE regnum_to_srnum (int regno) */
+/* OBSOLETE { */
+/* OBSOLETE switch (regno) */
+/* OBSOLETE { */
+/* OBSOLETE case VAB_REGNUM: */
+/* OBSOLETE return (0); */
+/* OBSOLETE case OPS_REGNUM: */
+/* OBSOLETE return (1); */
+/* OBSOLETE case CPS_REGNUM: */
+/* OBSOLETE return (2); */
+/* OBSOLETE case CFG_REGNUM: */
+/* OBSOLETE return (3); */
+/* OBSOLETE case CHA_REGNUM: */
+/* OBSOLETE return (4); */
+/* OBSOLETE case CHD_REGNUM: */
+/* OBSOLETE return (5); */
+/* OBSOLETE case CHC_REGNUM: */
+/* OBSOLETE return (6); */
+/* OBSOLETE case RBP_REGNUM: */
+/* OBSOLETE return (7); */
+/* OBSOLETE case TMC_REGNUM: */
+/* OBSOLETE return (8); */
+/* OBSOLETE case TMR_REGNUM: */
+/* OBSOLETE return (9); */
+/* OBSOLETE case NPC_REGNUM: */
+/* OBSOLETE return (USE_SHADOW_PC ? (20) : (10)); */
+/* OBSOLETE case PC_REGNUM: */
+/* OBSOLETE return (USE_SHADOW_PC ? (21) : (11)); */
+/* OBSOLETE case PC2_REGNUM: */
+/* OBSOLETE return (USE_SHADOW_PC ? (22) : (12)); */
+/* OBSOLETE case MMU_REGNUM: */
+/* OBSOLETE return (13); */
+/* OBSOLETE case LRU_REGNUM: */
+/* OBSOLETE return (14); */
+/* OBSOLETE case IPC_REGNUM: */
+/* OBSOLETE return (128); */
+/* OBSOLETE case IPA_REGNUM: */
+/* OBSOLETE return (129); */
+/* OBSOLETE case IPB_REGNUM: */
+/* OBSOLETE return (130); */
+/* OBSOLETE case Q_REGNUM: */
+/* OBSOLETE return (131); */
+/* OBSOLETE case ALU_REGNUM: */
+/* OBSOLETE return (132); */
+/* OBSOLETE case BP_REGNUM: */
+/* OBSOLETE return (133); */
+/* OBSOLETE case FC_REGNUM: */
+/* OBSOLETE return (134); */
+/* OBSOLETE case CR_REGNUM: */
+/* OBSOLETE return (135); */
+/* OBSOLETE case FPE_REGNUM: */
+/* OBSOLETE return (160); */
+/* OBSOLETE case INTE_REGNUM: */
+/* OBSOLETE return (161); */
+/* OBSOLETE case FPS_REGNUM: */
+/* OBSOLETE return (162); */
+/* OBSOLETE case EXO_REGNUM: */
+/* OBSOLETE return (164); */
+/* OBSOLETE default: */
+/* OBSOLETE return (255); /* Failure ? */ */
+/* OBSOLETE } */
+/* OBSOLETE } */
+/* OBSOLETE /****************************************************************************/ */
+/* OBSOLETE /* */
+/* OBSOLETE * Initialize the target debugger (minimon only). */
+/* OBSOLETE */ */
+/* OBSOLETE static void */
+/* OBSOLETE init_target_mm (ADDR32 tstart, ADDR32 tend, ADDR32 dstart, ADDR32 dend, */
+/* OBSOLETE ADDR32 entry, INT32 ms_size, INT32 rs_size, ADDR32 arg_start) */
+/* OBSOLETE { */
+/* OBSOLETE out_msg_buf->init_msg.code = INIT; */
+/* OBSOLETE out_msg_buf->init_msg.length = sizeof (struct init_msg_t) - 2 * sizeof (INT32); */
+/* OBSOLETE out_msg_buf->init_msg.text_start = tstart; */
+/* OBSOLETE out_msg_buf->init_msg.text_end = tend; */
+/* OBSOLETE out_msg_buf->init_msg.data_start = dstart; */
+/* OBSOLETE out_msg_buf->init_msg.data_end = dend; */
+/* OBSOLETE out_msg_buf->init_msg.entry_point = entry; */
+/* OBSOLETE out_msg_buf->init_msg.mem_stack_size = ms_size; */
+/* OBSOLETE out_msg_buf->init_msg.reg_stack_size = rs_size; */
+/* OBSOLETE out_msg_buf->init_msg.arg_start = arg_start; */
+/* OBSOLETE msg_send_serial (out_msg_buf); */
+/* OBSOLETE expect_msg (INIT_ACK, in_msg_buf, 1); */
+/* OBSOLETE } */
+/* OBSOLETE /****************************************************************************/ */
+/* OBSOLETE /* */
+/* OBSOLETE * Return a pointer to a string representing the given message code. */
+/* OBSOLETE * Not all messages are represented here, only the ones that we expect */
+/* OBSOLETE * to be called with. */
+/* OBSOLETE */ */
+/* OBSOLETE static char * */
+/* OBSOLETE msg_str (INT32 code) */
+/* OBSOLETE { */
+/* OBSOLETE static char cbuf[32]; */
+/* OBSOLETE */
+/* OBSOLETE switch (code) */
+/* OBSOLETE { */
+/* OBSOLETE case BKPT_SET_ACK: */
+/* OBSOLETE sprintf (cbuf, "%s (%d)", "BKPT_SET_ACK", code); */
+/* OBSOLETE break; */
+/* OBSOLETE case BKPT_RM_ACK: */
+/* OBSOLETE sprintf (cbuf, "%s (%d)", "BKPT_RM_ACK", code); */
+/* OBSOLETE break; */
+/* OBSOLETE case INIT_ACK: */
+/* OBSOLETE sprintf (cbuf, "%s (%d)", "INIT_ACK", code); */
+/* OBSOLETE break; */
+/* OBSOLETE case READ_ACK: */
+/* OBSOLETE sprintf (cbuf, "%s (%d)", "READ_ACK", code); */
+/* OBSOLETE break; */
+/* OBSOLETE case WRITE_ACK: */
+/* OBSOLETE sprintf (cbuf, "%s (%d)", "WRITE_ACK", code); */
+/* OBSOLETE break; */
+/* OBSOLETE case ERROR: */
+/* OBSOLETE sprintf (cbuf, "%s (%d)", "ERROR", code); */
+/* OBSOLETE break; */
+/* OBSOLETE case HALT: */
+/* OBSOLETE sprintf (cbuf, "%s (%d)", "HALT", code); */
+/* OBSOLETE break; */
+/* OBSOLETE default: */
+/* OBSOLETE sprintf (cbuf, "UNKNOWN (%d)", code); */
+/* OBSOLETE break; */
+/* OBSOLETE } */
+/* OBSOLETE return (cbuf); */
+/* OBSOLETE } */
+/* OBSOLETE /****************************************************************************/ */
+/* OBSOLETE /* */
+/* OBSOLETE * Selected (not all of them) error codes that we might get. */
+/* OBSOLETE */ */
+/* OBSOLETE static char * */
+/* OBSOLETE error_msg_str (INT32 code) */
+/* OBSOLETE { */
+/* OBSOLETE static char cbuf[50]; */
+/* OBSOLETE */
+/* OBSOLETE switch (code) */
+/* OBSOLETE { */
+/* OBSOLETE case EMFAIL: */
+/* OBSOLETE return ("EMFAIL: unrecoverable error"); */
+/* OBSOLETE case EMBADADDR: */
+/* OBSOLETE return ("EMBADADDR: Illegal address"); */
+/* OBSOLETE case EMBADREG: */
+/* OBSOLETE return ("EMBADREG: Illegal register "); */
+/* OBSOLETE case EMACCESS: */
+/* OBSOLETE return ("EMACCESS: Could not access memory"); */
+/* OBSOLETE case EMBADMSG: */
+/* OBSOLETE return ("EMBADMSG: Unknown message type"); */
+/* OBSOLETE case EMMSG2BIG: */
+/* OBSOLETE return ("EMMSG2BIG: Message to large"); */
+/* OBSOLETE case EMNOSEND: */
+/* OBSOLETE return ("EMNOSEND: Could not send message"); */
+/* OBSOLETE case EMNORECV: */
+/* OBSOLETE return ("EMNORECV: Could not recv message"); */
+/* OBSOLETE case EMRESET: */
+/* OBSOLETE return ("EMRESET: Could not RESET target"); */
+/* OBSOLETE case EMCONFIG: */
+/* OBSOLETE return ("EMCONFIG: Could not get target CONFIG"); */
+/* OBSOLETE case EMSTATUS: */
+/* OBSOLETE return ("EMSTATUS: Could not get target STATUS"); */
+/* OBSOLETE case EMREAD: */
+/* OBSOLETE return ("EMREAD: Could not READ target memory"); */
+/* OBSOLETE case EMWRITE: */
+/* OBSOLETE return ("EMWRITE: Could not WRITE target memory"); */
+/* OBSOLETE case EMBKPTSET: */
+/* OBSOLETE return ("EMBKPTSET: Could not set breakpoint"); */
+/* OBSOLETE case EMBKPTRM: */
+/* OBSOLETE return ("EMBKPTRM: Could not remove breakpoint"); */
+/* OBSOLETE case EMBKPTSTAT: */
+/* OBSOLETE return ("EMBKPTSTAT: Could not get breakpoint status"); */
+/* OBSOLETE case EMBKPTNONE: */
+/* OBSOLETE return ("EMBKPTNONE: All breakpoints in use"); */
+/* OBSOLETE case EMBKPTUSED: */
+/* OBSOLETE return ("EMBKPTUSED: Breakpoints already in use"); */
+/* OBSOLETE case EMINIT: */
+/* OBSOLETE return ("EMINIT: Could not init target memory"); */
+/* OBSOLETE case EMGO: */
+/* OBSOLETE return ("EMGO: Could not start execution"); */
+/* OBSOLETE case EMSTEP: */
+/* OBSOLETE return ("EMSTEP: Could not single step"); */
+/* OBSOLETE case EMBREAK: */
+/* OBSOLETE return ("EMBREAK: Could not BREAK"); */
+/* OBSOLETE case EMCOMMERR: */
+/* OBSOLETE return ("EMCOMMERR: Communication error"); */
+/* OBSOLETE default: */
+/* OBSOLETE sprintf (cbuf, "error number %d", code); */
+/* OBSOLETE break; */
+/* OBSOLETE } /* end switch */ */
+/* OBSOLETE */
+/* OBSOLETE return (cbuf); */
+/* OBSOLETE } */
+/* OBSOLETE /****************************************************************************/ */
+/* OBSOLETE */
+/* OBSOLETE /* Receive a message, placing it in MSG_BUF, and expect it to be of */
+/* OBSOLETE type MSGCODE. If an error occurs, a non-zero FROM_TTY indicates */
+/* OBSOLETE that the message should be printed. */
+/* OBSOLETE */
+/* OBSOLETE Return 0 for failure, 1 for success. */ */
+/* OBSOLETE */
+/* OBSOLETE static int */
+/* OBSOLETE expect_msg (INT32 msgcode, union msg_t *msg_buf, int from_tty) */
+/* OBSOLETE { */
+/* OBSOLETE int retries = 0; */
+/* OBSOLETE while (msg_recv_serial (msg_buf) && (retries++ < MAX_RETRIES)); */
+/* OBSOLETE if (retries >= MAX_RETRIES) */
+/* OBSOLETE { */
+/* OBSOLETE printf ("Expected msg %s, ", msg_str (msgcode)); */
+/* OBSOLETE printf ("no message received!\n"); */
+/* OBSOLETE return (0); /* Failure */ */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE if (msg_buf->generic_msg.code != msgcode) */
+/* OBSOLETE { */
+/* OBSOLETE if (from_tty) */
+/* OBSOLETE { */
+/* OBSOLETE printf ("Expected msg %s, ", msg_str (msgcode)); */
+/* OBSOLETE printf ("got msg %s\n", msg_str (msg_buf->generic_msg.code)); */
+/* OBSOLETE if (msg_buf->generic_msg.code == ERROR) */
+/* OBSOLETE printf ("%s\n", error_msg_str (msg_buf->error_msg.error_code)); */
+/* OBSOLETE } */
+/* OBSOLETE return (0); /* Failure */ */
+/* OBSOLETE } */
+/* OBSOLETE return (1); /* Success */ */
+/* OBSOLETE } */
+/* OBSOLETE /****************************************************************************/ */
+/* OBSOLETE /* */
+/* OBSOLETE * Determine the MiniMon memory space qualifier based on the addr. */
+/* OBSOLETE * FIXME: Can't distinguis I_ROM/D_ROM. */
+/* OBSOLETE * FIXME: Doesn't know anything about I_CACHE/D_CACHE. */
+/* OBSOLETE */ */
+/* OBSOLETE static int */
+/* OBSOLETE mm_memory_space (CORE_ADDR *addr) */
+/* OBSOLETE { */
+/* OBSOLETE ADDR32 tstart = target_config.I_mem_start; */
+/* OBSOLETE ADDR32 tend = tstart + target_config.I_mem_size; */
+/* OBSOLETE ADDR32 dstart = target_config.D_mem_start; */
+/* OBSOLETE ADDR32 dend = tstart + target_config.D_mem_size; */
+/* OBSOLETE ADDR32 rstart = target_config.ROM_start; */
+/* OBSOLETE ADDR32 rend = tstart + target_config.ROM_size; */
+/* OBSOLETE */
+/* OBSOLETE if (((ADDR32) addr >= tstart) && ((ADDR32) addr < tend)) */
+/* OBSOLETE { */
+/* OBSOLETE return I_MEM; */
+/* OBSOLETE } */
+/* OBSOLETE else if (((ADDR32) addr >= dstart) && ((ADDR32) addr < dend)) */
+/* OBSOLETE { */
+/* OBSOLETE return D_MEM; */
+/* OBSOLETE } */
+/* OBSOLETE else if (((ADDR32) addr >= rstart) && ((ADDR32) addr < rend)) */
+/* OBSOLETE { */
+/* OBSOLETE /* FIXME: how do we determine between D_ROM and I_ROM */ */
+/* OBSOLETE return D_ROM; */
+/* OBSOLETE } */
+/* OBSOLETE else /* FIXME: what do me do now? */ */
+/* OBSOLETE return D_MEM; /* Hmmm! */ */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /****************************************************************************/ */
+/* OBSOLETE /* */
+/* OBSOLETE * Define the target subroutine names */
+/* OBSOLETE */ */
+/* OBSOLETE struct target_ops mm_ops; */
+/* OBSOLETE */
+/* OBSOLETE static void */
+/* OBSOLETE init_mm_ops (void) */
+/* OBSOLETE { */
+/* OBSOLETE mm_ops.to_shortname = "minimon"; */
+/* OBSOLETE mm_ops.to_longname = "Remote AMD/Minimon target"; */
+/* OBSOLETE mm_ops.to_doc = "Remote debug an AMD 290*0 using the MiniMon dbg core on the target"; */
+/* OBSOLETE mm_ops.to_open = mm_open; */
+/* OBSOLETE mm_ops.to_close = mm_close; */
+/* OBSOLETE mm_ops.to_attach = mm_attach; */
+/* OBSOLETE mm_ops.to_post_attach = NULL; */
+/* OBSOLETE mm_ops.to_require_attach = NULL; */
+/* OBSOLETE mm_ops.to_detach = mm_detach; */
+/* OBSOLETE mm_ops.to_require_detach = NULL; */
+/* OBSOLETE mm_ops.to_resume = mm_resume; */
+/* OBSOLETE mm_ops.to_wait = mm_wait; */
+/* OBSOLETE mm_ops.to_post_wait = NULL; */
+/* OBSOLETE mm_ops.to_fetch_registers = mm_fetch_registers; */
+/* OBSOLETE mm_ops.to_store_registers = mm_store_registers; */
+/* OBSOLETE mm_ops.to_prepare_to_store = mm_prepare_to_store; */
+/* OBSOLETE mm_ops.to_xfer_memory = mm_xfer_inferior_memory; */
+/* OBSOLETE mm_ops.to_files_info = mm_files_info; */
+/* OBSOLETE mm_ops.to_insert_breakpoint = mm_insert_breakpoint; */
+/* OBSOLETE mm_ops.to_remove_breakpoint = mm_remove_breakpoint; */
+/* OBSOLETE mm_ops.to_terminal_init = 0; */
+/* OBSOLETE mm_ops.to_terminal_inferior = 0; */
+/* OBSOLETE mm_ops.to_terminal_ours_for_output = 0; */
+/* OBSOLETE mm_ops.to_terminal_ours = 0; */
+/* OBSOLETE mm_ops.to_terminal_info = 0; */
+/* OBSOLETE mm_ops.to_kill = mm_kill; */
+/* OBSOLETE mm_ops.to_load = mm_load; */
+/* OBSOLETE mm_ops.to_lookup_symbol = 0; */
+/* OBSOLETE mm_ops.to_create_inferior = mm_create_inferior; */
+/* OBSOLETE mm_ops.to_post_startup_inferior = NULL; */
+/* OBSOLETE mm_ops.to_acknowledge_created_inferior = NULL; */
+/* OBSOLETE mm_ops.to_clone_and_follow_inferior = NULL; */
+/* OBSOLETE mm_ops.to_post_follow_inferior_by_clone = NULL; */
+/* OBSOLETE mm_ops.to_insert_fork_catchpoint = NULL; */
+/* OBSOLETE mm_ops.to_remove_fork_catchpoint = NULL; */
+/* OBSOLETE mm_ops.to_insert_vfork_catchpoint = NULL; */
+/* OBSOLETE mm_ops.to_remove_vfork_catchpoint = NULL; */
+/* OBSOLETE mm_ops.to_has_forked = NULL; */
+/* OBSOLETE mm_ops.to_has_vforked = NULL; */
+/* OBSOLETE mm_ops.to_can_follow_vfork_prior_to_exec = NULL; */
+/* OBSOLETE mm_ops.to_post_follow_vfork = NULL; */
+/* OBSOLETE mm_ops.to_insert_exec_catchpoint = NULL; */
+/* OBSOLETE mm_ops.to_remove_exec_catchpoint = NULL; */
+/* OBSOLETE mm_ops.to_has_execd = NULL; */
+/* OBSOLETE mm_ops.to_reported_exec_events_per_exec_call = NULL; */
+/* OBSOLETE mm_ops.to_has_exited = NULL; */
+/* OBSOLETE mm_ops.to_mourn_inferior = mm_mourn; */
+/* OBSOLETE mm_ops.to_can_run = 0; */
+/* OBSOLETE mm_ops.to_notice_signals = 0; */
+/* OBSOLETE mm_ops.to_thread_alive = 0; */
+/* OBSOLETE mm_ops.to_stop = 0; */
+/* OBSOLETE mm_ops.to_pid_to_exec_file = NULL; */
+/* OBSOLETE mm_ops.to_stratum = process_stratum; */
+/* OBSOLETE mm_ops.DONT_USE = 0; */
+/* OBSOLETE mm_ops.to_has_all_memory = 1; */
+/* OBSOLETE mm_ops.to_has_memory = 1; */
+/* OBSOLETE mm_ops.to_has_stack = 1; */
+/* OBSOLETE mm_ops.to_has_registers = 1; */
+/* OBSOLETE mm_ops.to_has_execution = 1; */
+/* OBSOLETE mm_ops.to_sections = 0; */
+/* OBSOLETE mm_ops.to_sections_end = 0; */
+/* OBSOLETE mm_ops.to_magic = OPS_MAGIC; */
+/* OBSOLETE }; */
+/* OBSOLETE */
+/* OBSOLETE void */
+/* OBSOLETE _initialize_remote_mm (void) */
+/* OBSOLETE { */
+/* OBSOLETE init_mm_ops (); */
+/* OBSOLETE add_target (&mm_ops); */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE #ifdef NO_HIF_SUPPORT */
+/* OBSOLETE service_HIF (union msg_t *msg) */
+/* OBSOLETE { */
+/* OBSOLETE return (0); /* Emulate a failure */ */
+/* OBSOLETE } */
+/* OBSOLETE #endif */
-/* Remote debugging interface for AMD 29k interfaced via UDI, for GDB.
- Copyright 1990, 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001
- Free Software Foundation, Inc.
- Written by Daniel Mann. Contributed by AMD.
-
- This file is part of GDB.
-
- 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.
-
- 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.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA. */
-
-/* This is like remote.c but uses the Universal Debug Interface (UDI) to
- talk to the target hardware (or simulator). UDI is a TCP/IP based
- protocol; for hardware that doesn't run TCP, an interface adapter
- daemon talks UDI on one side, and talks to the hardware (typically
- over a serial port) on the other side.
-
- - Originally written by Daniel Mann at AMD for MiniMON and gdb 3.91.6.
- - David Wood (wood@lab.ultra.nyu.edu) at New York University adapted this
- file to gdb 3.95. I was unable to get this working on sun3os4
- with termio, only with sgtty.
- - Daniel Mann at AMD took the 3.95 adaptions above and replaced
- MiniMON interface with UDI-p interface. */
-
-#include "defs.h"
-#include "frame.h"
-#include "inferior.h"
-#include "value.h"
-#include <ctype.h>
-#include <fcntl.h>
-#include <errno.h>
-#include "gdb_string.h"
-#include "terminal.h"
-#include "target.h"
-#include "29k-share/udi/udiproc.h"
-#include "gdbcmd.h"
-#include "bfd.h"
-#include "gdbcore.h" /* For download function */
-#include "regcache.h"
-
-/* access the register store directly, without going through
- the normal handler functions. This avoids an extra data copy. */
-
-extern int stop_soon_quietly; /* for wait_for_inferior */
-extern struct value *call_function_by_hand ();
-static void udi_resume (ptid_t ptid, int step, enum target_signal sig);
-static void udi_fetch_registers (int regno);
-static void udi_load (char *args, int from_tty);
-static void fetch_register (int regno);
-static void udi_store_registers (int regno);
-static int store_register (int regno);
-static int regnum_to_srnum (int regno);
-static void udi_close (int quitting);
-static CPUSpace udi_memory_space (CORE_ADDR addr);
-static int udi_write_inferior_memory (CORE_ADDR memaddr, char *myaddr,
- int len);
-static int udi_read_inferior_memory (CORE_ADDR memaddr, char *myaddr,
- int len);
-static void download (char *load_arg_string, int from_tty);
-char CoffFileName[100] = "";
-
-#define FREEZE_MODE (read_register(CPS_REGNUM) & 0x400)
-#define USE_SHADOW_PC ((processor_type == a29k_freeze_mode) && FREEZE_MODE)
-
-static int timeout = 5;
-extern struct target_ops udi_ops; /* Forward declaration */
-
-/* Special register enumeration.
- */
-
-/******************************************************************* UDI DATA*/
-#define MAXDATA 2*1024 /* max UDI[read/write] byte size */
-/* Descriptor for I/O to remote machine. Initialize it to -1 so that
- udi_open knows that we don't have a file open when the program
- starts. */
-
-UDISessionId udi_session_id = -1;
-static char *udi_config_id;
-
-CPUOffset IMemStart = 0;
-CPUSizeT IMemSize = 0;
-CPUOffset DMemStart = 0;
-CPUSizeT DMemSize = 0;
-CPUOffset RMemStart = 0;
-CPUSizeT RMemSize = 0;
-UDIUInt32 CPUPRL;
-UDIUInt32 CoProcPRL;
-
-UDIMemoryRange address_ranges[2]; /* Text and data */
-UDIResource entry =
-{0, 0}; /* Entry point */
-CPUSizeT stack_sizes[2]; /* Regular and memory stacks */
-
-#define SBUF_MAX 1024 /* maximum size of string handling buffer */
-char sbuf[SBUF_MAX];
-
-typedef struct bkpt_entry_str
- {
- UDIResource Addr;
- UDIUInt32 PassCount;
- UDIBreakType Type;
- unsigned int BreakId;
- }
-bkpt_entry_t;
-#define BKPT_TABLE_SIZE 40
-static bkpt_entry_t bkpt_table[BKPT_TABLE_SIZE];
-extern char dfe_errmsg[]; /* error string */
-
-/* malloc'd name of the program on the remote system. */
-static char *prog_name = NULL;
-
-/* This is called not only when we first attach, but also when the
- user types "run" after having attached. */
-
-static void
-udi_create_inferior (char *execfile, char *args, char **env)
-{
- char *args1;
-
- if (execfile)
- {
- if (prog_name != NULL)
- xfree (prog_name);
- prog_name = savestring (execfile, strlen (execfile));
- }
- else if (entry.Offset)
- execfile = "";
- else
- error ("No image loaded into target.");
-
- if (udi_session_id < 0)
- {
- /* If the TIP is not open, open it. */
- if (UDIConnect (udi_config_id, &udi_session_id))
- error ("UDIConnect() failed: %s\n", dfe_errmsg);
- /* We will need to download the program. */
- entry.Offset = 0;
- }
-
- inferior_ptid = pid_to_ptid (40000);
-
- if (!entry.Offset)
- download (execfile, 0);
-
- args1 = alloca (strlen (execfile) + strlen (args) + 2);
-
- if (execfile[0] == '\0')
-
- /* It is empty. We need to quote it somehow, or else the target
- will think there is no argument being passed here. According
- to the UDI spec it is quoted "according to TIP OS rules" which
- I guess means quoting it like the Unix shell should work
- (sounds pretty bogus to me...). In fact it doesn't work (with
- isstip anyway), but passing in two quotes as the argument seems
- like a reasonable enough behavior anyway (I guess). */
-
- strcpy (args1, "''");
- else
- strcpy (args1, execfile);
- strcat (args1, " ");
- strcat (args1, args);
-
- UDIInitializeProcess (address_ranges, /* ProcessMemory[] */
- (UDIInt) 2, /* NumberOfRanges */
- entry, /* EntryPoint */
- stack_sizes, /* *StackSizes */
- (UDIInt) 2, /* NumberOfStacks */
- args1); /* ArgString */
-
- init_wait_for_inferior ();
- clear_proceed_status ();
- proceed (-1, TARGET_SIGNAL_DEFAULT, 0);
-}
-
-static void
-udi_mourn (void)
-{
-#if 0
- /* Requiring "target udi" each time you run is a major pain. I suspect
- this was just blindy copied from remote.c, in which "target" and
- "run" are combined. Having a udi target without an inferior seems
- to work between "target udi" and "run", so why not now? */
- pop_target (); /* Pop back to no-child state */
-#endif
- /* But if we're going to want to run it again, we better remove the
- breakpoints... */
- remove_breakpoints ();
- generic_mourn_inferior ();
-}
-
-/******************************************************************** UDI_OPEN
-** Open a connection to remote TIP.
- NAME is the socket domain used for communication with the TIP,
- then a space and the socket name or TIP-host name.
- '<udi_udi_config_id>' for example.
- */
-
-/* XXX - need cleanups for udiconnect for various failures!!! */
-
-static void
-udi_open (char *name, int from_tty)
-{
- unsigned int prl;
- char *p;
- int cnt;
- UDIMemoryRange KnownMemory[10];
- UDIUInt32 ChipVersions[10];
- UDIInt NumberOfRanges = 10;
- UDIInt NumberOfChips = 10;
- UDIPId PId;
- UDIUInt32 TIPId, TargetId, DFEId, DFE, TIP, DFEIPCId, TIPIPCId;
-
- target_preopen (from_tty);
-
- entry.Offset = 0;
-
- for (cnt = 0; cnt < BKPT_TABLE_SIZE; cnt++)
- bkpt_table[cnt].Type = 0;
-
- if (udi_config_id)
- xfree (udi_config_id);
-
- if (!name)
- error ("Usage: target udi config_id, where config_id appears in udi_soc file");
-
- udi_config_id = xstrdup (strtok (name, " \t"));
-
- if (UDIConnect (udi_config_id, &udi_session_id))
- /* FIXME: Should set udi_session_id to -1 here. */
- error ("UDIConnect() failed: %s\n", dfe_errmsg);
-
- push_target (&udi_ops);
-
- /*
- ** Initialize target configuration structure (global)
- */
- if (UDIGetTargetConfig (KnownMemory, &NumberOfRanges,
- ChipVersions, &NumberOfChips))
- error ("UDIGetTargetConfig() failed");
- if (NumberOfChips > 2)
- fprintf_unfiltered (gdb_stderr, "Target has more than one processor\n");
- for (cnt = 0; cnt < NumberOfRanges; cnt++)
- {
- switch (KnownMemory[cnt].Space)
- {
- default:
- fprintf_unfiltered (gdb_stderr, "UDIGetTargetConfig() unknown memory space\n");
- break;
- case UDI29KCP_S:
- break;
- case UDI29KIROMSpace:
- RMemStart = KnownMemory[cnt].Offset;
- RMemSize = KnownMemory[cnt].Size;
- break;
- case UDI29KIRAMSpace:
- IMemStart = KnownMemory[cnt].Offset;
- IMemSize = KnownMemory[cnt].Size;
- break;
- case UDI29KDRAMSpace:
- DMemStart = KnownMemory[cnt].Offset;
- DMemSize = KnownMemory[cnt].Size;
- break;
- }
- }
-
- a29k_get_processor_type ();
-
- if (UDICreateProcess (&PId))
- fprintf_unfiltered (gdb_stderr, "UDICreateProcess() failed\n");
-
- /* Print out some stuff, letting the user now what's going on */
- if (UDICapabilities (&TIPId, &TargetId, DFEId, DFE, &TIP, &DFEIPCId,
- &TIPIPCId, sbuf))
- error ("UDICapabilities() failed");
- if (from_tty)
- {
- printf_filtered ("Connected via UDI socket,\n\
- DFE-IPC version %x.%x.%x TIP-IPC version %x.%x.%x TIP version %x.%x.%x\n %s\n",
- (DFEIPCId >> 8) & 0xf, (DFEIPCId >> 4) & 0xf, DFEIPCId & 0xf,
- (TIPIPCId >> 8) & 0xf, (TIPIPCId >> 4) & 0xf, TIPIPCId & 0xf,
- (TargetId >> 8) & 0xf, (TargetId >> 4) & 0xf, TargetId & 0xf,
- sbuf);
- }
-}
-
-/******************************************************************* UDI_CLOSE
- Close the open connection to the TIP process.
- Use this when you want to detach and do something else
- with your gdb. */
-static void
-udi_close ( /*FIXME: how is quitting used */
- int quitting)
-{
- if (udi_session_id < 0)
- return;
-
- /* We should never get here if there isn't something valid in
- udi_session_id. */
-
- if (UDIDisconnect (udi_session_id, UDITerminateSession))
- {
- if (quitting)
- warning ("UDIDisconnect() failed in udi_close");
- else
- error ("UDIDisconnect() failed in udi_close");
- }
-
- /* Do not try to close udi_session_id again, later in the program. */
- udi_session_id = -1;
- inferior_ptid = null_ptid;
-
- printf_filtered (" Ending remote debugging\n");
-}
-
-/**************************************************************** UDI_ATACH */
-/* Attach to a program that is already loaded and running
- * Upon exiting the process's execution is stopped.
- */
-static void
-udi_attach (char *args, int from_tty)
-{
- UDIResource From;
- UDIInt32 PC_adds;
- UDICount Count = 1;
- UDISizeT Size = 4;
- UDICount CountDone;
- UDIBool HostEndian = 0;
- UDIError err;
-
- if (args == NULL)
- error_no_arg ("program to attach");
-
- if (udi_session_id < 0)
- error ("UDI connection not opened yet, use the 'target udi' command.\n");
-
- if (from_tty)
- printf_unfiltered ("Attaching to remote program %s...\n", prog_name);
-
- UDIStop ();
- From.Space = UDI29KSpecialRegs;
- From.Offset = 11;
- if (err = UDIRead (From, &PC_adds, Count, Size, &CountDone, HostEndian))
- error ("UDIRead failed in udi_attach");
- printf_unfiltered ("Remote process is now halted, pc1 = 0x%x.\n", PC_adds);
-}
-/************************************************************* UDI_DETACH */
-/* Terminate the open connection to the TIP process.
- Use this when you want to detach and do something else
- with your gdb. Leave remote process running (with no breakpoints set). */
-static void
-udi_detach (char *args, int from_tty)
-{
-
- remove_breakpoints (); /* Just in case there were any left in */
-
- if (UDIDisconnect (udi_session_id, UDIContinueSession))
- error ("UDIDisconnect() failed in udi_detach");
-
- /* Don't try to UDIDisconnect it again in udi_close, which is called from
- pop_target. */
- udi_session_id = -1;
- inferior_ptid = null_ptid;
-
- pop_target ();
-
- if (from_tty)
- printf_unfiltered ("Detaching from TIP\n");
-}
-
-
-/****************************************************************** UDI_RESUME
-** Tell the remote machine to resume. */
-
-static void
-udi_resume (ptid_t ptid, int step, enum target_signal sig)
-{
- UDIError tip_error;
- UDIUInt32 Steps = 1;
- UDIStepType StepType = UDIStepNatural;
- UDIRange Range;
-
- if (step) /* step 1 instruction */
- {
- tip_error = UDIStep (Steps, StepType, Range);
- if (!tip_error)
- return;
-
- fprintf_unfiltered (gdb_stderr, "UDIStep() error = %d\n", tip_error);
- error ("failed in udi_resume");
- }
-
- if (UDIExecute ())
- error ("UDIExecute() failed in udi_resume");
-}
-
-/******************************************************************** UDI_WAIT
-** Wait until the remote machine stops, then return,
- storing status in STATUS just as `wait' would. */
-
-static ptid_t
-udi_wait (ptid_t ptid, struct target_waitstatus *status)
-{
- UDIInt32 MaxTime;
- UDIPId PId;
- UDIInt32 StopReason;
- UDISizeT CountDone;
- int old_timeout = timeout;
- int old_immediate_quit = immediate_quit;
- int i;
-
- status->kind = TARGET_WAITKIND_EXITED;
- status->value.integer = 0;
-
-/* wait for message to arrive. It should be:
- If the target stops executing, udi_wait() should return.
- */
- timeout = 0; /* Wait indefinetly for a message */
- immediate_quit = 1; /* Helps ability to QUIT */
-
- while (1)
- {
- i = 0;
- MaxTime = UDIWaitForever;
- UDIWait (MaxTime, &PId, &StopReason);
- QUIT; /* Let user quit if they want */
-
- switch (StopReason & UDIGrossState)
- {
- case UDIStdoutReady:
- if (UDIGetStdout (sbuf, (UDISizeT) SBUF_MAX, &CountDone))
- /* This is said to happen if the program tries to output
- a whole bunch of output (more than SBUF_MAX, I would
- guess). It doesn't seem to happen with the simulator. */
- warning ("UDIGetStdout() failed in udi_wait");
- fwrite (sbuf, 1, CountDone, stdout);
- gdb_flush (gdb_stdout);
- continue;
-
- case UDIStderrReady:
- UDIGetStderr (sbuf, (UDISizeT) SBUF_MAX, &CountDone);
- fwrite (sbuf, 1, CountDone, stderr);
- gdb_flush (gdb_stderr);
- continue;
-
- case UDIStdinNeeded:
- {
- int ch;
- i = 0;
- do
- {
- ch = getchar ();
- if (ch == EOF)
- break;
- sbuf[i++] = ch;
- }
- while (i < SBUF_MAX && ch != '\n');
- UDIPutStdin (sbuf, (UDISizeT) i, &CountDone);
- continue;
- }
-
- case UDIRunning:
- /* In spite of the fact that we told UDIWait to wait forever, it will
- return spuriously sometimes. */
- case UDIStdinModeX:
- continue;
- default:
- break;
- }
- break;
- }
-
- switch (StopReason & UDIGrossState)
- {
- case UDITrapped:
- printf_unfiltered ("Am290*0 received vector number %d\n", StopReason >> 24);
-
- switch ((StopReason >> 8) & 0xff)
- {
- case 0: /* Illegal opcode */
- printf_unfiltered (" (break point)\n");
- status->kind = TARGET_WAITKIND_STOPPED;
- status->value.sig = TARGET_SIGNAL_TRAP;
- break;
- case 1: /* Unaligned Access */
- status->kind = TARGET_WAITKIND_STOPPED;
- status->value.sig = TARGET_SIGNAL_BUS;
- break;
- case 3:
- case 4:
- status->kind = TARGET_WAITKIND_STOPPED;
- status->value.sig = TARGET_SIGNAL_FPE;
- break;
- case 5: /* Protection Violation */
- status->kind = TARGET_WAITKIND_STOPPED;
- /* Why not SEGV? What is a Protection Violation? */
- status->value.sig = TARGET_SIGNAL_ILL;
- break;
- case 6:
- case 7:
- case 8: /* User Instruction Mapping Miss */
- case 9: /* User Data Mapping Miss */
- case 10: /* Supervisor Instruction Mapping Miss */
- case 11: /* Supervisor Data Mapping Miss */
- status->kind = TARGET_WAITKIND_STOPPED;
- status->value.sig = TARGET_SIGNAL_SEGV;
- break;
- case 12:
- case 13:
- status->kind = TARGET_WAITKIND_STOPPED;
- status->value.sig = TARGET_SIGNAL_ILL;
- break;
- case 14: /* Timer */
- status->kind = TARGET_WAITKIND_STOPPED;
- status->value.sig = TARGET_SIGNAL_ALRM;
- break;
- case 15: /* Trace */
- status->kind = TARGET_WAITKIND_STOPPED;
- status->value.sig = TARGET_SIGNAL_TRAP;
- break;
- case 16: /* INTR0 */
- case 17: /* INTR1 */
- case 18: /* INTR2 */
- case 19: /* INTR3/Internal */
- case 20: /* TRAP0 */
- case 21: /* TRAP1 */
- status->kind = TARGET_WAITKIND_STOPPED;
- status->value.sig = TARGET_SIGNAL_INT;
- break;
- case 22: /* Floating-Point Exception */
- status->kind = TARGET_WAITKIND_STOPPED;
- /* Why not FPE? */
- status->value.sig = TARGET_SIGNAL_ILL;
- break;
- case 77: /* assert 77 */
- status->kind = TARGET_WAITKIND_STOPPED;
- status->value.sig = TARGET_SIGNAL_TRAP;
- break;
- default:
- status->kind = TARGET_WAITKIND_EXITED;
- status->value.integer = 0;
- }
- break;
- case UDINotExecuting:
- status->kind = TARGET_WAITKIND_STOPPED;
- status->value.sig = TARGET_SIGNAL_TERM;
- break;
- case UDIStopped:
- status->kind = TARGET_WAITKIND_STOPPED;
- status->value.sig = TARGET_SIGNAL_TSTP;
- break;
- case UDIWarned:
- status->kind = TARGET_WAITKIND_STOPPED;
- status->value.sig = TARGET_SIGNAL_URG;
- break;
- case UDIStepped:
- case UDIBreak:
- status->kind = TARGET_WAITKIND_STOPPED;
- status->value.sig = TARGET_SIGNAL_TRAP;
- break;
- case UDIWaiting:
- status->kind = TARGET_WAITKIND_STOPPED;
- status->value.sig = TARGET_SIGNAL_STOP;
- break;
- case UDIHalted:
- status->kind = TARGET_WAITKIND_STOPPED;
- status->value.sig = TARGET_SIGNAL_KILL;
- break;
- case UDIExited:
- default:
- status->kind = TARGET_WAITKIND_EXITED;
- status->value.integer = 0;
- }
-
- timeout = old_timeout; /* Restore original timeout value */
- immediate_quit = old_immediate_quit;
- return inferior_ptid;
-}
-
-#if 0
-/* Handy for debugging */
-udi_pc (void)
-{
- UDIResource From;
- UDIUInt32 *To;
- UDICount Count;
- UDISizeT Size = 4;
- UDICount CountDone;
- UDIBool HostEndian = 0;
- UDIError err;
- int pc[2];
- unsigned long myregs[256];
- int i;
-
- From.Space = UDI29KPC;
- From.Offset = 0;
- To = (UDIUInt32 *) pc;
- Count = 2;
-
- err = UDIRead (From, To, Count, Size, &CountDone, HostEndian);
-
- printf_unfiltered ("err = %d, CountDone = %d, pc[0] = 0x%x, pc[1] = 0x%x\n",
- err, CountDone, pc[0], pc[1]);
-
- udi_fetch_registers (-1);
-
- printf_unfiltered ("other pc1 = 0x%x, pc0 = 0x%x\n", *(int *) ®isters[4 * PC_REGNUM],
- *(int *) ®isters[4 * NPC_REGNUM]);
-
- /* Now, read all the registers globally */
-
- From.Space = UDI29KGlobalRegs;
- From.Offset = 0;
- err = UDIRead (From, myregs, 256, 4, &CountDone, HostEndian);
-
- printf ("err = %d, CountDone = %d\n", err, CountDone);
-
- printf ("\n");
-
- for (i = 0; i < 256; i += 2)
- printf ("%d:\t%#10x\t%11d\t%#10x\t%11d\n", i, myregs[i], myregs[i],
- myregs[i + 1], myregs[i + 1]);
- printf ("\n");
-
- return pc[0];
-}
-#endif
-
-/********************************************************** UDI_FETCH_REGISTERS
- * Read a remote register 'regno'.
- * If regno==-1 then read all the registers.
- */
-static void
-udi_fetch_registers (int regno)
-{
- UDIResource From;
- UDIUInt32 *To;
- UDICount Count;
- UDISizeT Size = 4;
- UDICount CountDone;
- UDIBool HostEndian = 0;
- UDIError err;
- int i;
-
- if (regno >= 0)
- {
- fetch_register (regno);
- return;
- }
-
-/* Gr1/rsp */
-
- From.Space = UDI29KGlobalRegs;
- From.Offset = 1;
- To = (UDIUInt32 *) & registers[4 * GR1_REGNUM];
- Count = 1;
- if (err = UDIRead (From, To, Count, Size, &CountDone, HostEndian))
- error ("UDIRead() failed in udi_fetch_registers");
-
- register_valid[GR1_REGNUM] = 1;
-
-#if defined(GR64_REGNUM) /* Read gr64-127 */
-
-/* Global Registers gr64-gr95 */
-
- From.Space = UDI29KGlobalRegs;
- From.Offset = 64;
- To = (UDIUInt32 *) & registers[4 * GR64_REGNUM];
- Count = 32;
- if (err = UDIRead (From, To, Count, Size, &CountDone, HostEndian))
- error ("UDIRead() failed in udi_fetch_registers");
-
- for (i = GR64_REGNUM; i < GR64_REGNUM + 32; i++)
- register_valid[i] = 1;
-
-#endif /* GR64_REGNUM */
-
-/* Global Registers gr96-gr127 */
-
- From.Space = UDI29KGlobalRegs;
- From.Offset = 96;
- To = (UDIUInt32 *) & registers[4 * GR96_REGNUM];
- Count = 32;
- if (err = UDIRead (From, To, Count, Size, &CountDone, HostEndian))
- error ("UDIRead() failed in udi_fetch_registers");
-
- for (i = GR96_REGNUM; i < GR96_REGNUM + 32; i++)
- register_valid[i] = 1;
-
-/* Local Registers */
-
- From.Space = UDI29KLocalRegs;
- From.Offset = 0;
- To = (UDIUInt32 *) & registers[4 * LR0_REGNUM];
- Count = 128;
- if (err = UDIRead (From, To, Count, Size, &CountDone, HostEndian))
- error ("UDIRead() failed in udi_fetch_registers");
-
- for (i = LR0_REGNUM; i < LR0_REGNUM + 128; i++)
- register_valid[i] = 1;
-
-/* Protected Special Registers */
-
- From.Space = UDI29KSpecialRegs;
- From.Offset = 0;
- To = (UDIUInt32 *) & registers[4 * SR_REGNUM (0)];
- Count = 15;
- if (err = UDIRead (From, To, Count, Size, &CountDone, HostEndian))
- error ("UDIRead() failed in udi_fetch_registers");
-
- for (i = SR_REGNUM (0); i < SR_REGNUM (0) + 15; i++)
- register_valid[i] = 1;
-
- if (USE_SHADOW_PC)
- { /* Let regno_to_srnum() handle the register number */
- fetch_register (NPC_REGNUM);
- fetch_register (PC_REGNUM);
- fetch_register (PC2_REGNUM);
-
-/* Unprotected Special Registers sr128-sr135 */
-
- From.Space = UDI29KSpecialRegs;
- From.Offset = 128;
- To = (UDIUInt32 *) & registers[4 * SR_REGNUM (128)];
- Count = 135 - 128 + 1;
- if (err = UDIRead (From, To, Count, Size, &CountDone, HostEndian))
- error ("UDIRead() failed in udi_fetch_registers");
-
- for (i = SR_REGNUM (128); i < SR_REGNUM (128) + 135 - 128 + 1; i++)
- register_valid[i] = 1;
- }
-
- if (remote_debug)
- {
- fprintf_unfiltered (gdb_stdlog, "Fetching all registers\n");
- fprintf_unfiltered (gdb_stdlog,
- "Fetching PC0 = 0x%x, PC1 = 0x%x, PC2 = 0x%x\n",
- read_register (NPC_REGNUM),
- read_register (PC_REGNUM),
- read_register (PC2_REGNUM));
- }
-
- /* There doesn't seem to be any way to get these. */
- {
- int val = -1;
- supply_register (FPE_REGNUM, (char *) &val);
- supply_register (INTE_REGNUM, (char *) &val);
- supply_register (FPS_REGNUM, (char *) &val);
- supply_register (EXO_REGNUM, (char *) &val);
- }
-}
-
-
-/********************************************************* UDI_STORE_REGISTERS
-** Store register regno into the target.
- * If regno==-1 then store all the registers.
- */
-
-static void
-udi_store_registers (int regno)
-{
- UDIUInt32 *From;
- UDIResource To;
- UDICount Count;
- UDISizeT Size = 4;
- UDICount CountDone;
- UDIBool HostEndian = 0;
-
- if (regno >= 0)
- {
- store_register (regno);
- return;
- }
-
- if (remote_debug)
- {
- fprintf_unfiltered (gdb_stdlog, "Storing all registers\n");
- fprintf_unfiltered (gdb_stdlog,
- "PC0 = 0x%x, PC1 = 0x%x, PC2 = 0x%x\n",
- read_register (NPC_REGNUM),
- read_register (PC_REGNUM),
- read_register (PC2_REGNUM));
- }
-
-/* Gr1/rsp */
-
- From = (UDIUInt32 *) & registers[4 * GR1_REGNUM];
- To.Space = UDI29KGlobalRegs;
- To.Offset = 1;
- Count = 1;
- if (UDIWrite (From, To, Count, Size, &CountDone, HostEndian))
- error ("UDIWrite() failed in udi_store_regisetrs");
-
-#if defined(GR64_REGNUM)
-
-/* Global registers gr64-gr95 */
-
- From = (UDIUInt32 *) & registers[4 * GR64_REGNUM];
- To.Space = UDI29KGlobalRegs;
- To.Offset = 64;
- Count = 32;
- if (UDIWrite (From, To, Count, Size, &CountDone, HostEndian))
- error ("UDIWrite() failed in udi_store_regisetrs");
-
-#endif /* GR64_REGNUM */
-
-/* Global registers gr96-gr127 */
-
- From = (UDIUInt32 *) & registers[4 * GR96_REGNUM];
- To.Space = UDI29KGlobalRegs;
- To.Offset = 96;
- Count = 32;
- if (UDIWrite (From, To, Count, Size, &CountDone, HostEndian))
- error ("UDIWrite() failed in udi_store_regisetrs");
-
-/* Local Registers */
-
- From = (UDIUInt32 *) & registers[4 * LR0_REGNUM];
- To.Space = UDI29KLocalRegs;
- To.Offset = 0;
- Count = 128;
- if (UDIWrite (From, To, Count, Size, &CountDone, HostEndian))
- error ("UDIWrite() failed in udi_store_regisetrs");
-
-
- /* Protected Special Registers *//* VAB through TMR */
-
- From = (UDIUInt32 *) & registers[4 * SR_REGNUM (0)];
- To.Space = UDI29KSpecialRegs;
- To.Offset = 0;
- Count = 10;
- if (UDIWrite (From, To, Count, Size, &CountDone, HostEndian))
- error ("UDIWrite() failed in udi_store_regisetrs");
-
-/* PC0, PC1, PC2 possibly as shadow registers */
-
- From = (UDIUInt32 *) & registers[4 * SR_REGNUM (10)];
- To.Space = UDI29KSpecialRegs;
- Count = 3;
- if (USE_SHADOW_PC)
- To.Offset = 20; /* SPC0 */
- else
- To.Offset = 10; /* PC0 */
- if (UDIWrite (From, To, Count, Size, &CountDone, HostEndian))
- error ("UDIWrite() failed in udi_store_regisetrs");
-
-/* PC1 via UDI29KPC */
-
- From = (UDIUInt32 *) & registers[4 * PC_REGNUM];
- To.Space = UDI29KPC;
- To.Offset = 0; /* PC1 */
- Count = 1;
- if (UDIWrite (From, To, Count, Size, &CountDone, HostEndian))
- error ("UDIWrite() failed in udi_store_regisetrs");
-
- /* LRU and MMU */
-
- From = (UDIUInt32 *) & registers[4 * SR_REGNUM (13)];
- To.Space = UDI29KSpecialRegs;
- To.Offset = 13;
- Count = 2;
- if (UDIWrite (From, To, Count, Size, &CountDone, HostEndian))
- error ("UDIWrite() failed in udi_store_regisetrs");
-
-/* Unprotected Special Registers */
-
- From = (UDIUInt32 *) & registers[4 * SR_REGNUM (128)];
- To.Space = UDI29KSpecialRegs;
- To.Offset = 128;
- Count = 135 - 128 + 1;
- if (UDIWrite (From, To, Count, Size, &CountDone, HostEndian))
- error ("UDIWrite() failed in udi_store_regisetrs");
-
- registers_changed ();
-}
-
-/****************************************************** UDI_PREPARE_TO_STORE */
-/* Get ready to modify the registers array. On machines which store
- individual registers, this doesn't need to do anything. On machines
- which store all the registers in one fell swoop, this makes sure
- that registers contains all the registers from the program being
- debugged. */
-
-static void
-udi_prepare_to_store (void)
-{
- /* Do nothing, since we can store individual regs */
-}
-
-/********************************************************** TRANSLATE_ADDR */
-static CORE_ADDR
-translate_addr (CORE_ADDR addr)
-{
-#if defined(ULTRA3) && defined(KERNEL_DEBUGGING)
- /* Check for a virtual address in the kernel */
- /* Assume physical address of ublock is in paddr_u register */
- /* FIXME: doesn't work for user virtual addresses */
- if (addr >= UVADDR)
- {
- /* PADDR_U register holds the physical address of the ublock */
- CORE_ADDR i = (CORE_ADDR) read_register (PADDR_U_REGNUM);
- return (i + addr - (CORE_ADDR) UVADDR);
- }
- else
- {
- return (addr);
- }
-#else
- return (addr);
-#endif
-}
-/************************************************* UDI_XFER_INFERIOR_MEMORY */
-/* FIXME! Merge these two. */
-static int
-udi_xfer_inferior_memory (CORE_ADDR memaddr, char *myaddr, int len, int write,
- struct mem_attrib *attrib ATTRIBUTE_UNUSED,
- struct target_ops *target ATTRIBUTE_UNUSED)
-{
-
- memaddr = translate_addr (memaddr);
-
- if (write)
- return udi_write_inferior_memory (memaddr, myaddr, len);
- else
- return udi_read_inferior_memory (memaddr, myaddr, len);
-}
-
-/********************************************************** UDI_FILES_INFO */
-static void
-udi_files_info (struct target_ops *target)
-{
- printf_unfiltered ("\tAttached to UDI socket to %s", udi_config_id);
- if (prog_name != NULL)
- printf_unfiltered ("and running program %s", prog_name);
- printf_unfiltered (".\n");
-}
-
-/**************************************************** UDI_INSERT_BREAKPOINT */
-static int
-udi_insert_breakpoint (CORE_ADDR addr, char *contents_cache)
-{
- int cnt;
- UDIError err;
-
- for (cnt = 0; cnt < BKPT_TABLE_SIZE; cnt++)
- if (bkpt_table[cnt].Type == 0) /* Find first free slot */
- break;
-
- if (cnt >= BKPT_TABLE_SIZE)
- error ("Too many breakpoints set");
-
- bkpt_table[cnt].Addr.Offset = addr;
- bkpt_table[cnt].Addr.Space = UDI29KIRAMSpace;
- bkpt_table[cnt].PassCount = 1;
- bkpt_table[cnt].Type = UDIBreakFlagExecute;
-
- err = UDISetBreakpoint (bkpt_table[cnt].Addr,
- bkpt_table[cnt].PassCount,
- bkpt_table[cnt].Type,
- &bkpt_table[cnt].BreakId);
-
- if (err == 0)
- return 0; /* Success */
-
- bkpt_table[cnt].Type = 0;
- error ("UDISetBreakpoint returned error code %d\n", err);
-}
-
-/**************************************************** UDI_REMOVE_BREAKPOINT */
-static int
-udi_remove_breakpoint (CORE_ADDR addr, char *contents_cache)
-{
- int cnt;
- UDIError err;
-
- for (cnt = 0; cnt < BKPT_TABLE_SIZE; cnt++)
- if (bkpt_table[cnt].Addr.Offset == addr) /* Find matching breakpoint */
- break;
-
- if (cnt >= BKPT_TABLE_SIZE)
- error ("Can't find breakpoint in table");
-
- bkpt_table[cnt].Type = 0;
-
- err = UDIClearBreakpoint (bkpt_table[cnt].BreakId);
- if (err == 0)
- return 0; /* Success */
-
- error ("UDIClearBreakpoint returned error code %d\n", err);
-}
-
-static void
-udi_kill (void)
-{
-
-#if 0
-/*
- UDIStop does not really work as advertised. It causes the TIP to close it's
- connection, which usually results in GDB dying with a SIGPIPE. For now, we
- just invoke udi_close, which seems to get things right.
- */
- UDIStop ();
-
- udi_session_id = -1;
- inferior_ptid = null_ptid;
-
- if (from_tty)
- printf_unfiltered ("Target has been stopped.");
-#endif /* 0 */
-#if 0
- udi_close (0);
- pop_target ();
-#endif /* 0 */
-
- /* Keep the target around, e.g. so "run" can do the right thing when
- we are already debugging something. */
-
- if (UDIDisconnect (udi_session_id, UDITerminateSession))
- {
- warning ("UDIDisconnect() failed");
- }
-
- /* Do not try to close udi_session_id again, later in the program. */
- udi_session_id = -1;
- inferior_ptid = null_ptid;
-}
-
-/*
- Load a program into the target. Args are: `program {options}'. The options
- are used to control loading of the program, and are NOT passed onto the
- loaded code as arguments. (You need to use the `run' command to do that.)
-
- The options are:
- -ms %d Set mem stack size to %d
- -rs %d Set regular stack size to %d
- -i send init info (default)
- -noi don't send init info
- -[tT] Load Text section
- -[dD] Load Data section
- -[bB] Load BSS section
- -[lL] Load Lit section
- */
-
-static void
-download (char *load_arg_string, int from_tty)
-{
-#define DEFAULT_MEM_STACK_SIZE 0x6000
-#define DEFAULT_REG_STACK_SIZE 0x2000
-
- char *token;
- char *filename;
- asection *section;
- bfd *pbfd;
- UDIError err;
- int load_text = 1, load_data = 1, load_bss = 1, load_lit = 1;
-
- address_ranges[0].Space = UDI29KIRAMSpace;
- address_ranges[0].Offset = 0xffffffff;
- address_ranges[0].Size = 0;
-
- address_ranges[1].Space = UDI29KDRAMSpace;
- address_ranges[1].Offset = 0xffffffff;
- address_ranges[1].Size = 0;
-
- stack_sizes[0] = DEFAULT_REG_STACK_SIZE;
- stack_sizes[1] = DEFAULT_MEM_STACK_SIZE;
-
- dont_repeat ();
-
- filename = strtok (load_arg_string, " \t");
- if (!filename)
- error ("Must specify at least a file name with the load command");
-
- filename = tilde_expand (filename);
- make_cleanup (xfree, filename);
-
- while (token = strtok (NULL, " \t"))
- {
- if (token[0] == '-')
- {
- token++;
-
- if (STREQ (token, "ms"))
- stack_sizes[1] = atol (strtok (NULL, " \t"));
- else if (STREQ (token, "rs"))
- stack_sizes[0] = atol (strtok (NULL, " \t"));
- else
- {
- load_text = load_data = load_bss = load_lit = 0;
-
- while (*token)
- {
- switch (*token++)
- {
- case 't':
- case 'T':
- load_text = 1;
- break;
- case 'd':
- case 'D':
- load_data = 1;
- break;
- case 'b':
- case 'B':
- load_bss = 1;
- break;
- case 'l':
- case 'L':
- load_lit = 1;
- break;
- default:
- error ("Unknown UDI load option -%s", token - 1);
- }
- }
- }
- }
- }
-
- pbfd = bfd_openr (filename, gnutarget);
-
- if (!pbfd)
- /* FIXME: should be using bfd_errmsg, not assuming it was
- bfd_error_system_call. */
- perror_with_name (filename);
-
- /* FIXME: should be checking for errors from bfd_close (for one thing,
- on error it does not free all the storage associated with the
- bfd). */
- make_cleanup_bfd_close (pbfd);
-
- QUIT;
- immediate_quit++;
-
- if (!bfd_check_format (pbfd, bfd_object))
- error ("It doesn't seem to be an object file");
-
- for (section = pbfd->sections; section; section = section->next)
- {
- if (bfd_get_section_flags (pbfd, section) & SEC_ALLOC)
- {
- UDIResource To;
- UDICount Count;
- unsigned long section_size, section_end;
- const char *section_name;
-
- section_name = bfd_get_section_name (pbfd, section);
- if (STREQ (section_name, ".text") && !load_text)
- continue;
- else if (STREQ (section_name, ".data") && !load_data)
- continue;
- else if (STREQ (section_name, ".bss") && !load_bss)
- continue;
- else if (STREQ (section_name, ".lit") && !load_lit)
- continue;
-
- To.Offset = bfd_get_section_vma (pbfd, section);
- section_size = bfd_section_size (pbfd, section);
- section_end = To.Offset + section_size;
-
- if (section_size == 0)
- /* This is needed at least in the BSS case, where the code
- below starts writing before it even checks the size. */
- continue;
-
- printf_unfiltered ("[Loading section %s at %x (%d bytes)]\n",
- section_name,
- To.Offset,
- section_size);
-
- if (bfd_get_section_flags (pbfd, section) & SEC_CODE)
- {
- To.Space = UDI29KIRAMSpace;
-
- address_ranges[0].Offset = min (address_ranges[0].Offset,
- To.Offset);
- address_ranges[0].Size = max (address_ranges[0].Size,
- section_end
- - address_ranges[0].Offset);
- }
- else
- {
- To.Space = UDI29KDRAMSpace;
-
- address_ranges[1].Offset = min (address_ranges[1].Offset,
- To.Offset);
- address_ranges[1].Size = max (address_ranges[1].Size,
- section_end
- - address_ranges[1].Offset);
- }
-
- if (bfd_get_section_flags (pbfd, section) & SEC_LOAD) /* Text, data or lit */
- {
- file_ptr fptr;
-
- fptr = 0;
-
- while (section_size > 0)
- {
- char buffer[1024];
-
- Count = min (section_size, 1024);
-
- bfd_get_section_contents (pbfd, section, buffer, fptr,
- Count);
-
- err = UDIWrite ((UDIHostMemPtr) buffer, /* From */
- To, /* To */
- Count, /* Count */
- (UDISizeT) 1, /* Size */
- &Count, /* CountDone */
- (UDIBool) 0); /* HostEndian */
- if (err)
- error ("UDIWrite failed, error = %d", err);
-
- To.Offset += Count;
- fptr += Count;
- section_size -= Count;
- }
- }
- else
- /* BSS */
- {
- UDIResource From;
- unsigned long zero = 0;
-
- /* Write a zero byte at the vma */
- /* FIXME: Broken for sections of 1-3 bytes (we test for
- zero above). */
- err = UDIWrite ((UDIHostMemPtr) & zero, /* From */
- To, /* To */
- (UDICount) 1, /* Count */
- (UDISizeT) 4, /* Size */
- &Count, /* CountDone */
- (UDIBool) 0); /* HostEndian */
- if (err)
- error ("UDIWrite failed, error = %d", err);
-
- From = To;
- To.Offset += 4;
-
- /* Now, duplicate it for the length of the BSS */
- err = UDICopy (From, /* From */
- To, /* To */
- (UDICount) (section_size / 4 - 1), /* Count */
- (UDISizeT) 4, /* Size */
- &Count, /* CountDone */
- (UDIBool) 1); /* Direction */
- if (err)
- {
- char message[100];
- int xerr;
-
- xerr = UDIGetErrorMsg (err, 100, message, &Count);
- if (!xerr)
- fprintf_unfiltered (gdb_stderr, "Error is %s\n", message);
- else
- fprintf_unfiltered (gdb_stderr, "xerr is %d\n", xerr);
- error ("UDICopy failed, error = %d", err);
- }
- }
-
- }
- }
-
- entry.Space = UDI29KIRAMSpace;
- entry.Offset = bfd_get_start_address (pbfd);
-
- immediate_quit--;
-}
-
-/* Function to download an image into the remote target. */
-
-static void
-udi_load (char *args, int from_tty)
-{
- download (args, from_tty);
-
- /* As a convenience, pick up any symbol info that is in the program
- being loaded. Note that we assume that the program is the``mainline'';
- if this is not always true, then this code will need to be augmented. */
- symbol_file_add (strtok (args, " \t"), from_tty, NULL, 1, 0);
-
- /* Getting new symbols may change our opinion about what is
- frameless. */
- reinit_frame_cache ();
-}
-
-/*************************************************** UDI_WRITE_INFERIOR_MEMORY
-** Copy LEN bytes of data from debugger memory at MYADDR
- to inferior's memory at MEMADDR. Returns number of bytes written. */
-static int
-udi_write_inferior_memory (CORE_ADDR memaddr, char *myaddr, int len)
-{
- int nwritten = 0;
- UDIUInt32 *From;
- UDIResource To;
- UDICount Count;
- UDISizeT Size = 1;
- UDICount CountDone = 0;
- UDIBool HostEndian = 0;
-
- To.Space = udi_memory_space (memaddr);
- From = (UDIUInt32 *) myaddr;
-
- while (nwritten < len)
- {
- Count = len - nwritten;
- if (Count > MAXDATA)
- Count = MAXDATA;
- To.Offset = memaddr + nwritten;
- if (UDIWrite (From, To, Count, Size, &CountDone, HostEndian))
- {
- error ("UDIWrite() failed in udi_write_inferior_memory");
- break;
- }
- else
- {
- nwritten += CountDone;
- From += CountDone;
- }
- }
- return (nwritten);
-}
-
-/**************************************************** UDI_READ_INFERIOR_MEMORY
-** Read LEN bytes from inferior memory at MEMADDR. Put the result
- at debugger address MYADDR. Returns number of bytes read. */
-static int
-udi_read_inferior_memory (CORE_ADDR memaddr, char *myaddr, int len)
-{
- int nread = 0;
- UDIResource From;
- UDIUInt32 *To;
- UDICount Count;
- UDISizeT Size = 1;
- UDICount CountDone = 0;
- UDIBool HostEndian = 0;
- UDIError err;
-
- From.Space = udi_memory_space (memaddr);
- To = (UDIUInt32 *) myaddr;
-
- while (nread < len)
- {
- Count = len - nread;
- if (Count > MAXDATA)
- Count = MAXDATA;
- From.Offset = memaddr + nread;
- if (err = UDIRead (From, To, Count, Size, &CountDone, HostEndian))
- {
- error ("UDIRead() failed in udi_read_inferior_memory");
- break;
- }
- else
- {
- nread += CountDone;
- To += CountDone;
- }
- }
- return (nread);
-}
-
-/********************************************************************* WARNING
-*/
-udi_warning (int num)
-{
- error ("ERROR while loading program into remote TIP: $d\n", num);
-}
-
-
-/*****************************************************************************/
-/* Fetch a single register indicatated by 'regno'.
- * Returns 0/-1 on success/failure.
- */
-static void
-fetch_register (int regno)
-{
- UDIResource From;
- UDIUInt32 To;
- UDICount Count = 1;
- UDISizeT Size = 4;
- UDICount CountDone;
- UDIBool HostEndian = 0;
- UDIError err;
- int result;
-
- if (regno == GR1_REGNUM)
- {
- From.Space = UDI29KGlobalRegs;
- From.Offset = 1;
- }
- else if (regno >= GR96_REGNUM && regno < GR96_REGNUM + 32)
- {
- From.Space = UDI29KGlobalRegs;
- From.Offset = (regno - GR96_REGNUM) + 96;;
- }
-
-#if defined(GR64_REGNUM)
-
- else if (regno >= GR64_REGNUM && regno < GR64_REGNUM + 32)
- {
- From.Space = UDI29KGlobalRegs;
- From.Offset = (regno - GR64_REGNUM) + 64;
- }
-
-#endif /* GR64_REGNUM */
-
- else if (regno >= LR0_REGNUM && regno < LR0_REGNUM + 128)
- {
- From.Space = UDI29KLocalRegs;
- From.Offset = (regno - LR0_REGNUM);
- }
- else if (regno >= FPE_REGNUM && regno <= EXO_REGNUM)
- {
- int val = -1;
- /*supply_register(160 + (regno - FPE_REGNUM),(char *) &val); */
- supply_register (regno, (char *) &val);
- return; /* Pretend Success */
- }
- else
- {
- From.Space = UDI29KSpecialRegs;
- From.Offset = regnum_to_srnum (regno);
- }
-
- if (err = UDIRead (From, &To, Count, Size, &CountDone, HostEndian))
- error ("UDIRead() failed in udi_fetch_registers");
-
- supply_register (regno, (char *) &To);
-
- if (remote_debug)
- fprintf_unfiltered (gdb_stdlog, "Fetching register %s = 0x%x\n",
- REGISTER_NAME (regno), To);
-}
-/*****************************************************************************/
-/* Store a single register indicated by 'regno'.
- * Returns 0/-1 on success/failure.
- */
-static int
-store_register (int regno)
-{
- int result;
- UDIUInt32 From;
- UDIResource To;
- UDICount Count = 1;
- UDISizeT Size = 4;
- UDICount CountDone;
- UDIBool HostEndian = 0;
-
- From = read_register (regno); /* get data value */
-
- if (remote_debug)
- fprintf_unfiltered (gdb_stdlog, "Storing register %s = 0x%x\n",
- REGISTER_NAME (regno), From);
-
- if (regno == GR1_REGNUM)
- {
- To.Space = UDI29KGlobalRegs;
- To.Offset = 1;
- result = UDIWrite (&From, To, Count, Size, &CountDone, HostEndian);
- /* Setting GR1 changes the numbers of all the locals, so invalidate the
- * register cache. Do this *after* calling read_register, because we want
- * read_register to return the value that write_register has just stuffed
- * into the registers array, not the value of the register fetched from
- * the inferior.
- */
- registers_changed ();
- }
-#if defined(GR64_REGNUM)
- else if (regno >= GR64_REGNUM && regno < GR64_REGNUM + 32)
- {
- To.Space = UDI29KGlobalRegs;
- To.Offset = (regno - GR64_REGNUM) + 64;
- result = UDIWrite (&From, To, Count, Size, &CountDone, HostEndian);
- }
-#endif /* GR64_REGNUM */
- else if (regno >= GR96_REGNUM && regno < GR96_REGNUM + 32)
- {
- To.Space = UDI29KGlobalRegs;
- To.Offset = (regno - GR96_REGNUM) + 96;
- result = UDIWrite (&From, To, Count, Size, &CountDone, HostEndian);
- }
- else if (regno >= LR0_REGNUM && regno < LR0_REGNUM + 128)
- {
- To.Space = UDI29KLocalRegs;
- To.Offset = (regno - LR0_REGNUM);
- result = UDIWrite (&From, To, Count, Size, &CountDone, HostEndian);
- }
- else if (regno >= FPE_REGNUM && regno <= EXO_REGNUM)
- return 0; /* Pretend Success */
- else if (regno == PC_REGNUM)
- {
- /* PC1 via UDI29KPC */
-
- To.Space = UDI29KPC;
- To.Offset = 0; /* PC1 */
- result = UDIWrite (&From, To, Count, Size, &CountDone, HostEndian);
-
- /* Writing to this loc actually changes the values of pc0 & pc1 */
-
- register_valid[PC_REGNUM] = 0; /* pc1 */
- register_valid[NPC_REGNUM] = 0; /* pc0 */
- }
- else
- /* An unprotected or protected special register */
- {
- To.Space = UDI29KSpecialRegs;
- To.Offset = regnum_to_srnum (regno);
- result = UDIWrite (&From, To, Count, Size, &CountDone, HostEndian);
- }
-
- if (result != 0)
- error ("UDIWrite() failed in store_registers");
-
- return 0;
-}
-/********************************************************** REGNUM_TO_SRNUM */
-/*
- * Convert a gdb special register number to a 29000 special register number.
- */
-static int
-regnum_to_srnum (int regno)
-{
- switch (regno)
- {
- case VAB_REGNUM:
- return (0);
- case OPS_REGNUM:
- return (1);
- case CPS_REGNUM:
- return (2);
- case CFG_REGNUM:
- return (3);
- case CHA_REGNUM:
- return (4);
- case CHD_REGNUM:
- return (5);
- case CHC_REGNUM:
- return (6);
- case RBP_REGNUM:
- return (7);
- case TMC_REGNUM:
- return (8);
- case TMR_REGNUM:
- return (9);
- case NPC_REGNUM:
- return (USE_SHADOW_PC ? (20) : (10));
- case PC_REGNUM:
- return (USE_SHADOW_PC ? (21) : (11));
- case PC2_REGNUM:
- return (USE_SHADOW_PC ? (22) : (12));
- case MMU_REGNUM:
- return (13);
- case LRU_REGNUM:
- return (14);
- case IPC_REGNUM:
- return (128);
- case IPA_REGNUM:
- return (129);
- case IPB_REGNUM:
- return (130);
- case Q_REGNUM:
- return (131);
- case ALU_REGNUM:
- return (132);
- case BP_REGNUM:
- return (133);
- case FC_REGNUM:
- return (134);
- case CR_REGNUM:
- return (135);
- case FPE_REGNUM:
- return (160);
- case INTE_REGNUM:
- return (161);
- case FPS_REGNUM:
- return (162);
- case EXO_REGNUM:
- return (164);
- default:
- return (255); /* Failure ? */
- }
-}
-/****************************************************************************/
-/*
- * Determine the Target memory space qualifier based on the addr.
- * FIXME: Can't distinguis I_ROM/D_ROM.
- * FIXME: Doesn't know anything about I_CACHE/D_CACHE.
- */
-static CPUSpace
-udi_memory_space (CORE_ADDR addr)
-{
- UDIUInt32 tstart = IMemStart;
- UDIUInt32 tend = tstart + IMemSize;
- UDIUInt32 dstart = DMemStart;
- UDIUInt32 dend = tstart + DMemSize;
- UDIUInt32 rstart = RMemStart;
- UDIUInt32 rend = tstart + RMemSize;
-
- if (((UDIUInt32) addr >= tstart) && ((UDIUInt32) addr < tend))
- {
- return UDI29KIRAMSpace;
- }
- else if (((UDIUInt32) addr >= dstart) && ((UDIUInt32) addr < dend))
- {
- return UDI29KDRAMSpace;
- }
- else if (((UDIUInt32) addr >= rstart) && ((UDIUInt32) addr < rend))
- {
- /* FIXME: how do we determine between D_ROM and I_ROM */
- return UDI29KIROMSpace;
- }
- else /* FIXME: what do me do now? */
- return UDI29KDRAMSpace; /* Hmmm! */
-}
-/*********************************************************************** STUBS
-*/
-
-void
-convert16 (void)
-{;
-}
-void
-convert32 (void)
-{;
-}
-struct ui_file *EchoFile = 0; /* used for debugging */
-int QuietMode = 0; /* used for debugging */
-\f
-#ifdef NO_HIF_SUPPORT
-service_HIF (union msg_t *msg)
-{
- return (0); /* Emulate a failure */
-}
-#endif
-\f
-/* Target_ops vector. Not static because there does not seem to be
- any portable way to do a forward declaration of a static variable.
- The RS/6000 doesn't like "extern" followed by "static"; SunOS
- /bin/cc doesn't like "static" twice. */
-
-struct target_ops udi_ops;
-
-static void
-init_udi_ops (void)
-{
- udi_ops.to_shortname = "udi";
- udi_ops.to_longname = "Remote UDI connected TIP";
- udi_ops.to_doc = "Remote debug an AMD 29k using UDI socket connection to TIP process.\n\
-Arguments are\n\
-`configuration-id AF_INET hostname port-number'\n\
-To connect via the network, where hostname and port-number specify the\n\
-host and port where you can connect via UDI.\n\
-configuration-id is unused.\n\
-\n\
-`configuration-id AF_UNIX socket-name tip-program'\n\
-To connect using a local connection to the \"tip.exe\" program which is\n\
- supplied by AMD. If socket-name specifies an AF_UNIX socket then the\n\
- tip program must already be started; connect to it using that socket.\n\
- If not, start up tip-program, which should be the name of the tip\n\
- program. If appropriate, the PATH environment variable is searched.\n\
- configuration-id is unused.\n\
-\n\
-`configuration-id'\n\
- Look up the configuration in ./udi_soc or /etc/udi_soc, which\n\
- are files containing lines in the above formats. configuration-id is\n\
- used to pick which line of the file to use.";
- udi_ops.to_open = udi_open;
- udi_ops.to_close = udi_close;
- udi_ops.to_attach = udi_attach;
- udi_ops.to_detach = udi_detach;
- udi_ops.to_resume = udi_resume;
- udi_ops.to_wait = udi_wait;
- udi_ops.to_fetch_registers = udi_fetch_registers;
- udi_ops.to_store_registers = udi_store_registers;
- udi_ops.to_prepare_to_store = udi_prepare_to_store;
- udi_ops.to_xfer_memory = udi_xfer_inferior_memory;
- udi_ops.to_files_info = udi_files_info;
- udi_ops.to_insert_breakpoint = udi_insert_breakpoint;
- udi_ops.to_remove_breakpoint = udi_remove_breakpoint;
- udi_ops.to_terminal_init = 0;
- udi_ops.to_terminal_inferior = 0;
- udi_ops.to_terminal_ours_for_output = 0;
- udi_ops.to_terminal_ours = 0;
- udi_ops.to_terminal_info = 0;
- udi_ops.to_kill = udi_kill;
- udi_ops.to_load = udi_load;
- udi_ops.to_lookup_symbol = 0;
- udi_ops.to_create_inferior = udi_create_inferior;
- udi_ops.to_mourn_inferior = udi_mourn;
- udi_ops.to_can_run = 0;
- udi_ops.to_notice_signals = 0;
- udi_ops.to_thread_alive = 0;
- udi_ops.to_stop = 0;
- udi_ops.to_stratum = process_stratum;
- udi_ops.DONT_USE = 0;
- udi_ops.to_has_all_memory = 1;
- udi_ops.to_has_memory = 1;
- udi_ops.to_has_stack = 1;
- udi_ops.to_has_registers = 1;
- udi_ops.to_has_execution = 1;
- udi_ops.to_sections = 0;
- udi_ops.to_sections_end = 0;
- udi_ops.to_magic = OPS_MAGIC;
-};
-
-void
-_initialize_remote_udi (void)
-{
- init_udi_ops ();
- add_target (&udi_ops);
-}
+/* OBSOLETE /* Remote debugging interface for AMD 29k interfaced via UDI, for GDB. */
+/* OBSOLETE Copyright 1990, 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001 */
+/* OBSOLETE Free Software Foundation, Inc. */
+/* OBSOLETE Written by Daniel Mann. Contributed by AMD. */
+/* OBSOLETE */
+/* OBSOLETE This file is part of GDB. */
+/* OBSOLETE */
+/* OBSOLETE This program is free software; you can redistribute it and/or modify */
+/* OBSOLETE it under the terms of the GNU General Public License as published by */
+/* OBSOLETE the Free Software Foundation; either version 2 of the License, or */
+/* OBSOLETE (at your option) any later version. */
+/* OBSOLETE */
+/* OBSOLETE This program is distributed in the hope that it will be useful, */
+/* OBSOLETE but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* OBSOLETE MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* OBSOLETE GNU General Public License for more details. */
+/* OBSOLETE */
+/* OBSOLETE You should have received a copy of the GNU General Public License */
+/* OBSOLETE along with this program; if not, write to the Free Software */
+/* OBSOLETE Foundation, Inc., 59 Temple Place - Suite 330, */
+/* OBSOLETE Boston, MA 02111-1307, USA. */ */
+/* OBSOLETE */
+/* OBSOLETE /* This is like remote.c but uses the Universal Debug Interface (UDI) to */
+/* OBSOLETE talk to the target hardware (or simulator). UDI is a TCP/IP based */
+/* OBSOLETE protocol; for hardware that doesn't run TCP, an interface adapter */
+/* OBSOLETE daemon talks UDI on one side, and talks to the hardware (typically */
+/* OBSOLETE over a serial port) on the other side. */
+/* OBSOLETE */
+/* OBSOLETE - Originally written by Daniel Mann at AMD for MiniMON and gdb 3.91.6. */
+/* OBSOLETE - David Wood (wood@lab.ultra.nyu.edu) at New York University adapted this */
+/* OBSOLETE file to gdb 3.95. I was unable to get this working on sun3os4 */
+/* OBSOLETE with termio, only with sgtty. */
+/* OBSOLETE - Daniel Mann at AMD took the 3.95 adaptions above and replaced */
+/* OBSOLETE MiniMON interface with UDI-p interface. */ */
+/* OBSOLETE */
+/* OBSOLETE #include "defs.h" */
+/* OBSOLETE #include "frame.h" */
+/* OBSOLETE #include "inferior.h" */
+/* OBSOLETE #include "value.h" */
+/* OBSOLETE #include <ctype.h> */
+/* OBSOLETE #include <fcntl.h> */
+/* OBSOLETE #include <errno.h> */
+/* OBSOLETE #include "gdb_string.h" */
+/* OBSOLETE #include "terminal.h" */
+/* OBSOLETE #include "target.h" */
+/* OBSOLETE #include "29k-share/udi/udiproc.h" */
+/* OBSOLETE #include "gdbcmd.h" */
+/* OBSOLETE #include "bfd.h" */
+/* OBSOLETE #include "gdbcore.h" /* For download function */ */
+/* OBSOLETE #include "regcache.h" */
+/* OBSOLETE */
+/* OBSOLETE /* access the register store directly, without going through */
+/* OBSOLETE the normal handler functions. This avoids an extra data copy. */ */
+/* OBSOLETE */
+/* OBSOLETE extern int stop_soon_quietly; /* for wait_for_inferior */ */
+/* OBSOLETE extern struct value *call_function_by_hand (); */
+/* OBSOLETE static void udi_resume (ptid_t ptid, int step, enum target_signal sig); */
+/* OBSOLETE static void udi_fetch_registers (int regno); */
+/* OBSOLETE static void udi_load (char *args, int from_tty); */
+/* OBSOLETE static void fetch_register (int regno); */
+/* OBSOLETE static void udi_store_registers (int regno); */
+/* OBSOLETE static int store_register (int regno); */
+/* OBSOLETE static int regnum_to_srnum (int regno); */
+/* OBSOLETE static void udi_close (int quitting); */
+/* OBSOLETE static CPUSpace udi_memory_space (CORE_ADDR addr); */
+/* OBSOLETE static int udi_write_inferior_memory (CORE_ADDR memaddr, char *myaddr, */
+/* OBSOLETE int len); */
+/* OBSOLETE static int udi_read_inferior_memory (CORE_ADDR memaddr, char *myaddr, */
+/* OBSOLETE int len); */
+/* OBSOLETE static void download (char *load_arg_string, int from_tty); */
+/* OBSOLETE char CoffFileName[100] = ""; */
+/* OBSOLETE */
+/* OBSOLETE #define FREEZE_MODE (read_register(CPS_REGNUM) & 0x400) */
+/* OBSOLETE #define USE_SHADOW_PC ((processor_type == a29k_freeze_mode) && FREEZE_MODE) */
+/* OBSOLETE */
+/* OBSOLETE static int timeout = 5; */
+/* OBSOLETE extern struct target_ops udi_ops; /* Forward declaration */ */
+/* OBSOLETE */
+/* OBSOLETE /* Special register enumeration. */
+/* OBSOLETE */ */
+/* OBSOLETE */
+/* OBSOLETE /******************************************************************* UDI DATA*/ */
+/* OBSOLETE #define MAXDATA 2*1024 /* max UDI[read/write] byte size */ */
+/* OBSOLETE /* Descriptor for I/O to remote machine. Initialize it to -1 so that */
+/* OBSOLETE udi_open knows that we don't have a file open when the program */
+/* OBSOLETE starts. */ */
+/* OBSOLETE */
+/* OBSOLETE UDISessionId udi_session_id = -1; */
+/* OBSOLETE static char *udi_config_id; */
+/* OBSOLETE */
+/* OBSOLETE CPUOffset IMemStart = 0; */
+/* OBSOLETE CPUSizeT IMemSize = 0; */
+/* OBSOLETE CPUOffset DMemStart = 0; */
+/* OBSOLETE CPUSizeT DMemSize = 0; */
+/* OBSOLETE CPUOffset RMemStart = 0; */
+/* OBSOLETE CPUSizeT RMemSize = 0; */
+/* OBSOLETE UDIUInt32 CPUPRL; */
+/* OBSOLETE UDIUInt32 CoProcPRL; */
+/* OBSOLETE */
+/* OBSOLETE UDIMemoryRange address_ranges[2]; /* Text and data */ */
+/* OBSOLETE UDIResource entry = */
+/* OBSOLETE {0, 0}; /* Entry point */ */
+/* OBSOLETE CPUSizeT stack_sizes[2]; /* Regular and memory stacks */ */
+/* OBSOLETE */
+/* OBSOLETE #define SBUF_MAX 1024 /* maximum size of string handling buffer */ */
+/* OBSOLETE char sbuf[SBUF_MAX]; */
+/* OBSOLETE */
+/* OBSOLETE typedef struct bkpt_entry_str */
+/* OBSOLETE { */
+/* OBSOLETE UDIResource Addr; */
+/* OBSOLETE UDIUInt32 PassCount; */
+/* OBSOLETE UDIBreakType Type; */
+/* OBSOLETE unsigned int BreakId; */
+/* OBSOLETE } */
+/* OBSOLETE bkpt_entry_t; */
+/* OBSOLETE #define BKPT_TABLE_SIZE 40 */
+/* OBSOLETE static bkpt_entry_t bkpt_table[BKPT_TABLE_SIZE]; */
+/* OBSOLETE extern char dfe_errmsg[]; /* error string */ */
+/* OBSOLETE */
+/* OBSOLETE /* malloc'd name of the program on the remote system. */ */
+/* OBSOLETE static char *prog_name = NULL; */
+/* OBSOLETE */
+/* OBSOLETE /* This is called not only when we first attach, but also when the */
+/* OBSOLETE user types "run" after having attached. */ */
+/* OBSOLETE */
+/* OBSOLETE static void */
+/* OBSOLETE udi_create_inferior (char *execfile, char *args, char **env) */
+/* OBSOLETE { */
+/* OBSOLETE char *args1; */
+/* OBSOLETE */
+/* OBSOLETE if (execfile) */
+/* OBSOLETE { */
+/* OBSOLETE if (prog_name != NULL) */
+/* OBSOLETE xfree (prog_name); */
+/* OBSOLETE prog_name = savestring (execfile, strlen (execfile)); */
+/* OBSOLETE } */
+/* OBSOLETE else if (entry.Offset) */
+/* OBSOLETE execfile = ""; */
+/* OBSOLETE else */
+/* OBSOLETE error ("No image loaded into target."); */
+/* OBSOLETE */
+/* OBSOLETE if (udi_session_id < 0) */
+/* OBSOLETE { */
+/* OBSOLETE /* If the TIP is not open, open it. */ */
+/* OBSOLETE if (UDIConnect (udi_config_id, &udi_session_id)) */
+/* OBSOLETE error ("UDIConnect() failed: %s\n", dfe_errmsg); */
+/* OBSOLETE /* We will need to download the program. */ */
+/* OBSOLETE entry.Offset = 0; */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE inferior_ptid = pid_to_ptid (40000); */
+/* OBSOLETE */
+/* OBSOLETE if (!entry.Offset) */
+/* OBSOLETE download (execfile, 0); */
+/* OBSOLETE */
+/* OBSOLETE args1 = alloca (strlen (execfile) + strlen (args) + 2); */
+/* OBSOLETE */
+/* OBSOLETE if (execfile[0] == '\0') */
+/* OBSOLETE */
+/* OBSOLETE /* It is empty. We need to quote it somehow, or else the target */
+/* OBSOLETE will think there is no argument being passed here. According */
+/* OBSOLETE to the UDI spec it is quoted "according to TIP OS rules" which */
+/* OBSOLETE I guess means quoting it like the Unix shell should work */
+/* OBSOLETE (sounds pretty bogus to me...). In fact it doesn't work (with */
+/* OBSOLETE isstip anyway), but passing in two quotes as the argument seems */
+/* OBSOLETE like a reasonable enough behavior anyway (I guess). */ */
+/* OBSOLETE */
+/* OBSOLETE strcpy (args1, "''"); */
+/* OBSOLETE else */
+/* OBSOLETE strcpy (args1, execfile); */
+/* OBSOLETE strcat (args1, " "); */
+/* OBSOLETE strcat (args1, args); */
+/* OBSOLETE */
+/* OBSOLETE UDIInitializeProcess (address_ranges, /* ProcessMemory[] */ */
+/* OBSOLETE (UDIInt) 2, /* NumberOfRanges */ */
+/* OBSOLETE entry, /* EntryPoint */ */
+/* OBSOLETE stack_sizes, /* *StackSizes */ */
+/* OBSOLETE (UDIInt) 2, /* NumberOfStacks */ */
+/* OBSOLETE args1); /* ArgString */ */
+/* OBSOLETE */
+/* OBSOLETE init_wait_for_inferior (); */
+/* OBSOLETE clear_proceed_status (); */
+/* OBSOLETE proceed (-1, TARGET_SIGNAL_DEFAULT, 0); */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE static void */
+/* OBSOLETE udi_mourn (void) */
+/* OBSOLETE { */
+/* OBSOLETE #if 0 */
+/* OBSOLETE /* Requiring "target udi" each time you run is a major pain. I suspect */
+/* OBSOLETE this was just blindy copied from remote.c, in which "target" and */
+/* OBSOLETE "run" are combined. Having a udi target without an inferior seems */
+/* OBSOLETE to work between "target udi" and "run", so why not now? */ */
+/* OBSOLETE pop_target (); /* Pop back to no-child state */ */
+/* OBSOLETE #endif */
+/* OBSOLETE /* But if we're going to want to run it again, we better remove the */
+/* OBSOLETE breakpoints... */ */
+/* OBSOLETE remove_breakpoints (); */
+/* OBSOLETE generic_mourn_inferior (); */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /******************************************************************** UDI_OPEN */
+/* OBSOLETE ** Open a connection to remote TIP. */
+/* OBSOLETE NAME is the socket domain used for communication with the TIP, */
+/* OBSOLETE then a space and the socket name or TIP-host name. */
+/* OBSOLETE '<udi_udi_config_id>' for example. */
+/* OBSOLETE */ */
+/* OBSOLETE */
+/* OBSOLETE /* XXX - need cleanups for udiconnect for various failures!!! */ */
+/* OBSOLETE */
+/* OBSOLETE static void */
+/* OBSOLETE udi_open (char *name, int from_tty) */
+/* OBSOLETE { */
+/* OBSOLETE unsigned int prl; */
+/* OBSOLETE char *p; */
+/* OBSOLETE int cnt; */
+/* OBSOLETE UDIMemoryRange KnownMemory[10]; */
+/* OBSOLETE UDIUInt32 ChipVersions[10]; */
+/* OBSOLETE UDIInt NumberOfRanges = 10; */
+/* OBSOLETE UDIInt NumberOfChips = 10; */
+/* OBSOLETE UDIPId PId; */
+/* OBSOLETE UDIUInt32 TIPId, TargetId, DFEId, DFE, TIP, DFEIPCId, TIPIPCId; */
+/* OBSOLETE */
+/* OBSOLETE target_preopen (from_tty); */
+/* OBSOLETE */
+/* OBSOLETE entry.Offset = 0; */
+/* OBSOLETE */
+/* OBSOLETE for (cnt = 0; cnt < BKPT_TABLE_SIZE; cnt++) */
+/* OBSOLETE bkpt_table[cnt].Type = 0; */
+/* OBSOLETE */
+/* OBSOLETE if (udi_config_id) */
+/* OBSOLETE xfree (udi_config_id); */
+/* OBSOLETE */
+/* OBSOLETE if (!name) */
+/* OBSOLETE error ("Usage: target udi config_id, where config_id appears in udi_soc file"); */
+/* OBSOLETE */
+/* OBSOLETE udi_config_id = xstrdup (strtok (name, " \t")); */
+/* OBSOLETE */
+/* OBSOLETE if (UDIConnect (udi_config_id, &udi_session_id)) */
+/* OBSOLETE /* FIXME: Should set udi_session_id to -1 here. */ */
+/* OBSOLETE error ("UDIConnect() failed: %s\n", dfe_errmsg); */
+/* OBSOLETE */
+/* OBSOLETE push_target (&udi_ops); */
+/* OBSOLETE */
+/* OBSOLETE /* */
+/* OBSOLETE ** Initialize target configuration structure (global) */
+/* OBSOLETE */ */
+/* OBSOLETE if (UDIGetTargetConfig (KnownMemory, &NumberOfRanges, */
+/* OBSOLETE ChipVersions, &NumberOfChips)) */
+/* OBSOLETE error ("UDIGetTargetConfig() failed"); */
+/* OBSOLETE if (NumberOfChips > 2) */
+/* OBSOLETE fprintf_unfiltered (gdb_stderr, "Target has more than one processor\n"); */
+/* OBSOLETE for (cnt = 0; cnt < NumberOfRanges; cnt++) */
+/* OBSOLETE { */
+/* OBSOLETE switch (KnownMemory[cnt].Space) */
+/* OBSOLETE { */
+/* OBSOLETE default: */
+/* OBSOLETE fprintf_unfiltered (gdb_stderr, "UDIGetTargetConfig() unknown memory space\n"); */
+/* OBSOLETE break; */
+/* OBSOLETE case UDI29KCP_S: */
+/* OBSOLETE break; */
+/* OBSOLETE case UDI29KIROMSpace: */
+/* OBSOLETE RMemStart = KnownMemory[cnt].Offset; */
+/* OBSOLETE RMemSize = KnownMemory[cnt].Size; */
+/* OBSOLETE break; */
+/* OBSOLETE case UDI29KIRAMSpace: */
+/* OBSOLETE IMemStart = KnownMemory[cnt].Offset; */
+/* OBSOLETE IMemSize = KnownMemory[cnt].Size; */
+/* OBSOLETE break; */
+/* OBSOLETE case UDI29KDRAMSpace: */
+/* OBSOLETE DMemStart = KnownMemory[cnt].Offset; */
+/* OBSOLETE DMemSize = KnownMemory[cnt].Size; */
+/* OBSOLETE break; */
+/* OBSOLETE } */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE a29k_get_processor_type (); */
+/* OBSOLETE */
+/* OBSOLETE if (UDICreateProcess (&PId)) */
+/* OBSOLETE fprintf_unfiltered (gdb_stderr, "UDICreateProcess() failed\n"); */
+/* OBSOLETE */
+/* OBSOLETE /* Print out some stuff, letting the user now what's going on */ */
+/* OBSOLETE if (UDICapabilities (&TIPId, &TargetId, DFEId, DFE, &TIP, &DFEIPCId, */
+/* OBSOLETE &TIPIPCId, sbuf)) */
+/* OBSOLETE error ("UDICapabilities() failed"); */
+/* OBSOLETE if (from_tty) */
+/* OBSOLETE { */
+/* OBSOLETE printf_filtered ("Connected via UDI socket,\n\ */
+/* OBSOLETE DFE-IPC version %x.%x.%x TIP-IPC version %x.%x.%x TIP version %x.%x.%x\n %s\n", */
+/* OBSOLETE (DFEIPCId >> 8) & 0xf, (DFEIPCId >> 4) & 0xf, DFEIPCId & 0xf, */
+/* OBSOLETE (TIPIPCId >> 8) & 0xf, (TIPIPCId >> 4) & 0xf, TIPIPCId & 0xf, */
+/* OBSOLETE (TargetId >> 8) & 0xf, (TargetId >> 4) & 0xf, TargetId & 0xf, */
+/* OBSOLETE sbuf); */
+/* OBSOLETE } */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /******************************************************************* UDI_CLOSE */
+/* OBSOLETE Close the open connection to the TIP process. */
+/* OBSOLETE Use this when you want to detach and do something else */
+/* OBSOLETE with your gdb. */ */
+/* OBSOLETE static void */
+/* OBSOLETE udi_close ( /*FIXME: how is quitting used */ */
+/* OBSOLETE int quitting) */
+/* OBSOLETE { */
+/* OBSOLETE if (udi_session_id < 0) */
+/* OBSOLETE return; */
+/* OBSOLETE */
+/* OBSOLETE /* We should never get here if there isn't something valid in */
+/* OBSOLETE udi_session_id. */ */
+/* OBSOLETE */
+/* OBSOLETE if (UDIDisconnect (udi_session_id, UDITerminateSession)) */
+/* OBSOLETE { */
+/* OBSOLETE if (quitting) */
+/* OBSOLETE warning ("UDIDisconnect() failed in udi_close"); */
+/* OBSOLETE else */
+/* OBSOLETE error ("UDIDisconnect() failed in udi_close"); */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* Do not try to close udi_session_id again, later in the program. */ */
+/* OBSOLETE udi_session_id = -1; */
+/* OBSOLETE inferior_ptid = null_ptid; */
+/* OBSOLETE */
+/* OBSOLETE printf_filtered (" Ending remote debugging\n"); */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /**************************************************************** UDI_ATACH */ */
+/* OBSOLETE /* Attach to a program that is already loaded and running */
+/* OBSOLETE * Upon exiting the process's execution is stopped. */
+/* OBSOLETE */ */
+/* OBSOLETE static void */
+/* OBSOLETE udi_attach (char *args, int from_tty) */
+/* OBSOLETE { */
+/* OBSOLETE UDIResource From; */
+/* OBSOLETE UDIInt32 PC_adds; */
+/* OBSOLETE UDICount Count = 1; */
+/* OBSOLETE UDISizeT Size = 4; */
+/* OBSOLETE UDICount CountDone; */
+/* OBSOLETE UDIBool HostEndian = 0; */
+/* OBSOLETE UDIError err; */
+/* OBSOLETE */
+/* OBSOLETE if (args == NULL) */
+/* OBSOLETE error_no_arg ("program to attach"); */
+/* OBSOLETE */
+/* OBSOLETE if (udi_session_id < 0) */
+/* OBSOLETE error ("UDI connection not opened yet, use the 'target udi' command.\n"); */
+/* OBSOLETE */
+/* OBSOLETE if (from_tty) */
+/* OBSOLETE printf_unfiltered ("Attaching to remote program %s...\n", prog_name); */
+/* OBSOLETE */
+/* OBSOLETE UDIStop (); */
+/* OBSOLETE From.Space = UDI29KSpecialRegs; */
+/* OBSOLETE From.Offset = 11; */
+/* OBSOLETE if (err = UDIRead (From, &PC_adds, Count, Size, &CountDone, HostEndian)) */
+/* OBSOLETE error ("UDIRead failed in udi_attach"); */
+/* OBSOLETE printf_unfiltered ("Remote process is now halted, pc1 = 0x%x.\n", PC_adds); */
+/* OBSOLETE } */
+/* OBSOLETE /************************************************************* UDI_DETACH */ */
+/* OBSOLETE /* Terminate the open connection to the TIP process. */
+/* OBSOLETE Use this when you want to detach and do something else */
+/* OBSOLETE with your gdb. Leave remote process running (with no breakpoints set). */ */
+/* OBSOLETE static void */
+/* OBSOLETE udi_detach (char *args, int from_tty) */
+/* OBSOLETE { */
+/* OBSOLETE */
+/* OBSOLETE remove_breakpoints (); /* Just in case there were any left in */ */
+/* OBSOLETE */
+/* OBSOLETE if (UDIDisconnect (udi_session_id, UDIContinueSession)) */
+/* OBSOLETE error ("UDIDisconnect() failed in udi_detach"); */
+/* OBSOLETE */
+/* OBSOLETE /* Don't try to UDIDisconnect it again in udi_close, which is called from */
+/* OBSOLETE pop_target. */ */
+/* OBSOLETE udi_session_id = -1; */
+/* OBSOLETE inferior_ptid = null_ptid; */
+/* OBSOLETE */
+/* OBSOLETE pop_target (); */
+/* OBSOLETE */
+/* OBSOLETE if (from_tty) */
+/* OBSOLETE printf_unfiltered ("Detaching from TIP\n"); */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE */
+/* OBSOLETE /****************************************************************** UDI_RESUME */
+/* OBSOLETE ** Tell the remote machine to resume. */ */
+/* OBSOLETE */
+/* OBSOLETE static void */
+/* OBSOLETE udi_resume (ptid_t ptid, int step, enum target_signal sig) */
+/* OBSOLETE { */
+/* OBSOLETE UDIError tip_error; */
+/* OBSOLETE UDIUInt32 Steps = 1; */
+/* OBSOLETE UDIStepType StepType = UDIStepNatural; */
+/* OBSOLETE UDIRange Range; */
+/* OBSOLETE */
+/* OBSOLETE if (step) /* step 1 instruction */ */
+/* OBSOLETE { */
+/* OBSOLETE tip_error = UDIStep (Steps, StepType, Range); */
+/* OBSOLETE if (!tip_error) */
+/* OBSOLETE return; */
+/* OBSOLETE */
+/* OBSOLETE fprintf_unfiltered (gdb_stderr, "UDIStep() error = %d\n", tip_error); */
+/* OBSOLETE error ("failed in udi_resume"); */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE if (UDIExecute ()) */
+/* OBSOLETE error ("UDIExecute() failed in udi_resume"); */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /******************************************************************** UDI_WAIT */
+/* OBSOLETE ** Wait until the remote machine stops, then return, */
+/* OBSOLETE storing status in STATUS just as `wait' would. */ */
+/* OBSOLETE */
+/* OBSOLETE static ptid_t */
+/* OBSOLETE udi_wait (ptid_t ptid, struct target_waitstatus *status) */
+/* OBSOLETE { */
+/* OBSOLETE UDIInt32 MaxTime; */
+/* OBSOLETE UDIPId PId; */
+/* OBSOLETE UDIInt32 StopReason; */
+/* OBSOLETE UDISizeT CountDone; */
+/* OBSOLETE int old_timeout = timeout; */
+/* OBSOLETE int old_immediate_quit = immediate_quit; */
+/* OBSOLETE int i; */
+/* OBSOLETE */
+/* OBSOLETE status->kind = TARGET_WAITKIND_EXITED; */
+/* OBSOLETE status->value.integer = 0; */
+/* OBSOLETE */
+/* OBSOLETE /* wait for message to arrive. It should be: */
+/* OBSOLETE If the target stops executing, udi_wait() should return. */
+/* OBSOLETE */ */
+/* OBSOLETE timeout = 0; /* Wait indefinetly for a message */ */
+/* OBSOLETE immediate_quit = 1; /* Helps ability to QUIT */ */
+/* OBSOLETE */
+/* OBSOLETE while (1) */
+/* OBSOLETE { */
+/* OBSOLETE i = 0; */
+/* OBSOLETE MaxTime = UDIWaitForever; */
+/* OBSOLETE UDIWait (MaxTime, &PId, &StopReason); */
+/* OBSOLETE QUIT; /* Let user quit if they want */ */
+/* OBSOLETE */
+/* OBSOLETE switch (StopReason & UDIGrossState) */
+/* OBSOLETE { */
+/* OBSOLETE case UDIStdoutReady: */
+/* OBSOLETE if (UDIGetStdout (sbuf, (UDISizeT) SBUF_MAX, &CountDone)) */
+/* OBSOLETE /* This is said to happen if the program tries to output */
+/* OBSOLETE a whole bunch of output (more than SBUF_MAX, I would */
+/* OBSOLETE guess). It doesn't seem to happen with the simulator. */ */
+/* OBSOLETE warning ("UDIGetStdout() failed in udi_wait"); */
+/* OBSOLETE fwrite (sbuf, 1, CountDone, stdout); */
+/* OBSOLETE gdb_flush (gdb_stdout); */
+/* OBSOLETE continue; */
+/* OBSOLETE */
+/* OBSOLETE case UDIStderrReady: */
+/* OBSOLETE UDIGetStderr (sbuf, (UDISizeT) SBUF_MAX, &CountDone); */
+/* OBSOLETE fwrite (sbuf, 1, CountDone, stderr); */
+/* OBSOLETE gdb_flush (gdb_stderr); */
+/* OBSOLETE continue; */
+/* OBSOLETE */
+/* OBSOLETE case UDIStdinNeeded: */
+/* OBSOLETE { */
+/* OBSOLETE int ch; */
+/* OBSOLETE i = 0; */
+/* OBSOLETE do */
+/* OBSOLETE { */
+/* OBSOLETE ch = getchar (); */
+/* OBSOLETE if (ch == EOF) */
+/* OBSOLETE break; */
+/* OBSOLETE sbuf[i++] = ch; */
+/* OBSOLETE } */
+/* OBSOLETE while (i < SBUF_MAX && ch != '\n'); */
+/* OBSOLETE UDIPutStdin (sbuf, (UDISizeT) i, &CountDone); */
+/* OBSOLETE continue; */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE case UDIRunning: */
+/* OBSOLETE /* In spite of the fact that we told UDIWait to wait forever, it will */
+/* OBSOLETE return spuriously sometimes. */ */
+/* OBSOLETE case UDIStdinModeX: */
+/* OBSOLETE continue; */
+/* OBSOLETE default: */
+/* OBSOLETE break; */
+/* OBSOLETE } */
+/* OBSOLETE break; */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE switch (StopReason & UDIGrossState) */
+/* OBSOLETE { */
+/* OBSOLETE case UDITrapped: */
+/* OBSOLETE printf_unfiltered ("Am290*0 received vector number %d\n", StopReason >> 24); */
+/* OBSOLETE */
+/* OBSOLETE switch ((StopReason >> 8) & 0xff) */
+/* OBSOLETE { */
+/* OBSOLETE case 0: /* Illegal opcode */ */
+/* OBSOLETE printf_unfiltered (" (break point)\n"); */
+/* OBSOLETE status->kind = TARGET_WAITKIND_STOPPED; */
+/* OBSOLETE status->value.sig = TARGET_SIGNAL_TRAP; */
+/* OBSOLETE break; */
+/* OBSOLETE case 1: /* Unaligned Access */ */
+/* OBSOLETE status->kind = TARGET_WAITKIND_STOPPED; */
+/* OBSOLETE status->value.sig = TARGET_SIGNAL_BUS; */
+/* OBSOLETE break; */
+/* OBSOLETE case 3: */
+/* OBSOLETE case 4: */
+/* OBSOLETE status->kind = TARGET_WAITKIND_STOPPED; */
+/* OBSOLETE status->value.sig = TARGET_SIGNAL_FPE; */
+/* OBSOLETE break; */
+/* OBSOLETE case 5: /* Protection Violation */ */
+/* OBSOLETE status->kind = TARGET_WAITKIND_STOPPED; */
+/* OBSOLETE /* Why not SEGV? What is a Protection Violation? */ */
+/* OBSOLETE status->value.sig = TARGET_SIGNAL_ILL; */
+/* OBSOLETE break; */
+/* OBSOLETE case 6: */
+/* OBSOLETE case 7: */
+/* OBSOLETE case 8: /* User Instruction Mapping Miss */ */
+/* OBSOLETE case 9: /* User Data Mapping Miss */ */
+/* OBSOLETE case 10: /* Supervisor Instruction Mapping Miss */ */
+/* OBSOLETE case 11: /* Supervisor Data Mapping Miss */ */
+/* OBSOLETE status->kind = TARGET_WAITKIND_STOPPED; */
+/* OBSOLETE status->value.sig = TARGET_SIGNAL_SEGV; */
+/* OBSOLETE break; */
+/* OBSOLETE case 12: */
+/* OBSOLETE case 13: */
+/* OBSOLETE status->kind = TARGET_WAITKIND_STOPPED; */
+/* OBSOLETE status->value.sig = TARGET_SIGNAL_ILL; */
+/* OBSOLETE break; */
+/* OBSOLETE case 14: /* Timer */ */
+/* OBSOLETE status->kind = TARGET_WAITKIND_STOPPED; */
+/* OBSOLETE status->value.sig = TARGET_SIGNAL_ALRM; */
+/* OBSOLETE break; */
+/* OBSOLETE case 15: /* Trace */ */
+/* OBSOLETE status->kind = TARGET_WAITKIND_STOPPED; */
+/* OBSOLETE status->value.sig = TARGET_SIGNAL_TRAP; */
+/* OBSOLETE break; */
+/* OBSOLETE case 16: /* INTR0 */ */
+/* OBSOLETE case 17: /* INTR1 */ */
+/* OBSOLETE case 18: /* INTR2 */ */
+/* OBSOLETE case 19: /* INTR3/Internal */ */
+/* OBSOLETE case 20: /* TRAP0 */ */
+/* OBSOLETE case 21: /* TRAP1 */ */
+/* OBSOLETE status->kind = TARGET_WAITKIND_STOPPED; */
+/* OBSOLETE status->value.sig = TARGET_SIGNAL_INT; */
+/* OBSOLETE break; */
+/* OBSOLETE case 22: /* Floating-Point Exception */ */
+/* OBSOLETE status->kind = TARGET_WAITKIND_STOPPED; */
+/* OBSOLETE /* Why not FPE? */ */
+/* OBSOLETE status->value.sig = TARGET_SIGNAL_ILL; */
+/* OBSOLETE break; */
+/* OBSOLETE case 77: /* assert 77 */ */
+/* OBSOLETE status->kind = TARGET_WAITKIND_STOPPED; */
+/* OBSOLETE status->value.sig = TARGET_SIGNAL_TRAP; */
+/* OBSOLETE break; */
+/* OBSOLETE default: */
+/* OBSOLETE status->kind = TARGET_WAITKIND_EXITED; */
+/* OBSOLETE status->value.integer = 0; */
+/* OBSOLETE } */
+/* OBSOLETE break; */
+/* OBSOLETE case UDINotExecuting: */
+/* OBSOLETE status->kind = TARGET_WAITKIND_STOPPED; */
+/* OBSOLETE status->value.sig = TARGET_SIGNAL_TERM; */
+/* OBSOLETE break; */
+/* OBSOLETE case UDIStopped: */
+/* OBSOLETE status->kind = TARGET_WAITKIND_STOPPED; */
+/* OBSOLETE status->value.sig = TARGET_SIGNAL_TSTP; */
+/* OBSOLETE break; */
+/* OBSOLETE case UDIWarned: */
+/* OBSOLETE status->kind = TARGET_WAITKIND_STOPPED; */
+/* OBSOLETE status->value.sig = TARGET_SIGNAL_URG; */
+/* OBSOLETE break; */
+/* OBSOLETE case UDIStepped: */
+/* OBSOLETE case UDIBreak: */
+/* OBSOLETE status->kind = TARGET_WAITKIND_STOPPED; */
+/* OBSOLETE status->value.sig = TARGET_SIGNAL_TRAP; */
+/* OBSOLETE break; */
+/* OBSOLETE case UDIWaiting: */
+/* OBSOLETE status->kind = TARGET_WAITKIND_STOPPED; */
+/* OBSOLETE status->value.sig = TARGET_SIGNAL_STOP; */
+/* OBSOLETE break; */
+/* OBSOLETE case UDIHalted: */
+/* OBSOLETE status->kind = TARGET_WAITKIND_STOPPED; */
+/* OBSOLETE status->value.sig = TARGET_SIGNAL_KILL; */
+/* OBSOLETE break; */
+/* OBSOLETE case UDIExited: */
+/* OBSOLETE default: */
+/* OBSOLETE status->kind = TARGET_WAITKIND_EXITED; */
+/* OBSOLETE status->value.integer = 0; */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE timeout = old_timeout; /* Restore original timeout value */ */
+/* OBSOLETE immediate_quit = old_immediate_quit; */
+/* OBSOLETE return inferior_ptid; */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE #if 0 */
+/* OBSOLETE /* Handy for debugging */ */
+/* OBSOLETE udi_pc (void) */
+/* OBSOLETE { */
+/* OBSOLETE UDIResource From; */
+/* OBSOLETE UDIUInt32 *To; */
+/* OBSOLETE UDICount Count; */
+/* OBSOLETE UDISizeT Size = 4; */
+/* OBSOLETE UDICount CountDone; */
+/* OBSOLETE UDIBool HostEndian = 0; */
+/* OBSOLETE UDIError err; */
+/* OBSOLETE int pc[2]; */
+/* OBSOLETE unsigned long myregs[256]; */
+/* OBSOLETE int i; */
+/* OBSOLETE */
+/* OBSOLETE From.Space = UDI29KPC; */
+/* OBSOLETE From.Offset = 0; */
+/* OBSOLETE To = (UDIUInt32 *) pc; */
+/* OBSOLETE Count = 2; */
+/* OBSOLETE */
+/* OBSOLETE err = UDIRead (From, To, Count, Size, &CountDone, HostEndian); */
+/* OBSOLETE */
+/* OBSOLETE printf_unfiltered ("err = %d, CountDone = %d, pc[0] = 0x%x, pc[1] = 0x%x\n", */
+/* OBSOLETE err, CountDone, pc[0], pc[1]); */
+/* OBSOLETE */
+/* OBSOLETE udi_fetch_registers (-1); */
+/* OBSOLETE */
+/* OBSOLETE printf_unfiltered ("other pc1 = 0x%x, pc0 = 0x%x\n", *(int *) ®isters[4 * PC_REGNUM], */
+/* OBSOLETE *(int *) ®isters[4 * NPC_REGNUM]); */
+/* OBSOLETE */
+/* OBSOLETE /* Now, read all the registers globally */ */
+/* OBSOLETE */
+/* OBSOLETE From.Space = UDI29KGlobalRegs; */
+/* OBSOLETE From.Offset = 0; */
+/* OBSOLETE err = UDIRead (From, myregs, 256, 4, &CountDone, HostEndian); */
+/* OBSOLETE */
+/* OBSOLETE printf ("err = %d, CountDone = %d\n", err, CountDone); */
+/* OBSOLETE */
+/* OBSOLETE printf ("\n"); */
+/* OBSOLETE */
+/* OBSOLETE for (i = 0; i < 256; i += 2) */
+/* OBSOLETE printf ("%d:\t%#10x\t%11d\t%#10x\t%11d\n", i, myregs[i], myregs[i], */
+/* OBSOLETE myregs[i + 1], myregs[i + 1]); */
+/* OBSOLETE printf ("\n"); */
+/* OBSOLETE */
+/* OBSOLETE return pc[0]; */
+/* OBSOLETE } */
+/* OBSOLETE #endif */
+/* OBSOLETE */
+/* OBSOLETE /********************************************************** UDI_FETCH_REGISTERS */
+/* OBSOLETE * Read a remote register 'regno'. */
+/* OBSOLETE * If regno==-1 then read all the registers. */
+/* OBSOLETE */ */
+/* OBSOLETE static void */
+/* OBSOLETE udi_fetch_registers (int regno) */
+/* OBSOLETE { */
+/* OBSOLETE UDIResource From; */
+/* OBSOLETE UDIUInt32 *To; */
+/* OBSOLETE UDICount Count; */
+/* OBSOLETE UDISizeT Size = 4; */
+/* OBSOLETE UDICount CountDone; */
+/* OBSOLETE UDIBool HostEndian = 0; */
+/* OBSOLETE UDIError err; */
+/* OBSOLETE int i; */
+/* OBSOLETE */
+/* OBSOLETE if (regno >= 0) */
+/* OBSOLETE { */
+/* OBSOLETE fetch_register (regno); */
+/* OBSOLETE return; */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* Gr1/rsp */ */
+/* OBSOLETE */
+/* OBSOLETE From.Space = UDI29KGlobalRegs; */
+/* OBSOLETE From.Offset = 1; */
+/* OBSOLETE To = (UDIUInt32 *) & registers[4 * GR1_REGNUM]; */
+/* OBSOLETE Count = 1; */
+/* OBSOLETE if (err = UDIRead (From, To, Count, Size, &CountDone, HostEndian)) */
+/* OBSOLETE error ("UDIRead() failed in udi_fetch_registers"); */
+/* OBSOLETE */
+/* OBSOLETE register_valid[GR1_REGNUM] = 1; */
+/* OBSOLETE */
+/* OBSOLETE #if defined(GR64_REGNUM) /* Read gr64-127 */ */
+/* OBSOLETE */
+/* OBSOLETE /* Global Registers gr64-gr95 */ */
+/* OBSOLETE */
+/* OBSOLETE From.Space = UDI29KGlobalRegs; */
+/* OBSOLETE From.Offset = 64; */
+/* OBSOLETE To = (UDIUInt32 *) & registers[4 * GR64_REGNUM]; */
+/* OBSOLETE Count = 32; */
+/* OBSOLETE if (err = UDIRead (From, To, Count, Size, &CountDone, HostEndian)) */
+/* OBSOLETE error ("UDIRead() failed in udi_fetch_registers"); */
+/* OBSOLETE */
+/* OBSOLETE for (i = GR64_REGNUM; i < GR64_REGNUM + 32; i++) */
+/* OBSOLETE register_valid[i] = 1; */
+/* OBSOLETE */
+/* OBSOLETE #endif /* GR64_REGNUM */ */
+/* OBSOLETE */
+/* OBSOLETE /* Global Registers gr96-gr127 */ */
+/* OBSOLETE */
+/* OBSOLETE From.Space = UDI29KGlobalRegs; */
+/* OBSOLETE From.Offset = 96; */
+/* OBSOLETE To = (UDIUInt32 *) & registers[4 * GR96_REGNUM]; */
+/* OBSOLETE Count = 32; */
+/* OBSOLETE if (err = UDIRead (From, To, Count, Size, &CountDone, HostEndian)) */
+/* OBSOLETE error ("UDIRead() failed in udi_fetch_registers"); */
+/* OBSOLETE */
+/* OBSOLETE for (i = GR96_REGNUM; i < GR96_REGNUM + 32; i++) */
+/* OBSOLETE register_valid[i] = 1; */
+/* OBSOLETE */
+/* OBSOLETE /* Local Registers */ */
+/* OBSOLETE */
+/* OBSOLETE From.Space = UDI29KLocalRegs; */
+/* OBSOLETE From.Offset = 0; */
+/* OBSOLETE To = (UDIUInt32 *) & registers[4 * LR0_REGNUM]; */
+/* OBSOLETE Count = 128; */
+/* OBSOLETE if (err = UDIRead (From, To, Count, Size, &CountDone, HostEndian)) */
+/* OBSOLETE error ("UDIRead() failed in udi_fetch_registers"); */
+/* OBSOLETE */
+/* OBSOLETE for (i = LR0_REGNUM; i < LR0_REGNUM + 128; i++) */
+/* OBSOLETE register_valid[i] = 1; */
+/* OBSOLETE */
+/* OBSOLETE /* Protected Special Registers */ */
+/* OBSOLETE */
+/* OBSOLETE From.Space = UDI29KSpecialRegs; */
+/* OBSOLETE From.Offset = 0; */
+/* OBSOLETE To = (UDIUInt32 *) & registers[4 * SR_REGNUM (0)]; */
+/* OBSOLETE Count = 15; */
+/* OBSOLETE if (err = UDIRead (From, To, Count, Size, &CountDone, HostEndian)) */
+/* OBSOLETE error ("UDIRead() failed in udi_fetch_registers"); */
+/* OBSOLETE */
+/* OBSOLETE for (i = SR_REGNUM (0); i < SR_REGNUM (0) + 15; i++) */
+/* OBSOLETE register_valid[i] = 1; */
+/* OBSOLETE */
+/* OBSOLETE if (USE_SHADOW_PC) */
+/* OBSOLETE { /* Let regno_to_srnum() handle the register number */ */
+/* OBSOLETE fetch_register (NPC_REGNUM); */
+/* OBSOLETE fetch_register (PC_REGNUM); */
+/* OBSOLETE fetch_register (PC2_REGNUM); */
+/* OBSOLETE */
+/* OBSOLETE /* Unprotected Special Registers sr128-sr135 */ */
+/* OBSOLETE */
+/* OBSOLETE From.Space = UDI29KSpecialRegs; */
+/* OBSOLETE From.Offset = 128; */
+/* OBSOLETE To = (UDIUInt32 *) & registers[4 * SR_REGNUM (128)]; */
+/* OBSOLETE Count = 135 - 128 + 1; */
+/* OBSOLETE if (err = UDIRead (From, To, Count, Size, &CountDone, HostEndian)) */
+/* OBSOLETE error ("UDIRead() failed in udi_fetch_registers"); */
+/* OBSOLETE */
+/* OBSOLETE for (i = SR_REGNUM (128); i < SR_REGNUM (128) + 135 - 128 + 1; i++) */
+/* OBSOLETE register_valid[i] = 1; */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE if (remote_debug) */
+/* OBSOLETE { */
+/* OBSOLETE fprintf_unfiltered (gdb_stdlog, "Fetching all registers\n"); */
+/* OBSOLETE fprintf_unfiltered (gdb_stdlog, */
+/* OBSOLETE "Fetching PC0 = 0x%x, PC1 = 0x%x, PC2 = 0x%x\n", */
+/* OBSOLETE read_register (NPC_REGNUM), */
+/* OBSOLETE read_register (PC_REGNUM), */
+/* OBSOLETE read_register (PC2_REGNUM)); */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* There doesn't seem to be any way to get these. */ */
+/* OBSOLETE { */
+/* OBSOLETE int val = -1; */
+/* OBSOLETE supply_register (FPE_REGNUM, (char *) &val); */
+/* OBSOLETE supply_register (INTE_REGNUM, (char *) &val); */
+/* OBSOLETE supply_register (FPS_REGNUM, (char *) &val); */
+/* OBSOLETE supply_register (EXO_REGNUM, (char *) &val); */
+/* OBSOLETE } */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE */
+/* OBSOLETE /********************************************************* UDI_STORE_REGISTERS */
+/* OBSOLETE ** Store register regno into the target. */
+/* OBSOLETE * If regno==-1 then store all the registers. */
+/* OBSOLETE */ */
+/* OBSOLETE */
+/* OBSOLETE static void */
+/* OBSOLETE udi_store_registers (int regno) */
+/* OBSOLETE { */
+/* OBSOLETE UDIUInt32 *From; */
+/* OBSOLETE UDIResource To; */
+/* OBSOLETE UDICount Count; */
+/* OBSOLETE UDISizeT Size = 4; */
+/* OBSOLETE UDICount CountDone; */
+/* OBSOLETE UDIBool HostEndian = 0; */
+/* OBSOLETE */
+/* OBSOLETE if (regno >= 0) */
+/* OBSOLETE { */
+/* OBSOLETE store_register (regno); */
+/* OBSOLETE return; */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE if (remote_debug) */
+/* OBSOLETE { */
+/* OBSOLETE fprintf_unfiltered (gdb_stdlog, "Storing all registers\n"); */
+/* OBSOLETE fprintf_unfiltered (gdb_stdlog, */
+/* OBSOLETE "PC0 = 0x%x, PC1 = 0x%x, PC2 = 0x%x\n", */
+/* OBSOLETE read_register (NPC_REGNUM), */
+/* OBSOLETE read_register (PC_REGNUM), */
+/* OBSOLETE read_register (PC2_REGNUM)); */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* Gr1/rsp */ */
+/* OBSOLETE */
+/* OBSOLETE From = (UDIUInt32 *) & registers[4 * GR1_REGNUM]; */
+/* OBSOLETE To.Space = UDI29KGlobalRegs; */
+/* OBSOLETE To.Offset = 1; */
+/* OBSOLETE Count = 1; */
+/* OBSOLETE if (UDIWrite (From, To, Count, Size, &CountDone, HostEndian)) */
+/* OBSOLETE error ("UDIWrite() failed in udi_store_regisetrs"); */
+/* OBSOLETE */
+/* OBSOLETE #if defined(GR64_REGNUM) */
+/* OBSOLETE */
+/* OBSOLETE /* Global registers gr64-gr95 */ */
+/* OBSOLETE */
+/* OBSOLETE From = (UDIUInt32 *) & registers[4 * GR64_REGNUM]; */
+/* OBSOLETE To.Space = UDI29KGlobalRegs; */
+/* OBSOLETE To.Offset = 64; */
+/* OBSOLETE Count = 32; */
+/* OBSOLETE if (UDIWrite (From, To, Count, Size, &CountDone, HostEndian)) */
+/* OBSOLETE error ("UDIWrite() failed in udi_store_regisetrs"); */
+/* OBSOLETE */
+/* OBSOLETE #endif /* GR64_REGNUM */ */
+/* OBSOLETE */
+/* OBSOLETE /* Global registers gr96-gr127 */ */
+/* OBSOLETE */
+/* OBSOLETE From = (UDIUInt32 *) & registers[4 * GR96_REGNUM]; */
+/* OBSOLETE To.Space = UDI29KGlobalRegs; */
+/* OBSOLETE To.Offset = 96; */
+/* OBSOLETE Count = 32; */
+/* OBSOLETE if (UDIWrite (From, To, Count, Size, &CountDone, HostEndian)) */
+/* OBSOLETE error ("UDIWrite() failed in udi_store_regisetrs"); */
+/* OBSOLETE */
+/* OBSOLETE /* Local Registers */ */
+/* OBSOLETE */
+/* OBSOLETE From = (UDIUInt32 *) & registers[4 * LR0_REGNUM]; */
+/* OBSOLETE To.Space = UDI29KLocalRegs; */
+/* OBSOLETE To.Offset = 0; */
+/* OBSOLETE Count = 128; */
+/* OBSOLETE if (UDIWrite (From, To, Count, Size, &CountDone, HostEndian)) */
+/* OBSOLETE error ("UDIWrite() failed in udi_store_regisetrs"); */
+/* OBSOLETE */
+/* OBSOLETE */
+/* OBSOLETE /* Protected Special Registers *//* VAB through TMR */ */
+/* OBSOLETE */
+/* OBSOLETE From = (UDIUInt32 *) & registers[4 * SR_REGNUM (0)]; */
+/* OBSOLETE To.Space = UDI29KSpecialRegs; */
+/* OBSOLETE To.Offset = 0; */
+/* OBSOLETE Count = 10; */
+/* OBSOLETE if (UDIWrite (From, To, Count, Size, &CountDone, HostEndian)) */
+/* OBSOLETE error ("UDIWrite() failed in udi_store_regisetrs"); */
+/* OBSOLETE */
+/* OBSOLETE /* PC0, PC1, PC2 possibly as shadow registers */ */
+/* OBSOLETE */
+/* OBSOLETE From = (UDIUInt32 *) & registers[4 * SR_REGNUM (10)]; */
+/* OBSOLETE To.Space = UDI29KSpecialRegs; */
+/* OBSOLETE Count = 3; */
+/* OBSOLETE if (USE_SHADOW_PC) */
+/* OBSOLETE To.Offset = 20; /* SPC0 */ */
+/* OBSOLETE else */
+/* OBSOLETE To.Offset = 10; /* PC0 */ */
+/* OBSOLETE if (UDIWrite (From, To, Count, Size, &CountDone, HostEndian)) */
+/* OBSOLETE error ("UDIWrite() failed in udi_store_regisetrs"); */
+/* OBSOLETE */
+/* OBSOLETE /* PC1 via UDI29KPC */ */
+/* OBSOLETE */
+/* OBSOLETE From = (UDIUInt32 *) & registers[4 * PC_REGNUM]; */
+/* OBSOLETE To.Space = UDI29KPC; */
+/* OBSOLETE To.Offset = 0; /* PC1 */ */
+/* OBSOLETE Count = 1; */
+/* OBSOLETE if (UDIWrite (From, To, Count, Size, &CountDone, HostEndian)) */
+/* OBSOLETE error ("UDIWrite() failed in udi_store_regisetrs"); */
+/* OBSOLETE */
+/* OBSOLETE /* LRU and MMU */ */
+/* OBSOLETE */
+/* OBSOLETE From = (UDIUInt32 *) & registers[4 * SR_REGNUM (13)]; */
+/* OBSOLETE To.Space = UDI29KSpecialRegs; */
+/* OBSOLETE To.Offset = 13; */
+/* OBSOLETE Count = 2; */
+/* OBSOLETE if (UDIWrite (From, To, Count, Size, &CountDone, HostEndian)) */
+/* OBSOLETE error ("UDIWrite() failed in udi_store_regisetrs"); */
+/* OBSOLETE */
+/* OBSOLETE /* Unprotected Special Registers */ */
+/* OBSOLETE */
+/* OBSOLETE From = (UDIUInt32 *) & registers[4 * SR_REGNUM (128)]; */
+/* OBSOLETE To.Space = UDI29KSpecialRegs; */
+/* OBSOLETE To.Offset = 128; */
+/* OBSOLETE Count = 135 - 128 + 1; */
+/* OBSOLETE if (UDIWrite (From, To, Count, Size, &CountDone, HostEndian)) */
+/* OBSOLETE error ("UDIWrite() failed in udi_store_regisetrs"); */
+/* OBSOLETE */
+/* OBSOLETE registers_changed (); */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /****************************************************** UDI_PREPARE_TO_STORE */ */
+/* OBSOLETE /* Get ready to modify the registers array. On machines which store */
+/* OBSOLETE individual registers, this doesn't need to do anything. On machines */
+/* OBSOLETE which store all the registers in one fell swoop, this makes sure */
+/* OBSOLETE that registers contains all the registers from the program being */
+/* OBSOLETE debugged. */ */
+/* OBSOLETE */
+/* OBSOLETE static void */
+/* OBSOLETE udi_prepare_to_store (void) */
+/* OBSOLETE { */
+/* OBSOLETE /* Do nothing, since we can store individual regs */ */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /********************************************************** TRANSLATE_ADDR */ */
+/* OBSOLETE static CORE_ADDR */
+/* OBSOLETE translate_addr (CORE_ADDR addr) */
+/* OBSOLETE { */
+/* OBSOLETE #if defined(ULTRA3) && defined(KERNEL_DEBUGGING) */
+/* OBSOLETE /* Check for a virtual address in the kernel */ */
+/* OBSOLETE /* Assume physical address of ublock is in paddr_u register */ */
+/* OBSOLETE /* FIXME: doesn't work for user virtual addresses */ */
+/* OBSOLETE if (addr >= UVADDR) */
+/* OBSOLETE { */
+/* OBSOLETE /* PADDR_U register holds the physical address of the ublock */ */
+/* OBSOLETE CORE_ADDR i = (CORE_ADDR) read_register (PADDR_U_REGNUM); */
+/* OBSOLETE return (i + addr - (CORE_ADDR) UVADDR); */
+/* OBSOLETE } */
+/* OBSOLETE else */
+/* OBSOLETE { */
+/* OBSOLETE return (addr); */
+/* OBSOLETE } */
+/* OBSOLETE #else */
+/* OBSOLETE return (addr); */
+/* OBSOLETE #endif */
+/* OBSOLETE } */
+/* OBSOLETE /************************************************* UDI_XFER_INFERIOR_MEMORY */ */
+/* OBSOLETE /* FIXME! Merge these two. */ */
+/* OBSOLETE static int */
+/* OBSOLETE udi_xfer_inferior_memory (CORE_ADDR memaddr, char *myaddr, int len, int write, */
+/* OBSOLETE struct mem_attrib *attrib ATTRIBUTE_UNUSED, */
+/* OBSOLETE struct target_ops *target ATTRIBUTE_UNUSED) */
+/* OBSOLETE { */
+/* OBSOLETE */
+/* OBSOLETE memaddr = translate_addr (memaddr); */
+/* OBSOLETE */
+/* OBSOLETE if (write) */
+/* OBSOLETE return udi_write_inferior_memory (memaddr, myaddr, len); */
+/* OBSOLETE else */
+/* OBSOLETE return udi_read_inferior_memory (memaddr, myaddr, len); */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /********************************************************** UDI_FILES_INFO */ */
+/* OBSOLETE static void */
+/* OBSOLETE udi_files_info (struct target_ops *target) */
+/* OBSOLETE { */
+/* OBSOLETE printf_unfiltered ("\tAttached to UDI socket to %s", udi_config_id); */
+/* OBSOLETE if (prog_name != NULL) */
+/* OBSOLETE printf_unfiltered ("and running program %s", prog_name); */
+/* OBSOLETE printf_unfiltered (".\n"); */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /**************************************************** UDI_INSERT_BREAKPOINT */ */
+/* OBSOLETE static int */
+/* OBSOLETE udi_insert_breakpoint (CORE_ADDR addr, char *contents_cache) */
+/* OBSOLETE { */
+/* OBSOLETE int cnt; */
+/* OBSOLETE UDIError err; */
+/* OBSOLETE */
+/* OBSOLETE for (cnt = 0; cnt < BKPT_TABLE_SIZE; cnt++) */
+/* OBSOLETE if (bkpt_table[cnt].Type == 0) /* Find first free slot */ */
+/* OBSOLETE break; */
+/* OBSOLETE */
+/* OBSOLETE if (cnt >= BKPT_TABLE_SIZE) */
+/* OBSOLETE error ("Too many breakpoints set"); */
+/* OBSOLETE */
+/* OBSOLETE bkpt_table[cnt].Addr.Offset = addr; */
+/* OBSOLETE bkpt_table[cnt].Addr.Space = UDI29KIRAMSpace; */
+/* OBSOLETE bkpt_table[cnt].PassCount = 1; */
+/* OBSOLETE bkpt_table[cnt].Type = UDIBreakFlagExecute; */
+/* OBSOLETE */
+/* OBSOLETE err = UDISetBreakpoint (bkpt_table[cnt].Addr, */
+/* OBSOLETE bkpt_table[cnt].PassCount, */
+/* OBSOLETE bkpt_table[cnt].Type, */
+/* OBSOLETE &bkpt_table[cnt].BreakId); */
+/* OBSOLETE */
+/* OBSOLETE if (err == 0) */
+/* OBSOLETE return 0; /* Success */ */
+/* OBSOLETE */
+/* OBSOLETE bkpt_table[cnt].Type = 0; */
+/* OBSOLETE error ("UDISetBreakpoint returned error code %d\n", err); */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /**************************************************** UDI_REMOVE_BREAKPOINT */ */
+/* OBSOLETE static int */
+/* OBSOLETE udi_remove_breakpoint (CORE_ADDR addr, char *contents_cache) */
+/* OBSOLETE { */
+/* OBSOLETE int cnt; */
+/* OBSOLETE UDIError err; */
+/* OBSOLETE */
+/* OBSOLETE for (cnt = 0; cnt < BKPT_TABLE_SIZE; cnt++) */
+/* OBSOLETE if (bkpt_table[cnt].Addr.Offset == addr) /* Find matching breakpoint */ */
+/* OBSOLETE break; */
+/* OBSOLETE */
+/* OBSOLETE if (cnt >= BKPT_TABLE_SIZE) */
+/* OBSOLETE error ("Can't find breakpoint in table"); */
+/* OBSOLETE */
+/* OBSOLETE bkpt_table[cnt].Type = 0; */
+/* OBSOLETE */
+/* OBSOLETE err = UDIClearBreakpoint (bkpt_table[cnt].BreakId); */
+/* OBSOLETE if (err == 0) */
+/* OBSOLETE return 0; /* Success */ */
+/* OBSOLETE */
+/* OBSOLETE error ("UDIClearBreakpoint returned error code %d\n", err); */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE static void */
+/* OBSOLETE udi_kill (void) */
+/* OBSOLETE { */
+/* OBSOLETE */
+/* OBSOLETE #if 0 */
+/* OBSOLETE /* */
+/* OBSOLETE UDIStop does not really work as advertised. It causes the TIP to close it's */
+/* OBSOLETE connection, which usually results in GDB dying with a SIGPIPE. For now, we */
+/* OBSOLETE just invoke udi_close, which seems to get things right. */
+/* OBSOLETE */ */
+/* OBSOLETE UDIStop (); */
+/* OBSOLETE */
+/* OBSOLETE udi_session_id = -1; */
+/* OBSOLETE inferior_ptid = null_ptid; */
+/* OBSOLETE */
+/* OBSOLETE if (from_tty) */
+/* OBSOLETE printf_unfiltered ("Target has been stopped."); */
+/* OBSOLETE #endif /* 0 */ */
+/* OBSOLETE #if 0 */
+/* OBSOLETE udi_close (0); */
+/* OBSOLETE pop_target (); */
+/* OBSOLETE #endif /* 0 */ */
+/* OBSOLETE */
+/* OBSOLETE /* Keep the target around, e.g. so "run" can do the right thing when */
+/* OBSOLETE we are already debugging something. */ */
+/* OBSOLETE */
+/* OBSOLETE if (UDIDisconnect (udi_session_id, UDITerminateSession)) */
+/* OBSOLETE { */
+/* OBSOLETE warning ("UDIDisconnect() failed"); */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* Do not try to close udi_session_id again, later in the program. */ */
+/* OBSOLETE udi_session_id = -1; */
+/* OBSOLETE inferior_ptid = null_ptid; */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* */
+/* OBSOLETE Load a program into the target. Args are: `program {options}'. The options */
+/* OBSOLETE are used to control loading of the program, and are NOT passed onto the */
+/* OBSOLETE loaded code as arguments. (You need to use the `run' command to do that.) */
+/* OBSOLETE */
+/* OBSOLETE The options are: */
+/* OBSOLETE -ms %d Set mem stack size to %d */
+/* OBSOLETE -rs %d Set regular stack size to %d */
+/* OBSOLETE -i send init info (default) */
+/* OBSOLETE -noi don't send init info */
+/* OBSOLETE -[tT] Load Text section */
+/* OBSOLETE -[dD] Load Data section */
+/* OBSOLETE -[bB] Load BSS section */
+/* OBSOLETE -[lL] Load Lit section */
+/* OBSOLETE */ */
+/* OBSOLETE */
+/* OBSOLETE static void */
+/* OBSOLETE download (char *load_arg_string, int from_tty) */
+/* OBSOLETE { */
+/* OBSOLETE #define DEFAULT_MEM_STACK_SIZE 0x6000 */
+/* OBSOLETE #define DEFAULT_REG_STACK_SIZE 0x2000 */
+/* OBSOLETE */
+/* OBSOLETE char *token; */
+/* OBSOLETE char *filename; */
+/* OBSOLETE asection *section; */
+/* OBSOLETE bfd *pbfd; */
+/* OBSOLETE UDIError err; */
+/* OBSOLETE int load_text = 1, load_data = 1, load_bss = 1, load_lit = 1; */
+/* OBSOLETE */
+/* OBSOLETE address_ranges[0].Space = UDI29KIRAMSpace; */
+/* OBSOLETE address_ranges[0].Offset = 0xffffffff; */
+/* OBSOLETE address_ranges[0].Size = 0; */
+/* OBSOLETE */
+/* OBSOLETE address_ranges[1].Space = UDI29KDRAMSpace; */
+/* OBSOLETE address_ranges[1].Offset = 0xffffffff; */
+/* OBSOLETE address_ranges[1].Size = 0; */
+/* OBSOLETE */
+/* OBSOLETE stack_sizes[0] = DEFAULT_REG_STACK_SIZE; */
+/* OBSOLETE stack_sizes[1] = DEFAULT_MEM_STACK_SIZE; */
+/* OBSOLETE */
+/* OBSOLETE dont_repeat (); */
+/* OBSOLETE */
+/* OBSOLETE filename = strtok (load_arg_string, " \t"); */
+/* OBSOLETE if (!filename) */
+/* OBSOLETE error ("Must specify at least a file name with the load command"); */
+/* OBSOLETE */
+/* OBSOLETE filename = tilde_expand (filename); */
+/* OBSOLETE make_cleanup (xfree, filename); */
+/* OBSOLETE */
+/* OBSOLETE while (token = strtok (NULL, " \t")) */
+/* OBSOLETE { */
+/* OBSOLETE if (token[0] == '-') */
+/* OBSOLETE { */
+/* OBSOLETE token++; */
+/* OBSOLETE */
+/* OBSOLETE if (STREQ (token, "ms")) */
+/* OBSOLETE stack_sizes[1] = atol (strtok (NULL, " \t")); */
+/* OBSOLETE else if (STREQ (token, "rs")) */
+/* OBSOLETE stack_sizes[0] = atol (strtok (NULL, " \t")); */
+/* OBSOLETE else */
+/* OBSOLETE { */
+/* OBSOLETE load_text = load_data = load_bss = load_lit = 0; */
+/* OBSOLETE */
+/* OBSOLETE while (*token) */
+/* OBSOLETE { */
+/* OBSOLETE switch (*token++) */
+/* OBSOLETE { */
+/* OBSOLETE case 't': */
+/* OBSOLETE case 'T': */
+/* OBSOLETE load_text = 1; */
+/* OBSOLETE break; */
+/* OBSOLETE case 'd': */
+/* OBSOLETE case 'D': */
+/* OBSOLETE load_data = 1; */
+/* OBSOLETE break; */
+/* OBSOLETE case 'b': */
+/* OBSOLETE case 'B': */
+/* OBSOLETE load_bss = 1; */
+/* OBSOLETE break; */
+/* OBSOLETE case 'l': */
+/* OBSOLETE case 'L': */
+/* OBSOLETE load_lit = 1; */
+/* OBSOLETE break; */
+/* OBSOLETE default: */
+/* OBSOLETE error ("Unknown UDI load option -%s", token - 1); */
+/* OBSOLETE } */
+/* OBSOLETE } */
+/* OBSOLETE } */
+/* OBSOLETE } */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE pbfd = bfd_openr (filename, gnutarget); */
+/* OBSOLETE */
+/* OBSOLETE if (!pbfd) */
+/* OBSOLETE /* FIXME: should be using bfd_errmsg, not assuming it was */
+/* OBSOLETE bfd_error_system_call. */ */
+/* OBSOLETE perror_with_name (filename); */
+/* OBSOLETE */
+/* OBSOLETE /* FIXME: should be checking for errors from bfd_close (for one thing, */
+/* OBSOLETE on error it does not free all the storage associated with the */
+/* OBSOLETE bfd). */ */
+/* OBSOLETE make_cleanup_bfd_close (pbfd); */
+/* OBSOLETE */
+/* OBSOLETE QUIT; */
+/* OBSOLETE immediate_quit++; */
+/* OBSOLETE */
+/* OBSOLETE if (!bfd_check_format (pbfd, bfd_object)) */
+/* OBSOLETE error ("It doesn't seem to be an object file"); */
+/* OBSOLETE */
+/* OBSOLETE for (section = pbfd->sections; section; section = section->next) */
+/* OBSOLETE { */
+/* OBSOLETE if (bfd_get_section_flags (pbfd, section) & SEC_ALLOC) */
+/* OBSOLETE { */
+/* OBSOLETE UDIResource To; */
+/* OBSOLETE UDICount Count; */
+/* OBSOLETE unsigned long section_size, section_end; */
+/* OBSOLETE const char *section_name; */
+/* OBSOLETE */
+/* OBSOLETE section_name = bfd_get_section_name (pbfd, section); */
+/* OBSOLETE if (STREQ (section_name, ".text") && !load_text) */
+/* OBSOLETE continue; */
+/* OBSOLETE else if (STREQ (section_name, ".data") && !load_data) */
+/* OBSOLETE continue; */
+/* OBSOLETE else if (STREQ (section_name, ".bss") && !load_bss) */
+/* OBSOLETE continue; */
+/* OBSOLETE else if (STREQ (section_name, ".lit") && !load_lit) */
+/* OBSOLETE continue; */
+/* OBSOLETE */
+/* OBSOLETE To.Offset = bfd_get_section_vma (pbfd, section); */
+/* OBSOLETE section_size = bfd_section_size (pbfd, section); */
+/* OBSOLETE section_end = To.Offset + section_size; */
+/* OBSOLETE */
+/* OBSOLETE if (section_size == 0) */
+/* OBSOLETE /* This is needed at least in the BSS case, where the code */
+/* OBSOLETE below starts writing before it even checks the size. */ */
+/* OBSOLETE continue; */
+/* OBSOLETE */
+/* OBSOLETE printf_unfiltered ("[Loading section %s at %x (%d bytes)]\n", */
+/* OBSOLETE section_name, */
+/* OBSOLETE To.Offset, */
+/* OBSOLETE section_size); */
+/* OBSOLETE */
+/* OBSOLETE if (bfd_get_section_flags (pbfd, section) & SEC_CODE) */
+/* OBSOLETE { */
+/* OBSOLETE To.Space = UDI29KIRAMSpace; */
+/* OBSOLETE */
+/* OBSOLETE address_ranges[0].Offset = min (address_ranges[0].Offset, */
+/* OBSOLETE To.Offset); */
+/* OBSOLETE address_ranges[0].Size = max (address_ranges[0].Size, */
+/* OBSOLETE section_end */
+/* OBSOLETE - address_ranges[0].Offset); */
+/* OBSOLETE } */
+/* OBSOLETE else */
+/* OBSOLETE { */
+/* OBSOLETE To.Space = UDI29KDRAMSpace; */
+/* OBSOLETE */
+/* OBSOLETE address_ranges[1].Offset = min (address_ranges[1].Offset, */
+/* OBSOLETE To.Offset); */
+/* OBSOLETE address_ranges[1].Size = max (address_ranges[1].Size, */
+/* OBSOLETE section_end */
+/* OBSOLETE - address_ranges[1].Offset); */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE if (bfd_get_section_flags (pbfd, section) & SEC_LOAD) /* Text, data or lit */ */
+/* OBSOLETE { */
+/* OBSOLETE file_ptr fptr; */
+/* OBSOLETE */
+/* OBSOLETE fptr = 0; */
+/* OBSOLETE */
+/* OBSOLETE while (section_size > 0) */
+/* OBSOLETE { */
+/* OBSOLETE char buffer[1024]; */
+/* OBSOLETE */
+/* OBSOLETE Count = min (section_size, 1024); */
+/* OBSOLETE */
+/* OBSOLETE bfd_get_section_contents (pbfd, section, buffer, fptr, */
+/* OBSOLETE Count); */
+/* OBSOLETE */
+/* OBSOLETE err = UDIWrite ((UDIHostMemPtr) buffer, /* From */ */
+/* OBSOLETE To, /* To */ */
+/* OBSOLETE Count, /* Count */ */
+/* OBSOLETE (UDISizeT) 1, /* Size */ */
+/* OBSOLETE &Count, /* CountDone */ */
+/* OBSOLETE (UDIBool) 0); /* HostEndian */ */
+/* OBSOLETE if (err) */
+/* OBSOLETE error ("UDIWrite failed, error = %d", err); */
+/* OBSOLETE */
+/* OBSOLETE To.Offset += Count; */
+/* OBSOLETE fptr += Count; */
+/* OBSOLETE section_size -= Count; */
+/* OBSOLETE } */
+/* OBSOLETE } */
+/* OBSOLETE else */
+/* OBSOLETE /* BSS */ */
+/* OBSOLETE { */
+/* OBSOLETE UDIResource From; */
+/* OBSOLETE unsigned long zero = 0; */
+/* OBSOLETE */
+/* OBSOLETE /* Write a zero byte at the vma */ */
+/* OBSOLETE /* FIXME: Broken for sections of 1-3 bytes (we test for */
+/* OBSOLETE zero above). */ */
+/* OBSOLETE err = UDIWrite ((UDIHostMemPtr) & zero, /* From */ */
+/* OBSOLETE To, /* To */ */
+/* OBSOLETE (UDICount) 1, /* Count */ */
+/* OBSOLETE (UDISizeT) 4, /* Size */ */
+/* OBSOLETE &Count, /* CountDone */ */
+/* OBSOLETE (UDIBool) 0); /* HostEndian */ */
+/* OBSOLETE if (err) */
+/* OBSOLETE error ("UDIWrite failed, error = %d", err); */
+/* OBSOLETE */
+/* OBSOLETE From = To; */
+/* OBSOLETE To.Offset += 4; */
+/* OBSOLETE */
+/* OBSOLETE /* Now, duplicate it for the length of the BSS */ */
+/* OBSOLETE err = UDICopy (From, /* From */ */
+/* OBSOLETE To, /* To */ */
+/* OBSOLETE (UDICount) (section_size / 4 - 1), /* Count */ */
+/* OBSOLETE (UDISizeT) 4, /* Size */ */
+/* OBSOLETE &Count, /* CountDone */ */
+/* OBSOLETE (UDIBool) 1); /* Direction */ */
+/* OBSOLETE if (err) */
+/* OBSOLETE { */
+/* OBSOLETE char message[100]; */
+/* OBSOLETE int xerr; */
+/* OBSOLETE */
+/* OBSOLETE xerr = UDIGetErrorMsg (err, 100, message, &Count); */
+/* OBSOLETE if (!xerr) */
+/* OBSOLETE fprintf_unfiltered (gdb_stderr, "Error is %s\n", message); */
+/* OBSOLETE else */
+/* OBSOLETE fprintf_unfiltered (gdb_stderr, "xerr is %d\n", xerr); */
+/* OBSOLETE error ("UDICopy failed, error = %d", err); */
+/* OBSOLETE } */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE } */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE entry.Space = UDI29KIRAMSpace; */
+/* OBSOLETE entry.Offset = bfd_get_start_address (pbfd); */
+/* OBSOLETE */
+/* OBSOLETE immediate_quit--; */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* Function to download an image into the remote target. */ */
+/* OBSOLETE */
+/* OBSOLETE static void */
+/* OBSOLETE udi_load (char *args, int from_tty) */
+/* OBSOLETE { */
+/* OBSOLETE download (args, from_tty); */
+/* OBSOLETE */
+/* OBSOLETE /* As a convenience, pick up any symbol info that is in the program */
+/* OBSOLETE being loaded. Note that we assume that the program is the``mainline''; */
+/* OBSOLETE if this is not always true, then this code will need to be augmented. */ */
+/* OBSOLETE symbol_file_add (strtok (args, " \t"), from_tty, NULL, 1, 0); */
+/* OBSOLETE */
+/* OBSOLETE /* Getting new symbols may change our opinion about what is */
+/* OBSOLETE frameless. */ */
+/* OBSOLETE reinit_frame_cache (); */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /*************************************************** UDI_WRITE_INFERIOR_MEMORY */
+/* OBSOLETE ** Copy LEN bytes of data from debugger memory at MYADDR */
+/* OBSOLETE to inferior's memory at MEMADDR. Returns number of bytes written. */ */
+/* OBSOLETE static int */
+/* OBSOLETE udi_write_inferior_memory (CORE_ADDR memaddr, char *myaddr, int len) */
+/* OBSOLETE { */
+/* OBSOLETE int nwritten = 0; */
+/* OBSOLETE UDIUInt32 *From; */
+/* OBSOLETE UDIResource To; */
+/* OBSOLETE UDICount Count; */
+/* OBSOLETE UDISizeT Size = 1; */
+/* OBSOLETE UDICount CountDone = 0; */
+/* OBSOLETE UDIBool HostEndian = 0; */
+/* OBSOLETE */
+/* OBSOLETE To.Space = udi_memory_space (memaddr); */
+/* OBSOLETE From = (UDIUInt32 *) myaddr; */
+/* OBSOLETE */
+/* OBSOLETE while (nwritten < len) */
+/* OBSOLETE { */
+/* OBSOLETE Count = len - nwritten; */
+/* OBSOLETE if (Count > MAXDATA) */
+/* OBSOLETE Count = MAXDATA; */
+/* OBSOLETE To.Offset = memaddr + nwritten; */
+/* OBSOLETE if (UDIWrite (From, To, Count, Size, &CountDone, HostEndian)) */
+/* OBSOLETE { */
+/* OBSOLETE error ("UDIWrite() failed in udi_write_inferior_memory"); */
+/* OBSOLETE break; */
+/* OBSOLETE } */
+/* OBSOLETE else */
+/* OBSOLETE { */
+/* OBSOLETE nwritten += CountDone; */
+/* OBSOLETE From += CountDone; */
+/* OBSOLETE } */
+/* OBSOLETE } */
+/* OBSOLETE return (nwritten); */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /**************************************************** UDI_READ_INFERIOR_MEMORY */
+/* OBSOLETE ** Read LEN bytes from inferior memory at MEMADDR. Put the result */
+/* OBSOLETE at debugger address MYADDR. Returns number of bytes read. */ */
+/* OBSOLETE static int */
+/* OBSOLETE udi_read_inferior_memory (CORE_ADDR memaddr, char *myaddr, int len) */
+/* OBSOLETE { */
+/* OBSOLETE int nread = 0; */
+/* OBSOLETE UDIResource From; */
+/* OBSOLETE UDIUInt32 *To; */
+/* OBSOLETE UDICount Count; */
+/* OBSOLETE UDISizeT Size = 1; */
+/* OBSOLETE UDICount CountDone = 0; */
+/* OBSOLETE UDIBool HostEndian = 0; */
+/* OBSOLETE UDIError err; */
+/* OBSOLETE */
+/* OBSOLETE From.Space = udi_memory_space (memaddr); */
+/* OBSOLETE To = (UDIUInt32 *) myaddr; */
+/* OBSOLETE */
+/* OBSOLETE while (nread < len) */
+/* OBSOLETE { */
+/* OBSOLETE Count = len - nread; */
+/* OBSOLETE if (Count > MAXDATA) */
+/* OBSOLETE Count = MAXDATA; */
+/* OBSOLETE From.Offset = memaddr + nread; */
+/* OBSOLETE if (err = UDIRead (From, To, Count, Size, &CountDone, HostEndian)) */
+/* OBSOLETE { */
+/* OBSOLETE error ("UDIRead() failed in udi_read_inferior_memory"); */
+/* OBSOLETE break; */
+/* OBSOLETE } */
+/* OBSOLETE else */
+/* OBSOLETE { */
+/* OBSOLETE nread += CountDone; */
+/* OBSOLETE To += CountDone; */
+/* OBSOLETE } */
+/* OBSOLETE } */
+/* OBSOLETE return (nread); */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /********************************************************************* WARNING */
+/* OBSOLETE */ */
+/* OBSOLETE udi_warning (int num) */
+/* OBSOLETE { */
+/* OBSOLETE error ("ERROR while loading program into remote TIP: $d\n", num); */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE */
+/* OBSOLETE /*****************************************************************************/ */
+/* OBSOLETE /* Fetch a single register indicatated by 'regno'. */
+/* OBSOLETE * Returns 0/-1 on success/failure. */
+/* OBSOLETE */ */
+/* OBSOLETE static void */
+/* OBSOLETE fetch_register (int regno) */
+/* OBSOLETE { */
+/* OBSOLETE UDIResource From; */
+/* OBSOLETE UDIUInt32 To; */
+/* OBSOLETE UDICount Count = 1; */
+/* OBSOLETE UDISizeT Size = 4; */
+/* OBSOLETE UDICount CountDone; */
+/* OBSOLETE UDIBool HostEndian = 0; */
+/* OBSOLETE UDIError err; */
+/* OBSOLETE int result; */
+/* OBSOLETE */
+/* OBSOLETE if (regno == GR1_REGNUM) */
+/* OBSOLETE { */
+/* OBSOLETE From.Space = UDI29KGlobalRegs; */
+/* OBSOLETE From.Offset = 1; */
+/* OBSOLETE } */
+/* OBSOLETE else if (regno >= GR96_REGNUM && regno < GR96_REGNUM + 32) */
+/* OBSOLETE { */
+/* OBSOLETE From.Space = UDI29KGlobalRegs; */
+/* OBSOLETE From.Offset = (regno - GR96_REGNUM) + 96;; */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE #if defined(GR64_REGNUM) */
+/* OBSOLETE */
+/* OBSOLETE else if (regno >= GR64_REGNUM && regno < GR64_REGNUM + 32) */
+/* OBSOLETE { */
+/* OBSOLETE From.Space = UDI29KGlobalRegs; */
+/* OBSOLETE From.Offset = (regno - GR64_REGNUM) + 64; */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE #endif /* GR64_REGNUM */ */
+/* OBSOLETE */
+/* OBSOLETE else if (regno >= LR0_REGNUM && regno < LR0_REGNUM + 128) */
+/* OBSOLETE { */
+/* OBSOLETE From.Space = UDI29KLocalRegs; */
+/* OBSOLETE From.Offset = (regno - LR0_REGNUM); */
+/* OBSOLETE } */
+/* OBSOLETE else if (regno >= FPE_REGNUM && regno <= EXO_REGNUM) */
+/* OBSOLETE { */
+/* OBSOLETE int val = -1; */
+/* OBSOLETE /*supply_register(160 + (regno - FPE_REGNUM),(char *) &val); */ */
+/* OBSOLETE supply_register (regno, (char *) &val); */
+/* OBSOLETE return; /* Pretend Success */ */
+/* OBSOLETE } */
+/* OBSOLETE else */
+/* OBSOLETE { */
+/* OBSOLETE From.Space = UDI29KSpecialRegs; */
+/* OBSOLETE From.Offset = regnum_to_srnum (regno); */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE if (err = UDIRead (From, &To, Count, Size, &CountDone, HostEndian)) */
+/* OBSOLETE error ("UDIRead() failed in udi_fetch_registers"); */
+/* OBSOLETE */
+/* OBSOLETE supply_register (regno, (char *) &To); */
+/* OBSOLETE */
+/* OBSOLETE if (remote_debug) */
+/* OBSOLETE fprintf_unfiltered (gdb_stdlog, "Fetching register %s = 0x%x\n", */
+/* OBSOLETE REGISTER_NAME (regno), To); */
+/* OBSOLETE } */
+/* OBSOLETE /*****************************************************************************/ */
+/* OBSOLETE /* Store a single register indicated by 'regno'. */
+/* OBSOLETE * Returns 0/-1 on success/failure. */
+/* OBSOLETE */ */
+/* OBSOLETE static int */
+/* OBSOLETE store_register (int regno) */
+/* OBSOLETE { */
+/* OBSOLETE int result; */
+/* OBSOLETE UDIUInt32 From; */
+/* OBSOLETE UDIResource To; */
+/* OBSOLETE UDICount Count = 1; */
+/* OBSOLETE UDISizeT Size = 4; */
+/* OBSOLETE UDICount CountDone; */
+/* OBSOLETE UDIBool HostEndian = 0; */
+/* OBSOLETE */
+/* OBSOLETE From = read_register (regno); /* get data value */ */
+/* OBSOLETE */
+/* OBSOLETE if (remote_debug) */
+/* OBSOLETE fprintf_unfiltered (gdb_stdlog, "Storing register %s = 0x%x\n", */
+/* OBSOLETE REGISTER_NAME (regno), From); */
+/* OBSOLETE */
+/* OBSOLETE if (regno == GR1_REGNUM) */
+/* OBSOLETE { */
+/* OBSOLETE To.Space = UDI29KGlobalRegs; */
+/* OBSOLETE To.Offset = 1; */
+/* OBSOLETE result = UDIWrite (&From, To, Count, Size, &CountDone, HostEndian); */
+/* OBSOLETE /* Setting GR1 changes the numbers of all the locals, so invalidate the */
+/* OBSOLETE * register cache. Do this *after* calling read_register, because we want */
+/* OBSOLETE * read_register to return the value that write_register has just stuffed */
+/* OBSOLETE * into the registers array, not the value of the register fetched from */
+/* OBSOLETE * the inferior. */
+/* OBSOLETE */ */
+/* OBSOLETE registers_changed (); */
+/* OBSOLETE } */
+/* OBSOLETE #if defined(GR64_REGNUM) */
+/* OBSOLETE else if (regno >= GR64_REGNUM && regno < GR64_REGNUM + 32) */
+/* OBSOLETE { */
+/* OBSOLETE To.Space = UDI29KGlobalRegs; */
+/* OBSOLETE To.Offset = (regno - GR64_REGNUM) + 64; */
+/* OBSOLETE result = UDIWrite (&From, To, Count, Size, &CountDone, HostEndian); */
+/* OBSOLETE } */
+/* OBSOLETE #endif /* GR64_REGNUM */ */
+/* OBSOLETE else if (regno >= GR96_REGNUM && regno < GR96_REGNUM + 32) */
+/* OBSOLETE { */
+/* OBSOLETE To.Space = UDI29KGlobalRegs; */
+/* OBSOLETE To.Offset = (regno - GR96_REGNUM) + 96; */
+/* OBSOLETE result = UDIWrite (&From, To, Count, Size, &CountDone, HostEndian); */
+/* OBSOLETE } */
+/* OBSOLETE else if (regno >= LR0_REGNUM && regno < LR0_REGNUM + 128) */
+/* OBSOLETE { */
+/* OBSOLETE To.Space = UDI29KLocalRegs; */
+/* OBSOLETE To.Offset = (regno - LR0_REGNUM); */
+/* OBSOLETE result = UDIWrite (&From, To, Count, Size, &CountDone, HostEndian); */
+/* OBSOLETE } */
+/* OBSOLETE else if (regno >= FPE_REGNUM && regno <= EXO_REGNUM) */
+/* OBSOLETE return 0; /* Pretend Success */ */
+/* OBSOLETE else if (regno == PC_REGNUM) */
+/* OBSOLETE { */
+/* OBSOLETE /* PC1 via UDI29KPC */ */
+/* OBSOLETE */
+/* OBSOLETE To.Space = UDI29KPC; */
+/* OBSOLETE To.Offset = 0; /* PC1 */ */
+/* OBSOLETE result = UDIWrite (&From, To, Count, Size, &CountDone, HostEndian); */
+/* OBSOLETE */
+/* OBSOLETE /* Writing to this loc actually changes the values of pc0 & pc1 */ */
+/* OBSOLETE */
+/* OBSOLETE register_valid[PC_REGNUM] = 0; /* pc1 */ */
+/* OBSOLETE register_valid[NPC_REGNUM] = 0; /* pc0 */ */
+/* OBSOLETE } */
+/* OBSOLETE else */
+/* OBSOLETE /* An unprotected or protected special register */ */
+/* OBSOLETE { */
+/* OBSOLETE To.Space = UDI29KSpecialRegs; */
+/* OBSOLETE To.Offset = regnum_to_srnum (regno); */
+/* OBSOLETE result = UDIWrite (&From, To, Count, Size, &CountDone, HostEndian); */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE if (result != 0) */
+/* OBSOLETE error ("UDIWrite() failed in store_registers"); */
+/* OBSOLETE */
+/* OBSOLETE return 0; */
+/* OBSOLETE } */
+/* OBSOLETE /********************************************************** REGNUM_TO_SRNUM */ */
+/* OBSOLETE /* */
+/* OBSOLETE * Convert a gdb special register number to a 29000 special register number. */
+/* OBSOLETE */ */
+/* OBSOLETE static int */
+/* OBSOLETE regnum_to_srnum (int regno) */
+/* OBSOLETE { */
+/* OBSOLETE switch (regno) */
+/* OBSOLETE { */
+/* OBSOLETE case VAB_REGNUM: */
+/* OBSOLETE return (0); */
+/* OBSOLETE case OPS_REGNUM: */
+/* OBSOLETE return (1); */
+/* OBSOLETE case CPS_REGNUM: */
+/* OBSOLETE return (2); */
+/* OBSOLETE case CFG_REGNUM: */
+/* OBSOLETE return (3); */
+/* OBSOLETE case CHA_REGNUM: */
+/* OBSOLETE return (4); */
+/* OBSOLETE case CHD_REGNUM: */
+/* OBSOLETE return (5); */
+/* OBSOLETE case CHC_REGNUM: */
+/* OBSOLETE return (6); */
+/* OBSOLETE case RBP_REGNUM: */
+/* OBSOLETE return (7); */
+/* OBSOLETE case TMC_REGNUM: */
+/* OBSOLETE return (8); */
+/* OBSOLETE case TMR_REGNUM: */
+/* OBSOLETE return (9); */
+/* OBSOLETE case NPC_REGNUM: */
+/* OBSOLETE return (USE_SHADOW_PC ? (20) : (10)); */
+/* OBSOLETE case PC_REGNUM: */
+/* OBSOLETE return (USE_SHADOW_PC ? (21) : (11)); */
+/* OBSOLETE case PC2_REGNUM: */
+/* OBSOLETE return (USE_SHADOW_PC ? (22) : (12)); */
+/* OBSOLETE case MMU_REGNUM: */
+/* OBSOLETE return (13); */
+/* OBSOLETE case LRU_REGNUM: */
+/* OBSOLETE return (14); */
+/* OBSOLETE case IPC_REGNUM: */
+/* OBSOLETE return (128); */
+/* OBSOLETE case IPA_REGNUM: */
+/* OBSOLETE return (129); */
+/* OBSOLETE case IPB_REGNUM: */
+/* OBSOLETE return (130); */
+/* OBSOLETE case Q_REGNUM: */
+/* OBSOLETE return (131); */
+/* OBSOLETE case ALU_REGNUM: */
+/* OBSOLETE return (132); */
+/* OBSOLETE case BP_REGNUM: */
+/* OBSOLETE return (133); */
+/* OBSOLETE case FC_REGNUM: */
+/* OBSOLETE return (134); */
+/* OBSOLETE case CR_REGNUM: */
+/* OBSOLETE return (135); */
+/* OBSOLETE case FPE_REGNUM: */
+/* OBSOLETE return (160); */
+/* OBSOLETE case INTE_REGNUM: */
+/* OBSOLETE return (161); */
+/* OBSOLETE case FPS_REGNUM: */
+/* OBSOLETE return (162); */
+/* OBSOLETE case EXO_REGNUM: */
+/* OBSOLETE return (164); */
+/* OBSOLETE default: */
+/* OBSOLETE return (255); /* Failure ? */ */
+/* OBSOLETE } */
+/* OBSOLETE } */
+/* OBSOLETE /****************************************************************************/ */
+/* OBSOLETE /* */
+/* OBSOLETE * Determine the Target memory space qualifier based on the addr. */
+/* OBSOLETE * FIXME: Can't distinguis I_ROM/D_ROM. */
+/* OBSOLETE * FIXME: Doesn't know anything about I_CACHE/D_CACHE. */
+/* OBSOLETE */ */
+/* OBSOLETE static CPUSpace */
+/* OBSOLETE udi_memory_space (CORE_ADDR addr) */
+/* OBSOLETE { */
+/* OBSOLETE UDIUInt32 tstart = IMemStart; */
+/* OBSOLETE UDIUInt32 tend = tstart + IMemSize; */
+/* OBSOLETE UDIUInt32 dstart = DMemStart; */
+/* OBSOLETE UDIUInt32 dend = tstart + DMemSize; */
+/* OBSOLETE UDIUInt32 rstart = RMemStart; */
+/* OBSOLETE UDIUInt32 rend = tstart + RMemSize; */
+/* OBSOLETE */
+/* OBSOLETE if (((UDIUInt32) addr >= tstart) && ((UDIUInt32) addr < tend)) */
+/* OBSOLETE { */
+/* OBSOLETE return UDI29KIRAMSpace; */
+/* OBSOLETE } */
+/* OBSOLETE else if (((UDIUInt32) addr >= dstart) && ((UDIUInt32) addr < dend)) */
+/* OBSOLETE { */
+/* OBSOLETE return UDI29KDRAMSpace; */
+/* OBSOLETE } */
+/* OBSOLETE else if (((UDIUInt32) addr >= rstart) && ((UDIUInt32) addr < rend)) */
+/* OBSOLETE { */
+/* OBSOLETE /* FIXME: how do we determine between D_ROM and I_ROM */ */
+/* OBSOLETE return UDI29KIROMSpace; */
+/* OBSOLETE } */
+/* OBSOLETE else /* FIXME: what do me do now? */ */
+/* OBSOLETE return UDI29KDRAMSpace; /* Hmmm! */ */
+/* OBSOLETE } */
+/* OBSOLETE /*********************************************************************** STUBS */
+/* OBSOLETE */ */
+/* OBSOLETE */
+/* OBSOLETE void */
+/* OBSOLETE convert16 (void) */
+/* OBSOLETE {; */
+/* OBSOLETE } */
+/* OBSOLETE void */
+/* OBSOLETE convert32 (void) */
+/* OBSOLETE {; */
+/* OBSOLETE } */
+/* OBSOLETE struct ui_file *EchoFile = 0; /* used for debugging */ */
+/* OBSOLETE int QuietMode = 0; /* used for debugging */ */
+/* OBSOLETE \f */
+/* OBSOLETE #ifdef NO_HIF_SUPPORT */
+/* OBSOLETE service_HIF (union msg_t *msg) */
+/* OBSOLETE { */
+/* OBSOLETE return (0); /* Emulate a failure */ */
+/* OBSOLETE } */
+/* OBSOLETE #endif */
+/* OBSOLETE \f */
+/* OBSOLETE /* Target_ops vector. Not static because there does not seem to be */
+/* OBSOLETE any portable way to do a forward declaration of a static variable. */
+/* OBSOLETE The RS/6000 doesn't like "extern" followed by "static"; SunOS */
+/* OBSOLETE /bin/cc doesn't like "static" twice. */ */
+/* OBSOLETE */
+/* OBSOLETE struct target_ops udi_ops; */
+/* OBSOLETE */
+/* OBSOLETE static void */
+/* OBSOLETE init_udi_ops (void) */
+/* OBSOLETE { */
+/* OBSOLETE udi_ops.to_shortname = "udi"; */
+/* OBSOLETE udi_ops.to_longname = "Remote UDI connected TIP"; */
+/* OBSOLETE udi_ops.to_doc = "Remote debug an AMD 29k using UDI socket connection to TIP process.\n\ */
+/* OBSOLETE Arguments are\n\ */
+/* OBSOLETE `configuration-id AF_INET hostname port-number'\n\ */
+/* OBSOLETE To connect via the network, where hostname and port-number specify the\n\ */
+/* OBSOLETE host and port where you can connect via UDI.\n\ */
+/* OBSOLETE configuration-id is unused.\n\ */
+/* OBSOLETE \n\ */
+/* OBSOLETE `configuration-id AF_UNIX socket-name tip-program'\n\ */
+/* OBSOLETE To connect using a local connection to the \"tip.exe\" program which is\n\ */
+/* OBSOLETE supplied by AMD. If socket-name specifies an AF_UNIX socket then the\n\ */
+/* OBSOLETE tip program must already be started; connect to it using that socket.\n\ */
+/* OBSOLETE If not, start up tip-program, which should be the name of the tip\n\ */
+/* OBSOLETE program. If appropriate, the PATH environment variable is searched.\n\ */
+/* OBSOLETE configuration-id is unused.\n\ */
+/* OBSOLETE \n\ */
+/* OBSOLETE `configuration-id'\n\ */
+/* OBSOLETE Look up the configuration in ./udi_soc or /etc/udi_soc, which\n\ */
+/* OBSOLETE are files containing lines in the above formats. configuration-id is\n\ */
+/* OBSOLETE used to pick which line of the file to use."; */
+/* OBSOLETE udi_ops.to_open = udi_open; */
+/* OBSOLETE udi_ops.to_close = udi_close; */
+/* OBSOLETE udi_ops.to_attach = udi_attach; */
+/* OBSOLETE udi_ops.to_detach = udi_detach; */
+/* OBSOLETE udi_ops.to_resume = udi_resume; */
+/* OBSOLETE udi_ops.to_wait = udi_wait; */
+/* OBSOLETE udi_ops.to_fetch_registers = udi_fetch_registers; */
+/* OBSOLETE udi_ops.to_store_registers = udi_store_registers; */
+/* OBSOLETE udi_ops.to_prepare_to_store = udi_prepare_to_store; */
+/* OBSOLETE udi_ops.to_xfer_memory = udi_xfer_inferior_memory; */
+/* OBSOLETE udi_ops.to_files_info = udi_files_info; */
+/* OBSOLETE udi_ops.to_insert_breakpoint = udi_insert_breakpoint; */
+/* OBSOLETE udi_ops.to_remove_breakpoint = udi_remove_breakpoint; */
+/* OBSOLETE udi_ops.to_terminal_init = 0; */
+/* OBSOLETE udi_ops.to_terminal_inferior = 0; */
+/* OBSOLETE udi_ops.to_terminal_ours_for_output = 0; */
+/* OBSOLETE udi_ops.to_terminal_ours = 0; */
+/* OBSOLETE udi_ops.to_terminal_info = 0; */
+/* OBSOLETE udi_ops.to_kill = udi_kill; */
+/* OBSOLETE udi_ops.to_load = udi_load; */
+/* OBSOLETE udi_ops.to_lookup_symbol = 0; */
+/* OBSOLETE udi_ops.to_create_inferior = udi_create_inferior; */
+/* OBSOLETE udi_ops.to_mourn_inferior = udi_mourn; */
+/* OBSOLETE udi_ops.to_can_run = 0; */
+/* OBSOLETE udi_ops.to_notice_signals = 0; */
+/* OBSOLETE udi_ops.to_thread_alive = 0; */
+/* OBSOLETE udi_ops.to_stop = 0; */
+/* OBSOLETE udi_ops.to_stratum = process_stratum; */
+/* OBSOLETE udi_ops.DONT_USE = 0; */
+/* OBSOLETE udi_ops.to_has_all_memory = 1; */
+/* OBSOLETE udi_ops.to_has_memory = 1; */
+/* OBSOLETE udi_ops.to_has_stack = 1; */
+/* OBSOLETE udi_ops.to_has_registers = 1; */
+/* OBSOLETE udi_ops.to_has_execution = 1; */
+/* OBSOLETE udi_ops.to_sections = 0; */
+/* OBSOLETE udi_ops.to_sections_end = 0; */
+/* OBSOLETE udi_ops.to_magic = OPS_MAGIC; */
+/* OBSOLETE }; */
+/* OBSOLETE */
+/* OBSOLETE void */
+/* OBSOLETE _initialize_remote_udi (void) */
+/* OBSOLETE { */
+/* OBSOLETE init_udi_ops (); */
+/* OBSOLETE add_target (&udi_ops); */
+/* OBSOLETE } */