From: Eric Pouech epouech@codeweavers.com
Signed-off-by: Eric Pouech epouech@codeweavers.com --- dlls/dbghelp/coff.c | 9 ++++----- dlls/dbghelp/dbghelp_private.h | 9 +++++---- dlls/dbghelp/dwarf.c | 6 ++++-- dlls/dbghelp/elf_module.c | 13 ++++++------- dlls/dbghelp/msc.c | 5 ++--- dlls/dbghelp/pe_module.c | 2 +- dlls/dbghelp/source.c | 26 ++++++++++++++++---------- dlls/dbghelp/stabs.c | 2 +- dlls/dbghelp/symbol.c | 6 +++--- dlls/dbghelp/type.c | 3 +-- 10 files changed, 43 insertions(+), 38 deletions(-)
diff --git a/dlls/dbghelp/coff.c b/dlls/dbghelp/coff.c index 65ed3b7def2..d4d804d935e 100644 --- a/dlls/dbghelp/coff.c +++ b/dlls/dbghelp/coff.c @@ -114,7 +114,7 @@ static int coff_add_file(struct CoffFileSet* coff_files, struct module* module, file = coff_files->files + coff_files->nfiles; file->startaddr = 0xffffffff; file->endaddr = 0; - file->compiland = symt_new_compiland(module, source_new(module, NULL, filename)); + file->compiland = symt_new_compiland(module, filename); file->linetab_offset = -1; file->linecnt = 0; file->entries = NULL; @@ -218,8 +218,7 @@ BOOL coff_process_info(const struct msc_debug_info* msc_dbg) */ const char* fn;
- fn = source_get(msc_dbg->module, - coff_files.files[curr_file_idx].compiland->source); + fn = coff_files.files[curr_file_idx].compiland->filename;
TRACE("Duplicating sect from %s: %lx %x %x %d %d\n", fn, aux->Section.Length, @@ -241,7 +240,7 @@ BOOL coff_process_info(const struct msc_debug_info* msc_dbg) else { TRACE("New text sect from %s: %lx %x %x %d %d\n", - source_get(msc_dbg->module, coff_files.files[curr_file_idx].compiland->source), + coff_files.files[curr_file_idx].compiland->filename, aux->Section.Length, aux->Section.NumberOfRelocations, aux->Section.NumberOfLinenumbers, @@ -420,7 +419,7 @@ BOOL coff_process_info(const struct msc_debug_info* msc_dbg) { symt_add_func_line(msc_dbg->module, (struct symt_function*)coff_files.files[j].entries[l+1], - coff_files.files[j].compiland->source, + source_new(msc_dbg->module, NULL, coff_files.files[j].compiland->filename), linepnt->Linenumber, msc_dbg->module->module.BaseOfImage + linepnt->Type.VirtualAddress); } diff --git a/dlls/dbghelp/dbghelp_private.h b/dlls/dbghelp/dbghelp_private.h index 5576766fcfc..7b489f091fe 100644 --- a/dlls/dbghelp/dbghelp_private.h +++ b/dlls/dbghelp/dbghelp_private.h @@ -207,7 +207,7 @@ struct symt_compiland struct symt symt; struct symt_module* container; /* symt_module */ ULONG_PTR address; - unsigned source; + const char *filename; struct vector vchildren; /* global variables & functions */ void* user; /* when debug info provider needs to store information */ }; @@ -866,6 +866,7 @@ extern BOOL pe_has_buildid_debug(struct image_file_map *fmap, GUID *guid extern unsigned source_new(struct module* module, const char* basedir, const char* source); extern const char* source_get(const struct module* module, unsigned idx); extern int source_rb_compare(const void *key, const struct wine_rb_entry *entry); +extern char *source_build_path(const char *base, const char *name);
/* stabs.c */ typedef void (*stabs_def_cb)(struct module* module, ULONG_PTR load_offset, @@ -906,10 +907,10 @@ extern struct symt_ht* extern struct symt_module* symt_new_module(struct module* module); extern struct symt_compiland* - symt_new_compiland(struct module* module, unsigned src_idx); + symt_new_compiland(struct module* module, const char *filename); extern struct symt_public* - symt_new_public(struct module* module, - struct symt_compiland* parent, + symt_new_public(struct module* module, + struct symt_compiland* parent, const char* typename, BOOL is_function, ULONG_PTR address, diff --git a/dlls/dbghelp/dwarf.c b/dlls/dbghelp/dwarf.c index 831c56af63b..3e77da64d9c 100644 --- a/dlls/dbghelp/dwarf.c +++ b/dlls/dbghelp/dwarf.c @@ -3048,6 +3048,7 @@ static BOOL dwarf2_parse_compilation_unit(dwarf2_parse_context_t* ctx) struct attribute stmt_list, low_pc; struct attribute comp_dir; struct attribute language; + char *tmp;
if (!dwarf2_find_attribute(di, DW_AT_name, &name)) name.u.string = NULL; @@ -3064,8 +3065,9 @@ static BOOL dwarf2_parse_compilation_unit(dwarf2_parse_context_t* ctx)
ctx->language = language.u.uvalue;
- ctx->compiland = symt_new_compiland(ctx->module_ctx->module, - source_new(ctx->module_ctx->module, comp_dir.u.string, name.u.string)); + tmp = source_build_path(comp_dir.u.string, name.u.string); + ctx->compiland = symt_new_compiland(ctx->module_ctx->module, tmp); + HeapFree(GetProcessHeap(), 0, tmp); ctx->compiland->address = ctx->module_ctx->load_offset + low_pc.u.uvalue; dwarf2_cache_cuhead(ctx->module_ctx->module->format_info[DFI_DWARF]->u.dwarf2_info, ctx->compiland, &ctx->head); di->symt = &ctx->compiland->symt; diff --git a/dlls/dbghelp/elf_module.c b/dlls/dbghelp/elf_module.c index 8053f7a5a9a..dad0d459409 100644 --- a/dlls/dbghelp/elf_module.c +++ b/dlls/dbghelp/elf_module.c @@ -699,7 +699,7 @@ static void elf_hash_symtab(struct module* module, struct pool* pool, { case ELF_STT_FILE: if (symname) - compiland = symt_new_compiland(module, source_new(module, NULL, symname)); + compiland = symt_new_compiland(module, symname); else compiland = NULL; continue; @@ -778,12 +778,11 @@ static const struct elf_sym *elf_lookup_symtab(const struct module* module, */ if (compiland) { - compiland_name = source_get(module, - ((const struct symt_compiland*)compiland)->source); + compiland_name = ((const struct symt_compiland*)compiland)->filename; compiland_basename = file_nameA(compiland_name); } else compiland_name = compiland_basename = NULL; - + hash_table_iter_init(ht_symtab, &hti, name); while ((ste = hash_table_iter_up(&hti))) { @@ -794,7 +793,7 @@ static const struct elf_sym *elf_lookup_symtab(const struct module* module, continue; if (ste->compiland && compiland_name) { - const char* filename = source_get(module, ste->compiland->source); + const char* filename = ste->compiland->filename; if (strcmp(filename, compiland_name)) { base = file_nameA(filename); @@ -805,9 +804,9 @@ static const struct elf_sym *elf_lookup_symtab(const struct module* module, { FIXME("Already found symbol %s (%s) in symtab %s @%08x and %s @%08x\n", debugstr_a(name), debugstr_a(compiland_name), - debugstr_a(source_get(module, result->compiland->source)), + debugstr_a(result->compiland->filename), (unsigned int)result->sym.st_value, - debugstr_a(source_get(module, ste->compiland->source)), + debugstr_a(ste->compiland->filename), (unsigned int)ste->sym.st_value); } else diff --git a/dlls/dbghelp/msc.c b/dlls/dbghelp/msc.c index d9a4934696d..fbd7e29b531 100644 --- a/dlls/dbghelp/msc.c +++ b/dlls/dbghelp/msc.c @@ -2312,7 +2312,6 @@ static struct symt_function* codeview_create_inline_site(const struct msc_debug_
static struct symt_compiland* codeview_new_compiland(const struct msc_debug_info* msc_dbg, const char* objname) { - unsigned int src_idx = source_new(msc_dbg->module, NULL, objname); unsigned int i;
/* In some cases MSVC generates several compiland entries with same pathname in PDB file. @@ -2322,10 +2321,10 @@ static struct symt_compiland* codeview_new_compiland(const struct msc_debug_info for (i = 0; i < msc_dbg->module->top->vchildren.num_elts; i++) { struct symt_compiland** p = vector_at(&msc_dbg->module->top->vchildren, i); - if (symt_check_tag(&(*p)->symt, SymTagCompiland) && (*p)->source == src_idx) + if (symt_check_tag(&(*p)->symt, SymTagCompiland) && !strcmp((*p)->filename, objname)) return *p; } - return symt_new_compiland(msc_dbg->module, src_idx); + return symt_new_compiland(msc_dbg->module, objname); }
static BOOL codeview_snarf(const struct msc_debug_info* msc_dbg, diff --git a/dlls/dbghelp/pe_module.c b/dlls/dbghelp/pe_module.c index 1f2022fc1af..6b5a9a4b425 100644 --- a/dlls/dbghelp/pe_module.c +++ b/dlls/dbghelp/pe_module.c @@ -503,7 +503,7 @@ static BOOL pe_load_coff_symbol_table(struct module* module) if (name[0] == '_') name++;
if (!compiland && lastfilename) - compiland = symt_new_compiland(module, source_new(module, NULL, lastfilename)); + compiland = symt_new_compiland(module, lastfilename);
if (!(dbghelp_options & SYMOPT_NO_PUBLICS)) symt_new_public(module, compiland, name, FALSE, diff --git a/dlls/dbghelp/source.c b/dlls/dbghelp/source.c index 24ba224a499..79b4ff9989c 100644 --- a/dlls/dbghelp/source.c +++ b/dlls/dbghelp/source.c @@ -56,6 +56,21 @@ static unsigned source_find(const char* name) return WINE_RB_ENTRY_VALUE(e, struct source_rb, entry)->source; }
+char *source_build_path(const char *base, const char *name) +{ + char *dst; + unsigned bsz = strlen(base); + + dst = HeapAlloc(GetProcessHeap(), 0, bsz + 1 + strlen(name) + 1); + if (dst) + { + strcpy(dst, base); + if (bsz && dst[bsz - 1] != '/' && dst[bsz - 1] != '\') dst[bsz++] = '/'; + strcpy(&dst[bsz], name); + } + return dst; +} + /****************************************************************** * source_new * @@ -71,16 +86,7 @@ unsigned source_new(struct module* module, const char* base, const char* name) if (!base || *name == '/') full = name; else - { - unsigned bsz = strlen(base); - - tmp = HeapAlloc(GetProcessHeap(), 0, bsz + 1 + strlen(name) + 1); - if (!tmp) return ret; - full = tmp; - strcpy(tmp, base); - if (bsz && tmp[bsz - 1] != '/') tmp[bsz++] = '/'; - strcpy(&tmp[bsz], name); - } + full = source_build_path(base, name); rb_module = module; if (!module->sources || (ret = source_find(full)) == (unsigned)-1) { diff --git a/dlls/dbghelp/stabs.c b/dlls/dbghelp/stabs.c index ea5bed152e6..8aa9907449c 100644 --- a/dlls/dbghelp/stabs.c +++ b/dlls/dbghelp/stabs.c @@ -1587,7 +1587,7 @@ BOOL stabs_parse(struct module* module, ULONG_PTR load_offset, { stabs_reset_includes(); source_idx = source_new(module, srcpath, ptr); - compiland = symt_new_compiland(module, source_idx); + compiland = symt_new_compiland(module, source_get(module, source_idx)); } else { diff --git a/dlls/dbghelp/symbol.c b/dlls/dbghelp/symbol.c index c3ec770b2ba..e4c5361f897 100644 --- a/dlls/dbghelp/symbol.c +++ b/dlls/dbghelp/symbol.c @@ -231,19 +231,19 @@ struct symt_module* symt_new_module(struct module* module) return sym; }
-struct symt_compiland* symt_new_compiland(struct module* module, unsigned src_idx) +struct symt_compiland* symt_new_compiland(struct module* module, const char *filename) { struct symt_compiland* sym; struct symt_compiland** p;
TRACE_(dbghelp_symt)("Adding compiland symbol %s:%s\n", - debugstr_w(module->modulename), debugstr_a(source_get(module, src_idx))); + debugstr_w(module->modulename), debugstr_a(filename)); if ((sym = pool_alloc(&module->pool, sizeof(*sym)))) { sym->symt.tag = SymTagCompiland; sym->container = module->top; sym->address = 0; - sym->source = src_idx; + sym->filename = pool_strdup(&module->pool, filename); vector_init(&sym->vchildren, sizeof(struct symt*), 0); sym->user = NULL; p = vector_add(&module->top->vchildren, &module->pool); diff --git a/dlls/dbghelp/type.c b/dlls/dbghelp/type.c index b4c1a414d99..e0a79086ccf 100644 --- a/dlls/dbghelp/type.c +++ b/dlls/dbghelp/type.c @@ -102,8 +102,7 @@ const char* symt_get_name(const struct symt* sym) case SymTagEnum: return ((const struct symt_enum*)sym)->hash_elt.name; case SymTagTypedef: return ((const struct symt_typedef*)sym)->hash_elt.name; case SymTagUDT: return ((const struct symt_udt*)sym)->hash_elt.name; - case SymTagCompiland: return source_get(((const struct symt_compiland*)sym)->container->module, - ((const struct symt_compiland*)sym)->source); + case SymTagCompiland: return ((const struct symt_compiland*)sym)->filename; default: FIXME("Unsupported sym-tag %s\n", symt_get_tag_str(sym->tag)); /* fall through */