IBM Support

Advanced linux diagnostic tools

Troubleshooting


Problem

Segmentation fault or "hang" type failures generally do not log any useful information to the basic diagnostic traces available for the  IBM i Access Client Solutions ODBC driver for linux ("ibm-iaccess")

Diagnosing The Problem

This document describes three Linux diagnostic tools: strace, ltrace and gdb.
Use:
<command> --help 
or
man <command>
...for command details. 

Resolving The Problem

strace

  • Purposestrace is a diagnostic, debugging, and instructional userspace utility for Linux. It is used to monitor the system calls made by a program (interactions with the kernel) and the signals it receives. By tracing system calls, strace helps in understanding how a program interacts with the operating system.
  • Example Command:  strace -o strace.out -t -f -v <command to be traced>
    • This command runs <command to be traced> and writes the trace of system calls to strace.out.

ltrace

  • Purposeltrace is similar to strace, but it traces library calls instead of system calls. It monitors the calls made to shared libraries by a program. It is useful for debugging issues related to dynamic linking and library functions, providing insights into how a program uses external libraries.
  • Example Commandltrace -iStC -o ltrace.out <command to be traced>
    • This command runs <command to be traced> and writes the trace of library calls to ltrace.out.
gdb

... is the GNU project debugger. It gives a developer greater detail regarding the execution of a program while it executes -- or what another program was doing at the moment it crashed.

GDB has four main functions (plus other things in support of these) to help a developer catch bugs in the act:

  • Start your program, specifying anything that might affect its behavior.
  • Make your program stop on specified conditions.
  • Examine what has happened, when your program has stopped.
  • Change things in your program, so you can experiment with correcting the effects of one bug and go on to learn about another.
The program being debugged can be written in Ada, C, C++, Objective-C, Pascal (and many other languages). Those programs might be executing on the same machine as GDB (native) or on another machine (remote). GDB can run on most popular UNIX and Microsoft Windows variants.

For example, assume we can re-create a segfault using unixODBC's isql test utility. Collect the call stack using:
$ gdb isql
(gdb) run <DSNname> <USRPRF> <password>

When the segmentation fault is encountered, execute:
backtrace <enter>
PHP script example:
$ gdb /usr/bin/php
(gdb) run <somePHPscript.php>
When the segmentation fault is encountered, execute:
backtrace <enter>
The above shows the call stack at the time of the error.

[{"Business Unit":{"code":"BU070","label":"IBM Infrastructure"},"Product":{"code":"SWG60","label":"IBM i"},"Component":"Data Access","Platform":[{"code":"PF012","label":"IBM i"}],"Version":"Version Independent","Edition":"","Line of Business":{"code":"LOB68","label":"Power HW"}}]

Historical Number

604164141

Document Information

Modified date:
21 April 2025

UID

nas8N1011466