- fixed loading stabs from PE modules compiled with MingW
[wine/wine-kai.git] / dlls / dbghelp / dbghelp_private.h
blobf22d6af15545cc21d38003208721757b5057f336
1 /*
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
24 #include <stdarg.h>
25 #include "windef.h"
26 #include "winbase.h"
27 #include "winver.h"
28 #include "dbghelp.h"
29 #include "objbase.h"
30 #include "oaidl.h"
32 #include "cvconst.h"
34 /* #define USE_STATS */
36 struct pool /* poor's man */
38 struct pool_arena* first;
39 unsigned arena_size;
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);
49 struct vector
51 void** buckets;
52 unsigned elt_size;
53 unsigned shift;
54 unsigned num_elts;
55 unsigned num_buckets;
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);
66 struct hash_table_elt
68 const char* name;
69 struct hash_table_elt* next;
72 struct hash_table
74 unsigned num_buckets;
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;
89 int index;
90 int last;
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;
103 struct symt
105 enum SymTagEnum tag;
108 struct symt_ht
110 struct symt symt;
111 struct hash_table_elt hash_elt; /* if global symbol or type */
114 /* lexical tree */
115 struct symt_block
117 struct symt symt;
118 unsigned long address;
119 unsigned long size;
120 struct symt* container; /* block, or func */
121 struct vector vchildren; /* sub-blocks & local variables */
124 struct symt_compiland
126 struct symt symt;
127 unsigned source;
128 struct vector vchildren; /* global variables & functions */
131 struct symt_data
133 struct symt symt;
134 struct hash_table_elt hash_elt; /* if global symbol */
135 enum DataKind kind;
136 struct symt* container;
137 struct symt* type;
138 union /* depends on kind */
140 unsigned long address; /* DataIs{Global, FileStatic} */
141 struct
143 long offset; /* DataIs{Member,Local,Param} in bits*/
144 unsigned long length; /* DataIs{Member} in bits */
145 unsigned long reg_id; /* DataIs{Local} (0 if frame relative) */
146 } s;
147 VARIANT value; /* DataIsConstant */
148 } u;
151 struct symt_function
153 struct symt symt;
154 struct hash_table_elt hash_elt; /* if global symbol */
155 unsigned long address;
156 struct symt* container; /* compiland */
157 struct symt* type; /* points to function_signature */
158 unsigned long size;
159 struct vector vlines;
160 struct vector vchildren; /* locals, params, blocks, start/end, labels */
163 struct symt_function_point
165 struct symt symt; /* either SymTagFunctionDebugStart, SymTagFunctionDebugEnd, SymTagLabel */
166 struct symt_function* parent;
167 unsigned long offset;
168 const char* name; /* for labels */
171 struct symt_public
173 struct symt symt;
174 struct hash_table_elt hash_elt;
175 struct symt* container; /* compiland */
176 unsigned long address;
177 unsigned long size;
178 unsigned in_code : 1,
179 is_function : 1;
182 struct symt_thunk
184 struct symt symt;
185 struct hash_table_elt hash_elt;
186 struct symt* container; /* compiland */
187 unsigned long address;
188 unsigned long size;
189 THUNK_ORDINAL ordinal; /* FIXME: doesn't seem to be accessible */
192 /* class tree */
193 struct symt_array
195 struct symt symt;
196 int start;
197 int end;
198 struct symt* basetype;
201 struct symt_basic
203 struct symt symt;
204 struct hash_table_elt hash_elt;
205 enum BasicType bt;
206 unsigned long size;
209 struct symt_enum
211 struct symt symt;
212 const char* name;
213 struct vector vchildren;
216 struct symt_function_signature
218 struct symt symt;
219 struct symt* rettype;
220 struct vector vchildren;
223 struct symt_pointer
225 struct symt symt;
226 struct symt* pointsto;
229 struct symt_typedef
231 struct symt symt;
232 struct hash_table_elt hash_elt;
233 struct symt* type;
236 struct symt_udt
238 struct symt symt;
239 struct hash_table_elt hash_elt;
240 enum UdtKind kind;
241 int size;
242 struct vector vchildren;
245 enum module_type
247 DMT_UNKNOWN, /* for lookup, not actually used for a module */
248 DMT_ELF, /* a real ELF shared module */
249 DMT_PE, /* a native or builtin PE module */
252 struct module
254 IMAGEHLP_MODULE module;
255 struct module* next;
256 enum module_type type;
257 struct elf_module_info* elf_info;
259 /* memory allocation pool */
260 struct pool pool;
262 /* symbol tables */
263 int sortlist_valid;
264 struct symt_ht** addr_sorttab;
265 struct hash_table ht_symbols;
267 /* types */
268 struct hash_table ht_types;
269 struct vector vtypes;
271 /* source files */
272 unsigned sources_used;
273 unsigned sources_alloc;
274 char* sources;
277 struct process
279 struct process* next;
280 HANDLE handle;
281 char* search_path;
283 struct module* lmodules;
284 unsigned long dbg_hdr_addr;
286 IMAGEHLP_STACK_FRAME ctx_frame;
289 /* dbghelp.c */
290 extern struct process* process_find_by_handle(HANDLE hProcess);
292 /* elf_module.c */
293 extern BOOL elf_load_debug_info(struct module* module);
294 extern struct module*
295 elf_load_module(struct process* pcs, const char* name);
296 extern BOOL elf_read_wine_loader_dbg_info(struct process* pcs);
297 extern BOOL elf_synchronize_module_list(struct process* pcs);
299 extern DWORD WINAPI addr_to_linear(HANDLE hProcess, HANDLE hThread, ADDRESS* addr);
301 /* module.c */
302 extern struct module*
303 module_find_by_addr(const struct process* pcs, unsigned long addr,
304 enum module_type type);
305 extern struct module*
306 module_find_by_name(const struct process* pcs,
307 const char* name, enum module_type type);
308 extern struct module*
309 module_get_debug(const struct process* pcs, struct module*);
310 extern struct module*
311 module_new(struct process* pcs, const char* name,
312 enum module_type type, unsigned long addr,
313 unsigned long size, unsigned long stamp,
314 unsigned long checksum);
315 extern struct module*
316 module_get_container(const struct process* pcs,
317 const struct module* inner);
318 extern struct module*
319 module_get_containee(const struct process* pcs,
320 const struct module* inner);
321 extern void module_reset_debug_info(struct module* module);
322 extern BOOL module_remove(struct process* pcs,
323 struct module* module);
324 /* msc.c */
325 extern BOOL pe_load_debug_directory(const struct process* pcs,
326 struct module* module,
327 const BYTE* mapping,
328 const IMAGE_SECTION_HEADER* sectp, DWORD nsect,
329 const IMAGE_DEBUG_DIRECTORY* dbg, int nDbg);
330 /* pe_module.c */
331 extern struct module*
332 pe_load_module(struct process* pcs, char* name,
333 HANDLE hFile, DWORD base, DWORD size);
334 extern struct module*
335 pe_load_module_from_pcs(struct process* pcs, const char* name,
336 const char* mod_name, DWORD base, DWORD size);
337 extern BOOL pe_load_debug_info(const struct process* pcs,
338 struct module* module);
339 /* source.c */
340 extern unsigned source_new(struct module* module, const char* source);
341 extern const char* source_get(const struct module* module, unsigned idx);
343 /* stabs.c */
344 extern BOOL stabs_parse(struct module* module, unsigned long load_offset,
345 const void* stabs, int stablen,
346 const char* strs, int strtablen);
348 /* symbol.c */
349 extern const char* symt_get_name(const struct symt* sym);
350 extern int symt_cmp_addr(const void* p1, const void* p2);
351 extern int symt_find_nearest(struct module* module, DWORD addr);
352 extern struct symt_compiland*
353 symt_new_compiland(struct module* module,
354 const char* filename);
355 extern struct symt_public*
356 symt_new_public(struct module* module,
357 struct symt_compiland* parent,
358 const char* typename,
359 unsigned long address, unsigned size,
360 BOOL in_code, BOOL is_func);
361 extern struct symt_data*
362 symt_new_global_variable(struct module* module,
363 struct symt_compiland* parent,
364 const char* name, unsigned is_static,
365 unsigned long addr, unsigned long size,
366 struct symt* type);
367 extern struct symt_function*
368 symt_new_function(struct module* module,
369 struct symt_compiland* parent,
370 const char* name,
371 unsigned long addr, unsigned long size,
372 struct symt* type);
373 extern BOOL symt_normalize_function(struct module* module,
374 struct symt_function* func);
375 extern void symt_add_func_line(struct module* module,
376 struct symt_function* func,
377 unsigned source_idx, int line_num,
378 unsigned long offset);
379 extern struct symt_data*
380 symt_add_func_local(struct module* module,
381 struct symt_function* func,
382 int regno, int offset,
383 struct symt_block* block,
384 struct symt* type, const char* name);
385 extern struct symt_block*
386 symt_open_func_block(struct module* module,
387 struct symt_function* func,
388 struct symt_block* block,
389 unsigned pc, unsigned len);
390 extern struct symt_block*
391 symt_close_func_block(struct module* module,
392 struct symt_function* func,
393 struct symt_block* block, unsigned pc);
394 extern struct symt_function_point*
395 symt_add_function_point(struct module* module,
396 struct symt_function* func,
397 enum SymTagEnum point,
398 unsigned offset, const char* name);
399 extern BOOL symt_fill_func_line_info(struct module* module,
400 struct symt_function* func,
401 DWORD addr, IMAGEHLP_LINE* line);
402 extern BOOL symt_get_func_line_next(struct module* module, PIMAGEHLP_LINE line);
403 extern struct symt_thunk*
404 symt_new_thunk(struct module* module,
405 struct symt_compiland* parent,
406 const char* name, THUNK_ORDINAL ord,
407 unsigned long addr, unsigned long size);
409 /* type.c */
410 extern void symt_init_basic(struct module* module);
411 extern BOOL symt_get_info(const struct symt* type,
412 IMAGEHLP_SYMBOL_TYPE_INFO req, void* pInfo);
413 extern struct symt_basic*
414 symt_new_basic(struct module* module, enum BasicType,
415 const char* typename, unsigned size);
416 extern struct symt_udt*
417 symt_new_udt(struct module* module, const char* typename,
418 unsigned size, enum UdtKind kind);
419 extern BOOL symt_set_udt_size(struct module* module,
420 struct symt_udt* type, unsigned size);
421 extern BOOL symt_add_udt_element(struct module* module,
422 struct symt_udt* udt_type,
423 const char* name,
424 struct symt* elt_type, unsigned offset,
425 unsigned size);
426 extern struct symt_enum*
427 symt_new_enum(struct module* module, const char* typename);
428 extern BOOL symt_add_enum_element(struct module* module,
429 struct symt_enum* enum_type,
430 const char* name, int value);
431 extern struct symt_array*
432 symt_new_array(struct module* module, int min, int max,
433 struct symt* base);
434 extern struct symt_function_signature*
435 symt_new_function_signature(struct module* module,
436 struct symt* ret_type);
437 extern BOOL symt_add_function_signature_parameter(struct module* module,
438 struct symt_function_signature* sig,
439 struct symt* param);
440 extern struct symt_pointer*
441 symt_new_pointer(struct module* module,
442 struct symt* ref_type);
443 extern struct symt_typedef*
444 symt_new_typedef(struct module* module, struct symt* ref,
445 const char* name);
448 /* some more Wine extensions */
449 #define SYMOPT_WINE_WITH_ELF_MODULES 0x40000000