Commit c4f1f5b1 authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

dbghelp: Get rid of symt_inlinesite by merging it inside symt_function.

Basically: - extending symt_function to enable storage of multiple address ranges - symt_function and sym_inlinesite now share the same fields, so get rid to the later. Note that only the first range of a top level function is actually stored and used (even if the structure allows for more). Signed-off-by: 's avatarEric Pouech <eric.pouech@gmail.com>
parent 790a2852
...@@ -706,7 +706,7 @@ BOOL WINAPI SymSetScopeFromIndex(HANDLE hProcess, ULONG64 addr, DWORD index) ...@@ -706,7 +706,7 @@ BOOL WINAPI SymSetScopeFromIndex(HANDLE hProcess, ULONG64 addr, DWORD index)
BOOL WINAPI SymSetScopeFromInlineContext(HANDLE hProcess, ULONG64 addr, DWORD inlinectx) BOOL WINAPI SymSetScopeFromInlineContext(HANDLE hProcess, ULONG64 addr, DWORD inlinectx)
{ {
struct module_pair pair; struct module_pair pair;
struct symt_inlinesite* inlined; struct symt_function* inlined;
TRACE("(%p %I64x %lx)\n", hProcess, addr, inlinectx); TRACE("(%p %I64x %lx)\n", hProcess, addr, inlinectx);
...@@ -718,7 +718,7 @@ BOOL WINAPI SymSetScopeFromInlineContext(HANDLE hProcess, ULONG64 addr, DWORD in ...@@ -718,7 +718,7 @@ BOOL WINAPI SymSetScopeFromInlineContext(HANDLE hProcess, ULONG64 addr, DWORD in
if (inlined) if (inlined)
{ {
pair.pcs->localscope_pc = addr; pair.pcs->localscope_pc = addr;
pair.pcs->localscope_symt = &inlined->func.symt; pair.pcs->localscope_symt = &inlined->symt;
return TRUE; return TRUE;
} }
/* fall through */ /* fall through */
......
...@@ -284,20 +284,13 @@ struct symt_data ...@@ -284,20 +284,13 @@ struct symt_data
struct symt_function struct symt_function
{ {
struct symt symt; /* SymTagFunction (or SymTagInlineSite when embedded in symt_inlinesite) */ struct symt symt; /* SymTagFunction or SymTagInlineSite */
struct hash_table_elt hash_elt; /* if global symbol */ struct hash_table_elt hash_elt; /* if global symbol, inline site */
struct symt* container; /* compiland */ struct symt* container; /* compiland (for SymTagFunction) or function (for SymTagInlineSite) */
struct symt* type; /* points to function_signature */ struct symt* type; /* points to function_signature */
struct vector vlines; struct vector vlines;
struct vector vchildren; /* locals, params, blocks, start/end, labels, inline sites */ struct vector vchildren; /* locals, params, blocks, start/end, labels, inline sites */
struct symt_inlinesite* next_inlinesite;/* linked list of inline sites in this function */ struct symt_function* next_inlinesite;/* linked list of inline sites in this function */
struct addr_range ranges[1];
};
/* a symt_inlinesite* can be casted to a symt_function* to access all function bits */
struct symt_inlinesite
{
struct symt_function func;
unsigned num_ranges; unsigned num_ranges;
struct addr_range ranges[]; struct addr_range ranges[];
}; };
...@@ -850,7 +843,7 @@ extern struct symt_function* ...@@ -850,7 +843,7 @@ extern struct symt_function*
const char* name, const char* name,
ULONG_PTR addr, ULONG_PTR size, ULONG_PTR addr, ULONG_PTR size,
struct symt* type) DECLSPEC_HIDDEN; struct symt* type) DECLSPEC_HIDDEN;
extern struct symt_inlinesite* extern struct symt_function*
symt_new_inlinesite(struct module* module, symt_new_inlinesite(struct module* module,
struct symt_function* func, struct symt_function* func,
struct symt* parent, struct symt* parent,
...@@ -945,18 +938,18 @@ extern struct symt_pointer* ...@@ -945,18 +938,18 @@ extern struct symt_pointer*
extern struct symt_typedef* extern struct symt_typedef*
symt_new_typedef(struct module* module, struct symt* ref, symt_new_typedef(struct module* module, struct symt* ref,
const char* name) DECLSPEC_HIDDEN; const char* name) DECLSPEC_HIDDEN;
extern struct symt_inlinesite* extern struct symt_function*
symt_find_lowest_inlined(struct symt_function* func, DWORD64 addr) DECLSPEC_HIDDEN; symt_find_lowest_inlined(struct symt_function* func, DWORD64 addr) DECLSPEC_HIDDEN;
extern struct symt* extern struct symt*
symt_get_upper_inlined(struct symt_inlinesite* inlined) DECLSPEC_HIDDEN; symt_get_upper_inlined(struct symt_function* inlined) DECLSPEC_HIDDEN;
static inline struct symt_function* static inline struct symt_function*
symt_get_function_from_inlined(struct symt_inlinesite* inlined) symt_get_function_from_inlined(struct symt_function* inlined)
{ {
while (!symt_check_tag(&inlined->func.symt, SymTagFunction)) while (!symt_check_tag(&inlined->symt, SymTagFunction))
inlined = (struct symt_inlinesite*)symt_get_upper_inlined(inlined); inlined = (struct symt_function*)symt_get_upper_inlined(inlined);
return &inlined->func; return inlined;
} }
extern struct symt_inlinesite* extern struct symt_function*
symt_find_inlined_site(struct module* module, symt_find_inlined_site(struct module* module,
DWORD64 addr, DWORD inline_ctx) DECLSPEC_HIDDEN; DWORD64 addr, DWORD inline_ctx) DECLSPEC_HIDDEN;
extern DWORD symt_get_inlinesite_depth(HANDLE hProcess, DWORD64 addr) DECLSPEC_HIDDEN; extern DWORD symt_get_inlinesite_depth(HANDLE hProcess, DWORD64 addr) DECLSPEC_HIDDEN;
......
...@@ -2113,7 +2113,7 @@ static void dwarf2_parse_inlined_subroutine(dwarf2_subprogram_t* subpgm, ...@@ -2113,7 +2113,7 @@ static void dwarf2_parse_inlined_subroutine(dwarf2_subprogram_t* subpgm,
struct attribute name; struct attribute name;
struct symt* ret_type; struct symt* ret_type;
struct symt_function_signature* sig_type; struct symt_function_signature* sig_type;
struct symt_inlinesite* inlined; struct symt_function* inlined;
struct vector* children; struct vector* children;
dwarf2_debug_info_t*child; dwarf2_debug_info_t*child;
unsigned int i; unsigned int i;
...@@ -2149,8 +2149,6 @@ static void dwarf2_parse_inlined_subroutine(dwarf2_subprogram_t* subpgm, ...@@ -2149,8 +2149,6 @@ static void dwarf2_parse_inlined_subroutine(dwarf2_subprogram_t* subpgm,
FIXME("Unexpected situation\n"); FIXME("Unexpected situation\n");
inlined->num_ranges = 0; inlined->num_ranges = 0;
} }
/* temporary: update address field */
inlined->func.ranges[0].low = inlined->ranges[0].low;
children = dwarf2_get_di_children(di); children = dwarf2_get_di_children(di);
if (children) for (i = 0; i < vector_length(children); i++) if (children) for (i = 0; i < vector_length(children); i++)
...@@ -2182,7 +2180,7 @@ static void dwarf2_parse_inlined_subroutine(dwarf2_subprogram_t* subpgm, ...@@ -2182,7 +2180,7 @@ static void dwarf2_parse_inlined_subroutine(dwarf2_subprogram_t* subpgm,
} }
subpgm->current_block = symt_check_tag(subpgm->current_func->container, SymTagBlock) ? subpgm->current_block = symt_check_tag(subpgm->current_func->container, SymTagBlock) ?
(struct symt_block*)subpgm->current_func->container : NULL; (struct symt_block*)subpgm->current_func->container : NULL;
subpgm->current_func = (struct symt_function*)symt_get_upper_inlined((struct symt_inlinesite*)subpgm->current_func); subpgm->current_func = (struct symt_function*)symt_get_upper_inlined(subpgm->current_func);
} }
static void dwarf2_parse_subprogram_block(dwarf2_subprogram_t* subpgm, static void dwarf2_parse_subprogram_block(dwarf2_subprogram_t* subpgm,
...@@ -2601,7 +2599,7 @@ static void dwarf2_set_line_number(struct module* module, ULONG_PTR address, ...@@ -2601,7 +2599,7 @@ static void dwarf2_set_line_number(struct module* module, ULONG_PTR address,
const struct vector* v, unsigned file, unsigned line) const struct vector* v, unsigned file, unsigned line)
{ {
struct symt_function* func; struct symt_function* func;
struct symt_inlinesite* inlined; struct symt_function* inlined;
struct symt_ht* symt; struct symt_ht* symt;
unsigned* psrc; unsigned* psrc;
...@@ -2613,14 +2611,14 @@ static void dwarf2_set_line_number(struct module* module, ULONG_PTR address, ...@@ -2613,14 +2611,14 @@ static void dwarf2_set_line_number(struct module* module, ULONG_PTR address,
if (symt_check_tag(&symt->symt, SymTagFunction)) if (symt_check_tag(&symt->symt, SymTagFunction))
{ {
func = (struct symt_function*)symt; func = (struct symt_function*)symt;
for (inlined = func->next_inlinesite; inlined; inlined = inlined->func.next_inlinesite) for (inlined = func->next_inlinesite; inlined; inlined = inlined->next_inlinesite)
{ {
int i; int i;
for (i = 0; i < inlined->num_ranges; ++i) for (i = 0; i < inlined->num_ranges; ++i)
{ {
if (inlined->ranges[i].low <= address && address < inlined->ranges[i].high) if (inlined->ranges[i].low <= address && address < inlined->ranges[i].high)
{ {
symt_add_func_line(module, &inlined->func, *psrc, line, address); symt_add_func_line(module, inlined, *psrc, line, address);
return; /* only add to lowest matching inline site */ return; /* only add to lowest matching inline site */
} }
} }
...@@ -3019,7 +3017,7 @@ static BOOL dwarf2_lookup_loclist(const struct module_format* modfmt, const dwar ...@@ -3019,7 +3017,7 @@ static BOOL dwarf2_lookup_loclist(const struct module_format* modfmt, const dwar
static const dwarf2_cuhead_t* get_cuhead_from_func(const struct symt_function* func) static const dwarf2_cuhead_t* get_cuhead_from_func(const struct symt_function* func)
{ {
if (symt_check_tag(&func->symt, SymTagInlineSite)) if (symt_check_tag(&func->symt, SymTagInlineSite))
func = symt_get_function_from_inlined((struct symt_inlinesite*)func); func = symt_get_function_from_inlined((struct symt_function*)func);
if (symt_check_tag(&func->symt, SymTagFunction) && symt_check_tag(func->container, SymTagCompiland)) if (symt_check_tag(&func->symt, SymTagFunction) && symt_check_tag(func->container, SymTagCompiland))
{ {
struct symt_compiland* c = (struct symt_compiland*)func->container; struct symt_compiland* c = (struct symt_compiland*)func->container;
......
...@@ -1012,7 +1012,7 @@ BOOL module_remove(struct process* pcs, struct module* module) ...@@ -1012,7 +1012,7 @@ BOOL module_remove(struct process* pcs, struct module* module)
{ {
struct symt* locsym = pcs->localscope_symt; struct symt* locsym = pcs->localscope_symt;
if (symt_check_tag(locsym, SymTagInlineSite)) if (symt_check_tag(locsym, SymTagInlineSite))
locsym = &symt_get_function_from_inlined((struct symt_inlinesite*)locsym)->symt; locsym = &symt_get_function_from_inlined((struct symt_function*)locsym)->symt;
if (symt_check_tag(locsym, SymTagFunction)) if (symt_check_tag(locsym, SymTagFunction))
{ {
locsym = ((struct symt_function*)locsym)->container; locsym = ((struct symt_function*)locsym)->container;
......
...@@ -2077,7 +2077,7 @@ static BOOL cv_dbgsubsect_find_inlinee(const struct msc_debug_info* msc_dbg, ...@@ -2077,7 +2077,7 @@ static BOOL cv_dbgsubsect_find_inlinee(const struct msc_debug_info* msc_dbg,
return FALSE; return FALSE;
} }
static inline void inline_site_update_last_range(struct symt_inlinesite* inlined, unsigned index, ULONG_PTR hi) static inline void inline_site_update_last_range(struct symt_function* inlined, unsigned index, ULONG_PTR hi)
{ {
if (index && index <= inlined->num_ranges) if (index && index <= inlined->num_ranges)
{ {
...@@ -2119,17 +2119,17 @@ static unsigned inline_site_get_num_ranges(const unsigned char* annot, ...@@ -2119,17 +2119,17 @@ static unsigned inline_site_get_num_ranges(const unsigned char* annot,
return num_ranges; return num_ranges;
} }
static struct symt_inlinesite* codeview_create_inline_site(const struct msc_debug_info* msc_dbg, static struct symt_function* codeview_create_inline_site(const struct msc_debug_info* msc_dbg,
const struct cv_module_snarf* cvmod, const struct cv_module_snarf* cvmod,
struct symt_function* top_func, struct symt_function* top_func,
struct symt* container, struct symt* container,
cv_itemid_t inlinee, cv_itemid_t inlinee,
const unsigned char* annot, const unsigned char* annot,
const unsigned char* last_annot) const unsigned char* last_annot)
{ {
const struct CV_DebugSSubsectionHeader_t* hdr_files = NULL; const struct CV_DebugSSubsectionHeader_t* hdr_files = NULL;
const union codeview_type* cvt; const union codeview_type* cvt;
struct symt_inlinesite* inlined; struct symt_function* inlined;
struct cv_binannot cvba; struct cv_binannot cvba;
BOOL srcok; BOOL srcok;
unsigned num_ranges; unsigned num_ranges;
...@@ -2194,7 +2194,7 @@ static struct symt_inlinesite* codeview_create_inline_site(const struct msc_debu ...@@ -2194,7 +2194,7 @@ static struct symt_inlinesite* codeview_create_inline_site(const struct msc_debu
offset += cvba.arg1; offset += cvba.arg1;
inline_site_update_last_range(inlined, index, top_func->ranges[0].low + offset); inline_site_update_last_range(inlined, index, top_func->ranges[0].low + offset);
if (srcok) if (srcok)
symt_add_func_line(msc_dbg->module, &inlined->func, srcfile, line, top_func->ranges[0].low + offset); symt_add_func_line(msc_dbg->module, inlined, srcfile, line, top_func->ranges[0].low + offset);
inlined->ranges[index ].low = top_func->ranges[0].low + offset; inlined->ranges[index ].low = top_func->ranges[0].low + offset;
inlined->ranges[index++].high = top_func->ranges[0].low + offset; inlined->ranges[index++].high = top_func->ranges[0].low + offset;
break; break;
...@@ -2215,7 +2215,7 @@ static struct symt_inlinesite* codeview_create_inline_site(const struct msc_debu ...@@ -2215,7 +2215,7 @@ static struct symt_inlinesite* codeview_create_inline_site(const struct msc_debu
offset += cvba.arg1; offset += cvba.arg1;
inline_site_update_last_range(inlined, index, top_func->ranges[0].low + offset); inline_site_update_last_range(inlined, index, top_func->ranges[0].low + offset);
if (srcok) if (srcok)
symt_add_func_line(msc_dbg->module, &inlined->func, srcfile, line, top_func->ranges[0].low + offset); symt_add_func_line(msc_dbg->module, inlined, srcfile, line, top_func->ranges[0].low + offset);
inlined->ranges[index ].low = top_func->ranges[0].low + offset; inlined->ranges[index ].low = top_func->ranges[0].low + offset;
inlined->ranges[index++].high = top_func->ranges[0].low + offset; inlined->ranges[index++].high = top_func->ranges[0].low + offset;
break; break;
...@@ -2223,7 +2223,7 @@ static struct symt_inlinesite* codeview_create_inline_site(const struct msc_debu ...@@ -2223,7 +2223,7 @@ static struct symt_inlinesite* codeview_create_inline_site(const struct msc_debu
offset += cvba.arg2; offset += cvba.arg2;
inline_site_update_last_range(inlined, index, top_func->ranges[0].low + offset); inline_site_update_last_range(inlined, index, top_func->ranges[0].low + offset);
if (srcok) if (srcok)
symt_add_func_line(msc_dbg->module, &inlined->func, srcfile, line, top_func->ranges[0].low + offset); symt_add_func_line(msc_dbg->module, inlined, srcfile, line, top_func->ranges[0].low + offset);
inlined->ranges[index ].low = top_func->ranges[0].low + offset; inlined->ranges[index ].low = top_func->ranges[0].low + offset;
inlined->ranges[index++].high = top_func->ranges[0].low + offset + cvba.arg1; inlined->ranges[index++].high = top_func->ranges[0].low + offset + cvba.arg1;
break; break;
...@@ -2238,10 +2238,8 @@ static struct symt_inlinesite* codeview_create_inline_site(const struct msc_debu ...@@ -2238,10 +2238,8 @@ static struct symt_inlinesite* codeview_create_inline_site(const struct msc_debu
{ {
struct addr_range* range = &inlined->ranges[inlined->num_ranges - 1]; struct addr_range* range = &inlined->ranges[inlined->num_ranges - 1];
if (range->low == range->high) WARN("pending empty range at end of %s inside %s\n", if (range->low == range->high) WARN("pending empty range at end of %s inside %s\n",
inlined->func.hash_elt.name, inlined->hash_elt.name,
top_func->hash_elt.name); top_func->hash_elt.name);
/* temporary: update address field */
inlined->func.ranges[0].low = inlined->ranges[0].low;
} }
return inlined; return inlined;
} }
...@@ -2657,11 +2655,11 @@ static BOOL codeview_snarf(const struct msc_debug_info* msc_dbg, ...@@ -2657,11 +2655,11 @@ static BOOL codeview_snarf(const struct msc_debug_info* msc_dbg,
break; break;
case S_INLINESITE: case S_INLINESITE:
{ {
struct symt_inlinesite* inlined = codeview_create_inline_site(msc_dbg, cvmod, top_func, struct symt_function* inlined = codeview_create_inline_site(msc_dbg, cvmod, top_func,
block ? &block->symt : &curr_func->symt, block ? &block->symt : &curr_func->symt,
sym->inline_site_v3.inlinee, sym->inline_site_v3.inlinee,
sym->inline_site_v3.binaryAnnotations, sym->inline_site_v3.binaryAnnotations,
(const unsigned char*)sym + length); (const unsigned char*)sym + length);
if (inlined) if (inlined)
{ {
curr_func = (struct symt_function*)inlined; curr_func = (struct symt_function*)inlined;
...@@ -2678,11 +2676,11 @@ static BOOL codeview_snarf(const struct msc_debug_info* msc_dbg, ...@@ -2678,11 +2676,11 @@ static BOOL codeview_snarf(const struct msc_debug_info* msc_dbg,
break; break;
case S_INLINESITE2: case S_INLINESITE2:
{ {
struct symt_inlinesite* inlined = codeview_create_inline_site(msc_dbg, cvmod, top_func, struct symt_function* inlined = codeview_create_inline_site(msc_dbg, cvmod, top_func,
block ? &block->symt : &curr_func->symt, block ? &block->symt : &curr_func->symt,
sym->inline_site2_v3.inlinee, sym->inline_site2_v3.inlinee,
sym->inline_site2_v3.binaryAnnotations, sym->inline_site2_v3.binaryAnnotations,
(const unsigned char*)sym + length); (const unsigned char*)sym + length);
if (inlined) if (inlined)
{ {
curr_func = (struct symt_function*)inlined; curr_func = (struct symt_function*)inlined;
...@@ -2701,7 +2699,7 @@ static BOOL codeview_snarf(const struct msc_debug_info* msc_dbg, ...@@ -2701,7 +2699,7 @@ static BOOL codeview_snarf(const struct msc_debug_info* msc_dbg,
case S_INLINESITE_END: case S_INLINESITE_END:
block = symt_check_tag(curr_func->container, SymTagBlock) ? block = symt_check_tag(curr_func->container, SymTagBlock) ?
(struct symt_block*)curr_func->container : NULL; (struct symt_block*)curr_func->container : NULL;
curr_func = (struct symt_function*)symt_get_upper_inlined((struct symt_inlinesite*)curr_func); curr_func = (struct symt_function*)symt_get_upper_inlined(curr_func);
break; break;
/* /*
......
...@@ -314,23 +314,27 @@ struct symt_data* symt_new_global_variable(struct module* module, ...@@ -314,23 +314,27 @@ struct symt_data* symt_new_global_variable(struct module* module,
return sym; return sym;
} }
static void init_function_or_inlinesite(struct symt_function* sym, static struct symt_function* init_function_or_inlinesite(struct module* module,
struct module* module, DWORD tag,
DWORD tag, struct symt* container,
struct symt* container, const char* name,
const char* name, struct symt* sig_type,
ULONG_PTR addr, ULONG_PTR size, unsigned num_ranges)
struct symt* sig_type)
{ {
struct symt_function* sym;
assert(!sig_type || sig_type->tag == SymTagFunctionType); assert(!sig_type || sig_type->tag == SymTagFunctionType);
sym->symt.tag = tag; if ((sym = pool_alloc(&module->pool, offsetof(struct symt_function, ranges[num_ranges]))))
sym->hash_elt.name = pool_strdup(&module->pool, name); {
sym->container = container; sym->symt.tag = tag;
sym->ranges[0].low = addr; sym->hash_elt.name = pool_strdup(&module->pool, name);
sym->ranges[0].high = addr + size; sym->container = container;
sym->type = sig_type; sym->type = sig_type;
vector_init(&sym->vlines, sizeof(struct line_info), 64); vector_init(&sym->vlines, sizeof(struct line_info), 64);
vector_init(&sym->vchildren, sizeof(struct symt*), 8); vector_init(&sym->vchildren, sizeof(struct symt*), 8);
sym->num_ranges = num_ranges;
}
return sym;
} }
struct symt_function* symt_new_function(struct module* module, struct symt_function* symt_new_function(struct module* module,
...@@ -343,10 +347,11 @@ struct symt_function* symt_new_function(struct module* module, ...@@ -343,10 +347,11 @@ struct symt_function* symt_new_function(struct module* module,
TRACE_(dbghelp_symt)("Adding global function %s:%s @%Ix-%Ix\n", TRACE_(dbghelp_symt)("Adding global function %s:%s @%Ix-%Ix\n",
debugstr_w(module->modulename), name, addr, addr + size - 1); debugstr_w(module->modulename), name, addr, addr + size - 1);
if ((sym = pool_alloc(&module->pool, sizeof(*sym)))) if ((sym = init_function_or_inlinesite(module, SymTagFunction, &compiland->symt, name, sig_type, 1)))
{ {
struct symt** p; struct symt** p;
init_function_or_inlinesite(sym, module, SymTagFunction, &compiland->symt, name, addr, size, sig_type); sym->ranges[0].low = addr;
sym->ranges[0].high = addr + size;
sym->next_inlinesite = NULL; /* first of list */ sym->next_inlinesite = NULL; /* first of list */
symt_add_module_ht(module, (struct symt_ht*)sym); symt_add_module_ht(module, (struct symt_ht*)sym);
if (compiland) if (compiland)
...@@ -358,25 +363,24 @@ struct symt_function* symt_new_function(struct module* module, ...@@ -358,25 +363,24 @@ struct symt_function* symt_new_function(struct module* module,
return sym; return sym;
} }
struct symt_inlinesite* symt_new_inlinesite(struct module* module, struct symt_function* symt_new_inlinesite(struct module* module,
struct symt_function* func, struct symt_function* func,
struct symt* container, struct symt* container,
const char* name, const char* name,
struct symt* sig_type, struct symt* sig_type,
unsigned num_ranges) unsigned num_ranges)
{ {
struct symt_inlinesite* sym; struct symt_function* sym;
TRACE_(dbghelp_symt)("Adding inline site %s\n", name); TRACE_(dbghelp_symt)("Adding inline site %s\n", name);
if ((sym = pool_alloc(&module->pool, offsetof(struct symt_inlinesite, ranges[num_ranges])))) if ((sym = init_function_or_inlinesite(module, SymTagInlineSite, container, name, sig_type, num_ranges)))
{ {
struct symt** p; struct symt** p;
assert(container); assert(container);
init_function_or_inlinesite(&sym->func, module, SymTagInlineSite, container, name, 0, 0, sig_type);
/* chain inline sites */ /* chain inline sites */
sym->func.next_inlinesite = func->next_inlinesite; sym->next_inlinesite = func->next_inlinesite;
func->next_inlinesite = sym; func->next_inlinesite = sym;
sym->num_ranges = num_ranges;
if (container->tag == SymTagFunction || container->tag == SymTagInlineSite) if (container->tag == SymTagFunction || container->tag == SymTagInlineSite)
p = vector_add(&((struct symt_function*)container)->vchildren, &module->pool); p = vector_add(&((struct symt_function*)container)->vchildren, &module->pool);
else else
...@@ -384,7 +388,7 @@ struct symt_inlinesite* symt_new_inlinesite(struct module* module, ...@@ -384,7 +388,7 @@ struct symt_inlinesite* symt_new_inlinesite(struct module* module,
assert(container->tag == SymTagBlock); assert(container->tag == SymTagBlock);
p = vector_add(&((struct symt_block*)container)->vchildren, &module->pool); p = vector_add(&((struct symt_block*)container)->vchildren, &module->pool);
} }
*p = &sym->func.symt; *p = &sym->symt;
} }
return sym; return sym;
} }
...@@ -1201,13 +1205,13 @@ void copy_symbolW(SYMBOL_INFOW* siw, const SYMBOL_INFO* si) ...@@ -1201,13 +1205,13 @@ void copy_symbolW(SYMBOL_INFOW* siw, const SYMBOL_INFO* si)
} }
/* return the lowest inline site inside a function */ /* return the lowest inline site inside a function */
struct symt_inlinesite* symt_find_lowest_inlined(struct symt_function* func, DWORD64 addr) struct symt_function* symt_find_lowest_inlined(struct symt_function* func, DWORD64 addr)
{ {
struct symt_inlinesite* current; struct symt_function* current;
int i; int i;
assert(func->symt.tag == SymTagFunction); assert(func->symt.tag == SymTagFunction);
for (current = func->next_inlinesite; current; current = current->func.next_inlinesite) for (current = func->next_inlinesite; current; current = current->next_inlinesite)
{ {
for (i = 0; i < current->num_ranges; ++i) for (i = 0; i < current->num_ranges; ++i)
{ {
...@@ -1220,9 +1224,9 @@ struct symt_inlinesite* symt_find_lowest_inlined(struct symt_function* func, DWO ...@@ -1220,9 +1224,9 @@ struct symt_inlinesite* symt_find_lowest_inlined(struct symt_function* func, DWO
} }
/* from an inline function, get either the enclosing inlined function, or the top function when no inlined */ /* from an inline function, get either the enclosing inlined function, or the top function when no inlined */
struct symt* symt_get_upper_inlined(struct symt_inlinesite* inlined) struct symt* symt_get_upper_inlined(struct symt_function* inlined)
{ {
struct symt* symt = &inlined->func.symt; struct symt* symt = &inlined->symt;
do do
{ {
...@@ -1237,18 +1241,18 @@ struct symt* symt_get_upper_inlined(struct symt_inlinesite* inlined) ...@@ -1237,18 +1241,18 @@ struct symt* symt_get_upper_inlined(struct symt_inlinesite* inlined)
} }
/* lookup in module for an inline site (from addr and inline_ctx) */ /* lookup in module for an inline site (from addr and inline_ctx) */
struct symt_inlinesite* symt_find_inlined_site(struct module* module, DWORD64 addr, DWORD inline_ctx) struct symt_function* symt_find_inlined_site(struct module* module, DWORD64 addr, DWORD inline_ctx)
{ {
struct symt_ht* symt = symt_find_symbol_at(module, addr); struct symt_ht* symt = symt_find_symbol_at(module, addr);
if (symt_check_tag(&symt->symt, SymTagFunction)) if (symt_check_tag(&symt->symt, SymTagFunction))
{ {
struct symt_function* func = (struct symt_function*)symt; struct symt_function* func = (struct symt_function*)symt;
struct symt_inlinesite* curr = symt_find_lowest_inlined(func, addr); struct symt_function* curr = symt_find_lowest_inlined(func, addr);
DWORD depth = IFC_DEPTH(inline_ctx); DWORD depth = IFC_DEPTH(inline_ctx);
if (curr) if (curr)
for ( ; &curr->func != func; curr = (struct symt_inlinesite*)symt_get_upper_inlined(curr)) for ( ; curr != func; curr = (struct symt_function*)symt_get_upper_inlined(curr))
if (depth-- == 0) return curr; if (depth-- == 0) return curr;
} }
return NULL; return NULL;
...@@ -1264,10 +1268,10 @@ DWORD symt_get_inlinesite_depth(HANDLE hProcess, DWORD64 addr) ...@@ -1264,10 +1268,10 @@ DWORD symt_get_inlinesite_depth(HANDLE hProcess, DWORD64 addr)
struct symt_ht* symt = symt_find_symbol_at(pair.effective, addr); struct symt_ht* symt = symt_find_symbol_at(pair.effective, addr);
if (symt_check_tag(&symt->symt, SymTagFunction)) if (symt_check_tag(&symt->symt, SymTagFunction))
{ {
struct symt_inlinesite* inlined = symt_find_lowest_inlined((struct symt_function*)symt, addr); struct symt_function* inlined = symt_find_lowest_inlined((struct symt_function*)symt, addr);
if (inlined) if (inlined)
{ {
for ( ; &inlined->func.symt != &symt->symt; inlined = (struct symt_inlinesite*)symt_get_upper_inlined(inlined)) for ( ; &inlined->symt != &symt->symt; inlined = (struct symt_function*)symt_get_upper_inlined(inlined))
++depth; ++depth;
} }
} }
...@@ -2673,7 +2677,7 @@ PWSTR WINAPI SymSetHomeDirectoryW(HANDLE hProcess, PCWSTR dir) ...@@ -2673,7 +2677,7 @@ PWSTR WINAPI SymSetHomeDirectoryW(HANDLE hProcess, PCWSTR dir)
BOOL WINAPI SymFromInlineContext(HANDLE hProcess, DWORD64 addr, ULONG inline_ctx, PDWORD64 disp, PSYMBOL_INFO si) BOOL WINAPI SymFromInlineContext(HANDLE hProcess, DWORD64 addr, ULONG inline_ctx, PDWORD64 disp, PSYMBOL_INFO si)
{ {
struct module_pair pair; struct module_pair pair;
struct symt_inlinesite* inlined; struct symt_function* inlined;
TRACE("(%p, %#I64x, 0x%lx, %p, %p)\n", hProcess, addr, inline_ctx, disp, si); TRACE("(%p, %#I64x, 0x%lx, %p, %p)\n", hProcess, addr, inline_ctx, disp, si);
...@@ -2684,8 +2688,8 @@ BOOL WINAPI SymFromInlineContext(HANDLE hProcess, DWORD64 addr, ULONG inline_ctx ...@@ -2684,8 +2688,8 @@ BOOL WINAPI SymFromInlineContext(HANDLE hProcess, DWORD64 addr, ULONG inline_ctx
inlined = symt_find_inlined_site(pair.effective, addr, inline_ctx); inlined = symt_find_inlined_site(pair.effective, addr, inline_ctx);
if (inlined) if (inlined)
{ {
symt_fill_sym_info(&pair, NULL, &inlined->func.symt, si); symt_fill_sym_info(&pair, NULL, &inlined->symt, si);
if (disp) *disp = addr - inlined->func.ranges[0].low; if (disp) *disp = addr - inlined->ranges[0].low;
return TRUE; return TRUE;
} }
/* fall through */ /* fall through */
...@@ -2728,14 +2732,14 @@ static BOOL get_line_from_inline_context(HANDLE hProcess, DWORD64 addr, ULONG in ...@@ -2728,14 +2732,14 @@ static BOOL get_line_from_inline_context(HANDLE hProcess, DWORD64 addr, ULONG in
struct internal_line_t* intl) struct internal_line_t* intl)
{ {
struct module_pair pair; struct module_pair pair;
struct symt_inlinesite* inlined; struct symt_function* inlined;
if (!module_init_pair(&pair, hProcess, mod_addr ? mod_addr : addr)) return FALSE; if (!module_init_pair(&pair, hProcess, mod_addr ? mod_addr : addr)) return FALSE;
switch (IFC_MODE(inline_ctx)) switch (IFC_MODE(inline_ctx))
{ {
case IFC_MODE_INLINE: case IFC_MODE_INLINE:
inlined = symt_find_inlined_site(pair.effective, addr, inline_ctx); inlined = symt_find_inlined_site(pair.effective, addr, inline_ctx);
if (inlined && get_line_from_function(&pair, &inlined->func, addr, disp, intl)) if (inlined && get_line_from_function(&pair, inlined, addr, disp, intl))
return TRUE; return TRUE;
/* fall through: check if we can find line info at top function level */ /* fall through: check if we can find line info at top function level */
case IFC_MODE_IGNORE: case IFC_MODE_IGNORE:
......
...@@ -94,8 +94,8 @@ const char* symt_get_name(const struct symt* sym) ...@@ -94,8 +94,8 @@ const char* symt_get_name(const struct symt* sym)
{ {
/* lexical tree */ /* lexical tree */
case SymTagData: return ((const struct symt_data*)sym)->hash_elt.name; case SymTagData: return ((const struct symt_data*)sym)->hash_elt.name;
case SymTagFunction: return ((const struct symt_function*)sym)->hash_elt.name; case SymTagFunction:
case SymTagInlineSite: return ((const struct symt_inlinesite*)sym)->func.hash_elt.name; case SymTagInlineSite: return ((const struct symt_function*)sym)->hash_elt.name;
case SymTagPublicSymbol: return ((const struct symt_public*)sym)->hash_elt.name; case SymTagPublicSymbol: return ((const struct symt_public*)sym)->hash_elt.name;
case SymTagLabel: return ((const struct symt_hierarchy_point*)sym)->hash_elt.name; case SymTagLabel: return ((const struct symt_hierarchy_point*)sym)->hash_elt.name;
case SymTagThunk: return ((const struct symt_thunk*)sym)->hash_elt.name; case SymTagThunk: return ((const struct symt_thunk*)sym)->hash_elt.name;
...@@ -153,10 +153,8 @@ BOOL symt_get_address(const struct symt* type, ULONG64* addr) ...@@ -153,10 +153,8 @@ BOOL symt_get_address(const struct symt* type, ULONG64* addr)
*addr = ((const struct symt_block*)type)->ranges[0].low; *addr = ((const struct symt_block*)type)->ranges[0].low;
break; break;
case SymTagFunction: case SymTagFunction:
*addr = ((const struct symt_function*)type)->ranges[0].low;
break;
case SymTagInlineSite: case SymTagInlineSite:
*addr = ((const struct symt_inlinesite*)type)->func.ranges[0].low; *addr = ((const struct symt_function*)type)->ranges[0].low;
break; break;
case SymTagPublicSymbol: case SymTagPublicSymbol:
*addr = ((const struct symt_public*)type)->address; *addr = ((const struct symt_public*)type)->address;
...@@ -685,8 +683,8 @@ BOOL symt_get_info(struct module* module, const struct symt* type, ...@@ -685,8 +683,8 @@ BOOL symt_get_info(struct module* module, const struct symt* type,
case SymTagUDT: v = &((const struct symt_udt*)type)->vchildren; break; case SymTagUDT: v = &((const struct symt_udt*)type)->vchildren; break;
case SymTagEnum: v = &((const struct symt_enum*)type)->vchildren; break; case SymTagEnum: v = &((const struct symt_enum*)type)->vchildren; break;
case SymTagFunctionType: v = &((const struct symt_function_signature*)type)->vchildren; break; case SymTagFunctionType: v = &((const struct symt_function_signature*)type)->vchildren; break;
case SymTagFunction: v = &((const struct symt_function*)type)->vchildren; break; case SymTagFunction:
case SymTagInlineSite: v = &((const struct symt_inlinesite*)type)->func.vchildren; break; case SymTagInlineSite: v = &((const struct symt_function*)type)->vchildren; break;
case SymTagBlock: v = &((const struct symt_block*)type)->vchildren; break; case SymTagBlock: v = &((const struct symt_block*)type)->vchildren; break;
case SymTagPointerType: case SymTagPointerType:
case SymTagArrayType: case SymTagArrayType:
...@@ -756,10 +754,8 @@ BOOL symt_get_info(struct module* module, const struct symt* type, ...@@ -756,10 +754,8 @@ BOOL symt_get_info(struct module* module, const struct symt* type,
X(DWORD) = vector_length(&((const struct symt_function_signature*)type)->vchildren); X(DWORD) = vector_length(&((const struct symt_function_signature*)type)->vchildren);
break; break;
case SymTagFunction: case SymTagFunction:
X(DWORD) = vector_length(&((const struct symt_function*)type)->vchildren);
break;
case SymTagInlineSite: case SymTagInlineSite:
X(DWORD) = vector_length(&((const struct symt_inlinesite*)type)->func.vchildren); X(DWORD) = vector_length(&((const struct symt_function*)type)->vchildren);
break; break;
case SymTagBlock: case SymTagBlock:
X(DWORD) = vector_length(&((const struct symt_block*)type)->vchildren); X(DWORD) = vector_length(&((const struct symt_block*)type)->vchildren);
...@@ -898,10 +894,8 @@ BOOL symt_get_info(struct module* module, const struct symt* type, ...@@ -898,10 +894,8 @@ BOOL symt_get_info(struct module* module, const struct symt* type,
X(DWORD) = symt_ptr2index(module, ((const struct symt_data*)type)->container); X(DWORD) = symt_ptr2index(module, ((const struct symt_data*)type)->container);
break; break;
case SymTagFunction: case SymTagFunction:
X(DWORD) = symt_ptr2index(module, ((const struct symt_function*)type)->container);
break;
case SymTagInlineSite: case SymTagInlineSite:
X(DWORD) = symt_ptr2index(module, ((const struct symt_inlinesite*)type)->func.container); X(DWORD) = symt_ptr2index(module, ((const struct symt_function*)type)->container);
break; break;
case SymTagThunk: case SymTagThunk:
X(DWORD) = symt_ptr2index(module, ((const struct symt_thunk*)type)->container); X(DWORD) = symt_ptr2index(module, ((const struct symt_thunk*)type)->container);
...@@ -1043,10 +1037,8 @@ BOOL symt_get_info(struct module* module, const struct symt* type, ...@@ -1043,10 +1037,8 @@ BOOL symt_get_info(struct module* module, const struct symt* type,
X(DWORD) = symt_ptr2index(module, ((const struct symt_data*)type)->type); X(DWORD) = symt_ptr2index(module, ((const struct symt_data*)type)->type);
break; break;
case SymTagFunction: case SymTagFunction:
X(DWORD) = symt_ptr2index(module, ((const struct symt_function*)type)->type);
break;
case SymTagInlineSite: case SymTagInlineSite:
X(DWORD) = symt_ptr2index(module, ((const struct symt_inlinesite*)type)->func.type); X(DWORD) = symt_ptr2index(module, ((const struct symt_function*)type)->type);
break; break;
case SymTagEnum: case SymTagEnum:
X(DWORD) = symt_ptr2index(module, ((const struct symt_enum*)type)->base_type); X(DWORD) = symt_ptr2index(module, ((const struct symt_enum*)type)->base_type);
......
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