在Linux中调试C ++程序 [英] Debug C++ program in Linux

查看:76
本文介绍了在Linux中调试C ++程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经编写了一个简单的C ++程序,如下所示:

I have written a simple C++ program like this:

#include <iostream>
using namespace std;
int main()
{
    cout << "Hello.";
    return 0;
}

现在我要调试它.那么命令的目的是什么呢,以便我控制到每一行?

Now I want to debug it. So what will be the command for it so my control goes to every line?

推荐答案

您可以使用 gdb 为此:

You can use gdb for this:

$ gdb hello

这将启动gdb,并提示您下一步做什么. next命令执行源代码的一行,并在下一行停止.

This will start gdb and prompt you for what to do next. The next command executes one line of source and stops at the next line.

我发现一个基本的 GDB教程可能会有所帮助.

I found a basic GDB tutorial that may be helpful.

这篇关于在Linux中调试C ++程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆