Kernel Debugging with QEMU: Difference between revisions

Raboof (talk | contribs)
document how to debug a nix-built kernel including modules and sources
Axka (talk | contribs)
m Add link for more info about patching and configuring the kernel
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
== Set up the QEMU VM ==
== Set up the QEMU VM ==


=== With a Nix kernel ===
=== With a Nix-built kernel ===
Use a NixOS config like this:
Use a NixOS config like below. See [[Linux kernel#Custom configuration]] for more information about patching and configuring the kernel's build.


<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
Line 21: Line 21:
       name = "enable debugging information";
       name = "enable debugging information";
       patch = null;
       patch = null;
       extraConfig = ''
       structuredExtraConfig = {
         GDB_SCRIPTS y
         GDB_SCRIPTS = lib.kernel.yes;
         DEBUG_INFO y
         DEBUG_INFO = lib.kernel.yes;
         KALLSYMS y
         KALLSYMS = lib.kernel.yes;
       '';
       };
     }
     }
     {
     {
Line 56: Line 56:


==== Loading module symbols and accurate kernel sources ====
==== Loading module symbols and accurate kernel sources ====
Make sure you're using a branch of nixpkgs that has https://github.com/NixOS/nixpkgs/pull/432405 applied.


This generates a script that starts gdb with module symbols and kernel sources attached:
This generates a script that starts gdb with module symbols and kernel sources attached: