Release 970914
[wine.git] / include / debugger.h
blob91173735d1635b7fa63fee0aa4abd30345de904b
1 /*
2 * Debugger definitions
4 * Copyright 1995 Alexandre Julliard
5 */
7 #ifndef __WINE_DEBUGGER_H
8 #define __WINE_DEBUGGER_H
10 #include "winnt.h"
11 #include "selectors.h"
12 #include "sig_context.h"
13 #include "pe_image.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 {BASIC, CONST, POINTER, ARRAY, STRUCT, ENUM, TYPEDEF, FUNC, 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_FIX_ADDR_SEG(addr,default) \
89 { if ((addr)->seg == 0xffffffff) (addr)->seg = (default); \
90 if (((addr)->seg == WINE_CODE_SELECTOR) || \
91 (addr)->seg == WINE_DATA_SELECTOR) (addr)->seg = 0; }
93 #define DBG_ADDR_TO_LIN(addr) \
94 ((addr)->seg ? (char *)PTR_SEG_OFF_TO_LIN((addr)->seg,(addr)->off) \
95 : (char *)(addr)->off)
97 #define DBG_CHECK_READ_PTR(addr,len) \
98 (!DEBUG_IsBadReadPtr((addr),(len)) || \
99 (fprintf(stderr,"*** Invalid address "), \
100 DEBUG_PrintAddress((addr),dbg_mode, FALSE), \
101 fprintf(stderr,"\n"),0))
103 #define DBG_CHECK_WRITE_PTR(addr,len) \
104 (!DEBUG_IsBadWritePtr((addr),(len)) || \
105 (fprintf(stderr,"*** Invalid address "), \
106 DEBUG_PrintAddress(addr,dbg_mode, FALSE), \
107 fprintf(stderr,"\n"),0))
109 #ifdef REG_SP /* Some Sun includes define this */
110 #undef REG_SP
111 #endif
113 enum debug_regs
115 REG_EAX, REG_EBX, REG_ECX, REG_EDX, REG_ESI,
116 REG_EDI, REG_EBP, REG_EFL, REG_EIP, REG_ESP,
117 REG_AX, REG_BX, REG_CX, REG_DX, REG_SI,
118 REG_DI, REG_BP, REG_FL, REG_IP, REG_SP,
119 REG_CS, REG_DS, REG_ES, REG_SS, REG_FS, REG_GS
123 enum exec_mode
125 EXEC_CONT, /* Continuous execution */
126 EXEC_STEP_OVER, /* Stepping over a call to next source line */
127 EXEC_STEP_INSTR, /* Step to next source line, stepping in if needed */
128 EXEC_STEPI_OVER, /* Stepping over a call */
129 EXEC_STEPI_INSTR, /* Single-stepping an instruction */
130 EXEC_FINISH, /* Step until we exit current frame */
131 EXEC_STEP_OVER_TRAMPOLINE /* Step over trampoline. Requires that
132 * we dig the real return value off the stack
133 * and set breakpoint there - not at the
134 * instr just after the call.
138 extern CONTEXT DEBUG_context; /* debugger/registers.c */
139 extern unsigned int dbg_mode;
141 /* debugger/break.c */
142 extern void DEBUG_SetBreakpoints( BOOL32 set );
143 extern int DEBUG_FindBreakpoint( const DBG_ADDR *addr );
144 extern void DEBUG_AddBreakpoint( const DBG_ADDR *addr );
145 extern void DEBUG_DelBreakpoint( int num );
146 extern void DEBUG_EnableBreakpoint( int num, BOOL32 enable );
147 extern void DEBUG_InfoBreakpoints(void);
148 extern BOOL32 DEBUG_HandleTrap(void);
149 extern BOOL32 DEBUG_ShouldContinue( enum exec_mode mode, int * count );
150 extern enum exec_mode DEBUG_RestartExecution( enum exec_mode mode, int count );
151 extern BOOL32 DEBUG_IsFctReturn(void);
153 /* debugger/db_disasm.c */
154 extern void DEBUG_Disasm( DBG_ADDR *addr, int display );
156 /* debugger/expr.c */
157 extern void DEBUG_FreeExprMem(void);
158 struct expr * DEBUG_RegisterExpr(enum debug_regs);
159 struct expr * DEBUG_SymbolExpr(const char * name);
160 struct expr * DEBUG_ConstExpr(int val);
161 struct expr * DEBUG_StringExpr(const char * str);
162 struct expr * DEBUG_SegAddr(struct expr *, struct expr *);
163 struct expr * DEBUG_USConstExpr(unsigned int val);
164 struct expr * DEBUG_BinopExpr(int oper, struct expr *, struct expr *);
165 struct expr * DEBUG_UnopExpr(int oper, struct expr *);
166 struct expr * DEBUG_StructPExpr(struct expr *, const char * element);
167 struct expr * DEBUG_StructExpr(struct expr *, const char * element);
168 struct expr * DEBUG_ArrayExpr(struct expr *, struct expr * index);
169 struct expr * DEBUG_CallExpr(const char *, int nargs, ...);
170 struct expr * DEBUG_TypeCastExpr(struct datatype *, struct expr *);
171 extern int DEBUG_ExprValue(DBG_ADDR *, unsigned int *);
172 DBG_ADDR DEBUG_EvalExpr(struct expr *);
173 extern int DEBUG_DelDisplay(int displaynum);
174 extern struct expr * DEBUG_CloneExpr(struct expr * exp);
175 extern int DEBUG_FreeExpr(struct expr * exp);
176 extern int DEBUG_DisplayExpr(struct expr * exp);
178 /* more debugger/break.c */
179 extern int DEBUG_AddBPCondition(int bpnum, struct expr * exp);
181 /* debugger/display.c */
182 extern int DEBUG_DoDisplay(void);
183 extern int DEBUG_AddDisplay(struct expr * exp, int count, char format);
184 extern int DEBUG_DoDisplay(void);
185 extern int DEBUG_DelDisplay(int displaynum);
186 extern int DEBUG_InfoDisplay(void);
188 /* debugger/hash.c */
189 extern struct name_hash * DEBUG_AddSymbol( const char *name,
190 const DBG_ADDR *addr,
191 const char * sourcefile,
192 int flags);
193 extern struct name_hash * DEBUG_AddInvSymbol( const char *name,
194 const DBG_ADDR *addr,
195 const char * sourcefile);
196 extern BOOL32 DEBUG_GetSymbolValue( const char * name, const int lineno,
197 DBG_ADDR *addr, int );
198 extern BOOL32 DEBUG_SetSymbolValue( const char * name, const DBG_ADDR *addr );
199 extern const char * DEBUG_FindNearestSymbol( const DBG_ADDR *addr, int flag,
200 struct name_hash ** rtn,
201 unsigned int ebp,
202 struct list_id * source);
203 extern void DEBUG_ReadSymbolTable( const char * filename );
204 extern void DEBUG_LoadEntryPoints(void);
205 extern void DEBUG_AddLineNumber( struct name_hash * func, int line_num,
206 unsigned long offset );
207 extern struct wine_locals *
208 DEBUG_AddLocal( struct name_hash * func, int regno,
209 int offset,
210 int pc_start,
211 int pc_end,
212 char * name);
213 extern int DEBUG_CheckLinenoStatus(const DBG_ADDR *addr);
214 extern void DEBUG_GetFuncInfo(struct list_id * ret, const char * file,
215 const char * func);
216 extern int DEBUG_SetSymbolSize(struct name_hash * sym, unsigned int len);
217 extern int DEBUG_SetSymbolBPOff(struct name_hash * sym, unsigned int len);
218 extern int DEBUG_GetSymbolAddr(struct name_hash * sym, DBG_ADDR * addr);
219 extern int DEBUG_cmp_sym(const void * p1, const void * p2);
220 extern BOOL32 DEBUG_GetLineNumberAddr( struct name_hash *, const int lineno,
221 DBG_ADDR *addr, int bp_flag );
223 extern int DEBUG_SetLocalSymbolType(struct wine_locals * sym,
224 struct datatype * type);
225 BOOL32 DEBUG_Normalize(struct name_hash * nh );
227 /* debugger/info.c */
228 extern void DEBUG_PrintBasic( const DBG_ADDR *addr, int count, char format );
229 extern struct symbol_info DEBUG_PrintAddress( const DBG_ADDR *addr,
230 int addrlen, int flag );
231 extern void DEBUG_Help(void);
232 extern void DEBUG_HelpInfo(void);
233 extern struct symbol_info DEBUG_PrintAddressAndArgs( const DBG_ADDR *addr,
234 int addrlen,
235 unsigned int ebp,
236 int flag );
238 /* debugger/memory.c */
239 extern BOOL32 DEBUG_IsBadReadPtr( const DBG_ADDR *address, int size );
240 extern BOOL32 DEBUG_IsBadWritePtr( const DBG_ADDR *address, int size );
241 extern int DEBUG_ReadMemory( const DBG_ADDR *address );
242 extern void DEBUG_WriteMemory( const DBG_ADDR *address, int value );
243 extern void DEBUG_ExamineMemory( const DBG_ADDR *addr, int count, char format);
245 /* debugger/registers.c */
246 extern void DEBUG_SetRegister( enum debug_regs reg, int val );
247 extern int DEBUG_GetRegister( enum debug_regs reg );
248 extern void DEBUG_InfoRegisters(void);
249 extern BOOL32 DEBUG_ValidateRegisters(void);
250 extern void DEBUG_SetSigContext( const SIGCONTEXT *sigcontext );
251 extern void DEBUG_GetSigContext( SIGCONTEXT *sigcontext );
252 extern int DEBUG_PrintRegister(enum debug_regs reg);
254 /* debugger/stack.c */
255 extern void DEBUG_InfoStack(void);
256 extern void DEBUG_BackTrace(void);
257 extern void DEBUG_SilentBackTrace(void);
258 extern int DEBUG_InfoLocals(void);
259 extern int DEBUG_SetFrame(int newframe);
260 extern int DEBUG_GetCurrentFrame(struct name_hash ** name,
261 unsigned int * eip,
262 unsigned int * ebp);
264 /* debugger/stabs.c */
265 extern int DEBUG_ReadExecutableDbgInfo(void);
267 /* debugger/msc.c */
268 extern int DEBUG_RegisterDebugInfo(struct pe_data *pe,
269 int, unsigned long, unsigned long);
270 extern int DEBUG_ProcessDeferredDebug(void);
271 extern int DEBUG_RegisterELFDebugInfo(int load_addr, u_long size, char * name);
272 extern void DEBUG_InfoShare(void);
273 extern void DEBUG_InitCVDataTypes(void);
275 /* debugger/types.c */
276 extern int DEBUG_nchar;
277 extern void DEBUG_InitTypes(void);
278 extern struct datatype * DEBUG_NewDataType(enum debug_type xtype,
279 const char * typename);
280 extern unsigned int
281 DEBUG_TypeDerefPointer(DBG_ADDR * addr, struct datatype ** newtype);
282 extern int DEBUG_AddStructElement(struct datatype * dt,
283 char * name, struct datatype * type,
284 int offset, int size);
285 extern int DEBUG_SetStructSize(struct datatype * dt, int size);
286 extern int DEBUG_SetPointerType(struct datatype * dt, struct datatype * dt2);
287 extern int DEBUG_SetArrayParams(struct datatype * dt, int min, int max,
288 struct datatype * dt2);
289 extern void DEBUG_Print( const DBG_ADDR *addr, int count, char format, int level );
290 extern unsigned int DEBUG_FindStructElement(DBG_ADDR * addr,
291 const char * ele_name, int * tmpbuf);
292 extern struct datatype * DEBUG_GetPointerType(struct datatype * dt);
293 extern int DEBUG_GetObjectSize(struct datatype * dt);
294 extern unsigned int DEBUG_ArrayIndex(DBG_ADDR * addr, DBG_ADDR * result, int index);
295 extern struct datatype * DEBUG_FindOrMakePointerType(struct datatype * reftype);
296 extern long long int DEBUG_GetExprValue(DBG_ADDR * addr, char ** format);
297 extern int DEBUG_SetBitfieldParams(struct datatype * dt, int offset,
298 int nbits, struct datatype * dt2);
299 extern int DEBUG_CopyFieldlist(struct datatype * dt, struct datatype * dt2);
300 extern enum debug_type DEBUG_GetType(struct datatype * dt);
301 extern struct datatype * DEBUG_TypeCast(enum debug_type, const char *);
302 extern int DEBUG_PrintTypeCast(struct datatype *);
304 /* debugger/source.c */
305 extern void DEBUG_ShowDir(void);
306 extern void DEBUG_AddPath(const char * path);
307 extern void DEBUG_List(struct list_id * line1, struct list_id * line2,
308 int delta);
309 extern void DEBUG_NukePath(void);
310 extern void DEBUG_Disassemble( const DBG_ADDR *, const DBG_ADDR*, int offset );
312 /* debugger/dbg.y */
313 extern void wine_debug( int signal, SIGCONTEXT *regs );
315 #endif /* __WINE_DEBUGGER_H */