Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Gnu Debugger (GDB)

This thread is locked; no one can reply to it. rss feed Print
Gnu Debugger (GDB)
rswhite
Member #10,279
October 2008

After my last Thread Game Crash i learnt to use GDB.
But how i wrote in my last Post in this Thread:

Quote:

Hot tip, thanks :)

But i wanted to test gdb now, but if i start gdb this comes and then it crash like the game before:
Quote:

BFD: C:\Windows\system32\atiumdva.dll (.text): Section flag IMAGE_SCN_MEM_NOT_PAGED (0x8000000) ignored

I have searched for this but i couldn't find an answer which i understand :/
Can you help me?

How i start it:
i write

Quote:

gdb map.exe

and then run, after that it crash :/

ReyBrujo
Moderator
January 2001
avatar

Compile it with -ggdb3 and try again. Looks like you crashed your graphic driver bad.

--
RB
光子「あたしただ…奪う側に回ろうと思っただけよ」
Mitsuko's last words, Battle Royale

weapon_S
Member #7,859
October 2006
avatar

rswhite
Member #10,279
October 2008

How i use ggdb3? ggdb3 and gdb3 don't works - must i install anything else?

backtrace? you mean that i write instead "run" - "backtrace" or what?
If i do this, i get this message: "No Stack."

kazzmir
Member #1,786
December 2001
avatar

ggdb3 is a compilation flag to gcc.

$ gcc -ggdb3 foo.c -o foo

rswhite
Member #10,279
October 2008

I have changed my Makefile to this:

Quote:

CPP=g++

#CPPFLAGS=-mwindows -D__GTHREAD_HIDE_WIN32API -Wall
CPPFLAGS=-ggdb3
LIBS=-lalleg

OBJECTS=main.o util.o sprite.o map.o joypad.o player.o world.o character.o monster.o rules.o

map: ${OBJECTS}
${CPP} -o $@ ${OBJECTS} ${CPPFLAGS} ${LIBS}

But if i compile now (with aware error) and start then gdb with "gdb map.exe" this error comes:

Quote:

GNU gdb 5.2.1
Copyright 2002 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i686-pc-mingw32"...c:/cygmnt/prj/pkg/src/gdb/mingw32/gdb/dwarf2read.c:98
5: gdb-internal-error: read_comp_unit_head: dwarf from non elf file

An internal GDB error was detected. This may make further
debugging unreliable. Quit this debugging session? (y or n)

edit:
if i write "n" by this and the next question, gdb starts. If i write now "run" the same error comes:

rswhite said:

Starting program: C:\Users\White\Desktop\programmierung\c++\map_objects\step2\my_kapitel 28/map.exe

BFD: C:\Windows\system32\atiumdva.dll (.text): Section flag IMAGE_SCN_MEM_NOT_PAGED (0x8000000) ignored

kazzmir
Member #1,786
December 2001
avatar

FWIW, gdb is crap on windows. I highly recommend you try compiling your project with MSVC (express is free) and using its debugger.

ReyBrujo
Moderator
January 2001
avatar

Is it too big to post the full code to test it? I would suggest you to comment functions until it doesn't crash, it is probably memory corruption.

--
RB
光子「あたしただ…奪う側に回ろうと思っただけよ」
Mitsuko's last words, Battle Royale

rswhite
Member #10,279
October 2008

I have found all mistakes, hence, the following code functions completely perfectly, has packed him sometimes by Zip.

And what concerns MSVC, I hate the thing:) Permanently new projects put in, complicated use in contrast to other editors... no, i use rather textmate :)

kazzmir
Member #1,786
December 2001
avatar

Yes I agree but for a good debugging experience your choices seem to be:
1. msvc on windows
2. gdb on linux/osx

You could try to install a VM with ubuntu in it and debug in that in the future.

rswhite
Member #10,279
October 2008

You mean, that i must work with MSVC? -.-
I hate it, because i must create new projects and can't use existing folders as projects, it is too complicated, i hate complicate things...
Exist no other debugger for windows?

kazzmir
Member #1,786
December 2001
avatar

You could try the intel debugger (idb). Intel's compiler is like 99% backwards compatible with g++ so you don't have to change anything to get it to work.

You can download the intel compiler for free for non-commercial use, just google around for it.

ImLeftFooted
Member #3,935
October 2003
avatar

What's wrong with gdb on windows?

GullRaDriel
Member #3,861
September 2003
avatar

I was asking myself the same thing...

"Code is like shit - it only smells if it is not yours"
Allegro Wiki, full of examples and articles !!

rswhite
Member #10,279
October 2008

I don't know why the error which i posted comes.

edit:
I had read the manual to install Code::Blocks to use the gnu compiler (see here).
But if i now try to compile an allegro program, this error comes:

Quote:

-------------- Build: default in test ---------------
mingw32-gcc.exe: /nologo: No such file or directory
mingw32-gcc.exe: /ML: No such file or directory
mingw32-gcc.exe: /Gd: No such file or directory
mingw32-gcc.exe: /GX: No such file or directory
mingw32-gcc.exe: /O2: No such file or directory
mingw32-gcc.exe: /W3: No such file or directory
mingw32-gcc.exe: /IC:\Program Files\Microsoft DirectX 9.0 SDK (October 2005)\Include: Invalid argument
mingw32-gcc.exe: /IC:\Program Files\Microsoft Visual C++ Toolkit 2003\include: Invalid argument
mingw32-gcc.exe: /IC:\Program Files\Microsoft Platform SDK\Include: Invalid argument
mingw32-gcc.exe: /IC:\allegro: Invalid argument
mingw32-gcc.exe: /c: No such file or directory
mingw32-gcc.exe: /Fo.objs\main.obj: No such file or directory
Process terminated with status 1 (0 minutes, 0 seconds)
0 errors, 0 warnings

What happend now? What's going wrong? oO

Kitty Cat
Member #2,815
October 2002
avatar

What's wrong with gdb on windows?

It doesn't work too well. GDB is designed to work with signals (eg. SIGABRT, SIGSEGV), but Windows likes to use exceptions. This causes GDB to not catch signals reliably, and sometimes crash GDB itself instead of the app.

--
"Do not meddle in the affairs of cats, for they are subtle and will pee on your computer." -- Bruce Graham

rswhite
Member #10,279
October 2008

I thanks all for their help - i have read many manuals and now my Code::Blocks works, i program at now with this.
Thank you :)

Tobias Dammers
Member #2,604
August 2002
avatar

What's wrong with gdb on windows?

gdb also seems to have quite some trouble with the windows threading model.

rswhite said:

I hate it, because i must create new projects and can't use existing folders as projects, it is too complicated, i hate complicate things...

MSVC creates the projects for you, and you can simply add everything inside a folder to your project. It's not THAT complicated. It used to be quite bad and counter-intuitive, but the 2008 version is actually pretty good. And even though MSVC creates a project file for you, it doesn't touch your source files unless you tell it to.
If you are used to coding with a text editor and a command line, switching to an IDE does take some getting used to, I admit that.
My point is, MSVC is "the" compiler for windows, just like gcc is the compiler for gnu/linux. If you want to do serious windows development, be prepared to use MSVC, at least for some parts of your development process.

Quote:

Exist no other debugger for windows?

For the die-hards, there is always "manual debugging". It works as follows:
- Write very clean and readable code, with truckloads of concise, to-the-point comments; make sure the code is modular and maintainable, document everything unambiguously (especially function behaviour, return values and arguments); be consistent in everything you do including indentation and naming conventions; refactor early, optimize late (or not at all); favour readability over speed.
- Use assert() all over the place. When something goes wrong, chances are one of the asserts will catch it and tell you where things are not what you want them to be. If no assert() catches the error at hand, add more asserts to find it.
- When assert doesn't give you what you need, use trace() to dump line numbers and the values of interesting variables into a trace file. This is the manual equivalent of setting a breakpoint and examining variables. The technique can also be used to trace the program flow after the fact; place trace() statements at strategic locations (e.g. the beginning and end of each function, right before and after any decision, etc.); when stuff goes wrong, open up the trace file and see what the last actions of your program were.
- If you want to make absolutely sure that a certain line of code is reached, put in an assert that always fails (assert(0)). If the line is reached, the assert must fire.
- In the case of a graphical application, you can use the console to dump debugging information

---
Me make music: Triofobie
---
"We need Tobias and his awesome trombone, too." - Johan Halmén

GullRaDriel
Member #3,861
September 2003
avatar

Just a note: it's been a long time since the last time gdb crashed or not helped me to debug my apps correctly on windows.

"Code is like shit - it only smells if it is not yours"
Allegro Wiki, full of examples and articles !!

Go to: