Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] View of /sml/trunk/src/runtime/mach-dep/unix-fault.c
ViewVC logotype

View of /sml/trunk/src/runtime/mach-dep/unix-fault.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 569 - (download) (as text) (annotate)
Tue Mar 7 04:01:07 2000 UTC (19 years, 4 months ago) by blume
File size: 3548 byte(s)
- size info in BOOTLIST
     * no fixed upper limits for number of bootfiles or length of
       bootfile names in runtime
     * falling back to old behavior if no BOOTLIST size info found
- allocation size heuristics in .run-sml
     * tries to read cache size from /proc/cpuinfo (this is important for
        small-cache Celeron systems!)
- install.sh robustified
- CM manual updates
- paranoid mode
     * no more CMB.deliver() (i.e., all done by CMB.make())
     * can re-use existing sml.boot.* files
     * init.cmi now treated as library
     * library stamps for consistency checks
- sml.boot.<arch>-<os>/PIDMAP file
     * This file is read by the CM startup code.  This is used to minimize
       the amount of dynamic state that needs to be stowed away for the
       purpose of sharing between interactive system and user code.
- CM.Anchor.anchor instead of CM.Anchor.{set,cancel}
     * Upon request by Elsa.  Anchors now controlled by get-set-pair
       like most other CM state variables.
- Compiler.CMSA eliminated
     * No longer supported by CM anyway.
- fixed bugs in pickler that kept biting Stefan
     * past refs to past refs (was caused by the possibility that
       ad-hoc sharing is more discriminating than hash-cons sharing)
     * integer overflow on LargeInt.minInt
- ml-{lex,yacc} build scripts now use new mechanism
  for building standalone programs
- fixed several gcc -Wall warnings that were caused by missing header
  files, missing initializations, etc., in runtime (not all warnings
  eliminated, though)
/* unix-fault.c
 *
 * COPYRIGHT (c) 1992 by AT&T Bell Laboratories.
 *
 * Common code for handling arithmetic traps.
 */

#include "ml-unixdep.h"
#include "signal-sysdep.h"
#include "ml-base.h"
#include "vproc-state.h"
#include "ml-state.h"
#include "ml-globals.h"

/* this is temporary */
#define SELF_VPROC	(VProc[0])


/* local routines */
PVT SigReturn_t FaultHandler (/* int sig, SigInfo_t code, SigContext_t *scp */);
#if defined(TARGET_BYTECODE)
PVT SigReturn_t PanicTrace (/* int sig, SigInfo_t code, SigContext_t *scp */);
#endif


/* InitFaultHandlers:
 */
void InitFaultHandlers (ml_state_t *msp)
{

#ifndef TARGET_BYTECODE

  /** Set up the Div and Overflow faults **/
#ifdef SIG_FAULT1
    SIG_SetHandler (SIG_FAULT1, FaultHandler);
#endif
#ifdef SIG_FAULT2
    SIG_SetHandler (SIG_FAULT2, FaultHandler);
#endif

  /** Initialize the floating-point unit **/
    SIG_InitFPE ();

#else /* TARGET_BYTECODE */
/** **/ SIG_SetHandler (SIGINT, PanicTrace);
        SIG_SetHandler (SIGBUS, PanicTrace);
        SIG_SetHandler (SIGSEGV, PanicTrace);
#endif /* !TARGET_BYTECODE */

} /* end of InitFaultHandlers */


#ifndef TARGET_BYTECODE

/* FaultHandler:
 *
 * Handle arithmetic faults (e.g., divide by zero, integer overflow).
 */
PVT SigReturn_t FaultHandler (
    int		    signal,
#if defined(OPSYS_LINUX)
    SigContext_t    sc)
#elif defined(OPSYS_MKLINUX)
    SigContext_t    *scp)
#else
    SigInfo_t	    info,
    SigContext_t    *scp)
#endif
{
#if defined(OPSYS_LINUX)
    SigContext_t    *scp = &sc;
#endif
    ml_state_t	    *msp = SELF_VPROC->vp_state;
    extern Word_t   request_fault[];
    int		    code = SIG_GetCode(info, scp);

#ifdef SIGNAL_DEBUG
    SayDebug ("Fault handler: sig = %d, inML = %d\n",
	signal, SELF_VPROC->vp_inMLFlag);
#endif

    if (! SELF_VPROC->vp_inMLFlag) 
	Die ("bogus fault not in ML: (%d, %#x)\n", signal, SIG_GetCode(info, scp));

   /* Map the signal to the appropriate ML exception. */
    if (INT_DIVZERO(signal, code)) {
	msp->ml_faultExn = DivId;
	msp->ml_faultPC = (Word_t)SIG_GetPC(scp);
    }
    else if (INT_OVFLW(signal, code)) {
	msp->ml_faultExn = OverflowId;
	msp->ml_faultPC = (Word_t)SIG_GetPC(scp);
    }
    else
	Die ("unexpected fault, signal = %d, code = %#x", signal, code);

    SIG_SetPC (scp, request_fault);

    SIG_ResetFPE (scp);

} /* end of FaultHandler */

#endif /* !TARGET_BYTECODE */


#if defined(TARGET_BYTECODE)
extern void PrintRegs (FILE *);
#ifdef INSTR_HISTORY
extern void PrintInstrHistory (FILE *);
#endif

/* PanicTrace:
 * This signal handler prints a trace of the last few instructions executed
 * by the bytecode interpreter (for debugging purposes).
 */
PVT SigReturn_t PanicTrace (
    int		    signal,
#if defined(OPSYS_LINUX)
    SigContext_t    sc)
#else
    SigInfo_t	    info,
    SigContext_t    *scp)
#endif
{
#if defined(OPSYS_LINUX)
    SigContext_t    *scp = &sc;
#endif

    SayDebug ("**** PANIC: signal = %d, code = %#x ****\n",
	signal, SIG_GetCode(info, scp));
    PrintRegs(DebugF);
#ifdef INSTR_HISTORY
    PrintInstrHistory (DebugF);
#endif
    SayDebug ("\n");

    Exit (1);
}
#endif


#if ((defined(TARGET_RS6000) || defined(TARGET_PPC)) && defined(OPSYS_AIX))

/* SIG_GetCode:
 *
 * For  AIX, the overflow and divide by zero information is obtained
 * from information contained in the sigcontext structure.
 */
PVT int SIG_GetCode (SigInfo_t code, SigContext_t *scp)
{
    struct fp_sh_info	FPInfo;

    fp_sh_info (scp, &FPInfo, sizeof(struct fp_sh_info));

    return FPInfo.trap;

} /* end of SIG_GetCode */

#endif

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0