libs: Reduce logging

This commit is contained in:
IndecisiveTurtle 2024-11-10 20:15:28 +02:00
parent c9773c5c0a
commit f96a21551a
5 changed files with 32 additions and 65 deletions

View file

@ -157,8 +157,7 @@ struct AddressSpace::Impl {
ASSERT_MSG(ret, "VirtualProtect failed. {}", Common::GetLastErrorMsg()); ASSERT_MSG(ret, "VirtualProtect failed. {}", Common::GetLastErrorMsg());
} else { } else {
ptr = MapViewOfFile3(backing, process, reinterpret_cast<PVOID>(virtual_addr), ptr = MapViewOfFile3(backing, process, reinterpret_cast<PVOID>(virtual_addr),
phys_addr, size, MEM_REPLACE_PLACEHOLDER, prot, phys_addr, size, MEM_REPLACE_PLACEHOLDER, prot, nullptr, 0);
nullptr, 0);
} }
} else { } else {
ptr = ptr =
@ -211,7 +210,8 @@ struct AddressSpace::Impl {
region_size, size); region_size, size);
// Split the placeholder. // Split the placeholder.
if (!VirtualFreeEx(process, LPVOID(address), size, MEM_RELEASE | MEM_PRESERVE_PLACEHOLDER)) { if (!VirtualFreeEx(process, LPVOID(address), size,
MEM_RELEASE | MEM_PRESERVE_PLACEHOLDER)) {
UNREACHABLE_MSG("Region splitting failed: {}", Common::GetLastErrorMsg()); UNREACHABLE_MSG("Region splitting failed: {}", Common::GetLastErrorMsg());
return nullptr; return nullptr;
} }
@ -232,7 +232,8 @@ struct AddressSpace::Impl {
ASSERT(region_size >= minimum_size); ASSERT(region_size >= minimum_size);
// Split the placeholder. // Split the placeholder.
if (!VirtualFreeEx(process, LPVOID(address), size, MEM_RELEASE | MEM_PRESERVE_PLACEHOLDER)) { if (!VirtualFreeEx(process, LPVOID(address), size,
MEM_RELEASE | MEM_PRESERVE_PLACEHOLDER)) {
UNREACHABLE_MSG("Region splitting failed: {}", Common::GetLastErrorMsg()); UNREACHABLE_MSG("Region splitting failed: {}", Common::GetLastErrorMsg());
return nullptr; return nullptr;
} }
@ -241,8 +242,7 @@ struct AddressSpace::Impl {
if (region_size == minimum_size) { if (region_size == minimum_size) {
// Split into two; update tracked mappings and return the second one // Split into two; update tracked mappings and return the second one
region.size = offset_in_region; region.size = offset_in_region;
it = regions.emplace_hint(std::next(it), address, it = regions.emplace_hint(std::next(it), address, MemoryRegion(address, size, false));
MemoryRegion(address, size, false));
return &it->second; return &it->second;
} else { } else {
// Split into three; update tracked mappings and return the middle one // Split into three; update tracked mappings and return the middle one
@ -251,9 +251,10 @@ struct AddressSpace::Impl {
const size_t middle_mapping_size = size; const size_t middle_mapping_size = size;
const VAddr after_mapping_start = address + size; const VAddr after_mapping_start = address + size;
const size_t after_mapping_size = region_size - minimum_size; const size_t after_mapping_size = region_size - minimum_size;
it = regions.emplace_hint(std::next(it), it = regions.emplace_hint(std::next(it), after_mapping_start,
after_mapping_start, MemoryRegion(after_mapping_start, after_mapping_size, false)); MemoryRegion(after_mapping_start, after_mapping_size, false));
it = regions.emplace_hint(it, middle_mapping_start, it = regions.emplace_hint(
it, middle_mapping_start,
MemoryRegion(middle_mapping_start, middle_mapping_size, false)); MemoryRegion(middle_mapping_start, middle_mapping_size, false));
return &it->second; return &it->second;
} }
@ -285,7 +286,8 @@ struct AddressSpace::Impl {
auto it_next = std::next(it); auto it_next = std::next(it);
if (it_next != regions.end() && !it_next->second.is_mapped) { if (it_next != regions.end() && !it_next->second.is_mapped) {
const size_t total_size = it->second.size + it_next->second.size; const size_t total_size = it->second.size + it_next->second.size;
if (!VirtualFreeEx(process, LPVOID(it->first), total_size, MEM_RELEASE | MEM_COALESCE_PLACEHOLDERS)) { if (!VirtualFreeEx(process, LPVOID(it->first), total_size,
MEM_RELEASE | MEM_COALESCE_PLACEHOLDERS)) {
UNREACHABLE_MSG("Region coalescing failed: {}", Common::GetLastErrorMsg()); UNREACHABLE_MSG("Region coalescing failed: {}", Common::GetLastErrorMsg());
} }
@ -325,7 +327,8 @@ struct AddressSpace::Impl {
const size_t range_size = std::min(region.base + region.size, virtual_end) - range_addr; const size_t range_size = std::min(region.base + region.size, virtual_end) - range_addr;
DWORD old_flags{}; DWORD old_flags{};
if (!VirtualProtectEx(process, LPVOID(range_addr), range_size, new_flags, &old_flags)) { if (!VirtualProtectEx(process, LPVOID(range_addr), range_size, new_flags, &old_flags)) {
UNREACHABLE_MSG("Failed to change virtual memory protection for address {:#x}, size {}", UNREACHABLE_MSG(
"Failed to change virtual memory protection for address {:#x}, size {}",
range_addr, range_size); range_addr, range_size);
} }
} }

View file

@ -6,10 +6,10 @@
#include "core/file_sys/file.h" #include "core/file_sys/file.h"
#ifdef _WIN64 #ifdef _WIN64
#include "common/ntapi.h"
#include <io.h> #include <io.h>
#include <share.h> #include <share.h>
#include <windows.h> #include <windows.h>
#include "common/ntapi.h"
#endif #endif
namespace Core::FileSys { namespace Core::FileSys {
@ -27,7 +27,8 @@ int File::Open(const std::filesystem::path& path, Common::FS::FileAccessMode f_a
} else { } else {
UNREACHABLE(); UNREACHABLE();
} }
handle = CreateFileW(path.native().c_str(), access, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); handle = CreateFileW(path.native().c_str(), access, FILE_SHARE_READ, NULL, OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL, NULL);
if (handle == INVALID_HANDLE_VALUE) { if (handle == INVALID_HANDLE_VALUE) {
return ENOENT; return ENOENT;
} }

View file

@ -5,8 +5,8 @@
#include "common/alignment.h" #include "common/alignment.h"
#include "common/assert.h" #include "common/assert.h"
#include "common/scope_exit.h"
#include "common/logging/log.h" #include "common/logging/log.h"
#include "common/scope_exit.h"
#include "common/singleton.h" #include "common/singleton.h"
#include "core/file_sys/fs.h" #include "core/file_sys/fs.h"
#include "core/libraries/error_codes.h" #include "core/libraries/error_codes.h"
@ -166,7 +166,8 @@ int PS4_SYSV_ABI sceKernelMapNamedDirectMemory(void** addr, u64 len, int prot, i
const auto map_flags = static_cast<Core::MemoryMapFlags>(flags); const auto map_flags = static_cast<Core::MemoryMapFlags>(flags);
SCOPE_EXIT { SCOPE_EXIT {
LOG_INFO(Kernel_Vmm, LOG_INFO(Kernel_Vmm,
"in_addr = {:#x}, out_addr = {}, len = {:#x}, prot = {:#x}, flags = {:#x}, directMemoryStart = {:#x}, " "in_addr = {:#x}, out_addr = {}, len = {:#x}, prot = {:#x}, flags = {:#x}, "
"directMemoryStart = {:#x}, "
"alignment = {:#x}", "alignment = {:#x}",
in_addr, fmt::ptr(*addr), len, prot, flags, directMemoryStart, alignment); in_addr, fmt::ptr(*addr), len, prot, flags, directMemoryStart, alignment);
}; };
@ -205,7 +206,8 @@ s32 PS4_SYSV_ABI sceKernelMapNamedFlexibleMemory(void** addr_in_out, std::size_t
const auto mem_prot = static_cast<Core::MemoryProt>(prot); const auto mem_prot = static_cast<Core::MemoryProt>(prot);
const auto map_flags = static_cast<Core::MemoryMapFlags>(flags); const auto map_flags = static_cast<Core::MemoryMapFlags>(flags);
SCOPE_EXIT { SCOPE_EXIT {
LOG_INFO(Kernel_Vmm, "in_addr = {:#x}, out_addr = {}, len = {:#x}, prot = {:#x}, flags = {:#x}", LOG_INFO(Kernel_Vmm,
"in_addr = {:#x}, out_addr = {}, len = {:#x}, prot = {:#x}, flags = {:#x}",
in_addr, fmt::ptr(*addr_in_out), len, prot, flags); in_addr, fmt::ptr(*addr_in_out), len, prot, flags);
}; };
auto* memory = Core::Memory::Instance(); auto* memory = Core::Memory::Instance();

View file

@ -9,46 +9,9 @@
#include "core/loader/elf.h" #include "core/loader/elf.h"
#include "core/loader/symbols_resolver.h" #include "core/loader/symbols_resolver.h"
template <size_t N>
struct StringLiteral {
constexpr StringLiteral(const char (&str)[N]) {
std::copy_n(str, N, value);
}
char value[N];
};
template <StringLiteral name, class F, F f>
struct wrapper_impl;
template <StringLiteral name, class R, class... Args, PS4_SYSV_ABI R (*f)(Args...)>
struct wrapper_impl<name, PS4_SYSV_ABI R (*)(Args...), f> {
static R PS4_SYSV_ABI wrap(Args... args) {
if (std::string_view(name.value) != "scePthreadEqual" &&
std::string_view(name.value) != "sceUserServiceGetEvent" &&
!std::string_view(name.value).contains("scePthreadMutex") &&
!std::string_view(name.value).contains("pthread_mutex")) {
// LOG_WARNING(Core_Linker, "Function {} called", name.value);
}
if constexpr (std::is_same_v<R, s32> || std::is_same_v<R, u32>) {
const u32 ret = f(args...);
if (ret != 0 && !std::string_view(name.value).contains("pthread_equal")) {
LOG_WARNING(Core_Linker, "Function {} returned {:#x}", name.value, ret);
}
return ret;
}
// stuff
return f(args...);
}
};
template <StringLiteral name, class F, F f>
constexpr auto wrapper = wrapper_impl<name, F, f>::wrap;
// #define W(foo) wrapper<#foo, decltype(&foo), foo>
#define W(foo) foo #define W(foo) foo
#define LIB_FUNCTION(nid, lib, libversion, mod, moduleVersionMajor, moduleVersionMinor, f) \ #define LIB_FUNCTION(nid, lib, libversion, mod, moduleVersionMajor, moduleVersionMinor, function) \
{ \ { \
Core::Loader::SymbolResolver sr{}; \ Core::Loader::SymbolResolver sr{}; \
sr.name = nid; \ sr.name = nid; \
@ -58,10 +21,8 @@ constexpr auto wrapper = wrapper_impl<name, F, f>::wrap;
sr.module_version_major = moduleVersionMajor; \ sr.module_version_major = moduleVersionMajor; \
sr.module_version_minor = moduleVersionMinor; \ sr.module_version_minor = moduleVersionMinor; \
sr.type = Core::Loader::SymbolType::Function; \ sr.type = Core::Loader::SymbolType::Function; \
{ \ auto func = reinterpret_cast<u64>(function); \
auto func = reinterpret_cast<u64>(wrapper<#f, decltype(&f), f>); \
sym->AddSymbol(sr, func); \ sym->AddSymbol(sr, func); \
} \
} }
#define LIB_OBJ(nid, lib, libversion, mod, moduleVersionMajor, moduleVersionMinor, function) \ #define LIB_OBJ(nid, lib, libversion, mod, moduleVersionMajor, moduleVersionMinor, function) \

View file

@ -570,7 +570,7 @@ Liverpool::Task Liverpool::ProcessGraphics(std::span<const u32> dcb, std::span<c
sizeof(u32), false); sizeof(u32), false);
} else if (dma_data->src_sel == DmaDataSrc::Gds && } else if (dma_data->src_sel == DmaDataSrc::Gds &&
dma_data->dst_sel == DmaDataDst::Memory) { dma_data->dst_sel == DmaDataDst::Memory) {
//LOG_WARNING(Render_Vulkan, "GDS memory read"); // LOG_WARNING(Render_Vulkan, "GDS memory read");
} else if (dma_data->src_sel == DmaDataSrc::Memory && } else if (dma_data->src_sel == DmaDataSrc::Memory &&
dma_data->dst_sel == DmaDataDst::Memory) { dma_data->dst_sel == DmaDataDst::Memory) {
rasterizer->InlineData(dma_data->DstAddress<VAddr>(), rasterizer->InlineData(dma_data->DstAddress<VAddr>(),