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
32 /* #define USE_STATS */
34 struct pool /* poor's man */
36 struct pool_arena* first;
40 void pool_init(struct pool* a, unsigned arena_size);
41 void pool_destroy(struct pool* a);
42 void* pool_alloc(struct pool* a, unsigned len);
43 /* void* pool_realloc(struct pool* a, void* p,
44 unsigned old_size, unsigned new_size); */
45 char* pool_strdup(struct pool* a, const char* str);
50 unsigned elt_size : 24, shift : 8;
51 unsigned num_elts : 20, num_buckets : 12;
54 void vector_init(struct vector* v, unsigned elt_sz, unsigned bucket_sz);
55 unsigned vector_length(const struct vector* v);
56 void* vector_at(const struct vector* v, unsigned pos);
57 void* vector_add(struct vector* v, struct pool* pool);
58 /*void vector_pool_normalize(struct vector* v, struct pool* pool); */
59 void* vector_iter_up(const struct vector* v, void* elt);
60 void* vector_iter_down(const struct vector* v, void* elt);
65 struct hash_table_elt* next;
71 struct hash_table_elt** buckets;
74 void hash_table_init(struct pool* pool, struct hash_table* ht,
75 unsigned num_buckets);
76 void hash_table_destroy(struct hash_table* ht);
77 void hash_table_add(struct hash_table* ht, struct hash_table_elt* elt);
78 void* hash_table_find(const struct hash_table* ht, const char* name);
79 unsigned hash_table_hash(const char* name, unsigned num_buckets);
81 struct hash_table_iter
83 const struct hash_table* ht;
84 struct hash_table_elt* element;
89 void hash_table_iter_init(const struct hash_table* ht,
90 struct hash_table_iter* hti, const char* name);
91 void* hash_table_iter_up(struct hash_table_iter* hti);
93 #define GET_ENTRY(__i, __t, __f) \
94 ((__t*)((char*)(__i) - (unsigned int)(&((__t*)0)->__f)))
97 extern unsigned dbghelp_options;
107 struct hash_table_elt hash_elt; /* if global symbol or type */
114 unsigned long address;
116 struct symt* container; /* block, or func */
117 struct vector vchildren; /* sub-blocks & local variables */
120 struct symt_compiland
124 struct vector vchildren; /* global variables & functions */
130 struct hash_table_elt hash_elt; /* if global symbol */
132 struct symt* container;
134 enum LocationType location;
135 union /* depends on location */
137 unsigned long address; /* used by Static, Tls, ThisRel */
138 int offset; /* used by RegRel */
139 unsigned reg_id; /* used by Enregistered */
144 } bitfield; /* used by BitField */
146 unsigned value; /* LocIsConstant */
148 VARIANT value; /* LocIsConstant */
156 struct hash_table_elt hash_elt; /* if global symbol */
158 struct symt* container; /* compiland */
159 struct symt* type; /* points to function_signature */
161 struct vector vlines;
162 struct vector vchildren; /* locals, params, blocks */
168 struct hash_table_elt hash_elt;
169 struct symt* container; /* compiland */
170 unsigned long address;
172 unsigned in_code : 1,
182 struct symt* basetype;
188 struct hash_table_elt hash_elt;
197 struct vector vchildren;
200 struct symt_function_signature
203 struct symt* rettype;
209 struct symt* pointsto;
215 struct hash_table_elt hash_elt;
222 struct hash_table_elt hash_elt;
225 struct vector vchildren;
228 enum DbgModuleType {DMT_UNKNOWN, DMT_ELF, DMT_NE, DMT_PE};
232 IMAGEHLP_MODULE module;
234 enum DbgModuleType type;
235 unsigned short elf_mark : 1;
236 struct tagELF_DBG_INFO* elf_dbg_info;
238 /* memory allocation pool */
243 struct symt_ht** addr_sorttab;
244 struct hash_table ht_symbols;
247 struct hash_table ht_types;
250 unsigned sources_used;
251 unsigned sources_alloc;
257 struct process* next;
261 struct module* lmodules;
262 unsigned long dbg_hdr_addr;
264 IMAGEHLP_STACK_FRAME ctx_frame;
268 extern struct process* process_find_by_handle(HANDLE hProcess);
271 extern SYM_TYPE elf_load_debug_info(struct module* module);
272 extern struct module*
273 elf_load_module(struct process* pcs, const char* name);
275 elf_read_wine_loader_dbg_info(struct process* pcs);
276 extern BOOL elf_synchronize_module_list(struct process* pcs);
281 BOOL (*read_mem)(HANDLE hProcess, DWORD addr, void* buf, DWORD len);
282 BOOL (*write_mem)(HANDLE hProcess, DWORD addr, void* buf, DWORD len);
285 extern struct memory_access mem_access;
286 #define read_mem(p,a,b,l) (mem_access.read_mem)((p),(a),(b),(l))
287 #define write_mem(p,a,b,l) (mem_access.write_mem)((p),(a),(b),(l))
288 extern unsigned long WINAPI addr_to_linear(HANDLE hProcess, HANDLE hThread, ADDRESS* addr);
291 extern struct module*
292 module_find_by_addr(const struct process* pcs, unsigned long addr,
293 enum DbgModuleType type);
294 extern struct module*
295 module_find_by_name(const struct process* pcs,
296 const char* name, enum DbgModuleType type);
297 extern struct module*
298 module_get_debug(const struct process* pcs, struct module*);
299 extern struct module*
300 module_new(struct process* pcs, const char* name,
301 enum DbgModuleType type, unsigned long addr,
302 unsigned long size, unsigned long stamp,
303 unsigned long checksum);
305 extern BOOL module_remove(struct process* pcs,
306 struct module* module);
308 extern SYM_TYPE pe_load_debug_directory(const struct process* pcs,
309 struct module* module,
310 const BYTE* file_map,
311 PIMAGE_DEBUG_DIRECTORY dbg, int nDbg);
313 extern struct module*
314 pe_load_module(struct process* pcs, char* name,
315 HANDLE hFile, DWORD base, DWORD size);
316 extern struct module*
317 pe_load_module_from_pcs(struct process* pcs, const char* name,
318 const char* mod_name, DWORD base, DWORD size);
319 extern SYM_TYPE pe_load_debug_info(const struct process* pcs,
320 struct module* module);
322 extern unsigned source_new(struct module* module, const char* source);
323 extern const char* source_get(const struct module* module, unsigned idx);
326 extern SYM_TYPE stabs_parse(struct module* module, const char* addr,
327 unsigned long load_offset,
328 unsigned int staboff, int stablen,
329 unsigned int strtaboff, int strtablen);
332 extern const char* symt_get_name(const struct symt* sym);
333 extern int symt_cmp_addr(const void* p1, const void* p2);
334 extern struct symt_compiland*
335 symt_new_compiland(struct module* module,
336 const char* filename);
337 extern struct symt_public*
338 symt_new_public(struct module* module,
339 struct symt_compiland* parent,
340 const char* typename,
341 unsigned long address, unsigned size,
342 BOOL in_code, BOOL is_func);
343 extern struct symt_data*
344 symt_new_global_variable(struct module* module,
345 struct symt_compiland* parent,
346 const char* name, unsigned is_static,
347 unsigned long addr, unsigned long size,
349 extern struct symt_function*
350 symt_new_function(struct module* module,
351 struct symt_compiland* parent,
353 unsigned long addr, unsigned long size,
355 extern BOOL symt_normalize_function(struct module* module,
356 struct symt_function* func);
357 extern void symt_add_func_line(struct module* module,
358 struct symt_function* func,
359 unsigned source_idx, int line_num,
360 unsigned long offset);
361 extern struct symt_data*
362 symt_add_func_local(struct module* module,
363 struct symt_function* func,
364 int regno, int offset,
365 struct symt_block* block,
366 struct symt* type, const char* name);
367 extern struct symt_block*
368 symt_open_func_block(struct module* module,
369 struct symt_function* func,
370 struct symt_block* block, unsigned pc);
371 extern struct symt_block*
372 symt_close_func_block(struct module* module,
373 struct symt_function* func,
374 struct symt_block* block, unsigned pc);
377 extern void symt_init_basic(struct module* module);
378 extern BOOL symt_get_info(const struct symt* type,
379 IMAGEHLP_SYMBOL_TYPE_INFO req, void* pInfo);
380 extern struct symt_basic*
381 symt_new_basic(struct module* module, enum BasicType,
382 const char* typename, unsigned size);
383 extern struct symt_udt*
384 symt_new_udt(struct module* module, const char* typename,
385 unsigned size, enum UdtKind kind);
386 extern BOOL symt_set_udt_size(struct module* module,
387 struct symt_udt* type, unsigned size);
388 extern BOOL symt_add_udt_element(struct module* module,
389 struct symt_udt* udt_type,
391 struct symt* elt_type, unsigned offset,
393 extern struct symt_enum*
394 symt_new_enum(struct module* module, const char* typename);
395 extern BOOL symt_add_enum_element(struct module* module,
396 struct symt_enum* enum_type,
397 const char* name, unsigned value);
398 extern struct symt_array*
399 symt_new_array(struct module* module, int min, int max,
401 extern struct symt_function_signature*
402 symt_new_function_signature(struct module* module,
403 struct symt* ret_type);
404 extern struct symt_pointer*
405 symt_new_pointer(struct module* module,
406 struct symt* ref_type);