Logging system rework

* use one central unified log with channels/priorities ad-hoc listener registration and de-registration
* disable buffering by default
* add multi-threaded ringbuffer implementation
* use buffered listener for the gui (using the ringbuffer)
This commit is contained in:
Peter Tissen 2014-06-17 17:44:03 +02:00 committed by Bigpet
parent 394b698e92
commit 21da317453
165 changed files with 1731 additions and 1519 deletions

View file

@ -1,5 +1,5 @@
#include "stdafx.h"
#include "Emu/ConLog.h"
#include "Utilities/Log.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h"
#include "Emu/Cell/PPUThread.h"
@ -104,13 +104,13 @@ bool ELF64Loader::LoadEhdrInfo(s64 offset)
if(ehdr.e_phentsize != sizeof(Elf64_Phdr))
{
ConLog.Error("elf64 error: e_phentsize[0x%x] != sizeof(Elf64_Phdr)[0x%x]", ehdr.e_phentsize, sizeof(Elf64_Phdr));
LOGF_ERROR(LOADER, "elf64 error: e_phentsize[0x%x] != sizeof(Elf64_Phdr)[0x%x]", ehdr.e_phentsize, sizeof(Elf64_Phdr));
return false;
}
if(ehdr.e_shentsize != sizeof(Elf64_Shdr))
{
ConLog.Error("elf64 error: e_shentsize[0x%x] != sizeof(Elf64_Shdr)[0x%x]", ehdr.e_shentsize, sizeof(Elf64_Shdr));
LOGF_ERROR(LOADER, "elf64 error: e_shentsize[0x%x] != sizeof(Elf64_Shdr)[0x%x]", ehdr.e_shentsize, sizeof(Elf64_Shdr));
return false;
}
@ -123,14 +123,14 @@ bool ELF64Loader::LoadEhdrInfo(s64 offset)
default:
machine = MACHINE_Unknown;
ConLog.Error("Unknown elf64 type: 0x%x", ehdr.e_machine);
LOGF_ERROR(LOADER, "Unknown elf64 type: 0x%x", ehdr.e_machine);
return false;
}
entry = ehdr.GetEntry();
if(entry == 0)
{
ConLog.Error("elf64 error: entry is null!");
LOG_ERROR(LOADER, "elf64 error: entry is null!");
return false;
}
@ -143,7 +143,7 @@ bool ELF64Loader::LoadPhdrInfo(s64 offset)
if(ehdr.e_phoff == 0 && ehdr.e_phnum)
{
ConLog.Error("LoadPhdr64 error: Program header offset is null!");
LOG_ERROR(LOADER, "LoadPhdr64 error: Program header offset is null!");
return false;
}
@ -164,7 +164,7 @@ bool ELF64Loader::LoadShdrInfo(s64 offset)
shdr_name_arr.clear();
if(ehdr.e_shoff == 0 && ehdr.e_shnum)
{
ConLog.Warning("LoadShdr64 error: Section header offset is null!");
LOG_NOTICE(LOADER, "LoadShdr64 error: Section header offset is null!");
return true;
}
@ -177,7 +177,7 @@ bool ELF64Loader::LoadShdrInfo(s64 offset)
if(ehdr.e_shstrndx >= shdr_arr.size())
{
ConLog.Warning("LoadShdr64 error: shstrndx too big!");
LOG_WARNING(LOADER, "LoadShdr64 error: shstrndx too big!");
return true;
}
@ -201,9 +201,9 @@ bool ELF64Loader::LoadShdrInfo(s64 offset)
bool ELF64Loader::LoadEhdrData(u64 offset)
{
#ifdef LOADER_DEBUG
ConLog.SkipLn();
LOG_NOTICE(LOADER, "");
ehdr.Show();
ConLog.SkipLn();
LOG_NOTICE(LOADER, "");
#endif
return true;
}
@ -226,8 +226,9 @@ bool ELF64Loader::LoadPhdrData(u64 offset)
if(phdr_arr[i].p_vaddr != phdr_arr[i].p_paddr)
{
ConLog.Warning
(
LOGF_WARNING
(
LOADER,
"ElfProgram different load addrs: paddr=0x%8.8x, vaddr=0x%8.8x",
phdr_arr[i].p_paddr, phdr_arr[i].p_vaddr
);
@ -236,8 +237,8 @@ bool ELF64Loader::LoadPhdrData(u64 offset)
if(!Memory.MainMem.IsInMyRange(offset + phdr_arr[i].p_vaddr, phdr_arr[i].p_memsz))
{
#ifdef LOADER_DEBUG
ConLog.Warning("Skipping...");
ConLog.SkipLn();
LOG_WARNING(LOADER, "Skipping...");
LOG_WARNING(LOADER, "");
#endif
continue;
}
@ -270,12 +271,12 @@ bool ELF64Loader::LoadPhdrData(u64 offset)
if(re(proc_param.size) < sizeof(sys_process_param))
{
ConLog.Warning("Bad proc param size! [0x%x : 0x%x]", re(proc_param.size), sizeof(sys_process_param));
LOGF_WARNING(LOADER, "Bad proc param size! [0x%x : 0x%x]", re(proc_param.size), sizeof(sys_process_param));
}
if(re(proc_param.magic) != 0x13bcc5f6)
{
ConLog.Error("Bad magic! [0x%x]", Memory.Reverse32(proc_param.magic));
LOGF_ERROR(LOADER, "Bad magic! [0x%x]", Memory.Reverse32(proc_param.magic));
}
else
{
@ -287,12 +288,12 @@ bool ELF64Loader::LoadPhdrData(u64 offset)
info.ppc_seg = re(proc_param.info.ppc_seg);
//info.crash_dump_param_addr = re(proc_param.info.crash_dump_param_addr);
#ifdef LOADER_DEBUG
ConLog.Write("*** sdk version: 0x%x", info.sdk_version);
ConLog.Write("*** primary prio: %d", info.primary_prio);
ConLog.Write("*** primary stacksize: 0x%x", info.primary_stacksize);
ConLog.Write("*** malloc pagesize: 0x%x", info.malloc_pagesize);
ConLog.Write("*** ppc seg: 0x%x", info.ppc_seg);
//ConLog.Write("*** crash dump param addr: 0x%x", info.crash_dump_param_addr);
LOGF_NOTICE(LOADER, "*** sdk version: 0x%x", info.sdk_version);
LOGF_NOTICE(LOADER, "*** primary prio: %d", info.primary_prio);
LOGF_NOTICE(LOADER, "*** primary stacksize: 0x%x", info.primary_stacksize);
LOGF_NOTICE(LOADER, "*** malloc pagesize: 0x%x", info.malloc_pagesize);
LOGF_NOTICE(LOADER, "*** ppc seg: 0x%x", info.ppc_seg);
//LOGF_NOTICE(LOADER, "*** crash dump param addr: 0x%x", info.crash_dump_param_addr);
#endif
}
}
@ -314,19 +315,19 @@ bool ELF64Loader::LoadPhdrData(u64 offset)
proc_prx_param.ver = re(proc_prx_param.ver);
#ifdef LOADER_DEBUG
ConLog.Write("*** size: 0x%x", proc_prx_param.size);
ConLog.Write("*** magic: 0x%x", proc_prx_param.magic);
ConLog.Write("*** version: 0x%x", proc_prx_param.version);
ConLog.Write("*** libentstart: 0x%x", proc_prx_param.libentstart);
ConLog.Write("*** libentend: 0x%x", proc_prx_param.libentend);
ConLog.Write("*** libstubstart: 0x%x", proc_prx_param.libstubstart);
ConLog.Write("*** libstubend: 0x%x", proc_prx_param.libstubend);
ConLog.Write("*** ver: 0x%x", proc_prx_param.ver);
LOGF_NOTICE(LOADER, "*** size: 0x%x", proc_prx_param.size);
LOGF_NOTICE(LOADER, "*** magic: 0x%x", proc_prx_param.magic);
LOGF_NOTICE(LOADER, "*** version: 0x%x", proc_prx_param.version);
LOGF_NOTICE(LOADER, "*** libentstart: 0x%x", proc_prx_param.libentstart);
LOGF_NOTICE(LOADER, "*** libentend: 0x%x", proc_prx_param.libentend);
LOGF_NOTICE(LOADER, "*** libstubstart: 0x%x", proc_prx_param.libstubstart);
LOGF_NOTICE(LOADER, "*** libstubend: 0x%x", proc_prx_param.libstubend);
LOGF_NOTICE(LOADER, "*** ver: 0x%x", proc_prx_param.ver);
#endif
if(proc_prx_param.magic != 0x1b434cec)
{
ConLog.Error("Bad magic! (0x%x)", proc_prx_param.magic);
LOGF_ERROR(LOADER, "Bad magic! (0x%x)", proc_prx_param.magic);
}
else
{
@ -351,19 +352,19 @@ bool ELF64Loader::LoadPhdrData(u64 offset)
}
else
{
ConLog.Warning("Unknown module '%s'", module_name.c_str());
LOGF_WARNING(LOADER, "Unknown module '%s'", module_name.c_str());
}
#ifdef LOADER_DEBUG
ConLog.SkipLn();
ConLog.Write("*** size: 0x%x", stub.s_size);
ConLog.Write("*** version: 0x%x", stub.s_version);
ConLog.Write("*** unk0: 0x%x", stub.s_unk0);
ConLog.Write("*** unk1: 0x%x", stub.s_unk1);
ConLog.Write("*** imports: %d", stub.s_imports);
ConLog.Write("*** module name: %s [0x%x]", module_name.c_str(), stub.s_modulename);
ConLog.Write("*** nid: 0x%x", stub.s_nid);
ConLog.Write("*** text: 0x%x", stub.s_text);
LOG_NOTICE(LOADER, "");
LOGF_NOTICE(LOADER, "*** size: 0x%x", stub.s_size);
LOGF_NOTICE(LOADER, "*** version: 0x%x", stub.s_version);
LOGF_NOTICE(LOADER, "*** unk0: 0x%x", stub.s_unk0);
LOGF_NOTICE(LOADER, "*** unk1: 0x%x", stub.s_unk1);
LOGF_NOTICE(LOADER, "*** imports: %d", stub.s_imports);
LOGF_NOTICE(LOADER, "*** module name: %s [0x%x]", module_name.c_str(), stub.s_modulename);
LOGF_NOTICE(LOADER, "*** nid: 0x%x", stub.s_nid);
LOGF_NOTICE(LOADER, "*** text: 0x%x", stub.s_text);
#endif
static const u32 section = 4 * 3;
u64 tbl = Memory.MainMem.AllocAlign(stub.s_imports * 4 * 2);
@ -378,13 +379,13 @@ bool ELF64Loader::LoadPhdrData(u64 offset)
{
if(!module->Load(nid))
{
ConLog.Warning("Unimplemented function '%s' in '%s' module", SysCalls::GetHLEFuncName(nid).c_str(), module_name.c_str());
LOGF_WARNING(LOADER, "Unimplemented function '%s' in '%s' module", SysCalls::GetHLEFuncName(nid).c_str(), module_name.c_str());
}
}
#ifdef LOADER_DEBUG
ConLog.Write("import %d:", i+1);
ConLog.Write("*** nid: 0x%x (0x%x)", nid, stub.s_nid + i*4);
ConLog.Write("*** text: 0x%x (0x%x)", text, stub.s_text + i*4);
LOGF_NOTICE(LOADER, "import %d:", i+1);
LOGF_NOTICE(LOADER, "*** nid: 0x%x (0x%x)", nid, stub.s_nid + i*4);
LOGF_NOTICE(LOADER, "*** text: 0x%x (0x%x)", text, stub.s_text + i*4);
#endif
Memory.Write32(stub.s_text + i*4, tbl + i*8);
@ -399,14 +400,14 @@ bool ELF64Loader::LoadPhdrData(u64 offset)
}
}
#ifdef LOADER_DEBUG
ConLog.SkipLn();
LOG_NOTICE(LOADER, " ");
#endif
}
}
break;
}
#ifdef LOADER_DEBUG
ConLog.SkipLn();
LOGF_NOTICE(LOADER, " ");
#endif
}
@ -424,13 +425,13 @@ bool ELF64Loader::LoadShdrData(u64 offset)
if(i < shdr_name_arr.size())
{
#ifdef LOADER_DEBUG
ConLog.Write("Name: %s", shdr_name_arr[i].c_str());
LOGF_NOTICE(LOADER, "Name: %s", shdr_name_arr[i].c_str());
#endif
}
#ifdef LOADER_DEBUG
shdr.Show();
ConLog.SkipLn();
LOGF_NOTICE(LOADER, " ");
#endif
if(shdr.sh_addr + shdr.sh_size > max_addr) max_addr = shdr.sh_addr + shdr.sh_size;
@ -453,7 +454,7 @@ bool ELF64Loader::LoadShdrData(u64 offset)
if((shdr.sh_type == SHT_RELA) || (shdr.sh_type == SHT_REL))
{
ConLog.Error("ELF64 ERROR: Relocation");
LOG_ERROR(LOADER, "ELF64 ERROR: Relocation");
continue;
}