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
32 #include "wine/list.h"
33 #include "wine/rbtree.h"
37 struct pool
/* poor's man */
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
;
55 unsigned buckets_allocated
;
58 void vector_init(struct vector
* v
, unsigned elt_sz
, unsigned bucket_sz
) DECLSPEC_HIDDEN
;
59 unsigned vector_length(const struct vector
* v
) DECLSPEC_HIDDEN
;
60 void* vector_at(const struct vector
* v
, unsigned pos
) DECLSPEC_HIDDEN
;
61 void* vector_add(struct vector
* v
, struct pool
* pool
) DECLSPEC_HIDDEN
;
65 struct vector key2index
;
66 struct vector elements
;
69 void sparse_array_init(struct sparse_array
* sa
, unsigned elt_sz
, unsigned bucket_sz
) DECLSPEC_HIDDEN
;
70 void* sparse_array_find(const struct sparse_array
* sa
, ULONG_PTR idx
) DECLSPEC_HIDDEN
;
71 void* sparse_array_add(struct sparse_array
* sa
, ULONG_PTR key
, struct pool
* pool
) DECLSPEC_HIDDEN
;
72 unsigned sparse_array_length(const struct sparse_array
* sa
) DECLSPEC_HIDDEN
;
77 struct hash_table_elt
* next
;
80 struct hash_table_bucket
82 struct hash_table_elt
* first
;
83 struct hash_table_elt
* last
;
90 struct hash_table_bucket
* buckets
;
94 void hash_table_init(struct pool
* pool
, struct hash_table
* ht
,
95 unsigned num_buckets
) DECLSPEC_HIDDEN
;
96 void hash_table_destroy(struct hash_table
* ht
) DECLSPEC_HIDDEN
;
97 void hash_table_add(struct hash_table
* ht
, struct hash_table_elt
* elt
) DECLSPEC_HIDDEN
;
99 struct hash_table_iter
101 const struct hash_table
* ht
;
102 struct hash_table_elt
* element
;
107 void hash_table_iter_init(const struct hash_table
* ht
,
108 struct hash_table_iter
* hti
, const char* name
) DECLSPEC_HIDDEN
;
109 void* hash_table_iter_up(struct hash_table_iter
* hti
) DECLSPEC_HIDDEN
;
112 extern unsigned dbghelp_options DECLSPEC_HIDDEN
;
113 extern BOOL dbghelp_opt_native DECLSPEC_HIDDEN
;
114 extern SYSTEM_INFO sysinfo DECLSPEC_HIDDEN
;
116 /* FIXME: this could be optimized later on by using relative offsets and smaller integral sizes */
119 DWORD64 low
; /* absolute address of first byte of the range */
120 DWORD64 high
; /* absolute address of first byte after the range */
123 static inline DWORD64
addr_range_size(const struct addr_range
* ar
)
125 return ar
->high
- ar
->low
;
128 /* tests whether ar2 is inside ar1 */
129 static inline BOOL
addr_range_inside(const struct addr_range
* ar1
, const struct addr_range
* ar2
)
131 return ar1
->low
<= ar2
->low
&& ar2
->high
<= ar1
->high
;
134 /* tests whether ar1 and ar2 are disjoint */
135 static inline BOOL
addr_range_disjoint(const struct addr_range
* ar1
, const struct addr_range
* ar2
)
137 return ar1
->high
<= ar2
->low
|| ar2
->high
<= ar1
->low
;
140 enum location_kind
{loc_error
, /* reg is the error code */
141 loc_unavailable
, /* location is not available */
142 loc_absolute
, /* offset is the location */
143 loc_register
, /* reg is the location */
144 loc_regrel
, /* [reg+offset] is the location */
145 loc_tlsrel
, /* offset is the address of the TLS index */
146 loc_user
, /* value is debug information dependent,
147 reg & offset can be used ad libidem */
150 enum location_error
{loc_err_internal
= -1, /* internal while computing */
151 loc_err_too_complex
= -2, /* couldn't compute location (even at runtime) */
152 loc_err_out_of_scope
= -3, /* variable isn't available at current address */
153 loc_err_cant_read
= -4, /* couldn't read memory at given address */
154 loc_err_no_location
= -5, /* likely optimized away (by compiler) */
172 struct hash_table_elt hash_elt
; /* if global symbol or type */
175 static inline BOOL
symt_check_tag(const struct symt
* s
, enum SymTagEnum tag
)
177 return s
&& s
->tag
== tag
;
184 struct symt
* container
; /* block, or func */
185 struct vector vchildren
; /* sub-blocks & local variables */
187 struct addr_range ranges
[];
190 struct symt_module
/* in fact any of .exe, .dll... */
192 struct symt symt
; /* module */
193 struct vector vchildren
; /* compilation units */
194 struct module
* module
;
197 struct symt_compiland
200 struct symt_module
* container
; /* symt_module */
203 struct vector vchildren
; /* global variables & functions */
204 void* user
; /* when debug info provider needs to store information */
210 struct hash_table_elt hash_elt
; /* if global symbol */
212 struct symt
* container
;
214 union /* depends on kind */
216 /* DataIs{Global, FileStatic, StaticLocal}:
218 * loc_absolute loc.offset is address
219 * loc_tlsrel loc.offset is TLS index address
220 * DataIs{Local,Param}:
222 * loc_absolute not supported
223 * loc_register location is in register loc.reg
224 * loc_regrel location is at address loc.reg + loc.offset
225 * >= loc_user ask debug info provider for resolution
228 /* DataIs{Member} (all values are in bits, not bytes) */
232 ULONG_PTR bit_length
;
233 ULONG_PTR bit_offset
;
240 /* Understanding functions internal storage:
241 * - functions, inline sites and blocks can be described as spreading across
242 * several chunks of memory (hence describing potentially a non contiguous
244 * - this is described internally as an array of address ranges
245 * (struct addr_range)
247 * - there's a hierarchical (aka lexical) relationship:
248 * + function's parent is a compiland or the module itself
249 * + inline site's parent is either a function or another inline site
250 * + block's parent is either a function, an inline site or another block.
252 * - internal storage rely on the following assumptions:
253 * + in an array of address ranges, one address range doesn't overlap over
254 * one of its siblings
255 * + each address range of a block is inside a single range of its lexical
256 * parent (and outside of the others since they don't overlap)
257 * + each address range of an inline site is inside a single range its
259 * + a function (as of today) is only represented by a single address range
262 * - all inline sites of a function are stored in a linked list:
263 * + this linked list shall preserve the weak order of the lexical-parent
264 * relationship (eg for any inline site A, which has inline site B
265 * as lexical parent, A must appear before B in the linked list)
268 * + when looking up which inline site contains a given address, the first
269 * range containing that address found while walking the list of inline
270 * sites is the right one.
271 * + when lookup up which inner-most block contains an address, descend the
272 * blocks tree with branching on the block (if any) which contains the given
273 * address in one of its ranges
276 * (A): shall evolve but storage in native is awkward: from PGO testing, the
277 * top function is stored with its first range of address; all the others
278 * are stored as blocks, children of compiland, but which lexical parent
279 * is the top function. This breaks the natural assumption that
280 * children <> lexical parent is symmetrical.
281 * (B): see dwarf.c for some gory discrepancies between native & builtin
287 struct symt symt
; /* SymTagFunction or SymTagInlineSite */
288 struct hash_table_elt hash_elt
; /* if global symbol, inline site */
289 struct symt
* container
; /* compiland (for SymTagFunction) or function (for SymTagInlineSite) */
290 struct symt
* type
; /* points to function_signature */
291 struct vector vlines
;
292 struct vector vchildren
; /* locals, params, blocks, start/end, labels, inline sites */
293 struct symt_function
* next_inlinesite
;/* linked list of inline sites in this function */
295 struct addr_range ranges
[];
298 struct symt_hierarchy_point
300 struct symt symt
; /* either SymTagFunctionDebugStart, SymTagFunctionDebugEnd, SymTagLabel */
301 struct hash_table_elt hash_elt
; /* if label (and in compiland's hash table if global) */
302 struct symt
* parent
; /* symt_function or symt_compiland */
309 struct hash_table_elt hash_elt
;
310 struct symt
* container
; /* compiland */
319 struct hash_table_elt hash_elt
;
320 struct symt
* container
; /* compiland */
323 THUNK_ORDINAL ordinal
; /* FIXME: doesn't seem to be accessible */
329 struct hash_table_elt hash_elt
;
340 struct symt
* base_type
;
341 struct symt
* index_type
;
354 struct hash_table_elt hash_elt
;
355 struct symt
* base_type
;
356 struct vector vchildren
;
359 struct symt_function_signature
362 struct symt
* rettype
;
363 struct vector vchildren
;
364 enum CV_call_e call_conv
;
367 struct symt_function_arg_type
370 struct symt
* arg_type
;
376 struct symt
* pointsto
;
383 struct hash_table_elt hash_elt
;
390 struct hash_table_elt hash_elt
;
393 struct vector vchildren
;
398 DMT_UNKNOWN
, /* for lookup, not actually used for a module */
399 DMT_ELF
, /* a real ELF shared module */
400 DMT_PE
, /* a native or builtin PE module */
401 DMT_MACHO
, /* a real Mach-O shared module */
402 DMT_PDB
, /* .PDB file */
403 DMT_DBG
, /* .DBG file */
409 /* a module can be made of several debug information formats, so we have to
424 struct module
* module
;
425 void (*remove
)(struct process
* pcs
, struct module_format
* modfmt
);
426 void (*loc_compute
)(struct process
* pcs
,
427 const struct module_format
* modfmt
,
428 const struct symt_function
* func
,
429 struct location
* loc
);
432 struct elf_module_info
* elf_info
;
433 struct dwarf2_module_info_s
* dwarf2_info
;
434 struct pe_module_info
* pe_info
;
435 struct macho_module_info
* macho_info
;
436 struct pdb_module_info
* pdb_info
;
444 struct process
* process
;
445 IMAGEHLP_MODULEW64 module
;
446 WCHAR modulename
[64]; /* used for enumeration */
448 enum module_type type
: 16;
449 unsigned short is_virtual
: 1;
454 /* specific information for debug types */
455 struct module_format
* format_info
[DFI_LAST
];
457 /* memory allocation pool */
460 /* symbols & symbol tables */
462 struct vector vcustom_symt
;
464 unsigned num_sorttab
; /* number of symbols with addresses */
465 unsigned num_symbols
;
466 unsigned sorttab_size
;
467 struct symt_ht
** addr_sorttab
;
468 struct hash_table ht_symbols
;
469 struct symt_module
* top
;
472 struct hash_table ht_types
;
473 struct vector vtypes
;
476 unsigned sources_used
;
477 unsigned sources_alloc
;
479 struct wine_rb_tree sources_offsets_tree
;
482 typedef BOOL (*enum_modules_cb
)(const WCHAR
*, ULONG_PTR addr
, void* user
);
486 BOOL (*synchronize_module_list
)(struct process
* process
);
487 struct module
* (*load_module
)(struct process
* process
, const WCHAR
* name
, ULONG_PTR addr
);
488 BOOL (*load_debug_info
)(struct process
*process
, struct module
* module
);
489 BOOL (*enum_modules
)(struct process
* process
, enum_modules_cb callback
, void* user
);
490 BOOL (*fetch_file_info
)(struct process
* process
, const WCHAR
* name
, ULONG_PTR load_addr
, DWORD_PTR
* base
, DWORD
* size
, DWORD
* checksum
);
495 struct process
* next
;
497 const struct loader_ops
* loader
;
501 PSYMBOL_REGISTERED_CALLBACK64 reg_cb
;
502 PSYMBOL_REGISTERED_CALLBACK reg_cb32
;
506 struct module
* lmodules
;
507 ULONG_PTR dbg_hdr_addr
;
509 IMAGEHLP_STACK_FRAME ctx_frame
;
510 DWORD64 localscope_pc
;
511 struct symt
* localscope_symt
;
513 unsigned buffer_size
;
519 static inline BOOL
read_process_memory(const struct process
*process
, UINT64 addr
, void *buf
, size_t size
)
521 return ReadProcessMemory(process
->handle
, (void*)(UINT_PTR
)addr
, buf
, size
, NULL
);
526 ULONG_PTR is_first
: 1,
532 ULONG_PTR address
; /* absolute, if is_source_file isn't set */
533 unsigned source_file
; /* if is_source_file is set */
540 struct module
* requested
; /* in: to module_get_debug() */
541 struct module
* effective
; /* out: module with debug info */
544 enum pdb_kind
{PDB_JG
, PDB_DS
};
548 const char* filename
;
551 unsigned int timestamp
;
555 struct cpu_stack_walk
565 PREAD_PROCESS_MEMORY_ROUTINE f_read_mem
;
566 PTRANSLATE_ADDRESS_ROUTINE f_xlat_adr
;
567 PFUNCTION_TABLE_ACCESS_ROUTINE f_tabl_acs
;
568 PGET_MODULE_BASE_ROUTINE f_modl_bas
;
572 PREAD_PROCESS_MEMORY_ROUTINE64 f_read_mem
;
573 PTRANSLATE_ADDRESS_ROUTINE64 f_xlat_adr
;
574 PFUNCTION_TABLE_ACCESS_ROUTINE64 f_tabl_acs
;
575 PGET_MODULE_BASE_ROUTINE64 f_modl_bas
;
600 WCHAR name
[MAX_PATH
];
612 /* process & thread information */
613 struct process
*process
;
616 /* thread information */
617 struct dump_thread
* threads
;
618 unsigned num_threads
;
619 /* module information */
620 struct dump_module
* modules
;
621 unsigned num_modules
;
622 unsigned alloc_modules
;
623 /* exception information */
624 /* output information */
628 struct dump_memory
* mem
;
631 struct dump_memory64
* mem64
;
633 unsigned alloc_mem64
;
634 /* callback information */
635 MINIDUMP_CALLBACK_INFORMATION
* cb
;
644 enum cpu_addr
{cpu_addr_pc
, cpu_addr_stack
, cpu_addr_frame
};
651 /* address manipulation */
652 BOOL (*get_addr
)(HANDLE hThread
, const CONTEXT
* ctx
,
653 enum cpu_addr
, ADDRESS64
* addr
);
655 /* stack manipulation */
656 BOOL (*stack_walk
)(struct cpu_stack_walk
*csw
, STACKFRAME64
*frame
,
659 /* module manipulation */
660 void* (*find_runtime_function
)(struct module
*, DWORD64 addr
);
662 /* dwarf dedicated information */
663 unsigned (*map_dwarf_register
)(unsigned regno
, const struct module
* module
, BOOL eh_frame
);
665 /* context related manipulation */
666 void * (*fetch_context_reg
)(union ctx
*ctx
, unsigned regno
, unsigned *size
);
667 const char* (*fetch_regname
)(unsigned regno
);
669 /* minidump per CPU extension */
670 BOOL (*fetch_minidump_thread
)(struct dump_context
* dc
, unsigned index
, unsigned flags
, const CONTEXT
* ctx
);
671 BOOL (*fetch_minidump_module
)(struct dump_context
* dc
, unsigned index
, unsigned flags
);
674 extern struct cpu
* dbghelp_current_cpu DECLSPEC_HIDDEN
;
676 /* PDB and Codeview */
678 struct msc_debug_info
680 struct module
* module
;
682 const IMAGE_SECTION_HEADER
* sectp
;
689 extern BOOL
coff_process_info(const struct msc_debug_info
* msc_dbg
) DECLSPEC_HIDDEN
;
692 extern struct process
* process_find_by_handle(HANDLE hProcess
) DECLSPEC_HIDDEN
;
693 extern BOOL
validate_addr64(DWORD64 addr
) DECLSPEC_HIDDEN
;
694 extern BOOL
pcs_callback(const struct process
* pcs
, ULONG action
, void* data
) DECLSPEC_HIDDEN
;
695 extern void* fetch_buffer(struct process
* pcs
, unsigned size
) DECLSPEC_HIDDEN
;
696 extern const char* wine_dbgstr_addr(const ADDRESS64
* addr
) DECLSPEC_HIDDEN
;
697 extern struct cpu
* cpu_find(DWORD
) DECLSPEC_HIDDEN
;
698 extern const WCHAR
*process_getenv(const struct process
*process
, const WCHAR
*name
) DECLSPEC_HIDDEN
;
699 extern const struct cpu
* process_get_cpu(const struct process
* pcs
) DECLSPEC_HIDDEN
;
700 extern DWORD
calc_crc32(HANDLE handle
) DECLSPEC_HIDDEN
;
703 extern BOOL
elf_read_wine_loader_dbg_info(struct process
* pcs
, ULONG_PTR addr
) DECLSPEC_HIDDEN
;
704 struct elf_thunk_area
;
705 extern int elf_is_in_thunk_area(ULONG_PTR addr
, const struct elf_thunk_area
* thunks
) DECLSPEC_HIDDEN
;
708 extern BOOL
macho_read_wine_loader_dbg_info(struct process
* pcs
, ULONG_PTR addr
) DECLSPEC_HIDDEN
;
711 void minidump_add_memory_block(struct dump_context
* dc
, ULONG64 base
, ULONG size
, ULONG rva
) DECLSPEC_HIDDEN
;
714 extern const WCHAR S_ElfW
[] DECLSPEC_HIDDEN
;
715 extern const WCHAR S_WineLoaderW
[] DECLSPEC_HIDDEN
;
716 extern const struct loader_ops no_loader_ops DECLSPEC_HIDDEN
;
718 extern BOOL
module_init_pair(struct module_pair
* pair
, HANDLE hProcess
,
719 DWORD64 addr
) DECLSPEC_HIDDEN
;
720 extern struct module
*
721 module_find_by_addr(const struct process
* pcs
, DWORD64 addr
,
722 enum module_type type
) DECLSPEC_HIDDEN
;
723 extern struct module
*
724 module_find_by_nameW(const struct process
* pcs
,
725 const WCHAR
* name
) DECLSPEC_HIDDEN
;
726 extern struct module
*
727 module_find_by_nameA(const struct process
* pcs
,
728 const char* name
) DECLSPEC_HIDDEN
;
729 extern struct module
*
730 module_is_already_loaded(const struct process
* pcs
,
731 const WCHAR
* imgname
) DECLSPEC_HIDDEN
;
732 extern BOOL
module_get_debug(struct module_pair
*) DECLSPEC_HIDDEN
;
733 extern struct module
*
734 module_new(struct process
* pcs
, const WCHAR
* name
,
735 enum module_type type
, BOOL
virtual,
736 DWORD64 addr
, DWORD64 size
,
737 ULONG_PTR stamp
, ULONG_PTR checksum
, WORD machine
) DECLSPEC_HIDDEN
;
738 extern struct module
*
739 module_get_containee(const struct process
* pcs
,
740 const struct module
* inner
) DECLSPEC_HIDDEN
;
741 extern void module_reset_debug_info(struct module
* module
) DECLSPEC_HIDDEN
;
742 extern BOOL
module_remove(struct process
* pcs
,
743 struct module
* module
) DECLSPEC_HIDDEN
;
744 extern void module_set_module(struct module
* module
, const WCHAR
* name
) DECLSPEC_HIDDEN
;
745 extern WCHAR
* get_wine_loader_name(struct process
*pcs
) __WINE_DEALLOC(HeapFree
, 3) __WINE_MALLOC DECLSPEC_HIDDEN
;
748 extern BOOL
pe_load_debug_directory(const struct process
* pcs
,
749 struct module
* module
,
751 const IMAGE_SECTION_HEADER
* sectp
, DWORD nsect
,
752 const IMAGE_DEBUG_DIRECTORY
* dbg
, int nDbg
) DECLSPEC_HIDDEN
;
753 extern BOOL
pdb_fetch_file_info(const struct pdb_lookup
* pdb_lookup
, unsigned* matched
) DECLSPEC_HIDDEN
;
754 struct pdb_cmd_pair
{
758 extern BOOL
pdb_virtual_unwind(struct cpu_stack_walk
*csw
, DWORD_PTR ip
,
759 union ctx
*context
, struct pdb_cmd_pair
*cpair
) DECLSPEC_HIDDEN
;
762 extern BOOL
path_find_symbol_file(const struct process
* pcs
, const struct module
* module
,
763 PCSTR full_path
, enum module_type type
, const GUID
* guid
, DWORD dw1
, DWORD dw2
,
764 WCHAR
*buffer
, BOOL
* is_unmatched
) DECLSPEC_HIDDEN
;
765 extern WCHAR
*get_dos_file_name(const WCHAR
*filename
) __WINE_DEALLOC(HeapFree
, 3) __WINE_MALLOC DECLSPEC_HIDDEN
;
766 extern BOOL
search_dll_path(const struct process
* process
, const WCHAR
*name
,
767 BOOL (*match
)(void*, HANDLE
, const WCHAR
*), void *param
) DECLSPEC_HIDDEN
;
768 extern BOOL
search_unix_path(const WCHAR
*name
, const WCHAR
*path
, BOOL (*match
)(void*, HANDLE
, const WCHAR
*), void *param
) DECLSPEC_HIDDEN
;
769 extern const WCHAR
* file_name(const WCHAR
* str
) DECLSPEC_HIDDEN
;
770 extern const char* file_nameA(const char* str
) DECLSPEC_HIDDEN
;
773 extern BOOL
pe_load_nt_header(HANDLE hProc
, DWORD64 base
, IMAGE_NT_HEADERS
* nth
) DECLSPEC_HIDDEN
;
774 extern struct module
*
775 pe_load_native_module(struct process
* pcs
, const WCHAR
* name
,
776 HANDLE hFile
, DWORD64 base
, DWORD size
) DECLSPEC_HIDDEN
;
777 extern struct module
*
778 pe_load_builtin_module(struct process
* pcs
, const WCHAR
* name
,
779 DWORD64 base
, DWORD64 size
) DECLSPEC_HIDDEN
;
780 extern BOOL
pe_load_debug_info(const struct process
* pcs
,
781 struct module
* module
) DECLSPEC_HIDDEN
;
782 extern const char* pe_map_directory(struct module
* module
, int dirno
, DWORD
* size
) DECLSPEC_HIDDEN
;
785 extern unsigned source_new(struct module
* module
, const char* basedir
, const char* source
) DECLSPEC_HIDDEN
;
786 extern const char* source_get(const struct module
* module
, unsigned idx
) DECLSPEC_HIDDEN
;
787 extern int source_rb_compare(const void *key
, const struct wine_rb_entry
*entry
) DECLSPEC_HIDDEN
;
790 typedef void (*stabs_def_cb
)(struct module
* module
, ULONG_PTR load_offset
,
791 const char* name
, ULONG_PTR offset
,
792 BOOL is_public
, BOOL is_global
, unsigned char other
,
793 struct symt_compiland
* compiland
, void* user
);
794 extern BOOL
stabs_parse(struct module
* module
, ULONG_PTR load_offset
,
795 const char* stabs
, size_t nstab
, size_t stabsize
,
796 const char* strs
, int strtablen
,
797 stabs_def_cb callback
, void* user
) DECLSPEC_HIDDEN
;
800 struct image_file_map
;
801 extern BOOL
dwarf2_parse(struct module
* module
, ULONG_PTR load_offset
,
802 const struct elf_thunk_area
* thunks
,
803 struct image_file_map
* fmap
) DECLSPEC_HIDDEN
;
804 extern BOOL
dwarf2_virtual_unwind(struct cpu_stack_walk
*csw
, DWORD_PTR ip
,
805 union ctx
*ctx
, DWORD64
*cfa
) DECLSPEC_HIDDEN
;
808 extern BOOL
sw_read_mem(struct cpu_stack_walk
* csw
, DWORD64 addr
, void* ptr
, DWORD sz
) DECLSPEC_HIDDEN
;
809 extern DWORD64
sw_xlat_addr(struct cpu_stack_walk
* csw
, ADDRESS64
* addr
) DECLSPEC_HIDDEN
;
810 extern void* sw_table_access(struct cpu_stack_walk
* csw
, DWORD64 addr
) DECLSPEC_HIDDEN
;
811 extern DWORD64
sw_module_base(struct cpu_stack_walk
* csw
, DWORD64 addr
) DECLSPEC_HIDDEN
;
814 extern const char* symt_get_name(const struct symt
* sym
) DECLSPEC_HIDDEN
;
815 extern WCHAR
* symt_get_nameW(const struct symt
* sym
) DECLSPEC_HIDDEN
;
816 extern BOOL
symt_get_address(const struct symt
* type
, ULONG64
* addr
) DECLSPEC_HIDDEN
;
817 extern int __cdecl
symt_cmp_addr(const void* p1
, const void* p2
) DECLSPEC_HIDDEN
;
818 extern void copy_symbolW(SYMBOL_INFOW
* siw
, const SYMBOL_INFO
* si
) DECLSPEC_HIDDEN
;
819 extern void symbol_setname(SYMBOL_INFO
* si
, const char* name
) DECLSPEC_HIDDEN
;
820 extern struct symt_ht
*
821 symt_find_nearest(struct module
* module
, DWORD_PTR addr
) DECLSPEC_HIDDEN
;
822 extern struct symt_ht
*
823 symt_find_symbol_at(struct module
* module
, DWORD_PTR addr
) DECLSPEC_HIDDEN
;
824 extern struct symt_module
*
825 symt_new_module(struct module
* module
) DECLSPEC_HIDDEN
;
826 extern struct symt_compiland
*
827 symt_new_compiland(struct module
* module
, unsigned src_idx
) DECLSPEC_HIDDEN
;
828 extern struct symt_public
*
829 symt_new_public(struct module
* module
,
830 struct symt_compiland
* parent
,
831 const char* typename
,
834 unsigned size
) DECLSPEC_HIDDEN
;
835 extern struct symt_data
*
836 symt_new_global_variable(struct module
* module
,
837 struct symt_compiland
* parent
,
838 const char* name
, unsigned is_static
,
839 struct location loc
, ULONG_PTR size
,
840 struct symt
* type
) DECLSPEC_HIDDEN
;
841 extern struct symt_function
*
842 symt_new_function(struct module
* module
,
843 struct symt_compiland
* parent
,
845 ULONG_PTR addr
, ULONG_PTR size
,
846 struct symt
* type
) DECLSPEC_HIDDEN
;
847 extern struct symt_function
*
848 symt_new_inlinesite(struct module
* module
,
849 struct symt_function
* func
,
853 unsigned num_ranges
) DECLSPEC_HIDDEN
;
854 extern void symt_add_func_line(struct module
* module
,
855 struct symt_function
* func
,
856 unsigned source_idx
, int line_num
,
857 ULONG_PTR offset
) DECLSPEC_HIDDEN
;
858 extern struct symt_data
*
859 symt_add_func_local(struct module
* module
,
860 struct symt_function
* func
,
861 enum DataKind dt
, const struct location
* loc
,
862 struct symt_block
* block
,
863 struct symt
* type
, const char* name
) DECLSPEC_HIDDEN
;
864 extern struct symt_data
*
865 symt_add_func_constant(struct module
* module
,
866 struct symt_function
* func
, struct symt_block
* block
,
867 struct symt
* type
, const char* name
, VARIANT
* v
) DECLSPEC_HIDDEN
;
868 extern struct symt_block
*
869 symt_open_func_block(struct module
* module
,
870 struct symt_function
* func
,
871 struct symt_block
* block
,
872 unsigned num_ranges
) DECLSPEC_HIDDEN
;
873 extern struct symt_block
*
874 symt_close_func_block(struct module
* module
,
875 const struct symt_function
* func
,
876 struct symt_block
* block
) DECLSPEC_HIDDEN
;
877 extern struct symt_hierarchy_point
*
878 symt_add_function_point(struct module
* module
,
879 struct symt_function
* func
,
880 enum SymTagEnum point
,
881 const struct location
* loc
,
882 const char* name
) DECLSPEC_HIDDEN
;
883 extern struct symt_thunk
*
884 symt_new_thunk(struct module
* module
,
885 struct symt_compiland
* parent
,
886 const char* name
, THUNK_ORDINAL ord
,
887 ULONG_PTR addr
, ULONG_PTR size
) DECLSPEC_HIDDEN
;
888 extern struct symt_data
*
889 symt_new_constant(struct module
* module
,
890 struct symt_compiland
* parent
,
891 const char* name
, struct symt
* type
,
892 const VARIANT
* v
) DECLSPEC_HIDDEN
;
893 extern struct symt_hierarchy_point
*
894 symt_new_label(struct module
* module
,
895 struct symt_compiland
* compiland
,
896 const char* name
, ULONG_PTR address
) DECLSPEC_HIDDEN
;
897 extern struct symt
* symt_index2ptr(struct module
* module
, DWORD id
) DECLSPEC_HIDDEN
;
898 extern DWORD
symt_ptr2index(struct module
* module
, const struct symt
* sym
) DECLSPEC_HIDDEN
;
899 extern struct symt_custom
*
900 symt_new_custom(struct module
* module
, const char* name
,
901 DWORD64 addr
, DWORD size
) DECLSPEC_HIDDEN
;
904 extern void symt_init_basic(struct module
* module
) DECLSPEC_HIDDEN
;
905 extern BOOL
symt_get_info(struct module
* module
, const struct symt
* type
,
906 IMAGEHLP_SYMBOL_TYPE_INFO req
, void* pInfo
) DECLSPEC_HIDDEN
;
907 extern struct symt_basic
*
908 symt_get_basic(enum BasicType
, unsigned size
) DECLSPEC_HIDDEN
;
909 extern struct symt_udt
*
910 symt_new_udt(struct module
* module
, const char* typename
,
911 unsigned size
, enum UdtKind kind
) DECLSPEC_HIDDEN
;
912 extern BOOL
symt_set_udt_size(struct module
* module
,
913 struct symt_udt
* type
, unsigned size
) DECLSPEC_HIDDEN
;
914 extern BOOL
symt_add_udt_element(struct module
* module
,
915 struct symt_udt
* udt_type
,
917 struct symt
* elt_type
, unsigned offset
,
918 unsigned bit_offset
, unsigned bit_size
) DECLSPEC_HIDDEN
;
919 extern struct symt_enum
*
920 symt_new_enum(struct module
* module
, const char* typename
,
921 struct symt
* basetype
) DECLSPEC_HIDDEN
;
922 extern BOOL
symt_add_enum_element(struct module
* module
,
923 struct symt_enum
* enum_type
,
924 const char* name
, int value
) DECLSPEC_HIDDEN
;
925 extern struct symt_array
*
926 symt_new_array(struct module
* module
, int min
, DWORD count
,
927 struct symt
* base
, struct symt
* index
) DECLSPEC_HIDDEN
;
928 extern struct symt_function_signature
*
929 symt_new_function_signature(struct module
* module
,
930 struct symt
* ret_type
,
931 enum CV_call_e call_conv
) DECLSPEC_HIDDEN
;
932 extern BOOL
symt_add_function_signature_parameter(struct module
* module
,
933 struct symt_function_signature
* sig
,
934 struct symt
* param
) DECLSPEC_HIDDEN
;
935 extern struct symt_pointer
*
936 symt_new_pointer(struct module
* module
,
937 struct symt
* ref_type
,
938 ULONG_PTR size
) DECLSPEC_HIDDEN
;
939 extern struct symt_typedef
*
940 symt_new_typedef(struct module
* module
, struct symt
* ref
,
941 const char* name
) DECLSPEC_HIDDEN
;
942 extern struct symt_function
*
943 symt_find_lowest_inlined(struct symt_function
* func
, DWORD64 addr
) DECLSPEC_HIDDEN
;
945 symt_get_upper_inlined(struct symt_function
* inlined
) DECLSPEC_HIDDEN
;
946 static inline struct symt_function
*
947 symt_get_function_from_inlined(struct symt_function
* inlined
)
949 while (!symt_check_tag(&inlined
->symt
, SymTagFunction
))
950 inlined
= (struct symt_function
*)symt_get_upper_inlined(inlined
);
953 extern struct symt_function
*
954 symt_find_inlined_site(struct module
* module
,
955 DWORD64 addr
, DWORD inline_ctx
) DECLSPEC_HIDDEN
;
957 /* Inline context encoding (different from what native does):
958 * bits 31:30: 3 ignore (includes INLINE_FRAME_CONTEXT_IGNORE=0xFFFFFFFF)
960 * 1 frame with inlined function(s).
961 * 0 init (includes INLINE_FRAME_CONTEXT_INIT=0)
962 * so either stackwalkex is called with:
963 * - inlinectx=IGNORE, and we use (old) StackWalk64 behavior:
964 * - inlinectx=INIT, and StackWalkEx will upon return swing back&forth between:
965 * INLINE when the frame is from an inline site (inside a function)
966 * REGULAR when the frame is for a function without inline site
967 * bits 29:00 depth of inline site (way too big!!)
968 * 0 being the lowest inline site
970 #define IFC_MODE_IGNORE 0xC0000000
971 #define IFC_MODE_REGULAR 0x80000000
972 #define IFC_MODE_INLINE 0x40000000
973 #define IFC_MODE_INIT 0x00000000
974 #define IFC_DEPTH_MASK 0x3FFFFFFF
975 #define IFC_MODE(x) ((x) & ~IFC_DEPTH_MASK)
976 #define IFC_DEPTH(x) ((x) & IFC_DEPTH_MASK)