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
33 /* #define USE_STATS */
35 struct pool /* poor's man */
37 struct pool_arena* first;
41 void pool_init(struct pool* a, unsigned arena_size);
42 void pool_destroy(struct pool* a);
43 void* pool_alloc(struct pool* a, unsigned len);
44 /* void* pool_realloc(struct pool* a, void* p,
45 unsigned old_size, unsigned new_size); */
46 char* pool_strdup(struct pool* a, const char* str);
51 unsigned elt_size : 24, shift : 8;
52 unsigned num_elts : 20, num_buckets : 12;
55 void vector_init(struct vector* v, unsigned elt_sz, unsigned bucket_sz);
56 unsigned vector_length(const struct vector* v);
57 void* vector_at(const struct vector* v, unsigned pos);
58 void* vector_add(struct vector* v, struct pool* pool);
59 /*void vector_pool_normalize(struct vector* v, struct pool* pool); */
60 void* vector_iter_up(const struct vector* v, void* elt);
61 void* vector_iter_down(const struct vector* v, void* elt);
66 struct hash_table_elt* next;
72 struct hash_table_elt** buckets;
75 void hash_table_init(struct pool* pool, struct hash_table* ht,
76 unsigned num_buckets);
77 void hash_table_destroy(struct hash_table* ht);
78 void hash_table_add(struct hash_table* ht, struct hash_table_elt* elt);
79 void* hash_table_find(const struct hash_table* ht, const char* name);
80 unsigned hash_table_hash(const char* name, unsigned num_buckets);
82 struct hash_table_iter
84 const struct hash_table* ht;
85 struct hash_table_elt* element;
90 void hash_table_iter_init(const struct hash_table* ht,
91 struct hash_table_iter* hti, const char* name);
92 void* hash_table_iter_up(struct hash_table_iter* hti);
94 #define GET_ENTRY(__i, __t, __f) \
95 ((__t*)((char*)(__i) - (unsigned int)(&((__t*)0)->__f)))
98 extern unsigned dbghelp_options;
108 struct hash_table_elt hash_elt; /* if global symbol or type */
115 unsigned long address;
117 struct symt* container; /* block, or func */
118 struct vector vchildren; /* sub-blocks & local variables */
121 struct symt_compiland
125 struct vector vchildren; /* global variables & functions */
131 struct hash_table_elt hash_elt; /* if global symbol */
133 struct symt* container;
135 enum LocationType location;
136 union /* depends on location */
138 unsigned long address; /* used by Static, Tls, ThisRel */
139 int offset; /* used by RegRel */
140 unsigned reg_id; /* used by Enregistered */
145 } bitfield; /* used by BitField */
146 VARIANT value; /* LocIsConstant */
153 struct hash_table_elt hash_elt; /* if global symbol */
155 struct symt* container; /* compiland */
156 struct symt* type; /* points to function_signature */
158 struct vector vlines;
159 struct vector vchildren; /* locals, params, blocks, start/end, labels */
162 struct symt_function_point
164 struct symt symt; /* either SymTagFunctionDebugStart, SymTagFunctionDebugEnd, SymTagLabel */
165 struct symt_function* parent;
166 unsigned long offset;
167 const char* name; /* for labels */
173 struct hash_table_elt hash_elt;
174 struct symt* container; /* compiland */
175 unsigned long address;
177 unsigned in_code : 1,
187 struct symt* basetype;
193 struct hash_table_elt hash_elt;
202 struct vector vchildren;
205 struct symt_function_signature
208 struct symt* rettype;
209 struct vector vchildren;
215 struct symt* pointsto;
221 struct hash_table_elt hash_elt;
228 struct hash_table_elt hash_elt;
231 struct vector vchildren;
234 enum DbgModuleType {DMT_UNKNOWN, DMT_ELF, DMT_NE, DMT_PE};
238 IMAGEHLP_MODULE module;
240 enum DbgModuleType type;
241 unsigned short elf_mark : 1;
242 struct tagELF_DBG_INFO* elf_dbg_info;
244 /* memory allocation pool */
249 struct symt_ht** addr_sorttab;
250 struct hash_table ht_symbols;
253 struct hash_table ht_types;
256 unsigned sources_used;
257 unsigned sources_alloc;
263 struct process* next;
267 struct module* lmodules;
268 unsigned long dbg_hdr_addr;
270 IMAGEHLP_STACK_FRAME ctx_frame;
274 extern struct process* process_find_by_handle(HANDLE hProcess);
277 extern SYM_TYPE elf_load_debug_info(struct module* module);
278 extern struct module*
279 elf_load_module(struct process* pcs, const char* name);
281 elf_read_wine_loader_dbg_info(struct process* pcs);
282 extern BOOL elf_synchronize_module_list(struct process* pcs);
287 BOOL (*read_mem)(HANDLE hProcess, DWORD addr, void* buf, DWORD len);
288 BOOL (*write_mem)(HANDLE hProcess, DWORD addr, void* buf, DWORD len);
291 extern struct memory_access mem_access;
292 #define read_mem(p,a,b,l) (mem_access.read_mem)((p),(a),(b),(l))
293 #define write_mem(p,a,b,l) (mem_access.write_mem)((p),(a),(b),(l))
294 extern unsigned long WINAPI addr_to_linear(HANDLE hProcess, HANDLE hThread, ADDRESS* addr);
297 extern struct module*
298 module_find_by_addr(const struct process* pcs, unsigned long addr,
299 enum DbgModuleType type);
300 extern struct module*
301 module_find_by_name(const struct process* pcs,
302 const char* name, enum DbgModuleType type);
303 extern struct module*
304 module_get_debug(const struct process* pcs, struct module*);
305 extern struct module*
306 module_new(struct process* pcs, const char* name,
307 enum DbgModuleType type, unsigned long addr,
308 unsigned long size, unsigned long stamp,
309 unsigned long checksum);
311 extern BOOL module_remove(struct process* pcs,
312 struct module* module);
314 extern SYM_TYPE pe_load_debug_directory(const struct process* pcs,
315 struct module* module,
316 const BYTE* file_map,
317 PIMAGE_DEBUG_DIRECTORY dbg, int nDbg);
319 extern struct module*
320 pe_load_module(struct process* pcs, char* name,
321 HANDLE hFile, DWORD base, DWORD size);
322 extern struct module*
323 pe_load_module_from_pcs(struct process* pcs, const char* name,
324 const char* mod_name, DWORD base, DWORD size);
325 extern SYM_TYPE pe_load_debug_info(const struct process* pcs,
326 struct module* module);
328 extern unsigned source_new(struct module* module, const char* source);
329 extern const char* source_get(const struct module* module, unsigned idx);
332 extern SYM_TYPE stabs_parse(struct module* module, const char* addr,
333 unsigned long load_offset,
334 unsigned int staboff, int stablen,
335 unsigned int strtaboff, int strtablen);
338 extern const char* symt_get_name(const struct symt* sym);
339 extern int symt_cmp_addr(const void* p1, const void* p2);
340 extern struct symt_compiland*
341 symt_new_compiland(struct module* module,
342 const char* filename);
343 extern struct symt_public*
344 symt_new_public(struct module* module,
345 struct symt_compiland* parent,
346 const char* typename,
347 unsigned long address, unsigned size,
348 BOOL in_code, BOOL is_func);
349 extern struct symt_data*
350 symt_new_global_variable(struct module* module,
351 struct symt_compiland* parent,
352 const char* name, unsigned is_static,
353 unsigned long addr, unsigned long size,
355 extern struct symt_function*
356 symt_new_function(struct module* module,
357 struct symt_compiland* parent,
359 unsigned long addr, unsigned long size,
361 extern BOOL symt_normalize_function(struct module* module,
362 struct symt_function* func);
363 extern void symt_add_func_line(struct module* module,
364 struct symt_function* func,
365 unsigned source_idx, int line_num,
366 unsigned long offset);
367 extern struct symt_data*
368 symt_add_func_local(struct module* module,
369 struct symt_function* func,
370 int regno, int offset,
371 struct symt_block* block,
372 struct symt* type, const char* name);
373 extern struct symt_block*
374 symt_open_func_block(struct module* module,
375 struct symt_function* func,
376 struct symt_block* block,
377 unsigned pc, unsigned len);
378 extern struct symt_block*
379 symt_close_func_block(struct module* module,
380 struct symt_function* func,
381 struct symt_block* block, unsigned pc);
382 extern struct symt_function_point*
383 symt_add_function_point(struct module* module,
384 struct symt_function* func,
385 enum SymTagEnum point,
386 unsigned offset, const char* name);
387 extern BOOL symt_fill_func_line_info(struct module* module,
388 struct symt_function* func,
389 DWORD addr, IMAGEHLP_LINE* line);
390 extern BOOL symt_get_func_line_next(struct module* module, PIMAGEHLP_LINE line);
393 extern void symt_init_basic(struct module* module);
394 extern BOOL symt_get_info(const struct symt* type,
395 IMAGEHLP_SYMBOL_TYPE_INFO req, void* pInfo);
396 extern struct symt_basic*
397 symt_new_basic(struct module* module, enum BasicType,
398 const char* typename, unsigned size);
399 extern struct symt_udt*
400 symt_new_udt(struct module* module, const char* typename,
401 unsigned size, enum UdtKind kind);
402 extern BOOL symt_set_udt_size(struct module* module,
403 struct symt_udt* type, unsigned size);
404 extern BOOL symt_add_udt_element(struct module* module,
405 struct symt_udt* udt_type,
407 struct symt* elt_type, unsigned offset,
409 extern struct symt_enum*
410 symt_new_enum(struct module* module, const char* typename);
411 extern BOOL symt_add_enum_element(struct module* module,
412 struct symt_enum* enum_type,
413 const char* name, int value);
414 extern struct symt_array*
415 symt_new_array(struct module* module, int min, int max,
417 extern struct symt_function_signature*
418 symt_new_function_signature(struct module* module,
419 struct symt* ret_type);
420 extern BOOL symt_add_function_signature_parameter(struct module* module,
421 struct symt_function_signature* sig,
423 extern struct symt_pointer*
424 symt_new_pointer(struct module* module,
425 struct symt* ref_type);
426 extern struct symt_typedef*
427 symt_new_typedef(struct module* module, struct symt* ref,