Author Topic: How to use gdb in C::B?  (Read 20809 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


sethjackson

  • Guest
Re: How to use gdb in C::B?
« Reply #15 on: November 26, 2005, 03:36:46 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



Ok about the sleep part. :)

Umm what are the function values at that moment?

selles

  • Guest
Re: How to use gdb in C::B?
« Reply #16 on: November 27, 2005, 12:56:39 am »
the 1st argument is the mesh 3d that is the map scene(was loaded from a file)
the 2nd argument is the node which the mesh map is attachedin the scene manager
the 3rd argument is the minimal polygons per node.

so, I have created the triangle selector for the mesh map, this allows the engine to do the collision.

note that there are a statement "ITriangleSelector* seletor." in the begin of the  namespace Cente3D but outside any class..

in MapaCtrl class was done te detection of the scene (mesh map) for the collision, continuing, in the AtorLocal class was created a collision response for the collision of a actor (player) with the scene..for that, note that the seletor pointer was used, therefore seletor is a global pointer..I already to inherit that pointer, but hte program not compile.

that is the codeline use the seletor pointer.

Code

                                      ...

       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));

                                      ...



the collision probably run of transparent way  in a internal loop..

thanks,

Selles

sethjackson

  • Guest
Re: How to use gdb in C::B?
« Reply #17 on: November 27, 2005, 01:50:05 am »
I meant what are the function values?. An example would be nivelNodo and the value would be 1. Sorry I'm confusing sometimes. :)

selles

  • Guest
Re: How to use gdb in C::B?
« Reply #18 on: November 28, 2005, 04:15:31 pm »
oh, I was who didn't understand your question  :oops: ..sorry

I have added the pointer in watch, and in exact moment of the error, the values are:

seletorMapa = (struct ITriangleSelector*) 0xbaadf00d
nivelMalha = (struct IAnimatedMesh*) 0x0
nivelNodo = (struct ISceneNode*) 0x0

also sorry the slowness in posting here, it is that am very close of a condition of an athlete for here :lol:

thanks,

Selles

sethjackson

  • Guest
Re: How to use gdb in C::B?
« Reply #19 on: November 28, 2005, 04:43:55 pm »
Ok are nivelMaha and nivelNodo supposed to be 0? That is all I can think of unless selectorMapa is supposed to be 0.

Quote
also sorry the slowness in posting here, it is that am very close of a condition of an athlete for here :lol:

Off topic but what sport(s) do you play?

Offline Urxae

  • Regular
  • ***
  • Posts: 376
Re: How to use gdb in C::B?
« Reply #20 on: November 28, 2005, 04:45:49 pm »
Code
    ...
  seletorMapa = cena->createOctTreeTriangleSelector(nivelMalha->getMesh(0), nivelNodo, 128); //the chash is in that line!!!
    ...
I have added the pointer in watch, and in exact moment of the error, the values are:

seletorMapa = (struct ITriangleSelector*) 0xbaadf00d
nivelMalha = (struct IAnimatedMesh*) 0x0
nivelNodo = (struct ISceneNode*) 0x0

Well, there's your problem: your line includes nivelMalha->getMesh(0), but nivelMalha is 0x0. This means you're dereferencing a null pointer, which is pretty much never a good thing to do ;).

Ok are nivelMaha and nivelNodo supposed to be 0? That is all I can think of unless selectorMapa is supposed to be 0.

As seen above, at the very least nivelMalha isn't supposed to be.

selles

  • Guest
Re: How to use gdb in C::B?
« Reply #21 on: November 28, 2005, 06:45:19 pm »
 no understand..

the application is right, it is compiling, the mesh appear usually, how that is possible?   :?

thanks,

Selles


sethjackson

  • Guest
Re: How to use gdb in C::B?
« Reply #22 on: November 28, 2005, 06:52:08 pm »
no understand..

the application is right, it is compiling, the mesh appear usually, how that is possible?   :?

thanks,

Selles



You don't understand? Or do I misunderstand. :)

selles

  • Guest
Re: How to use gdb in C::B?
« Reply #23 on: November 28, 2005, 07:35:34 pm »
no, no Seth,

I made a joke ..I wanted to say that am working a lot  :lol: :lol: :lol:

Selles

sethjackson

  • Guest
Re: How to use gdb in C::B?
« Reply #24 on: November 28, 2005, 07:43:16 pm »
no, no Seth,

I made a joke ..I wanted to say that am working a lot  :lol: :lol: :lol:

Selles


Haha  I get it now. :lol:

selles

  • Guest
Re: How to use gdb in C::B?
« Reply #25 on: November 28, 2005, 11:26:31 pm »

no understand..

the application is right, it is compiling, the mesh appear usually, how that is possible? :?

thanks,

Selles



You don't understand? Or do I misunderstand. :)

 I understood what is happening, I tell that because I don't understand how do it can work when it usually rotates and not to work when it rotates for the debug?

 eccentric.. ?!

thanks,

Selles

sethjackson

  • Guest
Re: How to use gdb in C::B?
« Reply #26 on: November 29, 2005, 02:45:54 am »
Yes that is very odd...  :?

selles

  • Guest
Re: How to use gdb in C::B?
« Reply #27 on: November 29, 2005, 08:07:03 pm »
Well..It should be some mistake of GDB or of the compiler. . in my code this doesn't make sense to be

 thanks to you I understood those mistakes and I will always verify the pointers when there are like this mistakes..

Thank you,

           Selles

« Last Edit: November 29, 2005, 08:09:47 pm by selles »