22.3 General Linux debugging facilities

As in every Linux system, there are tools you can use to debug the kernel and to debug user space programs on the mainframe. Naturally, a lot of the tools you use on other Linux systems work here too, such as LTT, dprobes, rgbd, and kdb. As the subject of the book is the mainframe, we will concentrate on tools particular to the mainframe, and only skim over the Linux tools, for which there are readily available descriptions.

Table 22-2 lists some tools for Linux debugging. Detailed information about the tools can be found in the corresponding info- and man pages.

Table 22-2. General Linux debugging facilities

Tool name

Where available

Purpose

gdb

http://www.gnu.org/software/gdb/gdb.html

The GNU debugger (gdb) is a user space debugger also available for Linux on zSeries. It can be used to do stack backtraces, set breakpoints, and print out variables.

ldd

Included in Linux base system

The ldd utility can be used to get a list of all shared libraries which an executable uses. It is also possible to see the addresses where the libraries are located. When investigating a given PSW, you can use this information to find out in which shared library a program is currently running.

ltrace

Included in Linux base system

The ltrace utility will output all dynamic library calls of a program. It is possible to see all libc calls of a program such as "printf" or "strcpy." In order to trace the library calls of a program, the program has to be executed under ltrace. ltrace also can attach to an already running process.

nm

GNU binary utilities

The nm tool lists object file symbols, including address, type, and name. The nm tool can be of help if you get an "undefined reference" error when linking a program. Then you can search system libraries and object files and libraries of your software project after the corresponding symbol.

The output of nm is also helpful when debugging kernel modules with lcrash.

objdump

GNU binary utilities

The objdump utility displays object file information and can be used to create debug information lists.

OOPS message

Included in base Linux system

In certain situations, for example, when the kernel tries to access a bad page, the kernel generates an Oops message. The Oops message is written to the kernel buffers. Usually the message is written via klogd and syslogd to a syslog file.

In the Oops text, you find the following information:

  • What error occurred

  • Contents of some architecture-specific registers

  • A stack backtrace, which shows how the kernel ran into the error situation

proc file system

Included in base Linux system

The /proc file system is a powerful concept that allows you to investigate and modify kernel parameters. It is a virtual file system created by the kernel. Read requests from this file system are fulfilled by the kernel with the current system status. Write requests to this file system are used to modify kernel parameters on the fly.

s390dbf

Included in base Linux system

The Linux on zSeries Debug Feature traces kernel components such as device drivers. It produces trace logs, which can be useful when that specific component shows an error. Not all components produce the logs, however. A component must register with the feature to produce the traces.

The /proc directory holds debug logs from the s390dbf tool. Under the path /proc/s390dbf, there is a directory for each registered component. The names of the directory entries correspond to the names under which the components have been registered.

strace

http://sourceforge.net

Strace is a tool for intercepting calls to the kernel and logging them to a file and on the screen. You could use it, for instance, to find out what files a particular program opens.

SysRq

Included in base Linux system

You can use the "magical key combination" of SysRq to debug on the mainframe. Linux on zSeries supports SysRq. The key combination is directly intercepted by the kernel and can be used to perform an emergency shutdown, to synchronize disks, to unmount, and to reboot if the machine becomes partially hung.

top

Included in base Linux system

Use top to find out where processes are sleeping in the kernel. To do this, copy the System.map from the root directory where the Linux kernel was built to the /boot directory on your Linux machine.



Linux on the Mainframe
Linux on the Mainframe
ISBN: 0131014153
EAN: 2147483647
Year: 2005
Pages: 199

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net