在Linux ubuntu中逐行c - c ++代码调试 [英] Line by line c - c++ code debugging in Linux ubuntu

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

问题描述

我在ubuntu中使用gedit进行编码,并在终端中运行程序。在使用Turboc或netbeans的Windows中工作时,我们可以逐行调试代码。我们该如何在ubuntu终端上做?或任何其他选项?

解决方案

gdb (Gnu调试器)是最佳选择



apt-get install gdb



man gdb

  1。 cc -g file.c //编译你的程序,这将生成一个需要调试信息的a.out文件

2. gdb a.out //从gdb开始

3.主要//设置断点在主

4.运行//运行现在,它将在断点处停止main

5. s //选项s是单行,甚至步入函数

6. n //选项n是执行下一行并重新执行函数

7. p变量名称//打印该特定实例变量的值非常有帮助

man gdb 将给出更多信息



所有有用的gdb命令和一个简单的cpp程序的例子都被赋予了这里



GDB文档


I am coding using gedit in ubuntu and running program in terminal. While working in windows using Turboc or netbeans we can debug code line by line. How can we do it in ubuntu terminal? or any other option?

解决方案

gdb (The Gnu debugger) is best choice

apt-get install gdb

man gdb

1.    cc -g file.c             //       compile your program ,this will generate a.out file with required debugging information 

2.    gdb a.out                //        start with gdb

3.    b main                   //        to set break point at main       

4.     run                     //        run now , and it will stop at break point main 

5.     s                       //        option s is to step single line and even step into functions

6.     n                       //        option n is to execute next line and step over functions  

7.     p    variable name      //        to print the value of variable at that particular instance very helpful  

man gdb will give more info

All useful gdb commands and an example with simple cpp program are given Here

GDB Documentation

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

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