From 45adf0843f475b8755e5ee0eca64cf437edc7633 Mon Sep 17 00:00:00 2001 From: Eric Pouech Date: Thu, 30 Jan 2003 00:24:18 +0000 Subject: [PATCH] - Removed no longer used queue & modref related commands. - Protected walk commands while being called with no process loaded. - In command grammar, allowed some expressions while only numbers where accepted. - Renamed 'info maps' info 'walk maps' and let it work on any process. --- documentation/debugger.sgml | 18 +++++------ programs/winedbg/dbg.y | 46 ++++++++++++++--------------- programs/winedbg/debug.l | 4 +-- programs/winedbg/debugger.h | 7 ++--- programs/winedbg/info.c | 59 +++++++++++++++++++++---------------- programs/winedbg/module.c | 7 +++++ 6 files changed, 75 insertions(+), 66 deletions(-) diff --git a/documentation/debugger.sgml b/documentation/debugger.sgml index 3419029548e..4dbf8ce119e 100644 --- a/documentation/debugger.sgml +++ b/documentation/debugger.sgml @@ -1455,28 +1455,26 @@ disas <expr>,<expr>disassembles code between addresses specified by Information on Wine's internals -info class <id> prints information on Windows's class <id> +info class <id> prints information on Windows's class <id> walk class lists all Windows' class registered in Wine info share lists all the dynamic libraries loaded the debugged program (including .so files, NE and PE DLLs) -info module N prints information on module of handle N +info module <N> prints information on module of handle <N> walk module lists all modules loaded by debugged program -info queue N prints information on Wine's queue N -walk queue lists all queues allocated in Wine info regs prints the value of CPU register -info segment N prints information on segment N +info segment <N>prints information on segment <N> info segment lists all allocated segments info stack prints the values on top of the stack -info map lists all virtual mappings used by the debugged +walk map lists all virtual mappings used by the debugged program -info wnd N prints information of Window of handle N +walk map <N> lists all virtual mappings used by the program of pid <N> +info wnd <N> prints information of Window of handle <N> walk wnd lists all the window hierarchy starting from the desktop window -walk wnd N lists all the window hierarchy starting from the - window of handle N +walk wnd <N> lists all the window hierarchy starting from the + window of handle <N> walk process lists all w-processes in Wine session walk thread lists all w-threads in Wine session -walk modref (no longer avail) walk exception lists the exception frames (starting from current stack frame) diff --git a/programs/winedbg/dbg.y b/programs/winedbg/dbg.y index 16d542e7d42..dc64209b62c 100644 --- a/programs/winedbg/dbg.y +++ b/programs/winedbg/dbg.y @@ -52,6 +52,8 @@ int yyerror(char *); %token tCONT tPASS tSTEP tLIST tNEXT tQUIT tHELP tBACKTRACE tINFO tWALK tUP tDOWN %token tENABLE tDISABLE tBREAK tWATCH tDELETE tSET tMODE tPRINT tEXAM tABORT tVM86 +%token tCLASS tMAPS tMODULE tSTACK tSEGMENTS tSYMBOL tREGS tWND tLOCAL tEXCEPTION +%token tPROCESS tTHREAD tEOL tEOF %token tCLASS tMAPS tMODULE tSTACK tSEGMENTS tSYMBOL tREGS tWND tQUEUE tLOCAL tEXCEPTION %token tPROCESS tTHREAD tMODREF tEOL tEOF %token tFRAME tSHARE tCOND tDISPLAY tUNDISPLAY tDISASSEMBLE @@ -104,7 +106,7 @@ line: command ; command: - tQUIT tEOL { /*DEBUG_Quit();*/ return 1; } + tQUIT tEOL { /*DEBUG_Quit();*/ return 1; } | tHELP tEOL { DEBUG_Help(); } | tHELP tINFO tEOL { DEBUG_HelpInfo(); } | tPASS tEOL { DEBUG_WaitNextException(DBG_EXCEPTION_NOT_HANDLED, 0, 0); } @@ -122,8 +124,8 @@ command: | tABORT tEOL { kill(getpid(), SIGABRT); } | tMODE tNUM tEOL { mode_command($2); } | tMODE tVM86 tEOL { DEBUG_CurrThread->dbg_mode = MODE_VM86; } - | tENABLE tNUM tEOL { DEBUG_EnableBreakpoint( $2, TRUE ); } - | tDISABLE tNUM tEOL { DEBUG_EnableBreakpoint( $2, FALSE ); } + | tENABLE tNUM tEOL { DEBUG_EnableBreakpoint( $2, TRUE ); } + | tDISABLE tNUM tEOL { DEBUG_EnableBreakpoint( $2, FALSE ); } | tDELETE tBREAK tNUM tEOL { DEBUG_DelBreakpoint( $3 ); } | tBACKTRACE tEOL { DEBUG_BackTrace(DEBUG_CurrTid, TRUE); } | tBACKTRACE tNUM tEOL { DEBUG_BackTrace($2, TRUE); } @@ -165,28 +167,28 @@ command: set_command: tSET lval_addr '=' expr_value tEOL { DEBUG_WriteMemory(&$2, $4); DEBUG_FreeExprMem(); } - | tSET '+' tIDENTIFIER tEOL {DEBUG_DbgChannel(TRUE, NULL, $3);} - | tSET '-' tIDENTIFIER tEOL {DEBUG_DbgChannel(FALSE, NULL, $3);} - | tSET tIDENTIFIER '+' tIDENTIFIER tEOL {DEBUG_DbgChannel(TRUE, $2, $4);} - | tSET tIDENTIFIER '-' tIDENTIFIER tEOL {DEBUG_DbgChannel(FALSE, $2, $4);} + | tSET '+' tIDENTIFIER tEOL { DEBUG_DbgChannel(TRUE, NULL, $3); } + | tSET '-' tIDENTIFIER tEOL { DEBUG_DbgChannel(FALSE, NULL, $3); } + | tSET tIDENTIFIER '+' tIDENTIFIER tEOL { DEBUG_DbgChannel(TRUE, $2, $4); } + | tSET tIDENTIFIER '-' tIDENTIFIER tEOL { DEBUG_DbgChannel(FALSE, $2, $4); } ; pathname: - tIDENTIFIER { $$ = $1; } - | tPATH { $$ = $1; } + tIDENTIFIER { $$ = $1; } + | tPATH { $$ = $1; } ; disassemble_command: - tDISASSEMBLE tEOL { DEBUG_Disassemble( NULL, NULL, 10 ); } - | tDISASSEMBLE expr_addr tEOL { DEBUG_Disassemble( & $2, NULL, 10 ); } + tDISASSEMBLE tEOL { DEBUG_Disassemble( NULL, NULL, 10 ); } + | tDISASSEMBLE expr_addr tEOL { DEBUG_Disassemble( & $2, NULL, 10 ); } | tDISASSEMBLE expr_addr ',' expr_addr tEOL { DEBUG_Disassemble( & $2, & $4, 0 ); } ; list_command: - tLIST tEOL { DEBUG_List( NULL, NULL, 10 ); } - | tLIST '-' tEOL { DEBUG_List( NULL, NULL, -10 ); } - | tLIST list_arg tEOL { DEBUG_List( & $2, NULL, 10 ); } - | tLIST ',' list_arg tEOL { DEBUG_List( NULL, & $3, -10 ); } + tLIST tEOL { DEBUG_List( NULL, NULL, 10 ); } + | tLIST '-' tEOL { DEBUG_List( NULL, NULL, -10 ); } + | tLIST list_arg tEOL { DEBUG_List( & $2, NULL, 10 ); } + | tLIST ',' list_arg tEOL { DEBUG_List( NULL, & $3, -10 ); } | tLIST list_arg ',' list_arg tEOL { DEBUG_List( & $2, & $4, 0 ); } ; @@ -229,13 +231,11 @@ info_command: | tINFO tCLASS tSTRING tEOL { DEBUG_InfoClass( $3 ); } | tINFO tSHARE tEOL { DEBUG_InfoShare(); } | tINFO tMODULE expr_value tEOL { DEBUG_DumpModule( $3 ); DEBUG_FreeExprMem(); } - | tINFO tQUEUE expr_value tEOL { DEBUG_DumpQueue( $3 ); DEBUG_FreeExprMem(); } | tINFO tREGS tEOL { DEBUG_InfoRegisters(&DEBUG_context); } | tINFO tSEGMENTS expr_value tEOL { DEBUG_InfoSegments( $3, 1 ); DEBUG_FreeExprMem(); } | tINFO tSEGMENTS tEOL { DEBUG_InfoSegments( 0, -1 ); } | tINFO tSTACK tEOL { DEBUG_InfoStack(); } - | tINFO tSYMBOL tSTRING { DEBUG_InfoSymbols($3); } - | tINFO tMAPS tEOL { DEBUG_InfoVirtual(); } + | tINFO tSYMBOL tSTRING tEOL{ DEBUG_InfoSymbols($3); } | tINFO tWND expr_value tEOL{ DEBUG_InfoWindow( (HWND)$3 ); DEBUG_FreeExprMem(); } | tINFO tLOCAL tEOL { DEBUG_InfoLocals(); } | tINFO tDISPLAY tEOL { DEBUG_InfoDisplay(); } @@ -244,14 +244,14 @@ info_command: walk_command: tWALK tCLASS tEOL { DEBUG_WalkClasses(); } | tWALK tMODULE tEOL { DEBUG_WalkModules(); } - | tWALK tQUEUE tEOL { DEBUG_WalkQueues(); } | tWALK tWND tEOL { DEBUG_WalkWindows( 0, 0 ); } - | tWALK tWND tNUM tEOL { DEBUG_WalkWindows( (HWND)$3, 0 ); } + | tWALK tWND expr_value tEOL{ DEBUG_WalkWindows( (HWND)$3, 0 ); DEBUG_FreeExprMem(); } + | tWALK tMAPS tEOL { DEBUG_InfoVirtual(0); } + | tWALK tMAPS expr_value tEOL { DEBUG_InfoVirtual($3); DEBUG_FreeExprMem(); } | tWALK tPROCESS tEOL { DEBUG_WalkProcess(); } | tWALK tTHREAD tEOL { DEBUG_WalkThreads(); } - | tWALK tEXCEPTION tEOL { DEBUG_WalkExceptions(DEBUG_CurrTid); } - | tWALK tEXCEPTION tNUM tEOL { DEBUG_WalkExceptions($3); } - | tWALK tMODREF expr_value tEOL { DEBUG_WalkModref( $3 ); DEBUG_FreeExprMem(); } + | tWALK tEXCEPTION tEOL { DEBUG_WalkExceptions(DEBUG_CurrTid); } + | tWALK tEXCEPTION expr_value tEOL{ DEBUG_WalkExceptions($3); DEBUG_FreeExprMem(); } ; run_command: diff --git a/programs/winedbg/debug.l b/programs/winedbg/debug.l index 28df1795b74..7b1374cc515 100644 --- a/programs/winedbg/debug.l +++ b/programs/winedbg/debug.l @@ -144,16 +144,14 @@ STRING \"[^\n"]+\" locals|local|loca|loc { return tLOCAL; } class|clas|cla { return tCLASS; } module|modul|modu|mod { return tMODULE; } -queue|queu|que { return tQUEUE; } process|proces|proce|proc { return tPROCESS; } threads|thread|threa|thre|thr|th { return tTHREAD; } -modref|modre|modr { return tMODREF; } exception|except|exc|ex { return tEXCEPTION; } registers|regs|reg|re { return tREGS; } segments|segment|segm|seg|se { return tSEGMENTS; } stack|stac|sta|st { return tSTACK; } symbol|sym { BEGIN(ASTRING_EXPECTED); return tSYMBOL; } -maps|map { return tMAPS; } +maps|map { return tMAPS; } window|windo|wind|win|wnd { return tWND; } info|inf|in { return tINFO; } vm86 { return tVM86; } diff --git a/programs/winedbg/debugger.h b/programs/winedbg/debugger.h index f50ee1d6377..66ef468c545 100644 --- a/programs/winedbg/debugger.h +++ b/programs/winedbg/debugger.h @@ -248,7 +248,7 @@ extern DBG_PROCESS* DEBUG_CurrProcess; extern DBG_THREAD* DEBUG_CurrThread; extern DWORD DEBUG_CurrTid; extern DWORD DEBUG_CurrPid; -extern CONTEXT DEBUG_context; +extern CONTEXT DEBUG_context; extern BOOL DEBUG_InteractiveP; extern enum exit_mode DEBUG_ExitMode; extern HANDLE DEBUG_hParserInput; @@ -402,16 +402,13 @@ extern struct symbol_info DEBUG_PrintAddressAndArgs( const DBG_ADDR *addr, int flag ); extern void DEBUG_InfoClass(const char* clsName); extern void DEBUG_WalkClasses(void); -extern void DEBUG_WalkModref(DWORD p); extern void DEBUG_DumpModule(DWORD mod); extern void DEBUG_WalkModules(void); extern void DEBUG_WalkProcess(void); extern void DEBUG_WalkThreads(void); extern void DEBUG_WalkExceptions(DWORD tid); -extern void DEBUG_DumpQueue(DWORD q); -extern void DEBUG_WalkQueues(void); extern void DEBUG_InfoSegments(DWORD s, int v); -extern void DEBUG_InfoVirtual(void); +extern void DEBUG_InfoVirtual(DWORD pid); extern void DEBUG_InfoWindow(HWND hWnd); extern void DEBUG_WalkWindows(HWND hWnd, int indent); extern void DEBUG_DbgChannel(BOOL add, const char* chnl, const char* name); diff --git a/programs/winedbg/info.c b/programs/winedbg/info.c index 4e31e5907b7..3290d4ef3e3 100644 --- a/programs/winedbg/info.c +++ b/programs/winedbg/info.c @@ -220,8 +220,8 @@ void DEBUG_Help(void) " list disassemble [][,]", " show dir dir ", " set = set * = ", -" mode [16,32,vm86] walk [wnd,class,queue,module,", -" whatis process,modref ]", +" mode [16,32,vm86] walk [wnd,class,module,maps,", +" whatis process,thread,exception]", " info (see 'help info' for options) debugmsg [-+]\n", "The 'x' command accepts repeat counts and formats (including 'i') in the", @@ -255,9 +255,7 @@ void DEBUG_HelpInfo(void) " info break Dumps information about breakpoints", " info display Shows auto-display expressions in use", " info locals Displays values of all local vars for current frame", -" info maps Dumps all virtual memory mappings", " info module Displays internal module state", -" info queue Displays internal queue state", " info reg Displays values in all registers at top of stack", " info segments Dumps information about all known segments", " info share Dumps information about shared libraries", @@ -375,16 +373,6 @@ void DEBUG_WalkClasses(void) DBG_free(cw.table); } -void DEBUG_DumpQueue(DWORD q) -{ - DEBUG_Printf(DBG_CHN_MESG, "No longer doing info queue '0x%08lx'\n", q); -} - -void DEBUG_WalkQueues(void) -{ - DEBUG_Printf(DBG_CHN_MESG, "No longer walking queues list\n"); -} - void DEBUG_InfoWindow(HWND hWnd) { char clsName[128]; @@ -538,11 +526,6 @@ void DEBUG_WalkThreads(void) } } -void DEBUG_WalkModref(DWORD p) -{ - DEBUG_Printf(DBG_CHN_MESG, "No longer walking module references list\n"); -} - /*********************************************************************** * DEBUG_WalkExceptions * @@ -553,6 +536,13 @@ void DEBUG_WalkExceptions(DWORD tid) DBG_THREAD * thread; void *next_frame; + if (!DEBUG_CurrProcess || !DEBUG_CurrThread) + { + DEBUG_Printf(DBG_CHN_MESG, + "Cannot walk exceptions while no process is loaded\n"); + return; + } + DEBUG_Printf( DBG_CHN_MESG, "Exception frames:\n" ); if (tid == DEBUG_CurrTid) thread = DEBUG_CurrThread; @@ -606,8 +596,8 @@ void DEBUG_InfoSegments(DWORD start, int length) for (i = start; i < start + length; i++) { - if (!GetThreadSelectorEntry(DEBUG_CurrThread->handle, (i << 3)|7, &le)) - continue; + if (!GetThreadSelectorEntry(DEBUG_CurrThread->handle, (i << 3) | 7, &le)) + continue; if (le.HighWord.Bits.Type & 0x08) { @@ -633,20 +623,38 @@ void DEBUG_InfoSegments(DWORD start, int length) } } -void DEBUG_InfoVirtual(void) +void DEBUG_InfoVirtual(DWORD pid) { MEMORY_BASIC_INFORMATION mbi; char* addr = 0; char* state; char* type; char prot[3+1]; + HANDLE hProc; - if (DEBUG_CurrProcess == NULL) - return; + if (pid == 0) + { + if (DEBUG_CurrProcess == NULL) + { + DEBUG_Printf(DBG_CHN_MESG, + "Cannot look at mapping of current process, while no process is loaded\n"); + return; + } + hProc = DEBUG_CurrProcess->handle; + } + else + { + hProc = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, pid); + if (hProc == NULL) + { + DEBUG_Printf(DBG_CHN_MESG, "Cannot open process <%lu>\n", pid); + return; + } + } DEBUG_Printf(DBG_CHN_MESG, "Address Size State Type RWX\n"); - while (VirtualQueryEx(DEBUG_CurrProcess->handle, addr, &mbi, sizeof(mbi)) >= sizeof(mbi)) + while (VirtualQueryEx(hProc, addr, &mbi, sizeof(mbi)) >= sizeof(mbi)) { switch (mbi.State) { @@ -687,6 +695,7 @@ void DEBUG_InfoVirtual(void) break; addr += mbi.RegionSize; } + if (hProc != DEBUG_CurrProcess->handle) CloseHandle(hProc); } struct dll_option_layout diff --git a/programs/winedbg/module.c b/programs/winedbg/module.c index ff5b81dc23c..add3bee47de 100644 --- a/programs/winedbg/module.c +++ b/programs/winedbg/module.c @@ -622,6 +622,13 @@ void DEBUG_WalkModules(void) DBG_MODULE** amod; int i; + if (!DEBUG_CurrProcess) + { + DEBUG_Printf(DBG_CHN_MESG, + "Cannot walk classes while no process is loaded\n"); + return; + } + DEBUG_Printf(DBG_CHN_MESG, "Address\t\t\tModule\tName\n"); amod = DBG_alloc(sizeof(DBG_MODULE*) * DEBUG_CurrProcess->num_modules);