Implemented 'walk process' and 'walk threads' commands using toolhelp

snapshots.
This commit is contained in:
Alexandre Julliard 2000-04-16 19:46:35 +00:00
parent 07d8446918
commit a6795414d1
4 changed files with 48 additions and 2 deletions

View File

@ -45,7 +45,7 @@ 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
%token tCLASS tMAPS tMODULE tSTACK tSEGMENTS tREGS tWND tQUEUE tLOCAL
%token tPROCESS tMODREF
%token tPROCESS tTHREAD tMODREF
%token tEOL tSTRING tDEBUGSTR
%token tFRAME tSHARE tCOND tDISPLAY tUNDISPLAY tDISASSEMBLE
%token tSTEPI tNEXTI tFINISH tSHOW tDIR tWHATIS
@ -282,6 +282,7 @@ walk_command:
| tWALK tWND tEOL { DEBUG_WalkWindows( 0, 0 ); }
| tWALK tWND tNUM tEOL { DEBUG_WalkWindows( $3, 0 ); }
| tWALK tPROCESS tEOL { DEBUG_WalkProcess(); }
| tWALK tTHREAD tEOL { DEBUG_WalkThreads(); }
| tWALK tMODREF expr_value tEOL { DEBUG_WalkModref( $3 ); }

View File

@ -159,6 +159,7 @@ $gs { yylval.reg = REG_GS; return tREG; }
<INFO_CMD,WALK_CMD>module|modul|modu|mod { return tMODULE; }
<INFO_CMD,WALK_CMD>queue|queu|que { return tQUEUE; }
<INFO_CMD,WALK_CMD>process|proces|proce|proc { return tPROCESS; }
<INFO_CMD,WALK_CMD>threads|thread|threa|thre|thr|th { return tTHREAD; }
<INFO_CMD,WALK_CMD>modref|modre|modr { return tMODREF; }
<INFO_CMD>registers|regs|reg|re { return tREGS; }
<INFO_CMD>segments|segment|segm|seg|se { return tSEGMENTS; }

View File

@ -320,6 +320,7 @@ 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_DumpQueue(DWORD q);
extern void DEBUG_WalkQueues(void);
extern void DEBUG_InfoSegments(DWORD s, int v);

View File

@ -13,6 +13,7 @@
#include "wingdi.h"
#include "winuser.h"
#include "toolhelp.h"
#include "tlhelp32.h"
#include "debugger.h"
#include "expr.h"
@ -440,7 +441,49 @@ void DEBUG_WalkWindows(HWND hWnd, int indent)
void DEBUG_WalkProcess(void)
{
DEBUG_Printf(DBG_CHN_MESG, "No longer walking processes list\n");
HANDLE snap = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 );
if (snap != INVALID_HANDLE_VALUE)
{
PROCESSENTRY32 entry;
DWORD current = DEBUG_CurrProcess ? DEBUG_CurrProcess->pid : 0;
BOOL ok = Process32First( snap, &entry );
DEBUG_Printf(DBG_CHN_MESG, "%-8.8s %-8.8s %-8.8s %s\n",
"pid", "threads", "parent", "exe" );
while (ok)
{
if (entry.th32ProcessID != GetCurrentProcessId())
DEBUG_Printf(DBG_CHN_MESG, "%08lx %8d %08lx '%s'%s\n",
entry.th32ProcessID, entry.cntThreads,
entry.th32ParentProcessID, entry.szExeFile,
(entry.th32ProcessID == current) ? " <==" : "" );
ok = Process32Next( snap, &entry );
}
CloseHandle( snap );
}
}
void DEBUG_WalkThreads(void)
{
HANDLE snap = CreateToolhelp32Snapshot( TH32CS_SNAPTHREAD, 0 );
if (snap != INVALID_HANDLE_VALUE)
{
THREADENTRY32 entry;
DWORD current = DEBUG_CurrThread ? DEBUG_CurrThread->tid : 0;
BOOL ok = Thread32First( snap, &entry );
DEBUG_Printf(DBG_CHN_MESG, "%-8.8s %-8.8s %s\n",
"tid", "process", "prio" );
while (ok)
{
if (entry.th32OwnerProcessID != GetCurrentProcessId())
DEBUG_Printf(DBG_CHN_MESG, "%08lx %08lx %4ld%s\n",
entry.th32ThreadID, entry.th32OwnerProcessID,
entry.tbBasePri, (entry.th32ThreadID == current) ? " <==" : "" );
ok = Thread32Next( snap, &entry );
}
CloseHandle( snap );
}
}
void DEBUG_WalkModref(DWORD p)