🔹Operating-System
Debugging🔹
Presented BY:
Dr. P. SARAVANAN,
AP/[Link],
SRMIST.
Agenda:
✅ Introduction to OS Debugging
✅ Why Debugging is Challenging in Operating
Systems?
✅ Types of OS Debugging Techniques
a. Print Debugging , b. Logging
[Link] Debuggers, Postmortem
Debugging (Crash Dumps)
e. Simulators and Virtual Machines
Assertions
✅ 4. Tools for OS Debugging
✅ ⚙️5. Debugging Multithreaded and Concurrent
Systems
✅ 🧪 Example Debugging Scenarios
✅ Introduction to OS Debugging
Debugging in operating systems refers to the process
of identifying, analyzing, and fixing bugs or unexpected
behaviors in OS components such as the kernel, system
calls, device drivers, and memory management
systems.
🧠Why Debugging is Challenging in Operating Systems?
•Involves low-level operations.
•Bugs can cause system crashes or freezes.
•Often non-deterministic (hard to reproduce).
•Limited visibility (e.g., no screen output during boot).
•Concurrency issues due to multiple processes/threads.
🔍 Types of OS Debugging Techniques
a. Print Debugging
•Using printf() statements in kernel or drivers.
•Simple but can interfere with timing-sensitive code.
•Example: printk() in Linux kernel.
b. Logging
•Writing messages to log files.
•Useful for post-mortem analysis.
•Tools: dmesg, /var/log/messages, syslog.
c. Kernel Debuggers
Specialized
🔍 Types of OStools to step through
Debugging kernel
Techniques
code.
Examples:
KGDB (Kernel GNU Debugger for
Linux)
KDB (built-in Linux kernel debugger)
WinDbg for Windows kernel
debugging
d. Postmortem Debugging (Crash
Dumps)
Use memory dump after crash (core
dump)
Analyzed using tools like crash, gdb,
windbg
🔍 Types of OS Debugging Techniques
e. Simulators and Virtual Machines
•Run OS in a controlled environment.
•Easier to monitor and debug.
•Tools: QEMU, Bochs, VMware, VirtualBox
f. Assertions
•Embed sanity checks using assert()
statements.
•Stops execution when a condition fails.
Tools for OS Debugging
⚙️5. Debugging Multithreaded and
Concurrent Systems
Common Issues:
Race conditions
Deadlocks
Starvation
Priority inversion
Debugging Aids:
Thread sanitizer
Valgrind (Helgrind)
Lockdep in Linux (for lock dependency checks)
🧪 Example Debugging Scenarios
a. Kernel Panic
•Cause: Null pointer dereference in device driver
•Tool: dmesg, crash, source code trace
b. Memory Leak
•Tool: valgrind, memory profiling tools
c. System Hangs
•Use logging + kernel debugging to analyze process states, locks, and I/O waits.
🔐Best Practices for OS Debugging
•Use version control to track code changes.
•Employ automated testing for regression.
•Document known issues and fixes.
•Use safe coding patterns (e.g., proper locking).
•Avoid debugging on production systems.