Fixed bad register constraint in InterlockedCompareExchange.
[wine/hacks.git] / include / debugger.h
blobf79dd2d17483c60c214c15363965bfe04e2a7803
1 /*
2 * Debugger definitions
4 * Copyright 1995 Alexandre Julliard
5 */
7 #ifndef __WINE_DEBUGGER_H
8 #define __WINE_DEBUGGER_H
10 #include <sys/types.h> /* u_long ... */
11 #include "windef.h"
12 #include "miscemu.h"
14 #define STEP_FLAG 0x100 /* single step flag */
16 #define SYM_FUNC 0x0
17 #define SYM_DATA 0x1
18 #define SYM_WIN32 0x2
19 #define SYM_WINE 0x4
20 #define SYM_INVALID 0x8
21 #define SYM_TRAMPOLINE 0x10
22 #define SYM_STEP_THROUGH 0x20
24 enum debug_type {DT_BASIC, DT_CONST, DT_POINTER, DT_ARRAY, DT_STRUCT, DT_ENUM, DT_TYPEDEF, DT_FUNC, DT_BITFIELD};
28 * Return values for DEBUG_CheckLinenoStatus. Used to determine
29 * what to do when the 'step' command is given.
31 #define FUNC_HAS_NO_LINES (0)
32 #define NOT_ON_LINENUMBER (1)
33 #define AT_LINENUMBER (2)
34 #define FUNC_IS_TRAMPOLINE (3)
37 * For constants generated by the parser, we use this datatype
39 extern struct datatype * DEBUG_TypeInt;
40 extern struct datatype * DEBUG_TypeIntConst;
41 extern struct datatype * DEBUG_TypeUSInt;
42 extern struct datatype * DEBUG_TypeString;
44 typedef struct
46 struct datatype * type;
47 DWORD seg; /* 0xffffffff means current default segment (cs or ds) */
48 DWORD off;
49 } DBG_ADDR;
51 struct list_id
53 char * sourcefile;
54 int line;
57 struct wine_lines {
58 unsigned long line_number;
59 DBG_ADDR pc_offset;
62 struct symbol_info
64 struct name_hash * sym;
65 struct list_id list;
68 typedef struct wine_lines WineLineNo;
71 * This structure holds information about stack variables, function
72 * parameters, and register variables, which are all local to this
73 * function.
75 struct wine_locals {
76 unsigned int regno:8; /* For register symbols */
77 signed int offset:24; /* offset from esp/ebp to symbol */
78 unsigned int pc_start; /* For RBRAC/LBRAC */
79 unsigned int pc_end; /* For RBRAC/LBRAC */
80 char * name; /* Name of symbol */
81 struct datatype * type; /* Datatype of symbol */
84 typedef struct wine_locals WineLocals;
87 #ifdef __i386__
89 #define DBG_V86_MODULE(seg) ((seg)>>16)
90 #define IS_SELECTOR_V86(seg) DBG_V86_MODULE(seg)
92 #define DBG_FIX_ADDR_SEG(addr,default) { \
93 if ((addr)->seg == 0xffffffff) (addr)->seg = (default); \
94 if (!IS_SELECTOR_V86((addr)->seg)) \
95 if (IS_SELECTOR_SYSTEM((addr)->seg)) (addr)->seg = 0; }
97 #define DBG_ADDR_TO_LIN(addr) \
98 (IS_SELECTOR_V86((addr)->seg) \
99 ? (char*)(DOSMEM_MemoryBase(DBG_V86_MODULE((addr)->seg)) + \
100 ((((addr)->seg)&0xFFFF)<<4)+(addr)->off) : \
101 (IS_SELECTOR_SYSTEM((addr)->seg) ? (char *)(addr)->off \
102 : (char *)PTR_SEG_OFF_TO_LIN((addr)->seg,(addr)->off)))
104 #else /* __i386__ */
106 #define DBG_FIX_ADDR_SEG(addr,default)
107 #define DBG_ADDR_TO_LIN(addr) ((char *)(addr)->off)
109 #endif /* __386__ */
111 #define DBG_CHECK_READ_PTR(addr,len) \
112 (!DEBUG_IsBadReadPtr((addr),(len)) || \
113 (fprintf(stderr,"*** Invalid address "), \
114 DEBUG_PrintAddress((addr),dbg_mode, FALSE), \
115 fprintf(stderr,"\n"),0))
117 #define DBG_CHECK_WRITE_PTR(addr,len) \
118 (!DEBUG_IsBadWritePtr((addr),(len)) || \
119 (fprintf(stderr,"*** Invalid address "), \
120 DEBUG_PrintAddress(addr,dbg_mode, FALSE), \
121 fprintf(stderr,"\n"),0))
123 #ifdef REG_SP /* Some Sun includes define this */
124 #undef REG_SP
125 #endif
127 enum debug_regs
129 REG_EAX, REG_EBX, REG_ECX, REG_EDX, REG_ESI,
130 REG_EDI, REG_EBP, REG_EFL, REG_EIP, REG_ESP,
131 REG_AX, REG_BX, REG_CX, REG_DX, REG_SI,
132 REG_DI, REG_BP, REG_FL, REG_IP, REG_SP,
133 REG_CS, REG_DS, REG_ES, REG_SS, REG_FS, REG_GS
137 enum exec_mode
139 EXEC_CONT, /* Continuous execution */
140 EXEC_PASS, /* Continue, passing exception to app */
141 EXEC_STEP_OVER, /* Stepping over a call to next source line */
142 EXEC_STEP_INSTR, /* Step to next source line, stepping in if needed */
143 EXEC_STEPI_OVER, /* Stepping over a call */
144 EXEC_STEPI_INSTR, /* Single-stepping an instruction */
145 EXEC_FINISH, /* Step until we exit current frame */
146 EXEC_STEP_OVER_TRAMPOLINE /* Step over trampoline. Requires that
147 * we dig the real return value off the stack
148 * and set breakpoint there - not at the
149 * instr just after the call.
153 extern CONTEXT DEBUG_context; /* debugger/registers.c */
154 extern unsigned int dbg_mode;
155 extern HANDLE dbg_heap;
157 /* debugger/break.c */
158 extern void DEBUG_SetBreakpoints( BOOL set );
159 extern int DEBUG_FindBreakpoint( const DBG_ADDR *addr );
160 extern void DEBUG_AddBreakpoint( const DBG_ADDR *addr );
161 extern void DEBUG_DelBreakpoint( int num );
162 extern void DEBUG_EnableBreakpoint( int num, BOOL enable );
163 extern void DEBUG_InfoBreakpoints(void);
164 extern void DEBUG_AddTaskEntryBreakpoint( HTASK16 hTask );
165 extern BOOL DEBUG_HandleTrap(void);
166 extern BOOL DEBUG_ShouldContinue( enum exec_mode mode, int * count );
167 extern enum exec_mode DEBUG_RestartExecution( enum exec_mode mode, int count );
168 extern BOOL DEBUG_IsFctReturn(void);
170 /* debugger/db_disasm.c */
171 extern void DEBUG_Disasm( DBG_ADDR *addr, int display );
173 /* debugger/expr.c */
174 extern void DEBUG_FreeExprMem(void);
175 struct expr * DEBUG_RegisterExpr(enum debug_regs);
176 struct expr * DEBUG_SymbolExpr(const char * name);
177 struct expr * DEBUG_ConstExpr(int val);
178 struct expr * DEBUG_StringExpr(const char * str);
179 struct expr * DEBUG_SegAddr(struct expr *, struct expr *);
180 struct expr * DEBUG_USConstExpr(unsigned int val);
181 struct expr * DEBUG_BinopExpr(int oper, struct expr *, struct expr *);
182 struct expr * DEBUG_UnopExpr(int oper, struct expr *);
183 struct expr * DEBUG_StructPExpr(struct expr *, const char * element);
184 struct expr * DEBUG_StructExpr(struct expr *, const char * element);
185 struct expr * DEBUG_ArrayExpr(struct expr *, struct expr * index);
186 struct expr * DEBUG_CallExpr(const char *, int nargs, ...);
187 struct expr * DEBUG_TypeCastExpr(struct datatype *, struct expr *);
188 extern int DEBUG_ExprValue(DBG_ADDR *, unsigned int *);
189 DBG_ADDR DEBUG_EvalExpr(struct expr *);
190 extern int DEBUG_DelDisplay(int displaynum);
191 extern struct expr * DEBUG_CloneExpr(struct expr * exp);
192 extern int DEBUG_FreeExpr(struct expr * exp);
193 extern int DEBUG_DisplayExpr(struct expr * exp);
195 /* more debugger/break.c */
196 extern int DEBUG_AddBPCondition(int bpnum, struct expr * exp);
198 /* debugger/display.c */
199 extern int DEBUG_DoDisplay(void);
200 extern int DEBUG_AddDisplay(struct expr * exp, int count, char format);
201 extern int DEBUG_DoDisplay(void);
202 extern int DEBUG_DelDisplay(int displaynum);
203 extern int DEBUG_InfoDisplay(void);
205 /* debugger/hash.c */
206 extern struct name_hash * DEBUG_AddSymbol( const char *name,
207 const DBG_ADDR *addr,
208 const char * sourcefile,
209 int flags);
210 extern struct name_hash * DEBUG_AddInvSymbol( const char *name,
211 const DBG_ADDR *addr,
212 const char * sourcefile);
213 extern BOOL DEBUG_GetSymbolValue( const char * name, const int lineno,
214 DBG_ADDR *addr, int );
215 extern BOOL DEBUG_SetSymbolValue( const char * name, const DBG_ADDR *addr );
216 extern const char * DEBUG_FindNearestSymbol( const DBG_ADDR *addr, int flag,
217 struct name_hash ** rtn,
218 unsigned int ebp,
219 struct list_id * source);
220 extern void DEBUG_ReadSymbolTable( const char * filename );
221 extern int DEBUG_LoadEntryPoints( const char * prefix );
222 extern void DEBUG_AddLineNumber( struct name_hash * func, int line_num,
223 unsigned long offset );
224 extern struct wine_locals *
225 DEBUG_AddLocal( struct name_hash * func, int regno,
226 int offset,
227 int pc_start,
228 int pc_end,
229 char * name);
230 extern int DEBUG_CheckLinenoStatus(const DBG_ADDR *addr);
231 extern void DEBUG_GetFuncInfo(struct list_id * ret, const char * file,
232 const char * func);
233 extern int DEBUG_SetSymbolSize(struct name_hash * sym, unsigned int len);
234 extern int DEBUG_SetSymbolBPOff(struct name_hash * sym, unsigned int len);
235 extern int DEBUG_GetSymbolAddr(struct name_hash * sym, DBG_ADDR * addr);
236 extern int DEBUG_cmp_sym(const void * p1, const void * p2);
237 extern BOOL DEBUG_GetLineNumberAddr( struct name_hash *, const int lineno,
238 DBG_ADDR *addr, int bp_flag );
240 extern int DEBUG_SetLocalSymbolType(struct wine_locals * sym,
241 struct datatype * type);
242 BOOL DEBUG_Normalize(struct name_hash * nh );
244 /* debugger/info.c */
245 extern void DEBUG_PrintBasic( const DBG_ADDR *addr, int count, char format );
246 extern struct symbol_info DEBUG_PrintAddress( const DBG_ADDR *addr,
247 int addrlen, int flag );
248 extern void DEBUG_Help(void);
249 extern void DEBUG_HelpInfo(void);
250 extern struct symbol_info DEBUG_PrintAddressAndArgs( const DBG_ADDR *addr,
251 int addrlen,
252 unsigned int ebp,
253 int flag );
255 /* debugger/memory.c */
256 extern BOOL DEBUG_IsBadReadPtr( const DBG_ADDR *address, int size );
257 extern BOOL DEBUG_IsBadWritePtr( const DBG_ADDR *address, int size );
258 extern int DEBUG_ReadMemory( const DBG_ADDR *address );
259 extern void DEBUG_WriteMemory( const DBG_ADDR *address, int value );
260 extern void DEBUG_ExamineMemory( const DBG_ADDR *addr, int count, char format);
262 /* debugger/registers.c */
263 extern void DEBUG_SetRegister( enum debug_regs reg, int val );
264 extern int DEBUG_GetRegister( enum debug_regs reg );
265 extern void DEBUG_InfoRegisters(void);
266 extern BOOL DEBUG_ValidateRegisters(void);
267 extern int DEBUG_PrintRegister(enum debug_regs reg);
269 /* debugger/stack.c */
270 extern void DEBUG_InfoStack(void);
271 extern void DEBUG_BackTrace(void);
272 extern void DEBUG_SilentBackTrace(void);
273 extern int DEBUG_InfoLocals(void);
274 extern int DEBUG_SetFrame(int newframe);
275 extern int DEBUG_GetCurrentFrame(struct name_hash ** name,
276 unsigned int * eip,
277 unsigned int * ebp);
279 /* debugger/stabs.c */
280 extern int DEBUG_ReadExecutableDbgInfo(void);
281 extern int DEBUG_ParseStabs(char * addr, unsigned int load_offset, unsigned int staboff, int stablen, unsigned int strtaboff, int strtablen);
283 /* debugger/msc.c */
284 extern int DEBUG_RegisterDebugInfo( HMODULE, const char *);
285 extern int DEBUG_ProcessDeferredDebug(void);
286 extern int DEBUG_RegisterELFDebugInfo(int load_addr, u_long size, char * name);
287 extern void DEBUG_InfoShare(void);
288 extern void DEBUG_InitCVDataTypes(void);
290 /* debugger/types.c */
291 extern int DEBUG_nchar;
292 extern void DEBUG_InitTypes(void);
293 extern struct datatype * DEBUG_NewDataType(enum debug_type xtype,
294 const char * typename);
295 extern unsigned int
296 DEBUG_TypeDerefPointer(DBG_ADDR * addr, struct datatype ** newtype);
297 extern int DEBUG_AddStructElement(struct datatype * dt,
298 char * name, struct datatype * type,
299 int offset, int size);
300 extern int DEBUG_SetStructSize(struct datatype * dt, int size);
301 extern int DEBUG_SetPointerType(struct datatype * dt, struct datatype * dt2);
302 extern int DEBUG_SetArrayParams(struct datatype * dt, int min, int max,
303 struct datatype * dt2);
304 extern void DEBUG_Print( const DBG_ADDR *addr, int count, char format, int level );
305 extern unsigned int DEBUG_FindStructElement(DBG_ADDR * addr,
306 const char * ele_name, int * tmpbuf);
307 extern struct datatype * DEBUG_GetPointerType(struct datatype * dt);
308 extern int DEBUG_GetObjectSize(struct datatype * dt);
309 extern unsigned int DEBUG_ArrayIndex(DBG_ADDR * addr, DBG_ADDR * result, int index);
310 extern struct datatype * DEBUG_FindOrMakePointerType(struct datatype * reftype);
311 extern long long int DEBUG_GetExprValue(DBG_ADDR * addr, char ** format);
312 extern int DEBUG_SetBitfieldParams(struct datatype * dt, int offset,
313 int nbits, struct datatype * dt2);
314 extern int DEBUG_CopyFieldlist(struct datatype * dt, struct datatype * dt2);
315 extern enum debug_type DEBUG_GetType(struct datatype * dt);
316 extern struct datatype * DEBUG_TypeCast(enum debug_type, const char *);
317 extern int DEBUG_PrintTypeCast(struct datatype *);
319 /* debugger/source.c */
320 extern void DEBUG_ShowDir(void);
321 extern void DEBUG_AddPath(const char * path);
322 extern void DEBUG_List(struct list_id * line1, struct list_id * line2,
323 int delta);
324 extern void DEBUG_NukePath(void);
325 extern void DEBUG_GetCurrentAddress( DBG_ADDR * );
326 extern void DEBUG_Disassemble( const DBG_ADDR *, const DBG_ADDR*, int offset );
328 /* debugger/dbg.y */
329 extern DWORD wine_debugger( EXCEPTION_RECORD *rec, CONTEXT *context, BOOL first_chance );
330 extern void DEBUG_Exit( DWORD exit_code );
332 /* Choose your allocator! */
333 #if 1
334 /* this one is libc's fast one */
335 #include "xmalloc.h"
336 #define DBG_alloc(x) xmalloc(x)
337 #define DBG_realloc(x,y) xrealloc(x,y)
338 #define DBG_free(x) free(x)
339 #define DBG_strdup(x) xstrdup(x)
340 #else
341 /* this one is slow (takes 5 minutes to load the debugger on my machine),
342 but is pretty crash-proof (can step through malloc() without problems,
343 malloc() arena (and other heaps) can be totally wasted and it'll still
344 work, etc... if someone could make optimized routines so it wouldn't
345 take so long to load, it could be made default) */
346 #include "heap.h"
347 #define DBG_alloc(x) HEAP_xalloc(dbg_heap,0,x)
348 #define DBG_realloc(x,y) HEAP_xrealloc(dbg_heap,0,x,y)
349 #define DBG_free(x) HeapFree(dbg_heap,0,x)
350 #define DBG_strdup(x) HEAP_strdupA(dbg_heap,0,x)
351 #define DBG_need_heap
352 #endif
354 #endif /* __WINE_DEBUGGER_H */