Restored MakeCriticalSectionGlobal that got lost somewhere.
[wine/multimedia.git] / debugger / debugger.h
blob1ac6ea4dc651478bc69ce0b8fea8d3f317a1dd3d
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 /* to be kept as last... sentinel entry... do not use */
60 DT_BASIC_LAST};
63 * Return values for DEBUG_CheckLinenoStatus. Used to determine
64 * what to do when the 'step' command is given.
66 #define FUNC_HAS_NO_LINES (0)
67 #define NOT_ON_LINENUMBER (1)
68 #define AT_LINENUMBER (2)
69 #define FUNC_IS_TRAMPOLINE (3)
71 typedef struct
73 DWORD seg; /* 0xffffffff means current default segment (cs or ds) */
74 DWORD off;
75 } DBG_ADDR;
77 typedef struct
79 struct datatype* type;
80 int cookie; /* DV_??? */
81 /* DV_TARGET references an address in debugger's address space, whereas DV_HOST
82 * references the debuggee address space
84 # define DV_TARGET 0xF00D
85 # define DV_HOST 0x50DA
86 # define DV_INVALID 0x0000
88 DBG_ADDR addr;
89 } DBG_VALUE;
91 struct list_id
93 char * sourcefile;
94 int line;
97 struct wine_lines {
98 unsigned long line_number;
99 DBG_ADDR pc_offset;
102 struct symbol_info
104 struct name_hash * sym;
105 struct list_id list;
108 typedef struct wine_lines WineLineNo;
111 * This structure holds information about stack variables, function
112 * parameters, and register variables, which are all local to this
113 * function.
115 struct wine_locals {
116 unsigned int regno:8; /* For register symbols */
117 signed int offset:24; /* offset from esp/ebp to symbol */
118 unsigned int pc_start; /* For RBRAC/LBRAC */
119 unsigned int pc_end; /* For RBRAC/LBRAC */
120 char * name; /* Name of symbol */
121 struct datatype * type; /* Datatype of symbol */
124 typedef struct wine_locals WineLocals;
126 enum exec_mode
128 EXEC_CONT, /* Continuous execution */
129 EXEC_STEP_OVER, /* Stepping over a call to next source line */
130 EXEC_STEP_INSTR, /* Step to next source line, stepping in if needed */
131 EXEC_STEPI_OVER, /* Stepping over a call */
132 EXEC_STEPI_INSTR, /* Single-stepping an instruction */
133 EXEC_FINISH, /* Step until we exit current frame */
134 EXEC_STEP_OVER_TRAMPOLINE, /* Step over trampoline. Requires that
135 * we dig the real return value off the stack
136 * and set breakpoint there - not at the
137 * instr just after the call.
141 enum dbg_mode
143 MODE_INVALID, MODE_16, MODE_32, MODE_VM86
146 enum exit_mode /* of exception handling */
148 EXIT_CONTINUE, /* continue execution */
149 EXIT_PASS, /* pass exception back to app (1st chance) */
150 EXIT_DETACH, /* detach debugger */
151 EXIT_QUIT, /* exit debugger and kill debuggee */
154 #define DBG_BREAK 0
155 #define DBG_WATCH 1
157 typedef struct
159 DBG_ADDR addr;
160 WORD enabled : 1,
161 type : 1,
162 is32 : 1,
163 refcount : 13;
164 WORD skipcount;
165 union {
166 struct {
167 BYTE opcode;
168 BOOL (*func)(void);
169 } b;
170 struct {
171 BYTE rw : 1,
172 len : 2;
173 BYTE reg;
174 DWORD oldval;
175 } w;
176 } u;
177 struct expr * condition;
178 } DBG_BREAKPOINT;
180 /* Wine extension; Windows doesn't have a name for this code. This is an
181 undocumented exception understood by MS VC debugger, allowing the program
182 to name a particular thread. Search google.com or deja.com for "0x406d1388"
183 for more info. */
184 #define EXCEPTION_NAME_THREAD 0x406D1388
186 /* Helper structure */
187 typedef struct tagTHREADNAME_INFO
189 DWORD dwType; /* Must be 0x1000 */
190 LPCTSTR szName; /* Pointer to name - limited to 9 bytes (8 characters + terminator) */
191 DWORD dwThreadID; /* Thread ID (-1 = caller thread) */
192 DWORD dwFlags; /* Reserved for future use. Must be zero. */
193 } THREADNAME_INFO;
195 typedef struct tagDBG_THREAD {
196 struct tagDBG_PROCESS* process;
197 HANDLE handle;
198 DWORD tid;
199 LPVOID start;
200 LPVOID teb;
201 int wait_for_first_exception;
202 enum exec_mode exec_mode; /* mode the thread is run (step/run...) */
203 int exec_count; /* count of mode operations */
204 enum dbg_mode dbg_mode; /* mode (VM86, 32bit, 16bit) */
205 DBG_BREAKPOINT stepOverBP;
206 char name[9];
207 struct tagDBG_THREAD* next;
208 struct tagDBG_THREAD* prev;
209 } DBG_THREAD;
211 typedef struct tagDBG_DELAYED_BP {
212 int lineno;
213 char* name;
214 } DBG_DELAYED_BP;
216 typedef struct tagDBG_PROCESS {
217 HANDLE handle;
218 DWORD pid;
219 const char* imageName;
220 DBG_THREAD* threads;
221 int num_threads;
222 unsigned continue_on_first_exception;
223 struct tagDBG_MODULE** modules;
224 int num_modules;
225 unsigned long dbg_hdr_addr;
226 DBG_DELAYED_BP* delayed_bp;
227 int num_delayed_bp;
229 * This is an index we use to keep track of the debug information
230 * when we have multiple sources. We use the same database to also
231 * allow us to do an 'info shared' type of deal, and we use the index
232 * to eliminate duplicates.
234 int next_index;
235 struct tagDBG_PROCESS* next;
236 struct tagDBG_PROCESS* prev;
237 } DBG_PROCESS;
239 extern DBG_PROCESS* DEBUG_CurrProcess;
240 extern DBG_THREAD* DEBUG_CurrThread;
241 extern DWORD DEBUG_CurrTid;
242 extern DWORD DEBUG_CurrPid;
243 extern CONTEXT DEBUG_context;
244 extern BOOL DEBUG_interactiveP;
245 extern enum exit_mode DEBUG_ExitMode;
247 #define DEBUG_READ_MEM(addr, buf, len) \
248 (ReadProcessMemory(DEBUG_CurrProcess->handle, (addr), (buf), (len), NULL))
250 #define DEBUG_WRITE_MEM(addr, buf, len) \
251 (WriteProcessMemory(DEBUG_CurrProcess->handle, (addr), (buf), (len), NULL))
253 #define DEBUG_READ_MEM_VERBOSE(addr, buf, len) \
254 (DEBUG_READ_MEM((addr), (buf), (len)) || (DEBUG_InvalLinAddr( addr ),0))
256 #define DEBUG_WRITE_MEM_VERBOSE(addr, buf, len) \
257 (DEBUG_WRITE_MEM((addr), (buf), (len)) || (DEBUG_InvalLinAddr( addr ),0))
259 enum DbgInfoLoad {DIL_DEFERRED, DIL_LOADED, DIL_NOINFO, DIL_ERROR};
260 enum DbgModuleType {DMT_UNKNOWN, DMT_ELF, DMT_NE, DMT_PE};
262 typedef struct tagDBG_MODULE {
263 void* load_addr;
264 unsigned long size;
265 char* module_name;
266 enum DbgInfoLoad dil;
267 enum DbgModuleType type;
268 unsigned short main : 1;
269 short int dbg_index;
270 HMODULE handle;
271 struct tagMSC_DBG_INFO* msc_info;
272 struct tagELF_DBG_INFO* elf_info;
273 } DBG_MODULE;
275 typedef struct {
276 DWORD val;
277 const char* name;
278 LPDWORD pval;
279 struct datatype* type;
280 } DBG_INTVAR;
282 #define OFFSET_OF(__c,__f) ((int)(((char*)&(((__c*)0)->__f))-((char*)0)))
284 /* from winelib.so */
285 extern void DEBUG_ExternalDebugger(void);
287 /* debugger/break.c */
288 extern void DEBUG_SetBreakpoints( BOOL set );
289 extern void DEBUG_AddBreakpoint( const DBG_VALUE *addr, BOOL (*func)(void) );
290 extern void DEBUG_AddBreakpointFromId( const char *name, int lineno );
291 extern void DEBUG_AddBreakpointFromLineno( int lineno );
292 extern void DEBUG_AddWatchpoint( const DBG_VALUE *addr, int is_write );
293 extern void DEBUG_AddWatchpointFromId( const char *name );
294 extern void DEBUG_CheckDelayedBP( void );
295 extern void DEBUG_DelBreakpoint( int num );
296 extern void DEBUG_EnableBreakpoint( int num, BOOL enable );
297 extern void DEBUG_InfoBreakpoints(void);
298 extern BOOL DEBUG_HandleTrap(void);
299 extern BOOL DEBUG_ShouldContinue( DBG_ADDR* addr, DWORD code, int* count );
300 extern void DEBUG_SuspendExecution( void );
301 extern void DEBUG_RestartExecution( int count );
302 extern BOOL DEBUG_IsFctReturn(void);
303 extern int DEBUG_AddBPCondition(int bpnum, struct expr * exp);
305 /* debugger/db_disasm.c */
306 extern void DEBUG_Disasm( DBG_ADDR *addr, int display );
308 /* debugger/dbg.y */
309 extern void DEBUG_Parser(void);
310 extern void DEBUG_Exit( DWORD );
312 /* debugger/debug.l */
313 extern void DEBUG_FlushSymbols(void);
314 extern char*DEBUG_MakeSymbol(const char*);
315 extern int DEBUG_ReadLine(const char* pfx, char* buffer, int size, int flush_sym, int keep_hist);
317 /* debugger/display.c */
318 extern int DEBUG_DoDisplay(void);
319 extern int DEBUG_AddDisplay(struct expr * exp, int count, char format);
320 extern int DEBUG_DoDisplay(void);
321 extern int DEBUG_DelDisplay(int displaynum);
322 extern int DEBUG_InfoDisplay(void);
324 /* debugger/editline.c */
325 extern char * readline(const char *);
326 extern void add_history(char *);
328 /* debugger/expr.c */
329 extern void DEBUG_FreeExprMem(void);
330 struct expr * DEBUG_IntVarExpr(const char* name);
331 struct expr * DEBUG_SymbolExpr(const char * name);
332 struct expr * DEBUG_ConstExpr(int val);
333 struct expr * DEBUG_StringExpr(const char * str);
334 struct expr * DEBUG_SegAddr(struct expr *, struct expr *);
335 struct expr * DEBUG_USConstExpr(unsigned int val);
336 struct expr * DEBUG_BinopExpr(int oper, struct expr *, struct expr *);
337 struct expr * DEBUG_UnopExpr(int oper, struct expr *);
338 struct expr * DEBUG_StructPExpr(struct expr *, const char * element);
339 struct expr * DEBUG_StructExpr(struct expr *, const char * element);
340 struct expr * DEBUG_ArrayExpr(struct expr *, struct expr * index);
341 struct expr * DEBUG_CallExpr(const char *, int nargs, ...);
342 struct expr * DEBUG_TypeCastExpr(struct datatype *, struct expr *);
343 extern DBG_VALUE DEBUG_EvalExpr(struct expr *);
344 extern int DEBUG_DelDisplay(int displaynum);
345 extern struct expr * DEBUG_CloneExpr(const struct expr * exp);
346 extern int DEBUG_FreeExpr(struct expr * exp);
347 extern int DEBUG_DisplayExpr(const struct expr * exp);
349 /* debugger/hash.c */
350 extern struct name_hash * DEBUG_AddSymbol( const char *name,
351 const DBG_VALUE *addr,
352 const char *sourcefile,
353 int flags);
354 extern int DEBUG_GetSymbolValue( const char * name, const int lineno,
355 DBG_VALUE *addr, int );
356 extern BOOL DEBUG_SetSymbolValue( const char * name, const DBG_VALUE *addr );
357 extern const char * DEBUG_FindNearestSymbol( const DBG_ADDR *addr, int flag,
358 struct name_hash ** rtn,
359 unsigned int ebp,
360 struct list_id * source);
361 extern void DEBUG_ReadSymbolTable( const char * filename );
362 extern void DEBUG_AddLineNumber( struct name_hash * func, int line_num,
363 unsigned long offset );
364 extern struct wine_locals *
365 DEBUG_AddLocal( struct name_hash * func, int regno,
366 int offset,
367 int pc_start,
368 int pc_end,
369 char * name);
370 extern int DEBUG_CheckLinenoStatus(const DBG_ADDR *addr);
371 extern void DEBUG_GetFuncInfo(struct list_id * ret, const char * file,
372 const char * func);
373 extern int DEBUG_SetSymbolSize(struct name_hash * sym, unsigned int len);
374 extern int DEBUG_SetSymbolBPOff(struct name_hash * sym, unsigned int len);
375 extern int DEBUG_GetSymbolAddr(struct name_hash * sym, DBG_ADDR * addr);
376 extern int DEBUG_cmp_sym(const void * p1, const void * p2);
377 extern BOOL DEBUG_GetLineNumberAddr( const struct name_hash *, const int lineno,
378 DBG_ADDR *addr, int bp_flag );
380 extern int DEBUG_SetLocalSymbolType(struct wine_locals * sym,
381 struct datatype * type);
382 extern BOOL DEBUG_Normalize(struct name_hash * nh );
384 /* debugger/info.c */
385 extern void DEBUG_PrintBasic( const DBG_VALUE* value, int count, char format );
386 extern struct symbol_info DEBUG_PrintAddress( const DBG_ADDR *addr,
387 enum dbg_mode mode, int flag );
388 extern void DEBUG_Help(void);
389 extern void DEBUG_HelpInfo(void);
390 extern struct symbol_info DEBUG_PrintAddressAndArgs( const DBG_ADDR *addr,
391 enum dbg_mode mode,
392 unsigned int ebp,
393 int flag );
394 extern void DEBUG_InfoClass(const char* clsName);
395 extern void DEBUG_WalkClasses(void);
396 extern void DEBUG_WalkModref(DWORD p);
397 extern void DEBUG_DumpModule(DWORD mod);
398 extern void DEBUG_WalkModules(void);
399 extern void DEBUG_WalkProcess(void);
400 extern void DEBUG_WalkThreads(void);
401 extern void DEBUG_DumpQueue(DWORD q);
402 extern void DEBUG_WalkQueues(void);
403 extern void DEBUG_InfoSegments(DWORD s, int v);
404 extern void DEBUG_InfoVirtual(void);
405 extern void DEBUG_InfoWindow(HWND hWnd);
406 extern void DEBUG_WalkWindows(HWND hWnd, int indent);
407 extern void DEBUG_DbgChannel(BOOL add, const char* chnl, const char* name);
409 /* debugger/memory.c */
410 extern int DEBUG_ReadMemory( const DBG_VALUE* value );
411 extern void DEBUG_WriteMemory( const DBG_VALUE* val, int value );
412 extern void DEBUG_ExamineMemory( const DBG_VALUE *addr, int count, char format);
413 extern void DEBUG_InvalAddr( const DBG_ADDR* addr );
414 extern void DEBUG_InvalLinAddr( void* addr );
415 extern DWORD DEBUG_ToLinear( const DBG_ADDR *address );
416 extern void DEBUG_GetCurrentAddress( DBG_ADDR * );
417 extern BOOL DEBUG_GrabAddress( DBG_VALUE* value, BOOL fromCode );
418 extern enum dbg_mode DEBUG_GetSelectorType( WORD sel );
419 #ifdef __i386__
420 extern void DEBUG_FixAddress( DBG_ADDR *address, DWORD def );
421 extern int DEBUG_IsSelectorSystem( WORD sel );
422 #endif
423 extern int DEBUG_PrintStringA( int chnl, const DBG_ADDR* address, int len );
424 extern int DEBUG_PrintStringW( int chnl, const DBG_ADDR* address, int len );
426 /* debugger/module.c */
427 extern int DEBUG_LoadEntryPoints( const char * prefix );
428 extern void DEBUG_LoadModule32( const char* name, HANDLE hFile, DWORD base );
429 extern DBG_MODULE* DEBUG_AddModule(const char* name, enum DbgModuleType type,
430 void* mod_addr, u_long size, HMODULE hmod);
431 extern DBG_MODULE* DEBUG_FindModuleByName(const char* name, enum DbgModuleType type);
432 extern DBG_MODULE* DEBUG_FindModuleByHandle(HANDLE handle, enum DbgModuleType type);
433 extern DBG_MODULE* DEBUG_FindModuleByAddr(void* addr, enum DbgModuleType type);
434 extern DBG_MODULE* DEBUG_GetProcessMainModule(DBG_PROCESS* process);
435 extern DBG_MODULE* DEBUG_RegisterPEModule(HMODULE, u_long load_addr, u_long size,
436 const char* name);
437 extern DBG_MODULE* DEBUG_RegisterELFModule(u_long load_addr, u_long size,
438 const char* name);
439 extern enum DbgInfoLoad DEBUG_RegisterPEDebugInfo(DBG_MODULE* wmod, HANDLE hFile,
440 void* _nth, unsigned long nth_ofs);
441 extern void DEBUG_ReportDIL(enum DbgInfoLoad dil, const char* pfx,
442 const char* filename, DWORD load_addr);
443 extern void DEBUG_InfoShare(void);
445 /* debugger/msc.c */
446 extern enum DbgInfoLoad DEBUG_RegisterMSCDebugInfo(DBG_MODULE* module, HANDLE hFile,
447 void* nth, unsigned long nth_ofs);
448 extern enum DbgInfoLoad DEBUG_RegisterStabsDebugInfo(DBG_MODULE* module,
449 HANDLE hFile, void* nth,
450 unsigned long nth_ofs);
451 extern void DEBUG_InitCVDataTypes(void);
453 /* debugger/registers.c */
454 extern void DEBUG_InfoRegisters(void);
455 extern BOOL DEBUG_ValidateRegisters(void);
457 /* debugger/source.c */
458 extern void DEBUG_ShowDir(void);
459 extern void DEBUG_AddPath(const char * path);
460 extern void DEBUG_List(struct list_id * line1, struct list_id * line2,
461 int delta);
462 extern void DEBUG_NukePath(void);
463 extern void DEBUG_Disassemble(const DBG_VALUE *, const DBG_VALUE*, int offset);
464 extern BOOL DEBUG_DisassembleInstruction(DBG_ADDR *addr);
466 /* debugger/stack.c */
467 extern void DEBUG_InfoStack(void);
468 extern void DEBUG_BackTrace(DWORD threadID, BOOL noisy);
469 extern int DEBUG_InfoLocals(void);
470 extern int DEBUG_SetFrame(int newframe);
471 extern int DEBUG_GetCurrentFrame(struct name_hash ** name,
472 unsigned int * eip,
473 unsigned int * ebp);
475 /* debugger/stabs.c */
476 extern enum DbgInfoLoad DEBUG_ReadExecutableDbgInfo(const char* exe_name);
477 extern enum DbgInfoLoad DEBUG_ParseStabs(char * addr, unsigned int load_offset,
478 unsigned int staboff, int stablen,
479 unsigned int strtaboff, int strtablen);
481 /* debugger/types.c */
482 extern int DEBUG_nchar;
483 extern void DEBUG_InitTypes(void);
484 extern struct datatype * DEBUG_NewDataType(enum debug_type xtype,
485 const char * typename);
486 extern unsigned int DEBUG_TypeDerefPointer(const DBG_VALUE *value,
487 struct datatype ** newtype);
488 extern int DEBUG_AddStructElement(struct datatype * dt,
489 char * name, struct datatype * type,
490 int offset, int size);
491 extern int DEBUG_SetStructSize(struct datatype * dt, int size);
492 extern int DEBUG_SetPointerType(struct datatype * dt, struct datatype * dt2);
493 extern int DEBUG_SetArrayParams(struct datatype * dt, int min, int max,
494 struct datatype * dt2);
495 extern void DEBUG_Print( const DBG_VALUE *addr, int count, char format, int level );
496 extern unsigned int DEBUG_FindStructElement(DBG_VALUE * addr,
497 const char * ele_name, int * tmpbuf);
498 extern struct datatype * DEBUG_GetPointerType(struct datatype * dt);
499 extern int DEBUG_GetObjectSize(struct datatype * dt);
500 extern unsigned int DEBUG_ArrayIndex(const DBG_VALUE * addr, DBG_VALUE * result,
501 int index);
502 extern struct datatype * DEBUG_FindOrMakePointerType(struct datatype * reftype);
503 extern long long int DEBUG_GetExprValue(const DBG_VALUE * addr, char ** format);
504 extern int DEBUG_SetBitfieldParams(struct datatype * dt, int offset,
505 int nbits, struct datatype * dt2);
506 extern int DEBUG_CopyFieldlist(struct datatype * dt, struct datatype * dt2);
507 extern enum debug_type DEBUG_GetType(struct datatype * dt);
508 extern struct datatype * DEBUG_TypeCast(enum debug_type, const char *);
509 extern int DEBUG_PrintTypeCast(const struct datatype *);
510 extern int DEBUG_PrintType( const DBG_VALUE* addr );
511 extern struct datatype * DEBUG_GetBasicType(enum debug_type_basic);
513 /* debugger/winedbg.c */
514 #define DBG_CHN_MESG 1
515 #define DBG_CHN_ERR 2
516 #define DBG_CHN_WARN 4
517 #define DBG_CHN_FIXME 8
518 #define DBG_CHN_TRACE 16
519 extern void DEBUG_OutputA(int chn, const char* buffer, int len);
520 extern void DEBUG_OutputW(int chn, const WCHAR* buffer, int len);
521 #ifdef __GNUC__
522 extern int DEBUG_Printf(int chn, const char* format, ...) __attribute__((format (printf,2,3)));
523 #else
524 extern int DEBUG_Printf(int chn, const char* format, ...);
525 #endif
526 extern DBG_INTVAR* DEBUG_GetIntVar(const char*);
527 extern BOOL DEBUG_Attach(DWORD pid, BOOL cofe);
528 extern BOOL DEBUG_Detach(void);
529 extern void DEBUG_Run(const char* args);
530 extern DBG_PROCESS* DEBUG_GetProcess(DWORD pid);
531 extern DBG_THREAD* DEBUG_GetThread(DBG_PROCESS* p, DWORD tid);
532 extern int curr_frame;
533 extern int automatic_mode;
535 /* Choose your allocator! */
536 #if 1
537 /* this one is libc's fast one */
538 extern void* DEBUG_XMalloc(size_t size);
539 extern void* DEBUG_XReAlloc(void *ptr, size_t size);
540 extern char* DEBUG_XStrDup(const char *str);
542 #define DBG_alloc(x) DEBUG_XMalloc(x)
543 #define DBG_realloc(x,y) DEBUG_XReAlloc(x,y)
544 #define DBG_free(x) free(x)
545 #define DBG_strdup(x) DEBUG_XStrDup(x)
546 #else
547 /* this one is slow (takes 5 minutes to load the debugger on my machine),
548 if someone could make optimized routines so it wouldn't
549 take so long to load, it could be made default) */
550 #define DBG_alloc(x) HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,x)
551 #define DBG_realloc(x,y) HeapReAlloc(GetProcessHeap(),0,x,y)
552 #define DBG_free(x) HeapFree(GetProcessHeap(),0,x)
553 inline static LPSTR DBG_strdup( LPCSTR str )
555 INT len = strlen(str) + 1;
556 LPSTR p = DBG_alloc( len );
557 if (p) memcpy( p, str, len );
558 return p;
560 #endif
562 #define DEBUG_STATUS_OFFSET 0x80003000
563 #define DEBUG_STATUS_INTERNAL_ERROR (DEBUG_STATUS_OFFSET+0)
564 #define DEBUG_STATUS_NO_SYMBOL (DEBUG_STATUS_OFFSET+1)
565 #define DEBUG_STATUS_DIV_BY_ZERO (DEBUG_STATUS_OFFSET+2)
566 #define DEBUG_STATUS_BAD_TYPE (DEBUG_STATUS_OFFSET+3)
567 #define DEBUG_STATUS_NO_FIELD (DEBUG_STATUS_OFFSET+4)
569 extern DBG_INTVAR DEBUG_IntVars[];
571 #define DBG_IVARNAME(_var) DEBUG_IV_##_var
572 #define DBG_IVARSTRUCT(_var) DEBUG_IntVars[DBG_IVARNAME(_var)]
573 #define DBG_IVAR(_var) (*(DBG_IVARSTRUCT(_var).pval))
574 #define INTERNAL_VAR(_var,_val,_ref,_typ) DBG_IVARNAME(_var),
575 enum debug_int_var {
576 #include "intvar.h"
577 DBG_IV_LAST
579 #undef INTERNAL_VAR
581 #endif /* __WINE_DEBUGGER_H */