segfault and gdb won't give me a line number

I'm getting a segfault somewhere in this method:

void drawBattle::loadImage(int index, string filename, bool polarity)
if (polarity == true) //It's an ally

aimage[index] = aparty[index].getImage();

Uint32 colorkey = SDL_MapRGB(aimage[index]->format, 0, 255, 0);
SDL_SetColorKey(aimage[index], SDL_SRCCOLORKEY, colorkey);

asrc[index].x = 0;
asrc[index].y = 0;
asrc[index].w = aimage[index]->w;
asrc[index].h = aimage[index]->h;


adest[index].x = 600;
adest[index].y = index * 100;
adest[index].w = aimage[index]->w;
adest[index].h = aimage[index]->h;
else //Must be an enemy...
//Add in later the code to access the enemyParty info...

eimage[index] = eparty[index].getImage();

colorkey = SDL_MapRGB(eimage[index]->format, 0, 0, 255);
SDL_SetColorKey(eimage[index], SDL_SRCCOLORKEY, colorkey);

esrc[index].x = 0;
esrc[index].y = 0;
esrc[index].w = eimage[index]->w;
esrc[index].h = eimage[index]->h;


edest[index].x = 0;
edest[index].y = index * 100;
edest[index].w = eimage[index]->w;
edest[index].h = eimage[index]->h;

gdb won't tell me the line number where the error is actually occurring:

michael@camille ourrpg $ gdb battle
GNU gdb (Gentoo 7.3.1 p2) 7.3.1
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-pc-linux-gnu".
For bug reporting instructions, please see:
Reading symbols from /home/work/ourrpg/battle...done.
(gdb) run
Starting program: /home/work/ourrpg/battle
warning: Could not load shared library symbols for
Do you need "set solib-search-path" or "set sysroot"?
[Thread debugging using libthread_db enabled]

Program received signal SIGSEGV, Segmentation fault.
0x0804a54d in drawBattle::loadImage(int, std::string, bool) ()
(gdb) bt
#0 0x0804a54d in drawBattle::loadImage(int, std::string, bool) ()
#1 0x08049770 in drawBattle::init() ()
#2 0x0804a9be in main ()
(gdb) quit
A debugging session is active.

Inferior 1 [process 2665] will be killed.

Quit anyway? (y or n) y

Here's my complete Makefile (with a lot of stuff unnecessary to this post)

CFLAGS=-H -W -Wall -pedantic -dH `sdl-config --cflags` -ggdb -g

LIBS=`sdl-config --libs` -lSDL_image -lSDL_gfx -lSDL_ttf

OBJS = ally.o drawBattle.o character.o enemy.o party.o allyparty.o enemyparty.o

INCS = ally.h drawBattle.h character.h enemy.h party.h allypart.h enemyparty.h

all: battle

battle: $(OBJS)
$(CXX) -o $@ $(OBJS) $(LIBS)

%.o : %.cpp $(INCS)
$(CXX) $(CFLAGS) -c $<

-rm *.o *~ core* vgcore* battle

What do I need to build my program with that will get me line numbers in gdb???

Topic archived. No new replies allowed.