Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Automating NT wdw startup

5 views
Skip to first unread message

Walter Briscoe

unread,
Dec 8, 2003, 7:11:04 AM12/8/03
to
This reports experience today based on 2003/12/08 8:18:52.34 p4 sync.
I was running a W2K SP3 system. I expect similar behaviour on XP.

I have the following data in the registry:
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AeDebug]
"Auto"="0"
"Debugger"="c:\\wfb\\bin\\wdwstart.bat -p %ld -e %ld -g"
"UserDebuggerHotKey"=dword:00000000
"PreVisualStudio7Debugger"="c:\\msdevstd\\bin\\msdev.exe -p %ld -e %ld"

As I mentioned earlier, a debugger started from the Task Mananger is
always started with -p and a decimal pid. wdw currently requires # and a
hex pid.

C:\wfb\bin\wdwstart.bat does interface manipulation:
:: wdwstart.bat
::
:: Experimental attempt to use wdw as an NT system debugger
::
:: When Who What
:: 2003-12-06 W.Briscoe Original
:: 2003-12-08 W.Briscoe tidied dechex
@echo on
:: Set up Open Watcom environment
call c:\watcom\setvars.bat
:: Convert decimal pid in %2 to hex pid in %hexdigs%
:: dechex.bat
::
:: Convert a decimal number to hex
::
:: When Who What
:: 2003-12-06 W.Briscoe Original
:: 2003-12-08 W.Briscoe rolled into a loop
@echo off
set decdigs=%2
set hexdigs=
if %decdigs% equ 0 set hexdigs=0 & goto done
:nextdig
set /A d0="%decdigs% & 15" & set /A decdigs = "%decdigs% >> 4"
if %d0% leq 9 (set h0=%d0%) else (
if %d0% equ 10 (set h0=A) else (
if %d0% equ 11 (set h0=B) else (
if %d0% equ 12 (set h0=C) else (
if %d0% equ 13 (set h0=D) else (
if %d0% equ 14 (set h0=E) else (
if %d0% equ 15 (set h0=F) else (set h0=%d0%)))))))
set hexdigs=%h0%%hexdigs%
if %decdigs% neq 0 goto nextdig
:done
:: Fire up wdw
wdw #%hexdigs%
pause

I attempted to debug a program containing the following code:
#include "hello.h" // Grab MESSAGE
#include <stdio.h>

int main( void )
{
for( ; ; ) ;
puts( MESSAGE );
return 0;
}

I had built it with wcl386 -zq -d2 hello.c

I started hello.exe;
I started Task Manager by clicking an unused part of the Taskbar and
selecting "Task Manager...".
I right clicked the row describing hello.exe and selected "Debug".
I said yes to the asinine "WARNING: Debugging this process may result in
loss of data. Are you sure you wish to attach the debugger?"

wdw attached to my process but stopped at
ntdll.dll DbgBreakPoint ret
kernel32.dll DebugActiveProcess call CS:0x77ED1298
kernel32.dll Istrcmpiw call dword ptr +8[ebp]

I had put the infinite loop in the code for two purposes:
1) so I could attach to a process which would be in my code rather than
system code;
2) so the process would wait for attachment.

I restarted my process with a "Go" wdw command.
I clicked in the wdw code window.
I answered "Yes" when wdw responded: "The debugger cannot be used while
the application is running. Do you want to interrupt the application?"

I had "successfully" got into wdw with a running program.
Obviously, this situation is not good enough. I see the following as
necessary changes to wdw:
1) It must accept -p decimal_pid and should accept -e decimal_exception;
2) It needs an initialization mechanism which does not rely on %PATH%
being correct when it is started;
3) When it attaches to a process, it ought to enter the process so that
breakpoints, etc. can be used.
--
Walter Briscoe

0 new messages