Here comes the new debug code...
there's good chance that I just broke the cocoa and windows frontends, sorry about that.
This commit is contained in:
parent
9575c907a7
commit
ffc9f0284f
|
@ -50,6 +50,7 @@
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "render3D.h"
|
#include "render3D.h"
|
||||||
#include "GPU_osd.h"
|
#include "GPU_osd.h"
|
||||||
|
#include "debug.h"
|
||||||
|
|
||||||
ARM9_struct ARM9Mem;
|
ARM9_struct ARM9Mem;
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#include "mem.h"
|
#include "mem.h"
|
||||||
#include <string.h> //mem funcs
|
#include <string.h> //mem funcs
|
||||||
#include <stdarg.h> //va_start, etc
|
#include <stdarg.h> //va_start, etc
|
||||||
|
#include "debug.h"
|
||||||
|
|
||||||
#include "softrender.h"
|
#include "softrender.h"
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
#define __GPU_OSD_
|
#define __GPU_OSD_
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "debug.h"
|
#include "types.h"
|
||||||
|
|
||||||
#define OSD_MAX_LINES 10
|
#define OSD_MAX_LINES 10
|
||||||
|
|
||||||
|
|
|
@ -90,7 +90,7 @@ void mmu_log_debug(u32 adr, u8 proc, const char *fmt, ...)
|
||||||
_vsnprintf(msg,511,fmt,list);
|
_vsnprintf(msg,511,fmt,list);
|
||||||
va_end(list);
|
va_end(list);
|
||||||
|
|
||||||
printlog("MMU ARM%s 0x%08X: %s\n",proc==ARMCPU_ARM9?"9":"7",adr, msg);
|
LOG("MMU ARM%s 0x%08X: %s\n",proc==ARMCPU_ARM9?"9":"7",adr, msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
@ -234,7 +234,6 @@ void MMU_Init(void) {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
LOG("MMU init\n");
|
LOG("MMU init\n");
|
||||||
//printlog("MMU init\n");
|
|
||||||
|
|
||||||
memset(&MMU, 0, sizeof(MMU_struct));
|
memset(&MMU, 0, sizeof(MMU_struct));
|
||||||
|
|
||||||
|
@ -747,7 +746,6 @@ u8 FASTCALL _MMU_read8(u32 adr)
|
||||||
|
|
||||||
if(proc==ARMCPU_ARM9 && adr<0x02000000)
|
if(proc==ARMCPU_ARM9 && adr<0x02000000)
|
||||||
{
|
{
|
||||||
//printlog("MMU ITCM (08) Read %08X: %08X\n", adr, T1ReadByte(ARM9Mem.ARM9_ITCM, adr&0x7FFF));
|
|
||||||
return T1ReadByte(ARM9Mem.ARM9_ITCM, adr&0x7FFF);
|
return T1ReadByte(ARM9Mem.ARM9_ITCM, adr&0x7FFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -786,7 +784,6 @@ u16 FASTCALL _MMU_read16(u32 adr)
|
||||||
#endif
|
#endif
|
||||||
if(proc==ARMCPU_ARM9 && adr<0x02000000)
|
if(proc==ARMCPU_ARM9 && adr<0x02000000)
|
||||||
{
|
{
|
||||||
//printlog("MMU ITCM (16) Read %08X: %08X\n", adr, T1ReadWord(ARM9Mem.ARM9_ITCM, adr&0x7FFF));
|
|
||||||
return T1ReadWord(ARM9Mem.ARM9_ITCM, adr&0x7FFF);
|
return T1ReadWord(ARM9Mem.ARM9_ITCM, adr&0x7FFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -813,8 +810,7 @@ u16 FASTCALL _MMU_read16(u32 adr)
|
||||||
return (gfx3d_GetNumVertex()&8191);
|
return (gfx3d_GetNumVertex()&8191);
|
||||||
|
|
||||||
case REG_IPCFIFORECV : /* TODO (clear): ??? */
|
case REG_IPCFIFORECV : /* TODO (clear): ??? */
|
||||||
printlog("MMU read16: IPCFIFORECV\n");
|
LOG("MMU read16: IPCFIFORECV\n");
|
||||||
//printlog("Stopped IPCFIFORECV\n");
|
|
||||||
execute = FALSE;
|
execute = FALSE;
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
@ -827,10 +823,8 @@ u16 FASTCALL _MMU_read16(u32 adr)
|
||||||
return (u16)(MMU.reg_IE[proc]>>16);
|
return (u16)(MMU.reg_IE[proc]>>16);
|
||||||
|
|
||||||
case REG_IF :
|
case REG_IF :
|
||||||
//printlog("MMU read16 (low): REG_IF\n");
|
|
||||||
return (u16)MMU.reg_IF[proc];
|
return (u16)MMU.reg_IF[proc];
|
||||||
case REG_IF + 2 :
|
case REG_IF + 2 :
|
||||||
//printlog("MMU read16 (high): REG_IF\n");
|
|
||||||
return (u16)(MMU.reg_IF[proc]>>16);
|
return (u16)(MMU.reg_IF[proc]>>16);
|
||||||
|
|
||||||
case REG_TM0CNTL :
|
case REG_TM0CNTL :
|
||||||
|
@ -868,7 +862,6 @@ u32 FASTCALL _MMU_read32(u32 adr)
|
||||||
|
|
||||||
if(proc==ARMCPU_ARM9 && adr<0x02000000)
|
if(proc==ARMCPU_ARM9 && adr<0x02000000)
|
||||||
{
|
{
|
||||||
//printlog("MMU ITCM (32) Read %08X: %08X\n", adr, T1ReadLong(ARM9Mem.ARM9_ITCM, adr&0x7FFF));
|
|
||||||
return T1ReadLong(ARM9Mem.ARM9_ITCM, adr&0x7FFF);
|
return T1ReadLong(ARM9Mem.ARM9_ITCM, adr&0x7FFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -939,12 +932,10 @@ u32 FASTCALL _MMU_read32(u32 adr)
|
||||||
case REG_IE :
|
case REG_IE :
|
||||||
return MMU.reg_IE[proc];
|
return MMU.reg_IE[proc];
|
||||||
case REG_IF :
|
case REG_IF :
|
||||||
//printlog("MMU read32: REG_IF\n");
|
|
||||||
return MMU.reg_IF[proc];
|
return MMU.reg_IF[proc];
|
||||||
case REG_IPCFIFORECV :
|
case REG_IPCFIFORECV :
|
||||||
{
|
{
|
||||||
u16 cnt_l = T1ReadWord(MMU.MMU_MEM[proc][0x40], 0x184);
|
u16 cnt_l = T1ReadWord(MMU.MMU_MEM[proc][0x40], 0x184);
|
||||||
//printlog("MMU read32: REG_IPCFIFORECV (%X)\n", cnt_l);
|
|
||||||
if (!(cnt_l & 0x8000)) return 0; // FIFO disabled
|
if (!(cnt_l & 0x8000)) return 0; // FIFO disabled
|
||||||
u16 cnt_r = T1ReadWord(MMU.MMU_MEM[proc^1][0x40], 0x184);
|
u16 cnt_r = T1ReadWord(MMU.MMU_MEM[proc^1][0x40], 0x184);
|
||||||
u32 val = FIFOget(&MMU.fifos[proc]);
|
u32 val = FIFOget(&MMU.fifos[proc]);
|
||||||
|
@ -1031,7 +1022,6 @@ void FASTCALL _MMU_write8(u32 adr, u8 val)
|
||||||
#endif
|
#endif
|
||||||
if(proc==ARMCPU_ARM9 && adr<0x02000000)
|
if(proc==ARMCPU_ARM9 && adr<0x02000000)
|
||||||
{
|
{
|
||||||
//printlog("MMU ITCM (08) Write %08X: %08X\n", adr, val);
|
|
||||||
T1WriteByte(ARM9Mem.ARM9_ITCM, adr&0x7FFF, val);
|
T1WriteByte(ARM9Mem.ARM9_ITCM, adr&0x7FFF, val);
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
@ -1428,7 +1418,6 @@ void FASTCALL _MMU_write16(u32 adr, u16 val)
|
||||||
#endif
|
#endif
|
||||||
if(proc==ARMCPU_ARM9 && adr<0x02000000)
|
if(proc==ARMCPU_ARM9 && adr<0x02000000)
|
||||||
{
|
{
|
||||||
//printlog("MMU ITCM (16) Write %08X: %08X\n", adr, val);
|
|
||||||
T1WriteWord(ARM9Mem.ARM9_ITCM, adr&0x7FFF, val);
|
T1WriteWord(ARM9Mem.ARM9_ITCM, adr&0x7FFF, val);
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
@ -1852,11 +1841,9 @@ void FASTCALL _MMU_write16(u32 adr, u16 val)
|
||||||
|
|
||||||
case REG_IF :
|
case REG_IF :
|
||||||
//execute = FALSE;
|
//execute = FALSE;
|
||||||
//printlog("MMU write16 (low): REG_IF (%X)\n", val);
|
|
||||||
MMU.reg_IF[proc] &= (~((u32)val));
|
MMU.reg_IF[proc] &= (~((u32)val));
|
||||||
return;
|
return;
|
||||||
case REG_IF + 2 :
|
case REG_IF + 2 :
|
||||||
//printlog("MMU write16 (high): REG_IF (%X)\n", val);
|
|
||||||
//execute = FALSE;
|
//execute = FALSE;
|
||||||
MMU.reg_IF[proc] &= (~(((u32)val)<<16));
|
MMU.reg_IF[proc] &= (~(((u32)val)<<16));
|
||||||
return;
|
return;
|
||||||
|
@ -1877,8 +1864,6 @@ void FASTCALL _MMU_write16(u32 adr, u16 val)
|
||||||
u32 cnt_l = T1ReadWord(MMU.MMU_MEM[proc][0x40], 0x184) ;
|
u32 cnt_l = T1ReadWord(MMU.MMU_MEM[proc][0x40], 0x184) ;
|
||||||
u32 cnt_r = T1ReadWord(MMU.MMU_MEM[proc^1][0x40], 0x184) ;
|
u32 cnt_r = T1ReadWord(MMU.MMU_MEM[proc^1][0x40], 0x184) ;
|
||||||
|
|
||||||
//printlog("MMU write16 (%s): REG_IPCFIFOCNT 0x(%08X)\n", proc?"ARM9":"ARM7",REG_IPCFIFOCNT);
|
|
||||||
//printlog(" --- val=%X\n",val);
|
|
||||||
|
|
||||||
if ((val & 0x8000) && !(cnt_l & 0x8000))
|
if ((val & 0x8000) && !(cnt_l & 0x8000))
|
||||||
{
|
{
|
||||||
|
@ -2102,7 +2087,6 @@ void FASTCALL _MMU_write32(u32 adr, u32 val)
|
||||||
#endif
|
#endif
|
||||||
if(proc==ARMCPU_ARM9 && adr<0x02000000)
|
if(proc==ARMCPU_ARM9 && adr<0x02000000)
|
||||||
{
|
{
|
||||||
//printlog("MMU ITCM (32) Write %08X: %08X\n", adr, val);
|
|
||||||
T1WriteLong(ARM9Mem.ARM9_ITCM, adr&0x7FFF, val);
|
T1WriteLong(ARM9Mem.ARM9_ITCM, adr&0x7FFF, val);
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
@ -2543,7 +2527,6 @@ void FASTCALL _MMU_write32(u32 adr, u32 val)
|
||||||
|
|
||||||
case 0x04000600: // Geometry Engine Status Register (R and R/W)
|
case 0x04000600: // Geometry Engine Status Register (R and R/W)
|
||||||
{
|
{
|
||||||
//printlog("MMU write32: Geometry Engine Status Register (R and R/W)\n");
|
|
||||||
MMU.fifos[proc].irq = (val>>30) & 0x03;
|
MMU.fifos[proc].irq = (val>>30) & 0x03;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -2687,7 +2670,6 @@ void FASTCALL _MMU_write32(u32 adr, u32 val)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case REG_IF :
|
case REG_IF :
|
||||||
//printlog("MMU write32: REG_IF (%X)\n", val);
|
|
||||||
MMU.reg_IF[proc] &= (~val);
|
MMU.reg_IF[proc] &= (~val);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -2884,7 +2866,7 @@ void FASTCALL _MMU_write32(u32 adr, u32 val)
|
||||||
case REG_IPCSYNC :
|
case REG_IPCSYNC :
|
||||||
{
|
{
|
||||||
//execute=FALSE;
|
//execute=FALSE;
|
||||||
printlog("MMU write 32 IPCSYNC\n");
|
LOG("MMU write 32 IPCSYNC\n");
|
||||||
u32 remote = (proc+1)&1;
|
u32 remote = (proc+1)&1;
|
||||||
u32 IPCSYNC_remote = T1ReadLong(MMU.MMU_MEM[remote][0x40], 0x180);
|
u32 IPCSYNC_remote = T1ReadLong(MMU.MMU_MEM[remote][0x40], 0x180);
|
||||||
T1WriteLong(MMU.MMU_MEM[proc][0x40], 0x180, (val&0xFFF0)|((IPCSYNC_remote>>8)&0xF));
|
T1WriteLong(MMU.MMU_MEM[proc][0x40], 0x180, (val&0xFFF0)|((IPCSYNC_remote>>8)&0xF));
|
||||||
|
@ -2915,7 +2897,7 @@ void FASTCALL _MMU_write32(u32 adr, u32 val)
|
||||||
}
|
}
|
||||||
T1WriteWord(MMU.MMU_MEM[proc][0x40], 0x184, val & 0xBFF4);
|
T1WriteWord(MMU.MMU_MEM[proc][0x40], 0x184, val & 0xBFF4);
|
||||||
#else
|
#else
|
||||||
printlog("MMU write32: REG_IPCFIFOCNT\n");
|
LOG("MMU write32: REG_IPCFIFOCNT\n");
|
||||||
#endif
|
#endif
|
||||||
//execute = FALSE;
|
//execute = FALSE;
|
||||||
return;
|
return;
|
||||||
|
@ -2925,7 +2907,6 @@ void FASTCALL _MMU_write32(u32 adr, u32 val)
|
||||||
u16 cnt_l = T1ReadWord(MMU.MMU_MEM[proc][0x40], 0x184);
|
u16 cnt_l = T1ReadWord(MMU.MMU_MEM[proc][0x40], 0x184);
|
||||||
if (!(cnt_l & 0x8000)) return; //FIFO disabled
|
if (!(cnt_l & 0x8000)) return; //FIFO disabled
|
||||||
u16 cnt_r = T1ReadWord(MMU.MMU_MEM[proc^1][0x40], 0x184);
|
u16 cnt_r = T1ReadWord(MMU.MMU_MEM[proc^1][0x40], 0x184);
|
||||||
//printlog("MMU write32 (%s): REG_IPCFIFOSEND (%X-%X) val=%X\n", proc?"ARM9":"ARM7",cnt_l,cnt_r,val);
|
|
||||||
//FIFOadd(MMU.fifos+(proc^1), val);
|
//FIFOadd(MMU.fifos+(proc^1), val);
|
||||||
FIFOadd(&MMU.fifos[proc^1], val);
|
FIFOadd(&MMU.fifos[proc^1], val);
|
||||||
cnt_l = (cnt_l & 0xFFFC) | (MMU.fifos[proc^1].full?0x0002:0);
|
cnt_l = (cnt_l & 0xFFFC) | (MMU.fifos[proc^1].full?0x0002:0);
|
||||||
|
@ -3122,7 +3103,7 @@ void FASTCALL _MMU_write32(u32 adr, u32 val)
|
||||||
//Transfer starts at next frame.
|
//Transfer starts at next frame.
|
||||||
//Main Memory Display/Capture is supported for Display Engine A only.
|
//Main Memory Display/Capture is supported for Display Engine A only.
|
||||||
|
|
||||||
printlog("MMU write32: REG_DISPA_DISPMMEMFIFO\n");
|
LOG("MMU write32: REG_DISPA_DISPMMEMFIFO\n");
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -618,9 +618,6 @@ int main(int argc, char ** argv) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef DEBUG
|
|
||||||
LogStart();
|
|
||||||
#endif
|
|
||||||
#ifdef GDB_STUB
|
#ifdef GDB_STUB
|
||||||
NDS_Init( arm9_memio, &arm9_ctrl_iface,
|
NDS_Init( arm9_memio, &arm9_ctrl_iface,
|
||||||
arm7_memio, &arm7_ctrl_iface);
|
arm7_memio, &arm7_ctrl_iface);
|
||||||
|
@ -847,9 +844,5 @@ int main(int argc, char ** argv) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef DEBUG
|
|
||||||
LogStop();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* Copyright 2005 Guillaume Duhamel
|
/* Copyright (C) 2008 Guillaume Duhamel
|
||||||
|
|
||||||
This file is part of DeSmuME.
|
This file is part of DeSmuME
|
||||||
|
|
||||||
DeSmuME is free software; you can redistribute it and/or modify
|
DeSmuME is free software; you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@ -20,140 +20,77 @@
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdlib.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
std::vector<Logger *> Logger::channels;
|
||||||
|
|
||||||
Debug * DebugInit(const char * n, DebugOutType t, char * s) {
|
static void defaultCallback(const Logger& logger, const char * message) {
|
||||||
Debug * d;
|
logger.getOutput() << message;
|
||||||
|
|
||||||
if ((d = (Debug *) malloc(sizeof(Debug))) == NULL)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
d->output_type = t;
|
|
||||||
|
|
||||||
if ((d->name = strdup(n)) == NULL)
|
|
||||||
{
|
|
||||||
free(d);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch(t) {
|
|
||||||
case DEBUG_STREAM:
|
|
||||||
d->output.stream = fopen(s, "w");
|
|
||||||
break;
|
|
||||||
case DEBUG_STRING:
|
|
||||||
d->output.string = s;
|
|
||||||
break;
|
|
||||||
case DEBUG_STDOUT:
|
|
||||||
d->output.stream = stdout;
|
|
||||||
break;
|
|
||||||
case DEBUG_STDERR:
|
|
||||||
d->output.stream = stderr;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return d;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
Logger::Logger() {
|
||||||
|
out = &std::cout;
|
||||||
void DebugDeInit(Debug * d) {
|
callback = defaultCallback;
|
||||||
if (d == NULL)
|
flags = 0;
|
||||||
return;
|
|
||||||
|
|
||||||
switch(d->output_type) {
|
|
||||||
case DEBUG_STREAM:
|
|
||||||
if (d->output.stream)
|
|
||||||
fclose(d->output.stream);
|
|
||||||
break;
|
|
||||||
case DEBUG_STRING:
|
|
||||||
case DEBUG_STDOUT:
|
|
||||||
case DEBUG_STDERR:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (d->name)
|
|
||||||
free(d->name);
|
|
||||||
free(d);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
void Logger::vprintf(const char * format, va_list l, const char * file, unsigned int line) {
|
||||||
|
char buffer[1024];
|
||||||
|
char * cur = buffer;
|
||||||
|
|
||||||
void DebugChangeOutput(Debug * d, DebugOutType t, char * s) {
|
if (flags & Logger::FILE) cur += sprintf(cur, "%s:", file);
|
||||||
if (t != d->output_type) {
|
if (flags & Logger::LINE) cur += sprintf(cur, "%d:", line);
|
||||||
if (d->output_type == DEBUG_STREAM)
|
if (flags) cur += sprintf(cur, " ");
|
||||||
{
|
|
||||||
if (d->output.stream)
|
::vsnprintf(cur, 1024, format, l);
|
||||||
fclose(d->output.stream);
|
callback(*this, buffer);
|
||||||
}
|
}
|
||||||
d->output_type = t;
|
|
||||||
}
|
void Logger::setOutput(std::ostream * out) {
|
||||||
switch(t) {
|
this->out = out;
|
||||||
case DEBUG_STREAM:
|
}
|
||||||
d->output.stream = fopen(s, "w");
|
|
||||||
break;
|
void Logger::setCallback(void (*callback)(const Logger& logger, const char * message)) {
|
||||||
case DEBUG_STRING:
|
this->callback = callback;
|
||||||
d->output.string = s;
|
}
|
||||||
break;
|
|
||||||
case DEBUG_STDOUT:
|
void Logger::setFlag(unsigned int flag) {
|
||||||
d->output.stream = stdout;
|
this->flags = flag;
|
||||||
break;
|
}
|
||||||
case DEBUG_STDERR:
|
|
||||||
d->output.stream = stderr;
|
void Logger::fixSize(unsigned int channel) {
|
||||||
break;
|
while(channel >= channels.size()) {
|
||||||
|
channels.push_back(new Logger());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
std::ostream& Logger::getOutput() const {
|
||||||
|
return *out;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Logger::log(unsigned int channel, const char * file, unsigned int line, const char * format, ...) {
|
||||||
|
fixSize(channel);
|
||||||
|
|
||||||
void DebugPrintf(Debug * d, const char * file, u32 line, const char * format, ...) {
|
|
||||||
va_list l;
|
va_list l;
|
||||||
|
|
||||||
if (d == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
va_start(l, format);
|
va_start(l, format);
|
||||||
|
channels[channel]->vprintf(format, l, file, line);
|
||||||
switch(d->output_type) {
|
|
||||||
case DEBUG_STDOUT:
|
|
||||||
case DEBUG_STDERR:
|
|
||||||
case DEBUG_STREAM:
|
|
||||||
if (d->output.stream == NULL)
|
|
||||||
break;
|
|
||||||
fprintf(d->output.stream, "%s (%s:%ld): ", d->name, file, line);
|
|
||||||
vfprintf(d->output.stream, format, l);
|
|
||||||
break;
|
|
||||||
case DEBUG_STRING:
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
if (d->output.string == NULL)
|
|
||||||
break;
|
|
||||||
|
|
||||||
i = sprintf(d->output.string, "%s (%s:%ld): ", d->name, file, line);
|
|
||||||
vsprintf(d->output.string + i, format, l);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
va_end(l);
|
va_end(l);
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
void Logger::log(unsigned int channel, const char * file, unsigned int line, std::ostream& os) {
|
||||||
|
fixSize(channel);
|
||||||
|
|
||||||
Debug * MainLog;
|
channels[channel]->setOutput(&os);
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
void LogStart(void) {
|
|
||||||
MainLog = DebugInit("main", DEBUG_STDERR, NULL);
|
|
||||||
// MainLog = DebugInit("main", DEBUG_STREAM, "stdout.txt");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
void Logger::log(unsigned int channel, const char * file, unsigned int line, unsigned int flag) {
|
||||||
|
fixSize(channel);
|
||||||
|
|
||||||
void LogStop(void) {
|
channels[channel]->setFlag(flag);
|
||||||
DebugDeInit(MainLog);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
void Logger::log(unsigned int channel, const char * file, unsigned int line, void (*callback)(const Logger& logger, const char * message)) {
|
||||||
|
fixSize(channel);
|
||||||
|
|
||||||
|
channels[channel]->setCallback(callback);
|
||||||
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* Copyright 2005-2006 Guillaume Duhamel
|
/* Copyright (C) 2008 Guillaume Duhamel
|
||||||
|
|
||||||
This file is part of DeSmuME.
|
This file is part of DeSmuME
|
||||||
|
|
||||||
DeSmuME is free software; you can redistribute it and/or modify
|
DeSmuME is free software; you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@ -17,87 +17,63 @@
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef DEBUG_H
|
#ifndef LOGGER_H
|
||||||
#define DEBUG_H
|
#define LOGGER_H
|
||||||
|
|
||||||
#include "types.h"
|
#include <vector>
|
||||||
#include <stdio.h>
|
#include <iostream>
|
||||||
|
|
||||||
#ifdef _WIN32
|
class Logger {
|
||||||
#include "windows/console.h"
|
protected:
|
||||||
#endif
|
void (*callback)(const Logger& logger, const char * format);
|
||||||
|
std::ostream * out;
|
||||||
|
unsigned int flags;
|
||||||
|
|
||||||
#if defined(BETA_VERSION) && defined(WIN32)
|
static std::vector<Logger *> channels;
|
||||||
void OpenConsole();
|
|
||||||
void CloseConsole();
|
|
||||||
void printlog(const char *fmt, ...);
|
|
||||||
#else
|
|
||||||
#define OpenConsole()
|
|
||||||
#define CloseConsole()
|
|
||||||
#define printlog(...)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef enum { DEBUG_STRING, DEBUG_STREAM , DEBUG_STDOUT, DEBUG_STDERR } DebugOutType;
|
static void fixSize(unsigned int channel);
|
||||||
|
public:
|
||||||
|
Logger();
|
||||||
|
|
||||||
typedef struct {
|
void vprintf(const char * format, va_list l, const char * filename, unsigned int line);
|
||||||
DebugOutType output_type;
|
void setOutput(std::ostream * out);
|
||||||
union {
|
void setCallback(void (*callback)(const Logger& logger, const char * message));
|
||||||
FILE * stream;
|
void setFlag(unsigned int flag);
|
||||||
char * string;
|
|
||||||
} output;
|
|
||||||
char * name;
|
|
||||||
} Debug;
|
|
||||||
|
|
||||||
Debug * DebugInit(const char *, DebugOutType, char *);
|
std::ostream& getOutput() const;
|
||||||
void DebugDeInit(Debug *);
|
|
||||||
|
|
||||||
void DebugChangeOutput(Debug *, DebugOutType, char *);
|
static const int LINE = 1;
|
||||||
|
static const int FILE = 2;
|
||||||
|
|
||||||
void DebugPrintf(Debug *, const char *, u32, const char *, ...);
|
static void log(unsigned int channel, const char * file, unsigned int line, const char * format, ...);
|
||||||
|
static void log(unsigned int channel, const char * file, unsigned int line, std::ostream& os);
|
||||||
extern Debug * MainLog;
|
static void log(unsigned int channel, const char * file, unsigned int line, unsigned int flag);
|
||||||
|
static void log(unsigned int channel, const char * file, unsigned int line, void (*callback)(const Logger& logger, const char * message));
|
||||||
void LogStart(void);
|
};
|
||||||
void LogStop(void);
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
#define LOG(...) DebugPrintf(MainLog, __FILE__, __LINE__, __VA_ARGS__)
|
|
||||||
#else
|
#define LOGC(channel, ...) Logger::log(channel, __FILE__, __LINE__, __VA_ARGS__)
|
||||||
#if defined(WIN32) && defined(BETA_VERSION) && defined(OLD_LOG)
|
#define LOG(...) LOGC(0, __VA_ARGS__)
|
||||||
#define LOG(...) printlog(__VA_ARGS__)
|
|
||||||
|
#define GPULOG(...) LOGC(1, __VA_ARGS__)
|
||||||
|
#define DIVLOG(...) LOGC(2, __VA_ARGS__)
|
||||||
|
#define SQRTLOG(...) LOGC(3, __VA_ARGS__)
|
||||||
|
#define DMALOG(...) LOGC(3, __VA_ARGS__)
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
#define LOGC(...)
|
||||||
#define LOG(...)
|
#define LOG(...)
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef GPUDEBUG
|
|
||||||
#define GPULOG(...) DebugPrintf(MainLog, __FILE__, __LINE__, __VA_ARGS__)
|
|
||||||
#else
|
|
||||||
#define GPULOG(...)
|
#define GPULOG(...)
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef DIVDEBUG
|
|
||||||
#define DIVLOG(...) DebugPrintf(MainLog, __FILE__, __LINE__, __VA_ARGS__)
|
|
||||||
#else
|
|
||||||
#define DIVLOG(...)
|
#define DIVLOG(...)
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef SQRTDEBUG
|
|
||||||
#define SQRTLOG(...) DebugPrintf(MainLog, __FILE__, __LINE__, __VA_ARGS__)
|
|
||||||
#else
|
|
||||||
#define SQRTLOG(...)
|
#define SQRTLOG(...)
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CARDDEBUG
|
|
||||||
#define CARDLOG(...) DebugPrintf(MainLog, __FILE__, __LINE__, __VA_ARGS__)
|
|
||||||
#else
|
|
||||||
#define CARDLOG(...)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef DMADEBUG
|
|
||||||
#define DMALOG(...) DebugPrintf(MainLog, __FILE__, __LINE__, __VA_ARGS__)
|
|
||||||
#else
|
|
||||||
#define DMALOG(...)
|
#define DMALOG(...)
|
||||||
#endif
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define INFOC(channel, ...) Logger::log(channel, __FILE__, __LINE__, __VA_ARGS__)
|
||||||
|
#define INFO(...) INFOC(10, __VA_ARGS__)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -394,10 +394,6 @@ common_gtk_glade_main( struct configured_features *my_config) {
|
||||||
//g_thread_init(NULL);
|
//g_thread_init(NULL);
|
||||||
register_gl_fun(my_gl_Begin,my_gl_End);
|
register_gl_fun(my_gl_Begin,my_gl_End);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef DEBUG
|
|
||||||
LogStart();
|
|
||||||
#endif
|
|
||||||
init_keyvals();
|
init_keyvals();
|
||||||
|
|
||||||
#ifdef GDB_STUB
|
#ifdef GDB_STUB
|
||||||
|
@ -555,9 +551,6 @@ common_gtk_glade_main( struct configured_features *my_config) {
|
||||||
SDL_DestroySemaphore( glade_fps_limiter_semaphore);
|
SDL_DestroySemaphore( glade_fps_limiter_semaphore);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG
|
|
||||||
LogStop();
|
|
||||||
#endif
|
|
||||||
/* Unload joystick */
|
/* Unload joystick */
|
||||||
uninit_joy();
|
uninit_joy();
|
||||||
|
|
||||||
|
|
|
@ -1460,10 +1460,6 @@ common_gtk_main( struct configured_features *my_config)
|
||||||
|
|
||||||
bad_glob_cflash_disk_image_file = my_config->cflash_disk_image_file;
|
bad_glob_cflash_disk_image_file = my_config->cflash_disk_image_file;
|
||||||
|
|
||||||
#ifdef DEBUG
|
|
||||||
LogStart();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef GDB_STUB
|
#ifdef GDB_STUB
|
||||||
if ( my_config->arm9_gdb_port != 0) {
|
if ( my_config->arm9_gdb_port != 0) {
|
||||||
arm9_gdb_stub = createStub_gdb( my_config->arm9_gdb_port,
|
arm9_gdb_stub = createStub_gdb( my_config->arm9_gdb_port,
|
||||||
|
@ -1926,9 +1922,6 @@ common_gtk_main( struct configured_features *my_config)
|
||||||
SDL_DestroySemaphore( fps_limiter_semaphore);
|
SDL_DestroySemaphore( fps_limiter_semaphore);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG
|
|
||||||
LogStop();
|
|
||||||
#endif
|
|
||||||
/* Unload joystick */
|
/* Unload joystick */
|
||||||
uninit_joy();
|
uninit_joy();
|
||||||
|
|
||||||
|
|
|
@ -102,7 +102,7 @@ void mc_reset_com(memory_chip_t *mc)
|
||||||
{
|
{
|
||||||
u32 addr, size;
|
u32 addr, size;
|
||||||
|
|
||||||
printlog("autodetectsize = %d\n",mc->autodetectsize);
|
LOG("autodetectsize = %d\n",mc->autodetectsize);
|
||||||
|
|
||||||
if (mc->autodetectsize == (32768+2))
|
if (mc->autodetectsize == (32768+2))
|
||||||
{
|
{
|
||||||
|
|
|
@ -1223,9 +1223,6 @@ int WINAPI WinMain (HINSTANCE hThisInstance,
|
||||||
|
|
||||||
hAccel = LoadAccelerators(hAppInst, MAKEINTRESOURCE(IDR_MAIN_ACCEL));
|
hAccel = LoadAccelerators(hAppInst, MAKEINTRESOURCE(IDR_MAIN_ACCEL));
|
||||||
|
|
||||||
#ifdef DEBUG
|
|
||||||
LogStart();
|
|
||||||
#endif
|
|
||||||
mainMenu = LoadMenu(hThisInstance, "MENU_PRINCIPAL"); //Load Menu, and store handle
|
mainMenu = LoadMenu(hThisInstance, "MENU_PRINCIPAL"); //Load Menu, and store handle
|
||||||
if (!MainWindow->setMenu(mainMenu))
|
if (!MainWindow->setMenu(mainMenu))
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue