4 * Copyright 1995 Alexandre Julliard
7 #ifndef __WINE_DEBUGGER_H
8 #define __WINE_DEBUGGER_H
11 #include "selectors.h"
12 #include "sig_context.h"
16 #define STEP_FLAG 0x100 /* single step flag */
22 #define SYM_INVALID 0x8
23 #define SYM_TRAMPOLINE 0x10
24 #define SYM_STEP_THROUGH 0x20
26 enum debug_type
{DT_BASIC
, DT_CONST
, DT_POINTER
, DT_ARRAY
, DT_STRUCT
, DT_ENUM
, DT_TYPEDEF
, DT_FUNC
, DT_BITFIELD
};
30 * Return values for DEBUG_CheckLinenoStatus. Used to determine
31 * what to do when the 'step' command is given.
33 #define FUNC_HAS_NO_LINES (0)
34 #define NOT_ON_LINENUMBER (1)
35 #define AT_LINENUMBER (2)
36 #define FUNC_IS_TRAMPOLINE (3)
39 * For constants generated by the parser, we use this datatype
41 extern struct datatype
* DEBUG_TypeInt
;
42 extern struct datatype
* DEBUG_TypeIntConst
;
43 extern struct datatype
* DEBUG_TypeUSInt
;
44 extern struct datatype
* DEBUG_TypeString
;
48 struct datatype
* type
;
49 DWORD seg
; /* 0xffffffff means current default segment (cs or ds) */
60 unsigned long line_number
;
66 struct name_hash
* sym
;
70 typedef struct wine_lines WineLineNo
;
73 * This structure holds information about stack variables, function
74 * parameters, and register variables, which are all local to this
78 unsigned int regno
:8; /* For register symbols */
79 signed int offset
:24; /* offset from esp/ebp to symbol */
80 unsigned int pc_start
; /* For RBRAC/LBRAC */
81 unsigned int pc_end
; /* For RBRAC/LBRAC */
82 char * name
; /* Name of symbol */
83 struct datatype
* type
; /* Datatype of symbol */
86 typedef struct wine_locals WineLocals
;
89 #define DBG_V86_MODULE(seg) ((seg)>>16)
90 #define IS_SELECTOR_V86(seg) DBG_V86_MODULE(seg)
92 #define DBG_FIX_ADDR_SEG(addr,default) { \
93 if ((addr)->seg == 0xffffffff) (addr)->seg = (default); \
94 if (!IS_SELECTOR_V86((addr)->seg)) \
95 if (IS_SELECTOR_SYSTEM((addr)->seg)) (addr)->seg = 0; }
97 #define DBG_ADDR_TO_LIN(addr) \
98 (IS_SELECTOR_V86((addr)->seg) \
99 ? (char*)(DOSMEM_MemoryBase(DBG_V86_MODULE((addr)->seg)) + \
100 ((((addr)->seg)&0xFFFF)<<4)+(addr)->off) : \
101 (IS_SELECTOR_SYSTEM((addr)->seg) ? (char *)(addr)->off \
102 : (char *)PTR_SEG_OFF_TO_LIN((addr)->seg,(addr)->off)))
104 #define DBG_CHECK_READ_PTR(addr,len) \
105 (!DEBUG_IsBadReadPtr((addr),(len)) || \
106 (fprintf(stderr,"*** Invalid address "), \
107 DEBUG_PrintAddress((addr),dbg_mode, FALSE), \
108 fprintf(stderr,"\n"),0))
110 #define DBG_CHECK_WRITE_PTR(addr,len) \
111 (!DEBUG_IsBadWritePtr((addr),(len)) || \
112 (fprintf(stderr,"*** Invalid address "), \
113 DEBUG_PrintAddress(addr,dbg_mode, FALSE), \
114 fprintf(stderr,"\n"),0))
116 #ifdef REG_SP /* Some Sun includes define this */
122 REG_EAX
, REG_EBX
, REG_ECX
, REG_EDX
, REG_ESI
,
123 REG_EDI
, REG_EBP
, REG_EFL
, REG_EIP
, REG_ESP
,
124 REG_AX
, REG_BX
, REG_CX
, REG_DX
, REG_SI
,
125 REG_DI
, REG_BP
, REG_FL
, REG_IP
, REG_SP
,
126 REG_CS
, REG_DS
, REG_ES
, REG_SS
, REG_FS
, REG_GS
132 EXEC_CONT
, /* Continuous execution */
133 EXEC_STEP_OVER
, /* Stepping over a call to next source line */
134 EXEC_STEP_INSTR
, /* Step to next source line, stepping in if needed */
135 EXEC_STEPI_OVER
, /* Stepping over a call */
136 EXEC_STEPI_INSTR
, /* Single-stepping an instruction */
137 EXEC_FINISH
, /* Step until we exit current frame */
138 EXEC_STEP_OVER_TRAMPOLINE
/* Step over trampoline. Requires that
139 * we dig the real return value off the stack
140 * and set breakpoint there - not at the
141 * instr just after the call.
145 extern CONTEXT DEBUG_context
; /* debugger/registers.c */
146 extern unsigned int dbg_mode
;
148 /* debugger/break.c */
149 extern void DEBUG_SetBreakpoints( BOOL32 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
, BOOL32 enable
);
154 extern void DEBUG_InfoBreakpoints(void);
155 extern void DEBUG_AddTaskEntryBreakpoint( HTASK16 hTask
);
156 extern BOOL32
DEBUG_HandleTrap(void);
157 extern BOOL32
DEBUG_ShouldContinue( enum exec_mode mode
, int * count
);
158 extern enum exec_mode
DEBUG_RestartExecution( enum exec_mode mode
, int count
);
159 extern BOOL32
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 BOOL32
DEBUG_GetSymbolValue( const char * name
, const int lineno
,
205 DBG_ADDR
*addr
, int );
206 extern BOOL32
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 BOOL32
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 BOOL32
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 BOOL32
DEBUG_IsBadReadPtr( const DBG_ADDR
*address
, int size
);
248 extern BOOL32
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 BOOL32
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);
276 extern int DEBUG_RegisterDebugInfo( HMODULE32
, const char *,
277 unsigned long, unsigned long);
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 #endif /* __WINE_DEBUGGER_H */