sim_error.h 2.7 KB
/*
 * Copyright (C) 1996-1998 by the Board of Trustees
 *    of Leland Stanford Junior University.
 * 
 * This file is part of the SimOS distribution. 
 * See LICENSE file for terms of the license. 
 *
 */

/*****************************************************************
 * error.h
 *
 * Error handling headers for SimOS.
 *
 * Author: $Author: blythe $
 * Date:   $Date: 2002/05/29 01:09:09 $
 ****************************************************************/

#ifndef _CPU_SHARED_ERROR_H
#define _CPU_SHARED_ERROR_H


#ifndef _LANGUAGE_ASSEMBLY
#include <stdarg.h>
#include <stdio.h>
#include "simtypes.h"
extern FILE *cpulogF;

/* #define ASSERTS_DISABLED*/
#ifndef ASSERTS_DISABLED
#define ASSUME(x)  {if (!(x)) \
{CPUWarning("%s:%d: assumption failed: %s\n",\
 __FILE__, __LINE__, # x);} }
#define VASSUME(x,s)  {if (!(x)) \
{CPUPut s; CPUWarning("%s:%d: assumption failed: %s\n",\
 __FILE__, __LINE__, # x);} }
#define ASSERT(x)  {if (!(x)) \
{CPUError("%s:%d: assertion failed (looping): %s\n",\
 __FILE__, __LINE__, # x);} }
#define VASSERT(x,s)  {if (!(x)) \
{CPUPut s; CPUError("%s:%d: assertion failed (looping): %s\n",\
 __FILE__, __LINE__, # x);} }
#else
#define ASSUME(x)
#define VASSUME(x,s)
#define ASSERT(x)
#define VASSERT(x,s)
#endif

#define NOTREACHED() \
{CPUError("%s:%d: NOTREACHED() error\n",\
 __FILE__, __LINE__);} 

extern void SimErrorInit(char* log_file);

extern void CPUError(char *,...);
extern void CPUWarning(char *,...);
extern void vCPUPrint(char *,va_list);
extern void CPUPrint(char *,...);
extern void CPUPrintFlush(void);
extern void CPUPut(char *, ...);
extern void lCPUPut(char *, ...);
extern void CPU_nop(void);
extern void CPURestartLog(void);
extern void DebugInit(char* flags);
/* Don't call these directly... use the macros below. */
extern void Debug (char flag, char* format, ...); /* Print debug message if enabled */
extern void DebugDetail(char flag, char *symbol, int cpuNum, char *text,...);
extern void LogEntry(char *symbol, int cpuNum, char *text,...);

#if 0
#define DEBUGGING_DISABLED 
#endif
#ifndef DEBUGGING_DISABLED
#define SIM_DEBUG(arg1) Debug arg1
#define SIM_DEBUG_DETAIL(arg1) DebugDetail arg1
#else
#define SIM_DEBUG(arg1)
#define SIM_DEBUG_DETAIL(arg1) 
#endif

/*****************************************************************
 Seems like a good place to track which letters are used for what:
   b - backdoor/registry
   i - interrupt debugging -> console, ethernet
   d - dma
   e - ethernet
   f - fpu (mipsy/embra/whatever)
   g - general -> memory allocation, checkpoints, gdb, etc. 
   o - solo-specific debugging (syscalls, etc.)
   t - tcl (including timing)
   v - visual
   *****************************************************************/

#endif
#endif /* _LANGUAGE_ASSEMBY */