ultragdb.h
5.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
#ifndef __ultragdb__
#define __ultragdb__
#include "ultratypes.h"
#include "os.h"
#include "os_internal.h"
#include "dbgproto.h"
#include "sptask.h"
typedef void (* VFUNPTR)();
#define GDB_PRINTF osSyncPrintf
#define GDB_DBG_BUF_SIZE 2048
#define GDB_STACKSIZE 0x1000
#define __GDB_BUFMAX GDB_DBG_BUF_SIZE
#define TMP_BREAK 0x0000000d
#define CNX_BREAK 0x0001000d
#define NUM_REGS 71
#define GDB_BREAKMASK 0xfc00003f
#define GDB_USE_THREADID 0
/*
*Messages that may be sent to the GDB message queue
*/
#define MSG_BREAKPOINT 0x02
#define MSG_SPBREAKPOINT 0x04
#define MSG_CPUFAULT 0x08
#define MSG_THREADCREATE 0x10
#define MSG_THREADDESTROY 0x20
/* GDB reply status codes */
#define GDB_RESP_STATUS_OK "OK"
#define GDB_RESP_ERR_PKT_FORMAT "E01"
#define GDB_RESP_ERR_NO_THREAD "E02"
#define GDB_RESP_ERR_INVALID_ADDR "E03"
#define GDB_RESP_ERR_INVALID_THREAD_OP "E04"
#define GDB_RESP_ERR_NO_MORE_SLOTS "E05" /* No more breakpoint slots */
#define GDB_RESP_ERR_OP_FAILED "E06" /* Operation failed for some reason */
/* GDB error codes (similar to RMON's TV_ERROR_... codes */
#define GDB_ERROR_NO_ERROR 0
#define GDB_ERROR_INVALID_ID -2
#define GDB_ERROR_OP_FAILED -3 /* TV_ERROR_INVALID_TYPE */
#define GDB_ERROR_OP_PROTECTED -4
#define GDB_ERROR_INVALID_ADDRESS -5
#define GDB_ERROR_NO_MORE_IDS -10
/* GDB breakpoint types - currently only type 0 is supported */
#define GDB_BREAKPT_MEMORY 0
#define GDB_BREAKPT_HARDWARE 1
#define GDB_WATCHPT_WRITE 2
#define GDB_WATCHPT_READ 3
#define GDB_WATCHPT_ACCESS 4
#define __GDB_THREAD_LIST_LIMIT 32
/* Use -1 to indicate we are interested in all threads */
#define GDB_ALL_THREADS (OSThread*) -1
/* GDB debug verbosity masks */
#define GDB_DEBUG_SHOW_INFO 0x01
#define GDB_DEBUG_SHOW_ERROR 0x02
#define GDB_DEBUG_SHOW_PACKET 0x10
#define GDB_DEBUG_SHOW_CHAR 0x20
/* Macros for identifying different classes of threads
Thread t should be checked to be not NULL before using macros */
#define __OS_IS_IDLE_THREAD(t) (t->priority == OS_PRIORITY_IDLE)
#define __OS_IS_USER_THREAD(t) \
((t->priority > 0) && (t->priority <= OS_PRIORITY_APPMAX))
#define __OS_IS_SYSTEM_THREAD(t) \
((t->priority > OS_PRIORITY_APPMAX) && (t->priority <= OS_PRIORITY_MAX))
/* the order of the registers follows GDB's tm-mips.h */
typedef struct {
/* General purpose registers */
u32 zero; u32 at; u32 v0; u32 v1; u32 a0; u32 a1; u32 a2; u32 a3; /* 0-7 */
u32 t0; u32 t1; u32 t2; u32 t3; u32 t4; u32 t5; u32 t6; u32 t7; /* 8-15 */
u32 s0; u32 s1; u32 s2; u32 s3; u32 s4; u32 s5; u32 s6; u32 s7; /* 16-23 */
u32 t8; u32 t9; u32 k0; u32 k1; u32 gp; u32 sp; u32 s8; u32 ra; /* 24-31 */
/* Special registers */
u32 sr; u32 hi; u32 lo; u32 bad; u32 cause; u32 pc; /* 32-37 */
/* Floating point registers */
u32 f0; u32 f1; u32 f2; u32 f3; u32 f4; u32 f5; u32 f6; u32 f7; /* 38-45 */
u32 f8; u32 f9; u32 f10; u32 f11; u32 f12; u32 f13; u32 f14; u32 f15; /* 46-53 */
u32 f16; u32 f17; u32 f18; u32 f19; u32 f20; u32 f21; u32 f22; u32 f23; /* 54-61 */
u32 f24; u32 f25; u32 f26; u32 f27; u32 f28; u32 f29; u32 f30; u32 f31; /* 62-69 */
u32 fsr; u32 fir; /* 70-71 */
} Registers;
typedef struct {
char* name;
u32 addr;
} gdbSymbol;
extern char* gdb_module_name;
extern int gdbDebug;
extern int gdbShowAllThreadsFlag;
extern int gdbStopUserThreadsFlag;
extern int gdbWaitToSendBreakFlag;
extern OSThread *__gdb_curRunThread;
extern OSThread *__gdb_curThread;
/* Function prototypes */
void gdbWritebackDCache(void *, s32);
void gdbInvalICache(void *, s32);
/* from gdbutil.c */
char *strcpy (char *s1, const char *s2);
char* mem2hex(char *mem, char *buf, int count);
int hex(char ch);
int hexToInt(char **ptr, int *intValue);
char* hex2mem(char *buf, char *mem, int count);
/* from gdbbrk.c */
int gdbRemoveAllBreakpoints();
int gdbRemoveBreakpoint(int type, u32* addr, int length);
int gdbInsertBreakpoint(int type, u32* addr, int length);
int __gdbSetSingleStep(OSThread* thread, u32 * instptr);
void __gdbHitBreak( void );
void __gdbHitCpuFault( void );
/* from gdbregs.c */
u32 __gdbGetRegisterContents(OSThread* tptr, int regNumber);
int __gdbSetRegister(OSThread* thread, int reg, int value);
void gdbProcSetRegisterPkt(char* ptr, char *resp);
void gdbAssembleRegisters(char *resp);
/* from gdbio.c */
void __gdbSendFault( OSThread * thread );
void __gdbIOflush( void );
int __gdbSend(char *s, int n);
char __gdbPutDebugChar(char c);
int __gdbGetDebugChar(void);
u32 __gdbGetPacket(char *buffer, u32 bufsize, int* psig);
void __gdbPutPacket(char *buffer);
void __gdbIOhandler(void);
/* from gdbhandler.c */
char* __gdbWriteThreadID(char* buf, int threadID);
char* __gdbWriteThreadInfo(char *buf, int threadID);
char* __gdbWriteSignal(char *buf, int sigval);
char* __gdbWriteSRThreadID(char *buf, int threadID);
char* __gdbStartThreadSignalReply(char *buf, int sigval);
void gdbWriteSignalReply(char *buf, int sigval);
void gdbWriteThreadSignalReply(char *buf, int sigval, int threadID);
int gdbWriteThreadList(char *ptr, u32 limit, int restart);
void gdbQuerySymbol(char* buf, gdbSymbol *symbol);
int gdbAddSymbol(char* hex_symname, gdbSymbol *symbol, u32 addr);
void gdbProcSetThreadPkt(char* ptr, char *resp);
void gdbProcBreakPkt(char cmd, char* ptr, char *resp);
void gdbProcPacket();
/* from gdbthreads.c */
OSThread* __gdbGetActiveQueue(void);
int __gdbGetThreadID(OSThread* t);
OSThread* __gdbFindIdleThread();
OSThread* __gdbFindUserThread();
OSThread* __gdbIDToThread(int threadID);
void __gdbMaskIdleThreadInts( void );
int __gdbGetCurrentThreadID();
int __gdbSetRequestedThread(OSThread** thread, int tid);
OSThread* getOneCurrentThread();
int gdbRunThread(OSThread* thread, int flags, int addr);
void gdbFindFaultedThreads( void );
int gdbStopUserThread(OSThread* tptr);
#endif /* __ultragdb__ */