diff options
| author | Egor Yusov <egor.yusov@gmail.com> | 2017-12-21 03:07:18 +0000 |
|---|---|---|
| committer | Egor Yusov <egor.yusov@gmail.com> | 2017-12-21 03:07:18 +0000 |
| commit | abbde42c66eab273e9c8ce7f02fa427b4238beca (patch) | |
| tree | 5413528cb9f1c45d3bb7dcf79bd18ab42966b4de | |
| parent | Enabling linux build (in progress) (diff) | |
| download | DiligentCore-abbde42c66eab273e9c8ce7f02fa427b4238beca.tar.gz DiligentCore-abbde42c66eab273e9c8ce7f02fa427b4238beca.zip | |
Udated PlatformDebug; implemented LinuxDebug
| -rw-r--r-- | Platforms/Android/src/AndroidDebug.cpp | 10 | ||||
| -rw-r--r-- | Platforms/Basic/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | Platforms/Basic/include/BasicPlatformDebug.h | 1 | ||||
| -rw-r--r-- | Platforms/Basic/src/BasicPlatformDebug.cpp | 43 | ||||
| -rw-r--r-- | Platforms/Linux/src/LinuxDebug.cpp | 32 | ||||
| -rw-r--r-- | Platforms/UWP/src/UWPDebug.cpp | 16 | ||||
| -rw-r--r-- | Platforms/Win32/src/Win32Debug.cpp | 14 |
7 files changed, 74 insertions, 43 deletions
diff --git a/Platforms/Android/src/AndroidDebug.cpp b/Platforms/Android/src/AndroidDebug.cpp index 6ff13e14..419566b8 100644 --- a/Platforms/Android/src/AndroidDebug.cpp +++ b/Platforms/Android/src/AndroidDebug.cpp @@ -29,12 +29,8 @@ void AndroidDebug :: AssertionFailed( const Diligent::Char *Message, const char *Function, const char *File, int Line ) { - std::string FileName; - FileSystem::SplitFilePath( File, nullptr, &FileName ); - std::stringstream msgss; - Diligent::FormatMsg( msgss, "\nDebug assertion failed in ", Function, "(), file ", FileName, ", line ", Line, ":\n", Message); - auto FullMsg = msgss.str(); - OutputDebugMessage( DebugMessageSeverity::Error, FullMsg.c_str() ); + auto AssertionFailedMessage = FormatAssertionFailedMessage(Message, Function, File, Line); + OutputDebugMessage( DebugMessageSeverity::Error, AssertionFailedMessage.c_str() ); raise( SIGTRAP ); }; @@ -43,5 +39,5 @@ void AndroidDebug :: AssertionFailed( const Diligent::Char *Message, const char void AndroidDebug::OutputDebugMessage( DebugMessageSeverity Severity, const Diligent::Char *Message ) { static const android_LogPriority Priorities[] = { ANDROID_LOG_INFO, ANDROID_LOG_WARN, ANDROID_LOG_ERROR, ANDROID_LOG_FATAL }; - __android_log_print( Priorities[static_cast<int>(Severity)], "Graphics Engine", "%s", Message ); + __android_log_print( Priorities[static_cast<int>(Severity)], "Diligent Engine", "%s", Message ); } diff --git a/Platforms/Basic/CMakeLists.txt b/Platforms/Basic/CMakeLists.txt index 1a08f952..055258fd 100644 --- a/Platforms/Basic/CMakeLists.txt +++ b/Platforms/Basic/CMakeLists.txt @@ -4,6 +4,7 @@ project(BasicPlatform CXX) set(SOURCE src/BasicFileSystem.cpp + src/BasicPlatformDebug.cpp ) set(INCLUDE diff --git a/Platforms/Basic/include/BasicPlatformDebug.h b/Platforms/Basic/include/BasicPlatformDebug.h index f82a9f13..6bc76eb0 100644 --- a/Platforms/Basic/include/BasicPlatformDebug.h +++ b/Platforms/Basic/include/BasicPlatformDebug.h @@ -37,4 +37,5 @@ struct BasicPlatformDebug static void AssertionFailed( const Diligent::Char* /*Message*/, const char* /*Function*/, const char* /*File*/, int /*Line*/ ){} static void OutputDebugMessage( DebugMessageSeverity /*Severity*/, const Diligent::Char* /*Message */){} + static Diligent::String FormatAssertionFailedMessage(const Diligent::Char* /*Message*/, const char* /*Function*/, const char* /*File*/, int /*Line*/); }; diff --git a/Platforms/Basic/src/BasicPlatformDebug.cpp b/Platforms/Basic/src/BasicPlatformDebug.cpp new file mode 100644 index 00000000..6ed3e662 --- /dev/null +++ b/Platforms/Basic/src/BasicPlatformDebug.cpp @@ -0,0 +1,43 @@ +/* Copyright 2015-2017 Egor Yusov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent acts) or agreed to in writing, shall any Contributor be + * liable for any damages, including any direct, indirect, special, incidental, + * or consequential damages of any character arising as a result of this License or + * out of the use or inability to use the software (including but not limited to damages + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "pch.h" + +#include "BasicPlatformDebug.h" +#include "FormatMessage.h" +#include "BasicFileSystem.h" +#include <iostream> + +using namespace Diligent; + +String BasicPlatformDebug :: FormatAssertionFailedMessage( const Diligent::Char *Message, + const char *Function, + const char *File, + int Line ) +{ + std::string FileName; + BasicFileSystem::SplitFilePath( File, nullptr, &FileName ); + std::stringstream msgss; + Diligent::FormatMsg( msgss, "Debug assertion failed in ", Function, "(), file ", FileName, ", line ", Line, ":\n", Message); + return msgss.str(); +} diff --git a/Platforms/Linux/src/LinuxDebug.cpp b/Platforms/Linux/src/LinuxDebug.cpp index 2ffb7a12..b143e1af 100644 --- a/Platforms/Linux/src/LinuxDebug.cpp +++ b/Platforms/Linux/src/LinuxDebug.cpp @@ -21,30 +21,30 @@ * of the possibility of such damages. */ +#include <csignal> +#include <iostream> + #include "LinuxDebug.h" #include "FormatMessage.h" #include "FileSystem.h" -//#include <Linux/log.h> -#include <csignal> -#include <cassert> -void LinuxDebug :: AssertionFailed( const Diligent::Char *Message, const char *Function, const char *File, int Line ) +using namespace Diligent; + +void LinuxDebug :: AssertionFailed( const Char *Message, const char *Function, const char *File, int Line ) { - assert(false); - //std::string FileName; - //FileSystem::SplitFilePath( File, nullptr, &FileName ); - //std::stringstream msgss; - //Diligent::FormatMsg( msgss, "\nDebug assertion failed in ", Function, "(), file ", FileName, ", line ", Line, ":\n", Message); - //auto FullMsg = msgss.str(); - //OutputDebugMessage( DebugMessageSeverity::Error, FullMsg.c_str() ); + auto AssertionFailedMessage = FormatAssertionFailedMessage(Message, Function, File, Line); + OutputDebugMessage(DebugMessageSeverity::Error, AssertionFailedMessage.c_str()); - //raise( SIGTRAP ); + raise( SIGTRAP ); }; -void LinuxDebug::OutputDebugMessage( DebugMessageSeverity Severity, const Diligent::Char *Message ) +void LinuxDebug::OutputDebugMessage( DebugMessageSeverity Severity, const Char *Message ) { - assert(false); - //static const Linux_LogPriority Priorities[] = { Linux_LOG_INFO, Linux_LOG_WARN, Linux_LOG_ERROR, Linux_LOG_FATAL }; - //__Linux_log_print( Priorities[static_cast<int>(Severity)], "Graphics Engine", "%s", Message ); + static const Char* const strSeverities[] = { "Info: ", "Warning: ", "ERROR: ", "CRITICAL ERROR: " }; + auto* MessageSevery = strSeverities[static_cast<int>(Severity)]; + String str = MessageSevery; + str += Message; + str += '\n'; + std::cerr << str; } diff --git a/Platforms/UWP/src/UWPDebug.cpp b/Platforms/UWP/src/UWPDebug.cpp index 8a11f835..f95daed7 100644 --- a/Platforms/UWP/src/UWPDebug.cpp +++ b/Platforms/UWP/src/UWPDebug.cpp @@ -35,12 +35,8 @@ using namespace Diligent; void WindowsStoreDebug :: AssertionFailed( const Diligent::Char *Message, const char *Function, const char *File, int Line ) { - std::string FileName; - FileSystem::SplitFilePath( File, nullptr, &FileName ); - std::stringstream msgss; - Diligent::FormatMsg( msgss, "Debug assertion failed in ", Function, "(), file ", FileName, ", line ", Line, ":\n\n", Message); - auto FullMsg = msgss.str(); - OutputDebugMessage( DebugMessageSeverity::Error, FullMsg.c_str() ); + auto AssertionFailedMessage = FormatAssertionFailedMessage(Message, Function, File, Line); + OutputDebugMessage( DebugMessageSeverity::Error, AssertionFailedMessage.c_str() ); __debugbreak(); //int nCode = MessageBoxA(NULL, @@ -75,10 +71,10 @@ void WindowsStoreDebug :: AssertionFailed( const Diligent::Char *Message, const void WindowsStoreDebug::OutputDebugMessage( DebugMessageSeverity Severity, const Diligent::Char *Message ) { - String str = Message; + static const Char* const strSeverities[] = { "Info: ", "Warning: ", "ERROR: ", "CRITICAL ERROR: " }; + auto* MessageSevery = strSeverities[static_cast<int>(Severity)]; + String str = MessageSevery; + str += Message; str += '\n'; - static Char* strSeverities[] = { "Info: ", "Warning: ", "ERROR: ", "CRITICAL ERROR: " }; - auto* MessageSevery = strSeverities[ static_cast<int>(Severity) ]; - str += MessageSevery; OutputDebugStringA( str.c_str() ); } diff --git a/Platforms/Win32/src/Win32Debug.cpp b/Platforms/Win32/src/Win32Debug.cpp index 1d2398b8..acba898c 100644 --- a/Platforms/Win32/src/Win32Debug.cpp +++ b/Platforms/Win32/src/Win32Debug.cpp @@ -34,17 +34,11 @@ using namespace Diligent; void WindowsDebug :: AssertionFailed( const Diligent::Char *Message, const char *Function, const char *File, int Line ) { - std::string FileName; - FileSystem::SplitFilePath( File, nullptr, &FileName ); - std::stringstream msgss; - Diligent::FormatMsg( msgss, "Debug assertion failed in ", Function, "(), file ", FileName, ", line ", Line, ":\n"); - auto Msg = msgss.str(); - String DebugOutput = Msg + Message; - OutputDebugMessage( DebugMessageSeverity::Error, DebugOutput.c_str()); + auto AssertionFailedMessage = FormatAssertionFailedMessage(Message, Function, File, Line); + OutputDebugMessage( DebugMessageSeverity::Error, AssertionFailedMessage.c_str()); - String MBText = Msg + "\n" + Message; int nCode = MessageBoxA(NULL, - MBText.c_str(), + AssertionFailedMessage.c_str(), "Runtime assertion failed", MB_TASKMODAL|MB_ICONHAND|MB_ABORTRETRYIGNORE|MB_SETFOREGROUND); @@ -74,7 +68,7 @@ void WindowsDebug :: AssertionFailed( const Diligent::Char *Message, const char void WindowsDebug::OutputDebugMessage( DebugMessageSeverity Severity, const Diligent::Char *Message ) { - static Char* strSeverities[] = { "Info: ", "Warning: ", "ERROR: ", "CRITICAL ERROR: " }; + static const Char* const strSeverities[] = { "Info: ", "Warning: ", "ERROR: ", "CRITICAL ERROR: " }; auto* MessageSevery = strSeverities[ static_cast<int>(Severity) ]; String str = MessageSevery; str += Message; |
