[PATCH 01/13] [DbgHelp]: compiland and source files are not the
same thing
Eric Pouech
eric.pouech at wanadoo.fr
Sat Mar 18 06:32:31 CST 2006
- in MSC debug info parsing, clearly separate a source file
information from a compiland (including in linetab structure)
- in ELF debug info parsing, now storing compiland directly
in symtab_elt while browsing the symtab section (we still
create twice the compilands, once in stabs/dwarf parsing,
a second time in symtab parsing)
A+
---
dlls/dbghelp/elf_module.c | 58 +++++++++++------------------------
dlls/dbghelp/msc.c | 74 ++++++++++++++++++---------------------------
dlls/dbghelp/mscvpdb.h | 22 +++++++++----
3 files changed, 62 insertions(+), 92 deletions(-)
diff --git a/dlls/dbghelp/elf_module.c b/dlls/dbghelp/elf_module.c
index 9a77665..8df8ab2 100644
--- a/dlls/dbghelp/elf_module.c
+++ b/dlls/dbghelp/elf_module.c
@@ -118,7 +118,7 @@ struct symtab_elt
{
struct hash_table_elt ht_elt;
const Elf32_Sym* symp;
- const char* filename;
+ struct symt_compiland* compiland;
unsigned used;
};
@@ -251,14 +251,14 @@ static void elf_unmap_file(struct elf_fi
*
* creating an internal hash table to ease use ELF symtab information lookup
*/
-static void elf_hash_symtab(const struct module* module, struct pool* pool,
+static void elf_hash_symtab(struct module* module, struct pool* pool,
struct hash_table* ht_symtab, struct elf_file_map* fmap,
int symtab_idx, struct thunk_area* thunks)
{
int i, j, nsym;
const char* strp;
const char* symname;
- const char* filename = NULL;
+ struct symt_compiland* compiland = NULL;
const char* ptr;
const Elf32_Sym* symp;
struct symtab_elt* ste;
@@ -289,7 +289,7 @@ static void elf_hash_symtab(const struct
if (ELF32_ST_TYPE(symp->st_info) == STT_FILE)
{
- filename = symname;
+ compiland = symname ? symt_new_compiland(module, symname) : NULL;
continue;
}
for (j = 0; thunks[j].symname; j++)
@@ -331,7 +331,7 @@ static void elf_hash_symtab(const struct
}
}
ste->symp = symp;
- ste->filename = filename;
+ ste->compiland = compiland;
ste->used = 0;
hash_table_add(ht_symtab, &ste->ht_elt);
}
@@ -377,22 +377,24 @@ static const Elf32_Sym* elf_lookup_symta
if (ste->used || strcmp(ste->ht_elt.name, name)) continue;
weak_result = ste;
- if ((ste->filename && !compiland_name) || (!ste->filename && compiland_name))
+ if ((ste->compiland && !compiland_name) || (!ste->compiland && compiland_name))
continue;
- if (ste->filename && compiland_name)
+ if (ste->compiland && compiland_name)
{
- if (strcmp(ste->filename, compiland_name))
+ const char* filename = source_get(module, ste->compiland->source);
+ if (strcmp(filename, compiland_name))
{
- base = strrchr(ste->filename, '/');
- if (!base++) base = ste->filename;
+ base = strrchr(filename, '/');
+ if (!base++) base = filename;
if (strcmp(base, compiland_basename)) continue;
}
}
if (result)
{
FIXME("Already found symbol %s (%s) in symtab %s @%08x and %s @%08x\n",
- name, compiland_name, result->filename, result->symp->st_value,
- ste->filename, ste->symp->st_value);
+ name, compiland_name,
+ source_get(module, result->compiland->source), result->symp->st_value,
+ source_get(module, ste->compiland->source), ste->symp->st_value);
}
else
{
@@ -496,8 +498,6 @@ static int elf_new_wine_thunks(struct mo
unsigned num_areas, struct thunk_area* thunks)
{
int j;
- struct symt_compiland* compiland = NULL;
- const char* compiland_name = NULL;
struct hash_table_iter hti;
struct symtab_elt* ste;
DWORD addr;
@@ -508,16 +508,6 @@ static int elf_new_wine_thunks(struct mo
{
if (ste->used) continue;
- /* FIXME: this is not a good idea anyway... we are creating several
- * compiland objects for a same compilation unit
- * We try to cache the last compiland used, but it's not enough
- * (we should here only create compilands if they are not yet
- * defined)
- */
- if (!compiland_name || compiland_name != ste->filename)
- compiland = symt_new_compiland(module,
- compiland_name = ste->filename);
-
addr = module->elf_info->elf_addr + ste->symp->st_value;
for (j = 0; j < num_areas; j++)
@@ -528,7 +518,7 @@ static int elf_new_wine_thunks(struct mo
}
if (j < num_areas) /* thunk found */
{
- symt_new_thunk(module, compiland, ste->ht_elt.name, thunks[j].ordinal,
+ symt_new_thunk(module, ste->compiland, ste->ht_elt.name, thunks[j].ordinal,
addr, ste->symp->st_size);
}
else
@@ -548,11 +538,11 @@ static int elf_new_wine_thunks(struct mo
switch (ELF32_ST_TYPE(ste->symp->st_info))
{
case STT_FUNC:
- symt_new_function(module, compiland, ste->ht_elt.name,
+ symt_new_function(module, ste->compiland, ste->ht_elt.name,
addr, ste->symp->st_size, NULL);
break;
case STT_OBJECT:
- symt_new_global_variable(module, compiland, ste->ht_elt.name,
+ symt_new_global_variable(module, ste->compiland, ste->ht_elt.name,
ELF32_ST_BIND(ste->symp->st_info) == STB_LOCAL,
addr, ste->symp->st_size, NULL);
break;
@@ -605,8 +595,6 @@ static int elf_new_wine_thunks(struct mo
*/
static int elf_new_public_symbols(struct module* module, struct hash_table* symtab)
{
- struct symt_compiland* compiland = NULL;
- const char* compiland_name = NULL;
struct hash_table_iter hti;
struct symtab_elt* ste;
@@ -617,17 +605,7 @@ static int elf_new_public_symbols(struct
hash_table_iter_init(symtab, &hti, NULL);
while ((ste = hash_table_iter_up(&hti)))
{
- /* FIXME: this is not a good idea anyway... we are creating several
- * compiland objects for a same compilation unit
- * We try to cache the last compiland used, but it's not enough
- * (we should here only create compilands if they are not yet
- * defined)
- */
- if (!compiland_name || compiland_name != ste->filename)
- compiland = symt_new_compiland(module,
- compiland_name = ste->filename);
-
- symt_new_public(module, compiland, ste->ht_elt.name,
+ symt_new_public(module, ste->compiland, ste->ht_elt.name,
module->elf_info->elf_addr + ste->symp->st_value,
ste->symp->st_size, TRUE /* FIXME */,
ELF32_ST_TYPE(ste->symp->st_info) == STT_FUNC);
diff --git a/dlls/dbghelp/msc.c b/dlls/dbghelp/msc.c
index 64bd903..bcf9a9b 100644
--- a/dlls/dbghelp/msc.c
+++ b/dlls/dbghelp/msc.c
@@ -987,7 +987,7 @@ static struct codeview_linetab* codeview
union any_size pnt2;
const struct startend* start;
int this_seg;
- struct symt_compiland* compiland;
+ unsigned source;
/*
* Now get the important bits.
@@ -1048,17 +1048,17 @@ static struct codeview_linetab* codeview
p_fn = (const struct p_string*)(start + file_segcount);
memset(filename, 0, sizeof(filename));
memcpy(filename, p_fn->name, p_fn->namelen);
- compiland = symt_new_compiland(module, filename);
+ source = source_new(module, filename);
}
else
- compiland = symt_new_compiland(module, (const char*)(start + file_segcount));
+ source = source_new(module, (const char*)(start + file_segcount));
for (k = 0; k < file_segcount; k++, this_seg++)
{
pnt2.uc = linetab + lt_ptr[k];
lt_hdr[this_seg].start = start[k].start;
lt_hdr[this_seg].end = start[k].end;
- lt_hdr[this_seg].compiland = compiland;
+ lt_hdr[this_seg].source = source;
lt_hdr[this_seg].segno = *pnt2.s++;
lt_hdr[this_seg].nline = *pnt2.s++;
lt_hdr[this_seg].offtab = pnt2.ui;
@@ -1134,7 +1134,7 @@ static void codeview_add_func_linenum(st
{
if (linetab->offtab[i] >= offset && linetab->offtab[i] < offset + size)
{
- symt_add_func_line(module, func, linetab->compiland->source,
+ symt_add_func_line(module, func, linetab->source,
linetab->linetab[i], linetab->offtab[i] - offset);
}
}
@@ -1150,6 +1150,7 @@ static int codeview_snarf(const struct m
struct symt_block* block = NULL;
struct symt* symt;
const char* name;
+ struct symt_compiland* compiland = NULL;
/*
* Loop over the different types of records and whenever we
@@ -1170,9 +1171,7 @@ static int codeview_snarf(const struct m
*/
case S_GDATA_V1:
case S_LDATA_V1:
- flt = codeview_get_linetab(linetab, sym->data_v1.segment, sym->data_v1.offset);
- symt_new_global_variable(msc_dbg->module,
- flt ? flt->compiland : NULL,
+ symt_new_global_variable(msc_dbg->module, compiland,
terminate_string(&sym->data_v1.p_name), sym->generic.id == S_LDATA_V1,
codeview_get_address(msc_dbg, sym->data_v1.segment, sym->data_v1.offset),
0,
@@ -1180,10 +1179,9 @@ static int codeview_snarf(const struct m
break;
case S_GDATA_V2:
case S_LDATA_V2:
- flt = codeview_get_linetab(linetab, sym->data_v2.segment, sym->data_v2.offset);
name = terminate_string(&sym->data_v2.p_name);
if (name)
- symt_new_global_variable(msc_dbg->module, flt ? flt->compiland : NULL,
+ symt_new_global_variable(msc_dbg->module, compiland,
name, sym->generic.id == S_LDATA_V2,
codeview_get_address(msc_dbg, sym->data_v2.segment, sym->data_v2.offset),
0,
@@ -1191,9 +1189,8 @@ static int codeview_snarf(const struct m
break;
case S_GDATA_V3:
case S_LDATA_V3:
- flt = codeview_get_linetab(linetab, sym->data_v3.segment, sym->data_v3.offset);
if (*sym->data_v3.name)
- symt_new_global_variable(msc_dbg->module, flt ? flt->compiland : NULL,
+ symt_new_global_variable(msc_dbg->module, compiland,
sym->data_v3.name,
sym->generic.id == S_LDATA_V3,
codeview_get_address(msc_dbg, sym->data_v3.segment, sym->data_v3.offset),
@@ -1204,8 +1201,7 @@ static int codeview_snarf(const struct m
case S_PUB_V1: /* FIXME is this really a 'data_v1' structure ?? */
if (!(dbghelp_options & SYMOPT_NO_PUBLICS))
{
- flt = codeview_get_linetab(linetab, sym->data_v1.segment, sym->data_v1.offset);
- symt_new_public(msc_dbg->module, flt ? flt->compiland : NULL,
+ symt_new_public(msc_dbg->module, compiland,
terminate_string(&sym->data_v1.p_name),
codeview_get_address(msc_dbg, sym->data_v1.segment, sym->data_v1.offset),
1, TRUE /* FIXME */, TRUE /* FIXME */);
@@ -1214,8 +1210,7 @@ static int codeview_snarf(const struct m
case S_PUB_V2: /* FIXME is this really a 'data_v2' structure ?? */
if (!(dbghelp_options & SYMOPT_NO_PUBLICS))
{
- flt = codeview_get_linetab(linetab, sym->data_v2.segment, sym->data_v2.offset);
- symt_new_public(msc_dbg->module, flt ? flt->compiland : NULL,
+ symt_new_public(msc_dbg->module, compiland,
terminate_string(&sym->data_v2.p_name),
codeview_get_address(msc_dbg, sym->data_v2.segment, sym->data_v2.offset),
1, TRUE /* FIXME */, TRUE /* FIXME */);
@@ -1228,15 +1223,13 @@ static int codeview_snarf(const struct m
* a PLT slot in the normal jargon that everyone else uses.
*/
case S_THUNK_V1:
- flt = codeview_get_linetab(linetab, sym->thunk_v1.segment, sym->thunk_v1.offset);
- symt_new_thunk(msc_dbg->module, flt ? flt->compiland : NULL,
+ symt_new_thunk(msc_dbg->module, compiland,
terminate_string(&sym->thunk_v1.p_name), sym->thunk_v1.thtype,
codeview_get_address(msc_dbg, sym->thunk_v1.segment, sym->thunk_v1.offset),
sym->thunk_v1.thunk_len);
break;
case S_THUNK_V3:
- flt = codeview_get_linetab(linetab, sym->thunk_v3.segment, sym->thunk_v3.offset);
- symt_new_thunk(msc_dbg->module, flt ? flt->compiland : NULL,
+ symt_new_thunk(msc_dbg->module, compiland,
sym->thunk_v3.name, sym->thunk_v3.thtype,
codeview_get_address(msc_dbg, sym->thunk_v3.segment, sym->thunk_v3.offset),
sym->thunk_v3.thunk_len);
@@ -1249,8 +1242,7 @@ static int codeview_snarf(const struct m
case S_LPROC_V1:
flt = codeview_get_linetab(linetab, sym->proc_v1.segment, sym->proc_v1.offset);
if (curr_func) FIXME("nested function\n");
- curr_func = symt_new_function(msc_dbg->module,
- flt ? flt->compiland : NULL,
+ curr_func = symt_new_function(msc_dbg->module, compiland,
terminate_string(&sym->proc_v1.p_name),
codeview_get_address(msc_dbg, sym->proc_v1.segment, sym->proc_v1.offset),
sym->proc_v1.proc_len,
@@ -1264,8 +1256,7 @@ static int codeview_snarf(const struct m
case S_LPROC_V2:
flt = codeview_get_linetab(linetab, sym->proc_v2.segment, sym->proc_v2.offset);
if (curr_func) FIXME("nested function\n");
- curr_func = symt_new_function(msc_dbg->module,
- flt ? flt->compiland : NULL,
+ curr_func = symt_new_function(msc_dbg->module, compiland,
terminate_string(&sym->proc_v2.p_name),
codeview_get_address(msc_dbg, sym->proc_v2.segment, sym->proc_v2.offset),
sym->proc_v2.proc_len,
@@ -1279,8 +1270,7 @@ static int codeview_snarf(const struct m
case S_LPROC_V3:
flt = codeview_get_linetab(linetab, sym->proc_v3.segment, sym->proc_v3.offset);
if (curr_func) FIXME("nested function\n");
- curr_func = symt_new_function(msc_dbg->module,
- flt ? flt->compiland : NULL,
+ curr_func = symt_new_function(msc_dbg->module, compiland,
sym->proc_v3.name,
codeview_get_address(msc_dbg, sym->proc_v3.segment, sym->proc_v3.offset),
sym->proc_v3.proc_len,
@@ -1343,19 +1333,16 @@ static int codeview_snarf(const struct m
}
break;
- /* FIXME: we should use this as a compiland, instead of guessing it on the fly */
- case S_COMPILAND_V1:
- TRACE("S-Compiland-V1e %x %s\n",
- sym->compiland_v1.unknown,
- terminate_string(&sym->compiland_v1.p_name));
+ case S_COMPILE_V1:
+ TRACE("S-Compile-V1 %x %s\n",
+ sym->compile_v1.unknown, terminate_string(&sym->compile_v1.p_name));
break;
- case S_COMPILAND_V2:
- TRACE("S-Compiland-V2 %s\n",
- terminate_string(&sym->compiland_v2.p_name));
+ case S_COMPILE_V2:
+ TRACE("S-Compile-V2 %s\n", terminate_string(&sym->compile_v2.p_name));
if (TRACE_ON(dbghelp_msc))
{
- const char* ptr1 = sym->compiland_v2.p_name.name + sym->compiland_v2.p_name.namelen;
+ const char* ptr1 = sym->compile_v2.p_name.name + sym->compile_v2.p_name.namelen;
const char* ptr2;
while (*ptr1)
{
@@ -1365,11 +1352,11 @@ static int codeview_snarf(const struct m
}
}
break;
- case S_COMPILAND_V3:
- TRACE("S-Compiland-V3 %s\n", sym->compiland_v3.name);
+ case S_COMPILE_V3:
+ TRACE("S-Compile-V3 %s\n", sym->compile_v3.name);
if (TRACE_ON(dbghelp_msc))
{
- const char* ptr1 = sym->compiland_v3.name + strlen(sym->compiland_v3.name);
+ const char* ptr1 = sym->compile_v3.name + strlen(sym->compile_v3.name);
const char* ptr2;
while (*ptr1)
{
@@ -1381,7 +1368,8 @@ static int codeview_snarf(const struct m
break;
case S_OBJNAME_V1:
- TRACE("S-ObjName %.*s\n", ((const BYTE*)sym)[8], (const BYTE*)sym + 9);
+ 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));
break;
case S_LABEL_V1:
@@ -1512,9 +1500,7 @@ static int codeview_snarf(const struct m
case S_PUB_DATA_V3:
if (!(dbghelp_options & SYMOPT_NO_PUBLICS))
{
- flt = codeview_get_linetab(linetab, sym->data_v3.segment, sym->data_v3.offset);
- symt_new_public(msc_dbg->module,
- flt ? flt->compiland : NULL,
+ symt_new_public(msc_dbg->module, compiland,
sym->data_v3.name,
codeview_get_address(msc_dbg, sym->data_v3.segment, sym->data_v3.offset),
1, FALSE /* FIXME */, FALSE);
@@ -1524,9 +1510,7 @@ static int codeview_snarf(const struct m
case S_PUB_FUNC2_V3: /* using a data_v3 isn't what we'd expect */
if (!(dbghelp_options & SYMOPT_NO_PUBLICS))
{
- flt = codeview_get_linetab(linetab, sym->data_v3.segment, sym->data_v3.offset);
- symt_new_public(msc_dbg->module,
- flt ? flt->compiland : NULL,
+ symt_new_public(msc_dbg->module, compiland,
sym->data_v3.name,
codeview_get_address(msc_dbg, sym->data_v3.segment, sym->data_v3.offset),
1, TRUE /* FIXME */, TRUE);
diff --git a/dlls/dbghelp/mscvpdb.h b/dlls/dbghelp/mscvpdb.h
index 828f311..31d1c05 100644
--- a/dlls/dbghelp/mscvpdb.h
+++ b/dlls/dbghelp/mscvpdb.h
@@ -1084,9 +1084,17 @@ union codeview_symbol
{
short int len;
short int id;
+ char signature[4];
+ struct p_string p_name;
+ } objname_v1;
+
+ struct
+ {
+ short int len;
+ short int id;
unsigned int unknown;
struct p_string p_name;
- } compiland_v1;
+ } compile_v1;
struct
{
@@ -1095,7 +1103,7 @@ union codeview_symbol
unsigned unknown1[4];
unsigned short unknown2;
struct p_string p_name;
- } compiland_v2;
+ } compile_v2;
struct
{
@@ -1103,10 +1111,10 @@ union codeview_symbol
short int id;
unsigned int unknown;
char name[1];
- } compiland_v3;
+ } compile_v3;
};
-#define S_COMPILAND_V1 0x0001
+#define S_COMPILE_V1 0x0001
#define S_REGISTER_V1 0x0002
#define S_CONSTANT_V1 0x0003
#define S_UDT_V1 0x0004
@@ -1160,9 +1168,9 @@ union codeview_symbol
#if 0
#define S_XXXXXXXXX_32 0x1012 /* seems linked to a function, content unknown */
#endif
-#define S_COMPILAND_V2 0x1013
+#define S_COMPILE_V2 0x1013
-#define S_COMPILAND_V3 0x1101
+#define S_COMPILE_V3 0x1101
#define S_THUNK_V3 0x1102
#define S_BLOCK_V3 0x1103
#define S_LABEL_V3 0x1105
@@ -1203,7 +1211,7 @@ struct codeview_linetab
unsigned int segno;
unsigned int start;
unsigned int end;
- struct symt_compiland* compiland;
+ unsigned int source;
const unsigned short* linetab;
const unsigned int* offtab;
};
More information about the wine-patches
mailing list