"I am a person who works hard and plays hard."

Yuan Wei
Second Year Graduate Student Department of Computer Science
University of Virginia Charlottesville, VA 22903
Email: yw3f@cs.virginia.edu


Source Code Analysis

Main Page   Compound List   File List   Compound Members   File Members  

ptrace.h

Go to the documentation of this file.
00001 /*
00002  * ptrace.h - pipeline tracing definitions and interfaces
00003  *
00004  * This file is a part of the SimpleScalar tool suite written by
00005  * Todd M. Austin as a part of the Multiscalar Research Project.
00006  * 
00007  * The tool suite is currently maintained by Doug Burger and Todd M. Austin.
00008  * 
00009  * Copyright (C) 1994, 1995, 1996, 1997, 1998 by Todd M. Austin
00010  *
00011  * This source file is distributed "as is" in the hope that it will be
00012  * useful.  The tool set comes with no warranty, and no author or
00013  * distributor accepts any responsibility for the consequences of its
00014  * use. 
00015  * 
00016  * Everyone is granted permission to copy, modify and redistribute
00017  * this tool set under the following conditions:
00018  * 
00019  *    This source code is distributed for non-commercial use only. 
00020  *    Please contact the maintainer for restrictions applying to 
00021  *    commercial use.
00022  *
00023  *    Permission is granted to anyone to make or distribute copies
00024  *    of this source code, either as received or modified, in any
00025  *    medium, provided that all copyright notices, permission and
00026  *    nonwarranty notices are preserved, and that the distributor
00027  *    grants the recipient permission for further redistribution as
00028  *    permitted by this document.
00029  *
00030  *    Permission is granted to distribute this file in compiled
00031  *    or executable form under the same conditions that apply for
00032  *    source code, provided that either:
00033  *
00034  *    A. it is accompanied by the corresponding machine-readable
00035  *       source code,
00036  *    B. it is accompanied by a written offer, with no time limit,
00037  *       to give anyone a machine-readable copy of the corresponding
00038  *       source code in return for reimbursement of the cost of
00039  *       distribution.  This written offer must permit verbatim
00040  *       duplication by anyone, or
00041  *    C. it is distributed by someone who received only the
00042  *       executable form, and is accompanied by a copy of the
00043  *       written offer of source code that they received concurrently.
00044  *
00045  * In other words, you are welcome to use, share and improve this
00046  * source file.  You are forbidden to forbid anyone else to use, share
00047  * and improve what you give them.
00048  *
00049  * INTERNET: dburger@cs.wisc.edu
00050  * US Mail:  1210 W. Dayton Street, Madison, WI 53706
00051  *
00052  * $Id: ptrace.h,v 1.1.1.1 2000/05/26 15:18:59 taustin Exp $
00053  *
00054  * $Log: ptrace.h,v $
00055  * Revision 1.1.1.1  2000/05/26 15:18:59  taustin
00056  * SimpleScalar Tool Set
00057  *
00058  *
00059  * Revision 1.2  1998/08/27 15:50:04  taustin
00060  * implemented host interface description in host.h
00061  * added target interface support
00062  *
00063  * Revision 1.1  1997/03/11  01:32:28  taustin
00064  * Initial revision
00065  *
00066  *
00067  */
00068 
00069 #ifndef PTRACE_H
00070 #define PTRACE_H
00071 
00072 #include "host.h"
00073 #include "misc.h"
00074 #include "machine.h"
00075 #include "range.h"
00076 
00077 /*
00078  * pipeline events:
00079  *
00080  *      + <iseq> <pc> <addr> <inst>     - new instruction def
00081  *      - <iseq>                        - instruction squashed or retired
00082  *      @ <cycle>                       - new cycle def
00083  *      * <iseq> <stage> <events>       - instruction stage transition
00084  *
00085  */
00086 
00087 /*
00088         [IF]   [DA]   [EX]   [WB]   [CT]
00089          aa     dd     jj     ll     nn
00090          bb     ee     kk     mm     oo
00091          cc                          pp
00092  */
00093 
00094 /* pipeline stages */
00095 #define PST_IFETCH              "IF"
00096 #define PST_DISPATCH            "DA"
00097 #define PST_EXECUTE             "EX"
00098 #define PST_WRITEBACK           "WB"
00099 #define PST_COMMIT              "CT"
00100 
00101 /* pipeline events */
00102 #define PEV_CACHEMISS           0x00000001      /* I/D-cache miss */
00103 #define PEV_TLBMISS             0x00000002      /* I/D-tlb miss */
00104 #define PEV_MPOCCURED           0x00000004      /* mis-pred branch occurred */
00105 #define PEV_MPDETECT            0x00000008      /* mis-pred branch detected */
00106 #define PEV_AGEN                0x00000010      /* address generation */
00107 
00108 /* pipetrace file */
00109 extern FILE *ptrace_outfd;
00110 
00111 /* pipetracing is active */
00112 extern int ptrace_active;
00113 
00114 /* pipetracing range */
00115 extern struct range_range_t ptrace_range;
00116 
00117 /* one-shot switch for pipetracing */
00118 extern int ptrace_oneshot;
00119 
00120 /* open pipeline trace */
00121 void
00122 ptrace_open(char *range,                /* trace range */
00123             char *fname);               /* output filename */
00124 
00125 /* close pipeline trace */
00126 void
00127 ptrace_close(void);
00128 
00129 /* NOTE: pipetracing is a one-shot switch, since turning on a trace more than
00130    once will mess up the pipetrace viewer */
00131 #define ptrace_check_active(PC, ICNT, CYCLE)                            \
00132   ((ptrace_outfd != NULL                                                \
00133     && !range_cmp_range1(&ptrace_range, (PC), (ICNT), (CYCLE)))         \
00134    ? (!ptrace_oneshot ? (ptrace_active = ptrace_oneshot = TRUE) : FALSE)\
00135    : (ptrace_active = FALSE))
00136 
00137 /* main interfaces, with fast checks */
00138 #define ptrace_newinst(A,B,C,D)                                         \
00139   if (ptrace_active) __ptrace_newinst((A),(B),(C),(D))
00140 #define ptrace_newuop(A,B,C,D)                                          \
00141   if (ptrace_active) __ptrace_newuop((A),(B),(C),(D))
00142 #define ptrace_endinst(A)                                               \
00143   if (ptrace_active) __ptrace_endinst((A))
00144 #define ptrace_newcycle(A)                                              \
00145   if (ptrace_active) __ptrace_newcycle((A))
00146 #define ptrace_newstage(A,B,C)                                          \
00147   if (ptrace_active) __ptrace_newstage((A),(B),(C))
00148 
00149 #define ptrace_active(A,I,C)                                            \
00150   (ptrace_outfd != NULL && !range_cmp_range(&ptrace_range, (A), (I), (C)))
00151 
00152 /* declare a new instruction */
00153 void
00154 __ptrace_newinst(unsigned int iseq,     /* instruction sequence number */
00155                  md_inst_t inst,        /* new instruction */
00156                  md_addr_t pc,          /* program counter of instruction */
00157                  md_addr_t addr);       /* address referenced, if load/store */
00158 
00159 /* declare a new uop */
00160 void
00161 __ptrace_newuop(unsigned int iseq,      /* instruction sequence number */
00162                 char *uop_desc,         /* new uop description */
00163                 md_addr_t pc,           /* program counter of instruction */
00164                 md_addr_t addr);        /* address referenced, if load/store */
00165 
00166 /* declare instruction retirement or squash */
00167 void
00168 __ptrace_endinst(unsigned int iseq);    /* instruction sequence number */
00169 
00170 /* declare a new cycle */
00171 void
00172 __ptrace_newcycle(tick_t cycle);        /* new cycle */
00173 
00174 /* indicate instruction transition to a new pipeline stage */
00175 void
00176 __ptrace_newstage(unsigned int iseq,    /* instruction sequence number */
00177                   char *pstage,         /* pipeline stage entered */
00178                   unsigned int pevents);/* pipeline events while in stage */
00179 
00180 #endif /* PTRACE_H */


UVa CS Department of Computer Science
School of Engineering, University of Virginia
151 Engineer's Way, P.O. Box 400740
Charlottesville, Virginia 22904-4740

(434) 982-2200  Fax: (434) 982-2214