How to make a data breakpoint using C++ and Visual Studio


#1

You can make a C++ data break point to help determine whenever a SkookumScript value has been modified.

(I was typing this in to help track down a different problem though it turns out it wasn’t needed, though I thought it still might be useful to others in the future.)

It is a little cumbersome/hacky though it should work. (It would be nice if the SkookumIDE had data breakpoints - though they don’t exist yet. :madsci:)

Here is how you do it for an Integer called my_num though it should be similar for many other types:

  1. In your original :sk: code, place an Integer method that uses my_num that has no effect on my_num and you aren’t using (so it only gets the one call). !dummy: my_num.max(0) would do the trick or some similar method that you aren’t using. (Binding it to a variable so that the result is used or the bulk of the C++ method is ignored.)
  2. In Visual Studio, put a C++ breakpoint in the mthd_max() call in SkInteger.cpp. Make sure it is after SkInstance * this_obj_p = scope_p->get_this(); which is line 450 in my current version.
  3. Run your normal test and hit the above breakpoint.
  4. Copy this expression to your Watch window to find the memory address to watch &(((this_obj_p)->m_user_data).m_data).m_integer. I drag from the Value column to a new Name column to get the address.
  5. Now follow the steps here to set a data breakpoint using the address obtained in step #4. It should look similar to this (though with your own specific memory address):
  6. Continue the VS debugger and it will break when my_num is next modified. :+1:
  7. Examine the C++ callstack to determine where you are in the :sk: callstack.

Of course reading the C++ callstack to figure out what SkookumScript is doing is tricky too. Using the AgogCore.natvis and SkookumScript.natvis debugging visualizers for VS C++ debugging can help - let us know if you would like a copy.