进入系统,在Linux中使用Eclipse的CRTL功能 [英] step into system, CRTL functions with Eclipse in Linux

查看:274
本文介绍了进入系统,在Linux中使用Eclipse的CRTL功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Visual c + +的一个whiz,但是Linux开发对我来说是新的。在Visual Studio中,很容易跟踪由C运行时库实现的任何代码。我只需要确保源安装,我可以直接进入任何函数,我想 - malloc(),cout :: operator<<(),无论如何。



我试图开发使用Eclipse的C ++包。如何进入C运行时程序?由于Linux是开源的,我如何进入操作系统例程?似乎应该是可能的 - 我缺少调试信息,源代码,或两者?我的配置中有什么?



我目前使用的是Ubuntu 12.10。我使用g ++。我相信我使用Eclipse构建系统,因为我从来没有导入一个makefile项目;我刚刚从Eclipse中的C ++项目向导开始一个简单的Hello World项目。



这里有一点黑客: p>

我安装了libstdc ++ 6-4.2-dbg软件包,认为它是libstdc库的调试符号:

  sudo apt-get install libstdc ++ 6-4.2-dbg 


$ b b

我还安装了dpkg-dev,因为下一步说我需要它:

  sudo apt-get安装dpkg-dev 

我试过将libc6源安装到我家下的目录中:

  apt-get source libc6 

此时,试图进入printf()告诉我printf.c丢失了。我不能进入malloc或strlen,这表明我不明白C运行时库如何在Linux中。 libc,glib和libstdc ++有什么不同?



如果我要求Eclipse打开printf.c文件,我会有(在〜/ eglibc-2.15 / stdio-common / printf.c ),它不打开文件(不调整调试窗口以显示源),并重新绘制显示有关无法找到文件的错误消息的窗口。 (在printf.c找不到源文件找到该文件或编辑源查找路径以包含其位置。)

解决方案

同时,作为Linux上的内核开发人员,我同意单独使用单独的工具是一件好事,因为Basile的回答是usefuel。



但是,使用Eclipse的步骤应该是同样可能的。但是只是因为操作系统是开源并不意味着它支持你在里面它徘徊在寒冷的尼尔 - 事实上,你不能从用户模式代码进入操作系统本身。你肯定需要第二台计算机附加到被调试的计算机上,因为当你进入内核时,你将基本上锁定机器,至少在你正在执行的上下文中,但最有可能防止其他工作被执行,直到你从内核退出,因此,例如,如果你进入 open(),在某个时候整个文件系统可能完全停止工作,直到你退出了你所持有的任何锁。这个wll肯定会扰乱一些软件。注意,这只是一个例子,在调试内核时,事情可能会意外地工作,而不是严格的我做到了这一切,它发生了 - 我已经调试内核与调试器几次,你必须小心你的do,你肯定不能在同一台机器上运行调试器,就像在调试时的机器STOPS。



回到用户模式,你可以通过Eclipse调试,基本上你需要做的是安装你感兴趣的运行时库的源代码,然后去...与使用visual studio的Windows相同的原理 - 除了几乎所有在Linux系统上运行的软件都可以作为源代码。您可能需要使用调试符号重新编译一些库,就像在Windows中一样,您需要确保调试器知道如何查找源代码。其他一切都应该由Eclipse中的调试器处理。我花了大约三年时间使用Eclipse进行本地和远程调试,一般来说,它工作。在地方有奇怪,但几乎任何调试器的情况。



祝你好运。


I'm a whiz with Visual C++, but Linux development is new to me. In Visual Studio, it's easy to trace into any code implemented by the C run time libraries. I just need to make sure the sources are installed and I can step right into any function I'd like -- malloc(), cout::operator<<(), whatever.

I'm trying to develop using Eclipse's C++ package. How can I step into C run time routines there? Since Linux is open-source, how do I step into operating system routines? Seems like it should e possible -- am I missing debug information, source code, or both? Something in my configuration?

I'm using Ubuntu 12.10 at the moment. I'm using g++. I believe I'm using the Eclipse build system as I never imported a makefile project; I just started with a simple "Hello World" project from the C++ project wizard in Eclipse.

After hacking at this a bit:

I've installed the libstdc++6-4.2-dbg package thinking it would be debug symbols for the libstdc library:

sudo apt-get install libstdc++6-4.2-dbg

I've also installed dpkg-dev, since the next step said I needed it:

sudo apt-get install dpkg-dev

I tried installing libc6 sources into a directory under my home:

apt-get source libc6

At this point, trying to step into printf() tells me that printf.c is missing. I can't step into malloc or strlen, which suggests that I don't understand how the C runtime libraries are factored in Linux. How are libc, glib, and libstdc++ different? Which packages do I need?

If I ask Eclipse to open the printf.c file I do have (at ~/eglibc-2.15/stdio-common/printf.c), it doesn't open the file (doesn't adjust the debugging window to show the source) and repaints the window that shows the error message about not being able to find the file. (Can't find a source file at "printf.c" Locate the file or edit the source lookup path to include its location.)

解决方案

Whilst, as a Kernel developer on Linux, I do agree that using the individual tools separately will be a good thing to learn, and as such Basile's answer is usefuel.

However, the stepping into C runtime libraries should be equally possible with Eclipse. But just because the OS is open source doesn't mean that it supports you clambering around inside it willy nilly - in fact, you CAN NOT step into the OS itself from user-mode code. You nee KGDB (google it), and you definitely need a second computer to attach to the one being debugged, because when you step into the kernel, you will essentially lock up the machine, at the very least in the context you are stepping, but most likely also prevent other work from being done until you get back out from the kernel, so for example, if you step into open(), at some point the entire filesystem may well stop working altogether until you are back out of whatever lock you are holding. This wll certainly upset some software. Note that this is just an example of how things may work unexpectedly when debugging the kernel, not strictly "I've done this and it happened" - I have debugged kernels with debuggers several times, and you do have to be careful with what you do, and you certainly can not run the debugger on the same machine, as the machine STOPS when you are debugging.

Going back to the usermode, which you CAN debug via Eclipse, essentially all you need to do is install the source code for the runtime library you are interested in, and go... Same principle as on Windows with visual studio - except that nearly all software you ever run on a Linux system is available as source code. You may need to recompile some libraries with debugging symbols, and just like in Windows, you need to make sure the debugger knows how to find the source code. Everything else should be handled by the debugger in Eclipse. I spent about three years using Eclipse for both local and remote debugging, and in general, it works. There are quirks in places, but that's the case with almost any debugger.

Good luck.

这篇关于进入系统,在Linux中使用Eclipse的CRTL功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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