Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

dbx(1)

sysmips(2)

signal(2)

sigset(2)



UNALIGNED(3-SysV)   RISC/os Reference Manual    UNALIGNED(3-SysV)



NAME
     handle_unaligned_traps, print_unaligned_summary - gather
     statistics on unaligned references

SYNOPSIS
     void handle_unaligned_traps()

     void print_unaligned_summary()

     long unaligned_load_word(addr)
     char *addr;

     long unaligned_load_half(addr)
     char *addr;

     long unaligned_load_uhalf(addr)
     char *addr;

     float unaligned_load_float(addr)
     char *addr;

     double unaligned_load_double(addr)
     char *addr;

     void unaligned_store_word(addr, value)
     char *addr;
     long value;

     void unaligned_store_half(addr, value)
     char *addr;
     long value;

     void unaligned_store_float(addr, float value)
     char *addr;
     float value;

     void unaligned_store_double(addr, value)
     char *addr;
     double value;

DESCRIPTION
     The first two routines implement a facility for finding
     unaligned references.  The MIPS hardware traps load and
     store operations where the address is not a multiple of the
     number of bytes loaded or stored.  Usually this trap indi-
     cates incorrect program operation and so by default the ker-
     nel converts this trap into a SIGBUS signal to the process,
     typically causing a core dump for debugging.

     Older programs developed on systems with lax alignment con-
     straints sometimes make occasional misaligned references in
     course of correct operation.  The best way to port such



                         Printed 1/15/91                   Page 1





UNALIGNED(3-SysV)   RISC/os Reference Manual    UNALIGNED(3-SysV)



     programs to MIPS hardware is to correct the program by
     aligning the data.

     A call to handle_unaligned_traps installs a SIGBUS handler
     that fixes unaligned memory references and keeps a record of
     the types, counts, and instruction addresses of these traps.
     A call to print_unaligned_summary prints the accumulated
     information.  The following is an example of the output pro-
     duced by print_unaligned_summary:

          ###############################
          #         unaligned reference summary#
          # byte aligned lw         5000  33.3%#
          # byte aligned sw        10000  66.7%#
          # 0x0040024c/i            5000  33.3%  33.3%#
          # 0x004002a8/i            5000  33.3%  66.7%#
          # 0x004002b4/i            5000  33.3% 100.0%#
          ###############################

     The listing is written to standard error and describes the
     type and number of unaligned references, followed by a list
     of every address that contains an unaligned reference.  To
     convert the addresses into a dbx(1) script and run the
     script, pipe the output (both standard output and standard
     error) through the following command.  The output from dbx
     will be the name of the function and line number of the
     misalignment.

          sed -n -e 's;^ # [0-9a-f]*/i).*#$;1;p' | dbx prog

     This information can be used to decide the best way to
     correct the problem.  If not all of the data can be aligned,
     or not all of the identified program locations that refer-
     ence unaligned data can be changed, the sysmips(2)
     [MIPS_FIXADE] system call may be appropriate.

     The other routines load or store their indicated data type
     at the address specified.  The address need not meet the
     normal alignment constraints.

     There exist fortran entry points for these routines so they
     may be called directly from fortran with the names docu-
     mented here.

DIAGNOSTICS
     If these routines try to load or store to an address that is
     outside the program's address space a SIGSEGV signal will be
     generated from inside these routines.  If the program did
     not use these routines and the address was unaligned then
     the program would generate a SIGBUS signal.  This is because
     the check for alignment is done before the address is
     checked to be in the program's address space.



 Page 2                  Printed 1/15/91





UNALIGNED(3-SysV)   RISC/os Reference Manual    UNALIGNED(3-SysV)



SEE ALSO
     dbx(1), sysmips(2) [MIPS_FIXADE], signal(2), sigset(2).





















































                         Printed 1/15/91                   Page 3



Typewritten Software • bear@typewritten.org • Edmonds, WA 98026