diff --git a/dlls/dbghelp/dbghelp_private.h b/dlls/dbghelp/dbghelp_private.h index f4c88a00fac..531a74048a0 100644 --- a/dlls/dbghelp/dbghelp_private.h +++ b/dlls/dbghelp/dbghelp_private.h @@ -132,6 +132,7 @@ enum location_error {loc_err_internal = -1, /* internal while computing */ loc_err_too_complex = -2, /* couldn't compute location (even at runtime) */ loc_err_out_of_scope = -3, /* variable isn't available at current address */ loc_err_cant_read = -4, /* couldn't read memory at given address */ + loc_err_no_location = -5, /* likely optimized away (by compiler) */ }; struct location diff --git a/dlls/dbghelp/dwarf.c b/dlls/dbghelp/dwarf.c index a0fcc12b21a..d67c72a9ee9 100644 --- a/dlls/dbghelp/dwarf.c +++ b/dlls/dbghelp/dwarf.c @@ -1511,6 +1511,22 @@ static void dwarf2_parse_variable(dwarf2_subprogram_t* subpgm, di->symt = &symt_new_constant(subpgm->ctx->module, subpgm->compiland, name.u.string, param_type, &v)->symt; } + else + { + /* variable has been optimiezd away... report anyway */ + loc.kind = loc_error; + loc.reg = loc_err_no_location; + if (subpgm->func) + { + symt_add_func_local(subpgm->ctx->module, subpgm->func, + is_pmt ? DataIsParam : DataIsLocal, + &loc, block, param_type, name.u.string); + } + else + { + WARN("dropping global variable %s which has been optimized away\n", name.u.string); + } + } if (is_pmt && subpgm->func && subpgm->func->type) symt_add_function_signature_parameter(subpgm->ctx->module, (struct symt_function_signature*)subpgm->func->type, diff --git a/programs/winedbg/memory.c b/programs/winedbg/memory.c index 7d6112a56a7..1c8388c32a3 100644 --- a/programs/winedbg/memory.c +++ b/programs/winedbg/memory.c @@ -676,7 +676,7 @@ BOOL memory_get_register(DWORD regno, DWORD_PTR** value, char* buffer, int len) const struct dbg_internal_var* div; /* negative register values are wine's dbghelp hacks - * see dlls/dbghelp/dbghelp_internal.h for the details + * see dlls/dbghelp/dbghelp_private.h for the details */ switch (regno) { @@ -692,6 +692,9 @@ BOOL memory_get_register(DWORD regno, DWORD_PTR** value, char* buffer, int len) case -4: if (buffer) snprintf(buffer, len, ""); return FALSE; + case -5: + if (buffer) snprintf(buffer, len, ""); + return FALSE; } for (div = be_cpu->context_vars; div->name; div++)