00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 static const char hexchars[]="0123456789abcdef";
00031
00032 typedef void (*exception_t)(int);
00033
00034
00035
00036
00037 extern exception_t default_trap_hook;
00038
00039
00040 struct trap_info
00041 {
00042 unsigned char tt;
00043 unsigned char signo;
00044 };
00045
00046
00047
00048
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();
00066 extern char *gdb_write_registers(char *);
00067 extern char *gdb_read_memory(long, int);
00068 extern char *gdb_write_memory(long, int, char *);
00069 extern char *gdb_continue(int, long );
00070 extern char *gdb_step(int, long);
00071 extern char *gdb_kill();
00072 extern char *gdb_last_signal();
00073 extern char *gdb_baudrate(int);
00074 extern char *gdb_dump_state();
00075 extern char *gdb_set_thread(int, int);
00076 extern char *gdb_detach();
00077 extern char *gdb_read_reg(int);
00078 extern char *gdb_write_reg(int, long);
00079 extern char *gdb_exited();
00080 extern char *gdb_terminated();
00081 extern char *gdb_hex();
00082 extern char *gdb_thread_alive(int);
00083 extern char *gdb_extended();
00084 extern char *gdb_debug();
00085 extern char *gdb_toggle();
00086 extern char *gdb_reset();
00087 extern char *gdb_search(long, long, long);
00088 extern char *gdb_query(char *);
00089 extern char *gdb_set(char *);
00090
00091
00092
00093
00094
00095 extern int mem_err;
00096
00097
00098
00099
00100
00101 extern int initialized;
00102
00103
00104
00105
00106 extern int remote_debug;
00107
00108
00109
00110
00111
00112 struct gdb_ops {
00113
00114
00115
00116
00117 char *(*gdb_read_registers);
00118 char *(*gdb_write_registers)(char *);
00119 char *(*gdb_read_memory)(long, int);
00120 char *(*gdb_write_memory)(long, int, char *);
00121 char *(*gdb_continue)(int, long );
00122 char *(*gdb_step)(int, long);
00123 char *(*gdb_kill);
00124 char *(*gdb_last_signal);
00125 char *(*gdb_baudrate)(int);
00126 char *(*gdb_dump_state);
00127
00128
00129
00130
00131 char *(*gdb_set_thread)(int, int);
00132 char *(*gdb_detach);
00133 char *(*gdb_read_reg)(int);
00134 char *(*gdb_write_reg)(int, long);
00135 char *(*gdb_exited);
00136 char *(*gdb_terminated);
00137 char *(*gdb_hex);
00138 char *(*gdb_thread_alive)(int);
00139
00140 char *(*gdb_extended);
00141 char *(*gdb_debug);
00142 char *(*gdb_toggle);
00143 char *(*gdb_reset);
00144 char *(*gdb_search)(long, long, long);
00145 char *(*gdb_query)(char *);
00146 char *(*gdb_set)(long);
00147 };
00148
00149
00150
00151
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