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 2003/09/18 00:57:54 panalyzer Exp $ 00053 * 00054 * $Log: ptrace.h,v $ 00055 * Revision 1.1.1.1 2003/09/18 00:57:54 panalyzer 00056 * 00057 * 00058 * Revision 1.1.1.1 2003/09/18 00:18:44 panalyzer 00059 * 00060 * 00061 * Revision 1.1.1.1 2003/09/16 18:48:14 gdm 00062 * 00063 * 00064 * Revision 1.1.1.1 2000/11/29 14:53:54 cu-cs 00065 * Grand unification of arm sources. 00066 * 00067 * 00068 * Revision 1.1.1.1.2.2 2000/11/10 15:48:37 ernstd 00069 * created header file for shared variables in sim-outorder. Also added ptrace support for viewing uops. 00070 * 00071 * Revision 1.1.1.1.2.1 2000/10/13 17:45:14 chriswea 00072 * updated 00073 * 00074 * Revision 1.3 2000/08/10 18:22:45 chriswea 00075 * added ptracepipe 00076 * 00077 * Revision 1.2 2000/07/26 21:07:04 chriswea 00078 * added the visualization pipetrace new_stage_lat 00079 * 00080 * Revision 1.2 1998/08/27 15:50:04 taustin 00081 * implemented host interface description in host.h 00082 * added target interface support 00083 * 00084 * Revision 1.1 1997/03/11 01:32:28 taustin 00085 * Initial revision 00086 * 00087 * 00088 */ 00089 00090 #ifndef PTRACE_H 00091 #define PTRACE_H 00092 00093 #include "host.h" 00094 #include "misc.h" 00095 #include "machine.h" 00096 #include "range.h" 00097 #include "stats.h" 00098 00099 00100 /* 00101 * pipeline events: 00102 * 00103 * + <iseq> <pc> <addr> <inst> - new instruction def 00104 * - <iseq> - instruction squashed or retired 00105 * @ <cycle> - new cycle def 00106 * * <iseq> <stage> <events> - instruction stage transition 00107 * 00108 */ 00109 00110 /* 00111 [IF] [DA] [EX] [WB] [CT] 00112 aa dd jj ll nn 00113 bb ee kk mm oo 00114 cc pp 00115 */ 00116 00117 /* pipeline stages */ 00118 #define PST_IFETCH "IF" 00119 #define PST_DISPATCH "DA" 00120 #define PST_EXECUTE "EX" 00121 #define PST_WRITEBACK "WB" 00122 #define PST_COMMIT "CT" 00123 00124 /* pipeline events */ 00125 #define PEV_CACHEMISS 0x00000001 /* I/D-cache miss */ 00126 #define PEV_TLBMISS 0x00000002 /* I/D-tlb miss */ 00127 #define PEV_MPOCCURED 0x00000004 /* mis-pred branch occurred */ 00128 #define PEV_MPDETECT 0x00000008 /* mis-pred branch detected */ 00129 #define PEV_AGEN 0x00000010 /* address generation */ 00130 00131 /* pipetrace file */ 00132 extern FILE *ptrace_outfd; 00133 00134 /* pipetrace pipe */ 00135 extern int ptracepipe; 00136 00137 /* pipetracing is active */ 00138 extern int ptrace_active; 00139 00140 /* pipetracing range */ 00141 extern struct range_range_t ptrace_range; 00142 00143 /* one-shot switch for pipetracing */ 00144 extern int ptrace_oneshot; 00145 00146 /* open pipeline trace */ 00147 void 00148 ptrace_open(char *range, /* trace range */ 00149 char *fname); /* output filename */ 00150 00151 /* close pipeline trace */ 00152 void 00153 ptrace_close(void); 00154 00155 /* NOTE: pipetracing is a one-shot switch, since turning on a trace more than 00156 once will mess up the pipetrace viewer */ 00157 #define ptrace_check_active(PC, ICNT, CYCLE) \ 00158 ((ptrace_outfd != NULL \ 00159 && !range_cmp_range1(&ptrace_range, (PC), (ICNT), (CYCLE))) \ 00160 ? (!ptrace_oneshot ? (ptrace_active = ptrace_oneshot = TRUE) : FALSE)\ 00161 : (ptrace_active = FALSE)) 00162 00163 /* main interfaces, with fast checks */ 00164 #define ptrace_newinst(A,B,C,D) \ 00165 if (ptrace_active) __ptrace_newinst((A),(B),(C),(D)) 00166 #define ptrace_newuop(A,B,C,D,E) \ 00167 if (ptrace_active) __ptrace_newuop((A),(B),(C),(D),(E)) 00168 #define ptrace_endinst(A) \ 00169 if (ptrace_active) __ptrace_endinst((A)) 00170 #define ptrace_newcycle(A) \ 00171 if (ptrace_active) __ptrace_newcycle((A)) 00172 #define ptrace_newstage(A,B,C,D,E) \ 00173 if (ptrace_active) __ptrace_newstage_lat((A),(B),(C),(D),(E)) 00174 00175 #define ptrace_active(A,I,C) \ 00176 (ptrace_outfd != NULL && !range_cmp_range(&ptrace_range, (A), (I), (C))) 00177 00178 /* declare a new instruction */ 00179 void 00180 __ptrace_newinst(unsigned int iseq, /* instruction sequence number */ 00181 md_inst_t inst, /* new instruction */ 00182 md_addr_t pc, /* program counter of instruction */ 00183 md_addr_t addr); /* address referenced, if load/store */ 00184 00185 /* declare a new uop */ 00186 void 00187 __ptrace_newuop(unsigned int iseq, /* instruction sequence number */ 00188 md_inst_t inst, /* new uop description */ 00189 enum md_opcode op, 00190 md_addr_t pc, /* program counter of instruction */ 00191 md_addr_t addr); /* address referenced, if load/store */ 00192 00193 /* declare instruction retirement or squash */ 00194 void 00195 __ptrace_endinst(unsigned int iseq); /* instruction sequence number */ 00196 00197 /* declare a new cycle */ 00198 void 00199 __ptrace_newcycle(tick_t cycle); /* new cycle */ 00200 00201 /* indicate instruction transition to a new pipeline stage */ 00202 void 00203 __ptrace_newstage(unsigned int iseq, /* instruction sequence number */ 00204 char *pstage, /* pipeline stage entered */ 00205 unsigned int pevents);/* pipeline events while in stage */ 00206 00207 void 00208 __ptrace_newstage_lat(unsigned int iseq, /* instruction sequence number */ 00209 char *pstage, /* pipeline stage entered */ 00210 unsigned int pevents, unsigned int latency, unsigned int longerlat);/* pipeline events while in stage */ 00211 00212 /* print the value of stat variable STAT */ 00213 void 00214 ptrace_print_stat(struct stat_sdb_t *sdb, /* stat database */ 00215 struct stat_stat_t *stat,/* stat variable */ 00216 FILE *fd); /* output stream */ 00217 00218 /* print the value of all stat variables in stat database SDB */ 00219 void 00220 ptrace_print_stats(struct stat_sdb_t *sdb,/* stat database */ 00221 FILE *fd); /* output stream */ 00222 00223 00224 00225 00226 #endif /* PTRACE_H */