mirror of https://github.com/PCSX2/pcsx2.git
DEV9: Tweak logging to ease debugging
This commit is contained in:
parent
e0da758d1b
commit
d32b583b3e
|
@ -84,8 +84,6 @@ u8 eeprom[] = {
|
||||||
};
|
};
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
u32* iopPC;
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
HANDLE hEeprom;
|
HANDLE hEeprom;
|
||||||
HANDLE mapping;
|
HANDLE mapping;
|
||||||
|
@ -98,16 +96,20 @@ std::string s_strIniPath = "inis";
|
||||||
std::string s_strLogPath = "logs";
|
std::string s_strLogPath = "logs";
|
||||||
// Warning: The below log function is SLOW. Better fix it before attempting to use it.
|
// Warning: The below log function is SLOW. Better fix it before attempting to use it.
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
int Log = 1;
|
int logFile = 1;
|
||||||
#else
|
#else
|
||||||
int Log = 0;
|
int logFile = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void __Log(char* fmt, ...)
|
void __Log(int level, const char* fmt, ...)
|
||||||
{
|
{
|
||||||
if (!Log)
|
static char buffer[1024];
|
||||||
|
|
||||||
|
if (level < DEV9_LOG_LEVEL)
|
||||||
return;
|
return;
|
||||||
va_list list;
|
|
||||||
|
va_list list1;
|
||||||
|
va_list list2;
|
||||||
|
|
||||||
static int ticks = -1;
|
static int ticks = -1;
|
||||||
int nticks = GetTickCount();
|
int nticks = GetTickCount();
|
||||||
|
@ -115,35 +117,40 @@ void __Log(char* fmt, ...)
|
||||||
if (ticks == -1)
|
if (ticks == -1)
|
||||||
ticks = nticks;
|
ticks = nticks;
|
||||||
|
|
||||||
if (iopPC != NULL)
|
if (logFile)
|
||||||
{
|
|
||||||
DEV9Log.Write("[%10d + %4d, IOP PC = %08x] ", nticks, nticks - ticks, *iopPC);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
DEV9Log.Write("[%10d + %4d] ", nticks, nticks - ticks);
|
DEV9Log.Write("[%10d + %4d] ", nticks, nticks - ticks);
|
||||||
}
|
|
||||||
ticks = nticks;
|
ticks = nticks;
|
||||||
|
|
||||||
va_start(list, fmt);
|
if (logFile)
|
||||||
DEV9Log.Write(fmt, list);
|
{
|
||||||
va_end(list);
|
va_start(list1, fmt);
|
||||||
|
//PSELog has no vargs method
|
||||||
|
//use tmp buffer
|
||||||
|
vsnprintf(buffer, 1024, fmt, list1);
|
||||||
|
DEV9Log.Write(buffer);
|
||||||
|
va_end(list1);
|
||||||
|
}
|
||||||
|
|
||||||
|
va_start(list2, fmt);
|
||||||
|
emu_vprintf(fmt, list2);
|
||||||
|
va_end(list2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LogInit()
|
void LogInit()
|
||||||
{
|
{
|
||||||
const std::string LogFile(s_strLogPath + "/dev9Log.txt");
|
const std::string LogFile(s_strLogPath + "/dev9Log.txt");
|
||||||
|
if (logFile)
|
||||||
|
{
|
||||||
DEV9Log.WriteToFile = true;
|
DEV9Log.WriteToFile = true;
|
||||||
DEV9Log.Open(LogFile);
|
DEV9Log.Open(LogFile);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 DEV9init()
|
s32 DEV9init()
|
||||||
{
|
{
|
||||||
|
|
||||||
#ifdef DEV9_LOG_ENABLE
|
|
||||||
LogInit();
|
LogInit();
|
||||||
DEV9_LOG("DEV9init\n");
|
DEV9_LOG("DEV9init\n");
|
||||||
#endif
|
|
||||||
memset(&dev9, 0, sizeof(dev9));
|
memset(&dev9, 0, sizeof(dev9));
|
||||||
DEV9_LOG("DEV9init2\n");
|
DEV9_LOG("DEV9init2\n");
|
||||||
|
|
||||||
|
@ -223,9 +230,9 @@ s32 DEV9init()
|
||||||
void DEV9shutdown()
|
void DEV9shutdown()
|
||||||
{
|
{
|
||||||
DEV9_LOG("DEV9shutdown\n");
|
DEV9_LOG("DEV9shutdown\n");
|
||||||
#ifdef DEV9_LOG_ENABLE
|
|
||||||
|
if (logFile)
|
||||||
DEV9Log.Close();
|
DEV9Log.Close();
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 DEV9open(void* pDsp)
|
s32 DEV9open(void* pDsp)
|
||||||
|
@ -235,8 +242,6 @@ s32 DEV9open(void* pDsp)
|
||||||
DEV9_LOG("open r+: %s\n", config.Hdd);
|
DEV9_LOG("open r+: %s\n", config.Hdd);
|
||||||
config.HddSize = 8 * 1024;
|
config.HddSize = 8 * 1024;
|
||||||
|
|
||||||
iopPC = (u32*)pDsp;
|
|
||||||
|
|
||||||
#ifdef ENABLE_ATA
|
#ifdef ENABLE_ATA
|
||||||
ata_init();
|
ata_init();
|
||||||
#endif
|
#endif
|
||||||
|
@ -802,3 +807,11 @@ int emu_printf(const char* fmt, ...)
|
||||||
fflush(stderr);
|
fflush(stderr);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int emu_vprintf(const char* fmt, va_list vl)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
ret = vfprintf(stderr, fmt, vl);
|
||||||
|
fflush(stderr);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
|
@ -41,14 +41,18 @@
|
||||||
#define __inline inline
|
#define __inline inline
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
// clang-format off
|
||||||
|
#define DEV_LOG_LEVEL_VERBOSE 1
|
||||||
|
#define DEV_LOG_LEVEL_INFO 2
|
||||||
|
#define DEV_LOG_LEVEL_ERROR 3
|
||||||
|
|
||||||
//#define DEV9_LOG_ENABLE
|
#define DEV9_LOG_LEVEL DEV_LOG_LEVEL_INFO
|
||||||
|
|
||||||
#ifdef DEV9_LOG_ENABLE
|
#define DEV9_LOG(...) __Log(DEV_LOG_LEVEL_VERBOSE,__VA_ARGS__)
|
||||||
#define DEV9_LOG __Log
|
#define DEV9_LOG_VERB(...) __Log(DEV_LOG_LEVEL_VERBOSE,__VA_ARGS__)
|
||||||
#else
|
#define DEV9_LOG_INFO(...) __Log(DEV_LOG_LEVEL_INFO, __VA_ARGS__)
|
||||||
#define DEV9_LOG(...)
|
#define DEV9_LOG_ERROR(...) __Log(DEV_LOG_LEVEL_ERROR, __VA_ARGS__)
|
||||||
#endif
|
// clang-format on
|
||||||
|
|
||||||
void rx_process(NetPacket* pk);
|
void rx_process(NetPacket* pk);
|
||||||
bool rx_fifo_can_rx();
|
bool rx_fifo_can_rx();
|
||||||
|
@ -130,7 +134,7 @@ EXTERN PluginLog DEV9Log;
|
||||||
//Yes these are meant to be a lowercase extern
|
//Yes these are meant to be a lowercase extern
|
||||||
extern std::string s_strIniPath;
|
extern std::string s_strIniPath;
|
||||||
extern std::string s_strLogPath;
|
extern std::string s_strLogPath;
|
||||||
void __Log(char* fmt, ...);
|
void __Log(int level, const char* fmt, ...);
|
||||||
|
|
||||||
void SysMessage(char* fmt, ...);
|
void SysMessage(char* fmt, ...);
|
||||||
|
|
||||||
|
@ -718,6 +722,7 @@ void DEV9write16(u32 addr, u16 value);
|
||||||
void DEV9write32(u32 addr, u32 value);
|
void DEV9write32(u32 addr, u32 value);
|
||||||
|
|
||||||
int emu_printf(const char* fmt, ...);
|
int emu_printf(const char* fmt, ...);
|
||||||
|
int emu_vprintf(const char* fmt, va_list);
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#pragma warning(error : 4013)
|
#pragma warning(error : 4013)
|
||||||
|
|
Loading…
Reference in New Issue