blob: bf860a7980b7638cd25501d2932519f069dda84f [file] [log] [blame]
Alexandre Julliardded30381995-07-06 17:18:27 +00001/*
2 * Debugger definitions
3 *
4 * Copyright 1995 Alexandre Julliard
5 */
6
Alexandre Julliardca22b331996-07-12 19:02:39 +00007#ifndef __WINE_DEBUGGER_H
8#define __WINE_DEBUGGER_H
Alexandre Julliardded30381995-07-06 17:18:27 +00009
Marcus Meissner317af321999-02-17 13:51:06 +000010#include <sys/types.h> /* u_long ... */
Eric Pouechd33bcb62000-03-15 19:57:20 +000011#include <assert.h>
Jim Aston2e1cafa1999-03-14 16:35:05 +000012#include "windef.h"
Eric Pouech527eea92000-03-08 16:44:54 +000013#include "winbase.h"
Eric Pouechac11a682000-03-26 13:37:39 +000014#include "wine/exception.h"
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +000015
Eric Pouech527eea92000-03-08 16:44:54 +000016#ifdef __i386__
Eric Pouechd33bcb62000-03-15 19:57:20 +000017#define STEP_FLAG 0x00000100 /* single step flag */
Eric Pouech527eea92000-03-08 16:44:54 +000018#define V86_FLAG 0x00020000
19#endif
Alexandre Julliard7e56f681996-01-31 19:02:28 +000020
Alexandre Julliardc6c09441997-01-12 18:32:19 +000021#define SYM_FUNC 0x0
22#define SYM_DATA 0x1
23#define SYM_WIN32 0x2
24#define SYM_WINE 0x4
25#define SYM_INVALID 0x8
26#define SYM_TRAMPOLINE 0x10
27#define SYM_STEP_THROUGH 0x20
28
François Gouget241c7301998-10-28 10:47:09 +000029enum debug_type {DT_BASIC, DT_CONST, DT_POINTER, DT_ARRAY, DT_STRUCT, DT_ENUM, DT_TYPEDEF, DT_FUNC, DT_BITFIELD};
Alexandre Julliardc6c09441997-01-12 18:32:19 +000030
31
32/*
33 * Return values for DEBUG_CheckLinenoStatus. Used to determine
34 * what to do when the 'step' command is given.
35 */
36#define FUNC_HAS_NO_LINES (0)
37#define NOT_ON_LINENUMBER (1)
38#define AT_LINENUMBER (2)
39#define FUNC_IS_TRAMPOLINE (3)
40
41/*
42 * For constants generated by the parser, we use this datatype
43 */
Eric Pouech04c16b82000-04-30 12:21:15 +000044extern struct datatype * DEBUG_TypeShortUInt;
Alexandre Julliardc6c09441997-01-12 18:32:19 +000045extern struct datatype * DEBUG_TypeInt;
46extern struct datatype * DEBUG_TypeIntConst;
47extern struct datatype * DEBUG_TypeUSInt;
48extern struct datatype * DEBUG_TypeString;
49
Alexandre Julliard808cb041995-08-17 17:11:36 +000050typedef struct
51{
Eric Pouechd33bcb62000-03-15 19:57:20 +000052 DWORD seg; /* 0xffffffff means current default segment (cs or ds) */
53 DWORD off;
Alexandre Julliard808cb041995-08-17 17:11:36 +000054} DBG_ADDR;
55
Eric Pouechd33bcb62000-03-15 19:57:20 +000056typedef struct
57{
58 struct datatype* type;
59 int cookie; /* DV_??? */
Eric Pouech71189b52000-07-25 12:51:56 +000060/* DV_TARGET references an address in debugger's address space, whereas DV_HOST
61 * references the debuggee address space
62 */
63# define DV_TARGET 0xF00D
64# define DV_HOST 0x50DA
65# define DV_INVALID 0x0000
66
Eric Pouechd33bcb62000-03-15 19:57:20 +000067 DBG_ADDR addr;
68} DBG_VALUE;
69
Alexandre Julliardc6c09441997-01-12 18:32:19 +000070struct list_id
71{
72 char * sourcefile;
73 int line;
74};
75
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +000076struct wine_lines {
77 unsigned long line_number;
78 DBG_ADDR pc_offset;
79};
80
Alexandre Julliardc6c09441997-01-12 18:32:19 +000081struct symbol_info
82{
83 struct name_hash * sym;
84 struct list_id list;
85};
86
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +000087typedef struct wine_lines WineLineNo;
88
89/*
90 * This structure holds information about stack variables, function
91 * parameters, and register variables, which are all local to this
92 * function.
93 */
94struct wine_locals {
95 unsigned int regno:8; /* For register symbols */
Alexandre Julliardc6c09441997-01-12 18:32:19 +000096 signed int offset:24; /* offset from esp/ebp to symbol */
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +000097 unsigned int pc_start; /* For RBRAC/LBRAC */
98 unsigned int pc_end; /* For RBRAC/LBRAC */
99 char * name; /* Name of symbol */
Alexandre Julliardc6c09441997-01-12 18:32:19 +0000100 struct datatype * type; /* Datatype of symbol */
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000101};
102
103typedef struct wine_locals WineLocals;
104
Eric Pouech527eea92000-03-08 16:44:54 +0000105enum exec_mode
106{
107 EXEC_CONT, /* Continuous execution */
108 EXEC_PASS, /* Continue, passing exception to app */
109 EXEC_STEP_OVER, /* Stepping over a call to next source line */
110 EXEC_STEP_INSTR, /* Step to next source line, stepping in if needed */
111 EXEC_STEPI_OVER, /* Stepping over a call */
112 EXEC_STEPI_INSTR, /* Single-stepping an instruction */
113 EXEC_FINISH, /* Step until we exit current frame */
Eric Poueche5efa0c2000-04-13 19:31:58 +0000114 EXEC_STEP_OVER_TRAMPOLINE, /* Step over trampoline. Requires that
Eric Pouech527eea92000-03-08 16:44:54 +0000115 * we dig the real return value off the stack
116 * and set breakpoint there - not at the
117 * instr just after the call.
118 */
119};
Eric Pouechd33bcb62000-03-15 19:57:20 +0000120
Eric Pouechb9717452000-05-05 18:14:34 +0000121#define DBG_BREAK 0
122#define DBG_WATCH 1
Eric Pouechd33bcb62000-03-15 19:57:20 +0000123
Eric Pouech527eea92000-03-08 16:44:54 +0000124typedef struct
125{
126 DBG_ADDR addr;
Eric Pouech527eea92000-03-08 16:44:54 +0000127 WORD enabled : 1,
Eric Pouechd33bcb62000-03-15 19:57:20 +0000128 type : 1,
129 is32 : 1,
130 refcount : 13;
131 WORD skipcount;
132 union {
Eric Pouechb9717452000-05-05 18:14:34 +0000133 struct {
134 BYTE opcode;
135 BOOL (*func)(void);
136 } b;
Eric Pouechd33bcb62000-03-15 19:57:20 +0000137 struct {
138 BYTE rw : 1,
139 len : 2;
140 BYTE reg;
141 DWORD oldval;
142 } w;
143 } u;
Eric Pouech527eea92000-03-08 16:44:54 +0000144 struct expr * condition;
Eric Pouech04c16b82000-04-30 12:21:15 +0000145} DBG_BREAKPOINT;
Eric Pouech527eea92000-03-08 16:44:54 +0000146
Alexandre Julliard954a4132000-09-24 03:15:50 +0000147enum dbg_mode
148{
149 MODE_INVALID, MODE_16, MODE_32, MODE_VM86
150};
151
Eric Pouechac11a682000-03-26 13:37:39 +0000152typedef struct tagDBG_THREAD {
153 struct tagDBG_PROCESS* process;
Eric Pouech527eea92000-03-08 16:44:54 +0000154 HANDLE handle;
155 DWORD tid;
156 LPVOID start;
157 LPVOID teb;
158 int wait_for_first_exception;
Alexandre Julliard954a4132000-09-24 03:15:50 +0000159 enum dbg_mode dbg_mode;
Eric Pouech527eea92000-03-08 16:44:54 +0000160 enum exec_mode dbg_exec_mode;
161 int dbg_exec_count;
Eric Pouech04c16b82000-04-30 12:21:15 +0000162 DBG_BREAKPOINT stepOverBP;
Eric Pouechac11a682000-03-26 13:37:39 +0000163 struct tagDBG_THREAD* next;
164 struct tagDBG_THREAD* prev;
165} DBG_THREAD;
Eric Pouech527eea92000-03-08 16:44:54 +0000166
Eric Pouechac11a682000-03-26 13:37:39 +0000167typedef struct tagDBG_PROCESS {
Eric Pouech527eea92000-03-08 16:44:54 +0000168 HANDLE handle;
169 DWORD pid;
Eric Pouechac11a682000-03-26 13:37:39 +0000170 DBG_THREAD* threads;
171 int num_threads;
Eric Pouechb9717452000-05-05 18:14:34 +0000172 unsigned continue_on_first_exception;
Eric Pouechac11a682000-03-26 13:37:39 +0000173 struct tagDBG_MODULE* modules;
Eric Pouechb9717452000-05-05 18:14:34 +0000174 unsigned long dbg_hdr_addr;
Eric Pouechac11a682000-03-26 13:37:39 +0000175 /*
176 * This is an index we use to keep track of the debug information
177 * when we have multiple sources. We use the same database to also
178 * allow us to do an 'info shared' type of deal, and we use the index
179 * to eliminate duplicates.
180 */
181 int next_index;
182 struct tagDBG_PROCESS* next;
183 struct tagDBG_PROCESS* prev;
184} DBG_PROCESS;
Eric Pouech527eea92000-03-08 16:44:54 +0000185
Eric Pouechac11a682000-03-26 13:37:39 +0000186extern DBG_PROCESS* DEBUG_CurrProcess;
187extern DBG_THREAD* DEBUG_CurrThread;
Eric Pouechf1822352000-05-11 21:43:43 +0000188extern DWORD DEBUG_CurrTid;
189extern DWORD DEBUG_CurrPid;
Eric Pouechac11a682000-03-26 13:37:39 +0000190extern CONTEXT DEBUG_context;
Eric Pouech527eea92000-03-08 16:44:54 +0000191
192#define DEBUG_READ_MEM(addr, buf, len) \
193 (ReadProcessMemory(DEBUG_CurrProcess->handle, (addr), (buf), (len), NULL))
194
195#define DEBUG_WRITE_MEM(addr, buf, len) \
196 (WriteProcessMemory(DEBUG_CurrProcess->handle, (addr), (buf), (len), NULL))
197
198#define DEBUG_READ_MEM_VERBOSE(addr, buf, len) \
199 (DEBUG_READ_MEM((addr), (buf), (len)) || (DEBUG_InvalLinAddr( addr ),0))
200
201#define DEBUG_WRITE_MEM_VERBOSE(addr, buf, len) \
202 (DEBUG_WRITE_MEM((addr), (buf), (len)) || (DEBUG_InvalLinAddr( addr ),0))
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000203
Eric Pouechac11a682000-03-26 13:37:39 +0000204typedef struct tagDBG_MODULE {
205 struct tagDBG_MODULE* next;
206 void* load_addr;
207 char* module_name;
208 char status;
209 char type;
210 short int dbg_index;
211 HMODULE handle;
212 void* extra_info;
213} DBG_MODULE;
214
215/* status field */
216#define DM_STATUS_NEW 0
217#define DM_STATUS_LOADED 1
218#define DM_STATUS_ERROR 2
219
220/* type field */
221#define DM_TYPE_UNKNOWN 0
222#define DM_TYPE_ELF 1
223#define DM_TYPE_NE 2
224#define DM_TYPE_PE 3
225
Eric Pouech04c16b82000-04-30 12:21:15 +0000226typedef struct {
227 DWORD val;
228 const char* name;
229 LPDWORD pval;
230 struct datatype* type;
231} DBG_INTVAR;
Alexandre Julliardded30381995-07-06 17:18:27 +0000232
Eric Pouech527eea92000-03-08 16:44:54 +0000233#define OFFSET_OF(__c,__f) ((int)(((char*)&(((__c*)0)->__f))-((char*)0)))
Alexandre Julliardded30381995-07-06 17:18:27 +0000234
Eric Pouech911436b2000-06-18 19:30:24 +0000235 /* from winelib.so */
236extern void DEBUG_ExternalDebugger(void);
Ulrich Weigand1cbf27a2000-06-04 01:33:21 +0000237
Alexandre Julliardded30381995-07-06 17:18:27 +0000238 /* debugger/break.c */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000239extern void DEBUG_SetBreakpoints( BOOL set );
Eric Pouechb9717452000-05-05 18:14:34 +0000240extern void DEBUG_AddBreakpoint( const DBG_VALUE *addr, BOOL (*func)(void) );
Eric Pouech911436b2000-06-18 19:30:24 +0000241extern void DEBUG_AddBreakpointFromId( const char *name, int lineno );
242extern void DEBUG_AddBreakpointFromLineno( int lineno );
Eric Pouechd33bcb62000-03-15 19:57:20 +0000243extern void DEBUG_AddWatchpoint( const DBG_VALUE *addr, int is_write );
Eric Pouech911436b2000-06-18 19:30:24 +0000244extern void DEBUG_AddWatchpointFromId( const char *name, int lineno );
Alexandre Julliardded30381995-07-06 17:18:27 +0000245extern void DEBUG_DelBreakpoint( int num );
Alexandre Julliarda3960291999-02-26 11:11:13 +0000246extern void DEBUG_EnableBreakpoint( int num, BOOL enable );
Alexandre Julliardded30381995-07-06 17:18:27 +0000247extern void DEBUG_InfoBreakpoints(void);
Alexandre Julliarda3960291999-02-26 11:11:13 +0000248extern BOOL DEBUG_HandleTrap(void);
James Abbatielloebef9a92000-09-01 01:22:05 +0000249extern BOOL DEBUG_ShouldContinue( DBG_ADDR *addr, DWORD code, enum exec_mode mode, int * count );
Eric Pouech527eea92000-03-08 16:44:54 +0000250extern void DEBUG_SuspendExecution( void );
Alexandre Julliardc6c09441997-01-12 18:32:19 +0000251extern enum exec_mode DEBUG_RestartExecution( enum exec_mode mode, int count );
Alexandre Julliarda3960291999-02-26 11:11:13 +0000252extern BOOL DEBUG_IsFctReturn(void);
Eric Pouech911436b2000-06-18 19:30:24 +0000253extern int DEBUG_AddBPCondition(int bpnum, struct expr * exp);
Alexandre Julliardded30381995-07-06 17:18:27 +0000254
Alexandre Julliard808cb041995-08-17 17:11:36 +0000255 /* debugger/db_disasm.c */
Alexandre Julliardc6c09441997-01-12 18:32:19 +0000256extern void DEBUG_Disasm( DBG_ADDR *addr, int display );
257
Eric Pouech04c16b82000-04-30 12:21:15 +0000258 /* debugger/dbg.y */
Eric Pouech911436b2000-06-18 19:30:24 +0000259extern BOOL DEBUG_Parser(void);
Eric Pouech04c16b82000-04-30 12:21:15 +0000260extern void DEBUG_Exit( DWORD );
261
262 /* debugger/debug.l */
Eric Pouech911436b2000-06-18 19:30:24 +0000263extern void DEBUG_FlushSymbols(void);
Eric Pouech04c16b82000-04-30 12:21:15 +0000264
265 /* debugger/display.c */
266extern int DEBUG_DoDisplay(void);
267extern int DEBUG_AddDisplay(struct expr * exp, int count, char format);
268extern int DEBUG_DoDisplay(void);
269extern int DEBUG_DelDisplay(int displaynum);
270extern int DEBUG_InfoDisplay(void);
271
272 /* debugger/editline.c */
273extern char * readline(const char *);
274extern void add_history(char *);
275
Alexandre Julliardc6c09441997-01-12 18:32:19 +0000276 /* debugger/expr.c */
277extern void DEBUG_FreeExprMem(void);
Eric Pouech04c16b82000-04-30 12:21:15 +0000278struct expr * DEBUG_IntVarExpr(const char* name);
Alexandre Julliardc6c09441997-01-12 18:32:19 +0000279struct expr * DEBUG_SymbolExpr(const char * name);
280struct expr * DEBUG_ConstExpr(int val);
281struct expr * DEBUG_StringExpr(const char * str);
282struct expr * DEBUG_SegAddr(struct expr *, struct expr *);
283struct expr * DEBUG_USConstExpr(unsigned int val);
284struct expr * DEBUG_BinopExpr(int oper, struct expr *, struct expr *);
285struct expr * DEBUG_UnopExpr(int oper, struct expr *);
286struct expr * DEBUG_StructPExpr(struct expr *, const char * element);
287struct expr * DEBUG_StructExpr(struct expr *, const char * element);
288struct expr * DEBUG_ArrayExpr(struct expr *, struct expr * index);
289struct expr * DEBUG_CallExpr(const char *, int nargs, ...);
Alexandre Julliard01d63461997-01-20 19:43:45 +0000290struct expr * DEBUG_TypeCastExpr(struct datatype *, struct expr *);
Eric Pouechd33bcb62000-03-15 19:57:20 +0000291extern DBG_VALUE DEBUG_EvalExpr(struct expr *);
Alexandre Julliardc6c09441997-01-12 18:32:19 +0000292extern int DEBUG_DelDisplay(int displaynum);
Eric Pouechd33bcb62000-03-15 19:57:20 +0000293extern struct expr * DEBUG_CloneExpr(const struct expr * exp);
Alexandre Julliardc6c09441997-01-12 18:32:19 +0000294extern int DEBUG_FreeExpr(struct expr * exp);
Eric Pouechd33bcb62000-03-15 19:57:20 +0000295extern int DEBUG_DisplayExpr(const struct expr * exp);
Alexandre Julliardc6c09441997-01-12 18:32:19 +0000296
Alexandre Julliard808cb041995-08-17 17:11:36 +0000297 /* debugger/hash.c */
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000298extern struct name_hash * DEBUG_AddSymbol( const char *name,
Eric Pouechd33bcb62000-03-15 19:57:20 +0000299 const DBG_VALUE *addr,
300 const char *sourcefile,
Alexandre Julliardc6c09441997-01-12 18:32:19 +0000301 int flags);
Alexandre Julliarda3960291999-02-26 11:11:13 +0000302extern BOOL DEBUG_GetSymbolValue( const char * name, const int lineno,
Eric Pouechd33bcb62000-03-15 19:57:20 +0000303 DBG_VALUE *addr, int );
304extern BOOL DEBUG_SetSymbolValue( const char * name, const DBG_VALUE *addr );
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000305extern const char * DEBUG_FindNearestSymbol( const DBG_ADDR *addr, int flag,
306 struct name_hash ** rtn,
Alexandre Julliardc6c09441997-01-12 18:32:19 +0000307 unsigned int ebp,
308 struct list_id * source);
Alexandre Julliard808cb041995-08-17 17:11:36 +0000309extern void DEBUG_ReadSymbolTable( const char * filename );
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000310extern void DEBUG_AddLineNumber( struct name_hash * func, int line_num,
Eric Pouechd33bcb62000-03-15 19:57:20 +0000311 unsigned long offset );
Alexandre Julliardc6c09441997-01-12 18:32:19 +0000312extern struct wine_locals *
313 DEBUG_AddLocal( struct name_hash * func, int regno,
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000314 int offset,
315 int pc_start,
316 int pc_end,
317 char * name);
Alexandre Julliardc6c09441997-01-12 18:32:19 +0000318extern int DEBUG_CheckLinenoStatus(const DBG_ADDR *addr);
319extern void DEBUG_GetFuncInfo(struct list_id * ret, const char * file,
320 const char * func);
321extern int DEBUG_SetSymbolSize(struct name_hash * sym, unsigned int len);
322extern int DEBUG_SetSymbolBPOff(struct name_hash * sym, unsigned int len);
323extern int DEBUG_GetSymbolAddr(struct name_hash * sym, DBG_ADDR * addr);
324extern int DEBUG_cmp_sym(const void * p1, const void * p2);
Alexandre Julliarda3960291999-02-26 11:11:13 +0000325extern BOOL DEBUG_GetLineNumberAddr( struct name_hash *, const int lineno,
Eric Pouechd33bcb62000-03-15 19:57:20 +0000326 DBG_ADDR *addr, int bp_flag );
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000327
Alexandre Julliardc6c09441997-01-12 18:32:19 +0000328extern int DEBUG_SetLocalSymbolType(struct wine_locals * sym,
329 struct datatype * type);
Eric Pouechac11a682000-03-26 13:37:39 +0000330extern BOOL DEBUG_Normalize(struct name_hash * nh );
Alexandre Julliard808cb041995-08-17 17:11:36 +0000331
332 /* debugger/info.c */
Eric Pouechd33bcb62000-03-15 19:57:20 +0000333extern void DEBUG_PrintBasic( const DBG_VALUE* value, int count, char format );
Alexandre Julliard954a4132000-09-24 03:15:50 +0000334extern struct symbol_info DEBUG_PrintAddress( const DBG_ADDR *addr, enum dbg_mode mode, int flag );
Alexandre Julliard808cb041995-08-17 17:11:36 +0000335extern void DEBUG_Help(void);
Alexandre Julliardc6c09441997-01-12 18:32:19 +0000336extern void DEBUG_HelpInfo(void);
337extern struct symbol_info DEBUG_PrintAddressAndArgs( const DBG_ADDR *addr,
Alexandre Julliard954a4132000-09-24 03:15:50 +0000338 enum dbg_mode mode,
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000339 unsigned int ebp,
340 int flag );
Eric Pouech527eea92000-03-08 16:44:54 +0000341extern void DEBUG_InfoClass(const char* clsName);
342extern void DEBUG_WalkClasses(void);
343extern void DEBUG_WalkModref(DWORD p);
344extern void DEBUG_DumpModule(DWORD mod);
345extern void DEBUG_WalkModules(void);
346extern void DEBUG_WalkProcess(void);
Alexandre Julliarda6795412000-04-16 19:46:35 +0000347extern void DEBUG_WalkThreads(void);
Eric Pouech527eea92000-03-08 16:44:54 +0000348extern void DEBUG_DumpQueue(DWORD q);
349extern void DEBUG_WalkQueues(void);
350extern void DEBUG_InfoSegments(DWORD s, int v);
351extern void DEBUG_InfoVirtual(void);
352extern void DEBUG_InfoWindow(HWND hWnd);
353extern void DEBUG_WalkWindows(HWND hWnd, int indent);
Alexandre Julliard808cb041995-08-17 17:11:36 +0000354
355 /* debugger/memory.c */
Eric Pouech04c16b82000-04-30 12:21:15 +0000356extern int DEBUG_ReadMemory( const DBG_VALUE* value );
357extern void DEBUG_WriteMemory( const DBG_VALUE* val, int value );
Eric Pouechd33bcb62000-03-15 19:57:20 +0000358extern void DEBUG_ExamineMemory( const DBG_VALUE *addr, int count, char format);
Eric Poueche5efa0c2000-04-13 19:31:58 +0000359extern void DEBUG_InvalAddr( const DBG_ADDR* addr );
Eric Pouech527eea92000-03-08 16:44:54 +0000360extern void DEBUG_InvalLinAddr( void* addr );
Eric Pouech527eea92000-03-08 16:44:54 +0000361extern DWORD DEBUG_ToLinear( const DBG_ADDR *address );
Ulrich Weigand1cbf27a2000-06-04 01:33:21 +0000362extern void DEBUG_GetCurrentAddress( DBG_ADDR * );
Eric Pouech71189b52000-07-25 12:51:56 +0000363extern BOOL DEBUG_GrabAddress( DBG_VALUE* value, BOOL fromCode );
Alexandre Julliard954a4132000-09-24 03:15:50 +0000364extern enum dbg_mode DEBUG_GetSelectorType( WORD sel );
Ulrich Weigand1cbf27a2000-06-04 01:33:21 +0000365#ifdef __i386__
Eric Pouech527eea92000-03-08 16:44:54 +0000366extern void DEBUG_FixAddress( DBG_ADDR *address, DWORD def );
Eric Pouech527eea92000-03-08 16:44:54 +0000367extern int DEBUG_IsSelectorSystem( WORD sel );
368#endif
Alexandre Julliard808cb041995-08-17 17:11:36 +0000369
Eric Pouechac11a682000-03-26 13:37:39 +0000370 /* debugger/module.c */
371extern int DEBUG_LoadEntryPoints( const char * prefix );
Eric Poueche5efa0c2000-04-13 19:31:58 +0000372extern void DEBUG_LoadModule32( const char* name, HANDLE hFile, DWORD base );
Eric Pouechac11a682000-03-26 13:37:39 +0000373extern DBG_MODULE* DEBUG_AddModule(const char* name, int type,
374 void* mod_addr, HMODULE hmod);
375extern DBG_MODULE* DEBUG_FindModuleByName(const char* name, int type);
376extern DBG_MODULE* DEBUG_FindModuleByHandle(HANDLE handle, int type);
Eric Pouech911436b2000-06-18 19:30:24 +0000377extern DBG_MODULE* DEBUG_GetProcessMainModule(DBG_PROCESS* process);
Eric Pouechac11a682000-03-26 13:37:39 +0000378extern DBG_MODULE* DEBUG_RegisterPEModule(HMODULE, u_long load_addr, const char* name);
379extern DBG_MODULE* DEBUG_RegisterELFModule(u_long load_addr, const char* name);
Eric Pouechac11a682000-03-26 13:37:39 +0000380extern void DEBUG_InfoShare(void);
381
382 /* debugger/msc.c */
Eric Poueche5efa0c2000-04-13 19:31:58 +0000383extern int DEBUG_RegisterMSCDebugInfo(DBG_MODULE* module, HANDLE hFile, void* nth, unsigned long nth_ofs);
384extern int DEBUG_RegisterStabsDebugInfo(DBG_MODULE* module, HANDLE hFile, void* nth, unsigned long nth_ofs);
Eric Pouechac11a682000-03-26 13:37:39 +0000385extern void DEBUG_InitCVDataTypes(void);
Eric Pouechac11a682000-03-26 13:37:39 +0000386
Alexandre Julliardded30381995-07-06 17:18:27 +0000387 /* debugger/registers.c */
Alexandre Julliardded30381995-07-06 17:18:27 +0000388extern void DEBUG_InfoRegisters(void);
Alexandre Julliarda3960291999-02-26 11:11:13 +0000389extern BOOL DEBUG_ValidateRegisters(void);
Alexandre Julliardded30381995-07-06 17:18:27 +0000390
Eric Pouech71189b52000-07-25 12:51:56 +0000391 /* debugger/source.c */
392extern void DEBUG_ShowDir(void);
393extern void DEBUG_AddPath(const char * path);
394extern void DEBUG_List(struct list_id * line1, struct list_id * line2,
395 int delta);
396extern void DEBUG_NukePath(void);
397extern void DEBUG_Disassemble(const DBG_VALUE *, const DBG_VALUE*, int offset);
398extern BOOL DEBUG_DisassembleInstruction(DBG_ADDR *addr);
399
Alexandre Julliardded30381995-07-06 17:18:27 +0000400 /* debugger/stack.c */
401extern void DEBUG_InfoStack(void);
Eric Pouech527eea92000-03-08 16:44:54 +0000402extern void DEBUG_BackTrace(BOOL noisy);
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000403extern int DEBUG_InfoLocals(void);
404extern int DEBUG_SetFrame(int newframe);
Alexandre Julliardc6c09441997-01-12 18:32:19 +0000405extern int DEBUG_GetCurrentFrame(struct name_hash ** name,
406 unsigned int * eip,
407 unsigned int * ebp);
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000408
409 /* debugger/stabs.c */
Eric Poueche5efa0c2000-04-13 19:31:58 +0000410extern int DEBUG_ReadExecutableDbgInfo(const char* exe_name);
Eric Pouechd33bcb62000-03-15 19:57:20 +0000411extern int DEBUG_ParseStabs(char * addr, unsigned int load_offset, unsigned int staboff,
412 int stablen, unsigned int strtaboff, int strtablen);
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000413
Alexandre Julliardc6c09441997-01-12 18:32:19 +0000414 /* debugger/types.c */
Alexandre Julliard01d63461997-01-20 19:43:45 +0000415extern int DEBUG_nchar;
Alexandre Julliardc6c09441997-01-12 18:32:19 +0000416extern void DEBUG_InitTypes(void);
417extern struct datatype * DEBUG_NewDataType(enum debug_type xtype,
418 const char * typename);
Eric Pouechd33bcb62000-03-15 19:57:20 +0000419extern unsigned int DEBUG_TypeDerefPointer(const DBG_VALUE *value, struct datatype ** newtype);
Alexandre Julliardc6c09441997-01-12 18:32:19 +0000420extern int DEBUG_AddStructElement(struct datatype * dt,
421 char * name, struct datatype * type,
422 int offset, int size);
423extern int DEBUG_SetStructSize(struct datatype * dt, int size);
424extern int DEBUG_SetPointerType(struct datatype * dt, struct datatype * dt2);
425extern int DEBUG_SetArrayParams(struct datatype * dt, int min, int max,
426 struct datatype * dt2);
Eric Pouechd33bcb62000-03-15 19:57:20 +0000427extern void DEBUG_Print( const DBG_VALUE *addr, int count, char format, int level );
428extern unsigned int DEBUG_FindStructElement(DBG_VALUE * addr,
Alexandre Julliardc6c09441997-01-12 18:32:19 +0000429 const char * ele_name, int * tmpbuf);
430extern struct datatype * DEBUG_GetPointerType(struct datatype * dt);
431extern int DEBUG_GetObjectSize(struct datatype * dt);
Eric Pouechd33bcb62000-03-15 19:57:20 +0000432extern unsigned int DEBUG_ArrayIndex(const DBG_VALUE * addr, DBG_VALUE * result, int index);
Alexandre Julliardc6c09441997-01-12 18:32:19 +0000433extern struct datatype * DEBUG_FindOrMakePointerType(struct datatype * reftype);
Eric Pouechd33bcb62000-03-15 19:57:20 +0000434extern long long int DEBUG_GetExprValue(const DBG_VALUE * addr, char ** format);
Alexandre Julliardc6c09441997-01-12 18:32:19 +0000435extern int DEBUG_SetBitfieldParams(struct datatype * dt, int offset,
436 int nbits, struct datatype * dt2);
437extern int DEBUG_CopyFieldlist(struct datatype * dt, struct datatype * dt2);
Alexandre Julliard01d63461997-01-20 19:43:45 +0000438extern enum debug_type DEBUG_GetType(struct datatype * dt);
439extern struct datatype * DEBUG_TypeCast(enum debug_type, const char *);
Eric Pouechd33bcb62000-03-15 19:57:20 +0000440extern int DEBUG_PrintTypeCast(const struct datatype *);
441extern int DEBUG_PrintType( const DBG_VALUE* addr );
Alexandre Julliardc6c09441997-01-12 18:32:19 +0000442
Eric Poueche5efa0c2000-04-13 19:31:58 +0000443 /* debugger/winedbg.c */
444#define DBG_CHN_MESG 1
445#define DBG_CHN_ERR 2
446#define DBG_CHN_WARN 4
447#define DBG_CHN_FIXME 8
448#define DBG_CHN_TRACE 16
Eric Pouech04c16b82000-04-30 12:21:15 +0000449extern void DEBUG_Output(int chn, const char* buffer, int len);
Eric Pouechf1822352000-05-11 21:43:43 +0000450#ifdef __GNUC__
451extern int DEBUG_Printf(int chn, const char* format, ...) __attribute__((format (printf,2,3)));
452#else
Eric Pouech04c16b82000-04-30 12:21:15 +0000453extern int DEBUG_Printf(int chn, const char* format, ...);
Eric Pouechf1822352000-05-11 21:43:43 +0000454#endif
Eric Pouech04c16b82000-04-30 12:21:15 +0000455extern DBG_INTVAR* DEBUG_GetIntVar(const char*);
Eric Pouech911436b2000-06-18 19:30:24 +0000456extern BOOL DEBUG_Attach(DWORD pid, BOOL cofe);
457extern void DEBUG_Run(const char* args);
458extern int curr_frame;
Marcus Meissner9faa7d71999-02-13 17:55:17 +0000459
Eric Pouech911436b2000-06-18 19:30:24 +0000460/* Choose your allocator! */
Ove Kaavendda17c61999-04-25 12:24:42 +0000461#if 1
462/* this one is libc's fast one */
Eric Pouech527eea92000-03-08 16:44:54 +0000463extern void* DEBUG_XMalloc(size_t size);
464extern void* DEBUG_XReAlloc(void *ptr, size_t size);
465extern char* DEBUG_XStrDup(const char *str);
466
467#define DBG_alloc(x) DEBUG_XMalloc(x)
468#define DBG_realloc(x,y) DEBUG_XReAlloc(x,y)
469#define DBG_free(x) free(x)
470#define DBG_strdup(x) DEBUG_XStrDup(x)
Ove Kaavendda17c61999-04-25 12:24:42 +0000471#else
472/* this one is slow (takes 5 minutes to load the debugger on my machine),
473 but is pretty crash-proof (can step through malloc() without problems,
474 malloc() arena (and other heaps) can be totally wasted and it'll still
475 work, etc... if someone could make optimized routines so it wouldn't
476 take so long to load, it could be made default) */
477#include "heap.h"
Dimitrie O. Paun78272542000-04-28 14:43:34 +0000478#define DBG_alloc(x) HeapAlloc(dbg_heap,0,x)
479#define DBG_realloc(x,y) HeapRealloc(dbg_heap,0,x,y)
Ove Kaavendda17c61999-04-25 12:24:42 +0000480#define DBG_free(x) HeapFree(dbg_heap,0,x)
481#define DBG_strdup(x) HEAP_strdupA(dbg_heap,0,x)
482#define DBG_need_heap
Eric Pouech527eea92000-03-08 16:44:54 +0000483extern HANDLE dbg_heap;
Ove Kaavendda17c61999-04-25 12:24:42 +0000484#endif
Marcus Meissner9faa7d71999-02-13 17:55:17 +0000485
Eric Pouechd33bcb62000-03-15 19:57:20 +0000486#define DEBUG_STATUS_OFFSET 0x80003000
487#define DEBUG_STATUS_INTERNAL_ERROR (DEBUG_STATUS_OFFSET+0)
488#define DEBUG_STATUS_NO_SYMBOL (DEBUG_STATUS_OFFSET+1)
489#define DEBUG_STATUS_DIV_BY_ZERO (DEBUG_STATUS_OFFSET+2)
490#define DEBUG_STATUS_BAD_TYPE (DEBUG_STATUS_OFFSET+3)
Eric Pouech527eea92000-03-08 16:44:54 +0000491
Eric Pouech04c16b82000-04-30 12:21:15 +0000492extern DBG_INTVAR DEBUG_IntVars[];
493
494#define DBG_IVARNAME(_var) DEBUG_IV_##_var
495#define DBG_IVARSTRUCT(_var) DEBUG_IntVars[DBG_IVARNAME(_var)]
496#define DBG_IVAR(_var) (*(DBG_IVARSTRUCT(_var).pval))
497#define INTERNAL_VAR(_var,_val,_ref,_typ) DBG_IVARNAME(_var),
498enum debug_int_var {
Eric Poueche5efa0c2000-04-13 19:31:58 +0000499#include "intvar.h"
Eric Pouech04c16b82000-04-30 12:21:15 +0000500 DBG_IV_LAST
501};
Eric Poueche5efa0c2000-04-13 19:31:58 +0000502#undef INTERNAL_VAR
503
Alexandre Julliardca22b331996-07-12 19:02:39 +0000504#endif /* __WINE_DEBUGGER_H */