Debugging with GDB in templated function

Hi all, I'm debugging a function in GDB, compiled with g++, It's getting a segmentaation fault.

The problem is that GDB does not see any symbols loaded for this function. The function is as such:


1
2
3
4
5
template<typename FWork, typename FStore>
pair<FWork,FWork> Solver::walker(int gr, int pot, Vertex node, FWork prob0, FWork prob1)
{
    //...
}


With FWork and FStore as doubles, and Vertex works out to be void* (from Boost Graph). There's only one instantiation of this function, and it's the <double, double> version.


I compile it with g++ -Wall -DTIXML_USE_STL -march=native -Wno-deprecated -ggdb -D_GLIBCXX_DEBUG ... with g++ version "gcc version 4.4.3" on "x86_64-linux-gnu". (it is Ubuntu.)

I debug it with gdb [executable] and with gdb version "GNU gdb (GDB) 7.1-ubuntu".


All other functions have their symbol tables loaded, specifically, here is the output of backtrace full when I get the seg fault:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31

Program received signal SIGSEGV, Segmentation fault.
0x00000000004741a6 in std::pair<double, double> Solver::walker<double, double>(int, int, void*, double, double) ()
(gdb) bt full
#0  0x00000000004741a6 in std::pair<double, double> Solver::walker<double, double>(int, int, void*, double, double) ()
No symbol table info available.
#1  0x0000000000474803 in std::pair<double, double> Solver::walker<double, double>(int, int, void*, double, double) ()
No symbol table info available.
#2  0x0000000000474b91 in std::pair<double, double> Solver::walker<double, double>(int, int, void*, double, double) ()
No symbol table info available.
#3  0x0000000000474a2f in std::pair<double, double> Solver::walker<double, double>(int, int, void*, double, double) ()
No symbol table info available.
#4  0x0000000000474b91 in std::pair<double, double> Solver::walker<double, double>(int, int, void*, double, double) ()
No symbol table info available.
#5  0x000000000047492f in std::pair<double, double> Solver::walker<double, double>(int, int, void*, double, double) ()
No symbol table info available.
#6  0x0000000000474c3b in std::pair<double, double> Solver::walker<double, double>(int, int, void*, double, double) ()
No symbol table info available.
#7  0x000000000047322f in Solver::threadloop (this=0x7fffffffdf70) at PokerNoLimit/solver.cpp:357
No locals.
#8  0x0000000000473170 in Solver::doiter (iter=5) at PokerNoLimit/solver.cpp:239
        solvers = {{cardsi = {{0, 0}, {0, 0}, {0, 0}, {0, 0}}, twoprob0wins = 2, static iterations = 1, static total = 5, static inittime = 1278275101.5918269,
            static cardmachine = 0x913bd0, static tree = 0x708950, static treeroot = 0x70b3b0, static memory = 0x9167c0}}
#9  0x0000000000471e28 in Solver::solve (iter=5) at PokerNoLimit/solver.cpp:71
        starttime = 1278275101.591922
#10 0x0000000000470fcd in simulate (iter=5) at PokerNoLimit/pokernolimit.cpp:49
        prevrate = -1
        timetaken = 3.6400701472496346e-317
#11 0x0000000000471128 in main (argc=1, argv=0x7fffffffe1b8) at PokerNoLimit/pokernolimit.cpp:68
        current_iter_amount = 5
(gdb)


Does anybody have any idea how to get the symbol table working? I can't even tell the line where the seg fault is happening! This is not acceptable! The symbols for everything were fine before I changed walker to be templated. The Solver class itself is not templated.
1, Is there any warning after being complied?

2. seems the loop had succeed for 4 passes, check your pointer carefully.

3. "no symbol info" is not the segment reason. try -g2.
I would try this g++ -Wall -DTIXML_USE_STL -march=native -Wno-deprecated -ggdb -D_GLIBCXX_DEBUG -g3

-g3 adds debugging info.
Hey, thanks for the suggestion of -g3, but it doesn't work either. I've actually found this bug, but would still like to debug the templated function.

If I do objdump -S on the executable I see the source and disassembly of the walker function is there. objdump -t | grep walker shows the mangled name (and shows it is "weak" instead of "global"). Is this info from the executable the info gdb is looking for? I don't think there are any other debug files, right?

Any ideas?
Topic archived. No new replies allowed.