/[pcsx2_0.9.7]/trunk/pcsx2/Dump.cpp
ViewVC logotype

Annotation of /trunk/pcsx2/Dump.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 62 - (hide annotations) (download)
Tue Sep 7 11:08:22 2010 UTC (9 years, 9 months ago) by william
File size: 10516 byte(s)
Auto Commited Import of: pcsx2-0.9.7-r3738-debug in ./trunk
1 william 31 /* PCSX2 - PS2 Emulator for PCs
2     * Copyright (C) 2002-2010 PCSX2 Dev Team
3     *
4     * PCSX2 is free software: you can redistribute it and/or modify it under the terms
5     * of the GNU Lesser General Public License as published by the Free Software Found-
6     * ation, either version 3 of the License, or (at your option) any later version.
7     *
8     * PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
9     * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
10     * PURPOSE. See the GNU General Public License for more details.
11     *
12     * You should have received a copy of the GNU General Public License along with PCSX2.
13     * If not, see <http://www.gnu.org/licenses/>.
14     */
15    
16     #include "PrecompiledHeader.h"
17     #include "IopCommon.h"
18    
19     #include "Counters.h"
20     #include "iCore.h"
21     #include "iR5900.h"
22     #include "IPU/IPU.h"
23    
24     #include "AppConfig.h"
25     #include "Utilities/AsciiFile.h"
26    
27     using namespace R5900;
28 william 62 using std::string;
29    
30 william 31 // fixme: currently should not be uncommented.
31     //#define TEST_BROKEN_DUMP_ROUTINES
32    
33     #ifdef TEST_BROKEN_DUMP_ROUTINES
34     extern tIPU_BP g_BP;
35    
36     #define VF_VAL(x) ((x==0x80000000)?0:(x))
37     #endif
38    
39    
40     // iR5900-32.cpp
41     extern EEINST* s_pInstCache;
42     extern u32 s_nEndBlock; // what pc the current block ends
43    
44    
45     void iDumpPsxRegisters(u32 startpc, u32 temp)
46     {
47     // [TODO] fixme : this code is broken and has no labels. Needs a rewrite to be useful.
48    
49     #ifdef TEST_BROKEN_DUMP_ROUTINES
50     int i;
51     const char* pstr = temp ? "t" : "";
52    
53     // fixme: PSXM doesn't exist any more.
54     //__Log("%spsxreg: %x %x ra:%x k0: %x %x", pstr, startpc, psxRegs.cycle, psxRegs.GPR.n.ra, psxRegs.GPR.n.k0, *(int*)PSXM(0x13c128));
55    
56     for(i = 0; i < 34; i+=2) __Log("%spsx%s: %x %x", pstr, disRNameGPR[i], psxRegs.GPR.r[i], psxRegs.GPR.r[i+1]);
57    
58 william 62 DbgCon.WriteLn("%scycle: %x %x %x; counters %x %x", pstr, psxRegs.cycle, g_iopNextEventCycle, EEsCycle,
59 william 31 psxNextsCounter, psxNextCounter);
60    
61     DbgCon.WriteLn(wxsFormat(L"psxdma%d ", 2) + hw_dma(2).desc());
62     DbgCon.WriteLn(wxsFormat(L"psxdma%d ", 3) + hw_dma(3).desc());
63     DbgCon.WriteLn(wxsFormat(L"psxdma%d ", 4) + hw_dma(4).desc());
64     DbgCon.WriteLn(wxsFormat(L"psxdma%d ", 6) + hw_dma(6).desc());
65     DbgCon.WriteLn(wxsFormat(L"psxdma%d ", 7) + hw_dma(7).desc());
66     DbgCon.WriteLn(wxsFormat(L"psxdma%d ", 8) + hw_dma(8).desc());
67     DbgCon.WriteLn(wxsFormat(L"psxdma%d ", 9) + hw_dma(9).desc());
68     DbgCon.WriteLn(wxsFormat(L"psxdma%d ", 10) + hw_dma(10).desc());
69     DbgCon.WriteLn(wxsFormat(L"psxdma%d ", 11) + hw_dma(11).desc());
70     DbgCon.WriteLn(wxsFormat(L"psxdma%d ", 12) + hw_dma(12).desc());
71    
72     for(i = 0; i < 7; ++i)
73     DbgCon.WriteLn("%scounter%d: mode %x count %I64x rate %x scycle %x target %I64x", pstr, i, psxCounters[i].mode, psxCounters[i].count, psxCounters[i].rate, psxCounters[i].sCycleT, psxCounters[i].target);
74     #endif
75     }
76    
77     void iDumpRegisters(u32 startpc, u32 temp)
78     {
79     // [TODO] fixme : this code is broken and has no labels. Needs a rewrite to be useful.
80    
81     #ifdef TEST_BROKEN_DUMP_ROUTINES
82    
83     int i;
84     const char* pstr;// = temp ? "t" : "";
85     const u32 dmacs[] = {0x8000, 0x9000, 0xa000, 0xb000, 0xb400, 0xc000, 0xc400, 0xc800, 0xd000, 0xd400 };
86     const char* psymb;
87    
88     if (temp)
89     pstr = "t";
90     else
91     pstr = "";
92    
93     psymb = disR5900GetSym(startpc);
94    
95     if( psymb != NULL )
96     __Log("%sreg(%s): %x %x c:%x", pstr, psymb, startpc, cpuRegs.interrupt, cpuRegs.cycle);
97     else
98     __Log("%sreg: %x %x c:%x", pstr, startpc, cpuRegs.interrupt, cpuRegs.cycle);
99    
100     for(i = 1; i < 32; ++i) __Log("%s: %x_%x_%x_%x", disRNameGPR[i], cpuRegs.GPR.r[i].UL[3], cpuRegs.GPR.r[i].UL[2], cpuRegs.GPR.r[i].UL[1], cpuRegs.GPR.r[i].UL[0]);
101    
102     //for(i = 0; i < 32; i+=4) __Log("cp%d: %x_%x_%x_%x", i, cpuRegs.CP0.r[i], cpuRegs.CP0.r[i+1], cpuRegs.CP0.r[i+2], cpuRegs.CP0.r[i+3]);
103     //for(i = 0; i < 32; ++i) __Log("%sf%d: %f %x", pstr, i, fpuRegs.fpr[i].f, fpuRegs.fprc[i]);
104     //for(i = 1; i < 32; ++i) __Log("%svf%d: %f %f %f %f, vi: %x", pstr, i, VU0.VF[i].F[3], VU0.VF[i].F[2], VU0.VF[i].F[1], VU0.VF[i].F[0], VU0.VI[i].UL);
105    
106     for(i = 0; i < 32; ++i) __Log("%sf%d: %x %x", pstr, i, fpuRegs.fpr[i].UL, fpuRegs.fprc[i]);
107     for(i = 1; i < 32; ++i) __Log("%svf%d: %x %x %x %x, vi: %x", pstr, i, VU0.VF[i].UL[3], VU0.VF[i].UL[2], VU0.VF[i].UL[1], VU0.VF[i].UL[0], VU0.VI[i].UL);
108    
109     __Log("%svfACC: %x %x %x %x", pstr, VU0.ACC.UL[3], VU0.ACC.UL[2], VU0.ACC.UL[1], VU0.ACC.UL[0]);
110     __Log("%sLO: %x_%x_%x_%x, HI: %x_%x_%x_%x", pstr, cpuRegs.LO.UL[3], cpuRegs.LO.UL[2], cpuRegs.LO.UL[1], cpuRegs.LO.UL[0],
111     cpuRegs.HI.UL[3], cpuRegs.HI.UL[2], cpuRegs.HI.UL[1], cpuRegs.HI.UL[0]);
112 william 62 __Log("%sCycle: %x %x, Count: %x", pstr, cpuRegs.cycle, g_nextEventCycle, cpuRegs.CP0.n.Count);
113 william 31
114     iDumpPsxRegisters(psxRegs.pc, temp);
115    
116     __Log("f410,30,40: %x %x %x, %d %d", psHu32(0xf410), psHu32(0xf430), psHu32(0xf440), rdram_sdevid, rdram_devices);
117     __Log("cyc11: %x %x; vu0: %x, vu1: %x", cpuRegs.sCycle[1], cpuRegs.eCycle[1], VU0.cycle, VU1.cycle);
118    
119     __Log("%scounters: %x %x; psx: %x %x", pstr, nextsCounter, nextCounter, psxNextsCounter, psxNextCounter);
120    
121     // fixme: The members of the counters[i] struct are wrong here.
122     /*for(i = 0; i < 4; ++i) {
123     __Log("eetimer%d: count: %x mode: %x target: %x %x; %x %x; %x %x %x %x", i,
124     counters[i].count, counters[i].mode, counters[i].target, counters[i].hold, counters[i].rate,
125     counters[i].interrupt, counters[i].Cycle, counters[i].sCycle, counters[i].CycleT, counters[i].sCycleT);
126     }*/
127     __Log("VIF0_STAT = %x, VIF1_STAT = %x", psHu32(0x3800), psHu32(0x3C00));
128     __Log("ipu %x %x %x %x; bp: %x %x %x %x", psHu32(0x2000), psHu32(0x2010), psHu32(0x2020), psHu32(0x2030), g_BP.BP, g_BP.bufferhasnew, g_BP.FP, g_BP.IFC);
129     __Log("gif: %x %x %x", psHu32(0x3000), psHu32(0x3010), psHu32(0x3020));
130    
131     for(i = 0; i < ArraySize(dmacs); ++i) {
132 william 62 DMACh* p = (DMACh*)(&eeHw[dmacs[i]]);
133 william 31 __Log("dma%d c%x m%x q%x t%x s%x", i, p->chcr._u32, p->madr, p->qwc, p->tadr, p->sadr);
134     }
135 william 62 __Log(L"dmac " + dmacRegs.ctrl.desc() + L" " + dmacRegs.stat.desc() + L" " + dmacRegs.rbsr.desc() + L" " + dmacRegs.rbor.desc());
136 william 31 __Log(L"intc " + intcRegs->stat.desc() + L" " + intcRegs->mask.desc());
137     __Log("sif: %x %x %x %x %x", psHu32(SBUS_F200), psHu32(SBUS_F220), psHu32(SBUS_F230), psHu32(SBUS_F240), psHu32(SBUS_F260));
138     #endif
139     }
140    
141     void iDumpVU0Registers()
142     {
143     // fixme: This code is outdated, broken, and lacks printed labels.
144     // Needs heavy mods to be useful.
145     #ifdef TEST_BROKEN_DUMP_ROUTINES
146     for(int i = 1; i < 32; ++i) {
147     __Log("v%d: %x %x %x %x, vi: ", i, VF_VAL(VU0.VF[i].UL[3]), VF_VAL(VU0.VF[i].UL[2]),
148     VF_VAL(VU0.VF[i].UL[1]), VF_VAL(VU0.VF[i].UL[0]));
149    
150     switch (i)
151     {
152     case REG_Q:
153     case REG_P:
154     __Log("%f", VU0.VI[i].F);
155     break;
156     case REG_MAC_FLAG:
157     __Log("%x", 0);//VU0.VI[i].UL&0xff);
158     break;
159     case REG_STATUS_FLAG:
160     __Log("%x", 0);//VU0.VI[i].UL&0x03);
161     break;
162     case REG_CLIP_FLAG:
163     __Log("0");
164     break;
165     default:
166     __Log("%x", VU0.VI[i].UL);
167     break;
168     }
169     }
170     __Log("vfACC: %f %f %f %f\n", VU0.ACC.F[3], VU0.ACC.F[2], VU0.ACC.F[1], VU0.ACC.F[0]);
171     #endif
172     }
173    
174     void iDumpVU1Registers()
175     {
176     // fixme: This code is outdated, broken, and lacks printed labels.
177     // Needs heavy mods to be useful.
178     #ifdef TEST_BROKEN_DUMP_ROUTINES
179     int i;
180    
181     // static int icount = 0;
182     // __Log("%x\n", icount);
183    
184     for(i = 1; i < 32; ++i) {
185    
186     // __Log("v%d: w%f(%x) z%f(%x) y%f(%x) x%f(%x), vi: ", i, VU1.VF[i].F[3], VU1.VF[i].UL[3], VU1.VF[i].F[2], VU1.VF[i].UL[2],
187     // VU1.VF[i].F[1], VU1.VF[i].UL[1], VU1.VF[i].F[0], VU1.VF[i].UL[0]);
188     //__Log("v%d: %f %f %f %f, vi: ", i, VU1.VF[i].F[3], VU1.VF[i].F[2], VU1.VF[i].F[1], VU1.VF[i].F[0]);
189    
190     __Log("v%d: %x %x %x %x, vi: ", i, VF_VAL(VU1.VF[i].UL[3]), VF_VAL(VU1.VF[i].UL[2]), VF_VAL(VU1.VF[i].UL[1]), VF_VAL(VU1.VF[i].UL[0]));
191    
192     if( i == REG_Q || i == REG_P ) __Log("%f\n", VU1.VI[i].F);
193     //else __Log("%x\n", VU1.VI[i].UL);
194     else __Log("%x\n", (i==REG_STATUS_FLAG||i==REG_MAC_FLAG||i==REG_CLIP_FLAG)?0:VU1.VI[i].UL);
195     }
196     __Log("vfACC: %f %f %f %f\n", VU1.ACC.F[3], VU1.ACC.F[2], VU1.ACC.F[1], VU1.ACC.F[0]);
197     #endif
198     }
199    
200     // Originally from iR5900-32.cpp
201     void iDumpBlock( int startpc, u8 * ptr )
202     {
203     u8 used[34];
204     u8 fpuused[33];
205     int numused, fpunumused;
206    
207     DbgCon.WriteLn( Color_Gray, "dump1 %x:%x, %x", startpc, pc, cpuRegs.cycle );
208    
209     g_Conf->Folders.Logs.Mkdir();
210     AsciiFile eff(
211     Path::Combine( g_Conf->Folders.Logs, wxsFormat(L"R5900dump%.8X.txt", startpc) ), L"w"
212     );
213    
214     if( disR5900GetSym(startpc) != NULL )
215     {
216     eff.Printf( disR5900GetSym( startpc ) );
217     eff.Printf( "\n" );
218     }
219    
220     for ( uint i = startpc; i < s_nEndBlock; i += 4 )
221     {
222     string output;
223     disR5900Fasm( output, memRead32( i ), i );
224     eff.Printf( output.c_str() );
225     }
226    
227     // write the instruction info
228    
229     eff.Printf( "\n\nlive0 - %x, live2 - %x, lastuse - %x\nxmm - %x, used - %x\n",
230     EEINST_LIVE0, EEINST_LIVE2, EEINST_LASTUSE, EEINST_XMM, EEINST_USED
231     );
232    
233     memzero(used);
234     numused = 0;
235     for(uint i = 0; i < ArraySize(s_pInstCache->regs); ++i) {
236     if( s_pInstCache->regs[i] & EEINST_USED ) {
237     used[i] = 1;
238     numused++;
239     }
240     }
241    
242     memzero(fpuused);
243     fpunumused = 0;
244     for(uint i = 0; i < ArraySize(s_pInstCache->fpuregs); ++i) {
245     if( s_pInstCache->fpuregs[i] & EEINST_USED ) {
246     fpuused[i] = 1;
247     fpunumused++;
248     }
249     }
250    
251     eff.Printf( " " );
252     for(uint i = 0; i < ArraySize(s_pInstCache->regs); ++i) {
253     if( used[i] ) eff.Printf( "%2d ", i );
254     }
255     eff.Printf( "\n" );
256     for(uint i = 0; i < ArraySize(s_pInstCache->fpuregs); ++i) {
257     if( fpuused[i] ) eff.Printf( "%2d ", i );
258     }
259    
260     eff.Printf( "\n" );
261     eff.Printf( " " );
262    
263     // TODO : Finish converting this over to wxWidgets wxFile stuff...
264     /*
265     int count;
266     EEINST* pcur;
267    
268     for(uint i = 0; i < ArraySize(s_pInstCache->regs); ++i) {
269     if( used[i] ) fprintf(f, "%s ", disRNameGPR[i]);
270     }
271     for(uint i = 0; i < ArraySize(s_pInstCache->fpuregs); ++i) {
272     if( fpuused[i] ) fprintf(f, "%s ", i<32?"FR":"FA");
273     }
274     fprintf(f, "\n");
275    
276     pcur = s_pInstCache+1;
277     for( uint i = 0; i < (s_nEndBlock-startpc)/4; ++i, ++pcur) {
278     fprintf(f, "%2d: %2.2x ", i+1, pcur->info);
279    
280     count = 1;
281     for(uint j = 0; j < ArraySize(s_pInstCache->regs); j++) {
282     if( used[j] ) {
283     fprintf(f, "%2.2x%s", pcur->regs[j], ((count%8)&&count<numused)?"_":" ");
284     ++count;
285     }
286     }
287     count = 1;
288     for(uint j = 0; j < ArraySize(s_pInstCache->fpuregs); j++) {
289     if( fpuused[j] ) {
290     fprintf(f, "%2.2x%s", pcur->fpuregs[j], ((count%8)&&count<fpunumused)?"_":" ");
291     ++count;
292     }
293     }
294     fprintf(f, "\n");
295     }
296     fclose( f );*/
297     }

  ViewVC Help
Powered by ViewVC 1.1.22