Jump to content

[SOLVED] Debugging Unigine


photo

Recommended Posts

Hi,

 

I'm trying to debug engine within VS 2010, and seeing some inconstancy when stepping through the code. For this purpose I'm using 32-bit Debug version of engine (tried with both versions: built from VS 2010 and scons) and having identical issue. Of course in both approaches I'm using corresponding PDB file, and I been able to verify that appropriate DLL and PDB files are loaded through the Modules tab.

 

In detail when stepping through the code (breakpoints) I'm very often seeing that [this] pointer is changing a value on lines where is not expected, very often I'm not able to access local variables in function and sometimes steps go over some lines. Again on some other functions everything goes smooth. Typical example is Terrain::load_surface (snippet belos) call, where [this] pointer becomes corrupted after AtomicLock call, and local variable int id is not accessible trough the debugger.

 

I was thinking that this could be caused by optimization, but getting same results when removing it from VS 2010 Options.

 

Have try and x64 version, and again facing a similar (but not same) issue.

 

I hope that I'm not bringing this issue (questions) again in Forum, but could't find a similar description. Thanks in advance!

 

 

--- snip ---

 

 

int Terrain::load_surface(int x,int y,unsigned short *data,int size) {

 

assert(x >= 0 && x < surfaces_x && y >= 0 && y < surfaces_y && "Terrain::load_surface(): bad surface coordinates");

 

AtomicLock atomic(&lock);

 

// data file id

int id = get_surface_id(x,y);

if(files[id].isOpened() == 0) return 0;

 

// surface offset

int offset = (min(TERRAIN_FILE_SIZE,surfaces_x) * (y & TERRAIN_FILE_MASK) + (x & TERRAIN_FILE_MASK)) *

(TERRAIN_SURFACE_SIZE * TERRAIN_SURFACE_SIZE + TERRAIN_PATCH_SIZE * TERRAIN_PATCH_SIZE) * sizeof(unsigned short);

 

 

--- snip ---

 

Thanks!

M.

Link to comment

have you recompiled all unigine source with deactivated optimizations ? I can remember that unigine default VS project files still had optimizations enabled even within debug configuration

Link to comment

Thanks Ulf for your response!

 

Yes, I removed optimization and added linker option /stack:2097152 (which I found on forum). This makes difference and load_surface function goes like it should. Didn't mentioned that I'm using a latest SDK from Feb'2012.

 

BUT ...

 

Even when optimization is disabled, some of functions still going weird. One example is function int Terrain::renderSurfaces(const TerrainCulling &c). On first line of the code snippet (below) value of this pointer will be changed??? And local integer counter i in for loop is getting values without order (it should be increment from 0).

 

--- snip ---

 

vec4 parameters = vec4(TERRAIN_PATCH_STEP * step,height / 65535.0f,1.0f / surfaces_x,1.0f / surfaces_y);

 

render_surface_begin();

for(int i = 0; i < c.surfaces.size(); i++) {

const TerrainCulling::Surface &s = c.surfaces;

const TerrainSurface *surface = s.surface;

material->setSurface(surface->getX(),surface->getY());

material->setPosition(Math::itof(surface->getX()),Math::itof(surface->getY()));

material->setLodDistance(lod_distance);

material->setParameters(parameters);

render_surface(surface->getSurfaceVertexID(),s.lods);

}

render_surface_end();

 

--- snip ---

 

I would say that still something is missing to complete puzzle :)

 

Thanks,

Milos

Link to comment

Yes, VS project files are in form of XML, and ~70KB since there are a lot of source files within.

 

Snippet of Compile/Linker options for engine (DLL) unignine_vc2010 project:

 

 

<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">

<ClCompile>

<Optimization>Disabled</Optimization>

<IntrinsicFunctions>true</IntrinsicFunctions>

<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>

<OmitFramePointers>true</OmitFramePointers>

<AdditionalIncludeDirectories>./;api;common;controls;decals;filesystem;compute/cpu;framework;game;game/obstacles;game/navigations;gui;gui/fonts;gui/widgets;gui/flash;gui/flash/objects;gui/flash/characters;interpreter;lights;math;network;objects;physics;physics/bodies;physics/joints;physics/shapes;physics/collider;physics/physicals;physics/solvers;players;render;render/null;render/null/framework;render/opengl;render/opengl/framework;render/direct3d9;render/direct3d9/framework;render/direct3d10;render/direct3d10/framework;render/direct3d11;render/direct3d11/framework;sound;sound/null;sound/openal;utils;world;world/worlds;world/editors;../../include;../../externs/include;../../externs/direct3d/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>

<PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;ARCH_X86;HAVE_XML;HAVE_IMAGE;HAVE_REGEXP;HAVE_SOCKET;HAVE_BUFFER;HAVE_VORBIS;HAVE_THEORA;HAVE_NVCPL;USE_ASSERT;USE_MEMORY;USE_SHADER_CACHE;USE_EXTERN_INFO;USE_SSE;USE_SSE2;USE_OPENGL;USE_GL_WRAPPER;USE_DIRECT3D9;USE_D3D9_WRAPPER;USE_DIRECT3D10;USE_D3D10_WRAPPER;USE_DIRECT3D11;USE_D3D11_WRAPPER;USE_OPENAL;USE_AL_WRAPPER;USE_XPAD360;USE_JOYSTICK;USE_FLASH;USE_EDITOR;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>

<FloatingPointModel>Fast</FloatingPointModel>

<WarningLevel>Level3</WarningLevel>

<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>

<DisableSpecificWarnings>4355;4250;%(DisableSpecificWarnings)</DisableSpecificWarnings>

</ClCompile>

<Link>

<AdditionalLibraryDirectories>../../externs/lib/windows/x86;../../externs/direct3d/lib/x86;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>

<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;comdlg32.lib;%(AdditionalDependencies)</AdditionalDependencies>

<IgnoreSpecificDefaultLibraries>libcmt.lib;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>

<OutputFile>$(ProjectName)d.dll</OutputFile>

<GenerateDebugInformation>true</GenerateDebugInformation>

<ProgramDatabaseFile>$(ProjectName)d.pdb</ProgramDatabaseFile>

<AdditionalOptions>/stack:2097152 %(AdditionalOptions)</AdditionalOptions>

</Link>

</ItemDefinitionGroup>

 

or from Project Property pages:

 

C/C++ Command Line:

 

/I"./" /I"api" /I"common" /I"controls" /I"decals" /I"filesystem" /I"compute/cpu" /I"framework" /I"game" /I"game/obstacles" /I"game/navigations" /I"gui" /I"gui/fonts" /I"gui/widgets" /I"gui/flash" /I"gui/flash/objects" /I"gui/flash/characters" /I"interpreter" /I"lights" /I"math" /I"network" /I"objects" /I"physics" /I"physics/bodies" /I"physics/joints" /I"physics/shapes" /I"physics/collider" /I"physics/physicals" /I"physics/solvers" /I"players" /I"render" /I"render/null" /I"render/null/framework" /I"render/opengl" /I"render/opengl/framework" /I"render/direct3d9" /I"render/direct3d9/framework" /I"render/direct3d10" /I"render/direct3d10/framework" /I"render/direct3d11" /I"render/direct3d11/framework" /I"sound" /I"sound/null" /I"sound/openal" /I"utils" /I"world" /I"world/worlds" /I"world/editors" /I"../../include" /I"../../externs/include" /I"../../externs/direct3d/include" /Zi /nologo /W3 /WX- /Od /Oi /Os /Oy /D "_CRT_SECURE_NO_DEPRECATE" /D "ARCH_X86" /D "HAVE_XML" /D "HAVE_IMAGE" /D "HAVE_REGEXP" /D "HAVE_SOCKET" /D "HAVE_BUFFER" /D "HAVE_VORBIS" /D "HAVE_THEORA" /D "HAVE_NVCPL" /D "USE_ASSERT" /D "USE_MEMORY" /D "USE_SHADER_CACHE" /D "USE_EXTERN_INFO" /D "USE_SSE" /D "USE_SSE2" /D "USE_OPENGL" /D "USE_GL_WRAPPER" /D "USE_DIRECT3D9" /D "USE_D3D9_WRAPPER" /D "USE_DIRECT3D10" /D "USE_D3D10_WRAPPER" /D "USE_DIRECT3D11" /D "USE_D3D11_WRAPPER" /D "USE_OPENAL" /D "USE_AL_WRAPPER" /D "USE_XPAD360" /D "USE_JOYSTICK" /D "USE_FLASH" /D "USE_EDITOR" /D "_DEBUG" /D "_WINDLL" /Gm- /EHsc /GS /fp:fast /Zc:wchar_t /Zc:forScope /Fp"Debug\unigine_vc2010d.pch" /Fa"Debug\" /Fo"Debug\" /Fd"Debug\vc100.pdb" /Gd /wd"4355" /wd"4250" /analyze- /errorReport:queue

 

Linker Command Line:

 

/OUT:"unigine_vc2010d.dll" /NOLOGO /LIBPATH:"../../externs/lib/windows/x86" /LIBPATH:"../../externs/direct3d/lib/x86" /DLL "kernel32.lib" "user32.lib" "gdi32.lib" "comdlg32.lib" "winspool.lib" "advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "odbc32.lib" "odbccp32.lib" /NODEFAULTLIB:"libcmt.lib" /MANIFEST /ManifestFile:"Debug\unigine_vc2010d.dll.intermediate.manifest" /ALLOWISOLATION /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /PDB:"unigine_vc2010d.pdb" /PGD:"D:\Work\UnigineSDK\source\engine\unigine_vc2010d.pgd" /TLBID:1 /DYNAMICBASE /NXCOMPAT /MACHINE:X86 /ERRORREPORT:QUEUE /stack:2097152

 

Optimization is also disabled and for main_vc2010 project which only starts (wrap) engine DLL. Not sure if settings for this EXE are relevant at all.

 

Thanks,

Milos

Link to comment

yes, looks ok. Last idea: have a look on exact unigine dll file that gets loaded on debug startup and ensure that this is your own recompiled version.

Link to comment

That's good. Module tab in VS 2010 showing both correct DLL/PDB files from correct location. PDB file loaded as well. Also checked with Windows Debugging Tools that PDB is matching DLL, everything fine.

 

Ulf, you don't have this strange behavior in this function?

 

Thanks,

Milos

Link to comment
Ulf, you don't have this strange behavior in this function? Thanks, Milos

don't know, I stopped Unigine programming and debugging some time ago, so I am just digging in my memories of problems I encountered during that time

Link to comment

No problem. I'm seeing exactly a same behavior even on different computers, so looks like it's expected by default. Either there is a compile/linker option which is breaking stack at some point or there is some dependency which should be rebuilded as well.

Link to comment
×
×
  • Create New...