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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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
);
52 unsigned elt_size
: 24, shift
: 8;
53 unsigned num_elts
: 20, num_buckets
: 12;
56 void vector_init(struct vector
* v
, unsigned elt_sz
, unsigned bucket_sz
);
57 unsigned vector_length(const struct vector
* v
);
58 void* vector_at(const struct vector
* v
, unsigned pos
);
59 void* vector_add(struct vector
* v
, struct pool
* pool
);
60 /*void vector_pool_normalize(struct vector* v, struct pool* pool); */
61 void* vector_iter_up(const struct vector
* v
, void* elt
);
62 void* vector_iter_down(const struct vector
* v
, void* elt
);
67 struct hash_table_elt
* next
;
73 struct hash_table_elt
** buckets
;
76 void hash_table_init(struct pool
* pool
, struct hash_table
* ht
,
77 unsigned num_buckets
);
78 void hash_table_destroy(struct hash_table
* ht
);
79 void hash_table_add(struct hash_table
* ht
, struct hash_table_elt
* elt
);
80 void* hash_table_find(const struct hash_table
* ht
, const char* name
);
81 unsigned hash_table_hash(const char* name
, unsigned num_buckets
);
83 struct hash_table_iter
85 const struct hash_table
* ht
;
86 struct hash_table_elt
* element
;
91 void hash_table_iter_init(const struct hash_table
* ht
,
92 struct hash_table_iter
* hti
, const char* name
);
93 void* hash_table_iter_up(struct hash_table_iter
* hti
);
95 #define GET_ENTRY(__i, __t, __f) \
96 ((__t*)((char*)(__i) - (unsigned int)(&((__t*)0)->__f)))
99 extern unsigned dbghelp_options
;
109 struct hash_table_elt hash_elt
; /* if global symbol or type */
116 unsigned long address
;
118 struct symt
* container
; /* block, or func */
119 struct vector vchildren
; /* sub-blocks & local variables */
122 struct symt_compiland
126 struct vector vchildren
; /* global variables & functions */
132 struct hash_table_elt hash_elt
; /* if global symbol */
134 struct symt
* container
;
136 union /* depends on kind */
138 unsigned long address
; /* DataIs{Global, FileStatic} */
141 long offset
; /* DataIs{Member,Local,Param} in bits*/
142 unsigned long length
; /* DataIs{Member} in bits */
143 unsigned long reg_id
; /* DataIs{Local} (0 if frame relative) */
145 VARIANT value
; /* DataIsConstant */
152 struct hash_table_elt hash_elt
; /* if global symbol */
153 unsigned long address
;
154 struct symt
* container
; /* compiland */
155 struct symt
* type
; /* points to function_signature */
157 struct vector vlines
;
158 struct vector vchildren
; /* locals, params, blocks, start/end, labels */
161 struct symt_function_point
163 struct symt symt
; /* either SymTagFunctionDebugStart, SymTagFunctionDebugEnd, SymTagLabel */
164 struct symt_function
* parent
;
165 unsigned long offset
;
166 const char* name
; /* for labels */
172 struct hash_table_elt hash_elt
;
173 struct symt
* container
; /* compiland */
174 unsigned long address
;
176 unsigned in_code
: 1,
183 struct hash_table_elt hash_elt
;
184 struct symt
* container
; /* compiland */
185 unsigned long address
;
187 THUNK_ORDINAL ordinal
; /* FIXME: doesn't seem to be accessible */
196 struct symt
* basetype
;
202 struct hash_table_elt hash_elt
;
211 struct vector vchildren
;
214 struct symt_function_signature
217 struct symt
* rettype
;
218 struct vector vchildren
;
224 struct symt
* pointsto
;
230 struct hash_table_elt hash_elt
;
237 struct hash_table_elt hash_elt
;
240 struct vector vchildren
;
245 DMT_UNKNOWN
, /* for lookup, not actually used for a module */
246 DMT_ELF
, /* a real ELF shared module */
247 DMT_PE
, /* a native or builtin PE module */
252 IMAGEHLP_MODULE module
;
254 enum module_type type
;
255 struct elf_module_info
* elf_info
;
257 /* memory allocation pool */
262 struct symt_ht
** addr_sorttab
;
263 struct hash_table ht_symbols
;
266 struct hash_table ht_types
;
269 unsigned sources_used
;
270 unsigned sources_alloc
;
276 struct process
* next
;
280 struct module
* lmodules
;
281 unsigned long dbg_hdr_addr
;
283 IMAGEHLP_STACK_FRAME ctx_frame
;
287 extern struct process
* process_find_by_handle(HANDLE hProcess
);
290 extern BOOL
elf_load_debug_info(struct module
* module
);
291 extern struct module
*
292 elf_load_module(struct process
* pcs
, const char* name
);
293 extern BOOL
elf_read_wine_loader_dbg_info(struct process
* pcs
);
294 extern BOOL
elf_synchronize_module_list(struct process
* pcs
);
299 BOOL (*read_mem
)(HANDLE hProcess
, DWORD addr
, void* buf
, DWORD len
);
300 BOOL (*write_mem
)(HANDLE hProcess
, DWORD addr
, void* buf
, DWORD len
);
303 extern struct memory_access mem_access
;
304 #define read_mem(p,a,b,l) (mem_access.read_mem)((p),(a),(b),(l))
305 #define write_mem(p,a,b,l) (mem_access.write_mem)((p),(a),(b),(l))
306 extern unsigned long WINAPI
addr_to_linear(HANDLE hProcess
, HANDLE hThread
, ADDRESS
* addr
);
309 extern struct module
*
310 module_find_by_addr(const struct process
* pcs
, unsigned long addr
,
311 enum module_type type
);
312 extern struct module
*
313 module_find_by_name(const struct process
* pcs
,
314 const char* name
, enum module_type type
);
315 extern struct module
*
316 module_get_debug(const struct process
* pcs
, struct module
*);
317 extern struct module
*
318 module_new(struct process
* pcs
, const char* name
,
319 enum module_type type
, unsigned long addr
,
320 unsigned long size
, unsigned long stamp
,
321 unsigned long checksum
);
322 extern struct module
*
323 module_get_container(const struct process
* pcs
,
324 const struct module
* inner
);
325 extern struct module
*
326 module_get_containee(const struct process
* pcs
,
327 const struct module
* inner
);
328 extern void module_reset_debug_info(struct module
* module
);
329 extern BOOL
module_remove(struct process
* pcs
,
330 struct module
* module
);
332 extern BOOL
pe_load_debug_directory(const struct process
* pcs
,
333 struct module
* module
,
334 const BYTE
* file_map
,
335 const IMAGE_DEBUG_DIRECTORY
* dbg
, int nDbg
);
337 extern struct module
*
338 pe_load_module(struct process
* pcs
, char* name
,
339 HANDLE hFile
, DWORD base
, DWORD size
);
340 extern struct module
*
341 pe_load_module_from_pcs(struct process
* pcs
, const char* name
,
342 const char* mod_name
, DWORD base
, DWORD size
);
343 extern BOOL
pe_load_debug_info(const struct process
* pcs
,
344 struct module
* module
);
346 extern unsigned source_new(struct module
* module
, const char* source
);
347 extern const char* source_get(const struct module
* module
, unsigned idx
);
350 extern BOOL
stabs_parse(struct module
* module
, const char* addr
,
351 unsigned long load_offset
,
352 unsigned int staboff
, int stablen
,
353 unsigned int strtaboff
, int strtablen
);
356 extern const char* symt_get_name(const struct symt
* sym
);
357 extern int symt_cmp_addr(const void* p1
, const void* p2
);
358 extern int symt_find_nearest(struct module
* module
, DWORD addr
);
359 extern struct symt_compiland
*
360 symt_new_compiland(struct module
* module
,
361 const char* filename
);
362 extern struct symt_public
*
363 symt_new_public(struct module
* module
,
364 struct symt_compiland
* parent
,
365 const char* typename
,
366 unsigned long address
, unsigned size
,
367 BOOL in_code
, BOOL is_func
);
368 extern struct symt_data
*
369 symt_new_global_variable(struct module
* module
,
370 struct symt_compiland
* parent
,
371 const char* name
, unsigned is_static
,
372 unsigned long addr
, unsigned long size
,
374 extern struct symt_function
*
375 symt_new_function(struct module
* module
,
376 struct symt_compiland
* parent
,
378 unsigned long addr
, unsigned long size
,
380 extern BOOL
symt_normalize_function(struct module
* module
,
381 struct symt_function
* func
);
382 extern void symt_add_func_line(struct module
* module
,
383 struct symt_function
* func
,
384 unsigned source_idx
, int line_num
,
385 unsigned long offset
);
386 extern struct symt_data
*
387 symt_add_func_local(struct module
* module
,
388 struct symt_function
* func
,
389 int regno
, int offset
,
390 struct symt_block
* block
,
391 struct symt
* type
, const char* name
);
392 extern struct symt_block
*
393 symt_open_func_block(struct module
* module
,
394 struct symt_function
* func
,
395 struct symt_block
* block
,
396 unsigned pc
, unsigned len
);
397 extern struct symt_block
*
398 symt_close_func_block(struct module
* module
,
399 struct symt_function
* func
,
400 struct symt_block
* block
, unsigned pc
);
401 extern struct symt_function_point
*
402 symt_add_function_point(struct module
* module
,
403 struct symt_function
* func
,
404 enum SymTagEnum point
,
405 unsigned offset
, const char* name
);
406 extern BOOL
symt_fill_func_line_info(struct module
* module
,
407 struct symt_function
* func
,
408 DWORD addr
, IMAGEHLP_LINE
* line
);
409 extern BOOL
symt_get_func_line_next(struct module
* module
, PIMAGEHLP_LINE line
);
410 extern struct symt_thunk
*
411 symt_new_thunk(struct module
* module
,
412 struct symt_compiland
* parent
,
413 const char* name
, THUNK_ORDINAL ord
,
414 unsigned long addr
, unsigned long size
);
417 extern void symt_init_basic(struct module
* module
);
418 extern BOOL
symt_get_info(const struct symt
* type
,
419 IMAGEHLP_SYMBOL_TYPE_INFO req
, void* pInfo
);
420 extern struct symt_basic
*
421 symt_new_basic(struct module
* module
, enum BasicType
,
422 const char* typename
, unsigned size
);
423 extern struct symt_udt
*
424 symt_new_udt(struct module
* module
, const char* typename
,
425 unsigned size
, enum UdtKind kind
);
426 extern BOOL
symt_set_udt_size(struct module
* module
,
427 struct symt_udt
* type
, unsigned size
);
428 extern BOOL
symt_add_udt_element(struct module
* module
,
429 struct symt_udt
* udt_type
,
431 struct symt
* elt_type
, unsigned offset
,
433 extern struct symt_enum
*
434 symt_new_enum(struct module
* module
, const char* typename
);
435 extern BOOL
symt_add_enum_element(struct module
* module
,
436 struct symt_enum
* enum_type
,
437 const char* name
, int value
);
438 extern struct symt_array
*
439 symt_new_array(struct module
* module
, int min
, int max
,
441 extern struct symt_function_signature
*
442 symt_new_function_signature(struct module
* module
,
443 struct symt
* ret_type
);
444 extern BOOL
symt_add_function_signature_parameter(struct module
* module
,
445 struct symt_function_signature
* sig
,
447 extern struct symt_pointer
*
448 symt_new_pointer(struct module
* module
,
449 struct symt
* ref_type
);
450 extern struct symt_typedef
*
451 symt_new_typedef(struct module
* module
, struct symt
* ref
,
455 /* some more Wine extensions */
456 #define SYMOPT_WINE_WITH_ELF_MODULES 0x40000000