Convert HMMIO to a void*.
[wine.git] / debugger / debugger.h
blob31da4a8a4e7fdcdf844ffda9ff5a38c4a58978a9
1 /*
2 * Debugger definitions
4 * Copyright 1995 Alexandre Julliard
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #ifndef __WINE_DEBUGGER_H
22 #define __WINE_DEBUGGER_H
24 #include <sys/types.h> /* u_long ... */
25 #include <assert.h>
26 #include "windef.h"
27 #include "winbase.h"
28 #include "wine/exception.h"
30 #ifdef __i386__
31 #define STEP_FLAG 0x00000100 /* single step flag */
32 #define V86_FLAG 0x00020000
33 #endif
35 #define SYM_FUNC 0x0
36 #define SYM_DATA 0x1
37 #define SYM_WIN32 0x2
38 #define SYM_WINE 0x4
39 #define SYM_INVALID 0x8
40 #define SYM_TRAMPOLINE 0x10
41 #define SYM_STEP_THROUGH 0x20
43 enum debug_type {DT_BASIC, DT_POINTER, DT_ARRAY, DT_STRUCT, DT_ENUM,
44 DT_FUNC, DT_BITFIELD};
46 enum debug_type_basic {DT_BASIC_INT = 1, DT_BASIC_CHAR, DT_BASIC_LONGINT, DT_BASIC_UINT,
47 DT_BASIC_ULONGINT, DT_BASIC_LONGLONGINT, DT_BASIC_ULONGLONGINT,
48 DT_BASIC_SHORTINT, DT_BASIC_USHORTINT, DT_BASIC_SCHAR, DT_BASIC_UCHAR,
49 DT_BASIC_FLOAT, DT_BASIC_LONGDOUBLE, DT_BASIC_DOUBLE,
50 DT_BASIC_CMPLX_INT, DT_BASIC_CMPLX_FLOAT, DT_BASIC_CMPLX_DOUBLE,
51 DT_BASIC_CMPLX_LONGDOUBLE, DT_BASIC_VOID,
52 /* modifier on size isn't possible on current types definitions
53 * so we need to add more types... */
54 DT_BASIC_BOOL1, DT_BASIC_BOOL2, DT_BASIC_BOOL4,
55 /* this is not really a basic type... */
56 DT_BASIC_STRING,
57 /* this is for historical reasons... should take care of it RSN */
58 DT_BASIC_CONST_INT,
59 /* not so basic, but handy */
60 DT_BASIC_CONTEXT,
61 /* to be kept as last... sentinel entry... do not use */
62 DT_BASIC_LAST};
65 * Return values for DEBUG_CheckLinenoStatus. Used to determine
66 * what to do when the 'step' command is given.
68 #define FUNC_HAS_NO_LINES (0)
69 #define NOT_ON_LINENUMBER (1)
70 #define AT_LINENUMBER (2)
71 #define FUNC_IS_TRAMPOLINE (3)
73 typedef struct
75 DWORD seg; /* 0xffffffff means current default segment (cs or ds) */
76 DWORD off;
77 } DBG_ADDR;
79 typedef struct
81 struct datatype* type;
82 int cookie; /* DV_??? */
83 /* DV_TARGET references an address in debugger's address space, whereas DV_HOST
84 * references the debuggee address space
86 # define DV_TARGET 0xF00D
87 # define DV_HOST 0x50DA
88 # define DV_INVALID 0x0000
90 DBG_ADDR addr;
91 } DBG_VALUE;
93 struct list_id
95 char * sourcefile;
96 int line;
99 struct wine_lines {
100 unsigned long line_number;
101 DBG_ADDR pc_offset;
104 struct symbol_info
106 struct name_hash * sym;
107 struct list_id list;
110 typedef struct wine_lines WineLineNo;
113 * This structure holds information about stack variables, function
114 * parameters, and register variables, which are all local to this
115 * function.
117 struct wine_locals {
118 unsigned int regno:8; /* For register symbols */
119 signed int offset:24; /* offset from esp/ebp to symbol */
120 unsigned int pc_start; /* For RBRAC/LBRAC */
121 unsigned int pc_end; /* For RBRAC/LBRAC */
122 char * name; /* Name of symbol */
123 struct datatype * type; /* Datatype of symbol */
126 typedef struct wine_locals WineLocals;
128 enum exec_mode
130 EXEC_CONT, /* Continuous execution */
131 EXEC_STEP_OVER, /* Stepping over a call to next source line */
132 EXEC_STEP_INSTR, /* Step to next source line, stepping in if needed */
133 EXEC_STEPI_OVER, /* Stepping over a call */
134 EXEC_STEPI_INSTR, /* Single-stepping an instruction */
135 EXEC_FINISH, /* Step until we exit current frame */
136 EXEC_STEP_OVER_TRAMPOLINE, /* Step over trampoline. Requires that
137 * we dig the real return value off the stack
138 * and set breakpoint there - not at the
139 * instr just after the call.
143 enum dbg_mode
145 MODE_INVALID, MODE_16, MODE_32, MODE_VM86
148 enum exit_mode /* of exception handling */
150 EXIT_CONTINUE, /* continue execution */
151 EXIT_PASS, /* pass exception back to app (1st chance) */
152 EXIT_DETACH, /* detach debugger */
153 EXIT_QUIT, /* exit debugger and kill debuggee */
156 #define DBG_BREAK 0
157 #define DBG_WATCH 1
159 typedef struct
161 DBG_ADDR addr;
162 WORD enabled : 1,
163 type : 1,
164 is32 : 1,
165 refcount : 13;
166 WORD skipcount;
167 union {
168 struct {
169 BYTE opcode;
170 BOOL (*func)(void);
171 } b;
172 struct {
173 BYTE rw : 1,
174 len : 2;
175 BYTE reg;
176 DWORD oldval;
177 } w;
178 } u;
179 struct expr * condition;
180 } DBG_BREAKPOINT;
182 /* Wine extension; Windows doesn't have a name for this code. This is an
183 undocumented exception understood by MS VC debugger, allowing the program
184 to name a particular thread. Search google.com or deja.com for "0x406d1388"
185 for more info. */
186 #define EXCEPTION_NAME_THREAD 0x406D1388
188 /* Helper structure */
189 typedef struct tagTHREADNAME_INFO
191 DWORD dwType; /* Must be 0x1000 */
192 LPCTSTR szName; /* Pointer to name - limited to 9 bytes (8 characters + terminator) */
193 DWORD dwThreadID; /* Thread ID (-1 = caller thread) */
194 DWORD dwFlags; /* Reserved for future use. Must be zero. */
195 } THREADNAME_INFO;
197 typedef struct tagDBG_THREAD {
198 struct tagDBG_PROCESS* process;
199 HANDLE handle;
200 DWORD tid;
201 LPVOID start;
202 LPVOID teb;
203 int wait_for_first_exception;
204 enum exec_mode exec_mode; /* mode the thread is run (step/run...) */
205 int exec_count; /* count of mode operations */
206 enum dbg_mode dbg_mode; /* mode (VM86, 32bit, 16bit) */
207 DBG_BREAKPOINT stepOverBP;
208 char name[9];
209 struct tagDBG_THREAD* next;
210 struct tagDBG_THREAD* prev;
211 } DBG_THREAD;
213 typedef struct tagDBG_DELAYED_BP {
214 BOOL is_symbol;
215 union {
216 struct {
217 int lineno;
218 char* name;
219 } symbol;
220 DBG_VALUE value;
221 } u;
222 } DBG_DELAYED_BP;
224 typedef struct tagDBG_PROCESS {
225 HANDLE handle;
226 DWORD pid;
227 const char* imageName;
228 DBG_THREAD* threads;
229 int num_threads;
230 unsigned continue_on_first_exception;
231 struct tagDBG_MODULE** modules;
232 int num_modules;
233 unsigned long dbg_hdr_addr;
234 DBG_DELAYED_BP* delayed_bp;
235 int num_delayed_bp;
237 * This is an index we use to keep track of the debug information
238 * when we have multiple sources. We use the same database to also
239 * allow us to do an 'info shared' type of deal, and we use the index
240 * to eliminate duplicates.
242 int next_index;
243 struct tagDBG_PROCESS* next;
244 struct tagDBG_PROCESS* prev;
245 } DBG_PROCESS;
247 extern DBG_PROCESS* DEBUG_CurrProcess;
248 extern DBG_THREAD* DEBUG_CurrThread;
249 extern DWORD DEBUG_CurrTid;
250 extern DWORD DEBUG_CurrPid;
251 extern CONTEXT DEBUG_context;
252 extern BOOL DEBUG_InteractiveP;
253 extern enum exit_mode DEBUG_ExitMode;
254 extern HANDLE DEBUG_hParserInput;
255 extern HANDLE DEBUG_hParserOutput;
257 #define DEBUG_READ_MEM(addr, buf, len) \
258 (ReadProcessMemory(DEBUG_CurrProcess->handle, (addr), (buf), (len), NULL))
260 #define DEBUG_WRITE_MEM(addr, buf, len) \
261 (WriteProcessMemory(DEBUG_CurrProcess->handle, (addr), (buf), (len), NULL))
263 #define DEBUG_READ_MEM_VERBOSE(addr, buf, len) \
264 (DEBUG_READ_MEM((addr), (buf), (len)) || (DEBUG_InvalLinAddr( addr ),0))
266 #define DEBUG_WRITE_MEM_VERBOSE(addr, buf, len) \
267 (DEBUG_WRITE_MEM((addr), (buf), (len)) || (DEBUG_InvalLinAddr( addr ),0))
269 enum DbgInfoLoad {DIL_DEFERRED, DIL_LOADED, DIL_NOINFO, DIL_ERROR};
270 enum DbgModuleType {DMT_UNKNOWN, DMT_ELF, DMT_NE, DMT_PE};
272 typedef struct tagDBG_MODULE {
273 void* load_addr;
274 unsigned long size;
275 char* module_name;
276 enum DbgInfoLoad dil;
277 enum DbgModuleType type;
278 unsigned short main : 1;
279 short int dbg_index;
280 HMODULE handle;
281 struct tagMSC_DBG_INFO* msc_info;
282 struct tagELF_DBG_INFO* elf_info;
283 } DBG_MODULE;
285 typedef struct {
286 DWORD val;
287 const char* name;
288 LPDWORD pval;
289 struct datatype* type;
290 } DBG_INTVAR;
292 #define OFFSET_OF(__c,__f) ((int)(((char*)&(((__c*)0)->__f))-((char*)0)))
294 /* from winelib.so */
295 extern void DEBUG_ExternalDebugger(void);
297 /* debugger/break.c */
298 extern void DEBUG_SetBreakpoints( BOOL set );
299 extern BOOL DEBUG_AddBreakpoint( const DBG_VALUE *addr, BOOL (*func)(void), BOOL verbose );
300 extern BOOL DEBUG_AddBreakpointFromValue( const DBG_VALUE *addr );
301 extern void DEBUG_AddBreakpointFromId( const char *name, int lineno );
302 extern void DEBUG_AddBreakpointFromLineno( int lineno );
303 extern void DEBUG_AddWatchpoint( const DBG_VALUE *addr, int is_write );
304 extern void DEBUG_AddWatchpointFromId( const char *name );
305 extern void DEBUG_CheckDelayedBP( void );
306 extern void DEBUG_DelBreakpoint( int num );
307 extern void DEBUG_EnableBreakpoint( int num, BOOL enable );
308 extern void DEBUG_InfoBreakpoints(void);
309 extern BOOL DEBUG_HandleTrap(void);
310 extern BOOL DEBUG_ShouldContinue( DBG_ADDR* addr, DWORD code, int* count );
311 extern void DEBUG_SuspendExecution( void );
312 extern void DEBUG_RestartExecution( int count );
313 extern BOOL DEBUG_IsFctReturn(void);
314 extern int DEBUG_AddBPCondition(int bpnum, struct expr * exp);
316 /* debugger/db_disasm.c */
317 extern void DEBUG_Disasm( DBG_ADDR *addr, int display );
319 /* debugger/dbg.y */
320 extern void DEBUG_Parser(LPCSTR);
321 extern void DEBUG_Exit(DWORD);
323 /* debugger/debug.l */
324 extern void DEBUG_FlushSymbols(void);
325 extern char*DEBUG_MakeSymbol(const char*);
326 extern int DEBUG_ReadLine(const char* pfx, char* buffer, int size);
328 /* debugger/display.c */
329 extern int DEBUG_DoDisplay(void);
330 extern int DEBUG_AddDisplay(struct expr * exp, int count, char format);
331 extern int DEBUG_DoDisplay(void);
332 extern int DEBUG_DelDisplay(int displaynum);
333 extern int DEBUG_InfoDisplay(void);
335 /* debugger/expr.c */
336 extern void DEBUG_FreeExprMem(void);
337 struct expr * DEBUG_IntVarExpr(const char* name);
338 struct expr * DEBUG_SymbolExpr(const char * name);
339 struct expr * DEBUG_ConstExpr(int val);
340 struct expr * DEBUG_StringExpr(const char * str);
341 struct expr * DEBUG_SegAddr(struct expr *, struct expr *);
342 struct expr * DEBUG_USConstExpr(unsigned int val);
343 struct expr * DEBUG_BinopExpr(int oper, struct expr *, struct expr *);
344 struct expr * DEBUG_UnopExpr(int oper, struct expr *);
345 struct expr * DEBUG_StructPExpr(struct expr *, const char * element);
346 struct expr * DEBUG_StructExpr(struct expr *, const char * element);
347 struct expr * DEBUG_ArrayExpr(struct expr *, struct expr * index);
348 struct expr * DEBUG_CallExpr(const char *, int nargs, ...);
349 struct expr * DEBUG_TypeCastExpr(struct datatype *, struct expr *);
350 extern DBG_VALUE DEBUG_EvalExpr(struct expr *);
351 extern int DEBUG_DelDisplay(int displaynum);
352 extern struct expr * DEBUG_CloneExpr(const struct expr * exp);
353 extern int DEBUG_FreeExpr(struct expr * exp);
354 extern int DEBUG_DisplayExpr(const struct expr * exp);
356 /* debugger/hash.c */
357 extern struct name_hash * DEBUG_AddSymbol( const char *name,
358 const DBG_VALUE *addr,
359 const char *sourcefile,
360 int flags);
361 extern int DEBUG_GetSymbolValue( const char * name, const int lineno,
362 DBG_VALUE *addr, int );
363 extern BOOL DEBUG_SetSymbolValue( const char * name, const DBG_VALUE *addr );
364 extern const char * DEBUG_FindNearestSymbol( const DBG_ADDR *addr, int flag,
365 struct name_hash ** rtn,
366 unsigned int ebp,
367 struct list_id * source);
368 extern void DEBUG_ReadSymbolTable( const char * filename, unsigned long offset );
369 extern void DEBUG_AddLineNumber( struct name_hash * func, int line_num,
370 unsigned long offset );
371 extern struct wine_locals *
372 DEBUG_AddLocal( struct name_hash * func, int regno,
373 int offset,
374 int pc_start,
375 int pc_end,
376 char * name);
377 extern int DEBUG_CheckLinenoStatus(const DBG_ADDR *addr);
378 extern void DEBUG_GetFuncInfo(struct list_id * ret, const char * file,
379 const char * func);
380 extern int DEBUG_SetSymbolSize(struct name_hash * sym, unsigned int len);
381 extern int DEBUG_SetSymbolBPOff(struct name_hash * sym, unsigned int len);
382 extern int DEBUG_GetSymbolAddr(struct name_hash * sym, DBG_ADDR * addr);
383 extern int DEBUG_cmp_sym(const void * p1, const void * p2);
384 extern BOOL DEBUG_GetLineNumberAddr( const struct name_hash *, const int lineno,
385 DBG_ADDR *addr, int bp_flag );
387 extern int DEBUG_SetLocalSymbolType(struct wine_locals * sym,
388 struct datatype * type);
389 extern BOOL DEBUG_Normalize(struct name_hash * nh );
391 /* debugger/info.c */
392 extern void DEBUG_PrintBasic( const DBG_VALUE* value, int count, char format );
393 extern struct symbol_info DEBUG_PrintAddress( const DBG_ADDR *addr,
394 enum dbg_mode mode, int flag );
395 extern void DEBUG_Help(void);
396 extern void DEBUG_HelpInfo(void);
397 extern struct symbol_info DEBUG_PrintAddressAndArgs( const DBG_ADDR *addr,
398 enum dbg_mode mode,
399 unsigned int ebp,
400 int flag );
401 extern void DEBUG_InfoClass(const char* clsName);
402 extern void DEBUG_WalkClasses(void);
403 extern void DEBUG_WalkModref(DWORD p);
404 extern void DEBUG_DumpModule(DWORD mod);
405 extern void DEBUG_WalkModules(void);
406 extern void DEBUG_WalkProcess(void);
407 extern void DEBUG_WalkThreads(void);
408 extern void DEBUG_DumpQueue(DWORD q);
409 extern void DEBUG_WalkQueues(void);
410 extern void DEBUG_InfoSegments(DWORD s, int v);
411 extern void DEBUG_InfoVirtual(void);
412 extern void DEBUG_InfoWindow(HWND hWnd);
413 extern void DEBUG_WalkWindows(HWND hWnd, int indent);
414 extern void DEBUG_DbgChannel(BOOL add, const char* chnl, const char* name);
416 /* debugger/memory.c */
417 extern int DEBUG_ReadMemory( const DBG_VALUE* value );
418 extern void DEBUG_WriteMemory( const DBG_VALUE* val, int value );
419 extern void DEBUG_ExamineMemory( const DBG_VALUE *addr, int count, char format);
420 extern void DEBUG_InvalAddr( const DBG_ADDR* addr );
421 extern void DEBUG_InvalLinAddr( void* addr );
422 extern DWORD DEBUG_ToLinear( const DBG_ADDR *address );
423 extern void DEBUG_GetCurrentAddress( DBG_ADDR * );
424 extern BOOL DEBUG_GrabAddress( DBG_VALUE* value, BOOL fromCode );
425 extern enum dbg_mode DEBUG_GetSelectorType( WORD sel );
426 #ifdef __i386__
427 extern void DEBUG_FixAddress( DBG_ADDR *address, DWORD def );
428 extern int DEBUG_IsSelectorSystem( WORD sel );
429 #endif
430 extern int DEBUG_PrintStringA( int chnl, const DBG_ADDR* address, int len );
431 extern int DEBUG_PrintStringW( int chnl, const DBG_ADDR* address, int len );
433 /* debugger/module.c */
434 extern int DEBUG_LoadEntryPoints( const char * prefix );
435 extern void DEBUG_LoadModule32( const char* name, HANDLE hFile, DWORD base );
436 extern DBG_MODULE* DEBUG_AddModule(const char* name, enum DbgModuleType type,
437 void* mod_addr, u_long size, HMODULE hmod);
438 extern DBG_MODULE* DEBUG_FindModuleByName(const char* name, enum DbgModuleType type);
439 extern DBG_MODULE* DEBUG_FindModuleByHandle(HANDLE handle, enum DbgModuleType type);
440 extern DBG_MODULE* DEBUG_FindModuleByAddr(void* addr, enum DbgModuleType type);
441 extern DBG_MODULE* DEBUG_GetProcessMainModule(DBG_PROCESS* process);
442 extern DBG_MODULE* DEBUG_RegisterPEModule(HMODULE, u_long load_addr, u_long size,
443 const char* name);
444 extern DBG_MODULE* DEBUG_RegisterELFModule(u_long load_addr, u_long size,
445 const char* name);
446 extern enum DbgInfoLoad DEBUG_RegisterPEDebugInfo(DBG_MODULE* wmod, HANDLE hFile,
447 void* _nth, unsigned long nth_ofs);
448 extern void DEBUG_ReportDIL(enum DbgInfoLoad dil, const char* pfx,
449 const char* filename, DWORD load_addr);
450 extern void DEBUG_InfoShare(void);
452 /* debugger/msc.c */
453 extern enum DbgInfoLoad DEBUG_RegisterMSCDebugInfo(DBG_MODULE* module, HANDLE hFile,
454 void* nth, unsigned long nth_ofs);
455 extern enum DbgInfoLoad DEBUG_RegisterStabsDebugInfo(DBG_MODULE* module,
456 HANDLE hFile, void* nth,
457 unsigned long nth_ofs);
458 extern void DEBUG_InitCVDataTypes(void);
460 /* debugger/registers.c */
461 extern void DEBUG_InfoRegisters(const CONTEXT* ctx);
462 extern BOOL DEBUG_ValidateRegisters(void);
464 /* debugger/source.c */
465 extern void DEBUG_ShowDir(void);
466 extern void DEBUG_AddPath(const char * path);
467 extern void DEBUG_List(struct list_id * line1, struct list_id * line2,
468 int delta);
469 extern void DEBUG_NukePath(void);
470 extern void DEBUG_Disassemble(const DBG_VALUE *, const DBG_VALUE*, int offset);
471 extern BOOL DEBUG_DisassembleInstruction(DBG_ADDR *addr);
473 /* debugger/stack.c */
474 extern void DEBUG_InfoStack(void);
475 extern void DEBUG_BackTrace(DWORD threadID, BOOL noisy);
476 extern int DEBUG_InfoLocals(void);
477 extern int DEBUG_SetFrame(int newframe);
478 extern int DEBUG_GetCurrentFrame(struct name_hash ** name,
479 unsigned int * eip,
480 unsigned int * ebp);
482 /* debugger/stabs.c */
483 extern enum DbgInfoLoad DEBUG_ReadExecutableDbgInfo(const char* exe_name);
484 extern enum DbgInfoLoad DEBUG_ParseStabs(char * addr, unsigned int load_offset,
485 unsigned int staboff, int stablen,
486 unsigned int strtaboff, int strtablen);
488 /* debugger/types.c */
489 extern int DEBUG_nchar;
490 extern void DEBUG_InitTypes(void);
491 extern struct datatype * DEBUG_NewDataType(enum debug_type xtype,
492 const char * typename);
493 extern unsigned int DEBUG_TypeDerefPointer(const DBG_VALUE *value,
494 struct datatype ** newtype);
495 extern int DEBUG_AddStructElement(struct datatype * dt,
496 char * name, struct datatype * type,
497 int offset, int size);
498 extern int DEBUG_SetStructSize(struct datatype * dt, int size);
499 extern int DEBUG_SetPointerType(struct datatype * dt, struct datatype * dt2);
500 extern int DEBUG_SetArrayParams(struct datatype * dt, int min, int max,
501 struct datatype * dt2);
502 extern void DEBUG_Print( const DBG_VALUE *addr, int count, char format, int level );
503 extern unsigned int DEBUG_FindStructElement(DBG_VALUE * addr,
504 const char * ele_name, int * tmpbuf);
505 extern struct datatype * DEBUG_GetPointerType(struct datatype * dt);
506 extern int DEBUG_GetObjectSize(struct datatype * dt);
507 extern unsigned int DEBUG_ArrayIndex(const DBG_VALUE * addr, DBG_VALUE * result,
508 int index);
509 extern struct datatype * DEBUG_FindOrMakePointerType(struct datatype * reftype);
510 extern long long int DEBUG_GetExprValue(const DBG_VALUE * addr, char ** format);
511 extern int DEBUG_SetBitfieldParams(struct datatype * dt, int offset,
512 int nbits, struct datatype * dt2);
513 extern int DEBUG_CopyFieldlist(struct datatype * dt, struct datatype * dt2);
514 extern enum debug_type DEBUG_GetType(struct datatype * dt);
515 extern struct datatype * DEBUG_TypeCast(enum debug_type, const char *);
516 extern int DEBUG_PrintTypeCast(const struct datatype *);
517 extern int DEBUG_PrintType( const DBG_VALUE* addr );
518 extern struct datatype * DEBUG_GetBasicType(enum debug_type_basic);
520 /* debugger/winedbg.c */
521 #define DBG_CHN_MESG 1
522 #define DBG_CHN_ERR 2
523 #define DBG_CHN_WARN 4
524 #define DBG_CHN_FIXME 8
525 #define DBG_CHN_TRACE 16
526 extern void DEBUG_OutputA(int chn, const char* buffer, int len);
527 extern void DEBUG_OutputW(int chn, const WCHAR* buffer, int len);
528 #ifdef __GNUC__
529 extern int DEBUG_Printf(int chn, const char* format, ...) __attribute__((format (printf,2,3)));
530 #else
531 extern int DEBUG_Printf(int chn, const char* format, ...);
532 #endif
533 extern DBG_INTVAR* DEBUG_GetIntVar(const char*);
534 extern BOOL DEBUG_Attach(DWORD pid, BOOL cofe);
535 extern BOOL DEBUG_Detach(void);
536 extern void DEBUG_Run(const char* args);
537 extern DBG_PROCESS* DEBUG_AddProcess(DWORD pid, HANDLE h, const char* imageName);
538 extern DBG_PROCESS* DEBUG_GetProcess(DWORD pid);
539 extern void DEBUG_DelProcess(DBG_PROCESS* p);
540 extern DBG_THREAD* DEBUG_AddThread(DBG_PROCESS* p, DWORD tid, HANDLE h, LPVOID start, LPVOID teb);
541 extern DBG_THREAD* DEBUG_GetThread(DBG_PROCESS* p, DWORD tid);
542 extern void DEBUG_DelThread(DBG_THREAD* t);
543 extern BOOL DEBUG_ProcessGetString(char* buffer, int size, HANDLE hp, LPSTR addr);
544 extern BOOL DEBUG_ProcessGetStringIndirect(char* buffer, int size, HANDLE hp, LPVOID addr);
545 extern void DEBUG_WaitNextException(DWORD cont, int count, int mode);
546 extern int curr_frame;
548 /* gdbproxy.c */
549 extern BOOL DEBUG_GdbRemote(unsigned int);
551 /* Choose your allocator! */
552 #if 1
553 /* this one is libc's fast one */
554 extern void* DEBUG_XMalloc(size_t size);
555 extern void* DEBUG_XReAlloc(void *ptr, size_t size);
556 extern char* DEBUG_XStrDup(const char *str);
558 #define DBG_alloc(x) DEBUG_XMalloc(x)
559 #define DBG_realloc(x,y) DEBUG_XReAlloc(x,y)
560 #define DBG_free(x) free(x)
561 #define DBG_strdup(x) DEBUG_XStrDup(x)
562 #else
563 /* this one is slow (takes 5 minutes to load the debugger on my machine),
564 if someone could make optimized routines so it wouldn't
565 take so long to load, it could be made default) */
566 #define DBG_alloc(x) HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,x)
567 #define DBG_realloc(x,y) HeapReAlloc(GetProcessHeap(),0,x,y)
568 #define DBG_free(x) HeapFree(GetProcessHeap(),0,x)
569 inline static LPSTR DBG_strdup( LPCSTR str )
571 INT len = strlen(str) + 1;
572 LPSTR p = DBG_alloc( len );
573 if (p) memcpy( p, str, len );
574 return p;
576 #endif
578 #define DEBUG_STATUS_OFFSET 0x80003000
579 #define DEBUG_STATUS_INTERNAL_ERROR (DEBUG_STATUS_OFFSET+0)
580 #define DEBUG_STATUS_NO_SYMBOL (DEBUG_STATUS_OFFSET+1)
581 #define DEBUG_STATUS_DIV_BY_ZERO (DEBUG_STATUS_OFFSET+2)
582 #define DEBUG_STATUS_BAD_TYPE (DEBUG_STATUS_OFFSET+3)
583 #define DEBUG_STATUS_NO_FIELD (DEBUG_STATUS_OFFSET+4)
585 extern DBG_INTVAR DEBUG_IntVars[];
587 #define DBG_IVARNAME(_var) DEBUG_IV_##_var
588 #define DBG_IVARSTRUCT(_var) DEBUG_IntVars[DBG_IVARNAME(_var)]
589 #define DBG_IVAR(_var) (*(DBG_IVARSTRUCT(_var).pval))
590 #define INTERNAL_VAR(_var,_val,_ref,_typ) DBG_IVARNAME(_var),
591 enum debug_int_var {
592 #include "intvar.h"
593 DBG_IV_LAST
595 #undef INTERNAL_VAR
597 #endif /* __WINE_DEBUGGER_H */