News:

As usual while waiting for the next release - don't forget to check the nightly builds in the forum.

Main Menu

How to use gdb in C::B?

Started by selles, November 03, 2005, 11:10:46 PM

Previous topic - Next topic

selles

Hello, I am new in Free IDEs as Code::Blocks and Dev-C++..but, sincerely, C::B is fantastic.. :shock:

I have not idea how to use debug and the watches window..I already tried :?

I think that the gdb is already installed with C::B, i am  right?

so, I also checked the field "Produce Debugging Symbols " in compiler/compiler Options, is only this?

in "Add watch", I must simply put  the name of the variable, or others parameters are required?

thank you and Congratulations.. :P

                                                                                                                        F. Selles

mandrav

After you 've built your project, place any breakpoints you like in your code and start it by running Debug->Debug (F8).
When a breakpoint hits, look at the "Watches" tab ;)
Be patient!
This bug will be fixed soon...

selles

Oh, very simply!! 8)

and the "Add Watches" ?  for what he does serve then?

Thank you ,  :)

mandrav

By default, function arguments and local variables are watched (you can change this behaviour in debugger options).
Use "Add watch" to add watches for other variables.
Be patient!
This bug will be fixed soon...

selles

Thanks Mandrav, :D

but, some variables and definitions the Debugger do not recognized for some reason, see the following errors:

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: selles_console.exe
Changing directory to: "../../Documents and Settings/FSelles/Desktop/consoleApp2"
error
"../../Documents and Settings/FSelles/Desktop/consoleApp2": Invalid argument.
Program received signal (SIGSEGV)
Segmentation fault
Attempt to use a type name as an expression
Program received signal (SIGSEGV)
Segmentation fault
exited 128
Debugger finished with status 0


"Attempt to use a type name as an expression"  how do I configure that? ?

Thank you,
                       Selles


mandrav

Quote"Attempt to use a type name as an expression"  how do I configure that? ?
This means you tried to watch a typename, e.g. 'int'.
This message is usually harmless and might appear often if you enable "Settings->Plugins->Debugger->Evaluate expression under cursor" which will try to evaluate whatever word is under the mouse cursor...
Be patient!
This bug will be fixed soon...

selles


Quote
This message is usually harmless and might appear often..

I don't know if that is causing my problem here, so I unchecked in "Settings->Plugins->Debugger->Evaluate "expression under cursor", I don't believe that.. but that error always happens when I debug another program, I click then in the  " next line" button two times and the application finish.

error
Program received signal (SIGSEGV)
Segmentation fault
Program received signal (SIGSEGV)
Segmentation fault
exited 128
Debugger finished with status 0

can you clear me that errors?


Selles

mandrav

Quotecan you clear me that errors?
What errors? These segmentation faults means your program is crashing....
Be patient!
This bug will be fixed soon...

selles

no no Mandrav :lol:, of course I am not wanting to say that the mistake is of the C: : B,  I don't only get to understand what that is wanting me to say, because the application compiles e run perfectly, however that happens. . what do I have to do in that case? it can be because of the variable to be in another file.h and this file is not directly declared in the file in debug?

thank you Mandrav, and sorry for the confusion :)

Selles

selles

understood?
the codeline where is getting error in debug, works perfectly when only Run,

if you can give me a tip about what to do, I thank.. :)


rickg22

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

sethjackson


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:




#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



The mistakes that appear in GDB Debbuger are:


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



thanks you,

                               Selles

sethjackson

On which line does it seg?

Also why do you do this?


#define sleep(x)    Sleep(1 * (x))


This will always be the number you supply.

eg


sleep(1)


will be


Sleep(1 * (1))


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:


    ...

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


: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