2

During investigation crash of my cocos2d-x app I faced with problem that debugger not stops in AppDelegate.cpp class at all.

My assumption is: debugger could not connect before time when this code has been executed.

Is my assumption correct? Is any workaround there?

CAMOBAP
  • 5,523
  • 8
  • 58
  • 93
  • 1
    see [Debugging App Startup with VisualGDB](http://visualgdb.com/documentation/appstartup). – Alex Cohn Feb 10 '14 at 12:32
  • @AlexCohn Thanks for the link. But I see three problems here: 1. `VisualGDB` haven't plugin for `Eclipse`; 2. `VisualGDB` doesn't support `OSX`; 3. `VisualGDB` isn't free; – CAMOBAP Feb 10 '14 at 13:09
  • You are right. 3 times ;) That's why I didn't post this as an answer. Probably, you can reproduce their logic for your private solution. It would be great if you share it with us, when ready. – Alex Cohn Feb 10 '14 at 14:44
  • One simple approach is to throw in a `sleep` call that stalls app startup at the appropriate point for a few seconds. Just long enough to let the debugger get set up. – fadden Feb 11 '14 at 14:24

1 Answers1

3

I agree with fadden you can add call sleep (or usleep) function. In case cocos2d-x you should put it in beginning of void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thiz, jint w, jint h) function

void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, 
                                                       jobject thiz, 
                                                       jint w, 
                                                       jint h)
{
#if COCOS2D_DEBUG    
    sleep(30);
#endif
    ...
}

Also you should not forget to include <unistd.h> in case usleep

Community
  • 1
  • 1
Fr2eman
  • 156
  • 2
  • 7