cmd: DIR command outputs free space for the path.
[wine.git] / dlls / dbghelp / dbghelp_private.h
blob1ce221a0f278e7bedeffd0a2bf80977c1613026a
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-2007, 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, 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"
31 #include "winnls.h"
32 #include "wine/list.h"
33 #include "wine/rbtree.h"
35 #include "cvconst.h"
37 struct pool /* poor's man */
39 HANDLE heap;
42 void pool_init(struct pool* a, size_t arena_size) DECLSPEC_HIDDEN;
43 void pool_destroy(struct pool* a) DECLSPEC_HIDDEN;
44 void* pool_alloc(struct pool* a, size_t len) __WINE_ALLOC_SIZE(2) __WINE_MALLOC DECLSPEC_HIDDEN;
45 void* pool_realloc(struct pool* a, void* ptr, size_t len) __WINE_ALLOC_SIZE(3) DECLSPEC_HIDDEN;
46 char* pool_strdup(struct pool* a, const char* str) __WINE_MALLOC DECLSPEC_HIDDEN;
47 WCHAR* pool_wcsdup(struct pool* a, const WCHAR* str) __WINE_MALLOC DECLSPEC_HIDDEN;
49 struct vector
51 void** buckets;
52 unsigned elt_size;
53 unsigned shift;
54 unsigned num_elts;
55 unsigned num_buckets;
56 unsigned buckets_allocated;
59 void vector_init(struct vector* v, unsigned elt_sz, unsigned bucket_sz) DECLSPEC_HIDDEN;
60 unsigned vector_length(const struct vector* v) DECLSPEC_HIDDEN;
61 void* vector_at(const struct vector* v, unsigned pos) DECLSPEC_HIDDEN;
62 void* vector_add(struct vector* v, struct pool* pool) DECLSPEC_HIDDEN;
64 struct sparse_array
66 struct vector key2index;
67 struct vector elements;
70 void sparse_array_init(struct sparse_array* sa, unsigned elt_sz, unsigned bucket_sz) DECLSPEC_HIDDEN;
71 void* sparse_array_find(const struct sparse_array* sa, ULONG_PTR idx) DECLSPEC_HIDDEN;
72 void* sparse_array_add(struct sparse_array* sa, ULONG_PTR key, struct pool* pool) DECLSPEC_HIDDEN;
73 unsigned sparse_array_length(const struct sparse_array* sa) DECLSPEC_HIDDEN;
75 struct hash_table_elt
77 const char* name;
78 struct hash_table_elt* next;
81 struct hash_table_bucket
83 struct hash_table_elt* first;
84 struct hash_table_elt* last;
87 struct hash_table
89 unsigned num_elts;
90 unsigned num_buckets;
91 struct hash_table_bucket* buckets;
92 struct pool* pool;
95 void hash_table_init(struct pool* pool, struct hash_table* ht,
96 unsigned num_buckets) DECLSPEC_HIDDEN;
97 void hash_table_destroy(struct hash_table* ht) DECLSPEC_HIDDEN;
98 void hash_table_add(struct hash_table* ht, struct hash_table_elt* elt) DECLSPEC_HIDDEN;
100 struct hash_table_iter
102 const struct hash_table* ht;
103 struct hash_table_elt* element;
104 int index;
105 int last;
108 void hash_table_iter_init(const struct hash_table* ht,
109 struct hash_table_iter* hti, const char* name) DECLSPEC_HIDDEN;
110 void* hash_table_iter_up(struct hash_table_iter* hti) DECLSPEC_HIDDEN;
113 extern unsigned dbghelp_options DECLSPEC_HIDDEN;
114 extern BOOL dbghelp_opt_native DECLSPEC_HIDDEN;
115 extern BOOL dbghelp_opt_real_path DECLSPEC_HIDDEN;
116 extern BOOL dbghelp_opt_source_actual_path DECLSPEC_HIDDEN;
117 extern SYSTEM_INFO sysinfo DECLSPEC_HIDDEN;
119 /* FIXME: this could be optimized later on by using relative offsets and smaller integral sizes */
120 struct addr_range
122 DWORD64 low; /* absolute address of first byte of the range */
123 DWORD64 high; /* absolute address of first byte after the range */
126 static inline DWORD64 addr_range_size(const struct addr_range* ar)
128 return ar->high - ar->low;
131 /* tests whether ar2 is inside ar1 */
132 static inline BOOL addr_range_inside(const struct addr_range* ar1, const struct addr_range* ar2)
134 return ar1->low <= ar2->low && ar2->high <= ar1->high;
137 /* tests whether ar1 and ar2 are disjoint */
138 static inline BOOL addr_range_disjoint(const struct addr_range* ar1, const struct addr_range* ar2)
140 return ar1->high <= ar2->low || ar2->high <= ar1->low;
143 enum location_kind {loc_error, /* reg is the error code */
144 loc_unavailable, /* location is not available */
145 loc_absolute, /* offset is the location */
146 loc_register, /* reg is the location */
147 loc_regrel, /* [reg+offset] is the location */
148 loc_tlsrel, /* offset is the address of the TLS index */
149 loc_user, /* value is debug information dependent,
150 reg & offset can be used ad libidem */
153 enum location_error {loc_err_internal = -1, /* internal while computing */
154 loc_err_too_complex = -2, /* couldn't compute location (even at runtime) */
155 loc_err_out_of_scope = -3, /* variable isn't available at current address */
156 loc_err_cant_read = -4, /* couldn't read memory at given address */
157 loc_err_no_location = -5, /* likely optimized away (by compiler) */
160 struct location
162 unsigned kind : 8,
163 reg;
164 ULONG_PTR offset;
167 struct symt
169 enum SymTagEnum tag;
172 struct symt_ht
174 struct symt symt;
175 struct hash_table_elt hash_elt; /* if global symbol or type */
178 static inline BOOL symt_check_tag(const struct symt* s, enum SymTagEnum tag)
180 return s && s->tag == tag;
183 /* lexical tree */
184 struct symt_block
186 struct symt symt;
187 struct symt* container; /* block, or func */
188 struct vector vchildren; /* sub-blocks & local variables */
189 unsigned num_ranges;
190 struct addr_range ranges[];
193 struct symt_module /* in fact any of .exe, .dll... */
195 struct symt symt; /* module */
196 struct vector vchildren; /* compilation units */
197 struct module* module;
200 struct symt_compiland
202 struct symt symt;
203 struct symt_module* container; /* symt_module */
204 ULONG_PTR address;
205 unsigned source;
206 struct vector vchildren; /* global variables & functions */
207 void* user; /* when debug info provider needs to store information */
210 struct symt_data
212 struct symt symt;
213 struct hash_table_elt hash_elt; /* if global symbol */
214 enum DataKind kind;
215 struct symt* container;
216 struct symt* type;
217 union /* depends on kind */
219 /* DataIs{Global, FileStatic, StaticLocal}:
220 * with loc.kind
221 * loc_absolute loc.offset is address
222 * loc_tlsrel loc.offset is TLS index address
223 * DataIs{Local,Param}:
224 * with loc.kind
225 * loc_absolute not supported
226 * loc_register location is in register loc.reg
227 * loc_regrel location is at address loc.reg + loc.offset
228 * >= loc_user ask debug info provider for resolution
230 struct location var;
231 /* DataIs{Member} (all values are in bits, not bytes) */
232 struct
234 LONG_PTR offset;
235 ULONG_PTR bit_length;
236 ULONG_PTR bit_offset;
237 } member;
238 /* DataIsConstant */
239 VARIANT value;
240 } u;
243 /* Understanding functions internal storage:
244 * - functions, inline sites and blocks can be described as spreading across
245 * several chunks of memory (hence describing potentially a non contiguous
246 * memory space).
247 * - this is described internally as an array of address ranges
248 * (struct addr_range)
250 * - there's a hierarchical (aka lexical) relationship:
251 * + function's parent is a compiland or the module itself
252 * + inline site's parent is either a function or another inline site
253 * + block's parent is either a function, an inline site or another block.
255 * - internal storage rely on the following assumptions:
256 * + in an array of address ranges, one address range doesn't overlap over
257 * one of its siblings
258 * + each address range of a block is inside a single range of its lexical
259 * parent (and outside of the others since they don't overlap)
260 * + each address range of an inline site is inside a single range its
261 * lexical parent
262 * + a function (as of today) is only represented by a single address range
263 * (A).
265 * - all inline sites of a function are stored in a linked list:
266 * + this linked list shall preserve the weak order of the lexical-parent
267 * relationship (eg for any inline site A, which has inline site B
268 * as lexical parent, A must appear before B in the linked list)
270 * - lookup:
271 * + when looking up which inline site contains a given address, the first
272 * range containing that address found while walking the list of inline
273 * sites is the right one.
274 * + when lookup up which inner-most block contains an address, descend the
275 * blocks tree with branching on the block (if any) which contains the given
276 * address in one of its ranges
278 * Notes:
279 * (A): shall evolve but storage in native is awkward: from PGO testing, the
280 * top function is stored with its first range of address; all the others
281 * are stored as blocks, children of compiland, but which lexical parent
282 * is the top function. This breaks the natural assumption that
283 * children <> lexical parent is symmetrical.
284 * (B): see dwarf.c for some gory discrepancies between native & builtin
285 * DbgHelp.
288 struct symt_function
290 struct symt symt; /* SymTagFunction or SymTagInlineSite */
291 struct hash_table_elt hash_elt; /* if global symbol, inline site */
292 struct symt* container; /* compiland (for SymTagFunction) or function (for SymTagInlineSite) */
293 struct symt* type; /* points to function_signature */
294 struct vector vlines;
295 struct vector vchildren; /* locals, params, blocks, start/end, labels, inline sites */
296 struct symt_function* next_inlinesite;/* linked list of inline sites in this function */
297 unsigned num_ranges;
298 struct addr_range ranges[];
301 struct symt_hierarchy_point
303 struct symt symt; /* either SymTagFunctionDebugStart, SymTagFunctionDebugEnd, SymTagLabel */
304 struct hash_table_elt hash_elt; /* if label (and in compiland's hash table if global) */
305 struct symt* parent; /* symt_function or symt_compiland */
306 struct location loc;
309 struct symt_public
311 struct symt symt;
312 struct hash_table_elt hash_elt;
313 struct symt* container; /* compiland */
314 BOOL is_function;
315 ULONG_PTR address;
316 ULONG_PTR size;
319 struct symt_thunk
321 struct symt symt;
322 struct hash_table_elt hash_elt;
323 struct symt* container; /* compiland */
324 ULONG_PTR address;
325 ULONG_PTR size;
326 THUNK_ORDINAL ordinal; /* FIXME: doesn't seem to be accessible */
329 struct symt_custom
331 struct symt symt;
332 struct hash_table_elt hash_elt;
333 DWORD64 address;
334 DWORD size;
337 /* class tree */
338 struct symt_array
340 struct symt symt;
341 int start;
342 DWORD count;
343 struct symt* base_type;
344 struct symt* index_type;
347 struct symt_basic
349 struct symt symt;
350 enum BasicType bt;
351 ULONG_PTR size;
354 struct symt_enum
356 struct symt symt;
357 struct hash_table_elt hash_elt;
358 struct symt* base_type;
359 struct vector vchildren;
362 struct symt_function_signature
364 struct symt symt;
365 struct symt* rettype;
366 struct vector vchildren;
367 enum CV_call_e call_conv;
370 struct symt_function_arg_type
372 struct symt symt;
373 struct symt* arg_type;
376 struct symt_pointer
378 struct symt symt;
379 struct symt* pointsto;
380 ULONG_PTR size;
383 struct symt_typedef
385 struct symt symt;
386 struct hash_table_elt hash_elt;
387 struct symt* type;
390 struct symt_udt
392 struct symt symt;
393 struct hash_table_elt hash_elt;
394 enum UdtKind kind;
395 int size;
396 struct vector vchildren;
399 enum module_type
401 DMT_UNKNOWN, /* for lookup, not actually used for a module */
402 DMT_ELF, /* a real ELF shared module */
403 DMT_PE, /* a native or builtin PE module */
404 DMT_MACHO, /* a real Mach-O shared module */
405 DMT_PDB, /* .PDB file */
406 DMT_DBG, /* .DBG file */
409 struct process;
410 struct module;
412 /* a module can be made of several debug information formats, so we have to
413 * support them all
415 enum format_info
417 DFI_ELF,
418 DFI_PE,
419 DFI_MACHO,
420 DFI_DWARF,
421 DFI_PDB,
422 DFI_LAST
425 struct module_format
427 struct module* module;
428 void (*remove)(struct process* pcs, struct module_format* modfmt);
429 void (*loc_compute)(struct process* pcs,
430 const struct module_format* modfmt,
431 const struct symt_function* func,
432 struct location* loc);
433 union
435 struct elf_module_info* elf_info;
436 struct dwarf2_module_info_s* dwarf2_info;
437 struct pe_module_info* pe_info;
438 struct macho_module_info* macho_info;
439 struct pdb_module_info* pdb_info;
440 } u;
443 struct cpu;
445 struct module
447 struct process* process;
448 IMAGEHLP_MODULEW64 module;
449 WCHAR modulename[64]; /* used for enumeration */
450 struct module* next;
451 enum module_type type : 16;
452 unsigned short is_virtual : 1;
453 struct cpu* cpu;
454 DWORD64 reloc_delta;
455 WCHAR* real_path;
457 /* specific information for debug types */
458 struct module_format* format_info[DFI_LAST];
460 /* memory allocation pool */
461 struct pool pool;
463 /* symbols & symbol tables */
464 struct vector vsymt;
465 struct vector vcustom_symt;
466 int sortlist_valid;
467 unsigned num_sorttab; /* number of symbols with addresses */
468 unsigned num_symbols;
469 unsigned sorttab_size;
470 struct symt_ht** addr_sorttab;
471 struct hash_table ht_symbols;
472 struct symt_module* top;
474 /* types */
475 struct hash_table ht_types;
476 struct vector vtypes;
478 /* source files */
479 unsigned sources_used;
480 unsigned sources_alloc;
481 char* sources;
482 struct wine_rb_tree sources_offsets_tree;
485 typedef BOOL (*enum_modules_cb)(const WCHAR*, ULONG_PTR addr, void* user);
487 struct loader_ops
489 BOOL (*synchronize_module_list)(struct process* process);
490 struct module* (*load_module)(struct process* process, const WCHAR* name, ULONG_PTR addr);
491 BOOL (*load_debug_info)(struct process *process, struct module* module);
492 BOOL (*enum_modules)(struct process* process, enum_modules_cb callback, void* user);
493 BOOL (*fetch_file_info)(struct process* process, const WCHAR* name, ULONG_PTR load_addr, DWORD_PTR* base, DWORD* size, DWORD* checksum);
496 struct process
498 struct process* next;
499 HANDLE handle;
500 const struct loader_ops* loader;
501 WCHAR* search_path;
502 WCHAR* environment;
504 PSYMBOL_REGISTERED_CALLBACK64 reg_cb;
505 PSYMBOL_REGISTERED_CALLBACK reg_cb32;
506 BOOL reg_is_unicode;
507 DWORD64 reg_user;
509 struct module* lmodules;
510 ULONG_PTR dbg_hdr_addr;
512 IMAGEHLP_STACK_FRAME ctx_frame;
513 DWORD64 localscope_pc;
514 struct symt* localscope_symt;
516 unsigned buffer_size;
517 void* buffer;
519 BOOL is_64bit;
520 BOOL is_system_64bit;
523 static inline BOOL read_process_memory(const struct process *process, UINT64 addr, void *buf, size_t size)
525 return ReadProcessMemory(process->handle, (void*)(UINT_PTR)addr, buf, size, NULL);
528 static inline BOOL read_process_integral_value(const struct process* process, UINT64 addr, UINT64* pvalue, size_t size)
530 /* Assuming that debugger and debuggee are little endian. */
531 UINT64 value = 0;
532 if (size > sizeof(value) || !read_process_memory(process, addr, &value, size)) return FALSE;
533 *pvalue = value;
534 return TRUE;
537 struct line_info
539 ULONG_PTR is_first : 1,
540 is_last : 1,
541 is_source_file : 1,
542 line_number;
543 union
545 ULONG_PTR address; /* absolute, if is_source_file isn't set */
546 unsigned source_file; /* if is_source_file is set */
547 } u;
550 struct module_pair
552 struct process* pcs;
553 struct module* requested; /* in: to module_get_debug() */
554 struct module* effective; /* out: module with debug info */
557 enum pdb_kind {PDB_JG, PDB_DS};
559 struct pdb_lookup
561 const char* filename;
562 enum pdb_kind kind;
563 unsigned int age;
564 unsigned int timestamp;
565 GUID guid;
568 struct cpu_stack_walk
570 HANDLE hProcess;
571 HANDLE hThread;
572 BOOL is32;
573 struct cpu * cpu;
574 union
576 struct
578 PREAD_PROCESS_MEMORY_ROUTINE f_read_mem;
579 PTRANSLATE_ADDRESS_ROUTINE f_xlat_adr;
580 PFUNCTION_TABLE_ACCESS_ROUTINE f_tabl_acs;
581 PGET_MODULE_BASE_ROUTINE f_modl_bas;
582 } s32;
583 struct
585 PREAD_PROCESS_MEMORY_ROUTINE64 f_read_mem;
586 PTRANSLATE_ADDRESS_ROUTINE64 f_xlat_adr;
587 PFUNCTION_TABLE_ACCESS_ROUTINE64 f_tabl_acs;
588 PGET_MODULE_BASE_ROUTINE64 f_modl_bas;
589 } s64;
590 } u;
593 struct dump_memory
595 ULONG64 base;
596 ULONG size;
597 ULONG rva;
600 struct dump_memory64
602 ULONG64 base;
603 ULONG64 size;
606 struct dump_module
608 unsigned is_elf;
609 ULONG64 base;
610 ULONG size;
611 DWORD timestamp;
612 DWORD checksum;
613 WCHAR name[MAX_PATH];
616 struct dump_thread
618 ULONG tid;
619 ULONG prio_class;
620 ULONG curr_prio;
623 struct dump_context
625 /* process & thread information */
626 struct process *process;
627 DWORD pid;
628 unsigned flags_out;
629 /* thread information */
630 struct dump_thread* threads;
631 unsigned num_threads;
632 /* module information */
633 struct dump_module* modules;
634 unsigned num_modules;
635 unsigned alloc_modules;
636 /* exception information */
637 /* output information */
638 MINIDUMP_TYPE type;
639 HANDLE hFile;
640 RVA rva;
641 struct dump_memory* mem;
642 unsigned num_mem;
643 unsigned alloc_mem;
644 struct dump_memory64* mem64;
645 unsigned num_mem64;
646 unsigned alloc_mem64;
647 /* callback information */
648 MINIDUMP_CALLBACK_INFORMATION* cb;
651 union ctx
653 CONTEXT ctx;
654 WOW64_CONTEXT x86;
657 enum cpu_addr {cpu_addr_pc, cpu_addr_stack, cpu_addr_frame};
658 struct cpu
660 DWORD machine;
661 DWORD word_size;
662 DWORD frame_regno;
664 /* address manipulation */
665 BOOL (*get_addr)(HANDLE hThread, const CONTEXT* ctx,
666 enum cpu_addr, ADDRESS64* addr);
668 /* stack manipulation */
669 BOOL (*stack_walk)(struct cpu_stack_walk *csw, STACKFRAME64 *frame,
670 union ctx *ctx);
672 /* module manipulation */
673 void* (*find_runtime_function)(struct module*, DWORD64 addr);
675 /* dwarf dedicated information */
676 unsigned (*map_dwarf_register)(unsigned regno, const struct module* module, BOOL eh_frame);
678 /* context related manipulation */
679 void * (*fetch_context_reg)(union ctx *ctx, unsigned regno, unsigned *size);
680 const char* (*fetch_regname)(unsigned regno);
682 /* minidump per CPU extension */
683 BOOL (*fetch_minidump_thread)(struct dump_context* dc, unsigned index, unsigned flags, const CONTEXT* ctx);
684 BOOL (*fetch_minidump_module)(struct dump_context* dc, unsigned index, unsigned flags);
687 extern struct cpu* dbghelp_current_cpu DECLSPEC_HIDDEN;
689 /* PDB and Codeview */
691 struct msc_debug_info
693 struct module* module;
694 int nsect;
695 const IMAGE_SECTION_HEADER* sectp;
696 int nomap;
697 const OMAP* omapp;
698 const BYTE* root;
701 /* coff.c */
702 extern BOOL coff_process_info(const struct msc_debug_info* msc_dbg) DECLSPEC_HIDDEN;
704 /* dbghelp.c */
705 extern struct process* process_find_by_handle(HANDLE hProcess) DECLSPEC_HIDDEN;
706 extern BOOL validate_addr64(DWORD64 addr) DECLSPEC_HIDDEN;
707 extern BOOL pcs_callback(const struct process* pcs, ULONG action, void* data) DECLSPEC_HIDDEN;
708 extern void* fetch_buffer(struct process* pcs, unsigned size) DECLSPEC_HIDDEN;
709 extern const char* wine_dbgstr_addr(const ADDRESS64* addr) DECLSPEC_HIDDEN;
710 extern struct cpu* cpu_find(DWORD) DECLSPEC_HIDDEN;
711 extern const WCHAR *process_getenv(const struct process *process, const WCHAR *name) DECLSPEC_HIDDEN;
712 extern const struct cpu* process_get_cpu(const struct process* pcs) DECLSPEC_HIDDEN;
713 extern DWORD calc_crc32(HANDLE handle) DECLSPEC_HIDDEN;
715 /* elf_module.c */
716 extern BOOL elf_read_wine_loader_dbg_info(struct process* pcs, ULONG_PTR addr) DECLSPEC_HIDDEN;
717 struct elf_thunk_area;
718 extern int elf_is_in_thunk_area(ULONG_PTR addr, const struct elf_thunk_area* thunks) DECLSPEC_HIDDEN;
720 /* macho_module.c */
721 extern BOOL macho_read_wine_loader_dbg_info(struct process* pcs, ULONG_PTR addr) DECLSPEC_HIDDEN;
723 /* minidump.c */
724 void minidump_add_memory_block(struct dump_context* dc, ULONG64 base, ULONG size, ULONG rva) DECLSPEC_HIDDEN;
726 /* module.c */
727 extern const WCHAR S_ElfW[] DECLSPEC_HIDDEN;
728 extern const WCHAR S_WineLoaderW[] DECLSPEC_HIDDEN;
729 extern const struct loader_ops no_loader_ops DECLSPEC_HIDDEN;
730 extern const struct loader_ops empty_loader_ops DECLSPEC_HIDDEN;
732 extern BOOL module_init_pair(struct module_pair* pair, HANDLE hProcess,
733 DWORD64 addr) DECLSPEC_HIDDEN;
734 extern struct module*
735 module_find_by_addr(const struct process* pcs, DWORD64 addr,
736 enum module_type type) DECLSPEC_HIDDEN;
737 extern struct module*
738 module_find_by_nameW(const struct process* pcs,
739 const WCHAR* name) DECLSPEC_HIDDEN;
740 extern struct module*
741 module_find_by_nameA(const struct process* pcs,
742 const char* name) DECLSPEC_HIDDEN;
743 extern struct module*
744 module_is_already_loaded(const struct process* pcs,
745 const WCHAR* imgname) DECLSPEC_HIDDEN;
746 extern BOOL module_get_debug(struct module_pair*) DECLSPEC_HIDDEN;
747 extern struct module*
748 module_new(struct process* pcs, const WCHAR* name,
749 enum module_type type, BOOL virtual,
750 DWORD64 addr, DWORD64 size,
751 ULONG_PTR stamp, ULONG_PTR checksum, WORD machine) DECLSPEC_HIDDEN;
752 extern struct module*
753 module_get_containee(const struct process* pcs,
754 const struct module* inner) DECLSPEC_HIDDEN;
755 extern void module_reset_debug_info(struct module* module) DECLSPEC_HIDDEN;
756 extern BOOL module_remove(struct process* pcs,
757 struct module* module) DECLSPEC_HIDDEN;
758 extern void module_set_module(struct module* module, const WCHAR* name) DECLSPEC_HIDDEN;
759 extern WCHAR* get_wine_loader_name(struct process *pcs) __WINE_DEALLOC(HeapFree, 3) __WINE_MALLOC DECLSPEC_HIDDEN;
761 /* msc.c */
762 extern BOOL pe_load_debug_directory(const struct process* pcs,
763 struct module* module,
764 const BYTE* mapping,
765 const IMAGE_SECTION_HEADER* sectp, DWORD nsect,
766 const IMAGE_DEBUG_DIRECTORY* dbg, int nDbg) DECLSPEC_HIDDEN;
767 extern DWORD msc_get_file_indexinfo(void* image, const IMAGE_DEBUG_DIRECTORY* dbgdir, DWORD size,
768 SYMSRV_INDEX_INFOW* info) DECLSPEC_HIDDEN;
769 extern BOOL pdb_fetch_file_info(const struct pdb_lookup* pdb_lookup, unsigned* matched) DECLSPEC_HIDDEN;
770 struct pdb_cmd_pair {
771 const char* name;
772 DWORD* pvalue;
774 extern BOOL pdb_virtual_unwind(struct cpu_stack_walk *csw, DWORD_PTR ip,
775 union ctx *context, struct pdb_cmd_pair *cpair) DECLSPEC_HIDDEN;
776 extern DWORD pdb_get_file_indexinfo(void* image, DWORD size, SYMSRV_INDEX_INFOW* info);
778 /* path.c */
779 extern BOOL path_find_symbol_file(const struct process* pcs, const struct module* module,
780 PCSTR full_path, enum module_type type, const GUID* guid, DWORD dw1, DWORD dw2,
781 WCHAR *buffer, BOOL* is_unmatched) DECLSPEC_HIDDEN;
782 extern WCHAR *get_dos_file_name(const WCHAR *filename) __WINE_DEALLOC(HeapFree, 3) __WINE_MALLOC DECLSPEC_HIDDEN;
783 extern BOOL search_dll_path(const struct process* process, const WCHAR *name, WORD machine,
784 BOOL (*match)(void*, HANDLE, const WCHAR*), void *param) DECLSPEC_HIDDEN;
785 extern BOOL search_unix_path(const WCHAR *name, const WCHAR *path, BOOL (*match)(void*, HANDLE, const WCHAR*), void *param) DECLSPEC_HIDDEN;
786 extern const WCHAR* file_name(const WCHAR* str) DECLSPEC_HIDDEN;
787 extern const char* file_nameA(const char* str) DECLSPEC_HIDDEN;
789 /* pe_module.c */
790 extern BOOL pe_load_nt_header(HANDLE hProc, DWORD64 base, IMAGE_NT_HEADERS* nth) DECLSPEC_HIDDEN;
791 extern struct module*
792 pe_load_native_module(struct process* pcs, const WCHAR* name,
793 HANDLE hFile, DWORD64 base, DWORD size) DECLSPEC_HIDDEN;
794 extern struct module*
795 pe_load_builtin_module(struct process* pcs, const WCHAR* name,
796 DWORD64 base, DWORD64 size) DECLSPEC_HIDDEN;
797 extern BOOL pe_load_debug_info(const struct process* pcs,
798 struct module* module) DECLSPEC_HIDDEN;
799 extern const char* pe_map_directory(struct module* module, int dirno, DWORD* size) DECLSPEC_HIDDEN;
800 extern DWORD pe_get_file_indexinfo(void* image, DWORD size, SYMSRV_INDEX_INFOW* info) DECLSPEC_HIDDEN;
802 /* source.c */
803 extern unsigned source_new(struct module* module, const char* basedir, const char* source) DECLSPEC_HIDDEN;
804 extern const char* source_get(const struct module* module, unsigned idx) DECLSPEC_HIDDEN;
805 extern int source_rb_compare(const void *key, const struct wine_rb_entry *entry) DECLSPEC_HIDDEN;
807 /* stabs.c */
808 typedef void (*stabs_def_cb)(struct module* module, ULONG_PTR load_offset,
809 const char* name, ULONG_PTR offset,
810 BOOL is_public, BOOL is_global, unsigned char other,
811 struct symt_compiland* compiland, void* user);
812 extern BOOL stabs_parse(struct module* module, ULONG_PTR load_offset,
813 const char* stabs, size_t nstab, size_t stabsize,
814 const char* strs, int strtablen,
815 stabs_def_cb callback, void* user) DECLSPEC_HIDDEN;
817 /* dwarf.c */
818 struct image_file_map;
819 extern BOOL dwarf2_parse(struct module* module, ULONG_PTR load_offset,
820 const struct elf_thunk_area* thunks,
821 struct image_file_map* fmap) DECLSPEC_HIDDEN;
822 extern BOOL dwarf2_virtual_unwind(struct cpu_stack_walk *csw, DWORD_PTR ip,
823 union ctx *ctx, DWORD64 *cfa) DECLSPEC_HIDDEN;
825 /* stack.c */
826 extern BOOL sw_read_mem(struct cpu_stack_walk* csw, DWORD64 addr, void* ptr, DWORD sz) DECLSPEC_HIDDEN;
827 extern DWORD64 sw_xlat_addr(struct cpu_stack_walk* csw, ADDRESS64* addr) DECLSPEC_HIDDEN;
828 extern void* sw_table_access(struct cpu_stack_walk* csw, DWORD64 addr) DECLSPEC_HIDDEN;
829 extern DWORD64 sw_module_base(struct cpu_stack_walk* csw, DWORD64 addr) DECLSPEC_HIDDEN;
831 /* symbol.c */
832 extern const char* symt_get_name(const struct symt* sym) DECLSPEC_HIDDEN;
833 extern WCHAR* symt_get_nameW(const struct symt* sym) DECLSPEC_HIDDEN;
834 extern BOOL symt_get_address(const struct symt* type, ULONG64* addr) DECLSPEC_HIDDEN;
835 extern int __cdecl symt_cmp_addr(const void* p1, const void* p2) DECLSPEC_HIDDEN;
836 extern void copy_symbolW(SYMBOL_INFOW* siw, const SYMBOL_INFO* si) DECLSPEC_HIDDEN;
837 extern void symbol_setname(SYMBOL_INFO* si, const char* name) DECLSPEC_HIDDEN;
838 extern struct symt_ht*
839 symt_find_nearest(struct module* module, DWORD_PTR addr) DECLSPEC_HIDDEN;
840 extern struct symt_ht*
841 symt_find_symbol_at(struct module* module, DWORD_PTR addr) DECLSPEC_HIDDEN;
842 extern struct symt_module*
843 symt_new_module(struct module* module) DECLSPEC_HIDDEN;
844 extern struct symt_compiland*
845 symt_new_compiland(struct module* module, unsigned src_idx) DECLSPEC_HIDDEN;
846 extern struct symt_public*
847 symt_new_public(struct module* module,
848 struct symt_compiland* parent,
849 const char* typename,
850 BOOL is_function,
851 ULONG_PTR address,
852 unsigned size) DECLSPEC_HIDDEN;
853 extern struct symt_data*
854 symt_new_global_variable(struct module* module,
855 struct symt_compiland* parent,
856 const char* name, unsigned is_static,
857 struct location loc, ULONG_PTR size,
858 struct symt* type) DECLSPEC_HIDDEN;
859 extern struct symt_function*
860 symt_new_function(struct module* module,
861 struct symt_compiland* parent,
862 const char* name,
863 ULONG_PTR addr, ULONG_PTR size,
864 struct symt* type) DECLSPEC_HIDDEN;
865 extern struct symt_function*
866 symt_new_inlinesite(struct module* module,
867 struct symt_function* func,
868 struct symt* parent,
869 const char* name,
870 struct symt* type,
871 unsigned num_ranges) DECLSPEC_HIDDEN;
872 extern void symt_add_func_line(struct module* module,
873 struct symt_function* func,
874 unsigned source_idx, int line_num,
875 ULONG_PTR offset) DECLSPEC_HIDDEN;
876 extern struct symt_data*
877 symt_add_func_local(struct module* module,
878 struct symt_function* func,
879 enum DataKind dt, const struct location* loc,
880 struct symt_block* block,
881 struct symt* type, const char* name) DECLSPEC_HIDDEN;
882 extern struct symt_data*
883 symt_add_func_constant(struct module* module,
884 struct symt_function* func, struct symt_block* block,
885 struct symt* type, const char* name, VARIANT* v) DECLSPEC_HIDDEN;
886 extern struct symt_block*
887 symt_open_func_block(struct module* module,
888 struct symt_function* func,
889 struct symt_block* block,
890 unsigned num_ranges) DECLSPEC_HIDDEN;
891 extern struct symt_block*
892 symt_close_func_block(struct module* module,
893 const struct symt_function* func,
894 struct symt_block* block) DECLSPEC_HIDDEN;
895 extern struct symt_hierarchy_point*
896 symt_add_function_point(struct module* module,
897 struct symt_function* func,
898 enum SymTagEnum point,
899 const struct location* loc,
900 const char* name) DECLSPEC_HIDDEN;
901 extern struct symt_thunk*
902 symt_new_thunk(struct module* module,
903 struct symt_compiland* parent,
904 const char* name, THUNK_ORDINAL ord,
905 ULONG_PTR addr, ULONG_PTR size) DECLSPEC_HIDDEN;
906 extern struct symt_data*
907 symt_new_constant(struct module* module,
908 struct symt_compiland* parent,
909 const char* name, struct symt* type,
910 const VARIANT* v) DECLSPEC_HIDDEN;
911 extern struct symt_hierarchy_point*
912 symt_new_label(struct module* module,
913 struct symt_compiland* compiland,
914 const char* name, ULONG_PTR address) DECLSPEC_HIDDEN;
915 extern struct symt* symt_index2ptr(struct module* module, DWORD id) DECLSPEC_HIDDEN;
916 extern DWORD symt_ptr2index(struct module* module, const struct symt* sym) DECLSPEC_HIDDEN;
917 extern struct symt_custom*
918 symt_new_custom(struct module* module, const char* name,
919 DWORD64 addr, DWORD size) DECLSPEC_HIDDEN;
921 /* type.c */
922 extern void symt_init_basic(struct module* module) DECLSPEC_HIDDEN;
923 extern BOOL symt_get_info(struct module* module, const struct symt* type,
924 IMAGEHLP_SYMBOL_TYPE_INFO req, void* pInfo) DECLSPEC_HIDDEN;
925 extern struct symt_basic*
926 symt_get_basic(enum BasicType, unsigned size) DECLSPEC_HIDDEN;
927 extern struct symt_udt*
928 symt_new_udt(struct module* module, const char* typename,
929 unsigned size, enum UdtKind kind) DECLSPEC_HIDDEN;
930 extern BOOL symt_set_udt_size(struct module* module,
931 struct symt_udt* type, unsigned size) DECLSPEC_HIDDEN;
932 extern BOOL symt_add_udt_element(struct module* module,
933 struct symt_udt* udt_type,
934 const char* name,
935 struct symt* elt_type, unsigned offset,
936 unsigned bit_offset, unsigned bit_size) DECLSPEC_HIDDEN;
937 extern struct symt_enum*
938 symt_new_enum(struct module* module, const char* typename,
939 struct symt* basetype) DECLSPEC_HIDDEN;
940 extern BOOL symt_add_enum_element(struct module* module,
941 struct symt_enum* enum_type,
942 const char* name, int value) DECLSPEC_HIDDEN;
943 extern struct symt_array*
944 symt_new_array(struct module* module, int min, DWORD count,
945 struct symt* base, struct symt* index) DECLSPEC_HIDDEN;
946 extern struct symt_function_signature*
947 symt_new_function_signature(struct module* module,
948 struct symt* ret_type,
949 enum CV_call_e call_conv) DECLSPEC_HIDDEN;
950 extern BOOL symt_add_function_signature_parameter(struct module* module,
951 struct symt_function_signature* sig,
952 struct symt* param) DECLSPEC_HIDDEN;
953 extern struct symt_pointer*
954 symt_new_pointer(struct module* module,
955 struct symt* ref_type,
956 ULONG_PTR size) DECLSPEC_HIDDEN;
957 extern struct symt_typedef*
958 symt_new_typedef(struct module* module, struct symt* ref,
959 const char* name) DECLSPEC_HIDDEN;
960 extern struct symt_function*
961 symt_find_lowest_inlined(struct symt_function* func, DWORD64 addr) DECLSPEC_HIDDEN;
962 extern struct symt*
963 symt_get_upper_inlined(struct symt_function* inlined) DECLSPEC_HIDDEN;
964 static inline struct symt_function*
965 symt_get_function_from_inlined(struct symt_function* inlined)
967 while (!symt_check_tag(&inlined->symt, SymTagFunction))
968 inlined = (struct symt_function*)symt_get_upper_inlined(inlined);
969 return inlined;
971 extern struct symt_function*
972 symt_find_inlined_site(struct module* module,
973 DWORD64 addr, DWORD inline_ctx) DECLSPEC_HIDDEN;
975 /* Inline context encoding (different from what native does):
976 * bits 31:30: 3 ignore (includes INLINE_FRAME_CONTEXT_IGNORE=0xFFFFFFFF)
977 * 2 regular frame
978 * 1 frame with inlined function(s).
979 * 0 init (includes INLINE_FRAME_CONTEXT_INIT=0)
980 * so either stackwalkex is called with:
981 * - inlinectx=IGNORE, and we use (old) StackWalk64 behavior:
982 * - inlinectx=INIT, and StackWalkEx will upon return swing back&forth between:
983 * INLINE when the frame is from an inline site (inside a function)
984 * REGULAR when the frame is for a function without inline site
985 * bits 29:00 depth of inline site (way too big!!)
986 * 0 being the lowest inline site
988 #define IFC_MODE_IGNORE 0xC0000000
989 #define IFC_MODE_REGULAR 0x80000000
990 #define IFC_MODE_INLINE 0x40000000
991 #define IFC_MODE_INIT 0x00000000
992 #define IFC_DEPTH_MASK 0x3FFFFFFF
993 #define IFC_MODE(x) ((x) & ~IFC_DEPTH_MASK)
994 #define IFC_DEPTH(x) ((x) & IFC_DEPTH_MASK)