Replaced stack_get_frame with a pure symbol (and no longer stackframe)
oriented API (stack_get_current_symbol). Reused the func name (stack_get_frame) for internal stack.c handling.
This commit is contained in:
parent
e2bdb145ef
commit
c238ec520f
|
@ -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);
|
||||
|
|
|
@ -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 ||
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
IMAGEHLP_STACK_FRAME ihsf;
|
||||
DWORD64 disp;
|
||||
/*
|
||||
* If we don't have a valid backtrace, then just return.
|
||||
*/
|
||||
if (dbg_curr_thread->frames == NULL) return FALSE;
|
||||
|
||||
/*
|
||||
* 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;
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue