Module: wine Branch: master Commit: 83f85f5c919621c891473199f601c15341a36f13 URL: https://source.winehq.org/git/wine.git/?a=commit;h=83f85f5c919621c891473199f...
Author: Eric Pouech eric.pouech@gmail.com Date: Tue Oct 26 11:45:56 2021 +0200
winedbg: Add a pair of helpers for accessing frames' internal info.
Signed-off-by: Eric Pouech eric.pouech@gmail.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
programs/winedbg/debugger.h | 13 ++++++++++++- programs/winedbg/stack.c | 16 ++++++++-------- 2 files changed, 20 insertions(+), 9 deletions(-)
diff --git a/programs/winedbg/debugger.h b/programs/winedbg/debugger.h index 6ed0f8bfe2f..7af9e0d75e4 100644 --- a/programs/winedbg/debugger.h +++ b/programs/winedbg/debugger.h @@ -179,7 +179,7 @@ struct dbg_thread * - only valid when in_exception is TRUE */ EXCEPTION_RECORD excpt_record; /* only valid when in_exception is TRUE */ - struct + struct dbg_frame { ADDRESS64 addr_pc; ADDRESS64 addr_frame; @@ -390,6 +390,17 @@ extern BOOL stack_get_current_frame(IMAGEHLP_STACK_FRAME* ihsf); extern BOOL stack_get_register_frame(const struct dbg_internal_var* div, DWORD_PTR** pval); extern unsigned stack_fetch_frames(const dbg_ctx_t *ctx); extern BOOL stack_get_current_symbol(SYMBOL_INFO* sym); +static inline struct dbg_frame* + stack_get_thread_frame(struct dbg_thread* thd, unsigned nf) +{ + if (!thd->frames || nf >= thd->num_frames) return NULL; + return &thd->frames[nf]; +} +static inline struct dbg_frame* + stack_get_curr_frame(void) +{ + return stack_get_thread_frame(dbg_curr_thread, dbg_curr_thread->curr_frame); +}
/* 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/stack.c b/programs/winedbg/stack.c index 396caf11edd..9c22587a864 100644 --- a/programs/winedbg/stack.c +++ b/programs/winedbg/stack.c @@ -111,10 +111,10 @@ BOOL stack_get_current_frame(IMAGEHLP_STACK_FRAME* ihsf)
BOOL stack_get_register_frame(const struct dbg_internal_var* div, DWORD_PTR** pval) { - if (dbg_curr_thread->frames == NULL) return FALSE; - if (dbg_curr_thread->frames[dbg_curr_thread->curr_frame].is_ctx_valid) - *pval = (DWORD_PTR*)((char*)&dbg_curr_thread->frames[dbg_curr_thread->curr_frame].context + - (DWORD_PTR)div->pval); + struct dbg_frame* currfrm = stack_get_curr_frame(); + if (currfrm == NULL) return FALSE; + if (currfrm->is_ctx_valid) + *pval = (DWORD_PTR*)((char*)&currfrm->context + (DWORD_PTR)div->pval); else { enum be_cpu_addr kind; @@ -125,13 +125,13 @@ BOOL stack_get_register_frame(const struct dbg_internal_var* div, DWORD_PTR** pv switch (kind) { case be_cpu_addr_pc: - *pval = &dbg_curr_thread->frames[dbg_curr_thread->curr_frame].linear_pc; + *pval = &currfrm->linear_pc; break; case be_cpu_addr_stack: - *pval = &dbg_curr_thread->frames[dbg_curr_thread->curr_frame].linear_stack; + *pval = &currfrm->linear_stack; break; case be_cpu_addr_frame: - *pval = &dbg_curr_thread->frames[dbg_curr_thread->curr_frame].linear_frame; + *pval = &currfrm->linear_frame; break; } } @@ -143,7 +143,7 @@ BOOL stack_set_frame(int newframe) ADDRESS64 addr; if (!stack_set_frame_internal(newframe)) return FALSE; addr.Mode = AddrModeFlat; - addr.Offset = (DWORD_PTR)memory_to_linear_addr(&dbg_curr_thread->frames[dbg_curr_thread->curr_frame].addr_pc); + addr.Offset = (DWORD_PTR)memory_to_linear_addr(&stack_get_curr_frame()->addr_pc); source_list_from_addr(&addr, 0); return TRUE; }