00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00095 #if !defined(INCLUDED_TRACEENGINE_H)
00096 #define INCLUDED_TRACEENGINE_H
00097
00098 #if defined(IDB)
00099 #include "datatypes.h"
00100
00102 struct STraceFunction
00103 {
00104 u32 address;
00105 char* fn_name;
00106 char* fn_arglist;
00107 bool step_over;
00108 };
00109
00111 struct STracePRBR
00112 {
00113 u64 prbr;
00114 u64 hwpcb;
00115 FILE* f;
00116 u64 trcadd[701];
00117 int trclvl;
00118 int trchide;
00119 u64 trc_waitfor;
00120 char procname[30];
00121 int generation;
00122 };
00123
00125 struct STraceCPU
00126 {
00127 int last_prbr;
00128 };
00129
00133 class CTraceEngine
00134 {
00135 public:
00136 void read_procfile(const char* filename);
00137 CTraceEngine(class CSystem* sys);
00138 ~ CTraceEngine(void);
00139 void trace(class CAlphaCPU* cpu, u64 f, u64 t, bool down, bool up,
00140 const char* x, int y);
00141 void trace_br(class CAlphaCPU* cpu, u64 f, u64 t);
00142 void add_function(u64 address, const char* fn_name, const char* fn_arglist,
00143 bool step_over);
00144 bool get_fnc_name(class CAlphaCPU* cpu, u64 address, char ** p_fn_name);
00145 void set_waitfor(class CAlphaCPU* cpu, u64 address);
00146 FILE* trace_file();
00147 void trace_dev(const char* text);
00148 int parse(char command[100][100]);
00149 void run_script(const char* filename);
00150 void list_all();
00151 protected:
00152 class CSystem* cSystem;
00153 int trcfncs;
00154 int iNumFunctions;
00155 int iNumPRBRs;
00156 struct STraceFunction asFunctions[25000];
00157 struct STraceCPU asCPUs[4];
00158 struct STracePRBR asPRBRs[1000];
00159 int get_prbr(u64 prbr, u64 hwpcb);
00160 void write_arglist(CAlphaCPU* c, FILE* f, const char* a);
00161 FILE* current_trace_file;
00162 u64 iBreakPoint;
00163 int iBreakPointMode;
00164 bool bBreakPoint;
00165 u32 iBreakPointInstruction;
00166 };
00167
00168 extern bool bTrace;
00169 extern bool bDisassemble;
00170 extern bool bHashing;
00171 extern bool bListing;
00172
00173 #if defined(DEBUG_TB)
00174 extern bool bTB_Debug;
00175 #endif
00176 extern CTraceEngine* trc;
00177
00178 #define TRC_DEV(a) \
00179 { \
00180 if(bTrace) \
00181 { \
00182 char t[1000]; \
00183 sprintf(t, a); \
00184 trc->trace_dev(t); \
00185 } \
00186 }
00187 #define TRC_DEV2(a, b) \
00188 { \
00189 if(bTrace) \
00190 { \
00191 char t[1000]; \
00192 sprintf(t, a, b); \
00193 trc->trace_dev(t); \
00194 } \
00195 }
00196 #define TRC_DEV3(a, b, c) \
00197 { \
00198 if(bTrace) \
00199 { \
00200 char t[1000]; \
00201 sprintf(t, a, b, c); \
00202 trc->trace_dev(t); \
00203 } \
00204 }
00205 #define TRC_DEV4(a, b, c, d) \
00206 { \
00207 if(bTrace) \
00208 { \
00209 char t[1000]; \
00210 sprintf(t, a, b, c, d); \
00211 trc->trace_dev(t); \
00212 } \
00213 }
00214 #define TRC_DEV5(a, b, c, d, e) \
00215 { \
00216 if(bTrace) \
00217 { \
00218 char t[1000]; \
00219 sprintf(t, a, b, c, d, e); \
00220 trc->trace_dev(t); \
00221 } \
00222 }
00223 #define TRC_DEV6(a, b, c, d, e, f) \
00224 { \
00225 if(bTrace) \
00226 { \
00227 char t[1000]; \
00228 sprintf(t, a, b, c, d, e, f); \
00229 trc->trace_dev(t); \
00230 } \
00231 }
00232
00233 #define DO_ACTION !bListing
00234
00235 #else //IDB
00236 #define TRC_DEV(a) ;
00237 #define TRC_DEV2(a, b) ;
00238 #define TRC_DEV3(a, b, c) ;
00239 #define TRC_DEV4(a, b, c, d) ;
00240 #define TRC_DEV5(a, b, c, d, e) ;
00241 #define TRC_DEV6(a, b, c, d, e, f) ;
00242
00243 #define DO_ACTION 1
00244 #endif
00245 #endif