debug eclipse cdt + qemu虚拟机调试linux内核

(17页)

本资源提供全文预览,点击全文预览即可全文预览,如果喜欢文档就下载吧,查找使用更方便哦!

9.90 积分

A screencast demonstrating roughly the same thing is available at: http://blip.tv/file/586651 For iTunes users there's a videopodcast at: http://takis.blip.tv/rss/itunes/ Download the Linux kernel sourcecode from http://www.kernel.org/. For example, the current kernel version is 2.6.23, a direct link would be http://kernel.org/pub/linux/kernel/v2.6/linux-2.6.23.9.tar.bz2 Extract the Linux kernel sourcecode: cd /usr/local/src tar xvjf linux-2.6.23.9.tar.bz2 We will build the Linux kernel in a different directory: mkdir -p /mnt/build/linux-2.6 Then copy the provided kernel configuration into this directory giving it a new name ".config". The following commands will then use this as a base-configuration to start from. Next, we'll configure the kernel. Just keep pressing enter to use the default answers to all the questions that the kernel configuration program will ask you. cd /usr/local/src/linux-2.6.23 make oldconfig O=/mnt/build/linux-2.6 Next, make the kernel a bit easier to debug: make menuconfig O=/mnt/build/linux-2.6 And enable the following options: In the "Kernel hacking" menu enable both "Compile the kernel with debug info" and "Compile the kernel with frame pointers". Now, we'll fire up Eclipse with the CDT plugin. You can download Eclipse with the CDT plugin from http://www.eclipse.org/downloads/You'll need to download "Eclipse IDE for C/C++ Developers". Get rid of the intro screen. You'll get an empty workspace as shown in the screenshot. First disable automatic building, by using the "Window->Preferences" menu, selecting "General->Workspace" and deselecting "Build automatically". Eclipse will perform a time consuming indexing operation which you can disable by using the "Window->Preferences" menu, selecting "C/C++->Indexer" and switching from "Fast C/C++ Indexer" to "No Indexer". Start a new project, by using File->New->Project... Then select "C Project", "Makefile project", "Empty Project". Now enter a project name and specify a specific directory for the project sourcecode. To do this, first uncheck the "Use default location" checkbox. Finally click "Finish". If you hadn't disabled indexing, Eclipse will now start indexing the Linux kernel sourcecode. This will take a long time. You'll see a progressbar which might give you an indication on how long it might take to complete. Eclipse finished indexing the kernel sourcecode. Now, we're ready to configure our debugger. Right-click on the project-name in the left pane (Project explorer) and select "Properties". We want to modify the default build command and the location where the build files should go. Uncheck "Use default build command" and enter make CC=gcc-3.4 O=/mnt/build/linux-2.6 Modify the build location by clicking the "File system..." button and browsing to /mnt/build/linux-2.6 Through the menu-bar select "Project->Build all" or press "Ctrl-b". After some time the Linux kernel build will be completed and you see "bzImage is ready" appear in the Eclipse Console output. Next, we'll run our kernel binary using the Qemu system emulator. The nice thing about Qemu is that besides the normal virtual HD, floppy and ISO image booting, it can also boot Linux kernels directly. And, Qemu provides a GDB-stub to which we can connect from our Eclipse debugger. The "-s" switch activates this GDB-stub. The "-S" switch makes sure Qemu doesn't start running before we're ready (it freezes the CPU at startup). Because the CPU is "frozen" at startup, the Qemu window won't show anything useful yet. Through the menubar, select "Run->Debug Configurations...". Double-click "C/C++ Local Application". Modify the "C/C++ Application" textentry to point to the actual Linux kernel, being /mnt/build/linux-2.6/vmlinux Click on the "Debugger" tab, and in the "Debugger" listbox select the "gdbserver Debugger". Next, modify the "Stop on startup at:" to "start_kernel". Below this, you'll notice a frame named "Debugger Options"; click the "Connection" tab in this frame and modify the "Type" to "TCP" and the "Port number" to 1234. Continue by clicking the "Debug" button. Eclipse might compile and link a bit, but will finally launch the debugger and ask if you want to switch to the debugging perspective. Say yes. The next screenshot shows the debugging perspective. Just like with normal applications, you'll see that the line it is about the execute is highlighted. In the Qemu window, you'll notice some output already. This is the output which happened in functions preceding the start_kernel() function. ... By using "Run->Step over" or pressing the "F6" key, you can execute the kernel code line by line and examine what's happening. If you want to see the assembly instructions which are being executed, you can add a view which displays this by selecting "Windows->Show View->Disassembly". There's a register view too, as can be seen in the next screenshot. Registers who's contents has been altered by the previous execution step are highlighted in yellow. You can add breakpoints, inspect variables, inspect memory and much more, but as you keep running the kernel you'll run in trouble as we did not specify a true harddisk image for Qemu. So, you'll get the following output in the Qemu window, because the Linux kernel could not find a root filesystem on our fake harddisk image "/dev/zero". That's it. Hopefully the above is useful (and fun) for anyone :) 关 键 词: debugeclipsecdt+qemu虚拟机调试linux内核

 天天文库所有资源均是用户自行上传分享,仅供网友学习交流,未经上传用户书面授权,请勿作他用。

关于本文

本文标题:debug eclipse cdt + qemu虚拟机调试linux内核

链接地址: https://www.wenku365.com/p-3913918.html

elipse调试linux内核,debug eclipse cdt + qemu虚拟机调试linux内核相关推荐

  1. Eclipse CDT+Qemu调试Linux 0.11内核

    操作系统:CentOS 6.3 for 32bit 需要软件:eclipse-cpp-galileo-SR2-linux-gtk.tar.gz qemu 需要内核文件:linux 0.11(Makef ...

  2. Linux 内核实验室 —— 基于 Docker/Qemu 的极速 Linux 内核学习、开发和测试环境

    介绍: 项目简介 本项目致力于创建一个基于 Docker + QEMU 的 Linux 实验环境,方便大家学习.开发和测试 Linux 内核. Linux Lab 是一个开源软件,不提供任何保证,请自 ...

  3. Eclipse - CDT使用GDB调试C++的问题-无源文件命名(No source file named)

    CDT使用GDB调试C++的问题(No source file named) 本文地址: http://blog.csdn.net/caroline_wendy/article/details/170 ...

  4. Linux的pcie模拟网卡,Qemu虚拟机pci设备透传——网卡

    在qemu虚拟机中为了提高网络的性能,将本地host端的多余网卡透传到虚拟机中使用. 设备的透传需要主机支持Intel(VT-d)或AMD (IOMMU)硬件虚拟化加速技术 查看是否开启IOMMU1d ...

  5. linux查看应用线程号命令,虚拟机:Linux查看线程信息的步骤

    描述 1. 使用 pstree -p PID ps aux | grep firefox | grep -v grep charles 26058 0.0 0.0 4908 1152 ? S 19:1 ...

  6. linux如何查看tar的文件,虚拟机:Linux查看tar包文件内容的方法

    描述 1. tar 文件: code$ tar tvf etc.tar drwxr-xr-x root/root 0 2014-09-12 22:20 etc/ -rw-r--r-- root/roo ...

  7. Linux Kernel - Debug Guide (Linux内核调试指南 )

    linux内核调试指南 一些前言 作者前言 知识从哪里来 为什么撰写本文档 为什么需要汇编级调试 ***第一部分:基础知识*** 总纲:内核世界的陷阱 源码阅读的陷阱 代码调试的陷阱 原理理解的陷阱 ...

  8. Linux内核IO追踪:用GDB调试,一个磁盘IO的流程是什么样的

    Table of Contents 构建内核 产生IO写入的程序 追踪到兔子洞 准备步骤 进入FS层:我正在使用的fs是XFS 潜入块层 进入块驱动程序层:我的块驱动程序是SCSI 回到fs层,研究内 ...

  9. Eclipse+CDT+GDB调试android NDK程序

    http://www.cnblogs.com/shadox/archive/2011/12/02/2272564.html Eclipse+CDT+GDB调试android NDK程序 Eclipse ...

最新文章

  1. jdk5.0新特性—— 枚举
  2. 【干货】功能堆砌or视觉美观?看优秀PM如何权衡
  3. 天池 O2O 优惠券使用预测思路解析与代码实战
  4. MyBatis-学习笔记01【01.Mybatis课程介绍及环境搭建】
  5. Android的基本常用的短信操作
  6. 写单元测试的好处(转)
  7. ES6之Module 的加载实现(3)
  8. 音视频开发(20)---基于RTMP推送实时AAC+H264流(一)
  9. angular源码分析之platformBrowserDynamic
  10. Eclipse更改字体大小
  11. 台式电脑连不上wifi怎么办
  12. 2018年华为数通技术大赛复赛拓扑题
  13. 如何用好消息推送为app拉新、留存、促活
  14. 车辆前组合灯出口德国做的E-mark认证可以在其他国家使用吗?
  15. 织梦主动提交_织梦实现发布文章主动推送(实时)给百度的方法
  16. English语法_反身代词
  17. NVIDIA IC校招笔试题目
  18. mac上AnyProxy安装与使用
  19. word文档添加多级目录,自动生成目录
  20. LeetCode刷题(61)~找出数组中的幸运数

热门文章

  1. 一步一步搭建hibernate4+ spring+ struts2
  2. 【转载】Debian 6安装小记
  3. 用jQuery插件实现“小图点击预览大图”功能1
  4. NAnt 与 MS Build
  5. 新手如何入门PyTorch
  6. 【LeetCode 剑指offer刷题】字符串题12:Valid Palindrome(回文词系列)
  7. ASP.NET Core WebAPI控制器返回类型的最佳选项
  8. Jackson Annotation Examples
  9. [Data Structure Algorithm] 哈希表
  10. 使用transform实现手风琴布局