VisualGDB on cocos2d-x

Sysprogs forums Forums VisualGDB VisualGDB on cocos2d-x

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #686
    alenl
    Participant

    so i’m trying to setup VisualGDB for cocos2d-x (android). I got it to compile, run and break but i can’t get it to read and alter variables i get:

    -var-create: unable to create variable object
    #2791
    ket
    Participant

    Hi,

    Not every part of code you can hover over is a genuine variable. We poll the gdb always to ask whether it is a variable and then show the variable’s information if applicable. Please try the Autos and Locals windows to see all the current variables listed or enter them to the Watch window.

    If genuine variables are still not shown, then please give us a full GDB log showing all the GDB interaction. For this enable diagnostic GDB logging on the GDB settings page in VisualGDB Project Properties. Then start debugging and replicate your scenario. Finally stop debugging and send us the resulting log file from your project directory.

    #2792
    alenl
    Participant

    It is a “real” varibable thats for sure

    
    void cocos_android_app_init (struct android_app* app) {
    sleep(3);
    int iWantToReadYou = 123;
    LOGD("NUM %d",iWantToReadYou);
    LOGD("cocos_android_app_init");
    AppDelegate *pAppDelegate = new AppDelegate();
    }
    

    Im adding this argument for ndk-build

    NDK_MODULE_PATH=E:/mobilesvn/Wacky/cocos2d-x;E:/mobilesvn/Wacky/cocos2d-x/external;E:/mobilesvn/Wacky/cocos2d-x/cocos

    i noticed that the console was giving me this:

    No symbol "disassembly" in current context.
    
    No symbol table is loaded.  Use the "file" command. 

    I allso looked at the log file and found this

    
    ~"Reading symbols from C:/Users/Alen/AppData/Local/VisualGDB/AndroidBinaryCache/01bf1190e24af3cc/app_process..."
    ~"done.n"
    ~"n"
    ~"WARNING: no debugging symbols found in C:/Users/Alen/AppData/Local/VisualGDB/AndroidBinaryCache/01bf1190e24af3cc/app_process.n"
    ~"Either the binary was compiled without debugging informationnor the debugging information was removed (e.g., with strip or strip -g).nDebugger capabilities will be very limited.n"
    ~"For further information: http://wiki/Main/GdbFaq#No_debugging_symbols_foundn"
    ~"n"
    

    My Android.mk

    
    LOCAL_PATH := $(call my-dir)
    
    include $(CLEAR_VARS)
    
    LOCAL_MODULE := cocos2dcpp_shared
    
    LOCAL_MODULE_FILENAME := libcocos2dcpp
    
    #VisualGDBAndroid: AutoUpdateSourcesInNextLine
    LOCAL_SRC_FILES := ../../Classes/AppDelegate.cpp ../../Classes/HelloWorldScene.cpp hellocpp/main.cpp
    
    LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes
    
    LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static
    LOCAL_WHOLE_STATIC_LIBRARIES += spine_static
    LOCAL_WHOLE_STATIC_LIBRARIES += cocosdenshion_static
    
    
    include $(BUILD_SHARED_LIBRARY)
    
    $(call import-module,2d)
    $(call import-module,audio/android)
    $(call import-module,editor-support/spine)
    

    And Application.mk

    APP_STL := gnustl_static
    APP_CPPFLAGS := -frtti -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 -DCOCOS2D_DEBUG=1 -std=c++11 -fsigned-char
    NDK_TOOLCHAIN_VERSION := 4.8
    APP_ABI := armeabi-v7a
    

    So i guess that i dident get debug symbols at all

    #2793
    alenl
    Participant

    Ok so after many trys i got it to work.

    All i needed to to is change my toolchain version.

    NDK_TOOLCHAIN_VERSION := clang3.3

    But i still dont understand why that is?

    #2794
    ket
    Participant

    Hi,

    Based on the log, the symbols are loaded. The early errors in the log about symbols not being loaded are before gdb even connects to the Android device and loads the symbols. Based on the log you should also be able to see the call stack, threads and step through code. The gdb does reply that it cannot create the variable iWantToReadYou, that happens when it does not know of any variable with that name.

    It could be that the code was optimized and that iWantToReadYou was optimized out. As clang is a completely different compiler from gcc, it does compilation and optimization differently. Try adding V=1 to the ndk-build arguments and post the gcc command line from the build output in the Output window here. Also is iWantToReadYou the only variable not shown i.e. are there any variables shown in the Locals and Autos windows?

    #2795
    alenl
    Participant

    Hi

    So i can break see call stack and all that i can allso read all my global variables with 4.8 like so

    (file main.cpp)

    int thisOneWorks = 321;
    
    void cocos_android_app_init (struct android_app* app) {
    sleep(3);//WAIT FOR GDB
    int iWantToReadYou = 123;
    LOGD("NUM %d",iWantToReadYou); //<- i break here where i can get 'thisOneWorks ' but not 'iWantToReadYou'
    LOGD("cocos_android_app_init");
    AppDelegate *pAppDelegate = new AppDelegate();
    }
    

    Autos window will give me:

    		cocos_android_app_init	0x73759c4c <_z22cocos_android_app_initp11android_app>	
    sleep 0x4014c646

    And Locals gives me:

    +		cocos2d::PHYSICSSHAPE_MATERIAL_DEFAULT	{density = 0, restitution = 0.5, friction = 0.5}	const cocos2d::PhysicsMaterial
    cocos2d::kCCPriorityNonSystemMin	-2147483647	const int
    +		cocos2d::PHYSICSBODY_MATERIAL_DEFAULT	{density = 0.100000001, restitution = 0.5, ...}	const cocos2d::PhysicsMaterial
    +		std::__ioinit	{_S_refcount = 23, _S_synced_with_stdio = true}	std::ios_base::Init
    cocos2d::kCCPrioritySystem	-2147483648	const int
    thisOneWorks	321	int
    
    #2796
    ket
    Participant

    Hi,

    Based on the fact that some variables even from the same file have readable values, it is highly likely that the compiler has somehow optimized the iWantToReadYou variable out. Based on the build log however, there are no unusual flags passed to g++. There are the additional flags that cocos2dx needs, but none of them should affect optimization. It could be a compiler bug to still perform some optimization.

    If you wish to look further into it, look into the so file using objdump. Find the correct objdump.exe for your toolchain in your Android NDK installation directory and call objdump from cmd as follows:

     --dwarf lib  > 0

    Then open the 0 file with a text editor and search for iWantToReadYou.

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.