【发布时间】:2012-08-20 07:35:36
【问题描述】:
我在问题How to pass a string type path to boost::filesystem:path's constructor?成功编译了程序但是,输出结果显示的比预期的要多。
Folder status: 0
Bus error: 10
第一行是唯一的预期结果。我不明白为什么第二个来了?
我通过 gdb 得到以下调试信息:
(gdb) run
Starting program: /Users/ZL/Desktop/mtfsg
Reading symbols for shared libraries ++++............................. done
Folder status: 0
Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_PROTECTION_FAILURE at address: 0x00007fff5fc005a0
0x00007fff9046aab7 in std::basic_string<char, std::char_traits<char>,
std::allocator<char>>::~basic_string ()
(gdb) bt
#0 0x00007fff9046aab7 in std::basic_string<char, std::char_traits<char>,
std::allocator<char> >::~basic_string ()
#1 0x00000001000018dd in main () at m.cpp:12
【问题讨论】:
-
这是一个错误。您需要调试以找出问题所在。在您喜欢的调试器下运行程序。
-
但是关于如何在g++命令行编译器下调试有什么建议吗?还是在 Mac OS X 下?我在 C++ 中调试的经验很少。
-
运行
gbd下的程序。当它崩溃时,输入where。然后您使用up和down导航堆栈帧并使用print查看事物的值。 -
我通过gdb获取调试信息。请参阅问题区域的附加信息。
标签: c++ macos boost g++ boost-filesystem