Add tips on debugging/disassembling kernel sources
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
# Debugging the Kernel
|
||||
|
||||
Here we will add some helpful tips on debugging the kernel.
|
||||
|
||||
## Disassembling a public function
|
||||
|
||||
To disassemble a public function, first we need a symbol in the public symbol table, so start by making the function fully public (including any parent modules). Do this as though you are trying to make a public function for a library crate (this includes the `kernel` crate). Simply mark the function and any parent modules as public, up until the point of [lib.rs (kernel link)](../../kernel/src/lib.rs).
|
||||
|
||||
Then, we need to find the specific demangled symbol to disassemble, because the default objdump output can be very verbose.
|
||||
|
||||
```sh
|
||||
# Change as required, I pipe to less and /SEARCH FOR FUNCTION HERE.
|
||||
nm --demangle ./build/target/x86_64-kernel/debug/kernel | less
|
||||
# Now just paste the symbol where it says YOUR_SYMBOL_HERE and profit. Use -Mintel for Intel assembly syntax.
|
||||
objdump -Matt --source --line-numbers --visualize-jumps ./build/target/x86_64-kernel/debug/kernel --demangle=rust --disassemble="YOUR_SYMBOL_HERE"
|
||||
```
|
||||
Reference in New Issue
Block a user