Skip to main content
edited tags
Link
Ciro Santilli OurBigBook.com
  • 392.5k
  • 120
  • 1.3k
  • 1.1k
deleted 37 characters in body; edited title
Source Link
Ciro Santilli OurBigBook.com
  • 392.5k
  • 120
  • 1.3k
  • 1.1k

Kernel debugging How to debug the Linux kernel with gdbGDB and qemuQEMU?

I'm new to kernel development and I would like to know how to run/debug the linux kernel using QEMU and gdb. I'm actually reading Robert Love's book but unfortunately it doesn't help the reader on how to install proper tools to run or debug the kernel... So what I did was to follow this tutorial http://opensourceforu.efytimes.com/2011/02/kernel-development-debugging-using-eclipse/. I'm using eclipse as an IDE to develop on the kernel but I wanted first to get it work under QEMU/gdb. So what I did so far was:

  1. To compile the kernel with:

    make defconfig (then setting the CONFIG_DEBUG_INFO=y in the .config) make -j4

  2. Once the compilation is over I run Qemu using:

    qemu-system-x86_64 -s -S /dev/zero -kernel /arch/x86/boot/bzImage

which launch the kernel in "stopped" state

  1. Thus I have to use gdb, I try the following command:

    gdb ./vmlinux

which run it correctly but... Now I don't know what to do... I know that I have to use remote debugging on the port 1234 (default port used by Qemu), using the vmlinux as the symbol table file for debugging.

So my question is: What should I do to run the kernel on Qemu, attach my debugger to it and thus, get them work together to make my life easier with kernel development. Thank you in advance for your answers.

Kernel debugging with gdb and qemu

I'm new to kernel development and I would like to know how to run/debug the linux kernel using QEMU and gdb. I'm actually reading Robert Love's book but unfortunately it doesn't help the reader on how to install proper tools to run or debug the kernel... So what I did was to follow this tutorial http://opensourceforu.efytimes.com/2011/02/kernel-development-debugging-using-eclipse/. I'm using eclipse as an IDE to develop on the kernel but I wanted first to get it work under QEMU/gdb. So what I did so far was:

  1. To compile the kernel with:

    make defconfig (then setting the CONFIG_DEBUG_INFO=y in the .config) make -j4

  2. Once the compilation is over I run Qemu using:

    qemu-system-x86_64 -s -S /dev/zero -kernel /arch/x86/boot/bzImage

which launch the kernel in "stopped" state

  1. Thus I have to use gdb, I try the following command:

    gdb ./vmlinux

which run it correctly but... Now I don't know what to do... I know that I have to use remote debugging on the port 1234 (default port used by Qemu), using the vmlinux as the symbol table file for debugging.

So my question is: What should I do to run the kernel on Qemu, attach my debugger to it and thus, get them work together to make my life easier with kernel development. Thank you in advance for your answers.

How to debug the Linux kernel with GDB and QEMU?

I'm new to kernel development and I would like to know how to run/debug the linux kernel using QEMU and gdb. I'm actually reading Robert Love's book but unfortunately it doesn't help the reader on how to install proper tools to run or debug the kernel... So what I did was to follow this tutorial http://opensourceforu.efytimes.com/2011/02/kernel-development-debugging-using-eclipse/. I'm using eclipse as an IDE to develop on the kernel but I wanted first to get it work under QEMU/gdb. So what I did so far was:

  1. To compile the kernel with:

    make defconfig (then setting the CONFIG_DEBUG_INFO=y in the .config) make -j4

  2. Once the compilation is over I run Qemu using:

    qemu-system-x86_64 -s -S /dev/zero -kernel /arch/x86/boot/bzImage

which launch the kernel in "stopped" state

  1. Thus I have to use gdb, I try the following command:

    gdb ./vmlinux

which run it correctly but... Now I don't know what to do... I know that I have to use remote debugging on the port 1234 (default port used by Qemu), using the vmlinux as the symbol table file for debugging.

So my question is: What should I do to run the kernel on Qemu, attach my debugger to it and thus, get them work together to make my life easier with kernel development.

fix broken link
Source Link
Daniel Trebbien
  • 39.5k
  • 18
  • 131
  • 197

I'm new to kernel development and I would like to know how to run/debug the linux kernel using QEMU and gdb. I'm actually reading Robert Love's book but unfortunately it doesn't help the reader on how to install proper tools to run or debug the kernel... So what I did was to follow this tutorial http://www.linuxforu.com/2011/02/kernel-development-debugging-using-eclipse/http://opensourceforu.efytimes.com/2011/02/kernel-development-debugging-using-eclipse/. I'm using eclipse as an IDE to develop on the kernel but I wanted first to get it work under QEMU/gdb. So what I did so far was:

  1. To compile the kernel with:

    make defconfig (then setting the CONFIG_DEBUG_INFO=y in the .config) make -j4

  2. Once the compilation is over I run Qemu using:

    qemu-system-x86_64 -s -S /dev/zero -kernel /arch/x86/boot/bzImage

which launch the kernel in "stopped" state

  1. Thus I have to use gdb, I try the following command:

    gdb ./vmlinux

which run it correctly but... Now I don't know what to do... I know that I have to use remote debugging on the port 1234 (default port used by Qemu), using the vmlinux as the symbol table file for debugging.

So my question is: What should I do to run the kernel on Qemu, attach my debugger to it and thus, get them work together to make my life easier with kernel development. Thank you in advance for your answers.

I'm new to kernel development and I would like to know how to run/debug the linux kernel using QEMU and gdb. I'm actually reading Robert Love's book but unfortunately it doesn't help the reader on how to install proper tools to run or debug the kernel... So what I did was to follow this tutorial http://www.linuxforu.com/2011/02/kernel-development-debugging-using-eclipse/. I'm using eclipse as an IDE to develop on the kernel but I wanted first to get it work under QEMU/gdb. So what I did so far was:

  1. To compile the kernel with:

    make defconfig (then setting the CONFIG_DEBUG_INFO=y in the .config) make -j4

  2. Once the compilation is over I run Qemu using:

    qemu-system-x86_64 -s -S /dev/zero -kernel /arch/x86/boot/bzImage

which launch the kernel in "stopped" state

  1. Thus I have to use gdb, I try the following command:

    gdb ./vmlinux

which run it correctly but... Now I don't know what to do... I know that I have to use remote debugging on the port 1234 (default port used by Qemu), using the vmlinux as the symbol table file for debugging.

So my question is: What should I do to run the kernel on Qemu, attach my debugger to it and thus, get them work together to make my life easier with kernel development. Thank you in advance for your answers.

I'm new to kernel development and I would like to know how to run/debug the linux kernel using QEMU and gdb. I'm actually reading Robert Love's book but unfortunately it doesn't help the reader on how to install proper tools to run or debug the kernel... So what I did was to follow this tutorial http://opensourceforu.efytimes.com/2011/02/kernel-development-debugging-using-eclipse/. I'm using eclipse as an IDE to develop on the kernel but I wanted first to get it work under QEMU/gdb. So what I did so far was:

  1. To compile the kernel with:

    make defconfig (then setting the CONFIG_DEBUG_INFO=y in the .config) make -j4

  2. Once the compilation is over I run Qemu using:

    qemu-system-x86_64 -s -S /dev/zero -kernel /arch/x86/boot/bzImage

which launch the kernel in "stopped" state

  1. Thus I have to use gdb, I try the following command:

    gdb ./vmlinux

which run it correctly but... Now I don't know what to do... I know that I have to use remote debugging on the port 1234 (default port used by Qemu), using the vmlinux as the symbol table file for debugging.

So my question is: What should I do to run the kernel on Qemu, attach my debugger to it and thus, get them work together to make my life easier with kernel development. Thank you in advance for your answers.

formatting
Source Link
Grzegorz Rożniecki
  • 28.1k
  • 11
  • 95
  • 116
Loading
Source Link
E-Kami
  • 2.7k
  • 5
  • 32
  • 53
Loading