gdb does not stops inside a template function

Dima Sorkin dima.sorkin@gmail.com
Tue Jun 20 09:50:00 GMT 2006


Hi.
 I have the following problem with gdb6.3 :
If I put a breakpoint on a line inside a function template,
the gdb not always stops there.

Please see attached ".cpp" file and the gdb session transcript
(file: "templ_dbg.1.output").
It can be seen that gdb stops on first call to "f",
but not on second.

Regards and thank you,
  Dima.

P.S.
 I use various versions of gcc compiler (3.3.6, 4.0.0),
the result was the same.
-------------- next part --------------
1 // templ_dbg.cpp -*-c++-*-
2
3 template<typename T> T const f(T const &t){
4         return t+t;
5 }
6
7 #include<iostream>
8 using namespace std;
9
10 int main(){
11         int i(5);
12         cout << f(i) << '\n';
13
14         double d(0.3);
15         cout << f(d) << '\n';
16
17         return 0;
18 }
19

-------------- next part --------------
(gdb) break templ_dbg.cpp:4
Breakpoint 1 at 0x804870b: file templ_dbg.cpp, line 4.
(gdb) run
Starting program: /home/dima/templ_dbg 
Reading symbols from shared object read from target memory...done.
Loaded system supplied DSO at 0x50d000

Breakpoint 1, f<int> (t=@0xbfa784c4) at templ_dbg.cpp:4
4               return t+t;
(gdb) print t
$1 = (const int &) @0xbfa784c4: 5
(gdb) continue
Continuing.
10
0.6

Program exited normally.
(gdb)

-------------- next part --------------
GNU gdb Red Hat Linux (6.3.0.0-1.21rh)
Copyright 2004 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 "i386-redhat-linux-gnu".


More information about the Gdb mailing list