Command Line Debugging Revisited – Part 3: Process Control

In the previous parts of this series, I talked about getting started with MDbg and using the Device Emulator.  Today, I would like to talk about how to use MDbg to control processes on the device being debugged.


The cp[roc] command - Running a process without attaching the debugger
In my getting started post, I talked about how to connect to the NetCFLaunch application and start an application for debugging.  While I typically want to debug the process that I launch, there are instances where I wish to start a process without debugging.  To do so, I use the cp[roc] command as shown in the example below.

mdbg> cp "\program files\webcrawler.exe"

If the command is able to start the process, the mdbg> prompt will be displayed.  If it is unable to start the process (ex: the application could not be found) an error message will be displayed.

The pro[cessenum] command - Listing the processes running on the device
It is often interesting to know exactly what processes are running on your device.  Perhaps your application relies upon another process for some data or to perform a particular task.  Using the pro[cessenum] command allows you to verify whether or not the partner process is running.  The example, below, shows the processes running on my Windows Mobile 5.0 Pocket PC device.

mdbg> pro
Active processes on current machine:
(PID: 0x0dcb4002) NK.EXE
(PID: 0xedca5752) filesys.exe
(PID: 0x8dadc526) device.exe
(PID: 0xcd7f62ea) shell32.exe
(PID: 0xcd97c7a6) gwes.exe
(PID: 0xcd7f6732) services.exe
(PID: 0x2d4b6da6) CommLoader.exe
(PID: 0xcd517ac2) BatteryIndicator.exe
(PID: 0x2d5219ea) connmgr.exe
(PID: 0xad517b8a) srvtrust.exe
(PID: 0xed810392) repllog.exe
(PID: 0x2d4b6c76) poutlook.exe
(PID: 0xed3affce) cprog.exe
(PID: 0x2d99977a) rapiclnt
(PID: 0xeced62b2) webcrawler.exe
(PID: 0x2d0ed5be) tmail.exe
(PID: 0x8d30f68a) netcflaunch.exe

In looking at the process list, we can see that my earlier call to the cp[roc] command successfully loaded webcrawler.exe.

The kp[roc] command - Terminating a running process
There are a number of situations where being able to terminate a running process can be desirable.  I find this most useful when I wish to explore failure code paths when my applications leverage another process.  The following example shows using the kp[roc] command to terminate the webcrawler.exe process that I started with the cp[roc] command..

mdbg> kp 0xeced62b2

The value passed to the kp[roc] command is the process identifier (PID) listed by the pro[cessenum] command.

(PID: 0xeced62b2) webcrawler.exe

Note: Please take care when terminating a process on your device.  Forcibly exiting the wrong application can lead to instability or an unresponsive device.


Tip: Use QuickEdit Mode or the Mark and Paste features of the Command Prompt to enable cut and paste within MDbg.

-- DK

[Edit: fix formatting]

Disclaimer(s): This posting is provided "AS IS" with no warranties, and confers no rights.

Comments (4)

  1. In the previous parts of this series, I talked about getting started with MDbg and using the Device Emulator….

  2. David Kline says:

    Being able to attach to a running process is a very powerful debugger feature.  It is especially…

  3. David Kline says:

    I started this series last year and thought I would continue the tradition with my best of 2006 collection.

Skip to main content