Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ print_unaligned_summary(3) — bsd — mips UMIPS RISC/os 5.01

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

dbx(1)

fixade(2-BSD)

sigvec(2-BSD)

signal(2-SVR3)

sigset(2-SVR3)

sysmips(2-SVR3)



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



NAME
     handle_unaligned_traps, print_unaligned_summary - gather
          statistics on unaligned references

SYNOPSIS
     void handleunalignedtraps()

     void printunalignedsummary()

     long unalignedloadword(addr)
     char *addr;

     long unalignedloadhalf(addr)
     char *addr;

     long unalignedloaduhalf(addr)
     char *addr;

     float unalignedloadfloat(addr)
     char *addr;

     double unalignedloaddouble(addr)
     char *addr;

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

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

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

     void unalignedstoredouble(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 11/19/92                   Page 1





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



     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:














































 Page 2                 Printed 11/19/92





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



          ###############################
          #         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 fixade(2) (for -sys-
     type bsd) or sysmips(2) [MIPS_FIXADE] (for -systype svr3)
     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.

SEE ALSO
     dbx(1), fixade(2-BSD), sigvec(2-BSD), signal(2-SVR3),
     sigset(2-SVR3).  sysmips(2-SVR3) [MIPS_FIXADE].








                        Printed 11/19/92                   Page 3



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