- now storing vector of types on a per module basis (and giving it
[wine.git] / dlls / dbghelp / dbghelp_private.h
blobc424997cd10f35d9738a4d0a81e8917b2cb23598
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 : 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);
64 struct hash_table_elt
66 const char* name;
67 struct hash_table_elt* next;
70 struct hash_table
72 unsigned num_buckets;
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;
87 int index;
88 int last;
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;
101 struct symt
103 enum SymTagEnum tag;
106 struct symt_ht
108 struct symt symt;
109 struct hash_table_elt hash_elt; /* if global symbol or type */
112 /* lexical tree */
113 struct symt_block
115 struct symt symt;
116 unsigned long address;
117 unsigned long size;
118 struct symt* container; /* block, or func */
119 struct vector vchildren; /* sub-blocks & local variables */
122 struct symt_compiland
124 struct symt symt;
125 unsigned source;
126 struct vector vchildren; /* global variables & functions */
129 struct symt_data
131 struct symt symt;
132 struct hash_table_elt hash_elt; /* if global symbol */
133 enum DataKind kind;
134 struct symt* container;
135 struct symt* type;
136 union /* depends on kind */
138 unsigned long address; /* DataIs{Global, FileStatic} */
139 struct
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) */
144 } s;
145 VARIANT value; /* DataIsConstant */
146 } u;
149 struct symt_function
151 struct symt symt;
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 */
156 unsigned long size;
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 */
169 struct symt_public
171 struct symt symt;
172 struct hash_table_elt hash_elt;
173 struct symt* container; /* compiland */
174 unsigned long address;
175 unsigned long size;
176 unsigned in_code : 1,
177 is_function : 1;
180 struct symt_thunk
182 struct symt symt;
183 struct hash_table_elt hash_elt;
184 struct symt* container; /* compiland */
185 unsigned long address;
186 unsigned long size;
187 THUNK_ORDINAL ordinal; /* FIXME: doesn't seem to be accessible */
190 /* class tree */
191 struct symt_array
193 struct symt symt;
194 int start;
195 int end;
196 struct symt* basetype;
199 struct symt_basic
201 struct symt symt;
202 struct hash_table_elt hash_elt;
203 enum BasicType bt;
204 unsigned long size;
207 struct symt_enum
209 struct symt symt;
210 const char* name;
211 struct vector vchildren;
214 struct symt_function_signature
216 struct symt symt;
217 struct symt* rettype;
218 struct vector vchildren;
221 struct symt_pointer
223 struct symt symt;
224 struct symt* pointsto;
227 struct symt_typedef
229 struct symt symt;
230 struct hash_table_elt hash_elt;
231 struct symt* type;
234 struct symt_udt
236 struct symt symt;
237 struct hash_table_elt hash_elt;
238 enum UdtKind kind;
239 int size;
240 struct vector vchildren;
243 enum module_type
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 */
250 struct module
252 IMAGEHLP_MODULE module;
253 struct module* next;
254 enum module_type type;
255 struct elf_module_info* elf_info;
257 /* memory allocation pool */
258 struct pool pool;
260 /* symbol tables */
261 int sortlist_valid;
262 struct symt_ht** addr_sorttab;
263 struct hash_table ht_symbols;
265 /* types */
266 struct hash_table ht_types;
267 struct vector vtypes;
269 /* source files */
270 unsigned sources_used;
271 unsigned sources_alloc;
272 char* sources;
275 struct process
277 struct process* next;
278 HANDLE handle;
279 char* search_path;
281 struct module* lmodules;
282 unsigned long dbg_hdr_addr;
284 IMAGEHLP_STACK_FRAME ctx_frame;
287 /* dbghelp.c */
288 extern struct process* process_find_by_handle(HANDLE hProcess);
290 /* elf_module.c */
291 extern BOOL elf_load_debug_info(struct module* module);
292 extern struct module*
293 elf_load_module(struct process* pcs, const char* name);
294 extern BOOL elf_read_wine_loader_dbg_info(struct process* pcs);
295 extern BOOL elf_synchronize_module_list(struct process* pcs);
297 /* memory.c */
298 struct memory_access
300 BOOL (*read_mem)(HANDLE hProcess, DWORD addr, void* buf, DWORD len);
301 BOOL (*write_mem)(HANDLE hProcess, DWORD addr, void* buf, DWORD len);
304 extern struct memory_access mem_access;
305 #define read_mem(p,a,b,l) (mem_access.read_mem)((p),(a),(b),(l))
306 #define write_mem(p,a,b,l) (mem_access.write_mem)((p),(a),(b),(l))
307 extern unsigned long WINAPI addr_to_linear(HANDLE hProcess, HANDLE hThread, ADDRESS* addr);
309 /* module.c */
310 extern struct module*
311 module_find_by_addr(const struct process* pcs, unsigned long addr,
312 enum module_type type);
313 extern struct module*
314 module_find_by_name(const struct process* pcs,
315 const char* name, enum module_type type);
316 extern struct module*
317 module_get_debug(const struct process* pcs, struct module*);
318 extern struct module*
319 module_new(struct process* pcs, const char* name,
320 enum module_type type, unsigned long addr,
321 unsigned long size, unsigned long stamp,
322 unsigned long checksum);
323 extern struct module*
324 module_get_container(const struct process* pcs,
325 const struct module* inner);
326 extern struct module*
327 module_get_containee(const struct process* pcs,
328 const struct module* inner);
329 extern void module_reset_debug_info(struct module* module);
330 extern BOOL module_remove(struct process* pcs,
331 struct module* module);
332 /* msc.c */
333 extern BOOL pe_load_debug_directory(const struct process* pcs,
334 struct module* module,
335 const BYTE* file_map,
336 const IMAGE_DEBUG_DIRECTORY* dbg, int nDbg);
337 /* pe_module.c */
338 extern struct module*
339 pe_load_module(struct process* pcs, char* name,
340 HANDLE hFile, DWORD base, DWORD size);
341 extern struct module*
342 pe_load_module_from_pcs(struct process* pcs, const char* name,
343 const char* mod_name, DWORD base, DWORD size);
344 extern BOOL pe_load_debug_info(const struct process* pcs,
345 struct module* module);
346 /* source.c */
347 extern unsigned source_new(struct module* module, const char* source);
348 extern const char* source_get(const struct module* module, unsigned idx);
350 /* stabs.c */
351 extern BOOL stabs_parse(struct module* module, const char* addr,
352 unsigned long load_offset,
353 unsigned int staboff, int stablen,
354 unsigned int strtaboff, int strtablen);
356 /* symbol.c */
357 extern const char* symt_get_name(const struct symt* sym);
358 extern int symt_cmp_addr(const void* p1, const void* p2);
359 extern int symt_find_nearest(struct module* module, DWORD addr);
360 extern struct symt_compiland*
361 symt_new_compiland(struct module* module,
362 const char* filename);
363 extern struct symt_public*
364 symt_new_public(struct module* module,
365 struct symt_compiland* parent,
366 const char* typename,
367 unsigned long address, unsigned size,
368 BOOL in_code, BOOL is_func);
369 extern struct symt_data*
370 symt_new_global_variable(struct module* module,
371 struct symt_compiland* parent,
372 const char* name, unsigned is_static,
373 unsigned long addr, unsigned long size,
374 struct symt* type);
375 extern struct symt_function*
376 symt_new_function(struct module* module,
377 struct symt_compiland* parent,
378 const char* name,
379 unsigned long addr, unsigned long size,
380 struct symt* type);
381 extern BOOL symt_normalize_function(struct module* module,
382 struct symt_function* func);
383 extern void symt_add_func_line(struct module* module,
384 struct symt_function* func,
385 unsigned source_idx, int line_num,
386 unsigned long offset);
387 extern struct symt_data*
388 symt_add_func_local(struct module* module,
389 struct symt_function* func,
390 int regno, int offset,
391 struct symt_block* block,
392 struct symt* type, const char* name);
393 extern struct symt_block*
394 symt_open_func_block(struct module* module,
395 struct symt_function* func,
396 struct symt_block* block,
397 unsigned pc, unsigned len);
398 extern struct symt_block*
399 symt_close_func_block(struct module* module,
400 struct symt_function* func,
401 struct symt_block* block, unsigned pc);
402 extern struct symt_function_point*
403 symt_add_function_point(struct module* module,
404 struct symt_function* func,
405 enum SymTagEnum point,
406 unsigned offset, const char* name);
407 extern BOOL symt_fill_func_line_info(struct module* module,
408 struct symt_function* func,
409 DWORD addr, IMAGEHLP_LINE* line);
410 extern BOOL symt_get_func_line_next(struct module* module, PIMAGEHLP_LINE line);
411 extern struct symt_thunk*
412 symt_new_thunk(struct module* module,
413 struct symt_compiland* parent,
414 const char* name, THUNK_ORDINAL ord,
415 unsigned long addr, unsigned long size);
417 /* type.c */
418 extern void symt_init_basic(struct module* module);
419 extern BOOL symt_get_info(const struct symt* type,
420 IMAGEHLP_SYMBOL_TYPE_INFO req, void* pInfo);
421 extern struct symt_basic*
422 symt_new_basic(struct module* module, enum BasicType,
423 const char* typename, unsigned size);
424 extern struct symt_udt*
425 symt_new_udt(struct module* module, const char* typename,
426 unsigned size, enum UdtKind kind);
427 extern BOOL symt_set_udt_size(struct module* module,
428 struct symt_udt* type, unsigned size);
429 extern BOOL symt_add_udt_element(struct module* module,
430 struct symt_udt* udt_type,
431 const char* name,
432 struct symt* elt_type, unsigned offset,
433 unsigned size);
434 extern struct symt_enum*
435 symt_new_enum(struct module* module, const char* typename);
436 extern BOOL symt_add_enum_element(struct module* module,
437 struct symt_enum* enum_type,
438 const char* name, int value);
439 extern struct symt_array*
440 symt_new_array(struct module* module, int min, int max,
441 struct symt* base);
442 extern struct symt_function_signature*
443 symt_new_function_signature(struct module* module,
444 struct symt* ret_type);
445 extern BOOL symt_add_function_signature_parameter(struct module* module,
446 struct symt_function_signature* sig,
447 struct symt* param);
448 extern struct symt_pointer*
449 symt_new_pointer(struct module* module,
450 struct symt* ref_type);
451 extern struct symt_typedef*
452 symt_new_typedef(struct module* module, struct symt* ref,
453 const char* name);
456 /* some more Wine extensions */
457 #define SYMOPT_WINE_WITH_ELF_MODULES 0x40000000