Commit 6e7d28d5 authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

- now storing vector of types on a per module basis (and giving it

back in SymEnumTypes) - flagging local register vars as local too
parent 2537924c
...@@ -264,6 +264,7 @@ struct module ...@@ -264,6 +264,7 @@ struct module
/* types */ /* types */
struct hash_table ht_types; struct hash_table ht_types;
struct vector vtypes;
/* source files */ /* source files */
unsigned sources_used; unsigned sources_used;
......
...@@ -108,6 +108,7 @@ struct module* module_new(struct process* pcs, const char* name, ...@@ -108,6 +108,7 @@ struct module* module_new(struct process* pcs, const char* name,
*/ */
hash_table_init(&module->pool, &module->ht_symbols, 4096); hash_table_init(&module->pool, &module->ht_symbols, 4096);
hash_table_init(&module->pool, &module->ht_types, 4096); hash_table_init(&module->pool, &module->ht_types, 4096);
vector_init(&module->vtypes, sizeof(struct symt*), 32);
module->sources_used = 0; module->sources_used = 0;
module->sources_alloc = 0; module->sources_alloc = 0;
...@@ -497,6 +498,7 @@ void module_reset_debug_info(struct module* module) ...@@ -497,6 +498,7 @@ void module_reset_debug_info(struct module* module)
hash_table_destroy(&module->ht_types); hash_table_destroy(&module->ht_types);
module->ht_types.num_buckets = 0; module->ht_types.num_buckets = 0;
module->ht_types.buckets = NULL; module->ht_types.buckets = NULL;
module->vtypes.num_elts = 0;
hash_table_destroy(&module->ht_symbols); hash_table_destroy(&module->ht_symbols);
module->sources_used = module->sources_alloc = 0; module->sources_used = module->sources_alloc = 0;
module->sources = NULL; module->sources = NULL;
......
...@@ -470,7 +470,7 @@ static void symt_fill_sym_info(const struct module* module, ...@@ -470,7 +470,7 @@ static void symt_fill_sym_info(const struct module* module,
case DataIsParam: case DataIsParam:
if (data->u.s.reg_id) if (data->u.s.reg_id)
{ {
sym_info->Flags |= SYMFLAG_REGISTER; sym_info->Flags |= SYMFLAG_LOCAL | SYMFLAG_REGISTER;
sym_info->Register = data->u.s.reg_id; sym_info->Register = data->u.s.reg_id;
sym_info->Address = 0; sym_info->Address = 0;
} }
...@@ -480,7 +480,8 @@ static void symt_fill_sym_info(const struct module* module, ...@@ -480,7 +480,8 @@ static void symt_fill_sym_info(const struct module* module,
sym_info->Flags |= SYMFLAG_LOCAL | SYMFLAG_FRAMEREL; sym_info->Flags |= SYMFLAG_LOCAL | SYMFLAG_FRAMEREL;
else else
sym_info->Flags |= SYMFLAG_PARAMETER | SYMFLAG_FRAMEREL; sym_info->Flags |= SYMFLAG_PARAMETER | SYMFLAG_FRAMEREL;
sym_info->Register = CV_REG_EBP; /* FIXME: needed ? */ /* FIXME: needed ? moreover, it's i386 dependant !!! */
sym_info->Register = CV_REG_EBP;
sym_info->Address = data->u.s.offset; sym_info->Address = data->u.s.offset;
} }
break; break;
......
...@@ -124,6 +124,14 @@ static struct symt* symt_find_type_by_name(struct module* module, ...@@ -124,6 +124,14 @@ static struct symt* symt_find_type_by_name(struct module* module,
return NULL; return NULL;
} }
static void symt_add_type(struct module* module, struct symt* symt)
{
struct symt** p;
p = vector_add(&module->vtypes, &module->pool);
assert(p);
*p = symt;
}
struct symt_basic* symt_new_basic(struct module* module, enum BasicType bt, struct symt_basic* symt_new_basic(struct module* module, enum BasicType bt,
const char* typename, unsigned size) const char* typename, unsigned size)
{ {
...@@ -146,6 +154,7 @@ struct symt_basic* symt_new_basic(struct module* module, enum BasicType bt, ...@@ -146,6 +154,7 @@ struct symt_basic* symt_new_basic(struct module* module, enum BasicType bt,
} else sym->hash_elt.name = NULL; } else sym->hash_elt.name = NULL;
sym->bt = bt; sym->bt = bt;
sym->size = size; sym->size = size;
symt_add_type(module, &sym->symt);
} }
return sym; return sym;
} }
...@@ -167,6 +176,7 @@ struct symt_udt* symt_new_udt(struct module* module, const char* typename, ...@@ -167,6 +176,7 @@ struct symt_udt* symt_new_udt(struct module* module, const char* typename,
hash_table_add(&module->ht_types, &sym->hash_elt); hash_table_add(&module->ht_types, &sym->hash_elt);
} else sym->hash_elt.name = NULL; } else sym->hash_elt.name = NULL;
vector_init(&sym->vchildren, sizeof(struct symt*), 8); vector_init(&sym->vchildren, sizeof(struct symt*), 8);
symt_add_type(module, &sym->symt);
} }
return sym; return sym;
} }
...@@ -282,6 +292,7 @@ struct symt_array* symt_new_array(struct module* module, int min, int max, ...@@ -282,6 +292,7 @@ struct symt_array* symt_new_array(struct module* module, int min, int max,
sym->start = min; sym->start = min;
sym->end = max; sym->end = max;
sym->basetype = base; sym->basetype = base;
symt_add_type(module, &sym->symt);
} }
return sym; return sym;
} }
...@@ -296,6 +307,7 @@ struct symt_function_signature* symt_new_function_signature(struct module* modul ...@@ -296,6 +307,7 @@ struct symt_function_signature* symt_new_function_signature(struct module* modul
sym->symt.tag = SymTagFunctionType; sym->symt.tag = SymTagFunctionType;
sym->rettype = ret_type; sym->rettype = ret_type;
vector_init(&sym->vchildren, sizeof(struct symt*), 4); vector_init(&sym->vchildren, sizeof(struct symt*), 4);
symt_add_type(module, &sym->symt);
} }
return sym; return sym;
} }
...@@ -322,6 +334,7 @@ struct symt_pointer* symt_new_pointer(struct module* module, struct symt* ref_ty ...@@ -322,6 +334,7 @@ struct symt_pointer* symt_new_pointer(struct module* module, struct symt* ref_ty
{ {
sym->symt.tag = SymTagPointerType; sym->symt.tag = SymTagPointerType;
sym->pointsto = ref_type; sym->pointsto = ref_type;
symt_add_type(module, &sym->symt);
} }
return sym; return sym;
} }
...@@ -337,6 +350,7 @@ struct symt_typedef* symt_new_typedef(struct module* module, struct symt* ref, ...@@ -337,6 +350,7 @@ struct symt_typedef* symt_new_typedef(struct module* module, struct symt* ref,
sym->type = ref; sym->type = ref;
sym->hash_elt.name = pool_strdup(&module->pool, name); sym->hash_elt.name = pool_strdup(&module->pool, name);
hash_table_add(&module->ht_types, &sym->hash_elt); hash_table_add(&module->ht_types, &sym->hash_elt);
symt_add_type(module, &sym->symt);
} }
return sym; return sym;
} }
...@@ -351,12 +365,11 @@ BOOL WINAPI SymEnumTypes(HANDLE hProcess, unsigned long BaseOfDll, ...@@ -351,12 +365,11 @@ BOOL WINAPI SymEnumTypes(HANDLE hProcess, unsigned long BaseOfDll,
{ {
struct process* pcs; struct process* pcs;
struct module* module; struct module* module;
struct symt_ht* type;
void* ptr;
char buffer[sizeof(SYMBOL_INFO) + 256]; char buffer[sizeof(SYMBOL_INFO) + 256];
SYMBOL_INFO* sym_info = (SYMBOL_INFO*)buffer; SYMBOL_INFO* sym_info = (SYMBOL_INFO*)buffer;
struct hash_table_iter hti;
const char* tmp; const char* tmp;
struct symt* type;
void* pos = NULL;
TRACE("(%p %08lx %p %p)\n", TRACE("(%p %08lx %p %p)\n",
hProcess, BaseOfDll, EnumSymbolsCallback, UserContext); hProcess, BaseOfDll, EnumSymbolsCallback, UserContext);
...@@ -368,24 +381,27 @@ BOOL WINAPI SymEnumTypes(HANDLE hProcess, unsigned long BaseOfDll, ...@@ -368,24 +381,27 @@ BOOL WINAPI SymEnumTypes(HANDLE hProcess, unsigned long BaseOfDll,
sym_info->SizeOfStruct = sizeof(SYMBOL_INFO); sym_info->SizeOfStruct = sizeof(SYMBOL_INFO);
sym_info->MaxNameLen = sizeof(buffer) - sizeof(SYMBOL_INFO); sym_info->MaxNameLen = sizeof(buffer) - sizeof(SYMBOL_INFO);
hash_table_iter_init(&module->ht_types, &hti, NULL); while ((pos = vector_iter_up(&module->vtypes, pos)))
while ((ptr = hash_table_iter_up(&hti)))
{ {
type = GET_ENTRY(ptr, struct symt_ht, hash_elt); type = *(struct symt**)pos;
sym_info->TypeIndex = (DWORD)type; sym_info->TypeIndex = (DWORD)type;
sym_info->info = 0; /* FIXME */ sym_info->info = 0; /* FIXME */
symt_get_info(&type->symt, TI_GET_LENGTH, &sym_info->Size); symt_get_info(type, TI_GET_LENGTH, &sym_info->Size);
sym_info->ModBase = module->module.BaseOfImage; sym_info->ModBase = module->module.BaseOfImage;
sym_info->Flags = 0; /* FIXME */ sym_info->Flags = 0; /* FIXME */
sym_info->Value = 0; /* FIXME */ sym_info->Value = 0; /* FIXME */
sym_info->Address = 0; /* FIXME */ sym_info->Address = 0; /* FIXME */
sym_info->Register = 0; /* FIXME */ sym_info->Register = 0; /* FIXME */
sym_info->Scope = 0; /* FIXME */ sym_info->Scope = 0; /* FIXME */
sym_info->Tag = type->symt.tag; sym_info->Tag = type->tag;
tmp = symt_get_name(&type->symt); tmp = symt_get_name(type);
if (tmp)
{
sym_info->NameLen = strlen(tmp) + 1; sym_info->NameLen = strlen(tmp) + 1;
strncpy(sym_info->Name, tmp, min(sym_info->NameLen, sym_info->MaxNameLen)); strncpy(sym_info->Name, tmp, min(sym_info->NameLen, sym_info->MaxNameLen));
sym_info->Name[sym_info->MaxNameLen - 1] = '\0'; sym_info->Name[sym_info->MaxNameLen - 1] = '\0';
}
else sym_info->Name[sym_info->NameLen = 0] = '\0';
if (!EnumSymbolsCallback(sym_info, sym_info->Size, UserContext)) break; if (!EnumSymbolsCallback(sym_info, sym_info->Size, UserContext)) break;
} }
return TRUE; return TRUE;
...@@ -580,6 +596,8 @@ BOOL symt_get_info(const struct symt* type, IMAGEHLP_SYMBOL_TYPE_INFO req, ...@@ -580,6 +596,8 @@ BOOL symt_get_info(const struct symt* type, IMAGEHLP_SYMBOL_TYPE_INFO req,
default: default:
FIXME("Unsupported sym-tag %s for get-length\n", FIXME("Unsupported sym-tag %s for get-length\n",
symt_get_tag_str(type->tag)); symt_get_tag_str(type->tag));
/* fall through */
case SymTagFunctionType:
return 0; return 0;
} }
break; break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment