4 * Copyright 1995 Alexandre Julliard
7 #ifndef __WINE_DEBUGGER_H
8 #define __WINE_DEBUGGER_H
10 #include <sys/types.h> /* u_long ... */
12 #include "sig_context.h"
15 #define STEP_FLAG 0x100 /* single step flag */
21 #define SYM_INVALID 0x8
22 #define SYM_TRAMPOLINE 0x10
23 #define SYM_STEP_THROUGH 0x20
25 enum debug_type {DT_BASIC, DT_CONST, DT_POINTER, DT_ARRAY, DT_STRUCT, DT_ENUM, DT_TYPEDEF, DT_FUNC, DT_BITFIELD};
29 * Return values for DEBUG_CheckLinenoStatus. Used to determine
30 * what to do when the 'step' command is given.
32 #define FUNC_HAS_NO_LINES (0)
33 #define NOT_ON_LINENUMBER (1)
34 #define AT_LINENUMBER (2)
35 #define FUNC_IS_TRAMPOLINE (3)
38 * For constants generated by the parser, we use this datatype
40 extern struct datatype * DEBUG_TypeInt;
41 extern struct datatype * DEBUG_TypeIntConst;
42 extern struct datatype * DEBUG_TypeUSInt;
43 extern struct datatype * DEBUG_TypeString;
47 struct datatype * type;
48 DWORD seg; /* 0xffffffff means current default segment (cs or ds) */
59 unsigned long line_number;
65 struct name_hash * sym;
69 typedef struct wine_lines WineLineNo;
72 * This structure holds information about stack variables, function
73 * parameters, and register variables, which are all local to this
77 unsigned int regno:8; /* For register symbols */
78 signed int offset:24; /* offset from esp/ebp to symbol */
79 unsigned int pc_start; /* For RBRAC/LBRAC */
80 unsigned int pc_end; /* For RBRAC/LBRAC */
81 char * name; /* Name of symbol */
82 struct datatype * type; /* Datatype of symbol */
85 typedef struct wine_locals WineLocals;
88 #define DBG_V86_MODULE(seg) ((seg)>>16)
89 #define IS_SELECTOR_V86(seg) DBG_V86_MODULE(seg)
91 #define DBG_FIX_ADDR_SEG(addr,default) { \
92 if ((addr)->seg == 0xffffffff) (addr)->seg = (default); \
93 if (!IS_SELECTOR_V86((addr)->seg)) \
94 if (IS_SELECTOR_SYSTEM((addr)->seg)) (addr)->seg = 0; }
96 #define DBG_ADDR_TO_LIN(addr) \
97 (IS_SELECTOR_V86((addr)->seg) \
98 ? (char*)(DOSMEM_MemoryBase(DBG_V86_MODULE((addr)->seg)) + \
99 ((((addr)->seg)&0xFFFF)<<4)+(addr)->off) : \
100 (IS_SELECTOR_SYSTEM((addr)->seg) ? (char *)(addr)->off \
101 : (char *)PTR_SEG_OFF_TO_LIN((addr)->seg,(addr)->off)))
103 #define DBG_CHECK_READ_PTR(addr,len) \
104 (!DEBUG_IsBadReadPtr((addr),(len)) || \
105 (fprintf(stderr,"*** Invalid address "), \
106 DEBUG_PrintAddress((addr),dbg_mode, FALSE), \
107 fprintf(stderr,"\n"),0))
109 #define DBG_CHECK_WRITE_PTR(addr,len) \
110 (!DEBUG_IsBadWritePtr((addr),(len)) || \
111 (fprintf(stderr,"*** Invalid address "), \
112 DEBUG_PrintAddress(addr,dbg_mode, FALSE), \
113 fprintf(stderr,"\n"),0))
115 #ifdef REG_SP /* Some Sun includes define this */
121 REG_EAX, REG_EBX, REG_ECX, REG_EDX, REG_ESI,
122 REG_EDI, REG_EBP, REG_EFL, REG_EIP, REG_ESP,
123 REG_AX, REG_BX, REG_CX, REG_DX, REG_SI,
124 REG_DI, REG_BP, REG_FL, REG_IP, REG_SP,
125 REG_CS, REG_DS, REG_ES, REG_SS, REG_FS, REG_GS
131 EXEC_CONT, /* Continuous execution */
132 EXEC_STEP_OVER, /* Stepping over a call to next source line */
133 EXEC_STEP_INSTR, /* Step to next source line, stepping in if needed */
134 EXEC_STEPI_OVER, /* Stepping over a call */
135 EXEC_STEPI_INSTR, /* Single-stepping an instruction */
136 EXEC_FINISH, /* Step until we exit current frame */
137 EXEC_STEP_OVER_TRAMPOLINE /* Step over trampoline. Requires that
138 * we dig the real return value off the stack
139 * and set breakpoint there - not at the
140 * instr just after the call.
144 extern CONTEXT DEBUG_context; /* debugger/registers.c */
145 extern unsigned int dbg_mode;
146 extern HANDLE dbg_heap;
148 /* debugger/break.c */
149 extern void DEBUG_SetBreakpoints( BOOL set );
150 extern int DEBUG_FindBreakpoint( const DBG_ADDR *addr );
151 extern void DEBUG_AddBreakpoint( const DBG_ADDR *addr );
152 extern void DEBUG_DelBreakpoint( int num );
153 extern void DEBUG_EnableBreakpoint( int num, BOOL enable );
154 extern void DEBUG_InfoBreakpoints(void);
155 extern void DEBUG_AddTaskEntryBreakpoint( HTASK16 hTask );
156 extern BOOL DEBUG_HandleTrap(void);
157 extern BOOL DEBUG_ShouldContinue( enum exec_mode mode, int * count );
158 extern enum exec_mode DEBUG_RestartExecution( enum exec_mode mode, int count );
159 extern BOOL DEBUG_IsFctReturn(void);
161 /* debugger/db_disasm.c */
162 extern void DEBUG_Disasm( DBG_ADDR *addr, int display );
164 /* debugger/expr.c */
165 extern void DEBUG_FreeExprMem(void);
166 struct expr * DEBUG_RegisterExpr(enum debug_regs);
167 struct expr * DEBUG_SymbolExpr(const char * name);
168 struct expr * DEBUG_ConstExpr(int val);
169 struct expr * DEBUG_StringExpr(const char * str);
170 struct expr * DEBUG_SegAddr(struct expr *, struct expr *);
171 struct expr * DEBUG_USConstExpr(unsigned int val);
172 struct expr * DEBUG_BinopExpr(int oper, struct expr *, struct expr *);
173 struct expr * DEBUG_UnopExpr(int oper, struct expr *);
174 struct expr * DEBUG_StructPExpr(struct expr *, const char * element);
175 struct expr * DEBUG_StructExpr(struct expr *, const char * element);
176 struct expr * DEBUG_ArrayExpr(struct expr *, struct expr * index);
177 struct expr * DEBUG_CallExpr(const char *, int nargs, ...);
178 struct expr * DEBUG_TypeCastExpr(struct datatype *, struct expr *);
179 extern int DEBUG_ExprValue(DBG_ADDR *, unsigned int *);
180 DBG_ADDR DEBUG_EvalExpr(struct expr *);
181 extern int DEBUG_DelDisplay(int displaynum);
182 extern struct expr * DEBUG_CloneExpr(struct expr * exp);
183 extern int DEBUG_FreeExpr(struct expr * exp);
184 extern int DEBUG_DisplayExpr(struct expr * exp);
186 /* more debugger/break.c */
187 extern int DEBUG_AddBPCondition(int bpnum, struct expr * exp);
189 /* debugger/display.c */
190 extern int DEBUG_DoDisplay(void);
191 extern int DEBUG_AddDisplay(struct expr * exp, int count, char format);
192 extern int DEBUG_DoDisplay(void);
193 extern int DEBUG_DelDisplay(int displaynum);
194 extern int DEBUG_InfoDisplay(void);
196 /* debugger/hash.c */
197 extern struct name_hash * DEBUG_AddSymbol( const char *name,
198 const DBG_ADDR *addr,
199 const char * sourcefile,
201 extern struct name_hash * DEBUG_AddInvSymbol( const char *name,
202 const DBG_ADDR *addr,
203 const char * sourcefile);
204 extern BOOL DEBUG_GetSymbolValue( const char * name, const int lineno,
205 DBG_ADDR *addr, int );
206 extern BOOL DEBUG_SetSymbolValue( const char * name, const DBG_ADDR *addr );
207 extern const char * DEBUG_FindNearestSymbol( const DBG_ADDR *addr, int flag,
208 struct name_hash ** rtn,
210 struct list_id * source);
211 extern void DEBUG_ReadSymbolTable( const char * filename );
212 extern void DEBUG_LoadEntryPoints(void);
213 extern void DEBUG_AddLineNumber( struct name_hash * func, int line_num,
214 unsigned long offset );
215 extern struct wine_locals *
216 DEBUG_AddLocal( struct name_hash * func, int regno,
221 extern int DEBUG_CheckLinenoStatus(const DBG_ADDR *addr);
222 extern void DEBUG_GetFuncInfo(struct list_id * ret, const char * file,
224 extern int DEBUG_SetSymbolSize(struct name_hash * sym, unsigned int len);
225 extern int DEBUG_SetSymbolBPOff(struct name_hash * sym, unsigned int len);
226 extern int DEBUG_GetSymbolAddr(struct name_hash * sym, DBG_ADDR * addr);
227 extern int DEBUG_cmp_sym(const void * p1, const void * p2);
228 extern BOOL DEBUG_GetLineNumberAddr( struct name_hash *, const int lineno,
229 DBG_ADDR *addr, int bp_flag );
231 extern int DEBUG_SetLocalSymbolType(struct wine_locals * sym,
232 struct datatype * type);
233 BOOL DEBUG_Normalize(struct name_hash * nh );
235 /* debugger/info.c */
236 extern void DEBUG_PrintBasic( const DBG_ADDR *addr, int count, char format );
237 extern struct symbol_info DEBUG_PrintAddress( const DBG_ADDR *addr,
238 int addrlen, int flag );
239 extern void DEBUG_Help(void);
240 extern void DEBUG_HelpInfo(void);
241 extern struct symbol_info DEBUG_PrintAddressAndArgs( const DBG_ADDR *addr,
246 /* debugger/memory.c */
247 extern BOOL DEBUG_IsBadReadPtr( const DBG_ADDR *address, int size );
248 extern BOOL DEBUG_IsBadWritePtr( const DBG_ADDR *address, int size );
249 extern int DEBUG_ReadMemory( const DBG_ADDR *address );
250 extern void DEBUG_WriteMemory( const DBG_ADDR *address, int value );
251 extern void DEBUG_ExamineMemory( const DBG_ADDR *addr, int count, char format);
253 /* debugger/registers.c */
254 extern void DEBUG_SetRegister( enum debug_regs reg, int val );
255 extern int DEBUG_GetRegister( enum debug_regs reg );
256 extern void DEBUG_InfoRegisters(void);
257 extern BOOL DEBUG_ValidateRegisters(void);
258 extern void DEBUG_SetSigContext( const SIGCONTEXT *sigcontext );
259 extern void DEBUG_GetSigContext( SIGCONTEXT *sigcontext );
260 extern int DEBUG_PrintRegister(enum debug_regs reg);
262 /* debugger/stack.c */
263 extern void DEBUG_InfoStack(void);
264 extern void DEBUG_BackTrace(void);
265 extern void DEBUG_SilentBackTrace(void);
266 extern int DEBUG_InfoLocals(void);
267 extern int DEBUG_SetFrame(int newframe);
268 extern int DEBUG_GetCurrentFrame(struct name_hash ** name,
272 /* debugger/stabs.c */
273 extern int DEBUG_ReadExecutableDbgInfo(void);
274 extern int DEBUG_ParseStabs(char * addr, unsigned int load_offset, unsigned int staboff, int stablen, unsigned int strtaboff, int strtablen);
277 extern int DEBUG_RegisterDebugInfo( HMODULE, const char *);
278 extern int DEBUG_ProcessDeferredDebug(void);
279 extern int DEBUG_RegisterELFDebugInfo(int load_addr, u_long size, char * name);
280 extern void DEBUG_InfoShare(void);
281 extern void DEBUG_InitCVDataTypes(void);
283 /* debugger/types.c */
284 extern int DEBUG_nchar;
285 extern void DEBUG_InitTypes(void);
286 extern struct datatype * DEBUG_NewDataType(enum debug_type xtype,
287 const char * typename);
289 DEBUG_TypeDerefPointer(DBG_ADDR * addr, struct datatype ** newtype);
290 extern int DEBUG_AddStructElement(struct datatype * dt,
291 char * name, struct datatype * type,
292 int offset, int size);
293 extern int DEBUG_SetStructSize(struct datatype * dt, int size);
294 extern int DEBUG_SetPointerType(struct datatype * dt, struct datatype * dt2);
295 extern int DEBUG_SetArrayParams(struct datatype * dt, int min, int max,
296 struct datatype * dt2);
297 extern void DEBUG_Print( const DBG_ADDR *addr, int count, char format, int level );
298 extern unsigned int DEBUG_FindStructElement(DBG_ADDR * addr,
299 const char * ele_name, int * tmpbuf);
300 extern struct datatype * DEBUG_GetPointerType(struct datatype * dt);
301 extern int DEBUG_GetObjectSize(struct datatype * dt);
302 extern unsigned int DEBUG_ArrayIndex(DBG_ADDR * addr, DBG_ADDR * result, int index);
303 extern struct datatype * DEBUG_FindOrMakePointerType(struct datatype * reftype);
304 extern long long int DEBUG_GetExprValue(DBG_ADDR * addr, char ** format);
305 extern int DEBUG_SetBitfieldParams(struct datatype * dt, int offset,
306 int nbits, struct datatype * dt2);
307 extern int DEBUG_CopyFieldlist(struct datatype * dt, struct datatype * dt2);
308 extern enum debug_type DEBUG_GetType(struct datatype * dt);
309 extern struct datatype * DEBUG_TypeCast(enum debug_type, const char *);
310 extern int DEBUG_PrintTypeCast(struct datatype *);
312 /* debugger/source.c */
313 extern void DEBUG_ShowDir(void);
314 extern void DEBUG_AddPath(const char * path);
315 extern void DEBUG_List(struct list_id * line1, struct list_id * line2,
317 extern void DEBUG_NukePath(void);
318 extern void DEBUG_Disassemble( const DBG_ADDR *, const DBG_ADDR*, int offset );
321 extern void ctx_debug( int signal, CONTEXT *regs );
322 extern void wine_debug( int signal, SIGCONTEXT *regs );
324 /* miscemu/instr.c */
325 extern BOOL INSTR_EmulateInstruction( SIGCONTEXT* );
327 /* loader/signal.c */
328 extern void (*fnWINE_Debugger)(int,SIGCONTEXT*);
329 extern void (*ctx_debug_call)( int, CONTEXT* );
330 extern BOOL (*fnINSTR_EmulateInstruction)( SIGCONTEXT* );
332 /* Choose your allocator! */
334 /* this one is libc's fast one */
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)
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) */
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
354 #endif /* __WINE_DEBUGGER_H */