Вот простая программа:
#include <iostream>
#include <vector>
namespace Example
{
template <int dim>
class Problem
{
public:
void run() {
std::cout<<"here.."<<std::endl;
}
};
}
int main(int argc, char *argv[])
{
Example::Problem<2> problem;
problem.run();
return 0;
}
скомпилировано с помощью Macport gcc 4.7.3:
g++-mp-4.7 -g -O0 prog.cc -o prog
Если я попытаюсь выполнить отладку в gdb 7.7 (самособранном, а не в Macport!):
$gdb
file prog
b main
r
s
Я не могу активировать функцию:
34 problem.run();
(gdb) s
here..
36 return 0;
(gdb)
Я делаю что-то неправильно? Или это похоже на ошибку gdb при использовании на os-x mavericks?
ОБНОВЛЕНИЕ:
Я не вижу никаких предупреждений/ошибок при использовании gdb:
$ gdb ./prog
GNU gdb (GDB) 7.7
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
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 "x86_64-apple-darwin13.1.0".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./prog...Reading symbols from /Users/bla-bla-bla/prog.dSYM/Contents/Resources/DWARF/prog...done.
done.
(gdb)
также '-gdwarf-2 -gstrict-dwarf' не меняет поведение....
UDAPTE2:
Я вижу то же поведение отсутствующего стека вызовов, что и здесь. Хотя я не смог проверить, помогает ли компиляция с -m32
в моем случае, так как у меня все для 64bit и соответственно получаю undefined symbols
проблемы.
О другой пошаговой проблеме при отладке сообщается здесь и здесь на SO.