ReactOS  0.4.15-dev-1374-g8d3e80e
dbghelp_private.h File Reference
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "winver.h"
#include "dbghelp.h"
#include "objbase.h"
#include "oaidl.h"
#include "winnls.h"
#include "wine/list.h"
#include "wine/rbtree.h"
#include "cvconst.h"
Include dependency graph for dbghelp_private.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  pool
 
class  vector< _Tp, >
 
struct  sparse_array
 
struct  hash_table_elt
 
struct  hash_table_bucket
 
struct  hash_table
 
struct  hash_table_iter
 
struct  location
 
struct  symt
 
struct  symt_ht
 
struct  symt_block
 
struct  symt_compiland
 
struct  symt_data
 
struct  symt_function
 
struct  symt_hierarchy_point
 
struct  symt_public
 
struct  symt_thunk
 
struct  symt_array
 
struct  symt_basic
 
struct  symt_enum
 
struct  symt_function_signature
 
struct  symt_function_arg_type
 
struct  symt_pointer
 
struct  symt_typedef
 
struct  symt_udt
 
struct  module_format
 
struct  module
 
struct  loader_ops
 
struct  process
 
struct  line_info
 
struct  module_pair
 
struct  pdb_lookup
 
struct  cpu_stack_walk
 
struct  dump_memory
 
struct  dump_memory64
 
struct  dump_module
 
struct  dump_thread
 
struct  dump_context
 
union  ctx
 
struct  cpu
 
struct  _PEB32
 
struct  pdb_cmd_pair
 

Typedefs

typedef BOOL(* enum_modules_cb) (const WCHAR *, ULONG_PTR addr, void *user)
 
typedef struct _PEB32 PEB32
 
typedef void(* stabs_def_cb) (struct module *module, ULONG_PTR load_offset, const char *name, ULONG_PTR offset, BOOL is_public, BOOL is_global, unsigned char other, struct symt_compiland *compiland, void *user)
 

Enumerations

enum  location_kind {
  loc_error, loc_unavailable, loc_absolute, loc_register,
  loc_regrel, loc_tlsrel, loc_user
}
 
enum  location_error {
  loc_err_internal = -1, loc_err_too_complex = -2, loc_err_out_of_scope = -3, loc_err_cant_read = -4,
  loc_err_no_location = -5
}
 
enum  module_type {
  DMT_UNKNOWN, DMT_ELF, DMT_PE, DMT_MACHO,
  DMT_PDB, DMT_DBG
}
 
enum  format_info {
  DFI_ELF, DFI_PE, DFI_MACHO, DFI_DWARF,
  DFI_PDB, DFI_LAST
}
 
enum  pdb_kind { PDB_JG, PDB_DS }
 
enum  cpu_addr { cpu_addr_pc, cpu_addr_stack, cpu_addr_frame }
 

Functions

void pool_init (struct pool *a, size_t arena_size) DECLSPEC_HIDDEN
 
void pool_destroy (struct pool *a) DECLSPEC_HIDDEN
 
voidpool_alloc (struct pool *a, size_t len) DECLSPEC_HIDDEN
 
charpool_strdup (struct pool *a, const char *str) DECLSPEC_HIDDEN
 
void vector_init (struct vector *v, unsigned elt_sz, unsigned bucket_sz) DECLSPEC_HIDDEN
 
unsigned vector_length (const struct vector *v) DECLSPEC_HIDDEN
 
voidvector_at (const struct vector *v, unsigned pos) DECLSPEC_HIDDEN
 
voidvector_add (struct vector *v, struct pool *pool) DECLSPEC_HIDDEN
 
void sparse_array_init (struct sparse_array *sa, unsigned elt_sz, unsigned bucket_sz) DECLSPEC_HIDDEN
 
voidsparse_array_find (const struct sparse_array *sa, ULONG_PTR idx) DECLSPEC_HIDDEN
 
voidsparse_array_add (struct sparse_array *sa, ULONG_PTR key, struct pool *pool) DECLSPEC_HIDDEN
 
unsigned sparse_array_length (const struct sparse_array *sa) DECLSPEC_HIDDEN
 
void hash_table_init (struct pool *pool, struct hash_table *ht, unsigned num_buckets) DECLSPEC_HIDDEN
 
void hash_table_destroy (struct hash_table *ht) DECLSPEC_HIDDEN
 
void hash_table_add (struct hash_table *ht, struct hash_table_elt *elt) DECLSPEC_HIDDEN
 
void hash_table_iter_init (const struct hash_table *ht, struct hash_table_iter *hti, const char *name) DECLSPEC_HIDDEN
 
voidhash_table_iter_up (struct hash_table_iter *hti) DECLSPEC_HIDDEN
 
static BOOL read_process_memory (const struct process *process, UINT64 addr, void *buf, size_t size)
 
struct processprocess_find_by_handle (HANDLE hProcess) DECLSPEC_HIDDEN
 
BOOL validate_addr64 (DWORD64 addr) DECLSPEC_HIDDEN
 
BOOL pcs_callback (const struct process *pcs, ULONG action, void *data) DECLSPEC_HIDDEN
 
voidfetch_buffer (struct process *pcs, unsigned size) DECLSPEC_HIDDEN
 
const charwine_dbgstr_addr (const ADDRESS64 *addr) DECLSPEC_HIDDEN
 
struct cpucpu_find (DWORD) DECLSPEC_HIDDEN
 
const WCHARprocess_getenv (const struct process *process, const WCHAR *name)
 
DWORD calc_crc32 (HANDLE handle) DECLSPEC_HIDDEN
 
BOOL elf_read_wine_loader_dbg_info (struct process *pcs, ULONG_PTR addr) DECLSPEC_HIDDEN
 
int elf_is_in_thunk_area (ULONG_PTR addr, const struct elf_thunk_area *thunks) DECLSPEC_HIDDEN
 
BOOL macho_read_wine_loader_dbg_info (struct process *pcs, ULONG_PTR addr) DECLSPEC_HIDDEN
 
void minidump_add_memory_block (struct dump_context *dc, ULONG64 base, ULONG size, ULONG rva) DECLSPEC_HIDDEN
 
struct modulemodule_find_by_addr (const struct process *pcs, DWORD64 addr, enum module_type type) DECLSPEC_HIDDEN
 
struct modulemodule_find_by_nameW (const struct process *pcs, const WCHAR *name) DECLSPEC_HIDDEN
 
struct modulemodule_find_by_nameA (const struct process *pcs, const char *name) DECLSPEC_HIDDEN
 
struct modulemodule_is_already_loaded (const struct process *pcs, const WCHAR *imgname) DECLSPEC_HIDDEN
 
BOOL module_get_debug (struct module_pair *) DECLSPEC_HIDDEN
 
struct modulemodule_new (struct process *pcs, const WCHAR *name, enum module_type type, BOOL virtual, DWORD64 addr, DWORD64 size, ULONG_PTR stamp, ULONG_PTR checksum) DECLSPEC_HIDDEN
 
struct modulemodule_get_containee (const struct process *pcs, const struct module *inner) DECLSPEC_HIDDEN
 
void module_reset_debug_info (struct module *module) DECLSPEC_HIDDEN
 
BOOL module_remove (struct process *pcs, struct module *module) DECLSPEC_HIDDEN
 
void module_set_module (struct module *module, const WCHAR *name) DECLSPEC_HIDDEN
 
WCHARget_wine_loader_name (struct process *pcs) DECLSPEC_HIDDEN
 
BOOL pe_load_debug_directory (const struct process *pcs, struct module *module, const BYTE *mapping, const IMAGE_SECTION_HEADER *sectp, DWORD nsect, const IMAGE_DEBUG_DIRECTORY *dbg, int nDbg) DECLSPEC_HIDDEN
 
BOOL pdb_fetch_file_info (const struct pdb_lookup *pdb_lookup, unsigned *matched) DECLSPEC_HIDDEN
 
BOOL pdb_virtual_unwind (struct cpu_stack_walk *csw, DWORD_PTR ip, union ctx *context, struct pdb_cmd_pair *cpair) DECLSPEC_HIDDEN
 
BOOL path_find_symbol_file (const struct process *pcs, const struct module *module, PCSTR full_path, enum module_type type, const GUID *guid, DWORD dw1, DWORD dw2, WCHAR *buffer, BOOL *is_unmatched) DECLSPEC_HIDDEN
 
WCHARget_dos_file_name (const WCHAR *filename) DECLSPEC_HIDDEN
 
BOOL search_dll_path (const struct process *process, const WCHAR *name, BOOL(*match)(void *, HANDLE, const WCHAR *), void *param) DECLSPEC_HIDDEN
 
BOOL search_unix_path (const WCHAR *name, const WCHAR *path, BOOL(*match)(void *, HANDLE, const WCHAR *), void *param) DECLSPEC_HIDDEN
 
const WCHARfile_name (const WCHAR *str) DECLSPEC_HIDDEN
 
const charfile_nameA (const char *str) DECLSPEC_HIDDEN
 
BOOL pe_load_nt_header (HANDLE hProc, DWORD64 base, IMAGE_NT_HEADERS *nth) DECLSPEC_HIDDEN
 
struct modulepe_load_native_module (struct process *pcs, const WCHAR *name, HANDLE hFile, DWORD64 base, DWORD size) DECLSPEC_HIDDEN
 
struct modulepe_load_builtin_module (struct process *pcs, const WCHAR *name, DWORD64 base, DWORD64 size) DECLSPEC_HIDDEN
 
BOOL pe_load_debug_info (const struct process *pcs, struct module *module) DECLSPEC_HIDDEN
 
const charpe_map_directory (struct module *module, int dirno, DWORD *size) DECLSPEC_HIDDEN
 
unsigned source_new (struct module *module, const char *basedir, const char *source) DECLSPEC_HIDDEN
 
const charsource_get (const struct module *module, unsigned idx) DECLSPEC_HIDDEN
 
int source_rb_compare (const void *key, const struct wine_rb_entry *entry) DECLSPEC_HIDDEN
 
BOOL stabs_parse (struct module *module, ULONG_PTR load_offset, const char *stabs, size_t nstab, size_t stabsize, const char *strs, int strtablen, stabs_def_cb callback, void *user) DECLSPEC_HIDDEN
 
BOOL dwarf2_parse (struct module *module, ULONG_PTR load_offset, const struct elf_thunk_area *thunks, struct image_file_map *fmap) DECLSPEC_HIDDEN
 
BOOL dwarf2_virtual_unwind (struct cpu_stack_walk *csw, DWORD_PTR ip, union ctx *ctx, DWORD64 *cfa) DECLSPEC_HIDDEN
 
BOOL rsym_parse (struct module *module, unsigned long load_offset, const void *rsym, int rsymlen) DECLSPEC_HIDDEN
 
BOOL sw_read_mem (struct cpu_stack_walk *csw, DWORD64 addr, void *ptr, DWORD sz) DECLSPEC_HIDDEN
 
DWORD64 sw_xlat_addr (struct cpu_stack_walk *csw, ADDRESS64 *addr) DECLSPEC_HIDDEN
 
voidsw_table_access (struct cpu_stack_walk *csw, DWORD64 addr) DECLSPEC_HIDDEN
 
DWORD64 sw_module_base (struct cpu_stack_walk *csw, DWORD64 addr) DECLSPEC_HIDDEN
 
const charsymt_get_name (const struct symt *sym) DECLSPEC_HIDDEN
 
WCHARsymt_get_nameW (const struct symt *sym) DECLSPEC_HIDDEN
 
BOOL symt_get_address (const struct symt *type, ULONG64 *addr) DECLSPEC_HIDDEN
 
int __cdecl symt_cmp_addr (const void *p1, const void *p2) DECLSPEC_HIDDEN
 
void copy_symbolW (SYMBOL_INFOW *siw, const SYMBOL_INFO *si) DECLSPEC_HIDDEN
 
struct symt_htsymt_find_nearest (struct module *module, DWORD_PTR addr) DECLSPEC_HIDDEN
 
struct symt_compilandsymt_new_compiland (struct module *module, ULONG_PTR address, unsigned src_idx) DECLSPEC_HIDDEN
 
struct symt_publicsymt_new_public (struct module *module, struct symt_compiland *parent, const char *typename, BOOL is_function, ULONG_PTR address, unsigned size) DECLSPEC_HIDDEN
 
struct symt_datasymt_new_global_variable (struct module *module, struct symt_compiland *parent, const char *name, unsigned is_static, struct location loc, ULONG_PTR size, struct symt *type) DECLSPEC_HIDDEN
 
struct symt_functionsymt_new_function (struct module *module, struct symt_compiland *parent, const char *name, ULONG_PTR addr, ULONG_PTR size, struct symt *type) DECLSPEC_HIDDEN
 
BOOL symt_normalize_function (struct module *module, const struct symt_function *func) DECLSPEC_HIDDEN
 
void symt_add_func_line (struct module *module, struct symt_function *func, unsigned source_idx, int line_num, ULONG_PTR offset) DECLSPEC_HIDDEN
 
struct symt_datasymt_add_func_local (struct module *module, struct symt_function *func, enum DataKind dt, const struct location *loc, struct symt_block *block, struct symt *type, const char *name) DECLSPEC_HIDDEN
 
struct symt_blocksymt_open_func_block (struct module *module, struct symt_function *func, struct symt_block *block, unsigned pc, unsigned len) DECLSPEC_HIDDEN
 
struct symt_blocksymt_close_func_block (struct module *module, const struct symt_function *func, struct symt_block *block, unsigned pc) DECLSPEC_HIDDEN
 
struct symt_hierarchy_pointsymt_add_function_point (struct module *module, struct symt_function *func, enum SymTagEnum point, const struct location *loc, const char *name) DECLSPEC_HIDDEN
 
BOOL symt_fill_func_line_info (const struct module *module, const struct symt_function *func, DWORD64 addr, IMAGEHLP_LINE64 *line) DECLSPEC_HIDDEN
 
BOOL symt_get_func_line_next (const struct module *module, PIMAGEHLP_LINE64 line) DECLSPEC_HIDDEN
 
struct symt_thunksymt_new_thunk (struct module *module, struct symt_compiland *parent, const char *name, THUNK_ORDINAL ord, ULONG_PTR addr, ULONG_PTR size) DECLSPEC_HIDDEN
 
struct symt_datasymt_new_constant (struct module *module, struct symt_compiland *parent, const char *name, struct symt *type, const VARIANT *v) DECLSPEC_HIDDEN
 
struct symt_hierarchy_pointsymt_new_label (struct module *module, struct symt_compiland *compiland, const char *name, ULONG_PTR address) DECLSPEC_HIDDEN
 
struct symtsymt_index2ptr (struct module *module, DWORD id) DECLSPEC_HIDDEN
 
DWORD symt_ptr2index (struct module *module, const struct symt *sym) DECLSPEC_HIDDEN
 
void symt_init_basic (struct module *module) DECLSPEC_HIDDEN
 
BOOL symt_get_info (struct module *module, const struct symt *type, IMAGEHLP_SYMBOL_TYPE_INFO req, void *pInfo) DECLSPEC_HIDDEN
 
struct symt_basicsymt_new_basic (struct module *module, enum BasicType, const char *typename, unsigned size) DECLSPEC_HIDDEN
 
struct symt_udtsymt_new_udt (struct module *module, const char *typename, unsigned size, enum UdtKind kind) DECLSPEC_HIDDEN
 
BOOL symt_set_udt_size (struct module *module, struct symt_udt *type, unsigned size) DECLSPEC_HIDDEN
 
BOOL symt_add_udt_element (struct module *module, struct symt_udt *udt_type, const char *name, struct symt *elt_type, unsigned offset, unsigned size) DECLSPEC_HIDDEN
 
struct symt_enumsymt_new_enum (struct module *module, const char *typename, struct symt *basetype) DECLSPEC_HIDDEN
 
BOOL symt_add_enum_element (struct module *module, struct symt_enum *enum_type, const char *name, int value) DECLSPEC_HIDDEN
 
struct symt_arraysymt_new_array (struct module *module, int min, int max, struct symt *base, struct symt *index) DECLSPEC_HIDDEN
 
struct symt_function_signaturesymt_new_function_signature (struct module *module, struct symt *ret_type, enum CV_call_e call_conv) DECLSPEC_HIDDEN
 
BOOL symt_add_function_signature_parameter (struct module *module, struct symt_function_signature *sig, struct symt *param) DECLSPEC_HIDDEN
 
struct symt_pointersymt_new_pointer (struct module *module, struct symt *ref_type, ULONG_PTR size) DECLSPEC_HIDDEN
 
struct symt_typedefsymt_new_typedef (struct module *module, struct symt *ref, const char *name) DECLSPEC_HIDDEN
 

Variables

unsigned dbghelp_options DECLSPEC_HIDDEN
 

Typedef Documentation

◆ enum_modules_cb

typedef BOOL(* enum_modules_cb) (const WCHAR *, ULONG_PTR addr, void *user)

Definition at line 416 of file dbghelp_private.h.

◆ PEB32

typedef struct _PEB32 PEB32

◆ stabs_def_cb

typedef void(* stabs_def_cb) (struct module *module, ULONG_PTR load_offset, const char *name, ULONG_PTR offset, BOOL is_public, BOOL is_global, unsigned char other, struct symt_compiland *compiland, void *user)

Definition at line 732 of file dbghelp_private.h.

Enumeration Type Documentation

◆ cpu_addr

Enumerator
cpu_addr_pc 
cpu_addr_stack 
cpu_addr_frame 

Definition at line 576 of file dbghelp_private.h.

◆ format_info

Enumerator
DFI_ELF 
DFI_PE 
DFI_MACHO 
DFI_DWARF 
DFI_PDB 
DFI_LAST 

Definition at line 339 of file dbghelp_private.h.

◆ location_error

Enumerator
loc_err_internal 
loc_err_too_complex 
loc_err_out_of_scope 
loc_err_cant_read 
loc_err_no_location 

Definition at line 144 of file dbghelp_private.h.

144  {loc_err_internal = -1, /* internal while computing */
145  loc_err_too_complex = -2, /* couldn't compute location (even at runtime) */
146  loc_err_out_of_scope = -3, /* variable isn't available at current address */
147  loc_err_cant_read = -4, /* couldn't read memory at given address */
148  loc_err_no_location = -5, /* likely optimized away (by compiler) */
149 };

◆ location_kind

Enumerator
loc_error 
loc_unavailable 
loc_absolute 
loc_register 
loc_regrel 
loc_tlsrel 
loc_user 

Definition at line 134 of file dbghelp_private.h.

134  {loc_error, /* reg is the error code */
135  loc_unavailable, /* location is not available */
136  loc_absolute, /* offset is the location */
137  loc_register, /* reg is the location */
138  loc_regrel, /* [reg+offset] is the location */
139  loc_tlsrel, /* offset is the address of the TLS index */
140  loc_user, /* value is debug information dependent,
141  reg & offset can be used ad libidem */
142 };

◆ module_type

Enumerator
DMT_UNKNOWN 
DMT_ELF 
DMT_PE 
DMT_MACHO 
DMT_PDB 
DMT_DBG 

Definition at line 323 of file dbghelp_private.h.

324 {
325  DMT_UNKNOWN, /* for lookup, not actually used for a module */
326  DMT_ELF, /* a real ELF shared module */
327  DMT_PE, /* a native or builtin PE module */
328  DMT_MACHO, /* a real Mach-O shared module */
329  DMT_PDB, /* .PDB file */
330  DMT_DBG, /* .DBG file */
331 };

◆ pdb_kind

Enumerator
PDB_JG 
PDB_DS 

Definition at line 476 of file dbghelp_private.h.

Function Documentation

◆ calc_crc32()

DWORD calc_crc32 ( HANDLE  handle)

Definition at line 848 of file dbghelp.c.

849 {
850  BYTE buffer[8192];
851  DWORD crc = 0;
852  DWORD len;
853 
855  while (ReadFile(handle, buffer, sizeof(buffer), &len, NULL) && len)
856  crc = RtlComputeCrc32(crc, buffer, len);
857  return crc;
858 }
GLuint buffer
Definition: glext.h:5915
#define FILE_BEGIN
Definition: compat.h:620
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum GLsizei len
Definition: glext.h:6722
unsigned char BYTE
Definition: xxhash.c:193
#define RtlComputeCrc32
Definition: compat.h:669
#define ReadFile(a, b, c, d, e)
Definition: compat.h:601
#define NULL
Definition: types.h:112
#define SetFilePointer
Definition: compat.h:602

Referenced by elf_fetch_file_info(), elf_load_file_from_fmap(), image_check_debug_link(), macho_fetch_file_info(), and macho_load_file().

◆ copy_symbolW()

void copy_symbolW ( SYMBOL_INFOW siw,
const SYMBOL_INFO si 
)

Definition at line 1029 of file symbol.c.

1030 {
1031  siw->SizeOfStruct = si->SizeOfStruct;
1032  siw->TypeIndex = si->TypeIndex;
1033  siw->Reserved[0] = si->Reserved[0];
1034  siw->Reserved[1] = si->Reserved[1];
1035  siw->Index = si->Index;
1036  siw->Size = si->Size;
1037  siw->ModBase = si->ModBase;
1038  siw->Flags = si->Flags;
1039  siw->Value = si->Value;
1040  siw->Address = si->Address;
1041  siw->Register = si->Register;
1042  siw->Scope = si->Scope;
1043  siw->Tag = si->Tag;
1044  siw->NameLen = si->NameLen;
1045  siw->MaxNameLen = si->MaxNameLen;
1046  MultiByteToWideChar(CP_ACP, 0, si->Name, -1, siw->Name, siw->MaxNameLen);
1047 }
ULONG Tag
Definition: compat.h:908
CHAR Name[1]
Definition: compat.h:911
ULONG NameLen
Definition: compat.h:909
ULONG64 Address
Definition: compat.h:1225
ULONG MaxNameLen
Definition: compat.h:910
ULONG MaxNameLen
Definition: compat.h:1230
ULONG64 ModBase
Definition: compat.h:1222
#define CP_ACP
Definition: compat.h:109
ULONG Scope
Definition: compat.h:907
ULONG Flags
Definition: compat.h:903
ULONG TypeIndex
Definition: compat.h:898
ULONG64 Address
Definition: compat.h:905
ULONG NameLen
Definition: compat.h:1229
ULONG64 Reserved[2]
Definition: compat.h:899
ULONG64 Reserved[2]
Definition: compat.h:1219
ULONG SizeOfStruct
Definition: compat.h:1217
ULONG Scope
Definition: compat.h:1227
ULONG64 ModBase
Definition: compat.h:902
ULONG Index
Definition: compat.h:900
ULONG64 Value
Definition: compat.h:1224
ULONG Index
Definition: compat.h:1220
ULONG Flags
Definition: compat.h:1223
ULONG SizeOfStruct
Definition: compat.h:897
ULONG Register
Definition: compat.h:906
ULONG TypeIndex
Definition: compat.h:1218
#define MultiByteToWideChar
Definition: compat.h:110
WCHAR Name[1]
Definition: compat.h:1231
ULONG Register
Definition: compat.h:1226
ULONG64 Value
Definition: compat.h:904
ULONG Tag
Definition: compat.h:1228
ULONG Size
Definition: compat.h:901
ULONG Size
Definition: compat.h:1221

Referenced by enum_types_AtoW(), sym_enumW(), and SymFromAddrW().

◆ cpu_find()

struct cpu* cpu_find ( DWORD  )

Definition at line 183 of file dbghelp.c.

184 {
185  struct cpu** cpu;
186 
187  for (cpu = dbghelp_cpus ; *cpu; cpu++)
188  {
189  if (cpu[0]->machine == machine) return cpu[0];
190  }
191  return NULL;
192 }
static const char machine[]
Definition: profile.c:104
static struct cpu * dbghelp_cpus[]
Definition: dbghelp.c:164
#define NULL
Definition: types.h:112

Referenced by StackWalk(), and StackWalk64().

◆ dwarf2_parse()

BOOL dwarf2_parse ( struct module module,
ULONG_PTR  load_offset,
const struct elf_thunk_area thunks,
struct image_file_map fmap 
)

Definition at line 3509 of file dwarf.c.

3512 {
3514  dwarf2_traverse_context_t mod_ctx;
3515  struct image_section_map debug_sect, debug_str_sect, debug_abbrev_sect,
3516  debug_line_sect, debug_ranges_sect, eh_frame_sect;
3517  BOOL ret = TRUE;
3518  struct module_format* dwarf2_modfmt;
3519 
3520  if (!dwarf2_init_section(&eh_frame, fmap, ".eh_frame", NULL, &eh_frame_sect))
3521  /* lld produces .eh_fram to avoid generating a long name */
3522  dwarf2_init_section(&eh_frame, fmap, ".eh_fram", NULL, &eh_frame_sect);
3523  dwarf2_init_section(&section[section_debug], fmap, ".debug_info", ".zdebug_info", &debug_sect);
3524  dwarf2_init_section(&section[section_abbrev], fmap, ".debug_abbrev", ".zdebug_abbrev", &debug_abbrev_sect);
3525  dwarf2_init_section(&section[section_string], fmap, ".debug_str", ".zdebug_str", &debug_str_sect);
3526  dwarf2_init_section(&section[section_line], fmap, ".debug_line", ".zdebug_line", &debug_line_sect);
3527  dwarf2_init_section(&section[section_ranges], fmap, ".debug_ranges", ".zdebug_ranges", &debug_ranges_sect);
3528 
3529  /* to do anything useful we need either .eh_frame or .debug_info */
3530  if ((!eh_frame.address || eh_frame.address == IMAGE_NO_MAP) &&
3531  (!section[section_debug].address || section[section_debug].address == IMAGE_NO_MAP))
3532  {
3533  ret = FALSE;
3534  goto leave;
3535  }
3536 
3537  if (fmap->modtype == DMT_ELF && debug_sect.fmap)
3538  {
3539  /* debug info might have a different base address than .so file
3540  * when elf file is prelinked after splitting off debug info
3541  * adjust symbol base addresses accordingly
3542  */
3543  load_offset += fmap->u.elf.elf_start - debug_sect.fmap->u.elf.elf_start;
3544  }
3545 
3546  TRACE("Loading Dwarf2 information for %s\n", debugstr_w(module->module.ModuleName));
3547 
3548  mod_ctx.data = section[section_debug].address;
3549  mod_ctx.end_data = mod_ctx.data + section[section_debug].size;
3550  mod_ctx.word_size = 0; /* will be correctly set later on */
3551 
3552  dwarf2_modfmt = HeapAlloc(GetProcessHeap(), 0,
3553  sizeof(*dwarf2_modfmt) + sizeof(*dwarf2_modfmt->u.dwarf2_info));
3554  if (!dwarf2_modfmt)
3555  {
3556  ret = FALSE;
3557  goto leave;
3558  }
3559  dwarf2_modfmt->module = module;
3560  dwarf2_modfmt->remove = dwarf2_module_remove;
3561  dwarf2_modfmt->loc_compute = dwarf2_location_compute;
3562  dwarf2_modfmt->u.dwarf2_info = (struct dwarf2_module_info_s*)(dwarf2_modfmt + 1);
3563  dwarf2_modfmt->u.dwarf2_info->word_size = 0; /* will be correctly set later on */
3564  dwarf2_modfmt->module->format_info[DFI_DWARF] = dwarf2_modfmt;
3565 
3566  /* As we'll need later some sections' content, we won't unmap these
3567  * sections upon existing this function
3568  */
3569  dwarf2_init_section(&dwarf2_modfmt->u.dwarf2_info->debug_loc, fmap, ".debug_loc", ".zdebug_loc", NULL);
3570  dwarf2_init_section(&dwarf2_modfmt->u.dwarf2_info->debug_frame, fmap, ".debug_frame", ".zdebug_frame", NULL);
3571  dwarf2_modfmt->u.dwarf2_info->eh_frame = eh_frame;
3572 
3573  while (mod_ctx.data < mod_ctx.end_data)
3574  {
3575  dwarf2_parse_compilation_unit(section, dwarf2_modfmt->module, thunks, &mod_ctx, load_offset);
3576  }
3577  dwarf2_modfmt->module->module.SymType = SymDia;
3578  dwarf2_modfmt->module->module.CVSig = 'D' | ('W' << 8) | ('A' << 16) | ('R' << 24);
3579  /* FIXME: we could have a finer grain here */
3580  dwarf2_modfmt->module->module.GlobalSymbols = TRUE;
3581  dwarf2_modfmt->module->module.TypeInfo = TRUE;
3582  dwarf2_modfmt->module->module.SourceIndexed = TRUE;
3583  dwarf2_modfmt->module->module.Publics = TRUE;
3584 
3585  /* set the word_size for eh_frame parsing */
3586  dwarf2_modfmt->u.dwarf2_info->word_size = fmap->addr_size / 8;
3587 
3588 leave:
3594 
3595  image_unmap_section(&debug_sect);
3596  image_unmap_section(&debug_abbrev_sect);
3597  image_unmap_section(&debug_str_sect);
3598  image_unmap_section(&debug_line_sect);
3599  image_unmap_section(&debug_ranges_sect);
3600  if (!ret) image_unmap_section(&eh_frame_sect);
3601 
3602  return ret;
3603 }
void(* remove)(struct process *pcs, struct module_format *modfmt)
unsigned addr_size
enum module_type modtype
const unsigned char * address
Definition: dwarf.c:159
HMODULE module
Definition: main.cpp:47
static BOOL dwarf2_init_section(dwarf2_section_t *section, struct image_file_map *fmap, const char *sectname, const char *zsectname, struct image_section_map *ism)
Definition: dwarf.c:3467
Definition: compat.h:922
WCHAR ModuleName[32]
Definition: compat.h:935
const unsigned char * data
Definition: dwarf.c:168
#define TRUE
Definition: types.h:120
union module_format::@366 u
const unsigned char * end_data
Definition: dwarf.c:169
Definition: parser.c:55
#define IMAGE_NO_MAP
Definition: image_private.h:24
static void dwarf2_module_remove(struct process *pcs, struct module_format *modfmt)
Definition: dwarf.c:3502
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define debugstr_w
Definition: kernel32.h:32
struct image_file_map::@377::elf_file_map elf
#define leave
Definition: seh.h:23
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
void(* loc_compute)(struct process *pcs, const struct module_format *modfmt, const struct symt_function *func, struct location *loc)
static void dwarf2_fini_section(dwarf2_section_t *section)
Definition: dwarf.c:3496
struct dwarf2_module_info_s * dwarf2_info
int ret
static void image_unmap_section(struct image_section_map *ism)
dwarf2_section_t eh_frame
Definition: dwarf.c:201
#define NULL
Definition: types.h:112
struct module * module
static void dwarf2_location_compute(struct process *pcs, const struct module_format *modfmt, const struct symt_function *func, struct location *loc)
Definition: dwarf.c:3324
unsigned char word_size
Definition: dwarf.c:170
static BOOL dwarf2_parse_compilation_unit(const dwarf2_section_t *sections, struct module *module, const struct elf_thunk_area *thunks, dwarf2_traverse_context_t *mod_ctx, ULONG_PTR load_offset)
Definition: dwarf.c:2371
union image_file_map::@377 u
IMAGEHLP_MODULEW64 module

Referenced by elf_load_debug_info_from_map(), macho_load_debug_info(), and pe_load_dwarf().

◆ dwarf2_virtual_unwind()

BOOL dwarf2_virtual_unwind ( struct cpu_stack_walk csw,
DWORD_PTR  ip,
union ctx ctx,
DWORD64 cfa 
)

Definition at line 3258 of file dwarf.c.

3260 {
3261  struct module_pair pair;
3262  struct frame_info info;
3263  dwarf2_traverse_context_t cie_ctx, fde_ctx;
3264  struct module_format* modfmt;
3265  const unsigned char* end;
3266  DWORD_PTR delta;
3267 
3268  if (!(pair.pcs = process_find_by_handle(csw->hProcess)) ||
3269  !(pair.requested = module_find_by_addr(pair.pcs, ip, DMT_UNKNOWN)) ||
3271  return FALSE;
3272  modfmt = pair.effective->format_info[DFI_DWARF];
3273  if (!modfmt) return FALSE;
3274  memset(&info, 0, sizeof(info));
3275  fde_ctx.data = modfmt->u.dwarf2_info->eh_frame.address;
3276  fde_ctx.end_data = fde_ctx.data + modfmt->u.dwarf2_info->eh_frame.size;
3277  fde_ctx.word_size = modfmt->u.dwarf2_info->word_size;
3278  /* let offsets relative to the eh_frame sections be correctly computed, as we'll map
3279  * in this process the IMAGE section at a different address as the one expected by
3280  * the image
3281  */
3282  delta = pair.effective->module.BaseOfImage + modfmt->u.dwarf2_info->eh_frame.rva -
3283  (DWORD_PTR)modfmt->u.dwarf2_info->eh_frame.address;
3284  if (!dwarf2_get_cie(ip, pair.effective, delta, &fde_ctx, &cie_ctx, &info, TRUE))
3285  {
3286  fde_ctx.data = modfmt->u.dwarf2_info->debug_frame.address;
3287  fde_ctx.end_data = fde_ctx.data + modfmt->u.dwarf2_info->debug_frame.size;
3288  fde_ctx.word_size = modfmt->u.dwarf2_info->word_size;
3289  delta = pair.effective->reloc_delta;
3290  if (!dwarf2_get_cie(ip, pair.effective, delta, &fde_ctx, &cie_ctx, &info, FALSE))
3291  {
3292  TRACE("Couldn't find information for %lx\n", ip);
3293  return FALSE;
3294  }
3295  }
3296 
3297  TRACE("function %lx/%lx code_align %lu data_align %ld retaddr %s\n",
3298  ip, info.ip, info.code_align, info.data_align,
3299  csw->cpu->fetch_regname(csw->cpu->map_dwarf_register(info.retaddr_reg, pair.effective, TRUE)));
3300 
3301  /* if at very beginning of function, return and use default unwinder */
3302  if (ip == info.ip) return FALSE;
3303  execute_cfa_instructions(pair.effective, &cie_ctx, ip, &info);
3304 
3305  if (info.aug_z_format) /* get length of augmentation data */
3306  {
3308  end = fde_ctx.data + len;
3309  }
3310  else end = NULL;
3311  dwarf2_parse_augmentation_ptr(&fde_ctx, info.lsda_encoding); /* handler_data */
3312  if (end) fde_ctx.data = end;
3313 
3314  execute_cfa_instructions(pair.effective, &fde_ctx, ip, &info);
3315 
3316  /* if there is no information about retaddr, use default unwinder */
3317  if (info.state.rules[info.retaddr_reg] == RULE_UNSET) return FALSE;
3318 
3319  apply_frame_state(pair.effective, csw, context, &info.state, cfa);
3320 
3321  return TRUE;
3322 }
#define DWORD_PTR
Definition: treelist.c:76
Definition: http.c:7094
static BOOL dwarf2_get_cie(ULONG_PTR addr, struct module *module, DWORD_PTR delta, dwarf2_traverse_context_t *fde_ctx, dwarf2_traverse_context_t *cie_ctx, struct frame_info *info, BOOL in_eh_frame)
Definition: dwarf.c:2715
#define TRUE
Definition: types.h:120
struct process * process_find_by_handle(HANDLE hProcess)
Definition: dbghelp.c:99
union module_format::@366 u
static ULONG_PTR dwarf2_parse_augmentation_ptr(dwarf2_traverse_context_t *ctx, unsigned char encoding)
Definition: dwarf.c:2595
uint32_t ULONG_PTR
Definition: typedefs.h:65
struct cpu * cpu
#define FALSE
Definition: types.h:117
static void execute_cfa_instructions(struct module *module, dwarf2_traverse_context_t *ctx, ULONG_PTR last_ip, struct frame_info *info)
Definition: dwarf.c:2792
#define TRACE(s)
Definition: solgame.cpp:4
BOOL module_get_debug(struct module_pair *) DECLSPEC_HIDDEN
Definition: module.c:374
Definition: dhcpd.h:61
if(!(yy_init))
Definition: macro.lex.yy.c:714
static void apply_frame_state(const struct module *module, struct cpu_stack_walk *csw, union ctx *context, struct frame_state *state, DWORD64 *cfa)
Definition: dwarf.c:3201
static ULONG_PTR dwarf2_leb128_as_unsigned(dwarf2_traverse_context_t *ctx)
Definition: dwarf.c:276
GLuint GLuint end
Definition: gl.h:1545
struct dwarf2_module_info_s * dwarf2_info
struct module * module_find_by_addr(const struct process *pcs, DWORD64 addr, enum module_type type) DECLSPEC_HIDDEN
Definition: module.c:420
GLenum GLsizei len
Definition: glext.h:6722
uint32_t DWORD_PTR
Definition: typedefs.h:65
Definition: _pair.h:47
#define NULL
Definition: types.h:112
#define memset(x, y, z)
Definition: compat.h:39

Referenced by fetch_next_frame32().

◆ elf_is_in_thunk_area()

int elf_is_in_thunk_area ( ULONG_PTR  addr,
const struct elf_thunk_area thunks 
)

Definition at line 602 of file elf_module.c.

604 {
605  unsigned i;
606 
607  if (thunks) for (i = 0; thunks[i].symname; i++)
608  {
609  if (addr >= thunks[i].rva_start && addr < thunks[i].rva_end)
610  return i;
611  }
612  return -1;
613 }
const char * symname
Definition: elf_module.c:77
GLenum const GLvoid * addr
Definition: glext.h:9621
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248

Referenced by dwarf2_parse_subprogram(), and elf_new_wine_thunks().

◆ elf_read_wine_loader_dbg_info()

BOOL elf_read_wine_loader_dbg_info ( struct process pcs,
ULONG_PTR  addr 
)

Definition at line 1753 of file elf_module.c.

1754 {
1755  struct elf_info elf_info;
1756  WCHAR *loader;
1757  BOOL ret;
1758 
1760  loader = get_wine_loader_name(pcs);
1761  ret = elf_search_and_load_file(pcs, loader, addr, 0, &elf_info);
1762  heap_free(loader);
1763  if (!ret || !elf_info.dbg_hdr_addr) return FALSE;
1764 
1765  TRACE("Found ELF debug header %#lx\n", elf_info.dbg_hdr_addr);
1766  elf_info.module->format_info[DFI_ELF]->u.elf_info->elf_loader = 1;
1769  pcs->loader = &elf_loader_ops;
1770  return TRUE;
1771 }
void module_set_module(struct module *module, const WCHAR *name) DECLSPEC_HIDDEN
Definition: module.c:142
DWORD_PTR dbg_hdr_addr
Definition: elf_module.c:42
#define TRUE
Definition: types.h:120
#define ELF_INFO_DEBUG_HEADER
Definition: elf_module.c:33
#define FALSE
Definition: types.h:117
ULONG_PTR dbg_hdr_addr
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned flags
Definition: elf_module.c:41
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
const struct loader_ops * loader
int ret
static BOOL elf_search_and_load_file(struct process *pcs, const WCHAR *filename, ULONG_PTR load_offset, ULONG_PTR dyn_addr, struct elf_info *elf_info)
Definition: elf_module.c:1411
GLenum const GLvoid * addr
Definition: glext.h:9621
WCHAR * get_wine_loader_name(struct process *pcs) DECLSPEC_HIDDEN
Definition: module.c:150
const WCHAR S_WineLoaderW[]
Definition: module.c:42
#define ELF_INFO_MODULE
Definition: elf_module.c:34
struct module * module
Definition: elf_module.c:43
static const struct loader_ops elf_loader_ops
Definition: elf_module.c:1739
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by check_live_target().

◆ fetch_buffer()

void* fetch_buffer ( struct process pcs,
unsigned  size 
)

Definition at line 128 of file dbghelp.c.

129 {
130  if (size > pcs->buffer_size)
131  {
132  if (pcs->buffer)
133  pcs->buffer = HeapReAlloc(GetProcessHeap(), 0, pcs->buffer, size);
134  else
135  pcs->buffer = HeapAlloc(GetProcessHeap(), 0, size);
136  pcs->buffer_size = (pcs->buffer) ? size : 0;
137  }
138  return pcs->buffer;
139 }
unsigned buffer_size
GLsizeiptr size
Definition: glext.h:5919
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
void * buffer
#define HeapReAlloc
Definition: compat.h:593

Referenced by copy_line_W64_from_64(), and symt_fill_func_line_info().

◆ file_name()

const WCHAR* file_name ( const WCHAR str)

Definition at line 45 of file path.c.

46 {
47  const WCHAR* p;
48 
49  for (p = str + lstrlenW(str) - 1; p >= str && !is_sep(*p); p--);
50  return p + 1;
51 }
static BOOL is_sep(WCHAR ch)
Definition: path.c:35
#define lstrlenW
Definition: compat.h:609
const WCHAR * str
__wchar_t WCHAR
Definition: xmlstorage.h:180
GLfloat GLfloat p
Definition: glext.h:8902

Referenced by path_find_symbol_file(), search_dll_path(), search_unix_path(), and SymFindFileInPathW().

◆ file_nameA()

const char* file_nameA ( const char str)

Definition at line 37 of file path.c.

38 {
39  const char* p;
40 
41  for (p = str + strlen(str) - 1; p >= str && !is_sepA(*p); p--);
42  return p + 1;
43 }
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
const WCHAR * str
static BOOL is_sepA(char ch)
Definition: path.c:34
GLfloat GLfloat p
Definition: glext.h:8902

Referenced by elf_lookup_symtab(), FindDebugInfoFile(), is_wine_loader(), REGPROC_open_export_file(), and test_query_process_image_file_name().

◆ get_dos_file_name()

WCHAR* get_dos_file_name ( const WCHAR filename)

Definition at line 671 of file path.c.

672 {
673  WCHAR *dos_path;
674  size_t len;
675 
676  if (*filename == '/')
677  {
678  char *unix_path;
680  unix_path = heap_alloc(len * sizeof(WCHAR));
681  WideCharToMultiByte(CP_UNIXCP, 0, filename, -1, unix_path, len, NULL, NULL);
682  dos_path = wine_get_dos_file_name(unix_path);
683  heap_free(unix_path);
684  }
685  else
686  {
687  len = lstrlenW(filename);
688  dos_path = heap_alloc((len + 1) * sizeof(WCHAR));
689  memcpy(dos_path, filename, (len + 1) * sizeof(WCHAR));
690  }
691  return dos_path;
692 }
#define WideCharToMultiByte
Definition: compat.h:111
const char * filename
Definition: ioapi.h:135
#define lstrlenW
Definition: compat.h:609
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
#define CP_UNIXCP
Definition: compat.h:79
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
#define NULL
Definition: types.h:112
WCHAR *CDECL wine_get_dos_file_name(LPCSTR str)
Definition: path.c:42
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by elf_map_file(), image_check_debug_link(), and macho_map_file().

◆ get_wine_loader_name()

WCHAR* get_wine_loader_name ( struct process pcs)

Definition at line 150 of file module.c.

151 {
152  static const WCHAR wineW[] = {'w','i','n','e',0};
153  static const WCHAR suffixW[] = {'6','4',0};
154  WCHAR *buffer, *p;
155  const char *env;
156 
157  /* All binaries are loaded with WINELOADER (if run from tree) or by the
158  * main executable
159  */
160  if ((env = getenv("WINELOADER")))
161  {
162  DWORD len = 2 + MultiByteToWideChar( CP_UNIXCP, 0, env, -1, NULL, 0 );
163  buffer = heap_alloc( len * sizeof(WCHAR) );
165  }
166  else
167  {
168  buffer = heap_alloc( sizeof(wineW) + 2 * sizeof(WCHAR) );
169  lstrcpyW( buffer, wineW );
170  }
171 
172  p = buffer + lstrlenW( buffer ) - lstrlenW( suffixW );
173  if (p > buffer && !wcscmp( p, suffixW ))
174  *p = 0;
175 
176  if (pcs->is_64bit)
177  lstrcatW(buffer, suffixW);
178 
179  TRACE( "returning %s\n", debugstr_w(buffer) );
180  return buffer;
181 }
GLuint buffer
Definition: glext.h:5915
#define lstrlenW
Definition: compat.h:609
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
static WCHAR wineW[]
Definition: localmon.c:128
#define debugstr_w
Definition: kernel32.h:32
#define TRACE(s)
Definition: solgame.cpp:4
#define CP_UNIXCP
Definition: compat.h:79
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum GLsizei len
Definition: glext.h:6722
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
_Check_return_ char *__cdecl getenv(_In_z_ const char *_VarName)
#define lstrcpyW
Definition: compat.h:608
#define NULL
Definition: types.h:112
static LPCWSTR LPCWSTR LPCWSTR env
Definition: db.cpp:168
#define MultiByteToWideChar
Definition: compat.h:110
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274
GLfloat GLfloat p
Definition: glext.h:8902

Referenced by elf_read_wine_loader_dbg_info(), and macho_search_loader().

◆ hash_table_add()

void hash_table_add ( struct hash_table ht,
struct hash_table_elt elt 
)

Definition at line 378 of file storage.c.

379 {
380  unsigned hash = hash_table_hash(elt->name, ht->num_buckets);
381 
382  if (!ht->buckets)
383  {
384  ht->buckets = pool_alloc(ht->pool, ht->num_buckets * sizeof(struct hash_table_bucket));
385  assert(ht->buckets);
386  memset(ht->buckets, 0, ht->num_buckets * sizeof(struct hash_table_bucket));
387  }
388 
389  /* in some cases, we need to get back the symbols of same name in the order
390  * in which they've been inserted. So insert new elements at the end of the list.
391  */
392  if (!ht->buckets[hash].first)
393  {
394  ht->buckets[hash].first = elt;
395  }
396  else
397  {
398  ht->buckets[hash].last->next = elt;
399  }
400  ht->buckets[hash].last = elt;
401  elt->next = NULL;
402  ht->num_elts++;
403 }
#define assert(x)
Definition: debug.h:53
int hash
Definition: main.c:58
static unsigned hash_table_hash(const char *name, unsigned num_buckets)
Definition: storage.c:319
const char * name
void * pool_alloc(struct pool *pool, size_t len)
Definition: storage.c:89
struct hash_table_elt * next
static const struct newhuff ht[]
Definition: huffman.h:296
#define NULL
Definition: types.h:112
Definition: _hash_fun.h:40
#define memset(x, y, z)
Definition: compat.h:39

Referenced by elf_hash_symtab(), macho_stabs_def_cb(), pev_set_value(), symt_add_module_ht(), symt_new_basic(), symt_new_typedef(), symt_new_udt(), and symt_ptr2index().

◆ hash_table_destroy()

void hash_table_destroy ( struct hash_table ht)

Definition at line 342 of file storage.c.

343 {
344 #if defined(USE_STATS)
345  int i;
346  unsigned len;
347  unsigned min = 0xffffffff, max = 0, sq = 0;
348  struct hash_table_elt* elt;
349  double mean, variance;
350 
351  for (i = 0; i < ht->num_buckets; i++)
352  {
353  for (len = 0, elt = ht->buckets[i]; elt; elt = elt->next) len++;
354  if (len < min) min = len;
355  if (len > max) max = len;
356  sq += len * len;
357  }
358  mean = (double)ht->num_elts / ht->num_buckets;
359  variance = (double)sq / ht->num_buckets - mean * mean;
360  FIXME("STATS: elts[num:%-4u size:%u mean:%f] buckets[min:%-4u variance:%+f max:%-4u]\n",
361  ht->num_elts, ht->num_buckets, mean, min, variance, max);
362 
363  for (i = 0; i < ht->num_buckets; i++)
364  {
365  for (len = 0, elt = ht->buckets[i]; elt; elt = elt->next) len++;
366  if (len == max)
367  {
368  FIXME("Longest bucket:\n");
369  for (elt = ht->buckets[i]; elt; elt = elt->next)
370  FIXME("\t%s\n", elt->name);
371  break;
372  }
373 
374  }
375 #endif
376 }
#define max(a, b)
Definition: svc.c:63
#define FIXME(fmt,...)
Definition: debug.h:111
const char * name
static const char mbstate_t *static wchar_t const char mbstate_t *static const wchar_t int *static double
Definition: string.c:80
GLenum GLsizei len
Definition: glext.h:6722
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
struct hash_table_elt * next
static const struct newhuff ht[]
Definition: huffman.h:296
#define min(a, b)
Definition: monoChain.cc:55

Referenced by module_remove(), and module_reset_debug_info().

◆ hash_table_init()

void hash_table_init ( struct pool pool,
struct hash_table ht,
unsigned  num_buckets 
)

Definition at line 334 of file storage.c.

335 {
336  ht->num_elts = 0;
337  ht->num_buckets = num_buckets;
338  ht->pool = pool;
339  ht->buckets = NULL;
340 }
static const struct newhuff ht[]
Definition: huffman.h:296
#define NULL
Definition: types.h:112

Referenced by elf_load_debug_info(), macho_load_debug_info(), module_new(), and pev_init().

◆ hash_table_iter_init()

void hash_table_iter_init ( const struct hash_table ht,
struct hash_table_iter hti,
const char name 
)

Definition at line 405 of file storage.c.

407 {
408  hti->ht = ht;
409  if (name)
410  {
411  hti->last = hash_table_hash(name, ht->num_buckets);
412  hti->index = hti->last - 1;
413  }
414  else
415  {
416  hti->last = ht->num_buckets - 1;
417  hti->index = -1;
418  }
419  hti->element = NULL;
420 }
static unsigned hash_table_hash(const char *name, unsigned num_buckets)
Definition: storage.c:319
struct hash_table_elt * element
static const struct newhuff ht[]
Definition: huffman.h:296
#define NULL
Definition: types.h:112
const struct hash_table * ht
Definition: name.c:38

Referenced by codeview_add_type_struct(), elf_finish_stabs_info(), elf_lookup_symtab(), elf_new_public_symbols(), elf_new_wine_thunks(), find_name(), macho_finish_stabs(), pe_locate_with_coff_symbol_table(), pev_get_val(), pev_set_value(), SymEnumLines(), symt_enum_module(), symt_find_type_by_name(), and symt_ptr2index().

◆ hash_table_iter_up()

void* hash_table_iter_up ( struct hash_table_iter hti)

Definition at line 422 of file storage.c.

423 {
424  if (!hti->ht->buckets) return NULL;
425 
426  if (hti->element) hti->element = hti->element->next;
427  while (!hti->element && hti->index < hti->last)
428  hti->element = hti->ht->buckets[++hti->index].first;
429  return hti->element;
430 }
struct hash_table_elt * element
#define NULL
Definition: types.h:112
const struct hash_table * ht

Referenced by codeview_add_type_struct(), elf_finish_stabs_info(), elf_lookup_symtab(), elf_new_public_symbols(), elf_new_wine_thunks(), find_name(), macho_finish_stabs(), pe_locate_with_coff_symbol_table(), pev_get_val(), pev_set_value(), SymEnumLines(), symt_enum_module(), symt_find_type_by_name(), and symt_ptr2index().

◆ macho_read_wine_loader_dbg_info()

BOOL macho_read_wine_loader_dbg_info ( struct process pcs,
ULONG_PTR  addr 
)

Definition at line 1911 of file macho_module.c.

1912 {
1913  struct macho_info macho_info;
1914 
1915  TRACE("(%p/%p)\n", pcs, pcs->handle);
1916  pcs->dbg_hdr_addr = addr;
1918  if (!macho_search_loader(pcs, &macho_info)) return FALSE;
1919  macho_info.module->format_info[DFI_MACHO]->u.macho_info->is_loader = 1;
1921  pcs->loader = &macho_loader_ops;
1922  TRACE("Found macho debug header %#lx\n", pcs->dbg_hdr_addr);
1923  return TRUE;
1924 }
void module_set_module(struct module *module, const WCHAR *name) DECLSPEC_HIDDEN
Definition: module.c:142
unsigned flags
Definition: macho_module.c:194
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
ULONG_PTR dbg_hdr_addr
static const struct loader_ops macho_loader_ops
#define TRACE(s)
Definition: solgame.cpp:4
const struct loader_ops * loader
#define MACHO_INFO_MODULE
Definition: macho_module.c:189
GLenum const GLvoid * addr
Definition: glext.h:9621
const WCHAR S_WineLoaderW[]
Definition: module.c:42
HANDLE handle
struct module * module
Definition: macho_module.c:195
static BOOL macho_search_loader(struct process *pcs, struct macho_info *macho_info)

Referenced by check_live_target().

◆ minidump_add_memory_block()

void minidump_add_memory_block ( struct dump_context dc,
ULONG64  base,
ULONG  size,
ULONG  rva 
)

Definition at line 355 of file minidump.c.

356 {
357  if (!dc->mem)
358  {
359  dc->alloc_mem = 32;
360  dc->mem = HeapAlloc(GetProcessHeap(), 0, dc->alloc_mem * sizeof(*dc->mem));
361  }
362  else if (dc->num_mem >= dc->alloc_mem)
363  {
364  dc->alloc_mem *= 2;
365  dc->mem = HeapReAlloc(GetProcessHeap(), 0, dc->mem,
366  dc->alloc_mem * sizeof(*dc->mem));
367  }
368  if (dc->mem)
369  {
370  dc->mem[dc->num_mem].base = base;
371  dc->mem[dc->num_mem].size = size;
372  dc->mem[dc->num_mem].rva = rva;
373  dc->num_mem++;
374  }
375  else dc->num_mem = dc->alloc_mem = 0;
376 }
GLuint base
Definition: 3dtext.c:35
GLsizeiptr size
Definition: glext.h:5919
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define HeapReAlloc
Definition: compat.h:593
static const WCHAR dc[]

Referenced by arm64_fetch_minidump_thread(), arm_fetch_minidump_thread(), dump_threads(), i386_fetch_minidump_thread(), x86_64_fetch_minidump_module(), and x86_64_fetch_minidump_thread().

◆ module_find_by_addr()

struct module* module_find_by_addr ( const struct process pcs,
DWORD64  addr,
enum module_type  type 
)

Definition at line 420 of file module.c.

422 {
423  struct module* module;
424 
425  if (type == DMT_UNKNOWN)
426  {
427  if ((module = module_find_by_addr(pcs, addr, DMT_PE)) ||
428  (module = module_find_by_addr(pcs, addr, DMT_ELF)) ||
430  return module;
431  }
432  else
433  {
434  for (module = pcs->lmodules; module; module = module->next)
435  {
436  if (type == module->type && addr >= module->module.BaseOfImage &&
438  return module;
439  }
440  }
442  return module;
443 }
struct module * module_find_by_addr(const struct process *pcs, DWORD64 addr, enum module_type type)
Definition: module.c:420
DWORD64 BaseOfImage
Definition: compat.h:929
static HMODULE module
Definition: module.c:32
enum module_type type
struct module * lmodules
#define SetLastError(x)
Definition: compat.h:611
GLenum const GLvoid * addr
Definition: glext.h:9621
#define ERROR_MOD_NOT_FOUND
Definition: compat.h:104
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
IMAGEHLP_MODULEW64 module
struct module * next

Referenced by dwarf2_virtual_unwind(), pdb_virtual_unwind(), sym_enum(), SymAddSymbolW(), SymEnumLines(), SymEnumSourceFilesW(), SymEnumTypes(), SymFromAddr(), SymFunctionTableAccess64(), SymGetLineFromAddr64(), SymGetLineNext64(), SymGetLinePrev64(), SymGetModuleBase64(), SymGetModuleInfoW64(), SymGetTypeFromName(), SymGetTypeInfo(), symt_enum_locals(), SymUnloadModule(), SymUnloadModule64(), and x86_64_fetch_minidump_module().

◆ module_find_by_nameA()

struct module* module_find_by_nameA ( const struct process pcs,
const char name 
)

Definition at line 291 of file module.c.

292 {
293  WCHAR wname[MAX_PATH];
294 
295  MultiByteToWideChar(CP_ACP, 0, name, -1, wname, ARRAY_SIZE(wname));
296  return module_find_by_nameW(pcs, wname);
297 }
struct module * module_find_by_nameW(const struct process *pcs, const WCHAR *name)
Definition: module.c:279
#define CP_ACP
Definition: compat.h:109
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:34
#define ARRAY_SIZE(a)
Definition: main.h:24
#define MultiByteToWideChar
Definition: compat.h:110
Definition: name.c:38

Referenced by SymFromName().

◆ module_find_by_nameW()

struct module* module_find_by_nameW ( const struct process pcs,
const WCHAR name 
)

Definition at line 279 of file module.c.

280 {
281  struct module* module;
282 
283  for (module = pcs->lmodules; module; module = module->next)
284  {
285  if (!wcsicmp(name, module->module.ModuleName)) return module;
286  }
288  return NULL;
289 }
WCHAR ModuleName[32]
Definition: compat.h:935
static HMODULE module
Definition: module.c:32
struct module * lmodules
#define SetLastError(x)
Definition: compat.h:611
#define wcsicmp
Definition: compat.h:15
#define NULL
Definition: types.h:112
Definition: name.c:38
#define ERROR_INVALID_NAME
Definition: compat.h:103
IMAGEHLP_MODULEW64 module
struct module * next

Referenced by module_find_by_nameA(), and SymEnumSourceFilesW().

◆ module_get_containee()

struct module* module_get_containee ( const struct process pcs,
const struct module inner 
)

Definition at line 349 of file module.c.

350 {
351  struct module* module;
352 
353  for (module = pcs->lmodules; module; module = module->next)
354  {
355  if (module != outer &&
357  outer->module.BaseOfImage + outer->module.ImageSize >=
359  return module;
360  }
361  return NULL;
362 }
DWORD64 BaseOfImage
Definition: compat.h:929
static HMODULE module
Definition: module.c:32
struct module * lmodules
#define NULL
Definition: types.h:112
IMAGEHLP_MODULEW64 module
struct module * next

Referenced by sym_enum(), and SymFromName().

◆ module_get_debug()

BOOL module_get_debug ( struct module_pair )

Definition at line 374 of file module.c.

375 {
377 
378  if (!pair->requested) return FALSE;
379  /* for a PE builtin, always get info from container */
380  if (!(pair->effective = module_get_container(pair->pcs, pair->requested)))
381  pair->effective = pair->requested;
382  /* if deferred, force loading */
383  if (pair->effective->module.SymType == SymDeferred)
384  {
385  BOOL ret;
386 
387  if (pair->effective->is_virtual) ret = FALSE;
388  else if (pair->effective->type == DMT_PE)
389  {
390  idslW64.SizeOfStruct = sizeof(idslW64);
391  idslW64.BaseOfImage = pair->effective->module.BaseOfImage;
392  idslW64.CheckSum = pair->effective->module.CheckSum;
393  idslW64.TimeDateStamp = pair->effective->module.TimeDateStamp;
394  memcpy(idslW64.FileName, pair->effective->module.ImageName,
395  sizeof(pair->effective->module.ImageName));
396  idslW64.Reparse = FALSE;
397  idslW64.hFile = INVALID_HANDLE_VALUE;
398 
400  ret = pe_load_debug_info(pair->pcs, pair->effective);
401  pcs_callback(pair->pcs,
403  &idslW64);
404  }
405  else ret = pair->pcs->loader->load_debug_info(pair->pcs, pair->effective);
406 
407  if (!ret) pair->effective->module.SymType = SymNone;
408  assert(pair->effective->module.SymType != SymDeferred);
409  pair->effective->module.NumSyms = pair->effective->ht_symbols.num_elts;
410  }
411  return pair->effective->module.SymType != SymNone;
412 }
BOOL pcs_callback(const struct process *pcs, ULONG action, void *data)
Definition: dbghelp.c:705
#define CBA_DEFERRED_SYMBOL_LOAD_COMPLETE
Definition: compat.h:836
static struct module * module_get_container(const struct process *pcs, const struct module *inner)
Definition: module.c:329
#define INVALID_HANDLE_VALUE
Definition: compat.h:590
#define assert(x)
Definition: debug.h:53
WCHAR FileName[MAX_PATH+1]
Definition: compat.h:1026
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOL pe_load_debug_info(const struct process *pcs, struct module *module) DECLSPEC_HIDDEN
Definition: pe_module.c:747
#define CBA_DEFERRED_SYMBOL_LOAD_FAILURE
Definition: compat.h:837
int ret
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define CBA_DEFERRED_SYMBOL_LOAD_START
Definition: compat.h:835
Definition: _pair.h:47

Referenced by dwarf2_virtual_unwind(), find_name(), pdb_virtual_unwind(), sym_enum(), SymAddSymbolW(), SymEnumLines(), SymEnumSourceFilesW(), SymEnumTypes(), SymFromAddr(), SymGetLineFromAddr64(), SymGetLineNext64(), SymGetLinePrev64(), SymGetTypeFromName(), SymGetTypeInfo(), and symt_enum_locals().

◆ module_is_already_loaded()

struct module* module_is_already_loaded ( const struct process pcs,
const WCHAR imgname 
)

Definition at line 303 of file module.c.

304 {
305  struct module* module;
306  const WCHAR* filename;
307 
308  /* first compare the loaded image name... */
309  for (module = pcs->lmodules; module; module = module->next)
310  {
312  return module;
313  }
314  /* then compare the standard filenames (without the path) ... */
316  for (module = pcs->lmodules; module; module = module->next)
317  {
319  return module;
320  }
322  return NULL;
323 }
static HMODULE module
Definition: module.c:32
const char * filename
Definition: ioapi.h:135
WCHAR LoadedImageName[256]
Definition: compat.h:937
struct module * lmodules
static const WCHAR * get_filename(const WCHAR *name, const WCHAR *endptr)
Definition: module.c:70
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define SetLastError(x)
Definition: compat.h:611
#define wcsicmp
Definition: compat.h:15
#define NULL
Definition: types.h:112
Definition: name.c:38
#define ERROR_INVALID_NAME
Definition: compat.h:103
IMAGEHLP_MODULEW64 module
struct module * next

Referenced by elf_load_cb(), elf_search_and_load_file(), macho_search_and_load_file(), and SymLoadModuleExW().

◆ module_new()

struct module* module_new ( struct process pcs,
const WCHAR name,
enum module_type  type,
BOOL  virtual,
DWORD64  addr,
DWORD64  size,
ULONG_PTR  stamp,
ULONG_PTR  checksum 
)

Definition at line 198 of file module.c.

202 {
203  struct module* module;
204  unsigned i;
205 
206  assert(type == DMT_ELF || type == DMT_PE || type == DMT_MACHO);
207  if (!(module = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*module))))
208  return NULL;
209 
210  module->next = pcs->lmodules;
211  pcs->lmodules = module;
212 
213  TRACE("=> %s %s-%s %s\n",
214  get_module_type(type, virtual),
215  wine_dbgstr_longlong(mod_addr), wine_dbgstr_longlong(mod_addr + size),
216  debugstr_w(name));
217 
218  pool_init(&module->pool, 65536);
219 
220  module->process = pcs;
221  module->module.SizeOfStruct = sizeof(module->module);
222  module->module.BaseOfImage = mod_addr;
225  module->module.ImageName[0] = '\0';
228  module->module.NumSyms = 0;
229  module->module.TimeDateStamp = stamp;
231 
233  module->module.CVSig = 0;
234  memset(module->module.CVData, 0, sizeof(module->module.CVData));
235  module->module.PdbSig = 0;
237  module->module.PdbAge = 0;
245 
246  module->reloc_delta = 0;
247  module->type = type;
248  module->is_virtual = virtual;
249  for (i = 0; i < DFI_LAST; i++) module->format_info[i] = NULL;
251  module->sorttab_size = 0;
253  module->num_sorttab = 0;
254  module->num_symbols = 0;
255 
256  vector_init(&module->vsymt, sizeof(struct symt*), 128);
257  /* FIXME: this seems a bit too high (on a per module basis)
258  * need some statistics about this
259  */
262 #ifdef __x86_64__
263  hash_table_init(&module->pool, &module->ht_symaddr, 4096);
264 #endif
265  vector_init(&module->vtypes, sizeof(struct symt*), 32);
266 
267  module->sources_used = 0;
268  module->sources_alloc = 0;
269  module->sources = 0;
271 
272  return module;
273 }
unsigned sources_alloc
DWORD64 BaseOfImage
Definition: compat.h:929
unsigned sources_used
struct hash_table ht_symbols
struct vector vsymt
static HMODULE module
Definition: module.c:32
#define assert(x)
Definition: debug.h:53
struct wine_rb_tree sources_offsets_tree
unsigned num_symbols
char * sources
#define lstrcpynW
Definition: compat.h:597
enum module_type type
WCHAR LoadedImageName[256]
Definition: compat.h:937
#define FALSE
Definition: types.h:117
struct module * lmodules
int sortlist_valid
int source_rb_compare(const void *key, const struct wine_rb_entry *entry) DECLSPEC_HIDDEN
Definition: source.c:40
#define debugstr_w
Definition: kernel32.h:32
void vector_init(struct vector *v, unsigned elt_sz, unsigned bucket_sz) DECLSPEC_HIDDEN
Definition: storage.c:133
unsigned num_sorttab
static void wine_rb_init(struct wine_rb_tree *tree, wine_rb_compare_func_t compare)
Definition: rbtree.h:179
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
DWORD64 reloc_delta
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
struct vector vtypes
WCHAR ImageName[256]
Definition: compat.h:936
void module_set_module(struct module *module, const WCHAR *name)
Definition: module.c:142
void pool_init(struct pool *a, size_t arena_size) DECLSPEC_HIDDEN
Definition: storage.c:43
static const char * get_module_type(enum module_type type, BOOL virtual)
Definition: module.c:184
DWORD SizeOfStruct
Definition: compat.h:928
SYM_TYPE SymType
Definition: compat.h:934
static cab_ULONG checksum(const cab_UBYTE *data, cab_UWORD bytes, cab_ULONG csum)
Definition: fdi.c:353
struct pool pool
struct process * process
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define ARRAY_SIZE(a)
Definition: main.h:24
unsigned short is_virtual
DWORD TimeDateStamp
Definition: compat.h:931
struct hash_table ht_types
WCHAR CVData[MAX_PATH *3]
Definition: compat.h:940
#define NULL
Definition: types.h:112
unsigned sorttab_size
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
WCHAR LoadedPdbName[256]
Definition: compat.h:938
void hash_table_init(struct pool *pool, struct hash_table *ht, unsigned num_buckets) DECLSPEC_HIDDEN
Definition: storage.c:334
Definition: name.c:38
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:49
struct symt_ht ** addr_sorttab
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define memset(x, y, z)
Definition: compat.h:39
struct module_format * format_info[DFI_LAST]
IMAGEHLP_MODULEW64 module
struct module * next

Referenced by elf_load_file_from_fmap(), macho_load_file(), pe_load_builtin_module(), pe_load_native_module(), and SymLoadModuleExW().

◆ module_remove()

BOOL module_remove ( struct process pcs,
struct module module 
)

Definition at line 885 of file module.c.

886 {
887  struct module_format*modfmt;
888  struct module** p;
889  unsigned i;
890 
891  TRACE("%s (%p)\n", debugstr_w(module->module.ModuleName), module);
892 
893  for (i = 0; i < DFI_LAST; i++)
894  {
895  if ((modfmt = module->format_info[i]) && modfmt->remove)
896  modfmt->remove(pcs, module->format_info[i]);
897  }
904  /* native dbghelp doesn't invoke registered callback(,CBA_SYMBOLS_UNLOADED,) here
905  * so do we
906  */
907  for (p = &pcs->lmodules; *p; p = &(*p)->next)
908  {
909  if (*p == module)
910  {
911  *p = module->next;
913  return TRUE;
914  }
915  }
916  FIXME("This shouldn't happen\n");
917  return FALSE;
918 }
void(* remove)(struct process *pcs, struct module_format *modfmt)
WCHAR * real_path
WCHAR ModuleName[32]
Definition: compat.h:935
#define TRUE
Definition: types.h:120
struct hash_table ht_symbols
char * sources
#define FALSE
Definition: types.h:117
struct module * lmodules
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:111
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:595
struct pool pool
void hash_table_destroy(struct hash_table *ht) DECLSPEC_HIDDEN
Definition: storage.c:342
void pool_destroy(struct pool *a) DECLSPEC_HIDDEN
Definition: storage.c:50
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
struct hash_table ht_types
struct symt_ht ** addr_sorttab
GLfloat GLfloat p
Definition: glext.h:8902
struct module_format * format_info[DFI_LAST]
IMAGEHLP_MODULEW64 module
struct module * next
#define HeapFree(x, y, z)
Definition: compat.h:594

Referenced by elf_synchronize_module_list(), macho_synchronize_module_list(), SymCleanup(), SymUnloadModule(), and SymUnloadModule64().

◆ module_reset_debug_info()

void module_reset_debug_info ( struct module module)

Definition at line 1324 of file module.c.

1325 {
1327  module->sorttab_size = 0;
1331  module->ht_symbols.num_buckets = 0;
1332  module->ht_symbols.buckets = NULL;
1334  module->ht_types.num_buckets = 0;
1335  module->ht_types.buckets = NULL;
1336  module->vtypes.num_elts = 0;
1339  module->sources = NULL;
1340 }
unsigned sources_alloc
#define TRUE
Definition: types.h:120
unsigned sources_used
struct hash_table ht_symbols
unsigned num_symbols
char * sources
int sortlist_valid
unsigned num_sorttab
struct vector vtypes
void hash_table_destroy(struct hash_table *ht) DECLSPEC_HIDDEN
Definition: storage.c:342
struct hash_table ht_types
#define NULL
Definition: types.h:112
unsigned sorttab_size
struct symt_ht ** addr_sorttab

Referenced by stabs_parse().

◆ module_set_module()

void module_set_module ( struct module module,
const WCHAR name 
)

Definition at line 142 of file module.c.

143 {
146 }
WCHAR ModuleName[32]
Definition: compat.h:935
WCHAR modulename[64]
#define ARRAY_SIZE(a)
Definition: main.h:24
static void module_fill_module(const WCHAR *in, WCHAR *out, size_t size)
Definition: module.c:118
Definition: name.c:38
IMAGEHLP_MODULEW64 module

Referenced by elf_read_wine_loader_dbg_info(), macho_read_wine_loader_dbg_info(), module_new(), and SymLoadModuleExW().

◆ path_find_symbol_file()

BOOL path_find_symbol_file ( const struct process pcs,
const struct module module,
PCSTR  full_path,
enum module_type  type,
const GUID guid,
DWORD  dw1,
DWORD  dw2,
WCHAR buffer,
BOOL is_unmatched 
)

Definition at line 596 of file path.c.

599 {
600  struct module_find mf;
601  WCHAR full_pathW[MAX_PATH];
602  WCHAR* ptr;
603  const WCHAR* filename;
604  WCHAR* searchPath = pcs->search_path;
605 
606  TRACE("(pcs = %p, full_path = %s, guid = %s, dw1 = 0x%08x, dw2 = 0x%08x, buffer = %p)\n",
607  pcs, debugstr_a(full_path), debugstr_guid(guid), dw1, dw2, buffer);
608 
609  mf.guid = guid;
610  mf.dw1 = dw1;
611  mf.dw2 = dw2;
612  mf.matched = 0;
613 
614  MultiByteToWideChar(CP_ACP, 0, full_path, -1, full_pathW, MAX_PATH);
615  filename = file_name(full_pathW);
616  mf.kind = type;
617  *is_unmatched = FALSE;
618 
619  /* first check full path to file */
620  if (module_find_cb(full_pathW, &mf))
621  {
622  lstrcpyW( buffer, full_pathW );
623  return TRUE;
624  }
625 
626  /* FIXME: Use Environment-Variables (see MS docs)
627  _NT_SYMBOL_PATH and _NT_ALT_SYMBOL_PATH
628  FIXME: Implement "Standard Path Elements" (Path) ... (see MS docs)
629  do a search for (every?) path-element like this ...
630  <path>
631  <path>\dll
632  <path>\symbols\dll
633  (dll may be exe, or sys depending on the file extension) */
634 
635  /* 2. check module-path */
637  if (do_searchW(filename, buffer, FALSE, module_find_cb, &mf)) return TRUE;
638  if (module->real_path)
639  {
641  if (do_searchW(filename, buffer, FALSE, module_find_cb, &mf)) return TRUE;
642  }
643 
644  while (searchPath)
645  {
646  ptr = wcschr(searchPath, ';');
647  if (ptr)
648  {
649  memcpy(buffer, searchPath, (ptr - searchPath) * sizeof(WCHAR));
650  buffer[ptr - searchPath] = '\0';
651  searchPath = ptr + 1;
652  }
653  else
654  {
655  lstrcpyW(buffer, searchPath);
656  searchPath = NULL;
657  }
658  /* return first fully matched file */
659  if (do_searchW(filename, buffer, FALSE, module_find_cb, &mf)) return TRUE;
660  }
661  /* if no fully matching file is found, return the best matching file if any */
662  if ((dbghelp_options & SYMOPT_LOAD_ANYTHING) && mf.matched)
663  {
664  lstrcpyW( buffer, mf.filename );
665  *is_unmatched = TRUE;
666  return TRUE;
667  }
668  return FALSE;
669 }
WCHAR * search_path
WCHAR * real_path
#define TRUE
Definition: types.h:120
#define CP_ACP
Definition: compat.h:109
static BOOL CALLBACK module_find_cb(PCWSTR buffer, PVOID user)
Definition: path.c:473
GLuint buffer
Definition: glext.h:5915
const WCHAR * file_name(const WCHAR *str)
Definition: path.c:45
const char * filename
Definition: ioapi.h:135
WCHAR LoadedImageName[256]
Definition: compat.h:937
const GUID * guid
#define FALSE
Definition: types.h:117
static PVOID ptr
Definition: dispmode.c:27
static void file_pathW(const WCHAR *src, WCHAR *dst)
Definition: path.c:53
#define debugstr_guid
Definition: kernel32.h:35
#define TRACE(s)
Definition: solgame.cpp:4
_CONST_RETURN wchar_t *__cdecl wcschr(_In_z_ const wchar_t *_Str, wchar_t _Ch)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define debugstr_a
Definition: kernel32.h:31
#define MAX_PATH
Definition: compat.h:34
static BOOL do_searchW(PCWSTR file, PWSTR buffer, BOOL recurse, PENUMDIRTREE_CALLBACKW cb, PVOID user)
Definition: path.c:221
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define SYMOPT_LOAD_ANYTHING
Definition: compat.h:850
#define lstrcpyW
Definition: compat.h:608
#define NULL
Definition: types.h:112
unsigned dbghelp_options
Definition: dbghelp.c:73
#define MultiByteToWideChar
Definition: compat.h:110
DWORD dw1
Definition: path.c:462
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
IMAGEHLP_MODULEW64 module
DWORD dw2
Definition: path.c:463

Referenced by map_pdb_file(), and pe_load_dbg_file().

◆ pcs_callback()

BOOL pcs_callback ( const struct process pcs,
ULONG  action,
void data 
)

Definition at line 705 of file dbghelp.c.

706 {
708 
709  TRACE("%p %u %p\n", pcs, action, data);
710 
711  if (!pcs->reg_cb) return FALSE;
712  if (!pcs->reg_is_unicode)
713  {
715 
716  switch (action)
717  {
718  case CBA_DEBUG_INFO:
720  case CBA_SET_OPTIONS:
722  break;
727  idslW = data;
728  idsl.SizeOfStruct = sizeof(idsl);
729  idsl.BaseOfImage = idslW->BaseOfImage;
730  idsl.CheckSum = idslW->CheckSum;
731  idsl.TimeDateStamp = idslW->TimeDateStamp;
732  WideCharToMultiByte(CP_ACP, 0, idslW->FileName, -1,
733  idsl.FileName, sizeof(idsl.FileName), NULL, NULL);
734  idsl.Reparse = idslW->Reparse;
735  data = &idsl;
736  break;
738  case CBA_EVENT:
739  case CBA_READ_MEMORY:
740  default:
741  FIXME("No mapping for action %u\n", action);
742  return FALSE;
743  }
744  }
745  return pcs->reg_cb(pcs->handle, action, (ULONG64)(DWORD_PTR)data, pcs->reg_user);
746 }
#define CBA_DEFERRED_SYMBOL_LOAD_COMPLETE
Definition: compat.h:836
#define WideCharToMultiByte
Definition: compat.h:111
#define CP_ACP
Definition: compat.h:109
#define CBA_EVENT
Definition: compat.h:843
WCHAR FileName[MAX_PATH+1]
Definition: compat.h:1026
#define CBA_READ_MEMORY
Definition: compat.h:840
#define FALSE
Definition: types.h:117
#define FIXME(fmt,...)
Definition: debug.h:111
#define CBA_DEFERRED_SYMBOL_LOAD_FAILURE
Definition: compat.h:837
#define CBA_SYMBOLS_UNLOADED
Definition: compat.h:838
DWORD64 reg_user
#define TRACE(s)
Definition: solgame.cpp:4
PSYMBOL_REGISTERED_CALLBACK64 reg_cb
#define CBA_DEBUG_INFO
Definition: compat.h:845
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
unsigned __int64 ULONG64
Definition: imports.h:198
#define CBA_DUPLICATE_SYMBOL
Definition: compat.h:839
uint32_t DWORD_PTR
Definition: typedefs.h:65
#define CBA_DEFERRED_SYMBOL_LOAD_PARTIAL
Definition: compat.h:844
const WCHAR * action
Definition: action.c:7783
#define CBA_DEFERRED_SYMBOL_LOAD_START
Definition: compat.h:835
#define NULL
Definition: types.h:112
#define CBA_SET_OPTIONS
Definition: compat.h:842
HANDLE handle
#define CBA_DEFERRED_SYMBOL_LOAD_CANCEL
Definition: compat.h:841
BOOL reg_is_unicode

Referenced by module_get_debug(), and SymSetOptions().

◆ pdb_fetch_file_info()

BOOL pdb_fetch_file_info ( const struct pdb_lookup pdb_lookup,
unsigned matched 
)

Definition at line 2913 of file msc.c.

2914 {
2915  HANDLE hFile, hMap = NULL;
2916  char* image = NULL;
2917  BOOL ret;
2918  struct pdb_file_info pdb_file;
2919 
2922  ((hMap = CreateFileMappingW(hFile, NULL, PAGE_READONLY, 0, 0, NULL)) == NULL) ||
2923  ((image = MapViewOfFile(hMap, FILE_MAP_READ, 0, 0, 0)) == NULL))
2924  {
2925  WARN("Unable to open .PDB file: %s\n", pdb_lookup->filename);
2926  ret = FALSE;
2927  }
2928  else
2929  {
2930  ret = pdb_init(pdb_lookup, &pdb_file, image, matched);
2931  pdb_free_file(&pdb_file);
2932  }
2933 
2934  if (image) UnmapViewOfFile(image);
2935  if (hMap) CloseHandle(hMap);
2937 
2938  return ret;
2939 }
#define CloseHandle
Definition: compat.h:598
#define MapViewOfFile
Definition: compat.h:604
static BOOL pdb_init(const struct pdb_lookup *pdb_lookup, struct pdb_file_info *pdb_file, const char *image, unsigned *matched)
Definition: msc.c:2539
#define WARN(fmt,...)
Definition: debug.h:112
#define INVALID_HANDLE_VALUE
Definition: compat.h:590
#define FILE_SHARE_READ
Definition: compat.h:136
static void pdb_free_file(struct pdb_file_info *pdb_file)
Definition: msc.c:2269
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define FILE_MAP_READ
Definition: compat.h:635
#define OPEN_EXISTING
Definition: compat.h:634
#define CreateFileMappingW(a, b, c, d, e, f)
Definition: compat.h:603
int ret
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
#define GENERIC_READ
Definition: compat.h:135
_In_ HANDLE hFile
Definition: mswsock.h:90
#define NULL
Definition: types.h:112
#define PAGE_READONLY
Definition: compat.h:138
HANDLE hMap
Definition: msc.c:64
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:599
#define UnmapViewOfFile
Definition: compat.h:605
const char * filename

Referenced by module_find_cb().

◆ pdb_virtual_unwind()

BOOL pdb_virtual_unwind ( struct cpu_stack_walk csw,
DWORD_PTR  ip,
union ctx context,
struct pdb_cmd_pair cpair 
)

Definition at line 3200 of file msc.c.

3202 {
3203  struct module_pair pair;
3204  struct pdb_module_info* pdb_info;
3205  PDB_FPO_DATA* fpoext;
3206  unsigned i, size, strsize;
3207  char* strbase;
3208  BOOL ret = TRUE;
3209 
3210  if (!(pair.pcs = process_find_by_handle(csw->hProcess)) ||
3211  !(pair.requested = module_find_by_addr(pair.pcs, ip, DMT_UNKNOWN)) ||
3213  return FALSE;
3214  if (!pair.effective->format_info[DFI_PDB]) return FALSE;
3215  pdb_info = pair.effective->format_info[DFI_PDB]->u.pdb_info;
3216  TRACE("searching %lx => %lx\n", ip, ip - (DWORD_PTR)pair.effective->module.BaseOfImage);
3217  ip -= (DWORD_PTR)pair.effective->module.BaseOfImage;
3218 
3219  strbase = pdb_read_strings(&pdb_info->pdb_files[0]);
3220  if (!strbase) return FALSE;
3221  strsize = *(const DWORD*)(strbase + 8);
3222  fpoext = pdb_read_file(&pdb_info->pdb_files[0], pdb_info->pdb_files[0].fpoext_stream);
3223  size = pdb_get_file_size(&pdb_info->pdb_files[0], pdb_info->pdb_files[0].fpoext_stream);
3224  if (fpoext && (size % sizeof(*fpoext)) == 0)
3225  {
3226  size /= sizeof(*fpoext);
3227  for (i = 0; i < size; i++)
3228  {
3229  if (fpoext[i].start <= ip && ip < fpoext[i].start + fpoext[i].func_size)
3230  {
3231  TRACE("\t%08x %08x %8x %8x %4x %4x %4x %08x %s\n",
3232  fpoext[i].start, fpoext[i].func_size, fpoext[i].locals_size,
3233  fpoext[i].params_size, fpoext[i].maxstack_size, fpoext[i].prolog_size,
3234  fpoext[i].savedregs_size, fpoext[i].flags,
3235  fpoext[i].str_offset < strsize ?
3236  wine_dbgstr_a(strbase + 12 + fpoext[i].str_offset) : "<out of bounds>");
3237  if (fpoext[i].str_offset < strsize)
3238  ret = pdb_parse_cmd_string(csw, &fpoext[i], strbase + 12 + fpoext[i].str_offset, cpair);
3239  else
3240  ret = FALSE;
3241  break;
3242  }
3243  }
3244  }
3245  else ret = FALSE;
3246  pdb_free(fpoext);
3247  pdb_free(strbase);
3248 
3249  return ret;
3250 }
static unsigned pdb_get_file_size(const struct pdb_file_info *pdb_file, DWORD file_nr)
Definition: msc.c:2254
#define DWORD_PTR
Definition: treelist.c:76
const char int int int static __inline const char * wine_dbgstr_a(const char *s)
Definition: debug.h:186
static void * pdb_read_file(const struct pdb_file_info *pdb_file, DWORD file_nr)
Definition: msc.c:2239
#define TRUE
Definition: types.h:120
struct process * process_find_by_handle(HANDLE hProcess)
Definition: dbghelp.c:99
static void * pdb_read_strings(const struct pdb_file_info *pdb_file)
Definition: msc.c:2337
static void pdb_free(void *buffer)
Definition: msc.c:2264
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
struct pdb_file_info pdb_files[CV_MAX_MODULES]
Definition: msc.c:88
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
BOOL module_get_debug(struct module_pair *) DECLSPEC_HIDDEN
Definition: module.c:374
Definition: dhcpd.h:61
unsigned long DWORD
Definition: ntddk_ex.h:95
GLbitfield flags
Definition: glext.h:7161
int ret
struct module * module_find_by_addr(const struct process *pcs, DWORD64 addr, enum module_type type) DECLSPEC_HIDDEN
Definition: module.c:420
static BOOL pdb_parse_cmd_string(struct cpu_stack_walk *csw, PDB_FPO_DATA *fpoext, const char *cmd, struct pdb_cmd_pair *cpair)
Definition: msc.c:3147
uint32_t DWORD_PTR
Definition: typedefs.h:65
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLuint start
Definition: gl.h:1545
Definition: _pair.h:47

Referenced by fetch_next_frame32().

◆ pe_load_builtin_module()

struct module* pe_load_builtin_module ( struct process pcs,
const WCHAR name,
DWORD64  base,
DWORD64  size 
)

Definition at line 892 of file pe_module.c.

894 {
895  struct module* module = NULL;
896 
897  if (base && pcs->dbg_hdr_addr)
898  {
899  IMAGE_NT_HEADERS nth;
900 
901  if (pe_load_nt_header(pcs->handle, base, &nth))
902  {
903  if (!size) size = nth.OptionalHeader.SizeOfImage;
907  }
908  }
909  return module;
910 }
HMODULE module
Definition: main.cpp:47
#define FALSE
Definition: types.h:117
ULONG_PTR dbg_hdr_addr
IMAGE_FILE_HEADER FileHeader
Definition: ntddk_ex.h:183
BOOL pe_load_nt_header(HANDLE hProc, DWORD64 base, IMAGE_NT_HEADERS *nth)
Definition: pe_module.c:877
GLsizeiptr size
Definition: glext.h:5919
IMAGE_OPTIONAL_HEADER32 OptionalHeader
Definition: ntddk_ex.h:184
#define NULL
Definition: types.h:112
Definition: name.c:38
HANDLE handle
struct module * module_new(struct process *pcs, const WCHAR *name, enum module_type type, BOOL virtual, DWORD64 addr, DWORD64 size, ULONG_PTR stamp, ULONG_PTR checksum) DECLSPEC_HIDDEN
Definition: module.c:198

Referenced by SymLoadModuleExW().

◆ pe_load_debug_directory()

BOOL pe_load_debug_directory ( const struct process pcs,
struct module module,
const BYTE mapping,
const IMAGE_SECTION_HEADER sectp,
DWORD  nsect,
const IMAGE_DEBUG_DIRECTORY dbg,
int  nDbg 
)

Definition at line 3391 of file msc.c.

3395 {
3396  BOOL ret;
3397  int i;
3398  struct msc_debug_info msc_dbg;
3399 
3400  msc_dbg.module = module;
3401  msc_dbg.nsect = nsect;
3402  msc_dbg.sectp = sectp;
3403  msc_dbg.nomap = 0;
3404  msc_dbg.omapp = NULL;
3405 
3406  __TRY
3407  {
3408  ret = FALSE;
3409 
3410  /* First, watch out for OMAP data */
3411  for (i = 0; i < nDbg; i++)
3412  {
3414  {
3415  msc_dbg.nomap = dbg[i].SizeOfData / sizeof(OMAP_DATA);
3416  msc_dbg.omapp = (const OMAP_DATA*)(mapping + dbg[i].PointerToRawData);
3417  break;
3418  }
3419  }
3420 
3421  /* Now, try to parse CodeView debug info */
3422  for (i = 0; i < nDbg; i++)
3423  {
3424  if (dbg[i].Type == IMAGE_DEBUG_TYPE_CODEVIEW)
3425  {
3426  msc_dbg.root = mapping + dbg[i].PointerToRawData;
3427  if ((ret = codeview_process_info(pcs, &msc_dbg))) goto done;
3428  }
3429  }
3430 
3431  /* If not found, try to parse COFF debug info */
3432  for (i = 0; i < nDbg; i++)
3433  {
3434  if (dbg[i].Type == IMAGE_DEBUG_TYPE_COFF)
3435  {
3436  msc_dbg.root = mapping + dbg[i].PointerToRawData;
3437  if ((ret = coff_process_info(&msc_dbg))) goto done;
3438  }
3439  }
3440  done:
3441  /* FIXME: this should be supported... this is the debug information for
3442  * functions compiled without a frame pointer (FPO = frame pointer omission)
3443  * the associated data helps finding out the relevant information
3444  */
3445  for (i = 0; i < nDbg; i++)
3446  if (dbg[i].Type == IMAGE_DEBUG_TYPE_FPO)
3447  FIXME("This guy has FPO information\n");
3448 #if 0
3449 
3450 #define FRAME_FPO 0
3451 #define FRAME_TRAP 1
3452 #define FRAME_TSS 2
3453 
3454 typedef struct _FPO_DATA
3455 {
3456  DWORD ulOffStart; /* offset 1st byte of function code */
3457  DWORD cbProcSize; /* # bytes in function */
3458  DWORD cdwLocals; /* # bytes in locals/4 */
3459  WORD cdwParams; /* # bytes in params/4 */
3460 
3461  WORD cbProlog : 8; /* # bytes in prolog */
3462  WORD cbRegs : 3; /* # regs saved */
3463  WORD fHasSEH : 1; /* TRUE if SEH in func */
3464  WORD fUseBP : 1; /* TRUE if EBP has been allocated */
3465  WORD reserved : 1; /* reserved for future use */
3466  WORD cbFrame : 2; /* frame type */
3467 } FPO_DATA;
3468 #endif
3469 
3470  }
3472  {
3473  ERR("Got a page fault while loading symbols\n");
3474  ret = FALSE;
3475  }
3476  __ENDTRY
3477  return ret;
3478 }
WORD reserved
Definition: winnt_old.h:3453
WORD fHasSEH
Definition: winnt_old.h:3451
#define IMAGE_DEBUG_TYPE_COFF
Definition: compat.h:141
DECLSPEC_HIDDEN BOOL coff_process_info(const struct msc_debug_info *msc_dbg)
Definition: coff.c:148
HMODULE module
Definition: main.cpp:47
WORD cbFrame
Definition: winnt_old.h:3454
#define IMAGE_DEBUG_TYPE_CODEVIEW
Definition: compat.h:142
#define IMAGE_DEBUG_TYPE_OMAP_FROM_SRC
Definition: compat.h:148
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
WORD fUseBP
Definition: winnt_old.h:3452
#define FIXME(fmt,...)
Definition: debug.h:111
#define __TRY
Definition: compat.h:80
DWORD ulOffStart
Definition: winnt_old.h:3445
unsigned short WORD
Definition: ntddk_ex.h:93
Type
Definition: Type.h:6
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum GLenum GLenum GLenum mapping
Definition: glext.h:9031
static BOOL codeview_process_info(const struct process *pcs, const struct msc_debug_info *msc_dbg)
Definition: msc.c:3262
#define __ENDTRY
Definition: compat.h:82
int ret
#define ERR(fmt,...)
Definition: debug.h:110
#define IMAGE_DEBUG_TYPE_FPO
Definition: compat.h:143
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
struct module * module
Definition: mscvpdb.h:2134
WORD cbRegs
Definition: winnt_old.h:3450
#define NULL
Definition: types.h:112
struct _FPO_DATA FPO_DATA
DWORD cbProcSize
Definition: winnt_old.h:3446
DWORD cdwLocals
Definition: winnt_old.h:3447
const IMAGE_SECTION_HEADER * sectp
Definition: mscvpdb.h:2136
#define __EXCEPT_PAGE_FAULT
Definition: compat.h:81
WORD cdwParams
Definition: winnt_old.h:3448
WORD cbProlog
Definition: winnt_old.h:3449

Referenced by pe_load_dbg_file(), and pe_load_msc_debug_info().

◆ pe_load_debug_info()

BOOL pe_load_debug_info ( const struct process pcs,
struct module module 
)

Definition at line 747 of file pe_module.c.

748 {
749  BOOL ret = FALSE;
750 
752  {
753  ret = image_check_alternate(&module->format_info[DFI_PE]->u.pe_info->fmap, module);
754  ret = pe_load_stabs(pcs, module) || ret;
755  ret = pe_load_dwarf(module) || ret;
756  #ifndef DBGHELP_STATIC_LIB
758  ret = pe_load_rsym(module) || ret;
759  #endif
760 
761  ret = ret || pe_load_coff_symbol_table(module); /* FIXME */
762  /* if we still have no debug info (we could only get SymExport at this
763  * point), then do the SymExport except if we have an ELF container,
764  * in which case we'll rely on the export's on the ELF side
765  */
766  }
767  /* FIXME shouldn't we check that? if (!module_get_debug(pcs, module)) */
768  if (pe_load_export_debug_info(pcs, module) && !ret)
769  ret = TRUE;
770 
771  return ret;
772 }
#define TRUE
Definition: types.h:120
BOOL image_check_alternate(struct image_file_map *fmap, const struct module *module) DECLSPEC_HIDDEN
Definition: module.c:697
static BOOL pe_load_dwarf(struct module *module)
Definition: pe_module.c:521
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
static BOOL pe_load_export_debug_info(const struct process *pcs, struct module *module)
Definition: pe_module.c:662
int ret
static BOOL pe_load_rsym(struct module *module)
Definition: pe_module.c:541
static BOOL pe_load_msc_debug_info(const struct process *pcs, struct module *module)
Definition: pe_module.c:614
static BOOL pe_load_coff_symbol_table(struct module *module)
Definition: pe_module.c:416
unsigned dbghelp_options
Definition: dbghelp.c:73
#define SYMOPT_PUBLICS_ONLY
Definition: compat.h:851
static BOOL pe_load_stabs(const struct process *pcs, struct module *module)
Definition: pe_module.c:485
struct module_format * format_info[DFI_LAST]

Referenced by module_get_debug(), and pe_load_native_module().

◆ pe_load_native_module()

struct module* pe_load_native_module ( struct process pcs,
const WCHAR name,
HANDLE  hFile,
DWORD64  base,
DWORD  size 
)

Definition at line 799 of file pe_module.c.

801 {
802  struct module* module = NULL;
803  BOOL opened = FALSE;
804  struct module_format* modfmt;
805  WCHAR loaded_name[MAX_PATH];
806 
807  loaded_name[0] = '\0';
808  if (!hFile)
809  {
810  assert(name);
811 
812  if ((hFile = FindExecutableImageExW(name, pcs->search_path, loaded_name, NULL, NULL)) == NULL)
813  return NULL;
814  opened = TRUE;
815  }
816  else if (name) lstrcpyW(loaded_name, name);
818  FIXME("Trouble ahead (no module name passed in deferred mode)\n");
819  if (!(modfmt = HeapAlloc(GetProcessHeap(), 0, sizeof(struct module_format) + sizeof(struct pe_module_info))))
820  return NULL;
821  modfmt->u.pe_info = (struct pe_module_info*)(modfmt + 1);
822  if (pe_map_file(hFile, &modfmt->u.pe_info->fmap, DMT_PE))
823  {
824 #ifndef __REACTOS__
825  struct builtin_search builtin = { NULL };
826  if (modfmt->u.pe_info->fmap.u.pe.builtin && search_dll_path(pcs, loaded_name, search_builtin_pe, &builtin))
827  {
828  TRACE("reloaded %s from %s\n", debugstr_w(loaded_name), debugstr_w(builtin.path));
829  image_unmap_file(&modfmt->u.pe_info->fmap);
830  modfmt->u.pe_info->fmap = builtin.fmap;
831  }
832 #endif
833  if (!base) base = modfmt->u.pe_info->fmap.u.pe.ntheader.OptionalHeader.ImageBase;
834  if (!size) size = modfmt->u.pe_info->fmap.u.pe.ntheader.OptionalHeader.SizeOfImage;
835 
836  module = module_new(pcs, loaded_name, DMT_PE, FALSE, base, size,
837  modfmt->u.pe_info->fmap.u.pe.ntheader.FileHeader.TimeDateStamp,
838  modfmt->u.pe_info->fmap.u.pe.ntheader.OptionalHeader.CheckSum);
839  if (module)
840  {
841 #ifdef __REACTOS__
842  module->real_path = NULL;
843 #else
844  module->real_path = builtin.path;
845 #endif
846  modfmt->module = module;
847  modfmt->remove = pe_module_remove;
848  modfmt->loc_compute = NULL;
849 
850  module->format_info[DFI_PE] = modfmt;
853  else
855  module->reloc_delta = base - modfmt->u.pe_info->fmap.u.pe.ntheader.OptionalHeader.ImageBase;
856  }
857  else
858  {
859  ERR("could not load the module '%s'\n", debugstr_w(loaded_name));
860 #ifndef __REACTOS__
861  heap_free(builtin.path);
862 #endif
863  image_unmap_file(&modfmt->u.pe_info->fmap);
864  }
865  }
866  if (!module) HeapFree(GetProcessHeap(), 0, modfmt);
867 
868  if (opened) CloseHandle(hFile);
869 
870  return module;
871 }
void(* remove)(struct process *pcs, struct module_format *modfmt)
WCHAR * search_path
#define CloseHandle
Definition: compat.h:598
HMODULE module
Definition: main.cpp:47
WCHAR * real_path
#define TRUE
Definition: types.h:120
BOOL search_dll_path(const struct process *process, const WCHAR *name, BOOL(*match)(void *, HANDLE, const WCHAR *), void *param) DECLSPEC_HIDDEN
Definition: path.c:695
#define assert(x)
Definition: debug.h:53
union module_format::@366 u
WCHAR * path
Definition: pe_module.c:777
#define SYMOPT_DEFERRED_LOADS
Definition: compat.h:848
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:111
BOOL pe_load_debug_info(const struct process *pcs, struct module *module)
Definition: pe_module.c:747
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
DWORD64 reloc_delta
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
void(* loc_compute)(struct process *pcs, const struct module_format *modfmt, const struct symt_function *func, struct location *loc)
__wchar_t WCHAR
Definition: xmlstorage.h:180
static BOOL search_builtin_pe(void *param, HANDLE handle, const WCHAR *path)
Definition: pe_module.c:781
#define FindExecutableImageExW
Definition: compat.h:1000
#define MAX_PATH
Definition: compat.h:34
static void image_unmap_file(struct image_file_map *fmap)
static void pe_module_remove(struct process *pcs, struct module_format *modfmt)
Definition: pe_module.c:341
SYM_TYPE SymType
Definition: compat.h:934
_In_ HANDLE hFile
Definition: mswsock.h:90
#define ERR(fmt,...)
Definition: debug.h:110
#define lstrcpyW
Definition: compat.h:608
#define NULL
Definition: types.h:112
unsigned dbghelp_options
Definition: dbghelp.c:73
struct module * module
struct image_file_map fmap
Definition: pe_module.c:778
Definition: name.c:38
struct module * module_new(struct process *pcs, const WCHAR *name, enum module_type type, BOOL virtual, DWORD64 addr, DWORD64 size, ULONG_PTR stamp, ULONG_PTR checksum) DECLSPEC_HIDDEN
Definition: module.c:198
IMAGEHLP_MODULEW64 module
struct module_format * format_info[DFI_LAST]
#define HeapFree(x, y, z)
Definition: compat.h:594
BOOL pe_map_file(HANDLE file, struct image_file_map *fmap, enum module_type mt)
Definition: pe_module.c:241
static BOOL heap_free(void *mem)
Definition: appwiz.h:75
struct pe_module_info * pe_info

Referenced by SymLoadModuleExW().

◆ pe_load_nt_header()

BOOL pe_load_nt_header ( HANDLE  hProc,
DWORD64  base,
IMAGE_NT_HEADERS nth 
)

Definition at line 877 of file pe_module.c.

878 {
880 
881  return ReadProcessMemory(hProc, (char*)(DWORD_PTR)base, &dos, sizeof(dos), NULL) &&
883  ReadProcessMemory(hProc, (char*)(DWORD_PTR)(base + dos.e_lfanew),
884  nth, sizeof(*nth), NULL) &&
886 }
#define ReadProcessMemory(a, b, c, d, e)
Definition: compat.h:617
#define IMAGE_DOS_SIGNATURE
Definition: pedump.c:89
#define IMAGE_NT_SIGNATURE
Definition: pedump.c:93
IMAGE_DOS_HEADER dos
Definition: module.c:49
uint32_t DWORD_PTR
Definition: typedefs.h:65
#define NULL
Definition: types.h:112

Referenced by fetch_pe_module_info_cb(), and pe_load_builtin_module().

◆ pe_map_directory()

const char* pe_map_directory ( struct module module,
int  dirno,
DWORD size 
)

Definition at line 327 of file pe_module.c.

328 {
329  IMAGE_NT_HEADERS* nth;
330  void* mapping;
331 
332  if (module->type != DMT_PE || !module->format_info[DFI_PE]) return NULL;
333  if (dirno >= IMAGE_NUMBEROF_DIRECTORY_ENTRIES ||
334  !(mapping = pe_map_full(&module->format_info[DFI_PE]->u.pe_info->fmap, &nth)))
335  return NULL;
336  if (size) *size = nth->OptionalHeader.DataDirectory[dirno].Size;
337  return RtlImageRvaToVa(nth, mapping,
339 }
IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES]
Definition: ntddk_ex.h:178
#define IMAGE_NUMBEROF_DIRECTORY_ENTRIES
Definition: ntddk_ex.h:135
#define RtlImageRvaToVa
Definition: compat.h:666
static void * pe_map_full(struct image_file_map *fmap, IMAGE_NT_HEADERS **nth)
Definition: pe_module.c:46
enum module_type type
GLsizeiptr size
Definition: glext.h:5919
GLenum GLenum GLenum GLenum mapping
Definition: glext.h:9031
IMAGE_OPTIONAL_HEADER32 OptionalHeader
Definition: ntddk_ex.h:184
#define NULL
Definition: types.h:112
struct module_format * format_info[DFI_LAST]

Referenced by x86_64_fetch_minidump_module(), and x86_64_find_runtime_function().

◆ pool_alloc()

void* pool_alloc ( struct pool a,
size_t  len 
)

Definition at line 89 of file storage.c.

90 {
91  struct pool_arena* arena;
92  void* ret;
93  size_t size;
94 
95  len = (len + 3) & ~3; /* round up size on DWORD boundary */
96 
98  {
99  if (arena->end - arena->current >= len)
100  {
101  ret = arena->current;
102  arena->current += len;
103  if (arena->current + 16 >= arena->end)
104  {
105  list_remove( &arena->entry );
106  list_add_tail( &pool->arena_full, &arena->entry );
107  }
108  return ret;
109  }
110  }
111 
112  size = max( pool->arena_size, len );
113  arena = HeapAlloc(GetProcessHeap(), 0, size + sizeof(struct pool_arena));
114  if (!arena) return NULL;
115 
116  ret = arena + 1;
117  arena->current = (char*)ret + len;
118  arena->end = (char*)ret + size;
119  if (arena->current + 16 >= arena->end)
120  list_add_tail( &pool->arena_full, &arena->entry );
121  else
122  list_add_head( &pool->arena_list, &arena->entry );
123  return ret;
124 }
struct list arena_list
#define max(a, b)
Definition: svc.c:63
__WINE_SERVER_LIST_INLINE void list_add_head(struct list *list, struct list *elem)
Definition: list.h:96
char * current
Definition: storage.c:39
size_t arena_size
__WINE_SERVER_LIST_INLINE void list_add_tail(struct list *list, struct list *elem)
Definition: list.h:102
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
char * end
Definition: storage.c:40
__WINE_SERVER_LIST_INLINE void list_remove(struct list *elem)
Definition: list.h:108
GLsizeiptr size
Definition: glext.h:5919
struct list arena_full
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
int ret
uint32_t entry
Definition: isohybrid.c:63
GLenum GLsizei len
Definition: glext.h:6722
#define NULL
Definition: types.h:112
struct list entry
Definition: storage.c:38

Referenced by dwarf2_compute_location_attr(), dwarf2_get_cpp_name(), dwarf2_parse_abbrev_set(), dwarf2_parse_line_numbers(), dwarf2_parse_variable(), dwarf2_read_one_debug_info(), elf_hash_symtab(), hash_table_add(), macho_stabs_def_cb(), pev_set_value(), pool_strdup(), source_new(), symt_add_enum_element(), symt_add_func_local(), symt_add_function_point(), symt_add_function_signature_parameter(), symt_add_udt_element(), symt_new_array(), symt_new_basic(), symt_new_compiland(), symt_new_constant(), symt_new_enum(), symt_new_function(), symt_new_function_signature(), symt_new_global_variable(), symt_new_label(), symt_new_pointer(), symt_new_public(), symt_new_thunk(), symt_new_typedef(), symt_new_udt(), symt_open_func_block(), symt_ptr2index(), and vector_add().

◆ pool_destroy()

void pool_destroy ( struct pool a)

Definition at line 50 of file storage.c.

51 {
52  struct pool_arena* arena;
53  struct pool_arena* next;
54 
55 #ifdef USE_STATS
56  size_t alloc, used, num;
57 
58  alloc = used = num = 0;
60  {
61  alloc += arena->end - (char *)arena;
62  used += arena->current - (char*)arena;
63  num++;
64  }
66  {
67  alloc += arena->end - (char *)arena;
68  used += arena->current - (char*)arena;
69  num++;
70  }
71  if (alloc == 0) alloc = 1; /* avoid division by zero */
72  FIXME("STATS: pool %p has allocated %u kbytes, used %u kbytes in %u arenas, non-allocation ratio: %.2f%%\n",
73  pool, (unsigned)(alloc >> 10), (unsigned)(used >> 10), (unsigned)num,
74  100.0 - (float)used / (float)alloc * 100.0);
75 #endif
76 
78  {
79  list_remove( &arena->entry );
80  HeapFree(GetProcessHeap(), 0, arena);
81  }
83  {
84  list_remove( &arena->entry );
85  HeapFree(GetProcessHeap(), 0, arena);
86  }
87 }
struct list arena_list
char * current
Definition: storage.c:39
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
#define FIXME(fmt,...)
Definition: debug.h:111
char * end
Definition: storage.c:40
c used
Definition: write.c:2857
__WINE_SERVER_LIST_INLINE void list_remove(struct list *elem)
Definition: list.h:108
struct list arena_full
#define GetProcessHeap()
Definition: compat.h:595
GLuint GLuint num
Definition: glext.h:9618
uint32_t entry
Definition: isohybrid.c:63
static unsigned __int64 next
Definition: rand_nt.c:6
#define LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, list, type, field)
Definition: list.h:204
#define alloc
Definition: rosglue.h:13
#define HeapFree(x, y, z)
Definition: compat.h:594
struct list entry
Definition: storage.c:38

Referenced by dwarf2_parse_compilation_unit(), elf_load_debug_info(), macho_load_debug_info(), module_remove(), pev_free(), and rsym_parse().

◆ pool_init()

void pool_init ( struct pool a,
size_t  arena_size 
)

Definition at line 43 of file storage.c.

44 {
45  list_init( &a->arena_list );
46  list_init( &a->arena_full );
47  a->arena_size = arena_size;
48 }
__WINE_SERVER_LIST_INLINE void list_init(struct list *list)
Definition: list.h:149
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204

Referenced by dwarf2_parse_compilation_unit(), elf_load_debug_info(), macho_load_debug_info(), module_new(), pev_init(), and rsym_parse().

◆ pool_strdup()

char* pool_strdup ( struct pool a,
const char str 
)

Definition at line 126 of file storage.c.

127 {
128  char* ret;
129  if ((ret = pool_alloc(pool, strlen(str) + 1))) strcpy(ret, str);
130  return ret;
131 }
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
const WCHAR * str
void * pool_alloc(struct pool *pool, size_t len)
Definition: storage.c:89
int ret
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388

Referenced by dwarf2_parse_variable(), macho_stabs_def_cb(), pev_push(), pev_set_value(), symt_add_enum_element(), symt_add_func_local(), symt_add_function_point(), symt_add_udt_element(), symt_new_basic(), symt_new_constant(), symt_new_enum(), symt_new_function(), symt_new_global_variable(), symt_new_label(), symt_new_public(), symt_new_thunk(), symt_new_typedef(), symt_new_udt(), and symt_ptr2index().

◆ process_find_by_handle()

◆ process_getenv()

const WCHAR* process_getenv ( const struct process process,
const WCHAR name 
)

Definition at line 285 of file dbghelp.c.

286 {
287  size_t name_len;
288  const WCHAR *iter;
289 
290  if (!process->environment) return NULL;
291  name_len = lstrlenW(name);
292 
293  for (iter = process->environment; *iter; iter += lstrlenW(iter) + 1)
294  {
295  if (!wcsnicmp(iter, name, name_len) && iter[name_len] == '=')
296  return iter + name_len + 1;
297  }
298 
299  return NULL;
300 }
#define lstrlenW
Definition: compat.h:609
WCHAR * environment
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define wcsnicmp
Definition: compat.h:14
#define NULL
Definition: types.h:112
Definition: name.c:38

Referenced by elf_search_and_load_file(), macho_search_and_load_file(), and search_dll_path().

◆ read_process_memory()

static BOOL read_process_memory ( const struct process process,
UINT64  addr,
void buf,
size_t  size 
)
inlinestatic

Definition at line 451 of file dbghelp_private.h.

452 {
453  return ReadProcessMemory(process->handle, (void*)(UINT_PTR)addr, buf, size, NULL);
454 }
#define ReadProcessMemory(a, b, c, d, e)
Definition: compat.h:617
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLsizeiptr size
Definition: glext.h:5919
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
GLenum const GLvoid * addr
Definition: glext.h:9621
#define NULL
Definition: types.h:112
HANDLE handle

Referenced by check_live_target(), dump_memory64_info(), dump_memory_info(), elf_enum_modules_internal(), image_uses_split_segs(), macho_enum_modules_internal(), macho_search_loader(), and x86_64_fetch_minidump_module().

◆ rsym_parse()

BOOL rsym_parse ( struct module module,
unsigned long  load_offset,
const void rsym,
int  rsymlen 
)

Definition at line 79 of file rsym.c.

81 {
82  const ROSSYM_HEADER* RosSymHeader;
83  const ROSSYM_ENTRY* First, *Last, *Entry;
84  const CHAR* Strings;
85 
86  struct pool pool;
87  struct sparse_array file_table, func_table;
88  rsym_func_entry_t* first_func = NULL;
89 
90 
91  RosSymHeader = rsym_ptr;
92 
93  if (RosSymHeader->SymbolsOffset < sizeof(ROSSYM_HEADER)
94  || RosSymHeader->StringsOffset < RosSymHeader->SymbolsOffset + RosSymHeader->SymbolsLength
95  || rsymlen < RosSymHeader->StringsOffset + RosSymHeader->StringsLength
96  || 0 != (RosSymHeader->SymbolsLength % sizeof(ROSSYM_ENTRY)))
97  {
98  WARN("Invalid ROSSYM_HEADER\n");
99  return FALSE;
100  }
101 
102  First = (const ROSSYM_ENTRY *)((const char*)rsym_ptr + RosSymHeader->SymbolsOffset);
103  Last = First + RosSymHeader->SymbolsLength / sizeof(ROSSYM_ENTRY);
104  Strings = (const CHAR*)rsym_ptr + RosSymHeader->StringsOffset;
105 
106  pool_init(&pool, 65536);
107  sparse_array_init(&file_table, sizeof(rsym_file_entry_t), 64);
108  sparse_array_init(&func_table, sizeof(rsym_func_entry_t), 128);
109 
110  for (Entry = First; Entry != Last; Entry++)
111  {
112  ULONG Address = load_offset + Entry->Address;
113  if (!Entry->FileOffset)
114  {
115  rsym_func_entry_t* func = sparse_array_find(&func_table, Entry->FunctionOffset);
116 
117  /* We do not want to define a data point where there is already a function! */
118  if (!func || func->Address != Address)
119  {
120  const char* SymbolName = Strings + Entry->FunctionOffset;
121  if (!is_metadata_sym(SymbolName))
122  {
123  /* TODO: How should we determine the size? */
124  ULONG Size = sizeof(ULONG);
125  if (use_raw_address(SymbolName))
126  Address = Entry->Address;
127 
128  symt_new_public(module, NULL, SymbolName, FALSE, Address, Size);
129  }
130  else
131  {
132  /* Maybe use it to fill some metadata? */
133  }
134  }
135  }
136  else
137  {
138  rsym_file_entry_t* file = sparse_array_find(&file_table, Entry->FileOffset);
139  rsym_func_entry_t* func = sparse_array_find(&func_table, Entry->FunctionOffset);
140 
141  if (!file)
142  {
143  file = sparse_array_add(&file_table, Entry->FileOffset, &pool);
144  file->File = Strings + Entry->FileOffset;
145  file->Source = source_new(module, NULL, Strings + Entry->FileOffset);
146  }
147 
148  if (!func)
149  {
150  func = sparse_array_add(&func_table, Entry->FunctionOffset, &pool);
151  func->func = symt_new_function(module, NULL, Strings + Entry->FunctionOffset,
152  Address, 0, NULL);
153  func->Address = Address;
154  func->next = first_func;
155  first_func = func;
156  }
157 
158  /* TODO: What if we have multiple chunks scattered around? */
159  symt_add_func_line(module, func->func, file->Source, Entry->SourceLine, Address - func->Address);
160  }
161  }
162 
163  while (first_func)
164  {
165  /* TODO: Size of function? */
166  rsym_finalize_function(module, first_func->func);
167  first_func = first_func->next;
168  }
169 
171  module->module.CVSig = 'R' | ('S' << 8) | ('Y' << 16) | ('M' << 24);
177 
178  pool_destroy(&pool);
179 
180  return TRUE;
181 }
static void rsym_finalize_function(struct module *module, struct symt_function *func)
Definition: rsym.c:37
GLenum func
Definition: glext.h:6028
struct symt_function * symt_new_function(struct module *module, struct symt_compiland *parent, const char *name, ULONG_PTR addr, ULONG_PTR size, struct symt *type) DECLSPEC_HIDDEN
Definition: symbol.c:293
Definition: compat.h:922
struct _Entry Entry
Definition: kefuncs.h:627
#define TRUE
Definition: types.h:120
char CHAR
Definition: xmlstorage.h:175
#define WARN(fmt,...)
Definition: debug.h:112
Definition: rsym.c:15
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
Definition: rossym.h:26
unsigned long StringsOffset
Definition: rossym.h:22
WCHAR First[]
Definition: FormatMessage.c:11
#define FALSE
Definition: types.h:117
static WCHAR Address[46]
Definition: ping.c:68
void * sparse_array_add(struct sparse_array *sa, ULONG_PTR key, struct pool *pool) DECLSPEC_HIDDEN
Definition: storage.c:281
struct _ROSSYM_ENTRY ROSSYM_ENTRY
static int is_metadata_sym(const char *name)
Definition: rsym.c:58
void sparse_array_init(struct sparse_array *sa, unsigned elt_sz, unsigned bucket_sz) DECLSPEC_HIDDEN
Definition: storage.c:213
static const WCHAR Strings[]
Definition: reg.c:35
void pool_init(struct pool *a, size_t arena_size) DECLSPEC_HIDDEN
Definition: storage.c:43
SYM_TYPE SymType
Definition: compat.h:934
struct symt_public * symt_new_public(struct module *module, struct symt_compiland *parent, const char *typename, BOOL is_function, ULONG_PTR address, unsigned size) DECLSPEC_HIDDEN
Definition: symbol.c:224
void * sparse_array_find(const struct sparse_array *sa, ULONG_PTR idx) DECLSPEC_HIDDEN
Definition: storage.c:271
static int use_raw_address(const char *name)
Definition: rsym.c:64
unsigned long StringsLength
Definition: rossym.h:23
void pool_destroy(struct pool *a) DECLSPEC_HIDDEN
Definition: storage.c:50
void symt_add_func_line(struct module *module, struct symt_function *func, unsigned source_idx, int line_num, ULONG_PTR offset) DECLSPEC_HIDDEN
Definition: symbol.c:326
#define NULL
Definition: types.h:112
unsigned source_new(struct module *module, const char *basedir, const char *source) DECLSPEC_HIDDEN
Definition: source.c:66
unsigned long SymbolsLength
Definition: rossym.h:21
unsigned int ULONG
Definition: retypes.h:1
unsigned long SymbolsOffset
Definition: rossym.h:20
IMAGEHLP_MODULEW64 module
Definition: rsym.c:21
base of all file and directory entries
Definition: entries.h:82
Definition: fci.c:126

Referenced by pe_load_rsym().

◆ search_dll_path()

BOOL search_dll_path ( const struct process process,
const WCHAR name,
BOOL(*)(void *, HANDLE, const WCHAR *)  match,
void param 
)

Definition at line 695 of file path.c.

696 {
697  const WCHAR *env;
698  size_t len, i;
699  HANDLE file;
700  WCHAR *buf;
701  BOOL ret;
702 
703  name = file_name(name);
704 
705  if ((env = process_getenv(process, L"WINEBUILDDIR")))
706  {
707  WCHAR *p, *end;
708  const WCHAR dllsW[] = { '\\','d','l','l','s','\\' };
709  const WCHAR programsW[] = { '\\','p','r','o','g','r','a','m','s','\\' };
710  const WCHAR dot_dllW[] = {'.','d','l','l',0};
711  const WCHAR dot_exeW[] = {'.','e','x','e',0};
712  const WCHAR dot_soW[] = {'.','s','o',0};
713 
714 
715  len = lstrlenW(env);
716  if (!(buf = heap_alloc((len + 8 + 3 * lstrlenW(name)) * sizeof(WCHAR)))) return FALSE;
717  wcscpy(buf, env);
718  end = buf + len;
719 
720  memcpy(end, dllsW, sizeof(dllsW));
721  lstrcpyW(end + ARRAY_SIZE(dllsW), name);
722  if ((p = wcsrchr(end, '.')) && !lstrcmpW(p, dot_soW)) *p = 0;
723  if ((p = wcsrchr(end, '.')) && !lstrcmpW(p, dot_dllW)) *p = 0;
724  p = end + lstrlenW(end);
725  *p++ = '\\';
726  lstrcpyW(p, name);
728  if (file != INVALID_HANDLE_VALUE)
729  {
730  ret = match(param, file, buf);
731  CloseHandle(file);
732  if (ret) goto found;
733  }
734 
735  memcpy(end, programsW, sizeof(programsW));
736  end += ARRAY_SIZE(programsW);
737  lstrcpyW(end, name);
738  if ((p = wcsrchr(end, '.')) && !lstrcmpW(p, dot_soW)) *p = 0;
739  if ((p = wcsrchr(end, '.')) && !lstrcmpW(p, dot_exeW)) *p = 0;
740  p = end + lstrlenW(end);
741  *p++ = '\\';
742  lstrcpyW(p, name);
744  if (file != INVALID_HANDLE_VALUE)
745  {
746  ret = match(param, file, buf);
747  CloseHandle(file);
748  if (ret) goto found;
749  }
750 
751  heap_free(buf);
752  }
753 
754  for (i = 0;; i++)
755  {
756  WCHAR env_name[64];
757  swprintf(env_name, ARRAY_SIZE(env_name), L"WINEDLLDIR%u", i);
758  if (!(env = process_getenv(process, env_name))) return FALSE;
759  len = wcslen(env) + wcslen(name) + 2;
760  if (!(buf = heap_alloc(len * sizeof(WCHAR)))) return FALSE;
761  swprintf(buf, len, L"%s\\%s", env, name);
763  if (file != INVALID_HANDLE_VALUE)
764  {
765  ret = match(param, file, buf);
766  CloseHandle(file);
767  if (ret) goto found;
768  }
769  heap_free(buf);
770  }
771 
772  return FALSE;
773 
774 found:
775  TRACE("found %s\n", debugstr_w(buf));
776  heap_free(buf);
777  return TRUE;
778 }
#define CloseHandle
Definition: compat.h:598
#define TRUE
Definition: types.h:120
int WINAPI lstrcmpW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:170
#define INVALID_HANDLE_VALUE
Definition: compat.h:590
const WCHAR * file_name(const WCHAR *str)
Definition: path.c:45
#define lstrlenW
Definition: compat.h:609
DWORD ret
Definition: path.c:47
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
#define FILE_SHARE_READ
Definition: compat.h:136
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define debugstr_w
Definition: kernel32.h:32
struct match match
Definition: match.c:33
#define OPEN_EXISTING
Definition: compat.h:634
#define TRACE(s)
Definition: solgame.cpp:4
const WCHAR * process_getenv(const struct process *process, const WCHAR *name)
Definition: dbghelp.c:285
__wchar_t WCHAR
Definition: xmlstorage.h:180
GLfloat param
Definition: glext.h:5796
#define swprintf(buf, format,...)
Definition: sprintf.c:56
const char file[]
Definition: icontest.c:11
GLuint GLuint end
Definition: gl.h:1545
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
static const WCHAR L[]
Definition: oid.c:1250
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
#define GENERIC_READ
Definition: compat.h:135
#define wcsrchr
Definition: compat.h:16
#define lstrcpyW
Definition: compat.h:608
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble