使用gdb在Qemu上调试init [英] Debug init on Qemu using gdb

查看:173
本文介绍了使用gdb在Qemu上调试init的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在Qemu上模拟cav octeon的mips64 linux内核。我目前在使用模式init代码时遇到了一些问题,并且想要调试init.i,我正在命令行中使用-s -S选项启动Qemu并运行gdb使用命令

ddd --debugger / OCTEON-SDK / tools / bin / mips64-octeon-linux-gnu-gdb / OCTEON-SDK / linux /kernel_2.6/linux/vmlinux



然后用命令附加gdb
$ b

target remote localhost:1234



gdb目前仅显示在内核空间中运行的指令。



我想问的是,有什么方法可以像内核空间一样,一步一步地调试usermode init和库指令?
例如,如果发布了 printf ,那么我想看看库中正在执行哪些指令以及控制是如何返回给内核的?

解决方案

我已经设法使用在是否可以使用gdb和qemu同时调试linux用户空间程序和内核空间?



您必须记住的唯一附加事项是:




  • / sbin / init 只是符号链接 busybox ,因此您必须使用 / bin / busybox 作为目标文件

  • main函数为 / sbin / init 实际上是 init_main ,遵循BusyBox对每个伪exe调用main的约定cutable as < exec> _main



这有点片状,但大多只是工作。


i am trying to emulate cavium octeon's mips64 linux kernel on Qemu.I am currently having some issues with use mode init code and want to debug init.i am starting the Qemu using -s -S option in the command line and running the gdb using command

ddd --debugger /OCTEON-SDK/tools/bin/mips64-octeon-linux-gnu-gdb /OCTEON-SDK/linux/kernel_2.6/linux/vmlinux

and then attaching the gdb with command

target remote localhost:1234

The gdb is currently showing only the instructions running in kernel space.

What i want to ask is there any method by which i can debug the usermode init and libraries instructions step by step as in case of kernel space? For example if printf is issued from init then i want to see that which instructions are being executed in the libraries and how the control is returned to kernel ?

解决方案

I have managed to step debug BusyBox's /sbin/init using the procedure described at: Is it possible to use gdb and qemu to debug linux user space programs and kernel space simultaneously?

The only additional things you have to keep in mind are:

  • /sbin/init is just a symlink to busybox, so you must use /bin/busybox as the object file
  • the "main" function for /sbin/init is actually init_main, following BusyBox' convention of calling the main for each pseudo-executable as <exec>_main

It is a bit flaky, but mostly just works.

这篇关于使用gdb在Qemu上调试init的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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