Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 1 | /* |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 2 | * |
Courtney Goeltzenleuchter | fcbe16f | 2015-10-29 13:50:34 -0600 | [diff] [blame^] | 3 | * Copyright (C) 2015 Valve Corporation |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 4 | * |
| 5 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 6 | * copy of this software and associated documentation files (the "Software"), |
| 7 | * to deal in the Software without restriction, including without limitation |
| 8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 9 | * and/or sell copies of the Software, and to permit persons to whom the |
| 10 | * Software is furnished to do so, subject to the following conditions: |
| 11 | * |
| 12 | * The above copyright notice and this permission notice shall be included |
| 13 | * in all copies or substantial portions of the Software. |
| 14 | * |
| 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 18 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| 21 | * DEALINGS IN THE SOFTWARE. |
| 22 | * |
| 23 | * Authors: |
| 24 | * Jon Ashburn <jon@lunarg.com> |
| 25 | * Courtney Goeltzenleuchter <courtney@lunarg.com> |
| 26 | */ |
| 27 | |
Courtney Goeltzenleuchter | 7f5aafc | 2015-07-05 11:28:29 -0600 | [diff] [blame] | 28 | #define _GNU_SOURCE |
Courtney Goeltzenleuchter | 7dcc6a7 | 2015-06-11 16:01:11 -0600 | [diff] [blame] | 29 | #include <stdio.h> |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 30 | #include <string.h> |
| 31 | #include <stdlib.h> |
Courtney Goeltzenleuchter | 7dcc6a7 | 2015-06-11 16:01:11 -0600 | [diff] [blame] | 32 | #include <inttypes.h> |
Tony Barbour | 1d825c7 | 2015-06-18 16:29:32 -0600 | [diff] [blame] | 33 | #ifndef WIN32 |
Courtney Goeltzenleuchter | 03663d0 | 2015-07-22 11:01:53 -0600 | [diff] [blame] | 34 | #include <signal.h> |
| 35 | #else |
Tony Barbour | 1d825c7 | 2015-06-18 16:29:32 -0600 | [diff] [blame] | 36 | #endif |
Jon Ashburn | 480a50a | 2015-08-28 14:58:46 -0700 | [diff] [blame] | 37 | #include "vk_loader_platform.h" |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 38 | #include "debug_report.h" |
Tobin Ehlis | 0c6f9ee | 2015-07-03 09:42:57 -0600 | [diff] [blame] | 39 | #include "vk_layer.h" |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 40 | |
Courtney Goeltzenleuchter | 7dcc6a7 | 2015-06-11 16:01:11 -0600 | [diff] [blame] | 41 | typedef void (VKAPI *PFN_stringCallback)(char *message); |
| 42 | |
Jon Ashburn | 5c042ea | 2015-08-04 11:14:18 -0600 | [diff] [blame] | 43 | static const VkExtensionProperties debug_report_extension_info = { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 44 | .extensionName = VK_DEBUG_REPORT_EXTENSION_NAME, |
Ian Elliott | 464e0b5 | 2015-09-04 14:14:35 -0600 | [diff] [blame] | 45 | .specVersion = VK_DEBUG_REPORT_EXTENSION_REVISION, |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 46 | }; |
| 47 | |
| 48 | void debug_report_add_instance_extensions( |
Jon Ashburn | e39a4f8 | 2015-08-28 13:38:21 -0600 | [diff] [blame] | 49 | const struct loader_instance *inst, |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 50 | struct loader_extension_list *ext_list) |
| 51 | { |
Jon Ashburn | e39a4f8 | 2015-08-28 13:38:21 -0600 | [diff] [blame] | 52 | loader_add_to_ext_list(inst, ext_list, 1, &debug_report_extension_info); |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 53 | } |
| 54 | |
| 55 | void debug_report_create_instance( |
Courtney Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 56 | struct loader_instance *ptr_instance, |
| 57 | const VkInstanceCreateInfo *pCreateInfo) |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 58 | { |
Courtney Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 59 | ptr_instance->debug_report_enabled = false; |
| 60 | |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 61 | for (uint32_t i = 0; i < pCreateInfo->enabledExtensionNameCount; i++) { |
Courtney Goeltzenleuchter | 05159a9 | 2015-07-30 11:32:46 -0600 | [diff] [blame] | 62 | if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_DEBUG_REPORT_EXTENSION_NAME) == 0) { |
Courtney Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 63 | ptr_instance->debug_report_enabled = true; |
| 64 | return; |
| 65 | } |
| 66 | } |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 67 | } |
| 68 | |
| 69 | static VkResult debug_report_DbgCreateMsgCallback( |
| 70 | VkInstance instance, |
| 71 | VkFlags msgFlags, |
| 72 | const PFN_vkDbgMsgCallback pfnMsgCallback, |
| 73 | void* pUserData, |
| 74 | VkDbgMsgCallback* pMsgCallback) |
| 75 | { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 76 | VkLayerDbgFunctionNode *pNewDbgFuncNode = (VkLayerDbgFunctionNode *) loader_heap_alloc((struct loader_instance *)instance, sizeof(VkLayerDbgFunctionNode), VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 77 | if (!pNewDbgFuncNode) |
| 78 | return VK_ERROR_OUT_OF_HOST_MEMORY; |
| 79 | |
Jon Ashburn | e0e6457 | 2015-09-30 12:56:42 -0600 | [diff] [blame] | 80 | struct loader_instance *inst = loader_get_instance(instance); |
Jon Ashburn | 6301a0f | 2015-05-29 13:15:39 -0600 | [diff] [blame] | 81 | loader_platform_thread_lock_mutex(&loader_lock); |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 82 | VkResult result = inst->disp->DbgCreateMsgCallback(instance, msgFlags, pfnMsgCallback, pUserData, pMsgCallback); |
| 83 | if (result == VK_SUCCESS) { |
| 84 | pNewDbgFuncNode->msgCallback = *pMsgCallback; |
| 85 | pNewDbgFuncNode->pfnMsgCallback = pfnMsgCallback; |
| 86 | pNewDbgFuncNode->msgFlags = msgFlags; |
| 87 | pNewDbgFuncNode->pUserData = pUserData; |
| 88 | pNewDbgFuncNode->pNext = inst->DbgFunctionHead; |
| 89 | inst->DbgFunctionHead = pNewDbgFuncNode; |
| 90 | } else { |
Jon Ashburn | e39a4f8 | 2015-08-28 13:38:21 -0600 | [diff] [blame] | 91 | loader_heap_free((struct loader_instance *) instance, pNewDbgFuncNode); |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 92 | } |
Jon Ashburn | 6301a0f | 2015-05-29 13:15:39 -0600 | [diff] [blame] | 93 | loader_platform_thread_unlock_mutex(&loader_lock); |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 94 | return result; |
| 95 | } |
| 96 | |
| 97 | static VkResult debug_report_DbgDestroyMsgCallback( |
| 98 | VkInstance instance, |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 99 | VkDbgMsgCallback msg_callback) |
| 100 | { |
Jon Ashburn | e0e6457 | 2015-09-30 12:56:42 -0600 | [diff] [blame] | 101 | struct loader_instance *inst = loader_get_instance(instance); |
Jon Ashburn | 6301a0f | 2015-05-29 13:15:39 -0600 | [diff] [blame] | 102 | loader_platform_thread_lock_mutex(&loader_lock); |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 103 | VkLayerDbgFunctionNode *pTrav = inst->DbgFunctionHead; |
| 104 | VkLayerDbgFunctionNode *pPrev = pTrav; |
| 105 | |
Courtney Goeltzenleuchter | 7d0023c | 2015-06-08 15:09:22 -0600 | [diff] [blame] | 106 | VkResult result = inst->disp->DbgDestroyMsgCallback(instance, msg_callback); |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 107 | |
| 108 | while (pTrav) { |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 109 | if (pTrav->msgCallback == msg_callback) { |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 110 | pPrev->pNext = pTrav->pNext; |
| 111 | if (inst->DbgFunctionHead == pTrav) |
| 112 | inst->DbgFunctionHead = pTrav->pNext; |
Jon Ashburn | e39a4f8 | 2015-08-28 13:38:21 -0600 | [diff] [blame] | 113 | loader_heap_free((struct loader_instance *) instance, pTrav); |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 114 | break; |
| 115 | } |
| 116 | pPrev = pTrav; |
| 117 | pTrav = pTrav->pNext; |
| 118 | } |
| 119 | |
Jon Ashburn | 6301a0f | 2015-05-29 13:15:39 -0600 | [diff] [blame] | 120 | loader_platform_thread_unlock_mutex(&loader_lock); |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 121 | return result; |
| 122 | } |
| 123 | |
| 124 | |
| 125 | /* |
| 126 | * This is the instance chain terminator function |
| 127 | * for DbgCreateMsgCallback |
| 128 | */ |
Tony Barbour | 1d2cd3f | 2015-07-03 10:33:54 -0600 | [diff] [blame] | 129 | |
Dan Ginsburg | 78556e8 | 2015-07-23 13:15:00 -0400 | [diff] [blame] | 130 | VkResult VKAPI loader_DbgCreateMsgCallback( |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 131 | VkInstance instance, |
| 132 | VkFlags msgFlags, |
| 133 | const PFN_vkDbgMsgCallback pfnMsgCallback, |
Jon Ashburn | e67741a | 2015-08-06 13:56:43 -0600 | [diff] [blame] | 134 | void* pUserData, |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 135 | VkDbgMsgCallback* pMsgCallback) |
| 136 | { |
| 137 | VkDbgMsgCallback *icd_info; |
| 138 | const struct loader_icd *icd; |
| 139 | struct loader_instance *inst; |
| 140 | VkResult res; |
| 141 | uint32_t storage_idx; |
| 142 | |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 143 | for (inst = loader.instances; inst; inst = inst->next) { |
| 144 | if ((VkInstance) inst == instance) |
| 145 | break; |
| 146 | } |
| 147 | |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 148 | icd_info = calloc(sizeof(VkDbgMsgCallback), inst->total_icd_count); |
| 149 | if (!icd_info) { |
| 150 | return VK_ERROR_OUT_OF_HOST_MEMORY; |
| 151 | } |
| 152 | |
| 153 | storage_idx = 0; |
| 154 | for (icd = inst->icds; icd; icd = icd->next) { |
| 155 | if (!icd->DbgCreateMsgCallback) { |
| 156 | continue; |
| 157 | } |
| 158 | |
| 159 | res = icd->DbgCreateMsgCallback( |
| 160 | icd->instance, |
| 161 | msgFlags, |
| 162 | pfnMsgCallback, |
| 163 | pUserData, |
| 164 | &icd_info[storage_idx]); |
| 165 | |
| 166 | if (res != VK_SUCCESS) { |
| 167 | break; |
| 168 | } |
| 169 | storage_idx++; |
| 170 | } |
| 171 | |
| 172 | /* roll back on errors */ |
| 173 | if (icd) { |
| 174 | storage_idx = 0; |
| 175 | for (icd = inst->icds; icd; icd = icd->next) { |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 176 | if (icd_info[storage_idx]) { |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 177 | icd->DbgDestroyMsgCallback( |
| 178 | icd->instance, |
| 179 | icd_info[storage_idx]); |
| 180 | } |
| 181 | storage_idx++; |
| 182 | } |
| 183 | |
| 184 | return res; |
| 185 | } |
| 186 | |
Tony Barbour | 1d2cd3f | 2015-07-03 10:33:54 -0600 | [diff] [blame] | 187 | *(VkDbgMsgCallback **)pMsgCallback = icd_info; |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 188 | |
| 189 | return VK_SUCCESS; |
| 190 | } |
| 191 | |
| 192 | /* |
| 193 | * This is the instance chain terminator function |
| 194 | * for DbgDestroyMsgCallback |
| 195 | */ |
Dan Ginsburg | 78556e8 | 2015-07-23 13:15:00 -0400 | [diff] [blame] | 196 | VkResult VKAPI loader_DbgDestroyMsgCallback( |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 197 | VkInstance instance, |
| 198 | VkDbgMsgCallback msgCallback) |
| 199 | { |
| 200 | uint32_t storage_idx; |
| 201 | VkDbgMsgCallback *icd_info; |
| 202 | const struct loader_icd *icd; |
| 203 | VkResult res = VK_SUCCESS; |
| 204 | struct loader_instance *inst; |
| 205 | |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 206 | for (inst = loader.instances; inst; inst = inst->next) { |
| 207 | if ((VkInstance) inst == instance) |
| 208 | break; |
| 209 | } |
| 210 | |
Tony Barbour | 1d2cd3f | 2015-07-03 10:33:54 -0600 | [diff] [blame] | 211 | icd_info = *(VkDbgMsgCallback **) &msgCallback; |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 212 | storage_idx = 0; |
| 213 | for (icd = inst->icds; icd; icd = icd->next) { |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 214 | if (icd_info[storage_idx]) { |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 215 | icd->DbgDestroyMsgCallback( |
Courtney Goeltzenleuchter | 7d0023c | 2015-06-08 15:09:22 -0600 | [diff] [blame] | 216 | icd->instance, |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 217 | icd_info[storage_idx]); |
| 218 | } |
| 219 | storage_idx++; |
| 220 | } |
| 221 | return res; |
| 222 | } |
| 223 | |
Courtney Goeltzenleuchter | 7dcc6a7 | 2015-06-11 16:01:11 -0600 | [diff] [blame] | 224 | static void print_msg_flags(VkFlags msgFlags, char *msg_flags) |
| 225 | { |
| 226 | bool separator = false; |
| 227 | |
| 228 | msg_flags[0] = 0; |
| 229 | if (msgFlags & VK_DBG_REPORT_DEBUG_BIT) { |
| 230 | strcat(msg_flags, "DEBUG"); |
| 231 | separator = true; |
| 232 | } |
| 233 | if (msgFlags & VK_DBG_REPORT_INFO_BIT) { |
| 234 | if (separator) strcat(msg_flags, ","); |
| 235 | strcat(msg_flags, "INFO"); |
| 236 | separator = true; |
| 237 | } |
| 238 | if (msgFlags & VK_DBG_REPORT_WARN_BIT) { |
| 239 | if (separator) strcat(msg_flags, ","); |
| 240 | strcat(msg_flags, "WARN"); |
| 241 | separator = true; |
| 242 | } |
| 243 | if (msgFlags & VK_DBG_REPORT_PERF_WARN_BIT) { |
| 244 | if (separator) strcat(msg_flags, ","); |
| 245 | strcat(msg_flags, "PERF"); |
| 246 | separator = true; |
| 247 | } |
| 248 | if (msgFlags & VK_DBG_REPORT_ERROR_BIT) { |
| 249 | if (separator) strcat(msg_flags, ","); |
| 250 | strcat(msg_flags, "ERROR"); |
| 251 | } |
| 252 | } |
| 253 | |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 254 | // DebugReport utility callback functions |
| 255 | static void VKAPI StringCallback( |
| 256 | VkFlags msgFlags, |
Tony Barbour | 1d2cd3f | 2015-07-03 10:33:54 -0600 | [diff] [blame] | 257 | VkDbgObjectType objType, |
| 258 | uint64_t srcObject, |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 259 | size_t location, |
| 260 | int32_t msgCode, |
| 261 | const char* pLayerPrefix, |
| 262 | const char* pMsg, |
| 263 | void* pUserData) |
| 264 | { |
Jon Ashburn | 7242c67 | 2015-06-30 14:44:13 -0700 | [diff] [blame] | 265 | size_t buf_size; |
Courtney Goeltzenleuchter | 7dcc6a7 | 2015-06-11 16:01:11 -0600 | [diff] [blame] | 266 | char *buf; |
| 267 | char msg_flags[30]; |
| 268 | PFN_stringCallback callback = (PFN_stringCallback) pUserData; |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 269 | |
Courtney Goeltzenleuchter | 7dcc6a7 | 2015-06-11 16:01:11 -0600 | [diff] [blame] | 270 | print_msg_flags(msgFlags, msg_flags); |
| 271 | |
| 272 | buf_size = strlen(msg_flags) + /* ReportFlags: i.e. (DEBUG,INFO,WARN,PERF,ERROR) */ |
| 273 | 20 + /* objType */ |
| 274 | 20 + /* srcObject */ |
| 275 | 20 + /* location */ |
| 276 | 20 + /* msgCode */ |
| 277 | strlen(pLayerPrefix) + |
| 278 | strlen(pMsg) + |
| 279 | 50 /* other / whitespace */; |
Jon Ashburn | 48091a3 | 2015-08-27 13:06:58 -0600 | [diff] [blame] | 280 | buf = loader_stack_alloc(buf_size); |
| 281 | |
Courtney Goeltzenleuchter | 22d8d79 | 2015-10-07 17:03:42 -0600 | [diff] [blame] | 282 | snprintf(buf, buf_size, "%s (%s): object: 0x%" PRIxLEAST64 " type: %d location: " PRINTF_SIZE_T_SPECIFIER " msgCode : %d : %s", |
Courtney Goeltzenleuchter | 7dcc6a7 | 2015-06-11 16:01:11 -0600 | [diff] [blame] | 283 | pLayerPrefix, msg_flags, srcObject, objType, location, msgCode, pMsg); |
| 284 | callback(buf); |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 285 | } |
| 286 | |
| 287 | static void VKAPI StdioCallback( |
| 288 | VkFlags msgFlags, |
Tony Barbour | 1d2cd3f | 2015-07-03 10:33:54 -0600 | [diff] [blame] | 289 | VkDbgObjectType objType, |
| 290 | uint64_t srcObject, |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 291 | size_t location, |
| 292 | int32_t msgCode, |
| 293 | const char* pLayerPrefix, |
| 294 | const char* pMsg, |
| 295 | void* pUserData) |
| 296 | { |
Courtney Goeltzenleuchter | 7dcc6a7 | 2015-06-11 16:01:11 -0600 | [diff] [blame] | 297 | char msg_flags[30]; |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 298 | |
Courtney Goeltzenleuchter | 7dcc6a7 | 2015-06-11 16:01:11 -0600 | [diff] [blame] | 299 | print_msg_flags(msgFlags, msg_flags); |
| 300 | |
Courtney Goeltzenleuchter | 22d8d79 | 2015-10-07 17:03:42 -0600 | [diff] [blame] | 301 | fprintf((FILE *)pUserData, "%s(%s): object: 0x%" PRIxLEAST64 " type: %d location: " PRINTF_SIZE_T_SPECIFIER " msgCode : %d : %s", |
Courtney Goeltzenleuchter | 7dcc6a7 | 2015-06-11 16:01:11 -0600 | [diff] [blame] | 302 | pLayerPrefix, msg_flags, srcObject, objType, location, msgCode, pMsg); |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 303 | } |
| 304 | |
| 305 | static void VKAPI BreakCallback( |
| 306 | VkFlags msgFlags, |
Tony Barbour | 1d2cd3f | 2015-07-03 10:33:54 -0600 | [diff] [blame] | 307 | VkDbgObjectType objType, |
| 308 | uint64_t srcObject, |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 309 | size_t location, |
| 310 | int32_t msgCode, |
| 311 | const char* pLayerPrefix, |
| 312 | const char* pMsg, |
| 313 | void* pUserData) |
| 314 | { |
Courtney Goeltzenleuchter | 03663d0 | 2015-07-22 11:01:53 -0600 | [diff] [blame] | 315 | #ifndef WIN32 |
| 316 | raise(SIGTRAP); |
| 317 | #else |
| 318 | DebugBreak(); |
| 319 | #endif |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 320 | } |
| 321 | |
Jon Ashburn | f7a48db | 2015-10-01 12:03:17 -0600 | [diff] [blame] | 322 | bool debug_report_instance_gpa( |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 323 | struct loader_instance *ptr_instance, |
Jon Ashburn | f7a48db | 2015-10-01 12:03:17 -0600 | [diff] [blame] | 324 | const char* name, |
| 325 | void **addr) |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 326 | { |
Jon Ashburn | f7a48db | 2015-10-01 12:03:17 -0600 | [diff] [blame] | 327 | *addr = NULL; |
| 328 | if (ptr_instance == VK_NULL_HANDLE) |
| 329 | return false; |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 330 | |
Jon Ashburn | f7a48db | 2015-10-01 12:03:17 -0600 | [diff] [blame] | 331 | if (!strcmp("vkDbgCreateMsgCallback", name)) { |
| 332 | *addr = ptr_instance->debug_report_enabled ? (void *) debug_report_DbgCreateMsgCallback : NULL; |
| 333 | return true; |
| 334 | } |
| 335 | if (!strcmp("vkDbgDestroyMsgCallback", name)) { |
| 336 | *addr = ptr_instance->debug_report_enabled ? (void *) debug_report_DbgDestroyMsgCallback : NULL; |
| 337 | return true; |
| 338 | } |
| 339 | if (!strcmp("vkDbgStringCallback", name)) { |
| 340 | *addr = ptr_instance->debug_report_enabled ? (void *) StringCallback : NULL; |
| 341 | return true; |
| 342 | } |
| 343 | if (!strcmp("vkDbgStdioCallback", name)) { |
| 344 | *addr = ptr_instance->debug_report_enabled ? (void *) StdioCallback : NULL; |
| 345 | return true; |
| 346 | } |
| 347 | if (!strcmp("vkDbgBreakCallback", name)) { |
| 348 | *addr = ptr_instance->debug_report_enabled ? (void *) BreakCallback : NULL; |
| 349 | return true; |
| 350 | } |
| 351 | return false; |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 352 | } |