From c54d31778ff949d8f8df60a474791da2a0dcb7f1 Mon Sep 17 00:00:00 2001 From: georgemoralis Date: Tue, 11 Apr 2023 13:24:06 +0300 Subject: [PATCH] replaced printf's with fmt::print --- emulator/Loader/Elf.cpp | 126 ++++++++++++++--------------- emulator/emulator.vcxproj | 59 +------------- shadps4.sln | 20 +++-- vstudioprj/common.props | 24 ++++++ vstudioprj/fmt/fmt.vcxproj | 103 +++++++++++++++++++++++ vstudioprj/fmt/fmt.vcxproj.filters | 66 +++++++++++++++ 6 files changed, 274 insertions(+), 124 deletions(-) create mode 100644 vstudioprj/common.props create mode 100644 vstudioprj/fmt/fmt.vcxproj create mode 100644 vstudioprj/fmt/fmt.vcxproj.filters diff --git a/emulator/Loader/Elf.cpp b/emulator/Loader/Elf.cpp index 5fd42e98..719b0f88 100644 --- a/emulator/Loader/Elf.cpp +++ b/emulator/Loader/Elf.cpp @@ -1,5 +1,5 @@ #include "Elf.h" - +#include Elf::~Elf() { @@ -231,91 +231,91 @@ bool Elf::isElfFile() const void Elf::DebugDump() { printf("SELF header:\n"); - printf(" magic ..............: 0x%08" PRIx32 "\n", m_self->magic); - printf(" version .........: %" PRIu8 "\n", m_self->version); - printf(" mode .........: 0x%02" PRIx8 "\n", m_self->mode); - printf(" endian .........: %" PRIu8 "\n", m_self->endian); - printf(" attributes .........: 0x%02" PRIx8 "\n", m_self->attributes); - printf(" category .........: 0x%02" PRIx8 "\n", m_self->category); - printf(" program_type........: 0x%02" PRIx8 "\n", m_self->program_type); - printf(" padding1 ...........: 0x%04" PRIx16 "\n", m_self->padding1); - printf(" header size ........: %" PRIu16 "\n", m_self->header_size); - printf(" meta size .....: %" PRIu16 "\n", m_self->meta_size); - printf(" file size ..........: %" PRIu32 "\n", m_self->file_size); - printf(" padding2 ...........: 0x%08" PRIx32 "\n", m_self->padding2); - printf(" segment count ......: %" PRIu16 "\n", m_self->segment_count); - printf(" unknown 1A .........: 0x%04" PRIx16 "\n", m_self->unknown1A); - printf(" padding3 ...........: 0x%04" PRIx16 "\n", m_self->padding3); - printf("\n"); + fmt::print(" magic ..............: 0x{:x}\n", m_self->magic); + fmt::print(" version .........: {}\n", m_self->version); + fmt::print(" mode .........: {:#04x}\n", m_self->mode); + fmt::print(" endian .........: {}\n", m_self->endian); + fmt::print(" attributes .........: {:#04x}\n", m_self->attributes); + fmt::print(" category .........: {:#04x}\n", m_self->category); + fmt::print(" program_type........: {:#04x}\n", m_self->program_type); + fmt::print(" padding1 ...........: {:#06x}\n", m_self->padding1); + fmt::print(" header size ........: {}\n", m_self->header_size); + fmt::print(" meta size .....: {}\n", m_self->meta_size); + fmt::print(" file size ..........: {}\n", m_self->file_size); + fmt::print(" padding2 ...........: {:#010x}\n", m_self->padding2); + fmt::print(" segment count ......: {}\n", m_self->segment_count); + fmt::print(" unknown 1A .........: {:#06x}\n", m_self->unknown1A); + fmt::print(" padding3 ...........: {:#010x}\n", m_self->padding3); + fmt::print("\n"); - printf("SELF segments:\n"); + fmt::print("SELF segments:\n"); for (int i = 0; i < m_self->segment_count; i++) { auto segment_header = m_self_segments[i]; - printf(" [%d]\n", i); - printf(" flags ............: 0x%016" PRIx64 "\n", segment_header.flags); - printf(" file offset ......: 0x%016" PRIx64 "\n", segment_header.file_offset); - printf(" file size ........: %" PRIu64 "\n", segment_header.file_size); - printf(" memory size ......: %" PRIu64 "\n", segment_header.memory_size); + fmt::print(" [{}]\n", i); + fmt::print(" flags ............: {:#018x}\n", segment_header.flags); + fmt::print(" file offset ......: {:#018x}\n", segment_header.file_offset); + fmt::print(" file size ........: {}\n", segment_header.file_size); + fmt::print(" memory size ......: {}\n", segment_header.memory_size); } - printf("\n"); + fmt::print("\n"); - printf("Elf header:\n"); - printf(" ident .........: 0x"); + fmt::print("Elf header:\n"); + fmt::print(" ident .........: 0x"); for (auto i : m_elf_header->e_ident) { - printf("%02x", i); + fmt::print("{:02x}", i); } - printf("\n"); + fmt::print("\n"); - printf(" type .........: 0x%04" PRIx16 "\n", m_elf_header->e_type); - printf(" machine .......: 0x%04" PRIx16 "\n", m_elf_header->e_machine); - printf(" version .......: 0x%08" PRIx32 "\n", m_elf_header->e_version); + fmt::print(" type .........: {:#06x}\n", m_elf_header->e_type); + fmt::print(" machine .......: {:#06x}\n", m_elf_header->e_machine); + fmt::print(" version .......: {:#010x}\n", m_elf_header->e_version); - printf(" entry .........: 0x%016" PRIx64 "\n", m_elf_header->e_entry); - printf(" phoff .........: 0x%016" PRIx64 "\n", m_elf_header->e_phoff); - printf(" shoff .........: 0x%016" PRIx64 "\n", m_elf_header->e_shoff); - printf(" flags .........: 0x%08" PRIx32 "\n", m_elf_header->e_flags); - printf(" ehsize ........: 0x%04" PRIx16 "\n", m_elf_header->e_ehsize); - printf(" phentsize .....: 0x%04" PRIx16 "\n", m_elf_header->e_phentsize); - printf(" phnum .........: %" PRIu16 "\n", m_elf_header->e_phnum); - printf(" shentsize .....: 0x%04" PRIx16 "\n", m_elf_header->e_shentsize); - printf(" shnum .........: %" PRIu16 "\n", m_elf_header->e_shnum); - printf(" shstrndx ......: %" PRIu16 "\n", m_elf_header->e_shstrndx); + fmt::print(" entry .........: {:#018x}\n", m_elf_header->e_entry); + fmt::print(" phoff .........: {:#018x}\n", m_elf_header->e_phoff); + fmt::print(" shoff .........: {:#018x}\n", m_elf_header->e_shoff); + fmt::print(" flags .........: {:#010x}\n", m_elf_header->e_flags); + fmt::print(" ehsize ........: {:#06x}\n", m_elf_header->e_ehsize); + fmt::print(" phentsize .....: {:#06x}\n", m_elf_header->e_phentsize); + fmt::print(" phnum .........: {}\n", m_elf_header->e_phnum); + fmt::print(" shentsize .....: {:#06x}\n", m_elf_header->e_shentsize); + fmt::print(" shnum .........: {}\n", m_elf_header->e_shnum); + fmt::print(" shstrndx ......: {}\n", m_elf_header->e_shstrndx); if (m_elf_header->e_phentsize > 0) { - printf("Program headers:\n"); + fmt::print("Program headers:\n"); for (u16 i = 0; i < m_elf_header->e_phnum; i++) { - printf("--- phdr [%d] ---\n", i); - printf("p_type ....: 0x%08" PRIx32 "\n", (m_elf_phdr+i)->p_type); - printf("p_flags ...: 0x%08" PRIx32 "\n", (m_elf_phdr + i)->p_flags); - printf("p_offset ..: 0x%016" PRIx64 "\n", (m_elf_phdr + i)->p_offset); - printf("p_vaddr ...: 0x%016" PRIx64 "\n", (m_elf_phdr + i)->p_vaddr); - printf("p_paddr ...: 0x%016" PRIx64 "\n", (m_elf_phdr + i)->p_paddr); - printf("p_filesz ..: 0x%016" PRIx64 "\n", (m_elf_phdr + i)->p_filesz); - printf("p_memsz ...: 0x%016" PRIx64 "\n", (m_elf_phdr + i)->p_memsz); - printf("p_align ...: 0x%016" PRIx64 "\n", (m_elf_phdr + i)->p_align); + fmt::print("--- phdr [{}] ---\n", i); + fmt::print("p_type ....: {:#010x}\n", (m_elf_phdr+i)->p_type); + fmt::print("p_flags ...: {:#010x}\n", (m_elf_phdr + i)->p_flags); + fmt::print("p_offset ..: {:#018x}\n", (m_elf_phdr + i)->p_offset); + fmt::print("p_vaddr ...: {:#018x}\n", (m_elf_phdr + i)->p_vaddr); + fmt::print("p_paddr ...: {:#018x}\n", (m_elf_phdr + i)->p_paddr); + fmt::print("p_filesz ..: {:#018x}\n", (m_elf_phdr + i)->p_filesz); + fmt::print("p_memsz ...: {:#018x}\n", (m_elf_phdr + i)->p_memsz); + fmt::print("p_align ...: {:#018x}\n", (m_elf_phdr + i)->p_align); } } if (m_elf_header->e_shentsize > 0) { - printf("Section headers:\n"); + fmt::print("Section headers:\n"); for (uint16_t i = 0; i < m_elf_header->e_shnum; i++) { - printf("--- shdr [%d] --\n", i); - printf("sh_name ........: %d\n", (m_elf_shdr + i)->sh_name); - printf("sh_type ........: 0x%08" PRIx32 "\n", (m_elf_shdr + i)->sh_type); - printf("sh_flags .......: 0x%016" PRIx64 "\n", (m_elf_shdr + i)->sh_flags); - printf("sh_addr ........: 0x%016" PRIx64 "\n", (m_elf_shdr + i)->sh_addr); - printf("sh_offset ......: 0x%016" PRIx64 "\n", (m_elf_shdr + i)->sh_offset); - printf("sh_size ........: 0x%016" PRIx64 "\n", (m_elf_shdr + i)->sh_size); - printf("sh_link ........: %" PRId32 "\n", (m_elf_shdr + i)->sh_link); - printf("sh_info ........: 0x%08" PRIx32 "\n", (m_elf_shdr + i)->sh_info); - printf("sh_addralign ...: 0x%016" PRIx64 "\n", (m_elf_shdr + i)->sh_addralign); - printf("sh_entsize .....: 0x%016" PRIx64 "\n", (m_elf_shdr + i)->sh_entsize); + fmt::print("--- shdr [%d] --\n", i); + fmt::print("sh_name ........: {}\n", (m_elf_shdr + i)->sh_name); + fmt::print("sh_type ........: {:#010x}\n", (m_elf_shdr + i)->sh_type); + fmt::print("sh_flags .......: {:#018x}\n", (m_elf_shdr + i)->sh_flags); + fmt::print("sh_addr ........: {:#018x}\n", (m_elf_shdr + i)->sh_addr); + fmt::print("sh_offset ......: {:#018x}\n", (m_elf_shdr + i)->sh_offset); + fmt::print("sh_size ........: {:#018x}\n", (m_elf_shdr + i)->sh_size); + fmt::print("sh_link ........: {:#010x}\n", (m_elf_shdr + i)->sh_link); + fmt::print("sh_info ........: {:#010x}\n", (m_elf_shdr + i)->sh_info); + fmt::print("sh_addralign ...: {:#018x}\n", (m_elf_shdr + i)->sh_addralign); + fmt::print("sh_entsize .....: {:#018x}\n", (m_elf_shdr + i)->sh_entsize); } } } \ No newline at end of file diff --git a/emulator/emulator.vcxproj b/emulator/emulator.vcxproj index 435b1c86..cf2447cd 100644 --- a/emulator/emulator.vcxproj +++ b/emulator/emulator.vcxproj @@ -1,14 +1,6 @@ - - Debug - Win32 - - - Release - Win32 - Debug x64 @@ -26,19 +18,6 @@ 10.0 - - Application - true - v143 - Unicode - - - Application - false - v143 - true - Unicode - Application true @@ -57,17 +36,13 @@ - - - - - - + + @@ -76,34 +51,6 @@ shadps4 - - - Level3 - true - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - - - - - Level3 - true - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - Level3 @@ -114,6 +61,7 @@ Console true + ..\x64\Debug\fmt.lib;%(AdditionalDependencies) @@ -130,6 +78,7 @@ true true true + ..\x64\Release\fmt.lib;%(AdditionalDependencies) diff --git a/shadps4.sln b/shadps4.sln index 640bb8b8..811d9f6e 100644 --- a/shadps4.sln +++ b/shadps4.sln @@ -4,27 +4,35 @@ Microsoft Visual Studio Solution File, Format Version 12.00 VisualStudioVersion = 17.5.33516.290 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "emulator", "emulator\emulator.vcxproj", "{A9F02793-712D-4602-BF3F-14473D492952}" + ProjectSection(ProjectDependencies) = postProject + {71772007-5110-418D-BE9C-FB102B6EAABF} = {71772007-5110-418D-BE9C-FB102B6EAABF} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fmt", "vstudioprj\fmt\fmt.vcxproj", "{71772007-5110-418D-BE9C-FB102B6EAABF}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "3rdparty", "3rdparty", "{23D42BBC-3031-4224-ACAA-C1540F05AFCC}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 Release|x64 = Release|x64 - Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {A9F02793-712D-4602-BF3F-14473D492952}.Debug|x64.ActiveCfg = Debug|x64 {A9F02793-712D-4602-BF3F-14473D492952}.Debug|x64.Build.0 = Debug|x64 - {A9F02793-712D-4602-BF3F-14473D492952}.Debug|x86.ActiveCfg = Debug|Win32 - {A9F02793-712D-4602-BF3F-14473D492952}.Debug|x86.Build.0 = Debug|Win32 {A9F02793-712D-4602-BF3F-14473D492952}.Release|x64.ActiveCfg = Release|x64 {A9F02793-712D-4602-BF3F-14473D492952}.Release|x64.Build.0 = Release|x64 - {A9F02793-712D-4602-BF3F-14473D492952}.Release|x86.ActiveCfg = Release|Win32 - {A9F02793-712D-4602-BF3F-14473D492952}.Release|x86.Build.0 = Release|Win32 + {71772007-5110-418D-BE9C-FB102B6EAABF}.Debug|x64.ActiveCfg = Debug|x64 + {71772007-5110-418D-BE9C-FB102B6EAABF}.Debug|x64.Build.0 = Debug|x64 + {71772007-5110-418D-BE9C-FB102B6EAABF}.Release|x64.ActiveCfg = Release|x64 + {71772007-5110-418D-BE9C-FB102B6EAABF}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {71772007-5110-418D-BE9C-FB102B6EAABF} = {23D42BBC-3031-4224-ACAA-C1540F05AFCC} + EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {5ED4FBB3-A0BC-4244-B8FE-93A2BF2C1C9A} EndGlobalSection diff --git a/vstudioprj/common.props b/vstudioprj/common.props new file mode 100644 index 00000000..3af825b8 --- /dev/null +++ b/vstudioprj/common.props @@ -0,0 +1,24 @@ + + + + + x64 + + + + + true + $(SolutionDir)\third_party\fmt\include;%(AdditionalIncludeDirectories) + stdcpplatest + _CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;WIN32;_WINDOWS;%(PreprocessorDefinitions) + false + false + 4244;%(DisableSpecificWarnings) + false + + + crypt32.lib;normaliz.lib;wldap32.lib;%(AdditionalDependencies) + + + + \ No newline at end of file diff --git a/vstudioprj/fmt/fmt.vcxproj b/vstudioprj/fmt/fmt.vcxproj new file mode 100644 index 00000000..9b6e2762 --- /dev/null +++ b/vstudioprj/fmt/fmt.vcxproj @@ -0,0 +1,103 @@ + + + + + Debug + x64 + + + Release + x64 + + + + 16.0 + {71772007-5110-418D-BE9C-FB102B6EAABF} + fmt + 10.0 + + + + StaticLibrary + true + v143 + Unicode + + + StaticLibrary + false + v143 + true + Unicode + + + + + + + + + + + + + + + + + false + + + true + + + + Level3 + true + true + true + NDEBUG;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + true + _DEBUG;%(PreprocessorDefinitions) + true + + + Console + true + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/vstudioprj/fmt/fmt.vcxproj.filters b/vstudioprj/fmt/fmt.vcxproj.filters new file mode 100644 index 00000000..8a1fe3d6 --- /dev/null +++ b/vstudioprj/fmt/fmt.vcxproj.filters @@ -0,0 +1,66 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + \ No newline at end of file