Debug init on Qemu using gdb

假装没事ソ 提交于 2019-12-23 13:12:48

问题


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 ?


回答1:


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.



来源:https://stackoverflow.com/questions/16273614/debug-init-on-qemu-using-gdb

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!