create_callback_file:
   59|  3.25k|void create_callback_file(const char *filename) {}

create_config_file:
   24|  24.6k|int create_config_file(const char* config_path, const char* config_filename, const uint8_t* data, size_t size) {
   25|  24.6k|  char filename[512];
   26|  24.6k|  char path[256];
   27|  24.6k|  char command[256];
   28|       |
   29|  24.6k|  sprintf(path, "%s/%s", getenv("HOME"), config_path);
   30|  24.6k|  sprintf(command, "mkdir -p %s", path);
   31|       |
   32|  24.6k|  system(command);
   33|       |
   34|  24.6k|  sprintf(filename, "%s/%s", path, config_filename);
   35|       |
   36|  24.6k|  FILE *fp = fopen(filename, "wb");
   37|  24.6k|  if (!fp) {
  ------------------
  |  Branch (37:7): [True: 0, False: 24.6k]
  ------------------
   38|      0|    return 1;
   39|      0|  }
   40|  24.6k|  fwrite(data, size, 1, fp);
   41|  24.6k|  fclose(fp);
   42|       |
   43|  24.6k|  return 0;
   44|  24.6k|}
remove_config_file:
   49|  24.6k|void remove_config_file(const char* config_path, const char* config_filename) {
   50|  24.6k|  char filename[512];
   51|  24.6k|  sprintf(filename, "%s/%s/%s", getenv("HOME"), config_path, config_filename);
   52|  24.6k|  unlink(filename);
   53|  24.6k|}
LLVMFuzzerTestOneInput:
   58|  8.21k|int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
   59|  8.21k|  setenv("HOME", "/tmp", 1);
   60|       |
   61|       |  // Create implicit layer configuration file
   62|  8.21k|  int result = create_config_file(".local/share/vulkan/implicit_layer.d", "complex_layer.json", data, size);
   63|  8.21k|  if (result) {
  ------------------
  |  Branch (63:7): [True: 0, False: 8.21k]
  ------------------
   64|      0|    return 0;
   65|      0|  }
   66|       |  
   67|       |  // Create loader configuration file
   68|  8.21k|  result = create_config_file(".local/share/vulkan/loader_settings.d", "vk_loader_settings.json", data, size);
   69|  8.21k|  if (result) {
  ------------------
  |  Branch (69:7): [True: 0, False: 8.21k]
  ------------------
   70|      0|    return 0;
   71|      0|  }
   72|       |
   73|       |  // Create icd configuration file
   74|  8.21k|  result = create_config_file(".local/share/vulkan/icd.d", "icd_test.json", data, size);
   75|  8.21k|  if (result) {
  ------------------
  |  Branch (75:7): [True: 0, False: 8.21k]
  ------------------
   76|      0|    return 0;
   77|      0|  }
   78|       |
   79|  8.21k|  setenv("VK_LOADER_LAYERS_ENABLE", "all", 1);
   80|       |
   81|       |
   82|  8.21k|  VkInstance inst = {0};
   83|  8.21k|  char *instance_layers[] = {
   84|  8.21k|    "VK_LAYER_KHRONOS_validation",
   85|  8.21k|    "VK_LAYER_test_layer_1",
   86|  8.21k|    "VK_LAYER_test_layer_2"
   87|  8.21k|  };
   88|  8.21k|  const VkApplicationInfo app = {
   89|  8.21k|      .sType = VK_STRUCTURE_TYPE_APPLICATION_INFO,
   90|  8.21k|      .pNext = NULL,
   91|  8.21k|      .pApplicationName = "TEST_APP",
   92|  8.21k|      .applicationVersion = 0,
   93|  8.21k|      .pEngineName = "TEST_ENGINE",
   94|  8.21k|      .engineVersion = 0,
   95|  8.21k|      .apiVersion = VK_API_VERSION_1_0,
  ------------------
  |  |   92|  8.21k|#define VK_API_VERSION_1_0 VK_MAKE_API_VERSION(0, 1, 0, 0)// Patch version should always be set to 0
  |  |  ------------------
  |  |  |  |   63|  8.21k|    ((((uint32_t)(variant)) << 29U) | (((uint32_t)(major)) << 22U) | (((uint32_t)(minor)) << 12U) | ((uint32_t)(patch)))
  |  |  ------------------
  ------------------
   96|  8.21k|  };
   97|  8.21k|  VkInstanceCreateInfo inst_info = {
   98|  8.21k|      .sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO,
   99|  8.21k|      .pNext = NULL,
  100|  8.21k|      .pApplicationInfo = &app,
  101|  8.21k|      .enabledLayerCount = 1,
  102|  8.21k|      .ppEnabledLayerNames = (const char *const *)instance_layers,
  103|  8.21k|      .enabledExtensionCount = 0,
  104|  8.21k|      .ppEnabledExtensionNames = NULL,
  105|  8.21k|  };
  106|  8.21k|  VkResult err = vkCreateInstance(&inst_info, NULL, &inst);
  107|  8.21k|  if (err != VK_SUCCESS) {
  ------------------
  |  Branch (107:7): [True: 8.21k, False: 0]
  ------------------
  108|  8.21k|    goto out;
  109|  8.21k|  }
  110|       |
  111|      0|  vkDestroyInstance(inst, NULL);
  112|       |
  113|  8.21k|out:
  114|       |  // Clean up config files
  115|  8.21k|  remove_config_file(".local/share/vulkan/implicit_layer.d", "complex_layer.json");
  116|  8.21k|  remove_config_file(".local/share/vulkan/loader_settings.d", "vk_loader_settings.json");
  117|  8.21k|  remove_config_file(".local/share/vulkan/icd.d", "icd_test.json");
  118|       |
  119|  8.21k|  return 0;
  120|      0|}

loader_alloc:
   34|    793|void *loader_alloc(const VkAllocationCallbacks *pAllocator, size_t size, VkSystemAllocationScope allocation_scope) {
   35|    793|    void *pMemory = NULL;
   36|       |#if (DEBUG_DISABLE_APP_ALLOCATORS == 1)
   37|       |    {
   38|       |#else
   39|    793|    if (pAllocator && pAllocator->pfnAllocation) {
  ------------------
  |  Branch (39:9): [True: 793, False: 0]
  |  Branch (39:23): [True: 0, False: 793]
  ------------------
   40|       |        // These are internal structures, so it's best to align everything to
   41|       |        // the largest unit size which is the size of a uint64_t.
   42|      0|        pMemory = pAllocator->pfnAllocation(pAllocator->pUserData, size, sizeof(uint64_t), allocation_scope);
   43|    793|    } else {
   44|    793|#endif
   45|    793|        pMemory = malloc(size);
   46|    793|    }
   47|       |
   48|    793|    return pMemory;
   49|    793|}
loader_calloc:
   51|  24.1M|void *loader_calloc(const VkAllocationCallbacks *pAllocator, size_t size, VkSystemAllocationScope allocation_scope) {
   52|  24.1M|    void *pMemory = NULL;
   53|       |#if (DEBUG_DISABLE_APP_ALLOCATORS == 1)
   54|       |    {
   55|       |#else
   56|  24.1M|    if (pAllocator && pAllocator->pfnAllocation) {
  ------------------
  |  Branch (56:9): [True: 24.1M, False: 8.21k]
  |  Branch (56:23): [True: 0, False: 24.1M]
  ------------------
   57|       |        // These are internal structures, so it's best to align everything to
   58|       |        // the largest unit size which is the size of a uint64_t.
   59|      0|        pMemory = pAllocator->pfnAllocation(pAllocator->pUserData, size, sizeof(uint64_t), allocation_scope);
   60|      0|        if (pMemory) {
  ------------------
  |  Branch (60:13): [True: 0, False: 0]
  ------------------
   61|      0|            memset(pMemory, 0, size);
   62|      0|        }
   63|  24.1M|    } else {
   64|  24.1M|#endif
   65|  24.1M|        pMemory = calloc(1, size);
   66|  24.1M|    }
   67|       |
   68|  24.1M|    return pMemory;
   69|  24.1M|}
loader_free:
   71|  28.8M|void loader_free(const VkAllocationCallbacks *pAllocator, void *pMemory) {
   72|  28.8M|    if (pMemory != NULL) {
  ------------------
  |  Branch (72:9): [True: 24.1M, False: 4.71M]
  ------------------
   73|       |#if (DEBUG_DISABLE_APP_ALLOCATORS == 1)
   74|       |        {
   75|       |#else
   76|  24.1M|        if (pAllocator && pAllocator->pfnFree) {
  ------------------
  |  Branch (76:13): [True: 24.1M, False: 0]
  |  Branch (76:27): [True: 0, False: 24.1M]
  ------------------
   77|      0|            pAllocator->pfnFree(pAllocator->pUserData, pMemory);
   78|  24.1M|        } else {
   79|  24.1M|#endif
   80|  24.1M|            free(pMemory);
   81|  24.1M|        }
   82|  24.1M|    }
   83|  28.8M|}
loader_realloc:
   86|  1.43M|                     VkSystemAllocationScope allocation_scope) {
   87|  1.43M|    void *pNewMem = NULL;
   88|  1.43M|    if (pMemory == NULL || orig_size == 0) {
  ------------------
  |  Branch (88:9): [True: 0, False: 1.43M]
  |  Branch (88:28): [True: 0, False: 1.43M]
  ------------------
   89|      0|        pNewMem = loader_alloc(pAllocator, size, allocation_scope);
   90|  1.43M|    } else if (size == 0) {
  ------------------
  |  Branch (90:16): [True: 0, False: 1.43M]
  ------------------
   91|      0|        loader_free(pAllocator, pMemory);
   92|       |#if (DEBUG_DISABLE_APP_ALLOCATORS == 1)
   93|       |#else
   94|  1.43M|    } else if (pAllocator && pAllocator->pfnReallocation) {
  ------------------
  |  Branch (94:16): [True: 1.43M, False: 0]
  |  Branch (94:30): [True: 0, False: 1.43M]
  ------------------
   95|       |        // These are internal structures, so it's best to align everything to
   96|       |        // the largest unit size which is the size of a uint64_t.
   97|      0|        pNewMem = pAllocator->pfnReallocation(pAllocator->pUserData, pMemory, size, sizeof(uint64_t), allocation_scope);
   98|      0|#endif
   99|  1.43M|    } else {
  100|  1.43M|        pNewMem = realloc(pMemory, size);
  101|       |        // Clear out the newly allocated memory. On failure realloc returns NULL and leaves the original block valid, so
  102|       |        // only write through pNewMem once we know it points at the resized allocation.
  103|  1.43M|        if (NULL != pNewMem && size > orig_size) {
  ------------------
  |  Branch (103:13): [True: 1.43M, False: 0]
  |  Branch (103:32): [True: 14.0k, False: 1.41M]
  ------------------
  104|  14.0k|            memset((uint8_t *)pNewMem + orig_size, 0, size - orig_size);
  105|  14.0k|        }
  106|  1.43M|    }
  107|  1.43M|    return pNewMem;
  108|  1.43M|}
loader_instance_heap_alloc:
  110|    793|void *loader_instance_heap_alloc(const struct loader_instance *inst, size_t size, VkSystemAllocationScope allocation_scope) {
  111|    793|    return loader_alloc(inst ? &inst->alloc_callbacks : NULL, size, allocation_scope);
  ------------------
  |  Branch (111:25): [True: 793, False: 0]
  ------------------
  112|    793|}
loader_instance_heap_calloc:
  114|  1.06M|void *loader_instance_heap_calloc(const struct loader_instance *inst, size_t size, VkSystemAllocationScope allocation_scope) {
  115|  1.06M|    return loader_calloc(inst ? &inst->alloc_callbacks : NULL, size, allocation_scope);
  ------------------
  |  Branch (115:26): [True: 1.06M, False: 0]
  ------------------
  116|  1.06M|}
loader_instance_heap_free:
  118|  7.19M|void loader_instance_heap_free(const struct loader_instance *inst, void *pMemory) {
  119|  7.19M|    loader_free(inst ? &inst->alloc_callbacks : NULL, pMemory);
  ------------------
  |  Branch (119:17): [True: 7.19M, False: 2]
  ------------------
  120|  7.19M|}
loader_instance_heap_realloc:
  122|  3.85k|                                   VkSystemAllocationScope allocation_scope) {
  123|  3.85k|    return loader_realloc(inst ? &inst->alloc_callbacks : NULL, pMemory, orig_size, size, allocation_scope);
  ------------------
  |  Branch (123:27): [True: 3.85k, False: 0]
  ------------------
  124|  3.85k|}

loader_cJSON_GetStringValue:
   98|   873k|CJSON_PUBLIC(char *) loader_cJSON_GetStringValue(const cJSON *const item) {
   99|   873k|    if (!loader_cJSON_IsString(item)) {
  ------------------
  |  Branch (99:9): [True: 221k, False: 651k]
  ------------------
  100|   221k|        return NULL;
  101|   221k|    }
  102|       |
  103|   651k|    return item->valuestring;
  104|   873k|}
loader_cJSON_Delete:
  151|  3.04M|TEST_FUNCTION_EXPORT CJSON_PUBLIC(void) loader_cJSON_Delete(cJSON *item) {
  152|  3.04M|    cJSON *next = NULL;
  153|  13.7M|    while (item != NULL) {
  ------------------
  |  Branch (153:12): [True: 10.7M, False: 3.04M]
  ------------------
  154|  10.7M|        next = item->next;
  155|  10.7M|        if (!(item->type & cJSON_IsReference) && (item->child != NULL)) {
  ------------------
  |  |  106|  10.7M|#define cJSON_IsReference 256
  ------------------
  |  Branch (155:13): [True: 10.7M, False: 0]
  |  Branch (155:50): [True: 2.68M, False: 8.02M]
  ------------------
  156|  2.68M|            loader_cJSON_Delete(item->child);
  157|  2.68M|        }
  158|  10.7M|        if (!(item->type & cJSON_IsReference) && (item->valuestring != NULL)) {
  ------------------
  |  |  106|  10.7M|#define cJSON_IsReference 256
  ------------------
  |  Branch (158:13): [True: 10.7M, False: 0]
  |  Branch (158:50): [True: 5.42M, False: 5.29M]
  ------------------
  159|  5.42M|            loader_free(item->pAllocator, item->valuestring);
  160|  5.42M|            item->valuestring = NULL;
  161|  5.42M|        }
  162|  10.7M|        if (!(item->type & cJSON_StringIsConst) && (item->string != NULL)) {
  ------------------
  |  |  107|  10.7M|#define cJSON_StringIsConst 512
  ------------------
  |  Branch (162:13): [True: 10.7M, False: 0]
  |  Branch (162:52): [True: 5.54M, False: 5.16M]
  ------------------
  163|  5.54M|            loader_free(item->pAllocator, item->string);
  164|       |            item->string = NULL;
  165|  5.54M|        }
  166|  10.7M|        loader_free(item->pAllocator, item);
  167|  10.7M|        item = next;
  168|  10.7M|    }
  169|  3.04M|}
loader_cJSON_ParseWithLengthOpts:
  824|  86.4k|                                 const char **return_parse_end, cJSON_bool require_null_terminated, bool *out_of_memory) {
  825|  86.4k|    parse_buffer buffer = {0, 0, 0, 0, 0};
  826|  86.4k|    cJSON *item = NULL;
  827|       |
  828|       |    /* reset error position */
  829|       |    // global_error.json = NULL;
  830|       |    // global_error.position = 0;
  831|       |
  832|  86.4k|    if (value == NULL || 0 == buffer_length) {
  ------------------
  |  Branch (832:9): [True: 0, False: 86.4k]
  |  Branch (832:26): [True: 0, False: 86.4k]
  ------------------
  833|      0|        goto fail;
  834|      0|    }
  835|       |
  836|  86.4k|    buffer.content = (const unsigned char *)value;
  837|  86.4k|    buffer.length = buffer_length;
  838|  86.4k|    buffer.offset = 0;
  839|  86.4k|    buffer.pAllocator = pAllocator;
  840|       |
  841|  86.4k|    item = cJSON_New_Item(pAllocator);
  842|  86.4k|    if (item == NULL) /* memory fail */
  ------------------
  |  Branch (842:9): [True: 0, False: 86.4k]
  ------------------
  843|      0|    {
  844|      0|        *out_of_memory = true;
  ------------------
  |  |   67|      0|#define true ((cJSON_bool)1)
  ------------------
  845|      0|        goto fail;
  846|      0|    }
  847|       |
  848|  86.4k|    if (!parse_value(item, buffer_skip_whitespace(skip_utf8_bom(&buffer)), out_of_memory)) {
  ------------------
  |  Branch (848:9): [True: 58.1k, False: 28.2k]
  ------------------
  849|       |        /* parse failure. ep is set. */
  850|  58.1k|        goto fail;
  851|  58.1k|    }
  852|       |
  853|       |    /* if we require null-terminated JSON without appended garbage, skip and then check for a null terminator */
  854|  28.2k|    if (require_null_terminated) {
  ------------------
  |  Branch (854:9): [True: 0, False: 28.2k]
  ------------------
  855|      0|        buffer_skip_whitespace(&buffer);
  856|      0|        if ((buffer.offset >= buffer.length) || buffer_at_offset(&buffer)[0] != '\0') {
  ------------------
  |  |  195|      0|#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset)
  ------------------
  |  Branch (856:13): [True: 0, False: 0]
  |  Branch (856:49): [True: 0, False: 0]
  ------------------
  857|      0|            goto fail;
  858|      0|        }
  859|      0|    }
  860|  28.2k|    if (return_parse_end) {
  ------------------
  |  Branch (860:9): [True: 0, False: 28.2k]
  ------------------
  861|      0|        *return_parse_end = (const char *)buffer_at_offset(&buffer);
  ------------------
  |  |  195|      0|#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset)
  ------------------
  862|      0|    }
  863|       |
  864|  28.2k|    return item;
  865|       |
  866|  58.1k|fail:
  867|  58.1k|    if (item != NULL) {
  ------------------
  |  Branch (867:9): [True: 58.1k, False: 0]
  ------------------
  868|  58.1k|        loader_cJSON_Delete(item);
  869|  58.1k|    }
  870|       |
  871|  58.1k|    if (value != NULL) {
  ------------------
  |  Branch (871:9): [True: 58.1k, False: 0]
  ------------------
  872|  58.1k|        error local_error;
  873|  58.1k|        local_error.json = (const unsigned char *)value;
  874|  58.1k|        local_error.position = 0;
  875|       |
  876|  58.1k|        if (buffer.offset < buffer.length) {
  ------------------
  |  Branch (876:13): [True: 57.7k, False: 379]
  ------------------
  877|  57.7k|            local_error.position = buffer.offset;
  878|  57.7k|        } else if (buffer.length > 0) {
  ------------------
  |  Branch (878:20): [True: 379, False: 0]
  ------------------
  879|    379|            local_error.position = buffer.length - 1;
  880|    379|        }
  881|       |
  882|  58.1k|        if (return_parse_end != NULL) {
  ------------------
  |  Branch (882:13): [True: 0, False: 58.1k]
  ------------------
  883|      0|            *return_parse_end = (const char *)local_error.json + local_error.position;
  884|      0|        }
  885|       |
  886|       |        // global_error = local_error;
  887|  58.1k|    }
  888|       |
  889|       |    return NULL;
  890|  28.2k|}
loader_cJSON_ParseWithLength:
  899|  86.4k|                             bool *out_of_memory) {
  900|  86.4k|    return loader_cJSON_ParseWithLengthOpts(pAllocator, value, buffer_length, 0, 0, out_of_memory);
  901|  86.4k|}
loader_cJSON_Print:
  953|  1.41M|TEST_FUNCTION_EXPORT CJSON_PUBLIC(char *) loader_cJSON_Print(const cJSON *item, bool *out_of_memory) {
  954|  1.41M|    return (char *)print(item, true, out_of_memory);
  ------------------
  |  |   67|  1.41M|#define true ((cJSON_bool)1)
  ------------------
  955|  1.41M|}
loader_cJSON_PrintPreallocated:
  990|   504k|    loader_cJSON_PrintPreallocated(cJSON *item, char *buffer, const int length, const cJSON_bool format) {
  991|   504k|    printbuffer p = {0, 0, 0, 0, 0, 0, 0};
  992|       |
  993|   504k|    if ((length < 0) || (buffer == NULL)) {
  ------------------
  |  Branch (993:9): [True: 0, False: 504k]
  |  Branch (993:25): [True: 0, False: 504k]
  ------------------
  994|      0|        return false;
  ------------------
  |  |   72|      0|#define false ((cJSON_bool)0)
  ------------------
  995|      0|    }
  996|       |
  997|   504k|    p.buffer = (unsigned char *)buffer;
  998|   504k|    p.length = (size_t)length;
  999|   504k|    p.offset = 0;
 1000|   504k|    p.noalloc = true;
  ------------------
  |  |   67|   504k|#define true ((cJSON_bool)1)
  ------------------
 1001|   504k|    p.format = format;
 1002|   504k|    p.pAllocator = item->pAllocator;
 1003|   504k|    bool out_of_memory = false;
  ------------------
  |  |   72|   504k|#define false ((cJSON_bool)0)
  ------------------
 1004|   504k|    return print_value(item, &p, &out_of_memory);
 1005|   504k|}
loader_cJSON_GetArraySize:
 1457|   191k|CJSON_PUBLIC(int) loader_cJSON_GetArraySize(const cJSON *array) {
 1458|   191k|    cJSON *child = NULL;
 1459|   191k|    size_t size = 0;
 1460|       |
 1461|   191k|    if (array == NULL) {
  ------------------
  |  Branch (1461:9): [True: 0, False: 191k]
  ------------------
 1462|      0|        return 0;
 1463|      0|    }
 1464|       |
 1465|   191k|    child = array->child;
 1466|       |
 1467|  1.59M|    while (child != NULL) {
  ------------------
  |  Branch (1467:12): [True: 1.40M, False: 191k]
  ------------------
 1468|  1.40M|        size++;
 1469|  1.40M|        child = child->next;
 1470|  1.40M|    }
 1471|       |
 1472|       |    /* FIXME: Can overflow here. Cannot be fixed without breaking the API */
 1473|       |
 1474|   191k|    return (int)size;
 1475|   191k|}
loader_cJSON_GetObjectItem:
 1527|  3.74M|CJSON_PUBLIC(cJSON *) loader_cJSON_GetObjectItem(const cJSON *const object, const char *const string) {
 1528|  3.74M|    return get_object_item(object, string, false);
  ------------------
  |  |   72|  3.74M|#define false ((cJSON_bool)0)
  ------------------
 1529|  3.74M|}
loader_cJSON_IsTrue:
 1639|     27|CJSON_PUBLIC(cJSON_bool) loader_cJSON_IsTrue(const cJSON *const item) {
 1640|     27|    if (item == NULL) {
  ------------------
  |  Branch (1640:9): [True: 27, False: 0]
  ------------------
 1641|     27|        return false;
  ------------------
  |  |   72|     27|#define false ((cJSON_bool)0)
  ------------------
 1642|     27|    }
 1643|       |
 1644|      0|    return (item->type & 0xff) == cJSON_True;
  ------------------
  |  |   98|      0|#define cJSON_True (1 << 1)
  ------------------
 1645|     27|}
loader_cJSON_IsString:
 1670|   873k|CJSON_PUBLIC(cJSON_bool) loader_cJSON_IsString(const cJSON *const item) {
 1671|   873k|    if (item == NULL) {
  ------------------
  |  Branch (1671:9): [True: 220k, False: 652k]
  ------------------
 1672|   220k|        return false;
  ------------------
  |  |   72|   220k|#define false ((cJSON_bool)0)
  ------------------
 1673|   220k|    }
 1674|       |
 1675|   652k|    return (item->type & 0xFF) == cJSON_String;
  ------------------
  |  |  101|   652k|#define cJSON_String (1 << 4)
  ------------------
 1676|   873k|}
cJSON.c:cJSON_New_Item:
  142|  10.7M|static cJSON *cJSON_New_Item(const VkAllocationCallbacks *pAllocator) {
  143|  10.7M|    cJSON *node = (cJSON *)loader_calloc(pAllocator, sizeof(cJSON), VK_SYSTEM_ALLOCATION_SCOPE_COMMAND);
  144|  10.7M|    if (NULL != node) {
  ------------------
  |  Branch (144:9): [True: 10.7M, False: 0]
  ------------------
  145|  10.7M|        node->pAllocator = pAllocator;
  146|  10.7M|    }
  147|  10.7M|    return node;
  148|  10.7M|}
cJSON.c:buffer_skip_whitespace:
  772|  35.4M|static parse_buffer *buffer_skip_whitespace(parse_buffer *const buffer) {
  773|  35.4M|    if ((buffer == NULL) || (buffer->content == NULL)) {
  ------------------
  |  Branch (773:9): [True: 0, False: 35.4M]
  |  Branch (773:29): [True: 0, False: 35.4M]
  ------------------
  774|      0|        return NULL;
  775|      0|    }
  776|       |
  777|  35.4M|    if (cannot_access_at_index(buffer, 0)) {
  ------------------
  |  |  193|  35.4M|#define cannot_access_at_index(buffer, index) (!can_access_at_index(buffer, index))
  |  |  ------------------
  |  |  |  |  192|  35.4M|#define can_access_at_index(buffer, index) ((buffer != NULL) && (((buffer)->offset + index) < (buffer)->length))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (192:45): [True: 35.4M, False: 0]
  |  |  |  |  |  Branch (192:65): [True: 35.4M, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  778|      0|        return buffer;
  779|      0|    }
  780|       |
  781|  54.9M|    while (can_access_at_index(buffer, 0) && (buffer_at_offset(buffer)[0] <= 32)) {
  ------------------
  |  |  192|   109M|#define can_access_at_index(buffer, index) ((buffer != NULL) && (((buffer)->offset + index) < (buffer)->length))
  |  |  ------------------
  |  |  |  Branch (192:45): [True: 54.9M, False: 0]
  |  |  |  Branch (192:65): [True: 54.9M, False: 22.4k]
  |  |  ------------------
  ------------------
                  while (can_access_at_index(buffer, 0) && (buffer_at_offset(buffer)[0] <= 32)) {
  ------------------
  |  |  195|  54.9M|#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset)
  ------------------
  |  Branch (781:46): [True: 19.5M, False: 35.3M]
  ------------------
  782|  19.5M|        buffer->offset++;
  783|  19.5M|    }
  784|       |
  785|  35.4M|    if (buffer->offset == buffer->length) {
  ------------------
  |  Branch (785:9): [True: 22.4k, False: 35.3M]
  ------------------
  786|  22.4k|        buffer->offset--;
  787|  22.4k|    }
  788|       |
  789|  35.4M|    return buffer;
  790|  35.4M|}
cJSON.c:skip_utf8_bom:
  793|  86.4k|static parse_buffer *skip_utf8_bom(parse_buffer *const buffer) {
  794|  86.4k|    if ((buffer == NULL) || (buffer->content == NULL) || (buffer->offset != 0)) {
  ------------------
  |  Branch (794:9): [True: 0, False: 86.4k]
  |  Branch (794:29): [True: 0, False: 86.4k]
  |  Branch (794:58): [True: 0, False: 86.4k]
  ------------------
  795|      0|        return NULL;
  796|      0|    }
  797|       |
  798|  86.4k|    if (can_access_at_index(buffer, 4) && (strncmp((const char *)buffer_at_offset(buffer), "\xEF\xBB\xBF", 3) == 0)) {
  ------------------
  |  |  192|   172k|#define can_access_at_index(buffer, index) ((buffer != NULL) && (((buffer)->offset + index) < (buffer)->length))
  |  |  ------------------
  |  |  |  Branch (192:45): [True: 86.4k, False: 0]
  |  |  |  Branch (192:65): [True: 39.1k, False: 47.2k]
  |  |  ------------------
  ------------------
                  if (can_access_at_index(buffer, 4) && (strncmp((const char *)buffer_at_offset(buffer), "\xEF\xBB\xBF", 3) == 0)) {
  ------------------
  |  |  195|  39.1k|#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset)
  ------------------
  |  Branch (798:43): [True: 287, False: 38.8k]
  ------------------
  799|    287|        buffer->offset += 3;
  800|    287|    }
  801|       |
  802|  86.4k|    return buffer;
  803|  86.4k|}
cJSON.c:print:
  905|  1.41M|static unsigned char *print(const cJSON *const item, cJSON_bool format, bool *out_of_memory) {
  906|  1.41M|    static const size_t default_buffer_size = 256;
  907|  1.41M|    printbuffer buffer[1];
  908|  1.41M|    unsigned char *printed = NULL;
  909|       |
  910|  1.41M|    memset(buffer, 0, sizeof(buffer));
  911|       |
  912|       |    /* create buffer */
  913|  1.41M|    buffer->buffer = (unsigned char *)loader_calloc(item->pAllocator, default_buffer_size, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
  914|  1.41M|    buffer->length = default_buffer_size;
  915|  1.41M|    buffer->format = format;
  916|  1.41M|    buffer->pAllocator = item->pAllocator;
  917|  1.41M|    if (buffer->buffer == NULL) {
  ------------------
  |  Branch (917:9): [True: 0, False: 1.41M]
  ------------------
  918|      0|        *out_of_memory = true;
  ------------------
  |  |   67|      0|#define true ((cJSON_bool)1)
  ------------------
  919|      0|        goto fail;
  920|      0|    }
  921|       |
  922|       |    /* print the value */
  923|  1.41M|    if (!print_value(item, buffer, out_of_memory)) {
  ------------------
  |  Branch (923:9): [True: 0, False: 1.41M]
  ------------------
  924|      0|        goto fail;
  925|      0|    }
  926|  1.41M|    update_offset(buffer);
  927|       |
  928|  1.41M|    printed = (unsigned char *)loader_realloc(item->pAllocator, buffer->buffer, buffer->length, buffer->offset + 1,
  929|  1.41M|                                              VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
  930|  1.41M|    if (printed == NULL) {
  ------------------
  |  Branch (930:9): [True: 0, False: 1.41M]
  ------------------
  931|      0|        *out_of_memory = true;
  ------------------
  |  |   67|      0|#define true ((cJSON_bool)1)
  ------------------
  932|      0|        goto fail;
  933|      0|    }
  934|  1.41M|    buffer->buffer = NULL;
  935|       |
  936|  1.41M|    return printed;
  937|       |
  938|      0|fail:
  939|      0|    if (buffer->buffer != NULL) {
  ------------------
  |  Branch (939:9): [True: 0, False: 0]
  ------------------
  940|      0|        loader_free(item->pAllocator, buffer->buffer);
  941|      0|        buffer->buffer = NULL;
  942|      0|    }
  943|       |
  944|      0|    if (printed != NULL) {
  ------------------
  |  Branch (944:9): [True: 0, False: 0]
  ------------------
  945|      0|        loader_free(item->pAllocator, printed);
  946|      0|        printed = NULL;
  947|      0|    }
  948|       |
  949|       |    return NULL;
  950|  1.41M|}
cJSON.c:update_offset:
  331|  2.80M|static void update_offset(printbuffer *const buffer) {
  332|  2.80M|    const unsigned char *buffer_pointer = NULL;
  333|  2.80M|    if ((buffer == NULL) || (buffer->buffer == NULL)) {
  ------------------
  |  Branch (333:9): [True: 0, False: 2.80M]
  |  Branch (333:29): [True: 0, False: 2.80M]
  ------------------
  334|      0|        return;
  335|      0|    }
  336|  2.80M|    buffer_pointer = buffer->buffer + buffer->offset;
  337|       |
  338|  2.80M|    buffer->offset += strlen((const char *)buffer_pointer);
  339|  2.80M|}
cJSON.c:parse_value:
 1008|  10.7M|static cJSON_bool parse_value(cJSON *const item, parse_buffer *const input_buffer, bool *out_of_memory) {
 1009|  10.7M|    if ((input_buffer == NULL) || (input_buffer->content == NULL)) {
  ------------------
  |  Branch (1009:9): [True: 0, False: 10.7M]
  |  Branch (1009:35): [True: 0, False: 10.7M]
  ------------------
 1010|      0|        return false; /* no input */
  ------------------
  |  |   72|      0|#define false ((cJSON_bool)0)
  ------------------
 1011|      0|    }
 1012|       |
 1013|       |    /* parse the different types of values */
 1014|       |    /* null */
 1015|  10.7M|    if (can_read(input_buffer, 4) && (strncmp((const char *)buffer_at_offset(input_buffer), "null", 4) == 0)) {
  ------------------
  |  |  190|  21.4M|#define can_read(buffer, size) ((buffer != NULL) && (((buffer)->offset + size) <= (buffer)->length))
  |  |  ------------------
  |  |  |  Branch (190:33): [True: 10.7M, False: 0]
  |  |  |  Branch (190:53): [True: 10.6M, False: 52.6k]
  |  |  ------------------
  ------------------
                  if (can_read(input_buffer, 4) && (strncmp((const char *)buffer_at_offset(input_buffer), "null", 4) == 0)) {
  ------------------
  |  |  195|  10.6M|#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset)
  ------------------
  |  Branch (1015:38): [True: 3.35k, False: 10.6M]
  ------------------
 1016|  3.35k|        item->type = cJSON_NULL;
  ------------------
  |  |   99|  3.35k|#define cJSON_NULL (1 << 2)
  ------------------
 1017|  3.35k|        input_buffer->offset += 4;
 1018|  3.35k|        return true;
  ------------------
  |  |   67|  3.35k|#define true ((cJSON_bool)1)
  ------------------
 1019|  3.35k|    }
 1020|       |    /* false */
 1021|  10.7M|    if (can_read(input_buffer, 5) && (strncmp((const char *)buffer_at_offset(input_buffer), "false", 5) == 0)) {
  ------------------
  |  |  190|  21.4M|#define can_read(buffer, size) ((buffer != NULL) && (((buffer)->offset + size) <= (buffer)->length))
  |  |  ------------------
  |  |  |  Branch (190:33): [True: 10.7M, False: 0]
  |  |  |  Branch (190:53): [True: 10.6M, False: 56.5k]
  |  |  ------------------
  ------------------
                  if (can_read(input_buffer, 5) && (strncmp((const char *)buffer_at_offset(input_buffer), "false", 5) == 0)) {
  ------------------
  |  |  195|  10.6M|#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset)
  ------------------
  |  Branch (1021:38): [True: 10.0k, False: 10.6M]
  ------------------
 1022|  10.0k|        item->type = cJSON_False;
  ------------------
  |  |   97|  10.0k|#define cJSON_False (1 << 0)
  ------------------
 1023|  10.0k|        input_buffer->offset += 5;
 1024|  10.0k|        return true;
  ------------------
  |  |   67|  10.0k|#define true ((cJSON_bool)1)
  ------------------
 1025|  10.0k|    }
 1026|       |    /* true */
 1027|  10.6M|    if (can_read(input_buffer, 4) && (strncmp((const char *)buffer_at_offset(input_buffer), "true", 4) == 0)) {
  ------------------
  |  |  190|  21.3M|#define can_read(buffer, size) ((buffer != NULL) && (((buffer)->offset + size) <= (buffer)->length))
  |  |  ------------------
  |  |  |  Branch (190:33): [True: 10.6M, False: 0]
  |  |  |  Branch (190:53): [True: 10.6M, False: 52.6k]
  |  |  ------------------
  ------------------
                  if (can_read(input_buffer, 4) && (strncmp((const char *)buffer_at_offset(input_buffer), "true", 4) == 0)) {
  ------------------
  |  |  195|  10.6M|#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset)
  ------------------
  |  Branch (1027:38): [True: 134k, False: 10.5M]
  ------------------
 1028|   134k|        item->type = cJSON_True;
  ------------------
  |  |   98|   134k|#define cJSON_True (1 << 1)
  ------------------
 1029|   134k|        item->valueint = 1;
 1030|   134k|        input_buffer->offset += 4;
 1031|   134k|        return true;
  ------------------
  |  |   67|   134k|#define true ((cJSON_bool)1)
  ------------------
 1032|   134k|    }
 1033|       |    /* string */
 1034|  10.5M|    if (can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == '\"')) {
  ------------------
  |  |  192|  21.1M|#define can_access_at_index(buffer, index) ((buffer != NULL) && (((buffer)->offset + index) < (buffer)->length))
  |  |  ------------------
  |  |  |  Branch (192:45): [True: 10.5M, False: 0]
  |  |  |  Branch (192:65): [True: 10.5M, False: 0]
  |  |  ------------------
  ------------------
                  if (can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == '\"')) {
  ------------------
  |  |  195|  10.5M|#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset)
  ------------------
  |  Branch (1034:49): [True: 5.43M, False: 5.13M]
  ------------------
 1035|  5.43M|        return parse_string(item, input_buffer, out_of_memory);
 1036|  5.43M|    }
 1037|       |    /* number */
 1038|  5.13M|    if (can_access_at_index(input_buffer, 0) &&
  ------------------
  |  |  192|  10.2M|#define can_access_at_index(buffer, index) ((buffer != NULL) && (((buffer)->offset + index) < (buffer)->length))
  |  |  ------------------
  |  |  |  Branch (192:45): [True: 5.13M, False: 0]
  |  |  |  Branch (192:65): [True: 5.13M, False: 0]
  |  |  ------------------
  ------------------
 1039|  5.13M|        ((buffer_at_offset(input_buffer)[0] == '-') ||
  ------------------
  |  |  195|  5.13M|#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset)
  ------------------
  |  Branch (1039:10): [True: 31.3k, False: 5.09M]
  ------------------
 1040|  5.09M|         ((buffer_at_offset(input_buffer)[0] >= '0') && (buffer_at_offset(input_buffer)[0] <= '9')))) {
  ------------------
  |  |  195|  5.09M|#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset)
  ------------------
                       ((buffer_at_offset(input_buffer)[0] >= '0') && (buffer_at_offset(input_buffer)[0] <= '9')))) {
  ------------------
  |  |  195|  5.08M|#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset)
  ------------------
  |  Branch (1040:11): [True: 5.08M, False: 18.6k]
  |  Branch (1040:57): [True: 1.79M, False: 3.28M]
  ------------------
 1041|  1.82M|        return parse_number(item, input_buffer);
 1042|  1.82M|    }
 1043|       |    /* array */
 1044|  3.30M|    if (can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == '[')) {
  ------------------
  |  |  192|  6.60M|#define can_access_at_index(buffer, index) ((buffer != NULL) && (((buffer)->offset + index) < (buffer)->length))
  |  |  ------------------
  |  |  |  Branch (192:45): [True: 3.30M, False: 0]
  |  |  |  Branch (192:65): [True: 3.30M, False: 0]
  |  |  ------------------
  ------------------
                  if (can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == '[')) {
  ------------------
  |  |  195|  3.30M|#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset)
  ------------------
  |  Branch (1044:49): [True: 1.12M, False: 2.18M]
  ------------------
 1045|  1.12M|        return parse_array(item, input_buffer, out_of_memory);
 1046|  1.12M|    }
 1047|       |    /* object */
 1048|  2.18M|    if (can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == '{')) {
  ------------------
  |  |  192|  4.36M|#define can_access_at_index(buffer, index) ((buffer != NULL) && (((buffer)->offset + index) < (buffer)->length))
  |  |  ------------------
  |  |  |  Branch (192:45): [True: 2.18M, False: 0]
  |  |  |  Branch (192:65): [True: 2.18M, False: 0]
  |  |  ------------------
  ------------------
                  if (can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == '{')) {
  ------------------
  |  |  195|  2.18M|#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset)
  ------------------
  |  Branch (1048:49): [True: 2.13M, False: 44.2k]
  ------------------
 1049|  2.13M|        return parse_object(item, input_buffer, out_of_memory);
 1050|  2.13M|    }
 1051|       |
 1052|  44.2k|    return false;
  ------------------
  |  |   72|  44.2k|#define false ((cJSON_bool)0)
  ------------------
 1053|  2.18M|}
cJSON.c:parse_string:
  533|  10.9M|static cJSON_bool parse_string(cJSON *const item, parse_buffer *const input_buffer, bool *out_of_memory) {
  534|  10.9M|    const unsigned char *input_pointer = buffer_at_offset(input_buffer) + 1;
  ------------------
  |  |  195|  10.9M|#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset)
  ------------------
  535|  10.9M|    const unsigned char *input_end = buffer_at_offset(input_buffer) + 1;
  ------------------
  |  |  195|  10.9M|#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset)
  ------------------
  536|  10.9M|    unsigned char *output_pointer = NULL;
  537|  10.9M|    unsigned char *output = NULL;
  538|       |
  539|       |    /* not a string */
  540|  10.9M|    if (buffer_at_offset(input_buffer)[0] != '\"') {
  ------------------
  |  |  195|  10.9M|#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset)
  ------------------
  |  Branch (540:9): [True: 741, False: 10.9M]
  ------------------
  541|    741|        goto fail;
  542|    741|    }
  543|       |
  544|  10.9M|    {
  545|       |        /* calculate approximate size of the output (overestimate) */
  546|  10.9M|        size_t allocation_length = 0;
  547|  10.9M|        size_t skipped_bytes = 0;
  548|   310M|        while (((size_t)(input_end - input_buffer->content) < input_buffer->length) && (*input_end != '\"')) {
  ------------------
  |  Branch (548:16): [True: 310M, False: 11.5k]
  |  Branch (548:88): [True: 299M, False: 10.9M]
  ------------------
  549|       |            /* is escape sequence */
  550|   299M|            if (input_end[0] == '\\') {
  ------------------
  |  Branch (550:17): [True: 460k, False: 298M]
  ------------------
  551|   460k|                if ((size_t)(input_end + 1 - input_buffer->content) >= input_buffer->length) {
  ------------------
  |  Branch (551:21): [True: 0, False: 460k]
  ------------------
  552|       |                    /* prevent buffer overflow when last input character is a backslash */
  553|      0|                    goto fail;
  554|      0|                }
  555|   460k|                skipped_bytes++;
  556|   460k|                input_end++;
  557|   460k|            }
  558|   299M|            input_end++;
  559|   299M|        }
  560|  10.9M|        if (((size_t)(input_end - input_buffer->content) >= input_buffer->length) || (*input_end != '\"')) {
  ------------------
  |  Branch (560:13): [True: 11.5k, False: 10.9M]
  |  Branch (560:86): [True: 0, False: 10.9M]
  ------------------
  561|  11.5k|            goto fail; /* string ended unexpectedly */
  562|  11.5k|        }
  563|       |
  564|       |        /* This is at most how much we need for the output */
  565|  10.9M|        allocation_length = (size_t)(input_end - buffer_at_offset(input_buffer)) - skipped_bytes;
  ------------------
  |  |  195|  10.9M|#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset)
  ------------------
  566|  10.9M|        output = (unsigned char *)loader_calloc(input_buffer->pAllocator, allocation_length + sizeof(""),
  567|  10.9M|                                                VK_SYSTEM_ALLOCATION_SCOPE_COMMAND);
  568|  10.9M|        if (output == NULL) {
  ------------------
  |  Branch (568:13): [True: 0, False: 10.9M]
  ------------------
  569|      0|            *out_of_memory = true;
  ------------------
  |  |   67|      0|#define true ((cJSON_bool)1)
  ------------------
  570|      0|            goto fail; /* allocation failure */
  571|      0|        }
  572|  10.9M|    }
  573|       |
  574|  10.9M|    output_pointer = output;
  575|       |    /* loop through the string literal */
  576|   286M|    while (input_pointer < input_end) {
  ------------------
  |  Branch (576:12): [True: 275M, False: 10.9M]
  ------------------
  577|   275M|        if (*input_pointer != '\\') {
  ------------------
  |  Branch (577:13): [True: 274M, False: 401k]
  ------------------
  578|   274M|            *output_pointer++ = *input_pointer++;
  579|   274M|        }
  580|       |        /* escape sequence */
  581|   401k|        else {
  582|   401k|            unsigned char sequence_length = 2;
  583|   401k|            if ((input_end - input_pointer) < 1) {
  ------------------
  |  Branch (583:17): [True: 0, False: 401k]
  ------------------
  584|      0|                goto fail;
  585|      0|            }
  586|       |
  587|   401k|            switch (input_pointer[1]) {
  588|  14.5k|                case 'b':
  ------------------
  |  Branch (588:17): [True: 14.5k, False: 386k]
  ------------------
  589|  14.5k|                    *output_pointer++ = '\b';
  590|  14.5k|                    break;
  591|  13.0k|                case 'f':
  ------------------
  |  Branch (591:17): [True: 13.0k, False: 388k]
  ------------------
  592|  13.0k|                    *output_pointer++ = '\f';
  593|  13.0k|                    break;
  594|    767|                case 'n':
  ------------------
  |  Branch (594:17): [True: 767, False: 400k]
  ------------------
  595|    767|                    *output_pointer++ = '\n';
  596|    767|                    break;
  597|   113k|                case 'r':
  ------------------
  |  Branch (597:17): [True: 113k, False: 288k]
  ------------------
  598|   113k|                    *output_pointer++ = '\r';
  599|   113k|                    break;
  600|  8.82k|                case 't':
  ------------------
  |  Branch (600:17): [True: 8.82k, False: 392k]
  ------------------
  601|  8.82k|                    *output_pointer++ = '\t';
  602|  8.82k|                    break;
  603|  1.00k|                case '\"':
  ------------------
  |  Branch (603:17): [True: 1.00k, False: 400k]
  ------------------
  604|  12.4k|                case '\\':
  ------------------
  |  Branch (604:17): [True: 11.4k, False: 389k]
  ------------------
  605|  12.8k|                case '/':
  ------------------
  |  Branch (605:17): [True: 363, False: 400k]
  ------------------
  606|  12.8k|                    *output_pointer++ = input_pointer[1];
  607|  12.8k|                    break;
  608|       |
  609|       |                /* UTF-16 literal */
  610|   238k|                case 'u':
  ------------------
  |  Branch (610:17): [True: 238k, False: 163k]
  ------------------
  611|   238k|                    sequence_length = utf16_literal_to_utf8(input_pointer, input_end, &output_pointer);
  612|   238k|                    if (sequence_length == 0) {
  ------------------
  |  Branch (612:25): [True: 321, False: 237k]
  ------------------
  613|       |                        /* failed to convert UTF16-literal to UTF-8 */
  614|    321|                        goto fail;
  615|    321|                    }
  616|   237k|                    break;
  617|       |
  618|   237k|                default:
  ------------------
  |  Branch (618:17): [True: 33, False: 401k]
  ------------------
  619|     33|                    goto fail;
  620|   401k|            }
  621|   400k|            input_pointer += sequence_length;
  622|   400k|        }
  623|   275M|    }
  624|       |
  625|       |    /* zero terminate the output */
  626|  10.9M|    *output_pointer = '\0';
  627|       |
  628|  10.9M|    item->type = cJSON_String;
  ------------------
  |  |  101|  10.9M|#define cJSON_String (1 << 4)
  ------------------
  629|  10.9M|    item->valuestring = (char *)output;
  630|       |
  631|  10.9M|    input_buffer->offset = (size_t)(input_end - input_buffer->content);
  632|  10.9M|    input_buffer->offset++;
  633|       |
  634|  10.9M|    return true;
  ------------------
  |  |   67|  10.9M|#define true ((cJSON_bool)1)
  ------------------
  635|       |
  636|  12.6k|fail:
  637|  12.6k|    if (output != NULL) {
  ------------------
  |  Branch (637:9): [True: 354, False: 12.2k]
  ------------------
  638|    354|        loader_free(input_buffer->pAllocator, output);
  639|    354|        output = NULL;
  640|    354|    }
  641|       |
  642|  12.6k|    if (input_pointer != NULL) {
  ------------------
  |  Branch (642:9): [True: 12.6k, False: 0]
  ------------------
  643|  12.6k|        input_buffer->offset = (size_t)(input_pointer - input_buffer->content);
  644|  12.6k|    }
  645|       |
  646|  12.6k|    return false;
  ------------------
  |  |   72|  12.6k|#define false ((cJSON_bool)0)
  ------------------
  647|  10.9M|}
cJSON.c:utf16_literal_to_utf8:
  435|   238k|                                           unsigned char **output_pointer) {
  436|   238k|    long unsigned int codepoint = 0;
  437|   238k|    unsigned int first_code = 0;
  438|   238k|    const unsigned char *first_sequence = input_pointer;
  439|   238k|    unsigned char utf8_length = 0;
  440|   238k|    unsigned char utf8_position = 0;
  441|   238k|    unsigned char sequence_length = 0;
  442|   238k|    unsigned char first_byte_mark = 0;
  443|       |
  444|   238k|    if ((input_end - first_sequence) < 6) {
  ------------------
  |  Branch (444:9): [True: 12, False: 238k]
  ------------------
  445|       |        /* input ends unexpectedly */
  446|     12|        goto fail;
  447|     12|    }
  448|       |
  449|       |    /* get the first utf16 sequence */
  450|   238k|    first_code = parse_hex4(first_sequence + 2);
  451|       |
  452|       |    /* check that the code is valid */
  453|   238k|    if (((first_code >= 0xDC00) && (first_code <= 0xDFFF))) {
  ------------------
  |  Branch (453:10): [True: 27.4k, False: 210k]
  |  Branch (453:36): [True: 206, False: 27.2k]
  ------------------
  454|    206|        goto fail;
  455|    206|    }
  456|       |
  457|       |    /* UTF16 surrogate pair */
  458|   237k|    if ((first_code >= 0xD800) && (first_code <= 0xDBFF)) {
  ------------------
  |  Branch (458:9): [True: 35.5k, False: 202k]
  |  Branch (458:35): [True: 8.33k, False: 27.2k]
  ------------------
  459|  8.33k|        const unsigned char *second_sequence = first_sequence + 6;
  460|  8.33k|        unsigned int second_code = 0;
  461|  8.33k|        sequence_length = 12; /* \uXXXX\uXXXX */
  462|       |
  463|  8.33k|        if ((input_end - second_sequence) < 6) {
  ------------------
  |  Branch (463:13): [True: 8, False: 8.32k]
  ------------------
  464|       |            /* input ends unexpectedly */
  465|      8|            goto fail;
  466|      8|        }
  467|       |
  468|  8.32k|        if ((second_sequence[0] != '\\') || (second_sequence[1] != 'u')) {
  ------------------
  |  Branch (468:13): [True: 40, False: 8.28k]
  |  Branch (468:45): [True: 12, False: 8.27k]
  ------------------
  469|       |            /* missing second half of the surrogate pair */
  470|     52|            goto fail;
  471|     52|        }
  472|       |
  473|       |        /* get the second utf16 sequence */
  474|  8.27k|        second_code = parse_hex4(second_sequence + 2);
  475|       |        /* check that the code is valid */
  476|  8.27k|        if ((second_code < 0xDC00) || (second_code > 0xDFFF)) {
  ------------------
  |  Branch (476:13): [True: 35, False: 8.24k]
  |  Branch (476:39): [True: 8, False: 8.23k]
  ------------------
  477|       |            /* invalid second half of the surrogate pair */
  478|     43|            goto fail;
  479|     43|        }
  480|       |
  481|       |        /* calculate the unicode codepoint from the surrogate pair */
  482|  8.23k|        codepoint = 0x10000 + (((first_code & 0x3FF) << 10) | (second_code & 0x3FF));
  483|   229k|    } else {
  484|   229k|        sequence_length = 6; /* \uXXXX */
  485|   229k|        codepoint = first_code;
  486|   229k|    }
  487|       |
  488|       |    /* encode as UTF-8
  489|       |     * takes at maximum 4 bytes to encode:
  490|       |     * 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx */
  491|   237k|    if (codepoint < 0x80) {
  ------------------
  |  Branch (491:9): [True: 157k, False: 80.0k]
  ------------------
  492|       |        /* normal ascii, encoding 0xxxxxxx */
  493|   157k|        utf8_length = 1;
  494|   157k|    } else if (codepoint < 0x800) {
  ------------------
  |  Branch (494:16): [True: 13.5k, False: 66.5k]
  ------------------
  495|       |        /* two bytes, encoding 110xxxxx 10xxxxxx */
  496|  13.5k|        utf8_length = 2;
  497|  13.5k|        first_byte_mark = 0xC0; /* 11000000 */
  498|  66.5k|    } else if (codepoint < 0x10000) {
  ------------------
  |  Branch (498:16): [True: 58.3k, False: 8.23k]
  ------------------
  499|       |        /* three bytes, encoding 1110xxxx 10xxxxxx 10xxxxxx */
  500|  58.3k|        utf8_length = 3;
  501|  58.3k|        first_byte_mark = 0xE0; /* 11100000 */
  502|  58.3k|    } else if (codepoint <= 0x10FFFF) {
  ------------------
  |  Branch (502:16): [True: 8.23k, False: 0]
  ------------------
  503|       |        /* four bytes, encoding 1110xxxx 10xxxxxx 10xxxxxx 10xxxxxx */
  504|  8.23k|        utf8_length = 4;
  505|  8.23k|        first_byte_mark = 0xF0; /* 11110000 */
  506|  8.23k|    } else {
  507|       |        /* invalid unicode codepoint */
  508|      0|        goto fail;
  509|      0|    }
  510|       |
  511|       |    /* encode as utf8 */
  512|   392k|    for (utf8_position = (unsigned char)(utf8_length - 1); utf8_position > 0; utf8_position--) {
  ------------------
  |  Branch (512:60): [True: 154k, False: 237k]
  ------------------
  513|       |        /* 10xxxxxx */
  514|   154k|        (*output_pointer)[utf8_position] = (unsigned char)((codepoint | 0x80) & 0xBF);
  515|   154k|        codepoint >>= 6;
  516|   154k|    }
  517|       |    /* encode first byte */
  518|   237k|    if (utf8_length > 1) {
  ------------------
  |  Branch (518:9): [True: 80.0k, False: 157k]
  ------------------
  519|  80.0k|        (*output_pointer)[0] = (unsigned char)((codepoint | first_byte_mark) & 0xFF);
  520|   157k|    } else {
  521|   157k|        (*output_pointer)[0] = (unsigned char)(codepoint & 0x7F);
  522|   157k|    }
  523|       |
  524|   237k|    *output_pointer += utf8_length;
  525|       |
  526|   237k|    return sequence_length;
  527|       |
  528|    321|fail:
  529|    321|    return 0;
  530|   237k|}
cJSON.c:parse_hex4:
  406|   246k|static unsigned parse_hex4(const unsigned char *const input) {
  407|   246k|    unsigned int h = 0;
  408|   246k|    size_t i = 0;
  409|       |
  410|   837k|    for (i = 0; i < 4; i++) {
  ------------------
  |  Branch (410:17): [True: 749k, False: 88.8k]
  ------------------
  411|       |        /* parse digit */
  412|   749k|        if ((input[i] >= '0') && (input[i] <= '9')) {
  ------------------
  |  Branch (412:13): [True: 653k, False: 95.1k]
  |  Branch (412:34): [True: 291k, False: 362k]
  ------------------
  413|   291k|            h += (unsigned int)input[i] - '0';
  414|   457k|        } else if ((input[i] >= 'A') && (input[i] <= 'F')) {
  ------------------
  |  Branch (414:20): [True: 344k, False: 112k]
  |  Branch (414:41): [True: 78.1k, False: 266k]
  ------------------
  415|  78.1k|            h += (unsigned int)10 + input[i] - 'A';
  416|   379k|        } else if ((input[i] >= 'a') && (input[i] <= 'f')) {
  ------------------
  |  Branch (416:20): [True: 248k, False: 130k]
  |  Branch (416:41): [True: 221k, False: 27.0k]
  ------------------
  417|   221k|            h += (unsigned int)10 + input[i] - 'a';
  418|   221k|        } else /* invalid */
  419|   157k|        {
  420|   157k|            return 0;
  421|   157k|        }
  422|       |
  423|   591k|        if (i < 3) {
  ------------------
  |  Branch (423:13): [True: 502k, False: 88.8k]
  ------------------
  424|       |            /* shift left to make place for the next nibble */
  425|   502k|            h = h << 4;
  426|   502k|        }
  427|   591k|    }
  428|       |
  429|  88.8k|    return h;
  430|   246k|}
cJSON.c:parse_number:
  198|  1.82M|static cJSON_bool parse_number(cJSON *const item, parse_buffer *const input_buffer) {
  199|  1.82M|    double number = 0;
  200|  1.82M|    unsigned char *after_end = NULL;
  201|  1.82M|    unsigned char number_c_string[64];
  202|  1.82M|    unsigned char decimal_point = get_decimal_point();
  203|  1.82M|    size_t i = 0;
  204|       |
  205|  1.82M|    if ((input_buffer == NULL) || (input_buffer->content == NULL)) {
  ------------------
  |  Branch (205:9): [True: 0, False: 1.82M]
  |  Branch (205:35): [True: 0, False: 1.82M]
  ------------------
  206|      0|        return false;
  ------------------
  |  |   72|      0|#define false ((cJSON_bool)0)
  ------------------
  207|      0|    }
  208|       |
  209|       |    /* copy the number into a temporary buffer and replace '.' with the decimal point
  210|       |     * of the current locale (for strtod)
  211|       |     * This also takes care of '\0' not necessarily being available for marking the end of the input */
  212|  6.50M|    for (i = 0; (i < (sizeof(number_c_string) - 1)) && can_access_at_index(input_buffer, i); i++) {
  ------------------
  |  |  192|  6.50M|#define can_access_at_index(buffer, index) ((buffer != NULL) && (((buffer)->offset + index) < (buffer)->length))
  |  |  ------------------
  |  |  |  Branch (192:45): [True: 6.50M, False: 0]
  |  |  |  Branch (192:65): [True: 6.50M, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (212:17): [True: 6.50M, False: 1.25k]
  ------------------
  213|  6.50M|        switch (buffer_at_offset(input_buffer)[i]) {
  ------------------
  |  |  195|  6.50M|#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset)
  ------------------
  214|   535k|            case '0':
  ------------------
  |  Branch (214:13): [True: 535k, False: 5.96M]
  ------------------
  215|  1.83M|            case '1':
  ------------------
  |  Branch (215:13): [True: 1.29M, False: 5.20M]
  ------------------
  216|  2.13M|            case '2':
  ------------------
  |  Branch (216:13): [True: 303k, False: 6.20M]
  ------------------
  217|  2.34M|            case '3':
  ------------------
  |  Branch (217:13): [True: 207k, False: 6.29M]
  ------------------
  218|  2.53M|            case '4':
  ------------------
  |  Branch (218:13): [True: 194k, False: 6.30M]
  ------------------
  219|  2.71M|            case '5':
  ------------------
  |  Branch (219:13): [True: 183k, False: 6.31M]
  ------------------
  220|  3.22M|            case '6':
  ------------------
  |  Branch (220:13): [True: 508k, False: 5.99M]
  ------------------
  221|  3.51M|            case '7':
  ------------------
  |  Branch (221:13): [True: 288k, False: 6.21M]
  ------------------
  222|  3.73M|            case '8':
  ------------------
  |  Branch (222:13): [True: 218k, False: 6.28M]
  ------------------
  223|  4.26M|            case '9':
  ------------------
  |  Branch (223:13): [True: 534k, False: 5.96M]
  ------------------
  224|  4.27M|            case '+':
  ------------------
  |  Branch (224:13): [True: 2.10k, False: 6.50M]
  ------------------
  225|  4.30M|            case '-':
  ------------------
  |  Branch (225:13): [True: 35.3k, False: 6.46M]
  ------------------
  226|  4.64M|            case 'e':
  ------------------
  |  Branch (226:13): [True: 339k, False: 6.16M]
  ------------------
  227|  4.65M|            case 'E':
  ------------------
  |  Branch (227:13): [True: 5.45k, False: 6.49M]
  ------------------
  228|  4.65M|                number_c_string[i] = buffer_at_offset(input_buffer)[i];
  ------------------
  |  |  195|  4.65M|#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset)
  ------------------
  229|  4.65M|                break;
  230|       |
  231|  27.0k|            case '.':
  ------------------
  |  Branch (231:13): [True: 27.0k, False: 6.47M]
  ------------------
  232|  27.0k|                number_c_string[i] = decimal_point;
  233|  27.0k|                break;
  234|       |
  235|  1.82M|            default:
  ------------------
  |  Branch (235:13): [True: 1.82M, False: 4.67M]
  ------------------
  236|  1.82M|                goto loop_end;
  237|  6.50M|        }
  238|  6.50M|    }
  239|  1.82M|loop_end:
  240|  1.82M|    number_c_string[i] = '\0';
  241|       |
  242|  1.82M|    number = strtod((const char *)number_c_string, (char **)&after_end);
  243|  1.82M|    if (number_c_string == after_end) {
  ------------------
  |  Branch (243:9): [True: 47, False: 1.82M]
  ------------------
  244|     47|        return false; /* parse_error */
  ------------------
  |  |   72|     47|#define false ((cJSON_bool)0)
  ------------------
  245|     47|    }
  246|       |
  247|  1.82M|    item->valuedouble = number;
  248|       |
  249|       |    /* use saturation in case of overflow */
  250|  1.82M|    if (number >= INT_MAX) {
  ------------------
  |  Branch (250:9): [True: 170k, False: 1.65M]
  ------------------
  251|   170k|        item->valueint = INT_MAX;
  252|  1.65M|    } else if (number <= (double)INT_MIN) {
  ------------------
  |  Branch (252:16): [True: 16.4k, False: 1.63M]
  ------------------
  253|  16.4k|        item->valueint = INT_MIN;
  254|  1.63M|    } else {
  255|  1.63M|        item->valueint = (int)number;
  256|  1.63M|    }
  257|       |
  258|  1.82M|    item->type = cJSON_Number;
  ------------------
  |  |  100|  1.82M|#define cJSON_Number (1 << 3)
  ------------------
  259|       |
  260|  1.82M|    input_buffer->offset += (size_t)(after_end - number_c_string);
  261|  1.82M|    return true;
  ------------------
  |  |   67|  1.82M|#define true ((cJSON_bool)1)
  ------------------
  262|  1.82M|}
cJSON.c:get_decimal_point:
  172|  2.15M|static unsigned char get_decimal_point(void) {
  173|       |#ifdef ENABLE_LOCALES
  174|       |    struct lconv *lconv = localeconv();
  175|       |    return (unsigned char)lconv->decimal_point[0];
  176|       |#else
  177|  2.15M|    return '.';
  178|  2.15M|#endif
  179|  2.15M|}
cJSON.c:parse_array:
 1121|  1.12M|static cJSON_bool parse_array(cJSON *const item, parse_buffer *const input_buffer, bool *out_of_memory) {
 1122|  1.12M|    cJSON *head = NULL; /* head of the linked list */
 1123|  1.12M|    cJSON *current_item = NULL;
 1124|       |
 1125|  1.12M|    if (input_buffer->depth >= CJSON_NESTING_LIMIT) {
  ------------------
  |  |  138|  1.12M|#define CJSON_NESTING_LIMIT 1000
  ------------------
  |  Branch (1125:9): [True: 187, False: 1.12M]
  ------------------
 1126|    187|        return false; /* to deeply nested */
  ------------------
  |  |   72|    187|#define false ((cJSON_bool)0)
  ------------------
 1127|    187|    }
 1128|  1.12M|    input_buffer->depth++;
 1129|       |
 1130|  1.12M|    if (buffer_at_offset(input_buffer)[0] != '[') {
  ------------------
  |  |  195|  1.12M|#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset)
  ------------------
  |  Branch (1130:9): [True: 0, False: 1.12M]
  ------------------
 1131|       |        /* not an array */
 1132|      0|        goto fail;
 1133|      0|    }
 1134|       |
 1135|  1.12M|    input_buffer->offset++;
 1136|  1.12M|    buffer_skip_whitespace(input_buffer);
 1137|  1.12M|    if (can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == ']')) {
  ------------------
  |  |  192|  2.24M|#define can_access_at_index(buffer, index) ((buffer != NULL) && (((buffer)->offset + index) < (buffer)->length))
  |  |  ------------------
  |  |  |  Branch (192:45): [True: 1.12M, False: 0]
  |  |  |  Branch (192:65): [True: 1.12M, False: 0]
  |  |  ------------------
  ------------------
                  if (can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == ']')) {
  ------------------
  |  |  195|  1.12M|#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset)
  ------------------
  |  Branch (1137:49): [True: 269k, False: 850k]
  ------------------
 1138|       |        /* empty array */
 1139|   269k|        goto success;
 1140|   269k|    }
 1141|       |
 1142|       |    /* check if we skipped to the end of the buffer */
 1143|   850k|    if (cannot_access_at_index(input_buffer, 0)) {
  ------------------
  |  |  193|   850k|#define cannot_access_at_index(buffer, index) (!can_access_at_index(buffer, index))
  |  |  ------------------
  |  |  |  |  192|   850k|#define can_access_at_index(buffer, index) ((buffer != NULL) && (((buffer)->offset + index) < (buffer)->length))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (192:45): [True: 850k, False: 0]
  |  |  |  |  |  Branch (192:65): [True: 850k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1144|      0|        input_buffer->offset--;
 1145|      0|        goto fail;
 1146|      0|    }
 1147|       |
 1148|       |    /* step back to character in front of the first element */
 1149|   850k|    input_buffer->offset--;
 1150|       |    /* loop through the comma separated array elements */
 1151|  5.08M|    do {
 1152|       |        /* allocate next item */
 1153|  5.08M|        cJSON *new_item = cJSON_New_Item(input_buffer->pAllocator);
 1154|  5.08M|        if (new_item == NULL) {
  ------------------
  |  Branch (1154:13): [True: 0, False: 5.08M]
  ------------------
 1155|      0|            *out_of_memory = true;
  ------------------
  |  |   67|      0|#define true ((cJSON_bool)1)
  ------------------
 1156|      0|            goto fail; /* allocation failure */
 1157|      0|        }
 1158|       |
 1159|       |        /* attach next item to list */
 1160|  5.08M|        if (head == NULL) {
  ------------------
  |  Branch (1160:13): [True: 850k, False: 4.23M]
  ------------------
 1161|       |            /* start the linked list */
 1162|   850k|            current_item = head = new_item;
 1163|  4.23M|        } else {
 1164|       |            /* add to the end and advance */
 1165|  4.23M|            current_item->next = new_item;
 1166|  4.23M|            new_item->prev = current_item;
 1167|  4.23M|            current_item = new_item;
 1168|  4.23M|        }
 1169|       |
 1170|       |        /* parse next value */
 1171|  5.08M|        input_buffer->offset++;
 1172|  5.08M|        buffer_skip_whitespace(input_buffer);
 1173|  5.08M|        if (!parse_value(current_item, input_buffer, out_of_memory)) {
  ------------------
  |  Branch (1173:13): [True: 253k, False: 4.82M]
  ------------------
 1174|   253k|            goto fail; /* failed to parse value */
 1175|   253k|        }
 1176|  4.82M|        buffer_skip_whitespace(input_buffer);
 1177|  4.82M|    } while (can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == ','));
  ------------------
  |  |  192|  9.65M|#define can_access_at_index(buffer, index) ((buffer != NULL) && (((buffer)->offset + index) < (buffer)->length))
  |  |  ------------------
  |  |  |  Branch (192:45): [True: 4.82M, False: 0]
  |  |  |  Branch (192:65): [True: 4.82M, False: 0]
  |  |  ------------------
  ------------------
                  } while (can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == ','));
  ------------------
  |  |  195|  4.82M|#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset)
  ------------------
  |  Branch (1177:54): [True: 4.23M, False: 597k]
  ------------------
 1178|       |
 1179|   597k|    if (cannot_access_at_index(input_buffer, 0) || buffer_at_offset(input_buffer)[0] != ']') {
  ------------------
  |  |  193|  1.19M|#define cannot_access_at_index(buffer, index) (!can_access_at_index(buffer, index))
  |  |  ------------------
  |  |  |  |  192|   597k|#define can_access_at_index(buffer, index) ((buffer != NULL) && (((buffer)->offset + index) < (buffer)->length))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (192:45): [True: 597k, False: 0]
  |  |  |  |  |  Branch (192:65): [True: 597k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                  if (cannot_access_at_index(input_buffer, 0) || buffer_at_offset(input_buffer)[0] != ']') {
  ------------------
  |  |  195|   597k|#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset)
  ------------------
  |  Branch (1179:52): [True: 929, False: 596k]
  ------------------
 1180|    929|        goto fail; /* expected end of array */
 1181|    929|    }
 1182|       |
 1183|   866k|success:
 1184|   866k|    input_buffer->depth--;
 1185|       |
 1186|   866k|    if (head != NULL) {
  ------------------
  |  Branch (1186:9): [True: 596k, False: 269k]
  ------------------
 1187|   596k|        head->prev = current_item;
 1188|   596k|    }
 1189|       |
 1190|   866k|    item->type = cJSON_Array;
  ------------------
  |  |  102|   866k|#define cJSON_Array (1 << 5)
  ------------------
 1191|   866k|    item->child = head;
 1192|       |
 1193|   866k|    input_buffer->offset++;
 1194|       |
 1195|   866k|    return true;
  ------------------
  |  |   67|   866k|#define true ((cJSON_bool)1)
  ------------------
 1196|       |
 1197|   254k|fail:
 1198|   254k|    if (head != NULL) {
  ------------------
  |  Branch (1198:9): [True: 254k, False: 0]
  ------------------
 1199|   254k|        loader_cJSON_Delete(head);
 1200|   254k|    }
 1201|       |
 1202|   254k|    return false;
  ------------------
  |  |   72|   254k|#define false ((cJSON_bool)0)
  ------------------
 1203|   597k|}
cJSON.c:parse_object:
 1259|  2.13M|static cJSON_bool parse_object(cJSON *const item, parse_buffer *const input_buffer, bool *out_of_memory) {
 1260|  2.13M|    cJSON *head = NULL; /* linked list head */
 1261|  2.13M|    cJSON *current_item = NULL;
 1262|       |
 1263|  2.13M|    if (input_buffer->depth >= CJSON_NESTING_LIMIT) {
  ------------------
  |  |  138|  2.13M|#define CJSON_NESTING_LIMIT 1000
  ------------------
  |  Branch (1263:9): [True: 2, False: 2.13M]
  ------------------
 1264|      2|        return false; /* to deeply nested */
  ------------------
  |  |   72|      2|#define false ((cJSON_bool)0)
  ------------------
 1265|      2|    }
 1266|  2.13M|    input_buffer->depth++;
 1267|       |
 1268|  2.13M|    if (cannot_access_at_index(input_buffer, 0) || (buffer_at_offset(input_buffer)[0] != '{')) {
  ------------------
  |  |  193|  4.27M|#define cannot_access_at_index(buffer, index) (!can_access_at_index(buffer, index))
  |  |  ------------------
  |  |  |  |  192|  2.13M|#define can_access_at_index(buffer, index) ((buffer != NULL) && (((buffer)->offset + index) < (buffer)->length))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (192:45): [True: 2.13M, False: 0]
  |  |  |  |  |  Branch (192:65): [True: 2.13M, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                  if (cannot_access_at_index(input_buffer, 0) || (buffer_at_offset(input_buffer)[0] != '{')) {
  ------------------
  |  |  195|  2.13M|#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset)
  ------------------
  |  Branch (1268:52): [True: 0, False: 2.13M]
  ------------------
 1269|      0|        goto fail; /* not an object */
 1270|      0|    }
 1271|       |
 1272|  2.13M|    input_buffer->offset++;
 1273|  2.13M|    buffer_skip_whitespace(input_buffer);
 1274|  2.13M|    if (can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == '}')) {
  ------------------
  |  |  192|  4.27M|#define can_access_at_index(buffer, index) ((buffer != NULL) && (((buffer)->offset + index) < (buffer)->length))
  |  |  ------------------
  |  |  |  Branch (192:45): [True: 2.13M, False: 0]
  |  |  |  Branch (192:65): [True: 2.13M, False: 0]
  |  |  ------------------
  ------------------
                  if (can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == '}')) {
  ------------------
  |  |  195|  2.13M|#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset)
  ------------------
  |  Branch (1274:49): [True: 31.7k, False: 2.10M]
  ------------------
 1275|  31.7k|        goto success; /* empty object */
 1276|  31.7k|    }
 1277|       |
 1278|       |    /* check if we skipped to the end of the buffer */
 1279|  2.10M|    if (cannot_access_at_index(input_buffer, 0)) {
  ------------------
  |  |  193|  2.10M|#define cannot_access_at_index(buffer, index) (!can_access_at_index(buffer, index))
  |  |  ------------------
  |  |  |  |  192|  2.10M|#define can_access_at_index(buffer, index) ((buffer != NULL) && (((buffer)->offset + index) < (buffer)->length))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (192:45): [True: 2.10M, False: 0]
  |  |  |  |  |  Branch (192:65): [True: 2.10M, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1280|      0|        input_buffer->offset--;
 1281|      0|        goto fail;
 1282|      0|    }
 1283|       |
 1284|       |    /* step back to character in front of the first element */
 1285|  2.10M|    input_buffer->offset--;
 1286|       |    /* loop through the comma separated array elements */
 1287|  5.54M|    do {
 1288|       |        /* allocate next item */
 1289|  5.54M|        cJSON *new_item = cJSON_New_Item(input_buffer->pAllocator);
 1290|  5.54M|        if (new_item == NULL) {
  ------------------
  |  Branch (1290:13): [True: 0, False: 5.54M]
  ------------------
 1291|      0|            *out_of_memory = true;
  ------------------
  |  |   67|      0|#define true ((cJSON_bool)1)
  ------------------
 1292|      0|            goto fail; /* allocation failure */
 1293|      0|        }
 1294|       |
 1295|       |        /* attach next item to list */
 1296|  5.54M|        if (head == NULL) {
  ------------------
  |  Branch (1296:13): [True: 2.10M, False: 3.43M]
  ------------------
 1297|       |            /* start the linked list */
 1298|  2.10M|            current_item = head = new_item;
 1299|  3.43M|        } else {
 1300|       |            /* add to the end and advance */
 1301|  3.43M|            current_item->next = new_item;
 1302|  3.43M|            new_item->prev = current_item;
 1303|  3.43M|            current_item = new_item;
 1304|  3.43M|        }
 1305|       |
 1306|  5.54M|        if (cannot_access_at_index(input_buffer, 1)) {
  ------------------
  |  |  193|  5.54M|#define cannot_access_at_index(buffer, index) (!can_access_at_index(buffer, index))
  |  |  ------------------
  |  |  |  |  192|  5.54M|#define can_access_at_index(buffer, index) ((buffer != NULL) && (((buffer)->offset + index) < (buffer)->length))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (192:45): [True: 5.54M, False: 0]
  |  |  |  |  |  Branch (192:65): [True: 5.54M, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1307|      0|            goto fail; /* nothing comes after the comma */
 1308|      0|        }
 1309|       |
 1310|       |        /* parse the name of the child */
 1311|  5.54M|        input_buffer->offset++;
 1312|  5.54M|        buffer_skip_whitespace(input_buffer);
 1313|  5.54M|        if (!parse_string(current_item, input_buffer, out_of_memory)) {
  ------------------
  |  Branch (1313:13): [True: 808, False: 5.54M]
  ------------------
 1314|    808|            goto fail; /* failed to parse name */
 1315|    808|        }
 1316|  5.54M|        buffer_skip_whitespace(input_buffer);
 1317|       |
 1318|       |        /* swap valuestring and string, because we parsed the name */
 1319|  5.54M|        current_item->string = current_item->valuestring;
 1320|  5.54M|        current_item->valuestring = NULL;
 1321|       |
 1322|  5.54M|        if (cannot_access_at_index(input_buffer, 0) || (buffer_at_offset(input_buffer)[0] != ':')) {
  ------------------
  |  |  193|  11.0M|#define cannot_access_at_index(buffer, index) (!can_access_at_index(buffer, index))
  |  |  ------------------
  |  |  |  |  192|  5.54M|#define can_access_at_index(buffer, index) ((buffer != NULL) && (((buffer)->offset + index) < (buffer)->length))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (192:45): [True: 5.54M, False: 0]
  |  |  |  |  |  Branch (192:65): [True: 5.54M, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                      if (cannot_access_at_index(input_buffer, 0) || (buffer_at_offset(input_buffer)[0] != ':')) {
  ------------------
  |  |  195|  5.54M|#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset)
  ------------------
  |  Branch (1322:56): [True: 19, False: 5.54M]
  ------------------
 1323|     19|            goto fail; /* invalid object */
 1324|     19|        }
 1325|       |
 1326|       |        /* parse the value */
 1327|  5.54M|        input_buffer->offset++;
 1328|  5.54M|        buffer_skip_whitespace(input_buffer);
 1329|  5.54M|        if (!parse_value(current_item, input_buffer, out_of_memory)) {
  ------------------
  |  Branch (1329:13): [True: 17.6k, False: 5.52M]
  ------------------
 1330|  17.6k|            goto fail; /* failed to parse value */
 1331|  17.6k|        }
 1332|  5.52M|        buffer_skip_whitespace(input_buffer);
 1333|  5.52M|    } while (can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == ','));
  ------------------
  |  |  192|  11.0M|#define can_access_at_index(buffer, index) ((buffer != NULL) && (((buffer)->offset + index) < (buffer)->length))
  |  |  ------------------
  |  |  |  Branch (192:45): [True: 5.52M, False: 0]
  |  |  |  Branch (192:65): [True: 5.52M, False: 0]
  |  |  ------------------
  ------------------
                  } while (can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == ','));
  ------------------
  |  |  195|  5.52M|#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset)
  ------------------
  |  Branch (1333:54): [True: 3.43M, False: 2.08M]
  ------------------
 1334|       |
 1335|  2.08M|    if (cannot_access_at_index(input_buffer, 0) || (buffer_at_offset(input_buffer)[0] != '}')) {
  ------------------
  |  |  193|  4.17M|#define cannot_access_at_index(buffer, index) (!can_access_at_index(buffer, index))
  |  |  ------------------
  |  |  |  |  192|  2.08M|#define can_access_at_index(buffer, index) ((buffer != NULL) && (((buffer)->offset + index) < (buffer)->length))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (192:45): [True: 2.08M, False: 0]
  |  |  |  |  |  Branch (192:65): [True: 2.08M, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                  if (cannot_access_at_index(input_buffer, 0) || (buffer_at_offset(input_buffer)[0] != '}')) {
  ------------------
  |  |  195|  2.08M|#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset)
  ------------------
  |  Branch (1335:52): [True: 44, False: 2.08M]
  ------------------
 1336|     44|        goto fail; /* expected end of object */
 1337|     44|    }
 1338|       |
 1339|  2.12M|success:
 1340|  2.12M|    input_buffer->depth--;
 1341|       |
 1342|  2.12M|    if (head != NULL) {
  ------------------
  |  Branch (1342:9): [True: 2.08M, False: 31.7k]
  ------------------
 1343|  2.08M|        head->prev = current_item;
 1344|  2.08M|    }
 1345|       |
 1346|  2.12M|    item->type = cJSON_Object;
  ------------------
  |  |  103|  2.12M|#define cJSON_Object (1 << 6)
  ------------------
 1347|  2.12M|    item->child = head;
 1348|       |
 1349|  2.12M|    input_buffer->offset++;
 1350|  2.12M|    return true;
  ------------------
  |  |   67|  2.12M|#define true ((cJSON_bool)1)
  ------------------
 1351|       |
 1352|  18.4k|fail:
 1353|  18.4k|    if (head != NULL) {
  ------------------
  |  Branch (1353:9): [True: 18.4k, False: 0]
  ------------------
 1354|  18.4k|        loader_cJSON_Delete(head);
 1355|  18.4k|    }
 1356|       |
 1357|  18.4k|    return false;
  ------------------
  |  |   72|  18.4k|#define false ((cJSON_bool)0)
  ------------------
 1358|  2.08M|}
cJSON.c:print_value:
 1056|  2.80M|static cJSON_bool print_value(const cJSON *const item, printbuffer *const output_buffer, bool *out_of_memory) {
 1057|  2.80M|    unsigned char *output = NULL;
 1058|       |
 1059|  2.80M|    if ((item == NULL) || (output_buffer == NULL)) {
  ------------------
  |  Branch (1059:9): [True: 0, False: 2.80M]
  |  Branch (1059:27): [True: 0, False: 2.80M]
  ------------------
 1060|      0|        return false;
  ------------------
  |  |   72|      0|#define false ((cJSON_bool)0)
  ------------------
 1061|      0|    }
 1062|       |
 1063|  2.80M|    switch ((item->type) & 0xFF) {
 1064|    600|        case cJSON_NULL:
  ------------------
  |  |   99|    600|#define cJSON_NULL (1 << 2)
  ------------------
  |  Branch (1064:9): [True: 600, False: 2.80M]
  ------------------
 1065|    600|            output = ensure(output_buffer, 5, out_of_memory);
 1066|    600|            if (output == NULL) {
  ------------------
  |  Branch (1066:17): [True: 0, False: 600]
  ------------------
 1067|      0|                return false;
  ------------------
  |  |   72|      0|#define false ((cJSON_bool)0)
  ------------------
 1068|      0|            }
 1069|    600|            strcpy((char *)output, "null");
 1070|    600|            return true;
  ------------------
  |  |   67|    600|#define true ((cJSON_bool)1)
  ------------------
 1071|       |
 1072|  2.49k|        case cJSON_False:
  ------------------
  |  |   97|  2.49k|#define cJSON_False (1 << 0)
  ------------------
  |  Branch (1072:9): [True: 2.49k, False: 2.80M]
  ------------------
 1073|  2.49k|            output = ensure(output_buffer, 6, out_of_memory);
 1074|  2.49k|            if (output == NULL) {
  ------------------
  |  Branch (1074:17): [True: 0, False: 2.49k]
  ------------------
 1075|      0|                return false;
  ------------------
  |  |   72|      0|#define false ((cJSON_bool)0)
  ------------------
 1076|      0|            }
 1077|  2.49k|            strcpy((char *)output, "false");
 1078|  2.49k|            return true;
  ------------------
  |  |   67|  2.49k|#define true ((cJSON_bool)1)
  ------------------
 1079|       |
 1080|  31.8k|        case cJSON_True:
  ------------------
  |  |   98|  31.8k|#define cJSON_True (1 << 1)
  ------------------
  |  Branch (1080:9): [True: 31.8k, False: 2.77M]
  ------------------
 1081|  31.8k|            output = ensure(output_buffer, 5, out_of_memory);
 1082|  31.8k|            if (output == NULL) {
  ------------------
  |  Branch (1082:17): [True: 0, False: 31.8k]
  ------------------
 1083|      0|                return false;
  ------------------
  |  |   72|      0|#define false ((cJSON_bool)0)
  ------------------
 1084|      0|            }
 1085|  31.8k|            strcpy((char *)output, "true");
 1086|  31.8k|            return true;
  ------------------
  |  |   67|  31.8k|#define true ((cJSON_bool)1)
  ------------------
 1087|       |
 1088|   327k|        case cJSON_Number:
  ------------------
  |  |  100|   327k|#define cJSON_Number (1 << 3)
  ------------------
  |  Branch (1088:9): [True: 327k, False: 2.47M]
  ------------------
 1089|   327k|            return print_number(item, output_buffer, out_of_memory);
 1090|       |
 1091|      0|        case cJSON_Raw: {
  ------------------
  |  |  104|      0|#define cJSON_Raw (1 << 7) /* raw json */
  ------------------
  |  Branch (1091:9): [True: 0, False: 2.80M]
  ------------------
 1092|      0|            size_t raw_length = 0;
 1093|      0|            if (item->valuestring == NULL) {
  ------------------
  |  Branch (1093:17): [True: 0, False: 0]
  ------------------
 1094|      0|                return false;
  ------------------
  |  |   72|      0|#define false ((cJSON_bool)0)
  ------------------
 1095|      0|            }
 1096|       |
 1097|      0|            raw_length = strlen(item->valuestring) + sizeof("");
 1098|      0|            output = ensure(output_buffer, raw_length, out_of_memory);
 1099|      0|            if (output == NULL) {
  ------------------
  |  Branch (1099:17): [True: 0, False: 0]
  ------------------
 1100|      0|                return false;
  ------------------
  |  |   72|      0|#define false ((cJSON_bool)0)
  ------------------
 1101|      0|            }
 1102|      0|            memcpy(output, item->valuestring, raw_length);
 1103|      0|            return true;
  ------------------
  |  |   67|      0|#define true ((cJSON_bool)1)
  ------------------
 1104|      0|        }
 1105|       |
 1106|  1.97M|        case cJSON_String:
  ------------------
  |  |  101|  1.97M|#define cJSON_String (1 << 4)
  ------------------
  |  Branch (1106:9): [True: 1.97M, False: 832k]
  ------------------
 1107|  1.97M|            return print_string(item, output_buffer, out_of_memory);
 1108|       |
 1109|   140k|        case cJSON_Array:
  ------------------
  |  |  102|   140k|#define cJSON_Array (1 << 5)
  ------------------
  |  Branch (1109:9): [True: 140k, False: 2.66M]
  ------------------
 1110|   140k|            return print_array(item, output_buffer, out_of_memory);
 1111|       |
 1112|   330k|        case cJSON_Object:
  ------------------
  |  |  103|   330k|#define cJSON_Object (1 << 6)
  ------------------
  |  Branch (1112:9): [True: 330k, False: 2.47M]
  ------------------
 1113|   330k|            return print_object(item, output_buffer, out_of_memory);
 1114|       |
 1115|      0|        default:
  ------------------
  |  Branch (1115:9): [True: 0, False: 2.80M]
  ------------------
 1116|      0|            return false;
  ------------------
  |  |   72|      0|#define false ((cJSON_bool)0)
  ------------------
 1117|  2.80M|    }
 1118|  2.80M|}
cJSON.c:ensure:
  275|  5.52M|static unsigned char *ensure(printbuffer *const p, size_t needed, bool *out_of_memory) {
  276|  5.52M|    unsigned char *newbuffer = NULL;
  277|  5.52M|    size_t newsize = 0;
  278|       |
  279|  5.52M|    if ((p == NULL) || (p->buffer == NULL)) {
  ------------------
  |  Branch (279:9): [True: 0, False: 5.52M]
  |  Branch (279:24): [True: 0, False: 5.52M]
  ------------------
  280|      0|        return NULL;
  281|      0|    }
  282|       |
  283|  5.52M|    if ((p->length > 0) && (p->offset >= p->length)) {
  ------------------
  |  Branch (283:9): [True: 5.52M, False: 0]
  |  Branch (283:28): [True: 0, False: 5.52M]
  ------------------
  284|       |        /* make sure that offset is valid */
  285|      0|        return NULL;
  286|      0|    }
  287|       |
  288|  5.52M|    if (needed > INT_MAX) {
  ------------------
  |  Branch (288:9): [True: 0, False: 5.52M]
  ------------------
  289|       |        /* sizes bigger than INT_MAX are currently not supported */
  290|      0|        return NULL;
  291|      0|    }
  292|       |
  293|  5.52M|    needed += p->offset + 1;
  294|  5.52M|    if (needed <= p->length) {
  ------------------
  |  Branch (294:9): [True: 5.50M, False: 11.1k]
  ------------------
  295|  5.50M|        return p->buffer + p->offset;
  296|  5.50M|    }
  297|       |
  298|  11.1k|    if (p->noalloc) {
  ------------------
  |  Branch (298:9): [True: 971, False: 10.1k]
  ------------------
  299|    971|        return NULL;
  300|    971|    }
  301|       |
  302|       |    /* calculate new buffer size */
  303|  10.1k|    if (needed > (INT_MAX / 2)) {
  ------------------
  |  Branch (303:9): [True: 0, False: 10.1k]
  ------------------
  304|       |        /* overflow of int, use INT_MAX if possible */
  305|      0|        if (needed <= INT_MAX) {
  ------------------
  |  Branch (305:13): [True: 0, False: 0]
  ------------------
  306|      0|            newsize = INT_MAX;
  307|      0|        } else {
  308|      0|            return NULL;
  309|      0|        }
  310|  10.1k|    } else {
  311|  10.1k|        newsize = needed * 2;
  312|  10.1k|    }
  313|       |
  314|  10.1k|    newbuffer = (unsigned char *)loader_realloc(p->pAllocator, p->buffer, p->length, newsize, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
  315|  10.1k|    if (newbuffer == NULL) {
  ------------------
  |  Branch (315:9): [True: 0, False: 10.1k]
  ------------------
  316|      0|        *out_of_memory = true;
  ------------------
  |  |   67|      0|#define true ((cJSON_bool)1)
  ------------------
  317|      0|        loader_free(p->pAllocator, p->buffer);
  318|      0|        p->length = 0;
  319|      0|        p->buffer = NULL;
  320|       |
  321|      0|        return NULL;
  322|      0|    }
  323|       |
  324|  10.1k|    p->length = newsize;
  325|  10.1k|    p->buffer = newbuffer;
  326|       |
  327|  10.1k|    return newbuffer + p->offset;
  328|  10.1k|}
cJSON.c:print_number:
  348|   327k|static cJSON_bool print_number(const cJSON *const item, printbuffer *const output_buffer, bool *out_of_memory) {
  349|   327k|    unsigned char *output_pointer = NULL;
  350|   327k|    double d = item->valuedouble;
  351|   327k|    int length = 0;
  352|   327k|    size_t i = 0;
  353|   327k|    unsigned char number_buffer[26] = {0}; /* temporary buffer to print the number into */
  354|   327k|    unsigned char decimal_point = get_decimal_point();
  355|   327k|    double test = 0.0;
  356|       |
  357|   327k|    if (output_buffer == NULL) {
  ------------------
  |  Branch (357:9): [True: 0, False: 327k]
  ------------------
  358|      0|        return false;
  ------------------
  |  |   72|      0|#define false ((cJSON_bool)0)
  ------------------
  359|      0|    }
  360|       |
  361|       |    /* This checks for NaN and Infinity */
  362|   327k|    if (isnan(d) || isinf(d)) {
  ------------------
  |  Branch (362:9): [True: 0, False: 327k]
  |  Branch (362:21): [True: 967, False: 326k]
  ------------------
  363|    967|        length = snprintf((char *)number_buffer, 26, "null");
  364|   326k|    } else if (d == (double)item->valueint) {
  ------------------
  |  Branch (364:16): [True: 291k, False: 34.8k]
  ------------------
  365|   291k|        length = snprintf((char *)number_buffer, 26, "%d", item->valueint);
  366|   291k|    } else {
  367|       |        /* Try 15 decimal places of precision to avoid nonsignificant nonzero digits */
  368|  34.8k|        length = snprintf((char *)number_buffer, 26, "%1.15g", d);
  369|       |
  370|       |        /* Check whether the original double can be recovered */
  371|  34.8k|        if ((sscanf((char *)number_buffer, "%lg", &test) != 1) || !compare_double((double)test, d)) {
  ------------------
  |  Branch (371:13): [True: 0, False: 34.8k]
  |  Branch (371:67): [True: 718, False: 34.1k]
  ------------------
  372|       |            /* If not, print with 17 decimal places of precision */
  373|    718|            length = snprintf((char *)number_buffer, 26, "%1.17g", d);
  374|    718|        }
  375|  34.8k|    }
  376|       |
  377|       |    /* snprintf failed or buffer overrun occurred */
  378|   327k|    if ((length < 0) || (length > (int)(sizeof(number_buffer) - 1))) {
  ------------------
  |  Branch (378:9): [True: 0, False: 327k]
  |  Branch (378:25): [True: 0, False: 327k]
  ------------------
  379|      0|        return false;
  ------------------
  |  |   72|      0|#define false ((cJSON_bool)0)
  ------------------
  380|      0|    }
  381|       |
  382|       |    /* reserve appropriate space in the output */
  383|   327k|    output_pointer = ensure(output_buffer, (size_t)length + sizeof(""), out_of_memory);
  384|   327k|    if (output_pointer == NULL) {
  ------------------
  |  Branch (384:9): [True: 0, False: 327k]
  ------------------
  385|      0|        return false;
  ------------------
  |  |   72|      0|#define false ((cJSON_bool)0)
  ------------------
  386|      0|    }
  387|       |
  388|       |    /* copy the printed number to the output and replace locale
  389|       |     * dependent decimal point with '.' */
  390|   829k|    for (i = 0; i < ((size_t)length); i++) {
  ------------------
  |  Branch (390:17): [True: 502k, False: 327k]
  ------------------
  391|   502k|        if (number_buffer[i] == decimal_point) {
  ------------------
  |  Branch (391:13): [True: 2.31k, False: 499k]
  ------------------
  392|  2.31k|            output_pointer[i] = '.';
  393|  2.31k|            continue;
  394|  2.31k|        }
  395|       |
  396|   499k|        output_pointer[i] = number_buffer[i];
  397|   499k|    }
  398|   327k|    output_pointer[i] = '\0';
  399|       |
  400|   327k|    output_buffer->offset += (size_t)length;
  401|       |
  402|   327k|    return true;
  ------------------
  |  |   67|   327k|#define true ((cJSON_bool)1)
  ------------------
  403|   327k|}
cJSON.c:print_string:
  759|  1.97M|static cJSON_bool print_string(const cJSON *const item, printbuffer *const p, bool *out_of_memory) {
  760|  1.97M|    return print_string_ptr((unsigned char *)item->valuestring, p, out_of_memory);
  761|  1.97M|}
cJSON.c:print_string_ptr:
  650|  2.47M|static cJSON_bool print_string_ptr(const unsigned char *const input, printbuffer *const output_buffer, bool *out_of_memory) {
  651|  2.47M|    const unsigned char *input_pointer = NULL;
  652|  2.47M|    unsigned char *output = NULL;
  653|  2.47M|    unsigned char *output_pointer = NULL;
  654|  2.47M|    size_t output_length = 0;
  655|       |    /* numbers of additional characters needed for escaping */
  656|  2.47M|    size_t escape_characters = 0;
  657|       |
  658|  2.47M|    if (output_buffer == NULL) {
  ------------------
  |  Branch (658:9): [True: 0, False: 2.47M]
  ------------------
  659|      0|        return false;
  ------------------
  |  |   72|      0|#define false ((cJSON_bool)0)
  ------------------
  660|      0|    }
  661|       |
  662|       |    /* empty string */
  663|  2.47M|    if (input == NULL) {
  ------------------
  |  Branch (663:9): [True: 0, False: 2.47M]
  ------------------
  664|      0|        output = ensure(output_buffer, sizeof(""), out_of_memory);
  665|      0|        if (output == NULL) {
  ------------------
  |  Branch (665:13): [True: 0, False: 0]
  ------------------
  666|      0|            return false;
  ------------------
  |  |   72|      0|#define false ((cJSON_bool)0)
  ------------------
  667|      0|        }
  668|       |
  669|      0|        return true;
  ------------------
  |  |   67|      0|#define true ((cJSON_bool)1)
  ------------------
  670|      0|    }
  671|       |
  672|       |    /* set "flag" to 1 if something needs to be escaped */
  673|  55.8M|    for (input_pointer = input; *input_pointer; input_pointer++) {
  ------------------
  |  Branch (673:33): [True: 53.3M, False: 2.47M]
  ------------------
  674|  53.3M|        switch (*input_pointer) {
  675|    366|            case '\"':
  ------------------
  |  Branch (675:13): [True: 366, False: 53.3M]
  ------------------
  676|  3.05k|            case '\\':
  ------------------
  |  Branch (676:13): [True: 2.69k, False: 53.3M]
  ------------------
  677|  10.8k|            case '\b':
  ------------------
  |  Branch (677:13): [True: 7.76k, False: 53.3M]
  ------------------
  678|  12.6k|            case '\f':
  ------------------
  |  Branch (678:13): [True: 1.81k, False: 53.3M]
  ------------------
  679|   161k|            case '\n':
  ------------------
  |  Branch (679:13): [True: 149k, False: 53.2M]
  ------------------
  680|   205k|            case '\r':
  ------------------
  |  Branch (680:13): [True: 43.8k, False: 53.3M]
  ------------------
  681|   213k|            case '\t':
  ------------------
  |  Branch (681:13): [True: 8.27k, False: 53.3M]
  ------------------
  682|       |                /* one character escape sequence */
  683|   213k|                escape_characters++;
  684|   213k|                break;
  685|  53.1M|            default:
  ------------------
  |  Branch (685:13): [True: 53.1M, False: 213k]
  ------------------
  686|  53.1M|                if (*input_pointer < 32) {
  ------------------
  |  Branch (686:21): [True: 37.6M, False: 15.5M]
  ------------------
  687|       |                    /* UTF-16 escape sequence uXXXX */
  688|  37.6M|                    escape_characters += 5;
  689|  37.6M|                }
  690|  53.1M|                break;
  691|  53.3M|        }
  692|  53.3M|    }
  693|  2.47M|    output_length = (size_t)(input_pointer - input) + escape_characters;
  694|       |
  695|  2.47M|    output = ensure(output_buffer, output_length + sizeof(""), out_of_memory);
  696|  2.47M|    if (output == NULL) {
  ------------------
  |  Branch (696:9): [True: 971, False: 2.47M]
  ------------------
  697|    971|        return false;
  ------------------
  |  |   72|    971|#define false ((cJSON_bool)0)
  ------------------
  698|    971|    }
  699|       |
  700|       |    /* no characters have to be escaped */
  701|  2.47M|    if (escape_characters == 0) {
  ------------------
  |  Branch (701:9): [True: 2.34M, False: 128k]
  ------------------
  702|  2.34M|        memcpy(output, input, output_length);
  703|  2.34M|        output[output_length] = '\0';
  704|       |
  705|  2.34M|        return true;
  ------------------
  |  |   67|  2.34M|#define true ((cJSON_bool)1)
  ------------------
  706|  2.34M|    }
  707|       |
  708|   128k|    output_pointer = output;
  709|       |    /* copy the string */
  710|  42.7M|    for (input_pointer = input; *input_pointer != '\0'; (void)input_pointer++, output_pointer++) {
  ------------------
  |  Branch (710:33): [True: 42.6M, False: 128k]
  ------------------
  711|  42.6M|        if ((*input_pointer > 31) && (*input_pointer != '\"') && (*input_pointer != '\\')) {
  ------------------
  |  Branch (711:13): [True: 4.88M, False: 37.7M]
  |  Branch (711:38): [True: 4.88M, False: 366]
  |  Branch (711:66): [True: 4.87M, False: 2.69k]
  ------------------
  712|       |            /* normal character, copy */
  713|  4.87M|            *output_pointer = *input_pointer;
  714|  37.7M|        } else {
  715|       |            // Loader specific modification - don't add a backslash because that will 'double up' any existing back slashes.
  716|       |            // This change was added right after vulkan's public release, so while it may not be a problem, there are plenty
  717|       |            // of API calls made which might not work if the paths have "\\"" in them
  718|       |            /* character needs to be escaped */
  719|       |            //*output_pointer++ = '\\';
  720|  37.7M|            switch (*input_pointer) {
  721|  2.69k|                case '\\':
  ------------------
  |  Branch (721:17): [True: 2.69k, False: 37.7M]
  ------------------
  722|  2.69k|                    *output_pointer = '\\';
  723|  2.69k|                    break;
  724|    366|                case '\"':
  ------------------
  |  Branch (724:17): [True: 366, False: 37.7M]
  ------------------
  725|    366|                    *output_pointer = '\"';
  726|    366|                    break;
  727|  7.70k|                case '\b':
  ------------------
  |  Branch (727:17): [True: 7.70k, False: 37.7M]
  ------------------
  728|  7.70k|                    *output_pointer = '\b';
  729|  7.70k|                    break;
  730|  1.81k|                case '\f':
  ------------------
  |  Branch (730:17): [True: 1.81k, False: 37.7M]
  ------------------
  731|  1.81k|                    *output_pointer = '\f';
  732|  1.81k|                    break;
  733|   111k|                case '\n':
  ------------------
  |  Branch (733:17): [True: 111k, False: 37.6M]
  ------------------
  734|   111k|                    *output_pointer = '\n';
  735|   111k|                    break;
  736|  43.8k|                case '\r':
  ------------------
  |  Branch (736:17): [True: 43.8k, False: 37.7M]
  ------------------
  737|  43.8k|                    *output_pointer = '\r';
  738|  43.8k|                    break;
  739|  8.27k|                case '\t':
  ------------------
  |  Branch (739:17): [True: 8.27k, False: 37.7M]
  ------------------
  740|  8.27k|                    *output_pointer = '\t';
  741|  8.27k|                    break;
  742|  37.5M|                default:
  ------------------
  |  Branch (742:17): [True: 37.5M, False: 176k]
  ------------------
  743|       |                    /* escape and print as unicode codepoint */
  744|  37.5M|                    snprintf((char *)output_pointer, output_length - (size_t)(output_pointer - output), "u%04x", *input_pointer);
  745|  37.5M|                    output_pointer += 4;
  746|  37.5M|                    break;
  747|  37.7M|            }
  748|  37.7M|        }
  749|  42.6M|    }
  750|       |    // The loader-specific escaping above emits one byte where the standard form emits two, so the written
  751|       |    // length is shorter than output_length. Terminate at the actual end, otherwise the bytes between it and
  752|       |    // output_length (uninitialized when the caller buffer is not zeroed) get read back as part of the string.
  753|   128k|    *output_pointer = '\0';
  754|       |
  755|   128k|    return true;
  ------------------
  |  |   67|   128k|#define true ((cJSON_bool)1)
  ------------------
  756|   128k|}
cJSON.c:print_array:
 1206|   140k|static cJSON_bool print_array(const cJSON *const item, printbuffer *const output_buffer, bool *out_of_memory) {
 1207|   140k|    unsigned char *output_pointer = NULL;
 1208|   140k|    size_t length = 0;
 1209|   140k|    cJSON *current_element = item->child;
 1210|       |
 1211|   140k|    if (output_buffer == NULL) {
  ------------------
  |  Branch (1211:9): [True: 0, False: 140k]
  ------------------
 1212|      0|        return false;
  ------------------
  |  |   72|      0|#define false ((cJSON_bool)0)
  ------------------
 1213|      0|    }
 1214|       |
 1215|       |    /* Compose the output array. */
 1216|       |    /* opening square bracket */
 1217|   140k|    output_pointer = ensure(output_buffer, 1, out_of_memory);
 1218|   140k|    if (output_pointer == NULL) {
  ------------------
  |  Branch (1218:9): [True: 0, False: 140k]
  ------------------
 1219|      0|        return false;
  ------------------
  |  |   72|      0|#define false ((cJSON_bool)0)
  ------------------
 1220|      0|    }
 1221|       |
 1222|   140k|    *output_pointer = '[';
 1223|   140k|    output_buffer->offset++;
 1224|   140k|    output_buffer->depth++;
 1225|       |
 1226|   522k|    while (current_element != NULL) {
  ------------------
  |  Branch (1226:12): [True: 381k, False: 140k]
  ------------------
 1227|   381k|        if (!print_value(current_element, output_buffer, out_of_memory)) {
  ------------------
  |  Branch (1227:13): [True: 0, False: 381k]
  ------------------
 1228|      0|            return false;
  ------------------
  |  |   72|      0|#define false ((cJSON_bool)0)
  ------------------
 1229|      0|        }
 1230|   381k|        update_offset(output_buffer);
 1231|   381k|        if (current_element->next) {
  ------------------
  |  Branch (1231:13): [True: 243k, False: 138k]
  ------------------
 1232|   243k|            length = (size_t)(output_buffer->format ? 2 : 1);
  ------------------
  |  Branch (1232:31): [True: 243k, False: 0]
  ------------------
 1233|   243k|            output_pointer = ensure(output_buffer, length + 1, out_of_memory);
 1234|   243k|            if (output_pointer == NULL) {
  ------------------
  |  Branch (1234:17): [True: 0, False: 243k]
  ------------------
 1235|      0|                return false;
  ------------------
  |  |   72|      0|#define false ((cJSON_bool)0)
  ------------------
 1236|      0|            }
 1237|   243k|            *output_pointer++ = ',';
 1238|   243k|            if (output_buffer->format) {
  ------------------
  |  Branch (1238:17): [True: 243k, False: 0]
  ------------------
 1239|   243k|                *output_pointer++ = ' ';
 1240|   243k|            }
 1241|   243k|            *output_pointer = '\0';
 1242|   243k|            output_buffer->offset += length;
 1243|   243k|        }
 1244|   381k|        current_element = current_element->next;
 1245|   381k|    }
 1246|       |
 1247|   140k|    output_pointer = ensure(output_buffer, 2, out_of_memory);
 1248|   140k|    if (output_pointer == NULL) {
  ------------------
  |  Branch (1248:9): [True: 0, False: 140k]
  ------------------
 1249|      0|        return false;
  ------------------
  |  |   72|      0|#define false ((cJSON_bool)0)
  ------------------
 1250|      0|    }
 1251|   140k|    *output_pointer++ = ']';
 1252|   140k|    *output_pointer = '\0';
 1253|   140k|    output_buffer->depth--;
 1254|       |
 1255|   140k|    return true;
  ------------------
  |  |   67|   140k|#define true ((cJSON_bool)1)
  ------------------
 1256|   140k|}
cJSON.c:print_object:
 1361|   330k|static cJSON_bool print_object(const cJSON *const item, printbuffer *const output_buffer, bool *out_of_memory) {
 1362|   330k|    unsigned char *output_pointer = NULL;
 1363|   330k|    size_t length = 0;
 1364|   330k|    cJSON *current_item = item->child;
 1365|       |
 1366|   330k|    if (output_buffer == NULL) {
  ------------------
  |  Branch (1366:9): [True: 0, False: 330k]
  ------------------
 1367|      0|        return false;
  ------------------
  |  |   72|      0|#define false ((cJSON_bool)0)
  ------------------
 1368|      0|    }
 1369|       |
 1370|       |    /* Compose the output: */
 1371|   330k|    length = (size_t)(output_buffer->format ? 2 : 1); /* fmt: {\n */
  ------------------
  |  Branch (1371:23): [True: 330k, False: 0]
  ------------------
 1372|   330k|    output_pointer = ensure(output_buffer, length + 1, out_of_memory);
 1373|   330k|    if (output_pointer == NULL) {
  ------------------
  |  Branch (1373:9): [True: 0, False: 330k]
  ------------------
 1374|      0|        return false;
  ------------------
  |  |   72|      0|#define false ((cJSON_bool)0)
  ------------------
 1375|      0|    }
 1376|       |
 1377|   330k|    *output_pointer++ = '{';
 1378|   330k|    output_buffer->depth++;
 1379|   330k|    if (output_buffer->format) {
  ------------------
  |  Branch (1379:9): [True: 330k, False: 0]
  ------------------
 1380|   330k|        *output_pointer++ = '\n';
 1381|   330k|    }
 1382|   330k|    output_buffer->offset += length;
 1383|       |
 1384|   830k|    while (current_item) {
  ------------------
  |  Branch (1384:12): [True: 500k, False: 330k]
  ------------------
 1385|   500k|        if (output_buffer->format) {
  ------------------
  |  Branch (1385:13): [True: 500k, False: 0]
  ------------------
 1386|   500k|            size_t i;
 1387|   500k|            output_pointer = ensure(output_buffer, output_buffer->depth, out_of_memory);
 1388|   500k|            if (output_pointer == NULL) {
  ------------------
  |  Branch (1388:17): [True: 0, False: 500k]
  ------------------
 1389|      0|                return false;
  ------------------
  |  |   72|      0|#define false ((cJSON_bool)0)
  ------------------
 1390|      0|            }
 1391|   180M|            for (i = 0; i < output_buffer->depth; i++) {
  ------------------
  |  Branch (1391:25): [True: 179M, False: 500k]
  ------------------
 1392|   179M|                *output_pointer++ = '\t';
 1393|   179M|            }
 1394|   500k|            output_buffer->offset += output_buffer->depth;
 1395|   500k|        }
 1396|       |
 1397|       |        /* print key */
 1398|   500k|        if (!print_string_ptr((unsigned char *)current_item->string, output_buffer, out_of_memory)) {
  ------------------
  |  Branch (1398:13): [True: 0, False: 500k]
  ------------------
 1399|      0|            return false;
  ------------------
  |  |   72|      0|#define false ((cJSON_bool)0)
  ------------------
 1400|      0|        }
 1401|   500k|        update_offset(output_buffer);
 1402|       |
 1403|   500k|        length = (size_t)(output_buffer->format ? 2 : 1);
  ------------------
  |  Branch (1403:27): [True: 500k, False: 0]
  ------------------
 1404|   500k|        output_pointer = ensure(output_buffer, length, out_of_memory);
 1405|   500k|        if (output_pointer == NULL) {
  ------------------
  |  Branch (1405:13): [True: 0, False: 500k]
  ------------------
 1406|      0|            return false;
  ------------------
  |  |   72|      0|#define false ((cJSON_bool)0)
  ------------------
 1407|      0|        }
 1408|   500k|        *output_pointer++ = ':';
 1409|   500k|        if (output_buffer->format) {
  ------------------
  |  Branch (1409:13): [True: 500k, False: 0]
  ------------------
 1410|   500k|            *output_pointer++ = '\t';
 1411|   500k|        }
 1412|   500k|        output_buffer->offset += length;
 1413|       |
 1414|       |        /* print value */
 1415|   500k|        if (!print_value(current_item, output_buffer, out_of_memory)) {
  ------------------
  |  Branch (1415:13): [True: 0, False: 500k]
  ------------------
 1416|      0|            return false;
  ------------------
  |  |   72|      0|#define false ((cJSON_bool)0)
  ------------------
 1417|      0|        }
 1418|   500k|        update_offset(output_buffer);
 1419|       |
 1420|       |        /* print comma if not last */
 1421|   500k|        length = ((size_t)(output_buffer->format ? 1 : 0) + (size_t)(current_item->next ? 1 : 0));
  ------------------
  |  Branch (1421:28): [True: 500k, False: 0]
  |  Branch (1421:70): [True: 174k, False: 326k]
  ------------------
 1422|   500k|        output_pointer = ensure(output_buffer, length + 1, out_of_memory);
 1423|   500k|        if (output_pointer == NULL) {
  ------------------
  |  Branch (1423:13): [True: 0, False: 500k]
  ------------------
 1424|      0|            return false;
  ------------------
  |  |   72|      0|#define false ((cJSON_bool)0)
  ------------------
 1425|      0|        }
 1426|   500k|        if (current_item->next) {
  ------------------
  |  Branch (1426:13): [True: 174k, False: 326k]
  ------------------
 1427|   174k|            *output_pointer++ = ',';
 1428|   174k|        }
 1429|       |
 1430|   500k|        if (output_buffer->format) {
  ------------------
  |  Branch (1430:13): [True: 500k, False: 0]
  ------------------
 1431|   500k|            *output_pointer++ = '\n';
 1432|   500k|        }
 1433|   500k|        *output_pointer = '\0';
 1434|   500k|        output_buffer->offset += length;
 1435|       |
 1436|   500k|        current_item = current_item->next;
 1437|   500k|    }
 1438|       |
 1439|   330k|    output_pointer = ensure(output_buffer, output_buffer->format ? (output_buffer->depth + 1) : 2, out_of_memory);
  ------------------
  |  Branch (1439:44): [True: 330k, False: 0]
  ------------------
 1440|   330k|    if (output_pointer == NULL) {
  ------------------
  |  Branch (1440:9): [True: 0, False: 330k]
  ------------------
 1441|      0|        return false;
  ------------------
  |  |   72|      0|#define false ((cJSON_bool)0)
  ------------------
 1442|      0|    }
 1443|   330k|    if (output_buffer->format) {
  ------------------
  |  Branch (1443:9): [True: 330k, False: 0]
  ------------------
 1444|   330k|        size_t i;
 1445|   116M|        for (i = 0; i < (output_buffer->depth - 1); i++) {
  ------------------
  |  Branch (1445:21): [True: 116M, False: 330k]
  ------------------
 1446|   116M|            *output_pointer++ = '\t';
 1447|   116M|        }
 1448|   330k|    }
 1449|   330k|    *output_pointer++ = '}';
 1450|   330k|    *output_pointer = '\0';
 1451|   330k|    output_buffer->depth--;
 1452|       |
 1453|   330k|    return true;
  ------------------
  |  |   67|   330k|#define true ((cJSON_bool)1)
  ------------------
 1454|   330k|}
cJSON.c:get_object_item:
 1501|  3.74M|static cJSON *get_object_item(const cJSON *const object, const char *const name, const cJSON_bool case_sensitive) {
 1502|  3.74M|    cJSON *current_element = NULL;
 1503|       |
 1504|  3.74M|    if ((object == NULL) || (name == NULL)) {
  ------------------
  |  Branch (1504:9): [True: 0, False: 3.74M]
  |  Branch (1504:29): [True: 0, False: 3.74M]
  ------------------
 1505|      0|        return NULL;
 1506|      0|    }
 1507|       |
 1508|  3.74M|    current_element = object->child;
 1509|  3.74M|    if (case_sensitive) {
  ------------------
  |  Branch (1509:9): [True: 0, False: 3.74M]
  ------------------
 1510|      0|        while ((current_element != NULL) && (current_element->string != NULL) && (strcmp(name, current_element->string) != 0)) {
  ------------------
  |  Branch (1510:16): [True: 0, False: 0]
  |  Branch (1510:45): [True: 0, False: 0]
  |  Branch (1510:82): [True: 0, False: 0]
  ------------------
 1511|      0|            current_element = current_element->next;
 1512|      0|        }
 1513|  3.74M|    } else {
 1514|  22.2M|        while ((current_element != NULL) &&
  ------------------
  |  Branch (1514:16): [True: 20.3M, False: 1.88M]
  ------------------
 1515|  20.3M|               (case_insensitive_strcmp((const unsigned char *)name, (const unsigned char *)(current_element->string)) != 0)) {
  ------------------
  |  Branch (1515:16): [True: 18.5M, False: 1.85M]
  ------------------
 1516|  18.5M|            current_element = current_element->next;
 1517|  18.5M|        }
 1518|  3.74M|    }
 1519|       |
 1520|  3.74M|    if ((current_element == NULL) || (current_element->string == NULL)) {
  ------------------
  |  Branch (1520:9): [True: 1.88M, False: 1.85M]
  |  Branch (1520:38): [True: 0, False: 1.85M]
  ------------------
 1521|  1.88M|        return NULL;
 1522|  1.88M|    }
 1523|       |
 1524|  1.85M|    return current_element;
 1525|  3.74M|}
cJSON.c:case_insensitive_strcmp:
  120|  20.3M|static int case_insensitive_strcmp(const unsigned char *string1, const unsigned char *string2) {
  121|  20.3M|    if ((string1 == NULL) || (string2 == NULL)) {
  ------------------
  |  Branch (121:9): [True: 0, False: 20.3M]
  |  Branch (121:30): [True: 196, False: 20.3M]
  ------------------
  122|    196|        return 1;
  123|    196|    }
  124|       |
  125|  20.3M|    if (string1 == string2) {
  ------------------
  |  Branch (125:9): [True: 0, False: 20.3M]
  ------------------
  126|      0|        return 0;
  127|      0|    }
  128|       |
  129|  43.1M|    for (; tolower(*string1) == tolower(*string2); (void)string1++, string2++) {
  ------------------
  |  Branch (129:12): [True: 0, False: 0]
  |  Branch (129:12): [True: 0, False: 0]
  |  Branch (129:12): [Folded, False: 43.1M]
  |  Branch (129:12): [True: 24.6M, False: 18.5M]
  |  Branch (129:33): [True: 0, False: 0]
  |  Branch (129:33): [True: 0, False: 0]
  |  Branch (129:33): [Folded, False: 43.1M]
  ------------------
  130|  24.6M|        if (*string1 == '\0') {
  ------------------
  |  Branch (130:13): [True: 1.85M, False: 22.7M]
  ------------------
  131|  1.85M|            return 0;
  132|  1.85M|        }
  133|  24.6M|    }
  134|       |
  135|  18.5M|    return tolower(*string1) - tolower(*string2);
  ------------------
  |  Branch (135:12): [True: 0, False: 0]
  |  Branch (135:12): [True: 0, False: 0]
  |  Branch (135:12): [Folded, False: 18.5M]
  |  Branch (135:32): [True: 0, False: 0]
  |  Branch (135:32): [True: 0, False: 0]
  |  Branch (135:32): [Folded, False: 18.5M]
  ------------------
  136|  20.3M|}
cJSON.c:compare_double:
  342|  34.8k|static cJSON_bool compare_double(double a, double b) {
  343|  34.8k|    double maxVal = fabs(a) > fabs(b) ? fabs(a) : fabs(b);
  ------------------
  |  Branch (343:21): [True: 487, False: 34.3k]
  ------------------
  344|       |    return (fabs(a - b) <= maxVal * DBL_EPSILON);
  345|  34.8k|}

util_SubmitDebugUtilsMessageEXT:
   78|  1.78M|                                         const VkDebugUtilsMessengerCallbackDataEXT *pCallbackData) {
   79|  1.78M|    VkBool32 bail = false;
   80|       |
   81|  1.78M|    if (NULL != pCallbackData) {
  ------------------
  |  Branch (81:9): [True: 1.78M, False: 0]
  ------------------
   82|  1.78M|        VkLayerDbgFunctionNode *pTrav = inst->current_dbg_function_head;
   83|  1.78M|        VkDebugReportObjectTypeEXT object_type = VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT;
   84|  1.78M|        VkDebugReportFlagsEXT object_flags = 0;
   85|  1.78M|        uint64_t object_handle = 0;
   86|       |
   87|  1.78M|        debug_utils_AnnotFlagsToReportFlags(messageSeverity, messageTypes, &object_flags);
   88|  1.78M|        if (0 < pCallbackData->objectCount) {
  ------------------
  |  Branch (88:13): [True: 1.78M, False: 0]
  ------------------
   89|  1.78M|            debug_utils_AnnotObjectToDebugReportObject(pCallbackData->pObjects, &object_type, &object_handle);
   90|  1.78M|        }
   91|  1.78M|        while (pTrav) {
  ------------------
  |  Branch (91:16): [True: 0, False: 1.78M]
  ------------------
   92|      0|            if (pTrav->is_messenger && (pTrav->messenger.messageSeverity & messageSeverity) &&
  ------------------
  |  Branch (92:17): [True: 0, False: 0]
  |  Branch (92:40): [True: 0, False: 0]
  ------------------
   93|      0|                (pTrav->messenger.messageType & messageTypes)) {
  ------------------
  |  Branch (93:17): [True: 0, False: 0]
  ------------------
   94|      0|                if (pTrav->messenger.pfnUserCallback(messageSeverity, messageTypes, pCallbackData, pTrav->pUserData)) {
  ------------------
  |  Branch (94:21): [True: 0, False: 0]
  ------------------
   95|      0|                    bail = true;
   96|      0|                }
   97|      0|            }
   98|      0|            if (!pTrav->is_messenger && pTrav->report.msgFlags & object_flags) {
  ------------------
  |  Branch (98:17): [True: 0, False: 0]
  |  Branch (98:41): [True: 0, False: 0]
  ------------------
   99|      0|                if (pTrav->report.pfnMsgCallback(object_flags, object_type, object_handle, 0, pCallbackData->messageIdNumber,
  ------------------
  |  Branch (99:21): [True: 0, False: 0]
  ------------------
  100|      0|                                                 pCallbackData->pMessageIdName, pCallbackData->pMessage, pTrav->pUserData)) {
  101|      0|                    bail = true;
  102|      0|                }
  103|      0|            }
  104|      0|            pTrav = pTrav->pNext;
  105|      0|        }
  106|  1.78M|    }
  107|       |
  108|  1.78M|    return bail;
  109|  1.78M|}
util_CreateDebugUtilsMessengers:
  130|  8.21k|                                         const VkAllocationCallbacks *pAllocator) {
  131|  8.21k|    const void *pNext = pChain;
  132|  8.21k|    while (pNext) {
  ------------------
  |  Branch (132:12): [True: 0, False: 8.21k]
  ------------------
  133|      0|        VkBaseInStructure in_structure = {0};
  134|      0|        memcpy(&in_structure, pNext, sizeof(VkBaseInStructure));
  135|      0|        if (in_structure.sType == VK_STRUCTURE_TYPE_DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT) {
  ------------------
  |  Branch (135:13): [True: 0, False: 0]
  ------------------
  136|       |            // Assign a unique handle to each messenger (just use the address of the VkDebugUtilsMessengerCreateInfoEXT)
  137|       |            // This is only being used this way due to it being for an 'anonymous' callback during instance creation
  138|       |            // NOLINTNEXTLINE(performance-no-int-to-ptr) - non-dispatchable handle; round-trip via uintptr_t is required
  139|      0|            VkDebugUtilsMessengerEXT messenger_handle = (VkDebugUtilsMessengerEXT)(uintptr_t)pNext;
  140|      0|            VkResult ret = util_CreateDebugUtilsMessenger(inst, (const VkDebugUtilsMessengerCreateInfoEXT *)pNext, pAllocator,
  141|      0|                                                          messenger_handle);
  142|      0|            if (ret != VK_SUCCESS) {
  ------------------
  |  Branch (142:17): [True: 0, False: 0]
  ------------------
  143|      0|                return ret;
  144|      0|            }
  145|      0|        }
  146|      0|        pNext = in_structure.pNext;
  147|      0|    }
  148|  8.21k|    return VK_SUCCESS;
  149|  8.21k|}
util_CreateDebugReportCallbacks:
  416|  8.21k|                                         const VkAllocationCallbacks *pAllocator) {
  417|  8.21k|    const void *pNext = pChain;
  418|  8.21k|    while (pNext) {
  ------------------
  |  Branch (418:12): [True: 0, False: 8.21k]
  ------------------
  419|      0|        VkBaseInStructure in_structure = {0};
  420|      0|        memcpy(&in_structure, pNext, sizeof(VkBaseInStructure));
  421|      0|        if (in_structure.sType == VK_STRUCTURE_TYPE_DEBUG_REPORT_CREATE_INFO_EXT) {
  ------------------
  |  Branch (421:13): [True: 0, False: 0]
  ------------------
  422|       |            // Assign a unique handle to each callback (just use the address of the VkDebugReportCallbackCreateInfoEXT):
  423|       |            // This is only being used this way due to it being for an 'anonymous' callback during instance creation
  424|       |            // NOLINTNEXTLINE(performance-no-int-to-ptr) - non-dispatchable handle; round-trip via uintptr_t is required
  425|      0|            VkDebugReportCallbackEXT report_handle = (VkDebugReportCallbackEXT)(uintptr_t)pNext;
  426|      0|            VkResult ret =
  427|      0|                util_CreateDebugReportCallback(inst, (const VkDebugReportCallbackCreateInfoEXT *)pNext, pAllocator, report_handle);
  428|      0|            if (ret != VK_SUCCESS) {
  ------------------
  |  Branch (428:17): [True: 0, False: 0]
  ------------------
  429|      0|                return ret;
  430|      0|            }
  431|      0|        }
  432|      0|        pNext = in_structure.pNext;
  433|      0|    }
  434|  8.21k|    return VK_SUCCESS;
  435|  8.21k|}
destroy_debug_callbacks_chain:
  618|  8.21k|void destroy_debug_callbacks_chain(struct loader_instance *inst, const VkAllocationCallbacks *pAllocator) {
  619|  8.21k|    VkLayerDbgFunctionNode *pTrav = inst->current_dbg_function_head;
  620|  8.21k|    VkLayerDbgFunctionNode *pNext = NULL;
  621|  8.21k|    while (pTrav) {
  ------------------
  |  Branch (621:12): [True: 0, False: 8.21k]
  ------------------
  622|      0|        pNext = pTrav->pNext;
  623|      0|        loader_free_with_instance_fallback(pAllocator, inst, pTrav);
  624|      0|        pTrav = pNext;
  625|      0|    }
  626|       |    inst->current_dbg_function_head = NULL;
  627|  8.21k|}
debug_utils_AnnotFlagsToReportFlags:
  703|  1.78M|                                         VkDebugUtilsMessageTypeFlagsEXT da_type, VkDebugReportFlagsEXT *dr_flags) {
  704|  1.78M|    if (NULL == dr_flags) {
  ------------------
  |  Branch (704:9): [True: 0, False: 1.78M]
  ------------------
  705|      0|        return false;
  706|      0|    }
  707|       |
  708|  1.78M|    *dr_flags = 0;
  709|       |
  710|  1.78M|    if ((da_severity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT) != 0) {
  ------------------
  |  Branch (710:9): [True: 77.7k, False: 1.71M]
  ------------------
  711|  77.7k|        *dr_flags |= VK_DEBUG_REPORT_ERROR_BIT_EXT;
  712|  1.71M|    } else if ((da_severity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT) != 0) {
  ------------------
  |  Branch (712:16): [True: 598k, False: 1.11M]
  ------------------
  713|   598k|        if ((da_type & VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT) != 0) {
  ------------------
  |  Branch (713:13): [True: 0, False: 598k]
  ------------------
  714|      0|            *dr_flags |= VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT;
  715|   598k|        } else {
  716|   598k|            *dr_flags |= VK_DEBUG_REPORT_WARNING_BIT_EXT;
  717|   598k|        }
  718|  1.11M|    } else if ((da_severity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT) != 0) {
  ------------------
  |  Branch (718:16): [True: 683k, False: 428k]
  ------------------
  719|   683k|        *dr_flags |= VK_DEBUG_REPORT_INFORMATION_BIT_EXT;
  720|   683k|    } else if ((da_severity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT) != 0) {
  ------------------
  |  Branch (720:16): [True: 428k, False: 0]
  ------------------
  721|   428k|        *dr_flags |= VK_DEBUG_REPORT_DEBUG_BIT_EXT;
  722|   428k|    }
  723|       |
  724|       |    return true;
  725|  1.78M|}
debug_utils_AnnotObjectToDebugReportObject:
  742|  1.78M|                                                VkDebugReportObjectTypeEXT *dr_object_type, uint64_t *dr_object_handle) {
  743|  1.78M|    if (NULL == da_object_name_info || NULL == dr_object_type || NULL == dr_object_handle) {
  ------------------
  |  Branch (743:9): [True: 0, False: 1.78M]
  |  Branch (743:40): [True: 0, False: 1.78M]
  |  Branch (743:66): [True: 0, False: 1.78M]
  ------------------
  744|      0|        return false;
  745|      0|    }
  746|  1.78M|    *dr_object_type = convertCoreObjectToDebugReportObject(da_object_name_info->objectType);
  747|  1.78M|    *dr_object_handle = da_object_name_info->objectHandle;
  748|       |    return true;
  749|  1.78M|}

debug_utils.c:convertCoreObjectToDebugReportObject:
  391|  1.78M|static inline VkDebugReportObjectTypeEXT convertCoreObjectToDebugReportObject(VkObjectType core_report_obj){
  392|  1.78M|    if (core_report_obj == VK_OBJECT_TYPE_UNKNOWN) {
  ------------------
  |  Branch (392:9): [True: 0, False: 1.78M]
  ------------------
  393|      0|        return VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT;
  394|  1.78M|    } else if (core_report_obj == VK_OBJECT_TYPE_UNKNOWN) {
  ------------------
  |  Branch (394:16): [True: 0, False: 1.78M]
  ------------------
  395|      0|        return VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT;
  396|  1.78M|    } else if (core_report_obj == VK_OBJECT_TYPE_INSTANCE) {
  ------------------
  |  Branch (396:16): [True: 1.78M, False: 0]
  ------------------
  397|  1.78M|        return VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT;
  398|  1.78M|    } else if (core_report_obj == VK_OBJECT_TYPE_PHYSICAL_DEVICE) {
  ------------------
  |  Branch (398:16): [True: 0, False: 0]
  ------------------
  399|      0|        return VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT;
  400|      0|    } else if (core_report_obj == VK_OBJECT_TYPE_DEVICE) {
  ------------------
  |  Branch (400:16): [True: 0, False: 0]
  ------------------
  401|      0|        return VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT;
  402|      0|    } else if (core_report_obj == VK_OBJECT_TYPE_QUEUE) {
  ------------------
  |  Branch (402:16): [True: 0, False: 0]
  ------------------
  403|      0|        return VK_DEBUG_REPORT_OBJECT_TYPE_QUEUE_EXT;
  404|      0|    } else if (core_report_obj == VK_OBJECT_TYPE_SEMAPHORE) {
  ------------------
  |  Branch (404:16): [True: 0, False: 0]
  ------------------
  405|      0|        return VK_DEBUG_REPORT_OBJECT_TYPE_SEMAPHORE_EXT;
  406|      0|    } else if (core_report_obj == VK_OBJECT_TYPE_COMMAND_BUFFER) {
  ------------------
  |  Branch (406:16): [True: 0, False: 0]
  ------------------
  407|      0|        return VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT;
  408|      0|    } else if (core_report_obj == VK_OBJECT_TYPE_FENCE) {
  ------------------
  |  Branch (408:16): [True: 0, False: 0]
  ------------------
  409|      0|        return VK_DEBUG_REPORT_OBJECT_TYPE_FENCE_EXT;
  410|      0|    } else if (core_report_obj == VK_OBJECT_TYPE_DEVICE_MEMORY) {
  ------------------
  |  Branch (410:16): [True: 0, False: 0]
  ------------------
  411|      0|        return VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_MEMORY_EXT;
  412|      0|    } else if (core_report_obj == VK_OBJECT_TYPE_BUFFER) {
  ------------------
  |  Branch (412:16): [True: 0, False: 0]
  ------------------
  413|      0|        return VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT;
  414|      0|    } else if (core_report_obj == VK_OBJECT_TYPE_IMAGE) {
  ------------------
  |  Branch (414:16): [True: 0, False: 0]
  ------------------
  415|      0|        return VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT;
  416|      0|    } else if (core_report_obj == VK_OBJECT_TYPE_EVENT) {
  ------------------
  |  Branch (416:16): [True: 0, False: 0]
  ------------------
  417|      0|        return VK_DEBUG_REPORT_OBJECT_TYPE_EVENT_EXT;
  418|      0|    } else if (core_report_obj == VK_OBJECT_TYPE_QUERY_POOL) {
  ------------------
  |  Branch (418:16): [True: 0, False: 0]
  ------------------
  419|      0|        return VK_DEBUG_REPORT_OBJECT_TYPE_QUERY_POOL_EXT;
  420|      0|    } else if (core_report_obj == VK_OBJECT_TYPE_BUFFER_VIEW) {
  ------------------
  |  Branch (420:16): [True: 0, False: 0]
  ------------------
  421|      0|        return VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_VIEW_EXT;
  422|      0|    } else if (core_report_obj == VK_OBJECT_TYPE_IMAGE_VIEW) {
  ------------------
  |  Branch (422:16): [True: 0, False: 0]
  ------------------
  423|      0|        return VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_VIEW_EXT;
  424|      0|    } else if (core_report_obj == VK_OBJECT_TYPE_SHADER_MODULE) {
  ------------------
  |  Branch (424:16): [True: 0, False: 0]
  ------------------
  425|      0|        return VK_DEBUG_REPORT_OBJECT_TYPE_SHADER_MODULE_EXT;
  426|      0|    } else if (core_report_obj == VK_OBJECT_TYPE_PIPELINE_CACHE) {
  ------------------
  |  Branch (426:16): [True: 0, False: 0]
  ------------------
  427|      0|        return VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_CACHE_EXT;
  428|      0|    } else if (core_report_obj == VK_OBJECT_TYPE_PIPELINE_LAYOUT) {
  ------------------
  |  Branch (428:16): [True: 0, False: 0]
  ------------------
  429|      0|        return VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_LAYOUT_EXT;
  430|      0|    } else if (core_report_obj == VK_OBJECT_TYPE_RENDER_PASS) {
  ------------------
  |  Branch (430:16): [True: 0, False: 0]
  ------------------
  431|      0|        return VK_DEBUG_REPORT_OBJECT_TYPE_RENDER_PASS_EXT;
  432|      0|    } else if (core_report_obj == VK_OBJECT_TYPE_PIPELINE) {
  ------------------
  |  Branch (432:16): [True: 0, False: 0]
  ------------------
  433|      0|        return VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT;
  434|      0|    } else if (core_report_obj == VK_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT) {
  ------------------
  |  Branch (434:16): [True: 0, False: 0]
  ------------------
  435|      0|        return VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT_EXT;
  436|      0|    } else if (core_report_obj == VK_OBJECT_TYPE_SAMPLER) {
  ------------------
  |  Branch (436:16): [True: 0, False: 0]
  ------------------
  437|      0|        return VK_DEBUG_REPORT_OBJECT_TYPE_SAMPLER_EXT;
  438|      0|    } else if (core_report_obj == VK_OBJECT_TYPE_DESCRIPTOR_POOL) {
  ------------------
  |  Branch (438:16): [True: 0, False: 0]
  ------------------
  439|      0|        return VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_POOL_EXT;
  440|      0|    } else if (core_report_obj == VK_OBJECT_TYPE_DESCRIPTOR_SET) {
  ------------------
  |  Branch (440:16): [True: 0, False: 0]
  ------------------
  441|      0|        return VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_EXT;
  442|      0|    } else if (core_report_obj == VK_OBJECT_TYPE_FRAMEBUFFER) {
  ------------------
  |  Branch (442:16): [True: 0, False: 0]
  ------------------
  443|      0|        return VK_DEBUG_REPORT_OBJECT_TYPE_FRAMEBUFFER_EXT;
  444|      0|    } else if (core_report_obj == VK_OBJECT_TYPE_COMMAND_POOL) {
  ------------------
  |  Branch (444:16): [True: 0, False: 0]
  ------------------
  445|      0|        return VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_POOL_EXT;
  446|      0|    } else if (core_report_obj == VK_OBJECT_TYPE_DESCRIPTOR_UPDATE_TEMPLATE) {
  ------------------
  |  Branch (446:16): [True: 0, False: 0]
  ------------------
  447|      0|        return VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_UPDATE_TEMPLATE_EXT;
  448|      0|    } else if (core_report_obj == VK_OBJECT_TYPE_SAMPLER_YCBCR_CONVERSION) {
  ------------------
  |  Branch (448:16): [True: 0, False: 0]
  ------------------
  449|      0|        return VK_DEBUG_REPORT_OBJECT_TYPE_SAMPLER_YCBCR_CONVERSION_EXT;
  450|      0|    } else if (core_report_obj == VK_OBJECT_TYPE_SURFACE_KHR) {
  ------------------
  |  Branch (450:16): [True: 0, False: 0]
  ------------------
  451|      0|        return VK_DEBUG_REPORT_OBJECT_TYPE_SURFACE_KHR_EXT;
  452|      0|    } else if (core_report_obj == VK_OBJECT_TYPE_SWAPCHAIN_KHR) {
  ------------------
  |  Branch (452:16): [True: 0, False: 0]
  ------------------
  453|      0|        return VK_DEBUG_REPORT_OBJECT_TYPE_SWAPCHAIN_KHR_EXT;
  454|      0|    } else if (core_report_obj == VK_OBJECT_TYPE_DISPLAY_KHR) {
  ------------------
  |  Branch (454:16): [True: 0, False: 0]
  ------------------
  455|      0|        return VK_DEBUG_REPORT_OBJECT_TYPE_DISPLAY_KHR_EXT;
  456|      0|    } else if (core_report_obj == VK_OBJECT_TYPE_DISPLAY_MODE_KHR) {
  ------------------
  |  Branch (456:16): [True: 0, False: 0]
  ------------------
  457|      0|        return VK_DEBUG_REPORT_OBJECT_TYPE_DISPLAY_MODE_KHR_EXT;
  458|      0|    } else if (core_report_obj == VK_OBJECT_TYPE_DEBUG_REPORT_CALLBACK_EXT) {
  ------------------
  |  Branch (458:16): [True: 0, False: 0]
  ------------------
  459|      0|        return VK_DEBUG_REPORT_OBJECT_TYPE_DEBUG_REPORT_CALLBACK_EXT_EXT;
  460|      0|    } else if (core_report_obj == VK_OBJECT_TYPE_CU_MODULE_NVX) {
  ------------------
  |  Branch (460:16): [True: 0, False: 0]
  ------------------
  461|      0|        return VK_DEBUG_REPORT_OBJECT_TYPE_CU_MODULE_NVX_EXT;
  462|      0|    } else if (core_report_obj == VK_OBJECT_TYPE_CU_FUNCTION_NVX) {
  ------------------
  |  Branch (462:16): [True: 0, False: 0]
  ------------------
  463|      0|        return VK_DEBUG_REPORT_OBJECT_TYPE_CU_FUNCTION_NVX_EXT;
  464|      0|    } else if (core_report_obj == VK_OBJECT_TYPE_ACCELERATION_STRUCTURE_KHR) {
  ------------------
  |  Branch (464:16): [True: 0, False: 0]
  ------------------
  465|      0|        return VK_DEBUG_REPORT_OBJECT_TYPE_ACCELERATION_STRUCTURE_KHR_EXT;
  466|      0|    } else if (core_report_obj == VK_OBJECT_TYPE_VALIDATION_CACHE_EXT) {
  ------------------
  |  Branch (466:16): [True: 0, False: 0]
  ------------------
  467|      0|        return VK_DEBUG_REPORT_OBJECT_TYPE_VALIDATION_CACHE_EXT_EXT;
  468|      0|    } else if (core_report_obj == VK_OBJECT_TYPE_ACCELERATION_STRUCTURE_NV) {
  ------------------
  |  Branch (468:16): [True: 0, False: 0]
  ------------------
  469|      0|        return VK_DEBUG_REPORT_OBJECT_TYPE_ACCELERATION_STRUCTURE_NV_EXT;
  470|      0|    } else if (core_report_obj == VK_OBJECT_TYPE_CUDA_MODULE_NV) {
  ------------------
  |  Branch (470:16): [True: 0, False: 0]
  ------------------
  471|      0|        return VK_DEBUG_REPORT_OBJECT_TYPE_CUDA_MODULE_NV_EXT;
  472|      0|    } else if (core_report_obj == VK_OBJECT_TYPE_CUDA_FUNCTION_NV) {
  ------------------
  |  Branch (472:16): [True: 0, False: 0]
  ------------------
  473|      0|        return VK_DEBUG_REPORT_OBJECT_TYPE_CUDA_FUNCTION_NV_EXT;
  474|      0|    } else if (core_report_obj == VK_OBJECT_TYPE_BUFFER_COLLECTION_FUCHSIA) {
  ------------------
  |  Branch (474:16): [True: 0, False: 0]
  ------------------
  475|      0|        return VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_COLLECTION_FUCHSIA_EXT;
  476|      0|    }
  477|      0|    return VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT;
  478|  1.78M|}

loader_make_version:
  113|   191k|loader_api_version loader_make_version(uint32_t version) {
  114|   191k|    loader_api_version out_version;
  115|   191k|    out_version.major = VK_API_VERSION_MAJOR(version);
  116|       |    out_version.minor = VK_API_VERSION_MINOR(version);
  117|   191k|    out_version.patch = 0;
  118|   191k|    return out_version;
  119|   191k|}
loader_make_full_version:
  122|  18.5k|loader_api_version loader_make_full_version(uint32_t version) {
  123|  18.5k|    loader_api_version out_version;
  124|  18.5k|    out_version.major = VK_API_VERSION_MAJOR(version);
  125|  18.5k|    out_version.minor = VK_API_VERSION_MINOR(version);
  126|       |    out_version.patch = VK_API_VERSION_PATCH(version);
  127|  18.5k|    return out_version;
  128|  18.5k|}
loader_combine_version:
  131|   304k|loader_api_version loader_combine_version(uint32_t major, uint32_t minor, uint32_t patch) {
  132|   304k|    loader_api_version out_version;
  133|   304k|    out_version.major = (uint16_t)major;
  134|   304k|    out_version.minor = (uint16_t)minor;
  135|   304k|    out_version.patch = (uint16_t)patch;
  136|   304k|    return out_version;
  137|   304k|}
loader_check_version_meets_required:
  140|   320k|bool loader_check_version_meets_required(loader_api_version required, loader_api_version version) {
  141|       |    // major version is satisfied
  142|   320k|    return (version.major > required.major) ||
  ------------------
  |  Branch (142:12): [True: 236k, False: 84.4k]
  ------------------
  143|       |           // major version is equal, minor version is patch version is greater to minimum minor
  144|  84.4k|           (version.major == required.major && version.minor > required.minor) ||
  ------------------
  |  Branch (144:13): [True: 35.6k, False: 48.7k]
  |  Branch (144:48): [True: 7.84k, False: 27.8k]
  ------------------
  145|       |           // major and minor version are equal, patch version is greater or equal to minimum patch
  146|  76.5k|           (version.major == required.major && version.minor == required.minor && version.patch >= required.patch);
  ------------------
  |  Branch (146:13): [True: 27.8k, False: 48.7k]
  |  Branch (146:48): [True: 20.9k, False: 6.86k]
  |  Branch (146:83): [True: 17.4k, False: 3.50k]
  ------------------
  147|   320k|}
loader_opendir:
  172|   127k|DIR *loader_opendir(const struct loader_instance *instance, const char *name) {
  173|       |#if defined(_WIN32)
  174|       |    return opendir(instance ? &instance->alloc_callbacks : NULL, name);
  175|       |#elif COMMON_UNIX_PLATFORMS
  176|       |    (void)instance;
  177|   127k|    return opendir(name);
  178|       |#else
  179|       |#warning dirent.h - opendir not available on this platform
  180|       |#endif  // _WIN32
  181|   127k|}
loader_closedir:
  182|  9.33k|int loader_closedir(const struct loader_instance *instance, DIR *dir) {
  183|       |#if defined(_WIN32)
  184|       |    return closedir(instance ? &instance->alloc_callbacks : NULL, dir);
  185|       |#elif COMMON_UNIX_PLATFORMS
  186|       |    (void)instance;
  187|  9.33k|    return closedir(dir);
  188|       |#else
  189|       |#warning dirent.h - closedir not available on this platform
  190|       |#endif  // _WIN32
  191|  9.33k|}
is_json:
  193|   476k|bool is_json(const char *path, size_t len) {
  194|   476k|    if (len < 5) {
  ------------------
  |  Branch (194:9): [True: 113k, False: 362k]
  ------------------
  195|   113k|        return false;
  196|   113k|    }
  197|   362k|    return !strncmp(path + len - 5, ".json", 5);
  198|   476k|}
loader_handle_load_library_error:
  202|     28|                                      enum loader_layer_library_status *lib_status) {
  203|     28|    const char *error_message = loader_platform_open_library_error(filename);
  204|       |    // If the error is due to incompatible architecture (eg 32 bit vs 64 bit), report it with INFO level
  205|       |    // Discussed in Github issue 262 & 644
  206|       |    // "wrong ELF class" is a linux error, " with error 193" is a windows error
  207|     28|    VkFlags err_flag = VULKAN_LOADER_ERROR_BIT;
  208|     28|    if (strstr(error_message, "wrong ELF class:") != NULL || strstr(error_message, " with error 193") != NULL) {
  ------------------
  |  Branch (208:9): [True: 1, False: 27]
  |  Branch (208:62): [True: 1, False: 26]
  ------------------
  209|      2|        err_flag = VULKAN_LOADER_INFO_BIT;
  210|      2|        if (NULL != lib_status) {
  ------------------
  |  Branch (210:13): [True: 2, False: 0]
  ------------------
  211|      2|            *lib_status = LOADER_LAYER_LIB_ERROR_WRONG_BIT_TYPE;
  212|      2|        }
  213|      2|    }
  214|       |    // Check if the error is due to lack of memory
  215|       |    // "with error 8" is the windows error code for OOM cases, aka ERROR_NOT_ENOUGH_MEMORY
  216|       |    // Linux doesn't have such a nice error message - only if there are reported issues should this be called
  217|     26|    else if (strstr(error_message, " with error 8") != NULL) {
  ------------------
  |  Branch (217:14): [True: 3, False: 23]
  ------------------
  218|      3|        if (NULL != lib_status) {
  ------------------
  |  Branch (218:13): [True: 3, False: 0]
  ------------------
  219|      3|            *lib_status = LOADER_LAYER_LIB_ERROR_OUT_OF_MEMORY;
  220|      3|        }
  221|     23|    } else if (NULL != lib_status) {
  ------------------
  |  Branch (221:16): [True: 23, False: 0]
  ------------------
  222|     23|        *lib_status = LOADER_LAYER_LIB_ERROR_FAILED_TO_LOAD;
  223|     23|    }
  224|     28|    loader_log(inst, err_flag, 0, "%s", error_message);
  225|     28|}
loader_free_layer_properties:
  248|   357k|void loader_free_layer_properties(const struct loader_instance *inst, struct loader_layer_properties *layer_properties) {
  249|   357k|    loader_instance_heap_free(inst, layer_properties->manifest_file_name);
  250|   357k|    loader_instance_heap_free(inst, layer_properties->lib_name);
  251|   357k|    loader_instance_heap_free(inst, layer_properties->functions.str_gipa);
  252|   357k|    loader_instance_heap_free(inst, layer_properties->functions.str_gdpa);
  253|   357k|    loader_instance_heap_free(inst, layer_properties->functions.str_negotiate_interface);
  254|   357k|    loader_destroy_generic_list(inst, (struct loader_generic_list *)&layer_properties->instance_extension_list);
  255|   357k|    if (layer_properties->device_extension_list.capacity > 0 && NULL != layer_properties->device_extension_list.list) {
  ------------------
  |  Branch (255:9): [True: 8.05k, False: 349k]
  |  Branch (255:65): [True: 8.05k, False: 0]
  ------------------
  256|  67.0k|        for (uint32_t i = 0; i < layer_properties->device_extension_list.count; i++) {
  ------------------
  |  Branch (256:30): [True: 58.9k, False: 8.05k]
  ------------------
  257|  58.9k|            free_string_list(inst, &layer_properties->device_extension_list.list[i].entrypoints);
  258|  58.9k|        }
  259|  8.05k|    }
  260|   357k|    loader_destroy_generic_list(inst, (struct loader_generic_list *)&layer_properties->device_extension_list);
  261|   357k|    loader_instance_heap_free(inst, layer_properties->disable_env_var.name);
  262|   357k|    loader_instance_heap_free(inst, layer_properties->disable_env_var.value);
  263|   357k|    loader_instance_heap_free(inst, layer_properties->enable_env_var.name);
  264|   357k|    loader_instance_heap_free(inst, layer_properties->enable_env_var.value);
  265|   357k|    free_string_list(inst, &layer_properties->component_layer_names);
  266|   357k|    loader_instance_heap_free(inst, layer_properties->pre_instance_functions.enumerate_instance_extension_properties);
  267|   357k|    loader_instance_heap_free(inst, layer_properties->pre_instance_functions.enumerate_instance_layer_properties);
  268|   357k|    loader_instance_heap_free(inst, layer_properties->pre_instance_functions.enumerate_instance_version);
  269|   357k|    free_string_list(inst, &layer_properties->override_paths);
  270|   357k|    free_string_list(inst, &layer_properties->blacklist_layer_names);
  271|   357k|    free_string_list(inst, &layer_properties->app_key_paths);
  272|       |
  273|       |    // Make sure to clear out the removed layer, in case new layers are added in the previous location
  274|   357k|    memset(layer_properties, 0, sizeof(struct loader_layer_properties));
  275|   357k|}
is_string_in_string_list:
  288|   228k|bool is_string_in_string_list(struct loader_string_list *string_list, const char *str) {
  289|       |    // Remove duplicate paths, or it would result in duplicate extensions, duplicate devices, etc.
  290|  5.26M|    for (size_t i = 0; i < string_list->count; i++) {
  ------------------
  |  Branch (290:24): [True: 5.11M, False: 151k]
  ------------------
  291|  5.11M|        if (strcmp(string_list->list[i], str) == 0) {
  ------------------
  |  Branch (291:13): [True: 76.9k, False: 5.03M]
  ------------------
  292|  76.9k|            return true;
  293|  76.9k|        }
  294|  5.11M|    }
  295|   151k|    return false;
  296|   228k|}
loader_copy_to_new_str:
  298|   505k|VkResult loader_copy_to_new_str(const struct loader_instance *inst, const char *source_str, char **dest_str) {
  299|   505k|    assert(source_str && dest_str);
  300|   505k|    size_t str_len = strlen(source_str) + 1;
  301|   505k|    *dest_str = loader_instance_heap_calloc(inst, str_len, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
  302|   505k|    if (NULL == *dest_str) return VK_ERROR_OUT_OF_HOST_MEMORY;
  ------------------
  |  Branch (302:9): [True: 0, False: 505k]
  ------------------
  303|   505k|    loader_strncpy(*dest_str, str_len, source_str, str_len);
  304|   505k|    (*dest_str)[str_len - 1] = 0;
  305|   505k|    return VK_SUCCESS;
  306|   505k|}
create_string_list:
  308|  44.9k|VkResult create_string_list(const struct loader_instance *inst, uint32_t allocated_count, struct loader_string_list *string_list) {
  309|  44.9k|    assert(string_list);
  310|  44.9k|    string_list->list =
  311|  44.9k|        (char **)loader_instance_heap_calloc(inst, sizeof(char *) * allocated_count, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
  312|  44.9k|    if (NULL == string_list->list) {
  ------------------
  |  Branch (312:9): [True: 0, False: 44.9k]
  ------------------
  313|      0|        return VK_ERROR_OUT_OF_HOST_MEMORY;
  314|      0|    }
  315|  44.9k|    string_list->allocated_count = allocated_count;
  316|  44.9k|    string_list->count = 0;
  317|  44.9k|    return VK_SUCCESS;
  318|  44.9k|}
increase_str_capacity_by_at_least_one:
  320|  1.39M|VkResult increase_str_capacity_by_at_least_one(const struct loader_instance *inst, struct loader_string_list *string_list) {
  321|  1.39M|    assert(string_list);
  322|  1.39M|    if (string_list->allocated_count == 0) {
  ------------------
  |  Branch (322:9): [True: 26.1k, False: 1.36M]
  ------------------
  323|  26.1k|        string_list->allocated_count = 32;
  324|  26.1k|        string_list->list = (char **)loader_instance_heap_calloc(inst, sizeof(char *) * string_list->allocated_count,
  325|  26.1k|                                                                 VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
  326|  26.1k|        if (NULL == string_list->list) {
  ------------------
  |  Branch (326:13): [True: 0, False: 26.1k]
  ------------------
  327|      0|            return VK_ERROR_OUT_OF_HOST_MEMORY;
  328|      0|        }
  329|  1.36M|    } else if (string_list->count + 1 > string_list->allocated_count) {
  ------------------
  |  Branch (329:16): [True: 1.03k, False: 1.36M]
  ------------------
  330|  1.03k|        uint32_t new_allocated_count = string_list->allocated_count * 2;
  331|  1.03k|        void *new_ptr = loader_instance_heap_realloc(inst, (void *)string_list->list, sizeof(char *) * string_list->allocated_count,
  332|  1.03k|                                                     sizeof(char *) * new_allocated_count, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
  333|  1.03k|        if (NULL == new_ptr) {
  ------------------
  |  Branch (333:13): [True: 0, False: 1.03k]
  ------------------
  334|      0|            return VK_ERROR_OUT_OF_HOST_MEMORY;
  335|      0|        }
  336|  1.03k|        string_list->list = (char **)new_ptr;
  337|  1.03k|        string_list->allocated_count *= 2;
  338|  1.03k|    }
  339|  1.39M|    return VK_SUCCESS;
  340|  1.39M|}
append_str_to_string_list:
  342|  1.39M|VkResult append_str_to_string_list(const struct loader_instance *inst, struct loader_string_list *string_list, char *str) {
  343|  1.39M|    assert(string_list && str);
  344|  1.39M|    VkResult res = increase_str_capacity_by_at_least_one(inst, string_list);
  345|  1.39M|    if (res == VK_ERROR_OUT_OF_HOST_MEMORY) {
  ------------------
  |  Branch (345:9): [True: 0, False: 1.39M]
  ------------------
  346|      0|        loader_instance_heap_free(inst, str);  // Must clean up in case of failure
  347|      0|        return res;
  348|      0|    }
  349|  1.39M|    string_list->list[string_list->count++] = str;
  350|  1.39M|    return VK_SUCCESS;
  351|  1.39M|}
append_str_to_string_list_if_unique:
  354|   228k|                                             char *str) {
  355|   228k|    if (is_string_in_string_list(string_list, str)) {
  ------------------
  |  Branch (355:9): [True: 76.9k, False: 151k]
  ------------------
  356|       |        // Since this string is a duplicate and this function takes ownership, we need to free it.
  357|  76.9k|        loader_instance_heap_free(inst, str);
  358|  76.9k|        return VK_SUCCESS;
  359|  76.9k|    }
  360|   151k|    return append_str_to_string_list(inst, string_list, str);
  361|   228k|}
copy_str_to_string_list:
  379|  81.0k|                                 size_t str_len) {
  380|  81.0k|    assert(string_list && str);
  381|  81.0k|    char *new_str = loader_instance_heap_calloc(inst, str_len + 1, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
  382|  81.0k|    if (NULL == new_str) {
  ------------------
  |  Branch (382:9): [True: 0, False: 81.0k]
  ------------------
  383|      0|        return VK_ERROR_OUT_OF_HOST_MEMORY;
  384|      0|    }
  385|  81.0k|    loader_strncpy(new_str, str_len + 1, str, str_len);
  386|  81.0k|    new_str[str_len] = '\0';
  387|  81.0k|    return append_str_to_string_list(inst, string_list, new_str);
  388|  81.0k|}
free_string_list:
  410|  1.55M|void free_string_list(const struct loader_instance *inst, struct loader_string_list *string_list) {
  411|  1.55M|    assert(string_list);
  412|  1.55M|    if (string_list->list) {
  ------------------
  |  Branch (412:9): [True: 71.0k, False: 1.48M]
  ------------------
  413|  1.46M|        for (uint32_t i = 0; i < string_list->count; i++) {
  ------------------
  |  Branch (413:30): [True: 1.39M, False: 71.0k]
  ------------------
  414|  1.39M|            loader_instance_heap_free(inst, string_list->list[i]);
  415|       |            string_list->list[i] = NULL;
  416|  1.39M|        }
  417|  71.0k|        loader_instance_heap_free(inst, (void *)string_list->list);
  418|  71.0k|    }
  419|  1.55M|    memset(string_list, 0, sizeof(struct loader_string_list));
  420|  1.55M|}
loader_parse_version_string:
  697|   223k|uint32_t loader_parse_version_string(char *vers_str) {
  698|   223k|    uint32_t variant = 0;
  699|   223k|    uint32_t major = 0;
  700|   223k|    uint32_t minor = 0;
  701|   223k|    uint32_t patch = 0;
  702|   223k|    char *vers_tok;
  703|   223k|    char *context = NULL;
  704|   223k|    if (!vers_str) {
  ------------------
  |  Branch (704:9): [True: 0, False: 223k]
  ------------------
  705|      0|        return 0;
  706|      0|    }
  707|       |
  708|   223k|    vers_tok = thread_safe_strtok(vers_str, ".\"\n\r", &context);
  709|   223k|    if (NULL != vers_tok) {
  ------------------
  |  Branch (709:9): [True: 194k, False: 29.4k]
  ------------------
  710|   194k|        major = (uint16_t)strtoul(vers_tok, NULL, 10);
  711|   194k|        vers_tok = thread_safe_strtok(NULL, ".\"\n\r", &context);
  712|   194k|        if (NULL != vers_tok) {
  ------------------
  |  Branch (712:13): [True: 21.6k, False: 172k]
  ------------------
  713|  21.6k|            minor = (uint16_t)strtoul(vers_tok, NULL, 10);
  714|  21.6k|            vers_tok = thread_safe_strtok(NULL, ".\"\n\r", &context);
  715|  21.6k|            if (NULL != vers_tok) {
  ------------------
  |  Branch (715:17): [True: 7.33k, False: 14.3k]
  ------------------
  716|  7.33k|                patch = (uint16_t)strtoul(vers_tok, NULL, 10);
  717|  7.33k|                vers_tok = thread_safe_strtok(NULL, ".\"\n\r", &context);
  718|       |                // check that we are using a 4 part version string
  719|  7.33k|                if (NULL != vers_tok) {
  ------------------
  |  Branch (719:21): [True: 542, False: 6.79k]
  ------------------
  720|       |                    // if we are, move the values over into the correct place
  721|    542|                    variant = major;
  722|    542|                    major = minor;
  723|    542|                    minor = patch;
  724|    542|                    patch = (uint16_t)strtoul(vers_tok, NULL, 10);
  725|    542|                }
  726|  7.33k|            }
  727|  21.6k|        }
  728|   194k|    }
  729|       |
  730|       |    return VK_MAKE_API_VERSION(variant, major, minor, patch);
  731|   223k|}
compare_vk_extension_properties:
  733|  1.91M|bool compare_vk_extension_properties(const VkExtensionProperties *op1, const VkExtensionProperties *op2) {
  734|  1.91M|    return strcmp(op1->extensionName, op2->extensionName) == 0 ? true : false;
  ------------------
  |  Branch (734:12): [True: 16.2k, False: 1.89M]
  ------------------
  735|  1.91M|}
has_vk_extension_property:
  747|  46.1k|bool has_vk_extension_property(const VkExtensionProperties *vk_ext_prop, const struct loader_extension_list *ext_list) {
  748|   758k|    for (uint32_t i = 0; i < ext_list->count; i++) {
  ------------------
  |  Branch (748:26): [True: 715k, False: 42.7k]
  ------------------
  749|   715k|        if (compare_vk_extension_properties(&ext_list->list[i], vk_ext_prop)) return true;
  ------------------
  |  Branch (749:13): [True: 3.44k, False: 712k]
  ------------------
  750|   715k|    }
  751|  42.7k|    return false;
  752|  46.1k|}
has_vk_dev_ext_property:
  755|  90.5k|bool has_vk_dev_ext_property(const VkExtensionProperties *ext_prop, const struct loader_device_extension_list *ext_list) {
  756|  1.27M|    for (uint32_t i = 0; i < ext_list->count; i++) {
  ------------------
  |  Branch (756:26): [True: 1.19M, False: 77.8k]
  ------------------
  757|  1.19M|        if (compare_vk_extension_properties(&ext_list->list[i].props, ext_prop)) return true;
  ------------------
  |  Branch (757:13): [True: 12.7k, False: 1.18M]
  ------------------
  758|  1.19M|    }
  759|  77.8k|    return false;
  760|  90.5k|}
loader_append_layer_property:
  763|   264k|                                      struct loader_layer_properties *layer_property) {
  764|   264k|    VkResult res = VK_SUCCESS;
  765|   264k|    if (layer_list->capacity == 0) {
  ------------------
  |  Branch (765:9): [True: 5.41k, False: 258k]
  ------------------
  766|  5.41k|        res = loader_init_generic_list(inst, (struct loader_generic_list *)layer_list, sizeof(struct loader_layer_properties));
  767|  5.41k|        if (VK_SUCCESS != res) {
  ------------------
  |  Branch (767:13): [True: 0, False: 5.41k]
  ------------------
  768|      0|            goto out;
  769|      0|        }
  770|  5.41k|    }
  771|       |
  772|       |    // Ensure enough room to add an entry
  773|   264k|    if ((layer_list->count + 1) * sizeof(struct loader_layer_properties) > layer_list->capacity) {
  ------------------
  |  Branch (773:9): [True: 1.23k, False: 263k]
  ------------------
  774|  1.23k|        void *new_ptr = loader_instance_heap_realloc(inst, layer_list->list, layer_list->capacity, layer_list->capacity * 2,
  775|  1.23k|                                                     VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
  776|  1.23k|        if (NULL == new_ptr) {
  ------------------
  |  Branch (776:13): [True: 0, False: 1.23k]
  ------------------
  777|      0|            loader_log(inst, VULKAN_LOADER_ERROR_BIT, 0, "loader_append_layer_property: realloc failed for layer list");
  778|      0|            res = VK_ERROR_OUT_OF_HOST_MEMORY;
  779|      0|            goto out;
  780|      0|        }
  781|  1.23k|        layer_list->list = new_ptr;
  782|  1.23k|        layer_list->capacity *= 2;
  783|  1.23k|    }
  784|   264k|    memcpy(&layer_list->list[layer_list->count], layer_property, sizeof(struct loader_layer_properties));
  785|   264k|    layer_list->count++;
  786|   264k|    memset(layer_property, 0, sizeof(struct loader_layer_properties));
  787|   264k|out:
  788|   264k|    if (res != VK_SUCCESS) {
  ------------------
  |  Branch (788:9): [True: 0, False: 264k]
  ------------------
  789|      0|        loader_free_layer_properties(inst, layer_property);
  790|      0|    }
  791|   264k|    return res;
  792|   264k|}
loader_find_layer_property:
  795|  39.6k|struct loader_layer_properties *loader_find_layer_property(const char *name, const struct loader_layer_list *layer_list) {
  796|  3.72M|    for (uint32_t i = 0; i < layer_list->count; i++) {
  ------------------
  |  Branch (796:26): [True: 3.71M, False: 15.8k]
  ------------------
  797|  3.71M|        const VkLayerProperties *item = &layer_list->list[i].info;
  798|  3.71M|        if (strcmp(name, item->layerName) == 0) return &layer_list->list[i];
  ------------------
  |  Branch (798:13): [True: 23.7k, False: 3.68M]
  ------------------
  799|  3.71M|    }
  800|  15.8k|    return NULL;
  801|  39.6k|}
loader_find_layer_name_in_blacklist:
  824|   138k|bool loader_find_layer_name_in_blacklist(const char *layer_name, struct loader_layer_properties *meta_layer_props) {
  825|   138k|    for (uint32_t black_layer = 0; black_layer < meta_layer_props->blacklist_layer_names.count; ++black_layer) {
  ------------------
  |  Branch (825:36): [True: 0, False: 138k]
  ------------------
  826|      0|        if (!strcmp(meta_layer_props->blacklist_layer_names.list[black_layer], layer_name)) {
  ------------------
  |  Branch (826:13): [True: 0, False: 0]
  ------------------
  827|      0|            return true;
  828|      0|        }
  829|      0|    }
  830|   138k|    return false;
  831|   138k|}
loader_delete_layer_list_and_properties:
  835|  24.6k|                                                                  struct loader_layer_list *layer_list) {
  836|  24.6k|    uint32_t i;
  837|  24.6k|    if (!layer_list) return;
  ------------------
  |  Branch (837:9): [True: 0, False: 24.6k]
  ------------------
  838|       |
  839|   196k|    for (i = 0; i < layer_list->count; i++) {
  ------------------
  |  Branch (839:17): [True: 171k, False: 24.6k]
  ------------------
  840|   171k|        if (layer_list->list[i].lib_handle) {
  ------------------
  |  Branch (840:13): [True: 0, False: 171k]
  ------------------
  841|      0|            loader_platform_close_library(layer_list->list[i].lib_handle);
  842|      0|            loader_log(inst, VULKAN_LOADER_DEBUG_BIT | VULKAN_LOADER_LAYER_BIT, 0, "Unloading layer library %s",
  843|      0|                       layer_list->list[i].lib_name);
  844|      0|            layer_list->list[i].lib_handle = NULL;
  845|      0|        }
  846|   171k|        loader_free_layer_properties(inst, &(layer_list->list[i]));
  847|   171k|    }
  848|  24.6k|    layer_list->count = 0;
  849|       |
  850|  24.6k|    if (layer_list->capacity > 0) {
  ------------------
  |  Branch (850:9): [True: 5.97k, False: 18.6k]
  ------------------
  851|  5.97k|        layer_list->capacity = 0;
  852|  5.97k|        loader_instance_heap_free(inst, layer_list->list);
  853|  5.97k|    }
  854|  24.6k|    memset(layer_list, 0, sizeof(struct loader_layer_list));
  855|  24.6k|}
loader_remove_layer_in_list:
  858|  92.7k|                                 uint32_t layer_to_remove) {
  859|  92.7k|    if (layer_list == NULL || layer_to_remove >= layer_list->count) {
  ------------------
  |  Branch (859:9): [True: 0, False: 92.7k]
  |  Branch (859:31): [True: 0, False: 92.7k]
  ------------------
  860|      0|        return;
  861|      0|    }
  862|  92.7k|    loader_free_layer_properties(inst, &(layer_list->list[layer_to_remove]));
  863|       |
  864|       |    // Remove the current invalid meta-layer from the layer list.  Use memmove since we are
  865|       |    // overlapping the source and destination addresses.
  866|  92.7k|    if (layer_to_remove + 1 <= layer_list->count) {
  ------------------
  |  Branch (866:9): [True: 92.7k, False: 0]
  ------------------
  867|  92.7k|        memmove(&layer_list->list[layer_to_remove], &layer_list->list[layer_to_remove + 1],
  868|  92.7k|                sizeof(struct loader_layer_properties) * (layer_list->count - 1 - layer_to_remove));
  869|  92.7k|    }
  870|       |    // Decrement the count (because we now have one less) and decrement the loop index since we need to
  871|       |    // re-check this index.
  872|  92.7k|    layer_list->count--;
  873|  92.7k|}
loader_remove_layers_in_blacklist:
  877|  1.01k|void loader_remove_layers_in_blacklist(const struct loader_instance *inst, struct loader_layer_list *layer_list) {
  878|  1.01k|    struct loader_layer_properties *override_prop = loader_find_layer_property(VK_OVERRIDE_LAYER_NAME, layer_list);
  ------------------
  |  |  142|  1.01k|#define VK_OVERRIDE_LAYER_NAME "VK_LAYER_LUNARG_override"
  ------------------
  879|  1.01k|    if (NULL == override_prop) {
  ------------------
  |  Branch (879:9): [True: 0, False: 1.01k]
  ------------------
  880|      0|        return;
  881|      0|    }
  882|       |
  883|   143k|    for (int32_t j = 0; j < (int32_t)(layer_list->count); j++) {
  ------------------
  |  Branch (883:25): [True: 142k, False: 1.01k]
  ------------------
  884|   142k|        struct loader_layer_properties cur_layer_prop = layer_list->list[j];
  885|   142k|        const char *cur_layer_name = &cur_layer_prop.info.layerName[0];
  886|       |
  887|       |        // Skip the override layer itself.
  888|   142k|        if (!strcmp(VK_OVERRIDE_LAYER_NAME, cur_layer_name)) {
  ------------------
  |  |  142|   142k|#define VK_OVERRIDE_LAYER_NAME "VK_LAYER_LUNARG_override"
  ------------------
  |  Branch (888:13): [True: 3.58k, False: 138k]
  ------------------
  889|  3.58k|            continue;
  890|  3.58k|        }
  891|       |
  892|       |        // If found in the override layer's blacklist, remove it
  893|   138k|        if (loader_find_layer_name_in_blacklist(cur_layer_name, override_prop)) {
  ------------------
  |  Branch (893:13): [True: 0, False: 138k]
  ------------------
  894|      0|            loader_log(inst, VULKAN_LOADER_DEBUG_BIT, 0,
  895|      0|                       "loader_remove_layers_in_blacklist: Override layer is active and layer %s is in the blacklist inside of it. "
  896|      0|                       "Removing that layer from current layer list.",
  897|      0|                       cur_layer_name);
  898|      0|            loader_remove_layer_in_list(inst, layer_list, j);
  899|      0|            j--;
  900|       |
  901|       |            // Re-do the query for the override layer
  902|      0|            override_prop = loader_find_layer_property(VK_OVERRIDE_LAYER_NAME, layer_list);
  ------------------
  |  |  142|      0|#define VK_OVERRIDE_LAYER_NAME "VK_LAYER_LUNARG_override"
  ------------------
  903|      0|        }
  904|   138k|    }
  905|  1.01k|}
loader_init_generic_list:
 1062|  16.6k|VkResult loader_init_generic_list(const struct loader_instance *inst, struct loader_generic_list *list_info, size_t element_size) {
 1063|  16.6k|    size_t capacity = 32 * element_size;
 1064|  16.6k|    list_info->count = 0;
 1065|  16.6k|    list_info->capacity = 0;
 1066|  16.6k|    list_info->list = loader_instance_heap_calloc(inst, capacity, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
 1067|  16.6k|    if (list_info->list == NULL) {
  ------------------
  |  Branch (1067:9): [True: 0, False: 16.6k]
  ------------------
 1068|      0|        loader_log(inst, VULKAN_LOADER_ERROR_BIT, 0, "loader_init_generic_list: Failed to allocate space for generic list");
 1069|      0|        return VK_ERROR_OUT_OF_HOST_MEMORY;
 1070|      0|    }
 1071|  16.6k|    list_info->capacity = capacity;
 1072|  16.6k|    return VK_SUCCESS;
 1073|  16.6k|}
loader_destroy_generic_list:
 1091|   748k|void loader_destroy_generic_list(const struct loader_instance *inst, struct loader_generic_list *list) {
 1092|   748k|    loader_instance_heap_free(inst, list->list);
 1093|   748k|    memset(list, 0, sizeof(struct loader_generic_list));
 1094|   748k|}
loader_add_to_ext_list:
 1147|  31.3k|                                uint32_t prop_list_count, const VkExtensionProperties *props) {
 1148|  31.3k|    if (ext_list->list == NULL || ext_list->capacity == 0) {
  ------------------
  |  Branch (1148:9): [True: 2.59k, False: 28.7k]
  |  Branch (1148:35): [True: 0, False: 28.7k]
  ------------------
 1149|  2.59k|        VkResult res = loader_init_generic_list(inst, (struct loader_generic_list *)ext_list, sizeof(VkExtensionProperties));
 1150|  2.59k|        if (VK_SUCCESS != res) {
  ------------------
  |  Branch (1150:13): [True: 0, False: 2.59k]
  ------------------
 1151|      0|            return res;
 1152|      0|        }
 1153|  2.59k|    }
 1154|       |
 1155|  62.6k|    for (uint32_t i = 0; i < prop_list_count; i++) {
  ------------------
  |  Branch (1155:26): [True: 31.3k, False: 31.3k]
  ------------------
 1156|  31.3k|        const VkExtensionProperties *cur_ext = &props[i];
 1157|       |
 1158|       |        // look for duplicates
 1159|  31.3k|        if (has_vk_extension_property(cur_ext, ext_list)) {
  ------------------
  |  Branch (1159:13): [True: 3.04k, False: 28.3k]
  ------------------
 1160|  3.04k|            continue;
 1161|  3.04k|        }
 1162|       |
 1163|       |        // add to list at end
 1164|       |        // check for enough capacity
 1165|  28.3k|        if (ext_list->count * sizeof(VkExtensionProperties) >= ext_list->capacity) {
  ------------------
  |  Branch (1165:13): [True: 617, False: 27.6k]
  ------------------
 1166|    617|            void *new_ptr = loader_instance_heap_realloc(inst, ext_list->list, ext_list->capacity, ext_list->capacity * 2,
 1167|    617|                                                         VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
 1168|    617|            if (new_ptr == NULL) {
  ------------------
  |  Branch (1168:17): [True: 0, False: 617]
  ------------------
 1169|      0|                loader_log(inst, VULKAN_LOADER_ERROR_BIT, 0,
 1170|      0|                           "loader_add_to_ext_list: Failed to reallocate space for extension list");
 1171|      0|                return VK_ERROR_OUT_OF_HOST_MEMORY;
 1172|      0|            }
 1173|    617|            ext_list->list = new_ptr;
 1174|       |
 1175|       |            // double capacity
 1176|    617|            ext_list->capacity *= 2;
 1177|    617|        }
 1178|       |
 1179|       |        // every caller passes the address of an array element or on-stack struct, never NULL
 1180|       |        // NOLINTNEXTLINE(clang-analyzer-core.NonNullParamChecker)
 1181|  28.3k|        memcpy(&ext_list->list[ext_list->count], cur_ext, sizeof(VkExtensionProperties));
 1182|  28.3k|        ext_list->count++;
 1183|  28.3k|    }
 1184|  31.3k|    return VK_SUCCESS;
 1185|  31.3k|}
loader_add_to_dev_ext_list:
 1192|  70.3k|                                    const VkExtensionProperties *props, struct loader_string_list *entrys) {
 1193|  70.3k|    VkResult res = VK_SUCCESS;
 1194|  70.3k|    bool should_free_entrys = true;
 1195|  70.3k|    if (ext_list->list == NULL || ext_list->capacity == 0) {
  ------------------
  |  Branch (1195:9): [True: 8.05k, False: 62.2k]
  |  Branch (1195:35): [True: 0, False: 62.2k]
  ------------------
 1196|  8.05k|        res = loader_init_generic_list(inst, (struct loader_generic_list *)ext_list, sizeof(struct loader_dev_ext_props));
 1197|  8.05k|        if (VK_SUCCESS != res) {
  ------------------
  |  Branch (1197:13): [True: 0, False: 8.05k]
  ------------------
 1198|      0|            goto out;
 1199|      0|        }
 1200|  8.05k|    }
 1201|       |
 1202|       |    // look for duplicates
 1203|  70.3k|    if (has_vk_dev_ext_property(props, ext_list)) {
  ------------------
  |  Branch (1203:9): [True: 11.3k, False: 58.9k]
  ------------------
 1204|  11.3k|        goto out;
 1205|  11.3k|    }
 1206|       |
 1207|  58.9k|    uint32_t idx = ext_list->count;
 1208|       |    // add to list at end
 1209|       |    // check for enough capacity
 1210|  58.9k|    if (idx * sizeof(struct loader_dev_ext_props) >= ext_list->capacity) {
  ------------------
  |  Branch (1210:9): [True: 967, False: 57.9k]
  ------------------
 1211|    967|        void *new_ptr = loader_instance_heap_realloc(inst, ext_list->list, ext_list->capacity, ext_list->capacity * 2,
 1212|    967|                                                     VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
 1213|       |
 1214|    967|        if (NULL == new_ptr) {
  ------------------
  |  Branch (1214:13): [True: 0, False: 967]
  ------------------
 1215|      0|            loader_log(inst, VULKAN_LOADER_ERROR_BIT, 0,
 1216|      0|                       "loader_add_to_dev_ext_list: Failed to reallocate space for device extension list");
 1217|      0|            res = VK_ERROR_OUT_OF_HOST_MEMORY;
 1218|      0|            goto out;
 1219|      0|        }
 1220|    967|        ext_list->list = new_ptr;
 1221|       |
 1222|       |        // double capacity
 1223|    967|        ext_list->capacity *= 2;
 1224|    967|    }
 1225|       |
 1226|       |    // every caller passes the address of an array element or on-stack struct, never NULL
 1227|       |    // NOLINTNEXTLINE(clang-analyzer-core.NonNullParamChecker)
 1228|  58.9k|    memcpy(&ext_list->list[idx].props, props, sizeof(*props));
 1229|  58.9k|    if (entrys) {
  ------------------
  |  Branch (1229:9): [True: 15.3k, False: 43.6k]
  ------------------
 1230|  15.3k|        ext_list->list[idx].entrypoints = *entrys;
 1231|  15.3k|        should_free_entrys = false;
 1232|  43.6k|    } else {
 1233|  43.6k|        memset(&ext_list->list[idx].entrypoints, 0, sizeof(ext_list->list[idx].entrypoints));
 1234|  43.6k|    }
 1235|  58.9k|    ext_list->count++;
 1236|  70.3k|out:
 1237|  70.3k|    if (NULL != entrys && should_free_entrys) {
  ------------------
  |  Branch (1237:9): [True: 16.1k, False: 54.2k]
  |  Branch (1237:27): [True: 784, False: 15.3k]
  ------------------
 1238|    784|        free_string_list(inst, entrys);
 1239|    784|    }
 1240|  70.3k|    return res;
 1241|  58.9k|}
loader_destroy_pointer_layer_list:
 1266|  16.4k|void loader_destroy_pointer_layer_list(const struct loader_instance *inst, struct loader_pointer_layer_list *layer_list) {
 1267|  16.4k|    loader_instance_heap_free(inst, (void *)layer_list->list);
 1268|  16.4k|    memset(layer_list, 0, sizeof(struct loader_pointer_layer_list));
 1269|  16.4k|}
loader_layer_is_available:
 1300|   160k|                               const struct loader_layer_properties *prop) {
 1301|   160k|    bool available = true;
 1302|   160k|    bool is_implicit = (0 == (prop->type_flags & VK_LAYER_TYPE_FLAG_EXPLICIT_LAYER));
 1303|   160k|    bool disabled_by_type =
 1304|   160k|        is_implicit ? filters->disable_filter.disable_all_implicit : filters->disable_filter.disable_all_explicit;
  ------------------
  |  Branch (1304:9): [True: 79.9k, False: 80.5k]
  ------------------
 1305|   160k|    if ((filters->disable_filter.disable_all || disabled_by_type ||
  ------------------
  |  Branch (1305:10): [True: 0, False: 160k]
  |  Branch (1305:49): [True: 0, False: 160k]
  ------------------
 1306|   160k|         check_name_matches_filter_environment_var(prop->info.layerName, &filters->disable_filter.additional_filters)) &&
  ------------------
  |  Branch (1306:10): [True: 0, False: 160k]
  ------------------
 1307|      0|        !check_name_matches_filter_environment_var(prop->info.layerName, &filters->allow_filter)) {
  ------------------
  |  Branch (1307:9): [True: 0, False: 0]
  ------------------
 1308|      0|        available = false;
 1309|      0|    }
 1310|   160k|    if (check_name_matches_filter_environment_var(prop->info.layerName, &filters->enable_filter)) {
  ------------------
  |  Branch (1310:9): [True: 348, False: 160k]
  ------------------
 1311|    348|        available = true;
 1312|   160k|    } else if (!available) {
  ------------------
  |  Branch (1312:16): [True: 0, False: 160k]
  ------------------
 1313|      0|        loader_log(inst, VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_LAYER_BIT, 0,
 1314|      0|                   "Layer \"%s\" forced disabled because name matches filter of env var \'%s\'.", prop->info.layerName,
 1315|      0|                   VK_LAYERS_DISABLE_ENV_VAR);
  ------------------
  |  |  120|      0|#define VK_LAYERS_DISABLE_ENV_VAR "VK_LOADER_LAYERS_DISABLE"
  ------------------
 1316|      0|    }
 1317|       |
 1318|   160k|    return available;
 1319|   160k|}
loader_implicit_layer_is_enabled:
 1368|  4.76k|                                      const struct loader_layer_properties *prop) {
 1369|  4.76k|    bool enable = false;
 1370|  4.76k|    bool forced_disabled = false;
 1371|  4.76k|    bool forced_enabled = false;
 1372|       |
 1373|  4.76k|    if ((filters->disable_filter.disable_all || filters->disable_filter.disable_all_implicit ||
  ------------------
  |  Branch (1373:10): [True: 0, False: 4.76k]
  |  Branch (1373:49): [True: 0, False: 4.76k]
  ------------------
 1374|  4.76k|         check_name_matches_filter_environment_var(prop->info.layerName, &filters->disable_filter.additional_filters)) &&
  ------------------
  |  Branch (1374:10): [True: 0, False: 4.76k]
  ------------------
 1375|      0|        !check_name_matches_filter_environment_var(prop->info.layerName, &filters->allow_filter)) {
  ------------------
  |  Branch (1375:9): [True: 0, False: 0]
  ------------------
 1376|      0|        forced_disabled = true;
 1377|      0|    }
 1378|  4.76k|    if (check_name_matches_filter_environment_var(prop->info.layerName, &filters->enable_filter)) {
  ------------------
  |  Branch (1378:9): [True: 0, False: 4.76k]
  ------------------
 1379|      0|        forced_enabled = true;
 1380|      0|    }
 1381|       |
 1382|       |    // If no enable_environment variable is specified, this implicit layer is always be enabled by default.
 1383|  4.76k|    if (NULL == prop->enable_env_var.name) {
  ------------------
  |  Branch (1383:9): [True: 4.54k, False: 218]
  ------------------
 1384|  4.54k|        enable = true;
 1385|  4.54k|    } else {
 1386|    218|        char *env_value = loader_getenv(prop->enable_env_var.name, inst);
 1387|    218|        if (env_value && !strcmp(prop->enable_env_var.value, env_value)) {
  ------------------
  |  Branch (1387:13): [True: 215, False: 3]
  |  Branch (1387:26): [True: 0, False: 215]
  ------------------
 1388|      0|            enable = true;
 1389|      0|        }
 1390|       |
 1391|       |        // Otherwise, only enable this layer if the enable environment variable is defined
 1392|    218|        loader_free_getenv(env_value, inst);
 1393|    218|    }
 1394|       |
 1395|  4.76k|    if (forced_enabled) {
  ------------------
  |  Branch (1395:9): [True: 0, False: 4.76k]
  ------------------
 1396|       |        // Only report a message that we've forced on a layer if it wouldn't have been enabled
 1397|       |        // normally.
 1398|      0|        if (!enable) {
  ------------------
  |  Branch (1398:13): [True: 0, False: 0]
  ------------------
 1399|      0|            enable = true;
 1400|      0|            loader_log(inst, VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_LAYER_BIT, 0,
 1401|      0|                       "Implicit layer \"%s\" forced enabled due to env var \'%s\'.", prop->info.layerName,
 1402|      0|                       VK_LAYERS_ENABLE_ENV_VAR);
  ------------------
  |  |  119|      0|#define VK_LAYERS_ENABLE_ENV_VAR "VK_LOADER_LAYERS_ENABLE"
  ------------------
 1403|      0|        }
 1404|  4.76k|    } else if (enable && forced_disabled) {
  ------------------
  |  Branch (1404:16): [True: 4.54k, False: 218]
  |  Branch (1404:26): [True: 0, False: 4.54k]
  ------------------
 1405|      0|        enable = false;
 1406|       |        // Report a message that we've forced off a layer if it would have been enabled normally.
 1407|      0|        loader_log(inst, VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_LAYER_BIT, 0,
 1408|      0|                   "Implicit layer \"%s\" forced disabled because name matches filter of env var \'%s\'.", prop->info.layerName,
 1409|      0|                   VK_LAYERS_DISABLE_ENV_VAR);
  ------------------
  |  |  120|      0|#define VK_LAYERS_DISABLE_ENV_VAR "VK_LOADER_LAYERS_DISABLE"
  ------------------
 1410|      0|        return enable;
 1411|      0|    }
 1412|       |
 1413|       |    // The disable_environment has priority over everything else.  If it is defined, the layer is always
 1414|       |    // disabled.
 1415|  4.76k|    if (NULL != prop->disable_env_var.name) {
  ------------------
  |  Branch (1415:9): [True: 2.26k, False: 2.50k]
  ------------------
 1416|  2.26k|        char *env_value = loader_getenv(prop->disable_env_var.name, inst);
 1417|  2.26k|        if (NULL != env_value) {
  ------------------
  |  Branch (1417:13): [True: 3, False: 2.26k]
  ------------------
 1418|      3|            enable = false;
 1419|      3|        }
 1420|  2.26k|        loader_free_getenv(env_value, inst);
 1421|  2.50k|    } else if ((prop->type_flags & VK_LAYER_TYPE_FLAG_EXPLICIT_LAYER) == 0) {
  ------------------
  |  Branch (1421:16): [True: 0, False: 2.50k]
  ------------------
 1422|      0|        loader_log(inst, VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_LAYER_BIT, 0,
 1423|      0|                   "Implicit layer \"%s\" missing disabled environment variable!", prop->info.layerName);
 1424|      0|    }
 1425|       |
 1426|       |    // Enable this layer if it is included in the override layer
 1427|  4.76k|    if (inst != NULL && inst->override_layer_present) {
  ------------------
  |  Branch (1427:9): [True: 4.76k, False: 0]
  |  Branch (1427:25): [True: 0, False: 4.76k]
  ------------------
 1428|      0|        struct loader_layer_properties *override = NULL;
 1429|      0|        for (uint32_t i = 0; i < inst->instance_layer_list.count; ++i) {
  ------------------
  |  Branch (1429:30): [True: 0, False: 0]
  ------------------
 1430|      0|            if (strcmp(inst->instance_layer_list.list[i].info.layerName, VK_OVERRIDE_LAYER_NAME) == 0) {
  ------------------
  |  |  142|      0|#define VK_OVERRIDE_LAYER_NAME "VK_LAYER_LUNARG_override"
  ------------------
  |  Branch (1430:17): [True: 0, False: 0]
  ------------------
 1431|      0|                override = &inst->instance_layer_list.list[i];
 1432|      0|                break;
 1433|      0|            }
 1434|      0|        }
 1435|      0|        if (override != NULL) {
  ------------------
  |  Branch (1435:13): [True: 0, False: 0]
  ------------------
 1436|      0|            for (uint32_t i = 0; i < override->component_layer_names.count; ++i) {
  ------------------
  |  Branch (1436:34): [True: 0, False: 0]
  ------------------
 1437|      0|                if (strcmp(override->component_layer_names.list[i], prop->info.layerName) == 0) {
  ------------------
  |  Branch (1437:21): [True: 0, False: 0]
  ------------------
 1438|      0|                    enable = true;
 1439|      0|                    break;
 1440|      0|                }
 1441|      0|            }
 1442|      0|        }
 1443|      0|    }
 1444|       |
 1445|  4.76k|    return enable;
 1446|  4.76k|}
loader_clear_scanned_icd_list:
 1882|  9.00k|void loader_clear_scanned_icd_list(const struct loader_instance *inst, struct loader_icd_tramp_list *icd_tramp_list) {
 1883|  9.00k|    if (0 != icd_tramp_list->capacity && icd_tramp_list->scanned_list) {
  ------------------
  |  Branch (1883:9): [True: 793, False: 8.21k]
  |  Branch (1883:42): [True: 793, False: 0]
  ------------------
 1884|    793|        for (uint32_t i = 0; i < icd_tramp_list->count; i++) {
  ------------------
  |  Branch (1884:30): [True: 0, False: 793]
  ------------------
 1885|      0|            if (icd_tramp_list->scanned_list[i].handle) {
  ------------------
  |  Branch (1885:17): [True: 0, False: 0]
  ------------------
 1886|      0|                loader_platform_close_library(icd_tramp_list->scanned_list[i].handle);
 1887|       |                icd_tramp_list->scanned_list[i].handle = NULL;
 1888|      0|            }
 1889|      0|            loader_instance_heap_free(inst, icd_tramp_list->scanned_list[i].lib_name);
 1890|      0|        }
 1891|    793|        loader_instance_heap_free(inst, icd_tramp_list->scanned_list);
 1892|    793|    }
 1893|  9.00k|    memset(icd_tramp_list, 0, sizeof(struct loader_icd_tramp_list));
 1894|  9.00k|}
loader_init_scanned_icd_list:
 1896|    793|VkResult loader_init_scanned_icd_list(const struct loader_instance *inst, struct loader_icd_tramp_list *icd_tramp_list) {
 1897|    793|    VkResult res = VK_SUCCESS;
 1898|    793|    loader_clear_scanned_icd_list(inst, icd_tramp_list);
 1899|    793|    icd_tramp_list->capacity = 8 * sizeof(struct loader_scanned_icd);
 1900|    793|    icd_tramp_list->scanned_list = loader_instance_heap_alloc(inst, icd_tramp_list->capacity, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
 1901|    793|    if (NULL == icd_tramp_list->scanned_list) {
  ------------------
  |  Branch (1901:9): [True: 0, False: 793]
  ------------------
 1902|      0|        loader_log(inst, VULKAN_LOADER_ERROR_BIT, 0,
 1903|      0|                   "loader_init_scanned_icd_list: Realloc failed for layer list when attempting to add new layer");
 1904|      0|        res = VK_ERROR_OUT_OF_HOST_MEMORY;
 1905|      0|    }
 1906|    793|    return res;
 1907|    793|}
loader_scan_for_direct_drivers:
 2045|    793|                                        struct loader_icd_tramp_list *icd_tramp_list, bool *direct_driver_loading_exclusive_mode) {
 2046|    793|    if (NULL == pCreateInfo) {
  ------------------
  |  Branch (2046:9): [True: 0, False: 793]
  ------------------
 2047|       |        // Don't do this logic unless we are being called from vkCreateInstance, when pCreateInfo will be non-null
 2048|      0|        return VK_SUCCESS;
 2049|      0|    }
 2050|    793|    bool direct_driver_loading_enabled = false;
 2051|       |    // Try to if VK_LUNARG_direct_driver_loading is enabled and if we are using it exclusively
 2052|       |    // Skip this step if inst is NULL, aka when this function is being called before instance creation
 2053|    793|    if (inst != NULL && pCreateInfo->ppEnabledExtensionNames && pCreateInfo->enabledExtensionCount > 0) {
  ------------------
  |  Branch (2053:9): [True: 793, False: 0]
  |  Branch (2053:25): [True: 0, False: 793]
  |  Branch (2053:65): [True: 0, False: 0]
  ------------------
 2054|       |        // Look through the enabled extension list, make sure VK_LUNARG_direct_driver_loading is present
 2055|      0|        for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
  ------------------
  |  Branch (2055:30): [True: 0, False: 0]
  ------------------
 2056|      0|            if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_LUNARG_DIRECT_DRIVER_LOADING_EXTENSION_NAME) == 0) {
  ------------------
  |  Branch (2056:17): [True: 0, False: 0]
  ------------------
 2057|      0|                direct_driver_loading_enabled = true;
 2058|      0|                break;
 2059|      0|            }
 2060|      0|        }
 2061|      0|    }
 2062|    793|    const VkDirectDriverLoadingListLUNARG *ddl_list = NULL;
 2063|       |    // Find the VkDirectDriverLoadingListLUNARG struct in the pNext chain of vkInstanceCreateInfo
 2064|    793|    const void *pNext = pCreateInfo->pNext;
 2065|    793|    while (pNext) {
  ------------------
  |  Branch (2065:12): [True: 0, False: 793]
  ------------------
 2066|      0|        VkBaseInStructure out_structure = {0};
 2067|      0|        memcpy(&out_structure, pNext, sizeof(VkBaseInStructure));
 2068|      0|        if (out_structure.sType == VK_STRUCTURE_TYPE_DIRECT_DRIVER_LOADING_LIST_LUNARG) {
  ------------------
  |  Branch (2068:13): [True: 0, False: 0]
  ------------------
 2069|      0|            ddl_list = (VkDirectDriverLoadingListLUNARG *)pNext;
 2070|      0|            break;
 2071|      0|        }
 2072|      0|        pNext = out_structure.pNext;
 2073|      0|    }
 2074|    793|    if (NULL == ddl_list) {
  ------------------
  |  Branch (2074:9): [True: 793, False: 0]
  ------------------
 2075|    793|        if (direct_driver_loading_enabled) {
  ------------------
  |  Branch (2075:13): [True: 0, False: 793]
  ------------------
 2076|      0|            loader_log(inst, VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_DRIVER_BIT, 0,
 2077|      0|                       "loader_scan_for_direct_drivers: The VK_LUNARG_direct_driver_loading extension was enabled but the "
 2078|      0|                       "pNext chain of "
 2079|      0|                       "VkInstanceCreateInfo did not contain the "
 2080|      0|                       "VkDirectDriverLoadingListLUNARG structure.");
 2081|      0|        }
 2082|       |        // Always want to exit early if there was no VkDirectDriverLoadingListLUNARG in the pNext chain
 2083|    793|        return VK_SUCCESS;
 2084|    793|    }
 2085|       |
 2086|      0|    if (!direct_driver_loading_enabled) {
  ------------------
  |  Branch (2086:9): [True: 0, False: 0]
  ------------------
 2087|      0|        loader_log(inst, VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_DRIVER_BIT, 0,
 2088|      0|                   "loader_scan_for_direct_drivers: The pNext chain of VkInstanceCreateInfo contained the "
 2089|      0|                   "VkDirectDriverLoadingListLUNARG structure, but the VK_LUNARG_direct_driver_loading extension was "
 2090|      0|                   "not enabled.");
 2091|      0|        return VK_SUCCESS;
 2092|      0|    }
 2093|       |    // If we are using exclusive mode, skip looking for any more drivers from system or environment variables
 2094|      0|    if (ddl_list->mode == VK_DIRECT_DRIVER_LOADING_MODE_EXCLUSIVE_LUNARG) {
  ------------------
  |  Branch (2094:9): [True: 0, False: 0]
  ------------------
 2095|      0|        *direct_driver_loading_exclusive_mode = true;
 2096|      0|        loader_log(inst, VULKAN_LOADER_INFO_BIT | VULKAN_LOADER_DRIVER_BIT, 0,
 2097|      0|                   "loader_scan_for_direct_drivers: The VK_LUNARG_direct_driver_loading extension is active and specified "
 2098|      0|                   "VK_DIRECT_DRIVER_LOADING_MODE_EXCLUSIVE_LUNARG, skipping system and environment "
 2099|      0|                   "variable driver search mechanisms.");
 2100|      0|    }
 2101|      0|    if (NULL == ddl_list->pDrivers) {
  ------------------
  |  Branch (2101:9): [True: 0, False: 0]
  ------------------
 2102|      0|        loader_log(inst, VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_DRIVER_BIT, 0,
 2103|      0|                   "loader_scan_for_direct_drivers: The VkDirectDriverLoadingListLUNARG structure in the pNext chain of "
 2104|      0|                   "VkInstanceCreateInfo has a NULL pDrivers member.");
 2105|      0|        return VK_SUCCESS;
 2106|      0|    }
 2107|      0|    if (ddl_list->driverCount == 0) {
  ------------------
  |  Branch (2107:9): [True: 0, False: 0]
  ------------------
 2108|      0|        loader_log(inst, VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_DRIVER_BIT, 0,
 2109|      0|                   "loader_scan_for_direct_drivers: The VkDirectDriverLoadingListLUNARG structure in the pNext chain of "
 2110|      0|                   "VkInstanceCreateInfo has a non-null pDrivers member but a driverCount member with a value "
 2111|      0|                   "of zero.");
 2112|      0|        return VK_SUCCESS;
 2113|      0|    }
 2114|       |    // Go through all VkDirectDriverLoadingInfoLUNARG entries and add each driver
 2115|       |    // Because icd_tramp's are prepended, this will result in the drivers appearing at the end
 2116|      0|    for (uint32_t i = 0; i < ddl_list->driverCount; i++) {
  ------------------
  |  Branch (2116:26): [True: 0, False: 0]
  ------------------
 2117|      0|        VkResult res = loader_add_direct_driver(inst, i, &ddl_list->pDrivers[i], icd_tramp_list);
 2118|      0|        if (res == VK_ERROR_OUT_OF_HOST_MEMORY) {
  ------------------
  |  Branch (2118:13): [True: 0, False: 0]
  ------------------
 2119|      0|            return res;
 2120|      0|        }
 2121|      0|    }
 2122|       |
 2123|      0|    return VK_SUCCESS;
 2124|      0|}
loader_scanned_icd_add:
 2127|     28|                                const char *filename, uint32_t api_version, enum loader_layer_library_status *lib_status) {
 2128|     28|    loader_platform_dl_handle handle = NULL;
 2129|     28|    PFN_vkCreateInstance fp_create_inst = NULL;
 2130|     28|    PFN_vkEnumerateInstanceExtensionProperties fp_get_inst_ext_props = NULL;
 2131|     28|    PFN_vkGetInstanceProcAddr fp_get_proc_addr = NULL;
 2132|     28|    PFN_GetPhysicalDeviceProcAddr fp_get_phys_dev_proc_addr = NULL;
 2133|     28|    PFN_vkNegotiateLoaderICDInterfaceVersion fp_negotiate_icd_version = NULL;
 2134|       |#if defined(VK_USE_PLATFORM_WIN32_KHR)
 2135|       |    PFN_vk_icdEnumerateAdapterPhysicalDevices fp_enum_dxgi_adapter_phys_devs = NULL;
 2136|       |#endif
 2137|     28|    struct loader_scanned_icd *new_scanned_icd = NULL;
 2138|     28|    uint32_t interface_vers;
 2139|     28|    VkResult res = VK_SUCCESS;
 2140|       |
 2141|       |    // This shouldn't happen, but the check is necessary because dlopen returns a handle to the main program when
 2142|       |    // filename is NULL
 2143|     28|    if (filename == NULL) {
  ------------------
  |  Branch (2143:9): [True: 0, False: 28]
  ------------------
 2144|      0|        loader_log(inst, VULKAN_LOADER_ERROR_BIT, 0, "loader_scanned_icd_add: A NULL filename was used, skipping this ICD");
 2145|      0|        res = VK_ERROR_INCOMPATIBLE_DRIVER;
 2146|      0|        goto out;
 2147|      0|    }
 2148|       |
 2149|       |// TODO implement smarter opening/closing of libraries. For now this
 2150|       |// function leaves libraries open and the scanned_icd_clear closes them
 2151|       |#if defined(__Fuchsia__)
 2152|       |    handle = loader_platform_open_driver(filename);
 2153|       |#else
 2154|     28|    handle = loader_platform_open_library(filename);
 2155|     28|#endif
 2156|     28|    if (NULL == handle) {
  ------------------
  |  Branch (2156:9): [True: 28, False: 0]
  ------------------
 2157|     28|        loader_handle_load_library_error(inst, filename, lib_status);
 2158|     28|        if (lib_status && *lib_status == LOADER_LAYER_LIB_ERROR_OUT_OF_MEMORY) {
  ------------------
  |  Branch (2158:13): [True: 28, False: 0]
  |  Branch (2158:27): [True: 3, False: 25]
  ------------------
 2159|      3|            res = VK_ERROR_OUT_OF_HOST_MEMORY;
 2160|     25|        } else {
 2161|     25|            res = VK_ERROR_INCOMPATIBLE_DRIVER;
 2162|     25|        }
 2163|     28|        goto out;
 2164|     28|    }
 2165|       |
 2166|       |    // Try to load the driver's exported vk_icdNegotiateLoaderICDInterfaceVersion
 2167|      0|    fp_negotiate_icd_version = loader_platform_get_proc_address(handle, "vk_icdNegotiateLoaderICDInterfaceVersion");
 2168|       |
 2169|       |    // If it isn't exported, we are dealing with either a v0, v1, or a v7 and up driver
 2170|      0|    if (NULL == fp_negotiate_icd_version) {
  ------------------
  |  Branch (2170:9): [True: 0, False: 0]
  ------------------
 2171|       |        // Try to load the driver's exported vk_icdGetInstanceProcAddr - if this is a v7 or up driver, we can use it to get
 2172|       |        // the driver's vk_icdNegotiateLoaderICDInterfaceVersion function
 2173|      0|        fp_get_proc_addr = loader_platform_get_proc_address(handle, "vk_icdGetInstanceProcAddr");
 2174|       |
 2175|       |        // If we successfully loaded vk_icdGetInstanceProcAddr, try to get vk_icdNegotiateLoaderICDInterfaceVersion
 2176|      0|        if (fp_get_proc_addr) {
  ------------------
  |  Branch (2176:13): [True: 0, False: 0]
  ------------------
 2177|      0|            fp_negotiate_icd_version =
 2178|      0|                (PFN_vk_icdNegotiateLoaderICDInterfaceVersion)fp_get_proc_addr(NULL, "vk_icdNegotiateLoaderICDInterfaceVersion");
 2179|      0|        }
 2180|      0|    }
 2181|       |
 2182|       |    // Try to negotiate the Loader and Driver Interface Versions
 2183|       |    // loader_get_icd_interface_version will check if fp_negotiate_icd_version is NULL, so we don't have to.
 2184|       |    // If it *is* NULL, that means this driver uses interface version 0 or 1
 2185|      0|    if (!loader_get_icd_interface_version(fp_negotiate_icd_version, &interface_vers)) {
  ------------------
  |  Branch (2185:9): [True: 0, False: 0]
  ------------------
 2186|      0|        loader_log(inst, VULKAN_LOADER_ERROR_BIT, 0,
 2187|      0|                   "loader_scanned_icd_add: ICD %s doesn't support interface version compatible with loader, skip this ICD.",
 2188|      0|                   filename);
 2189|      0|        res = VK_ERROR_INCOMPATIBLE_DRIVER;
 2190|      0|        goto out;
 2191|      0|    }
 2192|       |
 2193|       |    // If we didn't already query vk_icdGetInstanceProcAddr, try now
 2194|      0|    if (NULL == fp_get_proc_addr) {
  ------------------
  |  Branch (2194:9): [True: 0, False: 0]
  ------------------
 2195|      0|        fp_get_proc_addr = loader_platform_get_proc_address(handle, "vk_icdGetInstanceProcAddr");
 2196|      0|    }
 2197|       |
 2198|       |    // If vk_icdGetInstanceProcAddr is NULL, this ICD is using version 0 and so we should respond accordingly.
 2199|      0|    if (NULL == fp_get_proc_addr) {
  ------------------
  |  Branch (2199:9): [True: 0, False: 0]
  ------------------
 2200|       |        // Exporting vk_icdNegotiateLoaderICDInterfaceVersion but not vk_icdGetInstanceProcAddr violates Version 2's
 2201|       |        // requirements, as for Version 2 to be supported Version 1 must also be supported
 2202|      0|        if (interface_vers != 0) {
  ------------------
  |  Branch (2202:13): [True: 0, False: 0]
  ------------------
 2203|      0|            loader_log(inst, VULKAN_LOADER_ERROR_BIT, 0,
 2204|      0|                       "loader_scanned_icd_add: ICD %s reports an interface version of %d but doesn't export "
 2205|      0|                       "vk_icdGetInstanceProcAddr, skip this ICD.",
 2206|      0|                       filename, interface_vers);
 2207|      0|            res = VK_ERROR_INCOMPATIBLE_DRIVER;
 2208|      0|            goto out;
 2209|      0|        }
 2210|       |        // Use deprecated interface from version 0
 2211|      0|        fp_get_proc_addr = loader_platform_get_proc_address(handle, "vkGetInstanceProcAddr");
 2212|      0|        if (NULL == fp_get_proc_addr) {
  ------------------
  |  Branch (2212:13): [True: 0, False: 0]
  ------------------
 2213|      0|            loader_log(inst, VULKAN_LOADER_ERROR_BIT, 0,
 2214|      0|                       "loader_scanned_icd_add: Attempt to retrieve either \'vkGetInstanceProcAddr\' or "
 2215|      0|                       "\'vk_icdGetInstanceProcAddr\' from ICD %s failed.",
 2216|      0|                       filename);
 2217|      0|            res = VK_ERROR_INCOMPATIBLE_DRIVER;
 2218|      0|            goto out;
 2219|      0|        } else {
 2220|      0|            loader_log(inst, VULKAN_LOADER_WARN_BIT, 0,
 2221|      0|                       "loader_scanned_icd_add: Using deprecated ICD interface of \'vkGetInstanceProcAddr\' instead of "
 2222|      0|                       "\'vk_icdGetInstanceProcAddr\' for ICD %s",
 2223|      0|                       filename);
 2224|      0|        }
 2225|      0|        fp_create_inst = loader_platform_get_proc_address(handle, "vkCreateInstance");
 2226|      0|        if (NULL == fp_create_inst) {
  ------------------
  |  Branch (2226:13): [True: 0, False: 0]
  ------------------
 2227|      0|            loader_log(inst, VULKAN_LOADER_ERROR_BIT, 0,
 2228|      0|                       "loader_scanned_icd_add:  Failed querying \'vkCreateInstance\' via dlsym/LoadLibrary for ICD %s", filename);
 2229|      0|            res = VK_ERROR_INCOMPATIBLE_DRIVER;
 2230|      0|            goto out;
 2231|      0|        }
 2232|      0|        fp_get_inst_ext_props = loader_platform_get_proc_address(handle, "vkEnumerateInstanceExtensionProperties");
 2233|      0|        if (NULL == fp_get_inst_ext_props) {
  ------------------
  |  Branch (2233:13): [True: 0, False: 0]
  ------------------
 2234|      0|            loader_log(inst, VULKAN_LOADER_ERROR_BIT, 0,
 2235|      0|                       "loader_scanned_icd_add: Could not get \'vkEnumerateInstanceExtensionProperties\' via dlsym/LoadLibrary "
 2236|      0|                       "for ICD %s",
 2237|      0|                       filename);
 2238|      0|            res = VK_ERROR_INCOMPATIBLE_DRIVER;
 2239|      0|            goto out;
 2240|      0|        }
 2241|      0|    } else {
 2242|       |        // vk_icdGetInstanceProcAddr was successfully found, we can assume the version is at least one
 2243|       |        // If vk_icdNegotiateLoaderICDInterfaceVersion was also found, interface_vers must be 2 or greater, so this check is
 2244|       |        // fine
 2245|      0|        if (interface_vers == 0) {
  ------------------
  |  Branch (2245:13): [True: 0, False: 0]
  ------------------
 2246|      0|            interface_vers = 1;
 2247|      0|        }
 2248|       |
 2249|      0|        fp_create_inst = (PFN_vkCreateInstance)fp_get_proc_addr(NULL, "vkCreateInstance");
 2250|      0|        if (NULL == fp_create_inst) {
  ------------------
  |  Branch (2250:13): [True: 0, False: 0]
  ------------------
 2251|      0|            loader_log(inst, VULKAN_LOADER_ERROR_BIT, 0,
 2252|      0|                       "loader_scanned_icd_add: Could not get \'vkCreateInstance\' via \'vk_icdGetInstanceProcAddr\' for ICD %s",
 2253|      0|                       filename);
 2254|      0|            res = VK_ERROR_INCOMPATIBLE_DRIVER;
 2255|      0|            goto out;
 2256|      0|        }
 2257|      0|        fp_get_inst_ext_props =
 2258|      0|            (PFN_vkEnumerateInstanceExtensionProperties)fp_get_proc_addr(NULL, "vkEnumerateInstanceExtensionProperties");
 2259|      0|        if (NULL == fp_get_inst_ext_props) {
  ------------------
  |  Branch (2259:13): [True: 0, False: 0]
  ------------------
 2260|      0|            loader_log(inst, VULKAN_LOADER_ERROR_BIT, 0,
 2261|      0|                       "loader_scanned_icd_add: Could not get \'vkEnumerateInstanceExtensionProperties\' via "
 2262|      0|                       "\'vk_icdGetInstanceProcAddr\' for ICD %s",
 2263|      0|                       filename);
 2264|      0|            res = VK_ERROR_INCOMPATIBLE_DRIVER;
 2265|      0|            goto out;
 2266|      0|        }
 2267|       |        // Query "vk_icdGetPhysicalDeviceProcAddr" with vk_icdGetInstanceProcAddr if the library reports interface version 7 or
 2268|       |        // greater, otherwise fallback to loading it from the platform dynamic linker
 2269|      0|        if (interface_vers >= 7) {
  ------------------
  |  Branch (2269:13): [True: 0, False: 0]
  ------------------
 2270|      0|            fp_get_phys_dev_proc_addr =
 2271|      0|                (PFN_vk_icdGetPhysicalDeviceProcAddr)fp_get_proc_addr(NULL, "vk_icdGetPhysicalDeviceProcAddr");
 2272|      0|        }
 2273|      0|        if (NULL == fp_get_phys_dev_proc_addr && interface_vers >= 3) {
  ------------------
  |  Branch (2273:13): [True: 0, False: 0]
  |  Branch (2273:50): [True: 0, False: 0]
  ------------------
 2274|      0|            fp_get_phys_dev_proc_addr = loader_platform_get_proc_address(handle, "vk_icdGetPhysicalDeviceProcAddr");
 2275|      0|        }
 2276|       |#if defined(VK_USE_PLATFORM_WIN32_KHR)
 2277|       |        // Query "vk_icdEnumerateAdapterPhysicalDevices" with vk_icdGetInstanceProcAddr if the library reports interface version
 2278|       |        // 7 or greater, otherwise fallback to loading it from the platform dynamic linker
 2279|       |        if (interface_vers >= 7) {
 2280|       |            fp_enum_dxgi_adapter_phys_devs =
 2281|       |                (PFN_vk_icdEnumerateAdapterPhysicalDevices)fp_get_proc_addr(NULL, "vk_icdEnumerateAdapterPhysicalDevices");
 2282|       |        }
 2283|       |        if (NULL == fp_enum_dxgi_adapter_phys_devs && interface_vers >= 6) {
 2284|       |            fp_enum_dxgi_adapter_phys_devs = loader_platform_get_proc_address(handle, "vk_icdEnumerateAdapterPhysicalDevices");
 2285|       |        }
 2286|       |#endif
 2287|      0|    }
 2288|       |
 2289|       |    // check for enough capacity
 2290|      0|    if ((icd_tramp_list->count * sizeof(struct loader_scanned_icd)) >= icd_tramp_list->capacity) {
  ------------------
  |  Branch (2290:9): [True: 0, False: 0]
  ------------------
 2291|      0|        void *new_ptr = loader_instance_heap_realloc(inst, icd_tramp_list->scanned_list, icd_tramp_list->capacity,
 2292|      0|                                                     icd_tramp_list->capacity * 2, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
 2293|      0|        if (NULL == new_ptr) {
  ------------------
  |  Branch (2293:13): [True: 0, False: 0]
  ------------------
 2294|      0|            res = VK_ERROR_OUT_OF_HOST_MEMORY;
 2295|      0|            loader_log(inst, VULKAN_LOADER_ERROR_BIT, 0, "loader_scanned_icd_add: Realloc failed on icd library list for ICD %s",
 2296|      0|                       filename);
 2297|      0|            goto out;
 2298|      0|        }
 2299|      0|        icd_tramp_list->scanned_list = new_ptr;
 2300|       |
 2301|       |        // double capacity
 2302|      0|        icd_tramp_list->capacity *= 2;
 2303|      0|    }
 2304|       |
 2305|      0|    loader_api_version api_version_struct = loader_make_version(api_version);
 2306|      0|    if (interface_vers <= 4 && loader_check_version_meets_required(LOADER_VERSION_1_1_0, api_version_struct)) {
  ------------------
  |  |  271|      0|#define LOADER_VERSION_1_1_0 loader_combine_version(1, 1, 0)
  ------------------
  |  Branch (2306:9): [True: 0, False: 0]
  |  Branch (2306:32): [True: 0, False: 0]
  ------------------
 2307|      0|        loader_log(inst, VULKAN_LOADER_WARN_BIT, 0,
 2308|      0|                   "loader_scanned_icd_add: Driver %s supports Vulkan %u.%u, but only supports loader interface version %u."
 2309|      0|                   " Interface version 5 or newer required to support this version of Vulkan (Policy #LDP_DRIVER_7)",
 2310|      0|                   filename, api_version_struct.major, api_version_struct.minor, interface_vers);
 2311|      0|    }
 2312|       |
 2313|      0|    new_scanned_icd = &(icd_tramp_list->scanned_list[icd_tramp_list->count]);
 2314|      0|    new_scanned_icd->handle = handle;
 2315|      0|    new_scanned_icd->api_version = api_version;
 2316|      0|    new_scanned_icd->GetInstanceProcAddr = fp_get_proc_addr;
 2317|      0|    new_scanned_icd->GetPhysicalDeviceProcAddr = fp_get_phys_dev_proc_addr;
 2318|      0|    new_scanned_icd->EnumerateInstanceExtensionProperties = fp_get_inst_ext_props;
 2319|      0|    new_scanned_icd->CreateInstance = fp_create_inst;
 2320|       |#if defined(VK_USE_PLATFORM_WIN32_KHR)
 2321|       |    new_scanned_icd->EnumerateAdapterPhysicalDevices = fp_enum_dxgi_adapter_phys_devs;
 2322|       |#endif
 2323|      0|    new_scanned_icd->interface_version = interface_vers;
 2324|       |
 2325|      0|    res = loader_copy_to_new_str(inst, filename, &new_scanned_icd->lib_name);
 2326|      0|    if (VK_ERROR_OUT_OF_HOST_MEMORY == res) {
  ------------------
  |  Branch (2326:9): [True: 0, False: 0]
  ------------------
 2327|      0|        loader_log(inst, VULKAN_LOADER_ERROR_BIT, 0, "loader_scanned_icd_add: Out of memory can't add ICD %s", filename);
 2328|      0|        goto out;
 2329|      0|    }
 2330|       |
 2331|       |    // Uses OS calls to find the 'true' path to the binary, for more accurate logging later on.
 2332|      0|    res = fixup_library_binary_path(inst, &(new_scanned_icd->lib_name), new_scanned_icd->handle, fp_get_proc_addr);
 2333|      0|    if (res == VK_ERROR_OUT_OF_HOST_MEMORY) {
  ------------------
  |  Branch (2333:9): [True: 0, False: 0]
  ------------------
 2334|      0|        loader_instance_heap_free(inst, new_scanned_icd->lib_name);
 2335|      0|        goto out;
 2336|      0|    }
 2337|       |
 2338|      0|    icd_tramp_list->count++;
 2339|       |
 2340|     28|out:
 2341|     28|    if (res != VK_SUCCESS) {
  ------------------
  |  Branch (2341:9): [True: 28, False: 0]
  ------------------
 2342|     28|        if (NULL != handle) {
  ------------------
  |  Branch (2342:13): [True: 0, False: 28]
  ------------------
 2343|      0|            loader_platform_close_library(handle);
 2344|      0|        }
 2345|     28|    }
 2346|       |
 2347|     28|    return res;
 2348|      0|}
loader_initialize:
 2356|      2|void loader_initialize(void) {
 2357|      2|    loader_platform_thread_create_mutex(&loader_lock);
 2358|      2|    loader_platform_thread_create_mutex(&loader_preload_icd_lock);
 2359|      2|    init_global_loader_settings();
 2360|      2|#endif
 2361|       |
 2362|       |    // initialize logging
 2363|      2|    loader_init_global_debug_level();
 2364|       |#if defined(_WIN32)
 2365|       |    windows_initialization();
 2366|       |#endif
 2367|       |
 2368|      2|    loader_api_version version = loader_make_full_version(VK_HEADER_VERSION_COMPLETE);
 2369|      2|    loader_log(NULL, VULKAN_LOADER_INFO_BIT, 0, "Vulkan Loader Version %d.%d.%d", version.major, version.minor, version.patch);
 2370|       |
 2371|       |#if defined(GIT_BRANCH_NAME) && defined(GIT_TAG_INFO)
 2372|       |    loader_log(NULL, VULKAN_LOADER_INFO_BIT, 0, "[Vulkan Loader Git - Tag: " GIT_BRANCH_NAME ", Branch/Commit: " GIT_TAG_INFO "]");
 2373|       |#endif
 2374|       |
 2375|      2|    char *loader_disable_dynamic_library_unloading_env_var = loader_getenv("VK_LOADER_DISABLE_DYNAMIC_LIBRARY_UNLOADING", NULL);
 2376|      2|    if (loader_disable_dynamic_library_unloading_env_var &&
  ------------------
  |  Branch (2376:9): [True: 0, False: 2]
  ------------------
 2377|       |        // NOLINTNEXTLINE(bugprone-not-null-terminated-result) - n=2 intentionally excludes "1x" values like "10"
 2378|      0|        0 == strncmp(loader_disable_dynamic_library_unloading_env_var, "1", 2)) {
  ------------------
  |  Branch (2378:9): [True: 0, False: 0]
  ------------------
 2379|      0|        loader_disable_dynamic_library_unloading = true;
 2380|      0|        loader_log(NULL, VULKAN_LOADER_WARN_BIT, 0, "Vulkan Loader: library unloading is disabled");
 2381|      2|    } else {
 2382|      2|        loader_disable_dynamic_library_unloading = false;
 2383|      2|    }
 2384|      2|    loader_free_getenv(loader_disable_dynamic_library_unloading_env_var, NULL);
 2385|       |#if defined(LOADER_USE_UNSAFE_FILE_SEARCH)
 2386|       |    loader_log(NULL, VULKAN_LOADER_WARN_BIT, 0, "Vulkan Loader: unsafe searching is enabled");
 2387|       |#endif
 2388|       |#if defined(_WIN32)
 2389|       |    return TRUE;
 2390|       |#endif
 2391|      2|}
loader_init_library:
 2428|      2|__attribute__((constructor)) void loader_init_library(void) { loader_initialize(); }
loader_get_next_path:
 2439|   242k|char *loader_get_next_path(char *path) {
 2440|   242k|    uint32_t len;
 2441|   242k|    char *next;
 2442|       |
 2443|   242k|    if (path == NULL) return NULL;
  ------------------
  |  Branch (2443:9): [True: 0, False: 242k]
  ------------------
 2444|   242k|    next = strchr(path, PATH_SEPARATOR);
  ------------------
  |  |  154|   242k|#define PATH_SEPARATOR ':'
  ------------------
 2445|   242k|    if (next == NULL) {
  ------------------
  |  Branch (2445:9): [True: 242k, False: 0]
  ------------------
 2446|   242k|        len = (uint32_t)strlen(path);
 2447|   242k|        next = path + len;
 2448|   242k|    } else {
 2449|      0|        *next = '\0';
 2450|      0|        next++;
 2451|      0|    }
 2452|       |
 2453|   242k|    return next;
 2454|   242k|}
combine_manifest_directory_and_library_path:
 2464|  23.1k|                                                     const char *manifest_file_path, char **out_fullpath) {
 2465|  23.1k|    assert(library_path && manifest_file_path && out_fullpath);
 2466|  23.1k|    if (loader_platform_is_path_absolute(library_path)) {
  ------------------
  |  Branch (2466:9): [True: 2.45k, False: 20.6k]
  ------------------
 2467|  2.45k|        *out_fullpath = library_path;
 2468|  2.45k|        return VK_SUCCESS;
 2469|  2.45k|    }
 2470|  20.6k|    VkResult res = VK_SUCCESS;
 2471|       |
 2472|  20.6k|    size_t library_path_len = strlen(library_path);
 2473|  20.6k|    size_t manifest_file_path_str_len = strlen(manifest_file_path);
 2474|  20.6k|    bool library_path_contains_directory_symbol = false;
 2475|  11.7M|    for (size_t i = 0; i < library_path_len; i++) {
  ------------------
  |  Branch (2475:24): [True: 11.7M, False: 9.72k]
  ------------------
 2476|  11.7M|        if (library_path[i] == DIRECTORY_SYMBOL) {
  ------------------
  |  |  155|  11.7M|#define DIRECTORY_SYMBOL '/'
  ------------------
  |  Branch (2476:13): [True: 10.9k, False: 11.7M]
  ------------------
 2477|  10.9k|            library_path_contains_directory_symbol = true;
 2478|  10.9k|            break;
 2479|  10.9k|        }
 2480|  11.7M|    }
 2481|       |    // Means that the library_path is neither absolute nor relative - thus we should not modify it at all
 2482|  20.6k|    if (!library_path_contains_directory_symbol) {
  ------------------
  |  Branch (2482:9): [True: 9.72k, False: 10.9k]
  ------------------
 2483|  9.72k|        *out_fullpath = library_path;
 2484|  9.72k|        return VK_SUCCESS;
 2485|  9.72k|    }
 2486|       |    // must include both a directory symbol and the null terminator
 2487|  10.9k|    size_t new_str_len = library_path_len + manifest_file_path_str_len + 1 + 1;
 2488|       |
 2489|  10.9k|    *out_fullpath = loader_instance_heap_calloc(inst, new_str_len, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
 2490|  10.9k|    if (NULL == *out_fullpath) {
  ------------------
  |  Branch (2490:9): [True: 0, False: 10.9k]
  ------------------
 2491|      0|        res = VK_ERROR_OUT_OF_HOST_MEMORY;
 2492|      0|        goto out;
 2493|      0|    }
 2494|  10.9k|    size_t cur_loc_in_out_fullpath = 0;
 2495|       |    // look for the last occurrence of DIRECTORY_SYMBOL in manifest_file_path
 2496|  10.9k|    size_t last_directory_symbol = 0;
 2497|  10.9k|    bool found_directory_symbol = false;
 2498|   371k|    for (size_t i = 0; i < manifest_file_path_str_len; i++) {
  ------------------
  |  Branch (2498:24): [True: 360k, False: 10.9k]
  ------------------
 2499|   360k|        if (manifest_file_path[i] == DIRECTORY_SYMBOL) {
  ------------------
  |  |  155|   360k|#define DIRECTORY_SYMBOL '/'
  ------------------
  |  Branch (2499:13): [True: 29.5k, False: 331k]
  ------------------
 2500|  29.5k|            last_directory_symbol = i + 1;  // we want to include the symbol
 2501|  29.5k|            found_directory_symbol = true;
 2502|       |            // dont break because we want to find the last occurrence
 2503|  29.5k|        }
 2504|   360k|    }
 2505|       |    // Add manifest_file_path up to the last directory symbol
 2506|  10.9k|    if (found_directory_symbol) {
  ------------------
  |  Branch (2506:9): [True: 8.25k, False: 2.66k]
  ------------------
 2507|  8.25k|        loader_strncpy(*out_fullpath, new_str_len, manifest_file_path, last_directory_symbol);
 2508|  8.25k|        cur_loc_in_out_fullpath += last_directory_symbol;
 2509|  8.25k|    }
 2510|  10.9k|    loader_strncpy(&(*out_fullpath)[cur_loc_in_out_fullpath], new_str_len - cur_loc_in_out_fullpath, library_path,
 2511|  10.9k|                   library_path_len);
 2512|  10.9k|    cur_loc_in_out_fullpath += library_path_len + 1;
 2513|  10.9k|    (*out_fullpath)[cur_loc_in_out_fullpath] = '\0';
 2514|       |
 2515|  10.9k|out:
 2516|  10.9k|    loader_instance_heap_free(inst, library_path);
 2517|       |
 2518|  10.9k|    return res;
 2519|  10.9k|}
loader_get_fullpath:
 2525|   110k|void loader_get_fullpath(const char *file, const char *in_dirs, size_t out_size, char *out_fullpath) {
 2526|   110k|    if (!loader_platform_is_path(file) && *in_dirs) {
  ------------------
  |  Branch (2526:9): [True: 109k, False: 870]
  |  Branch (2526:43): [True: 109k, False: 0]
  ------------------
 2527|   109k|        size_t dirs_copy_len = strlen(in_dirs) + 1;
 2528|   109k|        char *dirs_copy = loader_stack_alloc(dirs_copy_len);
  ------------------
  |  |   42|   109k|#define loader_stack_alloc(size) alloca(size)
  ------------------
 2529|   109k|        loader_strncpy(dirs_copy, dirs_copy_len, in_dirs, dirs_copy_len);
 2530|       |
 2531|       |        // find if file exists after prepending paths in given list
 2532|       |        // for (dir = dirs_copy; *dir && (next_dir = loader_get_next_path(dir)); dir = next_dir) {
 2533|   109k|        char *dir = dirs_copy;
 2534|   109k|        char *next_dir = loader_get_next_path(dir);
 2535|   112k|        while (*dir && next_dir) {
  ------------------
  |  Branch (2535:16): [True: 109k, False: 2.27k]
  |  Branch (2535:24): [True: 109k, False: 0]
  ------------------
 2536|   109k|            int path_concat_ret = snprintf(out_fullpath, out_size, "%s%c%s", dir, DIRECTORY_SYMBOL, file);
  ------------------
  |  |  155|   109k|#define DIRECTORY_SYMBOL '/'
  ------------------
 2537|   109k|            if (path_concat_ret < 0) {
  ------------------
  |  Branch (2537:17): [True: 0, False: 109k]
  ------------------
 2538|      0|                continue;
 2539|      0|            }
 2540|   109k|            if (loader_platform_file_exists(out_fullpath)) {
  ------------------
  |  Branch (2540:17): [True: 107k, False: 2.27k]
  ------------------
 2541|   107k|                return;
 2542|   107k|            }
 2543|  2.27k|            dir = next_dir;
 2544|  2.27k|            next_dir = loader_get_next_path(dir);
 2545|  2.27k|        }
 2546|   109k|    }
 2547|       |
 2548|  3.14k|    (void)snprintf(out_fullpath, out_size, "%s", file);
 2549|  3.14k|}
verify_meta_layer_component_layers:
 2556|   167k|                                        struct loader_layer_list *instance_layers, bool *already_checked_meta_layers) {
 2557|   167k|    struct loader_layer_properties *prop = &instance_layers->list[prop_index];
 2558|   167k|    loader_api_version meta_layer_version = loader_make_version(prop->info.specVersion);
 2559|       |
 2560|   167k|    if (NULL == already_checked_meta_layers) {
  ------------------
  |  Branch (2560:9): [True: 158k, False: 9.21k]
  ------------------
 2561|   158k|        already_checked_meta_layers = loader_stack_alloc(sizeof(bool) * instance_layers->count);
  ------------------
  |  |   42|   158k|#define loader_stack_alloc(size) alloca(size)
  ------------------
 2562|   158k|        if (already_checked_meta_layers == NULL) {
  ------------------
  |  Branch (2562:13): [True: 0, False: 158k]
  ------------------
 2563|      0|            return false;
 2564|      0|        }
 2565|   158k|        memset(already_checked_meta_layers, 0, sizeof(bool) * instance_layers->count);
 2566|   158k|    }
 2567|       |
 2568|       |    // Mark this meta layer as 'already checked', indicating which layers have already been recursed.
 2569|   167k|    already_checked_meta_layers[prop_index] = true;
 2570|       |
 2571|   174k|    for (uint32_t comp_layer = 0; comp_layer < prop->component_layer_names.count; comp_layer++) {
  ------------------
  |  Branch (2571:35): [True: 24.3k, False: 150k]
  ------------------
 2572|  24.3k|        struct loader_layer_properties *comp_prop =
 2573|  24.3k|            loader_find_layer_property(prop->component_layer_names.list[comp_layer], instance_layers);
 2574|  24.3k|        if (comp_prop == NULL) {
  ------------------
  |  Branch (2574:13): [True: 8.42k, False: 15.9k]
  ------------------
 2575|  8.42k|            loader_log(inst, VULKAN_LOADER_WARN_BIT, 0,
 2576|  8.42k|                       "verify_meta_layer_component_layers: Meta-layer %s can't find component layer %s at index %d."
 2577|  8.42k|                       "  Skipping this layer.",
 2578|  8.42k|                       prop->info.layerName, prop->component_layer_names.list[comp_layer], comp_layer);
 2579|       |
 2580|  8.42k|            return false;
 2581|  8.42k|        }
 2582|       |
 2583|       |        // Check the version of each layer, they need to be at least MAJOR and MINOR
 2584|  15.9k|        loader_api_version comp_prop_version = loader_make_version(comp_prop->info.specVersion);
 2585|  15.9k|        if (!loader_check_version_meets_required(meta_layer_version, comp_prop_version)) {
  ------------------
  |  Branch (2585:13): [True: 1.55k, False: 14.3k]
  ------------------
 2586|  1.55k|            loader_log(inst, VULKAN_LOADER_WARN_BIT, 0,
 2587|  1.55k|                       "verify_meta_layer_component_layers: Meta-layer uses API version %d.%d, but component "
 2588|  1.55k|                       "layer %d has API version %d.%d that is lower.  Skipping this layer.",
 2589|  1.55k|                       meta_layer_version.major, meta_layer_version.minor, comp_layer, comp_prop_version.major,
 2590|  1.55k|                       comp_prop_version.minor);
 2591|       |
 2592|  1.55k|            return false;
 2593|  1.55k|        }
 2594|       |
 2595|       |        // Make sure the layer isn't using it's own name
 2596|  14.3k|        if (!strcmp(prop->info.layerName, prop->component_layer_names.list[comp_layer])) {
  ------------------
  |  Branch (2596:13): [True: 2.28k, False: 12.0k]
  ------------------
 2597|  2.28k|            loader_log(inst, VULKAN_LOADER_WARN_BIT, 0,
 2598|  2.28k|                       "verify_meta_layer_component_layers: Meta-layer %s lists itself in its component layer "
 2599|  2.28k|                       "list at index %d.  Skipping this layer.",
 2600|  2.28k|                       prop->info.layerName, comp_layer);
 2601|       |
 2602|  2.28k|            return false;
 2603|  2.28k|        }
 2604|  12.0k|        if (comp_prop->type_flags & VK_LAYER_TYPE_FLAG_META_LAYER) {
  ------------------
  |  Branch (2604:13): [True: 10.2k, False: 1.85k]
  ------------------
 2605|  10.2k|            size_t comp_prop_index = INT32_MAX;
 2606|       |            // Make sure we haven't verified this meta layer before
 2607|  5.71M|            for (uint32_t i = 0; i < instance_layers->count; i++) {
  ------------------
  |  Branch (2607:34): [True: 5.70M, False: 10.2k]
  ------------------
 2608|  5.70M|                if (strcmp(comp_prop->info.layerName, instance_layers->list[i].info.layerName) == 0) {
  ------------------
  |  Branch (2608:21): [True: 359k, False: 5.34M]
  ------------------
 2609|   359k|                    comp_prop_index = i;
 2610|   359k|                }
 2611|  5.70M|            }
 2612|  10.2k|            if (comp_prop_index != INT32_MAX && already_checked_meta_layers[comp_prop_index]) {
  ------------------
  |  Branch (2612:17): [True: 10.2k, False: 0]
  |  Branch (2612:49): [True: 1.02k, False: 9.21k]
  ------------------
 2613|  1.02k|                loader_log(inst, VULKAN_LOADER_WARN_BIT, 0,
 2614|  1.02k|                           "verify_meta_layer_component_layers: Recursive dependency between Meta-layer %s and  Meta-layer %s.  "
 2615|  1.02k|                           "Skipping this layer.",
 2616|  1.02k|                           instance_layers->list[prop_index].info.layerName, comp_prop->info.layerName);
 2617|  1.02k|                return false;
 2618|  1.02k|            }
 2619|       |
 2620|  9.21k|            loader_log(inst, VULKAN_LOADER_INFO_BIT, 0,
 2621|  9.21k|                       "verify_meta_layer_component_layers: Adding meta-layer %s which also contains meta-layer %s",
 2622|  9.21k|                       prop->info.layerName, comp_prop->info.layerName);
 2623|       |
 2624|       |            // Make sure if the layer is using a meta-layer in its component list that we also verify that.
 2625|  9.21k|            if (!verify_meta_layer_component_layers(inst, comp_prop_index, instance_layers, already_checked_meta_layers)) {
  ------------------
  |  Branch (2625:17): [True: 4.08k, False: 5.13k]
  ------------------
 2626|  4.08k|                loader_log(inst, VULKAN_LOADER_WARN_BIT, 0,
 2627|  4.08k|                           "Meta-layer %s component layer %s can not find all component layers."
 2628|  4.08k|                           "  Skipping this layer.",
 2629|  4.08k|                           prop->info.layerName, prop->component_layer_names.list[comp_layer]);
 2630|  4.08k|                return false;
 2631|  4.08k|            }
 2632|  9.21k|        }
 2633|  12.0k|    }
 2634|       |    // Didn't exit early so that means it passed all checks
 2635|   150k|    loader_log(inst, VULKAN_LOADER_INFO_BIT | VULKAN_LOADER_LAYER_BIT, 0,
 2636|   150k|               "Meta-layer \"%s\" all %d component layers appear to be valid.", prop->info.layerName,
 2637|   150k|               prop->component_layer_names.count);
 2638|       |
 2639|       |    // If layer logging is on, list the internals included in the meta-layer
 2640|   156k|    for (uint32_t comp_layer = 0; comp_layer < prop->component_layer_names.count; comp_layer++) {
  ------------------
  |  Branch (2640:35): [True: 6.56k, False: 150k]
  ------------------
 2641|  6.56k|        loader_log(inst, VULKAN_LOADER_LAYER_BIT, 0, "  [%d] %s", comp_layer, prop->component_layer_names.list[comp_layer]);
 2642|  6.56k|    }
 2643|       |    return true;
 2644|   167k|}
update_meta_layer_extensions_from_component_layers:
 2650|   145k|                                                            struct loader_layer_list *instance_layers) {
 2651|   145k|    VkResult res = VK_SUCCESS;
 2652|   151k|    for (uint32_t comp_layer = 0; comp_layer < prop->component_layer_names.count; comp_layer++) {
  ------------------
  |  Branch (2652:35): [True: 6.05k, False: 145k]
  ------------------
 2653|  6.05k|        struct loader_layer_properties *comp_prop =
 2654|  6.05k|            loader_find_layer_property(prop->component_layer_names.list[comp_layer], instance_layers);
 2655|       |
 2656|  6.05k|        if (NULL != comp_prop->instance_extension_list.list) {
  ------------------
  |  Branch (2656:13): [True: 809, False: 5.24k]
  ------------------
 2657|  15.6k|            for (uint32_t ext = 0; ext < comp_prop->instance_extension_list.count; ext++) {
  ------------------
  |  Branch (2657:36): [True: 14.8k, False: 809]
  ------------------
 2658|  14.8k|                loader_log(inst, VULKAN_LOADER_DEBUG_BIT, 0, "Meta-layer %s component layer %s adding instance extension %s",
 2659|  14.8k|                           prop->info.layerName, prop->component_layer_names.list[comp_layer],
 2660|  14.8k|                           comp_prop->instance_extension_list.list[ext].extensionName);
 2661|       |
 2662|  14.8k|                if (!has_vk_extension_property(&comp_prop->instance_extension_list.list[ext], &prop->instance_extension_list)) {
  ------------------
  |  Branch (2662:21): [True: 14.4k, False: 403]
  ------------------
 2663|  14.4k|                    res = loader_add_to_ext_list(inst, &prop->instance_extension_list, 1,
 2664|  14.4k|                                                 &comp_prop->instance_extension_list.list[ext]);
 2665|  14.4k|                    if (VK_ERROR_OUT_OF_HOST_MEMORY == res) {
  ------------------
  |  Branch (2665:25): [True: 0, False: 14.4k]
  ------------------
 2666|      0|                        return res;
 2667|      0|                    }
 2668|  14.4k|                }
 2669|  14.8k|            }
 2670|    809|        }
 2671|  6.05k|        if (NULL != comp_prop->device_extension_list.list) {
  ------------------
  |  Branch (2671:13): [True: 1.39k, False: 4.65k]
  ------------------
 2672|  21.6k|            for (uint32_t ext = 0; ext < comp_prop->device_extension_list.count; ext++) {
  ------------------
  |  Branch (2672:36): [True: 20.2k, False: 1.39k]
  ------------------
 2673|  20.2k|                loader_log(inst, VULKAN_LOADER_DEBUG_BIT, 0, "Meta-layer %s component layer %s adding device extension %s",
 2674|  20.2k|                           prop->info.layerName, prop->component_layer_names.list[comp_layer],
 2675|  20.2k|                           comp_prop->device_extension_list.list[ext].props.extensionName);
 2676|       |
 2677|  20.2k|                if (!has_vk_dev_ext_property(&comp_prop->device_extension_list.list[ext].props, &prop->device_extension_list)) {
  ------------------
  |  Branch (2677:21): [True: 18.8k, False: 1.43k]
  ------------------
 2678|  18.8k|                    res = loader_add_to_dev_ext_list(inst, &prop->device_extension_list,
 2679|  18.8k|                                                     &comp_prop->device_extension_list.list[ext].props, NULL);
 2680|  18.8k|                    if (VK_ERROR_OUT_OF_HOST_MEMORY == res) {
  ------------------
  |  Branch (2680:25): [True: 0, False: 18.8k]
  ------------------
 2681|      0|                        return res;
 2682|      0|                    }
 2683|  18.8k|                }
 2684|  20.2k|            }
 2685|  1.39k|        }
 2686|  6.05k|    }
 2687|   145k|    return res;
 2688|   145k|}
verify_all_meta_layers:
 2692|  7.78k|                                struct loader_layer_list *instance_layers, bool *override_layer_present) {
 2693|  7.78k|    VkResult res = VK_SUCCESS;
 2694|  7.78k|    *override_layer_present = false;
 2695|   181k|    for (int32_t i = 0; i < (int32_t)instance_layers->count; i++) {
  ------------------
  |  Branch (2695:25): [True: 173k, False: 7.78k]
  ------------------
 2696|   173k|        struct loader_layer_properties *prop = &instance_layers->list[i];
 2697|       |
 2698|       |        // If this is a meta-layer, make sure it is valid
 2699|   173k|        if (prop->type_flags & VK_LAYER_TYPE_FLAG_META_LAYER) {
  ------------------
  |  Branch (2699:13): [True: 158k, False: 15.3k]
  ------------------
 2700|   158k|            if (verify_meta_layer_component_layers(inst, i, instance_layers, NULL)) {
  ------------------
  |  Branch (2700:17): [True: 145k, False: 13.2k]
  ------------------
 2701|       |                // If any meta layer is valid, update its extension list to include the extensions from its component layers.
 2702|   145k|                res = update_meta_layer_extensions_from_component_layers(inst, prop, instance_layers);
 2703|   145k|                if (VK_ERROR_OUT_OF_HOST_MEMORY == res) {
  ------------------
  |  Branch (2703:21): [True: 0, False: 145k]
  ------------------
 2704|      0|                    return res;
 2705|      0|                }
 2706|   145k|                if (prop->is_override && loader_implicit_layer_is_enabled(inst, filters, prop)) {
  ------------------
  |  Branch (2706:21): [True: 3.59k, False: 141k]
  |  Branch (2706:42): [True: 3.51k, False: 73]
  ------------------
 2707|  3.51k|                    *override_layer_present = true;
 2708|  3.51k|                }
 2709|   145k|            } else {
 2710|  13.2k|                loader_log(inst, VULKAN_LOADER_DEBUG_BIT, 0,
 2711|  13.2k|                           "Removing meta-layer %s from instance layer list since it appears invalid.", prop->info.layerName);
 2712|       |
 2713|  13.2k|                loader_remove_layer_in_list(inst, instance_layers, i);
 2714|  13.2k|                i--;
 2715|  13.2k|            }
 2716|   158k|        }
 2717|   173k|    }
 2718|  7.78k|    return res;
 2719|  7.78k|}
remove_all_non_valid_override_layers:
 2723|  7.78k|void remove_all_non_valid_override_layers(struct loader_instance *inst, struct loader_layer_list *instance_layers) {
 2724|  7.78k|    if (instance_layers == NULL) {
  ------------------
  |  Branch (2724:9): [True: 0, False: 7.78k]
  ------------------
 2725|      0|        return;
 2726|      0|    }
 2727|       |
 2728|  7.78k|    char cur_path[1024];
 2729|  7.78k|    char *ret = loader_platform_executable_path(cur_path, 1024);
 2730|  7.78k|    if (NULL == ret) {
  ------------------
  |  Branch (2730:9): [True: 0, False: 7.78k]
  ------------------
 2731|      0|        return;
 2732|      0|    }
 2733|       |    // Find out if there is an override layer with same the app_key_path as the path to the current executable.
 2734|       |    // If more than one is found, remove it and use the first layer
 2735|       |    // Remove any layers which aren't global and do not have the same app_key_path as the path to the current executable.
 2736|  7.78k|    bool found_active_override_layer = false;
 2737|  7.78k|    int global_layer_index = -1;
 2738|  94.3k|    for (uint32_t i = 0; i < instance_layers->count; i++) {
  ------------------
  |  Branch (2738:26): [True: 86.5k, False: 7.78k]
  ------------------
 2739|  86.5k|        struct loader_layer_properties *props = &instance_layers->list[i];
 2740|  86.5k|        if (strcmp(props->info.layerName, VK_OVERRIDE_LAYER_NAME) == 0) {
  ------------------
  |  |  142|  86.5k|#define VK_OVERRIDE_LAYER_NAME "VK_LAYER_LUNARG_override"
  ------------------
  |  Branch (2740:13): [True: 2.84k, False: 83.7k]
  ------------------
 2741|  2.84k|            if (props->app_key_paths.count > 0) {  // not the global layer
  ------------------
  |  Branch (2741:17): [True: 572, False: 2.27k]
  ------------------
 2742|  34.9k|                for (uint32_t j = 0; j < props->app_key_paths.count; j++) {
  ------------------
  |  Branch (2742:38): [True: 34.3k, False: 572]
  ------------------
 2743|  34.3k|                    if (strcmp(props->app_key_paths.list[j], cur_path) == 0) {
  ------------------
  |  Branch (2743:25): [True: 0, False: 34.3k]
  ------------------
 2744|      0|                        if (!found_active_override_layer) {
  ------------------
  |  Branch (2744:29): [True: 0, False: 0]
  ------------------
 2745|      0|                            found_active_override_layer = true;
 2746|      0|                        } else {
 2747|      0|                            loader_log(inst, VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_LAYER_BIT, 0,
 2748|      0|                                       "remove_all_non_valid_override_layers: Multiple override layers where the same path in "
 2749|      0|                                       "app_keys "
 2750|      0|                                       "was found. Using the first layer found");
 2751|       |
 2752|       |                            // Remove duplicate active override layers that have the same app_key_path
 2753|      0|                            loader_remove_layer_in_list(inst, instance_layers, i);
 2754|      0|                            i--;
 2755|      0|                        }
 2756|      0|                    }
 2757|  34.3k|                }
 2758|    572|                if (!found_active_override_layer) {
  ------------------
  |  Branch (2758:21): [True: 572, False: 0]
  ------------------
 2759|    572|                    loader_log(inst, VULKAN_LOADER_INFO_BIT | VULKAN_LOADER_LAYER_BIT, 0,
 2760|    572|                               "--Override layer found but not used because app \'%s\' is not in \'app_keys\' list!", cur_path);
 2761|       |
 2762|       |                    // Remove non-global override layers that don't have an app_key that matches cur_path
 2763|    572|                    loader_remove_layer_in_list(inst, instance_layers, i);
 2764|    572|                    i--;
 2765|    572|                }
 2766|  2.27k|            } else {
 2767|  2.27k|                if (global_layer_index == -1) {
  ------------------
  |  Branch (2767:21): [True: 1.17k, False: 1.09k]
  ------------------
 2768|  1.17k|                    global_layer_index = (int)i;
 2769|  1.17k|                } else {
 2770|  1.09k|                    loader_log(
 2771|  1.09k|                        inst, VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_LAYER_BIT, 0,
 2772|  1.09k|                        "remove_all_non_valid_override_layers: Multiple global override layers found. Using the first global "
 2773|  1.09k|                        "layer found");
 2774|  1.09k|                    loader_remove_layer_in_list(inst, instance_layers, i);
 2775|  1.09k|                    i--;
 2776|  1.09k|                }
 2777|  2.27k|            }
 2778|  2.84k|        }
 2779|  86.5k|    }
 2780|       |    // Remove global layer if layer with same the app_key_path as the path to the current executable is found
 2781|  7.78k|    if (found_active_override_layer && global_layer_index >= 0) {
  ------------------
  |  Branch (2781:9): [True: 0, False: 7.78k]
  |  Branch (2781:40): [True: 0, False: 0]
  ------------------
 2782|      0|        loader_remove_layer_in_list(inst, instance_layers, global_layer_index);
 2783|      0|    }
 2784|       |    // Should be at most 1 override layer in the list now.
 2785|  7.78k|    if (found_active_override_layer) {
  ------------------
  |  Branch (2785:9): [True: 0, False: 7.78k]
  ------------------
 2786|      0|        loader_log(inst, VULKAN_LOADER_INFO_BIT | VULKAN_LOADER_LAYER_BIT, 0, "Using the override layer for app key %s", cur_path);
 2787|  7.78k|    } else if (global_layer_index >= 0) {
  ------------------
  |  Branch (2787:16): [True: 1.17k, False: 6.60k]
  ------------------
 2788|  1.17k|        loader_log(inst, VULKAN_LOADER_INFO_BIT | VULKAN_LOADER_LAYER_BIT, 0, "Using the global override layer");
 2789|  1.17k|    }
 2790|  7.78k|}
loader_read_layer_json:
 2804|   268k|                                cJSON *layer_node, loader_api_version version, bool is_implicit, char *filename) {
 2805|   268k|    assert(layer_instance_list);
 2806|   268k|    char *library_path = NULL;
 2807|   268k|    VkResult result = VK_SUCCESS;
 2808|   268k|    struct loader_layer_properties props = {0};
 2809|       |
 2810|   268k|    result = loader_copy_to_new_str(inst, filename, &props.manifest_file_name);
 2811|   268k|    if (result == VK_ERROR_OUT_OF_HOST_MEMORY) {
  ------------------
  |  Branch (2811:9): [True: 0, False: 268k]
  ------------------
 2812|      0|        goto out;
 2813|      0|    }
 2814|       |
 2815|       |    // Parse name
 2816|       |
 2817|   268k|    result = loader_parse_json_string_to_existing_str(layer_node, "name", VK_MAX_EXTENSION_NAME_SIZE, props.info.layerName);
 2818|   268k|    if (VK_ERROR_INITIALIZATION_FAILED == result) {
  ------------------
  |  Branch (2818:9): [True: 26.5k, False: 242k]
  ------------------
 2819|  26.5k|        loader_log(inst, VULKAN_LOADER_WARN_BIT, 0,
 2820|  26.5k|                   "Layer located at %s didn't find required layer value \"name\" in manifest JSON file, skipping this layer",
 2821|  26.5k|                   filename);
 2822|  26.5k|        goto out;
 2823|  26.5k|    }
 2824|       |
 2825|       |    // Check if this layer's name matches the override layer name, set is_override to true if so.
 2826|   242k|    if (!strcmp(props.info.layerName, VK_OVERRIDE_LAYER_NAME)) {
  ------------------
  |  |  142|   242k|#define VK_OVERRIDE_LAYER_NAME "VK_LAYER_LUNARG_override"
  ------------------
  |  Branch (2826:9): [True: 8.53k, False: 233k]
  ------------------
 2827|  8.53k|        props.is_override = true;
 2828|  8.53k|    }
 2829|       |
 2830|   242k|    if (0 != strncmp(props.info.layerName, "VK_LAYER_", 9)) {
  ------------------
  |  Branch (2830:9): [True: 225k, False: 16.9k]
  ------------------
 2831|   225k|        loader_log(inst, VULKAN_LOADER_WARN_BIT, 0, "Layer name %s does not conform to naming standard (Policy #LLP_LAYER_3)",
 2832|   225k|                   props.info.layerName);
 2833|   225k|    }
 2834|       |
 2835|       |    // Parse type
 2836|   242k|    char *type = loader_cJSON_GetStringValue(loader_cJSON_GetObjectItem(layer_node, "type"));
 2837|   242k|    if (NULL == type) {
  ------------------
  |  Branch (2837:9): [True: 11.5k, False: 230k]
  ------------------
 2838|  11.5k|        loader_log(inst, VULKAN_LOADER_WARN_BIT, 0,
 2839|  11.5k|                   "Layer located at %s didn't find required layer value \"type\" in manifest JSON file, skipping this layer",
 2840|  11.5k|                   filename);
 2841|  11.5k|        result = VK_ERROR_INITIALIZATION_FAILED;
 2842|  11.5k|        goto out;
 2843|  11.5k|    }
 2844|       |
 2845|       |    // Add list entry
 2846|   230k|    if (!strcmp(type, "DEVICE")) {
  ------------------
  |  Branch (2846:9): [True: 333, False: 230k]
  ------------------
 2847|    333|        loader_log(inst, VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_LAYER_BIT, 0, "Device layers are deprecated. Skipping layer %s",
 2848|    333|                   props.info.layerName);
 2849|    333|        result = VK_ERROR_INITIALIZATION_FAILED;
 2850|    333|        goto out;
 2851|    333|    }
 2852|       |
 2853|       |    // Allow either GLOBAL or INSTANCE type interchangeably to handle layers that must work with older loaders
 2854|   230k|    if (!strcmp(type, "INSTANCE") || !strcmp(type, "GLOBAL")) {
  ------------------
  |  Branch (2854:9): [True: 69.7k, False: 160k]
  |  Branch (2854:38): [True: 156k, False: 4.39k]
  ------------------
 2855|   225k|        props.type_flags = VK_LAYER_TYPE_FLAG_INSTANCE_LAYER;
 2856|   225k|        if (!is_implicit) {
  ------------------
  |  Branch (2856:13): [True: 111k, False: 114k]
  ------------------
 2857|   111k|            props.type_flags |= VK_LAYER_TYPE_FLAG_EXPLICIT_LAYER;
 2858|   111k|        }
 2859|   225k|    } else {
 2860|  4.39k|        result = VK_ERROR_INITIALIZATION_FAILED;
 2861|  4.39k|        goto out;
 2862|  4.39k|    }
 2863|       |
 2864|       |    // Parse api_version
 2865|   225k|    char *api_version = loader_cJSON_GetStringValue(loader_cJSON_GetObjectItem(layer_node, "api_version"));
 2866|   225k|    if (NULL == api_version) {
  ------------------
  |  Branch (2866:9): [True: 20.4k, False: 205k]
  ------------------
 2867|  20.4k|        loader_log(
 2868|  20.4k|            inst, VULKAN_LOADER_WARN_BIT, 0,
 2869|  20.4k|            "Layer located at %s didn't find required layer value \"api_version\" in manifest JSON file, skipping this layer",
 2870|  20.4k|            filename);
 2871|  20.4k|        result = VK_ERROR_INITIALIZATION_FAILED;
 2872|  20.4k|        goto out;
 2873|  20.4k|    }
 2874|       |
 2875|   205k|    props.info.specVersion = loader_parse_version_string(api_version);
 2876|       |
 2877|       |    // Make sure the layer's manifest doesn't contain a non zero variant value
 2878|   205k|    if (VK_API_VERSION_VARIANT(props.info.specVersion) != 0) {
  ------------------
  |  Branch (2878:9): [True: 1.26k, False: 204k]
  ------------------
 2879|  1.26k|        loader_log(inst, VULKAN_LOADER_INFO_BIT | VULKAN_LOADER_LAYER_BIT, 0,
 2880|  1.26k|                   "Layer \"%s\" has an \'api_version\' field which contains a non-zero variant value of %d. "
 2881|  1.26k|                   " Skipping Layer.",
 2882|  1.26k|                   props.info.layerName, VK_API_VERSION_VARIANT(props.info.specVersion));
 2883|  1.26k|        result = VK_ERROR_INITIALIZATION_FAILED;
 2884|  1.26k|        goto out;
 2885|  1.26k|    }
 2886|       |
 2887|       |    // Parse implementation_version
 2888|   204k|    char *implementation_version = loader_cJSON_GetStringValue(loader_cJSON_GetObjectItem(layer_node, "implementation_version"));
 2889|   204k|    if (NULL == implementation_version) {
  ------------------
  |  Branch (2889:9): [True: 7.70k, False: 196k]
  ------------------
 2890|  7.70k|        loader_log(inst, VULKAN_LOADER_WARN_BIT, 0,
 2891|  7.70k|                   "Layer located at %s didn't find required layer value \"implementation_version\" in manifest JSON file, "
 2892|  7.70k|                   "skipping this layer",
 2893|  7.70k|                   filename);
 2894|  7.70k|        result = VK_ERROR_INITIALIZATION_FAILED;
 2895|  7.70k|        goto out;
 2896|  7.70k|    }
 2897|   196k|    props.info.implementationVersion = (uint32_t)strtoul(implementation_version, NULL, 10);
 2898|       |
 2899|       |    // Parse description
 2900|       |
 2901|   196k|    result = loader_parse_json_string_to_existing_str(layer_node, "description", VK_MAX_DESCRIPTION_SIZE, props.info.description);
 2902|   196k|    if (VK_ERROR_INITIALIZATION_FAILED == result) {
  ------------------
  |  Branch (2902:9): [True: 5.02k, False: 191k]
  ------------------
 2903|  5.02k|        loader_log(
 2904|  5.02k|            inst, VULKAN_LOADER_WARN_BIT, 0,
 2905|  5.02k|            "Layer located at %s didn't find required layer value \"description\" in manifest JSON file, skipping this layer",
 2906|  5.02k|            filename);
 2907|  5.02k|        goto out;
 2908|  5.02k|    }
 2909|       |
 2910|       |    // Parse library_path
 2911|       |
 2912|       |    // Library path no longer required unless component_layers is also not defined
 2913|   191k|    result = loader_parse_json_string(layer_node, "library_path", &library_path);
 2914|   191k|    if (result == VK_ERROR_OUT_OF_HOST_MEMORY) {
  ------------------
  |  Branch (2914:9): [True: 0, False: 191k]
  ------------------
 2915|      0|        loader_log(inst, VULKAN_LOADER_WARN_BIT, 0,
 2916|      0|                   "Skipping layer \"%s\" due to problem accessing the library_path value in the manifest JSON file",
 2917|      0|                   props.info.layerName);
 2918|      0|        result = VK_ERROR_OUT_OF_HOST_MEMORY;
 2919|      0|        goto out;
 2920|      0|    }
 2921|   191k|    if (NULL != library_path) {
  ------------------
  |  Branch (2921:9): [True: 22.5k, False: 168k]
  ------------------
 2922|  22.5k|        if (NULL != loader_cJSON_GetObjectItem(layer_node, "component_layers")) {
  ------------------
  |  Branch (2922:13): [True: 229, False: 22.3k]
  ------------------
 2923|    229|            loader_log(
 2924|    229|                inst, VULKAN_LOADER_WARN_BIT, 0,
 2925|    229|                "Layer \"%s\" contains meta-layer-specific component_layers, but also defining layer library path.  Both are not "
 2926|    229|                "compatible, so skipping this layer",
 2927|    229|                props.info.layerName);
 2928|    229|            result = VK_ERROR_INITIALIZATION_FAILED;
 2929|    229|            loader_instance_heap_free(inst, library_path);
 2930|    229|            goto out;
 2931|    229|        }
 2932|       |
 2933|       |        // This function takes ownership of library_path_str - so we don't need to clean it up
 2934|  22.3k|        result = combine_manifest_directory_and_library_path(inst, library_path, filename, &props.lib_name);
 2935|  22.3k|        if (result == VK_ERROR_OUT_OF_HOST_MEMORY) goto out;
  ------------------
  |  Branch (2935:13): [True: 0, False: 22.3k]
  ------------------
 2936|  22.3k|    }
 2937|       |
 2938|       |    // Parse component_layers
 2939|       |
 2940|   191k|    if (NULL == library_path) {
  ------------------
  |  Branch (2940:9): [True: 168k, False: 22.3k]
  ------------------
 2941|   168k|        if (!loader_check_version_meets_required(LOADER_VERSION_1_1_0, version)) {
  ------------------
  |  |  271|   168k|#define LOADER_VERSION_1_1_0 loader_combine_version(1, 1, 0)
  ------------------
  |  Branch (2941:13): [True: 37.4k, False: 131k]
  ------------------
 2942|  37.4k|            loader_log(inst, VULKAN_LOADER_WARN_BIT, 0,
 2943|  37.4k|                       "Layer \"%s\" contains meta-layer-specific component_layers, but using older JSON file version.",
 2944|  37.4k|                       props.info.layerName);
 2945|  37.4k|        }
 2946|       |
 2947|   168k|        result = loader_parse_json_array_of_strings(inst, layer_node, "component_layers", &(props.component_layer_names));
 2948|   168k|        if (VK_ERROR_OUT_OF_HOST_MEMORY == result) {
  ------------------
  |  Branch (2948:13): [True: 0, False: 168k]
  ------------------
 2949|      0|            goto out;
 2950|      0|        }
 2951|   168k|        if (VK_ERROR_INITIALIZATION_FAILED == result) {
  ------------------
  |  Branch (2951:13): [True: 3.99k, False: 164k]
  ------------------
 2952|  3.99k|            loader_log(inst, VULKAN_LOADER_WARN_BIT, 0,
 2953|  3.99k|                       "Layer \"%s\" is missing both library_path and component_layers fields.  One or the other MUST be defined.  "
 2954|  3.99k|                       "Skipping this layer",
 2955|  3.99k|                       props.info.layerName);
 2956|  3.99k|            goto out;
 2957|  3.99k|        }
 2958|       |        // This is now, officially, a meta-layer
 2959|   164k|        props.type_flags |= VK_LAYER_TYPE_FLAG_META_LAYER;
 2960|   164k|        loader_log(inst, VULKAN_LOADER_INFO_BIT | VULKAN_LOADER_LAYER_BIT, 0, "Encountered meta-layer \"%s\"",
 2961|   164k|                   props.info.layerName);
 2962|   164k|    }
 2963|       |
 2964|       |    // Parse blacklisted_layers
 2965|       |
 2966|   187k|    if (props.is_override) {
  ------------------
  |  Branch (2966:9): [True: 6.08k, False: 180k]
  ------------------
 2967|  6.08k|        result = loader_parse_json_array_of_strings(inst, layer_node, "blacklisted_layers", &(props.blacklist_layer_names));
 2968|  6.08k|        if (VK_ERROR_OUT_OF_HOST_MEMORY == result) {
  ------------------
  |  Branch (2968:13): [True: 0, False: 6.08k]
  ------------------
 2969|      0|            goto out;
 2970|      0|        }
 2971|  6.08k|    }
 2972|       |
 2973|       |    // Parse override_paths
 2974|       |
 2975|   187k|    result = loader_parse_json_array_of_strings(inst, layer_node, "override_paths", &(props.override_paths));
 2976|   187k|    if (VK_ERROR_OUT_OF_HOST_MEMORY == result) {
  ------------------
  |  Branch (2976:9): [True: 0, False: 187k]
  ------------------
 2977|      0|        goto out;
 2978|      0|    }
 2979|   187k|    if (NULL != props.override_paths.list && !loader_check_version_meets_required(loader_combine_version(1, 1, 0), version)) {
  ------------------
  |  Branch (2979:9): [True: 5.81k, False: 181k]
  |  Branch (2979:46): [True: 3.56k, False: 2.24k]
  ------------------
 2980|  3.56k|        loader_log(inst, VULKAN_LOADER_WARN_BIT, 0,
 2981|  3.56k|                   "Layer \"%s\" contains meta-layer-specific override paths, but using older JSON file version.",
 2982|  3.56k|                   props.info.layerName);
 2983|  3.56k|    }
 2984|       |
 2985|       |    // Parse disable_environment
 2986|       |
 2987|   187k|    if (is_implicit) {
  ------------------
  |  Branch (2987:9): [True: 92.8k, False: 94.2k]
  ------------------
 2988|  92.8k|        cJSON *disable_environment = loader_cJSON_GetObjectItem(layer_node, "disable_environment");
 2989|  92.8k|        if (disable_environment == NULL) {
  ------------------
  |  Branch (2989:13): [True: 5.28k, False: 87.5k]
  ------------------
 2990|  5.28k|            loader_log(inst, VULKAN_LOADER_WARN_BIT, 0,
 2991|  5.28k|                       "Layer \"%s\" doesn't contain required layer object disable_environment in the manifest JSON file, skipping "
 2992|  5.28k|                       "this layer",
 2993|  5.28k|                       props.info.layerName);
 2994|  5.28k|            result = VK_ERROR_INITIALIZATION_FAILED;
 2995|  5.28k|            goto out;
 2996|  5.28k|        }
 2997|       |
 2998|  87.5k|        if (!disable_environment->child || disable_environment->child->type != cJSON_String ||
  ------------------
  |  |  101|   174k|#define cJSON_String (1 << 4)
  ------------------
  |  Branch (2998:13): [True: 342, False: 87.2k]
  |  Branch (2998:44): [True: 221, False: 86.9k]
  ------------------
 2999|  86.9k|            !disable_environment->child->string || !disable_environment->child->valuestring) {
  ------------------
  |  Branch (2999:13): [True: 194, False: 86.7k]
  |  Branch (2999:52): [True: 0, False: 86.7k]
  ------------------
 3000|    757|            loader_log(inst, VULKAN_LOADER_WARN_BIT, 0,
 3001|    757|                       "Layer \"%s\" doesn't contain required child value in object disable_environment in the manifest JSON file, "
 3002|    757|                       "skipping this layer (Policy #LLP_LAYER_9)",
 3003|    757|                       props.info.layerName);
 3004|    757|            result = VK_ERROR_INITIALIZATION_FAILED;
 3005|    757|            goto out;
 3006|    757|        }
 3007|  86.7k|        result = loader_copy_to_new_str(inst, disable_environment->child->string, &(props.disable_env_var.name));
 3008|  86.7k|        if (VK_SUCCESS != result) goto out;
  ------------------
  |  Branch (3008:13): [True: 0, False: 86.7k]
  ------------------
 3009|  86.7k|        result = loader_copy_to_new_str(inst, disable_environment->child->valuestring, &(props.disable_env_var.value));
 3010|  86.7k|        if (VK_SUCCESS != result) goto out;
  ------------------
  |  Branch (3010:13): [True: 0, False: 86.7k]
  ------------------
 3011|  86.7k|    }
 3012|       |
 3013|       |    // Now get all optional items and objects and put in list:
 3014|       |    // functions
 3015|       |    // instance_extensions
 3016|       |    // device_extensions
 3017|       |    // enable_environment (implicit layers only)
 3018|       |    // library_arch
 3019|       |
 3020|       |    // Layer interface functions
 3021|       |    //    vkGetInstanceProcAddr
 3022|       |    //    vkGetDeviceProcAddr
 3023|       |    //    vkNegotiateLoaderLayerInterfaceVersion (starting with JSON file 1.1.0)
 3024|   181k|    cJSON *functions = loader_cJSON_GetObjectItem(layer_node, "functions");
 3025|   181k|    if (functions != NULL) {
  ------------------
  |  Branch (3025:9): [True: 1.34k, False: 179k]
  ------------------
 3026|  1.34k|        if (loader_check_version_meets_required(loader_combine_version(1, 1, 0), version)) {
  ------------------
  |  Branch (3026:13): [True: 703, False: 642]
  ------------------
 3027|    703|            result = loader_parse_json_string(functions, "vkNegotiateLoaderLayerInterfaceVersion",
 3028|    703|                                              &props.functions.str_negotiate_interface);
 3029|    703|            if (result == VK_ERROR_OUT_OF_HOST_MEMORY) goto out;
  ------------------
  |  Branch (3029:17): [True: 0, False: 703]
  ------------------
 3030|    703|        }
 3031|  1.34k|        result = loader_parse_json_string(functions, "vkGetInstanceProcAddr", &props.functions.str_gipa);
 3032|  1.34k|        if (result == VK_ERROR_OUT_OF_HOST_MEMORY) goto out;
  ------------------
  |  Branch (3032:13): [True: 0, False: 1.34k]
  ------------------
 3033|       |
 3034|  1.34k|        if (NULL == props.functions.str_negotiate_interface && props.functions.str_gipa &&
  ------------------
  |  Branch (3034:13): [True: 1.34k, False: 0]
  |  Branch (3034:64): [True: 0, False: 1.34k]
  ------------------
 3035|      0|            loader_check_version_meets_required(loader_combine_version(1, 1, 0), version)) {
  ------------------
  |  Branch (3035:13): [True: 0, False: 0]
  ------------------
 3036|      0|            loader_log(inst, VULKAN_LOADER_INFO_BIT, 0,
 3037|      0|                       "Layer \"%s\" using deprecated \'vkGetInstanceProcAddr\' tag which was deprecated starting with JSON "
 3038|      0|                       "file version 1.1.0. The new vkNegotiateLoaderLayerInterfaceVersion function is preferred, though for "
 3039|      0|                       "compatibility reasons it may be desirable to continue using the deprecated tag.",
 3040|      0|                       props.info.layerName);
 3041|      0|        }
 3042|       |
 3043|  1.34k|        result = loader_parse_json_string(functions, "vkGetDeviceProcAddr", &props.functions.str_gdpa);
 3044|  1.34k|        if (result == VK_ERROR_OUT_OF_HOST_MEMORY) goto out;
  ------------------
  |  Branch (3044:13): [True: 0, False: 1.34k]
  ------------------
 3045|       |
 3046|  1.34k|        if (NULL == props.functions.str_negotiate_interface && props.functions.str_gdpa &&
  ------------------
  |  Branch (3046:13): [True: 1.34k, False: 0]
  |  Branch (3046:64): [True: 0, False: 1.34k]
  ------------------
 3047|      0|            loader_check_version_meets_required(loader_combine_version(1, 1, 0), version)) {
  ------------------
  |  Branch (3047:13): [True: 0, False: 0]
  ------------------
 3048|      0|            loader_log(inst, VULKAN_LOADER_INFO_BIT, 0,
 3049|      0|                       "Layer \"%s\" using deprecated \'vkGetDeviceProcAddr\' tag which was deprecated starting with JSON "
 3050|      0|                       "file version 1.1.0. The new vkNegotiateLoaderLayerInterfaceVersion function is preferred, though for "
 3051|      0|                       "compatibility reasons it may be desirable to continue using the deprecated tag.",
 3052|      0|                       props.info.layerName);
 3053|      0|        }
 3054|  1.34k|    }
 3055|       |
 3056|       |    // instance_extensions
 3057|       |    //   array of {
 3058|       |    //     name
 3059|       |    //     spec_version
 3060|       |    //   }
 3061|       |
 3062|   181k|    cJSON *instance_extensions = loader_cJSON_GetObjectItem(layer_node, "instance_extensions");
 3063|   181k|    if (instance_extensions != NULL && instance_extensions->type == cJSON_Array) {
  ------------------
  |  |  102|  2.41k|#define cJSON_Array (1 << 5)
  ------------------
  |  Branch (3063:9): [True: 2.41k, False: 178k]
  |  Branch (3063:40): [True: 2.22k, False: 196]
  ------------------
 3064|  2.22k|        cJSON *ext_item = NULL;
 3065|  24.8k|        cJSON_ArrayForEach(ext_item, instance_extensions) {
  ------------------
  |  |  213|  27.0k|    for (element = (array != NULL) ? (array)->child : NULL; element != NULL; element = element->next)
  |  |  ------------------
  |  |  |  Branch (213:20): [True: 2.22k, False: 0]
  |  |  |  Branch (213:61): [True: 24.8k, False: 2.22k]
  |  |  ------------------
  ------------------
 3066|  24.8k|            if (ext_item->type != cJSON_Object) {
  ------------------
  |  |  103|  24.8k|#define cJSON_Object (1 << 6)
  ------------------
  |  Branch (3066:17): [True: 1.57k, False: 23.2k]
  ------------------
 3067|  1.57k|                continue;
 3068|  1.57k|            }
 3069|       |
 3070|  23.2k|            VkExtensionProperties ext_prop = {0};
 3071|  23.2k|            result = loader_parse_json_string_to_existing_str(ext_item, "name", VK_MAX_EXTENSION_NAME_SIZE, ext_prop.extensionName);
 3072|  23.2k|            if (result == VK_ERROR_INITIALIZATION_FAILED) {
  ------------------
  |  Branch (3072:17): [True: 4.45k, False: 18.8k]
  ------------------
 3073|  4.45k|                continue;
 3074|  4.45k|            }
 3075|  18.8k|            char *spec_version = NULL;
 3076|  18.8k|            result = loader_parse_json_string(ext_item, "spec_version", &spec_version);
 3077|  18.8k|            if (result == VK_ERROR_OUT_OF_HOST_MEMORY) goto out;
  ------------------
  |  Branch (3077:17): [True: 0, False: 18.8k]
  ------------------
 3078|  18.8k|            if (NULL != spec_version) {
  ------------------
  |  Branch (3078:17): [True: 206, False: 18.5k]
  ------------------
 3079|    206|                ext_prop.specVersion = (uint32_t)strtoul(spec_version, NULL, 10);
 3080|    206|            }
 3081|  18.8k|            loader_instance_heap_free(inst, spec_version);
 3082|  18.8k|            bool ext_unsupported = wsi_unsupported_instance_extension(&ext_prop);
 3083|  18.8k|            if (!ext_unsupported) {
  ------------------
  |  Branch (3083:17): [True: 16.9k, False: 1.88k]
  ------------------
 3084|  16.9k|                result = loader_add_to_ext_list(inst, &props.instance_extension_list, 1, &ext_prop);
 3085|  16.9k|                if (result == VK_ERROR_OUT_OF_HOST_MEMORY) goto out;
  ------------------
  |  Branch (3085:21): [True: 0, False: 16.9k]
  ------------------
 3086|  16.9k|            }
 3087|  18.8k|        }
 3088|  2.22k|    }
 3089|       |
 3090|       |    // device_extensions
 3091|       |    //   array of {
 3092|       |    //     name
 3093|       |    //     spec_version
 3094|       |    //     entrypoints
 3095|       |    //   }
 3096|   181k|    cJSON *device_extensions = loader_cJSON_GetObjectItem(layer_node, "device_extensions");
 3097|   181k|    if (device_extensions != NULL && device_extensions->type == cJSON_Array) {
  ------------------
  |  |  102|  10.4k|#define cJSON_Array (1 << 5)
  ------------------
  |  Branch (3097:9): [True: 10.4k, False: 170k]
  |  Branch (3097:38): [True: 10.0k, False: 423]
  ------------------
 3098|  10.0k|        cJSON *ext_item = NULL;
 3099|  67.1k|        cJSON_ArrayForEach(ext_item, device_extensions) {
  ------------------
  |  |  213|  77.1k|    for (element = (array != NULL) ? (array)->child : NULL; element != NULL; element = element->next)
  |  |  ------------------
  |  |  |  Branch (213:20): [True: 10.0k, False: 0]
  |  |  |  Branch (213:61): [True: 67.1k, False: 10.0k]
  |  |  ------------------
  ------------------
 3100|  67.1k|            if (ext_item->type != cJSON_Object) {
  ------------------
  |  |  103|  67.1k|#define cJSON_Object (1 << 6)
  ------------------
  |  Branch (3100:17): [True: 4.32k, False: 62.8k]
  ------------------
 3101|  4.32k|                continue;
 3102|  4.32k|            }
 3103|       |
 3104|  62.8k|            VkExtensionProperties ext_prop = {0};
 3105|  62.8k|            result = loader_parse_json_string_to_existing_str(ext_item, "name", VK_MAX_EXTENSION_NAME_SIZE, ext_prop.extensionName);
 3106|  62.8k|            if (result == VK_ERROR_INITIALIZATION_FAILED) {
  ------------------
  |  Branch (3106:17): [True: 11.3k, False: 51.4k]
  ------------------
 3107|  11.3k|                continue;
 3108|  11.3k|            }
 3109|       |
 3110|  51.4k|            char *spec_version = NULL;
 3111|  51.4k|            result = loader_parse_json_string(ext_item, "spec_version", &spec_version);
 3112|  51.4k|            if (result == VK_ERROR_OUT_OF_HOST_MEMORY) goto out;
  ------------------
  |  Branch (3112:17): [True: 0, False: 51.4k]
  ------------------
 3113|  51.4k|            if (NULL != spec_version) {
  ------------------
  |  Branch (3113:17): [True: 276, False: 51.1k]
  ------------------
 3114|    276|                ext_prop.specVersion = (uint32_t)strtoul(spec_version, NULL, 10);
 3115|    276|            }
 3116|  51.4k|            loader_instance_heap_free(inst, spec_version);
 3117|       |
 3118|  51.4k|            cJSON *entrypoints = loader_cJSON_GetObjectItem(ext_item, "entrypoints");
 3119|  51.4k|            if (entrypoints == NULL) {
  ------------------
  |  Branch (3119:17): [True: 35.3k, False: 16.1k]
  ------------------
 3120|  35.3k|                result = loader_add_to_dev_ext_list(inst, &props.device_extension_list, &ext_prop, NULL);
 3121|  35.3k|                if (result == VK_ERROR_OUT_OF_HOST_MEMORY) goto out;
  ------------------
  |  Branch (3121:21): [True: 0, False: 35.3k]
  ------------------
 3122|  35.3k|                continue;
 3123|  35.3k|            }
 3124|       |
 3125|  16.1k|            struct loader_string_list entrys = {0};
 3126|  16.1k|            result = loader_parse_json_array_of_strings(inst, ext_item, "entrypoints", &entrys);
 3127|  16.1k|            if (result == VK_ERROR_OUT_OF_HOST_MEMORY) goto out;
  ------------------
  |  Branch (3127:17): [True: 0, False: 16.1k]
  ------------------
 3128|  16.1k|            result = loader_add_to_dev_ext_list(inst, &props.device_extension_list, &ext_prop, &entrys);
 3129|  16.1k|            if (result == VK_ERROR_OUT_OF_HOST_MEMORY) goto out;
  ------------------
  |  Branch (3129:17): [True: 0, False: 16.1k]
  ------------------
 3130|  16.1k|        }
 3131|  10.0k|    }
 3132|   181k|    if (is_implicit) {
  ------------------
  |  Branch (3132:9): [True: 86.7k, False: 94.2k]
  ------------------
 3133|  86.7k|        cJSON *enable_environment = loader_cJSON_GetObjectItem(layer_node, "enable_environment");
 3134|       |
 3135|       |        // enable_environment is optional
 3136|  86.7k|        if (enable_environment && enable_environment->child && enable_environment->child->type == cJSON_String &&
  ------------------
  |  |  101|  88.0k|#define cJSON_String (1 << 4)
  ------------------
  |  Branch (3136:13): [True: 1.56k, False: 85.2k]
  |  Branch (3136:35): [True: 1.23k, False: 332]
  |  Branch (3136:64): [True: 1.04k, False: 195]
  ------------------
 3137|  1.04k|            enable_environment->child->string && enable_environment->child->valuestring) {
  ------------------
  |  Branch (3137:13): [True: 833, False: 207]
  |  Branch (3137:50): [True: 833, False: 0]
  ------------------
 3138|    833|            result = loader_copy_to_new_str(inst, enable_environment->child->string, &(props.enable_env_var.name));
 3139|    833|            if (VK_SUCCESS != result) goto out;
  ------------------
  |  Branch (3139:17): [True: 0, False: 833]
  ------------------
 3140|    833|            result = loader_copy_to_new_str(inst, enable_environment->child->valuestring, &(props.enable_env_var.value));
 3141|    833|            if (VK_SUCCESS != result) goto out;
  ------------------
  |  Branch (3141:17): [True: 0, False: 833]
  ------------------
 3142|    833|        }
 3143|  86.7k|    }
 3144|       |
 3145|       |    // Read in the pre-instance stuff
 3146|   181k|    cJSON *pre_instance = loader_cJSON_GetObjectItem(layer_node, "pre_instance_functions");
 3147|   181k|    if (NULL != pre_instance) {
  ------------------
  |  Branch (3147:9): [True: 112k, False: 68.5k]
  ------------------
 3148|       |        // Supported versions started in 1.1.2, so anything newer
 3149|   112k|        if (!loader_check_version_meets_required(loader_combine_version(1, 1, 2), version)) {
  ------------------
  |  Branch (3149:13): [True: 8.04k, False: 104k]
  ------------------
 3150|  8.04k|            loader_log(inst, VULKAN_LOADER_ERROR_BIT, 0,
 3151|  8.04k|                       "Found pre_instance_functions section in layer from \"%s\". This section is only valid in manifest version "
 3152|  8.04k|                       "1.1.2 or later. The section will be ignored",
 3153|  8.04k|                       filename);
 3154|   104k|        } else if (!is_implicit) {
  ------------------
  |  Branch (3154:20): [True: 51.2k, False: 53.1k]
  ------------------
 3155|  51.2k|            loader_log(inst, VULKAN_LOADER_WARN_BIT, 0,
 3156|  51.2k|                       "Found pre_instance_functions section in explicit layer from \"%s\". This section is only valid in implicit "
 3157|  51.2k|                       "layers. The section will be ignored",
 3158|  51.2k|                       filename);
 3159|  53.1k|        } else {
 3160|  53.1k|            result = loader_parse_json_string(pre_instance, "vkEnumerateInstanceExtensionProperties",
 3161|  53.1k|                                              &props.pre_instance_functions.enumerate_instance_extension_properties);
 3162|  53.1k|            if (result == VK_ERROR_OUT_OF_HOST_MEMORY) goto out;
  ------------------
  |  Branch (3162:17): [True: 0, False: 53.1k]
  ------------------
 3163|       |
 3164|  53.1k|            result = loader_parse_json_string(pre_instance, "vkEnumerateInstanceLayerProperties",
 3165|  53.1k|                                              &props.pre_instance_functions.enumerate_instance_layer_properties);
 3166|  53.1k|            if (result == VK_ERROR_OUT_OF_HOST_MEMORY) goto out;
  ------------------
  |  Branch (3166:17): [True: 0, False: 53.1k]
  ------------------
 3167|       |
 3168|  53.1k|            result = loader_parse_json_string(pre_instance, "vkEnumerateInstanceVersion",
 3169|  53.1k|                                              &props.pre_instance_functions.enumerate_instance_version);
 3170|  53.1k|            if (result == VK_ERROR_OUT_OF_HOST_MEMORY) goto out;
  ------------------
  |  Branch (3170:17): [True: 0, False: 53.1k]
  ------------------
 3171|  53.1k|        }
 3172|   112k|    }
 3173|       |
 3174|   181k|    if (loader_cJSON_GetObjectItem(layer_node, "app_keys")) {
  ------------------
  |  Branch (3174:9): [True: 1.44k, False: 179k]
  ------------------
 3175|  1.44k|        if (!props.is_override) {
  ------------------
  |  Branch (3175:13): [True: 814, False: 630]
  ------------------
 3176|    814|            loader_log(inst, VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_LAYER_BIT, 0,
 3177|    814|                       "Layer %s contains app_keys, but any app_keys can only be provided by the override meta layer. "
 3178|    814|                       "These will be ignored.",
 3179|    814|                       props.info.layerName);
 3180|    814|        }
 3181|       |
 3182|  1.44k|        result = loader_parse_json_array_of_strings(inst, layer_node, "app_keys", &props.app_key_paths);
 3183|  1.44k|        if (result == VK_ERROR_OUT_OF_HOST_MEMORY) goto out;
  ------------------
  |  Branch (3183:13): [True: 0, False: 1.44k]
  ------------------
 3184|  1.44k|    }
 3185|       |
 3186|   181k|    char *library_arch = loader_cJSON_GetStringValue(loader_cJSON_GetObjectItem(layer_node, "library_arch"));
 3187|   181k|    if (NULL != library_arch) {
  ------------------
  |  Branch (3187:9): [True: 710, False: 180k]
  ------------------
 3188|    710|        if ((strncmp(library_arch, "32", 2) == 0 && sizeof(void *) != 4) ||
  ------------------
  |  Branch (3188:14): [True: 308, False: 402]
  |  Branch (3188:53): [True: 0, Folded]
  ------------------
 3189|    402|            (strncmp(library_arch, "64", 2) == 0 && sizeof(void *) != 8)) {
  ------------------
  |  Branch (3189:14): [True: 1, False: 401]
  |  Branch (3189:53): [Folded, False: 1]
  ------------------
 3190|    308|            loader_log(inst, VULKAN_LOADER_INFO_BIT, 0,
 3191|    308|                       "The library architecture in layer %s doesn't match the current running architecture, skipping this layer",
 3192|    308|                       filename);
 3193|    308|            result = VK_ERROR_INITIALIZATION_FAILED;
 3194|    308|            goto out;
 3195|    308|        }
 3196|    710|    }
 3197|       |
 3198|   180k|    result = VK_SUCCESS;
 3199|       |
 3200|   268k|out:
 3201|       |    // Try to append the layer property
 3202|   268k|    if (VK_SUCCESS == result) {
  ------------------
  |  Branch (3202:9): [True: 180k, False: 87.8k]
  ------------------
 3203|   180k|        result = loader_append_layer_property(inst, layer_instance_list, &props);
 3204|   180k|    }
 3205|       |    // If appending fails - free all the memory allocated in it
 3206|   268k|    if (VK_SUCCESS != result) {
  ------------------
  |  Branch (3206:9): [True: 87.8k, False: 180k]
  ------------------
 3207|  87.8k|        loader_free_layer_properties(inst, &props);
 3208|  87.8k|    }
 3209|   268k|    return result;
 3210|   180k|}
is_valid_layer_json_version:
 3212|  17.7k|bool is_valid_layer_json_version(const loader_api_version *layer_json) {
 3213|       |    // Supported versions are: 1.0.0, 1.0.1, 1.1.0 - 1.1.2, and 1.2.0 - 1.2.1.
 3214|  17.7k|    if ((layer_json->major == 1 && layer_json->minor == 2 && layer_json->patch < 2) ||
  ------------------
  |  Branch (3214:10): [True: 4.94k, False: 12.7k]
  |  Branch (3214:36): [True: 142, False: 4.80k]
  |  Branch (3214:62): [True: 123, False: 19]
  ------------------
 3215|  17.5k|        (layer_json->major == 1 && layer_json->minor == 1 && layer_json->patch < 3) ||
  ------------------
  |  Branch (3215:10): [True: 4.82k, False: 12.7k]
  |  Branch (3215:36): [True: 455, False: 4.37k]
  |  Branch (3215:62): [True: 137, False: 318]
  ------------------
 3216|  17.4k|        (layer_json->major == 1 && layer_json->minor == 0 && layer_json->patch < 2)) {
  ------------------
  |  Branch (3216:10): [True: 4.68k, False: 12.7k]
  |  Branch (3216:36): [True: 3.49k, False: 1.19k]
  |  Branch (3216:62): [True: 3.44k, False: 48]
  ------------------
 3217|  3.70k|        return true;
 3218|  3.70k|    }
 3219|  14.0k|    return false;
 3220|  17.7k|}
loader_add_layer_properties:
 3232|  20.3k|                                     bool is_implicit, char *filename) {
 3233|       |    // The following Fields in layer manifest file that are required:
 3234|       |    //   - "file_format_version"
 3235|       |    //   - If more than one "layer" object are used, then the "layers" array is
 3236|       |    //     required
 3237|  20.3k|    VkResult result = VK_ERROR_INITIALIZATION_FAILED;
 3238|       |    // Make sure sure the top level json value is an object
 3239|  20.3k|    if (!json || json->type != cJSON_Object) {
  ------------------
  |  |  103|  20.3k|#define cJSON_Object (1 << 6)
  ------------------
  |  Branch (3239:9): [True: 0, False: 20.3k]
  |  Branch (3239:18): [True: 2.26k, False: 18.0k]
  ------------------
 3240|  2.26k|        goto out;
 3241|  2.26k|    }
 3242|  18.0k|    char *file_vers = loader_cJSON_GetStringValue(loader_cJSON_GetObjectItem(json, "file_format_version"));
 3243|  18.0k|    if (NULL == file_vers) {
  ------------------
  |  Branch (3243:9): [True: 391, False: 17.7k]
  ------------------
 3244|    391|        loader_log(inst, VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_LAYER_BIT, 0,
 3245|    391|                   "loader_add_layer_properties: Manifest %s missing required field file_format_version", filename);
 3246|    391|        goto out;
 3247|    391|    }
 3248|       |
 3249|  17.7k|    loader_log(inst, VULKAN_LOADER_INFO_BIT, 0, "Found manifest file %s (file version %s)", filename, file_vers);
 3250|       |    // Get the major/minor/and patch as integers for easier comparison
 3251|  17.7k|    loader_api_version json_version = loader_make_full_version(loader_parse_version_string(file_vers));
 3252|       |
 3253|  17.7k|    if (!is_valid_layer_json_version(&json_version)) {
  ------------------
  |  Branch (3253:9): [True: 14.0k, False: 3.70k]
  ------------------
 3254|  14.0k|        loader_log(inst, VULKAN_LOADER_INFO_BIT | VULKAN_LOADER_LAYER_BIT, 0,
 3255|  14.0k|                   "loader_add_layer_properties: %s has unknown layer manifest file version %d.%d.%d.  May cause errors.", filename,
 3256|  14.0k|                   json_version.major, json_version.minor, json_version.patch);
 3257|  14.0k|    }
 3258|       |
 3259|       |    // If "layers" is present, read in the array of layer objects
 3260|  17.7k|    cJSON *layers_node = loader_cJSON_GetObjectItem(json, "layers");
 3261|  17.7k|    if (layers_node != NULL) {
  ------------------
  |  Branch (3261:9): [True: 15.3k, False: 2.36k]
  ------------------
 3262|       |        // Supported versions started in 1.0.1, so anything newer
 3263|  15.3k|        if (!loader_check_version_meets_required(loader_combine_version(1, 0, 1), json_version)) {
  ------------------
  |  Branch (3263:13): [True: 7.16k, False: 8.17k]
  ------------------
 3264|  7.16k|            loader_log(inst, VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_LAYER_BIT, 0,
 3265|  7.16k|                       "loader_add_layer_properties: \'layers\' tag not supported until file version 1.0.1, but %s is reporting "
 3266|  7.16k|                       "version %s",
 3267|  7.16k|                       filename, file_vers);
 3268|  7.16k|        }
 3269|  15.3k|        cJSON *layer_node = NULL;
 3270|   271k|        cJSON_ArrayForEach(layer_node, layers_node) {
  ------------------
  |  |  213|   282k|    for (element = (array != NULL) ? (array)->child : NULL; element != NULL; element = element->next)
  |  |  ------------------
  |  |  |  Branch (213:20): [True: 15.3k, False: 0]
  |  |  |  Branch (213:61): [True: 271k, False: 11.6k]
  |  |  ------------------
  ------------------
 3271|   271k|            if (layer_node->type != cJSON_Object) {
  ------------------
  |  |  103|   271k|#define cJSON_Object (1 << 6)
  ------------------
  |  Branch (3271:17): [True: 3.67k, False: 267k]
  ------------------
 3272|  3.67k|                loader_log(
 3273|  3.67k|                    inst, VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_LAYER_BIT, 0,
 3274|  3.67k|                    "loader_add_layer_properties: Array element in \"layers\" field in manifest JSON file %s is not an object.  "
 3275|  3.67k|                    "Skipping this file",
 3276|  3.67k|                    filename);
 3277|  3.67k|                goto out;
 3278|  3.67k|            }
 3279|   267k|            result = loader_read_layer_json(inst, layer_instance_list, layer_node, json_version, is_implicit, filename);
 3280|   267k|        }
 3281|  15.3k|    } else {
 3282|       |        // Otherwise, try to read in individual layers
 3283|  2.36k|        cJSON *layer_node = loader_cJSON_GetObjectItem(json, "layer");
 3284|  2.36k|        if (layer_node == NULL) {
  ------------------
  |  Branch (3284:13): [True: 1.94k, False: 425]
  ------------------
 3285|       |            // Don't warn if this happens to be an ICD manifest
 3286|  1.94k|            if (loader_cJSON_GetObjectItem(json, "ICD") == NULL) {
  ------------------
  |  Branch (3286:17): [True: 1.94k, False: 3]
  ------------------
 3287|  1.94k|                loader_log(
 3288|  1.94k|                    inst, VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_LAYER_BIT, 0,
 3289|  1.94k|                    "loader_add_layer_properties: Can not find 'layer' object in manifest JSON file %s.  Skipping this file.",
 3290|  1.94k|                    filename);
 3291|  1.94k|            }
 3292|  1.94k|            goto out;
 3293|  1.94k|        }
 3294|       |        // Loop through all "layer" objects in the file to get a count of them
 3295|       |        // first.
 3296|    425|        uint16_t layer_count = 0;
 3297|    425|        cJSON *tempNode = layer_node;
 3298|  1.16k|        do {
 3299|  1.16k|            tempNode = tempNode->next;
 3300|  1.16k|            layer_count++;
 3301|  1.16k|        } while (tempNode != NULL);
  ------------------
  |  Branch (3301:18): [True: 743, False: 425]
  ------------------
 3302|       |
 3303|       |        // Throw a warning if we encounter multiple "layer" objects in file
 3304|       |        // versions newer than 1.0.0.  Having multiple objects with the same
 3305|       |        // name at the same level is actually a JSON standard violation.
 3306|    425|        if (layer_count > 1 && loader_check_version_meets_required(loader_combine_version(1, 0, 1), json_version)) {
  ------------------
  |  Branch (3306:13): [True: 45, False: 380]
  |  Branch (3306:32): [True: 26, False: 19]
  ------------------
 3307|     26|            loader_log(inst, VULKAN_LOADER_ERROR_BIT | VULKAN_LOADER_LAYER_BIT, 0,
 3308|     26|                       "loader_add_layer_properties: Multiple 'layer' nodes are deprecated starting in file version \"1.0.1\".  "
 3309|     26|                       "Please use 'layers' : [] array instead in %s.",
 3310|     26|                       filename);
 3311|    399|        } else {
 3312|  1.11k|            do {
 3313|  1.11k|                result = loader_read_layer_json(inst, layer_instance_list, layer_node, json_version, is_implicit, filename);
 3314|  1.11k|                layer_node = layer_node->next;
 3315|  1.11k|            } while (layer_node != NULL);
  ------------------
  |  Branch (3315:22): [True: 717, False: 399]
  ------------------
 3316|    399|        }
 3317|    425|    }
 3318|       |
 3319|  20.3k|out:
 3320|       |
 3321|  20.3k|    return result;
 3322|  17.7k|}
copy_data_file_info:
 3326|   203k|                             size_t relative_path_size, struct loader_string_list *search_paths) {
 3327|   203k|    if (NULL != cur_path) {
  ------------------
  |  Branch (3327:9): [True: 203k, False: 0]
  ------------------
 3328|   203k|        uint32_t start = 0;
 3329|   203k|        uint32_t stop = 0;
 3330|       |
 3331|   432k|        while (cur_path[start] != '\0') {
  ------------------
  |  Branch (3331:16): [True: 229k, False: 203k]
  ------------------
 3332|   286k|            while (cur_path[start] == PATH_SEPARATOR && cur_path[start] != '\0') {
  ------------------
  |  |  154|   572k|#define PATH_SEPARATOR ':'
  ------------------
  |  Branch (3332:20): [True: 56.8k, False: 229k]
  |  Branch (3332:57): [True: 56.8k, False: 0]
  ------------------
 3333|  56.8k|                start++;
 3334|  56.8k|            }
 3335|   229k|            stop = start;
 3336|   150M|            while (cur_path[stop] != PATH_SEPARATOR && cur_path[stop] != '\0') {
  ------------------
  |  |  154|   300M|#define PATH_SEPARATOR ':'
  ------------------
  |  Branch (3336:20): [True: 150M, False: 37.5k]
  |  Branch (3336:56): [True: 149M, False: 191k]
  ------------------
 3337|   149M|                stop++;
 3338|   149M|            }
 3339|   229k|            const size_t s = stop - start;
 3340|   229k|            if (s) {
  ------------------
  |  Branch (3340:17): [True: 228k, False: 455]
  ------------------
 3341|       |                // space enough for base path, relative path, path separator, and null terminator
 3342|   228k|                size_t new_str_len = s + relative_path_size + 2;
 3343|       |
 3344|   228k|                char *new_str = loader_instance_heap_calloc(inst, new_str_len, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
 3345|   228k|                if (NULL == new_str) {
  ------------------
  |  Branch (3345:21): [True: 0, False: 228k]
  ------------------
 3346|      0|                    return VK_ERROR_OUT_OF_HOST_MEMORY;
 3347|      0|                }
 3348|   228k|                memcpy(new_str, &cur_path[start], s);
 3349|   228k|                new_str[s] = '\0';
 3350|       |
 3351|       |                // If this is a specific JSON file, just add it and don't add any
 3352|       |                // relative path or directory symbol to it.
 3353|   228k|                if (!is_json(new_str, s)) {
  ------------------
  |  Branch (3353:21): [True: 221k, False: 6.89k]
  ------------------
 3354|       |                    // Add the relative directory if present.
 3355|   221k|                    if (relative_path_size > 0) {
  ------------------
  |  Branch (3355:25): [True: 108k, False: 112k]
  ------------------
 3356|   108k|                        char *rel_start = new_str + s;
 3357|       |
 3358|       |                        // If last symbol written was not a directory symbol, add it.
 3359|   108k|                        if (*(rel_start - 1) != DIRECTORY_SYMBOL) {
  ------------------
  |  |  155|   108k|#define DIRECTORY_SYMBOL '/'
  ------------------
  |  Branch (3359:29): [True: 108k, False: 0]
  ------------------
 3360|   108k|                            *rel_start++ = DIRECTORY_SYMBOL;
  ------------------
  |  |  155|   108k|#define DIRECTORY_SYMBOL '/'
  ------------------
 3361|   108k|                        }
 3362|   108k|                        memcpy(rel_start, relative_path, relative_path_size);
 3363|   108k|                        rel_start[relative_path_size] = '\0';
 3364|   108k|                    }
 3365|   221k|                }
 3366|       |
 3367|   228k|                VkResult res = append_str_to_string_list_if_unique(inst, search_paths, new_str);
 3368|   228k|                if (VK_SUCCESS != res) {
  ------------------
  |  Branch (3368:21): [True: 0, False: 228k]
  ------------------
 3369|      0|                    return res;
 3370|      0|                }
 3371|   228k|                start = stop;
 3372|   228k|            }
 3373|   229k|        }
 3374|   203k|    }
 3375|   203k|    return VK_SUCCESS;
 3376|   203k|}
add_if_manifest_file:
 3379|   110k|VkResult add_if_manifest_file(const struct loader_instance *inst, const char *file_name, struct loader_string_list *out_files) {
 3380|   110k|    assert(NULL != file_name && "add_if_manifest_file: Received NULL pointer for file_name");
 3381|   110k|    assert(NULL != out_files && "add_if_manifest_file: Received NULL pointer for out_files");
 3382|       |
 3383|       |    // Look for files ending with ".json" suffix
 3384|   110k|    size_t name_len = strlen(file_name);
 3385|   110k|    if (!is_json(file_name, name_len)) {
  ------------------
  |  Branch (3385:9): [True: 29.7k, False: 81.0k]
  ------------------
 3386|       |        // Use incomplete to indicate invalid name, but to keep going.
 3387|  29.7k|        return VK_INCOMPLETE;
 3388|  29.7k|    }
 3389|       |
 3390|  81.0k|    return copy_str_to_string_list(inst, out_files, file_name, name_len);
 3391|   110k|}
add_data_files:
 3412|  16.3k|                        struct loader_string_list *out_files) {
 3413|  16.3k|    VkResult vk_result = VK_SUCCESS;
 3414|  16.3k|    char full_path[2048];
 3415|  16.3k|#if !defined(_WIN32)
 3416|  16.3k|    char temp_path[2048];
 3417|  16.3k|#endif
 3418|       |
 3419|   146k|    for (size_t i = 0; i < search_paths->count; i++) {
  ------------------
  |  Branch (3419:24): [True: 130k, False: 16.3k]
  ------------------
 3420|       |        // Now, parse the paths
 3421|   130k|        char *next_file = search_paths->list[i];
 3422|   260k|        while (NULL != next_file && *next_file != '\0') {
  ------------------
  |  Branch (3422:16): [True: 260k, False: 0]
  |  Branch (3422:37): [True: 130k, False: 130k]
  ------------------
 3423|   130k|            char *name = NULL;
 3424|   130k|            char *cur_file = next_file;
 3425|   130k|            next_file = loader_get_next_path(cur_file);
 3426|       |
 3427|       |            // Is this a JSON file, then try to open it.
 3428|   130k|            size_t len = strlen(cur_file);
 3429|   130k|            if (is_json(cur_file, len)) {
  ------------------
  |  Branch (3429:17): [True: 3.28k, False: 127k]
  ------------------
 3430|       |#if defined(_WIN32)
 3431|       |                name = cur_file;
 3432|       |#elif COMMON_UNIX_PLATFORMS
 3433|       |                // Only Linux has relative paths, make a copy of location so it isn't modified
 3434|  3.28k|                size_t str_len;
 3435|  3.28k|                if (NULL != next_file) {
  ------------------
  |  Branch (3435:21): [True: 3.28k, False: 0]
  ------------------
 3436|  3.28k|                    str_len = next_file - cur_file + 1;
 3437|  3.28k|                } else {
 3438|      0|                    str_len = strlen(cur_file) + 1;
 3439|      0|                }
 3440|  3.28k|                if (str_len > sizeof(temp_path)) {
  ------------------
  |  Branch (3440:21): [True: 146, False: 3.13k]
  ------------------
 3441|    146|                    loader_log(inst, VULKAN_LOADER_DEBUG_BIT, 0, "add_data_files: Path to %s too long", cur_file);
 3442|    146|                    continue;
 3443|    146|                }
 3444|  3.13k|                strncpy(temp_path, cur_file, str_len);
 3445|  3.13k|                name = temp_path;
 3446|       |#else
 3447|       |#warning add_data_files must define relative path copy for this platform
 3448|       |#endif
 3449|  3.13k|                loader_get_fullpath(cur_file, name, sizeof(full_path), full_path);
 3450|  3.13k|                name = full_path;
 3451|       |
 3452|  3.13k|                VkResult local_res;
 3453|  3.13k|                local_res = add_if_manifest_file(inst, name, out_files);
 3454|       |
 3455|       |                // Incomplete means this was not a valid data file.
 3456|  3.13k|                if (local_res == VK_INCOMPLETE) {
  ------------------
  |  Branch (3456:21): [True: 0, False: 3.13k]
  ------------------
 3457|      0|                    continue;
 3458|      0|                }
 3459|  3.13k|                if (local_res != VK_SUCCESS) {
  ------------------
  |  Branch (3459:21): [True: 0, False: 3.13k]
  ------------------
 3460|      0|                    vk_result = local_res;
 3461|      0|                    break;
 3462|      0|                }
 3463|   127k|            } else {  // Otherwise, treat it as a directory
 3464|   127k|                DIR *dir_stream = loader_opendir(inst, cur_file);
 3465|   127k|                if (NULL == dir_stream) {
  ------------------
  |  Branch (3465:21): [True: 117k, False: 9.33k]
  ------------------
 3466|   117k|                    continue;
 3467|   117k|                }
 3468|   116k|                while (1) {
  ------------------
  |  Branch (3468:24): [True: 116k, Folded]
  ------------------
 3469|   116k|                    errno = 0;
 3470|       |                    // NOLINTNEXTLINE(concurrency-mt-unsafe) - readdir is safe here since each thread uses its own dir_stream
 3471|   116k|                    struct dirent *dir_entry = readdir(dir_stream);
 3472|   116k|#if !defined(WIN32)  // Windows doesn't use readdir, don't check errors on functions which aren't called
 3473|   116k|                    if (errno != 0) {
  ------------------
  |  Branch (3473:25): [True: 0, False: 116k]
  ------------------
 3474|       |                        // NOLINTNEXTLINE(concurrency-mt-unsafe) - strerror's static buffer is used immediately and not retained
 3475|      0|                        loader_log(inst, VULKAN_LOADER_ERROR_BIT, 0, "readdir failed with %d: %s", errno, strerror(errno));
 3476|      0|                        break;
 3477|      0|                    }
 3478|   116k|#endif
 3479|   116k|                    if (NULL == dir_entry) {
  ------------------
  |  Branch (3479:25): [True: 9.33k, False: 107k]
  ------------------
 3480|  9.33k|                        break;
 3481|  9.33k|                    }
 3482|       |
 3483|   107k|                    name = &(dir_entry->d_name[0]);
 3484|       |                    // 'name' is the bare filename, 'cur_file' is the directory being scanned; the substring "file" in
 3485|       |                    // cur_file just confuses the naming heuristic below.
 3486|       |                    // NOLINTNEXTLINE(readability-suspicious-call-argument) - arguments are correctly ordered, not swapped
 3487|   107k|                    loader_get_fullpath(name, cur_file, sizeof(full_path), full_path);
 3488|   107k|                    name = full_path;
 3489|       |
 3490|   107k|                    VkResult local_res;
 3491|   107k|                    local_res = add_if_manifest_file(inst, name, out_files);
 3492|       |
 3493|       |                    // Incomplete means this was not a valid data file.
 3494|   107k|                    if (local_res == VK_INCOMPLETE) {
  ------------------
  |  Branch (3494:25): [True: 29.7k, False: 77.9k]
  ------------------
 3495|  29.7k|                        continue;
 3496|  29.7k|                    }
 3497|  77.9k|                    if (local_res != VK_SUCCESS) {
  ------------------
  |  Branch (3497:25): [True: 0, False: 77.9k]
  ------------------
 3498|      0|                        vk_result = local_res;
 3499|      0|                        break;
 3500|      0|                    }
 3501|  77.9k|                }
 3502|  9.33k|                loader_closedir(inst, dir_stream);
 3503|  9.33k|                if (vk_result != VK_SUCCESS) {
  ------------------
  |  Branch (3503:21): [True: 0, False: 9.33k]
  ------------------
 3504|      0|                    goto out;
 3505|      0|                }
 3506|  9.33k|            }
 3507|   130k|        }
 3508|   130k|    }
 3509|       |
 3510|  16.3k|out:
 3511|       |
 3512|  16.3k|    return vk_result;
 3513|  16.3k|}
read_data_files_in_search_paths:
 3519|  16.3k|                                         struct loader_string_list *out_files) {
 3520|  16.3k|    VkResult vk_result = VK_SUCCESS;
 3521|  16.3k|    char *override_env = NULL;
 3522|  16.3k|    char *additional_env = NULL;
 3523|  16.3k|    struct loader_string_list search_paths = {0};
 3524|       |
 3525|  16.3k|#if COMMON_UNIX_PLATFORMS
 3526|  16.3k|    const char *relative_location = NULL;  // Only used on unix platforms
 3527|  16.3k|    size_t rel_size = 0;                   // unused in windows, dont declare so no compiler warnings are generated
 3528|  16.3k|#endif
 3529|       |
 3530|       |#if defined(__APPLE__)
 3531|       |    char *bundle_path = NULL;
 3532|       |    char *search_only_in_bundle_env_var = loader_secure_getenv(VK_LOADER_SEARCH_ONLY_IN_BUNDLE_ENV_VAR, inst);
 3533|       |#endif
 3534|       |
 3535|       |#if defined(_WIN32)
 3536|       |    char *package_path = NULL;
 3537|       |#elif COMMON_UNIX_PLATFORMS
 3538|       |    // Determine how much space is needed to generate the full search path
 3539|       |    // for the current manifest files.
 3540|  16.3k|    char *xdg_config_home = loader_secure_getenv("XDG_CONFIG_HOME", inst);
 3541|  16.3k|    char *xdg_config_dirs = loader_secure_getenv("XDG_CONFIG_DIRS", inst);
 3542|       |
 3543|  16.3k|#if !defined(__Fuchsia__) && !defined(__QNX__)
 3544|  16.3k|    if (NULL == xdg_config_dirs || '\0' == xdg_config_dirs[0]) {
  ------------------
  |  Branch (3544:9): [True: 16.3k, False: 0]
  |  Branch (3544:36): [True: 0, False: 0]
  ------------------
 3545|  16.3k|        xdg_config_dirs = FALLBACK_CONFIG_DIRS;
 3546|  16.3k|    }
 3547|  16.3k|#endif
 3548|       |
 3549|  16.3k|    char *xdg_data_home = loader_secure_getenv("XDG_DATA_HOME", inst);
 3550|  16.3k|    char *xdg_data_dirs = loader_secure_getenv("XDG_DATA_DIRS", inst);
 3551|       |
 3552|  16.3k|#if !defined(__Fuchsia__) && !defined(__QNX__)
 3553|  16.3k|    if (NULL == xdg_data_dirs || '\0' == xdg_data_dirs[0]) {
  ------------------
  |  Branch (3553:9): [True: 16.3k, False: 0]
  |  Branch (3553:34): [True: 0, False: 0]
  ------------------
 3554|  16.3k|        xdg_data_dirs = FALLBACK_DATA_DIRS;
 3555|  16.3k|    }
 3556|  16.3k|#endif
 3557|       |
 3558|  16.3k|    char *home = NULL;
 3559|  16.3k|    char *default_data_home = NULL;
 3560|  16.3k|    char *default_config_home = NULL;
 3561|  16.3k|    char *home_data_dir = NULL;
 3562|  16.3k|    char *home_config_dir = NULL;
 3563|       |
 3564|       |    // Only use HOME if XDG_DATA_HOME is not present on the system
 3565|  16.3k|    home = loader_secure_getenv("HOME", inst);
 3566|  16.3k|    if (home != NULL) {
  ------------------
  |  Branch (3566:9): [True: 16.3k, False: 0]
  ------------------
 3567|  16.3k|        if (NULL == xdg_config_home || '\0' == xdg_config_home[0]) {
  ------------------
  |  Branch (3567:13): [True: 16.3k, False: 0]
  |  Branch (3567:40): [True: 0, False: 0]
  ------------------
 3568|  16.3k|            const char config_suffix[] = "/.config";
 3569|  16.3k|            size_t default_config_home_len = strlen(home) + sizeof(config_suffix) + 1;
 3570|  16.3k|            default_config_home = loader_instance_heap_calloc(inst, default_config_home_len, VK_SYSTEM_ALLOCATION_SCOPE_COMMAND);
 3571|  16.3k|            if (default_config_home == NULL) {
  ------------------
  |  Branch (3571:17): [True: 0, False: 16.3k]
  ------------------
 3572|      0|                vk_result = VK_ERROR_OUT_OF_HOST_MEMORY;
 3573|      0|                goto out;
 3574|      0|            }
 3575|  16.3k|            strncpy(default_config_home, home, default_config_home_len);
 3576|  16.3k|            strncat(default_config_home, config_suffix, default_config_home_len);
 3577|  16.3k|        }
 3578|  16.3k|        if (NULL == xdg_data_home || '\0' == xdg_data_home[0]) {
  ------------------
  |  Branch (3578:13): [True: 16.3k, False: 0]
  |  Branch (3578:38): [True: 0, False: 0]
  ------------------
 3579|  16.3k|            const char data_suffix[] = "/.local/share";
 3580|  16.3k|            size_t default_data_home_len = strlen(home) + sizeof(data_suffix) + 1;
 3581|  16.3k|            default_data_home = loader_instance_heap_calloc(inst, default_data_home_len, VK_SYSTEM_ALLOCATION_SCOPE_COMMAND);
 3582|  16.3k|            if (default_data_home == NULL) {
  ------------------
  |  Branch (3582:17): [True: 0, False: 16.3k]
  ------------------
 3583|      0|                vk_result = VK_ERROR_OUT_OF_HOST_MEMORY;
 3584|      0|                goto out;
 3585|      0|            }
 3586|  16.3k|            strncpy(default_data_home, home, default_data_home_len);
 3587|  16.3k|            strncat(default_data_home, data_suffix, default_data_home_len);
 3588|  16.3k|        }
 3589|  16.3k|    }
 3590|       |
 3591|  16.3k|    if (NULL != default_config_home) {
  ------------------
  |  Branch (3591:9): [True: 16.3k, False: 0]
  ------------------
 3592|  16.3k|        home_config_dir = default_config_home;
 3593|  16.3k|    } else {
 3594|      0|        home_config_dir = xdg_config_home;
 3595|      0|    }
 3596|  16.3k|    if (NULL != default_data_home) {
  ------------------
  |  Branch (3596:9): [True: 16.3k, False: 0]
  ------------------
 3597|  16.3k|        home_data_dir = default_data_home;
 3598|  16.3k|    } else {
 3599|      0|        home_data_dir = xdg_data_home;
 3600|      0|    }
 3601|       |#else
 3602|       |#warning read_data_files_in_search_paths unsupported platform
 3603|       |#endif
 3604|       |
 3605|  16.3k|    switch (manifest_type) {
 3606|    793|        case LOADER_DATA_FILE_MANIFEST_DRIVER:
  ------------------
  |  Branch (3606:9): [True: 793, False: 15.5k]
  ------------------
 3607|    793|            if (loader_settings_should_use_driver_environment_variables(inst)) {
  ------------------
  |  Branch (3607:17): [True: 793, False: 0]
  ------------------
 3608|    793|                override_env = loader_secure_getenv(VK_DRIVER_FILES_ENV_VAR, inst);
  ------------------
  |  |  113|    793|#define VK_DRIVER_FILES_ENV_VAR "VK_DRIVER_FILES"
  ------------------
 3609|    793|                if (NULL == override_env) {
  ------------------
  |  Branch (3609:21): [True: 793, False: 0]
  ------------------
 3610|       |                    // Not there, so fall back to the old name
 3611|    793|                    override_env = loader_secure_getenv(VK_ICD_FILENAMES_ENV_VAR, inst);
  ------------------
  |  |  112|    793|#define VK_ICD_FILENAMES_ENV_VAR "VK_ICD_FILENAMES"  // Deprecated in v1.3.207 loader
  ------------------
 3612|    793|                }
 3613|    793|                additional_env = loader_secure_getenv(VK_ADDITIONAL_DRIVER_FILES_ENV_VAR, inst);
  ------------------
  |  |  116|    793|#define VK_ADDITIONAL_DRIVER_FILES_ENV_VAR "VK_ADD_DRIVER_FILES"
  ------------------
 3614|    793|            }
 3615|    793|#if COMMON_UNIX_PLATFORMS
 3616|    793|            relative_location = VK_DRIVERS_INFO_RELATIVE_DIR;
  ------------------
  |  |  165|    793|#define VK_DRIVERS_INFO_RELATIVE_DIR VULKAN_DIR VULKAN_ICDCONF_DIR
  |  |  ------------------
  |  |  |  |  157|    793|#define VULKAN_DIR "vulkan/"
  |  |  ------------------
  |  |               #define VK_DRIVERS_INFO_RELATIVE_DIR VULKAN_DIR VULKAN_ICDCONF_DIR
  |  |  ------------------
  |  |  |  |  158|    793|#define VULKAN_ICDCONF_DIR "icd.d"
  |  |  ------------------
  ------------------
 3617|    793|#endif
 3618|       |#if defined(_WIN32)
 3619|       |            package_path = windows_get_app_package_manifest_path(inst);
 3620|       |#endif
 3621|    793|            break;
 3622|  7.78k|        case LOADER_DATA_FILE_MANIFEST_IMPLICIT_LAYER:
  ------------------
  |  Branch (3622:9): [True: 7.78k, False: 8.57k]
  ------------------
 3623|  7.78k|            override_env = loader_secure_getenv(VK_IMPLICIT_LAYER_PATH_ENV_VAR, inst);
  ------------------
  |  |  130|  7.78k|#define VK_IMPLICIT_LAYER_PATH_ENV_VAR "VK_IMPLICIT_LAYER_PATH"
  ------------------
 3624|  7.78k|            additional_env = loader_secure_getenv(VK_ADDITIONAL_IMPLICIT_LAYER_PATH_ENV_VAR, inst);
  ------------------
  |  |  131|  7.78k|#define VK_ADDITIONAL_IMPLICIT_LAYER_PATH_ENV_VAR "VK_ADD_IMPLICIT_LAYER_PATH"
  ------------------
 3625|  7.78k|#if COMMON_UNIX_PLATFORMS
 3626|  7.78k|            relative_location = VK_ILAYERS_INFO_RELATIVE_DIR;
  ------------------
  |  |  168|  7.78k|#define VK_ILAYERS_INFO_RELATIVE_DIR VULKAN_DIR VULKAN_ILAYERCONF_DIR
  |  |  ------------------
  |  |  |  |  157|  7.78k|#define VULKAN_DIR "vulkan/"
  |  |  ------------------
  |  |               #define VK_ILAYERS_INFO_RELATIVE_DIR VULKAN_DIR VULKAN_ILAYERCONF_DIR
  |  |  ------------------
  |  |  |  |  162|  7.78k|#define VULKAN_ILAYERCONF_DIR "implicit_layer.d"
  |  |  ------------------
  ------------------
 3627|  7.78k|#endif
 3628|       |#if defined(_WIN32)
 3629|       |            package_path = windows_get_app_package_manifest_path(inst);
 3630|       |#endif
 3631|  7.78k|            break;
 3632|  7.78k|        case LOADER_DATA_FILE_MANIFEST_EXPLICIT_LAYER:
  ------------------
  |  Branch (3632:9): [True: 7.78k, False: 8.57k]
  ------------------
 3633|  7.78k|            override_env = loader_secure_getenv(VK_EXPLICIT_LAYER_PATH_ENV_VAR, inst);
  ------------------
  |  |  114|  7.78k|#define VK_EXPLICIT_LAYER_PATH_ENV_VAR "VK_LAYER_PATH"
  ------------------
 3634|  7.78k|            additional_env = loader_secure_getenv(VK_ADDITIONAL_EXPLICIT_LAYER_PATH_ENV_VAR, inst);
  ------------------
  |  |  117|  7.78k|#define VK_ADDITIONAL_EXPLICIT_LAYER_PATH_ENV_VAR "VK_ADD_LAYER_PATH"
  ------------------
 3635|  7.78k|#if COMMON_UNIX_PLATFORMS
 3636|  7.78k|            relative_location = VK_ELAYERS_INFO_RELATIVE_DIR;
  ------------------
  |  |  167|  7.78k|#define VK_ELAYERS_INFO_RELATIVE_DIR VULKAN_DIR VULKAN_ELAYERCONF_DIR
  |  |  ------------------
  |  |  |  |  157|  7.78k|#define VULKAN_DIR "vulkan/"
  |  |  ------------------
  |  |               #define VK_ELAYERS_INFO_RELATIVE_DIR VULKAN_DIR VULKAN_ELAYERCONF_DIR
  |  |  ------------------
  |  |  |  |  161|  7.78k|#define VULKAN_ELAYERCONF_DIR "explicit_layer.d"
  |  |  ------------------
  ------------------
 3637|  7.78k|#endif
 3638|  7.78k|            break;
 3639|      0|        default:
  ------------------
  |  Branch (3639:9): [True: 0, False: 16.3k]
  ------------------
 3640|      0|            assert(false && "Shouldn't get here!");
 3641|      0|            break;
 3642|  16.3k|    }
 3643|       |
 3644|       |    // Log a message when VK_LAYER_PATH is set but the override layer paths take priority
 3645|  16.3k|    if (manifest_type == LOADER_DATA_FILE_MANIFEST_EXPLICIT_LAYER &&
  ------------------
  |  Branch (3645:9): [True: 7.78k, False: 8.57k]
  ------------------
 3646|  7.78k|        (NULL != override_env && NULL != path_overrides && path_overrides->count > 0)) {
  ------------------
  |  Branch (3646:10): [True: 0, False: 7.78k]
  |  Branch (3646:34): [True: 0, False: 0]
  |  Branch (3646:60): [True: 0, False: 0]
  ------------------
 3647|      0|        loader_log(inst, VULKAN_LOADER_INFO_BIT | VULKAN_LOADER_LAYER_BIT, 0,
 3648|      0|                   "Ignoring VK_LAYER_PATH. The Override layer is active and has override paths set, which takes priority. "
 3649|      0|                   "VK_LAYER_PATH is set to %s",
 3650|      0|                   override_env);
 3651|      0|    }
 3652|       |
 3653|       |    // Add the remaining paths to the list
 3654|  16.3k|    if (NULL != path_overrides && path_overrides->count > 0) {
  ------------------
  |  Branch (3654:9): [True: 7.78k, False: 8.57k]
  |  Branch (3654:35): [True: 807, False: 6.97k]
  ------------------
 3655|  22.2k|        for (size_t i = 0; i < path_overrides->count; i++) {
  ------------------
  |  Branch (3655:28): [True: 21.4k, False: 807]
  ------------------
 3656|  21.4k|            if (NULL != path_overrides->list[i]) {
  ------------------
  |  Branch (3656:17): [True: 21.4k, False: 0]
  ------------------
 3657|  21.4k|                if (manifest_type == LOADER_DATA_FILE_MANIFEST_EXPLICIT_LAYER) {
  ------------------
  |  Branch (3657:21): [True: 21.4k, False: 0]
  ------------------
 3658|  21.4k|                    loader_log(inst, VULKAN_LOADER_INFO_BIT | VULKAN_LOADER_LAYER_BIT, 0, "%s", path_overrides->list[i]);
 3659|  21.4k|                }
 3660|  21.4k|                vk_result = copy_data_file_info(inst, path_overrides->list[i], NULL, 0, &search_paths);
 3661|  21.4k|                if (vk_result == VK_ERROR_OUT_OF_HOST_MEMORY) {
  ------------------
  |  Branch (3661:21): [True: 0, False: 21.4k]
  ------------------
 3662|      0|                    goto out;
 3663|      0|                }
 3664|  21.4k|            }
 3665|  21.4k|        }
 3666|  15.5k|    } else if (override_env != NULL) {
  ------------------
  |  Branch (3666:16): [True: 0, False: 15.5k]
  ------------------
 3667|      0|        vk_result = copy_data_file_info(inst, override_env, NULL, 0, &search_paths);
 3668|      0|        if (vk_result == VK_ERROR_OUT_OF_HOST_MEMORY) {
  ------------------
  |  Branch (3668:13): [True: 0, False: 0]
  ------------------
 3669|      0|            goto out;
 3670|      0|        }
 3671|  15.5k|    } else {
 3672|       |        // Add any additional search paths defined in the additive environment variable
 3673|  15.5k|        if (NULL != additional_env) {
  ------------------
  |  Branch (3673:13): [True: 0, False: 15.5k]
  ------------------
 3674|      0|            vk_result = copy_data_file_info(inst, additional_env, NULL, 0, &search_paths);
 3675|      0|            if (vk_result == VK_ERROR_OUT_OF_HOST_MEMORY) {
  ------------------
  |  Branch (3675:17): [True: 0, False: 0]
  ------------------
 3676|      0|                goto out;
 3677|      0|            }
 3678|      0|        }
 3679|       |
 3680|       |#if defined(_WIN32)
 3681|       |        if (NULL != package_path) {
 3682|       |            vk_result = copy_data_file_info(inst, package_path, NULL, 0, &search_paths);
 3683|       |            if (vk_result == VK_ERROR_OUT_OF_HOST_MEMORY) {
 3684|       |                goto out;
 3685|       |            }
 3686|       |        }
 3687|       |#elif COMMON_UNIX_PLATFORMS
 3688|  15.5k|        bool search_outside_of_bundle = true;
 3689|       |
 3690|  15.5k|        rel_size = strlen(relative_location);
 3691|  15.5k|        if (rel_size > 0) {
  ------------------
  |  Branch (3691:13): [True: 15.5k, False: 0]
  ------------------
 3692|       |#if defined(__APPLE__)
 3693|       |            // Add the bundle's Resources dir to the beginning of the search path.
 3694|       |            // Looks for manifests in the bundle first, before any system directories.
 3695|       |            // This also appears to work unmodified for iOS, it finds the app bundle on the devices
 3696|       |            // file system. (RSW)
 3697|       |            CFBundleRef main_bundle = CFBundleGetMainBundle();
 3698|       |            if (NULL != main_bundle) {
 3699|       |                CFURLRef ref = CFBundleCopyResourcesDirectoryURL(main_bundle);
 3700|       |                if (NULL != ref) {
 3701|       |                    // Allocate large scratch buffer to hold the bundles path, the relative location inside the bundle, plus a path
 3702|       |                    // separator and null terminator. Since we are using a while loop, initialize length with half the intended size
 3703|       |                    size_t bundle_path_len = (MAXPATHLEN + rel_size + 2) / 2;
 3704|       |                    bool bundle_query_success = false;
 3705|       |                    uint32_t retry_count = 0;
 3706|       |                    while (!bundle_query_success && retry_count < 4) {
 3707|       |                        void *new_bundle_path = loader_instance_heap_realloc(
 3708|       |                            inst, bundle_path, bundle_path_len, bundle_path_len * 2, VK_SYSTEM_ALLOCATION_SCOPE_COMMAND);
 3709|       |                        if (NULL == new_bundle_path) {
 3710|       |                            loader_log(inst, VULKAN_LOADER_ERROR_BIT, 0,
 3711|       |                                       "read_data_files_in_search_paths: Failed to allocate space for bundle path of length %d",
 3712|       |                                       (uint32_t)bundle_path_len * 2);
 3713|       |                            vk_result = VK_ERROR_OUT_OF_HOST_MEMORY;
 3714|       |                            goto out;
 3715|       |                        }
 3716|       |                        bundle_path = new_bundle_path;
 3717|       |                        bundle_path_len = bundle_path_len * 2;
 3718|       |                        memset(bundle_path, 0, bundle_path_len);
 3719|       |                        bundle_query_success = CFURLGetFileSystemRepresentation(ref, TRUE, (UInt8 *)bundle_path, bundle_path_len);
 3720|       |                        retry_count++;
 3721|       |                    }
 3722|       |
 3723|       |                    if (bundle_query_success) {
 3724|       |                        size_t cur_bundle_len = strlen(bundle_path);
 3725|       |
 3726|       |                        if (cur_bundle_len + rel_size + 2 > bundle_path_len) {
 3727|       |                            loader_log(inst, VULKAN_LOADER_ERROR_BIT, 0,
 3728|       |                                       "read_data_files_in_search_paths: bundle_path %s of size %d does not have enough space to "
 3729|       |                                       "append relative_path",
 3730|       |                                       bundle_path, (uint32_t)bundle_path_len);
 3731|       |                            vk_result = VK_ERROR_INITIALIZATION_FAILED;
 3732|       |                            goto out;
 3733|       |                        }
 3734|       |                        bundle_path[cur_bundle_len] = DIRECTORY_SYMBOL;
 3735|       |                        cur_bundle_len++;
 3736|       |                        memcpy(bundle_path + cur_bundle_len, relative_location, rel_size);
 3737|       |                        cur_bundle_len += rel_size;
 3738|       |                        bundle_path[cur_bundle_len] = '\0';
 3739|       |
 3740|       |                        vk_result = copy_data_file_info(inst, bundle_path, NULL, 0, &search_paths);
 3741|       |                        if (vk_result == VK_ERROR_OUT_OF_HOST_MEMORY) {
 3742|       |                            goto out;
 3743|       |                        }
 3744|       |                    }
 3745|       |                    CFRelease(ref);
 3746|       |                }
 3747|       |            }
 3748|       |
 3749|       |            if (NULL != search_only_in_bundle_env_var) {
 3750|       |                search_outside_of_bundle = false;
 3751|       |            }
 3752|       |#endif  // __APPLE__
 3753|  15.5k|            if (search_outside_of_bundle) {
  ------------------
  |  Branch (3753:17): [True: 15.5k, False: 0]
  ------------------
 3754|       |                // Only add the home folders if not NULL
 3755|  15.5k|                if (NULL != home_config_dir) {
  ------------------
  |  Branch (3755:21): [True: 15.5k, False: 0]
  ------------------
 3756|  15.5k|                    vk_result = copy_data_file_info(inst, home_config_dir, relative_location, rel_size, &search_paths);
 3757|  15.5k|                    if (VK_SUCCESS != vk_result) {
  ------------------
  |  Branch (3757:25): [True: 0, False: 15.5k]
  ------------------
 3758|      0|                        goto out;
 3759|      0|                    }
 3760|  15.5k|                }
 3761|  15.5k|                vk_result = copy_data_file_info(inst, xdg_config_dirs, relative_location, rel_size, &search_paths);
 3762|  15.5k|                if (VK_SUCCESS != vk_result) {
  ------------------
  |  Branch (3762:21): [True: 0, False: 15.5k]
  ------------------
 3763|      0|                    goto out;
 3764|      0|                }
 3765|  15.5k|                vk_result = copy_data_file_info(inst, SYSCONFDIR, relative_location, rel_size, &search_paths);
 3766|  15.5k|                if (VK_SUCCESS != vk_result) {
  ------------------
  |  Branch (3766:21): [True: 0, False: 15.5k]
  ------------------
 3767|      0|                    goto out;
 3768|      0|                }
 3769|  15.5k|#if defined(EXTRASYSCONFDIR)
 3770|  15.5k|                vk_result = copy_data_file_info(inst, EXTRASYSCONFDIR, relative_location, rel_size, &search_paths);
 3771|  15.5k|                if (VK_SUCCESS != vk_result) {
  ------------------
  |  Branch (3771:21): [True: 0, False: 15.5k]
  ------------------
 3772|      0|                    goto out;
 3773|      0|                }
 3774|  15.5k|#endif
 3775|       |
 3776|       |                // Only add the home folders if not NULL
 3777|  15.5k|                if (NULL != home_data_dir) {
  ------------------
  |  Branch (3777:21): [True: 15.5k, False: 0]
  ------------------
 3778|  15.5k|                    vk_result = copy_data_file_info(inst, home_data_dir, relative_location, rel_size, &search_paths);
 3779|  15.5k|                    if (VK_SUCCESS != vk_result) {
  ------------------
  |  Branch (3779:25): [True: 0, False: 15.5k]
  ------------------
 3780|      0|                        goto out;
 3781|      0|                    }
 3782|  15.5k|                }
 3783|  15.5k|                vk_result = copy_data_file_info(inst, xdg_data_dirs, relative_location, rel_size, &search_paths);
 3784|  15.5k|                if (VK_SUCCESS != vk_result) {
  ------------------
  |  Branch (3784:21): [True: 0, False: 15.5k]
  ------------------
 3785|      0|                    goto out;
 3786|      0|                }
 3787|  15.5k|            }
 3788|  15.5k|        }
 3789|       |#else
 3790|       |#warning read_data_files_in_search_paths unsupported platform
 3791|       |#endif
 3792|  15.5k|    }
 3793|       |
 3794|       |    // Print out the paths being searched if debugging is enabled
 3795|  16.3k|    uint32_t log_flags = 0;
 3796|       |
 3797|  16.3k|    if (manifest_type == LOADER_DATA_FILE_MANIFEST_DRIVER) {
  ------------------
  |  Branch (3797:9): [True: 793, False: 15.5k]
  ------------------
 3798|    793|        log_flags = VULKAN_LOADER_DRIVER_BIT;
 3799|    793|        loader_log(inst, VULKAN_LOADER_DRIVER_BIT, 0, "Searching for driver manifest files");
 3800|  15.5k|    } else {
 3801|  15.5k|        log_flags = VULKAN_LOADER_LAYER_BIT;
 3802|  15.5k|        loader_log(inst, VULKAN_LOADER_LAYER_BIT, 0, "Searching for %s layer manifest files",
 3803|  15.5k|                   manifest_type == LOADER_DATA_FILE_MANIFEST_EXPLICIT_LAYER ? "explicit" : "implicit");
  ------------------
  |  Branch (3803:20): [True: 7.78k, False: 7.78k]
  ------------------
 3804|  15.5k|    }
 3805|  16.3k|    loader_log(inst, log_flags, 0, "   In following locations:");
 3806|       |
 3807|   146k|    for (size_t i = 0; i < search_paths.count; i++) {
  ------------------
  |  Branch (3807:24): [True: 130k, False: 16.3k]
  ------------------
 3808|   130k|        loader_log(inst, log_flags, 0, "      %s", search_paths.list[i]);
 3809|   130k|    }
 3810|       |
 3811|       |    // Now, parse the paths and add any manifest files found in them.
 3812|  16.3k|    vk_result = add_data_files(inst, &search_paths, out_files);
 3813|       |
 3814|  16.3k|    if (log_flags != 0 && out_files->count > 0) {
  ------------------
  |  Branch (3814:9): [True: 16.3k, False: 0]
  |  Branch (3814:27): [True: 8.95k, False: 7.39k]
  ------------------
 3815|  8.95k|        loader_log(inst, log_flags, 0, "   Found the following files:");
 3816|  90.0k|        for (uint32_t cur_file = 0; cur_file < out_files->count; ++cur_file) {
  ------------------
  |  Branch (3816:37): [True: 81.0k, False: 8.95k]
  ------------------
 3817|  81.0k|            loader_log(inst, log_flags, 0, "      %s", out_files->list[cur_file]);
 3818|  81.0k|        }
 3819|  8.95k|    } else {
 3820|  7.39k|        loader_log(inst, log_flags, 0, "   Found no files");
 3821|  7.39k|    }
 3822|       |
 3823|  16.3k|    if ((NULL != path_overrides && path_overrides->count > 0) || NULL != override_env) {
  ------------------
  |  Branch (3823:10): [True: 7.78k, False: 8.57k]
  |  Branch (3823:36): [True: 807, False: 6.97k]
  |  Branch (3823:66): [True: 0, False: 15.5k]
  ------------------
 3824|    807|        *override_active = true;
 3825|  15.5k|    } else {
 3826|  15.5k|        *override_active = false;
 3827|  15.5k|    }
 3828|       |
 3829|  16.3k|out:
 3830|       |
 3831|  16.3k|    loader_free_getenv(additional_env, inst);
 3832|  16.3k|    loader_free_getenv(override_env, inst);
 3833|       |#if defined(_WIN32)
 3834|       |    loader_instance_heap_free(inst, package_path);
 3835|       |#elif COMMON_UNIX_PLATFORMS
 3836|       |#if defined(__APPLE__)
 3837|       |    loader_instance_heap_free(inst, bundle_path);
 3838|       |    loader_free_getenv(search_only_in_bundle_env_var, inst);
 3839|       |#endif
 3840|  16.3k|    loader_free_getenv(xdg_config_home, inst);
 3841|  16.3k|    loader_free_getenv(xdg_config_dirs, inst);
 3842|  16.3k|    loader_free_getenv(xdg_data_home, inst);
 3843|  16.3k|    loader_free_getenv(xdg_data_dirs, inst);
 3844|  16.3k|    loader_free_getenv(xdg_data_home, inst);
 3845|  16.3k|    loader_free_getenv(home, inst);
 3846|  16.3k|    loader_instance_heap_free(inst, default_data_home);
 3847|  16.3k|    loader_instance_heap_free(inst, default_config_home);
 3848|       |#else
 3849|       |#warning read_data_files_in_search_paths unsupported platform
 3850|       |#endif
 3851|       |
 3852|  16.3k|    free_string_list(inst, &search_paths);
 3853|       |
 3854|  16.3k|    return vk_result;
 3855|  16.3k|}
loader_get_data_files:
 3881|  16.3k|                               const struct loader_string_list *path_overrides, struct loader_string_list *out_files) {
 3882|  16.3k|    VkResult res = VK_SUCCESS;
 3883|  16.3k|    bool override_active = false;
 3884|       |
 3885|       |    // Free and init the out_files information so there's no false data left from uninitialized variables.
 3886|  16.3k|    free_string_list(inst, out_files);
 3887|       |
 3888|  16.3k|    res = read_data_files_in_search_paths(inst, manifest_type, path_overrides, &override_active, out_files);
 3889|  16.3k|    if (VK_SUCCESS != res) {
  ------------------
  |  Branch (3889:9): [True: 0, False: 16.3k]
  ------------------
 3890|      0|        goto out;
 3891|      0|    }
 3892|       |
 3893|       |#if defined(_WIN32)
 3894|       |    // Read the registry if the override wasn't active.
 3895|       |    if (!override_active) {
 3896|       |        bool warn_if_not_present = false;
 3897|       |        char *registry_location = NULL;
 3898|       |
 3899|       |        switch (manifest_type) {
 3900|       |            default:
 3901|       |                goto out;
 3902|       |            case LOADER_DATA_FILE_MANIFEST_DRIVER:
 3903|       |                warn_if_not_present = true;
 3904|       |                registry_location = VK_DRIVERS_INFO_REGISTRY_LOC;
 3905|       |                break;
 3906|       |            case LOADER_DATA_FILE_MANIFEST_IMPLICIT_LAYER:
 3907|       |                registry_location = VK_ILAYERS_INFO_REGISTRY_LOC;
 3908|       |                break;
 3909|       |            case LOADER_DATA_FILE_MANIFEST_EXPLICIT_LAYER:
 3910|       |                warn_if_not_present = true;
 3911|       |                registry_location = VK_ELAYERS_INFO_REGISTRY_LOC;
 3912|       |                break;
 3913|       |        }
 3914|       |        VkResult tmp_res =
 3915|       |            windows_read_data_files_in_registry(inst, manifest_type, warn_if_not_present, registry_location, out_files);
 3916|       |        // Only return an error if there was an error this time, and no manifest files from before.
 3917|       |        if (VK_SUCCESS != tmp_res && out_files->count == 0) {
 3918|       |            res = tmp_res;
 3919|       |            goto out;
 3920|       |        }
 3921|       |    }
 3922|       |#endif
 3923|       |
 3924|  16.3k|out:
 3925|       |
 3926|  16.3k|    if (VK_SUCCESS != res) {
  ------------------
  |  Branch (3926:9): [True: 0, False: 16.3k]
  ------------------
 3927|      0|        free_string_list(inst, out_files);
 3928|      0|    }
 3929|       |
 3930|  16.3k|    return res;
 3931|  16.3k|}
loader_parse_icd_manifest:
 3941|    793|                                   bool *skipped_portability_drivers) {
 3942|    793|    VkResult res = VK_SUCCESS;
 3943|    793|    cJSON *icd_manifest_json = NULL;
 3944|       |
 3945|    793|    if (file_str == NULL) {
  ------------------
  |  Branch (3945:9): [True: 0, False: 793]
  ------------------
 3946|      0|        goto out;
 3947|      0|    }
 3948|       |
 3949|    793|    res = loader_get_json(inst, file_str, &icd_manifest_json);
 3950|    793|    if (res == VK_ERROR_OUT_OF_HOST_MEMORY) {
  ------------------
  |  Branch (3950:9): [True: 0, False: 793]
  ------------------
 3951|      0|        goto out;
 3952|      0|    }
 3953|    793|    if (res != VK_SUCCESS || NULL == icd_manifest_json) {
  ------------------
  |  Branch (3953:9): [True: 0, False: 793]
  |  Branch (3953:30): [True: 0, False: 793]
  ------------------
 3954|      0|        res = VK_ERROR_INCOMPATIBLE_DRIVER;
 3955|      0|        goto out;
 3956|      0|    }
 3957|       |
 3958|    793|    cJSON *file_format_version_json = loader_cJSON_GetObjectItem(icd_manifest_json, "file_format_version");
 3959|    793|    if (file_format_version_json == NULL) {
  ------------------
  |  Branch (3959:9): [True: 0, False: 793]
  ------------------
 3960|      0|        loader_log(inst, VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_DRIVER_BIT, 0,
 3961|      0|                   "loader_parse_icd_manifest: ICD JSON %s does not have a \'file_format_version\' field. Skipping ICD JSON.",
 3962|      0|                   file_str);
 3963|      0|        res = VK_ERROR_INCOMPATIBLE_DRIVER;
 3964|      0|        goto out;
 3965|      0|    }
 3966|       |
 3967|    793|    char *file_vers_str = loader_cJSON_GetStringValue(file_format_version_json);
 3968|    793|    if (NULL == file_vers_str) {
  ------------------
  |  Branch (3968:9): [True: 0, False: 793]
  ------------------
 3969|       |        // Only reason the print can fail is if there was an allocation issue
 3970|      0|        loader_log(inst, VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_DRIVER_BIT, 0,
 3971|      0|                   "loader_parse_icd_manifest: Failed retrieving ICD JSON %s \'file_format_version\' field. Skipping ICD JSON",
 3972|      0|                   file_str);
 3973|      0|        goto out;
 3974|      0|    }
 3975|    793|    loader_log(inst, VULKAN_LOADER_DRIVER_BIT, 0, "Found ICD manifest file %s, version %s", file_str, file_vers_str);
 3976|       |
 3977|       |    // Get the version of the driver manifest
 3978|    793|    loader_api_version json_file_version = loader_make_full_version(loader_parse_version_string(file_vers_str));
 3979|       |
 3980|       |    // Loader only knows versions 1.0.0 and 1.0.1, anything above it is unknown
 3981|    793|    if (loader_check_version_meets_required(loader_combine_version(1, 0, 2), json_file_version)) {
  ------------------
  |  Branch (3981:9): [True: 84, False: 709]
  ------------------
 3982|     84|        loader_log(inst, VULKAN_LOADER_INFO_BIT | VULKAN_LOADER_DRIVER_BIT, 0,
 3983|     84|                   "loader_parse_icd_manifest: %s has unknown icd manifest file version %d.%d.%d. May cause errors.", file_str,
 3984|     84|                   json_file_version.major, json_file_version.minor, json_file_version.patch);
 3985|     84|    }
 3986|       |
 3987|    793|    cJSON *itemICD = loader_cJSON_GetObjectItem(icd_manifest_json, "ICD");
 3988|    793|    if (itemICD == NULL) {
  ------------------
  |  Branch (3988:9): [True: 27, False: 766]
  ------------------
 3989|       |        // Don't warn if this happens to be a layer manifest file
 3990|     27|        if (loader_cJSON_GetObjectItem(icd_manifest_json, "layer") == NULL &&
  ------------------
  |  Branch (3990:13): [True: 26, False: 1]
  ------------------
 3991|     26|            loader_cJSON_GetObjectItem(icd_manifest_json, "layers") == NULL) {
  ------------------
  |  Branch (3991:13): [True: 0, False: 26]
  ------------------
 3992|      0|            loader_log(inst, VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_DRIVER_BIT, 0,
 3993|      0|                       "loader_parse_icd_manifest: Can not find \'ICD\' object in ICD JSON file %s. Skipping ICD JSON", file_str);
 3994|      0|        }
 3995|     27|        res = VK_ERROR_INCOMPATIBLE_DRIVER;
 3996|     27|        goto out;
 3997|     27|    }
 3998|       |
 3999|    766|    cJSON *library_path_json = loader_cJSON_GetObjectItem(itemICD, "library_path");
 4000|    766|    if (library_path_json == NULL) {
  ------------------
  |  Branch (4000:9): [True: 10, False: 756]
  ------------------
 4001|     10|        loader_log(inst, VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_DRIVER_BIT, 0,
 4002|     10|                   "loader_parse_icd_manifest: Failed to find \'library_path\' object in ICD JSON file %s. Skipping ICD JSON.",
 4003|     10|                   file_str);
 4004|     10|        res = VK_ERROR_INCOMPATIBLE_DRIVER;
 4005|     10|        goto out;
 4006|     10|    }
 4007|    766|    bool out_of_memory = false;
 4008|    756|    char *library_path = loader_cJSON_Print(library_path_json, &out_of_memory);
 4009|    756|    if (out_of_memory) {
  ------------------
  |  Branch (4009:9): [True: 0, False: 756]
  ------------------
 4010|      0|        loader_log(inst, VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_DRIVER_BIT, 0,
 4011|      0|                   "loader_parse_icd_manifest: Failed retrieving ICD JSON %s \'library_path\' field. Skipping ICD JSON.", file_str);
 4012|      0|        res = VK_ERROR_OUT_OF_HOST_MEMORY;
 4013|      0|        goto out;
 4014|    756|    } else if (!library_path || strlen(library_path) == 0) {
  ------------------
  |  Branch (4014:16): [True: 0, False: 756]
  |  Branch (4014:33): [True: 1, False: 755]
  ------------------
 4015|      1|        loader_log(inst, VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_DRIVER_BIT, 0,
 4016|      1|                   "loader_parse_icd_manifest: ICD JSON %s \'library_path\' field is empty. Skipping ICD JSON.", file_str);
 4017|      1|        res = VK_ERROR_INCOMPATIBLE_DRIVER;
 4018|      1|        loader_instance_heap_free(inst, library_path);
 4019|      1|        goto out;
 4020|      1|    }
 4021|       |
 4022|       |    // Print out the paths being searched if debugging is enabled
 4023|    755|    loader_log(inst, VULKAN_LOADER_DEBUG_BIT | VULKAN_LOADER_DRIVER_BIT, 0, "Searching for ICD drivers named %s", library_path);
 4024|       |    // This function takes ownership of library_path - so we don't need to clean it up
 4025|    755|    res = combine_manifest_directory_and_library_path(inst, library_path, file_str, &icd->full_library_path);
 4026|    755|    if (VK_SUCCESS != res) {
  ------------------
  |  Branch (4026:9): [True: 0, False: 755]
  ------------------
 4027|      0|        goto out;
 4028|      0|    }
 4029|       |
 4030|    755|    cJSON *api_version_json = loader_cJSON_GetObjectItem(itemICD, "api_version");
 4031|    755|    if (api_version_json == NULL) {
  ------------------
  |  Branch (4031:9): [True: 707, False: 48]
  ------------------
 4032|    707|        loader_log(inst, VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_DRIVER_BIT, 0,
 4033|    707|                   "loader_parse_icd_manifest: ICD JSON %s does not have an \'api_version\' field. Skipping ICD JSON.", file_str);
 4034|    707|        res = VK_ERROR_INCOMPATIBLE_DRIVER;
 4035|    707|        goto out;
 4036|    707|    }
 4037|     48|    char *version_str = loader_cJSON_GetStringValue(api_version_json);
 4038|     48|    if (NULL == version_str) {
  ------------------
  |  Branch (4038:9): [True: 1, False: 47]
  ------------------
 4039|       |        // Only reason the print can fail is if there was an allocation issue
 4040|      1|        loader_log(inst, VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_DRIVER_BIT, 0,
 4041|      1|                   "loader_parse_icd_manifest: Failed retrieving ICD JSON %s \'api_version\' field. Skipping ICD JSON.", file_str);
 4042|       |
 4043|      1|        goto out;
 4044|      1|    }
 4045|     47|    icd->version = loader_parse_version_string(version_str);
 4046|       |
 4047|     47|    if (VK_API_VERSION_VARIANT(icd->version) != 0) {
  ------------------
  |  Branch (4047:9): [True: 20, False: 27]
  ------------------
 4048|     20|        loader_log(inst, VULKAN_LOADER_INFO_BIT | VULKAN_LOADER_DRIVER_BIT, 0,
 4049|     20|                   "loader_parse_icd_manifest: Driver's ICD JSON %s \'api_version\' field contains a non-zero variant value of %d. "
 4050|     20|                   " Skipping ICD JSON.",
 4051|     20|                   file_str, VK_API_VERSION_VARIANT(icd->version));
 4052|     20|        res = VK_ERROR_INCOMPATIBLE_DRIVER;
 4053|     20|        goto out;
 4054|     20|    }
 4055|       |
 4056|       |    // Skip over ICD's which contain a true "is_portability_driver" value whenever the application doesn't enable
 4057|       |    // portability enumeration.
 4058|     27|    cJSON *is_portability_driver_json = loader_cJSON_GetObjectItem(itemICD, "is_portability_driver");
 4059|     27|    if (loader_cJSON_IsTrue(is_portability_driver_json) && inst && !inst->portability_enumeration_enabled) {
  ------------------
  |  Branch (4059:9): [True: 0, False: 27]
  |  Branch (4059:60): [True: 0, False: 0]
  |  Branch (4059:68): [True: 0, False: 0]
  ------------------
 4060|      0|        if (skipped_portability_drivers) {
  ------------------
  |  Branch (4060:13): [True: 0, False: 0]
  ------------------
 4061|      0|            *skipped_portability_drivers = true;
 4062|      0|        }
 4063|      0|        res = VK_ERROR_INCOMPATIBLE_DRIVER;
 4064|      0|        goto out;
 4065|      0|    }
 4066|       |
 4067|     27|    char *library_arch_str = loader_cJSON_GetStringValue(loader_cJSON_GetObjectItem(itemICD, "library_arch"));
 4068|     27|    if (library_arch_str != NULL) {
  ------------------
  |  Branch (4068:9): [True: 0, False: 27]
  ------------------
 4069|      0|        if ((strncmp(library_arch_str, "32", 2) == 0 && sizeof(void *) != 4) ||
  ------------------
  |  Branch (4069:14): [True: 0, False: 0]
  |  Branch (4069:57): [True: 0, Folded]
  ------------------
 4070|      0|            (strncmp(library_arch_str, "64", 2) == 0 && sizeof(void *) != 8)) {
  ------------------
  |  Branch (4070:14): [True: 0, False: 0]
  |  Branch (4070:57): [Folded, False: 0]
  ------------------
 4071|      0|            loader_log(inst, VULKAN_LOADER_INFO_BIT, 0,
 4072|      0|                       "loader_parse_icd_manifest: Driver library architecture doesn't match the current running "
 4073|      0|                       "architecture, skipping this driver");
 4074|      0|            res = VK_ERROR_INCOMPATIBLE_DRIVER;
 4075|      0|            goto out;
 4076|      0|        }
 4077|      0|    }
 4078|    793|out:
 4079|    793|    loader_cJSON_Delete(icd_manifest_json);
 4080|    793|    return res;
 4081|     27|}
loader_icd_scan:
 4098|    793|                         const VkInstanceCreateInfo *pCreateInfo, bool *skipped_portability_drivers) {
 4099|    793|    VkResult res = VK_SUCCESS;
 4100|    793|    struct loader_string_list manifest_files = {0};
 4101|    793|    struct loader_envvar_filter select_filter = {0};
 4102|    793|    struct loader_envvar_filter disable_filter = {0};
 4103|    793|    struct ICDManifestInfo *icd_details = NULL;
 4104|       |
 4105|       |    // Set up the ICD Trampoline list so elements can be written into it.
 4106|    793|    res = loader_init_scanned_icd_list(inst, icd_tramp_list);
 4107|    793|    if (res == VK_ERROR_OUT_OF_HOST_MEMORY) {
  ------------------
  |  Branch (4107:9): [True: 0, False: 793]
  ------------------
 4108|      0|        return res;
 4109|      0|    }
 4110|       |
 4111|    793|    bool direct_driver_loading_exclusive_mode = false;
 4112|    793|    res = loader_scan_for_direct_drivers(inst, pCreateInfo, icd_tramp_list, &direct_driver_loading_exclusive_mode);
 4113|    793|    if (res == VK_ERROR_OUT_OF_HOST_MEMORY) {
  ------------------
  |  Branch (4113:9): [True: 0, False: 793]
  ------------------
 4114|      0|        goto out;
 4115|      0|    }
 4116|    793|    if (direct_driver_loading_exclusive_mode) {
  ------------------
  |  Branch (4116:9): [True: 0, False: 793]
  ------------------
 4117|       |        // Make sure to jump over the system & env-var driver discovery mechanisms if exclusive mode is set, even if no drivers
 4118|       |        // were successfully found through the direct driver loading mechanism
 4119|      0|        goto out;
 4120|      0|    }
 4121|       |
 4122|    793|    if (loader_settings_should_use_driver_environment_variables(inst)) {
  ------------------
  |  Branch (4122:9): [True: 793, False: 0]
  ------------------
 4123|       |        // Parse the filter environment variables to determine if we have any special behavior
 4124|    793|        res = parse_generic_filter_environment_var(inst, VK_DRIVERS_SELECT_ENV_VAR, &select_filter);
  ------------------
  |  |  122|    793|#define VK_DRIVERS_SELECT_ENV_VAR "VK_LOADER_DRIVERS_SELECT"
  ------------------
 4125|    793|        if (VK_SUCCESS != res) {
  ------------------
  |  Branch (4125:13): [True: 0, False: 793]
  ------------------
 4126|      0|            goto out;
 4127|      0|        }
 4128|    793|        res = parse_generic_filter_environment_var(inst, VK_DRIVERS_DISABLE_ENV_VAR, &disable_filter);
  ------------------
  |  |  123|    793|#define VK_DRIVERS_DISABLE_ENV_VAR "VK_LOADER_DRIVERS_DISABLE"
  ------------------
 4129|    793|        if (VK_SUCCESS != res) {
  ------------------
  |  Branch (4129:13): [True: 0, False: 793]
  ------------------
 4130|      0|            goto out;
 4131|      0|        }
 4132|    793|    }
 4133|       |
 4134|       |    // Get a list of manifest files for ICDs
 4135|    793|    res = loader_get_data_files(inst, LOADER_DATA_FILE_MANIFEST_DRIVER, NULL, &manifest_files);
 4136|    793|    if (VK_SUCCESS != res) {
  ------------------
  |  Branch (4136:9): [True: 0, False: 793]
  ------------------
 4137|      0|        goto out;
 4138|      0|    }
 4139|       |
 4140|       |    // Add any drivers provided by the loader settings file
 4141|    793|    res = loader_settings_get_additional_driver_files(inst, &manifest_files);
 4142|    793|    if (VK_SUCCESS != res) {
  ------------------
  |  Branch (4142:9): [True: 0, False: 793]
  ------------------
 4143|      0|        goto out;
 4144|      0|    }
 4145|       |
 4146|    793|    icd_details = loader_stack_alloc(sizeof(struct ICDManifestInfo) * manifest_files.count);
  ------------------
  |  |   42|    793|#define loader_stack_alloc(size) alloca(size)
  ------------------
 4147|    793|    if (NULL == icd_details) {
  ------------------
  |  Branch (4147:9): [True: 0, False: 793]
  ------------------
 4148|      0|        res = VK_ERROR_OUT_OF_HOST_MEMORY;
 4149|      0|        goto out;
 4150|      0|    }
 4151|    793|    memset(icd_details, 0, sizeof(struct ICDManifestInfo) * manifest_files.count);
 4152|       |
 4153|  1.58k|    for (uint32_t i = 0; i < manifest_files.count; i++) {
  ------------------
  |  Branch (4153:26): [True: 793, False: 790]
  ------------------
 4154|    793|        VkResult icd_res = VK_SUCCESS;
 4155|       |
 4156|    793|        icd_res = loader_parse_icd_manifest(inst, manifest_files.list[i], &icd_details[i], skipped_portability_drivers);
 4157|    793|        if (VK_ERROR_OUT_OF_HOST_MEMORY == icd_res) {
  ------------------
  |  Branch (4157:13): [True: 0, False: 793]
  ------------------
 4158|      0|            res = icd_res;
 4159|      0|            goto out;
 4160|    793|        } else if (VK_ERROR_INCOMPATIBLE_DRIVER == icd_res) {
  ------------------
  |  Branch (4160:20): [True: 765, False: 28]
  ------------------
 4161|    765|            continue;
 4162|    765|        }
 4163|       |
 4164|     28|        if (select_filter.count > 0 || disable_filter.count > 0) {
  ------------------
  |  Branch (4164:13): [True: 0, False: 28]
  |  Branch (4164:40): [True: 0, False: 28]
  ------------------
 4165|       |            // Get only the filename for comparing to the filters
 4166|      0|            char *just_filename_str = strrchr(manifest_files.list[i], DIRECTORY_SYMBOL);
  ------------------
  |  |  155|      0|#define DIRECTORY_SYMBOL '/'
  ------------------
 4167|       |
 4168|       |            // No directory symbol, just the filename
 4169|      0|            if (NULL == just_filename_str) {
  ------------------
  |  Branch (4169:17): [True: 0, False: 0]
  ------------------
 4170|      0|                just_filename_str = manifest_files.list[i];
 4171|      0|            } else {
 4172|      0|                just_filename_str++;
 4173|      0|            }
 4174|       |
 4175|      0|            bool name_matches_select =
 4176|      0|                (select_filter.count > 0 && check_name_matches_filter_environment_var(just_filename_str, &select_filter));
  ------------------
  |  Branch (4176:18): [True: 0, False: 0]
  |  Branch (4176:45): [True: 0, False: 0]
  ------------------
 4177|      0|            bool name_matches_disable =
 4178|      0|                (disable_filter.count > 0 && check_name_matches_filter_environment_var(just_filename_str, &disable_filter));
  ------------------
  |  Branch (4178:18): [True: 0, False: 0]
  |  Branch (4178:46): [True: 0, False: 0]
  ------------------
 4179|       |
 4180|      0|            if (name_matches_disable && !name_matches_select) {
  ------------------
  |  Branch (4180:17): [True: 0, False: 0]
  |  Branch (4180:41): [True: 0, False: 0]
  ------------------
 4181|      0|                loader_log(inst, VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_DRIVER_BIT, 0,
 4182|      0|                           "Driver \"%s\" ignored because it was disabled by env var \'%s\'", just_filename_str,
 4183|      0|                           VK_DRIVERS_DISABLE_ENV_VAR);
  ------------------
  |  |  123|      0|#define VK_DRIVERS_DISABLE_ENV_VAR "VK_LOADER_DRIVERS_DISABLE"
  ------------------
 4184|      0|                continue;
 4185|      0|            }
 4186|      0|            if (select_filter.count != 0 && !name_matches_select) {
  ------------------
  |  Branch (4186:17): [True: 0, False: 0]
  |  Branch (4186:45): [True: 0, False: 0]
  ------------------
 4187|      0|                loader_log(inst, VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_DRIVER_BIT, 0,
 4188|      0|                           "Driver \"%s\" ignored because not selected by env var \'%s\'", just_filename_str,
 4189|      0|                           VK_DRIVERS_SELECT_ENV_VAR);
  ------------------
  |  |  122|      0|#define VK_DRIVERS_SELECT_ENV_VAR "VK_LOADER_DRIVERS_SELECT"
  ------------------
 4190|      0|                continue;
 4191|      0|            }
 4192|      0|        }
 4193|       |
 4194|     28|        enum loader_layer_library_status lib_status;
 4195|     28|        icd_res =
 4196|     28|            loader_scanned_icd_add(inst, icd_tramp_list, icd_details[i].full_library_path, icd_details[i].version, &lib_status);
 4197|     28|        if (VK_ERROR_OUT_OF_HOST_MEMORY == icd_res) {
  ------------------
  |  Branch (4197:13): [True: 3, False: 25]
  ------------------
 4198|      3|            res = icd_res;
 4199|      3|            goto out;
 4200|     25|        } else if (VK_ERROR_INCOMPATIBLE_DRIVER == icd_res) {
  ------------------
  |  Branch (4200:20): [True: 25, False: 0]
  ------------------
 4201|     25|            switch (lib_status) {
  ------------------
  |  Branch (4201:21): [True: 25, False: 0]
  ------------------
 4202|      0|                case LOADER_LAYER_LIB_NOT_LOADED:
  ------------------
  |  Branch (4202:17): [True: 0, False: 25]
  ------------------
 4203|     23|                case LOADER_LAYER_LIB_ERROR_FAILED_TO_LOAD:
  ------------------
  |  Branch (4203:17): [True: 23, False: 2]
  ------------------
 4204|     23|                    loader_log(inst, VULKAN_LOADER_ERROR_BIT | VULKAN_LOADER_DRIVER_BIT, 0,
 4205|     23|                               "loader_icd_scan: Failed loading library associated with ICD JSON %s. Ignoring this JSON",
 4206|     23|                               icd_details[i].full_library_path);
 4207|     23|                    break;
 4208|      2|                case LOADER_LAYER_LIB_ERROR_WRONG_BIT_TYPE: {
  ------------------
  |  Branch (4208:17): [True: 2, False: 23]
  ------------------
 4209|      2|                    loader_log(inst, VULKAN_LOADER_DRIVER_BIT, 0, "Requested ICD %s was wrong bit-type. Ignoring this JSON",
 4210|      2|                               icd_details[i].full_library_path);
 4211|      2|                    break;
 4212|      0|                }
 4213|      0|                case LOADER_LAYER_LIB_SUCCESS_LOADED:
  ------------------
  |  Branch (4213:17): [True: 0, False: 25]
  ------------------
 4214|      0|                case LOADER_LAYER_LIB_ERROR_OUT_OF_MEMORY:
  ------------------
  |  Branch (4214:17): [True: 0, False: 25]
  ------------------
 4215|       |                    // Shouldn't be able to reach this but if it is, best to report a debug
 4216|      0|                    loader_log(inst, VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_DRIVER_BIT, 0,
 4217|      0|                               "Shouldn't reach this. A valid version of requested ICD %s was loaded but something bad "
 4218|      0|                               "happened afterwards.",
 4219|      0|                               icd_details[i].full_library_path);
 4220|      0|                    break;
 4221|     25|            }
 4222|     25|        }
 4223|     28|    }
 4224|       |
 4225|    793|out:
 4226|    793|    if (NULL != icd_details) {
  ------------------
  |  Branch (4226:9): [True: 793, False: 0]
  ------------------
 4227|       |        // Successfully got the icd_details structure, which means we need to free the paths contained within
 4228|  1.58k|        for (uint32_t i = 0; i < manifest_files.count; i++) {
  ------------------
  |  Branch (4228:30): [True: 793, False: 793]
  ------------------
 4229|    793|            loader_instance_heap_free(inst, icd_details[i].full_library_path);
 4230|    793|        }
 4231|    793|    }
 4232|    793|    free_string_list(inst, &manifest_files);
 4233|    793|    return res;
 4234|    793|}
loader_parse_instance_layers:
 4240|  15.5k|                                      const struct loader_string_list *path_overrides, struct loader_layer_list *instance_layers) {
 4241|  15.5k|    assert(manifest_type == LOADER_DATA_FILE_MANIFEST_IMPLICIT_LAYER || manifest_type == LOADER_DATA_FILE_MANIFEST_EXPLICIT_LAYER);
 4242|  15.5k|    VkResult res = VK_SUCCESS;
 4243|  15.5k|    struct loader_string_list manifest_files = {0};
 4244|       |
 4245|  15.5k|    res = loader_get_data_files(inst, manifest_type, path_overrides, &manifest_files);
 4246|  15.5k|    if (VK_SUCCESS != res) {
  ------------------
  |  Branch (4246:9): [True: 0, False: 15.5k]
  ------------------
 4247|      0|        goto out;
 4248|      0|    }
 4249|       |
 4250|  95.8k|    for (uint32_t i = 0; i < manifest_files.count; i++) {
  ------------------
  |  Branch (4250:26): [True: 80.2k, False: 15.5k]
  ------------------
 4251|  80.2k|        char *file_str = manifest_files.list[i];
 4252|  80.2k|        if (file_str == NULL) {
  ------------------
  |  Branch (4252:13): [True: 0, False: 80.2k]
  ------------------
 4253|      0|            continue;
 4254|      0|        }
 4255|       |
 4256|       |        // Parse file into JSON struct
 4257|  80.2k|        cJSON *json = NULL;
 4258|  80.2k|        VkResult local_res = loader_get_json(inst, file_str, &json);
 4259|  80.2k|        if (VK_ERROR_OUT_OF_HOST_MEMORY == local_res) {
  ------------------
  |  Branch (4259:13): [True: 0, False: 80.2k]
  ------------------
 4260|      0|            res = VK_ERROR_OUT_OF_HOST_MEMORY;
 4261|      0|            goto out;
 4262|  80.2k|        } else if (VK_SUCCESS != local_res || NULL == json) {
  ------------------
  |  Branch (4262:20): [True: 2.79k, False: 77.4k]
  |  Branch (4262:47): [True: 57.4k, False: 20.0k]
  ------------------
 4263|  60.2k|            continue;
 4264|  60.2k|        }
 4265|       |
 4266|  20.0k|        local_res = loader_add_layer_properties(inst, instance_layers, json,
 4267|  20.0k|                                                manifest_type == LOADER_DATA_FILE_MANIFEST_IMPLICIT_LAYER, file_str);
 4268|  20.0k|        loader_cJSON_Delete(json);
 4269|       |
 4270|       |        // If the error is anything other than out of memory we still want to try to load the other layers
 4271|  20.0k|        if (VK_ERROR_OUT_OF_HOST_MEMORY == local_res) {
  ------------------
  |  Branch (4271:13): [True: 0, False: 20.0k]
  ------------------
 4272|      0|            res = VK_ERROR_OUT_OF_HOST_MEMORY;
 4273|      0|            goto out;
 4274|      0|        }
 4275|  20.0k|    }
 4276|  15.5k|out:
 4277|  15.5k|    free_string_list(inst, &manifest_files);
 4278|       |
 4279|  15.5k|    return res;
 4280|  15.5k|}
get_override_layer_override_paths:
 4285|    810|                                           struct loader_string_list *override_paths) {
 4286|    810|    if (prop->override_paths.count > 0) {
  ------------------
  |  Branch (4286:9): [True: 810, False: 0]
  ------------------
 4287|  89.7k|        for (uint32_t j = 0; j < prop->override_paths.count; j++) {
  ------------------
  |  Branch (4287:30): [True: 88.9k, False: 810]
  ------------------
 4288|  88.9k|            VkResult result = copy_data_file_info(inst, prop->override_paths.list[j], NULL, 0, override_paths);
 4289|  88.9k|            if (VK_SUCCESS != result) {
  ------------------
  |  Branch (4289:17): [True: 0, False: 88.9k]
  ------------------
 4290|      0|                return result;
 4291|      0|            }
 4292|  88.9k|            loader_log(inst, VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_LAYER_BIT, 0, "Override layer has override path %s",
 4293|  88.9k|                       prop->override_paths.list[j]);
 4294|  88.9k|        }
 4295|    810|    }
 4296|    810|    return VK_SUCCESS;
 4297|    810|}
loader_remove_duplicate_layers:
 4299|  7.78k|void loader_remove_duplicate_layers(struct loader_instance *inst, struct loader_layer_list *layers) {
 4300|       |    // Remove duplicate layers (that share the same layerName)
 4301|  90.7k|    for (uint32_t i = 0; i < layers->count; ++i) {
  ------------------
  |  Branch (4301:26): [True: 82.9k, False: 7.78k]
  ------------------
 4302|  82.9k|        bool has_duplicate = false;
 4303|  82.9k|        uint32_t duplicate_index = 0;
 4304|   306k|        for (uint32_t j = i + 1; j < layers->count; ++j) {
  ------------------
  |  Branch (4304:34): [True: 300k, False: 5.43k]
  ------------------
 4305|   300k|            if (strcmp(layers->list[i].info.layerName, layers->list[j].info.layerName) == 0) {
  ------------------
  |  Branch (4305:17): [True: 77.5k, False: 223k]
  ------------------
 4306|  77.5k|                has_duplicate = true;
 4307|  77.5k|                duplicate_index = j;
 4308|  77.5k|                break;
 4309|  77.5k|            }
 4310|   300k|        }
 4311|  82.9k|        if (has_duplicate) {
  ------------------
  |  Branch (4311:13): [True: 77.5k, False: 5.43k]
  ------------------
 4312|  77.5k|            loader_log(inst, VULKAN_LOADER_WARN_BIT, 0, "Removing layer %s (%s) because it is a duplicate of %s (%s)",
 4313|  77.5k|                       layers->list[duplicate_index].info.layerName, layers->list[duplicate_index].manifest_file_name,
 4314|  77.5k|                       layers->list[i].info.layerName, layers->list[i].manifest_file_name);
 4315|  77.5k|            loader_remove_layer_in_list(inst, layers, duplicate_index);
 4316|  77.5k|        }
 4317|  82.9k|    }
 4318|  7.78k|}
loader_scan_for_layers:
 4321|  8.21k|                                const struct loader_envvar_all_filters *filters) {
 4322|  8.21k|    VkResult res = VK_SUCCESS;
 4323|  8.21k|    struct loader_layer_list settings_layers = {0};
 4324|  8.21k|    struct loader_layer_list regular_instance_layers = {0};
 4325|  8.21k|    bool override_layer_valid = false;
 4326|  8.21k|    struct loader_string_list override_paths = {0};
 4327|       |
 4328|  8.21k|    bool should_search_for_other_layers = true;
 4329|  8.21k|    res = get_settings_layers(inst, &settings_layers, &should_search_for_other_layers);
 4330|  8.21k|    if (VK_SUCCESS != res) {
  ------------------
  |  Branch (4330:9): [True: 0, False: 8.21k]
  ------------------
 4331|      0|        goto out;
 4332|      0|    }
 4333|       |
 4334|       |    // If we should not look for layers using other mechanisms, assign settings_layers to instance_layers and jump to the
 4335|       |    // output
 4336|  8.21k|    if (!should_search_for_other_layers) {
  ------------------
  |  Branch (4336:9): [True: 435, False: 7.78k]
  ------------------
 4337|    435|        *instance_layers = settings_layers;
 4338|    435|        memset(&settings_layers, 0, sizeof(struct loader_layer_list));
 4339|    435|        goto out;
 4340|    435|    }
 4341|       |
 4342|  7.78k|    res = loader_parse_instance_layers(inst, LOADER_DATA_FILE_MANIFEST_IMPLICIT_LAYER, NULL, &regular_instance_layers);
 4343|  7.78k|    if (VK_SUCCESS != res) {
  ------------------
  |  Branch (4343:9): [True: 0, False: 7.78k]
  ------------------
 4344|      0|        goto out;
 4345|      0|    }
 4346|       |
 4347|       |    // Remove any extraneous override layers.
 4348|  7.78k|    remove_all_non_valid_override_layers(inst, &regular_instance_layers);
 4349|       |
 4350|       |    // Check to see if the override layer is present, and use it's override paths.
 4351|  32.2k|    for (uint32_t i = 0; i < regular_instance_layers.count; i++) {
  ------------------
  |  Branch (4351:26): [True: 25.2k, False: 6.97k]
  ------------------
 4352|  25.2k|        struct loader_layer_properties *prop = &regular_instance_layers.list[i];
 4353|  25.2k|        if (prop->is_override && loader_implicit_layer_is_enabled(inst, filters, prop) && prop->override_paths.count > 0) {
  ------------------
  |  Branch (4353:13): [True: 1.17k, False: 24.1k]
  |  Branch (4353:34): [True: 1.02k, False: 148]
  |  Branch (4353:91): [True: 810, False: 217]
  ------------------
 4354|    810|            res = get_override_layer_override_paths(inst, prop, &override_paths);
 4355|    810|            if (VK_SUCCESS != res) {
  ------------------
  |  Branch (4355:17): [True: 0, False: 810]
  ------------------
 4356|      0|                goto out;
 4357|      0|            }
 4358|    810|            break;
 4359|    810|        }
 4360|  25.2k|    }
 4361|       |
 4362|       |    // Get a list of manifest files for explicit layers
 4363|  7.78k|    res = loader_parse_instance_layers(inst, LOADER_DATA_FILE_MANIFEST_EXPLICIT_LAYER, &override_paths, &regular_instance_layers);
 4364|  7.78k|    if (VK_SUCCESS != res) {
  ------------------
  |  Branch (4364:9): [True: 0, False: 7.78k]
  ------------------
 4365|      0|        goto out;
 4366|      0|    }
 4367|       |
 4368|       |    // Verify any meta-layers in the list are valid and all the component layers are
 4369|       |    // actually present in the available layer list
 4370|  7.78k|    res = verify_all_meta_layers(inst, filters, &regular_instance_layers, &override_layer_valid);
 4371|  7.78k|    if (VK_ERROR_OUT_OF_HOST_MEMORY == res) {
  ------------------
  |  Branch (4371:9): [True: 0, False: 7.78k]
  ------------------
 4372|      0|        return res;
 4373|      0|    }
 4374|       |
 4375|  7.78k|    if (override_layer_valid) {
  ------------------
  |  Branch (4375:9): [True: 1.01k, False: 6.76k]
  ------------------
 4376|  1.01k|        loader_remove_layers_in_blacklist(inst, &regular_instance_layers);
 4377|  1.01k|        if (NULL != inst) {
  ------------------
  |  Branch (4377:13): [True: 1.01k, False: 0]
  ------------------
 4378|  1.01k|            inst->override_layer_present = true;
 4379|  1.01k|        }
 4380|  1.01k|    }
 4381|       |
 4382|       |    // Remove disabled layers
 4383|   168k|    for (uint32_t i = 0; i < regular_instance_layers.count; ++i) {
  ------------------
  |  Branch (4383:26): [True: 160k, False: 7.78k]
  ------------------
 4384|   160k|        if (!loader_layer_is_available(inst, filters, &regular_instance_layers.list[i])) {
  ------------------
  |  Branch (4384:13): [True: 0, False: 160k]
  ------------------
 4385|      0|            loader_remove_layer_in_list(inst, &regular_instance_layers, i);
 4386|      0|            i--;
 4387|      0|        }
 4388|   160k|    }
 4389|       |
 4390|       |    // Make sure no layers have the same layerName
 4391|  7.78k|    loader_remove_duplicate_layers(inst, &regular_instance_layers);
 4392|       |
 4393|  7.78k|    res = combine_settings_layers_with_regular_layers(inst, &settings_layers, &regular_instance_layers, instance_layers);
 4394|       |
 4395|  8.21k|out:
 4396|  8.21k|    loader_delete_layer_list_and_properties(inst, &settings_layers);
 4397|  8.21k|    loader_delete_layer_list_and_properties(inst, &regular_instance_layers);
 4398|       |
 4399|  8.21k|    free_string_list(inst, &override_paths);
 4400|  8.21k|    return res;
 4401|  7.78k|}
loader_validate_layers:
 5607|  8.21k|                                const char *const *ppEnabledLayerNames, const struct loader_layer_list *list) {
 5608|  8.21k|    struct loader_layer_properties *prop;
 5609|       |
 5610|  8.21k|    if (layer_count > 0 && ppEnabledLayerNames == NULL) {
  ------------------
  |  Branch (5610:9): [True: 8.21k, False: 0]
  |  Branch (5610:28): [True: 0, False: 8.21k]
  ------------------
 5611|      0|        loader_log(inst, VULKAN_LOADER_ERROR_BIT, 0,
 5612|      0|                   "loader_validate_layers: ppEnabledLayerNames is NULL but enabledLayerCount is greater than zero");
 5613|      0|        return VK_ERROR_LAYER_NOT_PRESENT;
 5614|      0|    }
 5615|       |
 5616|  9.00k|    for (uint32_t i = 0; i < layer_count; i++) {
  ------------------
  |  Branch (5616:26): [True: 8.21k, False: 793]
  ------------------
 5617|  8.21k|        VkStringErrorFlags result = vk_string_validate(MaxLoaderStringLength, ppEnabledLayerNames[i]);
 5618|  8.21k|        if (result != VK_STRING_ERROR_NONE) {
  ------------------
  |  Branch (5618:13): [True: 0, False: 8.21k]
  ------------------
 5619|      0|            loader_log(inst, VULKAN_LOADER_ERROR_BIT, 0,
 5620|      0|                       "loader_validate_layers: ppEnabledLayerNames contains string that is too long or is badly formed");
 5621|      0|            return VK_ERROR_LAYER_NOT_PRESENT;
 5622|      0|        }
 5623|       |
 5624|  8.21k|        prop = loader_find_layer_property(ppEnabledLayerNames[i], list);
 5625|  8.21k|        if (NULL == prop) {
  ------------------
  |  Branch (5625:13): [True: 7.42k, False: 794]
  ------------------
 5626|  7.42k|            loader_log(inst, VULKAN_LOADER_ERROR_BIT, 0,
 5627|  7.42k|                       "loader_validate_layers: Layer %d does not exist in the list of available layers", i);
 5628|  7.42k|            return VK_ERROR_LAYER_NOT_PRESENT;
 5629|  7.42k|        }
 5630|    794|        if (inst->settings.settings_active && inst->settings.layer_configurations_active &&
  ------------------
  |  Branch (5630:13): [True: 13, False: 781]
  |  Branch (5630:47): [True: 4, False: 9]
  ------------------
 5631|      4|            prop->settings_control_value != LOADER_SETTINGS_LAYER_CONTROL_ON &&
  ------------------
  |  Branch (5631:13): [True: 4, False: 0]
  ------------------
 5632|      4|            prop->settings_control_value != LOADER_SETTINGS_LAYER_CONTROL_DEFAULT) {
  ------------------
  |  Branch (5632:13): [True: 1, False: 3]
  ------------------
 5633|      1|            loader_log(inst, VULKAN_LOADER_ERROR_BIT, 0,
 5634|      1|                       "loader_validate_layers: Layer %d was explicitly prevented from being enabled by the loader settings file",
 5635|      1|                       i);
 5636|      1|            return VK_ERROR_LAYER_NOT_PRESENT;
 5637|      1|        }
 5638|    794|    }
 5639|    793|    return VK_SUCCESS;
 5640|  8.21k|}
vk_string_validate:
 7542|  8.21k|TEST_FUNCTION_EXPORT VkStringErrorFlags vk_string_validate(const int max_length, const char *utf8) {
 7543|  8.21k|    VkStringErrorFlags result = VK_STRING_ERROR_NONE;
 7544|  8.21k|    int num_char_bytes = 0;
 7545|  8.21k|    int i;
 7546|  8.21k|    int j;
 7547|       |
 7548|  8.21k|    if (utf8 == NULL) {
  ------------------
  |  Branch (7548:9): [True: 0, False: 8.21k]
  ------------------
 7549|      0|        return VK_STRING_ERROR_NULL_PTR;
 7550|      0|    }
 7551|       |
 7552|   230k|    for (i = 0; i <= max_length; i++) {
  ------------------
  |  Branch (7552:17): [True: 230k, False: 0]
  ------------------
 7553|   230k|        if (utf8[i] == 0) {
  ------------------
  |  Branch (7553:13): [True: 8.21k, False: 221k]
  ------------------
 7554|  8.21k|            break;
 7555|  8.21k|        }
 7556|   221k|        if (i == max_length) {
  ------------------
  |  Branch (7556:13): [True: 0, False: 221k]
  ------------------
 7557|      0|            result |= VK_STRING_ERROR_LENGTH;
 7558|      0|            break;
 7559|      0|        }
 7560|   221k|        if ((utf8[i] >= 0x20) && (utf8[i] < 0x7f)) {
  ------------------
  |  Branch (7560:13): [True: 221k, False: 0]
  |  Branch (7560:34): [True: 221k, False: 0]
  ------------------
 7561|   221k|            num_char_bytes = 0;
 7562|   221k|        } else if ((utf8[i] & UTF8_ONE_BYTE_MASK) == UTF8_ONE_BYTE_CODE) {
  ------------------
  |  Branch (7562:20): [True: 0, False: 0]
  ------------------
 7563|      0|            num_char_bytes = 1;
 7564|      0|        } else if ((utf8[i] & UTF8_TWO_BYTE_MASK) == UTF8_TWO_BYTE_CODE) {
  ------------------
  |  Branch (7564:20): [True: 0, False: 0]
  ------------------
 7565|      0|            num_char_bytes = 2;
 7566|      0|        } else if ((utf8[i] & UTF8_THREE_BYTE_MASK) == UTF8_THREE_BYTE_CODE) {
  ------------------
  |  Branch (7566:20): [True: 0, False: 0]
  ------------------
 7567|      0|            num_char_bytes = 3;
 7568|      0|        } else {
 7569|      0|            result = VK_STRING_ERROR_BAD_DATA;
 7570|      0|        }
 7571|       |
 7572|       |        // Validate the following num_char_bytes of data
 7573|   221k|        for (j = 0; (j < num_char_bytes) && (i < max_length); j++) {
  ------------------
  |  Branch (7573:21): [True: 0, False: 221k]
  |  Branch (7573:45): [True: 0, False: 0]
  ------------------
 7574|      0|            if (++i == max_length) {
  ------------------
  |  Branch (7574:17): [True: 0, False: 0]
  ------------------
 7575|      0|                result |= VK_STRING_ERROR_LENGTH;
 7576|      0|                break;
 7577|      0|            }
 7578|      0|            if (utf8[i] == 0) {
  ------------------
  |  Branch (7578:17): [True: 0, False: 0]
  ------------------
 7579|       |                // The string terminated in the middle of a multi-byte character. Stop here so the
 7580|       |                // continuation-byte scan doesn't read past the terminator.
 7581|      0|                result |= VK_STRING_ERROR_BAD_DATA;
 7582|      0|                return result;
 7583|      0|            }
 7584|      0|            if ((utf8[i] & UTF8_DATA_BYTE_MASK) != UTF8_DATA_BYTE_CODE) {
  ------------------
  |  Branch (7584:17): [True: 0, False: 0]
  ------------------
 7585|      0|                result |= VK_STRING_ERROR_BAD_DATA;
 7586|      0|            }
 7587|      0|        }
 7588|   221k|    }
 7589|  8.21k|    return result;
 7590|  8.21k|}

loader_getenv:
   43|  2.48k|char *loader_getenv(const char *name, const struct loader_instance *inst) {
   44|  2.48k|    if (NULL == name) return NULL;
  ------------------
  |  Branch (44:9): [True: 0, False: 2.48k]
  ------------------
   45|       |    // No allocation of memory necessary for Linux, but we should at least touch
   46|       |    // the inst pointer to get rid of compiler warnings.
   47|  2.48k|    (void)inst;
   48|       |    // NOLINTNEXTLINE(concurrency-mt-unsafe) - there is no portable reentrant getenv; the loader never calls setenv concurrently
   49|  2.48k|    return getenv(name);
   50|  2.48k|}
loader_secure_getenv:
   52|   182k|char *loader_secure_getenv(const char *name, const struct loader_instance *inst) {
   53|       |#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__)
   54|       |    // Apple does not appear to have a secure getenv implementation.
   55|       |    // The main difference between secure getenv and getenv is that secure getenv
   56|       |    // returns NULL if the process is being run with elevated privileges by a normal user.
   57|       |    // The idea is to prevent the reading of malicious environment variables by a process
   58|       |    // that can do damage.
   59|       |    // This algorithm is derived from glibc code that sets an internal
   60|       |    // variable (__libc_enable_secure) if the process is running under setuid or setgid.
   61|       |    return is_high_integrity() ? NULL : loader_getenv(name, inst);
   62|       |#elif defined(__Fuchsia__)
   63|       |    return loader_getenv(name, inst);
   64|       |#else
   65|       |    // Linux
   66|   182k|    char *out;
   67|   182k|#if defined(HAVE_SECURE_GETENV) && !defined(LOADER_USE_UNSAFE_FILE_SEARCH)
   68|   182k|    (void)inst;
   69|   182k|    out = secure_getenv(name);
   70|       |#elif defined(HAVE___SECURE_GETENV) && !defined(LOADER_USE_UNSAFE_FILE_SEARCH)
   71|       |    (void)inst;
   72|       |    out = __secure_getenv(name);
   73|       |#else
   74|       |    out = loader_getenv(name, inst);
   75|       |#if !defined(LOADER_USE_UNSAFE_FILE_SEARCH)
   76|       |    loader_log(inst, VULKAN_LOADER_INFO_BIT, 0, "Loader is using non-secure environment variable lookup for %s", name);
   77|       |#endif
   78|       |#endif
   79|   182k|    return out;
   80|   182k|#endif
   81|   182k|}
loader_free_getenv:
   83|   149k|void loader_free_getenv(const char *val, const struct loader_instance *inst) {
   84|       |    // No freeing of memory necessary for Linux, but we should at least touch
   85|       |    // the val and inst pointers to get rid of compiler warnings.
   86|   149k|    (void)val;
   87|   149k|    (void)inst;
   88|   149k|}
determine_filter_type:
  193|  8.21k|                           size_t *new_length) {
  194|  8.21k|    size_t filter_length = strlen(filter_string);
  195|  8.21k|    bool star_begin = false;
  196|  8.21k|    bool star_end = false;
  197|  8.21k|    if ('~' == filter_string[0]) {
  ------------------
  |  Branch (197:9): [True: 0, False: 8.21k]
  ------------------
  198|       |        // One of the special identifiers like: ~all~, ~implicit~, or ~explicit~
  199|      0|        *filter_type = FILTER_STRING_SPECIAL;
  200|      0|        *new_start = filter_string;
  201|      0|        *new_length = filter_length;
  202|  8.21k|    } else {
  203|  8.21k|        if ('*' == filter_string[0]) {
  ------------------
  |  Branch (203:13): [True: 0, False: 8.21k]
  ------------------
  204|       |            // Only the * means everything
  205|      0|            if (filter_length == 1) {
  ------------------
  |  Branch (205:17): [True: 0, False: 0]
  ------------------
  206|      0|                *filter_type = FILTER_STRING_SPECIAL;
  207|      0|                *new_start = filter_string;
  208|      0|                *new_length = filter_length;
  209|      0|                return;
  210|      0|            }
  211|      0|            star_begin = true;
  212|      0|        }
  213|  8.21k|        if ('*' == filter_string[filter_length - 1]) {
  ------------------
  |  Branch (213:13): [True: 0, False: 8.21k]
  ------------------
  214|       |            // Not really valid, but just catch this case so if someone accidentally types "**" it will also mean everything
  215|      0|            if (star_begin && filter_length == 2) {
  ------------------
  |  Branch (215:17): [True: 0, False: 0]
  |  Branch (215:31): [True: 0, False: 0]
  ------------------
  216|      0|                *filter_type = FILTER_STRING_SPECIAL;
  217|      0|                *new_start = filter_string;
  218|      0|                *new_length = filter_length;
  219|      0|                return;
  220|      0|            }
  221|      0|            star_end = true;
  222|      0|        }
  223|  8.21k|        if (star_begin && star_end) {
  ------------------
  |  Branch (223:13): [True: 0, False: 8.21k]
  |  Branch (223:27): [True: 0, False: 0]
  ------------------
  224|      0|            *filter_type = FILTER_STRING_SUBSTRING;
  225|      0|            *new_start = &filter_string[1];
  226|      0|            *new_length = filter_length - 2;
  227|  8.21k|        } else if (star_begin) {
  ------------------
  |  Branch (227:20): [True: 0, False: 8.21k]
  ------------------
  228|      0|            *new_start = &filter_string[1];
  229|      0|            *new_length = filter_length - 1;
  230|      0|            *filter_type = FILTER_STRING_SUFFIX;
  231|  8.21k|        } else if (star_end) {
  ------------------
  |  Branch (231:20): [True: 0, False: 8.21k]
  ------------------
  232|      0|            *filter_type = FILTER_STRING_PREFIX;
  233|      0|            *new_start = filter_string;
  234|      0|            *new_length = filter_length - 1;
  235|  8.21k|        } else {
  236|  8.21k|            *filter_type = FILTER_STRING_FULLNAME;
  237|  8.21k|            *new_start = filter_string;
  238|  8.21k|            *new_length = filter_length;
  239|  8.21k|        }
  240|  8.21k|    }
  241|  8.21k|}
parse_generic_filter_environment_var:
  246|  18.0k|                                              struct loader_envvar_filter *filter_struct) {
  247|  18.0k|    VkResult result = VK_SUCCESS;
  248|  18.0k|    memset(filter_struct, 0, sizeof(struct loader_envvar_filter));
  249|  18.0k|    char *parsing_string = NULL;
  250|  18.0k|    char *env_var_value = loader_secure_getenv(env_var_name, inst);
  251|  18.0k|    if (NULL == env_var_value) {
  ------------------
  |  Branch (251:9): [True: 9.80k, False: 8.21k]
  ------------------
  252|  9.80k|        return result;
  253|  9.80k|    }
  254|  8.21k|    const size_t env_var_len = strlen(env_var_value);
  255|  8.21k|    if (env_var_len == 0) {
  ------------------
  |  Branch (255:9): [True: 0, False: 8.21k]
  ------------------
  256|      0|        goto out;
  257|      0|    }
  258|       |    // Allocate a separate string since scan_for_next_comma modifies the original string
  259|  8.21k|    parsing_string = loader_instance_heap_calloc(inst, env_var_len + 1, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
  260|  8.21k|    if (NULL == parsing_string) {
  ------------------
  |  Branch (260:9): [True: 0, False: 8.21k]
  ------------------
  261|      0|        loader_log(inst, VULKAN_LOADER_ERROR_BIT, 0,
  262|      0|                   "parse_generic_filter_environment_var: Failed to allocate space for parsing env var \'%s\'", env_var_name);
  263|      0|        result = VK_ERROR_OUT_OF_HOST_MEMORY;
  264|      0|        goto out;
  265|      0|    }
  266|       |
  267|  32.8k|    for (uint32_t iii = 0; iii < env_var_len; ++iii) {
  ------------------
  |  Branch (267:28): [True: 24.6k, False: 8.21k]
  ------------------
  268|  24.6k|        parsing_string[iii] = (char)tolower((unsigned char)env_var_value[iii]);
  ------------------
  |  Branch (268:37): [True: 0, False: 0]
  |  Branch (268:37): [True: 0, False: 0]
  |  Branch (268:37): [Folded, False: 24.6k]
  ------------------
  269|  24.6k|    }
  270|  8.21k|    parsing_string[env_var_len] = '\0';
  271|       |
  272|  8.21k|    char *context = NULL;
  273|  8.21k|    char *token = thread_safe_strtok(parsing_string, ",", &context);
  274|  16.4k|    while (NULL != token) {
  ------------------
  |  Branch (274:12): [True: 8.21k, False: 8.21k]
  ------------------
  275|  8.21k|        enum loader_filter_string_type cur_filter_type;
  276|  8.21k|        const char *actual_start;
  277|  8.21k|        size_t actual_len;
  278|  8.21k|        determine_filter_type(token, &cur_filter_type, &actual_start, &actual_len);
  279|       |        // value holds at most VK_MAX_EXTENSION_NAME_SIZE - 1 chars plus the null terminator. Keep the stored length in sync
  280|       |        // with what actually fits so the matcher never walks past the buffer, and make sure it stays null terminated.
  281|  8.21k|        size_t stored_len = actual_len < VK_MAX_EXTENSION_NAME_SIZE - 1 ? actual_len : VK_MAX_EXTENSION_NAME_SIZE - 1;
  ------------------
  |  Branch (281:29): [True: 8.21k, False: 0]
  ------------------
  282|  8.21k|        loader_strncpy(filter_struct->filters[filter_struct->count].value, VK_MAX_EXTENSION_NAME_SIZE, actual_start, stored_len);
  283|  8.21k|        filter_struct->filters[filter_struct->count].value[stored_len] = '\0';
  284|  8.21k|        filter_struct->filters[filter_struct->count].length = stored_len;
  285|  8.21k|        filter_struct->filters[filter_struct->count++].type = cur_filter_type;
  286|  8.21k|        if (filter_struct->count >= MAX_ADDITIONAL_FILTERS) {
  ------------------
  |  |  531|  8.21k|#define MAX_ADDITIONAL_FILTERS 16
  ------------------
  |  Branch (286:13): [True: 0, False: 8.21k]
  ------------------
  287|      0|            break;
  288|      0|        }
  289|  8.21k|        token = thread_safe_strtok(NULL, ",", &context);
  290|  8.21k|    }
  291|       |
  292|  8.21k|out:
  293|       |
  294|  8.21k|    loader_instance_heap_free(inst, parsing_string);
  295|  8.21k|    loader_free_getenv(env_var_value, inst);
  296|  8.21k|    return result;
  297|  8.21k|}
parse_layers_disable_filter_environment_var:
  303|  8.21k|                                                     struct loader_envvar_disable_layers_filter *disable_struct) {
  304|  8.21k|    VkResult result = VK_SUCCESS;
  305|  8.21k|    memset(disable_struct, 0, sizeof(struct loader_envvar_disable_layers_filter));
  306|  8.21k|    char *parsing_string = NULL;
  307|  8.21k|    char *env_var_value = loader_secure_getenv(VK_LAYERS_DISABLE_ENV_VAR, inst);
  ------------------
  |  |  120|  8.21k|#define VK_LAYERS_DISABLE_ENV_VAR "VK_LOADER_LAYERS_DISABLE"
  ------------------
  308|  8.21k|    if (NULL == env_var_value) {
  ------------------
  |  Branch (308:9): [True: 8.21k, False: 0]
  ------------------
  309|  8.21k|        goto out;
  310|  8.21k|    }
  311|      0|    const size_t env_var_len = strlen(env_var_value);
  312|      0|    if (env_var_len == 0) {
  ------------------
  |  Branch (312:9): [True: 0, False: 0]
  ------------------
  313|      0|        goto out;
  314|      0|    }
  315|       |    // Allocate a separate string since scan_for_next_comma modifies the original string
  316|      0|    parsing_string = loader_instance_heap_calloc(inst, env_var_len + 1, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
  317|      0|    if (NULL == parsing_string) {
  ------------------
  |  Branch (317:9): [True: 0, False: 0]
  ------------------
  318|      0|        loader_log(inst, VULKAN_LOADER_ERROR_BIT, 0,
  319|      0|                   "parse_layers_disable_filter_environment_var: Failed to allocate space for parsing env var "
  320|      0|                   "\'VK_LAYERS_DISABLE_ENV_VAR\'");
  321|      0|        result = VK_ERROR_OUT_OF_HOST_MEMORY;
  322|      0|        goto out;
  323|      0|    }
  324|       |
  325|      0|    for (uint32_t iii = 0; iii < env_var_len; ++iii) {
  ------------------
  |  Branch (325:28): [True: 0, False: 0]
  ------------------
  326|      0|        parsing_string[iii] = (char)tolower((unsigned char)env_var_value[iii]);
  ------------------
  |  Branch (326:37): [True: 0, False: 0]
  |  Branch (326:37): [True: 0, False: 0]
  |  Branch (326:37): [Folded, False: 0]
  ------------------
  327|      0|    }
  328|      0|    parsing_string[env_var_len] = '\0';
  329|       |
  330|      0|    char *context = NULL;
  331|      0|    char *token = thread_safe_strtok(parsing_string, ",", &context);
  332|      0|    while (NULL != token) {
  ------------------
  |  Branch (332:12): [True: 0, False: 0]
  ------------------
  333|      0|        uint32_t cur_count = disable_struct->additional_filters.count;
  334|      0|        enum loader_filter_string_type cur_filter_type;
  335|      0|        const char *actual_start;
  336|      0|        size_t actual_len;
  337|      0|        determine_filter_type(token, &cur_filter_type, &actual_start, &actual_len);
  338|      0|        if (cur_filter_type == FILTER_STRING_SPECIAL) {
  ------------------
  |  Branch (338:13): [True: 0, False: 0]
  ------------------
  339|      0|            if (!strcmp(VK_LOADER_DISABLE_ALL_LAYERS_VAR_1, token) || !strcmp(VK_LOADER_DISABLE_ALL_LAYERS_VAR_2, token) ||
  ------------------
  |  |  124|      0|#define VK_LOADER_DISABLE_ALL_LAYERS_VAR_1 "~all~"
  ------------------
                          if (!strcmp(VK_LOADER_DISABLE_ALL_LAYERS_VAR_1, token) || !strcmp(VK_LOADER_DISABLE_ALL_LAYERS_VAR_2, token) ||
  ------------------
  |  |  125|      0|#define VK_LOADER_DISABLE_ALL_LAYERS_VAR_2 "*"
  ------------------
  |  Branch (339:17): [True: 0, False: 0]
  |  Branch (339:71): [True: 0, False: 0]
  ------------------
  340|      0|                !strcmp(VK_LOADER_DISABLE_ALL_LAYERS_VAR_3, token)) {
  ------------------
  |  |  126|      0|#define VK_LOADER_DISABLE_ALL_LAYERS_VAR_3 "**"
  ------------------
  |  Branch (340:17): [True: 0, False: 0]
  ------------------
  341|      0|                disable_struct->disable_all = true;
  342|      0|            } else if (!strcmp(VK_LOADER_DISABLE_IMPLICIT_LAYERS_VAR, token)) {
  ------------------
  |  |  127|      0|#define VK_LOADER_DISABLE_IMPLICIT_LAYERS_VAR "~implicit~"
  ------------------
  |  Branch (342:24): [True: 0, False: 0]
  ------------------
  343|      0|                disable_struct->disable_all_implicit = true;
  344|      0|            } else if (!strcmp(VK_LOADER_DISABLE_EXPLICIT_LAYERS_VAR, token)) {
  ------------------
  |  |  128|      0|#define VK_LOADER_DISABLE_EXPLICIT_LAYERS_VAR "~explicit~"
  ------------------
  |  Branch (344:24): [True: 0, False: 0]
  ------------------
  345|      0|                disable_struct->disable_all_explicit = true;
  346|      0|            }
  347|      0|        } else {
  348|       |            // Keep the stored length in sync with what actually fits (value is VK_MAX_EXTENSION_NAME_SIZE bytes including
  349|       |            // the null terminator) so the matcher never reads past the buffer.
  350|      0|            size_t stored_len = actual_len < VK_MAX_EXTENSION_NAME_SIZE - 1 ? actual_len : VK_MAX_EXTENSION_NAME_SIZE - 1;
  ------------------
  |  Branch (350:33): [True: 0, False: 0]
  ------------------
  351|      0|            loader_strncpy(disable_struct->additional_filters.filters[cur_count].value, VK_MAX_EXTENSION_NAME_SIZE, actual_start,
  352|      0|                           stored_len);
  353|      0|            disable_struct->additional_filters.filters[cur_count].value[stored_len] = '\0';
  354|      0|            disable_struct->additional_filters.filters[cur_count].length = stored_len;
  355|      0|            disable_struct->additional_filters.filters[cur_count].type = cur_filter_type;
  356|      0|            disable_struct->additional_filters.count++;
  357|      0|            if (disable_struct->additional_filters.count >= MAX_ADDITIONAL_FILTERS) {
  ------------------
  |  |  531|      0|#define MAX_ADDITIONAL_FILTERS 16
  ------------------
  |  Branch (357:17): [True: 0, False: 0]
  ------------------
  358|      0|                break;
  359|      0|            }
  360|      0|        }
  361|      0|        token = thread_safe_strtok(NULL, ",", &context);
  362|      0|    }
  363|  8.21k|out:
  364|  8.21k|    loader_instance_heap_free(inst, parsing_string);
  365|  8.21k|    loader_free_getenv(env_var_value, inst);
  366|  8.21k|    return result;
  367|      0|}
parse_layer_environment_var_filters:
  370|  8.21k|VkResult parse_layer_environment_var_filters(const struct loader_instance *inst, struct loader_envvar_all_filters *layer_filters) {
  371|  8.21k|    VkResult res = parse_generic_filter_environment_var(inst, VK_LAYERS_ENABLE_ENV_VAR, &layer_filters->enable_filter);
  ------------------
  |  |  119|  8.21k|#define VK_LAYERS_ENABLE_ENV_VAR "VK_LOADER_LAYERS_ENABLE"
  ------------------
  372|  8.21k|    if (VK_SUCCESS != res) {
  ------------------
  |  Branch (372:9): [True: 0, False: 8.21k]
  ------------------
  373|      0|        return res;
  374|      0|    }
  375|  8.21k|    res = parse_layers_disable_filter_environment_var(inst, &layer_filters->disable_filter);
  376|  8.21k|    if (VK_SUCCESS != res) {
  ------------------
  |  Branch (376:9): [True: 0, False: 8.21k]
  ------------------
  377|      0|        return res;
  378|      0|    }
  379|  8.21k|    res = parse_generic_filter_environment_var(inst, VK_LAYERS_ALLOW_ENV_VAR, &layer_filters->allow_filter);
  ------------------
  |  |  121|  8.21k|#define VK_LAYERS_ALLOW_ENV_VAR "VK_LOADER_LAYERS_ALLOW"
  ------------------
  380|  8.21k|    if (VK_SUCCESS != res) {
  ------------------
  |  Branch (380:9): [True: 0, False: 8.21k]
  ------------------
  381|      0|        return res;
  382|      0|    }
  383|  8.21k|    return res;
  384|  8.21k|}
check_name_matches_filter_environment_var:
  405|   330k|bool check_name_matches_filter_environment_var(const char *name, const struct loader_envvar_filter *filter_struct) {
  406|   330k|    bool ret_value = false;
  407|   330k|    size_t name_len = strlen(name);
  408|       |    // Compare each filter against `name` directly. name_segment_matches_filter_value does a case-insensitive compare
  409|       |    // (filter values are already lowercased at parse time), so there's no need to make a lowercased copy of name first
  410|       |    // and no limit on how long name can be.
  411|   495k|    for (uint32_t filt = 0; filt < filter_struct->count; ++filt) {
  ------------------
  |  Branch (411:29): [True: 165k, False: 330k]
  ------------------
  412|   165k|        const struct loader_envvar_filter_value *filter = &filter_struct->filters[filt];
  413|       |        // The filter (with its wildcards stripped) is longer than the name, so it can't possibly match.
  414|   165k|        if (filter->length > name_len) {
  ------------------
  |  Branch (414:13): [True: 128k, False: 37.0k]
  ------------------
  415|   128k|            continue;
  416|   128k|        }
  417|  37.0k|        switch (filter->type) {
  ------------------
  |  Branch (417:17): [True: 37.0k, False: 0]
  ------------------
  418|      0|            case FILTER_STRING_SPECIAL:
  ------------------
  |  Branch (418:13): [True: 0, False: 37.0k]
  ------------------
  419|      0|                if (!strcmp(VK_LOADER_DISABLE_ALL_LAYERS_VAR_1, filter->value) ||
  ------------------
  |  |  124|      0|#define VK_LOADER_DISABLE_ALL_LAYERS_VAR_1 "~all~"
  ------------------
  |  Branch (419:21): [True: 0, False: 0]
  ------------------
  420|      0|                    !strcmp(VK_LOADER_DISABLE_ALL_LAYERS_VAR_2, filter->value) ||
  ------------------
  |  |  125|      0|#define VK_LOADER_DISABLE_ALL_LAYERS_VAR_2 "*"
  ------------------
  |  Branch (420:21): [True: 0, False: 0]
  ------------------
  421|      0|                    !strcmp(VK_LOADER_DISABLE_ALL_LAYERS_VAR_3, filter->value)) {
  ------------------
  |  |  126|      0|#define VK_LOADER_DISABLE_ALL_LAYERS_VAR_3 "**"
  ------------------
  |  Branch (421:21): [True: 0, False: 0]
  ------------------
  422|      0|                    ret_value = true;
  423|      0|                }
  424|      0|                break;
  425|       |
  426|      0|            case FILTER_STRING_SUBSTRING:
  ------------------
  |  Branch (426:13): [True: 0, False: 37.0k]
  ------------------
  427|       |                // Slide the filter along the name looking for a match, stopping as soon as one is found.
  428|      0|                for (size_t start = 0; start + filter->length <= name_len; ++start) {
  ------------------
  |  Branch (428:40): [True: 0, False: 0]
  ------------------
  429|      0|                    if (name_segment_matches_filter_value(name + start, filter->value, filter->length)) {
  ------------------
  |  Branch (429:25): [True: 0, False: 0]
  ------------------
  430|      0|                        ret_value = true;
  431|      0|                        break;
  432|      0|                    }
  433|      0|                }
  434|      0|                break;
  435|       |
  436|      0|            case FILTER_STRING_SUFFIX:
  ------------------
  |  Branch (436:13): [True: 0, False: 37.0k]
  ------------------
  437|      0|                ret_value = name_segment_matches_filter_value(name + name_len - filter->length, filter->value, filter->length);
  438|      0|                break;
  439|       |
  440|      0|            case FILTER_STRING_PREFIX:
  ------------------
  |  Branch (440:13): [True: 0, False: 37.0k]
  ------------------
  441|      0|                ret_value = name_segment_matches_filter_value(name, filter->value, filter->length);
  442|      0|                break;
  443|       |
  444|  37.0k|            case FILTER_STRING_FULLNAME:
  ------------------
  |  Branch (444:13): [True: 37.0k, False: 0]
  ------------------
  445|  37.0k|                ret_value = (name_len == filter->length) && name_segment_matches_filter_value(name, filter->value, filter->length);
  ------------------
  |  Branch (445:29): [True: 2.49k, False: 34.5k]
  |  Branch (445:61): [True: 348, False: 2.14k]
  ------------------
  446|  37.0k|                break;
  447|  37.0k|        }
  448|  37.0k|        if (ret_value) {
  ------------------
  |  Branch (448:13): [True: 348, False: 36.7k]
  ------------------
  449|    348|            break;
  450|    348|        }
  451|  37.0k|    }
  452|   330k|    return ret_value;
  453|   330k|}
loader_environment.c:name_segment_matches_filter_value:
  390|  2.49k|static bool name_segment_matches_filter_value(const char *name_segment, const char *lowercase_filter_value, size_t count) {
  391|  3.63k|    for (size_t iii = 0; iii < count; ++iii) {
  ------------------
  |  Branch (391:26): [True: 3.28k, False: 348]
  ------------------
  392|  3.28k|        if ((char)tolower((unsigned char)name_segment[iii]) != lowercase_filter_value[iii]) {
  ------------------
  |  Branch (392:13): [True: 2.14k, False: 1.14k]
  |  Branch (392:19): [True: 0, False: 0]
  |  Branch (392:19): [True: 0, False: 0]
  |  Branch (392:19): [Folded, False: 3.28k]
  ------------------
  393|  2.14k|            return false;
  394|  2.14k|        }
  395|  3.28k|    }
  396|    348|    return true;
  397|  2.49k|}

loader_get_json:
  164|  89.6k|TEST_FUNCTION_EXPORT VkResult loader_get_json(const struct loader_instance *inst, const char *filename, cJSON **json) {
  165|  89.6k|    char *json_buf = NULL;
  166|  89.6k|    VkResult res = VK_SUCCESS;
  167|       |
  168|  89.6k|    assert(json != NULL);
  169|       |
  170|  89.6k|    size_t json_len = 0;
  171|  89.6k|    *json = NULL;
  172|  89.6k|    res = loader_read_entire_file(inst, filename, &json_len, &json_buf);
  173|  89.6k|    if (VK_SUCCESS != res) {
  ------------------
  |  Branch (173:9): [True: 3.26k, False: 86.4k]
  ------------------
  174|  3.26k|        goto out;
  175|  3.26k|    }
  176|  89.6k|    bool out_of_memory = false;
  177|       |    // Parse text from file
  178|  86.4k|    *json = loader_cJSON_ParseWithLength(inst ? &inst->alloc_callbacks : NULL, json_buf, json_len, &out_of_memory);
  ------------------
  |  Branch (178:42): [True: 86.4k, False: 0]
  ------------------
  179|  86.4k|    if (out_of_memory) {
  ------------------
  |  Branch (179:9): [True: 0, False: 86.4k]
  ------------------
  180|      0|        loader_log(inst, VULKAN_LOADER_ERROR_BIT, 0, "loader_get_json: Out of Memory error occurred while parsing JSON file %s.",
  181|      0|                   filename);
  182|      0|        res = VK_ERROR_OUT_OF_HOST_MEMORY;
  183|      0|        goto out;
  184|  86.4k|    } else if (*json == NULL) {
  ------------------
  |  Branch (184:16): [True: 58.1k, False: 28.2k]
  ------------------
  185|  58.1k|        loader_log(inst, VULKAN_LOADER_ERROR_BIT, 0, "loader_get_json: Invalid JSON file %s.", filename);
  186|  58.1k|        goto out;
  187|  58.1k|    }
  188|       |
  189|  89.6k|out:
  190|  89.6k|    loader_instance_heap_free(inst, json_buf);
  191|  89.6k|    if (res != VK_SUCCESS && *json != NULL) {
  ------------------
  |  Branch (191:9): [True: 3.26k, False: 86.4k]
  |  Branch (191:30): [True: 0, False: 3.26k]
  ------------------
  192|      0|        loader_cJSON_Delete(*json);
  193|      0|        *json = NULL;
  194|      0|    }
  195|       |
  196|  89.6k|    return res;
  197|  86.4k|}
loader_parse_json_string_to_existing_str:
  199|   550k|VkResult loader_parse_json_string_to_existing_str(cJSON *object, const char *key, size_t out_str_len, char *out_string) {
  200|   550k|    if (NULL == key) {
  ------------------
  |  Branch (200:9): [True: 0, False: 550k]
  ------------------
  201|      0|        return VK_ERROR_INITIALIZATION_FAILED;
  202|      0|    }
  203|   550k|    cJSON *item = loader_cJSON_GetObjectItem(object, key);
  204|   550k|    if (NULL == item) {
  ------------------
  |  Branch (204:9): [True: 44.9k, False: 505k]
  ------------------
  205|  44.9k|        return VK_ERROR_INITIALIZATION_FAILED;
  206|  44.9k|    }
  207|       |
  208|   505k|    if (item->type != cJSON_String || item->valuestring == NULL) {
  ------------------
  |  |  101|  1.01M|#define cJSON_String (1 << 4)
  ------------------
  |  Branch (208:9): [True: 1.35k, False: 504k]
  |  Branch (208:39): [True: 0, False: 504k]
  ------------------
  209|  1.35k|        return VK_ERROR_INITIALIZATION_FAILED;
  210|  1.35k|    }
  211|   505k|    bool out_of_memory = false;
  212|   504k|    bool success = loader_cJSON_PrintPreallocated(item, out_string, (int)out_str_len, cJSON_False);
  ------------------
  |  |   97|   504k|#define cJSON_False (1 << 0)
  ------------------
  213|   504k|    if (out_of_memory) {
  ------------------
  |  Branch (213:9): [True: 0, False: 504k]
  ------------------
  214|      0|        return VK_ERROR_OUT_OF_HOST_MEMORY;
  215|      0|    }
  216|   504k|    if (!success) {
  ------------------
  |  Branch (216:9): [True: 971, False: 503k]
  ------------------
  217|    971|        return VK_ERROR_INITIALIZATION_FAILED;
  218|    971|    }
  219|   503k|    return VK_SUCCESS;
  220|   504k|}
loader_parse_json_string:
  222|   656k|VkResult loader_parse_json_string(cJSON *object, const char *key, char **out_string) {
  223|   656k|    if (NULL == key) {
  ------------------
  |  Branch (223:9): [True: 0, False: 656k]
  ------------------
  224|      0|        return VK_ERROR_INITIALIZATION_FAILED;
  225|      0|    }
  226|       |
  227|   656k|    cJSON *item = loader_cJSON_GetObjectItem(object, key);
  228|   656k|    if (NULL == item || NULL == item->valuestring) {
  ------------------
  |  Branch (228:9): [True: 401k, False: 254k]
  |  Branch (228:25): [True: 198, False: 254k]
  ------------------
  229|   401k|        return VK_ERROR_INITIALIZATION_FAILED;
  230|   401k|    }
  231|       |
  232|   656k|    bool out_of_memory = false;
  233|   254k|    char *str = loader_cJSON_Print(item, &out_of_memory);
  234|   254k|    if (out_of_memory || NULL == str) {
  ------------------
  |  Branch (234:9): [True: 0, False: 254k]
  |  Branch (234:26): [True: 0, False: 254k]
  ------------------
  235|      0|        return VK_ERROR_OUT_OF_HOST_MEMORY;
  236|      0|    }
  237|   254k|    if (NULL != out_string) {
  ------------------
  |  Branch (237:9): [True: 254k, False: 0]
  ------------------
  238|   254k|        *out_string = str;
  239|   254k|    }
  240|   254k|    return VK_SUCCESS;
  241|   254k|}
loader_parse_json_array_of_strings:
  243|   382k|                                            struct loader_string_list *string_list) {
  244|   382k|    if (NULL == key) {
  ------------------
  |  Branch (244:9): [True: 0, False: 382k]
  ------------------
  245|      0|        return VK_ERROR_INITIALIZATION_FAILED;
  246|      0|    }
  247|   382k|    cJSON *item = loader_cJSON_GetObjectItem(object, key);
  248|   382k|    if (NULL == item) {
  ------------------
  |  Branch (248:9): [True: 192k, False: 189k]
  ------------------
  249|   192k|        return VK_ERROR_INITIALIZATION_FAILED;
  250|   192k|    }
  251|       |
  252|   189k|    uint32_t count = loader_cJSON_GetArraySize(item);
  253|   189k|    if (count == 0) {
  ------------------
  |  Branch (253:9): [True: 145k, False: 44.9k]
  ------------------
  254|   145k|        return VK_SUCCESS;
  255|   145k|    }
  256|       |
  257|  44.9k|    VkResult res = create_string_list(inst, count, string_list);
  258|  44.9k|    if (VK_ERROR_OUT_OF_HOST_MEMORY == res) {
  ------------------
  |  Branch (258:9): [True: 0, False: 44.9k]
  ------------------
  259|      0|        goto out;
  260|      0|    }
  261|  44.9k|    cJSON *element = NULL;
  262|  1.17M|    cJSON_ArrayForEach(element, item) {
  ------------------
  |  |  213|  1.20M|    for (element = (array != NULL) ? (array)->child : NULL; element != NULL; element = element->next)
  |  |  ------------------
  |  |  |  Branch (213:20): [True: 44.9k, False: 0]
  |  |  |  Branch (213:61): [True: 1.17M, False: 27.7k]
  |  |  ------------------
  ------------------
  263|  1.17M|        if (element->type != cJSON_String) {
  ------------------
  |  |  101|  1.17M|#define cJSON_String (1 << 4)
  ------------------
  |  Branch (263:13): [True: 17.1k, False: 1.16M]
  ------------------
  264|  17.1k|            return VK_ERROR_INITIALIZATION_FAILED;
  265|  17.1k|        }
  266|  1.17M|        bool out_of_memory = false;
  267|  1.16M|        char *out_data = loader_cJSON_Print(element, &out_of_memory);
  268|  1.16M|        if (out_of_memory) {
  ------------------
  |  Branch (268:13): [True: 0, False: 1.16M]
  ------------------
  269|      0|            res = VK_ERROR_OUT_OF_HOST_MEMORY;
  270|      0|            goto out;
  271|      0|        }
  272|  1.16M|        res = append_str_to_string_list(inst, string_list, out_data);
  273|  1.16M|        if (VK_ERROR_OUT_OF_HOST_MEMORY == res) {
  ------------------
  |  Branch (273:13): [True: 0, False: 1.16M]
  ------------------
  274|      0|            goto out;
  275|      0|        }
  276|  1.16M|    }
  277|  27.7k|out:
  278|  27.7k|    if (res == VK_ERROR_OUT_OF_HOST_MEMORY && NULL != string_list->list) {
  ------------------
  |  Branch (278:9): [True: 0, False: 27.7k]
  |  Branch (278:47): [True: 0, False: 0]
  ------------------
  279|      0|        free_string_list(inst, string_list);
  280|      0|    }
  281|       |
  282|  27.7k|    return res;
  283|  44.9k|}
loader_json.c:loader_read_entire_file:
  110|  89.6k|                                        char **out_buff) {
  111|  89.6k|    FILE *file = NULL;
  112|  89.6k|    struct stat stats = {0};
  113|  89.6k|    VkResult res = VK_SUCCESS;
  114|       |
  115|       |    // fprintf(stderr, "loader_get_json: Reading JSON file %s\n", filename);
  116|  89.6k|    file = fopen(filename, "rb");
  117|  89.6k|#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
  118|  89.6k|    if (file == NULL) {
  ------------------
  |  Branch (118:9): [True: 3.25k, False: 86.4k]
  ------------------
  119|  3.25k|        create_callback_file(filename);
  120|  3.25k|        file = fopen(filename, "rb");
  121|  3.25k|    }
  122|  89.6k|#endif
  123|  89.6k|    if (NULL == file) {
  ------------------
  |  Branch (123:9): [True: 3.25k, False: 86.4k]
  ------------------
  124|  3.25k|        loader_log(inst, VULKAN_LOADER_ERROR_BIT, 0, "loader_get_json: Failed to open JSON file %s", filename);
  125|  3.25k|        res = VK_ERROR_INITIALIZATION_FAILED;
  126|  3.25k|        goto out;
  127|  3.25k|    }
  128|  86.4k|    if (-1 == fstat(fileno(file), &stats)) {
  ------------------
  |  Branch (128:9): [True: 0, False: 86.4k]
  ------------------
  129|      0|        loader_log(inst, VULKAN_LOADER_ERROR_BIT, 0, "loader_get_json: Failed to read file size of JSON file %s", filename);
  130|      0|        res = VK_ERROR_INITIALIZATION_FAILED;
  131|      0|        goto out;
  132|      0|    }
  133|  86.4k|    *out_buff = (char *)loader_instance_heap_calloc(inst, stats.st_size + 1, VK_SYSTEM_ALLOCATION_SCOPE_COMMAND);
  134|  86.4k|    if (NULL == *out_buff) {
  ------------------
  |  Branch (134:9): [True: 0, False: 86.4k]
  ------------------
  135|      0|        loader_log(inst, VULKAN_LOADER_ERROR_BIT, 0, "loader_get_json: Failed to allocate memory to read JSON file %s", filename);
  136|      0|        res = VK_ERROR_OUT_OF_HOST_MEMORY;
  137|      0|        goto out;
  138|      0|    }
  139|  86.4k|    if (stats.st_size != (long int)fread(*out_buff, sizeof(char), stats.st_size, file)) {
  ------------------
  |  Branch (139:9): [True: 9, False: 86.4k]
  ------------------
  140|      9|        loader_log(inst, VULKAN_LOADER_ERROR_BIT, 0, "loader_get_json: Failed to read entire JSON file %s", filename);
  141|      9|        res = VK_ERROR_INITIALIZATION_FAILED;
  142|      9|        goto out;
  143|      9|    }
  144|  86.4k|    *out_len = stats.st_size + 1;
  145|       |    // out_buff was allocated with stats.st_size + 1 bytes above, and the fread check already verified the file's
  146|       |    // contents did not change size out from under us; this is the last valid byte.
  147|       |    // NOLINTNEXTLINE(clang-analyzer-security.ArrayBound)
  148|  86.4k|    (*out_buff)[stats.st_size] = '\0';
  149|       |
  150|  89.6k|out:
  151|  89.6k|    if (NULL != file) {
  ------------------
  |  Branch (151:9): [True: 86.4k, False: 3.25k]
  ------------------
  152|       |        // NOLINTNEXTLINE(cert-err33-c) - file was only opened for reading, nothing to flush; res already reflects any read failure
  153|  86.4k|        fclose(file);
  154|  86.4k|    }
  155|  89.6k|    return res;
  156|  86.4k|}

loader_init_global_debug_level:
   42|      2|void loader_init_global_debug_level(void) {
   43|      2|    char *env;
   44|      2|    char *orig;
   45|       |
   46|      2|    if (g_loader_debug > 0) return;
  ------------------
  |  Branch (46:9): [True: 0, False: 2]
  ------------------
   47|       |
   48|      2|    g_loader_debug = 0;
   49|       |
   50|       |    // Parse comma-separated debug options
   51|      2|    orig = env = loader_getenv("VK_LOADER_DEBUG", NULL);
   52|      2|    while (env) {
  ------------------
  |  Branch (52:12): [True: 0, False: 2]
  ------------------
   53|      0|        char *p = strchr(env, ',');
   54|      0|        size_t len;
   55|       |
   56|      0|        if (p) {
  ------------------
  |  Branch (56:13): [True: 0, False: 0]
  ------------------
   57|      0|            len = p - env;
   58|      0|        } else {
   59|      0|            len = strlen(env);
   60|      0|        }
   61|       |
   62|      0|        if (len > 0) {
  ------------------
  |  Branch (62:13): [True: 0, False: 0]
  ------------------
   63|      0|            if (strncmp(env, "all", len) == 0) {
  ------------------
  |  Branch (63:17): [True: 0, False: 0]
  ------------------
   64|      0|                g_loader_debug = ~0u;
   65|      0|            } else if (strncmp(env, "warn", len) == 0) {
  ------------------
  |  Branch (65:24): [True: 0, False: 0]
  ------------------
   66|      0|                g_loader_debug |= VULKAN_LOADER_WARN_BIT;
   67|      0|            } else if (strncmp(env, "info", len) == 0) {
  ------------------
  |  Branch (67:24): [True: 0, False: 0]
  ------------------
   68|      0|                g_loader_debug |= VULKAN_LOADER_INFO_BIT;
   69|      0|            } else if (strncmp(env, "perf", len) == 0) {
  ------------------
  |  Branch (69:24): [True: 0, False: 0]
  ------------------
   70|      0|                g_loader_debug |= VULKAN_LOADER_PERF_BIT;
   71|      0|            } else if (strncmp(env, "error", len) == 0) {
  ------------------
  |  Branch (71:24): [True: 0, False: 0]
  ------------------
   72|      0|                g_loader_debug |= VULKAN_LOADER_ERROR_BIT;
   73|      0|            } else if (strncmp(env, "debug", len) == 0) {
  ------------------
  |  Branch (73:24): [True: 0, False: 0]
  ------------------
   74|      0|                g_loader_debug |= VULKAN_LOADER_DEBUG_BIT;
   75|      0|            } else if (strncmp(env, "layer", len) == 0) {
  ------------------
  |  Branch (75:24): [True: 0, False: 0]
  ------------------
   76|      0|                g_loader_debug |= VULKAN_LOADER_LAYER_BIT;
   77|      0|            } else if (strncmp(env, "driver", len) == 0 || strncmp(env, "implem", len) == 0 || strncmp(env, "icd", len) == 0) {
  ------------------
  |  Branch (77:24): [True: 0, False: 0]
  |  Branch (77:60): [True: 0, False: 0]
  |  Branch (77:96): [True: 0, False: 0]
  ------------------
   78|      0|                g_loader_debug |= VULKAN_LOADER_DRIVER_BIT;
   79|      0|            }
   80|      0|        }
   81|       |
   82|      0|        if (!p) break;
  ------------------
  |  Branch (82:13): [True: 0, False: 0]
  ------------------
   83|       |
   84|      0|        env = p + 1;
   85|      0|    }
   86|       |
   87|       |    loader_free_getenv(orig, NULL);
   88|      2|}
generate_debug_flag_str:
   93|  1.25k|void generate_debug_flag_str(VkFlags msg_type, size_t cmd_line_size, char *cmd_line_msg) {
   94|  1.25k|    cmd_line_msg[0] = '\0';
   95|       |
   96|  1.25k|    if ((msg_type & VULKAN_LOADER_ERROR_BIT) != 0) {
  ------------------
  |  Branch (96:9): [True: 129, False: 1.13k]
  ------------------
   97|    129|        loader_strncat(cmd_line_msg, cmd_line_size, "ERROR", sizeof("ERROR"));
   98|    129|    }
   99|  1.25k|    if ((msg_type & VULKAN_LOADER_WARN_BIT) != 0) {
  ------------------
  |  Branch (99:9): [True: 131, False: 1.12k]
  ------------------
  100|    131|        if (strlen(cmd_line_msg) > 0) {
  ------------------
  |  Branch (100:13): [True: 114, False: 17]
  ------------------
  101|    114|            loader_strncat(cmd_line_msg, cmd_line_size, " | ", sizeof(" | "));
  102|    114|        }
  103|    131|        loader_strncat(cmd_line_msg, cmd_line_size, "WARNING", sizeof("WARNING"));
  104|    131|    }
  105|  1.25k|    if ((msg_type & VULKAN_LOADER_INFO_BIT) != 0) {
  ------------------
  |  Branch (105:9): [True: 134, False: 1.12k]
  ------------------
  106|    134|        if (strlen(cmd_line_msg) > 0) {
  ------------------
  |  Branch (106:13): [True: 117, False: 17]
  ------------------
  107|    117|            loader_strncat(cmd_line_msg, cmd_line_size, " | ", sizeof(" | "));
  108|    117|        }
  109|    134|        loader_strncat(cmd_line_msg, cmd_line_size, "INFO", sizeof("INFO"));
  110|    134|    }
  111|  1.25k|    if ((msg_type & VULKAN_LOADER_DEBUG_BIT) != 0) {
  ------------------
  |  Branch (111:9): [True: 136, False: 1.12k]
  ------------------
  112|    136|        if (strlen(cmd_line_msg) > 0) {
  ------------------
  |  Branch (112:13): [True: 120, False: 16]
  ------------------
  113|    120|            loader_strncat(cmd_line_msg, cmd_line_size, " | ", sizeof(" | "));
  114|    120|        }
  115|    136|        loader_strncat(cmd_line_msg, cmd_line_size, "DEBUG", sizeof("DEBUG"));
  116|    136|    }
  117|  1.25k|    if ((msg_type & VULKAN_LOADER_PERF_BIT) != 0) {
  ------------------
  |  Branch (117:9): [True: 147, False: 1.11k]
  ------------------
  118|    147|        if (strlen(cmd_line_msg) > 0) {
  ------------------
  |  Branch (118:13): [True: 122, False: 25]
  ------------------
  119|    122|            loader_strncat(cmd_line_msg, cmd_line_size, " | ", sizeof(" | "));
  120|    122|        }
  121|    147|        loader_strncat(cmd_line_msg, cmd_line_size, "PERF", sizeof("PERF"));
  122|    147|    }
  123|  1.25k|    if ((msg_type & VULKAN_LOADER_DRIVER_BIT) != 0) {
  ------------------
  |  Branch (123:9): [True: 137, False: 1.12k]
  ------------------
  124|    137|        if (strlen(cmd_line_msg) > 0) {
  ------------------
  |  Branch (124:13): [True: 121, False: 16]
  ------------------
  125|    121|            loader_strncat(cmd_line_msg, cmd_line_size, " | ", sizeof(" | "));
  126|    121|        }
  127|    137|        loader_strncat(cmd_line_msg, cmd_line_size, "DRIVER", sizeof("DRIVER"));
  128|    137|    }
  129|  1.25k|    if ((msg_type & VULKAN_LOADER_LAYER_BIT) != 0) {
  ------------------
  |  Branch (129:9): [True: 126, False: 1.13k]
  ------------------
  130|    126|        if (strlen(cmd_line_msg) > 0) {
  ------------------
  |  Branch (130:13): [True: 118, False: 8]
  ------------------
  131|    118|            loader_strncat(cmd_line_msg, cmd_line_size, " | ", sizeof(" | "));
  132|    118|        }
  133|    126|        loader_strncat(cmd_line_msg, cmd_line_size, "LAYER", sizeof("LAYER"));
  134|    126|    }
  135|       |
  136|  1.25k|#undef STRNCAT_TO_BUFFER
  137|  1.25k|}
loader_log:
  141|  1.78M|    loader_log(const struct loader_instance *inst, VkFlags msg_type, int32_t msg_code, const char *format, ...) {
  142|  1.78M|    (void)msg_code;
  143|  1.78M|    char msg[512] = {0};
  144|       |
  145|  1.78M|    va_list ap;
  146|  1.78M|    va_start(ap, format);
  147|  1.78M|    int ret = vsnprintf(msg, sizeof(msg), format, ap);
  148|  1.78M|    if ((ret >= (int)sizeof(msg)) || ret < 0) {
  ------------------
  |  Branch (148:9): [True: 2.68k, False: 1.78M]
  |  Branch (148:38): [True: 0, False: 1.78M]
  ------------------
  149|  2.68k|        msg[sizeof(msg) - 1] = '\0';
  150|  2.68k|    }
  151|  1.78M|    va_end(ap);
  152|       |
  153|  1.78M|    if (inst) {
  ------------------
  |  Branch (153:9): [True: 1.78M, False: 2]
  ------------------
  154|       |        // NOLINTNEXTLINE(clang-analyzer-optin.core.EnumCastOutOfRange) - external Vulkan enum, has no zero value we can add
  155|  1.78M|        VkDebugUtilsMessageSeverityFlagBitsEXT severity = 0;
  156|  1.78M|        VkDebugUtilsMessageTypeFlagsEXT type = 0;
  157|  1.78M|        VkDebugUtilsMessengerCallbackDataEXT callback_data = {0};
  158|  1.78M|        VkDebugUtilsObjectNameInfoEXT object_name = {0};
  159|       |
  160|       |        // NOLINTNEXTLINE(bugprone-branch-clone) - duplicated so combined bit calls (e.g. WARN_BIT|LAYER_BIT) match first branch
  161|  1.78M|        if ((msg_type & VULKAN_LOADER_INFO_BIT) != 0) {
  ------------------
  |  Branch (161:13): [True: 416k, False: 1.37M]
  ------------------
  162|   416k|            severity = VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT;
  163|  1.37M|        } else if ((msg_type & VULKAN_LOADER_WARN_BIT) != 0) {
  ------------------
  |  Branch (163:20): [True: 598k, False: 774k]
  ------------------
  164|   598k|            severity = VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT;
  165|   774k|        } else if ((msg_type & VULKAN_LOADER_ERROR_BIT) != 0) {
  ------------------
  |  Branch (165:20): [True: 77.7k, False: 696k]
  ------------------
  166|  77.7k|            severity = VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT;
  167|   696k|        } else if ((msg_type & VULKAN_LOADER_DEBUG_BIT) != 0) {
  ------------------
  |  Branch (167:20): [True: 428k, False: 267k]
  ------------------
  168|   428k|            severity = VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT;
  169|   428k|        } else if ((msg_type & VULKAN_LOADER_LAYER_BIT) != 0 || (msg_type & VULKAN_LOADER_DRIVER_BIT) != 0) {
  ------------------
  |  Branch (169:20): [True: 258k, False: 9.51k]
  |  Branch (169:65): [True: 9.51k, False: 0]
  ------------------
  170|       |            // Just driver or just layer bit should be treated as an info message in debug utils.
  171|   267k|            severity = VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT;
  172|   267k|        }
  173|       |
  174|  1.78M|        if ((msg_type & VULKAN_LOADER_PERF_BIT) != 0) {
  ------------------
  |  Branch (174:13): [True: 0, False: 1.78M]
  ------------------
  175|      0|            type = VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT;
  176|  1.78M|        } else if ((msg_type & VULKAN_LOADER_VALIDATION_BIT) != 0) {
  ------------------
  |  Branch (176:20): [True: 0, False: 1.78M]
  ------------------
  177|       |            // For loader logging, if it's a validation message, we still want to also keep the general flag as well
  178|       |            // so messages of type validation can still be triggered for general message callbacks.
  179|      0|            type = VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT;
  180|  1.78M|        } else {
  181|  1.78M|            type = VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT;
  182|  1.78M|        }
  183|       |
  184|  1.78M|        callback_data.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_MESSENGER_CALLBACK_DATA_EXT;
  185|  1.78M|        callback_data.pMessageIdName = "Loader Message";
  186|  1.78M|        callback_data.pMessage = msg;
  187|  1.78M|        callback_data.objectCount = 1;
  188|  1.78M|        callback_data.pObjects = &object_name;
  189|  1.78M|        object_name.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT;
  190|  1.78M|        object_name.objectType = VK_OBJECT_TYPE_INSTANCE;
  191|  1.78M|        object_name.objectHandle = (uint64_t)(uintptr_t)inst;
  192|       |
  193|  1.78M|        util_SubmitDebugUtilsMessageEXT(inst, severity, type, &callback_data);
  194|  1.78M|    }
  195|       |
  196|       |    // Always log to stderr if this is a fatal error
  197|  1.78M|    if (0 == (msg_type & VULKAN_LOADER_FATAL_ERROR_BIT)) {
  ------------------
  |  Branch (197:9): [True: 1.78M, False: 0]
  ------------------
  198|  1.78M|        if (inst && inst->settings.settings_active && inst->settings.debug_level > 0) {
  ------------------
  |  Branch (198:13): [True: 1.78M, False: 2]
  |  Branch (198:21): [True: 511k, False: 1.27M]
  |  Branch (198:55): [True: 41.3k, False: 470k]
  ------------------
  199|       |            // Exit early if the current instance settings have some debugging options but do match the current msg_type
  200|  41.3k|            if (0 == (msg_type & inst->settings.debug_level)) {
  ------------------
  |  Branch (200:17): [True: 8.41k, False: 32.8k]
  ------------------
  201|  8.41k|                return;
  202|  8.41k|            }
  203|       |            // Check the global settings and if that doesn't say to skip, check the environment variable
  204|  1.74M|        } else if (0 == (msg_type & g_loader_debug)) {
  ------------------
  |  Branch (204:20): [True: 1.74M, False: 0]
  ------------------
  205|  1.74M|            return;
  206|  1.74M|        }
  207|  1.78M|    }
  208|       |
  209|       |#if defined(DEBUG)
  210|       |    int debug_flag_mask =
  211|       |        (int)(msg_type & (VULKAN_LOADER_ERROR_BIT | VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_INFO_BIT | VULKAN_LOADER_DEBUG_BIT));
  212|       |    assert((debug_flag_mask == 0 || debug_flag_mask == VULKAN_LOADER_ERROR_BIT || debug_flag_mask == VULKAN_LOADER_WARN_BIT ||
  213|       |            debug_flag_mask == VULKAN_LOADER_INFO_BIT || debug_flag_mask == VULKAN_LOADER_DEBUG_BIT) &&
  214|       |           "This log has more than one exclusive debug flags (error, warn, info, debug) set");
  215|       |#endif
  216|       |
  217|       |    // Only need enough space to create the filter description header for log messages
  218|       |    // Also use the same header for all output
  219|  32.8k|    char cmd_line_msg[64] = {0};
  220|  32.8k|    size_t cmd_line_size = sizeof(cmd_line_msg);
  221|       |
  222|  32.8k|    loader_strncat(cmd_line_msg, cmd_line_size, "[Vulkan Loader] ", sizeof("[Vulkan Loader] "));
  223|       |
  224|  32.8k|    bool need_separator = false;
  225|  32.8k|    if ((msg_type & VULKAN_LOADER_ERROR_BIT) != 0) {
  ------------------
  |  Branch (225:9): [True: 4.96k, False: 27.9k]
  ------------------
  226|  4.96k|        loader_strncat(cmd_line_msg, cmd_line_size, "ERROR", sizeof("ERROR"));
  227|  4.96k|        need_separator = true;
  228|  27.9k|    } else if ((msg_type & VULKAN_LOADER_WARN_BIT) != 0) {
  ------------------
  |  Branch (228:16): [True: 8.90k, False: 19.0k]
  ------------------
  229|  8.90k|        loader_strncat(cmd_line_msg, cmd_line_size, "WARNING", sizeof("WARNING"));
  230|  8.90k|        need_separator = true;
  231|  19.0k|    } else if ((msg_type & VULKAN_LOADER_INFO_BIT) != 0) {
  ------------------
  |  Branch (231:16): [True: 6.96k, False: 12.0k]
  ------------------
  232|  6.96k|        loader_strncat(cmd_line_msg, cmd_line_size, "INFO", sizeof("INFO"));
  233|  6.96k|        need_separator = true;
  234|  12.0k|    } else if ((msg_type & VULKAN_LOADER_DEBUG_BIT) != 0) {
  ------------------
  |  Branch (234:16): [True: 1.22k, False: 10.8k]
  ------------------
  235|  1.22k|        loader_strncat(cmd_line_msg, cmd_line_size, "DEBUG", sizeof("DEBUG"));
  236|  1.22k|        need_separator = true;
  237|  1.22k|    }
  238|       |
  239|  32.8k|    if ((msg_type & VULKAN_LOADER_PERF_BIT) != 0) {
  ------------------
  |  Branch (239:9): [True: 0, False: 32.8k]
  ------------------
  240|      0|        if (need_separator) {
  ------------------
  |  Branch (240:13): [True: 0, False: 0]
  ------------------
  241|      0|            loader_strncat(cmd_line_msg, cmd_line_size, " | ", sizeof(" | "));
  242|      0|        }
  243|      0|        loader_strncat(cmd_line_msg, cmd_line_size, "PERF", sizeof("PERF"));
  244|  32.8k|    } else if ((msg_type & VULKAN_LOADER_DRIVER_BIT) != 0) {
  ------------------
  |  Branch (244:16): [True: 128, False: 32.7k]
  ------------------
  245|    128|        if (need_separator) {
  ------------------
  |  Branch (245:13): [True: 20, False: 108]
  ------------------
  246|     20|            loader_strncat(cmd_line_msg, cmd_line_size, " | ", sizeof(" | "));
  247|     20|        }
  248|    128|        loader_strncat(cmd_line_msg, cmd_line_size, "DRIVER", sizeof("DRIVER"));
  249|  32.7k|    } else if ((msg_type & VULKAN_LOADER_LAYER_BIT) != 0) {
  ------------------
  |  Branch (249:16): [True: 17.8k, False: 14.8k]
  ------------------
  250|  17.8k|        if (need_separator) {
  ------------------
  |  Branch (250:13): [True: 7.14k, False: 10.7k]
  ------------------
  251|  7.14k|            loader_strncat(cmd_line_msg, cmd_line_size, " | ", sizeof(" | "));
  252|  7.14k|        }
  253|  17.8k|        loader_strncat(cmd_line_msg, cmd_line_size, "LAYER", sizeof("LAYER"));
  254|  17.8k|    }
  255|       |
  256|  32.8k|    loader_strncat(cmd_line_msg, cmd_line_size, ": ", sizeof(": "));
  257|  32.8k|    size_t num_used = strlen(cmd_line_msg);
  258|       |
  259|       |    // Justifies the output to at least 29 spaces
  260|  32.8k|    if (num_used < 32) {
  ------------------
  |  Branch (260:9): [True: 31.5k, False: 1.30k]
  ------------------
  261|  31.5k|        const char space_buffer[] = "                                ";
  262|       |        // Only write (32 - num_used) spaces
  263|  31.5k|        loader_strncat(cmd_line_msg, cmd_line_size, space_buffer, sizeof(space_buffer) - 1 - num_used);
  264|  31.5k|    }
  265|       |    // Assert that we didn't write more than what is available in cmd_line_msg
  266|  32.8k|    assert(cmd_line_size > num_used);
  267|       |
  268|       |    // NOLINTBEGIN(cert-err33-c) - this is the logger itself; no sane recovery from a failed stderr write
  269|       |    //fputs(cmd_line_msg, stderr);
  270|       |    //fputs(msg, stderr);
  271|       |    //fputc('\n', stderr);
  272|       |    // NOLINTEND(cert-err33-c)
  273|       |#if defined(WIN32)
  274|       |    OutputDebugString(cmd_line_msg);
  275|       |    OutputDebugString(msg);
  276|       |    OutputDebugString("\n");
  277|       |#endif
  278|  32.8k|}

free_layer_configuration:
   41|   114k|void free_layer_configuration(const struct loader_instance* inst, loader_settings_layer_configuration* layer_configuration) {
   42|   114k|    loader_instance_heap_free(inst, layer_configuration->name);
   43|   114k|    loader_instance_heap_free(inst, layer_configuration->path);
   44|   114k|    memset(layer_configuration, 0, sizeof(loader_settings_layer_configuration));
   45|   114k|}
free_loader_settings:
   57|  8.21k|void free_loader_settings(const struct loader_instance* inst, loader_settings* settings) {
   58|  8.21k|    if (NULL != settings->layer_configurations) {
  ------------------
  |  Branch (58:9): [True: 914, False: 7.30k]
  ------------------
   59|  85.6k|        for (uint32_t i = 0; i < settings->layer_configuration_count; i++) {
  ------------------
  |  Branch (59:30): [True: 84.7k, False: 914]
  ------------------
   60|  84.7k|            free_layer_configuration(inst, &settings->layer_configurations[i]);
   61|  84.7k|        }
   62|    914|        loader_instance_heap_free(inst, settings->layer_configurations);
   63|    914|    }
   64|  8.21k|    if (NULL != settings->additional_drivers) {
  ------------------
  |  Branch (64:9): [True: 0, False: 8.21k]
  ------------------
   65|      0|        for (uint32_t i = 0; i < settings->additional_driver_count; i++) {
  ------------------
  |  Branch (65:30): [True: 0, False: 0]
  ------------------
   66|      0|            free_driver_configuration(inst, &settings->additional_drivers[i]);
   67|      0|        }
   68|      0|        loader_instance_heap_free(inst, settings->additional_drivers);
   69|      0|    }
   70|  8.21k|    if (NULL != settings->device_configurations) {
  ------------------
  |  Branch (70:9): [True: 0, False: 8.21k]
  ------------------
   71|      0|        for (uint32_t i = 0; i < settings->device_configuration_count; i++) {
  ------------------
  |  Branch (71:30): [True: 0, False: 0]
  ------------------
   72|      0|            free_device_configuration(inst, &settings->device_configurations[i]);
   73|      0|        }
   74|      0|        loader_instance_heap_free(inst, settings->device_configurations);
   75|      0|    }
   76|  8.21k|    loader_instance_heap_free(inst, settings->settings_file_path);
   77|  8.21k|    memset(settings, 0, sizeof(loader_settings));
   78|  8.21k|}
parse_control_string:
   80|  86.6k|loader_settings_layer_control parse_control_string(char* control_string) {
   81|  86.6k|    loader_settings_layer_control layer_control = LOADER_SETTINGS_LAYER_CONTROL_DEFAULT;
   82|  86.6k|    if (strcmp(control_string, "auto") == 0)
  ------------------
  |  Branch (82:9): [True: 550, False: 86.0k]
  ------------------
   83|    550|        layer_control = LOADER_SETTINGS_LAYER_CONTROL_DEFAULT;
   84|  86.0k|    else if (strcmp(control_string, "on") == 0)
  ------------------
  |  Branch (84:14): [True: 1.13k, False: 84.9k]
  ------------------
   85|  1.13k|        layer_control = LOADER_SETTINGS_LAYER_CONTROL_ON;
   86|  84.9k|    else if (strcmp(control_string, "off") == 0)
  ------------------
  |  Branch (86:14): [True: 61.4k, False: 23.4k]
  ------------------
   87|  61.4k|        layer_control = LOADER_SETTINGS_LAYER_CONTROL_OFF;
   88|  23.4k|    else if (strcmp(control_string, "unordered_layer_location") == 0)
  ------------------
  |  Branch (88:14): [True: 17.4k, False: 6.03k]
  ------------------
   89|  17.4k|        layer_control = LOADER_SETTINGS_LAYER_UNORDERED_LAYER_LOCATION;
   90|  86.6k|    return layer_control;
   91|  86.6k|}
loader_settings_layer_control_to_string:
   93|  84.7k|const char* loader_settings_layer_control_to_string(loader_settings_layer_control control) {
   94|  84.7k|    switch (control) {
   95|  5.27k|        case LOADER_SETTINGS_LAYER_CONTROL_DEFAULT:
  ------------------
  |  Branch (95:9): [True: 5.27k, False: 79.4k]
  ------------------
   96|  5.27k|            return "auto";
   97|    976|        case LOADER_SETTINGS_LAYER_CONTROL_ON:
  ------------------
  |  Branch (97:9): [True: 976, False: 83.7k]
  ------------------
   98|    976|            return "on";
   99|  61.2k|        case LOADER_SETTINGS_LAYER_CONTROL_OFF:
  ------------------
  |  Branch (99:9): [True: 61.2k, False: 23.5k]
  ------------------
  100|  61.2k|            return "off";
  101|  17.2k|        case LOADER_SETTINGS_LAYER_UNORDERED_LAYER_LOCATION:
  ------------------
  |  Branch (101:9): [True: 17.2k, False: 67.4k]
  ------------------
  102|  17.2k|            return "unordered_layer_location";
  103|      0|        default:
  ------------------
  |  Branch (103:9): [True: 0, False: 84.7k]
  ------------------
  104|      0|            return "UNKNOWN_LAYER_CONTROl";
  105|  84.7k|    }
  106|  84.7k|}
parse_log_filters_from_strings:
  108|    612|uint32_t parse_log_filters_from_strings(struct loader_string_list* log_filters) {
  109|    612|    uint32_t filters = 0;
  110|   812k|    for (uint32_t i = 0; i < log_filters->count; i++) {
  ------------------
  |  Branch (110:26): [True: 811k, False: 612]
  ------------------
  111|   811k|        if (strcmp(log_filters->list[i], "all") == 0)
  ------------------
  |  Branch (111:13): [True: 18.4k, False: 793k]
  ------------------
  112|  18.4k|            filters |= VULKAN_LOADER_INFO_BIT | VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_PERF_BIT | VULKAN_LOADER_ERROR_BIT |
  113|  18.4k|                       VULKAN_LOADER_DEBUG_BIT | VULKAN_LOADER_LAYER_BIT | VULKAN_LOADER_DRIVER_BIT | VULKAN_LOADER_VALIDATION_BIT;
  114|   793k|        else if (strcmp(log_filters->list[i], "info") == 0)
  ------------------
  |  Branch (114:18): [True: 239, False: 793k]
  ------------------
  115|    239|            filters |= VULKAN_LOADER_INFO_BIT;
  116|   793k|        else if (strcmp(log_filters->list[i], "warn") == 0)
  ------------------
  |  Branch (116:18): [True: 14.4k, False: 778k]
  ------------------
  117|  14.4k|            filters |= VULKAN_LOADER_WARN_BIT;
  118|   778k|        else if (strcmp(log_filters->list[i], "perf") == 0)
  ------------------
  |  Branch (118:18): [True: 631, False: 778k]
  ------------------
  119|    631|            filters |= VULKAN_LOADER_PERF_BIT;
  120|   778k|        else if (strcmp(log_filters->list[i], "error") == 0)
  ------------------
  |  Branch (120:18): [True: 259, False: 777k]
  ------------------
  121|    259|            filters |= VULKAN_LOADER_ERROR_BIT;
  122|   777k|        else if (strcmp(log_filters->list[i], "debug") == 0)
  ------------------
  |  Branch (122:18): [True: 595, False: 777k]
  ------------------
  123|    595|            filters |= VULKAN_LOADER_DEBUG_BIT;
  124|   777k|        else if (strcmp(log_filters->list[i], "layer") == 0)
  ------------------
  |  Branch (124:18): [True: 4.90k, False: 772k]
  ------------------
  125|  4.90k|            filters |= VULKAN_LOADER_LAYER_BIT;
  126|   772k|        else if (strcmp(log_filters->list[i], "driver") == 0)
  ------------------
  |  Branch (126:18): [True: 547, False: 771k]
  ------------------
  127|    547|            filters |= VULKAN_LOADER_DRIVER_BIT;
  128|   771k|        else if (strcmp(log_filters->list[i], "validation") == 0)
  ------------------
  |  Branch (128:18): [True: 238, False: 771k]
  ------------------
  129|    238|            filters |= VULKAN_LOADER_VALIDATION_BIT;
  130|   811k|    }
  131|    612|    return filters;
  132|    612|}
parse_layer_configuration:
  147|  86.6k|                                   loader_settings_layer_configuration* layer_configuration) {
  148|  86.6k|    char* control_string = NULL;
  149|  86.6k|    VkResult res = loader_parse_json_string(layer_configuration_json, "control", &control_string);
  150|  86.6k|    if (res != VK_SUCCESS) {
  ------------------
  |  Branch (150:9): [True: 33, False: 86.6k]
  ------------------
  151|     33|        goto out;
  152|     33|    }
  153|  86.6k|    layer_configuration->control = parse_control_string(control_string);
  154|  86.6k|    loader_instance_heap_free(inst, control_string);
  155|       |
  156|       |    // If that is the only value - do no further parsing
  157|  86.6k|    if (layer_configuration->control == LOADER_SETTINGS_LAYER_UNORDERED_LAYER_LOCATION) {
  ------------------
  |  Branch (157:9): [True: 17.4k, False: 69.1k]
  ------------------
  158|  17.4k|        goto out;
  159|  17.4k|    }
  160|       |
  161|  69.1k|    res = loader_parse_json_string(layer_configuration_json, "name", &(layer_configuration->name));
  162|  69.1k|    if (res != VK_SUCCESS) {
  ------------------
  |  Branch (162:9): [True: 223, False: 68.9k]
  ------------------
  163|    223|        goto out;
  164|    223|    }
  165|       |
  166|  68.9k|    res = loader_parse_json_string(layer_configuration_json, "path", &(layer_configuration->path));
  167|  68.9k|    if (res != VK_SUCCESS) {
  ------------------
  |  Branch (167:9): [True: 18, False: 68.9k]
  ------------------
  168|     18|        goto out;
  169|     18|    }
  170|       |
  171|  68.9k|    cJSON* treat_as_implicit_manifest = loader_cJSON_GetObjectItem(layer_configuration_json, "treat_as_implicit_manifest");
  172|  68.9k|    if (treat_as_implicit_manifest && treat_as_implicit_manifest->type == cJSON_True) {
  ------------------
  |  |   98|    431|#define cJSON_True (1 << 1)
  ------------------
  |  Branch (172:9): [True: 431, False: 68.4k]
  |  Branch (172:39): [True: 233, False: 198]
  ------------------
  173|    233|        layer_configuration->treat_as_implicit_manifest = true;
  174|    233|    }
  175|  86.6k|out:
  176|  86.6k|    if (VK_SUCCESS != res) {
  ------------------
  |  Branch (176:9): [True: 274, False: 86.3k]
  ------------------
  177|    274|        free_layer_configuration(inst, layer_configuration);
  178|    274|    }
  179|  86.6k|    return res;
  180|  68.9k|}
parse_layer_configurations:
  182|  1.99k|VkResult parse_layer_configurations(const struct loader_instance* inst, cJSON* settings_object, loader_settings* loader_settings) {
  183|  1.99k|    VkResult res = VK_SUCCESS;
  184|       |
  185|  1.99k|    cJSON* layer_configurations = loader_cJSON_GetObjectItem(settings_object, "layers");
  186|       |    // If the layers object isn't present, return early with success to allow the settings file to still apply
  187|  1.99k|    if (NULL == layer_configurations) {
  ------------------
  |  Branch (187:9): [True: 646, False: 1.34k]
  ------------------
  188|    646|        return VK_SUCCESS;
  189|    646|    }
  190|       |
  191|  1.34k|    uint32_t layer_configurations_count = loader_cJSON_GetArraySize(layer_configurations);
  192|  1.34k|    if (layer_configurations_count == 0) {
  ------------------
  |  Branch (192:9): [True: 146, False: 1.20k]
  ------------------
  193|    146|        loader_settings->layer_configurations_active = true;
  194|    146|        return VK_SUCCESS;
  195|    146|    }
  196|       |
  197|  1.20k|    loader_settings->layer_configuration_count = layer_configurations_count;
  198|       |
  199|  1.20k|    loader_settings->layer_configurations = loader_instance_heap_calloc(
  200|  1.20k|        inst, sizeof(loader_settings_layer_configuration) * layer_configurations_count, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
  201|  1.20k|    if (NULL == loader_settings->layer_configurations) {
  ------------------
  |  Branch (201:9): [True: 0, False: 1.20k]
  ------------------
  202|      0|        res = VK_ERROR_OUT_OF_HOST_MEMORY;
  203|      0|        goto out;
  204|      0|    }
  205|       |
  206|  1.20k|    cJSON* layer = NULL;
  207|  1.20k|    size_t i = 0;
  208|  86.6k|    cJSON_ArrayForEach(layer, layer_configurations) {
  ------------------
  |  |  213|  87.5k|    for (element = (array != NULL) ? (array)->child : NULL; element != NULL; element = element->next)
  |  |  ------------------
  |  |  |  Branch (213:20): [True: 1.20k, False: 0]
  |  |  |  Branch (213:61): [True: 86.6k, False: 914]
  |  |  ------------------
  ------------------
  209|  86.6k|        if (layer->type != cJSON_Object) {
  ------------------
  |  |  103|  86.6k|#define cJSON_Object (1 << 6)
  ------------------
  |  Branch (209:13): [True: 15, False: 86.6k]
  ------------------
  210|     15|            res = VK_ERROR_INITIALIZATION_FAILED;
  211|     15|            goto out;
  212|     15|        }
  213|  86.6k|        res = parse_layer_configuration(inst, layer, &(loader_settings->layer_configurations[i++]));
  214|  86.6k|        if (VK_SUCCESS != res) {
  ------------------
  |  Branch (214:13): [True: 274, False: 86.3k]
  ------------------
  215|    274|            goto out;
  216|    274|        }
  217|  86.6k|    }
  218|    914|    loader_settings->layer_configurations_active = true;
  219|  1.20k|out:
  220|  1.20k|    if (res != VK_SUCCESS) {
  ------------------
  |  Branch (220:9): [True: 289, False: 914]
  ------------------
  221|    289|        if (loader_settings->layer_configurations) {
  ------------------
  |  Branch (221:13): [True: 289, False: 0]
  ------------------
  222|  30.1k|            for (size_t index = 0; index < loader_settings->layer_configuration_count; index++) {
  ------------------
  |  Branch (222:36): [True: 29.8k, False: 289]
  ------------------
  223|  29.8k|                free_layer_configuration(inst, &(loader_settings->layer_configurations[index]));
  224|  29.8k|            }
  225|    289|            loader_settings->layer_configuration_count = 0;
  226|    289|            loader_instance_heap_free(inst, loader_settings->layer_configurations);
  227|    289|            loader_settings->layer_configurations = NULL;
  228|    289|        }
  229|    289|    }
  230|       |
  231|  1.20k|    return res;
  232|    914|}
parse_additional_drivers:
  248|  1.99k|VkResult parse_additional_drivers(const struct loader_instance* inst, cJSON* settings_object, loader_settings* loader_settings) {
  249|  1.99k|    VkResult res = VK_SUCCESS;
  250|       |
  251|  1.99k|    cJSON* additional_drivers_use_exclusively_json =
  252|  1.99k|        loader_cJSON_GetObjectItem(settings_object, "additional_drivers_use_exclusively");
  253|  1.99k|    if (additional_drivers_use_exclusively_json && additional_drivers_use_exclusively_json->type == cJSON_True) {
  ------------------
  |  |   98|      0|#define cJSON_True (1 << 1)
  ------------------
  |  Branch (253:9): [True: 0, False: 1.99k]
  |  Branch (253:52): [True: 0, False: 0]
  ------------------
  254|      0|        loader_settings->additional_drivers_use_exclusively = true;
  255|      0|    }
  256|       |
  257|  1.99k|    cJSON* additional_drivers_json = loader_cJSON_GetObjectItem(settings_object, "additional_drivers");
  258|  1.99k|    if (NULL == additional_drivers_json) {
  ------------------
  |  Branch (258:9): [True: 1.99k, False: 0]
  ------------------
  259|  1.99k|        return VK_SUCCESS;
  260|  1.99k|    }
  261|       |
  262|      0|    uint32_t additional_driver_count = loader_cJSON_GetArraySize(additional_drivers_json);
  263|      0|    if (additional_driver_count == 0) {
  ------------------
  |  Branch (263:9): [True: 0, False: 0]
  ------------------
  264|      0|        return VK_SUCCESS;
  265|      0|    }
  266|       |
  267|      0|    loader_settings->additional_driver_count = additional_driver_count;
  268|       |
  269|      0|    loader_settings->additional_drivers = loader_instance_heap_calloc(
  270|      0|        inst, sizeof(loader_settings_driver_configuration) * additional_driver_count, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
  271|      0|    if (NULL == loader_settings->additional_drivers) {
  ------------------
  |  Branch (271:9): [True: 0, False: 0]
  ------------------
  272|      0|        res = VK_ERROR_OUT_OF_HOST_MEMORY;
  273|      0|        goto out;
  274|      0|    }
  275|       |
  276|      0|    cJSON* driver = NULL;
  277|      0|    size_t i = 0;
  278|      0|    cJSON_ArrayForEach(driver, additional_drivers_json) {
  ------------------
  |  |  213|      0|    for (element = (array != NULL) ? (array)->child : NULL; element != NULL; element = element->next)
  |  |  ------------------
  |  |  |  Branch (213:20): [True: 0, False: 0]
  |  |  |  Branch (213:61): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  279|      0|        if (driver->type != cJSON_Object) {
  ------------------
  |  |  103|      0|#define cJSON_Object (1 << 6)
  ------------------
  |  Branch (279:13): [True: 0, False: 0]
  ------------------
  280|      0|            res = VK_ERROR_INITIALIZATION_FAILED;
  281|      0|            goto out;
  282|      0|        }
  283|      0|        res = parse_additional_driver(inst, driver, &(loader_settings->additional_drivers[i++]));
  284|      0|        if (VK_SUCCESS != res) {
  ------------------
  |  Branch (284:13): [True: 0, False: 0]
  ------------------
  285|      0|            goto out;
  286|      0|        }
  287|      0|    }
  288|      0|out:
  289|      0|    if (res != VK_SUCCESS) {
  ------------------
  |  Branch (289:9): [True: 0, False: 0]
  ------------------
  290|      0|        if (loader_settings->additional_drivers) {
  ------------------
  |  Branch (290:13): [True: 0, False: 0]
  ------------------
  291|      0|            for (size_t index = 0; index < loader_settings->additional_driver_count; index++) {
  ------------------
  |  Branch (291:36): [True: 0, False: 0]
  ------------------
  292|      0|                free_driver_configuration(inst, &(loader_settings->additional_drivers[index]));
  293|      0|            }
  294|      0|            loader_settings->additional_driver_count = 0;
  295|      0|            loader_instance_heap_free(inst, loader_settings->additional_drivers);
  296|       |            loader_settings->additional_drivers = NULL;
  297|      0|        }
  298|      0|    }
  299|      0|    return res;
  300|      0|}
parse_device_configurations:
  375|  1.99k|VkResult parse_device_configurations(const struct loader_instance* inst, cJSON* settings_object, loader_settings* loader_settings) {
  376|  1.99k|    VkResult res = VK_SUCCESS;
  377|       |
  378|  1.99k|    cJSON* device_configurations = loader_cJSON_GetObjectItem(settings_object, "device_configurations");
  379|  1.99k|    if (NULL == device_configurations) {
  ------------------
  |  Branch (379:9): [True: 1.99k, False: 0]
  ------------------
  380|  1.99k|        return VK_SUCCESS;
  381|  1.99k|    }
  382|       |
  383|      0|    uint32_t device_configuration_count = loader_cJSON_GetArraySize(device_configurations);
  384|      0|    if (device_configuration_count == 0) {
  ------------------
  |  Branch (384:9): [True: 0, False: 0]
  ------------------
  385|      0|        loader_settings->device_configurations_active = true;
  386|      0|        return VK_SUCCESS;
  387|      0|    }
  388|       |
  389|      0|    loader_settings->device_configuration_count = device_configuration_count;
  390|       |
  391|      0|    loader_settings->device_configurations = loader_instance_heap_calloc(
  392|      0|        inst, sizeof(loader_settings_device_configuration) * device_configuration_count, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
  393|      0|    if (NULL == loader_settings->device_configurations) {
  ------------------
  |  Branch (393:9): [True: 0, False: 0]
  ------------------
  394|      0|        res = VK_ERROR_OUT_OF_HOST_MEMORY;
  395|      0|        goto out;
  396|      0|    }
  397|       |
  398|      0|    cJSON* device = NULL;
  399|      0|    size_t i = 0;
  400|      0|    cJSON_ArrayForEach(device, device_configurations) {
  ------------------
  |  |  213|      0|    for (element = (array != NULL) ? (array)->child : NULL; element != NULL; element = element->next)
  |  |  ------------------
  |  |  |  Branch (213:20): [True: 0, False: 0]
  |  |  |  Branch (213:61): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  401|      0|        if (device->type != cJSON_Object) {
  ------------------
  |  |  103|      0|#define cJSON_Object (1 << 6)
  ------------------
  |  Branch (401:13): [True: 0, False: 0]
  ------------------
  402|      0|            res = VK_ERROR_INITIALIZATION_FAILED;
  403|      0|            goto out;
  404|      0|        }
  405|      0|        res = parse_device_configuration(inst, device, &(loader_settings->device_configurations[i]));
  406|      0|        if (res == VK_ERROR_OUT_OF_HOST_MEMORY) {
  ------------------
  |  Branch (406:13): [True: 0, False: 0]
  ------------------
  407|      0|            goto out;
  408|      0|        } else if (res != VK_SUCCESS) {
  ------------------
  |  Branch (408:20): [True: 0, False: 0]
  ------------------
  409|       |            // Skip a malformed entry rather than discarding every device configuration in the file
  410|      0|            res = VK_SUCCESS;
  411|      0|            continue;
  412|      0|        }
  413|      0|        i++;
  414|      0|    }
  415|       |    // Only the first i entries were successfully parsed; the trailing entries are unpopulated
  416|      0|    loader_settings->device_configuration_count = (uint32_t)i;
  417|      0|    loader_settings->device_configurations_active = true;
  418|      0|out:
  419|      0|    if (res != VK_SUCCESS) {
  ------------------
  |  Branch (419:9): [True: 0, False: 0]
  ------------------
  420|      0|        if (loader_settings->device_configurations) {
  ------------------
  |  Branch (420:13): [True: 0, False: 0]
  ------------------
  421|      0|            for (size_t index = 0; index < loader_settings->device_configuration_count; index++) {
  ------------------
  |  Branch (421:36): [True: 0, False: 0]
  ------------------
  422|      0|                free_device_configuration(inst, &(loader_settings->device_configurations[index]));
  423|      0|            }
  424|      0|            loader_settings->device_configuration_count = 0;
  425|      0|            loader_instance_heap_free(inst, loader_settings->device_configurations);
  426|       |            loader_settings->device_configurations = NULL;
  427|      0|        }
  428|      0|    }
  429|      0|    return res;
  430|      0|}
check_if_settings_path_exists:
  437|  34.9k|                                       char** settings_file_path) {
  438|  34.9k|    if (NULL == base || NULL == suffix) {
  ------------------
  |  Branch (438:9): [True: 16.4k, False: 18.5k]
  |  Branch (438:25): [True: 0, False: 18.5k]
  ------------------
  439|  16.4k|        return VK_ERROR_INITIALIZATION_FAILED;
  440|  16.4k|    }
  441|       |
  442|  18.5k|    size_t base_len = strlen(base);
  443|  18.5k|    size_t suffix_len = strlen(suffix);
  444|       |
  445|  18.5k|    uint32_t start = 0;
  446|  18.5k|    uint32_t stop = 0;
  447|  29.9k|    while (base[start] != '\0' && start < base_len && stop < base_len) {
  ------------------
  |  Branch (447:12): [True: 29.9k, False: 0]
  |  Branch (447:35): [True: 29.9k, False: 0]
  |  Branch (447:55): [True: 19.0k, False: 10.8k]
  ------------------
  448|  19.0k|        start = stop;
  449|  19.0k|        stop = start + 1;
  450|  93.9k|        while (base[stop] != PATH_SEPARATOR && base[stop] != '\0' && stop < base_len) {
  ------------------
  |  |  154|   187k|#define PATH_SEPARATOR ':'
  ------------------
  |  Branch (450:16): [True: 93.4k, False: 533]
  |  Branch (450:48): [True: 74.8k, False: 18.5k]
  |  Branch (450:70): [True: 74.8k, False: 0]
  ------------------
  451|  74.8k|            stop++;
  452|  74.8k|        }
  453|       |
  454|  19.0k|        size_t segment_len = (stop - start);
  455|  19.0k|        if (segment_len <= 1) {
  ------------------
  |  Branch (455:13): [True: 0, False: 19.0k]
  ------------------
  456|       |            // segment is *just* a PATH_SEPARATOR, skip it
  457|      0|            continue;
  458|      0|        }
  459|  19.0k|        size_t path_len = segment_len + suffix_len + 1;
  460|  19.0k|        *settings_file_path = loader_instance_heap_calloc(inst, path_len, VK_SYSTEM_ALLOCATION_SCOPE_COMMAND);
  461|  19.0k|        if (NULL == *settings_file_path) {
  ------------------
  |  Branch (461:13): [True: 0, False: 19.0k]
  ------------------
  462|      0|            return VK_ERROR_OUT_OF_HOST_MEMORY;
  463|      0|        }
  464|  19.0k|        loader_strncpy(*settings_file_path, path_len, base + start, segment_len);
  465|  19.0k|        loader_strncat(*settings_file_path, path_len, suffix, suffix_len);
  466|       |
  467|  19.0k|        if (loader_platform_file_exists(*settings_file_path)) {
  ------------------
  |  Branch (467:13): [True: 7.68k, False: 11.4k]
  ------------------
  468|  7.68k|            return VK_SUCCESS;
  469|  7.68k|        }
  470|  11.4k|        loader_instance_heap_free(inst, *settings_file_path);
  471|  11.4k|        *settings_file_path = NULL;
  472|  11.4k|    }
  473|       |
  474|  10.8k|    return VK_ERROR_INITIALIZATION_FAILED;
  475|  18.5k|}
get_unix_settings_path:
  478|  8.21k|VkResult get_unix_settings_path(const struct loader_instance* inst, char** settings_file_path) {
  479|       |    // First, get XDG env-vars we use. Don't need to worry about free'ing because on linux getenv is non-allocating
  480|  8.21k|    char* xdg_config_home = loader_secure_getenv("XDG_CONFIG_HOME", inst);
  481|  8.21k|    char* xdg_config_dirs = loader_secure_getenv("XDG_CONFIG_DIRS", inst);
  482|  8.21k|    char* xdg_data_home = loader_secure_getenv("XDG_DATA_HOME", inst);
  483|  8.21k|    char* xdg_data_dirs = loader_secure_getenv("XDG_DATA_DIRS", inst);
  484|       |
  485|       |    // Use fallback directories for xdg_config_dirs and xdg_data_dirs if they are NULL.
  486|  8.21k|#if !defined(__Fuchsia__) && !defined(__QNX__)
  487|  8.21k|    if (NULL == xdg_config_dirs || '\0' == xdg_config_dirs[0]) {
  ------------------
  |  Branch (487:9): [True: 8.21k, False: 0]
  |  Branch (487:36): [True: 0, False: 0]
  ------------------
  488|  8.21k|        xdg_config_dirs = FALLBACK_CONFIG_DIRS;
  489|  8.21k|    }
  490|  8.21k|#endif
  491|       |
  492|  8.21k|#if !defined(__Fuchsia__) && !defined(__QNX__)
  493|  8.21k|    if (NULL == xdg_data_dirs || '\0' == xdg_data_dirs[0]) {
  ------------------
  |  Branch (493:9): [True: 8.21k, False: 0]
  |  Branch (493:34): [True: 0, False: 0]
  ------------------
  494|  8.21k|        xdg_data_dirs = FALLBACK_DATA_DIRS;
  495|  8.21k|    }
  496|  8.21k|#endif
  497|       |
  498|  8.21k|    VkResult res = check_if_settings_path_exists(
  499|  8.21k|        inst, xdg_config_home, "/" VULKAN_DIR "/loader_settings.d/" VK_LOADER_SETTINGS_FILENAME, settings_file_path);
  ------------------
  |  |  145|  8.21k|#define VK_LOADER_SETTINGS_FILENAME "vk_loader_settings.json"
  ------------------
  500|  8.21k|    if (res == VK_SUCCESS) {
  ------------------
  |  Branch (500:9): [True: 0, False: 8.21k]
  ------------------
  501|      0|        return res;
  502|      0|    }
  503|       |
  504|  8.21k|    res = check_if_settings_path_exists(inst, xdg_data_home, "/" VULKAN_DIR "/loader_settings.d/" VK_LOADER_SETTINGS_FILENAME,
  ------------------
  |  |  145|  8.21k|#define VK_LOADER_SETTINGS_FILENAME "vk_loader_settings.json"
  ------------------
  505|  8.21k|                                        settings_file_path);
  506|  8.21k|    if (res == VK_SUCCESS) {
  ------------------
  |  Branch (506:9): [True: 0, False: 8.21k]
  ------------------
  507|      0|        return res;
  508|      0|    }
  509|       |
  510|       |    // Check home if either xdg_config_home or xdg_data_home wasn't set
  511|  8.21k|    char* home = loader_secure_getenv("HOME", inst);
  512|  8.21k|    if (home != NULL) {
  ------------------
  |  Branch (512:9): [True: 8.21k, False: 0]
  ------------------
  513|  8.21k|        if (NULL == xdg_config_home || '\0' == xdg_config_home[0]) {
  ------------------
  |  Branch (513:13): [True: 8.21k, False: 0]
  |  Branch (513:40): [True: 0, False: 0]
  ------------------
  514|  8.21k|            res = check_if_settings_path_exists(
  515|  8.21k|                inst, home, "/.config/" VULKAN_DIR "/loader_settings.d/" VK_LOADER_SETTINGS_FILENAME, settings_file_path);
  ------------------
  |  |  145|  8.21k|#define VK_LOADER_SETTINGS_FILENAME "vk_loader_settings.json"
  ------------------
  516|  8.21k|            if (res == VK_SUCCESS) {
  ------------------
  |  Branch (516:17): [True: 0, False: 8.21k]
  ------------------
  517|      0|                return res;
  518|      0|            }
  519|  8.21k|        }
  520|  8.21k|        if (NULL == xdg_data_home || '\0' == xdg_data_home[0]) {
  ------------------
  |  Branch (520:13): [True: 8.21k, False: 0]
  |  Branch (520:38): [True: 0, False: 0]
  ------------------
  521|  8.21k|            res = check_if_settings_path_exists(
  522|  8.21k|                inst, home, "/.local/share/" VULKAN_DIR "/loader_settings.d/" VK_LOADER_SETTINGS_FILENAME, settings_file_path);
  ------------------
  |  |  145|  8.21k|#define VK_LOADER_SETTINGS_FILENAME "vk_loader_settings.json"
  ------------------
  523|  8.21k|            if (res == VK_SUCCESS) {
  ------------------
  |  Branch (523:17): [True: 7.68k, False: 533]
  ------------------
  524|  7.68k|                return res;
  525|  7.68k|            }
  526|  8.21k|        }
  527|  8.21k|    }
  528|       |
  529|    533|    res = check_if_settings_path_exists(inst, xdg_config_dirs, "/" VULKAN_DIR "/loader_settings.d/" VK_LOADER_SETTINGS_FILENAME,
  ------------------
  |  |  145|    533|#define VK_LOADER_SETTINGS_FILENAME "vk_loader_settings.json"
  ------------------
  530|    533|                                        settings_file_path);
  531|    533|    if (res == VK_SUCCESS) {
  ------------------
  |  Branch (531:9): [True: 0, False: 533]
  ------------------
  532|      0|        return res;
  533|      0|    }
  534|       |
  535|    533|    res = check_if_settings_path_exists(inst, SYSCONFDIR, "/" VULKAN_DIR "/loader_settings.d/" VK_LOADER_SETTINGS_FILENAME,
  ------------------
  |  |  145|    533|#define VK_LOADER_SETTINGS_FILENAME "vk_loader_settings.json"
  ------------------
  536|    533|                                        settings_file_path);
  537|    533|    if (res == VK_SUCCESS) {
  ------------------
  |  Branch (537:9): [True: 0, False: 533]
  ------------------
  538|      0|        return res;
  539|      0|    }
  540|    533|#if defined(EXTRASYSCONFDIR)
  541|       |
  542|    533|    res = check_if_settings_path_exists(inst, EXTRASYSCONFDIR, "/" VULKAN_DIR "/loader_settings.d/" VK_LOADER_SETTINGS_FILENAME,
  ------------------
  |  |  145|    533|#define VK_LOADER_SETTINGS_FILENAME "vk_loader_settings.json"
  ------------------
  543|    533|                                        settings_file_path);
  544|    533|    if (res == VK_SUCCESS) {
  ------------------
  |  Branch (544:9): [True: 0, False: 533]
  ------------------
  545|      0|        return res;
  546|      0|    }
  547|    533|#endif
  548|    533|    res = check_if_settings_path_exists(inst, xdg_data_dirs, "/" VULKAN_DIR "/loader_settings.d/" VK_LOADER_SETTINGS_FILENAME,
  ------------------
  |  |  145|    533|#define VK_LOADER_SETTINGS_FILENAME "vk_loader_settings.json"
  ------------------
  549|    533|                                        settings_file_path);
  550|    533|    if (res == VK_SUCCESS) {
  ------------------
  |  Branch (550:9): [True: 0, False: 533]
  ------------------
  551|      0|        return res;
  552|      0|    }
  553|       |
  554|    533|    return VK_ERROR_INITIALIZATION_FAILED;
  555|    533|}
log_settings:
  614|  1.25k|void log_settings(const struct loader_instance* inst, loader_settings* settings) {
  615|  1.25k|    if (settings == NULL) {
  ------------------
  |  Branch (615:9): [True: 0, False: 1.25k]
  ------------------
  616|      0|        return;
  617|      0|    }
  618|  1.25k|    loader_log(inst, VULKAN_LOADER_INFO_BIT, 0, "Using layer configurations found in loader settings from %s",
  619|  1.25k|               settings->settings_file_path);
  620|       |
  621|  1.25k|    char cmd_line_msg[64] = {0};
  622|  1.25k|    size_t cmd_line_size = sizeof(cmd_line_msg);
  623|       |
  624|  1.25k|    cmd_line_msg[0] = '\0';
  625|       |
  626|  1.25k|    generate_debug_flag_str(settings->debug_level, cmd_line_size, cmd_line_msg);
  627|  1.25k|    if (strlen(cmd_line_msg)) {
  ------------------
  |  Branch (627:9): [True: 228, False: 1.03k]
  ------------------
  628|    228|        loader_log(inst, VULKAN_LOADER_DEBUG_BIT, 0, "Loader Settings Filters for Logging to Standard Error: %s", cmd_line_msg);
  629|    228|    }
  630|  1.25k|    if (settings->layer_configurations_active) {
  ------------------
  |  Branch (630:9): [True: 1.06k, False: 199]
  ------------------
  631|  1.06k|        loader_log(inst, VULKAN_LOADER_DEBUG_BIT, 0, "Layer Configurations count = %d", settings->layer_configuration_count);
  632|  85.7k|        for (uint32_t i = 0; i < settings->layer_configuration_count; i++) {
  ------------------
  |  Branch (632:30): [True: 84.7k, False: 1.06k]
  ------------------
  633|  84.7k|            loader_log(inst, VULKAN_LOADER_DEBUG_BIT, 0, "---- Layer Configuration [%d] ----", i);
  634|  84.7k|            if (settings->layer_configurations[i].control != LOADER_SETTINGS_LAYER_UNORDERED_LAYER_LOCATION) {
  ------------------
  |  Branch (634:17): [True: 67.4k, False: 17.2k]
  ------------------
  635|  67.4k|                loader_log(inst, VULKAN_LOADER_DEBUG_BIT, 0, "Name: %s", settings->layer_configurations[i].name);
  636|  67.4k|                loader_log(inst, VULKAN_LOADER_DEBUG_BIT, 0, "Path: %s", settings->layer_configurations[i].path);
  637|  67.4k|                loader_log(inst, VULKAN_LOADER_DEBUG_BIT, 0, "Layer Type: %s",
  638|  67.4k|                           settings->layer_configurations[i].treat_as_implicit_manifest ? "Implicit" : "Explicit");
  ------------------
  |  Branch (638:28): [True: 233, False: 67.2k]
  ------------------
  639|  67.4k|            }
  640|  84.7k|            loader_log(inst, VULKAN_LOADER_DEBUG_BIT, 0, "Control: %s",
  641|  84.7k|                       loader_settings_layer_control_to_string(settings->layer_configurations[i].control));
  642|  84.7k|        }
  643|  1.06k|    }
  644|  1.25k|    if (settings->additional_driver_count > 0) {
  ------------------
  |  Branch (644:9): [True: 0, False: 1.25k]
  ------------------
  645|      0|        loader_log(inst, VULKAN_LOADER_DEBUG_BIT, 0, "----");
  646|      0|        loader_log(inst, VULKAN_LOADER_DEBUG_BIT, 0, "Use Additional Drivers Exclusively = %s",
  647|      0|                   settings->additional_drivers_use_exclusively ? "true" : "false");
  ------------------
  |  Branch (647:20): [True: 0, False: 0]
  ------------------
  648|      0|        loader_log(inst, VULKAN_LOADER_DEBUG_BIT, 0, "Additional Driver Configurations count = %d",
  649|      0|                   settings->additional_driver_count);
  650|      0|        for (uint32_t i = 0; i < settings->additional_driver_count; i++) {
  ------------------
  |  Branch (650:30): [True: 0, False: 0]
  ------------------
  651|      0|            loader_log(inst, VULKAN_LOADER_DEBUG_BIT, 0, "---- Driver Configuration [%d] ----", i);
  652|      0|            loader_log(inst, VULKAN_LOADER_DEBUG_BIT, 0, "Path: %s", settings->additional_drivers[i].path);
  653|      0|        }
  654|      0|    }
  655|  1.25k|    if (settings->device_configurations_active) {
  ------------------
  |  Branch (655:9): [True: 0, False: 1.25k]
  ------------------
  656|      0|        loader_log(inst, VULKAN_LOADER_DEBUG_BIT, 0, "----");
  657|      0|        loader_log(inst, VULKAN_LOADER_DEBUG_BIT, 0, "Device Configurations count = %d", settings->device_configuration_count);
  658|      0|        for (uint32_t i = 0; i < settings->device_configuration_count; i++) {
  ------------------
  |  Branch (658:30): [True: 0, False: 0]
  ------------------
  659|      0|            loader_log(inst, VULKAN_LOADER_DEBUG_BIT, 0, "---- Device Configuration [%d] ----", i);
  660|      0|            char device_uuid_str[UUID_STR_LEN] = {0};
  661|      0|            loader_log_generate_uuid_string(settings->device_configurations[i].deviceUUID, device_uuid_str);
  662|      0|            char driver_uuid_str[UUID_STR_LEN] = {0};
  663|      0|            loader_log_generate_uuid_string(settings->device_configurations[i].driverUUID, driver_uuid_str);
  664|      0|            loader_log(inst, VULKAN_LOADER_DEBUG_BIT, 0, "deviceUUID: %s", device_uuid_str);
  665|      0|            loader_log(inst, VULKAN_LOADER_DEBUG_BIT, 0, "driverUUID: %s", driver_uuid_str);
  666|      0|            loader_log(inst, VULKAN_LOADER_DEBUG_BIT, 0, "driverVersion: %d", settings->device_configurations[i].driverVersion);
  667|      0|            if ('\0' != settings->device_configurations[i].deviceName[0]) {
  ------------------
  |  Branch (667:17): [True: 0, False: 0]
  ------------------
  668|      0|                loader_log(inst, VULKAN_LOADER_DEBUG_BIT, 0, "deviceName: %s", settings->device_configurations[i].deviceName);
  669|      0|            }
  670|      0|            if ('\0' != settings->device_configurations[i].driverName[0]) {
  ------------------
  |  Branch (670:17): [True: 0, False: 0]
  ------------------
  671|      0|                loader_log(inst, VULKAN_LOADER_DEBUG_BIT, 0, "driverName: %s", settings->device_configurations[i].driverName);
  672|      0|            }
  673|      0|        }
  674|      0|    }
  675|  1.25k|    loader_log(inst, VULKAN_LOADER_DEBUG_BIT, 0, "---------------------------------");
  676|  1.25k|}
get_loader_settings:
  681|  8.21k|VkResult get_loader_settings(const struct loader_instance* inst, loader_settings* loader_settings) {
  682|  8.21k|    VkResult res = VK_SUCCESS;
  683|  8.21k|    cJSON* json = NULL;
  684|  8.21k|    char* file_format_version_string = NULL;
  685|  8.21k|    char* settings_file_path = NULL;
  686|       |#if defined(WIN32)
  687|       |    res = windows_get_loader_settings_file_path(inst, &settings_file_path);
  688|       |    if (res != VK_SUCCESS) {
  689|       |        loader_log(inst, VULKAN_LOADER_INFO_BIT, 0,
  690|       |                   "No valid vk_loader_settings.json file found, no loader settings will be active");
  691|       |        goto out;
  692|       |    }
  693|       |
  694|       |#elif COMMON_UNIX_PLATFORMS
  695|       |    res = get_unix_settings_path(inst, &settings_file_path);
  696|  8.21k|    if (res != VK_SUCCESS) {
  ------------------
  |  Branch (696:9): [True: 533, False: 7.68k]
  ------------------
  697|    533|        loader_log(inst, VULKAN_LOADER_INFO_BIT, 0,
  698|    533|                   "No valid vk_loader_settings.json file found, no loader settings will be active");
  699|    533|        goto out;
  700|    533|    }
  701|       |#else
  702|       |#warning "Unsupported platform - must specify platform specific location for vk_loader_settings.json"
  703|       |#endif
  704|       |
  705|  7.68k|    res = loader_get_json(inst, settings_file_path, &json);
  706|       |    // Make sure sure the top level json value is an object
  707|  7.68k|    if (res != VK_SUCCESS || NULL == json || json->type != cJSON_Object) {
  ------------------
  |  |  103|  7.13k|#define cJSON_Object (1 << 6)
  ------------------
  |  Branch (707:9): [True: 13, False: 7.66k]
  |  Branch (707:30): [True: 536, False: 7.13k]
  |  Branch (707:46): [True: 114, False: 7.01k]
  ------------------
  708|    663|        goto out;
  709|    663|    }
  710|       |
  711|  7.01k|    res = loader_parse_json_string(json, "file_format_version", &file_format_version_string);
  712|  7.01k|    if (res != VK_SUCCESS) {
  ------------------
  |  Branch (712:9): [True: 13, False: 7.00k]
  ------------------
  713|     13|        if (res != VK_ERROR_OUT_OF_HOST_MEMORY) {
  ------------------
  |  Branch (713:13): [True: 13, False: 0]
  ------------------
  714|     13|            loader_log(
  715|     13|                inst, VULKAN_LOADER_DEBUG_BIT, 0,
  716|     13|                "Loader settings file from %s missing required field file_format_version - no loader settings will be active",
  717|     13|                settings_file_path);
  718|     13|        }
  719|     13|        goto out;
  720|     13|    }
  721|       |
  722|       |    // Because the file may contain either a "settings_array" or a single "settings" object, we need to create a cJSON so that we
  723|       |    // can iterate on both cases with common code
  724|  7.00k|    cJSON settings_iter_parent = {0};
  725|       |
  726|  7.00k|    cJSON* settings_array = loader_cJSON_GetObjectItem(json, "settings_array");
  727|  7.00k|    cJSON* single_settings_object = loader_cJSON_GetObjectItem(json, "settings");
  728|  7.00k|    if (NULL != settings_array) {
  ------------------
  |  Branch (728:9): [True: 2.08k, False: 4.92k]
  ------------------
  729|  2.08k|        memcpy(&settings_iter_parent, settings_array, sizeof(cJSON));
  730|  4.92k|    } else if (NULL != single_settings_object) {
  ------------------
  |  Branch (730:16): [True: 117, False: 4.80k]
  ------------------
  731|    117|        settings_iter_parent.child = single_settings_object;
  732|  4.80k|    } else {
  733|  4.80k|        loader_log(inst, VULKAN_LOADER_DEBUG_BIT, 0,
  734|  4.80k|                   "Loader settings file from %s missing required settings objects: Either one of the \"settings\" or "
  735|  4.80k|                   "\"settings_array\" objects must be present - no loader settings will be active",
  736|  4.80k|                   settings_file_path);
  737|  4.80k|        res = VK_ERROR_INITIALIZATION_FAILED;
  738|  4.80k|        goto out;
  739|  4.80k|    }
  740|       |
  741|       |    // Corresponds to the settings object that has no app keys
  742|  2.20k|    cJSON* global_settings = NULL;
  743|       |    // Corresponds to the settings object which has a matching app key
  744|  2.20k|    cJSON* settings_to_use = NULL;
  745|       |
  746|  2.20k|    char current_process_path[1024];
  747|  2.20k|    bool valid_exe_path = NULL != loader_platform_executable_path(current_process_path, 1024);
  748|       |
  749|  2.20k|    cJSON* settings_object_iter = NULL;
  750|  2.92k|    cJSON_ArrayForEach(settings_object_iter, &settings_iter_parent) {
  ------------------
  |  |  213|  5.06k|    for (element = (array != NULL) ? (array)->child : NULL; element != NULL; element = element->next)
  |  |  ------------------
  |  |  |  Branch (213:20): [True: 2.20k, Folded]
  |  |  |  Branch (213:61): [True: 2.92k, False: 2.14k]
  |  |  ------------------
  ------------------
  751|  2.92k|        if (settings_object_iter->type != cJSON_Object) {
  ------------------
  |  |  103|  2.92k|#define cJSON_Object (1 << 6)
  ------------------
  |  Branch (751:13): [True: 54, False: 2.86k]
  ------------------
  752|     54|            loader_log(inst, VULKAN_LOADER_DEBUG_BIT, 0,
  753|     54|                       "Loader settings file from %s has a settings element that is not an object", settings_file_path);
  754|     54|            break;
  755|     54|        }
  756|       |
  757|  2.86k|        cJSON* app_keys = loader_cJSON_GetObjectItem(settings_object_iter, "app_keys");
  758|  2.86k|        if (NULL == app_keys) {
  ------------------
  |  Branch (758:13): [True: 2.26k, False: 601]
  ------------------
  759|       |            // use the first 'global' settings that has no app keys as the global one
  760|  2.26k|            if (global_settings == NULL) {
  ------------------
  |  Branch (760:17): [True: 1.99k, False: 270]
  ------------------
  761|  1.99k|                global_settings = settings_object_iter;
  762|  1.99k|            }
  763|  2.26k|            continue;
  764|  2.26k|        }
  765|       |        // No sense iterating if we couldn't get the executable path
  766|    601|        if (!valid_exe_path) {
  ------------------
  |  Branch (766:13): [True: 0, False: 601]
  ------------------
  767|      0|            break;
  768|      0|        }
  769|    601|        cJSON* app_key = NULL;
  770|  1.20k|        cJSON_ArrayForEach(app_key, app_keys) {
  ------------------
  |  |  213|  1.80k|    for (element = (array != NULL) ? (array)->child : NULL; element != NULL; element = element->next)
  |  |  ------------------
  |  |  |  Branch (213:20): [True: 601, False: 0]
  |  |  |  Branch (213:61): [True: 1.20k, False: 601]
  |  |  ------------------
  ------------------
  771|  1.20k|            char* app_key_str = loader_cJSON_GetStringValue(app_key);
  772|  1.20k|            if (app_key_str && strcmp(current_process_path, app_key_str) == 0) {
  ------------------
  |  Branch (772:17): [True: 568, False: 635]
  |  Branch (772:32): [True: 0, False: 568]
  ------------------
  773|      0|                settings_to_use = settings_object_iter;
  774|      0|                break;
  775|      0|            }
  776|  1.20k|        }
  777|       |
  778|       |        // Break if we have found a matching current_process_path
  779|    601|        if (NULL != settings_to_use) {
  ------------------
  |  Branch (779:13): [True: 0, False: 601]
  ------------------
  780|      0|            break;
  781|      0|        }
  782|    601|    }
  783|       |
  784|       |    // No app specific settings match - either use global settings or exit
  785|  2.20k|    if (settings_to_use == NULL) {
  ------------------
  |  Branch (785:9): [True: 2.20k, False: 0]
  ------------------
  786|  2.20k|        if (global_settings == NULL) {
  ------------------
  |  Branch (786:13): [True: 208, False: 1.99k]
  ------------------
  787|    208|            loader_log(inst, VULKAN_LOADER_DEBUG_BIT, 0,
  788|    208|                       "Loader settings file from %s missing global settings and none of the app specific settings matched the "
  789|    208|                       "current application - no loader settings will be active",
  790|    208|                       settings_file_path);
  791|    208|            goto out;  // No global settings were found - exit
  792|  1.99k|        } else {
  793|  1.99k|            settings_to_use = global_settings;  // Global settings are present - use it
  794|  1.99k|        }
  795|  2.20k|    }
  796|       |
  797|       |    // optional
  798|  1.99k|    cJSON* stderr_filter = loader_cJSON_GetObjectItem(settings_to_use, "stderr_log");
  799|  1.99k|    if (NULL != stderr_filter) {
  ------------------
  |  Branch (799:9): [True: 612, False: 1.38k]
  ------------------
  800|    612|        struct loader_string_list stderr_log = {0};
  801|    612|        VkResult stderr_log_result = VK_SUCCESS;
  802|    612|        stderr_log_result = loader_parse_json_array_of_strings(inst, settings_to_use, "stderr_log", &stderr_log);
  803|    612|        if (VK_ERROR_OUT_OF_HOST_MEMORY == stderr_log_result) {
  ------------------
  |  Branch (803:13): [True: 0, False: 612]
  ------------------
  804|      0|            res = VK_ERROR_OUT_OF_HOST_MEMORY;
  805|      0|            goto out;
  806|      0|        }
  807|       |        // NOLINTNEXTLINE(clang-analyzer-optin.core.EnumCastOutOfRange) - 0xFF is a valid bitwise-OR of all flags (the "all" filter)
  808|    612|        loader_settings->debug_level = parse_log_filters_from_strings(&stderr_log);
  809|    612|        free_string_list(inst, &stderr_log);
  810|    612|    }
  811|       |
  812|       |    // optional
  813|  1.99k|    cJSON* logs_to_use = loader_cJSON_GetObjectItem(settings_to_use, "log_locations");
  814|  1.99k|    if (NULL != logs_to_use) {
  ------------------
  |  Branch (814:9): [True: 50, False: 1.94k]
  ------------------
  815|     50|        cJSON* log_element = NULL;
  816|  1.25k|        cJSON_ArrayForEach(log_element, logs_to_use) {
  ------------------
  |  |  213|  1.30k|    for (element = (array != NULL) ? (array)->child : NULL; element != NULL; element = element->next)
  |  |  ------------------
  |  |  |  Branch (213:20): [True: 50, False: 0]
  |  |  |  Branch (213:61): [True: 1.25k, False: 50]
  |  |  ------------------
  ------------------
  817|       |            // bool is_valid = true;
  818|  1.25k|            struct loader_string_list log_destinations = {0};
  819|  1.25k|            VkResult parse_dest_res = loader_parse_json_array_of_strings(inst, log_element, "destinations", &log_destinations);
  820|  1.25k|            if (parse_dest_res != VK_SUCCESS) {
  ------------------
  |  Branch (820:17): [True: 1.00k, False: 254]
  ------------------
  821|       |                // is_valid = false;
  822|  1.00k|            }
  823|  1.25k|            free_string_list(inst, &log_destinations);
  824|  1.25k|            struct loader_string_list log_filters = {0};
  825|  1.25k|            VkResult parse_filters_res = loader_parse_json_array_of_strings(inst, log_element, "filters", &log_filters);
  826|  1.25k|            if (parse_filters_res != VK_SUCCESS) {
  ------------------
  |  Branch (826:17): [True: 820, False: 436]
  ------------------
  827|       |                // is_valid = false;
  828|    820|            }
  829|  1.25k|            free_string_list(inst, &log_filters);
  830|  1.25k|        }
  831|     50|    }
  832|       |
  833|  1.99k|    VkResult layer_configurations_res = parse_layer_configurations(inst, settings_to_use, loader_settings);
  834|  1.99k|    if (VK_ERROR_OUT_OF_HOST_MEMORY == layer_configurations_res) {
  ------------------
  |  Branch (834:9): [True: 0, False: 1.99k]
  ------------------
  835|      0|        res = layer_configurations_res;
  836|      0|        goto out;
  837|      0|    }
  838|       |
  839|       |    // Determine if there exists a layer configuration indicating where to put layers not contained in the settings file
  840|       |    // LOADER_SETTINGS_LAYER_UNORDERED_LAYER_LOCATION
  841|  64.6k|    for (uint32_t i = 0; i < loader_settings->layer_configuration_count; i++) {
  ------------------
  |  Branch (841:26): [True: 63.2k, False: 1.37k]
  ------------------
  842|  63.2k|        if (loader_settings->layer_configurations[i].control == LOADER_SETTINGS_LAYER_UNORDERED_LAYER_LOCATION) {
  ------------------
  |  Branch (842:13): [True: 625, False: 62.6k]
  ------------------
  843|    625|            loader_settings->has_unordered_layer_location = true;
  844|    625|            break;
  845|    625|        }
  846|  63.2k|    }
  847|       |
  848|  1.99k|    VkResult additional_drivers_res = parse_additional_drivers(inst, settings_to_use, loader_settings);
  849|  1.99k|    if (VK_ERROR_OUT_OF_HOST_MEMORY == additional_drivers_res) {
  ------------------
  |  Branch (849:9): [True: 0, False: 1.99k]
  ------------------
  850|      0|        res = additional_drivers_res;
  851|      0|        goto out;
  852|      0|    }
  853|       |
  854|  1.99k|    VkResult device_configurations_res = parse_device_configurations(inst, settings_to_use, loader_settings);
  855|  1.99k|    if (VK_ERROR_OUT_OF_HOST_MEMORY == device_configurations_res) {
  ------------------
  |  Branch (855:9): [True: 0, False: 1.99k]
  ------------------
  856|      0|        res = device_configurations_res;
  857|      0|        goto out;
  858|      0|    }
  859|       |
  860|       |    // Only consider the settings active if there is at least one "setting" active.
  861|       |    // Those are either logging, layers, additional_drivers, or device_configurations.
  862|  1.99k|    if (loader_settings->debug_level != 0 || loader_settings->layer_configurations_active ||
  ------------------
  |  Branch (862:9): [True: 238, False: 1.75k]
  |  Branch (862:46): [True: 1.02k, False: 736]
  ------------------
  863|  1.25k|        loader_settings->additional_driver_count != 0 || loader_settings->device_configurations_active) {
  ------------------
  |  Branch (863:9): [True: 0, False: 736]
  |  Branch (863:58): [True: 0, False: 736]
  ------------------
  864|  1.25k|        loader_settings->settings_file_path = settings_file_path;
  865|  1.25k|        settings_file_path = NULL;
  866|  1.25k|        loader_settings->settings_active = true;
  867|  1.25k|    } else {
  868|    736|        loader_log(inst, VULKAN_LOADER_INFO_BIT, 0,
  869|    736|                   "vk_loader_settings.json file found at \"%s\" but did not contain any valid settings.", settings_file_path);
  870|    736|    }
  871|  8.21k|out:
  872|  8.21k|    if (NULL != json) {
  ------------------
  |  Branch (872:9): [True: 7.13k, False: 1.08k]
  ------------------
  873|  7.13k|        loader_cJSON_Delete(json);
  874|  7.13k|    }
  875|       |
  876|  8.21k|    loader_instance_heap_free(inst, settings_file_path);
  877|       |
  878|  8.21k|    loader_instance_heap_free(inst, file_format_version_string);
  879|  8.21k|    return res;
  880|  1.99k|}
init_global_loader_settings:
  901|      2|void init_global_loader_settings(void) {
  902|      2|    loader_platform_thread_create_mutex(&global_loader_settings_lock);
  903|       |    // Free out the global settings in case the process was loaded & unloaded
  904|       |    free_loader_settings(NULL, &global_loader_settings);
  905|      2|}
get_current_settings_and_lock:
  921|  10.5k|const loader_settings* get_current_settings_and_lock(const struct loader_instance* inst) {
  922|  10.5k|    if (inst) {
  ------------------
  |  Branch (922:9): [True: 10.5k, False: 0]
  ------------------
  923|  10.5k|        return &inst->settings;
  924|  10.5k|    }
  925|      0|    loader_platform_thread_lock_mutex(&global_loader_settings_lock);
  926|      0|    return &global_loader_settings;
  927|  10.5k|}
release_current_settings_lock:
  929|  10.5k|void release_current_settings_lock(const struct loader_instance* inst) {
  930|  10.5k|    if (inst == NULL) {
  ------------------
  |  Branch (930:9): [True: 0, False: 10.5k]
  ------------------
  931|      0|        loader_platform_thread_unlock_mutex(&global_loader_settings_lock);
  932|      0|    }
  933|  10.5k|}
get_settings_layers:
  936|  8.21k|                                                  bool* should_search_for_other_layers) {
  937|  8.21k|    VkResult res = VK_SUCCESS;
  938|  8.21k|    *should_search_for_other_layers = true;  // default to true
  939|       |
  940|  8.21k|    const loader_settings* settings = get_current_settings_and_lock(inst);
  941|       |
  942|  8.21k|    if (NULL == settings || !settings->settings_active || !settings->layer_configurations_active) {
  ------------------
  |  Branch (942:9): [True: 0, False: 8.21k]
  |  Branch (942:29): [True: 6.95k, False: 1.25k]
  |  Branch (942:59): [True: 199, False: 1.06k]
  ------------------
  943|  7.15k|        goto out;
  944|  7.15k|    }
  945|       |
  946|       |    // Assume the list doesn't contain LOADER_SETTINGS_LAYER_UNORDERED_LAYER_LOCATION at first
  947|  1.06k|    *should_search_for_other_layers = false;
  948|       |
  949|  85.7k|    for (uint32_t i = 0; i < settings->layer_configuration_count; i++) {
  ------------------
  |  Branch (949:26): [True: 84.7k, False: 1.06k]
  ------------------
  950|  84.7k|        loader_settings_layer_configuration* layer_config = &settings->layer_configurations[i];
  951|       |
  952|       |        // If we encountered a layer that should be forced off, we add it to the settings_layers list but only
  953|       |        // with the data required to compare it with layers not in the settings file (aka name and manifest path)
  954|  84.7k|        if (layer_config->control == LOADER_SETTINGS_LAYER_CONTROL_OFF) {
  ------------------
  |  Branch (954:13): [True: 61.2k, False: 23.5k]
  ------------------
  955|  61.2k|            struct loader_layer_properties props = {0};
  956|  61.2k|            props.settings_control_value = LOADER_SETTINGS_LAYER_CONTROL_OFF;
  957|  61.2k|            loader_strncpy(props.info.layerName, VK_MAX_EXTENSION_NAME_SIZE, layer_config->name, VK_MAX_EXTENSION_NAME_SIZE);
  958|  61.2k|            props.info.layerName[VK_MAX_EXTENSION_NAME_SIZE - 1] = '\0';
  959|  61.2k|            res = loader_copy_to_new_str(inst, layer_config->path, &props.manifest_file_name);
  960|  61.2k|            if (VK_ERROR_OUT_OF_HOST_MEMORY == res) {
  ------------------
  |  Branch (960:17): [True: 0, False: 61.2k]
  ------------------
  961|      0|                goto out;
  962|      0|            }
  963|  61.2k|            res = loader_append_layer_property(inst, settings_layers, &props);
  964|  61.2k|            if (VK_ERROR_OUT_OF_HOST_MEMORY == res) {
  ------------------
  |  Branch (964:17): [True: 0, False: 61.2k]
  ------------------
  965|      0|                loader_free_layer_properties(inst, &props);
  966|      0|                goto out;
  967|      0|            }
  968|  61.2k|            continue;
  969|  61.2k|        }
  970|       |
  971|       |        // The special layer location that indicates where unordered layers should go only should have the
  972|       |        // settings_control_value set - everything else should be NULL
  973|  23.5k|        if (layer_config->control == LOADER_SETTINGS_LAYER_UNORDERED_LAYER_LOCATION) {
  ------------------
  |  Branch (973:13): [True: 17.2k, False: 6.25k]
  ------------------
  974|  17.2k|            struct loader_layer_properties props = {0};
  975|  17.2k|            props.settings_control_value = LOADER_SETTINGS_LAYER_UNORDERED_LAYER_LOCATION;
  976|  17.2k|            res = loader_append_layer_property(inst, settings_layers, &props);
  977|  17.2k|            if (VK_ERROR_OUT_OF_HOST_MEMORY == res) {
  ------------------
  |  Branch (977:17): [True: 0, False: 17.2k]
  ------------------
  978|      0|                loader_free_layer_properties(inst, &props);
  979|      0|                goto out;
  980|      0|            }
  981|  17.2k|            *should_search_for_other_layers = true;
  982|  17.2k|            continue;
  983|  17.2k|        }
  984|       |
  985|  6.25k|        if (layer_config->path == NULL) {
  ------------------
  |  Branch (985:13): [True: 0, False: 6.25k]
  ------------------
  986|      0|            continue;
  987|      0|        }
  988|       |
  989|  6.25k|        if (!is_json(layer_config->path, strlen(layer_config->path))) {
  ------------------
  |  Branch (989:13): [True: 5.30k, False: 948]
  ------------------
  990|  5.30k|            continue;
  991|  5.30k|        }
  992|       |
  993|    948|        cJSON* json = NULL;
  994|    948|        VkResult local_res = loader_get_json(inst, layer_config->path, &json);
  995|    948|        if (VK_ERROR_OUT_OF_HOST_MEMORY == local_res) {
  ------------------
  |  Branch (995:13): [True: 0, False: 948]
  ------------------
  996|      0|            res = VK_ERROR_OUT_OF_HOST_MEMORY;
  997|      0|            goto out;
  998|    948|        } else if (VK_SUCCESS != local_res || NULL == json) {
  ------------------
  |  Branch (998:20): [True: 454, False: 494]
  |  Branch (998:47): [True: 163, False: 331]
  ------------------
  999|    617|            continue;
 1000|    617|        }
 1001|       |
 1002|       |        // Makes it possible to know if a new layer was added or not, since the only return value is VkResult
 1003|    331|        uint32_t count_before_adding = settings_layers->count;
 1004|       |
 1005|    331|        local_res =
 1006|    331|            loader_add_layer_properties(inst, settings_layers, json, layer_config->treat_as_implicit_manifest, layer_config->path);
 1007|    331|        loader_cJSON_Delete(json);
 1008|       |
 1009|       |        // If the error is anything other than out of memory we still want to try to load the other layers
 1010|    331|        if (VK_ERROR_OUT_OF_HOST_MEMORY == local_res) {
  ------------------
  |  Branch (1010:13): [True: 0, False: 331]
  ------------------
 1011|      0|            res = VK_ERROR_OUT_OF_HOST_MEMORY;
 1012|      0|            goto out;
 1013|    331|        } else if (local_res != VK_SUCCESS || count_before_adding == settings_layers->count) {
  ------------------
  |  Branch (1013:20): [True: 242, False: 89]
  |  Branch (1013:47): [True: 0, False: 89]
  ------------------
 1014|       |            // Indicates something was wrong with the layer, can't add it to the list
 1015|    242|            continue;
 1016|    242|        }
 1017|       |
 1018|    564|        for (uint32_t j = count_before_adding; j < settings_layers->count; j++) {
  ------------------
  |  Branch (1018:48): [True: 475, False: 89]
  ------------------
 1019|    475|            struct loader_layer_properties* newly_added_layer = &settings_layers->list[j];
 1020|    475|            newly_added_layer->settings_control_value = layer_config->control;
 1021|       |            // If the manifest file found has a name that differs from the one in the settings, remove this layer from
 1022|       |            // consideration
 1023|    475|            if (strncmp(newly_added_layer->info.layerName, layer_config->name, VK_MAX_EXTENSION_NAME_SIZE) != 0) {
  ------------------
  |  Branch (1023:17): [True: 94, False: 381]
  ------------------
 1024|     94|                loader_remove_layer_in_list(inst, settings_layers, j);
 1025|     94|                j--;
 1026|     94|                continue;
 1027|     94|            }
 1028|    475|            bool should_remove = false;
 1029|       |            // Make sure the layer isn't already in the list
 1030|  7.28k|            for (uint32_t k = 0; k < j; k++) {
  ------------------
  |  Branch (1030:34): [True: 7.11k, False: 167]
  ------------------
 1031|  7.11k|                if (0 == strncmp(settings_layers->list[k].info.layerName, newly_added_layer->info.layerName,
  ------------------
  |  Branch (1031:21): [True: 6.14k, False: 967]
  ------------------
 1032|  7.11k|                                 VK_MAX_EXTENSION_NAME_SIZE)) {
 1033|  6.14k|                    if (0 == (newly_added_layer->type_flags & VK_LAYER_TYPE_FLAG_META_LAYER) &&
  ------------------
  |  Branch (1033:25): [True: 3.88k, False: 2.26k]
  ------------------
 1034|  3.88k|                        settings_layers->list[k].lib_name != NULL && newly_added_layer->lib_name != NULL &&
  ------------------
  |  Branch (1034:25): [True: 3.17k, False: 708]
  |  Branch (1034:70): [True: 3.17k, False: 0]
  ------------------
 1035|  3.17k|                        strcmp(settings_layers->list[k].lib_name, newly_added_layer->lib_name) == 0) {
  ------------------
  |  Branch (1035:25): [True: 214, False: 2.95k]
  ------------------
 1036|    214|                        should_remove = true;
 1037|    214|                        break;
 1038|    214|                    }
 1039|  6.14k|                }
 1040|  7.11k|            }
 1041|    381|            if (should_remove) {
  ------------------
  |  Branch (1041:17): [True: 214, False: 167]
  ------------------
 1042|    214|                loader_remove_layer_in_list(inst, settings_layers, j);
 1043|    214|                j--;
 1044|    214|            }
 1045|    381|        }
 1046|     89|    }
 1047|       |
 1048|  8.21k|out:
 1049|  8.21k|    release_current_settings_lock(inst);
 1050|  8.21k|    return res;
 1051|  1.06k|}
check_if_layer_is_in_list:
 1062|  28.3k|                               bool consider_lib_path) {
 1063|       |    // If the layer is a meta layer, just check against the name
 1064|   151k|    for (uint32_t i = 0; i < layer_list->count; i++) {
  ------------------
  |  Branch (1064:26): [True: 146k, False: 5.20k]
  ------------------
 1065|   146k|        if (0 == strncmp(layer_list->list[i].info.layerName, layer_property->info.layerName, VK_MAX_EXTENSION_NAME_SIZE)) {
  ------------------
  |  Branch (1065:13): [True: 72.5k, False: 74.2k]
  ------------------
 1066|  72.5k|            if (layer_list->list[i].settings_control_value == LOADER_SETTINGS_LAYER_CONTROL_OFF) {
  ------------------
  |  Branch (1066:17): [True: 15.3k, False: 57.2k]
  ------------------
 1067|  15.3k|                return true;
 1068|  15.3k|            }
 1069|  57.2k|            if (VK_LAYER_TYPE_FLAG_META_LAYER == (layer_property->type_flags & VK_LAYER_TYPE_FLAG_META_LAYER)) {
  ------------------
  |  Branch (1069:17): [True: 5.50k, False: 51.7k]
  ------------------
 1070|  5.50k|                return true;
 1071|  5.50k|            }
 1072|  51.7k|            if (!consider_lib_path) {
  ------------------
  |  Branch (1072:17): [True: 218, False: 51.4k]
  ------------------
 1073|    218|                return true;
 1074|    218|            }
 1075|  51.4k|            if (layer_list->list[i].lib_name && layer_property->lib_name) {
  ------------------
  |  Branch (1075:17): [True: 4.97k, False: 46.5k]
  |  Branch (1075:49): [True: 2.10k, False: 2.87k]
  ------------------
 1076|  2.10k|                return strcmp(layer_list->list[i].lib_name, layer_property->lib_name) == 0;
 1077|  2.10k|            }
 1078|  51.4k|        }
 1079|   146k|    }
 1080|  5.20k|    return false;
 1081|  28.3k|}
combine_settings_layers_with_regular_layers:
 1085|  7.78k|                                                     struct loader_layer_list* output_layers) {
 1086|  7.78k|    VkResult res = VK_SUCCESS;
 1087|  7.78k|    bool has_unordered_layer_location = false;
 1088|  7.78k|    uint32_t unordered_layer_location_index = 0;
 1089|       |    // Location to put layers that aren't known to the settings file
 1090|       |    // Find it here so we dont have to pass in a loader_settings struct
 1091|  23.6k|    for (uint32_t i = 0; i < settings_layers->count; i++) {
  ------------------
  |  Branch (1091:26): [True: 16.4k, False: 7.15k]
  ------------------
 1092|  16.4k|        if (settings_layers->list[i].settings_control_value == LOADER_SETTINGS_LAYER_UNORDERED_LAYER_LOCATION) {
  ------------------
  |  Branch (1092:13): [True: 625, False: 15.8k]
  ------------------
 1093|    625|            has_unordered_layer_location = true;
 1094|    625|            unordered_layer_location_index = i;
 1095|    625|            break;
 1096|    625|        }
 1097|  16.4k|    }
 1098|       |
 1099|  7.78k|    if (settings_layers->count == 0 && regular_layers->count == 0) {
  ------------------
  |  Branch (1099:9): [True: 7.15k, False: 625]
  |  Branch (1099:40): [True: 3.83k, False: 3.31k]
  ------------------
 1100|       |        // No layers to combine
 1101|  3.83k|        goto out;
 1102|  3.94k|    } else if (settings_layers->count == 0) {
  ------------------
  |  Branch (1102:16): [True: 3.31k, False: 625]
  ------------------
 1103|       |        // No settings layers - just copy regular to output_layers - memset regular layers to prevent double frees
 1104|  3.31k|        *output_layers = *regular_layers;
 1105|  3.31k|        memset(regular_layers, 0, sizeof(struct loader_layer_list));
 1106|  3.31k|        goto out;
 1107|  3.31k|    } else if (regular_layers->count == 0 || !has_unordered_layer_location) {
  ------------------
  |  Branch (1107:16): [True: 61, False: 564]
  |  Branch (1107:46): [True: 0, False: 564]
  ------------------
 1108|       |        // No regular layers or has_unordered_layer_location is false - just copy settings to output_layers -
 1109|       |        // memset settings layers to prevent double frees
 1110|     61|        *output_layers = *settings_layers;
 1111|     61|        memset(settings_layers, 0, sizeof(struct loader_layer_list));
 1112|     61|        goto out;
 1113|     61|    }
 1114|       |
 1115|    564|    res = loader_init_generic_list(inst, (struct loader_generic_list*)output_layers,
 1116|    564|                                   (settings_layers->count + regular_layers->count) * sizeof(struct loader_layer_properties));
 1117|    564|    if (VK_SUCCESS != res) {
  ------------------
  |  Branch (1117:9): [True: 0, False: 564]
  ------------------
 1118|      0|        goto out;
 1119|      0|    }
 1120|       |
 1121|       |    // Insert the settings layers into output_layers up to unordered_layer_index
 1122|  15.8k|    for (uint32_t i = 0; i < unordered_layer_location_index; i++) {
  ------------------
  |  Branch (1122:26): [True: 15.2k, False: 564]
  ------------------
 1123|  15.2k|        if (!check_if_layer_is_in_list(output_layers, &settings_layers->list[i], true)) {
  ------------------
  |  Branch (1123:13): [True: 2.41k, False: 12.8k]
  ------------------
 1124|  2.41k|            res = loader_append_layer_property(inst, output_layers, &settings_layers->list[i]);
 1125|  2.41k|            if (VK_SUCCESS != res) {
  ------------------
  |  Branch (1125:17): [True: 0, False: 2.41k]
  ------------------
 1126|      0|                goto out;
 1127|      0|            }
 1128|  2.41k|        }
 1129|  15.2k|    }
 1130|       |
 1131|  6.82k|    for (uint32_t i = 0; i < regular_layers->count; i++) {
  ------------------
  |  Branch (1131:26): [True: 6.25k, False: 564]
  ------------------
 1132|       |        // Check if its already been put in the output_layers list as well as the remaining settings_layers
 1133|  6.25k|        bool regular_layer_is_ordered = check_if_layer_is_in_list(output_layers, &regular_layers->list[i], false) ||
  ------------------
  |  Branch (1133:41): [True: 4.49k, False: 1.76k]
  ------------------
 1134|  1.76k|                                        check_if_layer_is_in_list(settings_layers, &regular_layers->list[i], false);
  ------------------
  |  Branch (1134:41): [True: 1.00k, False: 760]
  ------------------
 1135|       |        // If it isn't found, add it
 1136|  6.25k|        if (!regular_layer_is_ordered) {
  ------------------
  |  Branch (1136:13): [True: 760, False: 5.49k]
  ------------------
 1137|    760|            res = loader_append_layer_property(inst, output_layers, &regular_layers->list[i]);
 1138|    760|            if (VK_SUCCESS != res) {
  ------------------
  |  Branch (1138:17): [True: 0, False: 760]
  ------------------
 1139|      0|                goto out;
 1140|      0|            }
 1141|  5.49k|        } else {
 1142|       |            // layer is already ordered and can be safely freed
 1143|  5.49k|            loader_free_layer_properties(inst, &regular_layers->list[i]);
 1144|  5.49k|        }
 1145|  6.25k|    }
 1146|       |
 1147|       |    // Insert the rest of the settings layers into combined_layers from  unordered_layer_index to the end
 1148|       |    // start at one after the unordered_layer_index
 1149|  5.59k|    for (uint32_t i = unordered_layer_location_index + 1; i < settings_layers->count; i++) {
  ------------------
  |  Branch (1149:59): [True: 5.02k, False: 564]
  ------------------
 1150|  5.02k|        if (!check_if_layer_is_in_list(output_layers, &settings_layers->list[i], true)) {
  ------------------
  |  Branch (1150:13): [True: 2.01k, False: 3.00k]
  ------------------
 1151|  2.01k|            res = loader_append_layer_property(inst, output_layers, &settings_layers->list[i]);
 1152|  2.01k|            if (VK_SUCCESS != res) {
  ------------------
  |  Branch (1152:17): [True: 0, False: 2.01k]
  ------------------
 1153|      0|                goto out;
 1154|      0|            }
 1155|  2.01k|        }
 1156|  5.02k|    }
 1157|       |
 1158|  7.78k|out:
 1159|  7.78k|    if (res != VK_SUCCESS) {
  ------------------
  |  Branch (1159:9): [True: 0, False: 7.78k]
  ------------------
 1160|      0|        loader_delete_layer_list_and_properties(inst, output_layers);
 1161|      0|    }
 1162|       |
 1163|  7.78k|    return res;
 1164|    564|}
loader_settings_get_additional_driver_files:
 1284|    793|VkResult loader_settings_get_additional_driver_files(const struct loader_instance* inst, struct loader_string_list* out_files) {
 1285|    793|    VkResult res = VK_SUCCESS;
 1286|       |
 1287|    793|    const loader_settings* settings = get_current_settings_and_lock(inst);
 1288|       |
 1289|    793|    if (NULL == settings || !settings->settings_active) {
  ------------------
  |  Branch (1289:9): [True: 0, False: 793]
  |  Branch (1289:29): [True: 781, False: 12]
  ------------------
 1290|    781|        goto out;
 1291|    781|    }
 1292|       |
 1293|     12|    if (settings->additional_drivers_use_exclusively) {
  ------------------
  |  Branch (1293:9): [True: 0, False: 12]
  ------------------
 1294|      0|        free_string_list(inst, out_files);
 1295|      0|    }
 1296|       |
 1297|     12|    for (uint32_t i = 0; i < settings->additional_driver_count; i++) {
  ------------------
  |  Branch (1297:26): [True: 0, False: 12]
  ------------------
 1298|      0|        res = prepend_if_manifest_file(inst, settings->additional_drivers[i].path, out_files);
 1299|      0|    }
 1300|       |
 1301|    793|out:
 1302|    793|    release_current_settings_lock(inst);
 1303|    793|    return res;
 1304|     12|}
loader_settings_should_use_driver_environment_variables:
 1306|  1.58k|bool loader_settings_should_use_driver_environment_variables(const struct loader_instance* inst) {
 1307|  1.58k|    bool should_use = true;
 1308|  1.58k|    const loader_settings* settings = get_current_settings_and_lock(inst);
 1309|  1.58k|    if (NULL == settings || !settings->settings_active) {
  ------------------
  |  Branch (1309:9): [True: 0, False: 1.58k]
  |  Branch (1309:29): [True: 1.56k, False: 24]
  ------------------
 1310|  1.56k|        goto out;
 1311|  1.56k|    }
 1312|     24|    if (settings->device_configurations_active) {
  ------------------
  |  Branch (1312:9): [True: 0, False: 24]
  ------------------
 1313|      0|        should_use = false;
 1314|      0|    }
 1315|  1.58k|out:
 1316|  1.58k|    release_current_settings_lock(inst);
 1317|  1.58k|    return should_use;
 1318|     24|}

vkCreateInstance:
  522|  8.21k|                                                              const VkAllocationCallbacks *pAllocator, VkInstance *pInstance) {
  523|  8.21k|    struct loader_instance *ptr_instance = NULL;
  524|  8.21k|    VkInstance created_instance = VK_NULL_HANDLE;
  525|  8.21k|    VkResult res = VK_ERROR_INITIALIZATION_FAILED;
  526|  8.21k|    VkInstanceCreateInfo ici = {0};
  527|  8.21k|    bool portability_enumeration_flag_bit_set = false;
  528|  8.21k|    bool portability_enumeration_extension_enabled = false;
  529|  8.21k|    struct loader_envvar_all_filters layer_filters = {0};
  530|       |
  531|  8.21k|    LOADER_PLATFORM_THREAD_ONCE(&once_init, loader_initialize);
  532|       |
  533|  8.21k|    if (pCreateInfo == NULL) {
  ------------------
  |  Branch (533:9): [True: 0, False: 8.21k]
  ------------------
  534|      0|        loader_log(NULL, VULKAN_LOADER_FATAL_ERROR_BIT | VULKAN_LOADER_ERROR_BIT | VULKAN_LOADER_VALIDATION_BIT, 0,
  535|      0|                   "vkCreateInstance: \'pCreateInfo\' is NULL (VUID-vkCreateInstance-pCreateInfo-parameter)");
  536|      0|        goto out;
  537|      0|    }
  538|  8.21k|    ici = *pCreateInfo;
  539|       |
  540|  8.21k|    if (pInstance == NULL) {
  ------------------
  |  Branch (540:9): [True: 0, False: 8.21k]
  ------------------
  541|      0|        loader_log(NULL, VULKAN_LOADER_FATAL_ERROR_BIT | VULKAN_LOADER_ERROR_BIT | VULKAN_LOADER_VALIDATION_BIT, 0,
  542|      0|                   "vkCreateInstance \'pInstance\' not valid (VUID-vkCreateInstance-pInstance-parameter)");
  543|      0|        goto out;
  544|      0|    }
  545|       |
  546|  8.21k|    ptr_instance =
  547|  8.21k|        (struct loader_instance *)loader_calloc(pAllocator, sizeof(struct loader_instance), VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
  548|       |
  549|  8.21k|    if (ptr_instance == NULL) {
  ------------------
  |  Branch (549:9): [True: 0, False: 8.21k]
  ------------------
  550|      0|        res = VK_ERROR_OUT_OF_HOST_MEMORY;
  551|      0|        goto out;
  552|      0|    }
  553|       |
  554|  8.21k|    loader_platform_thread_lock_mutex(&loader_lock);
  555|  8.21k|    if (pAllocator) {
  ------------------
  |  Branch (555:9): [True: 0, False: 8.21k]
  ------------------
  556|      0|        ptr_instance->alloc_callbacks = *pAllocator;
  557|      0|    }
  558|  8.21k|    ptr_instance->magic = LOADER_MAGIC_NUMBER;
  ------------------
  |  |  327|  8.21k|#define LOADER_MAGIC_NUMBER 0x10ADED010110ADEDUL
  ------------------
  559|       |
  560|       |    // Save the application version
  561|  8.21k|    if (NULL == pCreateInfo->pApplicationInfo || 0 == pCreateInfo->pApplicationInfo->apiVersion) {
  ------------------
  |  Branch (561:9): [True: 0, False: 8.21k]
  |  Branch (561:50): [True: 0, False: 8.21k]
  ------------------
  562|      0|        ptr_instance->app_api_version = LOADER_VERSION_1_0_0;
  ------------------
  |  |  267|      0|#define LOADER_VERSION_1_0_0 loader_combine_version(1, 0, 0)
  ------------------
  563|  8.21k|    } else {
  564|  8.21k|        ptr_instance->app_api_version = loader_make_version(pCreateInfo->pApplicationInfo->apiVersion);
  565|  8.21k|    }
  566|       |
  567|       |    // Look for one or more VK_EXT_debug_report or VK_EXT_debug_utils create info structures
  568|       |    // and setup a callback(s) for each one found.
  569|       |
  570|       |    // Handle cases of VK_EXT_debug_utils
  571|       |    // Setup the temporary messenger(s) here to catch early issues:
  572|  8.21k|    res = util_CreateDebugUtilsMessengers(ptr_instance, pCreateInfo->pNext, pAllocator);
  573|  8.21k|    if (VK_ERROR_OUT_OF_HOST_MEMORY == res) {
  ------------------
  |  Branch (573:9): [True: 0, False: 8.21k]
  ------------------
  574|       |        // Failure of setting up one or more of the messenger.
  575|      0|        goto out;
  576|      0|    }
  577|       |
  578|       |    // Handle cases of VK_EXT_debug_report
  579|       |    // Setup the temporary callback(s) here to catch early issues:
  580|  8.21k|    res = util_CreateDebugReportCallbacks(ptr_instance, pCreateInfo->pNext, pAllocator);
  581|  8.21k|    if (VK_ERROR_OUT_OF_HOST_MEMORY == res) {
  ------------------
  |  Branch (581:9): [True: 0, False: 8.21k]
  ------------------
  582|       |        // Failure of setting up one or more of the callback.
  583|      0|        goto out;
  584|      0|    }
  585|       |
  586|  8.21k|    loader_log_instance_create_info(ptr_instance, pCreateInfo);
  587|       |
  588|  8.21k|    VkResult settings_file_res = get_loader_settings(ptr_instance, &ptr_instance->settings);
  589|  8.21k|    if (settings_file_res == VK_ERROR_OUT_OF_HOST_MEMORY) {
  ------------------
  |  Branch (589:9): [True: 0, False: 8.21k]
  ------------------
  590|      0|        res = settings_file_res;
  591|      0|        goto out;
  592|      0|    }
  593|  8.21k|    if (ptr_instance->settings.settings_active) {
  ------------------
  |  Branch (593:9): [True: 1.25k, False: 6.95k]
  ------------------
  594|  1.25k|        log_settings(ptr_instance, &ptr_instance->settings);
  595|  1.25k|    }
  596|       |
  597|       |    // Providing an apiVersion less than VK_API_VERSION_1_0 but greater than zero prevents the validation layers from starting
  598|  8.21k|    if (pCreateInfo->pApplicationInfo && pCreateInfo->pApplicationInfo->apiVersion != 0u &&
  ------------------
  |  Branch (598:9): [True: 8.21k, False: 0]
  |  Branch (598:42): [True: 8.21k, False: 0]
  ------------------
  599|  8.21k|        pCreateInfo->pApplicationInfo->apiVersion < VK_API_VERSION_1_0) {
  ------------------
  |  Branch (599:9): [True: 0, False: 8.21k]
  ------------------
  600|      0|        loader_log(ptr_instance, VULKAN_LOADER_FATAL_ERROR_BIT | VULKAN_LOADER_ERROR_BIT, 0,
  601|      0|                   "VkInstanceCreateInfo::pApplicationInfo::apiVersion has value of %u which is not permitted. If apiVersion is "
  602|      0|                   "not 0, then it must be "
  603|      0|                   "greater than or equal to the value of VK_API_VERSION_1_0 [VUID-VkApplicationInfo-apiVersion]",
  604|      0|                   pCreateInfo->pApplicationInfo->apiVersion);
  605|      0|    }
  606|       |
  607|       |    // Check the VkInstanceCreateInfoFlags wether to allow the portability enumeration flag
  608|  8.21k|    if ((pCreateInfo->flags & VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR) == 1) {
  ------------------
  |  Branch (608:9): [True: 0, False: 8.21k]
  ------------------
  609|      0|        portability_enumeration_flag_bit_set = true;
  610|      0|    }
  611|       |    // Make sure the portability extension extension has been enabled before enabling portability driver enumeration
  612|  8.21k|    if (pCreateInfo->ppEnabledExtensionNames) {
  ------------------
  |  Branch (612:9): [True: 0, False: 8.21k]
  ------------------
  613|      0|        for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
  ------------------
  |  Branch (613:30): [True: 0, False: 0]
  ------------------
  614|      0|            if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_PORTABILITY_ENUMERATION_EXTENSION_NAME) == 0) {
  ------------------
  |  Branch (614:17): [True: 0, False: 0]
  ------------------
  615|      0|                portability_enumeration_extension_enabled = true;
  616|      0|                if (portability_enumeration_flag_bit_set) {
  ------------------
  |  Branch (616:21): [True: 0, False: 0]
  ------------------
  617|      0|                    ptr_instance->portability_enumeration_enabled = true;
  618|      0|                    loader_log(ptr_instance, VULKAN_LOADER_INFO_BIT, 0,
  619|      0|                               "Portability enumeration bit was set, enumerating portability drivers.");
  620|      0|                }
  621|      0|                break;
  622|      0|            }
  623|      0|        }
  624|      0|    }
  625|       |
  626|       |    // Make sure the application provided API version has the correct variant
  627|  8.21k|    if (NULL != pCreateInfo->pApplicationInfo) {
  ------------------
  |  Branch (627:9): [True: 8.21k, False: 0]
  ------------------
  628|  8.21k|        uint32_t variant_version = VK_API_VERSION_VARIANT(pCreateInfo->pApplicationInfo->apiVersion);
  629|  8.21k|        const uint32_t expected_variant = 0;
  630|  8.21k|        if (expected_variant != variant_version) {
  ------------------
  |  Branch (630:13): [True: 0, False: 8.21k]
  ------------------
  631|      0|            loader_log(ptr_instance, VULKAN_LOADER_WARN_BIT, 0,
  632|      0|                       "vkCreateInstance: The API Variant specified in pCreateInfo->pApplicationInfo.apiVersion is %d instead of "
  633|      0|                       "the expected value of %d.",
  634|      0|                       variant_version, expected_variant);
  635|      0|        }
  636|  8.21k|    }
  637|       |
  638|  8.21k|    res = parse_layer_environment_var_filters(ptr_instance, &layer_filters);
  639|  8.21k|    if (VK_SUCCESS != res) {
  ------------------
  |  Branch (639:9): [True: 0, False: 8.21k]
  ------------------
  640|      0|        goto out;
  641|      0|    }
  642|       |
  643|       |    // Due to implicit layers need to get layer list even if
  644|       |    // enabledLayerCount == 0 and VK_INSTANCE_LAYERS is unset. For now always
  645|       |    // get layer list via loader_scan_for_layers().
  646|  8.21k|    memset(&ptr_instance->instance_layer_list, 0, sizeof(ptr_instance->instance_layer_list));
  647|  8.21k|    res = loader_scan_for_layers(ptr_instance, &ptr_instance->instance_layer_list, &layer_filters);
  648|  8.21k|    if (VK_SUCCESS != res) {
  ------------------
  |  Branch (648:9): [True: 0, False: 8.21k]
  ------------------
  649|      0|        goto out;
  650|      0|    }
  651|       |
  652|       |    // Validate the app requested layers to be enabled
  653|  8.21k|    if (pCreateInfo->enabledLayerCount > 0) {
  ------------------
  |  Branch (653:9): [True: 8.21k, False: 0]
  ------------------
  654|  8.21k|        res = loader_validate_layers(ptr_instance, pCreateInfo->enabledLayerCount, pCreateInfo->ppEnabledLayerNames,
  655|  8.21k|                                     &ptr_instance->instance_layer_list);
  656|  8.21k|        if (res != VK_SUCCESS) {
  ------------------
  |  Branch (656:13): [True: 7.42k, False: 793]
  ------------------
  657|  7.42k|            goto out;
  658|  7.42k|        }
  659|  8.21k|    }
  660|       |
  661|       |    // Scan/discover all System and Environment Variable ICD libraries
  662|  8.21k|    bool skipped_portability_drivers = false;
  663|    793|    res = loader_icd_scan(ptr_instance, &ptr_instance->icd_tramp_list, pCreateInfo, &skipped_portability_drivers);
  664|    793|    if (res == VK_ERROR_OUT_OF_HOST_MEMORY) {
  ------------------
  |  Branch (664:9): [True: 3, False: 790]
  ------------------
  665|      3|        goto out;
  666|      3|    }
  667|       |
  668|    790|    if (ptr_instance->icd_tramp_list.count == 0) {
  ------------------
  |  Branch (668:9): [True: 790, False: 0]
  ------------------
  669|       |        // No drivers found
  670|    790|        if (skipped_portability_drivers) {
  ------------------
  |  Branch (670:13): [True: 0, False: 790]
  ------------------
  671|      0|            if (portability_enumeration_extension_enabled && !portability_enumeration_flag_bit_set) {
  ------------------
  |  Branch (671:17): [True: 0, False: 0]
  |  Branch (671:62): [True: 0, False: 0]
  ------------------
  672|      0|                loader_log(ptr_instance, VULKAN_LOADER_ERROR_BIT | VULKAN_LOADER_DRIVER_BIT, 0,
  673|      0|                           "vkCreateInstance: Found drivers that contain devices which support the portability subset, but "
  674|      0|                           "the instance does not enumerate portability drivers! Applications that wish to enumerate portability "
  675|      0|                           "drivers must set the VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR bit in the VkInstanceCreateInfo "
  676|      0|                           "flags.");
  677|      0|            } else if (portability_enumeration_flag_bit_set && !portability_enumeration_extension_enabled) {
  ------------------
  |  Branch (677:24): [True: 0, False: 0]
  |  Branch (677:64): [True: 0, False: 0]
  ------------------
  678|      0|                loader_log(ptr_instance, VULKAN_LOADER_ERROR_BIT | VULKAN_LOADER_DRIVER_BIT, 0,
  679|      0|                           "VkInstanceCreateInfo: If flags has the VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR bit set, the "
  680|      0|                           "list of enabled extensions in ppEnabledExtensionNames must contain VK_KHR_portability_enumeration "
  681|      0|                           "[VUID-VkInstanceCreateInfo-flags-06559 ]"
  682|      0|                           "Applications that wish to enumerate portability drivers must enable the VK_KHR_portability_enumeration "
  683|      0|                           "instance extension.");
  684|      0|            } else {
  685|      0|                loader_log(ptr_instance, VULKAN_LOADER_ERROR_BIT | VULKAN_LOADER_DRIVER_BIT, 0,
  686|      0|                           "vkCreateInstance: Found drivers that contain devices which support the portability subset, but "
  687|      0|                           "the instance does not enumerate portability drivers! Applications that wish to enumerate portability "
  688|      0|                           "drivers must set the VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR bit in the VkInstanceCreateInfo "
  689|      0|                           "flags and enable the VK_KHR_portability_enumeration instance extension.");
  690|      0|            }
  691|      0|        }
  692|    790|        loader_log(ptr_instance, VULKAN_LOADER_ERROR_BIT | VULKAN_LOADER_DRIVER_BIT, 0, "vkCreateInstance: Found no drivers!");
  693|    790|        res = VK_ERROR_INCOMPATIBLE_DRIVER;
  694|    790|        goto out;
  695|    790|    }
  696|       |
  697|       |    // Get extensions from all ICD's, merge so no duplicates, then validate
  698|      0|    res = loader_get_icd_loader_instance_extensions(ptr_instance, &ptr_instance->icd_tramp_list, &ptr_instance->ext_list);
  699|      0|    if (res != VK_SUCCESS) {
  ------------------
  |  Branch (699:9): [True: 0, False: 0]
  ------------------
  700|      0|        goto out;
  701|      0|    }
  702|      0|    res = loader_validate_instance_extensions(ptr_instance, &ptr_instance->ext_list, &ptr_instance->instance_layer_list,
  703|      0|                                              &layer_filters, &ici);
  704|      0|    if (res != VK_SUCCESS) {
  ------------------
  |  Branch (704:9): [True: 0, False: 0]
  ------------------
  705|      0|        goto out;
  706|      0|    }
  707|       |
  708|      0|    ptr_instance->disp = loader_instance_heap_alloc(ptr_instance, sizeof(struct loader_instance_dispatch_table),
  709|      0|                                                    VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
  710|      0|    if (ptr_instance->disp == NULL) {
  ------------------
  |  Branch (710:9): [True: 0, False: 0]
  ------------------
  711|      0|        loader_log(ptr_instance, VULKAN_LOADER_ERROR_BIT, 0,
  712|      0|                   "vkCreateInstance:  Failed to allocate Loader's full Instance dispatch table.");
  713|      0|        res = VK_ERROR_OUT_OF_HOST_MEMORY;
  714|      0|        goto out;
  715|      0|    }
  716|      0|    memcpy(&ptr_instance->disp->layer_inst_disp, &instance_disp, sizeof(instance_disp));
  717|       |
  718|      0|    ptr_instance->next = loader.instances;
  719|      0|    loader.instances = ptr_instance;
  720|       |
  721|       |    // Activate any layers on instance chain
  722|      0|    res = loader_enable_instance_layers(ptr_instance, &ici, &ptr_instance->instance_layer_list, &layer_filters);
  723|      0|    if (res != VK_SUCCESS) {
  ------------------
  |  Branch (723:9): [True: 0, False: 0]
  ------------------
  724|      0|        goto out;
  725|      0|    }
  726|       |
  727|      0|    created_instance = (VkInstance)ptr_instance;
  728|      0|    res = loader_create_instance_chain(&ici, pAllocator, ptr_instance, &created_instance);
  729|       |
  730|      0|    if (VK_SUCCESS == res) {
  ------------------
  |  Branch (730:9): [True: 0, False: 0]
  ------------------
  731|       |        // Check for enabled extensions here to setup the loader structures so the loader knows what extensions
  732|       |        // it needs to worry about.
  733|       |        // We do it in the terminator and again above the layers here since we may think different extensions
  734|       |        // are enabled than what's down in the terminator.
  735|       |        // This is why we don't clear inside of these function calls.
  736|       |        // The clearing should actually be handled by the overall memset of the pInstance structure above.
  737|      0|        fill_out_enabled_instance_extensions(ici.enabledExtensionCount, ici.ppEnabledExtensionNames,
  738|      0|                                             &ptr_instance->enabled_extensions);
  739|       |
  740|      0|        *pInstance = (VkInstance)ptr_instance;
  741|       |
  742|       |        // Finally have the layers in place and everyone has seen
  743|       |        // the CreateInstance command go by. This allows the layer's
  744|       |        // GetInstanceProcAddr functions to return valid extension functions
  745|       |        // if enabled.
  746|      0|        loader_activate_instance_layer_extensions(ptr_instance, created_instance);
  747|      0|        ptr_instance->instance_finished_creation = true;
  748|      0|    } else if (VK_ERROR_EXTENSION_NOT_PRESENT == res && !ptr_instance->create_terminator_invalid_extension) {
  ------------------
  |  Branch (748:16): [True: 0, False: 0]
  |  Branch (748:57): [True: 0, False: 0]
  ------------------
  749|      0|        loader_log(ptr_instance, VULKAN_LOADER_WARN_BIT, 0,
  750|      0|                   "vkCreateInstance: Layer returning invalid extension error not triggered by ICD/Loader (Policy #LLP_LAYER_17).");
  751|      0|    }
  752|       |
  753|  8.21k|out:
  754|       |
  755|  8.21k|    if (NULL != ptr_instance) {
  ------------------
  |  Branch (755:9): [True: 8.21k, False: 0]
  ------------------
  756|  8.21k|        if (res != VK_SUCCESS) {
  ------------------
  |  Branch (756:13): [True: 8.21k, False: 0]
  ------------------
  757|       |            // error path, should clean everything up
  758|  8.21k|            if (loader.instances == ptr_instance) {
  ------------------
  |  Branch (758:17): [True: 0, False: 8.21k]
  ------------------
  759|      0|                loader.instances = ptr_instance->next;
  760|      0|            }
  761|       |
  762|  8.21k|            free_loader_settings(ptr_instance, &ptr_instance->settings);
  763|       |
  764|  8.21k|            loader_destroy_generic_list(ptr_instance, (struct loader_generic_list *)&ptr_instance->surfaces_list);
  765|  8.21k|            loader_destroy_generic_list(ptr_instance, (struct loader_generic_list *)&ptr_instance->debug_utils_messengers_list);
  766|  8.21k|            loader_destroy_generic_list(ptr_instance, (struct loader_generic_list *)&ptr_instance->debug_report_callbacks_list);
  767|       |
  768|  8.21k|            loader_instance_heap_free(ptr_instance, ptr_instance->disp);
  769|       |            // Remove any created VK_EXT_debug_report or VK_EXT_debug_utils items
  770|  8.21k|            destroy_debug_callbacks_chain(ptr_instance, pAllocator);
  771|       |
  772|  8.21k|            loader_destroy_pointer_layer_list(ptr_instance, &ptr_instance->expanded_activated_layer_list);
  773|  8.21k|            loader_destroy_pointer_layer_list(ptr_instance, &ptr_instance->app_activated_layer_list);
  774|       |
  775|  8.21k|            loader_delete_layer_list_and_properties(ptr_instance, &ptr_instance->instance_layer_list);
  776|  8.21k|            loader_destroy_generic_list(ptr_instance, (struct loader_generic_list *)&ptr_instance->ext_list);
  777|       |
  778|       |            // Free any icd_terms that were created.
  779|       |            // If an OOM occurs from a layer, terminator_CreateInstance won't be reached where this kind of
  780|       |            // cleanup normally occurs
  781|  8.21k|            struct loader_icd_term *icd_term = NULL;
  782|  8.21k|            while (NULL != ptr_instance->icd_terms) {
  ------------------
  |  Branch (782:20): [True: 0, False: 8.21k]
  ------------------
  783|      0|                icd_term = ptr_instance->icd_terms;
  784|       |                // Call destroy Instance on each driver in case we successfully called down the chain but failed on
  785|       |                // our way back out of it.
  786|      0|                if (icd_term->instance) {
  ------------------
  |  Branch (786:21): [True: 0, False: 0]
  ------------------
  787|      0|                    loader_icd_close_objects(ptr_instance, icd_term);
  788|      0|                    icd_term->dispatch.DestroyInstance(icd_term->instance, pAllocator);
  789|      0|                }
  790|      0|                icd_term->instance = VK_NULL_HANDLE;
  791|      0|                ptr_instance->icd_terms = icd_term->next;
  792|      0|                loader_icd_destroy(ptr_instance, icd_term, pAllocator);
  793|      0|            }
  794|       |
  795|  8.21k|            loader_clear_scanned_icd_list(ptr_instance, &ptr_instance->icd_tramp_list);
  796|  8.21k|            free_string_list(ptr_instance, &ptr_instance->enabled_layer_names);
  797|       |
  798|  8.21k|            loader_instance_heap_free(ptr_instance, ptr_instance);
  799|  8.21k|        } else {
  800|       |            // success path, swap out created debug callbacks out so they aren't used until instance destruction
  801|      0|            loader_remove_instance_only_debug_funcs(ptr_instance);
  802|      0|        }
  803|       |        // Only unlock when ptr_instance isn't NULL, as if it is, the above code didn't make it to when loader_lock was locked.
  804|  8.21k|        loader_platform_thread_unlock_mutex(&loader_lock);
  805|  8.21k|    }
  806|       |
  807|  8.21k|    return res;
  808|      0|}
trampoline.c:loader_log_instance_create_info:
  480|  8.21k|static void loader_log_instance_create_info(const struct loader_instance *inst, const VkInstanceCreateInfo *pCreateInfo) {
  481|  8.21k|    const VkApplicationInfo *app_info = pCreateInfo->pApplicationInfo;
  482|  8.21k|    const char *app_name = (app_info && app_info->pApplicationName) ? app_info->pApplicationName : "";
  ------------------
  |  Branch (482:29): [True: 8.21k, False: 0]
  |  Branch (482:41): [True: 8.21k, False: 0]
  ------------------
  483|  8.21k|    const char *engine_name = (app_info && app_info->pEngineName) ? app_info->pEngineName : "";
  ------------------
  |  Branch (483:32): [True: 8.21k, False: 0]
  |  Branch (483:44): [True: 8.21k, False: 0]
  ------------------
  484|  8.21k|    uint32_t app_version = app_info ? app_info->applicationVersion : 0;
  ------------------
  |  Branch (484:28): [True: 8.21k, False: 0]
  ------------------
  485|  8.21k|    uint32_t engine_version = app_info ? app_info->engineVersion : 0;
  ------------------
  |  Branch (485:31): [True: 8.21k, False: 0]
  ------------------
  486|  8.21k|    uint32_t api_version = app_info ? app_info->apiVersion : 0;
  ------------------
  |  Branch (486:28): [True: 8.21k, False: 0]
  ------------------
  487|       |
  488|  8.21k|    loader_log(inst, VULKAN_LOADER_INFO_BIT, 0,
  489|  8.21k|               "vkCreateInstance: applicationName: \"%s\", applicationVersion: %u, engineName: \"%s\", engineVersion: %u, "
  490|  8.21k|               "apiVersion: %u.%u.%u",
  491|  8.21k|               app_name, app_version, engine_name, engine_version, VK_API_VERSION_MAJOR(api_version),
  492|  8.21k|               VK_API_VERSION_MINOR(api_version), VK_API_VERSION_PATCH(api_version));
  493|       |
  494|       |    // Guard the name arrays: this runs before the loader validates pCreateInfo, so the count may be non-zero with a null
  495|       |    // array (see the null-pointer tests).
  496|  8.21k|    loader_log(inst, VULKAN_LOADER_INFO_BIT, 0,
  497|  8.21k|               "vkCreateInstance: Requested %u instance layer(s):", pCreateInfo->enabledLayerCount);
  498|  8.21k|    if (pCreateInfo->ppEnabledLayerNames) {
  ------------------
  |  Branch (498:9): [True: 8.21k, False: 0]
  ------------------
  499|  16.4k|        for (uint32_t i = 0; i < pCreateInfo->enabledLayerCount; ++i) {
  ------------------
  |  Branch (499:30): [True: 8.21k, False: 8.21k]
  ------------------
  500|  8.21k|            if (pCreateInfo->ppEnabledLayerNames[i]) {
  ------------------
  |  Branch (500:17): [True: 8.21k, False: 0]
  ------------------
  501|  8.21k|                loader_log(inst, VULKAN_LOADER_INFO_BIT, 0, "   %s", pCreateInfo->ppEnabledLayerNames[i]);
  502|  8.21k|            } else {
  503|      0|                loader_log(inst, VULKAN_LOADER_INFO_BIT, 0, "   <NULL>");
  504|      0|            }
  505|  8.21k|        }
  506|  8.21k|    }
  507|       |
  508|  8.21k|    loader_log(inst, VULKAN_LOADER_INFO_BIT, 0,
  509|  8.21k|               "vkCreateInstance: Requested %u instance extension(s):", pCreateInfo->enabledExtensionCount);
  510|  8.21k|    if (pCreateInfo->ppEnabledExtensionNames) {
  ------------------
  |  Branch (510:9): [True: 0, False: 8.21k]
  ------------------
  511|      0|        for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; ++i) {
  ------------------
  |  Branch (511:30): [True: 0, False: 0]
  ------------------
  512|      0|            if (pCreateInfo->ppEnabledExtensionNames[i]) {
  ------------------
  |  Branch (512:17): [True: 0, False: 0]
  ------------------
  513|      0|                loader_log(inst, VULKAN_LOADER_INFO_BIT, 0, "   %s", pCreateInfo->ppEnabledExtensionNames[i]);
  514|      0|            } else {
  515|      0|                loader_log(inst, VULKAN_LOADER_INFO_BIT, 0, "   <NULL>");
  516|      0|            }
  517|      0|        }
  518|      0|    }
  519|  8.21k|}

trampoline.c:loader_platform_thread_lock_mutex:
  456|  8.21k|static inline void loader_platform_thread_lock_mutex(loader_platform_thread_mutex *pMutex) { pthread_mutex_lock(pMutex); }
trampoline.c:loader_platform_thread_unlock_mutex:
  457|  8.21k|static inline void loader_platform_thread_unlock_mutex(loader_platform_thread_mutex *pMutex) { pthread_mutex_unlock(pMutex); }
loader.c:loader_platform_open_library_error:
  422|     28|static inline const char *loader_platform_open_library_error(const char *libPath) {
  423|     28|    (void)libPath;
  424|       |#if defined(__Fuchsia__)
  425|       |    return dlerror_fuchsia();
  426|       |#else
  427|       |    // NOLINTNEXTLINE(concurrency-mt-unsafe) - dlerror has no reentrant variant; the message is used immediately, not retained
  428|     28|    return dlerror();
  429|     28|#endif
  430|     28|}
loader.c:loader_strncpy:
  467|   715k|static inline char *loader_strncpy(char *dest, size_t dest_sz, const char *src, size_t count) {
  468|   715k|    (void)dest_sz;
  469|   715k|    return strncpy(dest, src, count);
  470|   715k|}
loader.c:thread_safe_strtok:
  460|   447k|static inline void *thread_safe_strtok(char *str, const char *delim, char **saveptr) { return strtok_r(str, delim, saveptr); }
loader.c:loader_platform_open_library:
  417|     28|static inline loader_platform_dl_handle loader_platform_open_library(const char *libPath) {
  418|       |    return dlopen(libPath, LOADER_DLOPEN_MODE);
  ------------------
  |  |  407|     28|#define LOADER_DLOPEN_MODE (RTLD_LAZY | RTLD_LOCAL)
  ------------------
  419|     28|}
loader.c:loader_platform_thread_create_mutex:
  450|      4|static inline void loader_platform_thread_create_mutex(loader_platform_thread_mutex *pMutex) {
  451|      4|    pthread_mutexattr_t attr;
  452|      4|    pthread_mutexattr_init(&attr);
  453|      4|    pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
  454|      4|    pthread_mutex_init(pMutex, &attr);
  455|      4|}
loader.c:loader_platform_is_path_absolute:
  296|  23.1k|static inline bool loader_platform_is_path_absolute(const char *path) {
  297|  23.1k|    if (path[0] == '/') return true;
  ------------------
  |  Branch (297:9): [True: 2.45k, False: 20.6k]
  ------------------
  298|  20.6k|    return false;
  299|  23.1k|}
loader.c:loader_platform_is_path:
  252|   110k|static inline bool loader_platform_is_path(const char *path) { return strchr(path, DIRECTORY_SYMBOL) != NULL; }
  ------------------
  |  |  155|   110k|#define DIRECTORY_SYMBOL '/'
  ------------------
loader.c:loader_platform_file_exists:
  289|   109k|static inline bool loader_platform_file_exists(const char *path) {
  290|   109k|    if (access(path, F_OK)) return false;
  ------------------
  |  Branch (290:9): [True: 2.27k, False: 107k]
  ------------------
  291|   107k|    return true;
  292|   109k|}
loader.c:loader_platform_executable_path:
  307|  7.78k|static inline char *loader_platform_executable_path(char *buffer, size_t size) {
  308|  7.78k|    ssize_t count = readlink("/proc/self/exe", buffer, size);
  309|  7.78k|    if (count == -1) return NULL;
  ------------------
  |  Branch (309:9): [True: 0, False: 7.78k]
  ------------------
  310|  7.78k|    if (count == 0) return NULL;
  ------------------
  |  Branch (310:9): [True: 0, False: 7.78k]
  ------------------
  311|       |    // readlink does not append a null terminator and returns up to size bytes, so a target of size or more
  312|       |    // would leave no room for the terminator and buffer[count] would write past the end.
  313|  7.78k|    if ((size_t)count >= size) return NULL;
  ------------------
  |  Branch (313:9): [True: 0, False: 7.78k]
  ------------------
  314|  7.78k|    buffer[count] = '\0';
  315|  7.78k|    return buffer;
  316|  7.78k|}
loader_environment.c:thread_safe_strtok:
  460|  16.4k|static inline void *thread_safe_strtok(char *str, const char *delim, char **saveptr) { return strtok_r(str, delim, saveptr); }
loader_environment.c:loader_strncpy:
  467|  8.21k|static inline char *loader_strncpy(char *dest, size_t dest_sz, const char *src, size_t count) {
  468|  8.21k|    (void)dest_sz;
  469|  8.21k|    return strncpy(dest, src, count);
  470|  8.21k|}
log.c:loader_strncat:
  463|   146k|static inline char *loader_strncat(char *dest, size_t dest_sz, const char *src, size_t count) {
  464|   146k|    (void)dest_sz;
  465|   146k|    return strncat(dest, src, count);
  466|   146k|}
settings.c:loader_strncpy:
  467|  80.3k|static inline char *loader_strncpy(char *dest, size_t dest_sz, const char *src, size_t count) {
  468|  80.3k|    (void)dest_sz;
  469|  80.3k|    return strncpy(dest, src, count);
  470|  80.3k|}
settings.c:loader_strncat:
  463|  19.0k|static inline char *loader_strncat(char *dest, size_t dest_sz, const char *src, size_t count) {
  464|  19.0k|    (void)dest_sz;
  465|  19.0k|    return strncat(dest, src, count);
  466|  19.0k|}
settings.c:loader_platform_file_exists:
  289|  19.0k|static inline bool loader_platform_file_exists(const char *path) {
  290|  19.0k|    if (access(path, F_OK)) return false;
  ------------------
  |  Branch (290:9): [True: 11.4k, False: 7.68k]
  ------------------
  291|  7.68k|    return true;
  292|  19.0k|}
settings.c:loader_platform_executable_path:
  307|  2.20k|static inline char *loader_platform_executable_path(char *buffer, size_t size) {
  308|  2.20k|    ssize_t count = readlink("/proc/self/exe", buffer, size);
  309|  2.20k|    if (count == -1) return NULL;
  ------------------
  |  Branch (309:9): [True: 0, False: 2.20k]
  ------------------
  310|  2.20k|    if (count == 0) return NULL;
  ------------------
  |  Branch (310:9): [True: 0, False: 2.20k]
  ------------------
  311|       |    // readlink does not append a null terminator and returns up to size bytes, so a target of size or more
  312|       |    // would leave no room for the terminator and buffer[count] would write past the end.
  313|  2.20k|    if ((size_t)count >= size) return NULL;
  ------------------
  |  Branch (313:9): [True: 0, False: 2.20k]
  ------------------
  314|  2.20k|    buffer[count] = '\0';
  315|  2.20k|    return buffer;
  316|  2.20k|}
settings.c:loader_platform_thread_create_mutex:
  450|      2|static inline void loader_platform_thread_create_mutex(loader_platform_thread_mutex *pMutex) {
  451|      2|    pthread_mutexattr_t attr;
  452|      2|    pthread_mutexattr_init(&attr);
  453|      2|    pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
  454|      2|    pthread_mutex_init(pMutex, &attr);
  455|      2|}

wsi_unsupported_instance_extension:
  280|  18.8k|bool wsi_unsupported_instance_extension(const VkExtensionProperties *ext_prop) {
  281|       |#if !defined(VK_USE_PLATFORM_WAYLAND_KHR)
  282|       |    if (!strcmp(ext_prop->extensionName, "VK_KHR_wayland_surface")) return true;
  283|       |#endif  // VK_USE_PLATFORM_WAYLAND_KHR
  284|       |#if !defined(VK_USE_PLATFORM_XCB_KHR)
  285|       |    if (!strcmp(ext_prop->extensionName, "VK_KHR_xcb_surface")) return true;
  286|       |#endif  // VK_USE_PLATFORM_XCB_KHR
  287|       |#if !defined(VK_USE_PLATFORM_XLIB_KHR)
  288|       |    if (!strcmp(ext_prop->extensionName, "VK_KHR_xlib_surface")) return true;
  289|       |#endif  // VK_USE_PLATFORM_XLIB_KHR
  290|  18.8k|#if !defined(VK_USE_PLATFORM_DIRECTFB_EXT)
  291|  18.8k|    if (!strcmp(ext_prop->extensionName, "VK_EXT_directfb_surface")) return true;
  ------------------
  |  Branch (291:9): [True: 1.68k, False: 17.1k]
  ------------------
  292|  17.1k|#endif  // VK_USE_PLATFORM_DIRECTFB_EXT
  293|  17.1k|#if !defined(VK_USE_PLATFORM_SCREEN_QNX)
  294|  17.1k|    if (!strcmp(ext_prop->extensionName, "VK_QNX_screen_surface")) return true;
  ------------------
  |  Branch (294:9): [True: 200, False: 16.9k]
  ------------------
  295|  16.9k|#endif  // VK_USE_PLATFORM_SCREEN_QNX
  296|       |
  297|  16.9k|    return false;
  298|  17.1k|}

