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