Posted by: Sue Loh
I've been working with one of our customers the last couple of days, and found that there were a few handy tips for using the Platform Builder debugger with Windows CE that I knew and they didn't. So I am sharing them here.
Uninstantiated Breakpoints
If you've ever tried to set a breakpoint, but gotten the pink-color uninstantiated circle (indicating that the breakpoint is not yet set) instead of the maroon-color circle (indicating that the breakpoint is set), the problem might be something like this:
Breakpoints without source
You can set a breakpoint even if you don't have the source code to set it on. If you know the exact function name and module name you can use the breakpoint window to break on function entry. In the View menu, go to Debug Windows / Breakpoint List. You can also get there by clicking the "hand" icon on the debug toolbar or by hitting ALT + 9. In the breakpoint window, create a new breakpoint using this syntax:
{,,modulename} function_name
That's an open curly-brace, two commas, module name, close curly-brace, function name. You can use this for EXEs or DLLs. For example:
{,,nk.exe} SC_QueryPerformanceCounter {,,pm.dll} PlatformSetSystemPowerState
This syntax is not actually specific to breakpoints. It's just a way to tell the debugger that a symbol is specific to a module. For example if you want to look at a global variable in the Watch window, you can use this syntax there too. For example you could type {,,nk.exe}CurMSec in the Watch window to see that global variable inside the kernel.
By setting a breakpoint on a symbol instead of a source file line, you use only the PDBs to set the breakpoint. There is no dependency on having the right source file or source path mapping.
Don't just guess random function names when using this method though. OS APIs often have prefixes and postfixes that differ from their official names (eg. the implementation of CreateFile is FS_CreateFileW) and may be completely different (eg. for some reason the implementation of DeleteAndRenameFile is called FS_PrestoChangoFileName... I like that one :-) ). You can search the .map files in your release directory to get clues about what the API names are.
The other useful thing about the breakpoint window is that you can see if your breakpoint changes are pending. Like I mention above, if you set (or unset) a breakpoint while the target device is still running, the change will not occur until you stop in the debugger.
Other tips
If you have a bunch of breakpoints set you may notice that your device is running slower. Every time a DLL or EXE is loaded the debugger does work to figure out if it needs to instantiate a breakpoint inside the module. Unfortunately from my experience, deactivating the breakpoints does not help. I don't know why. You would have to completely delete the breakpoints in order to get back to normal speed. My advice is not to do that though. Delete breakpoints when you're totally done with them, but don't let debugger speed put you into the habit of setting & deleting breakpoints left and right. Slower speed is better than having to redo some debugging because you forgot to set something.
Happy debugging...
UPDATE Dec 9, 05: I added the "debugger is not connected" case above.UPDATE Dec 4, 06: I added some more details to the "Bad Symbols" case and added the "Optimizations" and "Flash ROM" cases.UPDATE Jan 5, 07: Added bullet about the QFE to support VS2005 symbols.UPDATE Feb 14, 07: See also http://blogs.msdn.com/hopperx/archive/2007/02/14/map-file-breakpoints.aspx