alpha_trace.h 1.41 KB
/*
 * Copyright (C) 1998 by the Board of Trustees
 *    of Leland Stanford Junior University.
 * Copyright (C) 1998 Digital Equipment Corporation
 *
 * This file is part of the SimOS distribution.
 * See LICENSE file for terms of the license.
 *
 */



#ifndef TRACE_H
#define TRACE_H

#ifdef TRACING

#define TRACE_ENTRY(_code,_cpu,_val) { \
   if (trace.cpuMask[_cpu]) { \
     *trace.bufferPtr++ = TRACE_FORMAT(_code,_cpu,_val); \
     if (trace.bufferPtr==trace.bufferEnd) TraceDump(); \
   } \
} 


#define TRACE_LOG(_string) { \
   if (trace.active) TraceLog(_string); \
} 

#else

#define TRACE_ENTRY(_code,_cpu,_val)
#define TRACE_LOG(_string)


#endif /* TRACING */

#define TRACE_LOAD         1
#define TRACE_STORE        2
#define TRACE_MB           8
#define TRACE_BR_TAKEN    10
#define TRACE_BR_NOTTAKEN 11
#define TRACE_JSR         12  /*JMPRET*/
#define TRACE_BB          13  /*TARGET*/

#define TRACE_ASCII       20
#define TRACE_STORE_PHYS  21
#define TRACE_LOAD_PHYS   22
#define TRACE_TRAP        23

#define TRACE_FORMAT(_code,_cpu,_val) ( (((uint64)_code)<<56)|(((uint64)_cpu)<<52)|((_val)&BITMASK(52)))


#define TRACE_BUFFER_SIZE (32*1024)




typedef struct TracingState {
   int  active;
   char cpuMask[SIM_MAXCPUS];
   int  fd;
   uint64 *buffer;
   uint64 *bufferPtr;
   uint64 *bufferEnd;
} TracingState;


extern TracingState trace;

extern void TraceDump(void);
extern void TraceLog(char *);


#endif /* TRACE_H */