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

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

问题描述

我想和一些调试器一行一行地运行GTK + / C程序。我从来没有调试过一个Linux程序,所以在哪里可以找到关于如何调试代码的初学者的指示?我只想知道我必须从net下载源码,使用调试符号编译项目,并通过DDD或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. 安装包build-essential和devscripts

  2. 运行sudo apt-get build-dep some_package来安装编译该包所需的所有东西

  3. 运行mkdir -p〜/ src / some_package; cd〜/ src / some_package为源代码创建一个目录

  4. 进入System :: Administration: :软件来源并激活源代码存储库

  5. 运行apt-get source some_package下载some_package的源代码,并将其放在当前目录中

  6. 使用cd移动到特定的应用程序目录,通常类似于some-app-1.2.3

  1. install the packages "build-essential" and "devscripts"
  2. run "sudo apt-get build-dep some_package" to install all things needed to compile that package
  3. run "mkdir -p ~/src/some_package ; cd ~/src/some_package" to create a directory for the source code
  4. Go into System::Administration::Software Sources and activate the "Source Code" repository
  5. run "apt-get source some_package" to download the source code for some_package and put it in the current directory
  6. use "cd" to move into the specific app directory, usually something like "some-app-1.2.3"

7A。运行debuild -us -uc -b将源编译成一个新的可安装的.DEB文件,在发布模式下编译调试信息

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 parallel = 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文件二进制包,即DEB,可以从单个源包生成)

  2. sudosudo dpkg -i some_package_123.deb来安装刚刚构建的版本

当然,您可以选择修改步骤6和7之间的代码。这个方法的好处是它可以应用于任何应用程序。您可以将其用于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天全站免登陆