From 583e051044a97bd247cfb04b47be674059b48c03 Mon Sep 17 00:00:00 2001 From: Eric Pouech Date: Mon, 10 Nov 2008 15:03:10 +0100 Subject: [PATCH] winedbg: Added scoped symbol picker, and options to handle it. --- programs/winedbg/debugger.h | 2 ++ programs/winedbg/symbol.c | 32 ++++++++++++++++++++++++++++++++ programs/winedbg/winedbg.c | 15 +++++++++++++++ 3 files changed, 49 insertions(+) diff --git a/programs/winedbg/debugger.h b/programs/winedbg/debugger.h index 12ab719306f..319f0dc5f36 100644 --- a/programs/winedbg/debugger.h +++ b/programs/winedbg/debugger.h @@ -401,6 +401,8 @@ typedef enum sym_get_lval (*symbol_picker_t)(const char* name, const struct sgv_ extern symbol_picker_t symbol_current_picker; extern enum sym_get_lval symbol_picker_interactive(const char* name, const struct sgv_data* sgv, struct dbg_lvalue* rtn); +extern enum sym_get_lval symbol_picker_scoped(const char* name, const struct sgv_data* sgv, + struct dbg_lvalue* rtn); /* tgt_active.c */ extern void dbg_run_debuggee(const char* args); diff --git a/programs/winedbg/symbol.c b/programs/winedbg/symbol.c index 56f814bf0e2..90c5510e226 100644 --- a/programs/winedbg/symbol.c +++ b/programs/winedbg/symbol.c @@ -251,6 +251,38 @@ enum sym_get_lval symbol_picker_interactive(const char* name, const struct sgv_d return sglv_found; } +enum sym_get_lval symbol_picker_scoped(const char* name, const struct sgv_data* sgv, + struct dbg_lvalue* rtn) +{ + unsigned i; + int local = -1; + + for (i = 0; i < sgv->num; i++) + { + if (sgv->num - sgv->num_thunks > 1 && (sgv->syms[i].flags & SYMFLAG_THUNK) && !DBG_IVAR(AlwaysShowThunks)) + continue; + if (sgv->syms[i].flags & SYMFLAG_LOCAL) + { + if (local == -1) + local = i; + else + { + /* FIXME: several locals with same name... which one to pick ?? */ + dbg_printf("Several local variables/parameters for %s, aborting\n", name); + return sglv_aborted; + } + } + } + if (local != -1) + { + *rtn = sgv->syms[local].lvalue; + return sglv_found; + } + /* no locals found, multiple globals... abort for now */ + dbg_printf("Several global variables for %s, aborting\n", name); + return sglv_aborted; +} + symbol_picker_t symbol_current_picker = symbol_picker_interactive; /*********************************************************************** diff --git a/programs/winedbg/winedbg.c b/programs/winedbg/winedbg.c index 3fefd4c54a3..d1df695c497 100644 --- a/programs/winedbg/winedbg.c +++ b/programs/winedbg/winedbg.c @@ -517,6 +517,21 @@ void dbg_set_option(const char* option, const char* val) } SymSetOptions(opt); } + else if (!strcasecmp(option, "symbol_picker")) + { + if (!val) + dbg_printf("Option: symbol_picker %s\n", + symbol_current_picker == symbol_picker_interactive ? "interactive" : "scoped"); + else if (!strcasecmp(val, "interactive")) + symbol_current_picker = symbol_picker_interactive; + else if (!strcasecmp(val, "scoped")) + symbol_current_picker = symbol_picker_scoped; + else + { + dbg_printf("Syntax: symbol_picker [interactive|scoped]\n"); + return; + } + } else dbg_printf("Unknown option '%s'\n", option); }