![]() |
|
||||
Total/db User's Guide |
Simple Kernel Debugger - SKDB
Overview
The Simple Kernel Debugger (SKDB) is a machine-level symbolic debugger. This chapter provides an overview of SKDB, instructions on how to install and remove it, and how to start it after a kernel crash, and also lists details of SKDB commands.
SKDB is designed to support debugging of LynxOS kernel internals, primarily device drivers. It allows you to perform the following operations interactively in LynxOS kernel space:
- Setting breakpoints
- Examining memory and registers
- Changing memory contents
- Displaying kernel data structures.
In addition, you can use SKDB to determine the cause of a kernel crash or a kernel panic. LynxOS GDB uses SKDB as the target agent for kernel/device driver debugging.
To use SKDB, the user needs a solid understanding of LynxOS internals, including its memory model, scheduling, interrupt handling, and so forth. SKDB is not designed for user process debugging; use GDB for user process debugging instead.
SKDB has the following characteristics by design:
- SKDB is a tool that you use to debug new device drivers and similar components after the kernel has started and is running fairly stably. It is not intended to be used for porting the LynxOS kernel to a new platform; although SKDB may be still useful for LynxOS kernel porting, it requires a fairly stable kernel and it is not effective in the early stages of the kernel's start-up until the kernel internally installs and initializes SKDB.
- While SKDB is in operation (at its prompt) the entire operating system is paused and no kernel services are available.
Installing/Removing SKDB
In order to use SKDB, install the SKDB module into the kernel. It is possible install and/or remove SKDB support after initial installation of LynxOS.
Installing SKDB
To install, execute the following:
The installation script will prompt to choose the default SKDB port for SKDB to use when it starts automatically in case of a kernel crash or a kernel panic. SKDB uses this port to break in to SKDB with the hot key. The video console, if one exists, always accepts break-ins with the hot key. For more information about starting SKDB automatically, see "Using SKDB".
After installation, reboot the system to make SKDB effective.
Removing SKDB
To remove SKDB, execute the following:
Reboot the target system after removal of SKDB.
Using SKDB
SKDB Prompt
Whenever the operating system is in SKDB, it shows an asterisk (*) as its prompt. The entire operating system is paused and no kernel services are available while in SKDB.
Starting SKDB Automatically after a Kernel Crash or Panic
If installed, SKDB is automatically started by a kernel crash, such as kernel memory access fault or a panic situation. In this case, the kernel is usually unable to resume operation, but it is possible to determine the cause and the location of the kernel fault or the panic. For example, the following commands may be useful for analyzing the cause:
- p - process/thread table display
- t - stack trace display
- r - register contents display
- m - memory contents display.
Breaking into SKDB with Hot Key
Once SKDB has been installed, it can invoked by pressing ShiftCtrlMinus (the "hot key") on the keyboard of an SKDB-ready port while the operating system is up and running. Some keyboards (mostly video consoles) may use CtrlMinus instead.
The default hot key combination for SKDB can be changed by using the z command within SKDB.
The hot key combination is set per port, therefore different key combinations can be set for different ports.
The new hot key combination is not preserved across operating system reboots; it returns to the default combination after each reboot and it needs to be again.
Kernel Status Display
At each invocation, SKBD prints a line like the following:
trapcode Trap code; trap code is the same as the architecture's exception code with the addition of -1 for invocation from keyboard and -2 for a panic situation
slevel Last slevel; slevel is the kernel preemption level (0: user, 1: kernel, 2: no context switching, 3: no interrupts)
econtext Econtext address; econtext is the per-thread register stack into which the kernel saves registers
For example, breaking into SKDB with the "hot key" would display something similar to the following:
The above is interpreted that the operating system was running the null process code (process 0) at address 0x207 with context switching enabled when the break-in occurred.
Kernel Status Redisplay
To redisplay the above information, press Ctrl-B then ? and Return. This option is currently available on serial terminals only, not on video consoles.
Stack Trace Display
The t command displays a traceback or the "history" of nested function calls of a thread within the kernel. One can determine the "path" to the current breakpoint, panic location, or kernel fault location where the kernel entered SKDB. Tracing stops as soon as the stack frame appears to be out of the valid kernel address range.
Give the t command the process ID to determine the process's main thread, or the thread ID with a preceding - (minus sign). The default is the current thread.
Verbose Trace Mode
Turning on the verbose trace mode with the v command makes the
t command display the contents of each stack frame as well as the offset values from the frame pointer (or the stack pointer in the case of the PowerPC).
Process, Thread, and Other Displays
The p command displays the contents of the kernel's process table and thread table. The s command with options displays the contents of a variety of the kernel's internal data structures.
Resuming the Kernel
To exit SKDB and resume the operating system, press the Esc key; the kernel will continue running until the following occurs:
As discussed, it may not be possible to resume the kernel if the kernel was in SKDB due to a kernel crash or a kernel panic.
Setting Breakpoints
SKDB can set up to 10 breakpoints in the kernel including device drivers. When the CPU reaches the instruction at a breakpoint, the control is trapped into SKDB. The breakpoints remain set until explicitly unset by the
u command.SKDB may refuse to set a breakpoint on some instructions that are critical to its operation. These instructions include those handling the processor status word (PSW) register.
Single-Stepping
Pressing x and Return single-steps the current thread (the thread that caused to enter SKDB.) It is not, however, possible to single-step the following:
- The thread "broken-in" with the hot key
- Some machine instructions that are critical for SKDB's operation (generally those handling the processor status word (PSW) register)
- A crashed or panicked kernel.
Disassembly
The d command disassembles 10 instructions from the specified address or the current address. The current address is updated to the next text location after each disassembly. The current address is also updated to the breakpoint or the fault location whenever the kernel stops and reenters SKDB.
Setting Watchpoints
Some CPU architectures support hardware debug registers to implement watchpoints. The following LynxOS ports support SKDB watchpoints:
The B command can set as many watchpoints as the target CPU architecture allows. The B command takes two mandatory arguments-the watchpoint number and the watchpoint location address-plus the following optional arguments:
- Access mode - r for read access and w for write access; the default is w
- Ignore PC addresses - up to 10 text addresses after "!" for the program counter to be ignored for watchpoints hit. This is useful to avoid stopping at know kernel locations where the watchpoint is accessed.
For example, if one wants to catch all write accesses to currtptr but does not want to stop at resched+0x24 which is considered a normal access:
* B 1 currtptr w ! resched+0x24
To remove a watchpoint, use the U command with the watchpoint number.
SKDB Commands
1On the PowerPC, a text symbol is preceded by a "." (dot). A symbol without the preceding dot refers to the corresponding TOC entry.
General Notes
Parameter Validation
SKDB performs little validation for command arguments. Although SKDB catches most memory access faults resulting from SKDB commands, improper arguments may result in a system freeze.
Symbol Information
SKDB uses the kernel symbol table that is loaded at the startup time for symbol lookup. SKDB cannt do interactive symbolic debugging with a stripped kernel.
Address Expressions
SKDB accepts simple address expressions with symbolic notations for most commands that accept memory address parameters. The syntax is as follows:
- Number - hexadecimal if starting with "0x"; octal if starting with "0"; or otherwise decimal
- Symbol - the symbol's absolute virtual address value (note the PowerPC re quires a preceding dot for text symbols)
- Register - the CPU register of the current thread. The following mnemonics work as common aliases for all architectures: %pc, %fp, %sp. Other register mnemonics depend on the CPU architecture
- Operator - + and - represent addition and subtraction respectively. Operations are performed left to right without precedence or associatively.
For example, the following sets a breakpoint at the current PC address plus 20 bytes:
Default Virtual Address Space
The LynxOS memory model assigns a separate virtual address space to each process (kernel threads belong to process 0 <zero>). Although all processes share the same kernel text, kernel data, and kernel heap in the kernel, each supervisor stack still belongs to its respective process's virtual address space. To access a memory location of a non-current process, use the T command to get the memory location's PHYSBASE address.
The PHYSBASE address is the region of kernel address space where a mirror image of the system's physical memory is mapped (aliased). Since any page that the kernel may access is found in this region and the page is visible to all processes at the same virtual address, SKDB uses PHYSBASE for quick memory reference in a non-current process's virtual address space.
Remote Debugger Interface Protocol
SKDB supports a communication protocol for interfacing with a remote kernel debugger such as LynxOS GDB. For more information on how to debug the LynxOS kernel at the source level, see LynxOS GDB Enhancements, See "LynxOS GDB Enhancements"
![]() LynuxWorks, Inc. 855 Branham Lane East San Jose, CA 95138 http://www.lynuxworks.com 1.800.255.5969 |
![]() |
![]() |
![]() |
![]() |