2 * File dbghelp_private.h - dbghelp internal definitions
4 * Copyright (C) 1995, Alexandre Julliard
5 * Copyright (C) 1996, Eric Youngdale.
6 * Copyright (C) 1999-2000, Ulrich Weigand.
7 * Copyright (C) 2004, Eric Pouech.
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
34 /* #define USE_STATS */
36 struct pool /* poor's man */
38 struct pool_arena* first;
42 void pool_init(struct pool* a, unsigned arena_size);
43 void pool_destroy(struct pool* a);
44 void* pool_alloc(struct pool* a, unsigned len);
45 /* void* pool_realloc(struct pool* a, void* p,
46 unsigned old_size, unsigned new_size); */
47 char* pool_strdup(struct pool* a, const char* str);
58 void vector_init(struct vector* v, unsigned elt_sz, unsigned bucket_sz);
59 unsigned vector_length(const struct vector* v);
60 void* vector_at(const struct vector* v, unsigned pos);
61 void* vector_add(struct vector* v, struct pool* pool);
62 /*void vector_pool_normalize(struct vector* v, struct pool* pool); */
63 void* vector_iter_up(const struct vector* v, void* elt);
64 void* vector_iter_down(const struct vector* v, void* elt);
68 struct vector key2index;
69 struct vector elements;
72 void sparse_array_init(struct sparse_array* sa, unsigned elt_sz, unsigned bucket_sz);
73 void* sparse_array_find(const struct sparse_array* sa, unsigned long idx);
74 void* sparse_array_add(struct sparse_array* sa, unsigned long key, struct pool* pool);
75 unsigned sparse_array_length(const struct sparse_array* sa);
80 struct hash_table_elt* next;
86 struct hash_table_elt** buckets;
89 void hash_table_init(struct pool* pool, struct hash_table* ht,
90 unsigned num_buckets);
91 void hash_table_destroy(struct hash_table* ht);
92 void hash_table_add(struct hash_table* ht, struct hash_table_elt* elt);
93 void* hash_table_find(const struct hash_table* ht, const char* name);
94 unsigned hash_table_hash(const char* name, unsigned num_buckets);
96 struct hash_table_iter
98 const struct hash_table* ht;
99 struct hash_table_elt* element;
104 void hash_table_iter_init(const struct hash_table* ht,
105 struct hash_table_iter* hti, const char* name);
106 void* hash_table_iter_up(struct hash_table_iter* hti);
108 #define GET_ENTRY(__i, __t, __f) \
109 ((__t*)((char*)(__i) - (unsigned int)(&((__t*)0)->__f)))
112 extern unsigned dbghelp_options;
113 /* some more Wine extensions */
114 #define SYMOPT_WINE_WITH_ELF_MODULES 0x40000000
124 struct hash_table_elt hash_elt; /* if global symbol or type */
131 unsigned long address;
133 struct symt* container; /* block, or func */
134 struct vector vchildren; /* sub-blocks & local variables */
137 struct symt_compiland
141 struct vector vchildren; /* global variables & functions */
147 struct hash_table_elt hash_elt; /* if global symbol */
149 struct symt* container;
151 union /* depends on kind */
153 unsigned long address; /* DataIs{Global, FileStatic} */
156 long offset; /* DataIs{Member,Local,Param} in bits */
157 unsigned long length; /* DataIs{Member} in bits */
158 unsigned long reg_id; /* DataIs{Local} (0 if frame relative) */
160 VARIANT value; /* DataIsConstant */
167 struct hash_table_elt hash_elt; /* if global symbol */
168 unsigned long address;
169 struct symt* container; /* compiland */
170 struct symt* type; /* points to function_signature */
172 struct vector vlines;
173 struct vector vchildren; /* locals, params, blocks, start/end, labels */
176 struct symt_function_point
178 struct symt symt; /* either SymTagFunctionDebugStart, SymTagFunctionDebugEnd, SymTagLabel */
179 struct symt_function* parent;
180 unsigned long offset;
181 const char* name; /* for labels */
187 struct hash_table_elt hash_elt;
188 struct symt* container; /* compiland */
189 unsigned long address;
191 unsigned in_code : 1,
198 struct hash_table_elt hash_elt;
199 struct symt* container; /* compiland */
200 unsigned long address;
202 THUNK_ORDINAL ordinal; /* FIXME: doesn't seem to be accessible */
211 struct symt* base_type;
212 struct symt* index_type;
218 struct hash_table_elt hash_elt;
227 struct vector vchildren;
230 struct symt_function_signature
233 struct symt* rettype;
234 struct vector vchildren;
235 enum CV_call_e call_conv;
238 struct symt_function_arg_type
241 struct symt* arg_type;
242 struct symt* container;
248 struct symt* pointsto;
254 struct hash_table_elt hash_elt;
261 struct hash_table_elt hash_elt;
264 struct vector vchildren;
269 DMT_UNKNOWN, /* for lookup, not actually used for a module */
270 DMT_ELF, /* a real ELF shared module */
271 DMT_PE, /* a native or builtin PE module */
272 DMT_PDB, /* PDB file */
277 IMAGEHLP_MODULE64 module;
279 enum module_type type : 16;
280 unsigned short is_virtual : 1;
281 struct elf_module_info* elf_info;
283 /* memory allocation pool */
288 struct symt_ht** addr_sorttab;
289 struct hash_table ht_symbols;
292 struct hash_table ht_types;
293 struct vector vtypes;
296 unsigned sources_used;
297 unsigned sources_alloc;
303 struct process* next;
307 PSYMBOL_REGISTERED_CALLBACK64 reg_cb;
311 struct module* lmodules;
312 unsigned long dbg_hdr_addr;
314 IMAGEHLP_STACK_FRAME ctx_frame;
316 unsigned buffer_size;
322 unsigned long is_first : 1,
328 unsigned long pc_offset; /* if is_source_file isn't set */
329 unsigned source_file; /* if is_source_file is set */
335 struct module* requested; /* in: to module_get_debug() */
336 struct module* effective; /* out: module with debug info */
339 enum pdb_kind {PDB_JG, PDB_DS};
343 const char* filename;
351 struct PDB_JG_TOC* toc;
356 struct PDB_DS_TOC* toc;
362 extern struct process* process_find_by_handle(HANDLE hProcess);
363 extern HANDLE hMsvcrt;
364 extern BOOL validate_addr64(DWORD64 addr);
365 extern BOOL pcs_callback(const struct process* pcs, ULONG action, void* data);
366 extern void* fetch_buffer(struct process* pcs, unsigned size);
369 typedef BOOL (*elf_enum_modules_cb)(const char*, unsigned long addr, void* user);
370 extern BOOL elf_enum_modules(HANDLE hProc, elf_enum_modules_cb, void*);
371 extern BOOL elf_fetch_file_info(const char* name, DWORD* base, DWORD* size, DWORD* checksum);
373 extern BOOL elf_load_debug_info(struct module* module, struct elf_file_map* fmap);
374 extern struct module*
375 elf_load_module(struct process* pcs, const char* name, unsigned long);
376 extern BOOL elf_read_wine_loader_dbg_info(struct process* pcs);
377 extern BOOL elf_synchronize_module_list(struct process* pcs);
378 struct elf_thunk_area;
379 extern int elf_is_in_thunk_area(unsigned long addr, const struct elf_thunk_area* thunks);
380 extern DWORD WINAPI addr_to_linear(HANDLE hProcess, HANDLE hThread, ADDRESS* addr);
383 extern int module_compute_num_syms(struct module* module);
384 extern struct module*
385 module_find_by_addr(const struct process* pcs, unsigned long addr,
386 enum module_type type);
387 extern struct module*
388 module_find_by_name(const struct process* pcs,
389 const char* name, enum module_type type);
390 extern BOOL module_get_debug(const struct process* pcs, struct module_pair*);
391 extern struct module*
392 module_new(struct process* pcs, const char* name,
393 enum module_type type, BOOL virtual,
394 unsigned long addr, unsigned long size,
395 unsigned long stamp, unsigned long checksum);
396 extern struct module*
397 module_get_container(const struct process* pcs,
398 const struct module* inner);
399 extern struct module*
400 module_get_containee(const struct process* pcs,
401 const struct module* inner);
402 extern enum module_type
403 module_get_type_by_name(const char* name);
404 extern void module_reset_debug_info(struct module* module);
405 extern BOOL module_remove(struct process* pcs,
406 struct module* module);
408 extern BOOL pe_load_debug_directory(const struct process* pcs,
409 struct module* module,
411 const IMAGE_SECTION_HEADER* sectp, DWORD nsect,
412 const IMAGE_DEBUG_DIRECTORY* dbg, int nDbg);
413 extern BOOL pdb_fetch_file_info(struct pdb_lookup* pdb_lookup);
416 extern BOOL pe_load_nt_header(HANDLE hProc, DWORD base, IMAGE_NT_HEADERS* nth);
417 extern struct module*
418 pe_load_module(struct process* pcs, const char* name,
419 HANDLE hFile, DWORD base, DWORD size);
420 extern struct module*
421 pe_load_module_from_pcs(struct process* pcs, const char* name,
422 const char* mod_name, DWORD base, DWORD size);
423 extern BOOL pe_load_debug_info(const struct process* pcs,
424 struct module* module);
426 extern unsigned source_new(struct module* module, const char* basedir, const char* source);
427 extern const char* source_get(const struct module* module, unsigned idx);
430 extern BOOL stabs_parse(struct module* module, unsigned long load_offset,
431 const void* stabs, int stablen,
432 const char* strs, int strtablen);
435 extern BOOL dwarf2_parse(struct module* module, unsigned long load_offset,
436 const struct elf_thunk_area* thunks,
437 const unsigned char* debug, unsigned int debug_size,
438 const unsigned char* abbrev, unsigned int abbrev_size,
439 const unsigned char* str, unsigned int str_size,
440 const unsigned char* line, unsigned int line_size);
443 extern const char* symt_get_name(const struct symt* sym);
444 extern int symt_cmp_addr(const void* p1, const void* p2);
445 extern int symt_find_nearest(struct module* module, DWORD addr);
446 extern struct symt_compiland*
447 symt_new_compiland(struct module* module, unsigned src_idx);
448 extern struct symt_public*
449 symt_new_public(struct module* module,
450 struct symt_compiland* parent,
451 const char* typename,
452 unsigned long address, unsigned size,
453 BOOL in_code, BOOL is_func);
454 extern struct symt_data*
455 symt_new_global_variable(struct module* module,
456 struct symt_compiland* parent,
457 const char* name, unsigned is_static,
458 unsigned long addr, unsigned long size,
460 extern struct symt_function*
461 symt_new_function(struct module* module,
462 struct symt_compiland* parent,
464 unsigned long addr, unsigned long size,
466 extern BOOL symt_normalize_function(struct module* module,
467 struct symt_function* func);
468 extern void symt_add_func_line(struct module* module,
469 struct symt_function* func,
470 unsigned source_idx, int line_num,
471 unsigned long offset);
472 extern struct symt_data*
473 symt_add_func_local(struct module* module,
474 struct symt_function* func,
475 enum DataKind dt, int regno, long offset,
476 struct symt_block* block,
477 struct symt* type, const char* name);
478 extern struct symt_block*
479 symt_open_func_block(struct module* module,
480 struct symt_function* func,
481 struct symt_block* block,
482 unsigned pc, unsigned len);
483 extern struct symt_block*
484 symt_close_func_block(struct module* module,
485 struct symt_function* func,
486 struct symt_block* block, unsigned pc);
487 extern struct symt_function_point*
488 symt_add_function_point(struct module* module,
489 struct symt_function* func,
490 enum SymTagEnum point,
491 unsigned offset, const char* name);
492 extern BOOL symt_fill_func_line_info(struct module* module,
493 struct symt_function* func,
494 DWORD addr, IMAGEHLP_LINE* line);
495 extern BOOL symt_get_func_line_next(struct module* module, PIMAGEHLP_LINE line);
496 extern struct symt_thunk*
497 symt_new_thunk(struct module* module,
498 struct symt_compiland* parent,
499 const char* name, THUNK_ORDINAL ord,
500 unsigned long addr, unsigned long size);
503 extern void symt_init_basic(struct module* module);
504 extern BOOL symt_get_info(const struct symt* type,
505 IMAGEHLP_SYMBOL_TYPE_INFO req, void* pInfo);
506 extern struct symt_basic*
507 symt_new_basic(struct module* module, enum BasicType,
508 const char* typename, unsigned size);
509 extern struct symt_udt*
510 symt_new_udt(struct module* module, const char* typename,
511 unsigned size, enum UdtKind kind);
512 extern BOOL symt_set_udt_size(struct module* module,
513 struct symt_udt* type, unsigned size);
514 extern BOOL symt_add_udt_element(struct module* module,
515 struct symt_udt* udt_type,
517 struct symt* elt_type, unsigned offset,
519 extern struct symt_enum*
520 symt_new_enum(struct module* module, const char* typename);
521 extern BOOL symt_add_enum_element(struct module* module,
522 struct symt_enum* enum_type,
523 const char* name, int value);
524 extern struct symt_array*
525 symt_new_array(struct module* module, int min, int max,
526 struct symt* base, struct symt* index);
527 extern struct symt_function_signature*
528 symt_new_function_signature(struct module* module,
529 struct symt* ret_type,
530 enum CV_call_e call_conv);
531 extern BOOL symt_add_function_signature_parameter(struct module* module,
532 struct symt_function_signature* sig,
534 extern struct symt_pointer*
535 symt_new_pointer(struct module* module,
536 struct symt* ref_type);
537 extern struct symt_typedef*
538 symt_new_typedef(struct module* module, struct symt* ref,