Locating Unaligned Data

Unaligned data can slow program execution. You should determine the cause of the unaligned data, fix the source code (if necessary), and recompile and relink the program.

If your program encounters unaligned data at run time, to make it easier to debug the program, you should recompile and relink with the -fpen option to control the handling of exceptions.

To determine the cause of the unaligned data when using idb, follow these steps:

  1. Run the debugger, specifying the program with the unaligned data (shown as testprog in the following example): idb testprog

  2. Before you run the program, enter the catch unaligned command:
    catch unaligned

  3. Run the program:
    Unaligned access pid=28413 <
    testprog> va=140000154 pc=3ff80805d60
    ra=1200017e8 type=stl
    Thread received signal BUS
    stopped at [oops:13 0x120001834]
    13       end

  4. Enter a list command to display the source code at line 12:
    list 12
    12        i4 = 1
    >  13          end

  5. Enter the where command to find the location of the unaligned access:

  6. Use any other appropriate debugger commands needed to isolate the cause of the unaligned data, such as up, list, and down.

  7. Repeat these steps for other areas where unaligned data is reported. Use the rerun command to run the program again instead of exiting the debugger and running it from the shell prompt.

  8. After fixing the causes of the unaligned data, compile and link the program again.