00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00027 #ifndef _GDBREMOTE_H_
00028 #define _GDBREMOTE_H_
00029
00030 #include <assert.h>
00031 #include "tcp.h"
00032 #include <map>
00033
00034 #define GDB_REMOTE_DEFAULT_PORT 3141
00035 #define GDB_REMOTE_BUFFER_SIZE (32 * 1024)
00036
00038 #define BKPT_0_INSTR 0xe1200070
00039
00040 class JTAGpxa250;
00041
00047 class GdbRemote {
00048 public:
00049
00050 GdbRemote(JTAGpxa250 *pxa);
00051 ~GdbRemote();
00052
00056 bool openPort(int port = GDB_REMOTE_DEFAULT_PORT);
00057
00060 int prepareFD_SET(fd_set *set);
00061
00063 void processFD_SET(fd_set *set);
00064
00066 void printError();
00067
00068 private:
00069 JTAGpxa250 *pxa;
00070 int clientSocket;
00071 bool running;
00072 unsigned int hardBreak[2];
00073
00075 unsigned char buffer[GDB_REMOTE_BUFFER_SIZE];
00076
00078 char message[GDB_REMOTE_BUFFER_SIZE];
00079 int bufferLength;
00080 int ptr;
00081 void reset() { ptr = 0; }
00082 unsigned char current() { return buffer[ptr]; }
00083 bool next() { ++ptr; assert(ptr<GDB_REMOTE_BUFFER_SIZE); return ptr < bufferLength; }
00084
00085 void sendPacket();
00086 void parse();
00087 void parsePacket();
00088 void parseValidPacket();
00089 static unsigned char toAsciiHex(unsigned int v);
00090 static unsigned char asciiToHex(unsigned char c);
00091 static void hexPrintWord(unsigned char *str, unsigned int val);
00092 unsigned int parseHexWord();
00093 unsigned int parseHexByte();
00094
00095 static void callback(void *p);
00096
00097 void resumeExec();
00098 void query();
00099 void lastSignal();
00100 void setThread();
00101 void getRegisters();
00102 void setRegisters();
00103 void readMem();
00104 void writeMem();
00105 void cont();
00106 void insertBreakWatch();
00107 void removeBreakWatch();
00108 void step();
00109 };
00110
00111 #endif // _GDB_REMOTE_H_
00112