Share via


Conditional Breakpoint in Platform Builder for Windows CE and Mobile

I've had a hard time figuring out how to set conditional breakpoint in Platform Builder. No much useful information is available on the web, and the documentation does not even give an example.

So, here are the findings. The same expression rules apply to Watch window as well.

  • You can use register names directly in an expression. For example, you can set 'r1 == 0x200' as a condition in the context of a function. So whenever r1 is 0x200 it will break;
  • You can use type cast to see the fields of a struct and set breakpoint. For example, in a Watch window, you can type " (struct sockaddr*)r1" to view the sockaddr members that pointed by r1.
  • Use "*" with type cast to view a variable. For example, use * (short*)(r3) to view a SHORT variable pointed by r3.

Here is a little bit complicated example. Let's say I want to break WSAConnect() is ws2.dll only when the port number to connect is 80, the HTTP port. I know that the second parameter passed to this function is a sockaddr struct pointer. To create such a breakpoint, first enter the following as a breakpoint entry:

{,,ws2.dll} WSAConnect

Then hit the 'condition' button, and enter the following

*(short*)(r1+2) == 0x5000

r1 will carry the 2nd parameter, the sockaddr pointer.  0x5000  refers to port 80 because network byte order is always big-endian and the device I am using turns out to be little-endian.

The breakpoint window will look like this:

 

When the breakpoint is hit, a message box will pop up: 

Comments