cocos2dx android project breakpoint in windows platform

How to let cocos2dx eclipse android project
to set breakpoint to in eclipse windows platform?
I only can use log to print, but it is hard to debug.

  1. Set breakpoint in your C++ class
  2. Select project > Right Click> Debug as ->Android native application.

*Note: Make sure you have setup correct NDK path in Android Preferences in Eclipse.

I already add native support.

My project setting is use Eclipse Builders to run
C:-ndk-r8e\ndk-build.cmd to build source code,
I don’t have add any C++ source code into Eclipse Project,
it use Android.mk to set LOCAL_SRC_FILES := hellocpp/main.cpp …/…/Classes/AppDelegate.cpp …/…/Classes/GameData.cpp Cocos2dx source code and My Classes folder is not in proj.android folder.
If I want to debug AppDelegate.cpp or cocos2dx source code, how to add this source code into Eclipse project.

And my main.cpp show many error about unresolved inclusion.

#include “AppDelegate.h”
#include “platform/android/jni/JniHelper.h”
#include <jni.h>
#include <android/log.h>

#include “cocos2d.h”

#define LOG_TAG “main”
#define LOGD (…) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,VA_ARGS)

using namespace cocos2d;

extern “C”
{

jint JNI_OnLoad(JavaVM vm, voidreserved)
{
JniHelper::setJavaVM(vm);

return JNI_VERSION_1_4;
}

void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thiz, jint w, jint h)
{
if (!CCDirector::sharedDirector()->getOpenGLView())
{
CCEGLView view = CCEGLView::sharedOpenGLView;
view->setFrameSize;
AppDelegate
pAppDelegate = new AppDelegate();
CCApplication::sharedApplication()->run();
}
/*
else
{
ccDrawInit();
ccGLInvalidateStateCache();

CCShaderCache::sharedShaderCache()->reloadDefaultShaders();
CCTextureCache::reloadAllTextures();
CCNotificationCenter::sharedNotificationCenter()->postNotification(EVNET_COME_TO_FOREGROUND, NULL);
CCDirector::sharedDirector()->setGLDefaultValues();
}
*/
}

}
Description Resource Path Location Type
Function ‘sharedApplication’ could not be resolved main.cpp /xxx/jni/hellocpp line 31 Semantic Error
Type ‘AppDelegate’ could not be resolved main.cpp /xxx/jni/hellocpp line 30 Semantic Error
Method ‘run’ could not be resolved main.cpp /xxx/jni/hellocpp line 31 Semantic Error
Type ‘jint’ could not be resolved main.cpp /xxx/jni/hellocpp line 16 Semantic Error
Type ‘JavaVM’ could not be resolved main.cpp /xxx/jni/hellocpp line 16 Semantic Error
Symbol ‘cocos2d’ could not be resolved main.cpp /xxx/jni/hellocpp line 11 Semantic Error
Type ‘JNIEnv’ could not be resolved main.cpp /xxx/jni/hellocpp line 23 Semantic Error
Type ‘jobject’ could not be resolved main.cpp /xxx/jni/hellocpp line 23 Semantic Error
Function ‘setJavaVM’ could not be resolved main.cpp /xxx/jni/hellocpp line 18 Semantic Error
Symbol ‘JNI_VERSION_1_4’ could not be resolved main.cpp /xxx/jni/hellocpp line 20 Semantic Error
Function ‘sharedDirector’ could not be resolved main.cpp /xxx/jni/hellocpp line 25 Semantic Error
Method ‘getOpenGLView’ could not be resolved main.cpp /xxx/jni/hellocpp line 25 Semantic Error
Type ‘jint’ could not be resolved main.cpp /xxx/jni/hellocpp line 23 Semantic Error
Type ‘jint’ could not be resolved main.cpp /xxx/jni/hellocpp line 23 Semantic Error
Method ‘setFrameSize’ could not be resolved main.cpp /xxx/jni/hellocpp line 28 Semantic Error
Type ‘AppDelegate’ could not be resolved main.cpp /xxx/jni/hellocpp line 30 Semantic Error
Type ‘CCEGLView’ could not be resolved main.cpp /xxx/jni/hellocpp line 27 Semantic Error
Function ‘sharedOpenGLView’ could not be resolved main.cpp /xxx/jni/hellocpp line 27 Semantic Error

First you need to resolve errors related to Includes.

Go to Project properties -> C/C++ General -> Path and symbols -> Includes -> Add
then add paths like

E:/cocos2dx/cocos2d-x-2.1.5/cocos2dx/include E:/cocos2dx/cocos2d-x-2.1.5/extensions E:/cocos2dx/cocos2d-x-2.1.5/cocos2dx

This will resolves all issues related to include. And also disable Syntax and semantic errors
from C/C++ General -> Code Analysis -> Un-check Syntax and Semantic Errors

If you want to add Classes to your eclipse workspace then just create a folder and in advanced option link it to your classes folder.

Linking a folder in eclipse
http://help.eclipse.org/juno/topic/org.eclipse.platform.doc.user/tasks/tasks-45.htm?cp=0_3_5_5

I goto Debug as ->Android native application
But get these error message
[2013-10-08 00:05:09 - XXX] Unknown Application ABI:
[2013-10-08 00:05:09 - XXX] Android
[2013-10-08 00:05:09 - XXX] Unknown Application ABI:
[2013-10-08 00:05:09 - XXX] NDK:
[2013-10-08 00:05:09 - XXX] Unknown Application ABI:
[2013-10-08 00:05:09 - XXX] jni/Android.mk:
[2013-10-08 00:05:09 - XXX] Unknown Application ABI:
[2013-10-08 00:05:09 - XXX] Cannot
[2013-10-08 00:05:09 - XXX] Unknown Application ABI:
[2013-10-08 00:05:09 - XXX] find
[2013-10-08 00:05:09 - XXX] Unknown Application ABI:
[2013-10-08 00:05:09 - XXX] module
[2013-10-08 00:05:09 - XXX] Unknown Application ABI:
[2013-10-08 00:05:09 - XXX] with
[2013-10-08 00:05:09 - XXX] Unknown Application ABI:
[2013-10-08 00:05:09 - XXX] tag
[2013-10-08 00:05:09 - XXX] Unknown Application ABI:
[2013-10-08 00:05:09 - XXX] ‘CocosDenshion/android’
[2013-10-08 00:05:09 - XXX] Unknown Application ABI:
[2013-10-08 00:05:09 - XXX] in
[2013-10-08 00:05:09 - XXX] Unknown Application ABI:
[2013-10-08 00:05:09 - XXX] import
[2013-10-08 00:05:09 - XXX] Unknown Application ABI:
[2013-10-08 00:05:09 - XXX] path
[2013-10-08 00:05:09 - XXX] Unknown Application ABI:
[2013-10-08 00:05:09 - XXX]
[2013-10-08 00:05:09 - XXX] Unknown Application ABI:
[2013-10-08 00:05:09 - XXX]
[2013-10-08 00:05:09 - XXX] Unknown Application ABI:
[2013-10-08 00:05:09 - XXX]
[2013-10-08 00:05:09 - XXX] Unknown Application ABI:
[2013-10-08 00:05:09 - XXX]
Android
[2013-10-08 00:05:09 - XXX] Unknown Application ABI:
[2013-10-08 00:05:09 - XXX] NDK:
[2013-10-08 00:05:09 - XXX] Unknown Application ABI:
[2013-10-08 00:05:09 - XXX] Are
[2013-10-08 00:05:09 - XXX] Unknown Application ABI:
[2013-10-08 00:05:09 - XXX] you
[2013-10-08 00:05:09 - XXX] Unknown Application ABI:
[2013-10-08 00:05:09 - XXX] sure
[2013-10-08 00:05:09 - XXX] Unknown Application ABI:
[2013-10-08 00:05:09 - XXX] your
[2013-10-08 00:05:09 - XXX] Unknown Application ABI:
[2013-10-08 00:05:09 - XXX] NDK_MODULE_PATH
[2013-10-08 00:05:09 - XXX] Unknown Application ABI:
[2013-10-08 00:05:09 - XXX] variable
[2013-10-08 00:05:09 - XXX] Unknown Application ABI:
[2013-10-08 00:05:09 - XXX] is
[2013-10-08 00:05:09 - XXX] Unknown Application ABI:
[2013-10-08 00:05:09 - XXX] properly
[2013-10-08 00:05:09 - XXX] Unknown Application ABI:
[2013-10-08 00:05:09 - XXX] defined
[2013-10-08 00:05:09 - XXX] Unknown Application ABI:
[2013-10-08 00:05:09 - XXX] ?
[2013-10-08 00:05:09 - XXX] Unknown Application ABI:
[2013-10-08 00:05:09 - XXX]
[2013-10-08 00:05:09 - XXX] Unknown Application ABI:
[2013-10-08 00:05:09 - XXX]
[2013-10-08 00:05:09 - XXX] Unknown Application ABI:
[2013-10-08 00:05:09 - XXX]
[2013-10-08 00:05:09 - XXX] Unknown Application ABI:
[2013-10-08 00:05:09 - XXX]
Android
[2013-10-08 00:05:09 - XXX] Unknown Application ABI:
[2013-10-08 00:05:09 - XXX] NDK:
[2013-10-08 00:05:09 - XXX] Unknown Application ABI:
[2013-10-08 00:05:09 - XXX] The
[2013-10-08 00:05:09 - XXX] Unknown Application ABI:
[2013-10-08 00:05:09 - XXX] following
[2013-10-08 00:05:09 - XXX] Unknown Application ABI:
[2013-10-08 00:05:09 - XXX] directories
[2013-10-08 00:05:09 - XXX] Unknown Application ABI:
[2013-10-08 00:05:09 - XXX] were
[2013-10-08 00:05:09 - XXX] Unknown Application ABI:
[2013-10-08 00:05:09 - XXX] searched:
[2013-10-08 00:05:09 - XXX] Unknown Application ABI:
[2013-10-08 00:05:09 - XXX]
[2013-10-08 00:05:09 - XXX] Unknown Application ABI:
[2013-10-08 00:05:09 - XXX]
[2013-10-08 00:05:09 - XXX] Unknown Application ABI:
[2013-10-08 00:05:09 - XXX]
[2013-10-08 00:05:09 - XXX] Unknown Application ABI:
[2013-10-08 00:05:09 - XXX]
Android
[2013-10-08 00:05:09 - XXX] Unknown Application ABI:
[2013-10-08 00:05:09 - XXX] NDK:
[2013-10-08 00:05:09 - XXX] Unable to detect application ABI’s
[2013-10-08 00:05:21 - XXX]

Clean your project and go to Project -> Properties -> C/C++ Build -> Builder Settings
Now change Build command : ndk-build.cmd NDK_DEBUG=1 APP_ABI=armeabi

Here you need to set correct CPU architecture for APP_ABI. If you are using an Intel based device then you can set APP_ABI=x86 etc.

Hope this will help you.

I can run debug now,
I set breakpoint
But the call stack is only
XXXProject (1) [Android Native Application]
app_process
gdb
and have a gdb error below:

warning: Could not load shared library symbols for 77 libraries, e.g. /system/bin/linker.
Use the “info sharedlibrary” command to see the complete listing.
Do you need “set solib-search-path” or “set sysroot”?
warning: Unable to find dynamic linker breakpoint function.
GDB will retry eventurally. Meanwhile, it is likely
that GDB is unable to debug shared library initializers
or resolve pending breakpoints after dlopen().

Anybody know how to fix the warning?
Maybe this warning cause my breakpoint is not avalible.