如何运行逐行一个Linux程序行 [英] How to run a Linux program line by line

查看:341
本文介绍了如何运行逐行一个Linux程序行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用一些线调试运行GTK + / C程序行。我从来没有调试一个Linux程序,所以我在哪里可以找到的指示,就如何调试code非常初学者?我只是一个想法,我不得不从网上下载的来源,通过国内长途或GDB编译调试符号和运行源的项目。因此,谁能给点建议如何开始学习这些科目,什么可能是一个很好的调试器开始?我至少有时间去学习的东西。

I would like to run a GTK+/C program line by line with some debugger. I have never debugged a Linux program so where can I find instructions to a very beginner on how to debug code? I have just an idea that I have to download the sources from net, compile the project with debug symbols and run sources through DDD or GDB. So can anyone give suggestions how to start studying these subjects and what could be a good debugger to start? I have at least time to learn things.

推荐答案

还应考虑另外DDD nemiver,他们擅长不同的事情,但nemiver沿着非常漂亮的到来。

Also look into nemiver besides DDD, they are good at different things but nemiver is coming along very nicely.

PS。如果你在Ubuntu,你想一步通过的从包库安装的应用程序,让我们把它叫做some_package,那么这样做:

PS. If you're on Ubuntu and you want to step through an application that's installed from the package repository, let's called it some_package, then do this:


  1. 安装的软件包集结必要和devscripts中

  2. 运行sudo易于得到建立-DEP some_package安装来编译包所需的所有的事情

  3. 运行命令mkdir -p〜/ src目录/ some_package; CD〜/ src目录/ some_package创建源$ C ​​$ C目录

  4. 走进系统::管理::软件源并激活来源$ C ​​$ C库

  5. 运行apt-get的源some_package下载源$ C ​​$ C为some_package,并把它在当前目录

  6. 使用cd命令进入特定的应用程序目录,通常为类似一些-APP-1.2.3

7A。运行debuild -us -uc -b编译源成在发布模式的编译时没有的调试信息

7A. run "debuild -us -uc -b" to compile the source into a fresh installable .DEB file compiled in release mode WITHOUT debug information

或(这是中央部):

7B。运行MAKEFLAGS = -j6 DEB_BUILD_OPTIONS =NOSTRIP noopt进行并行= 5CFLAGS = - G3 -O0debuild -us -uc在调试模式下建立一个deb的的调试信息

7B. run "MAKEFLAGS=-j6 DEB_BUILD_OPTIONS="nostrip noopt parallel=5" CFLAGS="-g3 -O0" debuild -us -uc" to build a deb in debug mode WITH debug information


  1. 使用CD ..上移一步,然后做的ls,你应该可以看到生成的文件DEB(多个二进制包,即德布斯,可以从一个单一的源代码包生成)

  2. 须藤须藤dpkg -i来some_package_123.deb,安装您刚构建的版本

当然,你可以选择修改步骤6和7之间的code这个方法的好处是,它为pretty多的应用程序。您可以使用它为Firefox,Linux内核,台面堆栈或什么的。

Of course, you could optionally modify the code between steps 6 and 7. The nice thing about this method is that it works for pretty much any application. You can use it for Firefox, the Linux kernel, the mesa stack or whatever.

这篇关于如何运行逐行一个Linux程序行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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