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

dbghelp: Add support for static variables at function scope (PDB).

These should be stored in function's children vector. Signed-off-by: 's avatarEric Pouech <eric.pouech@gmail.com>
parent e654b631
...@@ -1764,6 +1764,8 @@ static const union codeview_symbol* get_next_sym(const union codeview_symbol* sy ...@@ -1764,6 +1764,8 @@ static const union codeview_symbol* get_next_sym(const union codeview_symbol* sy
static inline void codeview_add_variable(const struct msc_debug_info* msc_dbg, static inline void codeview_add_variable(const struct msc_debug_info* msc_dbg,
struct symt_compiland* compiland, struct symt_compiland* compiland,
struct symt_function* func,
struct symt_block* block,
const char* name, const char* name,
unsigned segment, unsigned offset, unsigned segment, unsigned offset,
unsigned symtype, BOOL is_local, BOOL in_tls, BOOL force) unsigned symtype, BOOL is_local, BOOL in_tls, BOOL force)
...@@ -1775,6 +1777,13 @@ static inline void codeview_add_variable(const struct msc_debug_info* msc_dbg, ...@@ -1775,6 +1777,13 @@ static inline void codeview_add_variable(const struct msc_debug_info* msc_dbg,
loc.kind = in_tls ? loc_tlsrel : loc_absolute; loc.kind = in_tls ? loc_tlsrel : loc_absolute;
loc.reg = 0; loc.reg = 0;
loc.offset = in_tls ? offset : codeview_get_address(msc_dbg, segment, offset); loc.offset = in_tls ? offset : codeview_get_address(msc_dbg, segment, offset);
if (func)
{
if (!is_local || in_tls) WARN("Unsupported construct\n");
symt_add_func_local(msc_dbg->module, func, DataIsStaticLocal, &loc, block,
codeview_get_type(symtype, FALSE), name);
return;
}
if (force || in_tls || !symt_find_symbol_at(msc_dbg->module, loc.offset)) if (force || in_tls || !symt_find_symbol_at(msc_dbg->module, loc.offset))
{ {
symt_new_global_variable(msc_dbg->module, compiland, symt_new_global_variable(msc_dbg->module, compiland,
...@@ -2232,21 +2241,21 @@ static BOOL codeview_snarf(const struct msc_debug_info* msc_dbg, ...@@ -2232,21 +2241,21 @@ static BOOL codeview_snarf(const struct msc_debug_info* msc_dbg,
case S_GDATA32_16t: case S_GDATA32_16t:
case S_LDATA32_16t: case S_LDATA32_16t:
if (do_globals) if (do_globals)
codeview_add_variable(msc_dbg, compiland, terminate_string(&sym->data_v1.p_name), codeview_add_variable(msc_dbg, compiland, curr_func, block, terminate_string(&sym->data_v1.p_name),
sym->data_v1.segment, sym->data_v1.offset, sym->data_v1.symtype, sym->data_v1.segment, sym->data_v1.offset, sym->data_v1.symtype,
sym->generic.id == S_LDATA32_16t, FALSE, TRUE); sym->generic.id == S_LDATA32_16t, FALSE, TRUE);
break; break;
case S_GDATA32_ST: case S_GDATA32_ST:
case S_LDATA32_ST: case S_LDATA32_ST:
if (do_globals) if (do_globals)
codeview_add_variable(msc_dbg, compiland, terminate_string(&sym->data_v2.p_name), codeview_add_variable(msc_dbg, compiland, curr_func, block, terminate_string(&sym->data_v2.p_name),
sym->data_v2.segment, sym->data_v2.offset, sym->data_v2.symtype, sym->data_v2.segment, sym->data_v2.offset, sym->data_v2.symtype,
sym->generic.id == S_LDATA32_ST, FALSE, TRUE); sym->generic.id == S_LDATA32_ST, FALSE, TRUE);
break; break;
case S_GDATA32: case S_GDATA32:
case S_LDATA32: case S_LDATA32:
if (do_globals) if (do_globals)
codeview_add_variable(msc_dbg, compiland, sym->data_v3.name, codeview_add_variable(msc_dbg, compiland, curr_func, block, sym->data_v3.name,
sym->data_v3.segment, sym->data_v3.offset, sym->data_v3.symtype, sym->data_v3.segment, sym->data_v3.offset, sym->data_v3.symtype,
sym->generic.id == S_LDATA32, FALSE, TRUE); sym->generic.id == S_LDATA32, FALSE, TRUE);
break; break;
...@@ -2255,21 +2264,21 @@ static BOOL codeview_snarf(const struct msc_debug_info* msc_dbg, ...@@ -2255,21 +2264,21 @@ static BOOL codeview_snarf(const struct msc_debug_info* msc_dbg,
case S_GTHREAD32_16t: case S_GTHREAD32_16t:
case S_LTHREAD32_16t: case S_LTHREAD32_16t:
if (do_globals) if (do_globals)
codeview_add_variable(msc_dbg, compiland, terminate_string(&sym->thread_v1.p_name), codeview_add_variable(msc_dbg, compiland, curr_func, block, terminate_string(&sym->thread_v1.p_name),
sym->thread_v1.segment, sym->thread_v1.offset, sym->thread_v1.symtype, sym->thread_v1.segment, sym->thread_v1.offset, sym->thread_v1.symtype,
sym->generic.id == S_LTHREAD32_16t, TRUE, TRUE); sym->generic.id == S_LTHREAD32_16t, TRUE, TRUE);
break; break;
case S_GTHREAD32_ST: case S_GTHREAD32_ST:
case S_LTHREAD32_ST: case S_LTHREAD32_ST:
if (do_globals) if (do_globals)
codeview_add_variable(msc_dbg, compiland, terminate_string(&sym->thread_v2.p_name), codeview_add_variable(msc_dbg, compiland, curr_func, block, terminate_string(&sym->thread_v2.p_name),
sym->thread_v2.segment, sym->thread_v2.offset, sym->thread_v2.symtype, sym->thread_v2.segment, sym->thread_v2.offset, sym->thread_v2.symtype,
sym->generic.id == S_LTHREAD32_ST, TRUE, TRUE); sym->generic.id == S_LTHREAD32_ST, TRUE, TRUE);
break; break;
case S_GTHREAD32: case S_GTHREAD32:
case S_LTHREAD32: case S_LTHREAD32:
if (do_globals) if (do_globals)
codeview_add_variable(msc_dbg, compiland, sym->thread_v3.name, codeview_add_variable(msc_dbg, compiland, curr_func, block, sym->thread_v3.name,
sym->thread_v3.segment, sym->thread_v3.offset, sym->thread_v3.symtype, sym->thread_v3.segment, sym->thread_v3.offset, sym->thread_v3.symtype,
sym->generic.id == S_LTHREAD32, TRUE, TRUE); sym->generic.id == S_LTHREAD32, TRUE, TRUE);
break; break;
...@@ -2881,19 +2890,19 @@ static BOOL codeview_snarf_public(const struct msc_debug_info* msc_dbg, const BY ...@@ -2881,19 +2890,19 @@ static BOOL codeview_snarf_public(const struct msc_debug_info* msc_dbg, const BY
*/ */
case S_GDATA32_16t: case S_GDATA32_16t:
case S_LDATA32_16t: case S_LDATA32_16t:
codeview_add_variable(msc_dbg, compiland, terminate_string(&sym->data_v1.p_name), codeview_add_variable(msc_dbg, compiland, NULL, NULL, terminate_string(&sym->data_v1.p_name),
sym->data_v1.segment, sym->data_v1.offset, sym->data_v1.symtype, sym->data_v1.segment, sym->data_v1.offset, sym->data_v1.symtype,
sym->generic.id == S_LDATA32_16t, FALSE, FALSE); sym->generic.id == S_LDATA32_16t, FALSE, FALSE);
break; break;
case S_GDATA32_ST: case S_GDATA32_ST:
case S_LDATA32_ST: case S_LDATA32_ST:
codeview_add_variable(msc_dbg, compiland, terminate_string(&sym->data_v2.p_name), codeview_add_variable(msc_dbg, compiland, NULL, NULL, terminate_string(&sym->data_v2.p_name),
sym->data_v2.segment, sym->data_v2.offset, sym->data_v2.symtype, sym->data_v2.segment, sym->data_v2.offset, sym->data_v2.symtype,
sym->generic.id == S_LDATA32_ST, FALSE, FALSE); sym->generic.id == S_LDATA32_ST, FALSE, FALSE);
break; break;
case S_GDATA32: case S_GDATA32:
case S_LDATA32: case S_LDATA32:
codeview_add_variable(msc_dbg, compiland, sym->data_v3.name, codeview_add_variable(msc_dbg, compiland, NULL, NULL, sym->data_v3.name,
sym->data_v3.segment, sym->data_v3.offset, sym->data_v3.symtype, sym->data_v3.segment, sym->data_v3.offset, sym->data_v3.symtype,
sym->generic.id == S_LDATA32, FALSE, FALSE); sym->generic.id == S_LDATA32, FALSE, FALSE);
break; break;
...@@ -2901,19 +2910,19 @@ static BOOL codeview_snarf_public(const struct msc_debug_info* msc_dbg, const BY ...@@ -2901,19 +2910,19 @@ static BOOL codeview_snarf_public(const struct msc_debug_info* msc_dbg, const BY
/* variables with thread storage */ /* variables with thread storage */
case S_GTHREAD32_16t: case S_GTHREAD32_16t:
case S_LTHREAD32_16t: case S_LTHREAD32_16t:
codeview_add_variable(msc_dbg, compiland, terminate_string(&sym->thread_v1.p_name), codeview_add_variable(msc_dbg, compiland, NULL, NULL, terminate_string(&sym->thread_v1.p_name),
sym->thread_v1.segment, sym->thread_v1.offset, sym->thread_v1.symtype, sym->thread_v1.segment, sym->thread_v1.offset, sym->thread_v1.symtype,
sym->generic.id == S_LTHREAD32_16t, TRUE, FALSE); sym->generic.id == S_LTHREAD32_16t, TRUE, FALSE);
break; break;
case S_GTHREAD32_ST: case S_GTHREAD32_ST:
case S_LTHREAD32_ST: case S_LTHREAD32_ST:
codeview_add_variable(msc_dbg, compiland, terminate_string(&sym->thread_v2.p_name), codeview_add_variable(msc_dbg, compiland, NULL, NULL, terminate_string(&sym->thread_v2.p_name),
sym->thread_v2.segment, sym->thread_v2.offset, sym->thread_v2.symtype, sym->thread_v2.segment, sym->thread_v2.offset, sym->thread_v2.symtype,
sym->generic.id == S_LTHREAD32_ST, TRUE, FALSE); sym->generic.id == S_LTHREAD32_ST, TRUE, FALSE);
break; break;
case S_GTHREAD32: case S_GTHREAD32:
case S_LTHREAD32: case S_LTHREAD32:
codeview_add_variable(msc_dbg, compiland, sym->thread_v3.name, codeview_add_variable(msc_dbg, compiland, NULL, NULL, sym->thread_v3.name,
sym->thread_v3.segment, sym->thread_v3.offset, sym->thread_v3.symtype, sym->thread_v3.segment, sym->thread_v3.offset, sym->thread_v3.symtype,
sym->generic.id == S_LTHREAD32, TRUE, FALSE); sym->generic.id == S_LTHREAD32, TRUE, FALSE);
break; break;
......
...@@ -449,6 +449,7 @@ void symt_add_func_line(struct module* module, struct symt_function* func, ...@@ -449,6 +449,7 @@ void symt_add_func_line(struct module* module, struct symt_function* func,
* *
* Adds a new local/parameter to a given function: * Adds a new local/parameter to a given function:
* In any cases, dt tells whether it's a local variable or a parameter * In any cases, dt tells whether it's a local variable or a parameter
* or a static variable inside the function.
* If regno it's not 0: * If regno it's not 0:
* - then variable is stored in a register * - then variable is stored in a register
* - otherwise, value is referenced by register + offset * - otherwise, value is referenced by register + offset
...@@ -470,7 +471,7 @@ struct symt_data* symt_add_func_local(struct module* module, ...@@ -470,7 +471,7 @@ struct symt_data* symt_add_func_local(struct module* module,
name, type); name, type);
assert(symt_check_tag(&func->symt, SymTagFunction) || symt_check_tag(&func->symt, SymTagInlineSite)); assert(symt_check_tag(&func->symt, SymTagFunction) || symt_check_tag(&func->symt, SymTagInlineSite));
assert(dt == DataIsParam || dt == DataIsLocal); assert(dt == DataIsParam || dt == DataIsLocal || dt == DataIsStaticLocal);
locsym = pool_alloc(&module->pool, sizeof(*locsym)); locsym = pool_alloc(&module->pool, sizeof(*locsym));
locsym->symt.tag = SymTagData; locsym->symt.tag = SymTagData;
...@@ -804,6 +805,7 @@ static void symt_fill_sym_info(struct module_pair* pair, ...@@ -804,6 +805,7 @@ static void symt_fill_sym_info(struct module_pair* pair,
break; break;
case DataIsGlobal: case DataIsGlobal:
case DataIsFileStatic: case DataIsFileStatic:
case DataIsStaticLocal:
switch (data->u.var.kind) switch (data->u.var.kind)
{ {
case loc_tlsrel: case loc_tlsrel:
......
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