Added ability to abort on interactive symbol lookup.

This commit is contained in:
Eric Pouech 2002-09-16 19:26:48 +00:00 committed by Alexandre Julliard
parent 43baa0acd8
commit 2fc867c045
7 changed files with 53 additions and 17 deletions

View file

@ -421,10 +421,15 @@ void DEBUG_AddBreakpointFromId(const char *name, int lineno)
DBG_VALUE value; DBG_VALUE value;
int i; int i;
if (DEBUG_GetSymbolValue(name, lineno, &value, TRUE)) switch (DEBUG_GetSymbolValue(name, lineno, &value, TRUE))
{ {
case gsv_found:
DEBUG_AddBreakpoint(&value, NULL, TRUE); DEBUG_AddBreakpoint(&value, NULL, TRUE);
return; 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"); 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 (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; continue;
} }
else else
@ -586,10 +591,17 @@ void DEBUG_AddWatchpointFromId(const char *name)
{ {
DBG_VALUE value; DBG_VALUE value;
if( DEBUG_GetSymbolValue(name, -1, &value, TRUE) ) switch (DEBUG_GetSymbolValue(name, -1, &value, TRUE))
{
case gsv_found:
DEBUG_AddWatchpoint( &value, 1 ); DEBUG_AddWatchpoint( &value, 1 );
else break;
case gsv_unknown:
DEBUG_Printf(DBG_CHN_MESG, "Unable to add watchpoint\n"); DEBUG_Printf(DBG_CHN_MESG, "Unable to add watchpoint\n");
break;
case gsv_aborted: /* user aborted symbol lookup */
break;
}
} }
/*********************************************************************** /***********************************************************************

View file

@ -405,6 +405,8 @@ static WINE_EXCEPTION_FILTER(wine_dbg_cmd)
case DEBUG_STATUS_NO_FIELD: case DEBUG_STATUS_NO_FIELD:
DEBUG_Printf(DBG_CHN_MESG, "No such field in structure or union\n"); DEBUG_Printf(DBG_CHN_MESG, "No such field in structure or union\n");
break; break;
case DEBUG_STATUS_ABORT:
break;
default: default:
DEBUG_Printf(DBG_CHN_MESG, "Exception %lx\n", GetExceptionCode()); DEBUG_Printf(DBG_CHN_MESG, "Exception %lx\n", GetExceptionCode());
DEBUG_ExternalDebugger(); DEBUG_ExternalDebugger();

View file

@ -291,6 +291,8 @@ typedef struct {
#define OFFSET_OF(__c,__f) ((int)(((char*)&(((__c*)0)->__f))-((char*)0))) #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 */ /* from winelib.so */
extern void DEBUG_ExternalDebugger(void); extern void DEBUG_ExternalDebugger(void);
@ -358,8 +360,7 @@ extern struct name_hash * DEBUG_AddSymbol( const char *name,
const DBG_VALUE *addr, const DBG_VALUE *addr,
const char *sourcefile, const char *sourcefile,
int flags); int flags);
extern int DEBUG_GetSymbolValue( const char * name, const int lineno, extern enum get_sym_val DEBUG_GetSymbolValue( const char * name, const int lineno, DBG_VALUE *addr, int );
DBG_VALUE *addr, int );
extern BOOL DEBUG_SetSymbolValue( const char * name, const DBG_VALUE *addr ); extern BOOL DEBUG_SetSymbolValue( const char * name, const DBG_VALUE *addr );
extern const char * DEBUG_FindNearestSymbol( const DBG_ADDR *addr, int flag, extern const char * DEBUG_FindNearestSymbol( const DBG_ADDR *addr, int flag,
struct name_hash ** rtn, 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_DIV_BY_ZERO (DEBUG_STATUS_OFFSET+2)
#define DEBUG_STATUS_BAD_TYPE (DEBUG_STATUS_OFFSET+3) #define DEBUG_STATUS_BAD_TYPE (DEBUG_STATUS_OFFSET+3)
#define DEBUG_STATUS_NO_FIELD (DEBUG_STATUS_OFFSET+4) #define DEBUG_STATUS_NO_FIELD (DEBUG_STATUS_OFFSET+4)
#define DEBUG_STATUS_ABORT (DEBUG_STATUS_OFFSET+5)
extern DBG_INTVAR DEBUG_IntVars[]; extern DBG_INTVAR DEBUG_IntVars[];

View file

@ -350,10 +350,16 @@ DBG_VALUE DEBUG_EvalExpr(struct expr * exp)
rtn.addr.seg = 0; rtn.addr.seg = 0;
break; break;
case EXPR_TYPE_SYMBOL: 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); 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; break;
case EXPR_TYPE_PSTRUCT: case EXPR_TYPE_PSTRUCT:
@ -408,10 +414,17 @@ DBG_VALUE DEBUG_EvalExpr(struct expr * exp)
/* /*
* Now look up the address of the function itself. * 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); 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 #if 0
/* FIXME: NEWDBG NIY */ /* FIXME: NEWDBG NIY */

View file

@ -346,6 +346,11 @@ BOOL DEBUG_Normalize(struct name_hash * nh )
* DEBUG_GetSymbolValue * DEBUG_GetSymbolValue
* *
* Get the address of a named symbol. * 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, static int DEBUG_GSV_Helper(const char* name, const int lineno,
DBG_VALUE* value, int num, int bp_flag) 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; return i;
} }
BOOL DEBUG_GetSymbolValue( const char * name, const int lineno, enum get_sym_val DEBUG_GetSymbolValue( const char * name,
DBG_VALUE *rtn, int bp_flag ) const int lineno,
DBG_VALUE *rtn, int bp_flag )
{ {
#define NUMDBGV 10 #define NUMDBGV 10
/* FIXME: NUMDBGV should be made variable */ /* FIXME: NUMDBGV should be made variable */
@ -398,7 +404,7 @@ BOOL DEBUG_GetSymbolValue( const char * name, const int lineno,
} }
if (num == 0) { if (num == 0) {
return FALSE; return gsv_unknown;
} else if (!DEBUG_InteractiveP || num == 1) { } else if (!DEBUG_InteractiveP || num == 1) {
i = 0; i = 0;
} else { } else {
@ -429,6 +435,7 @@ BOOL DEBUG_GetSymbolValue( const char * name, const int lineno,
i = 0; i = 0;
if (DEBUG_ReadLine("=> ", buffer, sizeof(buffer))) if (DEBUG_ReadLine("=> ", buffer, sizeof(buffer)))
{ {
if (buffer[0] == '\0') return gsv_aborted;
i = atoi(buffer); i = atoi(buffer);
if (i < 1 || i > num) if (i < 1 || i > num)
DEBUG_Printf(DBG_CHN_MESG, "Invalid choice %d\n", i); DEBUG_Printf(DBG_CHN_MESG, "Invalid choice %d\n", i);
@ -439,7 +446,7 @@ BOOL DEBUG_GetSymbolValue( const char * name, const int lineno,
i--; i--;
} }
*rtn = value[i]; *rtn = value[i];
return TRUE; return gsv_found;
} }
/*********************************************************************** /***********************************************************************

View file

@ -709,7 +709,7 @@ void DEBUG_DbgChannel(BOOL turn_on, const char* chnl, const char* name)
BOOL bAll; BOOL bAll;
void* addr; 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"); DEBUG_Printf(DBG_CHN_MESG, "Can't get first_option symbol");
return; return;

View file

@ -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 * we will have to keep the darned thing, because there can be
* multiple local symbols by the same name. * 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)) ) && (new_value.addr.off == (load_addr + symp->st_value)) )
continue; continue;