Implemented TOOLBAR_MouseLeave to handle WM_MOUSELEAVE messages.
[wine/multimedia.git] / debugger / debugger.h
blob1c7b9ed67d796455f766f0765104fbcbaf8906fc
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 <assert.h>
12 #include "windef.h"
13 #include "winbase.h"
14 #include "wine/exception.h"
16 #ifdef __i386__
17 #define STEP_FLAG 0x00000100 /* single step flag */
18 #define V86_FLAG 0x00020000
19 #endif
21 #define SYM_FUNC 0x0
22 #define SYM_DATA 0x1
23 #define SYM_WIN32 0x2
24 #define SYM_WINE 0x4
25 #define SYM_INVALID 0x8
26 #define SYM_TRAMPOLINE 0x10
27 #define SYM_STEP_THROUGH 0x20
29 enum debug_type {DT_BASIC, DT_CONST, DT_POINTER, DT_ARRAY, DT_STRUCT, DT_ENUM, DT_TYPEDEF, DT_FUNC, DT_BITFIELD};
33 * Return values for DEBUG_CheckLinenoStatus. Used to determine
34 * what to do when the 'step' command is given.
36 #define FUNC_HAS_NO_LINES (0)
37 #define NOT_ON_LINENUMBER (1)
38 #define AT_LINENUMBER (2)
39 #define FUNC_IS_TRAMPOLINE (3)
42 * For constants generated by the parser, we use this datatype
44 extern struct datatype * DEBUG_TypeInt;
45 extern struct datatype * DEBUG_TypeIntConst;
46 extern struct datatype * DEBUG_TypeUSInt;
47 extern struct datatype * DEBUG_TypeString;
49 typedef struct
51 DWORD seg; /* 0xffffffff means current default segment (cs or ds) */
52 DWORD off;
53 } DBG_ADDR;
55 #define DV_TARGET 0xF00D
56 #define DV_HOST 0x50DA
58 typedef struct
60 struct datatype* type;
61 int cookie; /* DV_??? */
62 DBG_ADDR addr;
63 } DBG_VALUE;
65 struct list_id
67 char * sourcefile;
68 int line;
71 struct wine_lines {
72 unsigned long line_number;
73 DBG_ADDR pc_offset;
76 struct symbol_info
78 struct name_hash * sym;
79 struct list_id list;
82 typedef struct wine_lines WineLineNo;
85 * This structure holds information about stack variables, function
86 * parameters, and register variables, which are all local to this
87 * function.
89 struct wine_locals {
90 unsigned int regno:8; /* For register symbols */
91 signed int offset:24; /* offset from esp/ebp to symbol */
92 unsigned int pc_start; /* For RBRAC/LBRAC */
93 unsigned int pc_end; /* For RBRAC/LBRAC */
94 char * name; /* Name of symbol */
95 struct datatype * type; /* Datatype of symbol */
98 typedef struct wine_locals WineLocals;
100 enum exec_mode
102 EXEC_CONT, /* Continuous execution */
103 EXEC_PASS, /* Continue, passing exception to app */
104 EXEC_STEP_OVER, /* Stepping over a call to next source line */
105 EXEC_STEP_INSTR, /* Step to next source line, stepping in if needed */
106 EXEC_STEPI_OVER, /* Stepping over a call */
107 EXEC_STEPI_INSTR, /* Single-stepping an instruction */
108 EXEC_FINISH, /* Step until we exit current frame */
109 EXEC_STEP_OVER_TRAMPOLINE, /* Step over trampoline. Requires that
110 * we dig the real return value off the stack
111 * and set breakpoint there - not at the
112 * instr just after the call.
114 EXEC_KILL /* terminate debugging session */
117 #define DBG_BREAK 0
118 #define DBG_WATCH 1
120 typedef struct
122 DBG_ADDR addr;
123 WORD enabled : 1,
124 type : 1,
125 is32 : 1,
126 refcount : 13;
127 WORD skipcount;
128 union {
129 BYTE opcode;
130 struct {
131 BYTE rw : 1,
132 len : 2;
133 BYTE reg;
134 DWORD oldval;
135 } w;
136 } u;
137 struct expr * condition;
138 } BREAKPOINT;
140 typedef struct tagDBG_THREAD {
141 struct tagDBG_PROCESS* process;
142 HANDLE handle;
143 DWORD tid;
144 LPVOID start;
145 LPVOID teb;
146 int wait_for_first_exception;
147 int dbg_mode;
148 enum exec_mode dbg_exec_mode;
149 int dbg_exec_count;
150 BREAKPOINT stepOverBP;
151 struct tagDBG_THREAD* next;
152 struct tagDBG_THREAD* prev;
153 } DBG_THREAD;
155 typedef struct tagDBG_PROCESS {
156 HANDLE handle;
157 DWORD pid;
158 DBG_THREAD* threads;
159 int num_threads;
160 struct tagDBG_MODULE* modules;
162 * This is an index we use to keep track of the debug information
163 * when we have multiple sources. We use the same database to also
164 * allow us to do an 'info shared' type of deal, and we use the index
165 * to eliminate duplicates.
167 int next_index;
168 struct tagDBG_PROCESS* next;
169 struct tagDBG_PROCESS* prev;
170 } DBG_PROCESS;
172 extern DBG_PROCESS* DEBUG_CurrProcess;
173 extern DBG_THREAD* DEBUG_CurrThread;
174 extern CONTEXT DEBUG_context;
176 #define DEBUG_READ_MEM(addr, buf, len) \
177 (ReadProcessMemory(DEBUG_CurrProcess->handle, (addr), (buf), (len), NULL))
179 #define DEBUG_WRITE_MEM(addr, buf, len) \
180 (WriteProcessMemory(DEBUG_CurrProcess->handle, (addr), (buf), (len), NULL))
182 #define DEBUG_READ_MEM_VERBOSE(addr, buf, len) \
183 (DEBUG_READ_MEM((addr), (buf), (len)) || (DEBUG_InvalLinAddr( addr ),0))
185 #define DEBUG_WRITE_MEM_VERBOSE(addr, buf, len) \
186 (DEBUG_WRITE_MEM((addr), (buf), (len)) || (DEBUG_InvalLinAddr( addr ),0))
188 typedef struct tagDBG_MODULE {
189 struct tagDBG_MODULE* next;
190 void* load_addr;
191 char* module_name;
192 char status;
193 char type;
194 short int dbg_index;
195 HMODULE handle;
196 void* extra_info;
197 } DBG_MODULE;
199 /* status field */
200 #define DM_STATUS_NEW 0
201 #define DM_STATUS_LOADED 1
202 #define DM_STATUS_ERROR 2
204 /* type field */
205 #define DM_TYPE_UNKNOWN 0
206 #define DM_TYPE_ELF 1
207 #define DM_TYPE_NE 2
208 #define DM_TYPE_PE 3
210 #ifdef __i386__
211 #ifdef REG_SP /* Some Sun includes define this */
212 #undef REG_SP
213 #endif
215 enum debug_regs
217 REG_EAX, REG_EBX, REG_ECX, REG_EDX, REG_ESI,
218 REG_EDI, REG_EBP, REG_EFL, REG_EIP, REG_ESP,
219 REG_AX, REG_BX, REG_CX, REG_DX, REG_SI,
220 REG_DI, REG_BP, REG_FL, REG_IP, REG_SP,
221 REG_CS, REG_DS, REG_ES, REG_SS, REG_FS, REG_GS
223 #endif
225 #define OFFSET_OF(__c,__f) ((int)(((char*)&(((__c*)0)->__f))-((char*)0)))
227 /* debugger/break.c */
228 extern void DEBUG_SetBreakpoints( BOOL set );
229 extern void DEBUG_AddBreakpoint( const DBG_VALUE *addr );
230 extern void DEBUG_AddWatchpoint( const DBG_VALUE *addr, int is_write );
231 extern void DEBUG_DelBreakpoint( int num );
232 extern void DEBUG_EnableBreakpoint( int num, BOOL enable );
233 extern void DEBUG_InfoBreakpoints(void);
234 extern BOOL DEBUG_HandleTrap(void);
235 extern BOOL DEBUG_ShouldContinue( DWORD code, enum exec_mode mode, int * count );
236 extern void DEBUG_SuspendExecution( void );
237 extern enum exec_mode DEBUG_RestartExecution( enum exec_mode mode, int count );
238 extern BOOL DEBUG_IsFctReturn(void);
239 extern int DEBUG_AddBPCondition(int bpnum, struct expr * exp);
241 /* debugger/db_disasm.c */
242 extern void DEBUG_Disasm( DBG_ADDR *addr, int display );
244 /* debugger/expr.c */
245 extern void DEBUG_FreeExprMem(void);
246 struct expr * DEBUG_RegisterExpr(enum debug_regs);
247 struct expr * DEBUG_SymbolExpr(const char * name);
248 struct expr * DEBUG_ConstExpr(int val);
249 struct expr * DEBUG_StringExpr(const char * str);
250 struct expr * DEBUG_SegAddr(struct expr *, struct expr *);
251 struct expr * DEBUG_USConstExpr(unsigned int val);
252 struct expr * DEBUG_BinopExpr(int oper, struct expr *, struct expr *);
253 struct expr * DEBUG_UnopExpr(int oper, struct expr *);
254 struct expr * DEBUG_StructPExpr(struct expr *, const char * element);
255 struct expr * DEBUG_StructExpr(struct expr *, const char * element);
256 struct expr * DEBUG_ArrayExpr(struct expr *, struct expr * index);
257 struct expr * DEBUG_CallExpr(const char *, int nargs, ...);
258 struct expr * DEBUG_TypeCastExpr(struct datatype *, struct expr *);
259 extern DBG_VALUE DEBUG_EvalExpr(struct expr *);
260 extern int DEBUG_DelDisplay(int displaynum);
261 extern struct expr * DEBUG_CloneExpr(const struct expr * exp);
262 extern int DEBUG_FreeExpr(struct expr * exp);
263 extern int DEBUG_DisplayExpr(const struct expr * exp);
265 /* debugger/display.c */
266 extern int DEBUG_DoDisplay(void);
267 extern int DEBUG_AddDisplay(struct expr * exp, int count, char format);
268 extern int DEBUG_DoDisplay(void);
269 extern int DEBUG_DelDisplay(int displaynum);
270 extern int DEBUG_InfoDisplay(void);
272 /* debugger/hash.c */
273 extern struct name_hash * DEBUG_AddSymbol( const char *name,
274 const DBG_VALUE *addr,
275 const char *sourcefile,
276 int flags);
277 extern BOOL DEBUG_GetSymbolValue( const char * name, const int lineno,
278 DBG_VALUE *addr, int );
279 extern BOOL DEBUG_SetSymbolValue( const char * name, const DBG_VALUE *addr );
280 extern const char * DEBUG_FindNearestSymbol( const DBG_ADDR *addr, int flag,
281 struct name_hash ** rtn,
282 unsigned int ebp,
283 struct list_id * source);
284 extern void DEBUG_ReadSymbolTable( const char * filename );
285 extern void DEBUG_AddLineNumber( struct name_hash * func, int line_num,
286 unsigned long offset );
287 extern struct wine_locals *
288 DEBUG_AddLocal( struct name_hash * func, int regno,
289 int offset,
290 int pc_start,
291 int pc_end,
292 char * name);
293 extern int DEBUG_CheckLinenoStatus(const DBG_ADDR *addr);
294 extern void DEBUG_GetFuncInfo(struct list_id * ret, const char * file,
295 const char * func);
296 extern int DEBUG_SetSymbolSize(struct name_hash * sym, unsigned int len);
297 extern int DEBUG_SetSymbolBPOff(struct name_hash * sym, unsigned int len);
298 extern int DEBUG_GetSymbolAddr(struct name_hash * sym, DBG_ADDR * addr);
299 extern int DEBUG_cmp_sym(const void * p1, const void * p2);
300 extern BOOL DEBUG_GetLineNumberAddr( struct name_hash *, const int lineno,
301 DBG_ADDR *addr, int bp_flag );
303 extern int DEBUG_SetLocalSymbolType(struct wine_locals * sym,
304 struct datatype * type);
305 extern BOOL DEBUG_Normalize(struct name_hash * nh );
307 /* debugger/info.c */
308 extern void DEBUG_PrintBasic( const DBG_VALUE* value, int count, char format );
309 extern struct symbol_info DEBUG_PrintAddress( const DBG_ADDR *addr,
310 int addrlen, int flag );
311 extern void DEBUG_Help(void);
312 extern void DEBUG_HelpInfo(void);
313 extern struct symbol_info DEBUG_PrintAddressAndArgs( const DBG_ADDR *addr,
314 int addrlen,
315 unsigned int ebp,
316 int flag );
317 extern void DEBUG_InfoClass(const char* clsName);
318 extern void DEBUG_WalkClasses(void);
319 extern void DEBUG_WalkModref(DWORD p);
320 extern void DEBUG_DumpModule(DWORD mod);
321 extern void DEBUG_WalkModules(void);
322 extern void DEBUG_WalkProcess(void);
323 extern void DEBUG_WalkThreads(void);
324 extern void DEBUG_DumpQueue(DWORD q);
325 extern void DEBUG_WalkQueues(void);
326 extern void DEBUG_InfoSegments(DWORD s, int v);
327 extern void DEBUG_InfoVirtual(void);
328 extern void DEBUG_InfoWindow(HWND hWnd);
329 extern void DEBUG_WalkWindows(HWND hWnd, int indent);
331 /* debugger/memory.c */
332 extern int DEBUG_ReadMemory( const DBG_ADDR *address );
333 extern void DEBUG_WriteMemory( const DBG_ADDR *address, int value );
334 extern void DEBUG_ExamineMemory( const DBG_VALUE *addr, int count, char format);
335 extern void DEBUG_InvalAddr( const DBG_ADDR* addr );
336 extern void DEBUG_InvalLinAddr( void* addr );
337 #ifdef __i386__
338 extern void DEBUG_GetCurrentAddress( DBG_ADDR * );
339 extern DWORD DEBUG_ToLinear( const DBG_ADDR *address );
340 extern void DEBUG_FixAddress( DBG_ADDR *address, DWORD def );
341 extern BOOL DEBUG_FixSegment( DBG_ADDR* addr );
342 extern int DEBUG_GetSelectorType( WORD sel );
343 extern int DEBUG_IsSelectorSystem( WORD sel );
344 #endif
346 /* debugger/module.c */
347 extern int DEBUG_LoadEntryPoints( const char * prefix );
348 extern void DEBUG_LoadModule32( const char* name, HANDLE hFile, DWORD base );
349 extern DBG_MODULE* DEBUG_AddModule(const char* name, int type,
350 void* mod_addr, HMODULE hmod);
351 extern DBG_MODULE* DEBUG_FindModuleByName(const char* name, int type);
352 extern DBG_MODULE* DEBUG_FindModuleByHandle(HANDLE handle, int type);
353 extern DBG_MODULE* DEBUG_RegisterPEModule(HMODULE, u_long load_addr, const char* name);
354 extern DBG_MODULE* DEBUG_RegisterELFModule(u_long load_addr, const char* name);
355 extern void DEBUG_InfoShare(void);
357 /* debugger/msc.c */
358 extern int DEBUG_RegisterMSCDebugInfo(DBG_MODULE* module, HANDLE hFile, void* nth, unsigned long nth_ofs);
359 extern int DEBUG_RegisterStabsDebugInfo(DBG_MODULE* module, HANDLE hFile, void* nth, unsigned long nth_ofs);
360 extern void DEBUG_InitCVDataTypes(void);
362 /* debugger/registers.c */
363 extern void DEBUG_SetRegister( enum debug_regs reg, int val );
364 extern int DEBUG_GetRegister( enum debug_regs reg );
365 extern void DEBUG_InfoRegisters(void);
366 extern BOOL DEBUG_ValidateRegisters(void);
367 extern int DEBUG_PrintRegister(enum debug_regs reg);
369 /* debugger/stack.c */
370 extern void DEBUG_InfoStack(void);
371 extern void DEBUG_BackTrace(BOOL noisy);
372 extern int DEBUG_InfoLocals(void);
373 extern int DEBUG_SetFrame(int newframe);
374 extern int DEBUG_GetCurrentFrame(struct name_hash ** name,
375 unsigned int * eip,
376 unsigned int * ebp);
378 /* debugger/stabs.c */
379 extern int DEBUG_ReadExecutableDbgInfo(const char* exe_name);
380 extern int DEBUG_ProcessElfObject(const char* filename, unsigned int load_offset);
381 extern int DEBUG_ParseStabs(char * addr, unsigned int load_offset, unsigned int staboff,
382 int stablen, unsigned int strtaboff, int strtablen);
384 /* debugger/types.c */
385 extern int DEBUG_nchar;
386 extern void DEBUG_InitTypes(void);
387 extern struct datatype * DEBUG_NewDataType(enum debug_type xtype,
388 const char * typename);
389 extern unsigned int DEBUG_TypeDerefPointer(const DBG_VALUE *value, struct datatype ** newtype);
390 extern int DEBUG_AddStructElement(struct datatype * dt,
391 char * name, struct datatype * type,
392 int offset, int size);
393 extern int DEBUG_SetStructSize(struct datatype * dt, int size);
394 extern int DEBUG_SetPointerType(struct datatype * dt, struct datatype * dt2);
395 extern int DEBUG_SetArrayParams(struct datatype * dt, int min, int max,
396 struct datatype * dt2);
397 extern void DEBUG_Print( const DBG_VALUE *addr, int count, char format, int level );
398 extern unsigned int DEBUG_FindStructElement(DBG_VALUE * addr,
399 const char * ele_name, int * tmpbuf);
400 extern struct datatype * DEBUG_GetPointerType(struct datatype * dt);
401 extern int DEBUG_GetObjectSize(struct datatype * dt);
402 extern unsigned int DEBUG_ArrayIndex(const DBG_VALUE * addr, DBG_VALUE * result, int index);
403 extern struct datatype * DEBUG_FindOrMakePointerType(struct datatype * reftype);
404 extern long long int DEBUG_GetExprValue(const DBG_VALUE * addr, char ** format);
405 extern int DEBUG_SetBitfieldParams(struct datatype * dt, int offset,
406 int nbits, struct datatype * dt2);
407 extern int DEBUG_CopyFieldlist(struct datatype * dt, struct datatype * dt2);
408 extern enum debug_type DEBUG_GetType(struct datatype * dt);
409 extern struct datatype * DEBUG_TypeCast(enum debug_type, const char *);
410 extern int DEBUG_PrintTypeCast(const struct datatype *);
411 extern int DEBUG_PrintType( const DBG_VALUE* addr );
413 /* debugger/source.c */
414 extern void DEBUG_ShowDir(void);
415 extern void DEBUG_AddPath(const char * path);
416 extern void DEBUG_List(struct list_id * line1, struct list_id * line2,
417 int delta);
418 extern void DEBUG_NukePath(void);
419 extern void DEBUG_Disassemble( const DBG_VALUE *, const DBG_VALUE*, int offset );
421 /* debugger/external.c */
422 extern void DEBUG_ExternalDebugger(void);
424 /* debugger/dbg.y */
425 extern BOOL DEBUG_Main( BOOL is_debug, BOOL force, DWORD code );
426 extern void DEBUG_Exit( DWORD );
428 /* debugger/winedbg.c */
429 #define DBG_CHN_MESG 1
430 #define DBG_CHN_ERR 2
431 #define DBG_CHN_WARN 4
432 #define DBG_CHN_FIXME 8
433 #define DBG_CHN_TRACE 16
434 extern int DEBUG_Printf(int chn, const char* format, ...);
436 /* Choose your allocator! */
437 #if 1
438 /* this one is libc's fast one */
439 extern void* DEBUG_XMalloc(size_t size);
440 extern void* DEBUG_XReAlloc(void *ptr, size_t size);
441 extern char* DEBUG_XStrDup(const char *str);
443 #define DBG_alloc(x) DEBUG_XMalloc(x)
444 #define DBG_realloc(x,y) DEBUG_XReAlloc(x,y)
445 #define DBG_free(x) free(x)
446 #define DBG_strdup(x) DEBUG_XStrDup(x)
447 #else
448 /* this one is slow (takes 5 minutes to load the debugger on my machine),
449 but is pretty crash-proof (can step through malloc() without problems,
450 malloc() arena (and other heaps) can be totally wasted and it'll still
451 work, etc... if someone could make optimized routines so it wouldn't
452 take so long to load, it could be made default) */
453 #include "heap.h"
454 #define DBG_alloc(x) HeapAlloc(dbg_heap,0,x)
455 #define DBG_realloc(x,y) HeapRealloc(dbg_heap,0,x,y)
456 #define DBG_free(x) HeapFree(dbg_heap,0,x)
457 #define DBG_strdup(x) HEAP_strdupA(dbg_heap,0,x)
458 #define DBG_need_heap
459 extern HANDLE dbg_heap;
460 #endif
462 #define DEBUG_STATUS_OFFSET 0x80003000
463 #define DEBUG_STATUS_INTERNAL_ERROR (DEBUG_STATUS_OFFSET+0)
464 #define DEBUG_STATUS_NO_SYMBOL (DEBUG_STATUS_OFFSET+1)
465 #define DEBUG_STATUS_DIV_BY_ZERO (DEBUG_STATUS_OFFSET+2)
466 #define DEBUG_STATUS_BAD_TYPE (DEBUG_STATUS_OFFSET+3)
468 #define DBG_IVAR(_var) DEBUG_IV_##_var
469 #define INTERNAL_VAR(_var,_val) extern int DBG_IVAR(_var);
470 #include "intvar.h"
471 #undef INTERNAL_VAR
473 #endif /* __WINE_DEBUGGER_H */