This is the mail archive of the gdb-patches@sourceware.cygnus.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RDI patches for gdb 4.18



Attached is a patch file generated agains gdb-4.18.  It implements the
changes listed below for rdi target support.

RDI Background (people who don't know what the rdi target is probably
don't care about the patches, but in case somebody is curious...)

The rdi target is used for remotely debugging ARM targets that
implement the Angel Debugging Protocol (ADP).  ADP is generally
implemented in one of two ways:

 1) By running the Angel Monitor (usually in ROM) on the target and
    talking to it via serial port.  AFAICT, this is quite similar to
    putting GDB stubs on the target.

    I don't have a target that runs the Angel monitor, so I haven't
    tested with this type of target.

 2) By buying an ARM processor with a JTAG debugging interface and
    using a JTAG interface box that implements ADP.  The processor
    that is most commonly used this way is the ARM7TDMI.  

    The two JTAG interfaces with which I have tested are the ARM
    Embedded-ICE and the EPI Jeeni.

Still on the todo list: incoporate changes received from Thomas Zenker
that

 + allow the user to get gdb's attention while it's waiting for an 
   ADP packet.

 + clean up some BSD 4.4 issues

 + clean up the code that opens serial ports (the existing code
   tries to outsmart the user regarding serial port names).

The attached patch should work cleanly if applied in the gdb-4.18 main
directory with the command

    $ patch -E -p4 <gdbrdi.patch



----------------------------------------------------------------------
			       Changes
----------------------------------------------------------------------

 * Added the boolean set/show variable rdiheartbeat.  

   This enables or disables ADP link-check "heartbeat" packets sent by
   the host to the target.  Heartbeat packets can cause both the ARM
   Embedded-ICE and the EPI Jeeni to malfunction: If a heartbeat
   packet is received by the target while it is sending a packet, that
   packet will be aborted, and the ADP protocol engine then gets very
   confused.

   Default state is off -- used to hardwired on.


 * Added the boolean set/show variable rdiromatzero.

   Should be set to true if the target has ROM at address 0.  If true,
   then gdb will not tell the target to trap fetches to interrupt
   vectors (which are located at address 0).  Using the Angel monitor,
   attempting to set breakpoints in ROM is an error.  Using JTAG
   debugging of the ARM7TDMI, attempting to set more than two
   breakpoints in ROM is an error.

   Default state is false (vectors will be trapped) -- used to be
   hardwired false.


 * Added command rdilogenable

   Allows the user to log ADP packets that are exchanged between
   gdb and the target.  Both the raw packets are shown and some
   minimal decoding is attempted.  [new feature]

   Default state is disabled.


 * Added command rdilogfile

   Allows the user to specify the filename to which the ADP packet log
   is to be written.  [new feature]

   Default state is "rdi.log".


 * Changed default names for Linux serial ports from /dev/cuan to
   /dev/ttySn.


 * Added code to split the arguments to the 'target rdi' command at the
   first space.  The first word is passed to Adp_OpenDevice as the
   device name, the tail is passed as the "arguments" parameter.  This
   allows user specified baud rates -- among other things that still
   need to be documented [e.g. (gdb) target rdi /dev/ttyS1 19200].

   NB: With very limited testing, the ARM Embedded-ICE seems to run at
   19.2K (though it is reported to be unreliable above 9600), and the
   EPI Jeeni seems to run at 38.4K.


 * Renamed the file rdi-share/endian.h to rdi-share/anendian.h to prevent
   shadowing of /usr/include/endian.h.  This was causing the wrong
   byte order to be used by htons() in the RDI Ethernet driver.

26 October 1999

Grant Edwards,
Comtrol Corporation

----------------------------------------------------------------------
--- /home/grante/gdb-4.18.orig/gdb/remote-rdi.c	Mon Jan 18 20:17:00 1999
+++ /home/grante/gdb-4.18.work/gdb/remote-rdi.c	Tue Oct 26 10:43:03 1999
@@ -204,6 +204,11 @@
 /* Open a connection to a remote debugger.  NAME is the filename used
    for communication.  */
 
+static char *log_filename = NULL;
+static int   log_enable = 0;
+static int   rom_at_zero = 0;
+static int   rdi_heartbeat = 0;
+
 static void
 arm_rdi_open (name, from_tty)
      char *name;
@@ -211,14 +216,33 @@
 {
   int rslt, i;
   unsigned long arg1, arg2;
+  char *openArgs = NULL;
+  char *devName = NULL;
+  char *p;
 
   if (name == NULL)
     error ("To open an RDI connection, you need to specify what serial\n\
 device is attached to the remote system (e.g. /dev/ttya).");
+  
+  /* split name after whitespace, pass tail as arg to open command */
+  
+  devName = strdup(name);
+  p = strchr(devName,' ');
+  if (p)
+    {
+      *p = '\0';
+      ++p;
+      
+      while (*p == ' ')
+        ++p;
+      
+      openArgs = p;
+    }
 
   /* Make the basic low-level connection.  */
 
-  rslt = Adp_OpenDevice (name, NULL, 1);
+  Adp_CloseDevice ();
+  rslt = Adp_OpenDevice (name, openArgs, rdi_heartbeat);
 
   if (rslt != adp_ok)
     error ("Could not open device \"%s\"", name);
@@ -290,7 +314,8 @@
       printf_filtered ("RDI_open: %s\n", rdi_error_message (rslt));
     }
 
-  arg1 = 0x13b;
+  arg1 = rom_at_zero ? 0x0 : 0x13b;
+  
   rslt = angel_RDI_info (RDIVector_Catch, &arg1, &arg2);
   if (rslt)
     {
@@ -961,11 +986,97 @@
   arm_rdi_ops.to_magic = OPS_MAGIC;	
 }
 
+static void rdilogfile_command(char *arg, int from_tty)
+{
+  if (!arg || strlen(arg) == 0)
+    {
+      printf_filtered("rdi log file is '%s'\n", log_filename);
+      return;
+    }
+  
+  if (log_filename)
+    free(log_filename);
+  
+  log_filename = strdup(arg);
+
+  Adp_SetLogfile(log_filename);
+}
+
+static void rdilogenable_command(char *args, int from_tty)
+{
+  if (!args || strlen(args) == 0)
+    {
+      printf_filtered("rdi log is %s\n", log_enable ? "enabled" : "disabled");
+      return;
+    }
+  
+  if (!strcasecmp(args,"1") || 
+      !strcasecmp(args,"y") ||
+      !strcasecmp(args,"yes") ||
+      !strcasecmp(args,"on") ||
+      !strcasecmp(args,"t") ||
+      !strcasecmp(args,"true"))
+    Adp_SetLogEnable(log_enable=1);
+  else if (!strcasecmp(args,"0") || 
+      !strcasecmp(args,"n") ||
+      !strcasecmp(args,"no") ||
+      !strcasecmp(args,"off") ||
+      !strcasecmp(args,"f") ||
+      !strcasecmp(args,"false"))
+    Adp_SetLogEnable(log_enable=0);
+  else
+    printf_filtered("rdilogenable: unrecognized argument '%s'\n"
+                    "              try y or n\n",args);
+}
+
 void
 _initialize_remote_rdi ()
 {
   init_rdi_ops () ;
   add_target (&arm_rdi_ops);
+  
+  log_filename = strdup("rdi.log");
+  log_enable = 0;
+  Adp_SetLogfile(log_filename);
+  Adp_SetLogEnable(log_enable);
+  
+  add_show_from_set 
+    (add_set_cmd ("rdiromatzero", no_class,
+                  var_boolean, (char *) &rom_at_zero,
+                  "Set target has ROM at addr 0.\n"
+                  "A true value disables vector catching, false enables vector catching.\n"
+                  "This is evaluated at the time the 'target rdi' command is executed\n",
+                  &setlist),
+     &showlist);
+
+  add_show_from_set 
+    (add_set_cmd ("rdiheartbeat", no_class,
+                  var_boolean, (char *) &rdi_heartbeat,
+                  "Set enable for ADP heartbeat packets.\n"
+                  "I don't know why you would want this. If you enable them,\n"
+                  "it will confuse ARM and EPI JTAG interface boxes. Perhaps\n"
+                  "it works better with the Angel Monitor?\n",
+                  &setlist),
+     &showlist);
+
+  add_cmd ("rdilogfile", no_class,
+           rdilogfile_command,
+           "Set filename for ADP packet log.\n"
+           "This file is used to log Angel Debugger Protocol packets.\n"
+           "With a single argument, sets the logfile name to that value.\n"
+           "Without an argument, shows the current logfile name.\n"
+           "See also: rdilogenable\n",
+           &cmdlist);
+  
+  add_cmd("rdilogenable", no_class,
+          rdilogenable_command,
+          "Set enable logging of ADP packets.\n"
+          "This will log ADP packets exchanged between gdb and the\n"
+          "rdi target device.\n"
+          "An argument of 1,t,true,y,yes will enable.\n"
+          "An argument of 0,f,false,n,no will disabled.\n"
+          "Withough an argument, it will display current state.\n",
+          &cmdlist);
 }
 
 /* A little dummy to make linking with the library succeed. */
diff -u -N /home/grante/gdb-4.18.orig/gdb/rdi-share/Makefile.am /home/grante/gdb-4.18.work/gdb/rdi-share/Makefile.am
--- /home/grante/gdb-4.18.orig/gdb/rdi-share/Makefile.am	Thu Aug 20 15:11:18 1998
+++ /home/grante/gdb-4.18.work/gdb/rdi-share/Makefile.am	Mon Oct 25 14:54:06 1999
@@ -11,7 +11,7 @@
 noinst_HEADERS = adp.h adperr.h angel.h ardi.h armdbg.h buffers.h bytesex.h \
                  chandefs.h channels.h chanpriv.h crc.h dbg_conf.h dbg_cp.h \
                  dbg_hif.h dbg_rdi.h devclnt.h devices.h devsw.h drivers.h \
-                 endian.h ethernet.h host.h hostchan.h hsys.h logging.h \
+                 anendian.h ethernet.h host.h hostchan.h hsys.h logging.h \
                  msgbuild.h params.h rxtx.h sys.h unixcomm.h
 
 EXTRA_DIST = README.CYGNUS
diff -u -N /home/grante/gdb-4.18.orig/gdb/rdi-share/Makefile.in /home/grante/gdb-4.18.work/gdb/rdi-share/Makefile.in
--- /home/grante/gdb-4.18.orig/gdb/rdi-share/Makefile.in	Mon Jan  4 18:17:07 1999
+++ /home/grante/gdb-4.18.work/gdb/rdi-share/Makefile.in	Mon Oct 25 13:07:37 1999
@@ -76,7 +76,7 @@
 noinst_HEADERS = adp.h adperr.h angel.h ardi.h armdbg.h buffers.h bytesex.h \
                  chandefs.h channels.h chanpriv.h crc.h dbg_conf.h dbg_cp.h \
                  dbg_hif.h dbg_rdi.h devclnt.h devices.h devsw.h drivers.h \
-                 endian.h ethernet.h host.h hostchan.h hsys.h logging.h \
+                 anendian.h ethernet.h host.h hostchan.h hsys.h logging.h \
                  msgbuild.h params.h rxtx.h sys.h unixcomm.h
 
 EXTRA_DIST = README.CYGNUS
diff -u -N /home/grante/gdb-4.18.orig/gdb/rdi-share/anendian.h /home/grante/gdb-4.18.work/gdb/rdi-share/anendian.h
--- /home/grante/gdb-4.18.orig/gdb/rdi-share/anendian.h	Wed Dec 31 18:00:00 1969
+++ /home/grante/gdb-4.18.work/gdb/rdi-share/anendian.h	Fri Oct 22 10:22:03 1999
@@ -0,0 +1,125 @@
+/* 
+ * Copyright (C) 1995 Advanced RISC Machines Limited. All rights reserved.
+ * 
+ * This software may be freely used, copied, modified, and distributed
+ * provided that the above copyright notice is preserved in all copies of the
+ * software.
+ */
+
+/* -*-C-*-
+ *
+ * $Revision: 1.2 $
+ *     $Date: 1998/01/08 11:12:04 $
+ *
+ *
+ * anendian.h - target endianness independent read/write primitives.
+ */
+
+#ifndef angel_endian_h
+#define angel_endian_h
+
+/*
+ * The endianness of the data being processed needs to be known, but
+ * the host endianness is not required (since the data is constructed
+ * using bytes).  At the moment these are provided as macros. This
+ * gives the compiler freedom in optimising individual calls. However,
+ * if space is at a premium then functions should be provided.
+ *
+ * NOTE: These macros assume that the data has been packed in the same format
+ *       as the packing on the build host. If this is not the case then
+ *       the wrong addresses could be used when dealing with structures.
+ *
+ */
+
+/*
+ * For all the following routines the target endianness is defined by the
+ * following boolean definitions.
+ */
+#define BE (1 == 1) /* TRUE  : big-endian */
+#define LE (1 == 0) /* FALSE : little-endian */
+
+/*
+ * The following type definitions are used by the endianness converting
+ * macros.
+ */
+typedef unsigned char U8;
+typedef U8 *P_U8;
+typedef const U8 *CP_U8;
+
+typedef unsigned short U16;
+typedef U16 *P_U16;
+
+typedef unsigned int U32;
+typedef U32 *P_U32;
+
+/*
+ * If the endianness of the host and target are known (fixed) and the same
+ * then the following macro definitions can be used. These just directly copy
+ * the data.
+ *
+ * #define READ(e,a)       (a)
+ * #define WRITE(e,a,v)    ((a) = (v))
+ * #define PREAD(e,a)      (a)
+ * #define PWRITE(e,a,v)   (*(a) = (v))
+ */
+
+/*
+ * These macros assume that a byte (char) is 8bits in size, and that the
+ * endianness is not important when reading or writing bytes.
+ */
+#define PUT8(a,v)       (*((P_U8)(a)) = (U8)(v))
+#define PUT16LE(a,v)    (PUT8(a,((v) & 0xFF)), \
+                         PUT8((((P_U8)(a)) + sizeof(char)),((v) >> 8)))
+#define PUT16BE(a,v)    (PUT8(a,((v) >> 8)), \
+                         PUT8((((P_U8)(a)) + sizeof(char)),((v) & 0xFF)))
+#define PUT32LE(a,v)    (PUT16LE(a,v), \
+                         PUT16LE((((P_U8)(a)) + sizeof(short)),((v) >> 16)))
+#define PUT32BE(a,v)    (PUT16BE(a,((v) >> 16)), \
+                         PUT16BE((((P_U8)(a)) + sizeof(short)),v))
+
+#define GET8(a)     (*((CP_U8)(a)))
+#define GET16LE(a)  (GET8(a) | (((U16)GET8(((CP_U8)(a)) + sizeof(char))) << 8))
+#define GET16BE(a)  ((((U16)GET8(a)) << 8) | GET8(((CP_U8)(a)) + sizeof(char)))
+#define GET32LE(a)  (GET16LE(a) | \
+                     (((U32)GET16LE(((CP_U8)(a)) + sizeof(short))) << 16))
+#define GET32BE(a)  ((((U32)GET16BE(a)) << 16) | \
+                     GET16BE(((CP_U8)(a)) + sizeof(short)))
+
+/*
+ * These macros simplify the code in respect to reading and writing the
+ * correct size data when dealing with endianness. "e" is TRUE if we are
+ * dealing with big-endian data, FALSE if we are dealing with little-endian.
+ */
+
+/* void WRITE(int endianness, void *address, unsigned value); */
+
+#define WRITE16(e,a,v) ((e) ? PUT16BE(&(a),v) : PUT16LE(&(a),v))
+#define WRITE32(e,a,v) ((e) ? PUT32BE(&(a),v) : PUT32LE(&(a),v))
+#define WRITE(e,a,v)   ((sizeof(v) == sizeof(char)) ? \
+                        PUT8(&(a),v) : ((sizeof(v) == sizeof(short)) ? \
+                                        WRITE16(e,a,v) : WRITE32(e,a,v)))
+
+/* unsigned READ(int endianness, void *address) */
+#define READ16(e,a) ((e) ? GET16BE(&(a)) : GET16LE(&(a)))
+#define READ32(e,a) ((e) ? GET32BE(&(a)) : GET32LE(&(a)))
+#define READ(e,a) ((sizeof(a) == sizeof(char)) ? \
+                   GET8((CP_U8)&(a)) : ((sizeof(a) == sizeof(short)) ? \
+                                       READ16(e,a) : READ32(e,a)))
+
+/* void PWRITE(int endianness, void *address, unsigned value); */
+#define PWRITE16(e,a,v) ((e) ? PUT16BE(a,v) : PUT16LE(a,v))
+#define PWRITE32(e,a,v) ((e) ? PUT32BE(a,v) : PUT32LE(a,v))
+#define PWRITE(e,a,v)   ((sizeof(v) == sizeof(char)) ? \
+                         PUT8(a,v) : ((sizeof(v) == sizeof(short)) ? \
+                                      PWRITE16(e,a,v) : PWRITE32(e,a,v)))
+
+/* unsigned PREAD(int endianness, void *address) */
+#define PREAD16(e,a) ((e) ? GET16BE(a) : GET16LE(a))
+#define PREAD32(e,a) ((e) ? GET32BE(a) : GET32LE(a))
+#define PREAD(e,a) ((sizeof(*(a)) == sizeof(char)) ? \
+                    GET8((CP_U8)a) : ((sizeof(*(a)) == sizeof(short)) ? \
+                                     PREAD16(e,a) : PREAD32(e,a)))
+
+#endif /* !defined(angel_endian_h) */
+
+/* EOF anendian.h */
diff -u -N /home/grante/gdb-4.18.orig/gdb/rdi-share/ardi.c /home/grante/gdb-4.18.work/gdb/rdi-share/ardi.c
--- /home/grante/gdb-4.18.orig/gdb/rdi-share/ardi.c	Thu Jan  8 05:11:28 1998
+++ /home/grante/gdb-4.18.work/gdb/rdi-share/ardi.c	Mon Oct 25 11:32:18 1999
@@ -27,7 +27,7 @@
 #undef uint
 
 
-#include "endian.h"
+#include "anendian.h"
 #include "ardi.h"
 #include "buffers.h"
 #include "channels.h"
@@ -1300,7 +1300,7 @@
     stopped_info->stopped_status = RDIError_NoError;
     break;
   default:
-    stopped_info->stopped_status = RDIError_NoError;
+    stopped_info->stopped_status = RDIError_Error;
     break;
   }
   return RDIError_NoError;
diff -u -N /home/grante/gdb-4.18.orig/gdb/rdi-share/devsw.c /home/grante/gdb-4.18.work/gdb/rdi-share/devsw.c
--- /home/grante/gdb-4.18.orig/gdb/rdi-share/devsw.c	Fri Sep 25 14:04:45 1998
+++ /home/grante/gdb-4.18.work/gdb/rdi-share/devsw.c	Mon Oct 25 11:34:13 1999
@@ -14,6 +14,7 @@
  */
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 
 #include "adp.h"
 #include "hsys.h"
@@ -26,6 +27,172 @@
 #include "hostchan.h"
 #include "logging.h"
 
+static char *angelDebugFilename = NULL;
+static FILE *angelDebugLogFile = NULL;
+static int angelDebugLogEnable = 0;
+
+static void openLogFile()
+{
+  time_t t;
+  struct tm lt;
+  
+  if (angelDebugFilename == NULL || *angelDebugFilename =='\0')
+    return;
+  
+  angelDebugLogFile = fopen(angelDebugFilename,"a");
+  
+  if (!angelDebugLogFile)
+    {
+      fprintf(stderr,"Error opening log file '%s'\n",angelDebugFilename);
+      perror("fopen");
+    }
+  else
+    setlinebuf(angelDebugLogFile);
+  
+  time(&t);
+  fprintf(angelDebugLogFile,"ADP log file opened at %s\n",asctime(localtime(&t)));
+}
+
+
+static void closeLogFile(void)
+{
+  time_t t;
+  struct tm lt;
+  
+  if (!angelDebugLogFile)
+    return;
+  
+  time(&t);
+  fprintf(angelDebugLogFile,"ADP log file closed at %s\n",asctime(localtime(&t)));
+  
+  fclose(angelDebugLogFile);
+  angelDebugLogFile = NULL;
+}
+
+void DevSW_SetLogEnable(int logEnableFlag)
+{
+  if (logEnableFlag && !angelDebugLogFile)
+    openLogFile();
+  else if (!logEnableFlag && angelDebugLogFile)
+    closeLogFile();
+  
+  angelDebugLogEnable = logEnableFlag;
+}
+
+
+void DevSW_SetLogfile(const char *filename)
+{
+  closeLogFile();
+  
+  if (angelDebugFilename)
+    {
+      free(angelDebugFilename);
+      angelDebugFilename = NULL;
+    }
+  
+  if (filename && *filename)
+    {
+      angelDebugFilename = strdup(filename);
+      if (angelDebugLogEnable)
+        openLogFile();
+    }
+}
+
+
+#define WordAt(p)  ((unsigned long) ((p)[0] | ((p)[1]<<8) | ((p)[2]<<16) | ((p)[3]<<24)))
+
+static void dumpPacket(FILE *fp, char *label, struct data_packet *p)
+{
+  unsigned r;
+  int i;
+  
+  if (!fp)
+    return;
+  
+  fprintf(fp,"%s [T=%d L=%d] ",label,p->type,p->len);
+  for (i=0; i<p->len; ++i)
+    fprintf(fp,"%02x ",p->data[i]);
+  fprintf(fp,"\n");
+
+  r = WordAt(p->data+4);
+  
+  fprintf(fp,"R=%08x ",r);
+  fprintf(fp,"%s ", r&0x80000000 ? "H<-T" : "H->T");
+
+  switch ((r>>16) & 0xff)
+    {
+     case CI_PRIVATE: fprintf(fp,"CI_PRIVATE: "); break;
+     case CI_HADP: fprintf(fp,"CI_HADP: "); break;
+     case CI_TADP: fprintf(fp,"CI_TADP: "); break;
+     case CI_HBOOT: fprintf(fp,"CI_HBOOT: "); break;
+     case CI_TBOOT: fprintf(fp,"CI_TBOOT: "); break;
+     case CI_CLIB: fprintf(fp,"CI_CLIB: "); break;
+     case CI_HUDBG: fprintf(fp,"CI_HUDBG: "); break;
+     case CI_TUDBG: fprintf(fp,"CI_TUDBG: "); break;
+     case CI_HTDCC: fprintf(fp,"CI_HTDCC: "); break;
+     case CI_TTDCC: fprintf(fp,"CI_TTDCC: "); break;
+     case CI_TLOG: fprintf(fp,"CI_TLOG: "); break;
+     default:      fprintf(fp,"BadChan: "); break;
+    }
+
+  switch (r & 0xffffff)
+    {
+     case ADP_Booted: fprintf(fp," ADP_Booted "); break;
+#if defined(ADP_TargetResetIndication)
+     case ADP_TargetResetIndication: fprintf(fp," ADP_TargetResetIndication "); break;
+#endif
+     case ADP_Reboot: fprintf(fp," ADP_Reboot "); break;
+     case ADP_Reset: fprintf(fp," ADP_Reset "); break;
+#if defined(ADP_HostResetIndication)
+     case ADP_HostResetIndication: fprintf(fp," ADP_HostResetIndication "); break;
+#endif      
+     case ADP_ParamNegotiate: fprintf(fp," ADP_ParamNegotiate "); break;
+     case ADP_LinkCheck: fprintf(fp," ADP_LinkCheck "); break;
+     case ADP_HADPUnrecognised: fprintf(fp," ADP_HADPUnrecognised "); break;
+     case ADP_Info: fprintf(fp," ADP_Info "); break;
+     case ADP_Control: fprintf(fp," ADP_Control "); break;
+     case ADP_Read: fprintf(fp," ADP_Read "); break;
+     case ADP_Write: fprintf(fp," ADP_Write "); break;
+     case ADP_CPUread: fprintf(fp," ADP_CPUread "); break;
+     case ADP_CPUwrite: fprintf(fp," ADP_CPUwrite "); break;
+     case ADP_CPread: fprintf(fp," ADP_CPread "); break;
+     case ADP_CPwrite: fprintf(fp," ADP_CPwrite "); break;
+     case ADP_SetBreak: fprintf(fp," ADP_SetBreak "); break;
+     case ADP_ClearBreak: fprintf(fp," ADP_ClearBreak "); break;
+     case ADP_SetWatch: fprintf(fp," ADP_SetWatch "); break;
+     case ADP_ClearWatch: fprintf(fp," ADP_ClearWatch "); break;
+     case ADP_Execute: fprintf(fp," ADP_Execute "); break;
+     case ADP_Step: fprintf(fp," ADP_Step "); break;
+     case ADP_InterruptRequest: fprintf(fp," ADP_InterruptRequest "); break;
+     case ADP_HW_Emulation: fprintf(fp," ADP_HW_Emulation "); break;
+     case ADP_ICEbreakerHADP: fprintf(fp," ADP_ICEbreakerHADP "); break;
+     case ADP_ICEman: fprintf(fp," ADP_ICEman "); break;
+     case ADP_Profile: fprintf(fp," ADP_Profile "); break;
+     case ADP_InitialiseApplication: fprintf(fp," ADP_InitialiseApplication "); break;
+     case ADP_End: fprintf(fp," ADP_End "); break;
+     case ADP_TADPUnrecognised: fprintf(fp," ADP_TADPUnrecognised "); break;
+     case ADP_Stopped: fprintf(fp," ADP_Stopped "); break;
+     case ADP_TDCC_ToHost: fprintf(fp," ADP_TDCC_ToHost "); break;
+     case ADP_TDCC_FromHost: fprintf(fp," ADP_TDCC_FromHost "); break;
+     default: fprintf(fp," BadReason "); break;
+    }
+
+  i = 20;
+  
+  if (((r & 0xffffff) == ADP_CPUread ||
+       (r & 0xffffff) == ADP_CPUwrite) && (r&0x80000000)==0)
+    {
+      fprintf(fp,"%02x ", p->data[i]);
+      ++i;
+    }
+  
+  for (; i<p->len; i+=4)
+    fprintf(fp,"%08x ",WordAt(p->data+i));
+  
+  fprintf(fp,"\n");
+}
+
+
 /*
  * TODO: this should be adjustable - it could be done by defining
  *       a reason code for DevSW_Ioctl.  It could even be a
@@ -309,6 +476,10 @@
 #ifdef RET_DEBUG
     printf("got a complete packet\n");
 #endif
+    
+    if (angelDebugLogEnable)
+      dumpPacket(angelDebugLogFile,"rx:",&ds->ds_activeread.dc_packet);
+
     enqueue_packet(ds);
     *packet = Adp_removeFromQueue(&ds->ds_readqueue[type]);
     return adp_ok;
@@ -380,6 +551,10 @@
      * we can take this packet - set things up, then try to get rid of it
      */
     initialise_write(dc, packet, type);
+  
+    if (angelDebugLogEnable)
+      dumpPacket(angelDebugLogFile,"tx:",&dc->dc_packet);
+  
     flush_packet(device, dc);
 
     return adp_ok;
diff -u -N /home/grante/gdb-4.18.orig/gdb/rdi-share/devsw.h /home/grante/gdb-4.18.work/gdb/rdi-share/devsw.h
--- /home/grante/gdb-4.18.orig/gdb/rdi-share/devsw.h	Thu Jan  8 05:12:00 1998
+++ /home/grante/gdb-4.18.work/gdb/rdi-share/devsw.h	Mon Oct 25 11:44:29 1999
@@ -259,6 +259,13 @@
  */
 bool DevSW_WriteFinished(const DeviceDescr *device);
 
+      
+/*
+ * set filename and enable/disable logginf of ADP packets
+ */
+void DevSW_SetLogfile(const char *filename);
+void DevSW_SetLogEnable(int logEnableFlag);
+      
 #ifdef __cplusplus
     }
 #endif
diff -u -N /home/grante/gdb-4.18.orig/gdb/rdi-share/endian.h /home/grante/gdb-4.18.work/gdb/rdi-share/endian.h
--- /home/grante/gdb-4.18.orig/gdb/rdi-share/endian.h	Thu Jan  8 05:12:04 1998
+++ /home/grante/gdb-4.18.work/gdb/rdi-share/endian.h	Wed Dec 31 18:00:00 1969
@@ -1,125 +0,0 @@
-/* 
- * Copyright (C) 1995 Advanced RISC Machines Limited. All rights reserved.
- * 
- * This software may be freely used, copied, modified, and distributed
- * provided that the above copyright notice is preserved in all copies of the
- * software.
- */
-
-/* -*-C-*-
- *
- * $Revision: 1.2 $
- *     $Date: 1998/01/08 11:12:04 $
- *
- *
- * endian.h - target endianness independent read/write primitives.
- */
-
-#ifndef angel_endian_h
-#define angel_endian_h
-
-/*
- * The endianness of the data being processed needs to be known, but
- * the host endianness is not required (since the data is constructed
- * using bytes).  At the moment these are provided as macros. This
- * gives the compiler freedom in optimising individual calls. However,
- * if space is at a premium then functions should be provided.
- *
- * NOTE: These macros assume that the data has been packed in the same format
- *       as the packing on the build host. If this is not the case then
- *       the wrong addresses could be used when dealing with structures.
- *
- */
-
-/*
- * For all the following routines the target endianness is defined by the
- * following boolean definitions.
- */
-#define BE (1 == 1) /* TRUE  : big-endian */
-#define LE (1 == 0) /* FALSE : little-endian */
-
-/*
- * The following type definitions are used by the endianness converting
- * macros.
- */
-typedef unsigned char U8;
-typedef U8 *P_U8;
-typedef const U8 *CP_U8;
-
-typedef unsigned short U16;
-typedef U16 *P_U16;
-
-typedef unsigned int U32;
-typedef U32 *P_U32;
-
-/*
- * If the endianness of the host and target are known (fixed) and the same
- * then the following macro definitions can be used. These just directly copy
- * the data.
- *
- * #define READ(e,a)       (a)
- * #define WRITE(e,a,v)    ((a) = (v))
- * #define PREAD(e,a)      (a)
- * #define PWRITE(e,a,v)   (*(a) = (v))
- */
-
-/*
- * These macros assume that a byte (char) is 8bits in size, and that the
- * endianness is not important when reading or writing bytes.
- */
-#define PUT8(a,v)       (*((P_U8)(a)) = (U8)(v))
-#define PUT16LE(a,v)    (PUT8(a,((v) & 0xFF)), \
-                         PUT8((((P_U8)(a)) + sizeof(char)),((v) >> 8)))
-#define PUT16BE(a,v)    (PUT8(a,((v) >> 8)), \
-                         PUT8((((P_U8)(a)) + sizeof(char)),((v) & 0xFF)))
-#define PUT32LE(a,v)    (PUT16LE(a,v), \
-                         PUT16LE((((P_U8)(a)) + sizeof(short)),((v) >> 16)))
-#define PUT32BE(a,v)    (PUT16BE(a,((v) >> 16)), \
-                         PUT16BE((((P_U8)(a)) + sizeof(short)),v))
-
-#define GET8(a)     (*((CP_U8)(a)))
-#define GET16LE(a)  (GET8(a) | (((U16)GET8(((CP_U8)(a)) + sizeof(char))) << 8))
-#define GET16BE(a)  ((((U16)GET8(a)) << 8) | GET8(((CP_U8)(a)) + sizeof(char)))
-#define GET32LE(a)  (GET16LE(a) | \
-                     (((U32)GET16LE(((CP_U8)(a)) + sizeof(short))) << 16))
-#define GET32BE(a)  ((((U32)GET16BE(a)) << 16) | \
-                     GET16BE(((CP_U8)(a)) + sizeof(short)))
-
-/*
- * These macros simplify the code in respect to reading and writing the
- * correct size data when dealing with endianness. "e" is TRUE if we are
- * dealing with big-endian data, FALSE if we are dealing with little-endian.
- */
-
-/* void WRITE(int endianness, void *address, unsigned value); */
-
-#define WRITE16(e,a,v) ((e) ? PUT16BE(&(a),v) : PUT16LE(&(a),v))
-#define WRITE32(e,a,v) ((e) ? PUT32BE(&(a),v) : PUT32LE(&(a),v))
-#define WRITE(e,a,v)   ((sizeof(v) == sizeof(char)) ? \
-                        PUT8(&(a),v) : ((sizeof(v) == sizeof(short)) ? \
-                                        WRITE16(e,a,v) : WRITE32(e,a,v)))
-
-/* unsigned READ(int endianness, void *address) */
-#define READ16(e,a) ((e) ? GET16BE(&(a)) : GET16LE(&(a)))
-#define READ32(e,a) ((e) ? GET32BE(&(a)) : GET32LE(&(a)))
-#define READ(e,a) ((sizeof(a) == sizeof(char)) ? \
-                   GET8((CP_U8)&(a)) : ((sizeof(a) == sizeof(short)) ? \
-                                       READ16(e,a) : READ32(e,a)))
-
-/* void PWRITE(int endianness, void *address, unsigned value); */
-#define PWRITE16(e,a,v) ((e) ? PUT16BE(a,v) : PUT16LE(a,v))
-#define PWRITE32(e,a,v) ((e) ? PUT32BE(a,v) : PUT32LE(a,v))
-#define PWRITE(e,a,v)   ((sizeof(v) == sizeof(char)) ? \
-                         PUT8(a,v) : ((sizeof(v) == sizeof(short)) ? \
-                                      PWRITE16(e,a,v) : PWRITE32(e,a,v)))
-
-/* unsigned PREAD(int endianness, void *address) */
-#define PREAD16(e,a) ((e) ? GET16BE(a) : GET16LE(a))
-#define PREAD32(e,a) ((e) ? GET32BE(a) : GET32LE(a))
-#define PREAD(e,a) ((sizeof(*(a)) == sizeof(char)) ? \
-                    GET8((CP_U8)a) : ((sizeof(*(a)) == sizeof(short)) ? \
-                                     PREAD16(e,a) : PREAD32(e,a)))
-
-#endif /* !defined(angel_endian_h) */
-
-/* EOF endian.h */
diff -u -N /home/grante/gdb-4.18.orig/gdb/rdi-share/etherdrv.c /home/grante/gdb-4.18.work/gdb/rdi-share/etherdrv.c
--- /home/grante/gdb-4.18.orig/gdb/rdi-share/etherdrv.c	Thu Apr 16 15:14:51 1998
+++ /home/grante/gdb-4.18.work/gdb/rdi-share/etherdrv.c	Mon Oct 25 11:35:31 1999
@@ -71,7 +71,7 @@
 
 #include "hsys.h"
 #include "devices.h"
-#include "endian.h"
+#include "anendian.h"
 #include "buffers.h"
 #include "hostchan.h"
 #include "params.h"
@@ -282,6 +282,10 @@
          * port on the remote target
          */
         ia->sin_port = htons(CTRL_PORT);
+      
+#ifdef DEBUG
+        printf("CTLR_PORT=0x%04x  sin_port=0x%04x\n");
+#endif
         if (sendto(sock, ctrlpacket, sizeof(ctrlpacket), 0,
                        (struct sockaddr *)ia, sizeof(*ia)) < 0)
         {
diff -u -N /home/grante/gdb-4.18.orig/gdb/rdi-share/hostchan.c /home/grante/gdb-4.18.work/gdb/rdi-share/hostchan.c
--- /home/grante/gdb-4.18.orig/gdb/rdi-share/hostchan.c	Wed Jan 27 21:50:15 1999
+++ /home/grante/gdb-4.18.work/gdb/rdi-share/hostchan.c	Mon Oct 25 16:25:04 1999
@@ -230,7 +230,7 @@
      */
     ASSERT(&(((Packet *)0)->pk_next) == 0, "bad struct Packet layout");
 
-#if DEBUG && 0
+#if defined(DEBUG) && 0
     printf("Adp_addToQueue(%p, %p)\n", head, newpkt);
 #endif
 
@@ -265,6 +265,16 @@
     return pk;
 }
 
+void Adp_SetLogEnable(int logEnableFlag)
+{
+  DevSW_SetLogEnable(logEnableFlag);
+}
+
+void Adp_SetLogfile(const char *filename)
+{
+  DevSW_SetLogfile(filename);
+}
+
 AdpErrs Adp_OpenDevice(const char *name, const char *arg,
                        unsigned int heartbeat_on)
 {
@@ -359,7 +369,7 @@
 #ifdef DEBUG
     printf("Adp_ChannelRegisterRead(%d, %p, %x)\n", chan, cbfunc, cbstate);
 #endif
-
+  
     if (deviceToUse == NULL)
         return adp_device_not_open;
 
@@ -991,6 +1001,7 @@
         {
           if (heartbeat_configured)
             async_process_heartbeat();
+          
           async_process_callbacks();
           INC_COUNT(hc);
         }
diff -u -N /home/grante/gdb-4.18.orig/gdb/rdi-share/hostchan.h /home/grante/gdb-4.18.work/gdb/rdi-share/hostchan.h
--- /home/grante/gdb-4.18.orig/gdb/rdi-share/hostchan.h	Wed Jan 27 21:50:16 1999
+++ /home/grante/gdb-4.18.work/gdb/rdi-share/hostchan.h	Mon Oct 25 09:59:53 1999
@@ -92,6 +92,13 @@
 extern Packet *Adp_removeFromQueue(Packet **head);
 
 /*
+ * Set log file and Enable/disable logging of ADP packets to file.
+ */
+
+void Adp_SetLogfile(const char *filename);
+void Adp_SetLogEnable(int logEnableFlag);
+
+/*
  *  Function: Adp_OpenDevice
  *   Purpose: Open a device to use for channels communication.  This is a
  *              very thin veneer to the device drivers: what hostchan.c
diff -u -N /home/grante/gdb-4.18.orig/gdb/rdi-share/hsys.c /home/grante/gdb-4.18.work/gdb/rdi-share/hsys.c
--- /home/grante/gdb-4.18.orig/gdb/rdi-share/hsys.c	Thu Jan  8 05:12:14 1998
+++ /home/grante/gdb-4.18.work/gdb/rdi-share/hsys.c	Fri Oct 22 10:21:06 1999
@@ -29,7 +29,7 @@
 #include "ardi.h"
 #include "buffers.h"
 #include "channels.h"        /* Channel interface. */
-#include "endian.h"
+#include "anendian.h"
 #include "logging.h"         /* Angel support functions. */
 #include "msgbuild.h"
 #include "sys.h"    
diff -u -N /home/grante/gdb-4.18.orig/gdb/rdi-share/msgbuild.c /home/grante/gdb-4.18.work/gdb/rdi-share/msgbuild.c
--- /home/grante/gdb-4.18.orig/gdb/rdi-share/msgbuild.c	Thu Jan  8 05:12:21 1998
+++ /home/grante/gdb-4.18.work/gdb/rdi-share/msgbuild.c	Fri Oct 22 10:20:58 1999
@@ -19,7 +19,7 @@
 #include <stdarg.h>     /* ANSI varargs support */
 
 #ifdef TARGET
-# include "angel.h"
+# include "anangel.h"
 # include "devconf.h"
 #else
 # include "host.h"
@@ -28,7 +28,7 @@
 
 #include "channels.h"
 #include "buffers.h"
-#include "endian.h"     /* Endianness support macros */
+#include "anendian.h"     /* Endianness support macros */
 #include "msgbuild.h"   /* Header file for this source code */
 
 #ifndef UNUSED
diff -u -N /home/grante/gdb-4.18.orig/gdb/rdi-share/params.c /home/grante/gdb-4.18.work/gdb/rdi-share/params.c
--- /home/grante/gdb-4.18.orig/gdb/rdi-share/params.c	Thu Jan  8 05:12:24 1998
+++ /home/grante/gdb-4.18.work/gdb/rdi-share/params.c	Fri Oct 22 10:20:36 1999
@@ -19,7 +19,7 @@
 
 #include "params.h"
 
-#include "endian.h"
+#include "anendian.h"
 #include "logging.h"
 
 
diff -u -N /home/grante/gdb-4.18.orig/gdb/rdi-share/rx.c /home/grante/gdb-4.18.work/gdb/rdi-share/rx.c
--- /home/grante/gdb-4.18.orig/gdb/rdi-share/rx.c	Thu Jan  8 05:12:27 1998
+++ /home/grante/gdb-4.18.work/gdb/rdi-share/rx.c	Fri Oct 22 10:20:26 1999
@@ -19,7 +19,7 @@
 
 #include <stdarg.h>    /* ANSI varargs support */
 #include "angel.h"     /* Angel system definitions */
-#include "endian.h"    /* Endian independant memory access macros */
+#include "anendian.h"    /* Endian independant memory access macros */
 #include "crc.h"       /* crc generation definitions and headers */
 #include "rxtx.h"
 #include "channels.h"
diff -u -N /home/grante/gdb-4.18.orig/gdb/rdi-share/tx.c /home/grante/gdb-4.18.work/gdb/rdi-share/tx.c
--- /home/grante/gdb-4.18.orig/gdb/rdi-share/tx.c	Thu Jan  8 05:12:36 1998
+++ /home/grante/gdb-4.18.work/gdb/rdi-share/tx.c	Fri Oct 22 10:20:11 1999
@@ -18,7 +18,7 @@
 
 #include <stdarg.h>    /* ANSI varargs support */
 #include "angel.h"     /* Angel system definitions */
-#include "endian.h"    /* Endian independant memory access macros */
+#include "anendian.h"    /* Endian independant memory access macros */
 #include "crc.h"       /* crc generation definitions and headers */
 #include "rxtx.h"
 #include "channels.h"
diff -u -N /home/grante/gdb-4.18.orig/gdb/rdi-share/unixcomm.c /home/grante/gdb-4.18.work/gdb/rdi-share/unixcomm.c
--- /home/grante/gdb-4.18.orig/gdb/rdi-share/unixcomm.c	Wed Jan 27 21:50:16 1999
+++ /home/grante/gdb-4.18.work/gdb/rdi-share/unixcomm.c	Mon Oct 25 11:42:29 1999
@@ -82,8 +82,8 @@
 #endif
 
 #ifdef __linux__
-#define SERPORT1   "/dev/cua0"
-#define SERPORT2   "/dev/cua1"
+#define SERPORT1   "/dev/ttyS0"
+#define SERPORT2   "/dev/ttyS1"
 #define PARPORT1   "/dev/par0"
 #define PARPORT2   "/dev/par1"
 #endif
@@ -287,7 +287,14 @@
         return -1;
     }
     else if (err > 0 && FD_ISSET(serpfd, &fdset))
-        return read(serpfd, buf, n);
+    {
+     int s;
+      
+      s = read(serpfd, buf, n);
+      if (s < 0)
+        perror("read:");
+      return s;
+    }
     else /* err == 0 || FD_CLR(serpfd, &fdset) */
     {
         errno = ERRNO_FOR_BLOCKED_IO;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]