This manual explains how to use tools to debug a kernel and analyze a
crash dump of the Tru64 UNIX (formerly DIGITAL UNIX) operating
system. Also, this manual explains how to write extensions to the kernel
debugging tools.
COMPAQ and the Compaq logo Registered in U.S. Patent and Trademark Office. Alpha and Tru64 are
trademarks of Compaq Information Technologies Group, L.P in the United States and other countries.
Microsoft and Windows are trademarks of Microsoft Corporation in the United States and other countries.
UNIX and The Open Group are trademarks of The Open Group.All other product names mentioned herein
may be trademarks of their respective companies.
Confidential computer software. Valid license from Compaq required for possession, use, or copying.
Consistent with FAR 12.211 and 12.212, Commercial Computer Software, Computer Software
Documentation, and Technical Data for Commercial Items are licensed to the U.S. Government under
vendor’s standard commercial license.
Compaq shall not be liable for technical or editorial errors or omissions contained herein. The information
in this document is provided “as is” without warranty of any kind and is subject to change without
notice. The warranties for Compaq products are set forth in the express limited warranty statements
accompanying such products. Nothing herein should be construed as constituting an additional warranty.
About This Manual
1Introduction to Kernel Debugging
1.1
1.2
1.3
1.4
Linking a Kernel Image for Debugging ............................1–1
Identifying the Cause of a Crash on an SMP System . ...... .. . .4–9
Contents v
AOutput from the crashdc Command
Index
Examples
3–1
3–2
3–3
3–4
3–5
Template Extension Using Lists .. . .................................3–23
Extension That Uses Linked Lists: callout.c . . .. .................3–24
Template Extensions Using Arrays . . ..............................3–27
Extension That Uses Arrays: file.c . .. .. ............................3–28
Extension That Uses Global Symbols: sum.c . .... . ...............3–34
Figures
2–1
Using a Gateway System During Remote Debugging .... . .. .. . .2–38
Tables
2–1
The dbx Address Modes ..............................................
2–5
vi Contents
This manual provides information on the tools used to debug a kernel and
analyze a crash dump file of the Tru64™ UNIX (formerly DIGITAL UNIX)
operating system. It also explains how to write extensions to the kernel
debugging tools. You can use extensions to display customized information
from kernel data structures or a crash dump file.
Audience
This manual is intended for system programmers who write programs that
use kernel data structures and are built into the kernel. It is also intended
for system administrators who are responsible for managing the operating
system. System programmers and administrators should have in-depth
knowledge of operating system concepts, commands, and utilities.
New and Changed Features
The following list describes changes that have been made to this manual
for Tru64 UNIX Version 5.0:
•The former Chapter 4, Managing Crash Dumps, has been deleted and
its contents have been moved to the System Administration manual.
All information on that subject is now in one manual. The SystemAdministration manual was chosen because many aspects of managing
crash dumps (such as storage considerations and default settings) are
handled by a system administrator, often during system installation.
•Crash dumps are now compressed by default and are stored in
compressed crash dump files. These are named
differentiate them from the uncompressed vmcore.n files. Starting with
Version 5.0, all the Tru64 UNIX debugging tools can read vmzcore.n as
well as vmcore.n files. Examples throughout this manual have been
updated to show use of vmzcore.n files.
•When debugging a crash dump with dbx or kdbx, you can examine the
call stack of the user program whose execution precipitated the kernel
crash. For more information, see Section 2.1.9.
•If a loadable kernel module was moved to another location after a kernel
crash, you can specify the directory path where dbx should look for the
module. For more information, see Section 2.1.3.
About This Manual
vmzcore.n to
About This Manual vii
Organization
This manual consists of four chapters and one appendix:
Chapter 1Introduces the concepts of kernel debugging and
Chapter 2
Chapter 3Describes how to write a
Chapter 4Provides background information useful for and examples
Appendix A
crash dump analysis.
Describes the tools used to debug kernels and
analyze crash dump files.
chapter assumes you have purchased and installed a Tru64
UNIX Source Kit and so have access to source files.
of analyzing crash dump files.
Contains example output from the crashdc utility.
Related Documents
For additional information, refer to the following manuals:
•The Alpha Architecture Reference Manual describes how the operating
system interfaces with the Alpha hardware.
•The Alpha Architecture Handbook gives an overview of the Alpha
hardware architecture and describes the 64-bit Alpha RISC (Reduced
Instruction Set Computing) instruction set.
•The Installation Guide and Installation Guide — Advanced Topics
describe how to install your operating system.
•The System Administration manual provides information on managing
and monitoring your system, including managing crash dumps.
kdbx debugger extension. This
•The Programmer’s Guide provides information on the tools, specifically
dbx debugger, for programming on the Tru64 UNIX operating
the
system. This manual also provides information about creating
configurable kernel subsystems.
•The Writing Kernel Modules manual discusses how to code kernel
modules (single binary images) that can be statically loaded as part of
the /vmunix kernel or dynamically loaded into memory, that enhance
the functionality of the Unix kernel.
Icons on Tru64 UNIX Printed Manuals
The printed version of the Tru64 UNIX documentation uses letter icons on
the spines of the manuals to help specific audiences quickly find the manuals
that meet their needs. (You can order the printed documentation from
Compaq.) The following list describes this convention:
viii About This Manual
GManuals for general users
SManuals for system and network administrators
PManuals for programmers
RManuals for reference page users
Some manuals in the documentation help meet the needs of several
audiences. For example, the information in some system manuals is also
used by programmers. Keep this in mind when searching for information
on specific topics.
The Documentation Overview provides information on all of the manuals in
the Tru64 UNIX documentation set.
Reader’s Comments
Compaq welcomes any comments and suggestions you have on this and
other Tru64 UNIX manuals.
A Reader’s Comment form is located on your system in the following
location:
/usr/doc/readers_comment.txt
Please include the following information along with your comments:
•The full title of the manual and the order number. (The order number
appears on the title page of printed and PDF versions of a manual.)
•The section numbers and page numbers of the information on which
you are commenting.
•The version of Tru64 UNIX that you are using.
•If known, the type of processor that is running the Tru64 UNIX software.
The Tru64 UNIX Publications group cannot respond to system problems
or technical support inquiries. Please address technical questions to your
local system vendor or to the appropriate Compaq technical support office.
Information provided with the software media explains how to send problem
reports to Compaq.
Conventions
The following conventions are used in this manual:
About This Manual ix
%
$
A percent sign represents the C shell system prompt.
A dollar sign represents the system prompt for the
Bourne, Korn, and POSIX shells.
#
% cat
A number sign represents the superuser prompt.
Boldface type in interactive examples indicates
typed user input.
file
Italic (slanted) type indicates variable values,
placeholders, and function argument names.
[|]
{ | }In syntax definitions, brackets indicate items that
are optional and braces indicate items that are
required. Vertical bars separating items inside
brackets or braces indicate that you choose one item
from among those listed.
.
.
.
A vertical ellipsis indicates that a portion of an
example that would normally be present is not
shown.
cat
(1)
A cross-reference to a reference page includes
the appropriate section number in parentheses.
For example, cat
(1) indicates that you can find
information on the cat command in Section 1 of
the reference pages.
Ctrl/xThis symbol indicates that you hold down the
x About This Manual
first named key while pressing the key or mouse
button that follows the slash. In examples, this
key combination is enclosed in a box (for example,
Ctrl/C ).
1
Introduction to Kernel Debugging
Kernel debugging is a task normally performed by systems engineers writing
kernel programs. A kernel program is one that is built as part of the kernel
and that references kernel data structures. System administrators might
also debug the kernel in the following situations:
•A process is hung or stops running unexpectedly
•The need arises to examine, and possibly modify, kernel parameters
•The system itself hangs, panics, or crashes
This manual describes how to debug kernel programs and the kernel. It also
includes information about analyzing crash dump files.
In addition to the information provided here, tracing a kernel problem can
require a basic understanding of one or more of the following technical areas:
•The hardware architecture
See the Alpha Architecture Handbook for an overview of the Alpha
hardware architecture and a description of the 64-bit Alpha RISC
instruction set.
•The internal design of the operating system at a source code and data
structure level
See the Alpha Architecture Reference Manual for information on how the
Tru64 UNIX operating system interfaces with the hardware.
This chapter provides an overview of the following topics:
•Linking a kernel image prior to debugging for systems that are running
a kernel built at boot time. (Section 1.1)
•Debugging kernel programs (Section 1.2)
•Debugging the running kernel (Section 1.3)
•Analyzing a crash dump file(Section 1.4)
1.1 Linking a Kernel Image for Debugging
By default, the kernel is a statically linked image that resides in the file
/vmunix. However, your system might be configured so that it is linked
at bootstrap time. Rather than being a bootable image, the boot file is a
Introduction to Kernel Debugging 1–1
text file that describes the hardware and software that will be present on
the running system. Using this information, the bootstrap linker links the
modules that are needed to support this hardware and software. The linker
builds the kernel directly into memory.
You cannot directly debug a bootstrap-linked kernel because you must supply
the name of an image to the kernel debugging tools. Without the image, the
tools have no access to symbol names, variable names, and so on. Therefore,
the first step in any kernel debugging effort is to determine whether your
kernel was linked at bootstrap time. If the kernel was linked at bootstrap
time, you must then build a kernel image file to use for debugging purposes.
The best way to determine whether your system is bootstrap linked or
statically linked is to use the file command to test the type of file from
which your system was booted. If your system is a bootstrap-linked system,
it was booted from an ASCII text file; otherwise, it was booted from an
executable image file. For example, issue the following command to
determine the type of file from which your system was booted:
#/usr/bin/file ‘/usr/sbin/sizer -b‘
/etc/sysconfigtab: ascii text
The sizer -b command returns the name of the file from which the system
was booted. This file name is input to the file command, which determines
that the system was booted from an ASCII text file. The output shown in the
preceeding example indicates that the system is a bootstrap-linked system.
If the system had been booted from an executable image file named vmunix,
the output from the file command would have appeared as follows:
vmunix:COFF format alpha executable or object module
not stripped
If your system is running a bootstrap-linked kernel, build a kernel image
that is identical to the bootstrap-linked kernel your system is running, by
entering the following command:
The output from the sizer -m command is a list of the exact modules and
linker flags used to build the currently running bootstrap-linked kernel.
This output causes the ld command to create a kernel image that is identical
to the bootstrap-linked kernel running on your system. The kernel image is
written to the file named by the -o flag, in this case the vmunix.image file.
Once you create this image, you can debug the kernel as described in this
manual, using the dbx, kdbx, and kdebug debuggers. When you invoke
the dbx or kdbx debugger, remember to specify the name of the kernel
image file you created with the ld command, such as the vmunix.image
file shown here.
When you are finished debugging the kernel, you can remove the kernel
image file you created for debugging purposes.
1–2 Introduction to Kernel Debugging
1.2 Debugging Kernel Programs
Kernel programs can be difficult to debug because you normally cannot
control kernel execution. To make debugging kernel programs more
convenient, the system provides the
debugger is code that resides inside the kernel and allows you to use the dbx
debugger to control execution of a running kernel in the same manner as
you control execution of a user space program. To debug a kernel program
in this manner, follow these steps:
1.Build your kernel program into the kernel on a test system.
2.Set up the kdebug debugger, as described in Section 2.3.
3.Issue the dbx -remote command on a remote build system, supplying
the pathname of the kernel running on the test system.
4.Set breakpoints and enter dbx commands as you normally would.
Section 2.1 describes some of the commands that are useful during
kernel debugging. For general information about using dbx, see the
Programmer’s Guide.
The system also provides the kdbx debugger, which is designed especially
for debugging kernel code. This debugger contains a number of special
commands, called extensions, that allow you to display kernel data
structures in a readable format. Section 2.2 describes using kdbx and its
extensions. (You cannot use the kdbx debugger with the kdebug debugger.)
kdebug debugger. The kdebug
Another feature of kdbx is that you can customize it by writing your own
extensions. The system contains a set of kdbx library routines that you can
use to create extensions that display kernel data structures in ways that are
meaningful to you. Chapter 3 describes writing kdbx extensions.
1.3 Debugging the Running Kernel
When you have problems with a process or set of processes, you can attempt
to identify the problem by debugging the running kernel. You might also
invoke the debugger on the running kernel to examine the values assigned
to system parameters. (You can modify the value of the parameters using
the debugger, but this practice can cause problems with the kernel and
should be avoided.)
You use the dbx or kdbx debugger to examine the state of processes running
on your system and to examine the value of system parameters. The kdbx
debugger provides special commands, called extensions, that you can use to
display kernel data structures. (Section 2.2.3 describes the extensions.)
To examine the state of processes, you invoke the debugger (as described in
Section 2.1 or Section 2.2) using the following command:
Introduction to Kernel Debugging 1–3
# dbx -k /vmunix /dev/mem
This command invokes dbx with the kernel debugging flag, −k, which
maps kernel addresses to make kernel debugging easier. The /vmunix and
/dev/mem parameters cause the debugger to operate on the running kernel.
Once in the dbx environment, you use dbx commands to display process IDs
and trace execution of processes. You can perform the same tasks using the
kdbx debugger. The following example shows the dbx command you use to
display process IDs:
If you want to trace the execution of the kloadsrv daemon, use the dbx
command to set the $pid symbol to the process ID of the kloadsrv daemon.
Then, enter the t command:
(dbx) set $pid = 14
(dbx) t
> 0 thread_block() ["/usr/sde/build/src/kernel/kern/sched_prim.c":1623, 0xfffffc0000\
43d77c]
Often, looking at the trace of a process that is hanging or has unexpectedly
stopped running reveals the problem. Once you find the problem, you can
modify system parameters, restart daemons, or take other corrective actions.
For more information about the commands you can use to debug the running
kernel, see Section 2.1 and Section 2.2.
1–4 Introduction to Kernel Debugging
1.4 Analyzing a Crash Dump File
If your system crashes, you can often find the cause of the crash by using
dbx or kdbx to debug or analyze a crash dump file.
The operating system can crash because one of the following occurs:
•Hardware exception
•Software panic
•Hung system
When a system hangs, it is often necessary to force the system to create
dumps that you can analyze to determine why the system hung. The
System Administration manual describes the procedure for forcing a
crash dump of a hung system.
•Resource exhaustion
The system crashes or hangs because it cannot continue executing. Normally,
even in the case of a hardware exception, the operating system detects
the problem. (For example a machine-checking routine might discover a
hardware problem and begin the process of crashing the system.) In general,
the operating system performs the following steps when it detects a problem
from which it cannot recover:
1.It calls the system panic function.
The panic function saves the contents of registers and sends the panic
string (a message describing the reason for the system panic) to the
error logger and the console terminal.
If the system is a Symmetric Multiprocessing (SMP) system, the panic
function notifies the other CPUs in the system that a panic has
occurred. The other CPUs then also execute the panic function and
record the following panic string:
cpu_ip_intr: panic request
Once each CPU has recorded the system panic, execution continues only
on the master CPU. All other CPUs in the SMP system stop execution.
2.It calls the system boot function.
The boot function records the stack.
3.It calls the dump function.
The dump function copies core memory into swap partitions and the
system stops running or the reboot process begins. Console environment
variables control whether the system reboots automatically. (The
System Administration manual describes these environment variables.)
Introduction to Kernel Debugging 1–5
At system reboot time, the copy of core memory saved in the swap partitions
is copied into a file, called a crash dump file. You can analyze the crash
dump file to determine what caused the crash. By default, the crash dump is
a partial (rather than full) dump and is in compressed form. For complete
information about managing crash dumps and crash dump files, including
how to change default settings, see the
System Administration manual. For
examples of analyzing crash dump files, see Chapter 4.
1–6 Introduction to Kernel Debugging
2
Kernel Debugging Utilities
The Tru64 UNIX system provides several tools you can use to debug the
kernel and kernel programs. The Ladebug debugger (available as an option)
is also capable of debugging the kernel.
This chapter describes three debuggers and a utility for analyzing crash
dumps:
•The dbx debugger, which is described for kernel debugging in Section 2.1.
(For general dbx user information, see the Programmer’s Guide.)
You can use the dbx debugger to display the values of kernel variables
and kernel structures. However, you must understand the structures
and be prepared to follow the address links to find the information you
need. You cannot use dbx alone to control execution of the running
kernel, for example by setting breakpoints.
•The kdbx debugger, which is described in Section 2.2.
The kdbx debugger is an interface to dbx that is tailored specifically
to debugging kernel code. The kdbx debugger has knowledge of the
structure of kernel data and so displays kernel data in a readable format.
Also, kdbx is extensible, allowing you to create commands that are
tailored to your kernel-debugging needs. (Chapter 3 describes how to
tailor the kdbx debugger.) However, you cannot use dbx command line
editing features when you use the kdbx debugger.
•The kdebug debugger, which is described in Section 2.3.
The kdebug debugger is a kernel-debugging program that resides
inside the kernel. Working with a remote version of the dbx debugger,
the kdebug debugger allows you to set breakpoints in and control the
execution of kernel programs and the kernel.
•The crashdc utility, which is described in Section 2.4.
The crashdc utility is a crash dump analysis tool. This utility is useful
when you need to determine why the system is hanging or crashing.
The sections that follow describe how to use these tools to debug the kernel
and kernel programs.
Kernel Debugging Utilities 2–1
______________________Note_______________________
Starting with Tru64 UNIX Version 5.0, all the previously
mentioned tools can be used with compressed (vmzcore.n) and
uncompressed (vmcore.n) crash dump files. Older versions of
these tools can read only vmcore.n files. If you are using an
older version of a tool, use the expand_dump utility to produce
a vmcore.n file from a vmzcore.n file. For more information
about compressed and uncompressed crash dump files, see
expand_dump
(8) and the System Administration manual.
2.1 The dbx Debugger
The dbx debugger is a symbolic debugger that allows you to examine,
modify, and display the variables and data structures found in stripped or
nonstripped kernel images.
The following sections describe how to invoke the dbx debugger for kernel
debugging (Section 2.1.1) and how to use its commands to perform tasks
such as the following:
•Debugging stripped images (Section 2.1.2)
•Specifying the location of loadable modules for crash dumps
(Section 2.1.3)
•Examining memory contents (Section 2.1.4)
•Displaying the values of kernel variables, and the value and format of
kernel data structures (Section 2.1.5)
•Displaying the format of a data structure (Section 2.1.6)
•Debugging multiple threads (Section 2.1.7)
•Examining the exception frame (Section 2.1.8)
•Examining the user program stack (Section 2.1.9)
•Extracting the preserved message buffer (Section 2.1.10)
•Debugging on SMP systems (Section 2.1.11)
For more information on dbx, see the Programmer’s Guide.
2.1.1 Invoking the dbx Debugger for Kernel Debugging
To debug kernel code with the dbx debugger, you use the −k flag. This flag
causes dbx to map memory addresses. When you use the dbx −k command,
the debugger operates on two separate files that reflect the current state of
the kernel that you want to examine. These files are as follows:
•The disk version of the executable kernel image
2–2 Kernel Debugging Utilities
•The system core memory image
These files may be files from a running system, such as /vmunix and
/dev/mem, or dump files, such as vmunix.n and vmzcore.n (compressed)
or vmcore.n (uncompressed). By default, crash dump files are created in
the /var/adm/crash directory (see the System Administration manual).
______________________Note_______________________
You might need to be the superuser (root login) to examine the
running system or crash dump files produced by savecore.
Whether you need to be the superuser depends on the directory
and file protections for the files you attempt to examine with
the dbx debugger.
Use the following dbx command to examine the running system:
# dbx −k /vmunix /dev/mem
Use a dbx command similar to the following to examine a compressed or
uncompressed crash dump file, respectively:
The version number (.1, in this example) is determined by the value
contained in the bounds file, which is located in the same directory as the
dump files.
2.1.2 Debugging Stripped Images
By default, the kernel is compiled with a debugging flag that does not strip
all of the symbol table information from the executable kernel image. The
kernel is also partially optimized during the compilation process by default.
If the kernel or any other file is fully optimized and stripped of all symbol
table information during compilation, your ability to debug the file is greatly
reduced. However, the dbx debugger provides commands to aid you in
debugging stripped images.
When you attempt to display the contents of a symbol during a debugging
session, you might encounter messages such as the following:
No local symbols.
Undefined symbol.
Inactive symbol.
These messages might indicate that you are debugging a stripped image.
To see the contents of all symbols during a debugging session, you can leave
the debugging session, rebuild all stripped modules (but do not strip them),
and reenter the debugging session. However, on certain occasions, you might
Kernel Debugging Utilities 2–3
want to add a symbol table to your current debugging session rather than
end the session and start a new one. To add a symbol table to your current
debugging session, follow these steps:
1.Go to a window other than the one in which the debugger is running,
or put the debugger in the background, and rebuild the modules for
which you need a symbol table.
2.Once the modules build correctly, use the
ostrip command to strip a
symbol table out of the resulting executable file. For example, if your
executable file is named kernel_program, issue a command such as
the following one:
% /usr/ucb/ostrip -t kernel_program
The -t flag causes the ostrip command to produce two files. One,
named kernel_program, is the stripped executable image. The other,
named kernel_program.stb, contains the symbol table information
for the kernel_program module. (For more information about the
ostrip command, see ostrip(1).)
3.Return to the debugging session and add the symbol table file by issuing
the dbx command stbadd as follows:
dbx> stbadd kernel_program.stb
You can specify an absolute or relative pathname on the stbadd
command line.
Once you issue this command, you can display the contents of symbols
included in the symbol table just as if you had built the module you
are debugging without stripping.
You can also delete symbol tables from a debugging session using the dbx
command stbdel. For more information about this command, see dbx(1).
2.1.3 Specifying the Location of Loadable Modules for Crash Dumps
When a crash dump occurs, the location of any loadable modules used
by the kernel is recorded in the crash dump file, enabling dbx to find the
modules. If the version of a loadable module that was running when the
crash occurred is moved to a different location, dbx will not find it. You can
specify the directory path where dbx should look for loadable modules by
using any one of the following methods (see dbx
•On the dbx command line, specify the directory path with the
•Before invoking dbx, set the environment variable DBX_MODULE_PATH.
For example:
# setenv DBX_MODULE_PATH /project4/mod_dir
2–4 Kernel Debugging Utilities
(1) for complete details):
•During the dbx session, if you want to load a module dynamically, first
set the $module_path dbx variable and then use the addobj command
to load the module, as in the following example:
(dbx) set $module_path /project4/mod_dir
(dbx) addobj kmodC
To verify that modules are being loaded from the correct location, turn on
verbose module-loading using any one of the following methods:
•Specify the -module_verbose dbx command option.
•Set the DBX_MODULE_VERBOSE environment variable to any integer
value.
•Set the $module_verbose dbx variable to a nonzero value.
2.1.4 Examining Memory Contents
To examine memory contents with dbx, use the following syntax:
address/count[mode]
The count argument specifies the number of items that the debugger
displays at the specified address, and the mode argument determines how
dbx displays memory. If you omit the mode argument, the debugger uses
the previous mode. The initial default mode is X (hexadecimal). Table 2–1
lists the dbx address modes.
Table 2–1: The dbx Address Modes
ModeDescription
b
c
d
D
f
g
i
n
o
O
s
x
X
Displays a byte in octal.
Displays a byte as a character.
Displays a short word in decimal.
Displays a long word in decimal.
Displays a single precision real number.
Displays a double precision real number.
Displays machine instructions.
Displays data in typed format.
Displays a short word in octal.
Displays a long word in octal.
Displays a string of characters that ends in a null.
Displays a short word in hexadecimal.
Displays a long word in hexadecimal.
Kernel Debugging Utilities 2–5
The following examples show how to use dbx to examine kernel images:
You can use the whatis command to display the format for many of the
kernel data structures. The whatis command has the following syntax:
whatis typename
The following example displays the itimerval data structure:
(dbx) whatis struct itimerval
struct itimerval {
struct timeval {
int tv_sec;
int tv_usec;
} it_interval;
2–6 Kernel Debugging Utilities
struct timeval {
int tv_sec;
int tv_usec;
} it_value;
};
2.1.7 Debugging Multiple Threads
You can use the dbx debugger to examine the state of the kernel’s threads
with the querying and scoping commands described in this section. You
use these commands to show process and thread lists and to change the
debugger’s context (by setting its current process and thread variables)
so that a stack trace for a particular thread can be displayed. Use these
commands to examine the state of the kernel’s threads:
print $tid
print $pid
where
tlist
kps
set $pid=process_id
tset thread_id
tstack
Display the thread ID of the current
thread
Display the process ID of the current
process
Display a stack trace for the current
thread
Display a list of kernel threads for the
current process
Display a list of processes (not available
when used with kdebug)
Change the context to another process (a
process ID of 0 changes context to the
kernel)
Change the context to another thread
Displays the stack trace for all threads.
2.1.8 Examining the Exception Frame
When you work with a crash dump file to debug your code, you can use
dbx to examine the exception frame. The exception frame is a stack frame
created during an exception. It contains the registers that define the state
of the routine that was running at the time of the exception. Refer to the
Kernel Debugging Utilities 2–7
/usr/include/machine/reg.h header file to determine where registers
are stored in the exception frame.
The savedefp variable contains the location of the exception frame. (Note
that no exception frames are created when you force a system to dump, as
described in the
System Administration manual.) The following example
When debugging a crash dump with dbx, you can examine the call stack of
the user program whose execution precipitated the kernel crash. To examine
a crash dump and also view the user program stack, you must invoke dbx
using the following command syntax:
dbx -k vmunix.n vm[z]core.n path/user-program
The version number (n) is determined by the value contained in the
bounds file, which is located in the same directory as the dump files. The
user-program parameter specifies the user program executable.
The crash dump file must contain a full crash dump. For information on
setting system defaults for full or partial crash dumps, see the SystemAdministration manual. You can use the assign command in dbx, as shown
in the following example, to temporarily specify a full crash dump. This
setting stays in effect until the system is rebooted.
# dbx -k vmunix.3
dbx version 5.0
.
.
.
(dbx) assign partial_dump=0
2–8 Kernel Debugging Utilities
To specify a full crash dump permanently so that this setting remains in
effect after a reboot, use the patch command in dbx, as shown in the
following example:
(dbx) patch partial_dump=0
With either command, a partial_dump value of 1 specifies a partial dump.
The following example shows how to examine the state of a user program
named test1 that purposely precipitated a kernel crash with a syscall
after several recursive calls:
# dbx -k vmunix.1 vmzcore.1 /usr/proj7/test1
dbx version 5.0
Type ’help’ for help.
stopped at [boot:1890 ,0xfffffc000041ebe8]Source not available
(dbx) up 8
recurse: 30if (r.a[2] > 0) recurse(r);
(dbx) print r
struct {
a={
(dbx) print r.a[511]
25
(dbx)
1
2
3
[0] 170
[1] 0
[2] 2
[3] 0
.
.
.
4
1The where command displays the kernel stack followed by the user
program stack at the time of the crash. In this case, the kernel stack
has 4 activation levels; the user program stack starts with the fifth level
and includes several recursive calls.
Kernel Debugging Utilities 2–9
2The up 8 command moves the debugging context 8 activation levels up
the stack to one of the recursive calls within the user program code.
3The print r command displays the current value of the variable r,
which is a structure of array elements. Full symbolization is available
for the user program, assuming it was compiled with the -g option.
4The print r.a[511] command displays the current value of array
element 511 of structure r.
2.1.10 Extracting the Preserved Message Buffer
The preserved message buffer (pmsgbuf) contains information such as
the firmware version, operating system version, pc value, and device
configuration. You can use dbx to extract the preserved message buffer from
a running system or dump files. For example:
msg_bufc = "Alpha boot: available memory from 0x7c6000 to 0x6000000
Tru64 UNIX V5.0; Sun Jan 03 11:20:36 EST 1999
physical memory = 96.00 megabytes.
available memory = 84.57 megabytes.
using 360 buffers containing 2.81 megabytes of memory
tc0 at nexus
scc0 at tc0 slot 7
asc0 at tc0 slot 6
rz1 at scsi0 target 1 lun 0 (LID=0) (DECRZ25(C) DEC 0700)
rz2 at scsi0 target 2 lun 0 (LID=1) (DECRZ25(C) DEC 0700)
rz3 at scsi0 target 3 lun 0 (LID=2) (DECRZ26(C) DEC T384)
rz4 at scsi0 target 4 lun 0 (LID=3) (DECRRD42(C) DEC 4.5d)
tz5 at scsi0 target 5 lun 0 (DECTLZ06(C)DEC 0374)
scsi1 at tc0 slot 7
fb0 at tc0 slot 8
1280X1024
ln0: DEC LANCE Module Name: PMAD-BA
ln0 at tc0 slot 7
.
.
.
2.1.11 Debugging on SMP Systems
Debugging in an SMP environment can be difficult because an SMP system
optimized for performance keeps the minimum of lock debug information.
The Tru64 UNIX system supports a lock mode to facilitate debugging SMP
locking problems. The lock mode is implemented in the lockmode boot
time system attribute. By default, the lockmode attribute is set to a value
between 0 and 3, depending upon whether the system is an SMP system and
whether the RT_PREEMPTION_OPT attribute is set. (This attribute optimizes
system performance.)
2–10 Kernel Debugging Utilities
For debugging purposes, set the lockmode attribute to 4. Follow these steps
to set the lockmode attribute to 4:
1.Create a stanza-formatted file named, for example, generic.stanza
that appears as follows:
generic:
lockmode=4
The contents of this file indicate that you are modifying the lockmode
attribute of the generic subsystem.
2.Add the new definition of lockmode to the /etc/sysconfigtab
database:
sysconfigdb -a -f generic.stanza generic
#
3.Reboot your system.
Some of the debugging features provided with lockmode set to 4 are as
follows:
•Automatic lock hierarchy checking and minimum spl checking when
any kernel lock is acquired (assuming a lockinfo structure exists
for the lock class in question). This checking helps you find potential
deadlock situations.
•Lock initialization checking.
•Additional debug information maintenance, including information about
simple and complex locks.
For simple locks, the system records an array of the last 32 simple locks
which were acquired on the system (slock_debug). The system creates
a slock_debug array for each CPU in the system.
For complex locks, the system records the locks owned by each thread in
the thread structure (up to eight complex locks).
To get a list of the complex locks a thread is holding use these commands:
The kdbx debugger is a crash analysis and kernel debugging tool; it serves
as a front end to the dbx debugger. The kdbx debugger is extensible,
customizable, and insensitive to changes to offsets and field sizes in
structures. The only dependencies on kernel header files are for bit
definitions in flag fields.
The kdbx debugger has facilities for interpreting various symbols and kernel
data structures. It can format and display these symbols and data structures
in the following ways:
•In a predefined form as specified in the source code modules that
currently accompany the kdbx debugger
•As defined in user-written source code modules according to a
standardized format for the contents of the kdbx modules
All dbx commands (except signals such as Ctrl/P) are available when you
use the kdbx debugger. In general, kdbx assumes hexadecimal addresses for
commands that perform input and output.
As with dbx, you can use kdbx to examine the call stack of the user program
whose execution precipitated a kernel crash (see Section 2.1.9).
The sections that follow explain using kdbx to debug kernel programs.
2.2.1 Beginning a kdbx Session
Using the kdbx debugger, you can examine the running kernel or dump files
created by the savecore utility. In either case, you examine an object file
and a core file. For running systems, these files are usually /vmunix and
2–12 Kernel Debugging Utilities
/dev/mem, respectively. By default, crash dump files are created in the
/var/adm/crash directory (see the System Administration manual).
Use the following kdbx command to examine a running system:
# kdbx −k /vmunix /dev/mem
Use a kdbx command similar to the following to examine a compressed or
uncompressed crash dump file, respectively:
The version number (.1 in this example) is determined by the value contained
in the bounds file, which is located in the same directory as the dump files.
To examine a crash dump file and also view the call stack of the user
program whose execution precipitated the kernel crash, you must invoke
kdbx using the following command syntax:
kdbx -k vmunix.
n vm[z]core.n path/user-program
For more information, see Section 2.1.9.
When you begin a debugging session, kdbx reads and executes the
commands in the system initialization file /var/kdbx/system.kdbxrc.
The initialization file contains setup commands and alias definitions. (For
a list of kdbx aliases, see the kdbx
(1) reference page.) You can further
customize the kdbx environment by adding commands and aliases to:
•The /var/kdbx/site.kdbxrc file
This file contains customized commands and alias definitions for a
particular system.
•The ~/.kdbxrc file
This file contains customized commands and alias definitions for a
specific user.
•The ./.kdbxrc file
This file contains customized commands and alias definitions for a
specific project. This file must reside in the current working directory
when kdbx is invoked.
2.2.2 The kdbx Debugger Commands
The kdbx debugger provides the following commands:
alias [name] [command-string]
Sets or displays aliases. If you omit all arguments, alias displays all
aliases. If you specify the variable name, alias displays the alias for
name, if one exists. If you specify name and command-string, alias
establishes name as an alias for command-string.
Kernel Debugging Utilities 2–13
context proc | user
Sets context to the user’s aliases or the extension’s aliases. This
command is used only by the extensions.
coredata start_address end_address
Dumps, in hexadecimal, the contents of the core file starting at
start_address and ending before end_address.
dbx command-string
Passes the command-string to dbx. Specifying dbx is optional; if
kdbx does not recognize a command, it automatically passes that
command to dbx. See the dbx
(1) reference page for a complete
description of dbx commands.
help [-long] [args]
Prints help text.
pr [flags] [extensions] [arguments]
Executes an extension and gives it control of the kdbx session until it
quits. You specify the name of the extension in extension and pass
arguments to it in arguments.
−debug
−pipe in_pipe
out_pipe
−print_output
−redirect_output
−tty
2–14 Kernel Debugging Utilities
Causes kdbx to display input to and output
from the extension on the screen.
Used in conjunction with the dbx debugger
for debugging extensions. See Chapter 3 for
information on using the −pipe flag.
Causes the output of the extension to be
sent to the invoker of the extension without
interpretation as kdbx commands.
Used by extensions that execute other
extensions to redirect the output from the
called extensions; otherwise, the user receives
the output.
Causes kdbx to communicate with the
subprocess through a terminal line instead
of pipes. If you specify the −pipe flag, proc
ignores it.
Loading...
+ 96 hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.