summaryrefslogtreecommitdiff
path: root/wrappers
diff options
context:
space:
mode:
authorJose Fonseca <jfonseca@vmware.com>2015-04-10 15:00:50 +0100
committerJose Fonseca <jfonseca@vmware.com>2015-04-10 15:04:55 +0100
commit8a1ba73572c713e298ae53821d000fc3a5087b5f (patch)
treef4fca9d22ca7b417a48b9f1a78a0778618e7bc27 /wrappers
parentd9092b390c97e4bd2096904d5401d7a94f106c78 (diff)
dxgitrace: Redirect output of assertions failures on Windows.
Diffstat (limited to 'wrappers')
-rw-r--r--wrappers/CMakeLists.txt35
-rw-r--r--wrappers/assert.cpp65
2 files changed, 82 insertions, 18 deletions
diff --git a/wrappers/CMakeLists.txt b/wrappers/CMakeLists.txt
index 40f81f5d..5d5bf6bb 100644
--- a/wrappers/CMakeLists.txt
+++ b/wrappers/CMakeLists.txt
@@ -35,6 +35,14 @@ include_directories (
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
+add_convenience_library (trace
+ assert.cpp
+)
+target_link_libraries (trace
+ common
+ ${SNAPPY_LIBRARIES}
+)
+
if (WIN32)
if (MINGW)
# Silence warnings about @nn suffix mismatch
@@ -62,8 +70,7 @@ if (WIN32)
)
add_library (ddrawtrace MODULE ddraw.def ddrawtrace.cpp)
target_link_libraries (ddrawtrace
- common
- ${SNAPPY_LIBRARIES}
+ trace
)
set_target_properties (ddrawtrace PROPERTIES
PREFIX ""
@@ -97,8 +104,7 @@ if (WIN32)
)
target_link_libraries (d3d8trace
d3dhelpers
- common
- ${SNAPPY_LIBRARIES}
+ trace
)
set_target_properties (d3d8trace PROPERTIES
PREFIX ""
@@ -133,8 +139,7 @@ if (WIN32)
)
target_link_libraries (d3d9trace
d3dhelpers
- common
- ${SNAPPY_LIBRARIES}
+ trace
)
set_target_properties (d3d9trace PROPERTIES
PREFIX ""
@@ -173,8 +178,7 @@ if (WIN32)
)
target_link_libraries (dxgitrace
d3dhelpers
- common
- ${SNAPPY_LIBRARIES}
+ trace
)
set_target_properties (dxgitrace
PROPERTIES PREFIX ""
@@ -205,8 +209,7 @@ if (WIN32)
)
add_library (d2d1trace MODULE d2d1trace.def d2d1trace.cpp)
target_link_libraries (d2d1trace
- common
- ${SNAPPY_LIBRARIES}
+ trace
)
set_target_properties (d2d1trace
PROPERTIES PREFIX ""
@@ -242,8 +245,7 @@ if (WIN32)
target_link_libraries (wgltrace
glhelpers
glproc_gl
- common
- ${SNAPPY_LIBRARIES}
+ trace
)
set_target_properties (wgltrace PROPERTIES
PREFIX ""
@@ -290,8 +292,7 @@ elseif (APPLE)
target_link_libraries (cgltrace
glhelpers
glproc_gl
- common
- ${SNAPPY_LIBRARIES}
+ trace
${CMAKE_THREAD_LIBS_INIT}
dl
)
@@ -336,8 +337,7 @@ elseif (X11_FOUND)
target_link_libraries (glxtrace
glhelpers
glproc_gl
- common
- ${SNAPPY_LIBRARIES}
+ trace
${CMAKE_THREAD_LIBS_INIT}
dl
)
@@ -397,8 +397,7 @@ if (ENABLE_EGL AND NOT WIN32 AND NOT APPLE)
target_link_libraries (egltrace
glhelpers
glproc_egl
- common
- ${SNAPPY_LIBRARIES}
+ trace
${CMAKE_THREAD_LIBS_INIT}
dl
)
diff --git a/wrappers/assert.cpp b/wrappers/assert.cpp
new file mode 100644
index 00000000..4643799d
--- /dev/null
+++ b/wrappers/assert.cpp
@@ -0,0 +1,65 @@
+/**************************************************************************
+ *
+ * Copyright 2015 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * 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. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ **************************************************************************/
+
+
+/*
+ * It's convenient to just use the standard assert() macro, but on Windows we
+ * want to ensure the messages go to somewhere we can actually see.
+ */
+
+#if defined(_WIN32) && !defined(NDEBUG)
+
+
+#include <assert.h>
+
+#include "os.hpp"
+
+
+extern "C" void
+_assert(const char *_Message, const char *_File, unsigned _Line)
+{
+ os::log("XAssertion failed: %s, file %s, line %u\n", _Message, _File, _Line);
+ os::abort();
+}
+
+
+extern "C" void
+_wassert(const wchar_t * _Message, const wchar_t *_File, unsigned _Line)
+{
+ os::log("XAssertion failed: %S, file %S, line %u\n", _Message, _File, _Line);
+ os::abort();
+}
+
+
+// Hack to force this module to be linked on MinGW
+#ifdef __GNUC__
+__attribute__ ((constructor))
+static void
+force_link(void)
+{}
+#endif /* __GNUC__ */
+
+
+#endif /* _WIN32 && !NDEBUG */