我在ubuntu里用gedit编码,在终端上运行程序.当使用Turboc或NetBeans在Windows中工作时,我们可以逐行调试代码.在ubuntu终端怎么做呢?或者其他 Select ?
我在ubuntu里用gedit编码,在终端上运行程序.当使用Turboc或NetBeans在Windows中工作时,我们可以逐行调试代码.在ubuntu终端怎么做呢?或者其他 Select ?
gdb(Gnu调试器)是最佳 Select
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
给出了所有有用的gdb命令和一个简单的cpp程序示例