Visual c++ 等待控制台输入时调用堆栈已断开?
我在VS2010(和VS2005)上观察到一些有趣(和恼人)的行为: 上下文:从Win78 64位上的Visual Studio调试器运行32位Windows控制台可执行文件Visual c++ 等待控制台输入时调用堆栈已断开?,visual-c++,console-application,visual-studio-debugging,Visual C++,Console Application,Visual Studio Debugging,我在VS2010(和VS2005)上观察到一些有趣(和恼人)的行为: 上下文:从Win78 64位上的Visual Studio调试器运行32位Windows控制台可执行文件 当从控制台获取输入(通过 STD::GETLeIO)并在应用程序等待用户输入时,进入调试器时,VisualStudioC++调试程序似乎无法正确地解析调用堆栈。有时,调用堆栈被完全破坏,我甚至看不到main,有时调用堆栈看起来有点不正常,也就是说,当我的代码正确显示时,它会向调用堆栈插入一些奇怪的函数调用 测试代码: #i
当从控制台获取输入(通过<代码> STD::GETLeIO<代码>)并在应用程序等待用户输入时,进入调试器时,VisualStudioC++调试程序似乎无法正确地解析调用堆栈。有时,调用堆栈被完全破坏,我甚至看不到main,有时调用堆栈看起来有点不正常,也就是说,当我的代码正确显示时,它会向调用堆栈插入一些奇怪的函数调用
测试代码:#include <iostream>
#include <string>
int main()
{
using namespace std;
cout << "Enter answer: ";
std::string ans;
std::getline(cin, ans); // << break into debugger while waiting here
cout << "\nYou answered: \"" << ans << "\"\n";
return 0;
}
#包括
#包括
int main()
{
使用名称空间std;
CUT这里没有任何需要修复的东西。你被埋藏在窗口深处。调试器因为你的线程被阻塞而不执行任何代码而抱怨。Windows本身当然是优化的代码,从优化的C或C++代码中获得可靠的堆栈跟踪是众所周知的困难。设置微软符号S。因此,获取Windows DLL的PDB是很重要的。Windows版本也是如此,以后的Windows版本不再使用帧指针省略优化选项,该选项使堆栈遍历变得困难
调试器恢复得足够好,一切都在_read_nolock()beyond是可靠的。这是你唯一应该关心的事情,它不像你能修复Windows本身的任何错误。当你知道你的程序正在运行时,使用Debug+Break All并没有多大用处,当然你可以找到一个更好的位置来设置断点。Windows本身当然是优化的代码,获得rel从优化的C或C++代码中找出的ILE堆栈是非常困难的——我在过去几年中看到了我的崩溃崩溃,并且<>代码> IdAccReSoelEng/<代码>实际上是MS符号在我身上的第一个(Kelnel.dll)。以一种可复制的方式,因此我认为,将损坏的调用堆栈归咎于任何优化都是不合适的——毕竟这就是PDB符号的作用。这里没有任何需要修复的东西。-胡说八道!这不是一个致命的问题,但如果我在50%的情况下看不到任何东西,我敢说可能有一些东西是warra的nts修复。
kernel32.dll!_ReadConsoleInternal@32() + 0x15 bytes
kernel32.dll!_ReadConsoleInternal@32() + 0x15 bytes
> msvcr100d.dll!__dllonexit(int (void)* func=0x00000003, void (void)* * * pbegin=0x10113a60, void (void)* * * pend=0x00001000) Line 272 + 0x5 bytes C
msvcr100d.dll!_read_nolock(int fh=0, void * inputbuf=0x10113a60, unsigned int cnt=4096) Line 230 + 0x2e bytes C
msvcr100d.dll!_read(int fh=0, void * buf=0x10113a60, unsigned int cnt=4096) Line 92 + 0x11 bytes C
msvcr100d.dll!_filbuf(_iobuf * str=0x1010f498) Line 136 + 0x20 bytes C
msvcr100d.dll!fgetc(_iobuf * stream=0x1010f498) Line 49 + 0x44 bytes C
msvcp100d.dll!std::_Fgetc<char>(char & _Byte=0, _iobuf * _File=0x1010f498) Line 37 + 0xa bytes C++
msvcp100d.dll!std::basic_filebuf<char,std::char_traits<char> >::uflow() Line 435 + 0x13 bytes C++
msvcp100d.dll!std::basic_filebuf<char,std::char_traits<char> >::underflow() Line 413 + 0xd bytes C++
msvcp100d.dll!std::basic_streambuf<char,std::char_traits<char> >::sgetc() Line 153 + 0x3f bytes C++
StdGetLine.exe!std::getline<char,std::char_traits<char>,std::allocator<char> >(std::basic_istream<char,std::char_traits<char> > && _Istr={...}, std::basic_string<char,std::char_traits<char>,std::allocator<char> > & _Str="", const char _Delim='
') Line 412 + 0x30 bytes C++
StdGetLine.exe!std::getline<char,std::char_traits<char>,std::allocator<char> >(std::basic_istream<char,std::char_traits<char> > & _Istr={...}, std::basic_string<char,std::char_traits<char>,std::allocator<char> > & _Str="") Line 483 + 0x38 bytes C++
StdGetLine.exe!main() Line 9 + 0x10 bytes C++
StdGetLine.exe!__tmainCRTStartup() Line 555 + 0x19 bytes C
StdGetLine.exe!mainCRTStartup() Line 371 C
kernel32.dll!@BaseThreadInitThunk@12() + 0x12 bytes
ntdll.dll!___RtlUserThreadStart@8() + 0x27 bytes
ntdll.dll!__RtlUserThreadStart@8() + 0x1b bytes