diff --git a/programs/winedbg/debugger.h b/programs/winedbg/debugger.h index d781897e4e6..d26bbc004e8 100644 --- a/programs/winedbg/debugger.h +++ b/programs/winedbg/debugger.h @@ -348,9 +348,9 @@ extern void source_nuke_path(void); extern void stack_info(void); extern void stack_backtrace(DWORD threadID); extern BOOL stack_set_frame(int newframe); -extern BOOL stack_get_frame(SYMBOL_INFO* sym, IMAGEHLP_STACK_FRAME* ihsf); extern BOOL stack_get_current_frame(IMAGEHLP_STACK_FRAME* ihsf); extern unsigned stack_fetch_frames(void); +extern BOOL stack_get_current_symbol(SYMBOL_INFO* sym); /* symbol.c */ extern enum sym_get_lval symbol_get_lvalue(const char* name, const int lineno, struct dbg_lvalue* addr, BOOL bp_disp); diff --git a/programs/winedbg/display.c b/programs/winedbg/display.c index 2f9189509cf..a3dae5d06c6 100644 --- a/programs/winedbg/display.c +++ b/programs/winedbg/display.c @@ -87,7 +87,7 @@ int display_add(struct expr *exp, int count, char format) displaypoints[i].func->SizeOfStruct = sizeof(SYMBOL_INFO); displaypoints[i].func->MaxNameLen = sizeof(displaypoints[i].func_buffer) - sizeof(*displaypoints[i].func); - if (!stack_get_frame(displaypoints[i].func, NULL)) + if (!stack_get_current_symbol(displaypoints[i].func)) { expr_free(displaypoints[i].exp); displaypoints[i].exp = NULL; @@ -110,7 +110,7 @@ int display_info(void) memset(func, 0, sizeof(SYMBOL_INFO)); func->SizeOfStruct = sizeof(SYMBOL_INFO); func->MaxNameLen = sizeof(buffer) - sizeof(*func); - if (!stack_get_frame(func, NULL)) return FALSE; + if (!stack_get_current_symbol(func)) return FALSE; for (i = 0; i < ndisplays; i++) { @@ -174,7 +174,7 @@ int display_print(void) memset(func, 0, sizeof(SYMBOL_INFO)); func->SizeOfStruct = sizeof(SYMBOL_INFO); func->MaxNameLen = sizeof(buffer) - sizeof(*func); - if (!stack_get_frame(func, NULL)) return FALSE; + if (!stack_get_current_symbol(func)) return FALSE; for (i = 0; i < ndisplays; i++) { @@ -243,7 +243,7 @@ int display_enable(int displaynum, int enable) memset(func, 0, sizeof(SYMBOL_INFO)); func->SizeOfStruct = sizeof(SYMBOL_INFO); func->MaxNameLen = sizeof(buffer) - sizeof(*func); - if (!stack_get_frame(func, NULL)) return FALSE; + if (!stack_get_current_symbol(func)) return FALSE; --displaynum; if (displaynum >= ndisplays || displaynum < 0 || diff --git a/programs/winedbg/stack.c b/programs/winedbg/stack.c index aec25e2720b..c7d49943647 100644 --- a/programs/winedbg/stack.c +++ b/programs/winedbg/stack.c @@ -82,7 +82,7 @@ static BOOL stack_set_frame_internal(int newframe) return TRUE; } -static BOOL stack_get_frame_internal(int nf, IMAGEHLP_STACK_FRAME* ihsf) +static BOOL stack_get_frame(int nf, IMAGEHLP_STACK_FRAME* ihsf) { ihsf->InstructionOffset = (unsigned long)memory_to_linear_addr(&dbg_curr_thread->frames[nf].addr_pc); ihsf->FrameOffset = (unsigned long)memory_to_linear_addr(&dbg_curr_thread->frames[nf].addr_frame); @@ -95,7 +95,7 @@ BOOL stack_get_current_frame(IMAGEHLP_STACK_FRAME* ihsf) * If we don't have a valid backtrace, then just return. */ if (dbg_curr_thread->frames == NULL) return FALSE; - return stack_get_frame_internal(dbg_curr_thread->curr_frame, ihsf); + return stack_get_frame(dbg_curr_thread->curr_frame, ihsf); } BOOL stack_set_frame(int newframe) @@ -108,27 +108,20 @@ BOOL stack_set_frame(int newframe) return TRUE; } -BOOL stack_get_frame(SYMBOL_INFO* symbol, IMAGEHLP_STACK_FRAME* ihsf) +/****************************************************************** + * stack_get_current_symbol + * + * Retrieves the symbol information for the current frame element + */ +BOOL stack_get_current_symbol(SYMBOL_INFO* symbol) { - DWORD64 disp; - /* - * If we don't have a valid backtrace, then just return. - */ - if (dbg_curr_thread->frames == NULL) return FALSE; + IMAGEHLP_STACK_FRAME ihsf; + DWORD64 disp; - /* - * If we don't know what the current function is, then we also have - * nothing to report here. - */ - if (!SymFromAddr(dbg_curr_process->handle, - (unsigned long)memory_to_linear_addr(&dbg_curr_thread->frames[dbg_curr_thread->curr_frame].addr_pc), - &disp, symbol)) - return FALSE; - if (ihsf && !stack_get_current_frame(ihsf)) return FALSE; - - return TRUE; + if (!stack_get_current_frame(&ihsf)) return FALSE; + return SymFromAddr(dbg_curr_process->handle, ihsf.InstructionOffset, + &disp, symbol); } - /****************************************************************** * stack_fetch_frames * @@ -214,7 +207,7 @@ static void stack_print_addr_and_args(int nf) print_bare_address(&dbg_curr_thread->frames[nf].addr_pc); - stack_get_frame_internal(nf, &ihsf); + stack_get_frame(nf, &ihsf); /* grab module where symbol is. If we don't have a module, we cannot print more */ im.SizeOfStruct = sizeof(im); @@ -270,7 +263,7 @@ static unsigned backtrace(void) dbg_printf(")\n"); } /* reset context to current stack frame */ - stack_get_frame_internal(dbg_curr_thread->curr_frame, &ihsf); + stack_get_frame(dbg_curr_thread->curr_frame, &ihsf); SymSetContext(dbg_curr_process->handle, &ihsf, NULL); return nf; } diff --git a/programs/winedbg/symbol.c b/programs/winedbg/symbol.c index 717f35b93e1..65a0bf7e092 100644 --- a/programs/winedbg/symbol.c +++ b/programs/winedbg/symbol.c @@ -595,17 +595,17 @@ static BOOL CALLBACK info_locals_cb(SYMBOL_INFO* sym, ULONG size, void* ctx) int symbol_info_locals(void) { IMAGEHLP_STACK_FRAME ihsf; - char buffer[sizeof(SYMBOL_INFO) + 256]; - SYMBOL_INFO* si = (SYMBOL_INFO*)buffer; + ADDRESS addr; + + stack_get_current_frame(&ihsf); + addr.Mode = AddrModeFlat; + addr.Offset = ihsf.InstructionOffset; + print_address(&addr, FALSE); + dbg_printf(": (%08lx)\n", (DWORD_PTR)ihsf.FrameOffset); + SymEnumSymbols(dbg_curr_process->handle, 0, NULL, info_locals_cb, (void*)(DWORD_PTR)ihsf.FrameOffset); - si->SizeOfStruct = sizeof(*si); - si->MaxNameLen = 256; - if (stack_get_frame(si, &ihsf)) - { - dbg_printf("%s:\n", si->Name); - SymEnumSymbols(dbg_curr_process->handle, 0, NULL, info_locals_cb, &ihsf); - } return TRUE; + } static BOOL CALLBACK symbols_info_cb(SYMBOL_INFO* sym, ULONG size, void* ctx)