eXDI Sample Driver (Windows Embedded CE 6.0)
1/5/2010
eXDI provides a sample eXDI driver called KdStubLite. KdStubLite is a sample eXDI2 driver. The KdStubLite sample shows how to generate a Hardware-Assisted Debugging solution for Windows Embedded CE Platform Builder 5.0 and later using the eXDI programming interfaces. In addition, the KdStubLite sample shows how to have the debugging solution hosted as a Core Connectivity infrastructure service.
As an eXDI2 driver, KdStubLite forms an adaptation layer between the kernel debugger and the target to be debugged. While eXDI drivers are typically used to allow Platform Builder debugger to take control of a Hardware-Assisted debugger probe or ICE, this sample uses KdStub, the kernel debugger software stub, as a virtual hardware probe. No separate hardware probe is required for testing KdStubLite.
This sample is provided for demonstration purposes. You can use the KdStubLite source code to help create new eXDI2 drivers.
Building the sample
Compile all the source files in the sample using a compiler such as Visual C++.
The following table provides a list of sources files and descriptions of the purpose of each:File Description KdSeXdi2.idl KdSeXdi2_i.c
Contains interface definitions.
KdApi2.cpp
Implements the kernel debugger interface stub, KDAPI.
KdPacket.cpp
Provides packet communications over KDBG, the KdStub KITL stream.
KdSBP.cpp
- Keeps track of object-encapsulating, target-side breakpoints
- Sets state
KdSRegGroup.cpp
Implements register groups.
eXdhAuto.cpp
Provides the automation template.
KdSeXdi2.cpp
- Defines Main project.
- Starts and stops monitoring
KdSeXdiHnd.cpp
Implements eXDI driver handler.
- Instantiates and manage helpers and probe handler
- Register SW trap opcodes for breakpoints
- Create default register aliases & register groups
KdSeXdi_CC.cpp
Implements CoreCon service-specific methods
- Acquires device-specific properties from datastore
- Connection handling
KdSProbHnd.cpp
Implements the probe handler.
- Initializes device and probe
- Transforms all low-level eXDI requests to probe-specific requests
- Provideds error handling
(..\..\common\)DataStoreHelper.cpp
Provides helper routines for High-level datastore access
KdSeXdi2.rc
Resource files
The
#include
files referenced in the source files listed in the previous table can be taken from the following directories:- ..\..\helpers
- ..\..\include
- ..\..\idl
- Keeps track of object-encapsulating, target-side breakpoints
Create a file called SCID_eXDIAccess.c with the following contents:
#include <objbase.h> // {0F20E4AD-A44D-45d3-BA05-A077C1441E90} const GUID SCID_eXdiAccess = { 0xf20e4ad, 0xa44d, 0x45d3, { 0xba, 0x5, 0xa0, 0x77, 0xc1, 0x44, 0x1e, 0x90 } };
Copy this file to ..\common.
Create a file called SCID_eXDIAccess.c with the following contents:
#include <objbase.h> // {B538C148-D73D-498d-86CC-3201463581A2} const GUID SCID_OsAccess = { 0xb538c148, 0xd73d, 0x498d, { 0x86, 0xcc, 0x32, 0x1, 0x46, 0x35, 0x81, 0xa2 } };
Copy this file to ..\common.
Include the files for interface definitions that you created in Steps 3 and 4:
- ..\common\SCID_eXdiAccess.c
- ..\common\SCID_OsAccess.c
Define UNICODE and _UNICODE by typing the following command at the compiler command line:
-DUNICODE –D_UNICODE
Run MIDL on all IDL files in \idl and \helpers\exdihlp.idl
Make sure the MIDL compiler generates <filename>.h and not <filename>_h.hWhen using a Visual Studio workspace the TLB reference in the resource file may have to be renamed.
Link the compiled source to a DLL named KdSeXdi2Lite.dll. The definition file is KdSeXdi2.def
The following libraries are required to link properly:- dbgutil.lib
- user32.lib
- kernel32.lib
- ole32.lib
- oleaut32.lib
- Advapi32.lib
- uuid.lib
- CeDiag.lib
- MSVCRT.lib
- msvcirt.lib
- msvcprt.lib
- atlmfc71.dll
- vccomsup.lib
Installing and registering the sample
- Copy the KdSeXdi2Lite.DLL to the development machine.
- Copy eDiag.dll, provided in ..\..\common, to the development machine..
- Call register.bat.
Running the sample
- Open Platform Builder.
- Open the PB workspace you want to debug.
- Build the run-time OS image, with kernel debugger support (KdStub) enabled.
- From the Target menu, choose Connectivity Options.
- In the Target Device Connectivity Options dialog, select Kernel Service Map.
- From the Download box, choose a download service and configure any necessary settings.
- From the Transport box, choose a kernel transport service and configure any necessary settings.
- From the Debugger box, select "KdStubLite"
- Select Apply.
- Select Target -> Attach device.
This downloads the run-time image to the target device.
You can now start debugging.
Note
If the sample were a driver for a hardware-debugging probe, the driver would use HdStub for OS event notifications instead of KdStub.