From 0e65b38ff3308aaad96676ae40e4f260142d6f17 Mon Sep 17 00:00:00 2001 From: Guy Albertelli Date: Sat, 12 Jun 1999 10:49:36 +0000 Subject: [PATCH] Add new "walk" command options to list processes and modref's. --- debugger/dbg.y | 3 +++ debugger/debug.l | 2 ++ debugger/info.c | 3 ++- include/module.h | 1 + include/process.h | 1 + loader/module.c | 29 +++++++++++++++++++++++++++++ scheduler/process.c | 24 ++++++++++++++++++++++++ 7 files changed, 62 insertions(+), 1 deletion(-) diff --git a/debugger/dbg.y b/debugger/dbg.y index 99822e6f492..cdbab33af55 100644 --- a/debugger/dbg.y +++ b/debugger/dbg.y @@ -74,6 +74,7 @@ extern void VIRTUAL_Dump(void); /* memory/virtual.c */ %token tCONT tSTEP tLIST tNEXT tQUIT tHELP tBACKTRACE tINFO tWALK tUP tDOWN %token tENABLE tDISABLE tBREAK tDELETE tSET tMODE tPRINT tEXAM tABORT tDEBUGMSG %token tCLASS tMAPS tMODULE tSTACK tSEGMENTS tREGS tWND tQUEUE tLOCAL +%token tPROCESS tMODREF %token tEOL tSTRING tDEBUGSTR %token tFRAME tSHARE tCOND tDISPLAY tUNDISPLAY tDISASSEMBLE %token tSTEPI tNEXTI tFINISH tSHOW tDIR @@ -313,6 +314,8 @@ walk_command: | tWALK tQUEUE tEOL { QUEUE_WalkQueues(); } | tWALK tWND tEOL { WIN_WalkWindows( 0, 0 ); } | tWALK tWND tNUM tEOL { WIN_WalkWindows( $3, 0 ); } + | tWALK tPROCESS tEOL { PROCESS_WalkProcess(); } + | tWALK tMODREF expr_value tEOL { MODULE_WalkModref( $3 ); } type_cast: diff --git a/debugger/debug.l b/debugger/debug.l index a77b17d9d67..669f65211bf 100644 --- a/debugger/debug.l +++ b/debugger/debug.l @@ -156,6 +156,8 @@ $gs { yylval.reg = REG_GS; return tREG; } class|clas|cla { return tCLASS; } module|modul|modu|mod { return tMODULE; } queue|queu|que { return tQUEUE; } +process|proces|proce|proc { return tPROCESS; } +modref|modre|modr { return tMODREF; } registers|regs|reg|re { return tREGS; } segments|segment|segm|seg|se { return tSEGMENTS; } stack|stac|sta|st { return tSTACK; } diff --git a/debugger/info.c b/debugger/info.c index a4ea51ebf2b..b71c0c2e388 100644 --- a/debugger/info.c +++ b/debugger/info.c @@ -142,7 +142,8 @@ void DEBUG_Help(void) " delete display debugmsg [-+]\n", "Wine-specific commands:", -" mode [16,32] walk [wnd,class,queue,module]", +" mode [16,32] walk [wnd,class,queue,module,", +" process,modref ]", " info (see 'help info' for options)\n", "The 'x' command accepts repeat counts and formats (including 'i') in the", diff --git a/include/module.h b/include/module.h index 3a49ecee389..dcfffc4129f 100644 --- a/include/module.h +++ b/include/module.h @@ -187,6 +187,7 @@ extern HMODULE MODULE_CreateDummyModule( const OFSTRUCT *ofs, LPCSTR modName ); extern FARPROC16 MODULE_GetWndProcEntry16( const char *name ); extern FARPROC16 WINAPI WIN32_GetProcAddress16( HMODULE hmodule, LPCSTR name ); extern SEGPTR WINAPI HasGPHandler16( SEGPTR address ); +extern void MODULE_WalkModref( DWORD id ); /* resource.c */ extern INT WINAPI AccessResource(HMODULE,HRSRC); diff --git a/include/process.h b/include/process.h index 224f352ea4b..7b5f0a1763b 100644 --- a/include/process.h +++ b/include/process.h @@ -165,6 +165,7 @@ extern PDB *PROCESS_Create( struct _NE_MODULE *pModule, BOOL inherit, DWORD flags, STARTUPINFOA *startup, PROCESS_INFORMATION *info ); extern void PROCESS_FreePDB( PDB *pdb ); +extern void PROCESS_WalkProcess( void ); /* scheduler/debugger.c */ extern DWORD DEBUG_SendExceptionEvent( EXCEPTION_RECORD *rec, BOOL first_chance ); diff --git a/loader/module.c b/loader/module.c index feb4974de44..44d600e3088 100644 --- a/loader/module.c +++ b/loader/module.c @@ -35,6 +35,35 @@ DECLARE_DEBUG_CHANNEL(module) DECLARE_DEBUG_CHANNEL(win32) +/************************************************************************* + * MODULE_WalkModref + * Walk MODREFs for input process ID + */ +void MODULE_WalkModref( DWORD id ) +{ + int i; + WINE_MODREF *zwm, *prev = NULL; + PDB *pdb = PROCESS_IdToPDB( id ); + + if (!pdb) { + MESSAGE("Invalid process id (pid)\n"); + return; + } + + MESSAGE("Modref list for process pdb=%p\n", pdb); + MESSAGE("Modref next prev handle deps flags name\n"); + for ( zwm = pdb->modref_list; zwm; zwm = zwm->next) { + MESSAGE("%p %p %p %04x %5d %04x %s\n", zwm, zwm->next, zwm->prev, + zwm->module, zwm->nDeps, zwm->flags, zwm->modname); + for ( i = 0; i < zwm->nDeps; i++ ) { + if ( zwm->deps[i] ) + MESSAGE(" %d %p %s\n", i, zwm->deps[i], zwm->deps[i]->modname); + } + if (prev != zwm->prev) + MESSAGE(" --> modref corrupt, previous pointer wrong!!\n"); + prev = zwm; + } +} /************************************************************************* * MODULE32_LookupHMODULE diff --git a/scheduler/process.c b/scheduler/process.c index 0933768357c..8866e9f59fb 100644 --- a/scheduler/process.c +++ b/scheduler/process.c @@ -36,6 +36,30 @@ static PDB initial_pdb; static PDB *PROCESS_First = &initial_pdb; +/*********************************************************************** + * PROCESS_WalkProcess + */ +void PROCESS_WalkProcess(void) +{ + PDB *pdb; + char *name; + + pdb = PROCESS_First; + MESSAGE( " pid PDB #th modref module \n" ); + while(pdb) + { + if (pdb == &initial_pdb) + name = "initial PDB"; + else + name = (pdb->exe_modref) ? pdb->exe_modref->shortname : ""; + + MESSAGE( " %8p %8p %5d %8p %s\n", pdb->server_pid, pdb, + pdb->threads, pdb->exe_modref, name); + pdb = pdb->next; + } + return; +} + /*********************************************************************** * PROCESS_Current */