diff --git a/programs/winedbg/break.c b/programs/winedbg/break.c index df40eaefa09..14050b07d6f 100644 --- a/programs/winedbg/break.c +++ b/programs/winedbg/break.c @@ -421,10 +421,15 @@ void DEBUG_AddBreakpointFromId(const char *name, int lineno) DBG_VALUE value; int i; - if (DEBUG_GetSymbolValue(name, lineno, &value, TRUE)) + switch (DEBUG_GetSymbolValue(name, lineno, &value, TRUE)) { + case gsv_found: DEBUG_AddBreakpoint(&value, NULL, TRUE); return; + case gsv_unknown: + break; + case gsv_aborted: /* user aborted symbol lookup */ + return; } DEBUG_Printf(DBG_CHN_MESG, "Unable to add breakpoint, will check again when a new DLL is loaded\n"); @@ -487,7 +492,7 @@ void DEBUG_CheckDelayedBP(void) { if (dbp[i].is_symbol) { - if (!DEBUG_GetSymbolValue(dbp[i].u.symbol.name, dbp[i].u.symbol.lineno, &value, TRUE)) + if (DEBUG_GetSymbolValue(dbp[i].u.symbol.name, dbp[i].u.symbol.lineno, &value, TRUE) != gsv_found) continue; } else @@ -586,10 +591,17 @@ void DEBUG_AddWatchpointFromId(const char *name) { DBG_VALUE value; - if( DEBUG_GetSymbolValue(name, -1, &value, TRUE) ) + switch (DEBUG_GetSymbolValue(name, -1, &value, TRUE)) + { + case gsv_found: DEBUG_AddWatchpoint( &value, 1 ); - else + break; + case gsv_unknown: DEBUG_Printf(DBG_CHN_MESG, "Unable to add watchpoint\n"); + break; + case gsv_aborted: /* user aborted symbol lookup */ + break; + } } /*********************************************************************** diff --git a/programs/winedbg/dbg.y b/programs/winedbg/dbg.y index 2c18c2bf31e..53450709317 100644 --- a/programs/winedbg/dbg.y +++ b/programs/winedbg/dbg.y @@ -405,6 +405,8 @@ static WINE_EXCEPTION_FILTER(wine_dbg_cmd) case DEBUG_STATUS_NO_FIELD: DEBUG_Printf(DBG_CHN_MESG, "No such field in structure or union\n"); break; + case DEBUG_STATUS_ABORT: + break; default: DEBUG_Printf(DBG_CHN_MESG, "Exception %lx\n", GetExceptionCode()); DEBUG_ExternalDebugger(); diff --git a/programs/winedbg/debugger.h b/programs/winedbg/debugger.h index 5dc26599fc1..84e36978ac6 100644 --- a/programs/winedbg/debugger.h +++ b/programs/winedbg/debugger.h @@ -291,6 +291,8 @@ typedef struct { #define OFFSET_OF(__c,__f) ((int)(((char*)&(((__c*)0)->__f))-((char*)0))) +enum get_sym_val {gsv_found, gsv_unknown, gsv_aborted}; + /* from winelib.so */ extern void DEBUG_ExternalDebugger(void); @@ -358,8 +360,7 @@ extern struct name_hash * DEBUG_AddSymbol( const char *name, const DBG_VALUE *addr, const char *sourcefile, int flags); -extern int DEBUG_GetSymbolValue( const char * name, const int lineno, - DBG_VALUE *addr, int ); +extern enum get_sym_val DEBUG_GetSymbolValue( const char * name, const int lineno, DBG_VALUE *addr, int ); extern BOOL DEBUG_SetSymbolValue( const char * name, const DBG_VALUE *addr ); extern const char * DEBUG_FindNearestSymbol( const DBG_ADDR *addr, int flag, struct name_hash ** rtn, @@ -582,6 +583,7 @@ inline static LPSTR DBG_strdup( LPCSTR str ) #define DEBUG_STATUS_DIV_BY_ZERO (DEBUG_STATUS_OFFSET+2) #define DEBUG_STATUS_BAD_TYPE (DEBUG_STATUS_OFFSET+3) #define DEBUG_STATUS_NO_FIELD (DEBUG_STATUS_OFFSET+4) +#define DEBUG_STATUS_ABORT (DEBUG_STATUS_OFFSET+5) extern DBG_INTVAR DEBUG_IntVars[]; diff --git a/programs/winedbg/expr.c b/programs/winedbg/expr.c index ce6f9ba3b1e..c40ef0a789e 100644 --- a/programs/winedbg/expr.c +++ b/programs/winedbg/expr.c @@ -350,10 +350,16 @@ DBG_VALUE DEBUG_EvalExpr(struct expr * exp) rtn.addr.seg = 0; break; case EXPR_TYPE_SYMBOL: - if( !DEBUG_GetSymbolValue(exp->un.symbol.name, -1, &rtn, FALSE) ) + switch (DEBUG_GetSymbolValue(exp->un.symbol.name, -1, &rtn, FALSE)) { - DEBUG_Printf(DBG_CHN_MESG, "%s\n", exp->un.symbol.name); + case gsv_found: + break; + case gsv_unknown: RaiseException(DEBUG_STATUS_NO_SYMBOL, 0, 0, NULL); + /* should never be here */ + case gsv_aborted: + RaiseException(DEBUG_STATUS_ABORT, 0, 0, NULL); + /* should never be here */ } break; case EXPR_TYPE_PSTRUCT: @@ -408,10 +414,17 @@ DBG_VALUE DEBUG_EvalExpr(struct expr * exp) /* * Now look up the address of the function itself. */ - if( !DEBUG_GetSymbolValue(exp->un.call.funcname, -1, &rtn, FALSE ) ) - { + switch (DEBUG_GetSymbolValue(exp->un.call.funcname, -1, &rtn, FALSE )) + { + case gsv_found: + break; + case gsv_unknown: RaiseException(DEBUG_STATUS_NO_SYMBOL, 0, 0, NULL); - } + /* should never be here */ + case gsv_aborted: + RaiseException(DEBUG_STATUS_ABORT, 0, 0, NULL); + /* should never be here */ + } #if 0 /* FIXME: NEWDBG NIY */ diff --git a/programs/winedbg/hash.c b/programs/winedbg/hash.c index cf6057e806b..dc6f3b937a4 100644 --- a/programs/winedbg/hash.c +++ b/programs/winedbg/hash.c @@ -346,6 +346,11 @@ BOOL DEBUG_Normalize(struct name_hash * nh ) * DEBUG_GetSymbolValue * * Get the address of a named symbol. + * Return values: + * gsv_found: if the symbol is found + * gsv_unknown: if the symbol isn't found + * gsv_aborted: some error occured (likely, many symbols of same name exist, + * and user didn't pick one of them) */ static int DEBUG_GSV_Helper(const char* name, const int lineno, DBG_VALUE* value, int num, int bp_flag) @@ -369,8 +374,9 @@ static int DEBUG_GSV_Helper(const char* name, const int lineno, return i; } -BOOL DEBUG_GetSymbolValue( const char * name, const int lineno, - DBG_VALUE *rtn, int bp_flag ) +enum get_sym_val DEBUG_GetSymbolValue( const char * name, + const int lineno, + DBG_VALUE *rtn, int bp_flag ) { #define NUMDBGV 10 /* FIXME: NUMDBGV should be made variable */ @@ -398,7 +404,7 @@ BOOL DEBUG_GetSymbolValue( const char * name, const int lineno, } if (num == 0) { - return FALSE; + return gsv_unknown; } else if (!DEBUG_InteractiveP || num == 1) { i = 0; } else { @@ -429,6 +435,7 @@ BOOL DEBUG_GetSymbolValue( const char * name, const int lineno, i = 0; if (DEBUG_ReadLine("=> ", buffer, sizeof(buffer))) { + if (buffer[0] == '\0') return gsv_aborted; i = atoi(buffer); if (i < 1 || i > num) DEBUG_Printf(DBG_CHN_MESG, "Invalid choice %d\n", i); @@ -439,7 +446,7 @@ BOOL DEBUG_GetSymbolValue( const char * name, const int lineno, i--; } *rtn = value[i]; - return TRUE; + return gsv_found; } /*********************************************************************** diff --git a/programs/winedbg/info.c b/programs/winedbg/info.c index 65911cc5fff..daa3e760660 100644 --- a/programs/winedbg/info.c +++ b/programs/winedbg/info.c @@ -709,7 +709,7 @@ void DEBUG_DbgChannel(BOOL turn_on, const char* chnl, const char* name) BOOL bAll; void* addr; - if (!DEBUG_GetSymbolValue("first_dll", -1, &val, FALSE)) + if (DEBUG_GetSymbolValue("first_dll", -1, &val, FALSE) != gsv_found) { DEBUG_Printf(DBG_CHN_MESG, "Can't get first_option symbol"); return; diff --git a/programs/winedbg/stabs.c b/programs/winedbg/stabs.c index 8d1e1c94efb..64f3ca8769f 100644 --- a/programs/winedbg/stabs.c +++ b/programs/winedbg/stabs.c @@ -1070,7 +1070,7 @@ static int DEBUG_ProcessElfSymtab(DBG_MODULE* module, char* addr, * we will have to keep the darned thing, because there can be * multiple local symbols by the same name. */ - if( (DEBUG_GetSymbolValue(symname, -1, &new_value, FALSE ) == TRUE) + if( (DEBUG_GetSymbolValue(symname, -1, &new_value, FALSE ) == gsv_found) && (new_value.addr.off == (load_addr + symp->st_value)) ) continue;