fixed crash on linux, added DISCIO logging type, some extra logging messages and some logging cleanup

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2533 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
nakeee 2009-03-03 00:21:08 +00:00
parent 9ef42aefac
commit e9430a0252
4 changed files with 35 additions and 43 deletions

View File

@ -174,6 +174,11 @@ bool CreateFullPath(const char *fullPath)
int panicCounter = 100;
INFO_LOG(COMMON, "CreateFullPath: path %s\n", fullPath);
if (File::Exists(fullPath)) {
INFO_LOG(COMMON, "CreateFullPath: path exists %s\n", fullPath);
return true;
}
const char *position = fullPath;
while (true) {
// Find next sub path, support both \ and / directory separators
@ -329,6 +334,7 @@ u64 GetSize(const char *filename)
// on windows it's actually _stat64 defined in commonFuncs
struct stat64 buf;
if (stat64(filename, &buf) == 0) {
DEBUG_LOG(COMMON, "GetSize: %s: %d", filename, buf.st_size);
return buf.st_size;
}

View File

@ -29,6 +29,7 @@ enum LOG_TYPE {
COMMANDPROCESSOR,
COMMON,
CONSOLE,
DISCIO,
DSPHLE,
DSPINTERFACE,
DVDINTERFACE,
@ -60,7 +61,7 @@ enum LOG_TYPE {
};
enum LOG_LEVELS {
LERROR, // Bad errors - that still don't deserve a PanicAlert.
LERROR = 0, // Bad errors - that still don't deserve a PanicAlert.
LWARNING, // Something is suspicious.
LINFO, // General information.
LDEBUG, // Strictly for detailed debugging - might make things slow.
@ -71,44 +72,22 @@ enum LOG_LEVELS {
/*
FIXME:
- How can generic_log support log levels in compile time?
Maybe it should call ERROR/.. according to level instead of the other way around.
- Check if we can make the win32 and gcc togther (get rid of those ##)
- Debug_run() - run only in debug time
- Compile the log functions according to LOGLEVEL
*/
#ifdef LOGGING
#define LOGLEVEL 4
#define LOGLEVEL 5
extern void __Log(int logNumber, const char* text, ...);
//extern void __Logv(int log, int v, const char *format, ...);
#ifdef _WIN32
/* #define LOG(t, ...) __Log(LogTypes::t, __VA_ARGS__); */
/* #define LOGV(t, v, ...) __Log(LogTypes::t + (v)*100, __VA_ARGS__); */
/* #define LOGP(t, ...) __Log(t, __VA_ARGS__); */
/* #define LOGVP(t, v, ...) __Log(t + (v)*100, __VA_ARGS__); */
// Let the compiler optimize this out
//#define GENERIC_LOG(t,v, ...) {if (v <= LOGLEVEL) __Log(t + (v)*100, __VA_ARGS__);}
#define GENERIC_LOG(t,v, ...) {__Log(t + (v)*100, __VA_ARGS__);}
#define ERROR_LOG(t,...) {GENERIC_LOG(LogTypes::t, LogTypes::LERROR, __VA_ARGS__)}
#define WARN_LOG(t,...) {GENERIC_LOG(LogTypes::t, LogTypes::LINFO, __VA_ARGS__)}
#define INFO_LOG(t,...) {GENERIC_LOG(LogTypes::t, LogTypes::LWARNING, __VA_ARGS__)}
#define DEBUG_LOG(t,...) {GENERIC_LOG(LogTypes::t, LogTypes::LDEBUG, __VA_ARGS__)}
#else
//#define LOG(t, ...) __Log(LogTypes::t, ##__VA_ARGS__);
//#define LOGV(t,v, ...) __Log(LogTypes::t + (v)*100, ##__VA_ARGS__);
//#define LOGP(t, ...) __Log(t, ##__VA_ARGS__);
//#define LOGVP(t,v, ...) __Log(t + (v)*100, ##__VA_ARGS__);
#define GENERIC_LOG(t,v, ...) {__Log(t + (v)*100, ##__VA_ARGS__);}
#define ERROR_LOG(t,...) {GENERIC_LOG(LogTypes::t, LogTypes::LERROR, ##__VA_ARGS__)}
#define WARN_LOG(t,...) {GENERIC_LOG(LogTypes::t, LogTypes::LINFO, ##__VA_ARGS__)}
#define INFO_LOG(t,...) {GENERIC_LOG(LogTypes::t, LogTypes::LWARNING, ##__VA_ARGS__)}
#define DEBUG_LOG(t,...) {GENERIC_LOG(LogTypes::t, LogTypes::LDEBUG, ##__VA_ARGS__)}
#endif // WIN32
#define _dbg_assert_(_t_, _a_) \
if (!(_a_)) {\
@ -124,11 +103,7 @@ extern void __Log(int logNumber, const char* text, ...);
#define _dbg_update_() Host_UpdateLogDisplay();
#else // no logging
//#define LOG(_t_, ...)
//#define LOGV(_t_, _v_, ...)
//#define LOGP(_t_, ...)
//#define LOGVP(_t_, _v_, ...)
#define LOGLEVEL 1
#define _dbg_clear_()
#define _dbg_update_() ;

View File

@ -121,6 +121,7 @@ void LogManager::Init()
{
m_Log[LogTypes::MASTER_LOG + i*100] = new CDebugger_Log("*", "Master Log", i);
m_Log[LogTypes::COMMON + i*100] = new CDebugger_Log("COMMON", "Common Lib", i);
m_Log[LogTypes::DISCIO + i*100] = new CDebugger_Log("DISCIO", "Disc IO", i);
m_Log[LogTypes::BOOT + i*100] = new CDebugger_Log("BOOT", "Boot", i);
m_Log[LogTypes::PIXELENGINE + i*100] = new CDebugger_Log("PE", "PixelEngine", i);
m_Log[LogTypes::COMMANDPROCESSOR + i*100] = new CDebugger_Log("CP", "CommandProc", i);

View File

@ -18,10 +18,10 @@
#include "stdafx.h"
#include "NANDContentLoader.h"
#include "AES/aes.h"
#include "MathUtil.h"
#include "FileUtil.h"
#include "Log.h"
namespace DiscIO
{
@ -100,9 +100,11 @@ bool CNANDContentLoader::CreateFromDirectory(const std::string& _rPath)
TMDFileName += "/title.tmd";
FILE* pTMDFile = fopen(TMDFileName.c_str(), "rb");
if (pTMDFile == NULL)
if (pTMDFile == NULL) {
ERROR_LOG(DISCIO, "CreateFromDirectory: error opening %s",
TMDFileName.c_str());
return false;
}
u64 Size = File::GetSize(TMDFileName.c_str());
u8* pTMD = new u8[Size];
fread(pTMD, Size, 1, pTMDFile);
@ -126,7 +128,7 @@ bool CNANDContentLoader::CreateFromDirectory(const std::string& _rPath)
rContent.m_pData = NULL;
char szFilename[1024];
sprintf(szFilename, "%s\\%08x.app", _rPath.c_str(), rContent.m_ContentID);
sprintf(szFilename, "%s/%08x.app", _rPath.c_str(), rContent.m_ContentID);
FILE* pFile = fopen(szFilename, "rb");
// i have seen TMDs which index to app which doesn't exist...
@ -139,6 +141,10 @@ bool CNANDContentLoader::CreateFromDirectory(const std::string& _rPath)
fread(rContent.m_pData, Size, 1, pFile);
fclose(pFile);
} else {
ERROR_LOG(DISCIO, "CreateFromDirectory: error opening %s",
szFilename);
}
}
@ -191,6 +197,7 @@ u8* CNANDContentLoader::CreateWADEntry(DiscIO::IBlobReader& _rReader, u32 _Size,
if (!_rReader.Read(_Offset, _Size, pTmpBuffer))
{
ERROR_LOG(DISCIO, "WiiWAD: Could not read from file");
PanicAlert("WiiWAD: Could not read from file");
}
return pTmpBuffer;
@ -283,4 +290,7 @@ bool CNANDContentLoader::ParseWAD(DiscIO::IBlobReader& _rReader)
return Result;
}
}
} // namespace end