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

Centralized calls for SymSetContext, we only do it when we change the

current stack frame, and no longer every time we look up local symbols on current stack
parent e968628e
......@@ -141,8 +141,6 @@ unsigned stack_fetch_frames(void)
HeapFree(GetProcessHeap(), 0, dbg_curr_thread->frames);
dbg_curr_thread->frames = NULL;
dbg_curr_thread->num_frames = 0;
dbg_curr_thread->curr_frame = 0;
memset(&sf, 0, sizeof(sf));
memory_get_current_frame(&sf.AddrFrame);
......@@ -168,7 +166,10 @@ unsigned stack_fetch_frames(void)
/* we've probably gotten ourselves into an infinite loop so bail */
if (nf > 200) break;
}
return dbg_curr_thread->num_frames = nf;
dbg_curr_thread->curr_frame = -1;
dbg_curr_thread->num_frames = nf;
stack_set_frame_internal(0);
return nf;
}
struct sym_enum
......@@ -215,9 +216,6 @@ static void stack_print_addr_and_args(int nf)
stack_get_frame_internal(nf, &ihsf);
ihsf.InstructionOffset = (DWORD_PTR)memory_to_linear_addr(&dbg_curr_thread->frames[nf].addr_pc);
ihsf.FrameOffset = (DWORD_PTR)memory_to_linear_addr(&dbg_curr_thread->frames[nf].addr_frame);
/* grab module where symbol is. If we don't have a module, we cannot print more */
im.SizeOfStruct = sizeof(im);
if (!SymGetModuleInfo(dbg_curr_process->handle, ihsf.InstructionOffset, &im))
......@@ -259,6 +257,7 @@ static void stack_print_addr_and_args(int nf)
static unsigned backtrace(void)
{
unsigned nf = 0;
IMAGEHLP_STACK_FRAME ihsf;
dbg_printf("Backtrace:\n");
for (nf = 0; nf < dbg_curr_thread->num_frames; nf++)
......@@ -270,6 +269,9 @@ static unsigned backtrace(void)
print_bare_address(&dbg_curr_thread->frames[nf].addr_pc);
dbg_printf(")\n");
}
/* reset context to current stack frame */
stack_get_frame_internal(dbg_curr_thread->curr_frame, &ihsf);
SymSetContext(dbg_curr_process->handle, &ihsf, NULL);
return nf;
}
......
......@@ -209,8 +209,6 @@ enum sym_get_lval symbol_get_lvalue(const char* name, const int lineno,
{
struct sgv_data sgv;
int i = 0;
char tmp[sizeof(SYMBOL_INFO) + 256];
SYMBOL_INFO* si = (SYMBOL_INFO*)tmp;
char buffer[512];
DWORD opt;
IMAGEHLP_STACK_FRAME ihsf;
......@@ -275,12 +273,9 @@ enum sym_get_lval symbol_get_lvalue(const char* name, const int lineno,
SymSetOptions(opt);
/* now grab local symbols */
si->SizeOfStruct = sizeof(*si);
si->MaxNameLen = 256;
if (stack_get_frame(si, &ihsf) && sgv.num < NUMDBGV)
if (stack_get_current_frame(&ihsf) && sgv.num < NUMDBGV)
{
sgv.frame_offset = ihsf.FrameOffset;
if (SymSetContext(dbg_curr_process->handle, &ihsf, NULL))
SymEnumSymbols(dbg_curr_process->handle, 0, name, sgv_cb, (void*)&sgv);
}
......@@ -308,7 +303,7 @@ enum sym_get_lval symbol_get_lvalue(const char* name, const int lineno,
dbg_printf("%s %sof %s\n",
sgv.syms[i].flags & SYMFLAG_PARAMETER ? "Parameter" : "Local variable",
sgv.syms[i].flags & (SYMFLAG_REGISTER|SYMFLAG_REGREL) ? "(in a register) " : "",
si->Name);
name);
}
else if (sgv.syms[i].flags & SYMFLAG_THUNK)
{
......@@ -353,8 +348,6 @@ enum sym_get_lval symbol_get_lvalue(const char* name, const int lineno,
BOOL symbol_is_local(const char* name)
{
struct sgv_data sgv;
char tmp[sizeof(SYMBOL_INFO) + 256];
SYMBOL_INFO* si = (SYMBOL_INFO*)tmp;
IMAGEHLP_STACK_FRAME ihsf;
sgv.num = 0;
......@@ -365,10 +358,7 @@ BOOL symbol_is_local(const char* name)
sgv.bp_disp = FALSE;
sgv.do_thunks = FALSE;
si->SizeOfStruct = sizeof(*si);
si->MaxNameLen = 256;
if (stack_get_frame(si, &ihsf) &&
SymSetContext(dbg_curr_process->handle, &ihsf, NULL))
if (stack_get_current_frame(&ihsf))
{
sgv.frame_offset = ihsf.FrameOffset;
SymEnumSymbols(dbg_curr_process->handle, 0, name, sgv_cb, (void*)&sgv);
......@@ -613,7 +603,6 @@ int symbol_info_locals(void)
if (stack_get_frame(si, &ihsf))
{
dbg_printf("%s:\n", si->Name);
if (SymSetContext(dbg_curr_process->handle, &ihsf, NULL))
SymEnumSymbols(dbg_curr_process->handle, 0, NULL, info_locals_cb, &ihsf);
}
return TRUE;
......
......@@ -606,7 +606,6 @@ static unsigned dbg_exception_prolog(BOOL is_debug, const EXCEPTION_RECORD* rec)
{
ADDRESS tmp = addr;
/* Show where we crashed */
stack_set_frame(0);
memory_disasm_one_insn(&tmp);
}
source_list_from_addr(&addr, 0);
......
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