Here's one scenario. Most big WinCE/Mobile system does not build debug images because this consume a lot of memory. But by default a lot of drivers have their debugging enabled only for DEBUG build. So what I do is define this on a specific file I want to debug:
#define DEBUGMSG(cond,printf_exp) \
((void)((cond|1)?(NKDbgPrintfW printf_exp),1:0))
What it does is convert all debug messages to print even in retail build. You just need to define the debug zones used by that module.
Ex.
#define ZONE_WARNING 1
Another way for better monitoring of functions and code lines is to add function names and line numbers to your RETAILMSG. Ex.
// declaration
#define DUMMY_DBG(fmt,p1,p2,p3) RETAILMSG(1, (TEXT("[File : %s][fn : %s ][line : %d]") TEXT(fmt), TEXT(__FILE__),TEXT(__FUNCTION__), __LINE__, p1, p2, p3)) // Marlon : debugging
RETAILMSG(1,(TEXT("Marlon Comment: Entered: %s\r\n"), TEXT(__FUNCTION__))); // Marlon
// usage
DUMMY_DBG("entry",0,0,0); //Marlon : debugging
DUMMY_DBG("exit",0,0,0); //Marlon : debugging
Another useful way in debugging especially with early driver development if to check which drivers are currently running. So here's what you can do:
#include
#include "bldver.h"
void EnumerateRunningDrivers( void )
{
#if CE_MAJOR_VER>4
HANDLE hDriver;
DeviceSearchType DeviceSearch = DeviceSearchByLegacyName;
DEVMGR_DEVICE_INFORMATION DeviceInfo;
DeviceInfo.dwSize = sizeof( DEVMGR_DEVICE_INFORMATION );
hDriver = FindFirstDevice(DeviceSearch, L"*", &DeviceInfo);
if( hDriver != INVALID_HANDLE_VALUE )
{
RETAILMSG( 1, (TEXT("Legacy Key Name BUS\n")));
do
{
RETAILMSG( 1, (TEXT("%s %s %s %s\n"),
DeviceInfo.szLegacyName,
DeviceInfo.szDeviceKey,
DeviceInfo.szDeviceName,
DeviceInfo.szBusName ));
} while( FindNextDevice( hDriver, &DeviceInfo ) );
FindClose( hDriver );
}
#else
RETAILMSG( 1, (TEXT("Cannot find drivers Windows CE Version doesn't support function\n")));
#endif
}
No comments:
Post a Comment