Author Topic: How to use gdb in C::B?  (Read 20669 times)

selles

  • Guest
How to use gdb in C::B?
« on: November 03, 2005, 11:10:46 pm »
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

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Re: How to use gdb in C::B?
« Reply #1 on: November 03, 2005, 11:21:04 pm »
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

  • Guest
Re: How to use gdb in C::B?
« Reply #2 on: November 04, 2005, 04:24:05 am »
Oh, very simply!! 8)

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

Thank you ,  :)

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Re: How to use gdb in C::B?
« Reply #3 on: November 04, 2005, 08:36:04 am »
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

  • Guest
Re: How to use gdb in C::B?
« Reply #4 on: November 06, 2005, 01:21:12 am »
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


Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Re: How to use gdb in C::B?
« Reply #5 on: November 06, 2005, 10:25:57 am »
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

  • Guest
Re: How to use gdb in C::B?
« Reply #6 on: November 06, 2005, 05:58:52 pm »

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

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Re: How to use gdb in C::B?
« Reply #7 on: November 06, 2005, 06:54:55 pm »
Quote
can you clear me that errors?
What errors? These segmentation faults means your program is crashing....
Be patient!
This bug will be fixed soon...

selles

  • Guest
Re: How to use gdb in C::B?
« Reply #8 on: November 08, 2005, 04:20:07 am »
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

  • Guest
Re: How to use gdb in C::B?
« Reply #9 on: November 09, 2005, 06:24:35 pm »
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.. :)


Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: How to use gdb in C::B?
« Reply #10 on: November 09, 2005, 06:28:08 pm »
OK let me get this straight. Your app "runs" fine, but segfaults if debugged. Is that it?

sethjackson

  • Guest
Re: How to use gdb in C::B?
« Reply #11 on: November 09, 2005, 07:51:56 pm »
Could you post the code?

selles

  • Guest
Re: How to use gdb in C::B?
« Reply #12 on: November 25, 2005, 07:41:16 pm »
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


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


thanks you,

                               Selles

sethjackson

  • Guest
Re: How to use gdb in C::B?
« Reply #13 on: November 25, 2005, 08:38:14 pm »
On which line does it seg?

Also why do you do this?

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

This will always be the number you supply.

eg

Code
sleep(1)

will be

Code
Sleep(1 * (1))

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

selles

  • Guest
Re: How to use gdb in C::B?
« Reply #14 on: November 26, 2005, 02:01:29 am »
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!!!
    ...

: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