TraceEngine.h

Go to the documentation of this file.
00001 /* ES40 emulator.
00002  * Copyright (C) 2007-2008 by the ES40 Emulator Project
00003  *
00004  * WWW    : http://sourceforge.net/projects/es40
00005  * E-mail : camiel@camicom.com
00006  * 
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  * 
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  * 
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00020  * 
00021  * Although this is not required, the author would appreciate being notified of, 
00022  * and receiving any modifications you may make to the source code that might serve
00023  * the general public.
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

SourceForge.net Logo
Project space on SourceForge.net