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
);
69 struct hash_table_elt
* next
;
75 struct hash_table_elt
** buckets
;
78 void hash_table_init(struct pool
* pool
, struct hash_table
* ht
,
79 unsigned num_buckets
);
80 void hash_table_destroy(struct hash_table
* ht
);
81 void hash_table_add(struct hash_table
* ht
, struct hash_table_elt
* elt
);
82 void* hash_table_find(const struct hash_table
* ht
, const char* name
);
83 unsigned hash_table_hash(const char* name
, unsigned num_buckets
);
85 struct hash_table_iter
87 const struct hash_table
* ht
;
88 struct hash_table_elt
* element
;
93 void hash_table_iter_init(const struct hash_table
* ht
,
94 struct hash_table_iter
* hti
, const char* name
);
95 void* hash_table_iter_up(struct hash_table_iter
* hti
);
97 #define GET_ENTRY(__i, __t, __f) \
98 ((__t*)((char*)(__i) - (unsigned int)(&((__t*)0)->__f)))
101 extern unsigned dbghelp_options
;
102 /* some more Wine extensions */
103 #define SYMOPT_WINE_WITH_ELF_MODULES 0x40000000
113 struct hash_table_elt hash_elt
; /* if global symbol or type */
120 unsigned long address
;
122 struct symt
* container
; /* block, or func */
123 struct vector vchildren
; /* sub-blocks & local variables */
126 struct symt_compiland
130 struct vector vchildren
; /* global variables & functions */
136 struct hash_table_elt hash_elt
; /* if global symbol */
138 struct symt
* container
;
140 union /* depends on kind */
142 unsigned long address
; /* DataIs{Global, FileStatic} */
145 long offset
; /* DataIs{Member,Local,Param} in bits */
146 unsigned long length
; /* DataIs{Member} in bits */
147 unsigned long reg_id
; /* DataIs{Local} (0 if frame relative) */
149 VARIANT value
; /* DataIsConstant */
156 struct hash_table_elt hash_elt
; /* if global symbol */
157 unsigned long address
;
158 struct symt
* container
; /* compiland */
159 struct symt
* type
; /* points to function_signature */
161 struct vector vlines
;
162 struct vector vchildren
; /* locals, params, blocks, start/end, labels */
165 struct symt_function_point
167 struct symt symt
; /* either SymTagFunctionDebugStart, SymTagFunctionDebugEnd, SymTagLabel */
168 struct symt_function
* parent
;
169 unsigned long offset
;
170 const char* name
; /* for labels */
176 struct hash_table_elt hash_elt
;
177 struct symt
* container
; /* compiland */
178 unsigned long address
;
180 unsigned in_code
: 1,
187 struct hash_table_elt hash_elt
;
188 struct symt
* container
; /* compiland */
189 unsigned long address
;
191 THUNK_ORDINAL ordinal
; /* FIXME: doesn't seem to be accessible */
200 struct symt
* base_type
;
201 struct symt
* index_type
;
207 struct hash_table_elt hash_elt
;
216 struct vector vchildren
;
219 struct symt_function_signature
222 struct symt
* rettype
;
223 struct vector vchildren
;
224 enum CV_call_e call_conv
;
227 struct symt_function_arg_type
230 struct symt
* arg_type
;
231 struct symt
* container
;
237 struct symt
* pointsto
;
243 struct hash_table_elt hash_elt
;
250 struct hash_table_elt hash_elt
;
253 struct vector vchildren
;
258 DMT_UNKNOWN
, /* for lookup, not actually used for a module */
259 DMT_ELF
, /* a real ELF shared module */
260 DMT_PE
, /* a native or builtin PE module */
261 DMT_PDB
, /* PDB file */
266 IMAGEHLP_MODULE module
;
268 enum module_type type
: 16;
269 unsigned short is_virtual
: 1;
270 struct elf_module_info
* elf_info
;
272 /* memory allocation pool */
277 struct symt_ht
** addr_sorttab
;
278 struct hash_table ht_symbols
;
281 struct hash_table ht_types
;
282 struct vector vtypes
;
285 unsigned sources_used
;
286 unsigned sources_alloc
;
292 struct process
* next
;
296 PSYMBOL_REGISTERED_CALLBACK64 reg_cb
;
300 struct module
* lmodules
;
301 unsigned long dbg_hdr_addr
;
303 IMAGEHLP_STACK_FRAME ctx_frame
;
305 unsigned buffer_size
;
311 unsigned long is_first
: 1,
317 unsigned long pc_offset
; /* if is_source_file isn't set */
318 unsigned source_file
; /* if is_source_file is set */
324 struct module
* requested
; /* in: to module_get_debug() */
325 struct module
* effective
; /* out: module with debug info */
328 enum pdb_kind
{PDB_JG
, PDB_DS
};
332 const char* filename
;
340 struct PDB_JG_TOC
* toc
;
345 struct PDB_DS_TOC
* toc
;
351 extern struct process
* process_find_by_handle(HANDLE hProcess
);
352 extern HANDLE hMsvcrt
;
353 extern BOOL
validate_addr64(DWORD64 addr
);
354 extern BOOL
pcs_callback(const struct process
* pcs
, ULONG action
, void* data
);
355 extern void* fetch_buffer(struct process
* pcs
, unsigned size
);
358 typedef BOOL (*elf_enum_modules_cb
)(const char*, unsigned long addr
, void* user
);
359 extern BOOL
elf_enum_modules(HANDLE hProc
, elf_enum_modules_cb
, void*);
360 extern BOOL
elf_fetch_file_info(const char* name
, DWORD
* base
, DWORD
* size
, DWORD
* checksum
);
362 extern BOOL
elf_load_debug_info(struct module
* module
, struct elf_file_map
* fmap
);
363 extern struct module
*
364 elf_load_module(struct process
* pcs
, const char* name
, unsigned long);
365 extern BOOL
elf_read_wine_loader_dbg_info(struct process
* pcs
);
366 extern BOOL
elf_synchronize_module_list(struct process
* pcs
);
368 extern DWORD WINAPI
addr_to_linear(HANDLE hProcess
, HANDLE hThread
, ADDRESS
* addr
);
371 extern int module_compute_num_syms(struct module
* module
);
372 extern struct module
*
373 module_find_by_addr(const struct process
* pcs
, unsigned long addr
,
374 enum module_type type
);
375 extern struct module
*
376 module_find_by_name(const struct process
* pcs
,
377 const char* name
, enum module_type type
);
378 extern BOOL
module_get_debug(const struct process
* pcs
, struct module_pair
*);
379 extern struct module
*
380 module_new(struct process
* pcs
, const char* name
,
381 enum module_type type
, BOOL
virtual,
382 unsigned long addr
, unsigned long size
,
383 unsigned long stamp
, unsigned long checksum
);
384 extern struct module
*
385 module_get_container(const struct process
* pcs
,
386 const struct module
* inner
);
387 extern struct module
*
388 module_get_containee(const struct process
* pcs
,
389 const struct module
* inner
);
390 extern enum module_type
391 module_get_type_by_name(const char* name
);
392 extern void module_reset_debug_info(struct module
* module
);
393 extern BOOL
module_remove(struct process
* pcs
,
394 struct module
* module
);
396 extern BOOL
pe_load_debug_directory(const struct process
* pcs
,
397 struct module
* module
,
399 const IMAGE_SECTION_HEADER
* sectp
, DWORD nsect
,
400 const IMAGE_DEBUG_DIRECTORY
* dbg
, int nDbg
);
401 extern BOOL
pdb_fetch_file_info(struct pdb_lookup
* pdb_lookup
);
404 extern BOOL
pe_load_nt_header(HANDLE hProc
, DWORD base
, IMAGE_NT_HEADERS
* nth
);
405 extern struct module
*
406 pe_load_module(struct process
* pcs
, const char* name
,
407 HANDLE hFile
, DWORD base
, DWORD size
);
408 extern struct module
*
409 pe_load_module_from_pcs(struct process
* pcs
, const char* name
,
410 const char* mod_name
, DWORD base
, DWORD size
);
411 extern BOOL
pe_load_debug_info(const struct process
* pcs
,
412 struct module
* module
);
414 extern unsigned source_new(struct module
* module
, const char* source
);
415 extern const char* source_get(const struct module
* module
, unsigned idx
);
418 extern BOOL
stabs_parse(struct module
* module
, unsigned long load_offset
,
419 const void* stabs
, int stablen
,
420 const char* strs
, int strtablen
);
423 extern BOOL
dwarf2_parse(struct module
* module
, unsigned long load_offset
,
424 const unsigned char* debug
, unsigned int debug_size
,
425 const unsigned char* abbrev
, unsigned int abbrev_size
,
426 const unsigned char* str
, unsigned int str_sz
);
429 extern const char* symt_get_name(const struct symt
* sym
);
430 extern int symt_cmp_addr(const void* p1
, const void* p2
);
431 extern int symt_find_nearest(struct module
* module
, DWORD addr
);
432 extern struct symt_compiland
*
433 symt_new_compiland(struct module
* module
,
434 const char* filename
);
435 extern struct symt_public
*
436 symt_new_public(struct module
* module
,
437 struct symt_compiland
* parent
,
438 const char* typename
,
439 unsigned long address
, unsigned size
,
440 BOOL in_code
, BOOL is_func
);
441 extern struct symt_data
*
442 symt_new_global_variable(struct module
* module
,
443 struct symt_compiland
* parent
,
444 const char* name
, unsigned is_static
,
445 unsigned long addr
, unsigned long size
,
447 extern struct symt_function
*
448 symt_new_function(struct module
* module
,
449 struct symt_compiland
* parent
,
451 unsigned long addr
, unsigned long size
,
453 extern BOOL
symt_normalize_function(struct module
* module
,
454 struct symt_function
* func
);
455 extern void symt_add_func_line(struct module
* module
,
456 struct symt_function
* func
,
457 unsigned source_idx
, int line_num
,
458 unsigned long offset
);
459 extern struct symt_data
*
460 symt_add_func_local(struct module
* module
,
461 struct symt_function
* func
,
462 int regno
, int offset
,
463 struct symt_block
* block
,
464 struct symt
* type
, const char* name
);
465 extern struct symt_block
*
466 symt_open_func_block(struct module
* module
,
467 struct symt_function
* func
,
468 struct symt_block
* block
,
469 unsigned pc
, unsigned len
);
470 extern struct symt_block
*
471 symt_close_func_block(struct module
* module
,
472 struct symt_function
* func
,
473 struct symt_block
* block
, unsigned pc
);
474 extern struct symt_function_point
*
475 symt_add_function_point(struct module
* module
,
476 struct symt_function
* func
,
477 enum SymTagEnum point
,
478 unsigned offset
, const char* name
);
479 extern BOOL
symt_fill_func_line_info(struct module
* module
,
480 struct symt_function
* func
,
481 DWORD addr
, IMAGEHLP_LINE
* line
);
482 extern BOOL
symt_get_func_line_next(struct module
* module
, PIMAGEHLP_LINE line
);
483 extern struct symt_thunk
*
484 symt_new_thunk(struct module
* module
,
485 struct symt_compiland
* parent
,
486 const char* name
, THUNK_ORDINAL ord
,
487 unsigned long addr
, unsigned long size
);
490 extern void symt_init_basic(struct module
* module
);
491 extern BOOL
symt_get_info(const struct symt
* type
,
492 IMAGEHLP_SYMBOL_TYPE_INFO req
, void* pInfo
);
493 extern struct symt_basic
*
494 symt_new_basic(struct module
* module
, enum BasicType
,
495 const char* typename
, unsigned size
);
496 extern struct symt_udt
*
497 symt_new_udt(struct module
* module
, const char* typename
,
498 unsigned size
, enum UdtKind kind
);
499 extern BOOL
symt_set_udt_size(struct module
* module
,
500 struct symt_udt
* type
, unsigned size
);
501 extern BOOL
symt_add_udt_element(struct module
* module
,
502 struct symt_udt
* udt_type
,
504 struct symt
* elt_type
, unsigned offset
,
506 extern struct symt_enum
*
507 symt_new_enum(struct module
* module
, const char* typename
);
508 extern BOOL
symt_add_enum_element(struct module
* module
,
509 struct symt_enum
* enum_type
,
510 const char* name
, int value
);
511 extern struct symt_array
*
512 symt_new_array(struct module
* module
, int min
, int max
,
513 struct symt
* base
, struct symt
* index
);
514 extern struct symt_function_signature
*
515 symt_new_function_signature(struct module
* module
,
516 struct symt
* ret_type
,
517 enum CV_call_e call_conv
);
518 extern BOOL
symt_add_function_signature_parameter(struct module
* module
,
519 struct symt_function_signature
* sig
,
521 extern struct symt_pointer
*
522 symt_new_pointer(struct module
* module
,
523 struct symt
* ref_type
);
524 extern struct symt_typedef
*
525 symt_new_typedef(struct module
* module
, struct symt
* ref
,