More Escapes for the PostScript driver.
[wine.git] / include / debugger.h
blob82c753121e4e78692e0cc5cfad6806823e55723a
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 "sig_context.h"
13 #include "miscemu.h"
15 #define STEP_FLAG 0x100 /* single step flag */
17 #define SYM_FUNC 0x0
18 #define SYM_DATA 0x1
19 #define SYM_WIN32 0x2
20 #define SYM_WINE 0x4
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;
45 typedef struct
47 struct datatype * type;
48 DWORD seg; /* 0xffffffff means current default segment (cs or ds) */
49 DWORD off;
50 } DBG_ADDR;
52 struct list_id
54 char * sourcefile;
55 int line;
58 struct wine_lines {
59 unsigned long line_number;
60 DBG_ADDR pc_offset;
63 struct symbol_info
65 struct name_hash * sym;
66 struct list_id list;
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
74 * function.
76 struct wine_locals {
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 */
116 #undef REG_SP
117 #endif
119 enum debug_regs
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
129 enum exec_mode
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;
147 /* debugger/break.c */
148 extern void DEBUG_SetBreakpoints( BOOL set );
149 extern int DEBUG_FindBreakpoint( const DBG_ADDR *addr );
150 extern void DEBUG_AddBreakpoint( const DBG_ADDR *addr );
151 extern void DEBUG_DelBreakpoint( int num );
152 extern void DEBUG_EnableBreakpoint( int num, BOOL enable );
153 extern void DEBUG_InfoBreakpoints(void);
154 extern void DEBUG_AddTaskEntryBreakpoint( HTASK16 hTask );
155 extern BOOL DEBUG_HandleTrap(void);
156 extern BOOL DEBUG_ShouldContinue( enum exec_mode mode, int * count );
157 extern enum exec_mode DEBUG_RestartExecution( enum exec_mode mode, int count );
158 extern BOOL DEBUG_IsFctReturn(void);
160 /* debugger/db_disasm.c */
161 extern void DEBUG_Disasm( DBG_ADDR *addr, int display );
163 /* debugger/expr.c */
164 extern void DEBUG_FreeExprMem(void);
165 struct expr * DEBUG_RegisterExpr(enum debug_regs);
166 struct expr * DEBUG_SymbolExpr(const char * name);
167 struct expr * DEBUG_ConstExpr(int val);
168 struct expr * DEBUG_StringExpr(const char * str);
169 struct expr * DEBUG_SegAddr(struct expr *, struct expr *);
170 struct expr * DEBUG_USConstExpr(unsigned int val);
171 struct expr * DEBUG_BinopExpr(int oper, struct expr *, struct expr *);
172 struct expr * DEBUG_UnopExpr(int oper, struct expr *);
173 struct expr * DEBUG_StructPExpr(struct expr *, const char * element);
174 struct expr * DEBUG_StructExpr(struct expr *, const char * element);
175 struct expr * DEBUG_ArrayExpr(struct expr *, struct expr * index);
176 struct expr * DEBUG_CallExpr(const char *, int nargs, ...);
177 struct expr * DEBUG_TypeCastExpr(struct datatype *, struct expr *);
178 extern int DEBUG_ExprValue(DBG_ADDR *, unsigned int *);
179 DBG_ADDR DEBUG_EvalExpr(struct expr *);
180 extern int DEBUG_DelDisplay(int displaynum);
181 extern struct expr * DEBUG_CloneExpr(struct expr * exp);
182 extern int DEBUG_FreeExpr(struct expr * exp);
183 extern int DEBUG_DisplayExpr(struct expr * exp);
185 /* more debugger/break.c */
186 extern int DEBUG_AddBPCondition(int bpnum, struct expr * exp);
188 /* debugger/display.c */
189 extern int DEBUG_DoDisplay(void);
190 extern int DEBUG_AddDisplay(struct expr * exp, int count, char format);
191 extern int DEBUG_DoDisplay(void);
192 extern int DEBUG_DelDisplay(int displaynum);
193 extern int DEBUG_InfoDisplay(void);
195 /* debugger/hash.c */
196 extern struct name_hash * DEBUG_AddSymbol( const char *name,
197 const DBG_ADDR *addr,
198 const char * sourcefile,
199 int flags);
200 extern struct name_hash * DEBUG_AddInvSymbol( const char *name,
201 const DBG_ADDR *addr,
202 const char * sourcefile);
203 extern BOOL DEBUG_GetSymbolValue( const char * name, const int lineno,
204 DBG_ADDR *addr, int );
205 extern BOOL DEBUG_SetSymbolValue( const char * name, const DBG_ADDR *addr );
206 extern const char * DEBUG_FindNearestSymbol( const DBG_ADDR *addr, int flag,
207 struct name_hash ** rtn,
208 unsigned int ebp,
209 struct list_id * source);
210 extern void DEBUG_ReadSymbolTable( const char * filename );
211 extern void DEBUG_LoadEntryPoints(void);
212 extern void DEBUG_AddLineNumber( struct name_hash * func, int line_num,
213 unsigned long offset );
214 extern struct wine_locals *
215 DEBUG_AddLocal( struct name_hash * func, int regno,
216 int offset,
217 int pc_start,
218 int pc_end,
219 char * name);
220 extern int DEBUG_CheckLinenoStatus(const DBG_ADDR *addr);
221 extern void DEBUG_GetFuncInfo(struct list_id * ret, const char * file,
222 const char * func);
223 extern int DEBUG_SetSymbolSize(struct name_hash * sym, unsigned int len);
224 extern int DEBUG_SetSymbolBPOff(struct name_hash * sym, unsigned int len);
225 extern int DEBUG_GetSymbolAddr(struct name_hash * sym, DBG_ADDR * addr);
226 extern int DEBUG_cmp_sym(const void * p1, const void * p2);
227 extern BOOL DEBUG_GetLineNumberAddr( struct name_hash *, const int lineno,
228 DBG_ADDR *addr, int bp_flag );
230 extern int DEBUG_SetLocalSymbolType(struct wine_locals * sym,
231 struct datatype * type);
232 BOOL DEBUG_Normalize(struct name_hash * nh );
234 /* debugger/info.c */
235 extern void DEBUG_PrintBasic( const DBG_ADDR *addr, int count, char format );
236 extern struct symbol_info DEBUG_PrintAddress( const DBG_ADDR *addr,
237 int addrlen, int flag );
238 extern void DEBUG_Help(void);
239 extern void DEBUG_HelpInfo(void);
240 extern struct symbol_info DEBUG_PrintAddressAndArgs( const DBG_ADDR *addr,
241 int addrlen,
242 unsigned int ebp,
243 int flag );
245 /* debugger/memory.c */
246 extern BOOL DEBUG_IsBadReadPtr( const DBG_ADDR *address, int size );
247 extern BOOL DEBUG_IsBadWritePtr( const DBG_ADDR *address, int size );
248 extern int DEBUG_ReadMemory( const DBG_ADDR *address );
249 extern void DEBUG_WriteMemory( const DBG_ADDR *address, int value );
250 extern void DEBUG_ExamineMemory( const DBG_ADDR *addr, int count, char format);
252 /* debugger/registers.c */
253 extern void DEBUG_SetRegister( enum debug_regs reg, int val );
254 extern int DEBUG_GetRegister( enum debug_regs reg );
255 extern void DEBUG_InfoRegisters(void);
256 extern BOOL DEBUG_ValidateRegisters(void);
257 extern void DEBUG_SetSigContext( const SIGCONTEXT *sigcontext );
258 extern void DEBUG_GetSigContext( SIGCONTEXT *sigcontext );
259 extern int DEBUG_PrintRegister(enum debug_regs reg);
261 /* debugger/stack.c */
262 extern void DEBUG_InfoStack(void);
263 extern void DEBUG_BackTrace(void);
264 extern void DEBUG_SilentBackTrace(void);
265 extern int DEBUG_InfoLocals(void);
266 extern int DEBUG_SetFrame(int newframe);
267 extern int DEBUG_GetCurrentFrame(struct name_hash ** name,
268 unsigned int * eip,
269 unsigned int * ebp);
271 /* debugger/stabs.c */
272 extern int DEBUG_ReadExecutableDbgInfo(void);
273 extern int DEBUG_ParseStabs(char * addr, unsigned int load_offset, unsigned int staboff, int stablen, unsigned int strtaboff, int strtablen);
275 /* debugger/msc.c */
276 extern int DEBUG_RegisterDebugInfo( HMODULE, const char *);
277 extern int DEBUG_ProcessDeferredDebug(void);
278 extern int DEBUG_RegisterELFDebugInfo(int load_addr, u_long size, char * name);
279 extern void DEBUG_InfoShare(void);
280 extern void DEBUG_InitCVDataTypes(void);
282 /* debugger/types.c */
283 extern int DEBUG_nchar;
284 extern void DEBUG_InitTypes(void);
285 extern struct datatype * DEBUG_NewDataType(enum debug_type xtype,
286 const char * typename);
287 extern unsigned int
288 DEBUG_TypeDerefPointer(DBG_ADDR * addr, struct datatype ** newtype);
289 extern int DEBUG_AddStructElement(struct datatype * dt,
290 char * name, struct datatype * type,
291 int offset, int size);
292 extern int DEBUG_SetStructSize(struct datatype * dt, int size);
293 extern int DEBUG_SetPointerType(struct datatype * dt, struct datatype * dt2);
294 extern int DEBUG_SetArrayParams(struct datatype * dt, int min, int max,
295 struct datatype * dt2);
296 extern void DEBUG_Print( const DBG_ADDR *addr, int count, char format, int level );
297 extern unsigned int DEBUG_FindStructElement(DBG_ADDR * addr,
298 const char * ele_name, int * tmpbuf);
299 extern struct datatype * DEBUG_GetPointerType(struct datatype * dt);
300 extern int DEBUG_GetObjectSize(struct datatype * dt);
301 extern unsigned int DEBUG_ArrayIndex(DBG_ADDR * addr, DBG_ADDR * result, int index);
302 extern struct datatype * DEBUG_FindOrMakePointerType(struct datatype * reftype);
303 extern long long int DEBUG_GetExprValue(DBG_ADDR * addr, char ** format);
304 extern int DEBUG_SetBitfieldParams(struct datatype * dt, int offset,
305 int nbits, struct datatype * dt2);
306 extern int DEBUG_CopyFieldlist(struct datatype * dt, struct datatype * dt2);
307 extern enum debug_type DEBUG_GetType(struct datatype * dt);
308 extern struct datatype * DEBUG_TypeCast(enum debug_type, const char *);
309 extern int DEBUG_PrintTypeCast(struct datatype *);
311 /* debugger/source.c */
312 extern void DEBUG_ShowDir(void);
313 extern void DEBUG_AddPath(const char * path);
314 extern void DEBUG_List(struct list_id * line1, struct list_id * line2,
315 int delta);
316 extern void DEBUG_NukePath(void);
317 extern void DEBUG_Disassemble( const DBG_ADDR *, const DBG_ADDR*, int offset );
319 /* debugger/dbg.y */
320 extern void ctx_debug( int signal, CONTEXT *regs );
321 extern void wine_debug( int signal, SIGCONTEXT *regs );
323 /* miscemu/instr.c */
324 extern BOOL INSTR_EmulateInstruction( SIGCONTEXT* );
326 /* loader/signal.c */
327 extern void (*fnWINE_Debugger)(int,SIGCONTEXT*);
328 extern void (*ctx_debug_call)( int, CONTEXT* );
329 extern BOOL (*fnINSTR_EmulateInstruction)( SIGCONTEXT* );
332 #endif /* __WINE_DEBUGGER_H */