Module: wine Branch: master Commit: 87e2b007744f8bafdea63df21a74ffc24b392912 URL: https://gitlab.winehq.org/wine/wine/-/commit/87e2b007744f8bafdea63df21a74ffc...
Author: Eric Pouech eric.pouech@gmail.com Date: Tue Jul 12 09:28:57 2022 +0200
dbghelp: Don't include global & static variables from S_LOCAL* records.
PDB supports description of a global or static variable: - accessed from a register - stored as a local variable record inside a function
This likely describes access to a global/static variable where intermediate computation is kept in a register.
We cannot store this kind of entries in local variable lists (builtin dbghelp and winedbg are not prepared to handle a global variable)
Note: the global or static Codeview data record is still present (with a relocatable address), so the variable should still be available from global access (but could be not up-to-date if temporarly stored in a register).
Signed-off-by: Eric Pouech eric.pouech@gmail.com
---
dlls/dbghelp/msc.c | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-)
diff --git a/dlls/dbghelp/msc.c b/dlls/dbghelp/msc.c index e34853b45e8..bec9dec2532 100644 --- a/dlls/dbghelp/msc.c +++ b/dlls/dbghelp/msc.c @@ -1821,6 +1821,17 @@ static void codeview_xform_range(const struct msc_debug_info* msc_dbg, locinfo->rangelen = adrange->cbRange; }
+static unsigned codeview_defrange_length(const union codeview_symbol* sym) +{ + const union codeview_symbol* first_symrange = get_next_sym(sym); + const union codeview_symbol* symrange; + + for (symrange = first_symrange; + symrange->generic.id >= S_DEFRANGE && symrange->generic.id <= S_DEFRANGE_REGISTER_REL; + symrange = get_next_sym(symrange)) {} + return (const char*)symrange - (const char*)first_symrange; +} + static unsigned codeview_transform_defrange(const struct msc_debug_info* msc_dbg, struct symt_function* curr_func, const union codeview_symbol* sym, @@ -2567,12 +2578,21 @@ static BOOL codeview_snarf(const struct msc_debug_info* msc_dbg, } break; case S_LOCAL: - length += codeview_transform_defrange(msc_dbg, curr_func, sym, &loc); - symt_add_func_local(msc_dbg->module, curr_func, - sym->local_v3.varflags.is_param ? DataIsParam : DataIsLocal, - &loc, block, - codeview_get_type(sym->local_v3.symtype, FALSE), - sym->local_v3.name); + /* FIXME: don't store global/static variables accessed through registers... we don't support that + * in locals... anyway, global data record should be present as well (so variable will be avaible + * through global defintion, but potentially not updated) + */ + if (!sym->local_v3.varflags.enreg_global && !sym->local_v3.varflags.enreg_static) + { + length += codeview_transform_defrange(msc_dbg, curr_func, sym, &loc); + symt_add_func_local(msc_dbg->module, curr_func, + sym->local_v3.varflags.is_param ? DataIsParam : DataIsLocal, + &loc, block, + codeview_get_type(sym->local_v3.symtype, FALSE), + sym->local_v3.name); + } + else + length += codeview_defrange_length(sym); break; case S_INLINESITE: {