User forums > Help

How to use gdb in C::B?

<< < (3/6) > >>

rickg22:
OK let me get this straight. Your app "runs" fine, but segfaults if debugged. Is that it?

sethjackson:
Could you post the code?

selles:
Hello All again, :D

Sorry for the delay in continuing with that discussion, I wait for qe they are still willing the they help me..

well... this problem is something sinister, I am working in a small game, using the engine Irrlicht and in the following codeline the error appear:



--- Code: ---
#include <windows.h>
#define sleep(x)    Sleep(1 * (x))

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "irrlicht.h"
#pragma comment(lib, "Irrlicht.lib")


using namespace irr;

using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;

namespce Cente
{

class FluxoProg
{
 ...

}


namespace Cente3D
{

    //colisão
    ITriangleSelector* seletor;

...

class AtorLocal : public Cente::FluxoProg
{
   public:
    AtorLocal(const wchar_t* nome, bool sexo, int altura, IrrlichtDevice* dispositivo,
              ISceneManager* gerCena) : zdirection(0),ydirection(0)
    {
     

     disp=dispositivo;
     cena=gerCena;
     nodo=0;
     camDist=164.0f;
     //inicia variaveis
     tam=0.5f;
     tamInicial=tam;
     
     if(!sexo)
     {
       ator=gerCena->getMesh("media/mulherTex2.X");
     }
     else
     {
       ator=gerCena->getMesh("media/homem.X");
     }
     
     if(ator)
     {
         nodo=gerCena->addAnimatedMeshSceneNode(ator);
         nodo->setID((s32)ProgRede::idCliLocal);
         nodo->setPosition(vector3df(50.0f, 50.0f, 1000.0f));
         nodo->setName(nome);
         
         //animação
        /* nodo->setAnimationSpeed(4);
         nodo->setLoopMode(true);
         nodo->setFrameLoop();
         */
         //aparencia e textura
         nodo->setMaterialType(EMT_TRANSPARENT_ALPHA_CHANNEL);     
     
         if(altura==1)//estatura pequena
         {
           tam-=0.1f;
           tam=tamInicial*tam/tamInicial;
           nodo->setScale(vector3df(tam,tam,tam)); 
         }
         if(altura==2)//estatura normal
         {
           nodo->setScale(vector3df(tam,tam,tam)); 
         }
         if(altura==3)//estatura alta
         {
           tam+=0.1f;
           tam=tamInicial*tam/tamInicial;//0.5*0.6/0.5
           nodo->setScale(vector3df(tam,tam,tam)); 
         }
     }
     aabbox3d<f32> box=nodo->getBoundingBox();
     vector3df raio=box.MaxEdge-box.getCenter();     
   
     visaoNodo=gerCena->addTestSceneNode(10.0f);
     visaoNodo->setName(L"cubo");
     visaoNodo->setPosition(vector3df(0.0f, 0.0f, 10.0f));

     cameraNodo1P=gerCena->addCameraSceneNode(nodo, vector3df(nodo->getPosition().X-20.0f,
                                                              nodo->getPosition().Y+180.0f*tam/tamInicial,
                                                              nodo->getPosition().Z));
     cameraNodo1P->setFOV(90.0f*180.0f/GRAD_PI2);
     cameraNodo=gerCena->addCameraSceneNode(0);
     cameraNodo->setFOV(90.0f*180.0f/GRAD_PI2);
     
     //colisao
       
       seletorAtor=seletor; 
       ISceneNodeAnimator* nodoAnim = cena->createCollisionResponseAnimator(seletorAtor, nodo,
                                                                            vector3df(raio.X,
                                                                                      raio.Y,
                                                                                      raio.Z),
                                                                            vector3df(0.0f,-1.0f,0.0f),
                                                                            vector3df(0.0f,-raio.Y,0.0f));
       nodo->addAnimator(nodoAnim);
       nodoAnim->drop();
     
       ISceneNodeAnimator* cameraAnim = cena->createCollisionResponseAnimator(seletorAtor, cameraNodo,
                                                                              vector3df(3,3,3),
                                                                              vector3df(0,0,0),
                                                                              vector3df(0,0,0));
       cameraNodo->addAnimator(cameraAnim);
       cameraAnim->drop();
     
   }
   
   private:
   
   IAnimatedMesh* ator;
   ICameraSceneNode* cameraNodo;
   ICameraSceneNode* cameraNodo1P;
   ISceneManager* cena;
   IrrlichtDevice* disp;
   
   ISceneNodeAnimator* cameraAnim;
   ISceneNodeAnimator* nodoAnim;
   ISceneNode* nodo;
   ISceneNode* visaoNodo;
   ISceneNode* selectedSceneNode;
   ISceneNode* lastSelectedSceneNode;
   ITriangleSelector* seletorAtor;
   
   float tam,
   tamInicial,
   zdirection,
   ydirection,
   camDist;   
   


...

}



...
...
...

class MapaCtrl : public FluxoProg
{
  public:

  MapaCtrl(const c8* nivel, const c8* pacote, const c8* caminho, ISceneManager* cena,
               IrrlichtDevice* dispositivo, IVideoDriver* vDriver)
 {
    gerCena=cena;
    disp=dispositivo;
    driver=vDriver;
   
    seletor=0;
    nivelNodo = 0;
   
    if (pacote!="")
    { 
       char caminhoPacote[1024];
       strcpy(caminhoPacote, caminho);
       strcat(caminhoPacote, pacote);
       
       dispositivo->getFileSystem()->addZipFileArchive(caminhoPacote);
   
    nivelMalha = cena->getMesh(nivel);
   
    if (nivelMalha)
    {
        nivelNodo = cena->addOctTreeSceneNode(nivelMalha->getMesh(0));
        nivelNodo->setScale(vector3df(10,10,10));
nivelNodo->setPosition(core::vector3df(0.0f,-9000.0f,0.0f));
nivelNodo->setName(L"cenario");
    }
   
    //colisão
    seletorMapa = cena->createOctTreeTriangleSelector(nivelMalha->getMesh(0), nivelNodo, 128); //the chash is in that line!!!
    nivelNodo->setTriangleSelector(seletorMapa);
    seletorMapa->drop();
   
    seletor=seletorMapa;
   
    cena->addLightSceneNode(0, core::vector3df(-60,100,400),
                    video::SColorf(1.0f,1.0f,1.0f,1.0f), 600.0f);

    cena->addLightSceneNode(0, core::vector3df(60,100,-400),
                                    video::SColorf(1.0f,1.0f,1.0f,1.0f), 600.0f);
 };
 
 ~MapaCtrl()
 {
 };

 private:

  ISceneManager* gerCena;
  IrrlichtDevice* disp;
  IVideoDriver* driver;
  ISceneNode* nivelNodo;
  IAnimatedMesh* nivelMalha;
  ITriangleSelector* seletorMapa;

...


};

}// namespace Cente3D

}//namespace Cente


--- End code ---

The mistakes that appear in GDB Debbuger are:


--- Code: ---Selecting target: default
Compiling: done
Starting debugger: done
Adding source dir: C:\irrlicht-0.10.0\Selles_app\
Adding source dir: C:\irrlicht-0.10.0\Selles_app\
Adding source dir: C:\irrlicht-0.10.0\Selles_app\
Adding source dir: C:\Documents and Settings\FSelles\Desktop\w32\
Adding source dir: C:\Documents and Settings\FSelles\Desktop\consoleApp2\
Adding source dir: C:\Documents and Settings\FSelles\Desktop\consoleApp2\
Adding source dir: C:\Documents and Settings\FSelles\Desktop\consoleApp2\
Adding file: ..\..\Documents and Settings\FSelles\Desktop\consoleApp2\selles_console.exe
Changing directory to: "../../Documents and Settings/FSelles/Desktop/consoleApp2"
"../../Documents and Settings/FSelles/Desktop/consoleApp2": Invalid argument.
error
Program received signal (SIGSEGV)
Segmentation fault
No symbol "MessageBox" in current context.
No symbol "setScale" in current context.
Attempt to use a type name as an expression
Attempt to use a type name as an expression
No symbol "ISceneNode" in current context.
No symbol "a" in current context.
No symbol "str" in current context.
The history is empty.
error
error
error
error
error
error
error
error
error
error
error
error


--- End code ---

thanks you,

                               Selles

sethjackson:
On which line does it seg?

Also why do you do this?


--- Code: ---#define sleep(x)    Sleep(1 * (x))

--- End code ---

This will always be the number you supply.

eg


--- Code: ---sleep(1)

--- End code ---

will be


--- Code: ---Sleep(1 * (1))

--- End code ---

Maybe I misunderstand but that seems useless to me. Unless you just like to have it lower case sleep().

selles:
I placed the comment " / / " in the line where the debbuger stops, int the class MapaCtrl exactly in that line:


--- Code: ---    ...

  seletorMapa = cena->createOctTreeTriangleSelector(nivelMalha->getMesh(0), nivelNodo, 128); //the chash is in that line!!!
    ...


--- End code ---
:wink:

with relationship to the " sleep ", sorry, that is a test that I am doing and I posted with the code, please ignore that line.. :)

Thanks for the answer,

                Selles

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version