Main Page   Modules   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

/projects/cubeos/src_current/libc/debug.h

Go to the documentation of this file.
00001 /*  src_experimental/libc/debug.h
00002     CubeOS Version 0.4.90 experimental
00003     Copyright (C) 1999,2000 Holger Kenn
00004 
00005     CubeOS is free software; you can redistribute it and/or
00006     modify it under the terms of the GNU Library General Public
00007     License as published by the Free Software Foundation; either
00008     version 2 of the License, or any later version.
00009 
00010     CubeOS is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013     Library General Public License for more details.
00014 
00015 */  
00016 /* 
00017  * Copyright (c) 1995, 1996 Cygnus Support
00018  *
00019  * The authors hereby grant permission to use, copy, modify, distribute,
00020  * and license this software and its documentation for any purpose, provided
00021  * that existing copyright notices are retained in all copies and that this
00022  * notice is included verbatim in any distributions. No written agreement,
00023  * license, or royalty fee is required for any of the authorized uses.
00024  * Modifications to this software may be copyrighted by their authors
00025  * and need not follow the licensing terms described here, provided that
00026  * the new terms are clearly indicated on the first page of each file where
00027  * they apply.
00028  */
00029 
00030 static const char hexchars[]="0123456789abcdef";
00031 
00032 typedef void (*exception_t)(int);   /* pointer to function with int parm */
00033 
00034 /*
00035  * This is the default function handler to be called with all exceptions.
00036  */
00037 extern exception_t default_trap_hook;
00038 
00039 /* this is used to make Unix style signale nukbers to an exception */
00040 struct trap_info
00041 {
00042   unsigned char tt;             /* exception number */
00043   unsigned char signo;          /* corresponding signal number */
00044 };
00045 
00046 /* 
00047  * prototypes for the functions in debug.c. As these'll only be used with GCC,
00048  * we don't worry about no stinkin K&R comilers.
00049  */
00050 extern void exception_handler (int, unsigned long);
00051 extern unsigned char *mem2hex(unsigned char *, unsigned char *, int, int);
00052 extern unsigned char *hex2mem(unsigned char *, unsigned char *, int, int);
00053 extern void getpacket(unsigned char *);
00054 extern void putpacket(unsigned char *);
00055 extern char *make_return_packet(int);
00056 extern void set_debug_traps();
00057 extern int computeSignal(int);
00058 extern char digit2hex(int);
00059 extern int hex2digit(int);
00060 extern void debuglogs(int level, char *msg);
00061 extern int hex2int();
00062 extern char *int2hex(int);
00063 extern void gdb_event_loop(int, unsigned long *);
00064 
00065 extern char *gdb_read_registers();              /* g - read registers */
00066 extern char *gdb_write_registers(char *);       /* G - write registers */
00067 extern char *gdb_read_memory(long, int);        /* m - read memory */
00068 extern char *gdb_write_memory(long, int, char *);/* M write memory */
00069 extern char *gdb_continue(int, long );          /* c - continue */
00070 extern char *gdb_step(int, long);               /* s - step instruction(s) */
00071 extern char *gdb_kill();                        /* k - kill program */
00072 extern char *gdb_last_signal();                 /* ? - last signal */
00073 extern char *gdb_baudrate(int);                 /* b - change baud rate */
00074 extern char *gdb_dump_state();                  /* T - dump state */
00075 extern char *gdb_set_thread(int, int);          /* H - set thread */
00076 extern char *gdb_detach();                      /* D - detach */
00077 extern char *gdb_read_reg(int);                 /* p - read one register */
00078 extern char *gdb_write_reg(int, long);          /* P - write one register */
00079 extern char *gdb_exited();                      /* W - process exited */
00080 extern char *gdb_terminated();                  /* X - process terminated */
00081 extern char *gdb_hex();                         /* O - hex encoding */
00082 extern char *gdb_thread_alive(int);             /* A - tread alive request */
00083 extern char *gdb_extended();                    /* ! - extended protocol */
00084 extern char *gdb_debug();                       /* d - toggle stub diagnostics */
00085 extern char *gdb_toggle();                      /* unsupported, toggle stub on/off */
00086 extern char *gdb_reset();                       /* r - reset target */
00087 extern char *gdb_search(long, long, long);      /* t - search backwards */
00088 extern char *gdb_query(char *);                 /* q - general query */
00089 extern char *gdb_set(char *);                   /* Q - set value */
00090 
00091 /*
00092  * indicate to caller of mem2hex or hex2mem that there has been an error. 
00093  * 0 means ok, 1 means error
00094  */
00095 extern int mem_err;
00096 
00097 /*
00098  * indicate whether the debug vectors have been initialized
00099  * 0 means not yet, 1 means yep, it's ready.
00100  */
00101 extern int initialized;
00102 
00103 /*
00104  * 1 means print debugging messages from the target, 0 means be quiet.
00105  */
00106 extern int remote_debug;
00107 
00108 /*
00109  * Set up the command processing required for GDB
00110  */
00111 
00112 struct gdb_ops {
00113   /* 
00114    * these functions are the most minimal working subset top get full
00115    * functionality for remote debugging
00116    */
00117   char  *(*gdb_read_registers);                 /* g - read registers */
00118   char  *(*gdb_write_registers)(char *);        /* G - write registers */
00119   char  *(*gdb_read_memory)(long, int);         /* m - read memory */
00120   char  *(*gdb_write_memory)(long, int, char *);/* M write memory */
00121   char  *(*gdb_continue)(int, long );           /* c - continue */
00122   char  *(*gdb_step)(int, long);                /* s - step instruction(s) */
00123   char  *(*gdb_kill);                           /* k - kill program */
00124   char  *(*gdb_last_signal);                    /* ? - last signal */
00125   char  *(*gdb_baudrate)(int);                  /* b - change baud rate */
00126   char  *(*gdb_dump_state);                     /* T - dump state */
00127   /*
00128    * these functions are for a more sophisticated target, typically
00129    * running a simple RTOS.
00130    */
00131   char  *(*gdb_set_thread)(int, int);           /* H - set thread */
00132   char  *(*gdb_detach);                         /* D - detach */
00133   char  *(*gdb_read_reg)(int);                  /* p - read one register */
00134   char  *(*gdb_write_reg)(int, long);           /* P - write one register */
00135   char  *(*gdb_exited);                         /* W - process exited */
00136   char  *(*gdb_terminated);                     /* X - process terminated */
00137   char  *(*gdb_hex);                            /* O - hex encoding */
00138   char  *(*gdb_thread_alive)(int);              /* A - tread alive request */
00139                                                 /* FIXME: not standard yet */
00140   char  *(*gdb_extended);                       /* ! - extended protocol */
00141   char  *(*gdb_debug);                          /* d - toggle stub diagnostics */
00142   char  *(*gdb_toggle);                         /* unsupported, toggle stub on/off */
00143   char  *(*gdb_reset);                          /* r - reset target */
00144   char  *(*gdb_search)(long, long, long);       /* t - search backwards */
00145   char  *(*gdb_query)(char *);                  /* q - general query */
00146   char  *(*gdb_set)(long);                      /* Q - set value */
00147 };
00148 
00149 /*
00150  * BUFMAX defines the maximum number of characters in inbound/outbound buffers
00151  * at least NUMREGBYTES*2 are needed for register packets
00152  */
00153 #define BUFMAX 2048
00154 extern char packet_in_buf[BUFMAX];
00155 extern char packet_out_buf[BUFMAX];
00156 extern int  packet_index;
00157 
00158 #define DEBUG(x, y)             debuglog(x, y);
00159 #define set_debug_level(x)      remote_debug = x;
00160 #define OK 0
00161 #define ERROR -1
00162 #define ENN(x) "x"
00163 
00164 #define MAY_FAULT 1
00165 #define NO_FAULT 0

Generated on Thu Feb 20 15:38:45 2003 for cubeOS by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002