Problem with GDB on Devcpp
Sophat Pheng

Hello,
I was wondering why GDB is running fine let's say for a simple program like this

int main()
{
   int i;
   // do some stuff
   i = 3;
   i+= 5;
   return 0;
}

but isn't working with my allegro program. I got a segmentation fault.

1#include <allegro.h>
2 
3int main() {
4 int depth, res;
5 allegro_init();
6 depth = desktop_color_depth();
7 if (depth == 0) depth = 32;
8 set_color_depth(depth);
9 res = set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0);
10 if (res != 0) {
11 allegro_message(allegro_error);
12 exit(-1);
13 }
14 install_keyboard();
15 
16 while (!key[KEY_ESC]) {
17 /* put your code here */
18 }
19 
20 allegro_exit();
21 return 0;
22}
23END_OF_MAIN()

I have enable "Generate debugging information"
I am compiling with -Wall -g and I am linking to liballd.a

Help please.
Thanks in advance

ReyBrujo

Code looks fine. Are you debugging step by step and it throws the exception, or it throws when trying to run it with F5?

Sophat Pheng

When i'm not debugging, it runs fines but it throws the error when I'm doing step-by-step (shift+F4) or simply debut (F8)

Im using Devcpp 4.9.9.2 (beta 5 release 9) could that be the problem ?

EDIT:
I've just uninstall everything and I reinstalled Mingw32 3.1.0-1 and devcpp 4.9.9.2 without mingw. I switch from allegro 4.2 to allegro 4.03 and I compiled the profile, debug and release version of the library. GDB version is 5.2.1
It still doesn't work and I'm running out of ideas... :'(

BAF

Well... showing us the full source and telling us what line it tells you the segfault is at would help.

Sophat Pheng

Well the code I posted is actually the full source. Also, wherever I put my breakpoint, a segmentation fault happens.

I'm running on XP.

I fount out in other threads that I'm not the only one having this problem and maybe GDB is at fault since it wasn't made to run on windows. Any advices are still appreciated.

Kitty Cat

Yes, GDB in Windows isn't the most stable thing in the world. Seems to be a recurring problem for MinGW users.

GullRaDriel

I've never had problem with it under windows ... But I think I got teh fluid ;-p

Arthur Kalliokoski

I see you're not setting GFX_TEXT before calling allegro_message if failing to set a graphic mode. Also, I thought there was an issue about installing keyboard before as well?

Can the example programs set GFX_AUTODETECT_WINDOWED 640 480 @ 32bpp?

Thread #574504. Printed from Allegro.cc