Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #9304 from lioncash/panic
General: Convert PanicAlerts over to fmt equivalent
  • Loading branch information
leoetlino committed Dec 2, 2020
2 parents 00f2e0e + 139d4fc commit b148b56
Show file tree
Hide file tree
Showing 45 changed files with 206 additions and 195 deletions.
7 changes: 4 additions & 3 deletions Source/Core/Common/ChunkFile.h
Expand Up @@ -267,9 +267,10 @@ class PointerWrap

if (mode == PointerWrap::MODE_READ && cookie != arbitraryNumber)
{
PanicAlertT("Error: After \"%s\", found %d (0x%X) instead of save marker %d (0x%X). Aborting "
"savestate load...",
prevName.c_str(), cookie, cookie, arbitraryNumber, arbitraryNumber);
PanicAlertFmtT(
"Error: After \"{0}\", found {1} ({2:#x}) instead of save marker {3} ({4:#x}). Aborting "
"savestate load...",
prevName, cookie, cookie, arbitraryNumber, arbitraryNumber);
mode = PointerWrap::MODE_MEASURE;
}
}
Expand Down
16 changes: 8 additions & 8 deletions Source/Core/Common/GL/GLInterface/WGL.cpp
Expand Up @@ -277,27 +277,27 @@ bool GLContextWGL::Initialize(const WindowSystemInfo& wsi, bool stereo, bool cor
m_dc = GetDC(m_window_handle);
if (!m_dc)
{
PanicAlert("(1) Can't create an OpenGL Device context. Fail.");
PanicAlertFmt("(1) Can't create an OpenGL Device context. Fail.");
return false;
}

int pixel_format = ChoosePixelFormat(m_dc, &pfd);
if (!pixel_format)
const int pixel_format = ChoosePixelFormat(m_dc, &pfd);
if (pixel_format == 0)
{
PanicAlert("(2) Can't find a suitable PixelFormat.");
PanicAlertFmt("(2) Can't find a suitable PixelFormat.");
return false;
}

if (!SetPixelFormat(m_dc, pixel_format, &pfd))
{
PanicAlert("(3) Can't set the PixelFormat.");
PanicAlertFmt("(3) Can't set the PixelFormat.");
return false;
}

m_rc = wglCreateContext(m_dc);
if (!m_rc)
{
PanicAlert("(4) Can't create an OpenGL rendering context.");
PanicAlertFmt("(4) Can't create an OpenGL rendering context.");
return false;
}

Expand All @@ -310,7 +310,7 @@ bool GLContextWGL::Initialize(const WindowSystemInfo& wsi, bool stereo, bool cor
// This is because we need an active context to use wglCreateContextAttribsARB.
if (!wglMakeCurrent(m_dc, m_rc))
{
PanicAlert("(5) Can't make dummy WGL context current.");
PanicAlertFmt("(5) Can't make dummy WGL context current.");
return false;
}

Expand All @@ -324,7 +324,7 @@ bool GLContextWGL::Initialize(const WindowSystemInfo& wsi, bool stereo, bool cor
// context. If we didn't get a core context, the caller expects that the context is not current.
if (!wglMakeCurrent(m_dc, nullptr))
{
PanicAlert("(6) Failed to switch out temporary context");
PanicAlertFmt("(6) Failed to switch out temporary context");
return false;
}

Expand Down
4 changes: 2 additions & 2 deletions Source/Core/Common/MemArena.cpp
Expand Up @@ -145,7 +145,7 @@ u8* MemArena::FindMemoryBase()
u8* base = static_cast<u8*>(VirtualAlloc(nullptr, memory_size, MEM_RESERVE, PAGE_READWRITE));
if (!base)
{
PanicAlert("Failed to map enough memory space: %s", GetLastErrorString().c_str());
PanicAlertFmt("Failed to map enough memory space: {}", GetLastErrorString());
return nullptr;
}
VirtualFree(base, 0, MEM_RELEASE);
Expand All @@ -162,7 +162,7 @@ u8* MemArena::FindMemoryBase()
void* base = mmap(nullptr, memory_size, PROT_NONE, flags, -1, 0);
if (base == MAP_FAILED)
{
PanicAlert("Failed to map enough memory space: %s", LastStrerrorString().c_str());
PanicAlertFmt("Failed to map enough memory space: {}", LastStrerrorString());
return nullptr;
}
munmap(base, memory_size);
Expand Down
22 changes: 11 additions & 11 deletions Source/Core/Common/MemoryUtil.cpp
Expand Up @@ -46,7 +46,7 @@ void* AllocateExecutableMemory(size_t size)
#endif

if (ptr == nullptr)
PanicAlert("Failed to allocate executable memory");
PanicAlertFmt("Failed to allocate executable memory");

return ptr;
}
Expand All @@ -63,7 +63,7 @@ void* AllocateMemoryPages(size_t size)
#endif

if (ptr == nullptr)
PanicAlert("Failed to allocate raw memory");
PanicAlertFmt("Failed to allocate raw memory");

return ptr;
}
Expand All @@ -79,7 +79,7 @@ void* AllocateAlignedMemory(size_t size, size_t alignment)
#endif

if (ptr == nullptr)
PanicAlert("Failed to allocate aligned memory");
PanicAlertFmt("Failed to allocate aligned memory");

return ptr;
}
Expand All @@ -90,10 +90,10 @@ void FreeMemoryPages(void* ptr, size_t size)
{
#ifdef _WIN32
if (!VirtualFree(ptr, 0, MEM_RELEASE))
PanicAlert("FreeMemoryPages failed!\nVirtualFree: %s", GetLastErrorString().c_str());
PanicAlertFmt("FreeMemoryPages failed!\nVirtualFree: {}", GetLastErrorString());
#else
if (munmap(ptr, size) != 0)
PanicAlert("FreeMemoryPages failed!\nmunmap: %s", LastStrerrorString().c_str());
PanicAlertFmt("FreeMemoryPages failed!\nmunmap: {}", LastStrerrorString());
#endif
}
}
Expand All @@ -115,10 +115,10 @@ void ReadProtectMemory(void* ptr, size_t size)
#ifdef _WIN32
DWORD oldValue;
if (!VirtualProtect(ptr, size, PAGE_NOACCESS, &oldValue))
PanicAlert("ReadProtectMemory failed!\nVirtualProtect: %s", GetLastErrorString().c_str());
PanicAlertFmt("ReadProtectMemory failed!\nVirtualProtect: {}", GetLastErrorString());
#else
if (mprotect(ptr, size, PROT_NONE) != 0)
PanicAlert("ReadProtectMemory failed!\nmprotect: %s", LastStrerrorString().c_str());
PanicAlertFmt("ReadProtectMemory failed!\nmprotect: {}", LastStrerrorString());
#endif
}

Expand All @@ -127,10 +127,10 @@ void WriteProtectMemory(void* ptr, size_t size, bool allowExecute)
#ifdef _WIN32
DWORD oldValue;
if (!VirtualProtect(ptr, size, allowExecute ? PAGE_EXECUTE_READ : PAGE_READONLY, &oldValue))
PanicAlert("WriteProtectMemory failed!\nVirtualProtect: %s", GetLastErrorString().c_str());
PanicAlertFmt("WriteProtectMemory failed!\nVirtualProtect: {}", GetLastErrorString());
#else
if (mprotect(ptr, size, allowExecute ? (PROT_READ | PROT_EXEC) : PROT_READ) != 0)
PanicAlert("WriteProtectMemory failed!\nmprotect: %s", LastStrerrorString().c_str());
PanicAlertFmt("WriteProtectMemory failed!\nmprotect: {}", LastStrerrorString());
#endif
}

Expand All @@ -139,12 +139,12 @@ void UnWriteProtectMemory(void* ptr, size_t size, bool allowExecute)
#ifdef _WIN32
DWORD oldValue;
if (!VirtualProtect(ptr, size, allowExecute ? PAGE_EXECUTE_READWRITE : PAGE_READWRITE, &oldValue))
PanicAlert("UnWriteProtectMemory failed!\nVirtualProtect: %s", GetLastErrorString().c_str());
PanicAlertFmt("UnWriteProtectMemory failed!\nVirtualProtect: {}", GetLastErrorString());
#else
if (mprotect(ptr, size,
allowExecute ? (PROT_READ | PROT_WRITE | PROT_EXEC) : PROT_WRITE | PROT_READ) != 0)
{
PanicAlert("UnWriteProtectMemory failed!\nmprotect: %s", LastStrerrorString().c_str());
PanicAlertFmt("UnWriteProtectMemory failed!\nmprotect: {}", LastStrerrorString());
}
#endif
}
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Common/TraversalClient.cpp
Expand Up @@ -77,7 +77,7 @@ void TraversalClient::ConnectToClient(const std::string& host)
{
if (host.size() > sizeof(TraversalHostId))
{
PanicAlert("host too long");
PanicAlertFmt("Host too long");
return;
}
TraversalPacket packet = {};
Expand Down
36 changes: 21 additions & 15 deletions Source/Core/Common/x64Emitter.cpp
Expand Up @@ -1028,14 +1028,14 @@ void XEmitter::TZCNT(int bits, X64Reg dest, const OpArg& src)
{
CheckFlags();
if (!cpu_info.bBMI1)
PanicAlert("Trying to use BMI1 on a system that doesn't support it. Bad programmer.");
PanicAlertFmt("Trying to use BMI1 on a system that doesn't support it. Bad programmer.");
WriteBitSearchType(bits, dest, src, 0xBC, true);
}
void XEmitter::LZCNT(int bits, X64Reg dest, const OpArg& src)
{
CheckFlags();
if (!cpu_info.bLZCNT)
PanicAlert("Trying to use LZCNT on a system that doesn't support it. Bad programmer.");
PanicAlertFmt("Trying to use LZCNT on a system that doesn't support it. Bad programmer.");
WriteBitSearchType(bits, dest, src, 0xBD, true);
}

Expand Down Expand Up @@ -1880,41 +1880,47 @@ void XEmitter::WriteAVXOp(u8 opPrefix, u16 op, X64Reg regOp1, X64Reg regOp2, con
int W, int extrabytes)
{
if (!cpu_info.bAVX)
PanicAlert("Trying to use AVX on a system that doesn't support it. Bad programmer.");
PanicAlertFmt("Trying to use AVX on a system that doesn't support it. Bad programmer.");
WriteVEXOp(opPrefix, op, regOp1, regOp2, arg, W, extrabytes);
}

void XEmitter::WriteAVXOp4(u8 opPrefix, u16 op, X64Reg regOp1, X64Reg regOp2, const OpArg& arg,
X64Reg regOp3, int W)
{
if (!cpu_info.bAVX)
PanicAlert("Trying to use AVX on a system that doesn't support it. Bad programmer.");
PanicAlertFmt("Trying to use AVX on a system that doesn't support it. Bad programmer.");
WriteVEXOp4(opPrefix, op, regOp1, regOp2, arg, regOp3, W);
}

void XEmitter::WriteFMA3Op(u8 op, X64Reg regOp1, X64Reg regOp2, const OpArg& arg, int W)
{
if (!cpu_info.bFMA)
PanicAlert("Trying to use FMA3 on a system that doesn't support it. Computer is v. f'n madd.");
{
PanicAlertFmt(
"Trying to use FMA3 on a system that doesn't support it. Computer is v. f'n madd.");
}
WriteVEXOp(0x66, 0x3800 | op, regOp1, regOp2, arg, W);
}

void XEmitter::WriteFMA4Op(u8 op, X64Reg dest, X64Reg regOp1, X64Reg regOp2, const OpArg& arg,
int W)
{
if (!cpu_info.bFMA4)
PanicAlert("Trying to use FMA4 on a system that doesn't support it. Computer is v. f'n madd.");
{
PanicAlertFmt(
"Trying to use FMA4 on a system that doesn't support it. Computer is v. f'n madd.");
}
WriteVEXOp4(0x66, 0x3A00 | op, dest, regOp1, arg, regOp2, W);
}

void XEmitter::WriteBMIOp(int size, u8 opPrefix, u16 op, X64Reg regOp1, X64Reg regOp2,
const OpArg& arg, int extrabytes)
{
if (arg.IsImm())
PanicAlert("BMI1/2 instructions don't support immediate operands.");
PanicAlertFmt("BMI1/2 instructions don't support immediate operands.");
if (size != 32 && size != 64)
PanicAlert("BMI1/2 instructions only support 32-bit and 64-bit modes!");
int W = size == 64;
PanicAlertFmt("BMI1/2 instructions only support 32-bit and 64-bit modes!");
const int W = size == 64;
WriteVEXOp(opPrefix, op, regOp1, regOp2, arg, W, extrabytes);
}

Expand All @@ -1923,15 +1929,15 @@ void XEmitter::WriteBMI1Op(int size, u8 opPrefix, u16 op, X64Reg regOp1, X64Reg
{
CheckFlags();
if (!cpu_info.bBMI1)
PanicAlert("Trying to use BMI1 on a system that doesn't support it. Bad programmer.");
PanicAlertFmt("Trying to use BMI1 on a system that doesn't support it. Bad programmer.");
WriteBMIOp(size, opPrefix, op, regOp1, regOp2, arg, extrabytes);
}

void XEmitter::WriteBMI2Op(int size, u8 opPrefix, u16 op, X64Reg regOp1, X64Reg regOp2,
const OpArg& arg, int extrabytes)
{
if (!cpu_info.bBMI2)
PanicAlert("Trying to use BMI2 on a system that doesn't support it. Bad programmer.");
PanicAlertFmt("Trying to use BMI2 on a system that doesn't support it. Bad programmer.");
WriteBMIOp(size, opPrefix, op, regOp1, regOp2, arg, extrabytes);
}

Expand Down Expand Up @@ -2580,7 +2586,7 @@ void XEmitter::PSLLDQ(X64Reg reg, int shift)
void XEmitter::PSRAW(X64Reg reg, int shift)
{
if (reg > 7)
PanicAlert("The PSRAW-emitter does not support regs above 7");
PanicAlertFmt("The PSRAW-emitter does not support regs above 7");
Write8(0x66);
Write8(0x0f);
Write8(0x71);
Expand All @@ -2592,7 +2598,7 @@ void XEmitter::PSRAW(X64Reg reg, int shift)
void XEmitter::PSRAD(X64Reg reg, int shift)
{
if (reg > 7)
PanicAlert("The PSRAD-emitter does not support regs above 7");
PanicAlertFmt("The PSRAD-emitter does not support regs above 7");
Write8(0x66);
Write8(0x0f);
Write8(0x72);
Expand All @@ -2603,14 +2609,14 @@ void XEmitter::PSRAD(X64Reg reg, int shift)
void XEmitter::WriteSSSE3Op(u8 opPrefix, u16 op, X64Reg regOp, const OpArg& arg, int extrabytes)
{
if (!cpu_info.bSSSE3)
PanicAlert("Trying to use SSSE3 on a system that doesn't support it. Bad programmer.");
PanicAlertFmt("Trying to use SSSE3 on a system that doesn't support it. Bad programmer.");
WriteSSEOp(opPrefix, op, regOp, arg, extrabytes);
}

void XEmitter::WriteSSE41Op(u8 opPrefix, u16 op, X64Reg regOp, const OpArg& arg, int extrabytes)
{
if (!cpu_info.bSSE4_1)
PanicAlert("Trying to use SSE4.1 on a system that doesn't support it. Bad programmer.");
PanicAlertFmt("Trying to use SSE4.1 on a system that doesn't support it. Bad programmer.");
WriteSSEOp(opPrefix, op, regOp, arg, extrabytes);
}

Expand Down
6 changes: 3 additions & 3 deletions Source/Core/VideoBackends/D3D/D3DBase.cpp
Expand Up @@ -43,7 +43,7 @@ bool Create(u32 adapter_index, bool enable_debug_layer)
if (!s_d3d11_library.Open("d3d11.dll") ||
!s_d3d11_library.GetSymbol("D3D11CreateDevice", &d3d11_create_device))
{
PanicAlertT("Failed to load d3d11.dll");
PanicAlertFmtT("Failed to load d3d11.dll");
s_d3d11_library.Close();
return false;
}
Expand All @@ -57,7 +57,7 @@ bool Create(u32 adapter_index, bool enable_debug_layer)
dxgi_factory = D3DCommon::CreateDXGIFactory(enable_debug_layer);
if (!dxgi_factory)
{
PanicAlertT("Failed to create DXGI factory");
PanicAlertFmtT("Failed to create DXGI factory");
D3DCommon::UnloadLibraries();
s_d3d11_library.Close();
return false;
Expand Down Expand Up @@ -113,7 +113,7 @@ bool Create(u32 adapter_index, bool enable_debug_layer)

if (FAILED(hr))
{
PanicAlertT(
PanicAlertFmtT(
"Failed to initialize Direct3D.\nMake sure your video card supports at least D3D 10.0");
dxgi_factory.Reset();
D3DCommon::UnloadLibraries();
Expand Down
12 changes: 6 additions & 6 deletions Source/Core/VideoBackends/D3D/DXTexture.cpp
Expand Up @@ -45,8 +45,8 @@ std::unique_ptr<DXTexture> DXTexture::Create(const TextureConfig& config)
HRESULT hr = D3D::device->CreateTexture2D(&desc, nullptr, d3d_texture.GetAddressOf());
if (FAILED(hr))
{
PanicAlert("Failed to create %ux%ux%u D3D backing texture", config.width, config.height,
config.layers);
PanicAlertFmt("Failed to create {}x{}x{} D3D backing texture", config.width, config.height,
config.layers);
return nullptr;
}

Expand Down Expand Up @@ -92,8 +92,8 @@ bool DXTexture::CreateSRV()
HRESULT hr = D3D::device->CreateShaderResourceView(m_texture.Get(), &desc, m_srv.GetAddressOf());
if (FAILED(hr))
{
PanicAlert("Failed to create %ux%ux%u D3D SRV", m_config.width, m_config.height,
m_config.layers);
PanicAlertFmt("Failed to create {}x{}x{} D3D SRV", m_config.width, m_config.height,
m_config.layers);
return false;
}

Expand All @@ -109,8 +109,8 @@ bool DXTexture::CreateUAV()
HRESULT hr = D3D::device->CreateUnorderedAccessView(m_texture.Get(), &desc, m_uav.GetAddressOf());
if (FAILED(hr))
{
PanicAlert("Failed to create %ux%ux%u D3D UAV", m_config.width, m_config.height,
m_config.layers);
PanicAlertFmt("Failed to create {}x{}x{} D3D UAV", m_config.width, m_config.height,
m_config.layers);
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion Source/Core/VideoBackends/D3D/NativeVertexFormat.cpp
Expand Up @@ -72,7 +72,7 @@ DXGI_FORMAT VarToD3D(VarType t, int size, bool integer)
DXGI_FORMAT retval = d3d_format_lookup[(int)t + 5 * (size - 1) + 5 * 4 * (int)integer];
if (retval == DXGI_FORMAT_UNKNOWN)
{
PanicAlert("VarToD3D: Invalid type/size combo %i , %i, %i", (int)t, size, (int)integer);
PanicAlertFmt("VarToD3D: Invalid type/size combo {}, {}, {}", t, size, integer);
}
return retval;
}
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/VideoBackends/D3D/main.cpp
Expand Up @@ -143,7 +143,7 @@ bool VideoBackend::Initialize(const WindowSystemInfo& wsi)
std::unique_ptr<SwapChain> swap_chain;
if (wsi.render_surface && !(swap_chain = SwapChain::Create(wsi)))
{
PanicAlertT("Failed to create D3D swap chain");
PanicAlertFmtT("Failed to create D3D swap chain");
ShutdownShared();
D3D::Destroy();
return false;
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/VideoBackends/D3D12/BoundingBox.cpp
Expand Up @@ -152,7 +152,7 @@ void BoundingBox::Flush()
Renderer::GetInstance()->ExecuteCommandList(false);
if (!m_upload_buffer.ReserveMemory(copy_size, sizeof(ValueType)))
{
PanicAlert("Failed to allocate bbox stream buffer space");
PanicAlertFmt("Failed to allocate bbox stream buffer space");
return;
}
}
Expand Down

0 comments on commit b148b56

Please sign in to comment.