1
0
mirror of https://github.com/wine-mirror/wine synced 2024-07-05 17:28:47 +00:00

dbghelp: Added the ability to define a source file by dir+filename instead of only filename.

This commit is contained in:
Eric Pouech 2006-06-18 21:32:20 +02:00 committed by Alexandre Julliard
parent 52db5c094e
commit 7af4097d80
8 changed files with 40 additions and 40 deletions

View File

@ -120,7 +120,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, filename);
file->compiland = symt_new_compiland(module, source_new(module, NULL, filename));
file->linetab_offset = -1;
file->linecnt = 0;
file->entries = NULL;

View File

@ -422,7 +422,7 @@ extern struct module*
extern BOOL pe_load_debug_info(const struct process* pcs,
struct module* module);
/* source.c */
extern unsigned source_new(struct module* module, const char* source);
extern unsigned source_new(struct module* module, const char* basedir, const char* source);
extern const char* source_get(const struct module* module, unsigned idx);
/* stabs.c */
@ -442,8 +442,7 @@ extern const char* symt_get_name(const struct symt* sym);
extern int symt_cmp_addr(const void* p1, const void* p2);
extern int symt_find_nearest(struct module* module, DWORD addr);
extern struct symt_compiland*
symt_new_compiland(struct module* module,
const char* filename);
symt_new_compiland(struct module* module, unsigned src_idx);
extern struct symt_public*
symt_new_public(struct module* module,
struct symt_compiland* parent,

View File

@ -1436,7 +1436,7 @@ static void dwarf2_parse_line_numbers(const dwarf2_section_t* sections,
while (traverse.data < traverse.end_data)
{
unsigned long address;
unsigned long address = 0;
unsigned file = 1;
unsigned line = 1;
unsigned is_stmt = default_stmt;
@ -1467,10 +1467,10 @@ static void dwarf2_parse_line_numbers(const dwarf2_section_t* sections,
address += insn_size * dwarf2_leb128_as_unsigned(&traverse);
break;
case DW_LNS_advance_line:
line += dwarf2_leb128_as_unsigned(&traverse);
line += dwarf2_leb128_as_signed(&traverse);
break;
case DW_LNS_set_file:
file = dwarf2_leb128_as_signed(&traverse);
file = dwarf2_leb128_as_unsigned(&traverse);
break;
case DW_LNS_set_column:
dwarf2_leb128_as_unsigned(&traverse);
@ -1496,8 +1496,7 @@ static void dwarf2_parse_line_numbers(const dwarf2_section_t* sections,
end_sequence = TRUE;
break;
case DW_LNE_set_address:
address = dwarf2_parse_addr(&traverse);
address += ctx->module->module.BaseOfImage;
address = ctx->module->module.BaseOfImage + dwarf2_parse_addr(&traverse);
break;
case DW_LNE_define_file:
traverse.data += strlen((const char *)traverse.data) + 1;
@ -1579,7 +1578,7 @@ static BOOL dwarf2_parse_compilation_unit(const dwarf2_section_t* sections,
TRACE("beginning at 0x%lx, for %lu\n", di->offset, di->abbrev->entry_code);
dwarf2_find_name(&ctx, di, &name, "compiland");
di->symt = &symt_new_compiland(module, name.string)->symt;
di->symt = &symt_new_compiland(module, source_new(module, NULL, name.string))->symt;
if (di->abbrev->have_child)
{

View File

@ -292,7 +292,7 @@ static void elf_hash_symtab(struct module* module, struct pool* pool,
if (ELF32_ST_TYPE(symp->st_info) == STT_FILE)
{
compiland = symname ? symt_new_compiland(module, symname) : NULL;
compiland = symname ? symt_new_compiland(module, source_new(module, NULL, symname)) : NULL;
continue;
}
for (j = 0; thunks[j].symname; j++)

View File

@ -1136,10 +1136,10 @@ static struct codeview_linetab* codeview_snarf_linetab(struct module* module,
p_fn = (const struct p_string*)(start + file_segcount);
memset(filename, 0, sizeof(filename));
memcpy(filename, p_fn->name, p_fn->namelen);
source = source_new(module, filename);
source = source_new(module, NULL, filename);
}
else
source = source_new(module, (const char*)(start + file_segcount));
source = source_new(module, NULL, (const char*)(start + file_segcount));
for (k = 0; k < file_segcount; k++, this_seg++)
{
@ -1465,7 +1465,9 @@ static int codeview_snarf(const struct msc_debug_info* msc_dbg, const BYTE* root
case S_OBJNAME_V1:
TRACE("S-ObjName %s\n", terminate_string(&sym->objname_v1.p_name));
compiland = symt_new_compiland(msc_dbg->module, terminate_string(&sym->objname_v1.p_name));
compiland = symt_new_compiland(msc_dbg->module,
source_new(msc_dbg->module, NULL,
terminate_string(&sym->objname_v1.p_name)));
break;
case S_LABEL_V1:

View File

@ -54,16 +54,30 @@ static unsigned source_find(const struct module* module, const char* name)
*
* checks if source exists. if not, add it
*/
unsigned source_new(struct module* module, const char* name)
unsigned source_new(struct module* module, const char* base, const char* name)
{
int len;
unsigned ret;
const char* full;
if (!name) return (unsigned)-1;
if (module->sources && (ret = source_find(module, name)) != (unsigned)-1)
if (!base || *name == '/')
full = name;
else
{
unsigned bsz = strlen(base);
char* tmp = HeapAlloc(GetProcessHeap(), 0, bsz + 1 + strlen(name) + 1);
if (!tmp) return (unsigned)-1;
full = tmp;
strcpy(tmp, base);
if (tmp[bsz - 1] != '/') tmp[bsz++] = '/';
strcpy(&tmp[bsz], name);
}
if (module->sources && (ret = source_find(module, full)) != (unsigned)-1)
return ret;
len = strlen(name) + 1;
len = strlen(full) + 1;
if (module->sources_used + len + 1 > module->sources_alloc)
{
/* Alloc by block of 256 bytes */
@ -75,9 +89,10 @@ unsigned source_new(struct module* module, const char* name)
module->sources_alloc);
}
ret = module->sources_used;
strcpy(module->sources + module->sources_used, name);
strcpy(module->sources + module->sources_used, full);
module->sources_used += len;
module->sources[module->sources_used] = '\0';
if (full != name) HeapFree(GetProcessHeap(), 0, (char*)full);
return ret;
}

View File

@ -1173,7 +1173,6 @@ BOOL stabs_parse(struct module* module, unsigned long load_offset,
struct symt_function* curr_func = NULL;
struct symt_block* block = NULL;
struct symt_compiland* compiland = NULL;
char currpath[PATH_MAX]; /* path to current file */
char srcpath[PATH_MAX]; /* path to directory source file is in */
int i;
int nstab;
@ -1475,30 +1474,16 @@ BOOL stabs_parse(struct module* module, unsigned long load_offset,
int len = strlen(ptr);
if (ptr[len-1] != '/')
{
if (ptr[0] == '/')
strcpy(currpath, ptr);
else
{
strcpy(currpath, srcpath);
strcat(currpath, ptr);
}
stabs_reset_includes();
compiland = symt_new_compiland(module, currpath);
source_idx = source_new(module, currpath);
source_idx = source_new(module, srcpath, ptr);
compiland = symt_new_compiland(module, source_idx);
}
else
strcpy(srcpath, ptr);
}
break;
case N_SOL:
if (*ptr != '/')
{
strcpy(currpath, srcpath);
strcat(currpath, ptr);
}
else
strcpy(currpath, ptr);
source_idx = source_new(module, currpath);
source_idx = source_new(module, srcpath, ptr);
break;
case N_UNDF:
strs += strtabinc;
@ -1518,7 +1503,7 @@ BOOL stabs_parse(struct module* module, unsigned long load_offset,
stabs_add_include(stabs_new_include(ptr, stab_ptr->n_value));
assert(incl_stk < (int)(sizeof(incl) / sizeof(incl[0])) - 1);
incl[++incl_stk] = source_idx;
source_idx = source_new(module, ptr);
source_idx = source_new(module, NULL, ptr);
break;
case N_EINCL:
assert(incl_stk >= 0);

View File

@ -125,16 +125,16 @@ static void compile_regex(const char* str, int numchar, regex_t* re, BOOL _case)
HeapFree(GetProcessHeap(), 0, mask);
}
struct symt_compiland* symt_new_compiland(struct module* module, const char* name)
struct symt_compiland* symt_new_compiland(struct module* module, unsigned src_idx)
{
struct symt_compiland* sym;
TRACE_(dbghelp_symt)("Adding compiland symbol %s:%s\n",
module->module.ModuleName, name);
module->module.ModuleName, source_get(module, src_idx));
if ((sym = pool_alloc(&module->pool, sizeof(*sym))))
{
sym->symt.tag = SymTagCompiland;
sym->source = source_new(module, name);
sym->source = src_idx;
vector_init(&sym->vchildren, sizeof(struct symt*), 32);
}
return sym;