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