debugger.h 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564
  1. /*
  2. * Debugger definitions
  3. *
  4. * Copyright 1995 Alexandre Julliard
  5. *
  6. * This library is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2.1 of the License, or (at your option) any later version.
  10. *
  11. * This library is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with this library; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  19. */
  20. #ifndef __WINE_DEBUGGER_H
  21. #define __WINE_DEBUGGER_H
  22. #include <assert.h>
  23. #include <stdarg.h>
  24. #define NONAMELESSUNION
  25. #define NONAMELESSSTRUCT
  26. #include "ntstatus.h"
  27. #define WIN32_NO_STATUS
  28. #define WIN32_LEAN_AND_MEAN
  29. #include "windef.h"
  30. #include "winbase.h"
  31. #include "winver.h"
  32. #include "winternl.h"
  33. #include "dbghelp.h"
  34. #include "cvconst.h"
  35. #include "objbase.h"
  36. #include "oaidl.h"
  37. #include <wine/list.h>
  38. #define ADDRSIZE ((int)(dbg_curr_process ? dbg_curr_process->be_cpu->pointer_size : sizeof(void*)))
  39. #define ADDRWIDTH (ADDRSIZE * 2)
  40. /* the debugger uses these exceptions for its internal use */
  41. #define DEBUG_STATUS_OFFSET 0x80003000
  42. #define DEBUG_STATUS_INTERNAL_ERROR (DEBUG_STATUS_OFFSET+0) /* something went wrong */
  43. #define DEBUG_STATUS_NO_SYMBOL (DEBUG_STATUS_OFFSET+1) /* no symbol found in lookup */
  44. #define DEBUG_STATUS_DIV_BY_ZERO (DEBUG_STATUS_OFFSET+2)
  45. #define DEBUG_STATUS_BAD_TYPE (DEBUG_STATUS_OFFSET+3) /* no type found, when type was expected */
  46. #define DEBUG_STATUS_NO_FIELD (DEBUG_STATUS_OFFSET+4) /* when dereferencing a struct, the field was not found */
  47. #define DEBUG_STATUS_ABORT (DEBUG_STATUS_OFFSET+5) /* user aborted on going action */
  48. #define DEBUG_STATUS_CANT_DEREF (DEBUG_STATUS_OFFSET+6) /* either not deref:able, or index out of bounds */
  49. #define DEBUG_STATUS_NOT_AN_INTEGER (DEBUG_STATUS_OFFSET+7) /* requiring an integral value */
  50. /*
  51. * Return values for symbol_get_function_line_status. Used to determine
  52. * what to do when the 'step' command is given.
  53. */
  54. enum dbg_line_status
  55. {
  56. dbg_no_line_info,
  57. dbg_not_on_a_line_number,
  58. dbg_on_a_line_number,
  59. dbg_in_a_thunk,
  60. };
  61. enum dbg_internal_types
  62. {
  63. dbg_itype_first = 0xffffff00,
  64. dbg_itype_unsigned_int,
  65. dbg_itype_signed_int,
  66. dbg_itype_signed_char_int,
  67. dbg_itype_unsigned_char_int,
  68. dbg_itype_unsigned_short_int,
  69. dbg_itype_signed_short_int,
  70. dbg_itype_unsigned_long_int,
  71. dbg_itype_signed_long_int,
  72. dbg_itype_unsigned_longlong_int,
  73. dbg_itype_signed_longlong_int,
  74. /* they represent the dbg_lg(u)int_t types */
  75. dbg_itype_lgint,
  76. dbg_itype_lguint,
  77. dbg_itype_char,
  78. dbg_itype_wchar,
  79. dbg_itype_short_real, /* aka float */
  80. dbg_itype_real, /* aka double */
  81. dbg_itype_long_real, /* aka long double */
  82. dbg_itype_astring,
  83. dbg_itype_ustring,
  84. dbg_itype_segptr, /* hack for segmented pointers */
  85. dbg_itype_m128a, /* 128-bit (XMM) registers */
  86. dbg_itype_none = 0xffffffff
  87. };
  88. /* Largest integers the debugger's compiler can support.
  89. * It's large enough to store a pointer (in debuggee or debugger's address space).
  90. * It can be smaller than the largest integer(s) of the debuggee.
  91. * (eg. 64 bit on PE build of debugger, vs 128 int in ELF build of a library)
  92. */
  93. typedef LONG64 dbg_lgint_t;
  94. typedef ULONG64 dbg_lguint_t;
  95. /* type description (in the following order):
  96. * - if 'id' is dbg_itype_none (whatever 'module' value), the type isn't known
  97. * - if 'module' is 0, it's an internal type (id is one of dbg_itype...)
  98. * - if 'module' is non 0, then 'id' is a type ID referring to module (loaded in
  99. * dbghelp) which (linear) contains address 'module'.
  100. */
  101. struct dbg_type
  102. {
  103. ULONG id;
  104. DWORD_PTR module;
  105. };
  106. struct dbg_lvalue /* structure to hold left-values... */
  107. {
  108. unsigned in_debuggee : 1, /* 1 = debuggee address space, 0 = debugger address space */
  109. bitstart : 8, /* in fact, 7 should be sufficient for underlying 128bit integers */
  110. bitlen;
  111. ADDRESS64 addr;
  112. struct dbg_type type;
  113. };
  114. static inline void init_lvalue(struct dbg_lvalue* lv, BOOL in_debuggee, void* addr)
  115. {
  116. lv->in_debuggee = !!in_debuggee;
  117. lv->bitstart = 0;
  118. lv->bitlen = 0;
  119. lv->addr.Mode = AddrModeFlat;
  120. lv->addr.Offset = (DWORD_PTR)addr;
  121. lv->type.module = 0;
  122. lv->type.id = dbg_itype_none;
  123. }
  124. static inline void init_lvalue_in_debugger(struct dbg_lvalue* lv, enum dbg_internal_types it, void* addr)
  125. {
  126. lv->in_debuggee = 0;
  127. lv->bitstart = 0;
  128. lv->bitlen = 0;
  129. lv->addr.Mode = AddrModeFlat;
  130. lv->addr.Offset = (DWORD_PTR)addr;
  131. lv->type.module = 0;
  132. lv->type.id = it;
  133. }
  134. enum dbg_exec_mode
  135. {
  136. dbg_exec_cont, /* Continue execution */
  137. dbg_exec_step_over_line, /* Stepping over a call to next source line */
  138. dbg_exec_step_into_line, /* Step to next source line, stepping in if needed */
  139. dbg_exec_step_over_insn, /* Stepping over a call */
  140. dbg_exec_step_into_insn, /* Single-stepping an instruction */
  141. dbg_exec_finish, /* Single-step until we exit current frame */
  142. #if 0
  143. EXEC_STEP_OVER_TRAMPOLINE, /* Step over trampoline. Requires that we dig the real
  144. * return value off the stack and set breakpoint there -
  145. * not at the instr just after the call.
  146. */
  147. #endif
  148. };
  149. struct dbg_breakpoint
  150. {
  151. ADDRESS64 addr;
  152. unsigned int enabled : 1,
  153. xpoint_type : 2,
  154. refcount : 13,
  155. skipcount : 16;
  156. unsigned int info;
  157. struct /* only used for watchpoints */
  158. {
  159. BYTE len : 2;
  160. DWORD64 oldval;
  161. } w;
  162. struct expr* condition;
  163. };
  164. /* Helper structure */
  165. typedef struct tagTHREADNAME_INFO
  166. {
  167. DWORD dwType; /* Must be 0x1000 */
  168. LPCSTR szName; /* Pointer to name - limited to 9 bytes (8 characters + terminator) */
  169. DWORD dwThreadID; /* Thread ID (-1 = caller thread) */
  170. DWORD dwFlags; /* Reserved for future use. Must be zero. */
  171. } THREADNAME_INFO;
  172. typedef union dbg_ctx
  173. {
  174. CONTEXT ctx;
  175. WOW64_CONTEXT x86;
  176. } dbg_ctx_t;
  177. struct dbg_thread
  178. {
  179. struct list entry;
  180. struct dbg_process* process;
  181. HANDLE handle;
  182. DWORD tid;
  183. void* teb;
  184. enum dbg_exec_mode exec_mode; /* mode the thread is run (step/run...) */
  185. int exec_count; /* count of mode operations */
  186. ADDRESS_MODE addr_mode; /* mode */
  187. int stopped_xpoint; /* xpoint on which the thread has stopped (-1 if none) */
  188. struct dbg_breakpoint step_over_bp;
  189. char name[9];
  190. BOOL in_exception; /* TRUE if thread stopped with an exception */
  191. BOOL first_chance; /* TRUE if thread stopped with a first chance exception
  192. * - only valid when in_exception is TRUE
  193. */
  194. EXCEPTION_RECORD excpt_record; /* only valid when in_exception is TRUE */
  195. struct dbg_frame
  196. {
  197. ADDRESS64 addr_pc;
  198. ADDRESS64 addr_frame;
  199. ADDRESS64 addr_stack;
  200. DWORD_PTR linear_pc;
  201. DWORD_PTR linear_frame;
  202. DWORD_PTR linear_stack;
  203. dbg_ctx_t context; /* context we got out of stackwalk for this frame */
  204. DWORD inline_ctx;
  205. BOOL is_ctx_valid; /* is the context above valid */
  206. }* frames;
  207. int num_frames;
  208. int curr_frame;
  209. BOOL suspended;
  210. };
  211. struct dbg_delayed_bp
  212. {
  213. BOOL is_symbol;
  214. BOOL software_bp;
  215. union
  216. {
  217. struct
  218. {
  219. int lineno;
  220. char* name;
  221. } symbol;
  222. ADDRESS64 addr;
  223. } u;
  224. };
  225. #define MAX_BREAKPOINTS 100
  226. struct dbg_process
  227. {
  228. struct list entry;
  229. HANDLE handle;
  230. DWORD pid;
  231. const struct be_process_io* process_io;
  232. void* pio_data;
  233. const WCHAR* imageName;
  234. struct list threads;
  235. struct backend_cpu* be_cpu;
  236. HANDLE event_on_first_exception;
  237. BOOL active_debuggee;
  238. struct dbg_breakpoint bp[MAX_BREAKPOINTS];
  239. unsigned next_bp;
  240. struct dbg_delayed_bp* delayed_bp;
  241. int num_delayed_bp;
  242. struct open_file_list* source_ofiles;
  243. char* search_path;
  244. char source_current_file[MAX_PATH];
  245. int source_start_line;
  246. int source_end_line;
  247. };
  248. /* describes the way the debugger interacts with a given process */
  249. struct be_process_io
  250. {
  251. BOOL (*close_process)(struct dbg_process*, BOOL);
  252. BOOL (*read)(HANDLE, const void*, void*, SIZE_T, SIZE_T*);
  253. BOOL (*write)(HANDLE, void*, const void*, SIZE_T, SIZE_T*);
  254. BOOL (*get_selector)(HANDLE, DWORD, LDT_ENTRY*);
  255. };
  256. extern struct dbg_process* dbg_curr_process;
  257. extern DWORD dbg_curr_pid;
  258. extern struct dbg_thread* dbg_curr_thread;
  259. extern DWORD dbg_curr_tid;
  260. extern dbg_ctx_t dbg_context;
  261. extern BOOL dbg_interactiveP;
  262. extern HANDLE dbg_houtput;
  263. struct dbg_internal_var
  264. {
  265. DWORD val;
  266. const char* name;
  267. void* pval;
  268. ULONG typeid; /* always internal type */
  269. };
  270. enum sym_get_lval {sglv_found, sglv_unknown, sglv_aborted};
  271. enum type_expr_e
  272. {
  273. type_expr_type_id,
  274. type_expr_udt_class,
  275. type_expr_udt_struct,
  276. type_expr_udt_union,
  277. type_expr_enumeration
  278. };
  279. struct type_expr_t
  280. {
  281. enum type_expr_e type;
  282. unsigned deref_count;
  283. union
  284. {
  285. struct dbg_type type;
  286. const char* name;
  287. } u;
  288. };
  289. enum dbg_start {start_ok, start_error_parse, start_error_init};
  290. /* break.c */
  291. extern void break_set_xpoints(BOOL set);
  292. extern BOOL break_add_break(const ADDRESS64* addr, BOOL verbose, BOOL swbp);
  293. extern BOOL break_add_break_from_lvalue(const struct dbg_lvalue* value, BOOL swbp);
  294. extern void break_add_break_from_id(const char* name, int lineno, BOOL swbp);
  295. extern void break_add_break_from_lineno(const char *filename, int lineno, BOOL swbp);
  296. extern void break_add_watch_from_lvalue(const struct dbg_lvalue* lvalue, BOOL is_write);
  297. extern void break_add_watch_from_id(const char* name, BOOL is_write);
  298. extern void break_check_delayed_bp(void);
  299. extern void break_delete_xpoint(int num);
  300. extern void break_delete_xpoints_from_module(DWORD64 base);
  301. extern void break_enable_xpoint(int num, BOOL enable);
  302. extern void break_info(void);
  303. extern void break_adjust_pc(ADDRESS64* addr, DWORD code, BOOL first_chance, BOOL* is_break);
  304. extern BOOL break_should_continue(ADDRESS64* addr, DWORD code);
  305. extern void break_suspend_execution(void);
  306. extern void break_restart_execution(int count);
  307. extern int break_add_condition(int bpnum, struct expr* exp);
  308. /* crashdlg.c */
  309. extern int display_crash_dialog(void);
  310. extern HANDLE display_crash_details(HANDLE event);
  311. extern int msgbox_res_id(HWND hwnd, UINT textId, UINT captionId, UINT uType);
  312. /* dbg.y */
  313. extern void parser_handle(const char*, HANDLE);
  314. extern int input_read_line(const char* pfx, char* buffer, int size);
  315. extern size_t input_lex_read_buffer(char* pfx, int size);
  316. extern HANDLE WINAPIV parser_generate_command_file(const char*, ...);
  317. /* debug.l */
  318. extern void lexeme_flush(void);
  319. extern char* lexeme_alloc_size(int);
  320. /* display.c */
  321. extern BOOL display_print(void);
  322. extern BOOL display_add(struct expr* exp, int count, char format);
  323. extern BOOL display_delete(int displaynum);
  324. extern BOOL display_info(void);
  325. extern BOOL display_enable(int displaynum, int enable);
  326. /* expr.c */
  327. extern void expr_free_all(void);
  328. extern struct expr* expr_alloc_internal_var(const char* name);
  329. extern struct expr* expr_alloc_symbol(const char* name);
  330. extern struct expr* expr_alloc_sconstant(dbg_lgint_t val);
  331. extern struct expr* expr_alloc_uconstant(dbg_lguint_t val);
  332. extern struct expr* expr_alloc_string(const char* str);
  333. extern struct expr* expr_alloc_binary_op(int oper, struct expr*, struct expr*);
  334. extern struct expr* expr_alloc_unary_op(int oper, struct expr*);
  335. extern struct expr* expr_alloc_pstruct(struct expr*, const char* element);
  336. extern struct expr* expr_alloc_struct(struct expr*, const char* element);
  337. extern struct expr* WINAPIV expr_alloc_func_call(const char*, int nargs, ...);
  338. extern struct expr* expr_alloc_typecast(struct type_expr_t*, struct expr*);
  339. extern struct dbg_lvalue expr_eval(struct expr*);
  340. extern struct expr* expr_clone(const struct expr* exp, BOOL *local_binding);
  341. extern BOOL expr_free(struct expr* exp);
  342. extern BOOL expr_print(const struct expr* exp);
  343. /* info.c */
  344. extern void print_help(void);
  345. extern void info_help(void);
  346. extern void info_win32_module(DWORD64 mod);
  347. extern void info_win32_class(HWND hWnd, const char* clsName);
  348. extern void info_win32_window(HWND hWnd, BOOL detailed);
  349. extern void info_win32_processes(void);
  350. extern void info_win32_threads(void);
  351. extern void info_win32_frame_exceptions(DWORD tid);
  352. extern void info_win32_virtual(DWORD pid);
  353. extern void info_win32_segments(DWORD start, int length);
  354. extern void info_win32_exception(void);
  355. extern void info_wine_dbg_channel(BOOL add, const char* chnl, const char* name);
  356. /* memory.c */
  357. extern BOOL memory_read_value(const struct dbg_lvalue* lvalue, DWORD size, void* result);
  358. extern BOOL memory_write_value(const struct dbg_lvalue* val, DWORD size, void* value);
  359. extern BOOL memory_transfer_value(const struct dbg_lvalue* to, const struct dbg_lvalue* from);
  360. extern BOOL memory_fetch_integer(const struct dbg_lvalue* lvalue, unsigned size,
  361. BOOL is_signed, dbg_lgint_t* ret);
  362. extern BOOL memory_store_integer(const struct dbg_lvalue* lvalue, dbg_lgint_t val);
  363. extern BOOL memory_fetch_float(const struct dbg_lvalue* lvalue, double *ret);
  364. extern BOOL memory_store_float(const struct dbg_lvalue* lvalue, double *ret);
  365. extern void memory_examine(const struct dbg_lvalue *lvalue, int count, char format);
  366. extern void* memory_to_linear_addr(const ADDRESS64* address);
  367. extern BOOL memory_get_current_pc(ADDRESS64* address);
  368. extern BOOL memory_get_current_stack(ADDRESS64* address);
  369. extern BOOL memory_get_string(struct dbg_process* pcs, void* addr, BOOL in_debuggee, BOOL unicode, char* buffer, int size);
  370. extern BOOL memory_get_string_indirect(struct dbg_process* pcs, void* addr, BOOL unicode, WCHAR* buffer, int size);
  371. extern BOOL memory_get_register(DWORD regno, DWORD_PTR** value, char* buffer, int len);
  372. extern void memory_disassemble(const struct dbg_lvalue*, const struct dbg_lvalue*, int instruction_count);
  373. extern BOOL memory_disasm_one_insn(ADDRESS64* addr);
  374. #define MAX_OFFSET_TO_STR_LEN 19
  375. extern char* memory_offset_to_string(char *str, DWORD64 offset, unsigned mode);
  376. extern void print_bare_address(const ADDRESS64* addr);
  377. extern void print_address(const ADDRESS64* addr, BOOLEAN with_line);
  378. extern void print_basic(const struct dbg_lvalue* value, char format);
  379. /* source.c */
  380. extern void source_list(IMAGEHLP_LINE64* src1, IMAGEHLP_LINE64* src2, int delta);
  381. extern void source_list_from_addr(const ADDRESS64* addr, int nlines);
  382. extern void source_show_path(void);
  383. extern void source_add_path(const char* path);
  384. extern void source_nuke_path(struct dbg_process* p);
  385. extern void source_free_files(struct dbg_process* p);
  386. /* stack.c */
  387. extern void stack_info(int len);
  388. extern void stack_backtrace(DWORD threadID);
  389. extern BOOL stack_set_frame(int newframe);
  390. extern BOOL stack_get_register_frame(const struct dbg_internal_var* div, DWORD_PTR** pval);
  391. extern unsigned stack_fetch_frames(const dbg_ctx_t *ctx);
  392. extern BOOL stack_get_current_symbol(SYMBOL_INFO* sym);
  393. static inline struct dbg_frame*
  394. stack_get_thread_frame(struct dbg_thread* thd, unsigned nf)
  395. {
  396. if (!thd->frames || nf >= thd->num_frames) return NULL;
  397. return &thd->frames[nf];
  398. }
  399. static inline struct dbg_frame*
  400. stack_get_curr_frame(void)
  401. {
  402. return stack_get_thread_frame(dbg_curr_thread, dbg_curr_thread->curr_frame);
  403. }
  404. /* symbol.c */
  405. extern enum sym_get_lval symbol_get_lvalue(const char* name, const int lineno, struct dbg_lvalue* addr, BOOL bp_disp);
  406. extern void symbol_read_symtable(const char* filename, ULONG_PTR offset);
  407. extern enum dbg_line_status symbol_get_function_line_status(const ADDRESS64* addr);
  408. extern BOOL symbol_get_line(const char* filename, const char* func, IMAGEHLP_LINE64* ret);
  409. extern void symbol_info(const char* str);
  410. extern void symbol_print_local(const SYMBOL_INFO* sym, DWORD_PTR base, BOOL detailed);
  411. extern BOOL symbol_info_locals(void);
  412. extern BOOL symbol_is_local(const char* name);
  413. struct sgv_data;
  414. typedef enum sym_get_lval (*symbol_picker_t)(const char* name, const struct sgv_data* sgv,
  415. struct dbg_lvalue* rtn);
  416. extern symbol_picker_t symbol_current_picker;
  417. extern enum sym_get_lval symbol_picker_interactive(const char* name, const struct sgv_data* sgv,
  418. struct dbg_lvalue* rtn);
  419. extern enum sym_get_lval symbol_picker_scoped(const char* name, const struct sgv_data* sgv,
  420. struct dbg_lvalue* rtn);
  421. /* tgt_active.c */
  422. struct list_string
  423. {
  424. char* string;
  425. struct list_string* next;
  426. };
  427. extern void dbg_run_debuggee(struct list_string* ls);
  428. extern void dbg_wait_next_exception(DWORD cont, int count, int mode);
  429. extern enum dbg_start dbg_active_attach(int argc, char* argv[]);
  430. extern BOOL dbg_set_curr_thread(DWORD tid);
  431. extern enum dbg_start dbg_active_launch(int argc, char* argv[]);
  432. extern enum dbg_start dbg_active_auto(int argc, char* argv[]);
  433. extern enum dbg_start dbg_active_minidump(int argc, char* argv[]);
  434. extern void dbg_active_wait_for_first_exception(void);
  435. extern BOOL dbg_attach_debuggee(DWORD pid);
  436. extern void fetch_module_name(void* name_addr, void* mod_addr, WCHAR* buffer, size_t bufsz);
  437. /* tgt_minidump.c */
  438. extern void minidump_write(const char*, const EXCEPTION_RECORD*);
  439. extern enum dbg_start minidump_reload(int argc, char* argv[]);
  440. /* tgt_module.c */
  441. extern enum dbg_start tgt_module_load(const char* name, BOOL keep);
  442. /* types.c */
  443. extern void print_value(const struct dbg_lvalue* addr, char format, int level);
  444. extern BOOL types_print_type(const struct dbg_type*, BOOL details);
  445. extern BOOL print_types(void);
  446. extern dbg_lgint_t types_extract_as_integer(const struct dbg_lvalue*);
  447. extern dbg_lgint_t types_extract_as_lgint(const struct dbg_lvalue*, unsigned* psize, BOOL *pissigned);
  448. extern void types_extract_as_address(const struct dbg_lvalue*, ADDRESS64*);
  449. extern BOOL types_store_value(struct dbg_lvalue* lvalue_to, const struct dbg_lvalue* lvalue_from);
  450. extern BOOL types_udt_find_element(struct dbg_lvalue* value, const char* name);
  451. extern BOOL types_array_index(const struct dbg_lvalue* value, int index, struct dbg_lvalue* result);
  452. extern BOOL types_get_info(const struct dbg_type*, IMAGEHLP_SYMBOL_TYPE_INFO, void*);
  453. extern BOOL types_get_real_type(struct dbg_type* type, DWORD* tag);
  454. extern struct dbg_type types_find_pointer(const struct dbg_type* type);
  455. extern struct dbg_type types_find_type(DWORD64 linear, const char* name, enum SymTagEnum tag);
  456. extern BOOL types_compare(const struct dbg_type, const struct dbg_type, BOOL* equal);
  457. extern BOOL types_is_integral_type(const struct dbg_lvalue*);
  458. extern BOOL types_is_float_type(const struct dbg_lvalue*);
  459. /* winedbg.c */
  460. #ifdef __GNUC__
  461. extern int WINAPIV dbg_printf(const char* format, ...) __attribute__((format (printf,1,2)));
  462. #else
  463. extern int WINAPIV dbg_printf(const char* format, ...);
  464. #endif
  465. extern const struct dbg_internal_var* dbg_get_internal_var(const char*);
  466. extern BOOL dbg_interrupt_debuggee(void);
  467. extern unsigned dbg_num_processes(void);
  468. extern struct dbg_process* dbg_add_process(const struct be_process_io* pio, DWORD pid, HANDLE h);
  469. extern void dbg_set_process_name(struct dbg_process* p, const WCHAR* name);
  470. extern struct dbg_process* dbg_get_process(DWORD pid);
  471. extern struct dbg_process* dbg_get_process_h(HANDLE handle);
  472. extern void dbg_del_process(struct dbg_process* p);
  473. struct dbg_thread* dbg_add_thread(struct dbg_process* p, DWORD tid, HANDLE h, void* teb);
  474. extern struct dbg_thread* dbg_get_thread(struct dbg_process* p, DWORD tid);
  475. extern void dbg_del_thread(struct dbg_thread* t);
  476. extern BOOL dbg_init(HANDLE hProc, const WCHAR* in, BOOL invade);
  477. extern BOOL dbg_load_module(HANDLE hProc, HANDLE hFile, const WCHAR* name, DWORD_PTR base, DWORD size);
  478. extern void dbg_set_option(const char*, const char*);
  479. extern void dbg_start_interactive(const char*, HANDLE hFile);
  480. extern void dbg_init_console(void);
  481. /* gdbproxy.c */
  482. extern int gdb_main(int argc, char* argv[]);
  483. static inline BOOL dbg_read_memory(const void* addr, void* buffer, size_t len)
  484. {
  485. SIZE_T rlen;
  486. return dbg_curr_process->process_io->read(dbg_curr_process->handle, addr, buffer, len, &rlen) && len == rlen;
  487. }
  488. static inline BOOL dbg_write_memory(void* addr, const void* buffer, size_t len)
  489. {
  490. SIZE_T wlen;
  491. return dbg_curr_process->process_io->write(dbg_curr_process->handle, addr, buffer, len, &wlen) && len == wlen;
  492. }
  493. static inline void* dbg_heap_realloc(void* buffer, size_t size)
  494. {
  495. return (buffer) ? HeapReAlloc(GetProcessHeap(), 0, buffer, size) :
  496. HeapAlloc(GetProcessHeap(), 0, size);
  497. }
  498. extern struct dbg_internal_var dbg_internal_vars[];
  499. #define DBG_IVARNAME(_var) dbg_internal_var_##_var
  500. #define DBG_IVARSTRUCT(_var) dbg_internal_vars[DBG_IVARNAME(_var)]
  501. #define DBG_IVAR(_var) (DBG_IVARSTRUCT(_var).val)
  502. #define INTERNAL_VAR(_var,_val,_ref,itype) DBG_IVARNAME(_var),
  503. enum debug_int_var
  504. {
  505. #include "intvar.h"
  506. DBG_IV_LAST
  507. };
  508. #undef INTERNAL_VAR
  509. /* include CPU dependent bits */
  510. #include "be_cpu.h"
  511. #endif /* __WINE_DEBUGGER_H */