Developing Isadora Plugin Visual C++ 2010 Express -> Debugging

  • Dear Forum,

    I have been working some time now on a few custom OSC recieve and OSC send plugins. I develop on my MacbookPro where the development comes along quite well. The target platform is however Windows so I am now porting the Mac plugins to Window plugins.
    Thanks to these posts:
    I am now successfully working in Visual Studio Express 2010, but how do I debug? On the Mac I use cout and read the console. On Windows I use OutputDebugStringA() and start Isadora through Visual Studio 2010, but is is pretty slow to startup an thus every time I make a small adjustment it takes quite some time.
    Is there anybody out there who has a bit more experience in how to do the debugging on windows of a .dll as effectively as possible ?
    Thanks in advance!

  • Dear Machiel,

    Mark here, I'll try to help. Regarding the debugging: I also end up using OutputDebugString -- though I've got some macros defined that allow me to handle it more like a printf, which allows you to print the values of parameters etc. In the end, I created my own, separate console object so that the debug output goes there. I don't know if that speeds things up, but I like having the console in a separate window.
    If you want to speed up Isadora's startup,
    1) rename the the "Isadora Plugins" folder (same level as the app) to "Isadora PluginsX"
    2) Make a new "Isadora Plugins" folder
    3) Copy the essential plugins you need (if any) into that new folder
    That way, it won't spend time loading all the plugins (which is extra slow when you're debugging.)
    The Movie Player and Projector actors are hard coded into the Isadora app itself, so if that's all you need, you can leave the new "Isadora Plugins" folder empty.
    Hopefully those suggestions will get you somewhere.
    All the Best,

  • Thanks for the hint! That will help me a lot too.

  • Dear Mark,

    thanks for your suggestion of the plugins that already speeds things up a lot. What I also did in Visual Express 2010 is to go to Debug -> Options and Settings... -> Debugging -> Symbols and checked :"Automatically load symbols for: Only Specified modules" 
    I think this is a rather brute way to speed things up but for now it suit my purposes. I will need to look more into using Macro's to handle it more like printf, because I am having a bit trouble printing strings in combination with variables.
    Any pointers on that would also be appreciated. I feel I need to dig more into what the difference is between std:string and char* or char[256] and how to use them with OutputDebugString I seem to miss some basic C++ knowledge there.

  • Well, regarding the string types:

    char* = pointer to a null terminated string
    char[256] is an array that, one would assume, is also a null terminated string.
    std::string is a C++ class from the Standard Template Library. You can get a char* using the function c_str()
    So, to print them:
    char* testString1 = "hello"
    char testString2 = [ 'w', 'o', 'r', 'l', 'd', '\0];
    std::string testString3 = "*This is Isadora*";
    printf("%s %s %s\n", testString1, testString2, testString3.c_str());
    would print
    Hello World *This is Isadora*
    Also, in terms of a macro function, you can use something like this:
    #ifdef DEBUG #define log_info(...) __std_log_info(__FILE__, __LINE__, __VA_ARGS__) #else #define log_info(...) { } #endif
    void __std_log_info( const char* fileName, int lineNumber, const char* format, ...) { char msg[2048];

    // add the content supplied by the caller
    va_list args;
    va_start(args, format);
    int len = strlen(msg);
    vsnprintf(msg, sizeof(msg), format, args);
    msg[sizeof(msg) - 1] = 0;

    OutputDebugStringA(msg); }
    Then you can use log_info just like you'd use printf. (Hopefully that will work... a little cut,copy,paste action going on here; I didn't actually compile it.)
    I hope that helps.
    Best Wishes,

  • Hi Mark,

    Thanks for the info regarding the difference between char, char* and string It is getting a lot clearer also your suggestion for Macro's should make developing on Windows easier..
    For the OSC receive plugin I am trying to implement some error handling for when a user is trying to create two instance's of the plugin with the same receiving port. This goes wrong because you can only open one socket per port.
    I have implemented a try catch, but looking at the Isadora code it seems that Isadora also has some error handling with message pop-ups. Could you give me an example how to graciously implement that ? 
    Thanks in advance!

  • Dear Machiel,

    Are you creating your own socket? If so, try/catch stuff I have won't affect yours. Or are you just asking how to catch a duplicate port assignment?
    Best Wishes,

  • I am creating my own socket within the actor. So if you duplicate the actor (or drag a new actor on the stage with the same port) it tries to create a socket two times on the same port and it will fail because you cannot have to similar binds.

    Some background info which helped me figuring this out I found is here:
    To clarify the way I make bind the address is: 
    listen_socket = new UdpListeningReceiveSocket( IpEndpointName( IpEndpointName::ANY_ADDRESS, listen_port ), this );
    Where listen_port is the port to which I listen.
    I am using the oscpack library and the way OpenFrameworks implements it.
    The try{}  catch(exception& e){} works fine (in the sense that Isadora does not crash), but output to the console will not really help the user ..
    So, my question is how can I create visible feedback to an Isadora user when a second actor of the same type with the same port is created. As reference I am attaching an image of the plugin I am working on.
    I hope I am expressing myself clearly and you understand my question better.