"Kernel panic, core dumped" is one of my favorite memories of my early (R&D) engineering career when I used to write a lot of code.
I implemented something similar even for my libraries
lib_debug_v2 contains panic(fid, mid, reason)
uint32_t fid = function_id uint32_t mid = module_id(1) safestring_t reason which may contains regs and other detailsI also use this system on Xinu, a rather educational kernel that did include neither a panic primitive, nor a graphic stuff; now there is a panic(), and I also added one in graphic mode.
It is much-much simpler than on linux. You don't even have a MMU, you have "tasks" instead of "processes", and you do not go through DRM, and there is not even X11 or Wayland there is a video driver that exposes the graphic LCD (320x240, comes with a built-in controller) as a very simple framebuffer, it is just a huge array, where each 32bit cell represents 1 pixel { R0..7, G0..7, B0..7, A0..7 }, and there are very simple primitives that draw lines, squares, solid fill, and text with only 3 types of fonts, for equally spaced characters.
The kernel/panic.c:panic() does nothing but writes the error information in a list of buffers
usually only two buffers
- the system console, on which always and only the UART driver operates
- the graphic console, on which to promote the primitives mentioned above the result is that you see on the LCD that the kernel has gone into panic
When something catastrophically breaks, e.g. the filesystem has a bug so serious that it cannot continue (without causing more data corruption), then it invokes panic(), which halts the system, but typically before invoking halt(), you still have the serial and the graphical display functional, at least with the simplest primitives
This is good because the LCD immediately displays the blue screen of death, indicating that the system has gone into panic, and you can investigate on the system console, where you will also have all the details saved in a file thanks to minicom which can record.
Very nice, and very useful! I really like it
(1) "module" means ... the physical C file to which a function belongs