From 38f2be49f012a5da021849a8ecc8adb5d72567a8 Mon Sep 17 00:00:00 2001 From: Eric Pouech Date: Wed, 15 Aug 2001 17:40:31 +0000 Subject: [PATCH] Fixed the parsing of id1.id2 which could be either access to field id2 of struct id1, or the identifier id2 in dll id1. Enhanced some error reporting as well as 'info local' display layout. Minor cosmetic changes. --- debugger/dbg.y | 17 +++++++++++++---- debugger/debug.l | 11 +++++------ debugger/debugger.h | 2 ++ debugger/expr.c | 33 +++++++++++++++++++++------------ debugger/hash.c | 12 ++++++++---- debugger/module.c | 4 ++-- debugger/winedbg.c | 18 +++++++++++------- documentation/debugger.sgml | 8 +++----- 8 files changed, 65 insertions(+), 40 deletions(-) diff --git a/debugger/dbg.y b/debugger/dbg.y index 765728557bf..57c8012a6b3 100644 --- a/debugger/dbg.y +++ b/debugger/dbg.y @@ -75,7 +75,7 @@ int yyerror(char *); %type type_cast type_expr %type expr_addr lval_addr %type expr_value -%type pathname +%type pathname identifier %type list_arg @@ -196,14 +196,14 @@ print_command: break_command: tBREAK '*' expr_addr tEOL{ DEBUG_AddBreakpoint( &$3, NULL ); DEBUG_FreeExprMem(); } - | tBREAK tIDENTIFIER tEOL { DEBUG_AddBreakpointFromId($2, -1); } - | tBREAK tIDENTIFIER ':' tNUM tEOL { DEBUG_AddBreakpointFromId($2, $4); } + | tBREAK identifier tEOL { DEBUG_AddBreakpointFromId($2, -1); } + | tBREAK identifier ':' tNUM tEOL { DEBUG_AddBreakpointFromId($2, $4); } | tBREAK tNUM tEOL { DEBUG_AddBreakpointFromLineno($2); } | tBREAK tEOL { DEBUG_AddBreakpointFromLineno(-1); } watch_command: tWATCH '*' expr_addr tEOL { DEBUG_AddWatchpoint( &$3, 1 ); DEBUG_FreeExprMem(); } - | tWATCH tIDENTIFIER tEOL { DEBUG_AddWatchpointFromId($2); } + | tWATCH identifier tEOL { DEBUG_AddWatchpointFromId($2); } info_command: tINFO tBREAK tEOL { DEBUG_InfoBreakpoints(); } @@ -336,6 +336,12 @@ lvalue: | lvalue '.' tIDENTIFIER { $$ = DEBUG_StructExpr($1, $3); } | lvalue '[' expr ']' { $$ = DEBUG_BinopExpr(EXP_OP_ARR, $1, $3); } +identifier: + tIDENTIFIER { $$ = $1; } + | identifier '.' tIDENTIFIER { char* ptr = DBG_alloc(strlen($1) + 1 + strlen($3)+ 1); + sprintf(ptr, "%s.%s", $1, $3); $$ = DEBUG_MakeSymbol(ptr); + DBG_free(ptr); } + %% static void issue_prompt(void) @@ -376,6 +382,9 @@ static WINE_EXCEPTION_FILTER(wine_dbg_cmd) case DEBUG_STATUS_BAD_TYPE: DEBUG_Printf(DBG_CHN_MESG, "No type or type mismatch\n"); break; + case DEBUG_STATUS_NO_FIELD: + DEBUG_Printf(DBG_CHN_MESG, "No such field in structure or union\n"); + break; default: DEBUG_Printf(DBG_CHN_MESG, "Exception %lx\n", GetExceptionCode()); break; diff --git a/debugger/debug.l b/debugger/debug.l index 78dd6694d4b..c4ee4d1e1d0 100644 --- a/debugger/debug.l +++ b/debugger/debug.l @@ -18,7 +18,6 @@ YY_FATAL_ERROR( "read() in flex scanner failed" ); static int dbg_read(char * buf, int size); -static char * DEBUG_MakeSymbol(char *); #endif /* DONT_USE_READLINE */ @@ -30,7 +29,7 @@ static int syntax_error; DIGIT [0-9] HEXDIGIT [0-9a-fA-F] FORMAT [ubcdiswx] -IDENTIFIER [_a-zA-Z\.~][_a-zA-Z0-9\.~@]* +IDENTIFIER [_a-zA-Z~][_a-zA-Z0-9~@]* PATHNAME [/_a-zA-Z\.~][/_a-zA-Z0-9\.~@]* STRING \"[^\n"]+\" @@ -116,9 +115,9 @@ STRING \"[^\n"]+\" show|sho|sh { BEGIN(SHOW_CMD); return tSHOW; } symbolfile|symbols|symbol|sf { BEGIN(PATH_EXPECTED); return tSYMBOLFILE; } -break|brea|bre|br|b { BEGIN(PATH_EXPECTED); return tBREAK; } -watch|watc|wat { BEGIN(PATH_EXPECTED); return tWATCH; } -whatis|whati|what { BEGIN(PATH_EXPECTED); return tWHATIS; } +break|brea|bre|br|b { BEGIN(NOCMD); return tBREAK; } +watch|watc|wat { BEGIN(NOCMD); return tWATCH; } +whatis|whati|what { BEGIN(NOCMD); return tWHATIS; } run|ru|r { BEGIN(ASTRING_EXPECTED); return tRUN;} attach|attac|atta|att { BEGIN(NOCMD); return tATTACH; } share|shar|sha { return tSHARE; } @@ -247,7 +246,7 @@ static int dbg_read(char * buf, int size) static char *local_symbols[30]; static int next_symbol; -static char * DEBUG_MakeSymbol(char * symbol) +char * DEBUG_MakeSymbol(const char * symbol) { assert(0 <= next_symbol && next_symbol < (sizeof(local_symbols) / sizeof(local_symbols[0]))); return local_symbols[next_symbol++] = DBG_strdup(symbol); diff --git a/debugger/debugger.h b/debugger/debugger.h index 0d2a064225b..567b9497b7e 100644 --- a/debugger/debugger.h +++ b/debugger/debugger.h @@ -286,6 +286,7 @@ extern void DEBUG_Exit( DWORD ); /* debugger/debug.l */ extern void DEBUG_FlushSymbols(void); +extern char*DEBUG_MakeSymbol(const char*); /* debugger/display.c */ extern int DEBUG_DoDisplay(void); @@ -534,6 +535,7 @@ extern HANDLE dbg_heap; #define DEBUG_STATUS_NO_SYMBOL (DEBUG_STATUS_OFFSET+1) #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) extern DBG_INTVAR DEBUG_IntVars[]; diff --git a/debugger/expr.c b/debugger/expr.c index 2bcac137dbb..45492f1b475 100644 --- a/debugger/expr.c +++ b/debugger/expr.c @@ -333,9 +333,10 @@ DBG_VALUE DEBUG_EvalExpr(struct expr * exp) break; case EXPR_TYPE_SYMBOL: if( !DEBUG_GetSymbolValue(exp->un.symbol.name, -1, &rtn, FALSE) ) - { - RaiseException(DEBUG_STATUS_NO_SYMBOL, 0, 0, NULL); - } + { + DEBUG_Printf(DBG_CHN_MESG, "%s\n", exp->un.symbol.name); + RaiseException(DEBUG_STATUS_NO_SYMBOL, 0, 0, NULL); + } break; case EXPR_TYPE_PSTRUCT: exp1 = DEBUG_EvalExpr(exp->un.structure.exp1); @@ -344,24 +345,32 @@ DBG_VALUE DEBUG_EvalExpr(struct expr * exp) RaiseException(DEBUG_STATUS_BAD_TYPE, 0, 0, NULL); } rtn.cookie = DV_TARGET; - rtn.addr.off = DEBUG_TypeDerefPointer(&exp1, &type1); - if( type1 == NULL ) + rtn.addr.off = DEBUG_TypeDerefPointer(&exp1, &rtn.type); + if( rtn.type == NULL ) { RaiseException(DEBUG_STATUS_BAD_TYPE, 0, 0, NULL); } - rtn.type = type1; - DEBUG_FindStructElement(&rtn, exp->un.structure.element_name, - &exp->un.structure.result); + if (!DEBUG_FindStructElement(&rtn, exp->un.structure.element_name, + &exp->un.structure.result)) + { + DEBUG_Printf(DBG_CHN_MESG, "%s\n", exp->un.structure.element_name); + RaiseException(DEBUG_STATUS_NO_FIELD, 0, 0, NULL); + } + break; case EXPR_TYPE_STRUCT: exp1 = DEBUG_EvalExpr(exp->un.structure.exp1); if( exp1.type == NULL ) - { + { RaiseException(DEBUG_STATUS_BAD_TYPE, 0, 0, NULL); - } + } rtn = exp1; - DEBUG_FindStructElement(&rtn, exp->un.structure.element_name, - &exp->un.structure.result); + if (!DEBUG_FindStructElement(&rtn, exp->un.structure.element_name, + &exp->un.structure.result)) + { + DEBUG_Printf(DBG_CHN_MESG, "%s\n", exp->un.structure.element_name); + RaiseException(DEBUG_STATUS_NO_FIELD, 0, 0, NULL); + } break; case EXPR_TYPE_CALL: /* diff --git a/debugger/hash.c b/debugger/hash.c index 86c809a7a0e..a76d6322b0b 100644 --- a/debugger/hash.c +++ b/debugger/hash.c @@ -1214,6 +1214,8 @@ DEBUG_InfoLocals(void) return FALSE; } + DEBUG_Printf(DBG_CHN_MESG, "%s:\n", curr_func->name); + for(i=0; i < curr_func->n_locals; i++ ) { /* @@ -1234,12 +1236,14 @@ DEBUG_InfoLocals(void) continue; } + DEBUG_PrintTypeCast(curr_func->local_vars[i].type); + if( curr_func->local_vars[i].regno != 0 ) { ptr = (unsigned int *)(((DWORD)&DEBUG_context) + reg_ofs[curr_func->local_vars[i].regno - 1]); - DEBUG_Printf(DBG_CHN_MESG, "%s:%s (optimized into register $%s) == 0x%8.8x\n", - curr_func->name, curr_func->local_vars[i].name, + DEBUG_Printf(DBG_CHN_MESG, " %s (optimized into register $%s) == 0x%8.8x\n", + curr_func->local_vars[i].name, reg_name[curr_func->local_vars[i].regno - 1], *ptr); } @@ -1247,8 +1251,8 @@ DEBUG_InfoLocals(void) { DEBUG_READ_MEM_VERBOSE((void*)(ebp + curr_func->local_vars[i].offset), &val, sizeof(val)); - DEBUG_Printf(DBG_CHN_MESG, "%s:%s == 0x%8.8x\n", - curr_func->name, curr_func->local_vars[i].name, val); + DEBUG_Printf(DBG_CHN_MESG, " %s == 0x%8.8x\n", + curr_func->local_vars[i].name, val); } } diff --git a/debugger/module.c b/debugger/module.c index cce20da6350..dfc43abf40e 100644 --- a/debugger/module.c +++ b/debugger/module.c @@ -282,7 +282,7 @@ void DEBUG_LoadModule32(const char* name, HANDLE hFile, DWORD base) if (size < pe_seg.VirtualAddress + pe_seg.SizeOfRawData) size = pe_seg.VirtualAddress + pe_seg.SizeOfRawData; } - + /* FIXME: we make the assumption that hModule == base */ wmod = DEBUG_RegisterPEModule((HMODULE)base, base, size, name); if (wmod) { @@ -291,9 +291,9 @@ void DEBUG_LoadModule32(const char* name, HANDLE hFile, DWORD base) dil = DEBUG_RegisterMSCDebugInfo(wmod, hFile, &pe_header, nth_ofs); if (dil != DIL_LOADED) dil = DEBUG_RegisterPEDebugInfo(wmod, hFile, &pe_header, nth_ofs); + wmod->dil = dil; } - if (wmod) wmod->dil = dil; DEBUG_ReportDIL(dil, "32bit DLL", name, base); } diff --git a/debugger/winedbg.c b/debugger/winedbg.c index f157c0124b7..2ac92f83ab1 100644 --- a/debugger/winedbg.c +++ b/debugger/winedbg.c @@ -297,25 +297,26 @@ static BOOL DEBUG_ExceptionProlog(BOOL is_debug, BOOL force, DWORD code) if (!is_debug) { if (!addr.seg) - DEBUG_Printf(DBG_CHN_MESG, " in 32-bit code (0x%08lx).\n", addr.off); + DEBUG_Printf(DBG_CHN_MESG, " in 32-bit code (0x%08lx)", addr.off); else switch(DEBUG_GetSelectorType(addr.seg)) { case MODE_32: - DEBUG_Printf(DBG_CHN_MESG, " in 32-bit code (%04lx:%08lx).\n", addr.seg, addr.off); + DEBUG_Printf(DBG_CHN_MESG, " in 32-bit code (%04lx:%08lx)", addr.seg, addr.off); break; case MODE_16: - DEBUG_Printf(DBG_CHN_MESG, " in 16-bit code (%04lx:%04lx).\n", addr.seg, addr.off); + DEBUG_Printf(DBG_CHN_MESG, " in 16-bit code (%04lx:%04lx)", addr.seg, addr.off); break; case MODE_VM86: - DEBUG_Printf(DBG_CHN_MESG, " in vm86 code (%04lx:%04lx).\n", addr.seg, addr.off); + DEBUG_Printf(DBG_CHN_MESG, " in vm86 code (%04lx:%04lx)", addr.seg, addr.off); break; case MODE_INVALID: - DEBUG_Printf(DBG_CHN_MESG, "bad CS (%lx)\n", addr.seg); + DEBUG_Printf(DBG_CHN_MESG, " bad CS (%lx)", addr.seg); break; } + DEBUG_Printf(DBG_CHN_MESG, ".\n"); } - + DEBUG_LoadEntryPoints("Loading new modules symbols:\n"); if (!force && is_debug && @@ -505,9 +506,9 @@ static BOOL DEBUG_HandleException(EXCEPTION_RECORD *rec, BOOL first_chance, BOOL DEBUG_Printf(DBG_CHN_MESG, "%08lx", rec->ExceptionCode); break; } - DEBUG_Printf(DBG_CHN_MESG, "\n"); } +#if 0 DEBUG_Printf(DBG_CHN_TRACE, "Entering debugger PC=%lx EFL=%08lx mode=%d count=%d\n", #ifdef __i386__ @@ -516,6 +517,7 @@ static BOOL DEBUG_HandleException(EXCEPTION_RECORD *rec, BOOL first_chance, BOOL 0L, 0L, #endif DEBUG_CurrThread->dbg_exec_mode, DEBUG_CurrThread->dbg_exec_count); +#endif if (DEBUG_ExceptionProlog(is_debug, force, rec->ExceptionCode)) { DEBUG_interactiveP = TRUE; @@ -530,6 +532,7 @@ static BOOL DEBUG_HandleException(EXCEPTION_RECORD *rec, BOOL first_chance, BOOL } *cont = DEBUG_ExceptionEpilog(); +#if 0 DEBUG_Printf(DBG_CHN_TRACE, "Exiting debugger PC=%lx EFL=%08lx mode=%d count=%d\n", #ifdef __i386__ @@ -538,6 +541,7 @@ static BOOL DEBUG_HandleException(EXCEPTION_RECORD *rec, BOOL first_chance, BOOL 0L, 0L, #endif DEBUG_CurrThread->dbg_exec_mode, DEBUG_CurrThread->dbg_exec_count); +#endif return ret; } diff --git a/documentation/debugger.sgml b/documentation/debugger.sgml index dfd15e5bebc..da1380a3980 100644 --- a/documentation/debugger.sgml +++ b/documentation/debugger.sgml @@ -1494,11 +1494,9 @@ b => 8 bit unsigned hexadecimal integer - Because of previous rule, fields access from a struct must be written as: - - my_struct . my_field - - (note the spaces after and before the dot). + The debugger will try to distinguish this writing with structure operations. + Therefore, you can only use the previous writing in operations manipulating + symbols ({break|watch}points, type information command...).