编译 - gdb调试c++时,遇到endl就无法继续调试
PHP中文网
PHP中文网 2017-04-17 14:18:48
0
1
655

使用gcc编译时候,编译选项如下:

g++ -std=c++11 -g -o cpp730 cpp730.cpp

程序可以正常运行,但是使用gdb.exe调试的时候,遇到endl,就无法继续调试,每次都卡在这个语句.

用来试验的代码比较简单

#include <iostream>
#include <string>
#include <cctype>
using namespace std;

int main(){
    string temp("abcdefg");
    
    cout << temp << endl;
    
    for (auto &a : temp)
        a = toupper(a);
    
    cout << temp << endl;
    
    return 0;
}

g++和gdb都是最新的版本,然后gdb用来调试C语言程序没有出现问题.

PHP中文网
PHP中文网

认证高级PHP讲师

reply all(1)
小葫芦

Update: Sorry, there was a mistake. For 64-bit to be able to correctly single-step trace std::cout << std::endl, it must be the Mingw-w64 compiler.

Supplement: Are you using the latest version (tdm64-gcc-5.1.0-2.exe) of Tdm-mingw x86-64 (64-bit version)?
I tested today and the tdm64-gcc-5.1.0-2.exe version has this problem! (It freezes when debugging to << endl)
Please return to the previous version: tdm64-gcc-5.1.0.exe
(Download page https://sourceforge.net/proje... )
Everything is OK.
If I am free tomorrow, I will submit this question to the author.

---------------(The following analysis is correct, but it is not the root cause of this problem)---------
1. endl is actually a function The address of source code.
Try using n on that line.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template