gdb 7.7没有使用gcc4.7.3(Macports)登录OS-X Mavericks

时间:2014-03-22 18:19:38

标签: c++ macos gdb osx-mavericks

这是一个简单的程序:

#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)

我做错了吗?或者在os-x mavericks上使用它看起来像gdb的bug?

更新

使用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

我看到与here相同的缺少调用堆栈行为。虽然我无法检查编译-m32是否有助于我的情况,因为我拥有64位的所有内容,从而导致undefined symbols问题。

报告调试时的另一个步进问题here,此处SO

1 个答案:

答案 0 :(得分:0)

您需要将 -gdwarf-2 选项与-g一起添加到使用gdb进行调试以获取更新版本的gcc。

  

g ++ - mp-4.7 -g -gdwarf-2 -O0 prog.cc -o prog