From: Eric Pouech epouech@codeweavers.com
Signed-off-by: Eric Pouech epouech@codeweavers.com --- dlls/dbghelp/dbghelp_private.h | 17 ++-- dlls/dbghelp/module.c | 8 -- dlls/dbghelp/msc.c | 149 ++++++++++++--------------------- dlls/dbghelp/pdb.c | 101 ++++++++++++++-------- 4 files changed, 130 insertions(+), 145 deletions(-)
diff --git a/dlls/dbghelp/dbghelp_private.h b/dlls/dbghelp/dbghelp_private.h index 522c7ba595d..62019889fe1 100644 --- a/dlls/dbghelp/dbghelp_private.h +++ b/dlls/dbghelp/dbghelp_private.h @@ -414,6 +414,7 @@ enum format_info DFI_PE, DFI_MACHO, DFI_DWARF, + DFI_PDB, DFI_OLD_PDB, DFI_LAST }; @@ -479,6 +480,7 @@ struct module_format struct pe_module_info* pe_info; struct macho_module_info* macho_info; struct old_pdb_module_info* old_pdb_info; + struct pdb_module_info* pdb_info; } u; };
@@ -503,7 +505,12 @@ struct module /* specific information for debug types */ struct module_format* format_info[DFI_LAST]; unsigned debug_format_bitmask; - struct module_format *ops_symref_modfmt; /* HACK for fast access to the ops table */ + /* Hack for fast symdef deref... + * Note: if ever we need another backend with dedicated symref_t support, + * we could always use the 3 non-zero lower bits of symref_t to match a + * debug backend. + */ + struct module_format *ops_symref_modfmt;
/* memory allocation pool */ struct pool pool; @@ -843,6 +850,8 @@ extern const WCHAR* file_name(const WCHAR* str); extern const char* file_nameA(const char* str);
/* pdb.c */ +extern BOOL pdb_init_modfmt(const struct process *pcs, const struct msc_debug_info *msc_dbg, + const WCHAR *filename, BOOL *has_linenumber_info); extern BOOL pdb_virtual_unwind(struct cpu_stack_walk *csw, DWORD_PTR ip, union ctx *context); struct _PDB_FPO_DATA; extern BOOL pdb_fpo_unwind_parse_cmd_string(struct cpu_stack_walk* csw, struct _PDB_FPO_DATA* fpoext, @@ -1087,9 +1096,3 @@ extern struct symt_function* #define IFC_MODE(x) ((x) & ~IFC_DEPTH_MASK) #define IFC_DEPTH(x) ((x) & IFC_DEPTH_MASK)
-/* temporary helpers for PDB rewriting */ -struct pdb_reader; -extern BOOL pdb_hack_get_main_info(struct module_format *modfmt, struct pdb_reader **pdb, unsigned *fpoext_stream); -extern void pdb_reader_dispose(struct pdb_reader *pdb); -extern struct pdb_reader *pdb_hack_reader_init(struct module *module, HANDLE file, const IMAGE_SECTION_HEADER *sections, unsigned num_sections); -extern BOOL cv_hack_ptr_to_symref(struct pdb_reader *pdb, unsigned typeno, symref_t *symref); diff --git a/dlls/dbghelp/module.c b/dlls/dbghelp/module.c index f3dc9f34a62..3f009b6b1ef 100644 --- a/dlls/dbghelp/module.c +++ b/dlls/dbghelp/module.c @@ -346,14 +346,6 @@ BOOL module_load_debug(struct module* module) } else ret = module->process->loader->load_debug_info(module->process, module);
- /* Hack for fast symdef deref... - * Note: if ever we need another backend with dedicated symref_t support, - * we could always use the 3 non-zero lower bits of symref_t to match a - * debug backend. - */ - if (module->format_info[DFI_OLD_PDB] && module->format_info[DFI_OLD_PDB]->vtable) - module->ops_symref_modfmt = module->format_info[DFI_OLD_PDB]; - if (!ret) module->module.SymType = SymNone; assert(module->module.SymType != SymDeferred); module->module.NumSyms = module->ht_symbols.num_elts; diff --git a/dlls/dbghelp/msc.c b/dlls/dbghelp/msc.c index 296286d5807..43ee8509a0d 100644 --- a/dlls/dbghelp/msc.c +++ b/dlls/dbghelp/msc.c @@ -61,7 +61,6 @@ enum pdb_kind {PDB_JG, PDB_DS}; struct pdb_file_info { enum pdb_kind kind; - struct pdb_reader *pdb_reader; /* new pdb reader */ const char* image; struct pdb_stream_name* stream_dict; unsigned fpoext_stream; @@ -96,18 +95,6 @@ struct cv_module_snarf const PDB_STRING_TABLE* strimage; };
-BOOL pdb_hack_get_main_info(struct module_format *modfmt, struct pdb_reader **pdb, unsigned *fpoext_stream) -{ - struct old_pdb_module_info* pdb_info; - - if (!modfmt) return FALSE; - pdb_info = modfmt->u.old_pdb_info; - *pdb = pdb_info->pdb_files[0].pdb_reader; - if (fpoext_stream) - *fpoext_stream = pdb_info->pdb_files[0].fpoext_stream; - return TRUE; -} - /*======================================================================== * Debug file access helper routines */ @@ -149,7 +136,6 @@ struct cv_defined_module unsigned int first_type_index; unsigned int last_type_index; struct symt** defined_types; /* when old reader */ - struct pdb_reader *pdb; /* new reader: hack */ }; /* FIXME: don't make it static */ #define CV_MAX_MODULES 32 @@ -666,25 +652,12 @@ static struct symt* codeview_fetch_type(struct codeview_type_parse* ctp,
static symref_t codeview_fetch_symref(struct codeview_type_parse* ctp, unsigned typeno) { - symref_t symref; - - if (!cv_hack_ptr_to_symref(ctp->module->format_info[DFI_OLD_PDB]->u.old_pdb_info->pdb_files[0].pdb_reader, typeno, &symref)) - { - symref = symt_ptr_to_symref(codeview_fetch_type(ctp, typeno)); - } - - return symref; + return symt_ptr_to_symref(codeview_fetch_type(ctp, typeno)); }
static symref_t codeview_get_symref(struct module *module, unsigned typeno) { - symref_t symref; - - if (!cv_hack_ptr_to_symref(module->format_info[DFI_OLD_PDB]->u.old_pdb_info->pdb_files[0].pdb_reader, typeno, &symref)) - { - symref = symt_ptr_to_symref(codeview_get_type(typeno, TRUE)); - } - return symref; + return symt_ptr_to_symref(codeview_get_type(typeno, TRUE)); }
static UINT32 codeview_compute_hash(const char* ptr, unsigned len) @@ -1548,7 +1521,6 @@ static BOOL codeview_parse_type_table(struct codeview_type_parse* ctp) unsigned int i, curr_type; const union codeview_type* type;
- cv_current_module->pdb = ctp->module->format_info[DFI_OLD_PDB]->u.old_pdb_info->pdb_files[0].pdb_reader; cv_current_module->first_type_index = ctp->header.first_index; cv_current_module->last_type_index = ctp->header.last_index; cv_current_module->defined_types = calloc(ctp->header.last_index - ctp->header.first_index, @@ -2329,7 +2301,6 @@ static struct symt_compiland* codeview_new_compiland(const struct msc_debug_info }
static BOOL codeview_snarf(const struct msc_debug_info* msc_dbg, - unsigned stream_id, const BYTE* root, unsigned offset, unsigned size, const struct cv_module_snarf* cvmod, const char* objname) @@ -2720,15 +2691,7 @@ static BOOL codeview_snarf(const struct msc_debug_info* msc_dbg, */ if (!sym->local_v3.varflags.enreg_global && !sym->local_v3.varflags.enreg_static) { - if (stream_id) - { - loc.kind = loc_user + 1 /* loc_cv_defrange for new PDB reader (see pdb.c) */; - loc.reg = stream_id; - loc.offset = (const BYTE*)sym - root; - length += codeview_defrange_length(sym); - } - else - length += codeview_transform_defrange(msc_dbg, curr_func, sym, &loc); + length += codeview_transform_defrange(msc_dbg, curr_func, sym, &loc); symt_add_func_local(msc_dbg->module, curr_func, sym->local_v3.varflags.is_param ? DataIsParam : DataIsLocal, &loc, block, @@ -3209,7 +3172,7 @@ static void pdb_free(void* buffer) HeapFree(GetProcessHeap(), 0, buffer); }
-static void pdb_free_file(struct pdb_file_info* pdb_file, BOOL unmap) +static void pdb_free_file(struct pdb_file_info* pdb_file) { switch (pdb_file->kind) { @@ -3224,11 +3187,8 @@ static void pdb_free_file(struct pdb_file_info* pdb_file, BOOL unmap) } HeapFree(GetProcessHeap(), 0, pdb_file->stream_dict); pdb_file->stream_dict = NULL; - if (unmap) - { - UnmapViewOfFile(pdb_file->image); - pdb_file->image = NULL; - } + UnmapViewOfFile(pdb_file->image); + pdb_file->image = NULL; }
static struct pdb_stream_name* pdb_load_stream_name_table(const char* str, unsigned cb) @@ -3308,11 +3268,9 @@ static void pdb_module_remove(struct module_format* modfmt)
for (i = 0; i < modfmt->u.old_pdb_info->used_subfiles; i++) { - pdb_free_file(&modfmt->u.old_pdb_info->pdb_files[i], TRUE); + pdb_free_file(&modfmt->u.old_pdb_info->pdb_files[i]); if (modfmt->u.old_pdb_info->pdb_files[i].image) UnmapViewOfFile(modfmt->u.old_pdb_info->pdb_files[i].image); - if (modfmt->u.old_pdb_info->pdb_files[i].pdb_reader) - pdb_reader_dispose(modfmt->u.old_pdb_info->pdb_files[i].pdb_reader); } HeapFree(GetProcessHeap(), 0, modfmt); } @@ -3839,22 +3797,11 @@ static BOOL pdb_process_internal(const struct process *pcs, return FALSE; }
+ CloseHandle(hFile); CloseHandle(hMap); /* old pdb reader */ if (!pdb_init(pdb_file, image)) { - CloseHandle(hFile); - UnmapViewOfFile(image); - return FALSE; - } - if (getenv("WINE_DBGHELP_OLD_PDB")) /* keep using old pdb reader */ - { - pdb_file->pdb_reader = NULL; - CloseHandle(hFile); - } - else if (!(pdb_file->pdb_reader = pdb_hack_reader_init(msc_dbg->module, hFile, msc_dbg->sectp, msc_dbg->nsect))) - { - CloseHandle(hFile); UnmapViewOfFile(image); return FALSE; } @@ -3899,10 +3846,7 @@ static BOOL pdb_process_internal(const struct process *pcs,
pdb_process_symbol_imports(pcs, msc_dbg, &symbols, symbols_image, image, pdb_module_info, module_index); - if (!pdb_file->pdb_reader) - { - pdb_process_types(msc_dbg, pdb_file); - } + pdb_process_types(msc_dbg, pdb_file);
ipi_image = pdb_read_stream(pdb_file, 4); ipi_ok = pdb_init_type_parse(msc_dbg, pdb_file, &ipi_ctp, ipi_image); @@ -3911,7 +3855,7 @@ static BOOL pdb_process_internal(const struct process *pcs, * streams' loading can succeed them. */ globalimage = pdb_read_stream(pdb_file, symbols.gsym_stream); - if (globalimage && !pdb_file->pdb_reader) + if (globalimage) { const BYTE* data; unsigned global_size = pdb_get_stream_size(pdb_file, symbols.gsym_stream); @@ -3929,7 +3873,6 @@ static BOOL pdb_process_internal(const struct process *pcs,
/* Read per-module symbols' tables */ file = symbols_image + header_size; - if (pdb_file->pdb_reader) file += symbols.module_size; /* skip it */ while (file - symbols_image < header_size + symbols.module_size) { PDB_SYMBOL_FILE_EX sfile; @@ -3945,22 +3888,19 @@ static BOOL pdb_process_internal(const struct process *pcs, { struct cv_module_snarf cvmod = {ipi_ok ? &ipi_ctp : NULL, (const void*)(modimage + sfile.symbol_size), sfile.lineno2_size, files_image}; - codeview_snarf(msc_dbg, pdb_file->pdb_reader ? sfile.stream : 0, modimage, sizeof(DWORD), sfile.symbol_size, + codeview_snarf(msc_dbg, modimage, sizeof(DWORD), sfile.symbol_size, &cvmod, file_name);
if (sfile.lineno_size && sfile.lineno2_size) FIXME("Both line info present... preferring second\n"); if (sfile.lineno2_size) { - if (pdb_file->pdb_reader || - ((SymGetOptions() & SYMOPT_LOAD_LINES) && codeview_snarf_linetab2(msc_dbg, &cvmod))) + if (((SymGetOptions() & SYMOPT_LOAD_LINES) && codeview_snarf_linetab2(msc_dbg, &cvmod))) *has_linenumber_info = TRUE; } else if (sfile.lineno_size) { - if (pdb_file->pdb_reader) - FIXME("New PDB reader doesn't support old line format\n"); - else if ((SymGetOptions() & SYMOPT_LOAD_LINES) && + if ((SymGetOptions() & SYMOPT_LOAD_LINES) && codeview_snarf_linetab(msc_dbg, modimage + sfile.symbol_size, sfile.lineno_size, @@ -3974,7 +3914,7 @@ static BOOL pdb_process_internal(const struct process *pcs, file = (BYTE*)((DWORD_PTR)(file_name + strlen(file_name) + 1 + 3) & ~3); } /* Load the global variables and constants (if not yet loaded) and public information */ - if (globalimage && !pdb_file->pdb_reader) + if (globalimage) { const BYTE* data; unsigned global_size = pdb_get_stream_size(pdb_file, symbols.gsym_stream); @@ -4008,7 +3948,7 @@ static BOOL pdb_process_internal(const struct process *pcs, pdb_free(symbols_image); pdb_free(files_image);
- pdb_free_file(pdb_file, pdb_file->pdb_reader != NULL); + pdb_free_file(pdb_file);
return TRUE; } @@ -4025,33 +3965,52 @@ static const struct module_format_vtable old_pdb_module_format_vtable = pdb_location_compute, };
+static BOOL old_pdb_process_file(const struct process *pcs, + const struct msc_debug_info *msc_dbg, + const WCHAR *filename, BOOL *has_linenumber_info) +{ + struct module_format* modfmt; + struct old_pdb_module_info* pdb_module_info; + BOOL ret; + + if (!(modfmt = HeapAlloc(GetProcessHeap(), 0, + sizeof(struct module_format) + sizeof(struct old_pdb_module_info)))) + return FALSE; + + pdb_module_info = (void*)(modfmt + 1); + msc_dbg->module->format_info[DFI_OLD_PDB] = modfmt; + modfmt->module = msc_dbg->module; + modfmt->vtable = &old_pdb_module_format_vtable; + modfmt->u.old_pdb_info = pdb_module_info; + + memset(cv_zmodules, 0, sizeof(cv_zmodules)); + codeview_init_basic_types(msc_dbg->module); + ret = pdb_process_internal(pcs, msc_dbg, filename, + msc_dbg->module->format_info[DFI_OLD_PDB]->u.old_pdb_info, -1, has_linenumber_info); + codeview_clear_type_table(); + if (!ret) + { + msc_dbg->module->format_info[DFI_OLD_PDB] = NULL; + HeapFree(GetProcessHeap(), 0, modfmt); + } + return ret; +} + static BOOL pdb_process_file(const struct process *pcs, const struct msc_debug_info *msc_dbg, const char *filename, const GUID *guid, DWORD timestamp, DWORD age) { - struct module_format* modfmt; - struct old_pdb_module_info* pdb_module_info; SYMSRV_INDEX_INFOW info; - BOOL unmatched; + BOOL unmatched, has_linenumber_info, ret;
if (!msc_dbg->module->dont_load_symbols && - path_find_symbol_file(pcs, msc_dbg->module, filename, TRUE, guid, timestamp, age, &info, &unmatched) && - (modfmt = HeapAlloc(GetProcessHeap(), 0, - sizeof(struct module_format) + sizeof(struct old_pdb_module_info)))) + path_find_symbol_file(pcs, msc_dbg->module, filename, TRUE, guid, timestamp, age, &info, &unmatched)) { - BOOL ret, has_linenumber_info; - - pdb_module_info = (void*)(modfmt + 1); - msc_dbg->module->format_info[DFI_OLD_PDB] = modfmt; - modfmt->module = msc_dbg->module; - modfmt->vtable = &old_pdb_module_format_vtable; - modfmt->u.old_pdb_info = pdb_module_info; + if (getenv("WINE_DBGHELP_OLD_PDB")) /* keep using old pdb reader */ + ret = old_pdb_process_file(pcs, msc_dbg, info.pdbfile, &has_linenumber_info); + else + ret = pdb_init_modfmt(pcs, msc_dbg, info.pdbfile, &has_linenumber_info);
- memset(cv_zmodules, 0, sizeof(cv_zmodules)); - codeview_init_basic_types(msc_dbg->module); - ret = pdb_process_internal(pcs, msc_dbg, info.pdbfile, - msc_dbg->module->format_info[DFI_OLD_PDB]->u.old_pdb_info, -1, &has_linenumber_info); - codeview_clear_type_table(); if (ret) { msc_dbg->module->module.SymType = SymPdb; @@ -4070,8 +4029,6 @@ static BOOL pdb_process_file(const struct process *pcs,
return TRUE; } - msc_dbg->module->format_info[DFI_OLD_PDB] = NULL; - HeapFree(GetProcessHeap(), 0, modfmt); } msc_dbg->module->module.SymType = SymNone; if (guid) @@ -4151,7 +4108,7 @@ static BOOL codeview_process_info(const struct process *pcs,
if (ent->SubSection == sstAlignSym) { - codeview_snarf(msc_dbg, 0, msc_dbg->root + ent->lfo, sizeof(DWORD), ent->cb, NULL, NULL); + codeview_snarf(msc_dbg, msc_dbg->root + ent->lfo, sizeof(DWORD), ent->cb, NULL, NULL);
if (SymGetOptions() & SYMOPT_LOAD_LINES) { diff --git a/dlls/dbghelp/pdb.c b/dlls/dbghelp/pdb.c index d046effb9bb..c4f4319de43 100644 --- a/dlls/dbghelp/pdb.c +++ b/dlls/dbghelp/pdb.c @@ -510,7 +510,7 @@ static enum pdb_result pdb_reader_init(struct pdb_reader *pdb, struct module *mo pdb->streams[i].name = NULL; } /* hack (must be set before loading debug info so it can be used therein) */ - pdb->module->ops_symref_modfmt = module->format_info[DFI_OLD_PDB]; + pdb->module->ops_symref_modfmt = module->format_info[DFI_PDB]; pdb_reader_init_DBI(pdb);
return R_PDB_SUCCESS; @@ -522,7 +522,7 @@ failure: return result; }
-void pdb_reader_dispose(struct pdb_reader *pdb) +static void pdb_reader_dispose(struct pdb_reader *pdb) { CloseHandle(pdb->file); /* note: pdb is allocated inside its pool, so this must be last line */ @@ -1051,6 +1051,16 @@ static enum pdb_result pdb_reader_get_line_from_address_internal(struct pdb_read return R_PDB_NOT_FOUND; }
+struct pdb_module_info +{ + struct pdb_reader pdb_reader; +}; + +static inline struct pdb_reader *pdb_get_current_reader(const struct module_format *modfmt) +{ + return &modfmt->u.pdb_info->pdb_reader; +} + static enum method_result pdb_method_result(enum pdb_result result) { switch (result) @@ -1068,7 +1078,7 @@ static enum method_result pdb_method_get_line_from_address(struct module_format struct pdb_reader *pdb; pdbsize_t compiland_offset;
- if (!pdb_hack_get_main_info(modfmt, &pdb, NULL)) return MR_FAILURE; + pdb = pdb_get_current_reader(modfmt); result = pdb_reader_get_line_from_address_internal(pdb, address, line_info, &compiland_offset); return pdb_method_result(result); } @@ -1142,7 +1152,7 @@ static enum method_result pdb_method_advance_line_info(struct module_format *mod { struct pdb_reader *pdb;
- if (!pdb_hack_get_main_info(modfmt, &pdb, NULL)) return MR_FAILURE; + pdb = pdb_get_current_reader(modfmt); return pdb_reader_advance_line_info(pdb, line_info, forward) == R_PDB_SUCCESS ? MR_SUCCESS : MR_FAILURE; }
@@ -1261,8 +1271,7 @@ static enum method_result pdb_method_enumerate_lines(struct module_format *modfm { struct pdb_reader *pdb;
- if (!pdb_hack_get_main_info(modfmt, &pdb, NULL)) return MR_FAILURE; - + pdb = pdb_get_current_reader(modfmt); return pdb_method_result(pdb_method_enumerate_lines_internal(pdb, compiland_regex, source_file_regex, cb, user)); }
@@ -1308,7 +1317,7 @@ static enum method_result pdb_method_enumerate_sources(struct module_format *mod { struct pdb_reader *pdb;
- if (!pdb_hack_get_main_info(modfmt, &pdb, NULL)) return MR_FAILURE; + pdb = pdb_get_current_reader(modfmt);
/* Note: in PDB, each compiland lists its used files, which are all in global string table, * but there's no global source files table AFAICT. @@ -1975,7 +1984,7 @@ static void pdb_method_location_compute(const struct module_format* modfmt, loc->kind = loc_error; loc->reg = loc_err_internal;
- if (!pdb_hack_get_main_info((struct module_format *)modfmt, &pdb, NULL)) return; + pdb = pdb_get_current_reader(modfmt); if (in_loc.kind != loc_cv_defrange || pdb_reader_walker_init(pdb, in_loc.reg, &walker)) return; walker.offset = in_loc.offset;
@@ -2582,7 +2591,7 @@ static enum method_result pdb_method_find_type(struct module_format *modfmt, con struct pdb_type_details *type_details; pdbsize_t stream_offset;
- if (!pdb_hack_get_main_info(modfmt, &pdb, NULL)) return MR_FAILURE; + pdb = pdb_get_current_reader(modfmt); if ((result = pdb_reader_init_TPI(pdb))) return pdb_method_result(result); /* search in TPI hash table */ if ((result = pdb_reader_read_codeview_type_by_name(pdb, name, &walker, &cv_type, &cv_typeid)) == R_PDB_SUCCESS) @@ -2706,7 +2715,7 @@ static enum method_result pdb_method_enumerate_types(struct module_format *modfm VARIANT v; BOOL ret;
- if (!pdb_hack_get_main_info(modfmt, &pdb, NULL)) return MR_FAILURE; + pdb = pdb_get_current_reader(modfmt); if ((result = pdb_reader_init_TPI(pdb))) return pdb_method_result(result); walker = pdb->tpi_types_walker; /* Note: walking the types through the hash table may not be the most efficient */ @@ -3598,7 +3607,7 @@ static enum method_result pdb_method_request_symref_t(struct module_format *modf { struct pdb_reader *pdb;
- if (!pdb_hack_get_main_info(modfmt, &pdb, NULL)) return MR_FAILURE; + pdb = pdb_get_current_reader(modfmt); if (pdb_reader_init_TPI(pdb)) return MR_FAILURE; return pdb_reader_request_symref_t(pdb, symref, req, data); } @@ -4047,8 +4056,7 @@ static enum method_result pdb_method_get_line_from_inlined_address(struct module { struct pdb_reader *pdb;
- if (!pdb_hack_get_main_info(modfmt, &pdb, NULL)) return MR_FAILURE; - + pdb = pdb_get_current_reader(modfmt); return pdb_method_result(pdb_method_get_line_from_inlined_address_internal(pdb, inlined, address, line_info)); }
@@ -4662,7 +4670,7 @@ static enum method_result pdb_method_lookup_symbol_by_address(struct module_form struct pdb_reader *pdb; unsigned segment, offset;
- if (!pdb_hack_get_main_info(modfmt, &pdb, NULL)) return MR_FAILURE; + pdb = pdb_get_current_reader(modfmt); if ((result = pdb_reader_get_segment_offset_from_address(pdb, address, &segment, &offset))) return MR_FAILURE; return pdb_method_result(pdb_reader_lookup_top_symbol_by_segment_offset(pdb, segment, offset, symref)); } @@ -4717,7 +4725,7 @@ static enum method_result pdb_method_lookup_symbol_by_name(struct module_format unsigned segment; unsigned offset;
- if (!pdb_hack_get_main_info(modfmt, &pdb, NULL)) return MR_FAILURE; + pdb = pdb_get_current_reader(modfmt);
if ((result = pdb_reader_read_DBI_codeview_symbol_by_name(pdb, name, &globals_offset, &cv_symbol))) return pdb_method_result(result); @@ -4756,7 +4764,7 @@ static enum method_result pdb_method_enumerate_symbols(struct module_format *mod unsigned offset; char *symbol_name;
- if (!pdb_hack_get_main_info(modfmt, &pdb, NULL)) return MR_FAILURE; + pdb = pdb_get_current_reader(modfmt);
/* FIXME could be optimized if match doesn't contain wild cards */ /* this is currently ugly, but basically we just ensure that all the compilands which contain matching symbols @@ -4813,9 +4821,15 @@ static enum method_result pdb_method_enumerate_symbols(struct module_format *mod return MR_FAILURE; }
+static void pdb_module_remove(struct module_format* modfmt) +{ + pdb_reader_dispose(&modfmt->u.pdb_info->pdb_reader); + HeapFree(GetProcessHeap(), 0, modfmt); +} + static struct module_format_vtable pdb_module_format_vtable = { - NULL,/*pdb_module_remove*/ + pdb_module_remove, pdb_method_request_symref_t, pdb_method_lookup_symbol_by_address, pdb_method_lookup_symbol_by_name, @@ -4830,24 +4844,44 @@ static struct module_format_vtable pdb_module_format_vtable = pdb_method_enumerate_sources, };
-struct pdb_reader *pdb_hack_reader_init(struct module *module, HANDLE file, const IMAGE_SECTION_HEADER *sections, unsigned num_sections) +BOOL pdb_init_modfmt(const struct process *pcs, + const struct msc_debug_info *msc_dbg, + const WCHAR *filename, BOOL *has_linenumber_info) { - struct pdb_reader *pdb = pool_alloc(&module->pool, sizeof(*pdb) + num_sections * sizeof(*sections)); - if (pdb) + struct module_format *modfmt; + struct pdb_module_info *pdb_module_info; + IMAGE_SECTION_HEADER *new_sections; + HANDLE file; + + if (!(modfmt = HeapAlloc(GetProcessHeap(), 0, + sizeof(struct module_format) + sizeof(struct pdb_module_info) + msc_dbg->nsect * sizeof(msc_dbg->sectp[0])))) + return FALSE; + + if ((file = CreateFileW(filename, GENERIC_READ, FILE_SHARE_READ, NULL, + OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) { - IMAGE_SECTION_HEADER *new_sections = (void*)(pdb + 1); - memcpy(new_sections, sections, num_sections * sizeof(*sections)); - if (pdb_reader_init(pdb, module, file, new_sections, num_sections) == R_PDB_SUCCESS) - { - /* hack (copy old pdb methods until they are moved here) */ - pdb_module_format_vtable.remove = module->format_info[DFI_OLD_PDB]->vtable->remove; + HeapFree(GetProcessHeap(), 0, modfmt); + return FALSE; + }
- module->format_info[DFI_OLD_PDB]->vtable = &pdb_module_format_vtable; - return pdb; - } + pdb_module_info = (void*)(modfmt + 1); + msc_dbg->module->format_info[DFI_PDB] = modfmt; + modfmt->module = msc_dbg->module; + modfmt->vtable = &pdb_module_format_vtable; + modfmt->u.pdb_info = pdb_module_info; + + new_sections = (void*)(pdb_module_info + 1); + memcpy(new_sections, msc_dbg->sectp, msc_dbg->nsect * sizeof(*new_sections)); + if (pdb_reader_init(&pdb_module_info->pdb_reader, msc_dbg->module, file, new_sections, msc_dbg->nsect) == R_PDB_SUCCESS) + { + /* FIXME */ + *has_linenumber_info = TRUE; + return TRUE; } - pool_free(&module->pool, pdb); - return NULL; + msc_dbg->module->format_info[DFI_PDB] = NULL; + HeapFree(GetProcessHeap(), 0, modfmt); + CloseHandle(file); + return FALSE; }
/*======================================================================== @@ -5178,9 +5212,8 @@ BOOL pdb_virtual_unwind(struct cpu_stack_walk *csw, DWORD_PTR ip, union ctx *con BOOL ret = FALSE;
if (!module_init_pair(&pair, csw->hProcess, ip)) return FALSE; - if (!pair.effective->format_info[DFI_OLD_PDB]) return FALSE; - if (!pdb_hack_get_main_info(pair.effective->format_info[DFI_OLD_PDB], &pdb, NULL)) return FALSE; - if (!pdb) return FALSE; + if (!pair.effective->format_info[DFI_PDB]) return FALSE; + pdb = pdb_get_current_reader(pair.effective->format_info[DFI_PDB]);
TRACE("searching %Ix => %Ix\n", ip, ip - (DWORD_PTR)pair.effective->module.BaseOfImage); ip -= (DWORD_PTR)pair.effective->module.BaseOfImage;