fuzz_init:
   25|  7.00k|void fuzz_init(const uint8_t *data, size_t size) {
   26|  7.00k|    global_fuzz_data = (uint8_t *)data;
   27|  7.00k|    global_size = size;
   28|       |    
   29|  7.00k|    callback1 = NULL;
   30|  7.00k|    callback2 = NULL;
   31|  7.00k|    callback3 = NULL;
   32|       |    callback4 = NULL;
   33|  7.00k|}
create_callback_file:
   36|    738|void create_callback_file(const char *filename) {
   37|    738|  fprintf(stderr, "create_callback_file: Creating file %s\n", filename);
   38|    738|  FILE *fp = fopen(filename, "wb");
   39|    738|  if (!fp) {
  ------------------
  |  Branch (39:7): [True: 72, False: 666]
  ------------------
   40|     72|    return;
   41|     72|  }
   42|    666|  fwrite(global_fuzz_data, global_size, 1, fp);
   43|    666|  fclose(fp);
   44|       |
   45|    666|  if (callback1 == NULL) {
  ------------------
  |  Branch (45:7): [True: 283, False: 383]
  ------------------
   46|    283|    callback1 = strdup(filename);
   47|    383|  } else if (callback2 == NULL) {
  ------------------
  |  Branch (47:14): [True: 24, False: 359]
  ------------------
   48|     24|    callback2 = strdup(filename);
   49|    359|  } else if (callback3 == NULL) {
  ------------------
  |  Branch (49:14): [True: 17, False: 342]
  ------------------
   50|     17|    callback3 = strdup(filename);
   51|    342|  } else if (callback4 == NULL) {
  ------------------
  |  Branch (51:14): [True: 16, False: 326]
  ------------------
   52|     16|    callback4 = strdup(filename);
   53|    326|  } else {
   54|       |    fprintf(stderr, "create_callback_file: Too many callbacks created, ignoring %s\n", filename);
   55|    326|  }
   56|    666|}
fuzz_cleanup:
   62|  7.00k|void fuzz_cleanup() {
   63|  7.00k|  if (callback1) {
  ------------------
  |  Branch (63:7): [True: 283, False: 6.72k]
  ------------------
   64|    283| unlink(callback1);    
   65|    283|    free(callback1);
   66|       |   
   67|    283|    callback1 = NULL;
   68|    283|  }
   69|  7.00k|  if (callback2) {
  ------------------
  |  Branch (69:7): [True: 24, False: 6.97k]
  ------------------
   70|     24| unlink(callback2);    
   71|     24|    free(callback2);
   72|     24|    callback2 = NULL;
   73|     24|  }
   74|  7.00k|  if (callback3) {
  ------------------
  |  Branch (74:7): [True: 17, False: 6.98k]
  ------------------
   75|     17| unlink(callback3);      
   76|     17|    free(callback3);
   77|     17|    callback3 = NULL;
   78|     17|  }
   79|  7.00k|  if (callback4) {
  ------------------
  |  Branch (79:7): [True: 16, False: 6.98k]
  ------------------
   80|     16|     unlink(callback4);
   81|     16|    free(callback4);
   82|       |    callback4 = NULL;
   83|     16|  }
   84|  7.00k|}

LLVMFuzzerInitialize:
   22|      2|int LLVMFuzzerInitialize(int *argc, char ***argv) {
   23|      2|  setenv("HOME", "/tmp", 1);
   24|      2|  system("mkdir -p $HOME/.local/share/vulkan/implicit_layer.d");
   25|      2|  system("mkdir -p $HOME/.local/share/vulkan/loader_settings.d");
   26|      2|  system("mkdir -p $HOME/.local/share/vulkan/icd.d");
   27|      2|  return 0;
   28|      2|}
create_config_file:
   33|  21.0k|int create_config_file(const char* config_path, const char* config_filename, const uint8_t* data, size_t size) {
   34|  21.0k|  char filename[512];
   35|  21.0k|  char path[256];
   36|       |  // char command[256];
   37|       |
   38|  21.0k|  sprintf(path, "%s/%s", getenv("HOME"), config_path);
   39|       |  //sprintf(command, "mkdir -p %s", path);
   40|       |
   41|       |  //system(command);
   42|       |
   43|  21.0k|  sprintf(filename, "%s/%s", path, config_filename);
   44|       |
   45|  21.0k|  FILE *fp = fopen(filename, "wb");
   46|  21.0k|  if (!fp) {
  ------------------
  |  Branch (46:7): [True: 0, False: 21.0k]
  ------------------
   47|      0|    return 1;
   48|      0|  }
   49|  21.0k|  fwrite(data, size, 1, fp);
   50|  21.0k|  fclose(fp);
   51|       |
   52|  21.0k|  return 0;
   53|  21.0k|}
remove_config_file:
   58|  21.0k|void remove_config_file(const char* config_path, const char* config_filename) {
   59|  21.0k|  char filename[512];
   60|  21.0k|  sprintf(filename, "%s/%s/%s", getenv("HOME"), config_path, config_filename);
   61|  21.0k|  unlink(filename);
   62|  21.0k|}
LLVMFuzzerTestOneInput:
   67|  7.03k|int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
   68|  7.03k|  if (size < 3*sizeof(size_t)) {
  ------------------
  |  Branch (68:7): [True: 8, False: 7.02k]
  ------------------
   69|      8|    return 0;
   70|      8|  }
   71|       |
   72|       |  // Split the loaders into two different parts so the files
   73|       |  // are independently seeded with fuzz data.
   74|  7.02k|  size_t first_size = (*(size_t*)data) % 40000;
   75|  7.02k|  size_t second_size = (*(size_t*)(data + sizeof(size_t))) % 40000;
   76|  7.02k|  size_t third_size = (*(size_t*)(data + 2*sizeof(size_t))) % 40000;
   77|       |
   78|  7.02k|  data += 3*sizeof(size_t); // Move past the first two integers
   79|  7.02k|  size -= 3*sizeof(size_t); // Adjust size to account for the first two integers
   80|  7.02k|  size_t total_size_needed = first_size + second_size + third_size;
   81|  7.02k|  if (size <= total_size_needed) {
  ------------------
  |  Branch (81:7): [True: 20, False: 7.00k]
  ------------------
   82|     20|    return 0;
   83|     20|  }
   84|  7.00k|  int result = create_config_file(".local/share/vulkan/implicit_layer.d", "complex_layer.json", data, first_size);
   85|  7.00k|  if (result) {
  ------------------
  |  Branch (85:7): [True: 0, False: 7.00k]
  ------------------
   86|      0|    return 0;
   87|      0|  }
   88|       |
   89|  7.00k|  data += first_size;
   90|  7.00k|  size -= first_size;
   91|  7.00k|  result = create_config_file(".local/share/vulkan/loader_settings.d", "vk_loader_settings.json", data, second_size);
   92|  7.00k|  if (result) {
  ------------------
  |  Branch (92:7): [True: 0, False: 7.00k]
  ------------------
   93|      0|    return 0;
   94|      0|  }
   95|       |
   96|  7.00k|  data += second_size;
   97|  7.00k|  size -= second_size;
   98|  7.00k|  result = create_config_file(".local/share/vulkan/loader_settings.d", "icd_test.json", data, third_size);
   99|  7.00k|  if (result) {
  ------------------
  |  Branch (99:7): [True: 0, False: 7.00k]
  ------------------
  100|      0|    return 0;
  101|      0|  }
  102|  7.00k|  data += third_size;
  103|  7.00k|  size -= third_size;
  104|       |
  105|  7.00k|  fuzz_init(data, size);
  106|       |
  107|  7.00k|  setenv("VK_LOADER_LAYERS_ENABLE", "all", 1);
  108|       |
  109|       |
  110|  7.00k|  VkInstance inst = {0};
  111|  7.00k|  char *instance_layers[] = {
  112|  7.00k|    "VK_LAYER_KHRONOS_validation",
  113|  7.00k|    "VK_LAYER_test_layer_1",
  114|  7.00k|    "VK_LAYER_test_layer_2"
  115|  7.00k|  };
  116|  7.00k|  const VkApplicationInfo app = {
  117|  7.00k|      .sType = VK_STRUCTURE_TYPE_APPLICATION_INFO,
  118|  7.00k|      .pNext = NULL,
  119|  7.00k|      .pApplicationName = "TEST_APP",
  120|  7.00k|      .applicationVersion = 0,
  121|  7.00k|      .pEngineName = "TEST_ENGINE",
  122|  7.00k|      .engineVersion = 0,
  123|  7.00k|      .apiVersion = VK_API_VERSION_1_0,
  ------------------
  |  |   92|  7.00k|#define VK_API_VERSION_1_0 VK_MAKE_API_VERSION(0, 1, 0, 0)// Patch version should always be set to 0
  |  |  ------------------
  |  |  |  |   63|  7.00k|    ((((uint32_t)(variant)) << 29U) | (((uint32_t)(major)) << 22U) | (((uint32_t)(minor)) << 12U) | ((uint32_t)(patch)))
  |  |  ------------------
  ------------------
  124|  7.00k|  };
  125|  7.00k|  VkInstanceCreateInfo inst_info = {
  126|  7.00k|      .sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO,
  127|  7.00k|      .pNext = NULL,
  128|  7.00k|      .pApplicationInfo = &app,
  129|  7.00k|      .enabledLayerCount = 1,
  130|  7.00k|      .ppEnabledLayerNames = (const char *const *)instance_layers,
  131|  7.00k|      .enabledExtensionCount = 0,
  132|  7.00k|      .ppEnabledExtensionNames = NULL,
  133|  7.00k|  };
  134|  7.00k|  VkResult err = vkCreateInstance(&inst_info, NULL, &inst);
  135|  7.00k|  if (err != VK_SUCCESS) {
  ------------------
  |  Branch (135:7): [True: 7.00k, False: 0]
  ------------------
  136|  7.00k|    goto out;
  137|  7.00k|  }
  138|      0|  else {
  139|       |
  140|      0|  }
  141|       |
  142|      0|  vkDestroyInstance(inst, NULL);
  143|       |
  144|  7.00k|out:
  145|       |  // Clean up config files
  146|  7.00k|  remove_config_file(".local/share/vulkan/implicit_layer.d", "complex_layer.json");
  147|  7.00k|  remove_config_file(".local/share/vulkan/loader_settings.d", "vk_loader_settings.json");
  148|  7.00k|  remove_config_file(".local/share/vulkan/icd.d", "icd_test.json");
  149|       |
  150|       |
  151|  7.00k|  fuzz_cleanup();
  152|       |
  153|  7.00k|  return 0;
  154|      0|}

loader_alloc:
   34|      4|void *loader_alloc(const VkAllocationCallbacks *pAllocator, size_t size, VkSystemAllocationScope allocation_scope) {
   35|      4|    void *pMemory = NULL;
   36|       |#if (DEBUG_DISABLE_APP_ALLOCATORS == 1)
   37|       |    {
   38|       |#else
   39|      4|    if (pAllocator && pAllocator->pfnAllocation) {
  ------------------
  |  Branch (39:9): [True: 4, False: 0]
  |  Branch (39:23): [True: 0, False: 4]
  ------------------
   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|      4|    } else {
   44|      4|#endif
   45|      4|        pMemory = malloc(size);
   46|      4|    }
   47|       |
   48|      4|    return pMemory;
   49|      4|}
loader_calloc:
   51|  1.94M|void *loader_calloc(const VkAllocationCallbacks *pAllocator, size_t size, VkSystemAllocationScope allocation_scope) {
   52|  1.94M|    void *pMemory = NULL;
   53|       |#if (DEBUG_DISABLE_APP_ALLOCATORS == 1)
   54|       |    {
   55|       |#else
   56|  1.94M|    if (pAllocator && pAllocator->pfnAllocation) {
  ------------------
  |  Branch (56:9): [True: 1.93M, False: 7.00k]
  |  Branch (56:23): [True: 0, False: 1.93M]
  ------------------
   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|  1.94M|    } else {
   64|  1.94M|#endif
   65|  1.94M|        pMemory = calloc(1, size);
   66|  1.94M|    }
   67|       |
   68|  1.94M|    return pMemory;
   69|  1.94M|}
loader_free:
   71|  2.46M|void loader_free(const VkAllocationCallbacks *pAllocator, void *pMemory) {
   72|  2.46M|    if (pMemory != NULL) {
  ------------------
  |  Branch (72:9): [True: 1.94M, False: 524k]
  ------------------
   73|       |#if (DEBUG_DISABLE_APP_ALLOCATORS == 1)
   74|       |        {
   75|       |#else
   76|  1.94M|        if (pAllocator && pAllocator->pfnFree) {
  ------------------
  |  Branch (76:13): [True: 1.94M, False: 0]
  |  Branch (76:27): [True: 0, False: 1.94M]
  ------------------
   77|      0|            pAllocator->pfnFree(pAllocator->pUserData, pMemory);
   78|  1.94M|        } else {
   79|  1.94M|#endif
   80|  1.94M|            free(pMemory);
   81|  1.94M|        }
   82|  1.94M|    }
   83|  2.46M|}
loader_realloc:
   86|   105k|                     VkSystemAllocationScope allocation_scope) {
   87|   105k|    void *pNewMem = NULL;
   88|   105k|    if (pMemory == NULL || orig_size == 0) {
  ------------------
  |  Branch (88:9): [True: 0, False: 105k]
  |  Branch (88:28): [True: 0, False: 105k]
  ------------------
   89|      0|        pNewMem = loader_alloc(pAllocator, size, allocation_scope);
   90|   105k|    } else if (size == 0) {
  ------------------
  |  Branch (90:16): [True: 0, False: 105k]
  ------------------
   91|      0|        loader_free(pAllocator, pMemory);
   92|       |#if (DEBUG_DISABLE_APP_ALLOCATORS == 1)
   93|       |#else
   94|   105k|    } else if (pAllocator && pAllocator->pfnReallocation) {
  ------------------
  |  Branch (94:16): [True: 105k, False: 0]
  |  Branch (94:30): [True: 0, False: 105k]
  ------------------
   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|   105k|    } else {
  100|   105k|        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|   105k|        if (NULL != pNewMem && size > orig_size) {
  ------------------
  |  Branch (103:13): [True: 105k, False: 0]
  |  Branch (103:32): [True: 1.30k, False: 104k]
  ------------------
  104|  1.30k|            memset((uint8_t *)pNewMem + orig_size, 0, size - orig_size);
  105|  1.30k|        }
  106|   105k|    }
  107|   105k|    return pNewMem;
  108|   105k|}
loader_instance_heap_alloc:
  110|      4|void *loader_instance_heap_alloc(const struct loader_instance *inst, size_t size, VkSystemAllocationScope allocation_scope) {
  111|      4|    return loader_alloc(inst ? &inst->alloc_callbacks : NULL, size, allocation_scope);
  ------------------
  |  Branch (111:25): [True: 4, False: 0]
  ------------------
  112|      4|}
loader_instance_heap_calloc:
  114|   238k|void *loader_instance_heap_calloc(const struct loader_instance *inst, size_t size, VkSystemAllocationScope allocation_scope) {
  115|   238k|    return loader_calloc(inst ? &inst->alloc_callbacks : NULL, size, allocation_scope);
  ------------------
  |  Branch (115:26): [True: 238k, False: 0]
  ------------------
  116|   238k|}
loader_instance_heap_free:
  118|   873k|void loader_instance_heap_free(const struct loader_instance *inst, void *pMemory) {
  119|   873k|    loader_free(inst ? &inst->alloc_callbacks : NULL, pMemory);
  ------------------
  |  Branch (119:17): [True: 873k, False: 2]
  ------------------
  120|   873k|}
loader_instance_heap_realloc:
  122|    465|                                   VkSystemAllocationScope allocation_scope) {
  123|    465|    return loader_realloc(inst ? &inst->alloc_callbacks : NULL, pMemory, orig_size, size, allocation_scope);
  ------------------
  |  Branch (123:27): [True: 465, False: 0]
  ------------------
  124|    465|}

loader_cJSON_GetStringValue:
   98|  76.6k|CJSON_PUBLIC(char *) loader_cJSON_GetStringValue(const cJSON *const item) {
   99|  76.6k|    if (!loader_cJSON_IsString(item)) {
  ------------------
  |  Branch (99:9): [True: 19.0k, False: 57.6k]
  ------------------
  100|  19.0k|        return NULL;
  101|  19.0k|    }
  102|       |
  103|  57.6k|    return item->valuestring;
  104|  76.6k|}
loader_cJSON_Delete:
  151|   195k|TEST_FUNCTION_EXPORT CJSON_PUBLIC(void) loader_cJSON_Delete(cJSON *item) {
  152|   195k|    cJSON *next = NULL;
  153|  1.01M|    while (item != NULL) {
  ------------------
  |  Branch (153:12): [True: 816k, False: 195k]
  ------------------
  154|   816k|        next = item->next;
  155|   816k|        if (!(item->type & cJSON_IsReference) && (item->child != NULL)) {
  ------------------
  |  |  106|   816k|#define cJSON_IsReference 256
  ------------------
  |  Branch (155:13): [True: 816k, False: 0]
  |  Branch (155:50): [True: 140k, False: 675k]
  ------------------
  156|   140k|            loader_cJSON_Delete(item->child);
  157|   140k|        }
  158|   816k|        if (!(item->type & cJSON_IsReference) && (item->valuestring != NULL)) {
  ------------------
  |  |  106|   816k|#define cJSON_IsReference 256
  ------------------
  |  Branch (158:13): [True: 816k, False: 0]
  |  Branch (158:50): [True: 390k, False: 425k]
  ------------------
  159|   390k|            loader_free(item->pAllocator, item->valuestring);
  160|   390k|            item->valuestring = NULL;
  161|   390k|        }
  162|   816k|        if (!(item->type & cJSON_StringIsConst) && (item->string != NULL)) {
  ------------------
  |  |  107|   816k|#define cJSON_StringIsConst 512
  ------------------
  |  Branch (162:13): [True: 816k, False: 0]
  |  Branch (162:52): [True: 386k, False: 429k]
  ------------------
  163|   386k|            loader_free(item->pAllocator, item->string);
  164|       |            item->string = NULL;
  165|   386k|        }
  166|   816k|        loader_free(item->pAllocator, item);
  167|   816k|        item = next;
  168|   816k|    }
  169|   195k|}
loader_cJSON_ParseWithLengthOpts:
  824|  15.2k|                                 const char **return_parse_end, cJSON_bool require_null_terminated, bool *out_of_memory) {
  825|  15.2k|    parse_buffer buffer = {0, 0, 0, 0, 0};
  826|  15.2k|    cJSON *item = NULL;
  827|       |
  828|       |    /* reset error position */
  829|       |    // global_error.json = NULL;
  830|       |    // global_error.position = 0;
  831|       |
  832|  15.2k|    if (value == NULL || 0 == buffer_length) {
  ------------------
  |  Branch (832:9): [True: 0, False: 15.2k]
  |  Branch (832:26): [True: 0, False: 15.2k]
  ------------------
  833|      0|        goto fail;
  834|      0|    }
  835|       |
  836|  15.2k|    buffer.content = (const unsigned char *)value;
  837|  15.2k|    buffer.length = buffer_length;
  838|  15.2k|    buffer.offset = 0;
  839|  15.2k|    buffer.pAllocator = pAllocator;
  840|       |
  841|  15.2k|    item = cJSON_New_Item(pAllocator);
  842|  15.2k|    if (item == NULL) /* memory fail */
  ------------------
  |  Branch (842:9): [True: 0, False: 15.2k]
  ------------------
  843|      0|    {
  844|      0|        *out_of_memory = true;
  ------------------
  |  |   67|      0|#define true ((cJSON_bool)1)
  ------------------
  845|      0|        goto fail;
  846|      0|    }
  847|       |
  848|  15.2k|    if (!parse_value(item, buffer_skip_whitespace(skip_utf8_bom(&buffer)), out_of_memory)) {
  ------------------
  |  Branch (848:9): [True: 6.40k, False: 8.88k]
  ------------------
  849|       |        /* parse failure. ep is set. */
  850|  6.40k|        goto fail;
  851|  6.40k|    }
  852|       |
  853|       |    /* if we require null-terminated JSON without appended garbage, skip and then check for a null terminator */
  854|  8.88k|    if (require_null_terminated) {
  ------------------
  |  Branch (854:9): [True: 0, False: 8.88k]
  ------------------
  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|  8.88k|    if (return_parse_end) {
  ------------------
  |  Branch (860:9): [True: 0, False: 8.88k]
  ------------------
  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|  8.88k|    return item;
  865|       |
  866|  6.40k|fail:
  867|  6.40k|    if (item != NULL) {
  ------------------
  |  Branch (867:9): [True: 6.40k, False: 0]
  ------------------
  868|  6.40k|        loader_cJSON_Delete(item);
  869|  6.40k|    }
  870|       |
  871|  6.40k|    if (value != NULL) {
  ------------------
  |  Branch (871:9): [True: 6.40k, False: 0]
  ------------------
  872|  6.40k|        error local_error;
  873|  6.40k|        local_error.json = (const unsigned char *)value;
  874|  6.40k|        local_error.position = 0;
  875|       |
  876|  6.40k|        if (buffer.offset < buffer.length) {
  ------------------
  |  Branch (876:13): [True: 6.34k, False: 59]
  ------------------
  877|  6.34k|            local_error.position = buffer.offset;
  878|  6.34k|        } else if (buffer.length > 0) {
  ------------------
  |  Branch (878:20): [True: 59, False: 0]
  ------------------
  879|     59|            local_error.position = buffer.length - 1;
  880|     59|        }
  881|       |
  882|  6.40k|        if (return_parse_end != NULL) {
  ------------------
  |  Branch (882:13): [True: 0, False: 6.40k]
  ------------------
  883|      0|            *return_parse_end = (const char *)local_error.json + local_error.position;
  884|      0|        }
  885|       |
  886|       |        // global_error = local_error;
  887|  6.40k|    }
  888|       |
  889|       |    return NULL;
  890|  8.88k|}
loader_cJSON_ParseWithLength:
  899|  15.2k|                             bool *out_of_memory) {
  900|  15.2k|    return loader_cJSON_ParseWithLengthOpts(pAllocator, value, buffer_length, 0, 0, out_of_memory);
  901|  15.2k|}
loader_cJSON_Print:
  953|   104k|TEST_FUNCTION_EXPORT CJSON_PUBLIC(char *) loader_cJSON_Print(const cJSON *item, bool *out_of_memory) {
  954|   104k|    return (char *)print(item, true, out_of_memory);
  ------------------
  |  |   67|   104k|#define true ((cJSON_bool)1)
  ------------------
  955|   104k|}
loader_cJSON_PrintPreallocated:
  990|  44.8k|    loader_cJSON_PrintPreallocated(cJSON *item, char *buffer, const int length, const cJSON_bool format) {
  991|  44.8k|    printbuffer p = {0, 0, 0, 0, 0, 0, 0};
  992|       |
  993|  44.8k|    if ((length < 0) || (buffer == NULL)) {
  ------------------
  |  Branch (993:9): [True: 0, False: 44.8k]
  |  Branch (993:25): [True: 0, False: 44.8k]
  ------------------
  994|      0|        return false;
  ------------------
  |  |   72|      0|#define false ((cJSON_bool)0)
  ------------------
  995|      0|    }
  996|       |
  997|  44.8k|    p.buffer = (unsigned char *)buffer;
  998|  44.8k|    p.length = (size_t)length;
  999|  44.8k|    p.offset = 0;
 1000|  44.8k|    p.noalloc = true;
  ------------------
  |  |   67|  44.8k|#define true ((cJSON_bool)1)
  ------------------
 1001|  44.8k|    p.format = format;
 1002|  44.8k|    p.pAllocator = item->pAllocator;
 1003|  44.8k|    bool out_of_memory = false;
  ------------------
  |  |   72|  44.8k|#define false ((cJSON_bool)0)
  ------------------
 1004|  44.8k|    return print_value(item, &p, &out_of_memory);
 1005|  44.8k|}
loader_cJSON_GetArraySize:
 1457|  14.6k|CJSON_PUBLIC(int) loader_cJSON_GetArraySize(const cJSON *array) {
 1458|  14.6k|    cJSON *child = NULL;
 1459|  14.6k|    size_t size = 0;
 1460|       |
 1461|  14.6k|    if (array == NULL) {
  ------------------
  |  Branch (1461:9): [True: 0, False: 14.6k]
  ------------------
 1462|      0|        return 0;
 1463|      0|    }
 1464|       |
 1465|  14.6k|    child = array->child;
 1466|       |
 1467|  84.7k|    while (child != NULL) {
  ------------------
  |  Branch (1467:12): [True: 70.1k, False: 14.6k]
  ------------------
 1468|  70.1k|        size++;
 1469|  70.1k|        child = child->next;
 1470|  70.1k|    }
 1471|       |
 1472|       |    /* FIXME: Can overflow here. Cannot be fixed without breaking the API */
 1473|       |
 1474|  14.6k|    return (int)size;
 1475|  14.6k|}
loader_cJSON_GetObjectItem:
 1527|   367k|CJSON_PUBLIC(cJSON *) loader_cJSON_GetObjectItem(const cJSON *const object, const char *const string) {
 1528|   367k|    return get_object_item(object, string, false);
  ------------------
  |  |   72|   367k|#define false ((cJSON_bool)0)
  ------------------
 1529|   367k|}
loader_cJSON_IsString:
 1670|  76.6k|CJSON_PUBLIC(cJSON_bool) loader_cJSON_IsString(const cJSON *const item) {
 1671|  76.6k|    if (item == NULL) {
  ------------------
  |  Branch (1671:9): [True: 18.7k, False: 57.9k]
  ------------------
 1672|  18.7k|        return false;
  ------------------
  |  |   72|  18.7k|#define false ((cJSON_bool)0)
  ------------------
 1673|  18.7k|    }
 1674|       |
 1675|  57.9k|    return (item->type & 0xFF) == cJSON_String;
  ------------------
  |  |  101|  57.9k|#define cJSON_String (1 << 4)
  ------------------
 1676|  76.6k|}
cJSON.c:cJSON_New_Item:
  142|   816k|static cJSON *cJSON_New_Item(const VkAllocationCallbacks *pAllocator) {
  143|   816k|    cJSON *node = (cJSON *)loader_calloc(pAllocator, sizeof(cJSON), VK_SYSTEM_ALLOCATION_SCOPE_COMMAND);
  144|   816k|    if (NULL != node) {
  ------------------
  |  Branch (144:9): [True: 816k, False: 0]
  ------------------
  145|   816k|        node->pAllocator = pAllocator;
  146|   816k|    }
  147|   816k|    return node;
  148|   816k|}
cJSON.c:buffer_skip_whitespace:
  772|  2.54M|static parse_buffer *buffer_skip_whitespace(parse_buffer *const buffer) {
  773|  2.54M|    if ((buffer == NULL) || (buffer->content == NULL)) {
  ------------------
  |  Branch (773:9): [True: 0, False: 2.54M]
  |  Branch (773:29): [True: 0, False: 2.54M]
  ------------------
  774|      0|        return NULL;
  775|      0|    }
  776|       |
  777|  2.54M|    if (cannot_access_at_index(buffer, 0)) {
  ------------------
  |  |  193|  2.54M|#define cannot_access_at_index(buffer, index) (!can_access_at_index(buffer, index))
  |  |  ------------------
  |  |  |  |  192|  2.54M|#define can_access_at_index(buffer, index) ((buffer != NULL) && (((buffer)->offset + index) < (buffer)->length))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (192:45): [True: 2.54M, False: 0]
  |  |  |  |  |  Branch (192:65): [True: 2.54M, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  778|      0|        return buffer;
  779|      0|    }
  780|       |
  781|  8.66M|    while (can_access_at_index(buffer, 0) && (buffer_at_offset(buffer)[0] <= 32)) {
  ------------------
  |  |  192|  17.3M|#define can_access_at_index(buffer, index) ((buffer != NULL) && (((buffer)->offset + index) < (buffer)->length))
  |  |  ------------------
  |  |  |  Branch (192:45): [True: 8.66M, False: 0]
  |  |  |  Branch (192:65): [True: 8.66M, False: 4.54k]
  |  |  ------------------
  ------------------
                  while (can_access_at_index(buffer, 0) && (buffer_at_offset(buffer)[0] <= 32)) {
  ------------------
  |  |  195|  8.66M|#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset)
  ------------------
  |  Branch (781:46): [True: 6.11M, False: 2.54M]
  ------------------
  782|  6.11M|        buffer->offset++;
  783|  6.11M|    }
  784|       |
  785|  2.54M|    if (buffer->offset == buffer->length) {
  ------------------
  |  Branch (785:9): [True: 4.54k, False: 2.54M]
  ------------------
  786|  4.54k|        buffer->offset--;
  787|  4.54k|    }
  788|       |
  789|  2.54M|    return buffer;
  790|  2.54M|}
cJSON.c:skip_utf8_bom:
  793|  15.2k|static parse_buffer *skip_utf8_bom(parse_buffer *const buffer) {
  794|  15.2k|    if ((buffer == NULL) || (buffer->content == NULL) || (buffer->offset != 0)) {
  ------------------
  |  Branch (794:9): [True: 0, False: 15.2k]
  |  Branch (794:29): [True: 0, False: 15.2k]
  |  Branch (794:58): [True: 0, False: 15.2k]
  ------------------
  795|      0|        return NULL;
  796|      0|    }
  797|       |
  798|  15.2k|    if (can_access_at_index(buffer, 4) && (strncmp((const char *)buffer_at_offset(buffer), "\xEF\xBB\xBF", 3) == 0)) {
  ------------------
  |  |  192|  30.5k|#define can_access_at_index(buffer, index) ((buffer != NULL) && (((buffer)->offset + index) < (buffer)->length))
  |  |  ------------------
  |  |  |  Branch (192:45): [True: 15.2k, False: 0]
  |  |  |  Branch (192:65): [True: 9.93k, False: 5.36k]
  |  |  ------------------
  ------------------
                  if (can_access_at_index(buffer, 4) && (strncmp((const char *)buffer_at_offset(buffer), "\xEF\xBB\xBF", 3) == 0)) {
  ------------------
  |  |  195|  9.93k|#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset)
  ------------------
  |  Branch (798:43): [True: 89, False: 9.84k]
  ------------------
  799|     89|        buffer->offset += 3;
  800|     89|    }
  801|       |
  802|  15.2k|    return buffer;
  803|  15.2k|}
cJSON.c:print:
  905|   104k|static unsigned char *print(const cJSON *const item, cJSON_bool format, bool *out_of_memory) {
  906|   104k|    static const size_t default_buffer_size = 256;
  907|   104k|    printbuffer buffer[1];
  908|   104k|    unsigned char *printed = NULL;
  909|       |
  910|   104k|    memset(buffer, 0, sizeof(buffer));
  911|       |
  912|       |    /* create buffer */
  913|   104k|    buffer->buffer = (unsigned char *)loader_calloc(item->pAllocator, default_buffer_size, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
  914|   104k|    buffer->length = default_buffer_size;
  915|   104k|    buffer->format = format;
  916|   104k|    buffer->pAllocator = item->pAllocator;
  917|   104k|    if (buffer->buffer == NULL) {
  ------------------
  |  Branch (917:9): [True: 0, False: 104k]
  ------------------
  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|   104k|    if (!print_value(item, buffer, out_of_memory)) {
  ------------------
  |  Branch (923:9): [True: 0, False: 104k]
  ------------------
  924|      0|        goto fail;
  925|      0|    }
  926|   104k|    update_offset(buffer);
  927|       |
  928|   104k|    printed = (unsigned char *)loader_realloc(item->pAllocator, buffer->buffer, buffer->length, buffer->offset + 1,
  929|   104k|                                              VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
  930|   104k|    if (printed == NULL) {
  ------------------
  |  Branch (930:9): [True: 0, False: 104k]
  ------------------
  931|      0|        *out_of_memory = true;
  ------------------
  |  |   67|      0|#define true ((cJSON_bool)1)
  ------------------
  932|      0|        goto fail;
  933|      0|    }
  934|   104k|    buffer->buffer = NULL;
  935|       |
  936|   104k|    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|   104k|}
cJSON.c:update_offset:
  331|   104k|static void update_offset(printbuffer *const buffer) {
  332|   104k|    const unsigned char *buffer_pointer = NULL;
  333|   104k|    if ((buffer == NULL) || (buffer->buffer == NULL)) {
  ------------------
  |  Branch (333:9): [True: 0, False: 104k]
  |  Branch (333:29): [True: 0, False: 104k]
  ------------------
  334|      0|        return;
  335|      0|    }
  336|   104k|    buffer_pointer = buffer->buffer + buffer->offset;
  337|       |
  338|   104k|    buffer->offset += strlen((const char *)buffer_pointer);
  339|   104k|}
cJSON.c:parse_value:
 1008|   815k|static cJSON_bool parse_value(cJSON *const item, parse_buffer *const input_buffer, bool *out_of_memory) {
 1009|   815k|    if ((input_buffer == NULL) || (input_buffer->content == NULL)) {
  ------------------
  |  Branch (1009:9): [True: 0, False: 815k]
  |  Branch (1009:35): [True: 0, False: 815k]
  ------------------
 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|   815k|    if (can_read(input_buffer, 4) && (strncmp((const char *)buffer_at_offset(input_buffer), "null", 4) == 0)) {
  ------------------
  |  |  190|  1.63M|#define can_read(buffer, size) ((buffer != NULL) && (((buffer)->offset + size) <= (buffer)->length))
  |  |  ------------------
  |  |  |  Branch (190:33): [True: 815k, False: 0]
  |  |  |  Branch (190:53): [True: 810k, False: 5.69k]
  |  |  ------------------
  ------------------
                  if (can_read(input_buffer, 4) && (strncmp((const char *)buffer_at_offset(input_buffer), "null", 4) == 0)) {
  ------------------
  |  |  195|   810k|#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset)
  ------------------
  |  Branch (1015:38): [True: 253, False: 809k]
  ------------------
 1016|    253|        item->type = cJSON_NULL;
  ------------------
  |  |   99|    253|#define cJSON_NULL (1 << 2)
  ------------------
 1017|    253|        input_buffer->offset += 4;
 1018|    253|        return true;
  ------------------
  |  |   67|    253|#define true ((cJSON_bool)1)
  ------------------
 1019|    253|    }
 1020|       |    /* false */
 1021|   815k|    if (can_read(input_buffer, 5) && (strncmp((const char *)buffer_at_offset(input_buffer), "false", 5) == 0)) {
  ------------------
  |  |  190|  1.63M|#define can_read(buffer, size) ((buffer != NULL) && (((buffer)->offset + size) <= (buffer)->length))
  |  |  ------------------
  |  |  |  Branch (190:33): [True: 815k, False: 0]
  |  |  |  Branch (190:53): [True: 809k, False: 5.91k]
  |  |  ------------------
  ------------------
                  if (can_read(input_buffer, 5) && (strncmp((const char *)buffer_at_offset(input_buffer), "false", 5) == 0)) {
  ------------------
  |  |  195|   809k|#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset)
  ------------------
  |  Branch (1021:38): [True: 138, False: 809k]
  ------------------
 1022|    138|        item->type = cJSON_False;
  ------------------
  |  |   97|    138|#define cJSON_False (1 << 0)
  ------------------
 1023|    138|        input_buffer->offset += 5;
 1024|    138|        return true;
  ------------------
  |  |   67|    138|#define true ((cJSON_bool)1)
  ------------------
 1025|    138|    }
 1026|       |    /* true */
 1027|   815k|    if (can_read(input_buffer, 4) && (strncmp((const char *)buffer_at_offset(input_buffer), "true", 4) == 0)) {
  ------------------
  |  |  190|  1.63M|#define can_read(buffer, size) ((buffer != NULL) && (((buffer)->offset + size) <= (buffer)->length))
  |  |  ------------------
  |  |  |  Branch (190:33): [True: 815k, False: 0]
  |  |  |  Branch (190:53): [True: 809k, False: 5.69k]
  |  |  ------------------
  ------------------
                  if (can_read(input_buffer, 4) && (strncmp((const char *)buffer_at_offset(input_buffer), "true", 4) == 0)) {
  ------------------
  |  |  195|   809k|#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset)
  ------------------
  |  Branch (1027:38): [True: 11.3k, False: 798k]
  ------------------
 1028|  11.3k|        item->type = cJSON_True;
  ------------------
  |  |   98|  11.3k|#define cJSON_True (1 << 1)
  ------------------
 1029|  11.3k|        item->valueint = 1;
 1030|  11.3k|        input_buffer->offset += 4;
 1031|  11.3k|        return true;
  ------------------
  |  |   67|  11.3k|#define true ((cJSON_bool)1)
  ------------------
 1032|  11.3k|    }
 1033|       |    /* string */
 1034|   804k|    if (can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == '\"')) {
  ------------------
  |  |  192|  1.60M|#define can_access_at_index(buffer, index) ((buffer != NULL) && (((buffer)->offset + index) < (buffer)->length))
  |  |  ------------------
  |  |  |  Branch (192:45): [True: 804k, False: 0]
  |  |  |  Branch (192:65): [True: 804k, False: 0]
  |  |  ------------------
  ------------------
                  if (can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == '\"')) {
  ------------------
  |  |  195|   804k|#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset)
  ------------------
  |  Branch (1034:49): [True: 390k, False: 413k]
  ------------------
 1035|   390k|        return parse_string(item, input_buffer, out_of_memory);
 1036|   390k|    }
 1037|       |    /* number */
 1038|   413k|    if (can_access_at_index(input_buffer, 0) &&
  ------------------
  |  |  192|   826k|#define can_access_at_index(buffer, index) ((buffer != NULL) && (((buffer)->offset + index) < (buffer)->length))
  |  |  ------------------
  |  |  |  Branch (192:45): [True: 413k, False: 0]
  |  |  |  Branch (192:65): [True: 413k, False: 0]
  |  |  ------------------
  ------------------
 1039|   413k|        ((buffer_at_offset(input_buffer)[0] == '-') ||
  ------------------
  |  |  195|   413k|#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset)
  ------------------
  |  Branch (1039:10): [True: 4.58k, False: 408k]
  ------------------
 1040|   408k|         ((buffer_at_offset(input_buffer)[0] >= '0') && (buffer_at_offset(input_buffer)[0] <= '9')))) {
  ------------------
  |  |  195|   408k|#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset)
  ------------------
                       ((buffer_at_offset(input_buffer)[0] >= '0') && (buffer_at_offset(input_buffer)[0] <= '9')))) {
  ------------------
  |  |  195|   404k|#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset)
  ------------------
  |  Branch (1040:11): [True: 404k, False: 4.35k]
  |  Branch (1040:57): [True: 204k, False: 199k]
  ------------------
 1041|   209k|        return parse_number(item, input_buffer);
 1042|   209k|    }
 1043|       |    /* array */
 1044|   204k|    if (can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == '[')) {
  ------------------
  |  |  192|   408k|#define can_access_at_index(buffer, index) ((buffer != NULL) && (((buffer)->offset + index) < (buffer)->length))
  |  |  ------------------
  |  |  |  Branch (192:45): [True: 204k, False: 0]
  |  |  |  Branch (192:65): [True: 204k, False: 0]
  |  |  ------------------
  ------------------
                  if (can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == '[')) {
  ------------------
  |  |  195|   204k|#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset)
  ------------------
  |  Branch (1044:49): [True: 86.0k, False: 118k]
  ------------------
 1045|  86.0k|        return parse_array(item, input_buffer, out_of_memory);
 1046|  86.0k|    }
 1047|       |    /* object */
 1048|   118k|    if (can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == '{')) {
  ------------------
  |  |  192|   236k|#define can_access_at_index(buffer, index) ((buffer != NULL) && (((buffer)->offset + index) < (buffer)->length))
  |  |  ------------------
  |  |  |  Branch (192:45): [True: 118k, False: 0]
  |  |  |  Branch (192:65): [True: 118k, False: 0]
  |  |  ------------------
  ------------------
                  if (can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == '{')) {
  ------------------
  |  |  195|   118k|#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset)
  ------------------
  |  Branch (1048:49): [True: 112k, False: 5.71k]
  ------------------
 1049|   112k|        return parse_object(item, input_buffer, out_of_memory);
 1050|   112k|    }
 1051|       |
 1052|  5.71k|    return false;
  ------------------
  |  |   72|  5.71k|#define false ((cJSON_bool)0)
  ------------------
 1053|   118k|}
cJSON.c:parse_string:
  533|   777k|static cJSON_bool parse_string(cJSON *const item, parse_buffer *const input_buffer, bool *out_of_memory) {
  534|   777k|    const unsigned char *input_pointer = buffer_at_offset(input_buffer) + 1;
  ------------------
  |  |  195|   777k|#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset)
  ------------------
  535|   777k|    const unsigned char *input_end = buffer_at_offset(input_buffer) + 1;
  ------------------
  |  |  195|   777k|#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset)
  ------------------
  536|   777k|    unsigned char *output_pointer = NULL;
  537|   777k|    unsigned char *output = NULL;
  538|       |
  539|       |    /* not a string */
  540|   777k|    if (buffer_at_offset(input_buffer)[0] != '\"') {
  ------------------
  |  |  195|   777k|#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset)
  ------------------
  |  Branch (540:9): [True: 81, False: 776k]
  ------------------
  541|     81|        goto fail;
  542|     81|    }
  543|       |
  544|   776k|    {
  545|       |        /* calculate approximate size of the output (overestimate) */
  546|   776k|        size_t allocation_length = 0;
  547|   776k|        size_t skipped_bytes = 0;
  548|  13.8M|        while (((size_t)(input_end - input_buffer->content) < input_buffer->length) && (*input_end != '\"')) {
  ------------------
  |  Branch (548:16): [True: 13.8M, False: 119]
  |  Branch (548:88): [True: 13.1M, False: 776k]
  ------------------
  549|       |            /* is escape sequence */
  550|  13.1M|            if (input_end[0] == '\\') {
  ------------------
  |  Branch (550:17): [True: 40.6k, False: 13.0M]
  ------------------
  551|  40.6k|                if ((size_t)(input_end + 1 - input_buffer->content) >= input_buffer->length) {
  ------------------
  |  Branch (551:21): [True: 0, False: 40.6k]
  ------------------
  552|       |                    /* prevent buffer overflow when last input character is a backslash */
  553|      0|                    goto fail;
  554|      0|                }
  555|  40.6k|                skipped_bytes++;
  556|  40.6k|                input_end++;
  557|  40.6k|            }
  558|  13.1M|            input_end++;
  559|  13.1M|        }
  560|   776k|        if (((size_t)(input_end - input_buffer->content) >= input_buffer->length) || (*input_end != '\"')) {
  ------------------
  |  Branch (560:13): [True: 119, False: 776k]
  |  Branch (560:86): [True: 0, False: 776k]
  ------------------
  561|    119|            goto fail; /* string ended unexpectedly */
  562|    119|        }
  563|       |
  564|       |        /* This is at most how much we need for the output */
  565|   776k|        allocation_length = (size_t)(input_end - buffer_at_offset(input_buffer)) - skipped_bytes;
  ------------------
  |  |  195|   776k|#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset)
  ------------------
  566|   776k|        output = (unsigned char *)loader_calloc(input_buffer->pAllocator, allocation_length + sizeof(""),
  567|   776k|                                                VK_SYSTEM_ALLOCATION_SCOPE_COMMAND);
  568|   776k|        if (output == NULL) {
  ------------------
  |  Branch (568:13): [True: 0, False: 776k]
  ------------------
  569|      0|            *out_of_memory = true;
  ------------------
  |  |   67|      0|#define true ((cJSON_bool)1)
  ------------------
  570|      0|            goto fail; /* allocation failure */
  571|      0|        }
  572|   776k|    }
  573|       |
  574|   776k|    output_pointer = output;
  575|       |    /* loop through the string literal */
  576|  12.4M|    while (input_pointer < input_end) {
  ------------------
  |  Branch (576:12): [True: 11.6M, False: 776k]
  ------------------
  577|  11.6M|        if (*input_pointer != '\\') {
  ------------------
  |  Branch (577:13): [True: 11.6M, False: 30.0k]
  ------------------
  578|  11.6M|            *output_pointer++ = *input_pointer++;
  579|  11.6M|        }
  580|       |        /* escape sequence */
  581|  30.0k|        else {
  582|  30.0k|            unsigned char sequence_length = 2;
  583|  30.0k|            if ((input_end - input_pointer) < 1) {
  ------------------
  |  Branch (583:17): [True: 0, False: 30.0k]
  ------------------
  584|      0|                goto fail;
  585|      0|            }
  586|       |
  587|  30.0k|            switch (input_pointer[1]) {
  588|    500|                case 'b':
  ------------------
  |  Branch (588:17): [True: 500, False: 29.5k]
  ------------------
  589|    500|                    *output_pointer++ = '\b';
  590|    500|                    break;
  591|  1.02k|                case 'f':
  ------------------
  |  Branch (591:17): [True: 1.02k, False: 28.9k]
  ------------------
  592|  1.02k|                    *output_pointer++ = '\f';
  593|  1.02k|                    break;
  594|    602|                case 'n':
  ------------------
  |  Branch (594:17): [True: 602, False: 29.4k]
  ------------------
  595|    602|                    *output_pointer++ = '\n';
  596|    602|                    break;
  597|    567|                case 'r':
  ------------------
  |  Branch (597:17): [True: 567, False: 29.4k]
  ------------------
  598|    567|                    *output_pointer++ = '\r';
  599|    567|                    break;
  600|    525|                case 't':
  ------------------
  |  Branch (600:17): [True: 525, False: 29.4k]
  ------------------
  601|    525|                    *output_pointer++ = '\t';
  602|    525|                    break;
  603|    614|                case '\"':
  ------------------
  |  Branch (603:17): [True: 614, False: 29.4k]
  ------------------
  604|  2.96k|                case '\\':
  ------------------
  |  Branch (604:17): [True: 2.35k, False: 27.6k]
  ------------------
  605|  3.18k|                case '/':
  ------------------
  |  Branch (605:17): [True: 222, False: 29.7k]
  ------------------
  606|  3.18k|                    *output_pointer++ = input_pointer[1];
  607|  3.18k|                    break;
  608|       |
  609|       |                /* UTF-16 literal */
  610|  23.5k|                case 'u':
  ------------------
  |  Branch (610:17): [True: 23.5k, False: 6.43k]
  ------------------
  611|  23.5k|                    sequence_length = utf16_literal_to_utf8(input_pointer, input_end, &output_pointer);
  612|  23.5k|                    if (sequence_length == 0) {
  ------------------
  |  Branch (612:25): [True: 101, False: 23.4k]
  ------------------
  613|       |                        /* failed to convert UTF16-literal to UTF-8 */
  614|    101|                        goto fail;
  615|    101|                    }
  616|  23.4k|                    break;
  617|       |
  618|  23.4k|                default:
  ------------------
  |  Branch (618:17): [True: 33, False: 29.9k]
  ------------------
  619|     33|                    goto fail;
  620|  30.0k|            }
  621|  29.8k|            input_pointer += sequence_length;
  622|  29.8k|        }
  623|  11.6M|    }
  624|       |
  625|       |    /* zero terminate the output */
  626|   776k|    *output_pointer = '\0';
  627|       |
  628|   776k|    item->type = cJSON_String;
  ------------------
  |  |  101|   776k|#define cJSON_String (1 << 4)
  ------------------
  629|   776k|    item->valuestring = (char *)output;
  630|       |
  631|   776k|    input_buffer->offset = (size_t)(input_end - input_buffer->content);
  632|   776k|    input_buffer->offset++;
  633|       |
  634|   776k|    return true;
  ------------------
  |  |   67|   776k|#define true ((cJSON_bool)1)
  ------------------
  635|       |
  636|    334|fail:
  637|    334|    if (output != NULL) {
  ------------------
  |  Branch (637:9): [True: 134, False: 200]
  ------------------
  638|    134|        loader_free(input_buffer->pAllocator, output);
  639|    134|        output = NULL;
  640|    134|    }
  641|       |
  642|    334|    if (input_pointer != NULL) {
  ------------------
  |  Branch (642:9): [True: 334, False: 0]
  ------------------
  643|    334|        input_buffer->offset = (size_t)(input_pointer - input_buffer->content);
  644|    334|    }
  645|       |
  646|    334|    return false;
  ------------------
  |  |   72|    334|#define false ((cJSON_bool)0)
  ------------------
  647|   776k|}
cJSON.c:utf16_literal_to_utf8:
  435|  23.5k|                                           unsigned char **output_pointer) {
  436|  23.5k|    long unsigned int codepoint = 0;
  437|  23.5k|    unsigned int first_code = 0;
  438|  23.5k|    const unsigned char *first_sequence = input_pointer;
  439|  23.5k|    unsigned char utf8_length = 0;
  440|  23.5k|    unsigned char utf8_position = 0;
  441|  23.5k|    unsigned char sequence_length = 0;
  442|  23.5k|    unsigned char first_byte_mark = 0;
  443|       |
  444|  23.5k|    if ((input_end - first_sequence) < 6) {
  ------------------
  |  Branch (444:9): [True: 12, False: 23.5k]
  ------------------
  445|       |        /* input ends unexpectedly */
  446|     12|        goto fail;
  447|     12|    }
  448|       |
  449|       |    /* get the first utf16 sequence */
  450|  23.5k|    first_code = parse_hex4(first_sequence + 2);
  451|       |
  452|       |    /* check that the code is valid */
  453|  23.5k|    if (((first_code >= 0xDC00) && (first_code <= 0xDFFF))) {
  ------------------
  |  Branch (453:10): [True: 2.02k, False: 21.5k]
  |  Branch (453:36): [True: 16, False: 2.00k]
  ------------------
  454|     16|        goto fail;
  455|     16|    }
  456|       |
  457|       |    /* UTF16 surrogate pair */
  458|  23.5k|    if ((first_code >= 0xD800) && (first_code <= 0xDBFF)) {
  ------------------
  |  Branch (458:9): [True: 2.40k, False: 21.1k]
  |  Branch (458:35): [True: 396, False: 2.00k]
  ------------------
  459|    396|        const unsigned char *second_sequence = first_sequence + 6;
  460|    396|        unsigned int second_code = 0;
  461|    396|        sequence_length = 12; /* \uXXXX\uXXXX */
  462|       |
  463|    396|        if ((input_end - second_sequence) < 6) {
  ------------------
  |  Branch (463:13): [True: 13, False: 383]
  ------------------
  464|       |            /* input ends unexpectedly */
  465|     13|            goto fail;
  466|     13|        }
  467|       |
  468|    383|        if ((second_sequence[0] != '\\') || (second_sequence[1] != 'u')) {
  ------------------
  |  Branch (468:13): [True: 18, False: 365]
  |  Branch (468:45): [True: 9, False: 356]
  ------------------
  469|       |            /* missing second half of the surrogate pair */
  470|     27|            goto fail;
  471|     27|        }
  472|       |
  473|       |        /* get the second utf16 sequence */
  474|    356|        second_code = parse_hex4(second_sequence + 2);
  475|       |        /* check that the code is valid */
  476|    356|        if ((second_code < 0xDC00) || (second_code > 0xDFFF)) {
  ------------------
  |  Branch (476:13): [True: 27, False: 329]
  |  Branch (476:39): [True: 6, False: 323]
  ------------------
  477|       |            /* invalid second half of the surrogate pair */
  478|     33|            goto fail;
  479|     33|        }
  480|       |
  481|       |        /* calculate the unicode codepoint from the surrogate pair */
  482|    323|        codepoint = 0x10000 + (((first_code & 0x3FF) << 10) | (second_code & 0x3FF));
  483|  23.1k|    } else {
  484|  23.1k|        sequence_length = 6; /* \uXXXX */
  485|  23.1k|        codepoint = first_code;
  486|  23.1k|    }
  487|       |
  488|       |    /* encode as UTF-8
  489|       |     * takes at maximum 4 bytes to encode:
  490|       |     * 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx */
  491|  23.4k|    if (codepoint < 0x80) {
  ------------------
  |  Branch (491:9): [True: 16.0k, False: 7.40k]
  ------------------
  492|       |        /* normal ascii, encoding 0xxxxxxx */
  493|  16.0k|        utf8_length = 1;
  494|  16.0k|    } else if (codepoint < 0x800) {
  ------------------
  |  Branch (494:16): [True: 2.92k, False: 4.48k]
  ------------------
  495|       |        /* two bytes, encoding 110xxxxx 10xxxxxx */
  496|  2.92k|        utf8_length = 2;
  497|  2.92k|        first_byte_mark = 0xC0; /* 11000000 */
  498|  4.48k|    } else if (codepoint < 0x10000) {
  ------------------
  |  Branch (498:16): [True: 4.16k, False: 323]
  ------------------
  499|       |        /* three bytes, encoding 1110xxxx 10xxxxxx 10xxxxxx */
  500|  4.16k|        utf8_length = 3;
  501|  4.16k|        first_byte_mark = 0xE0; /* 11100000 */
  502|  4.16k|    } else if (codepoint <= 0x10FFFF) {
  ------------------
  |  Branch (502:16): [True: 323, False: 0]
  ------------------
  503|       |        /* four bytes, encoding 1110xxxx 10xxxxxx 10xxxxxx 10xxxxxx */
  504|    323|        utf8_length = 4;
  505|    323|        first_byte_mark = 0xF0; /* 11110000 */
  506|    323|    } else {
  507|       |        /* invalid unicode codepoint */
  508|      0|        goto fail;
  509|      0|    }
  510|       |
  511|       |    /* encode as utf8 */
  512|  35.6k|    for (utf8_position = (unsigned char)(utf8_length - 1); utf8_position > 0; utf8_position--) {
  ------------------
  |  Branch (512:60): [True: 12.2k, False: 23.4k]
  ------------------
  513|       |        /* 10xxxxxx */
  514|  12.2k|        (*output_pointer)[utf8_position] = (unsigned char)((codepoint | 0x80) & 0xBF);
  515|  12.2k|        codepoint >>= 6;
  516|  12.2k|    }
  517|       |    /* encode first byte */
  518|  23.4k|    if (utf8_length > 1) {
  ------------------
  |  Branch (518:9): [True: 7.40k, False: 16.0k]
  ------------------
  519|  7.40k|        (*output_pointer)[0] = (unsigned char)((codepoint | first_byte_mark) & 0xFF);
  520|  16.0k|    } else {
  521|  16.0k|        (*output_pointer)[0] = (unsigned char)(codepoint & 0x7F);
  522|  16.0k|    }
  523|       |
  524|  23.4k|    *output_pointer += utf8_length;
  525|       |
  526|  23.4k|    return sequence_length;
  527|       |
  528|    101|fail:
  529|    101|    return 0;
  530|  23.4k|}
cJSON.c:parse_hex4:
  406|  23.9k|static unsigned parse_hex4(const unsigned char *const input) {
  407|  23.9k|    unsigned int h = 0;
  408|  23.9k|    size_t i = 0;
  409|       |
  410|  79.7k|    for (i = 0; i < 4; i++) {
  ------------------
  |  Branch (410:17): [True: 71.7k, False: 8.01k]
  ------------------
  411|       |        /* parse digit */
  412|  71.7k|        if ((input[i] >= '0') && (input[i] <= '9')) {
  ------------------
  |  Branch (412:13): [True: 67.4k, False: 4.32k]
  |  Branch (412:34): [True: 29.6k, False: 37.7k]
  ------------------
  413|  29.6k|            h += (unsigned int)input[i] - '0';
  414|  42.0k|        } else if ((input[i] >= 'A') && (input[i] <= 'F')) {
  ------------------
  |  Branch (414:20): [True: 35.2k, False: 6.84k]
  |  Branch (414:41): [True: 11.8k, False: 23.3k]
  ------------------
  415|  11.8k|            h += (unsigned int)10 + input[i] - 'A';
  416|  30.2k|        } else if ((input[i] >= 'a') && (input[i] <= 'f')) {
  ------------------
  |  Branch (416:20): [True: 18.9k, False: 11.2k]
  |  Branch (416:41): [True: 14.3k, False: 4.62k]
  ------------------
  417|  14.3k|            h += (unsigned int)10 + input[i] - 'a';
  418|  14.3k|        } else /* invalid */
  419|  15.9k|        {
  420|  15.9k|            return 0;
  421|  15.9k|        }
  422|       |
  423|  55.8k|        if (i < 3) {
  ------------------
  |  Branch (423:13): [True: 47.8k, False: 8.01k]
  ------------------
  424|       |            /* shift left to make place for the next nibble */
  425|  47.8k|            h = h << 4;
  426|  47.8k|        }
  427|  55.8k|    }
  428|       |
  429|  8.01k|    return h;
  430|  23.9k|}
cJSON.c:parse_number:
  198|   209k|static cJSON_bool parse_number(cJSON *const item, parse_buffer *const input_buffer) {
  199|   209k|    double number = 0;
  200|   209k|    unsigned char *after_end = NULL;
  201|   209k|    unsigned char number_c_string[64];
  202|   209k|    unsigned char decimal_point = get_decimal_point();
  203|   209k|    size_t i = 0;
  204|       |
  205|   209k|    if ((input_buffer == NULL) || (input_buffer->content == NULL)) {
  ------------------
  |  Branch (205:9): [True: 0, False: 209k]
  |  Branch (205:35): [True: 0, False: 209k]
  ------------------
  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|   613k|    for (i = 0; (i < (sizeof(number_c_string) - 1)) && can_access_at_index(input_buffer, i); i++) {
  ------------------
  |  |  192|   613k|#define can_access_at_index(buffer, index) ((buffer != NULL) && (((buffer)->offset + index) < (buffer)->length))
  |  |  ------------------
  |  |  |  Branch (192:45): [True: 613k, False: 0]
  |  |  |  Branch (192:65): [True: 613k, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (212:17): [True: 613k, False: 146]
  ------------------
  213|   613k|        switch (buffer_at_offset(input_buffer)[i]) {
  ------------------
  |  |  195|   613k|#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset)
  ------------------
  214|  38.0k|            case '0':
  ------------------
  |  Branch (214:13): [True: 38.0k, False: 575k]
  ------------------
  215|   211k|            case '1':
  ------------------
  |  Branch (215:13): [True: 173k, False: 439k]
  ------------------
  216|   258k|            case '2':
  ------------------
  |  Branch (216:13): [True: 46.3k, False: 567k]
  ------------------
  217|   282k|            case '3':
  ------------------
  |  Branch (217:13): [True: 24.0k, False: 589k]
  ------------------
  218|   313k|            case '4':
  ------------------
  |  Branch (218:13): [True: 31.2k, False: 582k]
  ------------------
  219|   324k|            case '5':
  ------------------
  |  Branch (219:13): [True: 11.5k, False: 601k]
  ------------------
  220|   340k|            case '6':
  ------------------
  |  Branch (220:13): [True: 15.8k, False: 597k]
  ------------------
  221|   357k|            case '7':
  ------------------
  |  Branch (221:13): [True: 16.7k, False: 596k]
  ------------------
  222|   368k|            case '8':
  ------------------
  |  Branch (222:13): [True: 11.3k, False: 602k]
  ------------------
  223|   386k|            case '9':
  ------------------
  |  Branch (223:13): [True: 17.2k, False: 596k]
  ------------------
  224|   386k|            case '+':
  ------------------
  |  Branch (224:13): [True: 613, False: 612k]
  ------------------
  225|   394k|            case '-':
  ------------------
  |  Branch (225:13): [True: 7.63k, False: 605k]
  ------------------
  226|   397k|            case 'e':
  ------------------
  |  Branch (226:13): [True: 3.01k, False: 610k]
  ------------------
  227|   400k|            case 'E':
  ------------------
  |  Branch (227:13): [True: 3.13k, False: 610k]
  ------------------
  228|   400k|                number_c_string[i] = buffer_at_offset(input_buffer)[i];
  ------------------
  |  |  195|   400k|#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset)
  ------------------
  229|   400k|                break;
  230|       |
  231|  3.67k|            case '.':
  ------------------
  |  Branch (231:13): [True: 3.67k, False: 609k]
  ------------------
  232|  3.67k|                number_c_string[i] = decimal_point;
  233|  3.67k|                break;
  234|       |
  235|   209k|            default:
  ------------------
  |  Branch (235:13): [True: 209k, False: 404k]
  ------------------
  236|   209k|                goto loop_end;
  237|   613k|        }
  238|   613k|    }
  239|   209k|loop_end:
  240|   209k|    number_c_string[i] = '\0';
  241|       |
  242|   209k|    number = strtod((const char *)number_c_string, (char **)&after_end);
  243|   209k|    if (number_c_string == after_end) {
  ------------------
  |  Branch (243:9): [True: 37, False: 209k]
  ------------------
  244|     37|        return false; /* parse_error */
  ------------------
  |  |   72|     37|#define false ((cJSON_bool)0)
  ------------------
  245|     37|    }
  246|       |
  247|   209k|    item->valuedouble = number;
  248|       |
  249|       |    /* use saturation in case of overflow */
  250|   209k|    if (number >= INT_MAX) {
  ------------------
  |  Branch (250:9): [True: 4.34k, False: 205k]
  ------------------
  251|  4.34k|        item->valueint = INT_MAX;
  252|   205k|    } else if (number <= (double)INT_MIN) {
  ------------------
  |  Branch (252:16): [True: 319, False: 204k]
  ------------------
  253|    319|        item->valueint = INT_MIN;
  254|   204k|    } else {
  255|   204k|        item->valueint = (int)number;
  256|   204k|    }
  257|       |
  258|   209k|    item->type = cJSON_Number;
  ------------------
  |  |  100|   209k|#define cJSON_Number (1 << 3)
  ------------------
  259|       |
  260|   209k|    input_buffer->offset += (size_t)(after_end - number_c_string);
  261|   209k|    return true;
  ------------------
  |  |   67|   209k|#define true ((cJSON_bool)1)
  ------------------
  262|   209k|}
cJSON.c:get_decimal_point:
  172|   209k|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|   209k|    return '.';
  178|   209k|#endif
  179|   209k|}
cJSON.c:parse_array:
 1121|  86.0k|static cJSON_bool parse_array(cJSON *const item, parse_buffer *const input_buffer, bool *out_of_memory) {
 1122|  86.0k|    cJSON *head = NULL; /* head of the linked list */
 1123|  86.0k|    cJSON *current_item = NULL;
 1124|       |
 1125|  86.0k|    if (input_buffer->depth >= CJSON_NESTING_LIMIT) {
  ------------------
  |  |  138|  86.0k|#define CJSON_NESTING_LIMIT 1000
  ------------------
  |  Branch (1125:9): [True: 2, False: 86.0k]
  ------------------
 1126|      2|        return false; /* to deeply nested */
  ------------------
  |  |   72|      2|#define false ((cJSON_bool)0)
  ------------------
 1127|      2|    }
 1128|  86.0k|    input_buffer->depth++;
 1129|       |
 1130|  86.0k|    if (buffer_at_offset(input_buffer)[0] != '[') {
  ------------------
  |  |  195|  86.0k|#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset)
  ------------------
  |  Branch (1130:9): [True: 0, False: 86.0k]
  ------------------
 1131|       |        /* not an array */
 1132|      0|        goto fail;
 1133|      0|    }
 1134|       |
 1135|  86.0k|    input_buffer->offset++;
 1136|  86.0k|    buffer_skip_whitespace(input_buffer);
 1137|  86.0k|    if (can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == ']')) {
  ------------------
  |  |  192|   172k|#define can_access_at_index(buffer, index) ((buffer != NULL) && (((buffer)->offset + index) < (buffer)->length))
  |  |  ------------------
  |  |  |  Branch (192:45): [True: 86.0k, False: 0]
  |  |  |  Branch (192:65): [True: 86.0k, False: 0]
  |  |  ------------------
  ------------------
                  if (can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == ']')) {
  ------------------
  |  |  195|  86.0k|#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset)
  ------------------
  |  Branch (1137:49): [True: 14.1k, False: 71.9k]
  ------------------
 1138|       |        /* empty array */
 1139|  14.1k|        goto success;
 1140|  14.1k|    }
 1141|       |
 1142|       |    /* check if we skipped to the end of the buffer */
 1143|  71.9k|    if (cannot_access_at_index(input_buffer, 0)) {
  ------------------
  |  |  193|  71.9k|#define cannot_access_at_index(buffer, index) (!can_access_at_index(buffer, index))
  |  |  ------------------
  |  |  |  |  192|  71.9k|#define can_access_at_index(buffer, index) ((buffer != NULL) && (((buffer)->offset + index) < (buffer)->length))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (192:45): [True: 71.9k, False: 0]
  |  |  |  |  |  Branch (192:65): [True: 71.9k, 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|  71.9k|    input_buffer->offset--;
 1150|       |    /* loop through the comma separated array elements */
 1151|   414k|    do {
 1152|       |        /* allocate next item */
 1153|   414k|        cJSON *new_item = cJSON_New_Item(input_buffer->pAllocator);
 1154|   414k|        if (new_item == NULL) {
  ------------------
  |  Branch (1154:13): [True: 0, False: 414k]
  ------------------
 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|   414k|        if (head == NULL) {
  ------------------
  |  Branch (1160:13): [True: 71.9k, False: 342k]
  ------------------
 1161|       |            /* start the linked list */
 1162|  71.9k|            current_item = head = new_item;
 1163|   342k|        } else {
 1164|       |            /* add to the end and advance */
 1165|   342k|            current_item->next = new_item;
 1166|   342k|            new_item->prev = current_item;
 1167|   342k|            current_item = new_item;
 1168|   342k|        }
 1169|       |
 1170|       |        /* parse next value */
 1171|   414k|        input_buffer->offset++;
 1172|   414k|        buffer_skip_whitespace(input_buffer);
 1173|   414k|        if (!parse_value(current_item, input_buffer, out_of_memory)) {
  ------------------
  |  Branch (1173:13): [True: 36.9k, False: 377k]
  ------------------
 1174|  36.9k|            goto fail; /* failed to parse value */
 1175|  36.9k|        }
 1176|   377k|        buffer_skip_whitespace(input_buffer);
 1177|   377k|    } while (can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == ','));
  ------------------
  |  |  192|   754k|#define can_access_at_index(buffer, index) ((buffer != NULL) && (((buffer)->offset + index) < (buffer)->length))
  |  |  ------------------
  |  |  |  Branch (192:45): [True: 377k, False: 0]
  |  |  |  Branch (192:65): [True: 377k, False: 0]
  |  |  ------------------
  ------------------
                  } while (can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == ','));
  ------------------
  |  |  195|   377k|#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset)
  ------------------
  |  Branch (1177:54): [True: 342k, False: 34.9k]
  ------------------
 1178|       |
 1179|  34.9k|    if (cannot_access_at_index(input_buffer, 0) || buffer_at_offset(input_buffer)[0] != ']') {
  ------------------
  |  |  193|  69.9k|#define cannot_access_at_index(buffer, index) (!can_access_at_index(buffer, index))
  |  |  ------------------
  |  |  |  |  192|  34.9k|#define can_access_at_index(buffer, index) ((buffer != NULL) && (((buffer)->offset + index) < (buffer)->length))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (192:45): [True: 34.9k, False: 0]
  |  |  |  |  |  Branch (192:65): [True: 34.9k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                  if (cannot_access_at_index(input_buffer, 0) || buffer_at_offset(input_buffer)[0] != ']') {
  ------------------
  |  |  195|  34.9k|#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset)
  ------------------
  |  Branch (1179:52): [True: 197, False: 34.7k]
  ------------------
 1180|    197|        goto fail; /* expected end of array */
 1181|    197|    }
 1182|       |
 1183|  48.9k|success:
 1184|  48.9k|    input_buffer->depth--;
 1185|       |
 1186|  48.9k|    if (head != NULL) {
  ------------------
  |  Branch (1186:9): [True: 34.7k, False: 14.1k]
  ------------------
 1187|  34.7k|        head->prev = current_item;
 1188|  34.7k|    }
 1189|       |
 1190|  48.9k|    item->type = cJSON_Array;
  ------------------
  |  |  102|  48.9k|#define cJSON_Array (1 << 5)
  ------------------
 1191|  48.9k|    item->child = head;
 1192|       |
 1193|  48.9k|    input_buffer->offset++;
 1194|       |
 1195|  48.9k|    return true;
  ------------------
  |  |   67|  48.9k|#define true ((cJSON_bool)1)
  ------------------
 1196|       |
 1197|  37.1k|fail:
 1198|  37.1k|    if (head != NULL) {
  ------------------
  |  Branch (1198:9): [True: 37.1k, False: 0]
  ------------------
 1199|  37.1k|        loader_cJSON_Delete(head);
 1200|  37.1k|    }
 1201|       |
 1202|  37.1k|    return false;
  ------------------
  |  |   72|  37.1k|#define false ((cJSON_bool)0)
  ------------------
 1203|  34.9k|}
cJSON.c:parse_object:
 1259|   112k|static cJSON_bool parse_object(cJSON *const item, parse_buffer *const input_buffer, bool *out_of_memory) {
 1260|   112k|    cJSON *head = NULL; /* linked list head */
 1261|   112k|    cJSON *current_item = NULL;
 1262|       |
 1263|   112k|    if (input_buffer->depth >= CJSON_NESTING_LIMIT) {
  ------------------
  |  |  138|   112k|#define CJSON_NESTING_LIMIT 1000
  ------------------
  |  Branch (1263:9): [True: 2, False: 112k]
  ------------------
 1264|      2|        return false; /* to deeply nested */
  ------------------
  |  |   72|      2|#define false ((cJSON_bool)0)
  ------------------
 1265|      2|    }
 1266|   112k|    input_buffer->depth++;
 1267|       |
 1268|   112k|    if (cannot_access_at_index(input_buffer, 0) || (buffer_at_offset(input_buffer)[0] != '{')) {
  ------------------
  |  |  193|   224k|#define cannot_access_at_index(buffer, index) (!can_access_at_index(buffer, index))
  |  |  ------------------
  |  |  |  |  192|   112k|#define can_access_at_index(buffer, index) ((buffer != NULL) && (((buffer)->offset + index) < (buffer)->length))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (192:45): [True: 112k, False: 0]
  |  |  |  |  |  Branch (192:65): [True: 112k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                  if (cannot_access_at_index(input_buffer, 0) || (buffer_at_offset(input_buffer)[0] != '{')) {
  ------------------
  |  |  195|   112k|#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset)
  ------------------
  |  Branch (1268:52): [True: 0, False: 112k]
  ------------------
 1269|      0|        goto fail; /* not an object */
 1270|      0|    }
 1271|       |
 1272|   112k|    input_buffer->offset++;
 1273|   112k|    buffer_skip_whitespace(input_buffer);
 1274|   112k|    if (can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == '}')) {
  ------------------
  |  |  192|   224k|#define can_access_at_index(buffer, index) ((buffer != NULL) && (((buffer)->offset + index) < (buffer)->length))
  |  |  ------------------
  |  |  |  Branch (192:45): [True: 112k, False: 0]
  |  |  |  Branch (192:65): [True: 112k, False: 0]
  |  |  ------------------
  ------------------
                  if (can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == '}')) {
  ------------------
  |  |  195|   112k|#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset)
  ------------------
  |  Branch (1274:49): [True: 4.37k, False: 107k]
  ------------------
 1275|  4.37k|        goto success; /* empty object */
 1276|  4.37k|    }
 1277|       |
 1278|       |    /* check if we skipped to the end of the buffer */
 1279|   107k|    if (cannot_access_at_index(input_buffer, 0)) {
  ------------------
  |  |  193|   107k|#define cannot_access_at_index(buffer, index) (!can_access_at_index(buffer, index))
  |  |  ------------------
  |  |  |  |  192|   107k|#define can_access_at_index(buffer, index) ((buffer != NULL) && (((buffer)->offset + index) < (buffer)->length))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (192:45): [True: 107k, False: 0]
  |  |  |  |  |  Branch (192:65): [True: 107k, 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|   107k|    input_buffer->offset--;
 1286|       |    /* loop through the comma separated array elements */
 1287|   386k|    do {
 1288|       |        /* allocate next item */
 1289|   386k|        cJSON *new_item = cJSON_New_Item(input_buffer->pAllocator);
 1290|   386k|        if (new_item == NULL) {
  ------------------
  |  Branch (1290:13): [True: 0, False: 386k]
  ------------------
 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|   386k|        if (head == NULL) {
  ------------------
  |  Branch (1296:13): [True: 107k, False: 278k]
  ------------------
 1297|       |            /* start the linked list */
 1298|   107k|            current_item = head = new_item;
 1299|   278k|        } else {
 1300|       |            /* add to the end and advance */
 1301|   278k|            current_item->next = new_item;
 1302|   278k|            new_item->prev = current_item;
 1303|   278k|            current_item = new_item;
 1304|   278k|        }
 1305|       |
 1306|   386k|        if (cannot_access_at_index(input_buffer, 1)) {
  ------------------
  |  |  193|   386k|#define cannot_access_at_index(buffer, index) (!can_access_at_index(buffer, index))
  |  |  ------------------
  |  |  |  |  192|   386k|#define can_access_at_index(buffer, index) ((buffer != NULL) && (((buffer)->offset + index) < (buffer)->length))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (192:45): [True: 386k, False: 0]
  |  |  |  |  |  Branch (192:65): [True: 386k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1307|      0|            goto fail; /* nothing comes after the comma */
 1308|      0|        }
 1309|       |
 1310|       |        /* parse the name of the child */
 1311|   386k|        input_buffer->offset++;
 1312|   386k|        buffer_skip_whitespace(input_buffer);
 1313|   386k|        if (!parse_string(current_item, input_buffer, out_of_memory)) {
  ------------------
  |  Branch (1313:13): [True: 129, False: 386k]
  ------------------
 1314|    129|            goto fail; /* failed to parse name */
 1315|    129|        }
 1316|   386k|        buffer_skip_whitespace(input_buffer);
 1317|       |
 1318|       |        /* swap valuestring and string, because we parsed the name */
 1319|   386k|        current_item->string = current_item->valuestring;
 1320|   386k|        current_item->valuestring = NULL;
 1321|       |
 1322|   386k|        if (cannot_access_at_index(input_buffer, 0) || (buffer_at_offset(input_buffer)[0] != ':')) {
  ------------------
  |  |  193|   772k|#define cannot_access_at_index(buffer, index) (!can_access_at_index(buffer, index))
  |  |  ------------------
  |  |  |  |  192|   386k|#define can_access_at_index(buffer, index) ((buffer != NULL) && (((buffer)->offset + index) < (buffer)->length))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (192:45): [True: 386k, False: 0]
  |  |  |  |  |  Branch (192:65): [True: 386k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                      if (cannot_access_at_index(input_buffer, 0) || (buffer_at_offset(input_buffer)[0] != ':')) {
  ------------------
  |  |  195|   386k|#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset)
  ------------------
  |  Branch (1322:56): [True: 75, False: 386k]
  ------------------
 1323|     75|            goto fail; /* invalid object */
 1324|     75|        }
 1325|       |
 1326|       |        /* parse the value */
 1327|   386k|        input_buffer->offset++;
 1328|   386k|        buffer_skip_whitespace(input_buffer);
 1329|   386k|        if (!parse_value(current_item, input_buffer, out_of_memory)) {
  ------------------
  |  Branch (1329:13): [True: 1.46k, False: 384k]
  ------------------
 1330|  1.46k|            goto fail; /* failed to parse value */
 1331|  1.46k|        }
 1332|   384k|        buffer_skip_whitespace(input_buffer);
 1333|   384k|    } while (can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == ','));
  ------------------
  |  |  192|   769k|#define can_access_at_index(buffer, index) ((buffer != NULL) && (((buffer)->offset + index) < (buffer)->length))
  |  |  ------------------
  |  |  |  Branch (192:45): [True: 384k, False: 0]
  |  |  |  Branch (192:65): [True: 384k, False: 0]
  |  |  ------------------
  ------------------
                  } while (can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == ','));
  ------------------
  |  |  195|   384k|#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset)
  ------------------
  |  Branch (1333:54): [True: 278k, False: 106k]
  ------------------
 1334|       |
 1335|   106k|    if (cannot_access_at_index(input_buffer, 0) || (buffer_at_offset(input_buffer)[0] != '}')) {
  ------------------
  |  |  193|   212k|#define cannot_access_at_index(buffer, index) (!can_access_at_index(buffer, index))
  |  |  ------------------
  |  |  |  |  192|   106k|#define can_access_at_index(buffer, index) ((buffer != NULL) && (((buffer)->offset + index) < (buffer)->length))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (192:45): [True: 106k, False: 0]
  |  |  |  |  |  Branch (192:65): [True: 106k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                  if (cannot_access_at_index(input_buffer, 0) || (buffer_at_offset(input_buffer)[0] != '}')) {
  ------------------
  |  |  195|   106k|#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset)
  ------------------
  |  Branch (1335:52): [True: 51, False: 106k]
  ------------------
 1336|     51|        goto fail; /* expected end of object */
 1337|     51|    }
 1338|       |
 1339|   110k|success:
 1340|   110k|    input_buffer->depth--;
 1341|       |
 1342|   110k|    if (head != NULL) {
  ------------------
  |  Branch (1342:9): [True: 106k, False: 4.37k]
  ------------------
 1343|   106k|        head->prev = current_item;
 1344|   106k|    }
 1345|       |
 1346|   110k|    item->type = cJSON_Object;
  ------------------
  |  |  103|   110k|#define cJSON_Object (1 << 6)
  ------------------
 1347|   110k|    item->child = head;
 1348|       |
 1349|   110k|    input_buffer->offset++;
 1350|   110k|    return true;
  ------------------
  |  |   67|   110k|#define true ((cJSON_bool)1)
  ------------------
 1351|       |
 1352|  1.71k|fail:
 1353|  1.71k|    if (head != NULL) {
  ------------------
  |  Branch (1353:9): [True: 1.71k, False: 0]
  ------------------
 1354|  1.71k|        loader_cJSON_Delete(head);
 1355|  1.71k|    }
 1356|       |
 1357|  1.71k|    return false;
  ------------------
  |  |   72|  1.71k|#define false ((cJSON_bool)0)
  ------------------
 1358|   106k|}
cJSON.c:print_value:
 1056|   149k|static cJSON_bool print_value(const cJSON *const item, printbuffer *const output_buffer, bool *out_of_memory) {
 1057|   149k|    unsigned char *output = NULL;
 1058|       |
 1059|   149k|    if ((item == NULL) || (output_buffer == NULL)) {
  ------------------
  |  Branch (1059:9): [True: 0, False: 149k]
  |  Branch (1059:27): [True: 0, False: 149k]
  ------------------
 1060|      0|        return false;
  ------------------
  |  |   72|      0|#define false ((cJSON_bool)0)
  ------------------
 1061|      0|    }
 1062|       |
 1063|   149k|    switch ((item->type) & 0xFF) {
 1064|      0|        case cJSON_NULL:
  ------------------
  |  |   99|      0|#define cJSON_NULL (1 << 2)
  ------------------
  |  Branch (1064:9): [True: 0, False: 149k]
  ------------------
 1065|      0|            output = ensure(output_buffer, 5, out_of_memory);
 1066|      0|            if (output == NULL) {
  ------------------
  |  Branch (1066:17): [True: 0, False: 0]
  ------------------
 1067|      0|                return false;
  ------------------
  |  |   72|      0|#define false ((cJSON_bool)0)
  ------------------
 1068|      0|            }
 1069|      0|            strcpy((char *)output, "null");
 1070|      0|            return true;
  ------------------
  |  |   67|      0|#define true ((cJSON_bool)1)
  ------------------
 1071|       |
 1072|      0|        case cJSON_False:
  ------------------
  |  |   97|      0|#define cJSON_False (1 << 0)
  ------------------
  |  Branch (1072:9): [True: 0, False: 149k]
  ------------------
 1073|      0|            output = ensure(output_buffer, 6, out_of_memory);
 1074|      0|            if (output == NULL) {
  ------------------
  |  Branch (1074:17): [True: 0, False: 0]
  ------------------
 1075|      0|                return false;
  ------------------
  |  |   72|      0|#define false ((cJSON_bool)0)
  ------------------
 1076|      0|            }
 1077|      0|            strcpy((char *)output, "false");
 1078|      0|            return true;
  ------------------
  |  |   67|      0|#define true ((cJSON_bool)1)
  ------------------
 1079|       |
 1080|      0|        case cJSON_True:
  ------------------
  |  |   98|      0|#define cJSON_True (1 << 1)
  ------------------
  |  Branch (1080:9): [True: 0, False: 149k]
  ------------------
 1081|      0|            output = ensure(output_buffer, 5, out_of_memory);
 1082|      0|            if (output == NULL) {
  ------------------
  |  Branch (1082:17): [True: 0, False: 0]
  ------------------
 1083|      0|                return false;
  ------------------
  |  |   72|      0|#define false ((cJSON_bool)0)
  ------------------
 1084|      0|            }
 1085|      0|            strcpy((char *)output, "true");
 1086|      0|            return true;
  ------------------
  |  |   67|      0|#define true ((cJSON_bool)1)
  ------------------
 1087|       |
 1088|      0|        case cJSON_Number:
  ------------------
  |  |  100|      0|#define cJSON_Number (1 << 3)
  ------------------
  |  Branch (1088:9): [True: 0, False: 149k]
  ------------------
 1089|      0|            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: 149k]
  ------------------
 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|   149k|        case cJSON_String:
  ------------------
  |  |  101|   149k|#define cJSON_String (1 << 4)
  ------------------
  |  Branch (1106:9): [True: 149k, False: 0]
  ------------------
 1107|   149k|            return print_string(item, output_buffer, out_of_memory);
 1108|       |
 1109|      0|        case cJSON_Array:
  ------------------
  |  |  102|      0|#define cJSON_Array (1 << 5)
  ------------------
  |  Branch (1109:9): [True: 0, False: 149k]
  ------------------
 1110|      0|            return print_array(item, output_buffer, out_of_memory);
 1111|       |
 1112|      0|        case cJSON_Object:
  ------------------
  |  |  103|      0|#define cJSON_Object (1 << 6)
  ------------------
  |  Branch (1112:9): [True: 0, False: 149k]
  ------------------
 1113|      0|            return print_object(item, output_buffer, out_of_memory);
 1114|       |
 1115|      0|        default:
  ------------------
  |  Branch (1115:9): [True: 0, False: 149k]
  ------------------
 1116|      0|            return false;
  ------------------
  |  |   72|      0|#define false ((cJSON_bool)0)
  ------------------
 1117|   149k|    }
 1118|   149k|}
cJSON.c:ensure:
  275|   149k|static unsigned char *ensure(printbuffer *const p, size_t needed, bool *out_of_memory) {
  276|   149k|    unsigned char *newbuffer = NULL;
  277|   149k|    size_t newsize = 0;
  278|       |
  279|   149k|    if ((p == NULL) || (p->buffer == NULL)) {
  ------------------
  |  Branch (279:9): [True: 0, False: 149k]
  |  Branch (279:24): [True: 0, False: 149k]
  ------------------
  280|      0|        return NULL;
  281|      0|    }
  282|       |
  283|   149k|    if ((p->length > 0) && (p->offset >= p->length)) {
  ------------------
  |  Branch (283:9): [True: 149k, False: 0]
  |  Branch (283:28): [True: 0, False: 149k]
  ------------------
  284|       |        /* make sure that offset is valid */
  285|      0|        return NULL;
  286|      0|    }
  287|       |
  288|   149k|    if (needed > INT_MAX) {
  ------------------
  |  Branch (288:9): [True: 0, False: 149k]
  ------------------
  289|       |        /* sizes bigger than INT_MAX are currently not supported */
  290|      0|        return NULL;
  291|      0|    }
  292|       |
  293|   149k|    needed += p->offset + 1;
  294|   149k|    if (needed <= p->length) {
  ------------------
  |  Branch (294:9): [True: 147k, False: 1.21k]
  ------------------
  295|   147k|        return p->buffer + p->offset;
  296|   147k|    }
  297|       |
  298|  1.21k|    if (p->noalloc) {
  ------------------
  |  Branch (298:9): [True: 370, False: 842]
  ------------------
  299|    370|        return NULL;
  300|    370|    }
  301|       |
  302|       |    /* calculate new buffer size */
  303|    842|    if (needed > (INT_MAX / 2)) {
  ------------------
  |  Branch (303:9): [True: 0, False: 842]
  ------------------
  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|    842|    } else {
  311|    842|        newsize = needed * 2;
  312|    842|    }
  313|       |
  314|    842|    newbuffer = (unsigned char *)loader_realloc(p->pAllocator, p->buffer, p->length, newsize, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
  315|    842|    if (newbuffer == NULL) {
  ------------------
  |  Branch (315:9): [True: 0, False: 842]
  ------------------
  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|    842|    p->length = newsize;
  325|    842|    p->buffer = newbuffer;
  326|       |
  327|    842|    return newbuffer + p->offset;
  328|    842|}
cJSON.c:print_string:
  759|   149k|static cJSON_bool print_string(const cJSON *const item, printbuffer *const p, bool *out_of_memory) {
  760|   149k|    return print_string_ptr((unsigned char *)item->valuestring, p, out_of_memory);
  761|   149k|}
cJSON.c:print_string_ptr:
  650|   149k|static cJSON_bool print_string_ptr(const unsigned char *const input, printbuffer *const output_buffer, bool *out_of_memory) {
  651|   149k|    const unsigned char *input_pointer = NULL;
  652|   149k|    unsigned char *output = NULL;
  653|   149k|    unsigned char *output_pointer = NULL;
  654|   149k|    size_t output_length = 0;
  655|       |    /* numbers of additional characters needed for escaping */
  656|   149k|    size_t escape_characters = 0;
  657|       |
  658|   149k|    if (output_buffer == NULL) {
  ------------------
  |  Branch (658:9): [True: 0, False: 149k]
  ------------------
  659|      0|        return false;
  ------------------
  |  |   72|      0|#define false ((cJSON_bool)0)
  ------------------
  660|      0|    }
  661|       |
  662|       |    /* empty string */
  663|   149k|    if (input == NULL) {
  ------------------
  |  Branch (663:9): [True: 0, False: 149k]
  ------------------
  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|  2.45M|    for (input_pointer = input; *input_pointer; input_pointer++) {
  ------------------
  |  Branch (673:33): [True: 2.30M, False: 149k]
  ------------------
  674|  2.30M|        switch (*input_pointer) {
  675|    146|            case '\"':
  ------------------
  |  Branch (675:13): [True: 146, False: 2.30M]
  ------------------
  676|  1.03k|            case '\\':
  ------------------
  |  Branch (676:13): [True: 888, False: 2.30M]
  ------------------
  677|  8.07k|            case '\b':
  ------------------
  |  Branch (677:13): [True: 7.04k, False: 2.30M]
  ------------------
  678|  9.76k|            case '\f':
  ------------------
  |  Branch (678:13): [True: 1.68k, False: 2.30M]
  ------------------
  679|  19.5k|            case '\n':
  ------------------
  |  Branch (679:13): [True: 9.74k, False: 2.29M]
  ------------------
  680|  24.7k|            case '\r':
  ------------------
  |  Branch (680:13): [True: 5.19k, False: 2.30M]
  ------------------
  681|  26.1k|            case '\t':
  ------------------
  |  Branch (681:13): [True: 1.45k, False: 2.30M]
  ------------------
  682|       |                /* one character escape sequence */
  683|  26.1k|                escape_characters++;
  684|  26.1k|                break;
  685|  2.28M|            default:
  ------------------
  |  Branch (685:13): [True: 2.28M, False: 26.1k]
  ------------------
  686|  2.28M|                if (*input_pointer < 32) {
  ------------------
  |  Branch (686:21): [True: 688k, False: 1.59M]
  ------------------
  687|       |                    /* UTF-16 escape sequence uXXXX */
  688|   688k|                    escape_characters += 5;
  689|   688k|                }
  690|  2.28M|                break;
  691|  2.30M|        }
  692|  2.30M|    }
  693|   149k|    output_length = (size_t)(input_pointer - input) + escape_characters;
  694|       |
  695|   149k|    output = ensure(output_buffer, output_length + sizeof(""), out_of_memory);
  696|   149k|    if (output == NULL) {
  ------------------
  |  Branch (696:9): [True: 370, False: 148k]
  ------------------
  697|    370|        return false;
  ------------------
  |  |   72|    370|#define false ((cJSON_bool)0)
  ------------------
  698|    370|    }
  699|       |
  700|       |    /* no characters have to be escaped */
  701|   148k|    if (escape_characters == 0) {
  ------------------
  |  Branch (701:9): [True: 129k, False: 18.8k]
  ------------------
  702|   129k|        memcpy(output, input, output_length);
  703|   129k|        output[output_length] = '\0';
  704|       |
  705|   129k|        return true;
  ------------------
  |  |   67|   129k|#define true ((cJSON_bool)1)
  ------------------
  706|   129k|    }
  707|       |
  708|  18.8k|    output_pointer = output;
  709|       |    /* copy the string */
  710|  1.18M|    for (input_pointer = input; *input_pointer != '\0'; (void)input_pointer++, output_pointer++) {
  ------------------
  |  Branch (710:33): [True: 1.16M, False: 18.8k]
  ------------------
  711|  1.16M|        if ((*input_pointer > 31) && (*input_pointer != '\"') && (*input_pointer != '\\')) {
  ------------------
  |  Branch (711:13): [True: 488k, False: 680k]
  |  Branch (711:38): [True: 488k, False: 146]
  |  Branch (711:66): [True: 487k, False: 888]
  ------------------
  712|       |            /* normal character, copy */
  713|   487k|            *output_pointer = *input_pointer;
  714|   681k|        } 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|   681k|            switch (*input_pointer) {
  721|    888|                case '\\':
  ------------------
  |  Branch (721:17): [True: 888, False: 680k]
  ------------------
  722|    888|                    *output_pointer = '\\';
  723|    888|                    break;
  724|    146|                case '\"':
  ------------------
  |  Branch (724:17): [True: 146, False: 681k]
  ------------------
  725|    146|                    *output_pointer = '\"';
  726|    146|                    break;
  727|  7.03k|                case '\b':
  ------------------
  |  Branch (727:17): [True: 7.03k, False: 674k]
  ------------------
  728|  7.03k|                    *output_pointer = '\b';
  729|  7.03k|                    break;
  730|  1.33k|                case '\f':
  ------------------
  |  Branch (730:17): [True: 1.33k, False: 680k]
  ------------------
  731|  1.33k|                    *output_pointer = '\f';
  732|  1.33k|                    break;
  733|  9.60k|                case '\n':
  ------------------
  |  Branch (733:17): [True: 9.60k, False: 672k]
  ------------------
  734|  9.60k|                    *output_pointer = '\n';
  735|  9.60k|                    break;
  736|  5.19k|                case '\r':
  ------------------
  |  Branch (736:17): [True: 5.19k, False: 676k]
  ------------------
  737|  5.19k|                    *output_pointer = '\r';
  738|  5.19k|                    break;
  739|  1.44k|                case '\t':
  ------------------
  |  Branch (739:17): [True: 1.44k, False: 680k]
  ------------------
  740|  1.44k|                    *output_pointer = '\t';
  741|  1.44k|                    break;
  742|   656k|                default:
  ------------------
  |  Branch (742:17): [True: 656k, False: 25.6k]
  ------------------
  743|       |                    /* escape and print as unicode codepoint */
  744|   656k|                    snprintf((char *)output_pointer, output_length - (size_t)(output_pointer - output), "u%04x", *input_pointer);
  745|   656k|                    output_pointer += 4;
  746|   656k|                    break;
  747|   681k|            }
  748|   681k|        }
  749|  1.16M|    }
  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 (uninitialised when the caller buffer is not zeroed) get read back as part of the string.
  753|  18.8k|    *output_pointer = '\0';
  754|       |
  755|  18.8k|    return true;
  ------------------
  |  |   67|  18.8k|#define true ((cJSON_bool)1)
  ------------------
  756|  18.8k|}
cJSON.c:get_object_item:
 1501|   367k|static cJSON *get_object_item(const cJSON *const object, const char *const name, const cJSON_bool case_sensitive) {
 1502|   367k|    cJSON *current_element = NULL;
 1503|       |
 1504|   367k|    if ((object == NULL) || (name == NULL)) {
  ------------------
  |  Branch (1504:9): [True: 0, False: 367k]
  |  Branch (1504:29): [True: 0, False: 367k]
  ------------------
 1505|      0|        return NULL;
 1506|      0|    }
 1507|       |
 1508|   367k|    current_element = object->child;
 1509|   367k|    if (case_sensitive) {
  ------------------
  |  Branch (1509:9): [True: 0, False: 367k]
  ------------------
 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|   367k|    } else {
 1514|  2.07M|        while ((current_element != NULL) &&
  ------------------
  |  Branch (1514:16): [True: 1.90M, False: 175k]
  ------------------
 1515|  1.90M|               (case_insensitive_strcmp((const unsigned char *)name, (const unsigned char *)(current_element->string)) != 0)) {
  ------------------
  |  Branch (1515:16): [True: 1.71M, False: 192k]
  ------------------
 1516|  1.71M|            current_element = current_element->next;
 1517|  1.71M|        }
 1518|   367k|    }
 1519|       |
 1520|   367k|    if ((current_element == NULL) || (current_element->string == NULL)) {
  ------------------
  |  Branch (1520:9): [True: 175k, False: 192k]
  |  Branch (1520:38): [True: 0, False: 192k]
  ------------------
 1521|   175k|        return NULL;
 1522|   175k|    }
 1523|       |
 1524|   192k|    return current_element;
 1525|   367k|}
cJSON.c:case_insensitive_strcmp:
  120|  1.90M|static int case_insensitive_strcmp(const unsigned char *string1, const unsigned char *string2) {
  121|  1.90M|    if ((string1 == NULL) || (string2 == NULL)) {
  ------------------
  |  Branch (121:9): [True: 0, False: 1.90M]
  |  Branch (121:30): [True: 52, False: 1.90M]
  ------------------
  122|     52|        return 1;
  123|     52|    }
  124|       |
  125|  1.90M|    if (string1 == string2) {
  ------------------
  |  Branch (125:9): [True: 0, False: 1.90M]
  ------------------
  126|      0|        return 0;
  127|      0|    }
  128|       |
  129|  4.06M|    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: 4.06M]
  |  Branch (129:12): [True: 2.35M, False: 1.71M]
  |  Branch (129:33): [True: 0, False: 0]
  |  Branch (129:33): [True: 0, False: 0]
  |  Branch (129:33): [Folded, False: 4.06M]
  ------------------
  130|  2.35M|        if (*string1 == '\0') {
  ------------------
  |  Branch (130:13): [True: 192k, False: 2.15M]
  ------------------
  131|   192k|            return 0;
  132|   192k|        }
  133|  2.35M|    }
  134|       |
  135|  1.71M|    return tolower(*string1) - tolower(*string2);
  ------------------
  |  Branch (135:12): [True: 0, False: 0]
  |  Branch (135:12): [True: 0, False: 0]
  |  Branch (135:12): [Folded, False: 1.71M]
  |  Branch (135:32): [True: 0, False: 0]
  |  Branch (135:32): [True: 0, False: 0]
  |  Branch (135:32): [Folded, False: 1.71M]
  ------------------
  136|  1.90M|}

util_SubmitDebugUtilsMessageEXT:
   78|   358k|                                         const VkDebugUtilsMessengerCallbackDataEXT *pCallbackData) {
   79|   358k|    VkBool32 bail = false;
   80|       |
   81|   358k|    if (NULL != pCallbackData) {
  ------------------
  |  Branch (81:9): [True: 358k, False: 0]
  ------------------
   82|   358k|        VkLayerDbgFunctionNode *pTrav = inst->current_dbg_function_head;
   83|   358k|        VkDebugReportObjectTypeEXT object_type = VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT;
   84|   358k|        VkDebugReportFlagsEXT object_flags = 0;
   85|   358k|        uint64_t object_handle = 0;
   86|       |
   87|   358k|        debug_utils_AnnotFlagsToReportFlags(messageSeverity, messageTypes, &object_flags);
   88|   358k|        if (0 < pCallbackData->objectCount) {
  ------------------
  |  Branch (88:13): [True: 358k, False: 0]
  ------------------
   89|   358k|            debug_utils_AnnotObjectToDebugReportObject(pCallbackData->pObjects, &object_type, &object_handle);
   90|   358k|        }
   91|   358k|        while (pTrav) {
  ------------------
  |  Branch (91:16): [True: 0, False: 358k]
  ------------------
   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|   358k|    }
  107|       |
  108|   358k|    return bail;
  109|   358k|}
util_CreateDebugUtilsMessengers:
  130|  7.00k|                                         const VkAllocationCallbacks *pAllocator) {
  131|  7.00k|    const void *pNext = pChain;
  132|  7.00k|    while (pNext) {
  ------------------
  |  Branch (132:12): [True: 0, False: 7.00k]
  ------------------
  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|      0|            VkDebugUtilsMessengerEXT messenger_handle = (VkDebugUtilsMessengerEXT)(uintptr_t)pNext;
  139|      0|            VkResult ret = util_CreateDebugUtilsMessenger(inst, (const VkDebugUtilsMessengerCreateInfoEXT *)pNext, pAllocator,
  140|      0|                                                          messenger_handle);
  141|      0|            if (ret != VK_SUCCESS) {
  ------------------
  |  Branch (141:17): [True: 0, False: 0]
  ------------------
  142|      0|                return ret;
  143|      0|            }
  144|      0|        }
  145|      0|        pNext = in_structure.pNext;
  146|      0|    }
  147|  7.00k|    return VK_SUCCESS;
  148|  7.00k|}
util_CreateDebugReportCallbacks:
  413|  7.00k|                                         const VkAllocationCallbacks *pAllocator) {
  414|  7.00k|    const void *pNext = pChain;
  415|  7.00k|    while (pNext) {
  ------------------
  |  Branch (415:12): [True: 0, False: 7.00k]
  ------------------
  416|      0|        VkBaseInStructure in_structure = {0};
  417|      0|        memcpy(&in_structure, pNext, sizeof(VkBaseInStructure));
  418|      0|        if (in_structure.sType == VK_STRUCTURE_TYPE_DEBUG_REPORT_CREATE_INFO_EXT) {
  ------------------
  |  Branch (418:13): [True: 0, False: 0]
  ------------------
  419|       |            // Assign a unique handle to each callback (just use the address of the VkDebugReportCallbackCreateInfoEXT):
  420|       |            // This is only being used this way due to it being for an 'anonymous' callback during instance creation
  421|      0|            VkDebugReportCallbackEXT report_handle = (VkDebugReportCallbackEXT)(uintptr_t)pNext;
  422|      0|            VkResult ret =
  423|      0|                util_CreateDebugReportCallback(inst, (const VkDebugReportCallbackCreateInfoEXT *)pNext, pAllocator, report_handle);
  424|      0|            if (ret != VK_SUCCESS) {
  ------------------
  |  Branch (424:17): [True: 0, False: 0]
  ------------------
  425|      0|                return ret;
  426|      0|            }
  427|      0|        }
  428|      0|        pNext = in_structure.pNext;
  429|      0|    }
  430|  7.00k|    return VK_SUCCESS;
  431|  7.00k|}
destroy_debug_callbacks_chain:
  611|  7.00k|void destroy_debug_callbacks_chain(struct loader_instance *inst, const VkAllocationCallbacks *pAllocator) {
  612|  7.00k|    VkLayerDbgFunctionNode *pTrav = inst->current_dbg_function_head;
  613|  7.00k|    VkLayerDbgFunctionNode *pNext = NULL;
  614|  7.00k|    while (pTrav) {
  ------------------
  |  Branch (614:12): [True: 0, False: 7.00k]
  ------------------
  615|      0|        pNext = pTrav->pNext;
  616|      0|        loader_free_with_instance_fallback(pAllocator, inst, pTrav);
  617|      0|        pTrav = pNext;
  618|      0|    }
  619|       |    inst->current_dbg_function_head = NULL;
  620|  7.00k|}
debug_utils_AnnotFlagsToReportFlags:
  694|   358k|                                         VkDebugUtilsMessageTypeFlagsEXT da_type, VkDebugReportFlagsEXT *dr_flags) {
  695|   358k|    if (NULL == dr_flags) {
  ------------------
  |  Branch (695:9): [True: 0, False: 358k]
  ------------------
  696|      0|        return false;
  697|      0|    }
  698|       |
  699|   358k|    *dr_flags = 0;
  700|       |
  701|   358k|    if ((da_severity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT) != 0) {
  ------------------
  |  Branch (701:9): [True: 13.7k, False: 345k]
  ------------------
  702|  13.7k|        *dr_flags |= VK_DEBUG_REPORT_ERROR_BIT_EXT;
  703|   345k|    } else if ((da_severity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT) != 0) {
  ------------------
  |  Branch (703:16): [True: 65.0k, False: 280k]
  ------------------
  704|  65.0k|        if ((da_type & VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT) != 0) {
  ------------------
  |  Branch (704:13): [True: 0, False: 65.0k]
  ------------------
  705|      0|            *dr_flags |= VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT;
  706|  65.0k|        } else {
  707|  65.0k|            *dr_flags |= VK_DEBUG_REPORT_WARNING_BIT_EXT;
  708|  65.0k|        }
  709|   280k|    } else if ((da_severity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT) != 0) {
  ------------------
  |  Branch (709:16): [True: 188k, False: 91.9k]
  ------------------
  710|   188k|        *dr_flags |= VK_DEBUG_REPORT_INFORMATION_BIT_EXT;
  711|   188k|    } else if ((da_severity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT) != 0) {
  ------------------
  |  Branch (711:16): [True: 91.9k, False: 0]
  ------------------
  712|  91.9k|        *dr_flags |= VK_DEBUG_REPORT_DEBUG_BIT_EXT;
  713|  91.9k|    }
  714|       |
  715|       |    return true;
  716|   358k|}
debug_utils_AnnotObjectToDebugReportObject:
  732|   358k|                                                VkDebugReportObjectTypeEXT *dr_object_type, uint64_t *dr_object_handle) {
  733|   358k|    if (NULL == da_object_name_info || NULL == dr_object_type || NULL == dr_object_handle) {
  ------------------
  |  Branch (733:9): [True: 0, False: 358k]
  |  Branch (733:40): [True: 0, False: 358k]
  |  Branch (733:66): [True: 0, False: 358k]
  ------------------
  734|      0|        return false;
  735|      0|    }
  736|   358k|    *dr_object_type = convertCoreObjectToDebugReportObject(da_object_name_info->objectType);
  737|   358k|    *dr_object_handle = da_object_name_info->objectHandle;
  738|       |    return true;
  739|   358k|}

debug_utils.c:convertCoreObjectToDebugReportObject:
  391|   358k|static inline VkDebugReportObjectTypeEXT convertCoreObjectToDebugReportObject(VkObjectType core_report_obj){
  392|   358k|    if (core_report_obj == VK_OBJECT_TYPE_UNKNOWN) {
  ------------------
  |  Branch (392:9): [True: 0, False: 358k]
  ------------------
  393|      0|        return VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT;
  394|   358k|    } else if (core_report_obj == VK_OBJECT_TYPE_UNKNOWN) {
  ------------------
  |  Branch (394:16): [True: 0, False: 358k]
  ------------------
  395|      0|        return VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT;
  396|   358k|    } else if (core_report_obj == VK_OBJECT_TYPE_INSTANCE) {
  ------------------
  |  Branch (396:16): [True: 358k, False: 0]
  ------------------
  397|   358k|        return VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT;
  398|   358k|    } 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|   358k|}

loader_make_version:
  112|  24.3k|loader_api_version loader_make_version(uint32_t version) {
  113|  24.3k|    loader_api_version out_version;
  114|  24.3k|    out_version.major = VK_API_VERSION_MAJOR(version);
  115|       |    out_version.minor = VK_API_VERSION_MINOR(version);
  116|  24.3k|    out_version.patch = 0;
  117|  24.3k|    return out_version;
  118|  24.3k|}
loader_make_full_version:
  121|  4.81k|loader_api_version loader_make_full_version(uint32_t version) {
  122|  4.81k|    loader_api_version out_version;
  123|  4.81k|    out_version.major = VK_API_VERSION_MAJOR(version);
  124|  4.81k|    out_version.minor = VK_API_VERSION_MINOR(version);
  125|       |    out_version.patch = VK_API_VERSION_PATCH(version);
  126|  4.81k|    return out_version;
  127|  4.81k|}
loader_combine_version:
  129|  16.8k|loader_api_version loader_combine_version(uint32_t major, uint32_t minor, uint32_t patch) {
  130|  16.8k|    loader_api_version out_version;
  131|  16.8k|    out_version.major = (uint16_t)major;
  132|  16.8k|    out_version.minor = (uint16_t)minor;
  133|  16.8k|    out_version.patch = (uint16_t)patch;
  134|  16.8k|    return out_version;
  135|  16.8k|}
loader_check_version_meets_required:
  138|  21.6k|bool loader_check_version_meets_required(loader_api_version required, loader_api_version version) {
  139|       |    // major version is satisfied
  140|  21.6k|    return (version.major > required.major) ||
  ------------------
  |  Branch (140:12): [True: 4.87k, False: 16.8k]
  ------------------
  141|       |           // major version is equal, minor version is patch version is greater to minimum minor
  142|  16.8k|           (version.major == required.major && version.minor > required.minor) ||
  ------------------
  |  Branch (142:13): [True: 8.74k, False: 8.05k]
  |  Branch (142:48): [True: 2.04k, False: 6.70k]
  ------------------
  143|       |           // major and minor version are equal, patch version is greater or equal to minimum patch
  144|  14.7k|           (version.major == required.major && version.minor == required.minor && version.patch >= required.patch);
  ------------------
  |  Branch (144:13): [True: 6.70k, False: 8.05k]
  |  Branch (144:48): [True: 4.76k, False: 1.94k]
  |  Branch (144:83): [True: 4.15k, False: 611]
  ------------------
  145|  21.6k|}
loader_opendir:
  172|  75.0k|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|  75.0k|    return opendir(name);
  178|       |#else
  179|       |#warning dirent.h - opendir not available on this platform
  180|       |#endif  // _WIN32
  181|  75.0k|}
loader_closedir:
  182|  5.71k|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|  5.71k|    return closedir(dir);
  188|       |#else
  189|       |#warning dirent.h - closedir not available on this platform
  190|       |#endif  // _WIN32
  191|  5.71k|}
is_json:
  193|   202k|bool is_json(const char *path, size_t len) {
  194|   202k|    if (len < 5) {
  ------------------
  |  Branch (194:9): [True: 23.4k, False: 178k]
  ------------------
  195|  23.4k|        return false;
  196|  23.4k|    }
  197|   178k|    return !strncmp(path + len - 5, ".json", 5);
  198|   202k|}
loader_free_layer_properties:
  248|  35.1k|void loader_free_layer_properties(const struct loader_instance *inst, struct loader_layer_properties *layer_properties) {
  249|  35.1k|    loader_instance_heap_free(inst, layer_properties->manifest_file_name);
  250|  35.1k|    loader_instance_heap_free(inst, layer_properties->lib_name);
  251|  35.1k|    loader_instance_heap_free(inst, layer_properties->functions.str_gipa);
  252|  35.1k|    loader_instance_heap_free(inst, layer_properties->functions.str_gdpa);
  253|  35.1k|    loader_instance_heap_free(inst, layer_properties->functions.str_negotiate_interface);
  254|  35.1k|    loader_destroy_generic_list(inst, (struct loader_generic_list *)&layer_properties->instance_extension_list);
  255|  35.1k|    if (layer_properties->device_extension_list.capacity > 0 && NULL != layer_properties->device_extension_list.list) {
  ------------------
  |  Branch (255:9): [True: 859, False: 34.2k]
  |  Branch (255:65): [True: 859, False: 0]
  ------------------
  256|  8.14k|        for (uint32_t i = 0; i < layer_properties->device_extension_list.count; i++) {
  ------------------
  |  Branch (256:30): [True: 7.28k, False: 859]
  ------------------
  257|  7.28k|            free_string_list(inst, &layer_properties->device_extension_list.list[i].entrypoints);
  258|  7.28k|        }
  259|    859|    }
  260|  35.1k|    loader_destroy_generic_list(inst, (struct loader_generic_list *)&layer_properties->device_extension_list);
  261|  35.1k|    loader_instance_heap_free(inst, layer_properties->disable_env_var.name);
  262|  35.1k|    loader_instance_heap_free(inst, layer_properties->disable_env_var.value);
  263|  35.1k|    loader_instance_heap_free(inst, layer_properties->enable_env_var.name);
  264|  35.1k|    loader_instance_heap_free(inst, layer_properties->enable_env_var.value);
  265|  35.1k|    free_string_list(inst, &layer_properties->component_layer_names);
  266|  35.1k|    loader_instance_heap_free(inst, layer_properties->pre_instance_functions.enumerate_instance_extension_properties);
  267|  35.1k|    loader_instance_heap_free(inst, layer_properties->pre_instance_functions.enumerate_instance_layer_properties);
  268|  35.1k|    loader_instance_heap_free(inst, layer_properties->pre_instance_functions.enumerate_instance_version);
  269|  35.1k|    free_string_list(inst, &layer_properties->override_paths);
  270|  35.1k|    free_string_list(inst, &layer_properties->blacklist_layer_names);
  271|  35.1k|    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|  35.1k|    memset(layer_properties, 0, sizeof(struct loader_layer_properties));
  275|  35.1k|}
is_string_in_string_list:
  287|  91.2k|bool is_string_in_string_list(struct loader_string_list *string_list, const char *str) {
  288|       |    // Remove duplicate paths, or it would result in duplicate extensions, duplicate devices, etc.
  289|  1.02M|    for (size_t i = 0; i < string_list->count; i++) {
  ------------------
  |  Branch (289:24): [True: 941k, False: 80.0k]
  ------------------
  290|   941k|        if (strcmp(string_list->list[i], str) == 0) {
  ------------------
  |  Branch (290:13): [True: 11.1k, False: 930k]
  ------------------
  291|  11.1k|            return true;
  292|  11.1k|        }
  293|   941k|    }
  294|  80.0k|    return false;
  295|  91.2k|}
loader_copy_to_new_str:
  297|  44.9k|VkResult loader_copy_to_new_str(const struct loader_instance *inst, const char *source_str, char **dest_str) {
  298|  44.9k|    assert(source_str && dest_str);
  299|  44.9k|    size_t str_len = strlen(source_str) + 1;
  300|  44.9k|    *dest_str = loader_instance_heap_calloc(inst, str_len, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
  301|  44.9k|    if (NULL == *dest_str) return VK_ERROR_OUT_OF_HOST_MEMORY;
  ------------------
  |  Branch (301:9): [True: 0, False: 44.9k]
  ------------------
  302|  44.9k|    loader_strncpy(*dest_str, str_len, source_str, str_len);
  303|  44.9k|    (*dest_str)[str_len - 1] = 0;
  304|  44.9k|    return VK_SUCCESS;
  305|  44.9k|}
create_string_list:
  307|  6.23k|VkResult create_string_list(const struct loader_instance *inst, uint32_t allocated_count, struct loader_string_list *string_list) {
  308|  6.23k|    assert(string_list);
  309|  6.23k|    string_list->list = loader_instance_heap_calloc(inst, sizeof(char *) * allocated_count, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
  310|  6.23k|    if (NULL == string_list->list) {
  ------------------
  |  Branch (310:9): [True: 0, False: 6.23k]
  ------------------
  311|      0|        return VK_ERROR_OUT_OF_HOST_MEMORY;
  312|      0|    }
  313|  6.23k|    string_list->allocated_count = allocated_count;
  314|  6.23k|    string_list->count = 0;
  315|  6.23k|    return VK_SUCCESS;
  316|  6.23k|}
increase_str_capacity_by_at_least_one:
  318|   139k|VkResult increase_str_capacity_by_at_least_one(const struct loader_instance *inst, struct loader_string_list *string_list) {
  319|   139k|    assert(string_list);
  320|   139k|    if (string_list->allocated_count == 0) {
  ------------------
  |  Branch (320:9): [True: 15.3k, False: 124k]
  ------------------
  321|  15.3k|        string_list->allocated_count = 32;
  322|  15.3k|        string_list->list =
  323|  15.3k|            loader_instance_heap_calloc(inst, sizeof(char *) * string_list->allocated_count, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
  324|  15.3k|        if (NULL == string_list->list) {
  ------------------
  |  Branch (324:13): [True: 0, False: 15.3k]
  ------------------
  325|      0|            return VK_ERROR_OUT_OF_HOST_MEMORY;
  326|      0|        }
  327|   124k|    } else if (string_list->count + 1 > string_list->allocated_count) {
  ------------------
  |  Branch (327:16): [True: 145, False: 124k]
  ------------------
  328|    145|        uint32_t new_allocated_count = string_list->allocated_count * 2;
  329|    145|        void *new_ptr = loader_instance_heap_realloc(inst, string_list->list, sizeof(char *) * string_list->allocated_count,
  330|    145|                                                     sizeof(char *) * new_allocated_count, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
  331|    145|        if (NULL == new_ptr) {
  ------------------
  |  Branch (331:13): [True: 0, False: 145]
  ------------------
  332|      0|            return VK_ERROR_OUT_OF_HOST_MEMORY;
  333|      0|        }
  334|    145|        string_list->list = new_ptr;
  335|    145|        string_list->allocated_count *= 2;
  336|    145|    }
  337|   139k|    return VK_SUCCESS;
  338|   139k|}
append_str_to_string_list:
  340|   139k|VkResult append_str_to_string_list(const struct loader_instance *inst, struct loader_string_list *string_list, char *str) {
  341|   139k|    assert(string_list && str);
  342|   139k|    VkResult res = increase_str_capacity_by_at_least_one(inst, string_list);
  343|   139k|    if (res == VK_ERROR_OUT_OF_HOST_MEMORY) {
  ------------------
  |  Branch (343:9): [True: 0, False: 139k]
  ------------------
  344|      0|        loader_instance_heap_free(inst, str);  // Must clean up in case of failure
  345|      0|        return res;
  346|      0|    }
  347|   139k|    string_list->list[string_list->count++] = str;
  348|   139k|    return VK_SUCCESS;
  349|   139k|}
append_str_to_string_list_if_unique:
  352|  91.2k|                                             char *str) {
  353|  91.2k|    if (is_string_in_string_list(string_list, str)) {
  ------------------
  |  Branch (353:9): [True: 11.1k, False: 80.0k]
  ------------------
  354|       |        // Since this string is a duplicate and this function takes ownership, we need to free it.
  355|  11.1k|        loader_instance_heap_free(inst, str);
  356|  11.1k|        return VK_SUCCESS;
  357|  11.1k|    }
  358|  80.0k|    return append_str_to_string_list(inst, string_list, str);
  359|  91.2k|}
copy_str_to_string_list:
  376|  9.24k|                                 size_t str_len) {
  377|  9.24k|    assert(string_list && str);
  378|  9.24k|    char *new_str = loader_instance_heap_calloc(inst, str_len + 1, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
  379|  9.24k|    if (NULL == new_str) {
  ------------------
  |  Branch (379:9): [True: 0, False: 9.24k]
  ------------------
  380|      0|        return VK_ERROR_OUT_OF_HOST_MEMORY;
  381|      0|    }
  382|  9.24k|    loader_strncpy(new_str, str_len + 1, str, str_len);
  383|  9.24k|    new_str[str_len] = '\0';
  384|  9.24k|    return append_str_to_string_list(inst, string_list, new_str);
  385|  9.24k|}
free_string_list:
  407|   194k|void free_string_list(const struct loader_instance *inst, struct loader_string_list *string_list) {
  408|   194k|    assert(string_list);
  409|   194k|    if (string_list->list) {
  ------------------
  |  Branch (409:9): [True: 21.6k, False: 173k]
  ------------------
  410|   161k|        for (uint32_t i = 0; i < string_list->count; i++) {
  ------------------
  |  Branch (410:30): [True: 139k, False: 21.6k]
  ------------------
  411|   139k|            loader_instance_heap_free(inst, string_list->list[i]);
  412|       |            string_list->list[i] = NULL;
  413|   139k|        }
  414|  21.6k|        loader_instance_heap_free(inst, string_list->list);
  415|  21.6k|    }
  416|   194k|    memset(string_list, 0, sizeof(struct loader_string_list));
  417|   194k|}
loader_parse_version_string:
  694|  21.6k|uint32_t loader_parse_version_string(char *vers_str) {
  695|  21.6k|    uint32_t variant = 0, major = 0, minor = 0, patch = 0;
  696|  21.6k|    char *vers_tok;
  697|  21.6k|    char *context = NULL;
  698|  21.6k|    if (!vers_str) {
  ------------------
  |  Branch (698:9): [True: 0, False: 21.6k]
  ------------------
  699|      0|        return 0;
  700|      0|    }
  701|       |
  702|  21.6k|    vers_tok = thread_safe_strtok(vers_str, ".\"\n\r", &context);
  703|  21.6k|    if (NULL != vers_tok) {
  ------------------
  |  Branch (703:9): [True: 14.4k, False: 7.20k]
  ------------------
  704|  14.4k|        major = (uint16_t)atoi(vers_tok);
  705|  14.4k|        vers_tok = thread_safe_strtok(NULL, ".\"\n\r", &context);
  706|  14.4k|        if (NULL != vers_tok) {
  ------------------
  |  Branch (706:13): [True: 2.21k, False: 12.1k]
  ------------------
  707|  2.21k|            minor = (uint16_t)atoi(vers_tok);
  708|  2.21k|            vers_tok = thread_safe_strtok(NULL, ".\"\n\r", &context);
  709|  2.21k|            if (NULL != vers_tok) {
  ------------------
  |  Branch (709:17): [True: 902, False: 1.31k]
  ------------------
  710|    902|                patch = (uint16_t)atoi(vers_tok);
  711|    902|                vers_tok = thread_safe_strtok(NULL, ".\"\n\r", &context);
  712|       |                // check that we are using a 4 part version string
  713|    902|                if (NULL != vers_tok) {
  ------------------
  |  Branch (713:21): [True: 76, False: 826]
  ------------------
  714|       |                    // if we are, move the values over into the correct place
  715|     76|                    variant = major;
  716|     76|                    major = minor;
  717|     76|                    minor = patch;
  718|     76|                    patch = (uint16_t)atoi(vers_tok);
  719|     76|                }
  720|    902|            }
  721|  2.21k|        }
  722|  14.4k|    }
  723|       |
  724|       |    return VK_MAKE_API_VERSION(variant, major, minor, patch);
  725|  21.6k|}
compare_vk_extension_properties:
  727|   579k|bool compare_vk_extension_properties(const VkExtensionProperties *op1, const VkExtensionProperties *op2) {
  728|   579k|    return strcmp(op1->extensionName, op2->extensionName) == 0 ? true : false;
  ------------------
  |  Branch (728:12): [True: 2.22k, False: 577k]
  ------------------
  729|   579k|}
has_vk_extension_property:
  741|  10.8k|bool has_vk_extension_property(const VkExtensionProperties *vk_ext_prop, const struct loader_extension_list *ext_list) {
  742|   380k|    for (uint32_t i = 0; i < ext_list->count; i++) {
  ------------------
  |  Branch (742:26): [True: 370k, False: 9.97k]
  ------------------
  743|   370k|        if (compare_vk_extension_properties(&ext_list->list[i], vk_ext_prop)) return true;
  ------------------
  |  Branch (743:13): [True: 879, False: 370k]
  ------------------
  744|   370k|    }
  745|  9.97k|    return false;
  746|  10.8k|}
has_vk_dev_ext_property:
  749|  13.0k|bool has_vk_dev_ext_property(const VkExtensionProperties *ext_prop, const struct loader_device_extension_list *ext_list) {
  750|   220k|    for (uint32_t i = 0; i < ext_list->count; i++) {
  ------------------
  |  Branch (750:26): [True: 208k, False: 11.7k]
  ------------------
  751|   208k|        if (compare_vk_extension_properties(&ext_list->list[i].props, ext_prop)) return true;
  ------------------
  |  Branch (751:13): [True: 1.34k, False: 206k]
  ------------------
  752|   208k|    }
  753|  11.7k|    return false;
  754|  13.0k|}
loader_append_layer_property:
  757|  18.5k|                                      struct loader_layer_properties *layer_property) {
  758|  18.5k|    VkResult res = VK_SUCCESS;
  759|  18.5k|    if (layer_list->capacity == 0) {
  ------------------
  |  Branch (759:9): [True: 2.87k, False: 15.6k]
  ------------------
  760|  2.87k|        res = loader_init_generic_list(inst, (struct loader_generic_list *)layer_list, sizeof(struct loader_layer_properties));
  761|  2.87k|        if (VK_SUCCESS != res) {
  ------------------
  |  Branch (761:13): [True: 0, False: 2.87k]
  ------------------
  762|      0|            goto out;
  763|      0|        }
  764|  2.87k|    }
  765|       |
  766|       |    // Ensure enough room to add an entry
  767|  18.5k|    if ((layer_list->count + 1) * sizeof(struct loader_layer_properties) > layer_list->capacity) {
  ------------------
  |  Branch (767:9): [True: 148, False: 18.3k]
  ------------------
  768|    148|        void *new_ptr = loader_instance_heap_realloc(inst, layer_list->list, layer_list->capacity, layer_list->capacity * 2,
  769|    148|                                                     VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
  770|    148|        if (NULL == new_ptr) {
  ------------------
  |  Branch (770:13): [True: 0, False: 148]
  ------------------
  771|      0|            loader_log(inst, VULKAN_LOADER_ERROR_BIT, 0, "loader_append_layer_property: realloc failed for layer list");
  772|      0|            res = VK_ERROR_OUT_OF_HOST_MEMORY;
  773|      0|            goto out;
  774|      0|        }
  775|    148|        layer_list->list = new_ptr;
  776|    148|        layer_list->capacity *= 2;
  777|    148|    }
  778|  18.5k|    memcpy(&layer_list->list[layer_list->count], layer_property, sizeof(struct loader_layer_properties));
  779|  18.5k|    layer_list->count++;
  780|  18.5k|    memset(layer_property, 0, sizeof(struct loader_layer_properties));
  781|  18.5k|out:
  782|  18.5k|    if (res != VK_SUCCESS) {
  ------------------
  |  Branch (782:9): [True: 0, False: 18.5k]
  ------------------
  783|      0|        loader_free_layer_properties(inst, layer_property);
  784|      0|    }
  785|  18.5k|    return res;
  786|  18.5k|}
loader_find_layer_property:
  789|  15.1k|struct loader_layer_properties *loader_find_layer_property(const char *name, const struct loader_layer_list *layer_list) {
  790|   119k|    for (uint32_t i = 0; i < layer_list->count; i++) {
  ------------------
  |  Branch (790:26): [True: 111k, False: 7.69k]
  ------------------
  791|   111k|        const VkLayerProperties *item = &layer_list->list[i].info;
  792|   111k|        if (strcmp(name, item->layerName) == 0) return &layer_list->list[i];
  ------------------
  |  Branch (792:13): [True: 7.50k, False: 104k]
  ------------------
  793|   111k|    }
  794|  7.69k|    return NULL;
  795|  15.1k|}
loader_find_layer_name_in_blacklist:
  818|  7.47k|bool loader_find_layer_name_in_blacklist(const char *layer_name, struct loader_layer_properties *meta_layer_props) {
  819|  7.47k|    for (uint32_t black_layer = 0; black_layer < meta_layer_props->blacklist_layer_names.count; ++black_layer) {
  ------------------
  |  Branch (819:36): [True: 0, False: 7.47k]
  ------------------
  820|      0|        if (!strcmp(meta_layer_props->blacklist_layer_names.list[black_layer], layer_name)) {
  ------------------
  |  Branch (820:13): [True: 0, False: 0]
  ------------------
  821|      0|            return true;
  822|      0|        }
  823|      0|    }
  824|  7.47k|    return false;
  825|  7.47k|}
loader_delete_layer_list_and_properties:
  829|  21.0k|                                                                  struct loader_layer_list *layer_list) {
  830|  21.0k|    uint32_t i;
  831|  21.0k|    if (!layer_list) return;
  ------------------
  |  Branch (831:9): [True: 0, False: 21.0k]
  ------------------
  832|       |
  833|  33.5k|    for (i = 0; i < layer_list->count; i++) {
  ------------------
  |  Branch (833:17): [True: 12.5k, False: 21.0k]
  ------------------
  834|  12.5k|        if (layer_list->list[i].lib_handle) {
  ------------------
  |  Branch (834:13): [True: 0, False: 12.5k]
  ------------------
  835|      0|            loader_platform_close_library(layer_list->list[i].lib_handle);
  836|      0|            loader_log(inst, VULKAN_LOADER_DEBUG_BIT | VULKAN_LOADER_LAYER_BIT, 0, "Unloading layer library %s",
  837|      0|                       layer_list->list[i].lib_name);
  838|      0|            layer_list->list[i].lib_handle = NULL;
  839|      0|        }
  840|  12.5k|        loader_free_layer_properties(inst, &(layer_list->list[i]));
  841|  12.5k|    }
  842|  21.0k|    layer_list->count = 0;
  843|       |
  844|  21.0k|    if (layer_list->capacity > 0) {
  ------------------
  |  Branch (844:9): [True: 3.45k, False: 17.5k]
  ------------------
  845|  3.45k|        layer_list->capacity = 0;
  846|  3.45k|        loader_instance_heap_free(inst, layer_list->list);
  847|  3.45k|    }
  848|  21.0k|    memset(layer_list, 0, sizeof(struct loader_layer_list));
  849|  21.0k|}
loader_remove_layer_in_list:
  852|  6.03k|                                 uint32_t layer_to_remove) {
  853|  6.03k|    if (layer_list == NULL || layer_to_remove >= layer_list->count) {
  ------------------
  |  Branch (853:9): [True: 0, False: 6.03k]
  |  Branch (853:31): [True: 0, False: 6.03k]
  ------------------
  854|      0|        return;
  855|      0|    }
  856|  6.03k|    loader_free_layer_properties(inst, &(layer_list->list[layer_to_remove]));
  857|       |
  858|       |    // Remove the current invalid meta-layer from the layer list.  Use memmove since we are
  859|       |    // overlapping the source and destination addresses.
  860|  6.03k|    if (layer_to_remove + 1 <= layer_list->count) {
  ------------------
  |  Branch (860:9): [True: 6.03k, False: 0]
  ------------------
  861|  6.03k|        memmove(&layer_list->list[layer_to_remove], &layer_list->list[layer_to_remove + 1],
  862|  6.03k|                sizeof(struct loader_layer_properties) * (layer_list->count - 1 - layer_to_remove));
  863|  6.03k|    }
  864|       |    // Decrement the count (because we now have one less) and decrement the loop index since we need to
  865|       |    // re-check this index.
  866|  6.03k|    layer_list->count--;
  867|  6.03k|}
loader_remove_layers_in_blacklist:
  871|    395|void loader_remove_layers_in_blacklist(const struct loader_instance *inst, struct loader_layer_list *layer_list) {
  872|    395|    struct loader_layer_properties *override_prop = loader_find_layer_property(VK_OVERRIDE_LAYER_NAME, layer_list);
  ------------------
  |  |  138|    395|#define VK_OVERRIDE_LAYER_NAME "VK_LAYER_LUNARG_override"
  ------------------
  873|    395|    if (NULL == override_prop) {
  ------------------
  |  Branch (873:9): [True: 0, False: 395]
  ------------------
  874|      0|        return;
  875|      0|    }
  876|       |
  877|  8.74k|    for (int32_t j = 0; j < (int32_t)(layer_list->count); j++) {
  ------------------
  |  Branch (877:25): [True: 8.34k, False: 395]
  ------------------
  878|  8.34k|        struct loader_layer_properties cur_layer_prop = layer_list->list[j];
  879|  8.34k|        const char *cur_layer_name = &cur_layer_prop.info.layerName[0];
  880|       |
  881|       |        // Skip the override layer itself.
  882|  8.34k|        if (!strcmp(VK_OVERRIDE_LAYER_NAME, cur_layer_name)) {
  ------------------
  |  |  138|  8.34k|#define VK_OVERRIDE_LAYER_NAME "VK_LAYER_LUNARG_override"
  ------------------
  |  Branch (882:13): [True: 873, False: 7.47k]
  ------------------
  883|    873|            continue;
  884|    873|        }
  885|       |
  886|       |        // If found in the override layer's blacklist, remove it
  887|  7.47k|        if (loader_find_layer_name_in_blacklist(cur_layer_name, override_prop)) {
  ------------------
  |  Branch (887:13): [True: 0, False: 7.47k]
  ------------------
  888|      0|            loader_log(inst, VULKAN_LOADER_DEBUG_BIT, 0,
  889|      0|                       "loader_remove_layers_in_blacklist: Override layer is active and layer %s is in the blacklist inside of it. "
  890|      0|                       "Removing that layer from current layer list.",
  891|      0|                       cur_layer_name);
  892|      0|            loader_remove_layer_in_list(inst, layer_list, j);
  893|      0|            j--;
  894|       |
  895|       |            // Re-do the query for the override layer
  896|      0|            override_prop = loader_find_layer_property(VK_OVERRIDE_LAYER_NAME, layer_list);
  ------------------
  |  |  138|      0|#define VK_OVERRIDE_LAYER_NAME "VK_LAYER_LUNARG_override"
  ------------------
  897|      0|        }
  898|  7.47k|    }
  899|    395|}
loader_init_generic_list:
 1054|  5.28k|VkResult loader_init_generic_list(const struct loader_instance *inst, struct loader_generic_list *list_info, size_t element_size) {
 1055|  5.28k|    size_t capacity = 32 * element_size;
 1056|  5.28k|    list_info->count = 0;
 1057|  5.28k|    list_info->capacity = 0;
 1058|  5.28k|    list_info->list = loader_instance_heap_calloc(inst, capacity, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
 1059|  5.28k|    if (list_info->list == NULL) {
  ------------------
  |  Branch (1059:9): [True: 0, False: 5.28k]
  ------------------
 1060|      0|        loader_log(inst, VULKAN_LOADER_ERROR_BIT, 0, "loader_init_generic_list: Failed to allocate space for generic list");
 1061|      0|        return VK_ERROR_OUT_OF_HOST_MEMORY;
 1062|      0|    }
 1063|  5.28k|    list_info->capacity = capacity;
 1064|  5.28k|    return VK_SUCCESS;
 1065|  5.28k|}
loader_destroy_generic_list:
 1083|  98.2k|void loader_destroy_generic_list(const struct loader_instance *inst, struct loader_generic_list *list) {
 1084|  98.2k|    loader_instance_heap_free(inst, list->list);
 1085|  98.2k|    memset(list, 0, sizeof(struct loader_generic_list));
 1086|  98.2k|}
loader_add_to_ext_list:
 1139|  7.25k|                                uint32_t prop_list_count, const VkExtensionProperties *props) {
 1140|  7.25k|    if (ext_list->list == NULL || ext_list->capacity == 0) {
  ------------------
  |  Branch (1140:9): [True: 963, False: 6.29k]
  |  Branch (1140:35): [True: 0, False: 6.29k]
  ------------------
 1141|    963|        VkResult res = loader_init_generic_list(inst, (struct loader_generic_list *)ext_list, sizeof(VkExtensionProperties));
 1142|    963|        if (VK_SUCCESS != res) {
  ------------------
  |  Branch (1142:13): [True: 0, False: 963]
  ------------------
 1143|      0|            return res;
 1144|      0|        }
 1145|    963|    }
 1146|       |
 1147|  14.5k|    for (uint32_t i = 0; i < prop_list_count; i++) {
  ------------------
  |  Branch (1147:26): [True: 7.25k, False: 7.25k]
  ------------------
 1148|  7.25k|        const VkExtensionProperties *cur_ext = &props[i];
 1149|       |
 1150|       |        // look for duplicates
 1151|  7.25k|        if (has_vk_extension_property(cur_ext, ext_list)) {
  ------------------
  |  Branch (1151:13): [True: 746, False: 6.51k]
  ------------------
 1152|    746|            continue;
 1153|    746|        }
 1154|       |
 1155|       |        // add to list at end
 1156|       |        // check for enough capacity
 1157|  6.51k|        if (ext_list->count * sizeof(VkExtensionProperties) >= ext_list->capacity) {
  ------------------
  |  Branch (1157:13): [True: 99, False: 6.41k]
  ------------------
 1158|     99|            void *new_ptr = loader_instance_heap_realloc(inst, ext_list->list, ext_list->capacity, ext_list->capacity * 2,
 1159|     99|                                                         VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
 1160|     99|            if (new_ptr == NULL) {
  ------------------
  |  Branch (1160:17): [True: 0, False: 99]
  ------------------
 1161|      0|                loader_log(inst, VULKAN_LOADER_ERROR_BIT, 0,
 1162|      0|                           "loader_add_to_ext_list: Failed to reallocate space for extension list");
 1163|      0|                return VK_ERROR_OUT_OF_HOST_MEMORY;
 1164|      0|            }
 1165|     99|            ext_list->list = new_ptr;
 1166|       |
 1167|       |            // double capacity
 1168|     99|            ext_list->capacity *= 2;
 1169|     99|        }
 1170|       |
 1171|  6.51k|        memcpy(&ext_list->list[ext_list->count], cur_ext, sizeof(VkExtensionProperties));
 1172|  6.51k|        ext_list->count++;
 1173|  6.51k|    }
 1174|  7.25k|    return VK_SUCCESS;
 1175|  7.25k|}
loader_add_to_dev_ext_list:
 1182|  7.82k|                                    const VkExtensionProperties *props, struct loader_string_list *entrys) {
 1183|  7.82k|    VkResult res = VK_SUCCESS;
 1184|  7.82k|    bool should_free_entrys = true;
 1185|  7.82k|    if (ext_list->list == NULL || ext_list->capacity == 0) {
  ------------------
  |  Branch (1185:9): [True: 859, False: 6.96k]
  |  Branch (1185:35): [True: 0, False: 6.96k]
  ------------------
 1186|    859|        res = loader_init_generic_list(inst, (struct loader_generic_list *)ext_list, sizeof(struct loader_dev_ext_props));
 1187|    859|        if (VK_SUCCESS != res) {
  ------------------
  |  Branch (1187:13): [True: 0, False: 859]
  ------------------
 1188|      0|            goto out;
 1189|      0|        }
 1190|    859|    }
 1191|       |
 1192|       |    // look for duplicates
 1193|  7.82k|    if (has_vk_dev_ext_property(props, ext_list)) {
  ------------------
  |  Branch (1193:9): [True: 540, False: 7.28k]
  ------------------
 1194|    540|        goto out;
 1195|    540|    }
 1196|       |
 1197|  7.28k|    uint32_t idx = ext_list->count;
 1198|       |    // add to list at end
 1199|       |    // check for enough capacity
 1200|  7.28k|    if (idx * sizeof(struct loader_dev_ext_props) >= ext_list->capacity) {
  ------------------
  |  Branch (1200:9): [True: 73, False: 7.21k]
  ------------------
 1201|     73|        void *new_ptr = loader_instance_heap_realloc(inst, ext_list->list, ext_list->capacity, ext_list->capacity * 2,
 1202|     73|                                                     VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
 1203|       |
 1204|     73|        if (NULL == new_ptr) {
  ------------------
  |  Branch (1204:13): [True: 0, False: 73]
  ------------------
 1205|      0|            loader_log(inst, VULKAN_LOADER_ERROR_BIT, 0,
 1206|      0|                       "loader_add_to_dev_ext_list: Failed to reallocate space for device extension list");
 1207|      0|            res = VK_ERROR_OUT_OF_HOST_MEMORY;
 1208|      0|            goto out;
 1209|      0|        }
 1210|     73|        ext_list->list = new_ptr;
 1211|       |
 1212|       |        // double capacity
 1213|     73|        ext_list->capacity *= 2;
 1214|     73|    }
 1215|       |
 1216|  7.28k|    memcpy(&ext_list->list[idx].props, props, sizeof(*props));
 1217|  7.28k|    if (entrys) {
  ------------------
  |  Branch (1217:9): [True: 71, False: 7.21k]
  ------------------
 1218|     71|        ext_list->list[idx].entrypoints = *entrys;
 1219|     71|        should_free_entrys = false;
 1220|  7.21k|    } else {
 1221|  7.21k|        memset(&ext_list->list[idx].entrypoints, 0, sizeof(ext_list->list[idx].entrypoints));
 1222|  7.21k|    }
 1223|  7.28k|    ext_list->count++;
 1224|  7.82k|out:
 1225|  7.82k|    if (NULL != entrys && should_free_entrys) {
  ------------------
  |  Branch (1225:9): [True: 248, False: 7.57k]
  |  Branch (1225:27): [True: 177, False: 71]
  ------------------
 1226|    177|        free_string_list(inst, entrys);
 1227|    177|    }
 1228|  7.82k|    return res;
 1229|  7.28k|}
loader_destroy_pointer_layer_list:
 1253|  14.0k|void loader_destroy_pointer_layer_list(const struct loader_instance *inst, struct loader_pointer_layer_list *layer_list) {
 1254|  14.0k|    loader_instance_heap_free(inst, layer_list->list);
 1255|  14.0k|    memset(layer_list, 0, sizeof(struct loader_pointer_layer_list));
 1256|  14.0k|}
loader_layer_is_available:
 1287|  11.2k|                               const struct loader_layer_properties *prop) {
 1288|  11.2k|    bool available = true;
 1289|  11.2k|    bool is_implicit = (0 == (prop->type_flags & VK_LAYER_TYPE_FLAG_EXPLICIT_LAYER));
 1290|  11.2k|    bool disabled_by_type =
 1291|  11.2k|        (is_implicit) ? (filters->disable_filter.disable_all_implicit) : (filters->disable_filter.disable_all_explicit);
  ------------------
  |  Branch (1291:9): [True: 5.16k, False: 6.12k]
  ------------------
 1292|  11.2k|    if ((filters->disable_filter.disable_all || disabled_by_type ||
  ------------------
  |  Branch (1292:10): [True: 0, False: 11.2k]
  |  Branch (1292:49): [True: 0, False: 11.2k]
  ------------------
 1293|  11.2k|         check_name_matches_filter_environment_var(prop->info.layerName, &filters->disable_filter.additional_filters)) &&
  ------------------
  |  Branch (1293:10): [True: 0, False: 11.2k]
  ------------------
 1294|      0|        !check_name_matches_filter_environment_var(prop->info.layerName, &filters->allow_filter)) {
  ------------------
  |  Branch (1294:9): [True: 0, False: 0]
  ------------------
 1295|      0|        available = false;
 1296|      0|    }
 1297|  11.2k|    if (check_name_matches_filter_environment_var(prop->info.layerName, &filters->enable_filter)) {
  ------------------
  |  Branch (1297:9): [True: 71, False: 11.2k]
  ------------------
 1298|     71|        available = true;
 1299|  11.2k|    } else if (!available) {
  ------------------
  |  Branch (1299:16): [True: 0, False: 11.2k]
  ------------------
 1300|      0|        loader_log(inst, VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_LAYER_BIT, 0,
 1301|      0|                   "Layer \"%s\" forced disabled because name matches filter of env var \'%s\'.", prop->info.layerName,
 1302|      0|                   VK_LAYERS_DISABLE_ENV_VAR);
  ------------------
  |  |  120|      0|#define VK_LAYERS_DISABLE_ENV_VAR "VK_LOADER_LAYERS_DISABLE"
  ------------------
 1303|      0|    }
 1304|       |
 1305|  11.2k|    return available;
 1306|  11.2k|}
loader_implicit_layer_is_enabled:
 1355|  1.38k|                                      const struct loader_layer_properties *prop) {
 1356|  1.38k|    bool enable = false;
 1357|  1.38k|    bool forced_disabled = false;
 1358|  1.38k|    bool forced_enabled = false;
 1359|       |
 1360|  1.38k|    if ((filters->disable_filter.disable_all || filters->disable_filter.disable_all_implicit ||
  ------------------
  |  Branch (1360:10): [True: 0, False: 1.38k]
  |  Branch (1360:49): [True: 0, False: 1.38k]
  ------------------
 1361|  1.38k|         check_name_matches_filter_environment_var(prop->info.layerName, &filters->disable_filter.additional_filters)) &&
  ------------------
  |  Branch (1361:10): [True: 0, False: 1.38k]
  ------------------
 1362|      0|        !check_name_matches_filter_environment_var(prop->info.layerName, &filters->allow_filter)) {
  ------------------
  |  Branch (1362:9): [True: 0, False: 0]
  ------------------
 1363|      0|        forced_disabled = true;
 1364|      0|    }
 1365|  1.38k|    if (check_name_matches_filter_environment_var(prop->info.layerName, &filters->enable_filter)) {
  ------------------
  |  Branch (1365:9): [True: 0, False: 1.38k]
  ------------------
 1366|      0|        forced_enabled = true;
 1367|      0|    }
 1368|       |
 1369|       |    // If no enable_environment variable is specified, this implicit layer is always be enabled by default.
 1370|  1.38k|    if (NULL == prop->enable_env_var.name) {
  ------------------
  |  Branch (1370:9): [True: 1.27k, False: 106]
  ------------------
 1371|  1.27k|        enable = true;
 1372|  1.27k|    } else {
 1373|    106|        char *env_value = loader_getenv(prop->enable_env_var.name, inst);
 1374|    106|        if (env_value && !strcmp(prop->enable_env_var.value, env_value)) {
  ------------------
  |  Branch (1374:13): [True: 101, False: 5]
  |  Branch (1374:26): [True: 0, False: 101]
  ------------------
 1375|      0|            enable = true;
 1376|      0|        }
 1377|       |
 1378|       |        // Otherwise, only enable this layer if the enable environment variable is defined
 1379|    106|        loader_free_getenv(env_value, inst);
 1380|    106|    }
 1381|       |
 1382|  1.38k|    if (forced_enabled) {
  ------------------
  |  Branch (1382:9): [True: 0, False: 1.38k]
  ------------------
 1383|       |        // Only report a message that we've forced on a layer if it wouldn't have been enabled
 1384|       |        // normally.
 1385|      0|        if (!enable) {
  ------------------
  |  Branch (1385:13): [True: 0, False: 0]
  ------------------
 1386|      0|            enable = true;
 1387|      0|            loader_log(inst, VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_LAYER_BIT, 0,
 1388|      0|                       "Implicit layer \"%s\" forced enabled due to env var \'%s\'.", prop->info.layerName,
 1389|      0|                       VK_LAYERS_ENABLE_ENV_VAR);
  ------------------
  |  |  119|      0|#define VK_LAYERS_ENABLE_ENV_VAR "VK_LOADER_LAYERS_ENABLE"
  ------------------
 1390|      0|        }
 1391|  1.38k|    } else if (enable && forced_disabled) {
  ------------------
  |  Branch (1391:16): [True: 1.27k, False: 106]
  |  Branch (1391:26): [True: 0, False: 1.27k]
  ------------------
 1392|      0|        enable = false;
 1393|       |        // Report a message that we've forced off a layer if it would have been enabled normally.
 1394|      0|        loader_log(inst, VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_LAYER_BIT, 0,
 1395|      0|                   "Implicit layer \"%s\" forced disabled because name matches filter of env var \'%s\'.", prop->info.layerName,
 1396|      0|                   VK_LAYERS_DISABLE_ENV_VAR);
  ------------------
  |  |  120|      0|#define VK_LAYERS_DISABLE_ENV_VAR "VK_LOADER_LAYERS_DISABLE"
  ------------------
 1397|      0|        return enable;
 1398|      0|    }
 1399|       |
 1400|       |    // The disable_environment has priority over everything else.  If it is defined, the layer is always
 1401|       |    // disabled.
 1402|  1.38k|    if (NULL != prop->disable_env_var.name) {
  ------------------
  |  Branch (1402:9): [True: 915, False: 469]
  ------------------
 1403|    915|        char *env_value = loader_getenv(prop->disable_env_var.name, inst);
 1404|    915|        if (NULL != env_value) {
  ------------------
  |  Branch (1404:13): [True: 5, False: 910]
  ------------------
 1405|      5|            enable = false;
 1406|      5|        }
 1407|    915|        loader_free_getenv(env_value, inst);
 1408|    915|    } else if ((prop->type_flags & VK_LAYER_TYPE_FLAG_EXPLICIT_LAYER) == 0) {
  ------------------
  |  Branch (1408:16): [True: 0, False: 469]
  ------------------
 1409|      0|        loader_log(inst, VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_LAYER_BIT, 0,
 1410|      0|                   "Implicit layer \"%s\" missing disabled environment variable!", prop->info.layerName);
 1411|      0|    }
 1412|       |
 1413|       |    // Enable this layer if it is included in the override layer
 1414|  1.38k|    if (inst != NULL && inst->override_layer_present) {
  ------------------
  |  Branch (1414:9): [True: 1.38k, False: 0]
  |  Branch (1414:25): [True: 0, False: 1.38k]
  ------------------
 1415|      0|        struct loader_layer_properties *override = NULL;
 1416|      0|        for (uint32_t i = 0; i < inst->instance_layer_list.count; ++i) {
  ------------------
  |  Branch (1416:30): [True: 0, False: 0]
  ------------------
 1417|      0|            if (strcmp(inst->instance_layer_list.list[i].info.layerName, VK_OVERRIDE_LAYER_NAME) == 0) {
  ------------------
  |  |  138|      0|#define VK_OVERRIDE_LAYER_NAME "VK_LAYER_LUNARG_override"
  ------------------
  |  Branch (1417:17): [True: 0, False: 0]
  ------------------
 1418|      0|                override = &inst->instance_layer_list.list[i];
 1419|      0|                break;
 1420|      0|            }
 1421|      0|        }
 1422|      0|        if (override != NULL) {
  ------------------
  |  Branch (1422:13): [True: 0, False: 0]
  ------------------
 1423|      0|            for (uint32_t i = 0; i < override->component_layer_names.count; ++i) {
  ------------------
  |  Branch (1423:34): [True: 0, False: 0]
  ------------------
 1424|      0|                if (strcmp(override->component_layer_names.list[i], prop->info.layerName) == 0) {
  ------------------
  |  Branch (1424:21): [True: 0, False: 0]
  ------------------
 1425|      0|                    enable = true;
 1426|      0|                    break;
 1427|      0|                }
 1428|      0|            }
 1429|      0|        }
 1430|      0|    }
 1431|       |
 1432|  1.38k|    return enable;
 1433|  1.38k|}
loader_clear_scanned_icd_list:
 1866|  7.00k|void loader_clear_scanned_icd_list(const struct loader_instance *inst, struct loader_icd_tramp_list *icd_tramp_list) {
 1867|  7.00k|    if (0 != icd_tramp_list->capacity && icd_tramp_list->scanned_list) {
  ------------------
  |  Branch (1867:9): [True: 4, False: 7.00k]
  |  Branch (1867:42): [True: 4, False: 0]
  ------------------
 1868|      4|        for (uint32_t i = 0; i < icd_tramp_list->count; i++) {
  ------------------
  |  Branch (1868:30): [True: 0, False: 4]
  ------------------
 1869|      0|            if (icd_tramp_list->scanned_list[i].handle) {
  ------------------
  |  Branch (1869:17): [True: 0, False: 0]
  ------------------
 1870|      0|                loader_platform_close_library(icd_tramp_list->scanned_list[i].handle);
 1871|       |                icd_tramp_list->scanned_list[i].handle = NULL;
 1872|      0|            }
 1873|      0|            loader_instance_heap_free(inst, icd_tramp_list->scanned_list[i].lib_name);
 1874|      0|        }
 1875|      4|        loader_instance_heap_free(inst, icd_tramp_list->scanned_list);
 1876|      4|    }
 1877|  7.00k|    memset(icd_tramp_list, 0, sizeof(struct loader_icd_tramp_list));
 1878|  7.00k|}
loader_init_scanned_icd_list:
 1880|      4|VkResult loader_init_scanned_icd_list(const struct loader_instance *inst, struct loader_icd_tramp_list *icd_tramp_list) {
 1881|      4|    VkResult res = VK_SUCCESS;
 1882|      4|    loader_clear_scanned_icd_list(inst, icd_tramp_list);
 1883|      4|    icd_tramp_list->capacity = 8 * sizeof(struct loader_scanned_icd);
 1884|      4|    icd_tramp_list->scanned_list = loader_instance_heap_alloc(inst, icd_tramp_list->capacity, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
 1885|      4|    if (NULL == icd_tramp_list->scanned_list) {
  ------------------
  |  Branch (1885:9): [True: 0, False: 4]
  ------------------
 1886|      0|        loader_log(inst, VULKAN_LOADER_ERROR_BIT, 0,
 1887|      0|                   "loader_init_scanned_icd_list: Realloc failed for layer list when attempting to add new layer");
 1888|      0|        res = VK_ERROR_OUT_OF_HOST_MEMORY;
 1889|      0|    }
 1890|      4|    return res;
 1891|      4|}
loader_scan_for_direct_drivers:
 2029|      4|                                        struct loader_icd_tramp_list *icd_tramp_list, bool *direct_driver_loading_exclusive_mode) {
 2030|      4|    if (NULL == pCreateInfo) {
  ------------------
  |  Branch (2030:9): [True: 0, False: 4]
  ------------------
 2031|       |        // Don't do this logic unless we are being called from vkCreateInstance, when pCreateInfo will be non-null
 2032|      0|        return VK_SUCCESS;
 2033|      0|    }
 2034|      4|    bool direct_driver_loading_enabled = false;
 2035|       |    // Try to if VK_LUNARG_direct_driver_loading is enabled and if we are using it exclusively
 2036|       |    // Skip this step if inst is NULL, aka when this function is being called before instance creation
 2037|      4|    if (inst != NULL && pCreateInfo->ppEnabledExtensionNames && pCreateInfo->enabledExtensionCount > 0) {
  ------------------
  |  Branch (2037:9): [True: 4, False: 0]
  |  Branch (2037:25): [True: 0, False: 4]
  |  Branch (2037:65): [True: 0, False: 0]
  ------------------
 2038|       |        // Look through the enabled extension list, make sure VK_LUNARG_direct_driver_loading is present
 2039|      0|        for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
  ------------------
  |  Branch (2039:30): [True: 0, False: 0]
  ------------------
 2040|      0|            if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_LUNARG_DIRECT_DRIVER_LOADING_EXTENSION_NAME) == 0) {
  ------------------
  |  Branch (2040:17): [True: 0, False: 0]
  ------------------
 2041|      0|                direct_driver_loading_enabled = true;
 2042|      0|                break;
 2043|      0|            }
 2044|      0|        }
 2045|      0|    }
 2046|      4|    const VkDirectDriverLoadingListLUNARG *ddl_list = NULL;
 2047|       |    // Find the VkDirectDriverLoadingListLUNARG struct in the pNext chain of vkInstanceCreateInfo
 2048|      4|    const void *pNext = pCreateInfo->pNext;
 2049|      4|    while (pNext) {
  ------------------
  |  Branch (2049:12): [True: 0, False: 4]
  ------------------
 2050|      0|        VkBaseInStructure out_structure = {0};
 2051|      0|        memcpy(&out_structure, pNext, sizeof(VkBaseInStructure));
 2052|      0|        if (out_structure.sType == VK_STRUCTURE_TYPE_DIRECT_DRIVER_LOADING_LIST_LUNARG) {
  ------------------
  |  Branch (2052:13): [True: 0, False: 0]
  ------------------
 2053|      0|            ddl_list = (VkDirectDriverLoadingListLUNARG *)pNext;
 2054|      0|            break;
 2055|      0|        }
 2056|      0|        pNext = out_structure.pNext;
 2057|      0|    }
 2058|      4|    if (NULL == ddl_list) {
  ------------------
  |  Branch (2058:9): [True: 4, False: 0]
  ------------------
 2059|      4|        if (direct_driver_loading_enabled) {
  ------------------
  |  Branch (2059:13): [True: 0, False: 4]
  ------------------
 2060|      0|            loader_log(inst, VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_DRIVER_BIT, 0,
 2061|      0|                       "loader_scan_for_direct_drivers: The VK_LUNARG_direct_driver_loading extension was enabled but the "
 2062|      0|                       "pNext chain of "
 2063|      0|                       "VkInstanceCreateInfo did not contain the "
 2064|      0|                       "VkDirectDriverLoadingListLUNARG structure.");
 2065|      0|        }
 2066|       |        // Always want to exit early if there was no VkDirectDriverLoadingListLUNARG in the pNext chain
 2067|      4|        return VK_SUCCESS;
 2068|      4|    }
 2069|       |
 2070|      0|    if (!direct_driver_loading_enabled) {
  ------------------
  |  Branch (2070:9): [True: 0, False: 0]
  ------------------
 2071|      0|        loader_log(inst, VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_DRIVER_BIT, 0,
 2072|      0|                   "loader_scan_for_direct_drivers: The pNext chain of VkInstanceCreateInfo contained the "
 2073|      0|                   "VkDirectDriverLoadingListLUNARG structure, but the VK_LUNARG_direct_driver_loading extension was "
 2074|      0|                   "not enabled.");
 2075|      0|        return VK_SUCCESS;
 2076|      0|    }
 2077|       |    // If we are using exclusive mode, skip looking for any more drivers from system or environment variables
 2078|      0|    if (ddl_list->mode == VK_DIRECT_DRIVER_LOADING_MODE_EXCLUSIVE_LUNARG) {
  ------------------
  |  Branch (2078:9): [True: 0, False: 0]
  ------------------
 2079|      0|        *direct_driver_loading_exclusive_mode = true;
 2080|      0|        loader_log(inst, VULKAN_LOADER_INFO_BIT | VULKAN_LOADER_DRIVER_BIT, 0,
 2081|      0|                   "loader_scan_for_direct_drivers: The VK_LUNARG_direct_driver_loading extension is active and specified "
 2082|      0|                   "VK_DIRECT_DRIVER_LOADING_MODE_EXCLUSIVE_LUNARG, skipping system and environment "
 2083|      0|                   "variable driver search mechanisms.");
 2084|      0|    }
 2085|      0|    if (NULL == ddl_list->pDrivers) {
  ------------------
  |  Branch (2085:9): [True: 0, False: 0]
  ------------------
 2086|      0|        loader_log(inst, VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_DRIVER_BIT, 0,
 2087|      0|                   "loader_scan_for_direct_drivers: The VkDirectDriverLoadingListLUNARG structure in the pNext chain of "
 2088|      0|                   "VkInstanceCreateInfo has a NULL pDrivers member.");
 2089|      0|        return VK_SUCCESS;
 2090|      0|    }
 2091|      0|    if (ddl_list->driverCount == 0) {
  ------------------
  |  Branch (2091:9): [True: 0, False: 0]
  ------------------
 2092|      0|        loader_log(inst, VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_DRIVER_BIT, 0,
 2093|      0|                   "loader_scan_for_direct_drivers: The VkDirectDriverLoadingListLUNARG structure in the pNext chain of "
 2094|      0|                   "VkInstanceCreateInfo has a non-null pDrivers member but a driverCount member with a value "
 2095|      0|                   "of zero.");
 2096|      0|        return VK_SUCCESS;
 2097|      0|    }
 2098|       |    // Go through all VkDirectDriverLoadingInfoLUNARG entries and add each driver
 2099|       |    // Because icd_tramp's are prepended, this will result in the drivers appearing at the end
 2100|      0|    for (uint32_t i = 0; i < ddl_list->driverCount; i++) {
  ------------------
  |  Branch (2100:26): [True: 0, False: 0]
  ------------------
 2101|      0|        VkResult res = loader_add_direct_driver(inst, i, &ddl_list->pDrivers[i], icd_tramp_list);
 2102|      0|        if (res == VK_ERROR_OUT_OF_HOST_MEMORY) {
  ------------------
  |  Branch (2102:13): [True: 0, False: 0]
  ------------------
 2103|      0|            return res;
 2104|      0|        }
 2105|      0|    }
 2106|       |
 2107|      0|    return VK_SUCCESS;
 2108|      0|}
loader_initialize:
 2340|      2|void loader_initialize(void) {
 2341|      2|    loader_platform_thread_create_mutex(&loader_lock);
 2342|      2|    loader_platform_thread_create_mutex(&loader_preload_icd_lock);
 2343|      2|    init_global_loader_settings();
 2344|      2|#endif
 2345|       |
 2346|       |    // initialize logging
 2347|      2|    loader_init_global_debug_level();
 2348|       |#if defined(_WIN32)
 2349|       |    windows_initialization();
 2350|       |#endif
 2351|       |
 2352|      2|    loader_api_version version = loader_make_full_version(VK_HEADER_VERSION_COMPLETE);
 2353|      2|    loader_log(NULL, VULKAN_LOADER_INFO_BIT, 0, "Vulkan Loader Version %d.%d.%d", version.major, version.minor, version.patch);
 2354|       |
 2355|       |#if defined(GIT_BRANCH_NAME) && defined(GIT_TAG_INFO)
 2356|       |    loader_log(NULL, VULKAN_LOADER_INFO_BIT, 0, "[Vulkan Loader Git - Tag: " GIT_BRANCH_NAME ", Branch/Commit: " GIT_TAG_INFO "]");
 2357|       |#endif
 2358|       |
 2359|      2|    char *loader_disable_dynamic_library_unloading_env_var = loader_getenv("VK_LOADER_DISABLE_DYNAMIC_LIBRARY_UNLOADING", NULL);
 2360|      2|    if (loader_disable_dynamic_library_unloading_env_var &&
  ------------------
  |  Branch (2360:9): [True: 0, False: 2]
  ------------------
 2361|      0|        0 == strncmp(loader_disable_dynamic_library_unloading_env_var, "1", 2)) {
  ------------------
  |  Branch (2361:9): [True: 0, False: 0]
  ------------------
 2362|      0|        loader_disable_dynamic_library_unloading = true;
 2363|      0|        loader_log(NULL, VULKAN_LOADER_WARN_BIT, 0, "Vulkan Loader: library unloading is disabled");
 2364|      2|    } else {
 2365|      2|        loader_disable_dynamic_library_unloading = false;
 2366|      2|    }
 2367|      2|    loader_free_getenv(loader_disable_dynamic_library_unloading_env_var, NULL);
 2368|       |#if defined(LOADER_USE_UNSAFE_FILE_SEARCH)
 2369|       |    loader_log(NULL, VULKAN_LOADER_WARN_BIT, 0, "Vulkan Loader: unsafe searching is enabled");
 2370|       |#endif
 2371|       |#if defined(_WIN32)
 2372|       |    return TRUE;
 2373|       |#endif
 2374|      2|}
loader_init_library:
 2411|      2|__attribute__((constructor)) void loader_init_library(void) { loader_initialize(); }
loader_get_next_path:
 2422|  99.3k|char *loader_get_next_path(char *path) {
 2423|  99.3k|    uint32_t len;
 2424|  99.3k|    char *next;
 2425|       |
 2426|  99.3k|    if (path == NULL) return NULL;
  ------------------
  |  Branch (2426:9): [True: 0, False: 99.3k]
  ------------------
 2427|  99.3k|    next = strchr(path, PATH_SEPARATOR);
  ------------------
  |  |  150|  99.3k|#define PATH_SEPARATOR ':'
  ------------------
 2428|  99.3k|    if (next == NULL) {
  ------------------
  |  Branch (2428:9): [True: 99.3k, False: 0]
  ------------------
 2429|  99.3k|        len = (uint32_t)strlen(path);
 2430|  99.3k|        next = path + len;
 2431|  99.3k|    } else {
 2432|      0|        *next = '\0';
 2433|      0|        next++;
 2434|      0|    }
 2435|       |
 2436|  99.3k|    return next;
 2437|  99.3k|}
combine_manifest_directory_and_library_path:
 2447|  4.74k|                                                     const char *manifest_file_path, char **out_fullpath) {
 2448|  4.74k|    assert(library_path && manifest_file_path && out_fullpath);
 2449|  4.74k|    if (loader_platform_is_path_absolute(library_path)) {
  ------------------
  |  Branch (2449:9): [True: 991, False: 3.75k]
  ------------------
 2450|    991|        *out_fullpath = library_path;
 2451|    991|        return VK_SUCCESS;
 2452|    991|    }
 2453|  3.75k|    VkResult res = VK_SUCCESS;
 2454|       |
 2455|  3.75k|    size_t library_path_len = strlen(library_path);
 2456|  3.75k|    size_t manifest_file_path_str_len = strlen(manifest_file_path);
 2457|  3.75k|    bool library_path_contains_directory_symbol = false;
 2458|   722k|    for (size_t i = 0; i < library_path_len; i++) {
  ------------------
  |  Branch (2458:24): [True: 720k, False: 1.76k]
  ------------------
 2459|   720k|        if (library_path[i] == DIRECTORY_SYMBOL) {
  ------------------
  |  |  151|   720k|#define DIRECTORY_SYMBOL '/'
  ------------------
  |  Branch (2459:13): [True: 1.98k, False: 718k]
  ------------------
 2460|  1.98k|            library_path_contains_directory_symbol = true;
 2461|  1.98k|            break;
 2462|  1.98k|        }
 2463|   720k|    }
 2464|       |    // Means that the library_path is neither absolute nor relative - thus we should not modify it at all
 2465|  3.75k|    if (!library_path_contains_directory_symbol) {
  ------------------
  |  Branch (2465:9): [True: 1.76k, False: 1.98k]
  ------------------
 2466|  1.76k|        *out_fullpath = library_path;
 2467|  1.76k|        return VK_SUCCESS;
 2468|  1.76k|    }
 2469|       |    // must include both a directory symbol and the null terminator
 2470|  1.98k|    size_t new_str_len = library_path_len + manifest_file_path_str_len + 1 + 1;
 2471|       |
 2472|  1.98k|    *out_fullpath = loader_instance_heap_calloc(inst, new_str_len, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
 2473|  1.98k|    if (NULL == *out_fullpath) {
  ------------------
  |  Branch (2473:9): [True: 0, False: 1.98k]
  ------------------
 2474|      0|        res = VK_ERROR_OUT_OF_HOST_MEMORY;
 2475|      0|        goto out;
 2476|      0|    }
 2477|  1.98k|    size_t cur_loc_in_out_fullpath = 0;
 2478|       |    // look for the last occurrence of DIRECTORY_SYMBOL in manifest_file_path
 2479|  1.98k|    size_t last_directory_symbol = 0;
 2480|  1.98k|    bool found_directory_symbol = false;
 2481|  89.4k|    for (size_t i = 0; i < manifest_file_path_str_len; i++) {
  ------------------
  |  Branch (2481:24): [True: 87.4k, False: 1.98k]
  ------------------
 2482|  87.4k|        if (manifest_file_path[i] == DIRECTORY_SYMBOL) {
  ------------------
  |  |  151|  87.4k|#define DIRECTORY_SYMBOL '/'
  ------------------
  |  Branch (2482:13): [True: 14.9k, False: 72.4k]
  ------------------
 2483|  14.9k|            last_directory_symbol = i + 1;  // we want to include the symbol
 2484|  14.9k|            found_directory_symbol = true;
 2485|       |            // dont break because we want to find the last occurrence
 2486|  14.9k|        }
 2487|  87.4k|    }
 2488|       |    // Add manifest_file_path up to the last directory symbol
 2489|  1.98k|    if (found_directory_symbol) {
  ------------------
  |  Branch (2489:9): [True: 1.90k, False: 80]
  ------------------
 2490|  1.90k|        loader_strncpy(*out_fullpath, new_str_len, manifest_file_path, last_directory_symbol);
 2491|  1.90k|        cur_loc_in_out_fullpath += last_directory_symbol;
 2492|  1.90k|    }
 2493|  1.98k|    loader_strncpy(&(*out_fullpath)[cur_loc_in_out_fullpath], new_str_len - cur_loc_in_out_fullpath, library_path,
 2494|  1.98k|                   library_path_len);
 2495|  1.98k|    cur_loc_in_out_fullpath += library_path_len + 1;
 2496|  1.98k|    (*out_fullpath)[cur_loc_in_out_fullpath] = '\0';
 2497|       |
 2498|  1.98k|out:
 2499|  1.98k|    loader_instance_heap_free(inst, library_path);
 2500|       |
 2501|  1.98k|    return res;
 2502|  1.98k|}
loader_get_fullpath:
 2508|  22.7k|void loader_get_fullpath(const char *file, const char *in_dirs, size_t out_size, char *out_fullpath) {
 2509|  22.7k|    if (!loader_platform_is_path(file) && *in_dirs) {
  ------------------
  |  Branch (2509:9): [True: 22.6k, False: 57]
  |  Branch (2509:43): [True: 22.6k, False: 0]
  ------------------
 2510|  22.6k|        size_t dirs_copy_len = strlen(in_dirs) + 1;
 2511|  22.6k|        char *dirs_copy = loader_stack_alloc(dirs_copy_len);
  ------------------
  |  |   42|  22.6k|#define loader_stack_alloc(size) alloca(size)
  ------------------
 2512|  22.6k|        loader_strncpy(dirs_copy, dirs_copy_len, in_dirs, dirs_copy_len);
 2513|       |
 2514|       |        // find if file exists after prepending paths in given list
 2515|       |        // for (dir = dirs_copy; *dir && (next_dir = loader_get_next_path(dir)); dir = next_dir) {
 2516|  22.6k|        char *dir = dirs_copy;
 2517|  22.6k|        char *next_dir = loader_get_next_path(dir);
 2518|  23.4k|        while (*dir && next_dir) {
  ------------------
  |  Branch (2518:16): [True: 22.6k, False: 774]
  |  Branch (2518:24): [True: 22.6k, False: 0]
  ------------------
 2519|  22.6k|            int path_concat_ret = snprintf(out_fullpath, out_size, "%s%c%s", dir, DIRECTORY_SYMBOL, file);
  ------------------
  |  |  151|  22.6k|#define DIRECTORY_SYMBOL '/'
  ------------------
 2520|  22.6k|            if (path_concat_ret < 0) {
  ------------------
  |  Branch (2520:17): [True: 0, False: 22.6k]
  ------------------
 2521|      0|                continue;
 2522|      0|            }
 2523|  22.6k|            if (loader_platform_file_exists(out_fullpath)) {
  ------------------
  |  Branch (2523:17): [True: 21.8k, False: 774]
  ------------------
 2524|  21.8k|                return;
 2525|  21.8k|            }
 2526|    774|            dir = next_dir;
 2527|    774|            next_dir = loader_get_next_path(dir);
 2528|    774|        }
 2529|  22.6k|    }
 2530|       |
 2531|    831|    (void)snprintf(out_fullpath, out_size, "%s", file);
 2532|    831|}
verify_meta_layer_component_layers:
 2538|  12.4k|                                        struct loader_layer_list *instance_layers, bool *already_checked_meta_layers) {
 2539|  12.4k|    struct loader_layer_properties *prop = &instance_layers->list[prop_index];
 2540|  12.4k|    loader_api_version meta_layer_version = loader_make_version(prop->info.specVersion);
 2541|       |
 2542|  12.4k|    if (NULL == already_checked_meta_layers) {
  ------------------
  |  Branch (2542:9): [True: 8.87k, False: 3.62k]
  ------------------
 2543|  8.87k|        already_checked_meta_layers = loader_stack_alloc(sizeof(bool) * instance_layers->count);
  ------------------
  |  |   42|  8.87k|#define loader_stack_alloc(size) alloca(size)
  ------------------
 2544|  8.87k|        if (already_checked_meta_layers == NULL) {
  ------------------
  |  Branch (2544:13): [True: 0, False: 8.87k]
  ------------------
 2545|      0|            return false;
 2546|      0|        }
 2547|  8.87k|        memset(already_checked_meta_layers, 0, sizeof(bool) * instance_layers->count);
 2548|  8.87k|    }
 2549|       |
 2550|       |    // Mark this meta layer as 'already checked', indicating which layers have already been recursed.
 2551|  12.4k|    already_checked_meta_layers[prop_index] = true;
 2552|       |
 2553|  15.4k|    for (uint32_t comp_layer = 0; comp_layer < prop->component_layer_names.count; comp_layer++) {
  ------------------
  |  Branch (2553:35): [True: 5.53k, False: 9.92k]
  ------------------
 2554|  5.53k|        struct loader_layer_properties *comp_prop =
 2555|  5.53k|            loader_find_layer_property(prop->component_layer_names.list[comp_layer], instance_layers);
 2556|  5.53k|        if (comp_prop == NULL) {
  ------------------
  |  Branch (2556:13): [True: 692, False: 4.83k]
  ------------------
 2557|    692|            loader_log(inst, VULKAN_LOADER_WARN_BIT, 0,
 2558|    692|                       "verify_meta_layer_component_layers: Meta-layer %s can't find component layer %s at index %d."
 2559|    692|                       "  Skipping this layer.",
 2560|    692|                       prop->info.layerName, prop->component_layer_names.list[comp_layer], comp_layer);
 2561|       |
 2562|    692|            return false;
 2563|    692|        }
 2564|       |
 2565|       |        // Check the version of each layer, they need to be at least MAJOR and MINOR
 2566|  4.83k|        loader_api_version comp_prop_version = loader_make_version(comp_prop->info.specVersion);
 2567|  4.83k|        if (!loader_check_version_meets_required(meta_layer_version, comp_prop_version)) {
  ------------------
  |  Branch (2567:13): [True: 226, False: 4.61k]
  ------------------
 2568|    226|            loader_log(inst, VULKAN_LOADER_WARN_BIT, 0,
 2569|    226|                       "verify_meta_layer_component_layers: Meta-layer uses API version %d.%d, but component "
 2570|    226|                       "layer %d has API version %d.%d that is lower.  Skipping this layer.",
 2571|    226|                       meta_layer_version.major, meta_layer_version.minor, comp_layer, comp_prop_version.major,
 2572|    226|                       comp_prop_version.minor);
 2573|       |
 2574|    226|            return false;
 2575|    226|        }
 2576|       |
 2577|       |        // Make sure the layer isn't using it's own name
 2578|  4.61k|        if (!strcmp(prop->info.layerName, prop->component_layer_names.list[comp_layer])) {
  ------------------
  |  Branch (2578:13): [True: 202, False: 4.41k]
  ------------------
 2579|    202|            loader_log(inst, VULKAN_LOADER_WARN_BIT, 0,
 2580|    202|                       "verify_meta_layer_component_layers: Meta-layer %s lists itself in its component layer "
 2581|    202|                       "list at index %d.  Skipping this layer.",
 2582|    202|                       prop->info.layerName, comp_layer);
 2583|       |
 2584|    202|            return false;
 2585|    202|        }
 2586|  4.41k|        if (comp_prop->type_flags & VK_LAYER_TYPE_FLAG_META_LAYER) {
  ------------------
  |  Branch (2586:13): [True: 3.94k, False: 463]
  ------------------
 2587|  3.94k|            size_t comp_prop_index = INT32_MAX;
 2588|       |            // Make sure we haven't verified this meta layer before
 2589|   230k|            for (uint32_t i = 0; i < instance_layers->count; i++) {
  ------------------
  |  Branch (2589:34): [True: 226k, False: 3.94k]
  ------------------
 2590|   226k|                if (strcmp(comp_prop->info.layerName, instance_layers->list[i].info.layerName) == 0) {
  ------------------
  |  Branch (2590:21): [True: 77.5k, False: 148k]
  ------------------
 2591|  77.5k|                    comp_prop_index = i;
 2592|  77.5k|                }
 2593|   226k|            }
 2594|  3.94k|            if (comp_prop_index != INT32_MAX && already_checked_meta_layers[comp_prop_index]) {
  ------------------
  |  Branch (2594:17): [True: 3.94k, False: 0]
  |  Branch (2594:49): [True: 326, False: 3.62k]
  ------------------
 2595|    326|                loader_log(inst, VULKAN_LOADER_WARN_BIT, 0,
 2596|    326|                           "verify_meta_layer_component_layers: Recursive dependency between Meta-layer %s and  Meta-layer %s.  "
 2597|    326|                           "Skipping this layer.",
 2598|    326|                           instance_layers->list[prop_index].info.layerName, comp_prop->info.layerName);
 2599|    326|                return false;
 2600|    326|            }
 2601|       |
 2602|  3.62k|            loader_log(inst, VULKAN_LOADER_INFO_BIT, 0,
 2603|  3.62k|                       "verify_meta_layer_component_layers: Adding meta-layer %s which also contains meta-layer %s",
 2604|  3.62k|                       prop->info.layerName, comp_prop->info.layerName);
 2605|       |
 2606|       |            // Make sure if the layer is using a meta-layer in its component list that we also verify that.
 2607|  3.62k|            if (!verify_meta_layer_component_layers(inst, comp_prop_index, instance_layers, already_checked_meta_layers)) {
  ------------------
  |  Branch (2607:17): [True: 1.12k, False: 2.49k]
  ------------------
 2608|  1.12k|                loader_log(inst, VULKAN_LOADER_WARN_BIT, 0,
 2609|  1.12k|                           "Meta-layer %s component layer %s can not find all component layers."
 2610|  1.12k|                           "  Skipping this layer.",
 2611|  1.12k|                           prop->info.layerName, prop->component_layer_names.list[comp_layer]);
 2612|  1.12k|                return false;
 2613|  1.12k|            }
 2614|  3.62k|        }
 2615|  4.41k|    }
 2616|       |    // Didn't exit early so that means it passed all checks
 2617|  9.92k|    loader_log(inst, VULKAN_LOADER_INFO_BIT | VULKAN_LOADER_LAYER_BIT, 0,
 2618|  9.92k|               "Meta-layer \"%s\" all %d component layers appear to be valid.", prop->info.layerName,
 2619|  9.92k|               prop->component_layer_names.count);
 2620|       |
 2621|       |    // If layer logging is on, list the internals included in the meta-layer
 2622|  12.7k|    for (uint32_t comp_layer = 0; comp_layer < prop->component_layer_names.count; comp_layer++) {
  ------------------
  |  Branch (2622:35): [True: 2.83k, False: 9.92k]
  ------------------
 2623|  2.83k|        loader_log(inst, VULKAN_LOADER_LAYER_BIT, 0, "  [%d] %s", comp_layer, prop->component_layer_names.list[comp_layer]);
 2624|  2.83k|    }
 2625|       |    return true;
 2626|  12.4k|}
update_meta_layer_extensions_from_component_layers:
 2631|  7.42k|                                                        struct loader_layer_list *instance_layers) {
 2632|  7.42k|    VkResult res = VK_SUCCESS;
 2633|  9.69k|    for (uint32_t comp_layer = 0; comp_layer < prop->component_layer_names.count; comp_layer++) {
  ------------------
  |  Branch (2633:35): [True: 2.26k, False: 7.42k]
  ------------------
 2634|  2.26k|        struct loader_layer_properties *comp_prop =
 2635|  2.26k|            loader_find_layer_property(prop->component_layer_names.list[comp_layer], instance_layers);
 2636|       |
 2637|  2.26k|        if (NULL != comp_prop->instance_extension_list.list) {
  ------------------
  |  Branch (2637:13): [True: 339, False: 1.92k]
  ------------------
 2638|  3.93k|            for (uint32_t ext = 0; ext < comp_prop->instance_extension_list.count; ext++) {
  ------------------
  |  Branch (2638:36): [True: 3.59k, False: 339]
  ------------------
 2639|  3.59k|                loader_log(inst, VULKAN_LOADER_DEBUG_BIT, 0, "Meta-layer %s component layer %s adding instance extension %s",
 2640|  3.59k|                           prop->info.layerName, prop->component_layer_names.list[comp_layer],
 2641|  3.59k|                           comp_prop->instance_extension_list.list[ext].extensionName);
 2642|       |
 2643|  3.59k|                if (!has_vk_extension_property(&comp_prop->instance_extension_list.list[ext], &prop->instance_extension_list)) {
  ------------------
  |  Branch (2643:21): [True: 3.46k, False: 133]
  ------------------
 2644|  3.46k|                    res = loader_add_to_ext_list(inst, &prop->instance_extension_list, 1,
 2645|  3.46k|                                                 &comp_prop->instance_extension_list.list[ext]);
 2646|  3.46k|                    if (VK_ERROR_OUT_OF_HOST_MEMORY == res) {
  ------------------
  |  Branch (2646:25): [True: 0, False: 3.46k]
  ------------------
 2647|      0|                        return res;
 2648|      0|                    }
 2649|  3.46k|                }
 2650|  3.59k|            }
 2651|    339|        }
 2652|  2.26k|        if (NULL != comp_prop->device_extension_list.list) {
  ------------------
  |  Branch (2652:13): [True: 649, False: 1.61k]
  ------------------
 2653|  5.90k|            for (uint32_t ext = 0; ext < comp_prop->device_extension_list.count; ext++) {
  ------------------
  |  Branch (2653:36): [True: 5.25k, False: 649]
  ------------------
 2654|  5.25k|                loader_log(inst, VULKAN_LOADER_DEBUG_BIT, 0, "Meta-layer %s component layer %s adding device extension %s",
 2655|  5.25k|                           prop->info.layerName, prop->component_layer_names.list[comp_layer],
 2656|  5.25k|                           comp_prop->device_extension_list.list[ext].props.extensionName);
 2657|       |
 2658|  5.25k|                if (!has_vk_dev_ext_property(&comp_prop->device_extension_list.list[ext].props, &prop->device_extension_list)) {
  ------------------
  |  Branch (2658:21): [True: 4.45k, False: 809]
  ------------------
 2659|  4.45k|                    loader_add_to_dev_ext_list(inst, &prop->device_extension_list,
 2660|  4.45k|                                               &comp_prop->device_extension_list.list[ext].props, NULL);
 2661|  4.45k|                    if (VK_ERROR_OUT_OF_HOST_MEMORY == res) {
  ------------------
  |  Branch (2661:25): [True: 0, False: 4.45k]
  ------------------
 2662|      0|                        return res;
 2663|      0|                    }
 2664|  4.45k|                }
 2665|  5.25k|            }
 2666|    649|        }
 2667|  2.26k|    }
 2668|  7.42k|    return res;
 2669|  7.42k|}
verify_all_meta_layers:
 2673|  5.24k|                                struct loader_layer_list *instance_layers, bool *override_layer_present) {
 2674|  5.24k|    VkResult res = VK_SUCCESS;
 2675|  5.24k|    *override_layer_present = false;
 2676|  17.9k|    for (int32_t i = 0; i < (int32_t)instance_layers->count; i++) {
  ------------------
  |  Branch (2676:25): [True: 12.7k, False: 5.24k]
  ------------------
 2677|  12.7k|        struct loader_layer_properties *prop = &instance_layers->list[i];
 2678|       |
 2679|       |        // If this is a meta-layer, make sure it is valid
 2680|  12.7k|        if (prop->type_flags & VK_LAYER_TYPE_FLAG_META_LAYER) {
  ------------------
  |  Branch (2680:13): [True: 8.87k, False: 3.86k]
  ------------------
 2681|  8.87k|            if (verify_meta_layer_component_layers(inst, i, instance_layers, NULL)) {
  ------------------
  |  Branch (2681:17): [True: 7.42k, False: 1.44k]
  ------------------
 2682|       |                // If any meta layer is valid, update its extension list to include the extensions from its component layers.
 2683|  7.42k|                res = update_meta_layer_extensions_from_component_layers(inst, prop, instance_layers);
 2684|  7.42k|                if (VK_ERROR_OUT_OF_HOST_MEMORY == res) {
  ------------------
  |  Branch (2684:21): [True: 0, False: 7.42k]
  ------------------
 2685|      0|                    return res;
 2686|      0|                }
 2687|  7.42k|                if (prop->is_override && loader_implicit_layer_is_enabled(inst, filters, prop)) {
  ------------------
  |  Branch (2687:21): [True: 879, False: 6.54k]
  |  Branch (2687:42): [True: 862, False: 17]
  ------------------
 2688|    862|                    *override_layer_present = true;
 2689|    862|                }
 2690|  7.42k|            } else {
 2691|  1.44k|                loader_log(inst, VULKAN_LOADER_DEBUG_BIT, 0,
 2692|  1.44k|                           "Removing meta-layer %s from instance layer list since it appears invalid.", prop->info.layerName);
 2693|       |
 2694|  1.44k|                loader_remove_layer_in_list(inst, instance_layers, i);
 2695|  1.44k|                i--;
 2696|  1.44k|            }
 2697|  8.87k|        }
 2698|  12.7k|    }
 2699|  5.24k|    return res;
 2700|  5.24k|}
remove_all_non_valid_override_layers:
 2704|  5.24k|void remove_all_non_valid_override_layers(struct loader_instance *inst, struct loader_layer_list *instance_layers) {
 2705|  5.24k|    if (instance_layers == NULL) {
  ------------------
  |  Branch (2705:9): [True: 0, False: 5.24k]
  ------------------
 2706|      0|        return;
 2707|      0|    }
 2708|       |
 2709|  5.24k|    char cur_path[1024];
 2710|  5.24k|    char *ret = loader_platform_executable_path(cur_path, 1024);
 2711|  5.24k|    if (NULL == ret) {
  ------------------
  |  Branch (2711:9): [True: 0, False: 5.24k]
  ------------------
 2712|      0|        return;
 2713|      0|    }
 2714|       |    // Find out if there is an override layer with same the app_key_path as the path to the current executable.
 2715|       |    // If more than one is found, remove it and use the first layer
 2716|       |    // Remove any layers which aren't global and do not have the same app_key_path as the path to the current executable.
 2717|  5.24k|    bool found_active_override_layer = false;
 2718|  5.24k|    int global_layer_index = -1;
 2719|  11.8k|    for (uint32_t i = 0; i < instance_layers->count; i++) {
  ------------------
  |  Branch (2719:26): [True: 6.64k, False: 5.24k]
  ------------------
 2720|  6.64k|        struct loader_layer_properties *props = &instance_layers->list[i];
 2721|  6.64k|        if (strcmp(props->info.layerName, VK_OVERRIDE_LAYER_NAME) == 0) {
  ------------------
  |  |  138|  6.64k|#define VK_OVERRIDE_LAYER_NAME "VK_LAYER_LUNARG_override"
  ------------------
  |  Branch (2721:13): [True: 850, False: 5.79k]
  ------------------
 2722|    850|            if (props->app_key_paths.count > 0) {  // not the global layer
  ------------------
  |  Branch (2722:17): [True: 179, False: 671]
  ------------------
 2723|  1.61k|                for (uint32_t j = 0; j < props->app_key_paths.count; j++) {
  ------------------
  |  Branch (2723:38): [True: 1.43k, False: 179]
  ------------------
 2724|  1.43k|                    if (strcmp(props->app_key_paths.list[j], cur_path) == 0) {
  ------------------
  |  Branch (2724:25): [True: 0, False: 1.43k]
  ------------------
 2725|      0|                        if (!found_active_override_layer) {
  ------------------
  |  Branch (2725:29): [True: 0, False: 0]
  ------------------
 2726|      0|                            found_active_override_layer = true;
 2727|      0|                        } else {
 2728|      0|                            loader_log(inst, VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_LAYER_BIT, 0,
 2729|      0|                                       "remove_all_non_valid_override_layers: Multiple override layers where the same path in "
 2730|      0|                                       "app_keys "
 2731|      0|                                       "was found. Using the first layer found");
 2732|       |
 2733|       |                            // Remove duplicate active override layers that have the same app_key_path
 2734|      0|                            loader_remove_layer_in_list(inst, instance_layers, i);
 2735|      0|                            i--;
 2736|      0|                        }
 2737|      0|                    }
 2738|  1.43k|                }
 2739|    179|                if (!found_active_override_layer) {
  ------------------
  |  Branch (2739:21): [True: 179, False: 0]
  ------------------
 2740|    179|                    loader_log(inst, VULKAN_LOADER_INFO_BIT | VULKAN_LOADER_LAYER_BIT, 0,
 2741|    179|                               "--Override layer found but not used because app \'%s\' is not in \'app_keys\' list!", cur_path);
 2742|       |
 2743|       |                    // Remove non-global override layers that don't have an app_key that matches cur_path
 2744|    179|                    loader_remove_layer_in_list(inst, instance_layers, i);
 2745|    179|                    i--;
 2746|    179|                }
 2747|    671|            } else {
 2748|    671|                if (global_layer_index == -1) {
  ------------------
  |  Branch (2748:21): [True: 505, False: 166]
  ------------------
 2749|    505|                    global_layer_index = i;
 2750|    505|                } else {
 2751|    166|                    loader_log(
 2752|    166|                        inst, VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_LAYER_BIT, 0,
 2753|    166|                        "remove_all_non_valid_override_layers: Multiple global override layers found. Using the first global "
 2754|    166|                        "layer found");
 2755|    166|                    loader_remove_layer_in_list(inst, instance_layers, i);
 2756|    166|                    i--;
 2757|    166|                }
 2758|    671|            }
 2759|    850|        }
 2760|  6.64k|    }
 2761|       |    // Remove global layer if layer with same the app_key_path as the path to the current executable is found
 2762|  5.24k|    if (found_active_override_layer && global_layer_index >= 0) {
  ------------------
  |  Branch (2762:9): [True: 0, False: 5.24k]
  |  Branch (2762:40): [True: 0, False: 0]
  ------------------
 2763|      0|        loader_remove_layer_in_list(inst, instance_layers, global_layer_index);
 2764|      0|    }
 2765|       |    // Should be at most 1 override layer in the list now.
 2766|  5.24k|    if (found_active_override_layer) {
  ------------------
  |  Branch (2766:9): [True: 0, False: 5.24k]
  ------------------
 2767|      0|        loader_log(inst, VULKAN_LOADER_INFO_BIT | VULKAN_LOADER_LAYER_BIT, 0, "Using the override layer for app key %s", cur_path);
 2768|  5.24k|    } else if (global_layer_index >= 0) {
  ------------------
  |  Branch (2768:16): [True: 505, False: 4.74k]
  ------------------
 2769|    505|        loader_log(inst, VULKAN_LOADER_INFO_BIT | VULKAN_LOADER_LAYER_BIT, 0, "Using the global override layer");
 2770|    505|    }
 2771|  5.24k|}
loader_read_layer_json:
 2785|  28.3k|                                cJSON *layer_node, loader_api_version version, bool is_implicit, char *filename) {
 2786|  28.3k|    assert(layer_instance_list);
 2787|  28.3k|    char *library_path = NULL;
 2788|  28.3k|    VkResult result = VK_SUCCESS;
 2789|  28.3k|    struct loader_layer_properties props = {0};
 2790|       |
 2791|  28.3k|    result = loader_copy_to_new_str(inst, filename, &props.manifest_file_name);
 2792|  28.3k|    if (result == VK_ERROR_OUT_OF_HOST_MEMORY) {
  ------------------
  |  Branch (2792:9): [True: 0, False: 28.3k]
  ------------------
 2793|      0|        goto out;
 2794|      0|    }
 2795|       |
 2796|       |    // Parse name
 2797|       |
 2798|  28.3k|    result = loader_parse_json_string_to_existing_str(layer_node, "name", VK_MAX_EXTENSION_NAME_SIZE, props.info.layerName);
 2799|  28.3k|    if (VK_ERROR_INITIALIZATION_FAILED == result) {
  ------------------
  |  Branch (2799:9): [True: 6.07k, False: 22.2k]
  ------------------
 2800|  6.07k|        loader_log(inst, VULKAN_LOADER_WARN_BIT, 0,
 2801|  6.07k|                   "Layer located at %s didn't find required layer value \"name\" in manifest JSON file, skipping this layer",
 2802|  6.07k|                   filename);
 2803|  6.07k|        goto out;
 2804|  6.07k|    }
 2805|       |
 2806|       |    // Check if this layer's name matches the override layer name, set is_override to true if so.
 2807|  22.2k|    if (!strcmp(props.info.layerName, VK_OVERRIDE_LAYER_NAME)) {
  ------------------
  |  |  138|  22.2k|#define VK_OVERRIDE_LAYER_NAME "VK_LAYER_LUNARG_override"
  ------------------
  |  Branch (2807:9): [True: 1.74k, False: 20.5k]
  ------------------
 2808|  1.74k|        props.is_override = true;
 2809|  1.74k|    }
 2810|       |
 2811|  22.2k|    if (0 != strncmp(props.info.layerName, "VK_LAYER_", 9)) {
  ------------------
  |  Branch (2811:9): [True: 19.0k, False: 3.23k]
  ------------------
 2812|  19.0k|        loader_log(inst, VULKAN_LOADER_WARN_BIT, 0, "Layer name %s does not conform to naming standard (Policy #LLP_LAYER_3)",
 2813|  19.0k|                   props.info.layerName);
 2814|  19.0k|    }
 2815|       |
 2816|       |    // Parse type
 2817|  22.2k|    char *type = loader_cJSON_GetStringValue(loader_cJSON_GetObjectItem(layer_node, "type"));
 2818|  22.2k|    if (NULL == type) {
  ------------------
  |  Branch (2818:9): [True: 2.39k, False: 19.8k]
  ------------------
 2819|  2.39k|        loader_log(inst, VULKAN_LOADER_WARN_BIT, 0,
 2820|  2.39k|                   "Layer located at %s didn't find required layer value \"type\" in manifest JSON file, skipping this layer",
 2821|  2.39k|                   filename);
 2822|  2.39k|        result = VK_ERROR_INITIALIZATION_FAILED;
 2823|  2.39k|        goto out;
 2824|  2.39k|    }
 2825|       |
 2826|       |    // Add list entry
 2827|  19.8k|    if (!strcmp(type, "DEVICE")) {
  ------------------
  |  Branch (2827:9): [True: 54, False: 19.8k]
  ------------------
 2828|     54|        loader_log(inst, VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_LAYER_BIT, 0, "Device layers are deprecated. Skipping layer %s",
 2829|     54|                   props.info.layerName);
 2830|     54|        result = VK_ERROR_INITIALIZATION_FAILED;
 2831|     54|        goto out;
 2832|     54|    }
 2833|       |
 2834|       |    // Allow either GLOBAL or INSTANCE type interchangeably to handle layers that must work with older loaders
 2835|  19.8k|    if (!strcmp(type, "INSTANCE") || !strcmp(type, "GLOBAL")) {
  ------------------
  |  Branch (2835:9): [True: 12.6k, False: 7.21k]
  |  Branch (2835:38): [True: 6.48k, False: 724]
  ------------------
 2836|  19.0k|        props.type_flags = VK_LAYER_TYPE_FLAG_INSTANCE_LAYER;
 2837|  19.0k|        if (!is_implicit) {
  ------------------
  |  Branch (2837:13): [True: 8.30k, False: 10.7k]
  ------------------
 2838|  8.30k|            props.type_flags |= VK_LAYER_TYPE_FLAG_EXPLICIT_LAYER;
 2839|  8.30k|        }
 2840|  19.0k|    } else {
 2841|    724|        result = VK_ERROR_INITIALIZATION_FAILED;
 2842|    724|        goto out;
 2843|    724|    }
 2844|       |
 2845|       |    // Parse api_version
 2846|  19.0k|    char *api_version = loader_cJSON_GetStringValue(loader_cJSON_GetObjectItem(layer_node, "api_version"));
 2847|  19.0k|    if (NULL == api_version) {
  ------------------
  |  Branch (2847:9): [True: 2.29k, False: 16.7k]
  ------------------
 2848|  2.29k|        loader_log(
 2849|  2.29k|            inst, VULKAN_LOADER_WARN_BIT, 0,
 2850|  2.29k|            "Layer located at %s didn't find required layer value \"api_version\" in manifest JSON file, skipping this layer",
 2851|  2.29k|            filename);
 2852|  2.29k|        result = VK_ERROR_INITIALIZATION_FAILED;
 2853|  2.29k|        goto out;
 2854|  2.29k|    }
 2855|       |
 2856|  16.7k|    props.info.specVersion = loader_parse_version_string(api_version);
 2857|       |
 2858|       |    // Make sure the layer's manifest doesn't contain a non zero variant value
 2859|  16.7k|    if (VK_API_VERSION_VARIANT(props.info.specVersion) != 0) {
  ------------------
  |  Branch (2859:9): [True: 45, False: 16.7k]
  ------------------
 2860|     45|        loader_log(inst, VULKAN_LOADER_INFO_BIT | VULKAN_LOADER_LAYER_BIT, 0,
 2861|     45|                   "Layer \"%s\" has an \'api_version\' field which contains a non-zero variant value of %d. "
 2862|     45|                   " Skipping Layer.",
 2863|     45|                   props.info.layerName, VK_API_VERSION_VARIANT(props.info.specVersion));
 2864|     45|        result = VK_ERROR_INITIALIZATION_FAILED;
 2865|     45|        goto out;
 2866|     45|    }
 2867|       |
 2868|       |    // Parse implementation_version
 2869|  16.7k|    char *implementation_version = loader_cJSON_GetStringValue(loader_cJSON_GetObjectItem(layer_node, "implementation_version"));
 2870|  16.7k|    if (NULL == implementation_version) {
  ------------------
  |  Branch (2870:9): [True: 1.03k, False: 15.7k]
  ------------------
 2871|  1.03k|        loader_log(inst, VULKAN_LOADER_WARN_BIT, 0,
 2872|  1.03k|                   "Layer located at %s didn't find required layer value \"implementation_version\" in manifest JSON file, "
 2873|  1.03k|                   "skipping this layer",
 2874|  1.03k|                   filename);
 2875|  1.03k|        result = VK_ERROR_INITIALIZATION_FAILED;
 2876|  1.03k|        goto out;
 2877|  1.03k|    }
 2878|  15.7k|    props.info.implementationVersion = atoi(implementation_version);
 2879|       |
 2880|       |    // Parse description
 2881|       |
 2882|  15.7k|    result = loader_parse_json_string_to_existing_str(layer_node, "description", VK_MAX_DESCRIPTION_SIZE, props.info.description);
 2883|  15.7k|    if (VK_ERROR_INITIALIZATION_FAILED == result) {
  ------------------
  |  Branch (2883:9): [True: 693, False: 15.0k]
  ------------------
 2884|    693|        loader_log(
 2885|    693|            inst, VULKAN_LOADER_WARN_BIT, 0,
 2886|    693|            "Layer located at %s didn't find required layer value \"description\" in manifest JSON file, skipping this layer",
 2887|    693|            filename);
 2888|    693|        goto out;
 2889|    693|    }
 2890|       |
 2891|       |    // Parse library_path
 2892|       |
 2893|       |    // Library path no longer required unless component_layers is also not defined
 2894|  15.0k|    result = loader_parse_json_string(layer_node, "library_path", &library_path);
 2895|  15.0k|    if (result == VK_ERROR_OUT_OF_HOST_MEMORY) {
  ------------------
  |  Branch (2895:9): [True: 0, False: 15.0k]
  ------------------
 2896|      0|        loader_log(inst, VULKAN_LOADER_WARN_BIT, 0,
 2897|      0|                   "Skipping layer \"%s\" due to problem accessing the library_path value in the manifest JSON file",
 2898|      0|                   props.info.layerName);
 2899|      0|        result = VK_ERROR_OUT_OF_HOST_MEMORY;
 2900|      0|        goto out;
 2901|      0|    }
 2902|  15.0k|    if (NULL != library_path) {
  ------------------
  |  Branch (2902:9): [True: 4.76k, False: 10.2k]
  ------------------
 2903|  4.76k|        if (NULL != loader_cJSON_GetObjectItem(layer_node, "component_layers")) {
  ------------------
  |  Branch (2903:13): [True: 15, False: 4.74k]
  ------------------
 2904|     15|            loader_log(
 2905|     15|                inst, VULKAN_LOADER_WARN_BIT, 0,
 2906|     15|                "Layer \"%s\" contains meta-layer-specific component_layers, but also defining layer library path.  Both are not "
 2907|     15|                "compatible, so skipping this layer",
 2908|     15|                props.info.layerName);
 2909|     15|            result = VK_ERROR_INITIALIZATION_FAILED;
 2910|     15|            loader_instance_heap_free(inst, library_path);
 2911|     15|            goto out;
 2912|     15|        }
 2913|       |
 2914|       |        // This function takes ownership of library_path_str - so we don't need to clean it up
 2915|  4.74k|        result = combine_manifest_directory_and_library_path(inst, library_path, filename, &props.lib_name);
 2916|  4.74k|        if (result == VK_ERROR_OUT_OF_HOST_MEMORY) goto out;
  ------------------
  |  Branch (2916:13): [True: 0, False: 4.74k]
  ------------------
 2917|  4.74k|    }
 2918|       |
 2919|       |    // Parse component_layers
 2920|       |
 2921|  15.0k|    if (NULL == library_path) {
  ------------------
  |  Branch (2921:9): [True: 10.2k, False: 4.74k]
  ------------------
 2922|  10.2k|        if (!loader_check_version_meets_required(LOADER_VERSION_1_1_0, version)) {
  ------------------
  |  |  272|  10.2k|#define LOADER_VERSION_1_1_0 loader_combine_version(1, 1, 0)
  ------------------
  |  Branch (2922:13): [True: 6.19k, False: 4.07k]
  ------------------
 2923|  6.19k|            loader_log(inst, VULKAN_LOADER_WARN_BIT, 0,
 2924|  6.19k|                       "Layer \"%s\" contains meta-layer-specific component_layers, but using older JSON file version.",
 2925|  6.19k|                       props.info.layerName);
 2926|  6.19k|        }
 2927|       |
 2928|  10.2k|        result = loader_parse_json_array_of_strings(inst, layer_node, "component_layers", &(props.component_layer_names));
 2929|  10.2k|        if (VK_ERROR_OUT_OF_HOST_MEMORY == result) {
  ------------------
  |  Branch (2929:13): [True: 0, False: 10.2k]
  ------------------
 2930|      0|            goto out;
 2931|      0|        }
 2932|  10.2k|        if (VK_ERROR_INITIALIZATION_FAILED == result) {
  ------------------
  |  Branch (2932:13): [True: 801, False: 9.46k]
  ------------------
 2933|    801|            loader_log(inst, VULKAN_LOADER_WARN_BIT, 0,
 2934|    801|                       "Layer \"%s\" is missing both library_path and component_layers fields.  One or the other MUST be defined.  "
 2935|    801|                       "Skipping this layer",
 2936|    801|                       props.info.layerName);
 2937|    801|            goto out;
 2938|    801|        }
 2939|       |        // This is now, officially, a meta-layer
 2940|  9.46k|        props.type_flags |= VK_LAYER_TYPE_FLAG_META_LAYER;
 2941|  9.46k|        loader_log(inst, VULKAN_LOADER_INFO_BIT | VULKAN_LOADER_LAYER_BIT, 0, "Encountered meta-layer \"%s\"",
 2942|  9.46k|                   props.info.layerName);
 2943|  9.46k|    }
 2944|       |
 2945|       |    // Parse blacklisted_layers
 2946|       |
 2947|  14.2k|    if (props.is_override) {
  ------------------
  |  Branch (2947:9): [True: 1.55k, False: 12.6k]
  ------------------
 2948|  1.55k|        result = loader_parse_json_array_of_strings(inst, layer_node, "blacklisted_layers", &(props.blacklist_layer_names));
 2949|  1.55k|        if (VK_ERROR_OUT_OF_HOST_MEMORY == result) {
  ------------------
  |  Branch (2949:13): [True: 0, False: 1.55k]
  ------------------
 2950|      0|            goto out;
 2951|      0|        }
 2952|  1.55k|    }
 2953|       |
 2954|       |    // Parse override_paths
 2955|       |
 2956|  14.2k|    result = loader_parse_json_array_of_strings(inst, layer_node, "override_paths", &(props.override_paths));
 2957|  14.2k|    if (VK_ERROR_OUT_OF_HOST_MEMORY == result) {
  ------------------
  |  Branch (2957:9): [True: 0, False: 14.2k]
  ------------------
 2958|      0|        goto out;
 2959|      0|    }
 2960|  14.2k|    if (NULL != props.override_paths.list && !loader_check_version_meets_required(loader_combine_version(1, 1, 0), version)) {
  ------------------
  |  Branch (2960:9): [True: 1.07k, False: 13.1k]
  |  Branch (2960:46): [True: 557, False: 519]
  ------------------
 2961|    557|        loader_log(inst, VULKAN_LOADER_WARN_BIT, 0,
 2962|    557|                   "Layer \"%s\" contains meta-layer-specific override paths, but using older JSON file version.",
 2963|    557|                   props.info.layerName);
 2964|    557|    }
 2965|       |
 2966|       |    // Parse disable_environment
 2967|       |
 2968|  14.2k|    if (is_implicit) {
  ------------------
  |  Branch (2968:9): [True: 7.74k, False: 6.46k]
  ------------------
 2969|  7.74k|        cJSON *disable_environment = loader_cJSON_GetObjectItem(layer_node, "disable_environment");
 2970|  7.74k|        if (disable_environment == NULL) {
  ------------------
  |  Branch (2970:13): [True: 1.01k, False: 6.72k]
  ------------------
 2971|  1.01k|            loader_log(inst, VULKAN_LOADER_WARN_BIT, 0,
 2972|  1.01k|                       "Layer \"%s\" doesn't contain required layer object disable_environment in the manifest JSON file, skipping "
 2973|  1.01k|                       "this layer",
 2974|  1.01k|                       props.info.layerName);
 2975|  1.01k|            result = VK_ERROR_INITIALIZATION_FAILED;
 2976|  1.01k|            goto out;
 2977|  1.01k|        }
 2978|       |
 2979|  6.72k|        if (!disable_environment->child || disable_environment->child->type != cJSON_String ||
  ------------------
  |  |  101|  13.4k|#define cJSON_String (1 << 4)
  ------------------
  |  Branch (2979:13): [True: 36, False: 6.69k]
  |  Branch (2979:44): [True: 9, False: 6.68k]
  ------------------
 2980|  6.68k|            !disable_environment->child->string || !disable_environment->child->valuestring) {
  ------------------
  |  Branch (2980:13): [True: 17, False: 6.66k]
  |  Branch (2980:52): [True: 0, False: 6.66k]
  ------------------
 2981|     62|            loader_log(inst, VULKAN_LOADER_WARN_BIT, 0,
 2982|     62|                       "Layer \"%s\" doesn't contain required child value in object disable_environment in the manifest JSON file, "
 2983|     62|                       "skipping this layer (Policy #LLP_LAYER_9)",
 2984|     62|                       props.info.layerName);
 2985|     62|            result = VK_ERROR_INITIALIZATION_FAILED;
 2986|     62|            goto out;
 2987|     62|        }
 2988|  6.66k|        result = loader_copy_to_new_str(inst, disable_environment->child->string, &(props.disable_env_var.name));
 2989|  6.66k|        if (VK_SUCCESS != result) goto out;
  ------------------
  |  Branch (2989:13): [True: 0, False: 6.66k]
  ------------------
 2990|  6.66k|        result = loader_copy_to_new_str(inst, disable_environment->child->valuestring, &(props.disable_env_var.value));
 2991|  6.66k|        if (VK_SUCCESS != result) goto out;
  ------------------
  |  Branch (2991:13): [True: 0, False: 6.66k]
  ------------------
 2992|  6.66k|    }
 2993|       |
 2994|       |    // Now get all optional items and objects and put in list:
 2995|       |    // functions
 2996|       |    // instance_extensions
 2997|       |    // device_extensions
 2998|       |    // enable_environment (implicit layers only)
 2999|       |    // library_arch
 3000|       |
 3001|       |    // Layer interface functions
 3002|       |    //    vkGetInstanceProcAddr
 3003|       |    //    vkGetDeviceProcAddr
 3004|       |    //    vkNegotiateLoaderLayerInterfaceVersion (starting with JSON file 1.1.0)
 3005|  13.1k|    cJSON *functions = loader_cJSON_GetObjectItem(layer_node, "functions");
 3006|  13.1k|    if (functions != NULL) {
  ------------------
  |  Branch (3006:9): [True: 520, False: 12.6k]
  ------------------
 3007|    520|        if (loader_check_version_meets_required(loader_combine_version(1, 1, 0), version)) {
  ------------------
  |  Branch (3007:13): [True: 122, False: 398]
  ------------------
 3008|    122|            result = loader_parse_json_string(functions, "vkNegotiateLoaderLayerInterfaceVersion",
 3009|    122|                                              &props.functions.str_negotiate_interface);
 3010|    122|            if (result == VK_ERROR_OUT_OF_HOST_MEMORY) goto out;
  ------------------
  |  Branch (3010:17): [True: 0, False: 122]
  ------------------
 3011|    122|        }
 3012|    520|        result = loader_parse_json_string(functions, "vkGetInstanceProcAddr", &props.functions.str_gipa);
 3013|    520|        if (result == VK_ERROR_OUT_OF_HOST_MEMORY) goto out;
  ------------------
  |  Branch (3013:13): [True: 0, False: 520]
  ------------------
 3014|       |
 3015|    520|        if (NULL == props.functions.str_negotiate_interface && props.functions.str_gipa &&
  ------------------
  |  Branch (3015:13): [True: 520, False: 0]
  |  Branch (3015:64): [True: 0, False: 520]
  ------------------
 3016|      0|            loader_check_version_meets_required(loader_combine_version(1, 1, 0), version)) {
  ------------------
  |  Branch (3016:13): [True: 0, False: 0]
  ------------------
 3017|      0|            loader_log(inst, VULKAN_LOADER_INFO_BIT, 0,
 3018|      0|                       "Layer \"%s\" using deprecated \'vkGetInstanceProcAddr\' tag which was deprecated starting with JSON "
 3019|      0|                       "file version 1.1.0. The new vkNegotiateLoaderLayerInterfaceVersion function is preferred, though for "
 3020|      0|                       "compatibility reasons it may be desirable to continue using the deprecated tag.",
 3021|      0|                       props.info.layerName);
 3022|      0|        }
 3023|       |
 3024|    520|        result = loader_parse_json_string(functions, "vkGetDeviceProcAddr", &props.functions.str_gdpa);
 3025|    520|        if (result == VK_ERROR_OUT_OF_HOST_MEMORY) goto out;
  ------------------
  |  Branch (3025:13): [True: 0, False: 520]
  ------------------
 3026|       |
 3027|    520|        if (NULL == props.functions.str_negotiate_interface && props.functions.str_gdpa &&
  ------------------
  |  Branch (3027:13): [True: 520, False: 0]
  |  Branch (3027:64): [True: 0, False: 520]
  ------------------
 3028|      0|            loader_check_version_meets_required(loader_combine_version(1, 1, 0), version)) {
  ------------------
  |  Branch (3028:13): [True: 0, False: 0]
  ------------------
 3029|      0|            loader_log(inst, VULKAN_LOADER_INFO_BIT, 0,
 3030|      0|                       "Layer \"%s\" using deprecated \'vkGetDeviceProcAddr\' tag which was deprecated starting with JSON "
 3031|      0|                       "file version 1.1.0. The new vkNegotiateLoaderLayerInterfaceVersion function is preferred, though for "
 3032|      0|                       "compatibility reasons it may be desirable to continue using the deprecated tag.",
 3033|      0|                       props.info.layerName);
 3034|      0|        }
 3035|    520|    }
 3036|       |
 3037|       |    // instance_extensions
 3038|       |    //   array of {
 3039|       |    //     name
 3040|       |    //     spec_version
 3041|       |    //   }
 3042|       |
 3043|  13.1k|    cJSON *instance_extensions = loader_cJSON_GetObjectItem(layer_node, "instance_extensions");
 3044|  13.1k|    if (instance_extensions != NULL && instance_extensions->type == cJSON_Array) {
  ------------------
  |  |  102|    890|#define cJSON_Array (1 << 5)
  ------------------
  |  Branch (3044:9): [True: 890, False: 12.2k]
  |  Branch (3044:40): [True: 766, False: 124]
  ------------------
 3045|    766|        cJSON *ext_item = NULL;
 3046|  5.31k|        cJSON_ArrayForEach(ext_item, instance_extensions) {
  ------------------
  |  |  213|  6.08k|    for (element = (array != NULL) ? (array)->child : NULL; element != NULL; element = element->next)
  |  |  ------------------
  |  |  |  Branch (213:20): [True: 766, False: 0]
  |  |  |  Branch (213:61): [True: 5.31k, False: 766]
  |  |  ------------------
  ------------------
 3047|  5.31k|            if (ext_item->type != cJSON_Object) {
  ------------------
  |  |  103|  5.31k|#define cJSON_Object (1 << 6)
  ------------------
  |  Branch (3047:17): [True: 856, False: 4.46k]
  ------------------
 3048|    856|                continue;
 3049|    856|            }
 3050|       |
 3051|  4.46k|            VkExtensionProperties ext_prop = {0};
 3052|  4.46k|            result = loader_parse_json_string_to_existing_str(ext_item, "name", VK_MAX_EXTENSION_NAME_SIZE, ext_prop.extensionName);
 3053|  4.46k|            if (result == VK_ERROR_INITIALIZATION_FAILED) {
  ------------------
  |  Branch (3053:17): [True: 606, False: 3.85k]
  ------------------
 3054|    606|                continue;
 3055|    606|            }
 3056|  3.85k|            char *spec_version = NULL;
 3057|  3.85k|            result = loader_parse_json_string(ext_item, "spec_version", &spec_version);
 3058|  3.85k|            if (result == VK_ERROR_OUT_OF_HOST_MEMORY) goto out;
  ------------------
  |  Branch (3058:17): [True: 0, False: 3.85k]
  ------------------
 3059|  3.85k|            if (NULL != spec_version) {
  ------------------
  |  Branch (3059:17): [True: 3, False: 3.85k]
  ------------------
 3060|      3|                ext_prop.specVersion = atoi(spec_version);
 3061|      3|            }
 3062|  3.85k|            loader_instance_heap_free(inst, spec_version);
 3063|  3.85k|            bool ext_unsupported = wsi_unsupported_instance_extension(&ext_prop);
 3064|  3.85k|            if (!ext_unsupported) {
  ------------------
  |  Branch (3064:17): [True: 3.79k, False: 62]
  ------------------
 3065|  3.79k|                result = loader_add_to_ext_list(inst, &props.instance_extension_list, 1, &ext_prop);
 3066|  3.79k|                if (result == VK_ERROR_OUT_OF_HOST_MEMORY) goto out;
  ------------------
  |  Branch (3066:21): [True: 0, False: 3.79k]
  ------------------
 3067|  3.79k|            }
 3068|  3.85k|        }
 3069|    766|    }
 3070|       |
 3071|       |    // device_extensions
 3072|       |    //   array of {
 3073|       |    //     name
 3074|       |    //     spec_version
 3075|       |    //     entrypoints
 3076|       |    //   }
 3077|  13.1k|    cJSON *device_extensions = loader_cJSON_GetObjectItem(layer_node, "device_extensions");
 3078|  13.1k|    if (device_extensions != NULL && device_extensions->type == cJSON_Array) {
  ------------------
  |  |  102|  1.68k|#define cJSON_Array (1 << 5)
  ------------------
  |  Branch (3078:9): [True: 1.68k, False: 11.4k]
  |  Branch (3078:38): [True: 1.61k, False: 71]
  ------------------
 3079|  1.61k|        cJSON *ext_item = NULL;
 3080|  4.49k|        cJSON_ArrayForEach(ext_item, device_extensions) {
  ------------------
  |  |  213|  6.11k|    for (element = (array != NULL) ? (array)->child : NULL; element != NULL; element = element->next)
  |  |  ------------------
  |  |  |  Branch (213:20): [True: 1.61k, False: 0]
  |  |  |  Branch (213:61): [True: 4.49k, False: 1.61k]
  |  |  ------------------
  ------------------
 3081|  4.49k|            if (ext_item->type != cJSON_Object) {
  ------------------
  |  |  103|  4.49k|#define cJSON_Object (1 << 6)
  ------------------
  |  Branch (3081:17): [True: 347, False: 4.15k]
  ------------------
 3082|    347|                continue;
 3083|    347|            }
 3084|       |
 3085|  4.15k|            VkExtensionProperties ext_prop = {0};
 3086|  4.15k|            result = loader_parse_json_string_to_existing_str(ext_item, "name", VK_MAX_EXTENSION_NAME_SIZE, ext_prop.extensionName);
 3087|  4.15k|            if (result == VK_ERROR_INITIALIZATION_FAILED) {
  ------------------
  |  Branch (3087:17): [True: 775, False: 3.37k]
  ------------------
 3088|    775|                continue;
 3089|    775|            }
 3090|       |
 3091|  3.37k|            char *spec_version = NULL;
 3092|  3.37k|            result = loader_parse_json_string(ext_item, "spec_version", &spec_version);
 3093|  3.37k|            if (result == VK_ERROR_OUT_OF_HOST_MEMORY) goto out;
  ------------------
  |  Branch (3093:17): [True: 0, False: 3.37k]
  ------------------
 3094|  3.37k|            if (NULL != spec_version) {
  ------------------
  |  Branch (3094:17): [True: 78, False: 3.29k]
  ------------------
 3095|     78|                ext_prop.specVersion = atoi(spec_version);
 3096|     78|            }
 3097|  3.37k|            loader_instance_heap_free(inst, spec_version);
 3098|       |
 3099|  3.37k|            cJSON *entrypoints = loader_cJSON_GetObjectItem(ext_item, "entrypoints");
 3100|  3.37k|            if (entrypoints == NULL) {
  ------------------
  |  Branch (3100:17): [True: 3.12k, False: 248]
  ------------------
 3101|  3.12k|                result = loader_add_to_dev_ext_list(inst, &props.device_extension_list, &ext_prop, NULL);
 3102|  3.12k|                if (result == VK_ERROR_OUT_OF_HOST_MEMORY) goto out;
  ------------------
  |  Branch (3102:21): [True: 0, False: 3.12k]
  ------------------
 3103|  3.12k|                continue;
 3104|  3.12k|            }
 3105|       |
 3106|    248|            struct loader_string_list entrys = {0};
 3107|    248|            result = loader_parse_json_array_of_strings(inst, ext_item, "entrypoints", &entrys);
 3108|    248|            if (result == VK_ERROR_OUT_OF_HOST_MEMORY) goto out;
  ------------------
  |  Branch (3108:17): [True: 0, False: 248]
  ------------------
 3109|    248|            result = loader_add_to_dev_ext_list(inst, &props.device_extension_list, &ext_prop, &entrys);
 3110|    248|            if (result == VK_ERROR_OUT_OF_HOST_MEMORY) goto out;
  ------------------
  |  Branch (3110:17): [True: 0, False: 248]
  ------------------
 3111|    248|        }
 3112|  1.61k|    }
 3113|  13.1k|    if (is_implicit) {
  ------------------
  |  Branch (3113:9): [True: 6.66k, False: 6.46k]
  ------------------
 3114|  6.66k|        cJSON *enable_environment = loader_cJSON_GetObjectItem(layer_node, "enable_environment");
 3115|       |
 3116|       |        // enable_environment is optional
 3117|  6.66k|        if (enable_environment && enable_environment->child && enable_environment->child->type == cJSON_String &&
  ------------------
  |  |  101|  7.44k|#define cJSON_String (1 << 4)
  ------------------
  |  Branch (3117:13): [True: 1.52k, False: 5.14k]
  |  Branch (3117:35): [True: 784, False: 740]
  |  Branch (3117:64): [True: 745, False: 39]
  ------------------
 3118|    745|            enable_environment->child->string && enable_environment->child->valuestring) {
  ------------------
  |  Branch (3118:13): [True: 710, False: 35]
  |  Branch (3118:50): [True: 710, False: 0]
  ------------------
 3119|    710|            result = loader_copy_to_new_str(inst, enable_environment->child->string, &(props.enable_env_var.name));
 3120|    710|            if (VK_SUCCESS != result) goto out;
  ------------------
  |  Branch (3120:17): [True: 0, False: 710]
  ------------------
 3121|    710|            result = loader_copy_to_new_str(inst, enable_environment->child->valuestring, &(props.enable_env_var.value));
 3122|    710|            if (VK_SUCCESS != result) goto out;
  ------------------
  |  Branch (3122:17): [True: 0, False: 710]
  ------------------
 3123|    710|        }
 3124|  6.66k|    }
 3125|       |
 3126|       |    // Read in the pre-instance stuff
 3127|  13.1k|    cJSON *pre_instance = loader_cJSON_GetObjectItem(layer_node, "pre_instance_functions");
 3128|  13.1k|    if (NULL != pre_instance) {
  ------------------
  |  Branch (3128:9): [True: 439, False: 12.6k]
  ------------------
 3129|       |        // Supported versions started in 1.1.2, so anything newer
 3130|    439|        if (!loader_check_version_meets_required(loader_combine_version(1, 1, 2), version)) {
  ------------------
  |  Branch (3130:13): [True: 153, False: 286]
  ------------------
 3131|    153|            loader_log(inst, VULKAN_LOADER_ERROR_BIT, 0,
 3132|    153|                       "Found pre_instance_functions section in layer from \"%s\". This section is only valid in manifest version "
 3133|    153|                       "1.1.2 or later. The section will be ignored",
 3134|    153|                       filename);
 3135|    286|        } else if (!is_implicit) {
  ------------------
  |  Branch (3135:20): [True: 162, False: 124]
  ------------------
 3136|    162|            loader_log(inst, VULKAN_LOADER_WARN_BIT, 0,
 3137|    162|                       "Found pre_instance_functions section in explicit layer from \"%s\". This section is only valid in implicit "
 3138|    162|                       "layers. The section will be ignored",
 3139|    162|                       filename);
 3140|    162|        } else {
 3141|    124|            result = loader_parse_json_string(pre_instance, "vkEnumerateInstanceExtensionProperties",
 3142|    124|                                              &props.pre_instance_functions.enumerate_instance_extension_properties);
 3143|    124|            if (result == VK_ERROR_OUT_OF_HOST_MEMORY) goto out;
  ------------------
  |  Branch (3143:17): [True: 0, False: 124]
  ------------------
 3144|       |
 3145|    124|            result = loader_parse_json_string(pre_instance, "vkEnumerateInstanceLayerProperties",
 3146|    124|                                              &props.pre_instance_functions.enumerate_instance_layer_properties);
 3147|    124|            if (result == VK_ERROR_OUT_OF_HOST_MEMORY) goto out;
  ------------------
  |  Branch (3147:17): [True: 0, False: 124]
  ------------------
 3148|       |
 3149|    124|            result = loader_parse_json_string(pre_instance, "vkEnumerateInstanceVersion",
 3150|    124|                                              &props.pre_instance_functions.enumerate_instance_version);
 3151|    124|            if (result == VK_ERROR_OUT_OF_HOST_MEMORY) goto out;
  ------------------
  |  Branch (3151:17): [True: 0, False: 124]
  ------------------
 3152|    124|        }
 3153|    439|    }
 3154|       |
 3155|  13.1k|    if (loader_cJSON_GetObjectItem(layer_node, "app_keys")) {
  ------------------
  |  Branch (3155:9): [True: 462, False: 12.6k]
  ------------------
 3156|    462|        if (!props.is_override) {
  ------------------
  |  Branch (3156:13): [True: 261, False: 201]
  ------------------
 3157|    261|            loader_log(inst, VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_LAYER_BIT, 0,
 3158|    261|                       "Layer %s contains app_keys, but any app_keys can only be provided by the override meta layer. "
 3159|    261|                       "These will be ignored.",
 3160|    261|                       props.info.layerName);
 3161|    261|        }
 3162|       |
 3163|    462|        result = loader_parse_json_array_of_strings(inst, layer_node, "app_keys", &props.app_key_paths);
 3164|    462|        if (result == VK_ERROR_OUT_OF_HOST_MEMORY) goto out;
  ------------------
  |  Branch (3164:13): [True: 0, False: 462]
  ------------------
 3165|    462|    }
 3166|       |
 3167|  13.1k|    char *library_arch = loader_cJSON_GetStringValue(loader_cJSON_GetObjectItem(layer_node, "library_arch"));
 3168|  13.1k|    if (NULL != library_arch) {
  ------------------
  |  Branch (3168:9): [True: 125, False: 13.0k]
  ------------------
 3169|    125|        if ((strncmp(library_arch, "32", 2) == 0 && sizeof(void *) != 4) ||
  ------------------
  |  Branch (3169:14): [True: 55, False: 70]
  |  Branch (3169:53): [True: 0, Folded]
  ------------------
 3170|     70|            (strncmp(library_arch, "64", 2) == 0 && sizeof(void *) != 8)) {
  ------------------
  |  Branch (3170:14): [True: 0, False: 70]
  |  Branch (3170:53): [Folded, False: 0]
  ------------------
 3171|     55|            loader_log(inst, VULKAN_LOADER_INFO_BIT, 0,
 3172|     55|                       "The library architecture in layer %s doesn't match the current running architecture, skipping this layer",
 3173|     55|                       filename);
 3174|     55|            result = VK_ERROR_INITIALIZATION_FAILED;
 3175|     55|            goto out;
 3176|     55|        }
 3177|    125|    }
 3178|       |
 3179|  13.0k|    result = VK_SUCCESS;
 3180|       |
 3181|  28.3k|out:
 3182|       |    // Try to append the layer property
 3183|  28.3k|    if (VK_SUCCESS == result) {
  ------------------
  |  Branch (3183:9): [True: 13.0k, False: 15.2k]
  ------------------
 3184|  13.0k|        result = loader_append_layer_property(inst, layer_instance_list, &props);
 3185|  13.0k|    }
 3186|       |    // If appending fails - free all the memory allocated in it
 3187|  28.3k|    if (VK_SUCCESS != result) {
  ------------------
  |  Branch (3187:9): [True: 15.2k, False: 13.0k]
  ------------------
 3188|  15.2k|        loader_free_layer_properties(inst, &props);
 3189|  15.2k|    }
 3190|  28.3k|    return result;
 3191|  13.0k|}
is_valid_layer_json_version:
 3193|  4.81k|bool is_valid_layer_json_version(const loader_api_version *layer_json) {
 3194|       |    // Supported versions are: 1.0.0, 1.0.1, 1.1.0 - 1.1.2, and 1.2.0 - 1.2.1.
 3195|  4.81k|    if ((layer_json->major == 1 && layer_json->minor == 2 && layer_json->patch < 2) ||
  ------------------
  |  Branch (3195:10): [True: 801, False: 4.01k]
  |  Branch (3195:36): [True: 73, False: 728]
  |  Branch (3195:62): [True: 71, False: 2]
  ------------------
 3196|  4.74k|        (layer_json->major == 1 && layer_json->minor == 1 && layer_json->patch < 3) ||
  ------------------
  |  Branch (3196:10): [True: 730, False: 4.01k]
  |  Branch (3196:36): [True: 71, False: 659]
  |  Branch (3196:62): [True: 54, False: 17]
  ------------------
 3197|  4.69k|        (layer_json->major == 1 && layer_json->minor == 0 && layer_json->patch < 2)) {
  ------------------
  |  Branch (3197:10): [True: 676, False: 4.01k]
  |  Branch (3197:36): [True: 597, False: 79]
  |  Branch (3197:62): [True: 565, False: 32]
  ------------------
 3198|    690|        return true;
 3199|    690|    }
 3200|  4.12k|    return false;
 3201|  4.81k|}
loader_add_layer_properties:
 3213|  5.18k|                                     bool is_implicit, char *filename) {
 3214|       |    // The following Fields in layer manifest file that are required:
 3215|       |    //   - "file_format_version"
 3216|       |    //   - If more than one "layer" object are used, then the "layers" array is
 3217|       |    //     required
 3218|  5.18k|    VkResult result = VK_ERROR_INITIALIZATION_FAILED;
 3219|       |    // Make sure sure the top level json value is an object
 3220|  5.18k|    if (!json || json->type != cJSON_Object) {
  ------------------
  |  |  103|  5.18k|#define cJSON_Object (1 << 6)
  ------------------
  |  Branch (3220:9): [True: 0, False: 5.18k]
  |  Branch (3220:18): [True: 344, False: 4.83k]
  ------------------
 3221|    344|        goto out;
 3222|    344|    }
 3223|  4.83k|    char *file_vers = loader_cJSON_GetStringValue(loader_cJSON_GetObjectItem(json, "file_format_version"));
 3224|  4.83k|    if (NULL == file_vers) {
  ------------------
  |  Branch (3224:9): [True: 23, False: 4.81k]
  ------------------
 3225|     23|        loader_log(inst, VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_LAYER_BIT, 0,
 3226|     23|                   "loader_add_layer_properties: Manifest %s missing required field file_format_version", filename);
 3227|     23|        goto out;
 3228|     23|    }
 3229|       |
 3230|  4.81k|    loader_log(inst, VULKAN_LOADER_INFO_BIT, 0, "Found manifest file %s (file version %s)", filename, file_vers);
 3231|       |    // Get the major/minor/and patch as integers for easier comparison
 3232|  4.81k|    loader_api_version json_version = loader_make_full_version(loader_parse_version_string(file_vers));
 3233|       |
 3234|  4.81k|    if (!is_valid_layer_json_version(&json_version)) {
  ------------------
  |  Branch (3234:9): [True: 4.12k, False: 690]
  ------------------
 3235|  4.12k|        loader_log(inst, VULKAN_LOADER_INFO_BIT | VULKAN_LOADER_LAYER_BIT, 0,
 3236|  4.12k|                   "loader_add_layer_properties: %s has unknown layer manifest file version %d.%d.%d.  May cause errors.", filename,
 3237|  4.12k|                   json_version.major, json_version.minor, json_version.patch);
 3238|  4.12k|    }
 3239|       |
 3240|       |    // If "layers" is present, read in the array of layer objects
 3241|  4.81k|    cJSON *layers_node = loader_cJSON_GetObjectItem(json, "layers");
 3242|  4.81k|    if (layers_node != NULL) {
  ------------------
  |  Branch (3242:9): [True: 4.35k, False: 462]
  ------------------
 3243|       |        // Supported versions started in 1.0.1, so anything newer
 3244|  4.35k|        if (!loader_check_version_meets_required(loader_combine_version(1, 0, 1), json_version)) {
  ------------------
  |  Branch (3244:13): [True: 2.92k, False: 1.43k]
  ------------------
 3245|  2.92k|            loader_log(inst, VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_LAYER_BIT, 0,
 3246|  2.92k|                       "loader_add_layer_properties: \'layers\' tag not supported until file version 1.0.1, but %s is reporting "
 3247|  2.92k|                       "version %s",
 3248|  2.92k|                       filename, file_vers);
 3249|  2.92k|        }
 3250|  4.35k|        cJSON *layer_node = NULL;
 3251|  25.8k|        cJSON_ArrayForEach(layer_node, layers_node) {
  ------------------
  |  |  213|  30.0k|    for (element = (array != NULL) ? (array)->child : NULL; element != NULL; element = element->next)
  |  |  ------------------
  |  |  |  Branch (213:20): [True: 4.35k, False: 0]
  |  |  |  Branch (213:61): [True: 25.8k, False: 4.24k]
  |  |  ------------------
  ------------------
 3252|  25.8k|            if (layer_node->type != cJSON_Object) {
  ------------------
  |  |  103|  25.8k|#define cJSON_Object (1 << 6)
  ------------------
  |  Branch (3252:17): [True: 108, False: 25.7k]
  ------------------
 3253|    108|                loader_log(
 3254|    108|                    inst, VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_LAYER_BIT, 0,
 3255|    108|                    "loader_add_layer_properties: Array element in \"layers\" field in manifest JSON file %s is not an object.  "
 3256|    108|                    "Skipping this file",
 3257|    108|                    filename);
 3258|    108|                goto out;
 3259|    108|            }
 3260|  25.7k|            result = loader_read_layer_json(inst, layer_instance_list, layer_node, json_version, is_implicit, filename);
 3261|  25.7k|        }
 3262|  4.35k|    } else {
 3263|       |        // Otherwise, try to read in individual layers
 3264|    462|        cJSON *layer_node = loader_cJSON_GetObjectItem(json, "layer");
 3265|    462|        if (layer_node == NULL) {
  ------------------
  |  Branch (3265:13): [True: 266, False: 196]
  ------------------
 3266|       |            // Don't warn if this happens to be an ICD manifest
 3267|    266|            if (loader_cJSON_GetObjectItem(json, "ICD") == NULL) {
  ------------------
  |  Branch (3267:17): [True: 264, False: 2]
  ------------------
 3268|    264|                loader_log(
 3269|    264|                    inst, VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_LAYER_BIT, 0,
 3270|    264|                    "loader_add_layer_properties: Can not find 'layer' object in manifest JSON file %s.  Skipping this file.",
 3271|    264|                    filename);
 3272|    264|            }
 3273|    266|            goto out;
 3274|    266|        }
 3275|       |        // Loop through all "layer" objects in the file to get a count of them
 3276|       |        // first.
 3277|    196|        uint16_t layer_count = 0;
 3278|    196|        cJSON *tempNode = layer_node;
 3279|  2.64k|        do {
 3280|  2.64k|            tempNode = tempNode->next;
 3281|  2.64k|            layer_count++;
 3282|  2.64k|        } while (tempNode != NULL);
  ------------------
  |  Branch (3282:18): [True: 2.44k, False: 196]
  ------------------
 3283|       |
 3284|       |        // Throw a warning if we encounter multiple "layer" objects in file
 3285|       |        // versions newer than 1.0.0.  Having multiple objects with the same
 3286|       |        // name at the same level is actually a JSON standard violation.
 3287|    196|        if (layer_count > 1 && loader_check_version_meets_required(loader_combine_version(1, 0, 1), json_version)) {
  ------------------
  |  Branch (3287:13): [True: 183, False: 13]
  |  Branch (3287:32): [True: 17, False: 166]
  ------------------
 3288|     17|            loader_log(inst, VULKAN_LOADER_ERROR_BIT | VULKAN_LOADER_LAYER_BIT, 0,
 3289|     17|                       "loader_add_layer_properties: Multiple 'layer' nodes are deprecated starting in file version \"1.0.1\".  "
 3290|     17|                       "Please use 'layers' : [] array instead in %s.",
 3291|     17|                       filename);
 3292|    179|        } else {
 3293|  2.60k|            do {
 3294|  2.60k|                result = loader_read_layer_json(inst, layer_instance_list, layer_node, json_version, is_implicit, filename);
 3295|  2.60k|                layer_node = layer_node->next;
 3296|  2.60k|            } while (layer_node != NULL);
  ------------------
  |  Branch (3296:22): [True: 2.42k, False: 179]
  ------------------
 3297|    179|        }
 3298|    196|    }
 3299|       |
 3300|  5.18k|out:
 3301|       |
 3302|  5.18k|    return result;
 3303|  4.81k|}
copy_data_file_info:
 3306|  79.7k|                             size_t relative_path_size, struct loader_string_list *search_paths) {
 3307|  79.7k|    if (NULL != cur_path) {
  ------------------
  |  Branch (3307:9): [True: 79.7k, False: 0]
  ------------------
 3308|  79.7k|        uint32_t start = 0;
 3309|  79.7k|        uint32_t stop = 0;
 3310|       |
 3311|   171k|        while (cur_path[start] != '\0') {
  ------------------
  |  Branch (3311:16): [True: 91.3k, False: 79.7k]
  ------------------
 3312|   105k|            while (cur_path[start] == PATH_SEPARATOR && cur_path[start] != '\0') {
  ------------------
  |  |  150|   211k|#define PATH_SEPARATOR ':'
  ------------------
  |  Branch (3312:20): [True: 14.3k, False: 91.3k]
  |  Branch (3312:57): [True: 14.3k, False: 0]
  ------------------
 3313|  14.3k|                start++;
 3314|  14.3k|            }
 3315|  91.3k|            stop = start;
 3316|  4.35M|            while (cur_path[stop] != PATH_SEPARATOR && cur_path[stop] != '\0') {
  ------------------
  |  |  150|  8.71M|#define PATH_SEPARATOR ':'
  ------------------
  |  Branch (3316:20): [True: 4.34M, False: 12.0k]
  |  Branch (3316:56): [True: 4.26M, False: 79.3k]
  ------------------
 3317|  4.26M|                stop++;
 3318|  4.26M|            }
 3319|  91.3k|            const size_t s = stop - start;
 3320|  91.3k|            if (s) {
  ------------------
  |  Branch (3320:17): [True: 91.2k, False: 187]
  ------------------
 3321|       |                // space enough for base path, relative path, path separator, and null terminator
 3322|  91.2k|                size_t new_str_len = s + relative_path_size + 2;
 3323|       |
 3324|  91.2k|                char *new_str = loader_instance_heap_calloc(inst, new_str_len, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
 3325|  91.2k|                if (NULL == new_str) {
  ------------------
  |  Branch (3325:21): [True: 0, False: 91.2k]
  ------------------
 3326|      0|                    return VK_ERROR_OUT_OF_HOST_MEMORY;
 3327|      0|                }
 3328|  91.2k|                memcpy(new_str, &cur_path[start], s);
 3329|  91.2k|                new_str[s] = '\0';
 3330|       |
 3331|       |                // If this is a specific JSON file, just add it and don't add any
 3332|       |                // relative path or directory symbol to it.
 3333|  91.2k|                if (!is_json(new_str, s)) {
  ------------------
  |  Branch (3333:21): [True: 89.3k, False: 1.90k]
  ------------------
 3334|       |                    // Add the relative directory if present.
 3335|  89.3k|                    if (relative_path_size > 0) {
  ------------------
  |  Branch (3335:25): [True: 71.7k, False: 17.5k]
  ------------------
 3336|  71.7k|                        char *rel_start = new_str + s;
 3337|       |
 3338|       |                        // If last symbol written was not a directory symbol, add it.
 3339|  71.7k|                        if (*(rel_start - 1) != DIRECTORY_SYMBOL) {
  ------------------
  |  |  151|  71.7k|#define DIRECTORY_SYMBOL '/'
  ------------------
  |  Branch (3339:29): [True: 71.7k, False: 0]
  ------------------
 3340|  71.7k|                            *rel_start++ = DIRECTORY_SYMBOL;
  ------------------
  |  |  151|  71.7k|#define DIRECTORY_SYMBOL '/'
  ------------------
 3341|  71.7k|                        }
 3342|  71.7k|                        memcpy(rel_start, relative_path, relative_path_size);
 3343|  71.7k|                        rel_start[relative_path_size] = '\0';
 3344|  71.7k|                    }
 3345|  89.3k|                }
 3346|       |
 3347|  91.2k|                VkResult res = append_str_to_string_list_if_unique(inst, search_paths, new_str);
 3348|  91.2k|                if (VK_SUCCESS != res) {
  ------------------
  |  Branch (3348:21): [True: 0, False: 91.2k]
  ------------------
 3349|      0|                    return res;
 3350|      0|                }
 3351|  91.2k|                start = stop;
 3352|  91.2k|            }
 3353|  91.3k|        }
 3354|  79.7k|    }
 3355|  79.7k|    return VK_SUCCESS;
 3356|  79.7k|}
add_if_manifest_file:
 3359|  22.7k|VkResult add_if_manifest_file(const struct loader_instance *inst, const char *file_name, struct loader_string_list *out_files) {
 3360|  22.7k|    assert(NULL != file_name && "add_if_manifest_file: Received NULL pointer for file_name");
 3361|  22.7k|    assert(NULL != out_files && "add_if_manifest_file: Received NULL pointer for out_files");
 3362|       |
 3363|       |    // Look for files ending with ".json" suffix
 3364|  22.7k|    size_t name_len = strlen(file_name);
 3365|  22.7k|    if (!is_json(file_name, name_len)) {
  ------------------
  |  Branch (3365:9): [True: 13.4k, False: 9.24k]
  ------------------
 3366|       |        // Use incomplete to indicate invalid name, but to keep going.
 3367|  13.4k|        return VK_INCOMPLETE;
 3368|  13.4k|    }
 3369|       |
 3370|  9.24k|    return copy_str_to_string_list(inst, out_files, file_name, name_len);
 3371|  22.7k|}
add_data_files:
 3391|  10.5k|                        struct loader_string_list *out_files) {
 3392|  10.5k|    VkResult vk_result = VK_SUCCESS;
 3393|  10.5k|    char full_path[2048];
 3394|  10.5k|#if !defined(_WIN32)
 3395|  10.5k|    char temp_path[2048];
 3396|  10.5k|#endif
 3397|       |
 3398|  86.4k|    for (size_t i = 0; i < search_paths->count; i++) {
  ------------------
  |  Branch (3398:24): [True: 75.9k, False: 10.5k]
  ------------------
 3399|       |        // Now, parse the paths
 3400|  75.9k|        char *next_file = search_paths->list[i];
 3401|   151k|        while (NULL != next_file && *next_file != '\0') {
  ------------------
  |  Branch (3401:16): [True: 151k, False: 0]
  |  Branch (3401:37): [True: 75.9k, False: 75.9k]
  ------------------
 3402|  75.9k|            char *name = NULL;
 3403|  75.9k|            char *cur_file = next_file;
 3404|  75.9k|            next_file = loader_get_next_path(cur_file);
 3405|       |
 3406|       |            // Is this a JSON file, then try to open it.
 3407|  75.9k|            size_t len = strlen(cur_file);
 3408|  75.9k|            if (is_json(cur_file, len)) {
  ------------------
  |  Branch (3408:17): [True: 818, False: 75.0k]
  ------------------
 3409|       |#if defined(_WIN32)
 3410|       |                name = cur_file;
 3411|       |#elif COMMON_UNIX_PLATFORMS
 3412|       |                // Only Linux has relative paths, make a copy of location so it isn't modified
 3413|    818|                size_t str_len;
 3414|    818|                if (NULL != next_file) {
  ------------------
  |  Branch (3414:21): [True: 818, False: 0]
  ------------------
 3415|    818|                    str_len = next_file - cur_file + 1;
 3416|    818|                } else {
 3417|      0|                    str_len = strlen(cur_file) + 1;
 3418|      0|                }
 3419|    818|                if (str_len > sizeof(temp_path)) {
  ------------------
  |  Branch (3419:21): [True: 19, False: 799]
  ------------------
 3420|     19|                    loader_log(inst, VULKAN_LOADER_DEBUG_BIT, 0, "add_data_files: Path to %s too long", cur_file);
 3421|     19|                    continue;
 3422|     19|                }
 3423|    799|                strncpy(temp_path, cur_file, str_len);
 3424|    799|                name = temp_path;
 3425|       |#else
 3426|       |#warning add_data_files must define relative path copy for this platform
 3427|       |#endif
 3428|    799|                loader_get_fullpath(cur_file, name, sizeof(full_path), full_path);
 3429|    799|                name = full_path;
 3430|       |
 3431|    799|                VkResult local_res;
 3432|    799|                local_res = add_if_manifest_file(inst, name, out_files);
 3433|       |
 3434|       |                // Incomplete means this was not a valid data file.
 3435|    799|                if (local_res == VK_INCOMPLETE) {
  ------------------
  |  Branch (3435:21): [True: 0, False: 799]
  ------------------
 3436|      0|                    continue;
 3437|    799|                } else if (local_res != VK_SUCCESS) {
  ------------------
  |  Branch (3437:28): [True: 0, False: 799]
  ------------------
 3438|      0|                    vk_result = local_res;
 3439|      0|                    break;
 3440|      0|                }
 3441|  75.0k|            } else {  // Otherwise, treat it as a directory
 3442|  75.0k|                DIR *dir_stream = loader_opendir(inst, cur_file);
 3443|  75.0k|                if (NULL == dir_stream) {
  ------------------
  |  Branch (3443:21): [True: 69.3k, False: 5.71k]
  ------------------
 3444|  69.3k|                    continue;
 3445|  69.3k|                }
 3446|  27.6k|                while (1) {
  ------------------
  |  Branch (3446:24): [True: 27.6k, Folded]
  ------------------
 3447|  27.6k|                    errno = 0;
 3448|  27.6k|                    struct dirent *dir_entry = readdir(dir_stream);
 3449|  27.6k|#if !defined(WIN32)  // Windows doesn't use readdir, don't check errors on functions which aren't called
 3450|  27.6k|                    if (errno != 0) {
  ------------------
  |  Branch (3450:25): [True: 0, False: 27.6k]
  ------------------
 3451|      0|                        loader_log(inst, VULKAN_LOADER_ERROR_BIT, 0, "readdir failed with %d: %s", errno, strerror(errno));
 3452|      0|                        break;
 3453|      0|                    }
 3454|  27.6k|#endif
 3455|  27.6k|                    if (NULL == dir_entry) {
  ------------------
  |  Branch (3455:25): [True: 5.71k, False: 21.9k]
  ------------------
 3456|  5.71k|                        break;
 3457|  5.71k|                    }
 3458|       |
 3459|  21.9k|                    name = &(dir_entry->d_name[0]);
 3460|  21.9k|                    loader_get_fullpath(name, cur_file, sizeof(full_path), full_path);
 3461|  21.9k|                    name = full_path;
 3462|       |
 3463|  21.9k|                    VkResult local_res;
 3464|  21.9k|                    local_res = add_if_manifest_file(inst, name, out_files);
 3465|       |
 3466|       |                    // Incomplete means this was not a valid data file.
 3467|  21.9k|                    if (local_res == VK_INCOMPLETE) {
  ------------------
  |  Branch (3467:25): [True: 13.4k, False: 8.44k]
  ------------------
 3468|  13.4k|                        continue;
 3469|  13.4k|                    } else if (local_res != VK_SUCCESS) {
  ------------------
  |  Branch (3469:32): [True: 0, False: 8.44k]
  ------------------
 3470|      0|                        vk_result = local_res;
 3471|      0|                        break;
 3472|      0|                    }
 3473|  21.9k|                }
 3474|  5.71k|                loader_closedir(inst, dir_stream);
 3475|  5.71k|                if (vk_result != VK_SUCCESS) {
  ------------------
  |  Branch (3475:21): [True: 0, False: 5.71k]
  ------------------
 3476|      0|                    goto out;
 3477|      0|                }
 3478|  5.71k|            }
 3479|  75.9k|        }
 3480|  75.9k|    }
 3481|       |
 3482|  10.5k|out:
 3483|       |
 3484|  10.5k|    return vk_result;
 3485|  10.5k|}
read_data_files_in_search_paths:
 3491|  10.5k|                                         struct loader_string_list *out_files) {
 3492|  10.5k|    VkResult vk_result = VK_SUCCESS;
 3493|  10.5k|    char *override_env = NULL;
 3494|  10.5k|    char *additional_env = NULL;
 3495|  10.5k|    struct loader_string_list search_paths = {0};
 3496|       |
 3497|  10.5k|#if COMMON_UNIX_PLATFORMS
 3498|  10.5k|    const char *relative_location = NULL;  // Only used on unix platforms
 3499|  10.5k|    size_t rel_size = 0;                   // unused in windows, dont declare so no compiler warnings are generated
 3500|  10.5k|#endif
 3501|       |
 3502|       |#if defined(__APPLE__)
 3503|       |    char *bundle_path = NULL;
 3504|       |#endif
 3505|       |
 3506|       |#if defined(_WIN32)
 3507|       |    char *package_path = NULL;
 3508|       |#elif COMMON_UNIX_PLATFORMS
 3509|       |    // Determine how much space is needed to generate the full search path
 3510|       |    // for the current manifest files.
 3511|  10.5k|    char *xdg_config_home = loader_secure_getenv("XDG_CONFIG_HOME", inst);
 3512|  10.5k|    char *xdg_config_dirs = loader_secure_getenv("XDG_CONFIG_DIRS", inst);
 3513|       |
 3514|  10.5k|#if !defined(__Fuchsia__) && !defined(__QNX__)
 3515|  10.5k|    if (NULL == xdg_config_dirs || '\0' == xdg_config_dirs[0]) {
  ------------------
  |  Branch (3515:9): [True: 10.5k, False: 0]
  |  Branch (3515:36): [True: 0, False: 0]
  ------------------
 3516|  10.5k|        xdg_config_dirs = FALLBACK_CONFIG_DIRS;
 3517|  10.5k|    }
 3518|  10.5k|#endif
 3519|       |
 3520|  10.5k|    char *xdg_data_home = loader_secure_getenv("XDG_DATA_HOME", inst);
 3521|  10.5k|    char *xdg_data_dirs = loader_secure_getenv("XDG_DATA_DIRS", inst);
 3522|       |
 3523|  10.5k|#if !defined(__Fuchsia__) && !defined(__QNX__)
 3524|  10.5k|    if (NULL == xdg_data_dirs || '\0' == xdg_data_dirs[0]) {
  ------------------
  |  Branch (3524:9): [True: 10.5k, False: 0]
  |  Branch (3524:34): [True: 0, False: 0]
  ------------------
 3525|  10.5k|        xdg_data_dirs = FALLBACK_DATA_DIRS;
 3526|  10.5k|    }
 3527|  10.5k|#endif
 3528|       |
 3529|  10.5k|    char *home = NULL;
 3530|  10.5k|    char *default_data_home = NULL;
 3531|  10.5k|    char *default_config_home = NULL;
 3532|  10.5k|    char *home_data_dir = NULL;
 3533|  10.5k|    char *home_config_dir = NULL;
 3534|       |
 3535|       |    // Only use HOME if XDG_DATA_HOME is not present on the system
 3536|  10.5k|    home = loader_secure_getenv("HOME", inst);
 3537|  10.5k|    if (home != NULL) {
  ------------------
  |  Branch (3537:9): [True: 10.5k, False: 0]
  ------------------
 3538|  10.5k|        if (NULL == xdg_config_home || '\0' == xdg_config_home[0]) {
  ------------------
  |  Branch (3538:13): [True: 10.5k, False: 0]
  |  Branch (3538:40): [True: 0, False: 0]
  ------------------
 3539|  10.5k|            const char config_suffix[] = "/.config";
 3540|  10.5k|            size_t default_config_home_len = strlen(home) + sizeof(config_suffix) + 1;
 3541|  10.5k|            default_config_home = loader_instance_heap_calloc(inst, default_config_home_len, VK_SYSTEM_ALLOCATION_SCOPE_COMMAND);
 3542|  10.5k|            if (default_config_home == NULL) {
  ------------------
  |  Branch (3542:17): [True: 0, False: 10.5k]
  ------------------
 3543|      0|                vk_result = VK_ERROR_OUT_OF_HOST_MEMORY;
 3544|      0|                goto out;
 3545|      0|            }
 3546|  10.5k|            strncpy(default_config_home, home, default_config_home_len);
 3547|  10.5k|            strncat(default_config_home, config_suffix, default_config_home_len);
 3548|  10.5k|        }
 3549|  10.5k|        if (NULL == xdg_data_home || '\0' == xdg_data_home[0]) {
  ------------------
  |  Branch (3549:13): [True: 10.5k, False: 0]
  |  Branch (3549:38): [True: 0, False: 0]
  ------------------
 3550|  10.5k|            const char data_suffix[] = "/.local/share";
 3551|  10.5k|            size_t default_data_home_len = strlen(home) + sizeof(data_suffix) + 1;
 3552|  10.5k|            default_data_home = loader_instance_heap_calloc(inst, default_data_home_len, VK_SYSTEM_ALLOCATION_SCOPE_COMMAND);
 3553|  10.5k|            if (default_data_home == NULL) {
  ------------------
  |  Branch (3553:17): [True: 0, False: 10.5k]
  ------------------
 3554|      0|                vk_result = VK_ERROR_OUT_OF_HOST_MEMORY;
 3555|      0|                goto out;
 3556|      0|            }
 3557|  10.5k|            strncpy(default_data_home, home, default_data_home_len);
 3558|  10.5k|            strncat(default_data_home, data_suffix, default_data_home_len);
 3559|  10.5k|        }
 3560|  10.5k|    }
 3561|       |
 3562|  10.5k|    if (NULL != default_config_home) {
  ------------------
  |  Branch (3562:9): [True: 10.5k, False: 0]
  ------------------
 3563|  10.5k|        home_config_dir = default_config_home;
 3564|  10.5k|    } else {
 3565|      0|        home_config_dir = xdg_config_home;
 3566|      0|    }
 3567|  10.5k|    if (NULL != default_data_home) {
  ------------------
  |  Branch (3567:9): [True: 10.5k, False: 0]
  ------------------
 3568|  10.5k|        home_data_dir = default_data_home;
 3569|  10.5k|    } else {
 3570|      0|        home_data_dir = xdg_data_home;
 3571|      0|    }
 3572|       |#else
 3573|       |#warning read_data_files_in_search_paths unsupported platform
 3574|       |#endif
 3575|       |
 3576|  10.5k|    switch (manifest_type) {
 3577|      4|        case LOADER_DATA_FILE_MANIFEST_DRIVER:
  ------------------
  |  Branch (3577:9): [True: 4, False: 10.4k]
  ------------------
 3578|      4|            if (loader_settings_should_use_driver_environment_variables(inst)) {
  ------------------
  |  Branch (3578:17): [True: 4, False: 0]
  ------------------
 3579|      4|                override_env = loader_secure_getenv(VK_DRIVER_FILES_ENV_VAR, inst);
  ------------------
  |  |  113|      4|#define VK_DRIVER_FILES_ENV_VAR "VK_DRIVER_FILES"
  ------------------
 3580|      4|                if (NULL == override_env) {
  ------------------
  |  Branch (3580:21): [True: 4, False: 0]
  ------------------
 3581|       |                    // Not there, so fall back to the old name
 3582|      4|                    override_env = loader_secure_getenv(VK_ICD_FILENAMES_ENV_VAR, inst);
  ------------------
  |  |  112|      4|#define VK_ICD_FILENAMES_ENV_VAR "VK_ICD_FILENAMES"  // Deprecated in v1.3.207 loader
  ------------------
 3583|      4|                }
 3584|      4|                additional_env = loader_secure_getenv(VK_ADDITIONAL_DRIVER_FILES_ENV_VAR, inst);
  ------------------
  |  |  116|      4|#define VK_ADDITIONAL_DRIVER_FILES_ENV_VAR "VK_ADD_DRIVER_FILES"
  ------------------
 3585|      4|            }
 3586|      4|#if COMMON_UNIX_PLATFORMS
 3587|      4|            relative_location = VK_DRIVERS_INFO_RELATIVE_DIR;
  ------------------
  |  |  161|      4|#define VK_DRIVERS_INFO_RELATIVE_DIR VULKAN_DIR VULKAN_ICDCONF_DIR
  |  |  ------------------
  |  |  |  |  153|      4|#define VULKAN_DIR "vulkan/"
  |  |  ------------------
  |  |               #define VK_DRIVERS_INFO_RELATIVE_DIR VULKAN_DIR VULKAN_ICDCONF_DIR
  |  |  ------------------
  |  |  |  |  154|      4|#define VULKAN_ICDCONF_DIR "icd.d"
  |  |  ------------------
  ------------------
 3588|      4|#endif
 3589|       |#if defined(_WIN32)
 3590|       |            package_path = windows_get_app_package_manifest_path(inst);
 3591|       |#endif
 3592|      4|            break;
 3593|  5.24k|        case LOADER_DATA_FILE_MANIFEST_IMPLICIT_LAYER:
  ------------------
  |  Branch (3593:9): [True: 5.24k, False: 5.25k]
  ------------------
 3594|  5.24k|            override_env = loader_secure_getenv(VK_IMPLICIT_LAYER_PATH_ENV_VAR, inst);
  ------------------
  |  |  130|  5.24k|#define VK_IMPLICIT_LAYER_PATH_ENV_VAR "VK_IMPLICIT_LAYER_PATH"
  ------------------
 3595|  5.24k|            additional_env = loader_secure_getenv(VK_ADDITIONAL_IMPLICIT_LAYER_PATH_ENV_VAR, inst);
  ------------------
  |  |  131|  5.24k|#define VK_ADDITIONAL_IMPLICIT_LAYER_PATH_ENV_VAR "VK_ADD_IMPLICIT_LAYER_PATH"
  ------------------
 3596|  5.24k|#if COMMON_UNIX_PLATFORMS
 3597|  5.24k|            relative_location = VK_ILAYERS_INFO_RELATIVE_DIR;
  ------------------
  |  |  164|  5.24k|#define VK_ILAYERS_INFO_RELATIVE_DIR VULKAN_DIR VULKAN_ILAYERCONF_DIR
  |  |  ------------------
  |  |  |  |  153|  5.24k|#define VULKAN_DIR "vulkan/"
  |  |  ------------------
  |  |               #define VK_ILAYERS_INFO_RELATIVE_DIR VULKAN_DIR VULKAN_ILAYERCONF_DIR
  |  |  ------------------
  |  |  |  |  158|  5.24k|#define VULKAN_ILAYERCONF_DIR "implicit_layer.d"
  |  |  ------------------
  ------------------
 3598|  5.24k|#endif
 3599|       |#if defined(_WIN32)
 3600|       |            package_path = windows_get_app_package_manifest_path(inst);
 3601|       |#endif
 3602|  5.24k|            break;
 3603|  5.24k|        case LOADER_DATA_FILE_MANIFEST_EXPLICIT_LAYER:
  ------------------
  |  Branch (3603:9): [True: 5.24k, False: 5.25k]
  ------------------
 3604|  5.24k|            override_env = loader_secure_getenv(VK_EXPLICIT_LAYER_PATH_ENV_VAR, inst);
  ------------------
  |  |  114|  5.24k|#define VK_EXPLICIT_LAYER_PATH_ENV_VAR "VK_LAYER_PATH"
  ------------------
 3605|  5.24k|            additional_env = loader_secure_getenv(VK_ADDITIONAL_EXPLICIT_LAYER_PATH_ENV_VAR, inst);
  ------------------
  |  |  117|  5.24k|#define VK_ADDITIONAL_EXPLICIT_LAYER_PATH_ENV_VAR "VK_ADD_LAYER_PATH"
  ------------------
 3606|  5.24k|#if COMMON_UNIX_PLATFORMS
 3607|  5.24k|            relative_location = VK_ELAYERS_INFO_RELATIVE_DIR;
  ------------------
  |  |  163|  5.24k|#define VK_ELAYERS_INFO_RELATIVE_DIR VULKAN_DIR VULKAN_ELAYERCONF_DIR
  |  |  ------------------
  |  |  |  |  153|  5.24k|#define VULKAN_DIR "vulkan/"
  |  |  ------------------
  |  |               #define VK_ELAYERS_INFO_RELATIVE_DIR VULKAN_DIR VULKAN_ELAYERCONF_DIR
  |  |  ------------------
  |  |  |  |  157|  5.24k|#define VULKAN_ELAYERCONF_DIR "explicit_layer.d"
  |  |  ------------------
  ------------------
 3608|  5.24k|#endif
 3609|  5.24k|            break;
 3610|      0|        default:
  ------------------
  |  Branch (3610:9): [True: 0, False: 10.5k]
  ------------------
 3611|      0|            assert(false && "Shouldn't get here!");
 3612|      0|            break;
 3613|  10.5k|    }
 3614|       |
 3615|       |    // Log a message when VK_LAYER_PATH is set but the override layer paths take priority
 3616|  10.5k|    if (manifest_type == LOADER_DATA_FILE_MANIFEST_EXPLICIT_LAYER &&
  ------------------
  |  Branch (3616:9): [True: 5.24k, False: 5.25k]
  ------------------
 3617|  5.24k|        (NULL != override_env && NULL != path_overrides && path_overrides->count > 0)) {
  ------------------
  |  Branch (3617:10): [True: 0, False: 5.24k]
  |  Branch (3617:34): [True: 0, False: 0]
  |  Branch (3617:60): [True: 0, False: 0]
  ------------------
 3618|      0|        loader_log(inst, VULKAN_LOADER_INFO_BIT | VULKAN_LOADER_LAYER_BIT, 0,
 3619|      0|                   "Ignoring VK_LAYER_PATH. The Override layer is active and has override paths set, which takes priority. "
 3620|      0|                   "VK_LAYER_PATH is set to %s",
 3621|      0|                   override_env);
 3622|      0|    }
 3623|       |
 3624|       |    // Add the remaining paths to the list
 3625|  10.5k|    if (NULL != path_overrides && path_overrides->count > 0) {
  ------------------
  |  Branch (3625:9): [True: 5.24k, False: 5.25k]
  |  Branch (3625:35): [True: 243, False: 5.00k]
  ------------------
 3626|  4.36k|        for (size_t i = 0; i < path_overrides->count; i++) {
  ------------------
  |  Branch (3626:28): [True: 4.11k, False: 243]
  ------------------
 3627|  4.11k|            if (NULL != path_overrides->list[i]) {
  ------------------
  |  Branch (3627:17): [True: 4.11k, False: 0]
  ------------------
 3628|  4.11k|                if (manifest_type == LOADER_DATA_FILE_MANIFEST_EXPLICIT_LAYER) {
  ------------------
  |  Branch (3628:21): [True: 4.11k, False: 0]
  ------------------
 3629|  4.11k|                    loader_log(inst, VULKAN_LOADER_INFO_BIT | VULKAN_LOADER_LAYER_BIT, 0, "%s", path_overrides->list[i]);
 3630|  4.11k|                }
 3631|  4.11k|                vk_result = copy_data_file_info(inst, path_overrides->list[i], NULL, 0, &search_paths);
 3632|  4.11k|                if (vk_result == VK_ERROR_OUT_OF_HOST_MEMORY) {
  ------------------
  |  Branch (3632:21): [True: 0, False: 4.11k]
  ------------------
 3633|      0|                    goto out;
 3634|      0|                }
 3635|  4.11k|            }
 3636|  4.11k|        }
 3637|  10.2k|    } else if (override_env != NULL) {
  ------------------
  |  Branch (3637:16): [True: 0, False: 10.2k]
  ------------------
 3638|      0|        vk_result = copy_data_file_info(inst, override_env, NULL, 0, &search_paths);
 3639|      0|        if (vk_result == VK_ERROR_OUT_OF_HOST_MEMORY) {
  ------------------
  |  Branch (3639:13): [True: 0, False: 0]
  ------------------
 3640|      0|            goto out;
 3641|      0|        }
 3642|  10.2k|    } else {
 3643|       |        // Add any additional search paths defined in the additive environment variable
 3644|  10.2k|        if (NULL != additional_env) {
  ------------------
  |  Branch (3644:13): [True: 0, False: 10.2k]
  ------------------
 3645|      0|            vk_result = copy_data_file_info(inst, additional_env, NULL, 0, &search_paths);
 3646|      0|            if (vk_result == VK_ERROR_OUT_OF_HOST_MEMORY) {
  ------------------
  |  Branch (3646:17): [True: 0, False: 0]
  ------------------
 3647|      0|                goto out;
 3648|      0|            }
 3649|      0|        }
 3650|       |
 3651|       |#if defined(_WIN32)
 3652|       |        if (NULL != package_path) {
 3653|       |            vk_result = copy_data_file_info(inst, package_path, NULL, 0, &search_paths);
 3654|       |            if (vk_result == VK_ERROR_OUT_OF_HOST_MEMORY) {
 3655|       |                goto out;
 3656|       |            }
 3657|       |        }
 3658|       |#elif COMMON_UNIX_PLATFORMS
 3659|  10.2k|        rel_size = strlen(relative_location);
 3660|  10.2k|        if (rel_size > 0) {
  ------------------
  |  Branch (3660:13): [True: 10.2k, False: 0]
  ------------------
 3661|       |#if defined(__APPLE__)
 3662|       |            // Add the bundle's Resources dir to the beginning of the search path.
 3663|       |            // Looks for manifests in the bundle first, before any system directories.
 3664|       |            // This also appears to work unmodified for iOS, it finds the app bundle on the devices
 3665|       |            // file system. (RSW)
 3666|       |            CFBundleRef main_bundle = CFBundleGetMainBundle();
 3667|       |            if (NULL != main_bundle) {
 3668|       |                CFURLRef ref = CFBundleCopyResourcesDirectoryURL(main_bundle);
 3669|       |                if (NULL != ref) {
 3670|       |                    // Allocate large scratch buffer to hold the bundles path, the relative location inside the bundle, plus a path
 3671|       |                    // separator and null terminator. Since we are using a while loop, initialize length with half the intended size
 3672|       |                    size_t bundle_path_len = (MAXPATHLEN + rel_size + 2) / 2;
 3673|       |                    bool bundle_query_success = false;
 3674|       |                    uint32_t retry_count = 0;
 3675|       |                    while (!bundle_query_success && retry_count < 4) {
 3676|       |                        void *new_bundle_path = loader_instance_heap_realloc(
 3677|       |                            inst, bundle_path, bundle_path_len, bundle_path_len * 2, VK_SYSTEM_ALLOCATION_SCOPE_COMMAND);
 3678|       |                        if (NULL == new_bundle_path) {
 3679|       |                            loader_log(inst, VULKAN_LOADER_ERROR_BIT, 0,
 3680|       |                                       "read_data_files_in_search_paths: Failed to allocate space for bundle path of length %d",
 3681|       |                                       (uint32_t)bundle_path_len * 2);
 3682|       |                            vk_result = VK_ERROR_OUT_OF_HOST_MEMORY;
 3683|       |                            goto out;
 3684|       |                        }
 3685|       |                        bundle_path = new_bundle_path;
 3686|       |                        bundle_path_len = bundle_path_len * 2;
 3687|       |                        memset(bundle_path, 0, bundle_path_len);
 3688|       |                        bundle_query_success = CFURLGetFileSystemRepresentation(ref, TRUE, (UInt8 *)bundle_path, bundle_path_len);
 3689|       |                        retry_count++;
 3690|       |                    }
 3691|       |
 3692|       |                    if (bundle_query_success) {
 3693|       |                        size_t cur_bundle_len = strlen(bundle_path);
 3694|       |
 3695|       |                        if (cur_bundle_len + rel_size + 2 > bundle_path_len) {
 3696|       |                            loader_log(inst, VULKAN_LOADER_ERROR_BIT, 0,
 3697|       |                                       "read_data_files_in_search_paths: bundle_path %s of size %d does not have enough space to "
 3698|       |                                       "append relative_path",
 3699|       |                                       bundle_path, (uint32_t)bundle_path_len);
 3700|       |                            vk_result = VK_ERROR_INITIALIZATION_FAILED;
 3701|       |                            goto out;
 3702|       |                        }
 3703|       |                        bundle_path[cur_bundle_len] = DIRECTORY_SYMBOL;
 3704|       |                        cur_bundle_len++;
 3705|       |                        memcpy(bundle_path + cur_bundle_len, relative_location, rel_size);
 3706|       |                        cur_bundle_len += rel_size;
 3707|       |                        bundle_path[cur_bundle_len] = '\0';
 3708|       |
 3709|       |                        vk_result = copy_data_file_info(inst, bundle_path, NULL, 0, &search_paths);
 3710|       |                        if (vk_result == VK_ERROR_OUT_OF_HOST_MEMORY) {
 3711|       |                            goto out;
 3712|       |                        }
 3713|       |                    }
 3714|       |                    CFRelease(ref);
 3715|       |                }
 3716|       |            }
 3717|       |#endif  // __APPLE__
 3718|       |
 3719|       |            // Only add the home folders if not NULL
 3720|  10.2k|            if (NULL != home_config_dir) {
  ------------------
  |  Branch (3720:17): [True: 10.2k, False: 0]
  ------------------
 3721|  10.2k|                vk_result = copy_data_file_info(inst, home_config_dir, relative_location, rel_size, &search_paths);
 3722|  10.2k|                if (VK_SUCCESS != vk_result) {
  ------------------
  |  Branch (3722:21): [True: 0, False: 10.2k]
  ------------------
 3723|      0|                    goto out;
 3724|      0|                }
 3725|  10.2k|            }
 3726|  10.2k|            vk_result = copy_data_file_info(inst, xdg_config_dirs, relative_location, rel_size, &search_paths);
 3727|  10.2k|            if (VK_SUCCESS != vk_result) {
  ------------------
  |  Branch (3727:17): [True: 0, False: 10.2k]
  ------------------
 3728|      0|                goto out;
 3729|      0|            }
 3730|  10.2k|            vk_result = copy_data_file_info(inst, SYSCONFDIR, relative_location, rel_size, &search_paths);
 3731|  10.2k|            if (VK_SUCCESS != vk_result) {
  ------------------
  |  Branch (3731:17): [True: 0, False: 10.2k]
  ------------------
 3732|      0|                goto out;
 3733|      0|            }
 3734|  10.2k|#if defined(EXTRASYSCONFDIR)
 3735|  10.2k|            vk_result = copy_data_file_info(inst, EXTRASYSCONFDIR, relative_location, rel_size, &search_paths);
 3736|  10.2k|            if (VK_SUCCESS != vk_result) {
  ------------------
  |  Branch (3736:17): [True: 0, False: 10.2k]
  ------------------
 3737|      0|                goto out;
 3738|      0|            }
 3739|  10.2k|#endif
 3740|       |
 3741|       |            // Only add the home folders if not NULL
 3742|  10.2k|            if (NULL != home_data_dir) {
  ------------------
  |  Branch (3742:17): [True: 10.2k, False: 0]
  ------------------
 3743|  10.2k|                vk_result = copy_data_file_info(inst, home_data_dir, relative_location, rel_size, &search_paths);
 3744|  10.2k|                if (VK_SUCCESS != vk_result) {
  ------------------
  |  Branch (3744:21): [True: 0, False: 10.2k]
  ------------------
 3745|      0|                    goto out;
 3746|      0|                }
 3747|  10.2k|            }
 3748|  10.2k|            vk_result = copy_data_file_info(inst, xdg_data_dirs, relative_location, rel_size, &search_paths);
 3749|  10.2k|            if (VK_SUCCESS != vk_result) {
  ------------------
  |  Branch (3749:17): [True: 0, False: 10.2k]
  ------------------
 3750|      0|                goto out;
 3751|      0|            }
 3752|  10.2k|        }
 3753|       |#else
 3754|       |#warning read_data_files_in_search_paths unsupported platform
 3755|       |#endif
 3756|  10.2k|    }
 3757|       |
 3758|       |    // Print out the paths being searched if debugging is enabled
 3759|  10.5k|    uint32_t log_flags = 0;
 3760|       |
 3761|  10.5k|    if (manifest_type == LOADER_DATA_FILE_MANIFEST_DRIVER) {
  ------------------
  |  Branch (3761:9): [True: 4, False: 10.4k]
  ------------------
 3762|      4|        log_flags = VULKAN_LOADER_DRIVER_BIT;
 3763|      4|        loader_log(inst, VULKAN_LOADER_DRIVER_BIT, 0, "Searching for driver manifest files");
 3764|  10.4k|    } else {
 3765|  10.4k|        log_flags = VULKAN_LOADER_LAYER_BIT;
 3766|  10.4k|        loader_log(inst, VULKAN_LOADER_LAYER_BIT, 0, "Searching for %s layer manifest files",
 3767|  10.4k|                   manifest_type == LOADER_DATA_FILE_MANIFEST_EXPLICIT_LAYER ? "explicit" : "implicit");
  ------------------
  |  Branch (3767:20): [True: 5.24k, False: 5.24k]
  ------------------
 3768|  10.4k|    }
 3769|  10.5k|    loader_log(inst, log_flags, 0, "   In following locations:");
 3770|       |
 3771|  86.4k|    for (size_t i = 0; i < search_paths.count; i++) {
  ------------------
  |  Branch (3771:24): [True: 75.9k, False: 10.5k]
  ------------------
 3772|  75.9k|        loader_log(inst, log_flags, 0, "      %s", search_paths.list[i]);
 3773|  75.9k|    }
 3774|       |
 3775|       |    // Now, parse the paths and add any manifest files found in them.
 3776|  10.5k|    vk_result = add_data_files(inst, &search_paths, out_files);
 3777|       |
 3778|  10.5k|    if (log_flags != 0 && out_files->count > 0) {
  ------------------
  |  Branch (3778:9): [True: 10.5k, False: 0]
  |  Branch (3778:27): [True: 4.62k, False: 5.87k]
  ------------------
 3779|  4.62k|        loader_log(inst, log_flags, 0, "   Found the following files:");
 3780|  13.8k|        for (uint32_t cur_file = 0; cur_file < out_files->count; ++cur_file) {
  ------------------
  |  Branch (3780:37): [True: 9.24k, False: 4.62k]
  ------------------
 3781|  9.24k|            loader_log(inst, log_flags, 0, "      %s", out_files->list[cur_file]);
 3782|  9.24k|        }
 3783|  5.87k|    } else {
 3784|  5.87k|        loader_log(inst, log_flags, 0, "   Found no files");
 3785|  5.87k|    }
 3786|       |
 3787|  10.5k|    if ((NULL != path_overrides && path_overrides->count > 0) || NULL != override_env) {
  ------------------
  |  Branch (3787:10): [True: 5.24k, False: 5.25k]
  |  Branch (3787:36): [True: 243, False: 5.00k]
  |  Branch (3787:66): [True: 0, False: 10.2k]
  ------------------
 3788|    243|        *override_active = true;
 3789|  10.2k|    } else {
 3790|  10.2k|        *override_active = false;
 3791|  10.2k|    }
 3792|       |
 3793|  10.5k|out:
 3794|       |
 3795|  10.5k|    loader_free_getenv(additional_env, inst);
 3796|  10.5k|    loader_free_getenv(override_env, inst);
 3797|       |#if defined(_WIN32)
 3798|       |    loader_instance_heap_free(inst, package_path);
 3799|       |#elif COMMON_UNIX_PLATFORMS
 3800|       |#if defined(__APPLE__)
 3801|       |    loader_instance_heap_free(inst, bundle_path);
 3802|       |#endif
 3803|  10.5k|    loader_free_getenv(xdg_config_home, inst);
 3804|  10.5k|    loader_free_getenv(xdg_config_dirs, inst);
 3805|  10.5k|    loader_free_getenv(xdg_data_home, inst);
 3806|  10.5k|    loader_free_getenv(xdg_data_dirs, inst);
 3807|  10.5k|    loader_free_getenv(xdg_data_home, inst);
 3808|  10.5k|    loader_free_getenv(home, inst);
 3809|  10.5k|    loader_instance_heap_free(inst, default_data_home);
 3810|  10.5k|    loader_instance_heap_free(inst, default_config_home);
 3811|       |#else
 3812|       |#warning read_data_files_in_search_paths unsupported platform
 3813|       |#endif
 3814|       |
 3815|  10.5k|    free_string_list(inst, &search_paths);
 3816|       |
 3817|  10.5k|    return vk_result;
 3818|  10.5k|}
loader_get_data_files:
 3844|  10.5k|                               const struct loader_string_list *path_overrides, struct loader_string_list *out_files) {
 3845|  10.5k|    VkResult res = VK_SUCCESS;
 3846|  10.5k|    bool override_active = false;
 3847|       |
 3848|       |    // Free and init the out_files information so there's no false data left from uninitialized variables.
 3849|  10.5k|    free_string_list(inst, out_files);
 3850|       |
 3851|  10.5k|    res = read_data_files_in_search_paths(inst, manifest_type, path_overrides, &override_active, out_files);
 3852|  10.5k|    if (VK_SUCCESS != res) {
  ------------------
  |  Branch (3852:9): [True: 0, False: 10.5k]
  ------------------
 3853|      0|        goto out;
 3854|      0|    }
 3855|       |
 3856|       |#if defined(_WIN32)
 3857|       |    // Read the registry if the override wasn't active.
 3858|       |    if (!override_active) {
 3859|       |        bool warn_if_not_present = false;
 3860|       |        char *registry_location = NULL;
 3861|       |
 3862|       |        switch (manifest_type) {
 3863|       |            default:
 3864|       |                goto out;
 3865|       |            case LOADER_DATA_FILE_MANIFEST_DRIVER:
 3866|       |                warn_if_not_present = true;
 3867|       |                registry_location = VK_DRIVERS_INFO_REGISTRY_LOC;
 3868|       |                break;
 3869|       |            case LOADER_DATA_FILE_MANIFEST_IMPLICIT_LAYER:
 3870|       |                registry_location = VK_ILAYERS_INFO_REGISTRY_LOC;
 3871|       |                break;
 3872|       |            case LOADER_DATA_FILE_MANIFEST_EXPLICIT_LAYER:
 3873|       |                warn_if_not_present = true;
 3874|       |                registry_location = VK_ELAYERS_INFO_REGISTRY_LOC;
 3875|       |                break;
 3876|       |        }
 3877|       |        VkResult tmp_res =
 3878|       |            windows_read_data_files_in_registry(inst, manifest_type, warn_if_not_present, registry_location, out_files);
 3879|       |        // Only return an error if there was an error this time, and no manifest files from before.
 3880|       |        if (VK_SUCCESS != tmp_res && out_files->count == 0) {
 3881|       |            res = tmp_res;
 3882|       |            goto out;
 3883|       |        }
 3884|       |    }
 3885|       |#endif
 3886|       |
 3887|  10.5k|out:
 3888|       |
 3889|  10.5k|    if (VK_SUCCESS != res) {
  ------------------
  |  Branch (3889:9): [True: 0, False: 10.5k]
  ------------------
 3890|      0|        free_string_list(inst, out_files);
 3891|      0|    }
 3892|       |
 3893|  10.5k|    return res;
 3894|  10.5k|}
loader_parse_icd_manifest:
 3904|      3|                                   bool *skipped_portability_drivers) {
 3905|      3|    VkResult res = VK_SUCCESS;
 3906|      3|    cJSON *icd_manifest_json = NULL;
 3907|       |
 3908|      3|    if (file_str == NULL) {
  ------------------
  |  Branch (3908:9): [True: 0, False: 3]
  ------------------
 3909|      0|        goto out;
 3910|      0|    }
 3911|       |
 3912|      3|    res = loader_get_json(inst, file_str, &icd_manifest_json);
 3913|      3|    if (res == VK_ERROR_OUT_OF_HOST_MEMORY) {
  ------------------
  |  Branch (3913:9): [True: 0, False: 3]
  ------------------
 3914|      0|        goto out;
 3915|      0|    }
 3916|      3|    if (res != VK_SUCCESS || NULL == icd_manifest_json) {
  ------------------
  |  Branch (3916:9): [True: 0, False: 3]
  |  Branch (3916:30): [True: 1, False: 2]
  ------------------
 3917|      1|        res = VK_ERROR_INCOMPATIBLE_DRIVER;
 3918|      1|        goto out;
 3919|      1|    }
 3920|       |
 3921|      2|    cJSON *file_format_version_json = loader_cJSON_GetObjectItem(icd_manifest_json, "file_format_version");
 3922|      2|    if (file_format_version_json == NULL) {
  ------------------
  |  Branch (3922:9): [True: 2, False: 0]
  ------------------
 3923|      2|        loader_log(inst, VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_DRIVER_BIT, 0,
 3924|      2|                   "loader_parse_icd_manifest: ICD JSON %s does not have a \'file_format_version\' field. Skipping ICD JSON.",
 3925|      2|                   file_str);
 3926|      2|        res = VK_ERROR_INCOMPATIBLE_DRIVER;
 3927|      2|        goto out;
 3928|      2|    }
 3929|       |
 3930|      0|    char *file_vers_str = loader_cJSON_GetStringValue(file_format_version_json);
 3931|      0|    if (NULL == file_vers_str) {
  ------------------
  |  Branch (3931:9): [True: 0, False: 0]
  ------------------
 3932|       |        // Only reason the print can fail is if there was an allocation issue
 3933|      0|        loader_log(inst, VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_DRIVER_BIT, 0,
 3934|      0|                   "loader_parse_icd_manifest: Failed retrieving ICD JSON %s \'file_format_version\' field. Skipping ICD JSON",
 3935|      0|                   file_str);
 3936|      0|        goto out;
 3937|      0|    }
 3938|      0|    loader_log(inst, VULKAN_LOADER_DRIVER_BIT, 0, "Found ICD manifest file %s, version %s", file_str, file_vers_str);
 3939|       |
 3940|       |    // Get the version of the driver manifest
 3941|      0|    loader_api_version json_file_version = loader_make_full_version(loader_parse_version_string(file_vers_str));
 3942|       |
 3943|       |    // Loader only knows versions 1.0.0 and 1.0.1, anything above it is unknown
 3944|      0|    if (loader_check_version_meets_required(loader_combine_version(1, 0, 2), json_file_version)) {
  ------------------
  |  Branch (3944:9): [True: 0, False: 0]
  ------------------
 3945|      0|        loader_log(inst, VULKAN_LOADER_INFO_BIT | VULKAN_LOADER_DRIVER_BIT, 0,
 3946|      0|                   "loader_parse_icd_manifest: %s has unknown icd manifest file version %d.%d.%d. May cause errors.", file_str,
 3947|      0|                   json_file_version.major, json_file_version.minor, json_file_version.patch);
 3948|      0|    }
 3949|       |
 3950|      0|    cJSON *itemICD = loader_cJSON_GetObjectItem(icd_manifest_json, "ICD");
 3951|      0|    if (itemICD == NULL) {
  ------------------
  |  Branch (3951:9): [True: 0, False: 0]
  ------------------
 3952|       |        // Don't warn if this happens to be a layer manifest file
 3953|      0|        if (loader_cJSON_GetObjectItem(icd_manifest_json, "layer") == NULL &&
  ------------------
  |  Branch (3953:13): [True: 0, False: 0]
  ------------------
 3954|      0|            loader_cJSON_GetObjectItem(icd_manifest_json, "layers") == NULL) {
  ------------------
  |  Branch (3954:13): [True: 0, False: 0]
  ------------------
 3955|      0|            loader_log(inst, VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_DRIVER_BIT, 0,
 3956|      0|                       "loader_parse_icd_manifest: Can not find \'ICD\' object in ICD JSON file %s. Skipping ICD JSON", file_str);
 3957|      0|        }
 3958|      0|        res = VK_ERROR_INCOMPATIBLE_DRIVER;
 3959|      0|        goto out;
 3960|      0|    }
 3961|       |
 3962|      0|    cJSON *library_path_json = loader_cJSON_GetObjectItem(itemICD, "library_path");
 3963|      0|    if (library_path_json == NULL) {
  ------------------
  |  Branch (3963:9): [True: 0, False: 0]
  ------------------
 3964|      0|        loader_log(inst, VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_DRIVER_BIT, 0,
 3965|      0|                   "loader_parse_icd_manifest: Failed to find \'library_path\' object in ICD JSON file %s. Skipping ICD JSON.",
 3966|      0|                   file_str);
 3967|      0|        res = VK_ERROR_INCOMPATIBLE_DRIVER;
 3968|      0|        goto out;
 3969|      0|    }
 3970|      0|    bool out_of_memory = false;
 3971|      0|    char *library_path = loader_cJSON_Print(library_path_json, &out_of_memory);
 3972|      0|    if (out_of_memory) {
  ------------------
  |  Branch (3972:9): [True: 0, False: 0]
  ------------------
 3973|      0|        loader_log(inst, VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_DRIVER_BIT, 0,
 3974|      0|                   "loader_parse_icd_manifest: Failed retrieving ICD JSON %s \'library_path\' field. Skipping ICD JSON.", file_str);
 3975|      0|        res = VK_ERROR_OUT_OF_HOST_MEMORY;
 3976|      0|        goto out;
 3977|      0|    } else if (!library_path || strlen(library_path) == 0) {
  ------------------
  |  Branch (3977:16): [True: 0, False: 0]
  |  Branch (3977:33): [True: 0, False: 0]
  ------------------
 3978|      0|        loader_log(inst, VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_DRIVER_BIT, 0,
 3979|      0|                   "loader_parse_icd_manifest: ICD JSON %s \'library_path\' field is empty. Skipping ICD JSON.", file_str);
 3980|      0|        res = VK_ERROR_INCOMPATIBLE_DRIVER;
 3981|      0|        loader_instance_heap_free(inst, library_path);
 3982|      0|        goto out;
 3983|      0|    }
 3984|       |
 3985|       |    // Print out the paths being searched if debugging is enabled
 3986|      0|    loader_log(inst, VULKAN_LOADER_DEBUG_BIT | VULKAN_LOADER_DRIVER_BIT, 0, "Searching for ICD drivers named %s", library_path);
 3987|       |    // This function takes ownership of library_path - so we don't need to clean it up
 3988|      0|    res = combine_manifest_directory_and_library_path(inst, library_path, file_str, &icd->full_library_path);
 3989|      0|    if (VK_SUCCESS != res) {
  ------------------
  |  Branch (3989:9): [True: 0, False: 0]
  ------------------
 3990|      0|        goto out;
 3991|      0|    }
 3992|       |
 3993|      0|    cJSON *api_version_json = loader_cJSON_GetObjectItem(itemICD, "api_version");
 3994|      0|    if (api_version_json == NULL) {
  ------------------
  |  Branch (3994:9): [True: 0, False: 0]
  ------------------
 3995|      0|        loader_log(inst, VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_DRIVER_BIT, 0,
 3996|      0|                   "loader_parse_icd_manifest: ICD JSON %s does not have an \'api_version\' field. Skipping ICD JSON.", file_str);
 3997|      0|        res = VK_ERROR_INCOMPATIBLE_DRIVER;
 3998|      0|        goto out;
 3999|      0|    }
 4000|      0|    char *version_str = loader_cJSON_GetStringValue(api_version_json);
 4001|      0|    if (NULL == version_str) {
  ------------------
  |  Branch (4001:9): [True: 0, False: 0]
  ------------------
 4002|       |        // Only reason the print can fail is if there was an allocation issue
 4003|      0|        loader_log(inst, VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_DRIVER_BIT, 0,
 4004|      0|                   "loader_parse_icd_manifest: Failed retrieving ICD JSON %s \'api_version\' field. Skipping ICD JSON.", file_str);
 4005|       |
 4006|      0|        goto out;
 4007|      0|    }
 4008|      0|    icd->version = loader_parse_version_string(version_str);
 4009|       |
 4010|      0|    if (VK_API_VERSION_VARIANT(icd->version) != 0) {
  ------------------
  |  Branch (4010:9): [True: 0, False: 0]
  ------------------
 4011|      0|        loader_log(inst, VULKAN_LOADER_INFO_BIT | VULKAN_LOADER_DRIVER_BIT, 0,
 4012|      0|                   "loader_parse_icd_manifest: Driver's ICD JSON %s \'api_version\' field contains a non-zero variant value of %d. "
 4013|      0|                   " Skipping ICD JSON.",
 4014|      0|                   file_str, VK_API_VERSION_VARIANT(icd->version));
 4015|      0|        res = VK_ERROR_INCOMPATIBLE_DRIVER;
 4016|      0|        goto out;
 4017|      0|    }
 4018|       |
 4019|       |    // Skip over ICD's which contain a true "is_portability_driver" value whenever the application doesn't enable
 4020|       |    // portability enumeration.
 4021|      0|    cJSON *is_portability_driver_json = loader_cJSON_GetObjectItem(itemICD, "is_portability_driver");
 4022|      0|    if (loader_cJSON_IsTrue(is_portability_driver_json) && inst && !inst->portability_enumeration_enabled) {
  ------------------
  |  Branch (4022:9): [True: 0, False: 0]
  |  Branch (4022:60): [True: 0, False: 0]
  |  Branch (4022:68): [True: 0, False: 0]
  ------------------
 4023|      0|        if (skipped_portability_drivers) {
  ------------------
  |  Branch (4023:13): [True: 0, False: 0]
  ------------------
 4024|      0|            *skipped_portability_drivers = true;
 4025|      0|        }
 4026|      0|        res = VK_ERROR_INCOMPATIBLE_DRIVER;
 4027|      0|        goto out;
 4028|      0|    }
 4029|       |
 4030|      0|    char *library_arch_str = loader_cJSON_GetStringValue(loader_cJSON_GetObjectItem(itemICD, "library_arch"));
 4031|      0|    if (library_arch_str != NULL) {
  ------------------
  |  Branch (4031:9): [True: 0, False: 0]
  ------------------
 4032|      0|        if ((strncmp(library_arch_str, "32", 2) == 0 && sizeof(void *) != 4) ||
  ------------------
  |  Branch (4032:14): [True: 0, False: 0]
  |  Branch (4032:57): [True: 0, Folded]
  ------------------
 4033|      0|            (strncmp(library_arch_str, "64", 2) == 0 && sizeof(void *) != 8)) {
  ------------------
  |  Branch (4033:14): [True: 0, False: 0]
  |  Branch (4033:57): [Folded, False: 0]
  ------------------
 4034|      0|            loader_log(inst, VULKAN_LOADER_INFO_BIT, 0,
 4035|      0|                       "loader_parse_icd_manifest: Driver library architecture doesn't match the current running "
 4036|      0|                       "architecture, skipping this driver");
 4037|      0|            res = VK_ERROR_INCOMPATIBLE_DRIVER;
 4038|      0|            goto out;
 4039|      0|        }
 4040|      0|    }
 4041|      3|out:
 4042|      3|    loader_cJSON_Delete(icd_manifest_json);
 4043|      3|    return res;
 4044|      0|}
loader_icd_scan:
 4061|      4|                         const VkInstanceCreateInfo *pCreateInfo, bool *skipped_portability_drivers) {
 4062|      4|    VkResult res = VK_SUCCESS;
 4063|      4|    struct loader_string_list manifest_files = {0};
 4064|      4|    struct loader_envvar_filter select_filter = {0};
 4065|      4|    struct loader_envvar_filter disable_filter = {0};
 4066|      4|    struct ICDManifestInfo *icd_details = NULL;
 4067|       |
 4068|       |    // Set up the ICD Trampoline list so elements can be written into it.
 4069|      4|    res = loader_init_scanned_icd_list(inst, icd_tramp_list);
 4070|      4|    if (res == VK_ERROR_OUT_OF_HOST_MEMORY) {
  ------------------
  |  Branch (4070:9): [True: 0, False: 4]
  ------------------
 4071|      0|        return res;
 4072|      0|    }
 4073|       |
 4074|      4|    bool direct_driver_loading_exclusive_mode = false;
 4075|      4|    res = loader_scan_for_direct_drivers(inst, pCreateInfo, icd_tramp_list, &direct_driver_loading_exclusive_mode);
 4076|      4|    if (res == VK_ERROR_OUT_OF_HOST_MEMORY) {
  ------------------
  |  Branch (4076:9): [True: 0, False: 4]
  ------------------
 4077|      0|        goto out;
 4078|      0|    }
 4079|      4|    if (direct_driver_loading_exclusive_mode) {
  ------------------
  |  Branch (4079:9): [True: 0, False: 4]
  ------------------
 4080|       |        // Make sure to jump over the system & env-var driver discovery mechanisms if exclusive mode is set, even if no drivers
 4081|       |        // were successfully found through the direct driver loading mechanism
 4082|      0|        goto out;
 4083|      0|    }
 4084|       |
 4085|      4|    if (loader_settings_should_use_driver_environment_variables(inst)) {
  ------------------
  |  Branch (4085:9): [True: 4, False: 0]
  ------------------
 4086|       |        // Parse the filter environment variables to determine if we have any special behavior
 4087|      4|        res = parse_generic_filter_environment_var(inst, VK_DRIVERS_SELECT_ENV_VAR, &select_filter);
  ------------------
  |  |  122|      4|#define VK_DRIVERS_SELECT_ENV_VAR "VK_LOADER_DRIVERS_SELECT"
  ------------------
 4088|      4|        if (VK_SUCCESS != res) {
  ------------------
  |  Branch (4088:13): [True: 0, False: 4]
  ------------------
 4089|      0|            goto out;
 4090|      0|        }
 4091|      4|        res = parse_generic_filter_environment_var(inst, VK_DRIVERS_DISABLE_ENV_VAR, &disable_filter);
  ------------------
  |  |  123|      4|#define VK_DRIVERS_DISABLE_ENV_VAR "VK_LOADER_DRIVERS_DISABLE"
  ------------------
 4092|      4|        if (VK_SUCCESS != res) {
  ------------------
  |  Branch (4092:13): [True: 0, False: 4]
  ------------------
 4093|      0|            goto out;
 4094|      0|        }
 4095|      4|    }
 4096|       |
 4097|       |    // Get a list of manifest files for ICDs
 4098|      4|    res = loader_get_data_files(inst, LOADER_DATA_FILE_MANIFEST_DRIVER, NULL, &manifest_files);
 4099|      4|    if (VK_SUCCESS != res) {
  ------------------
  |  Branch (4099:9): [True: 0, False: 4]
  ------------------
 4100|      0|        goto out;
 4101|      0|    }
 4102|       |
 4103|       |    // Add any drivers provided by the loader settings file
 4104|      4|    res = loader_settings_get_additional_driver_files(inst, &manifest_files);
 4105|      4|    if (VK_SUCCESS != res) {
  ------------------
  |  Branch (4105:9): [True: 0, False: 4]
  ------------------
 4106|      0|        goto out;
 4107|      0|    }
 4108|       |
 4109|      4|    icd_details = loader_stack_alloc(sizeof(struct ICDManifestInfo) * manifest_files.count);
  ------------------
  |  |   42|      4|#define loader_stack_alloc(size) alloca(size)
  ------------------
 4110|      4|    if (NULL == icd_details) {
  ------------------
  |  Branch (4110:9): [True: 0, False: 4]
  ------------------
 4111|      0|        res = VK_ERROR_OUT_OF_HOST_MEMORY;
 4112|      0|        goto out;
 4113|      0|    }
 4114|      4|    memset(icd_details, 0, sizeof(struct ICDManifestInfo) * manifest_files.count);
 4115|       |
 4116|      7|    for (uint32_t i = 0; i < manifest_files.count; i++) {
  ------------------
  |  Branch (4116:26): [True: 3, False: 4]
  ------------------
 4117|      3|        VkResult icd_res = VK_SUCCESS;
 4118|       |
 4119|      3|        icd_res = loader_parse_icd_manifest(inst, manifest_files.list[i], &icd_details[i], skipped_portability_drivers);
 4120|      3|        if (VK_ERROR_OUT_OF_HOST_MEMORY == icd_res) {
  ------------------
  |  Branch (4120:13): [True: 0, False: 3]
  ------------------
 4121|      0|            res = icd_res;
 4122|      0|            goto out;
 4123|      3|        } else if (VK_ERROR_INCOMPATIBLE_DRIVER == icd_res) {
  ------------------
  |  Branch (4123:20): [True: 3, False: 0]
  ------------------
 4124|      3|            continue;
 4125|      3|        }
 4126|       |
 4127|      0|        if (select_filter.count > 0 || disable_filter.count > 0) {
  ------------------
  |  Branch (4127:13): [True: 0, False: 0]
  |  Branch (4127:40): [True: 0, False: 0]
  ------------------
 4128|       |            // Get only the filename for comparing to the filters
 4129|      0|            char *just_filename_str = strrchr(manifest_files.list[i], DIRECTORY_SYMBOL);
  ------------------
  |  |  151|      0|#define DIRECTORY_SYMBOL '/'
  ------------------
 4130|       |
 4131|       |            // No directory symbol, just the filename
 4132|      0|            if (NULL == just_filename_str) {
  ------------------
  |  Branch (4132:17): [True: 0, False: 0]
  ------------------
 4133|      0|                just_filename_str = manifest_files.list[i];
 4134|      0|            } else {
 4135|      0|                just_filename_str++;
 4136|      0|            }
 4137|       |
 4138|      0|            bool name_matches_select =
 4139|      0|                (select_filter.count > 0 && check_name_matches_filter_environment_var(just_filename_str, &select_filter));
  ------------------
  |  Branch (4139:18): [True: 0, False: 0]
  |  Branch (4139:45): [True: 0, False: 0]
  ------------------
 4140|      0|            bool name_matches_disable =
 4141|      0|                (disable_filter.count > 0 && check_name_matches_filter_environment_var(just_filename_str, &disable_filter));
  ------------------
  |  Branch (4141:18): [True: 0, False: 0]
  |  Branch (4141:46): [True: 0, False: 0]
  ------------------
 4142|       |
 4143|      0|            if (name_matches_disable && !name_matches_select) {
  ------------------
  |  Branch (4143:17): [True: 0, False: 0]
  |  Branch (4143:41): [True: 0, False: 0]
  ------------------
 4144|      0|                loader_log(inst, VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_DRIVER_BIT, 0,
 4145|      0|                           "Driver \"%s\" ignored because it was disabled by env var \'%s\'", just_filename_str,
 4146|      0|                           VK_DRIVERS_DISABLE_ENV_VAR);
  ------------------
  |  |  123|      0|#define VK_DRIVERS_DISABLE_ENV_VAR "VK_LOADER_DRIVERS_DISABLE"
  ------------------
 4147|      0|                continue;
 4148|      0|            }
 4149|      0|            if (select_filter.count != 0 && !name_matches_select) {
  ------------------
  |  Branch (4149:17): [True: 0, False: 0]
  |  Branch (4149:45): [True: 0, False: 0]
  ------------------
 4150|      0|                loader_log(inst, VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_DRIVER_BIT, 0,
 4151|      0|                           "Driver \"%s\" ignored because not selected by env var \'%s\'", just_filename_str,
 4152|      0|                           VK_DRIVERS_SELECT_ENV_VAR);
  ------------------
  |  |  122|      0|#define VK_DRIVERS_SELECT_ENV_VAR "VK_LOADER_DRIVERS_SELECT"
  ------------------
 4153|      0|                continue;
 4154|      0|            }
 4155|      0|        }
 4156|       |
 4157|      0|        enum loader_layer_library_status lib_status;
 4158|      0|        icd_res =
 4159|      0|            loader_scanned_icd_add(inst, icd_tramp_list, icd_details[i].full_library_path, icd_details[i].version, &lib_status);
 4160|      0|        if (VK_ERROR_OUT_OF_HOST_MEMORY == icd_res) {
  ------------------
  |  Branch (4160:13): [True: 0, False: 0]
  ------------------
 4161|      0|            res = icd_res;
 4162|      0|            goto out;
 4163|      0|        } else if (VK_ERROR_INCOMPATIBLE_DRIVER == icd_res) {
  ------------------
  |  Branch (4163:20): [True: 0, False: 0]
  ------------------
 4164|      0|            switch (lib_status) {
  ------------------
  |  Branch (4164:21): [True: 0, False: 0]
  ------------------
 4165|      0|                case LOADER_LAYER_LIB_NOT_LOADED:
  ------------------
  |  Branch (4165:17): [True: 0, False: 0]
  ------------------
 4166|      0|                case LOADER_LAYER_LIB_ERROR_FAILED_TO_LOAD:
  ------------------
  |  Branch (4166:17): [True: 0, False: 0]
  ------------------
 4167|      0|                    loader_log(inst, VULKAN_LOADER_ERROR_BIT | VULKAN_LOADER_DRIVER_BIT, 0,
 4168|      0|                               "loader_icd_scan: Failed loading library associated with ICD JSON %s. Ignoring this JSON",
 4169|      0|                               icd_details[i].full_library_path);
 4170|      0|                    break;
 4171|      0|                case LOADER_LAYER_LIB_ERROR_WRONG_BIT_TYPE: {
  ------------------
  |  Branch (4171:17): [True: 0, False: 0]
  ------------------
 4172|      0|                    loader_log(inst, VULKAN_LOADER_DRIVER_BIT, 0, "Requested ICD %s was wrong bit-type. Ignoring this JSON",
 4173|      0|                               icd_details[i].full_library_path);
 4174|      0|                    break;
 4175|      0|                }
 4176|      0|                case LOADER_LAYER_LIB_SUCCESS_LOADED:
  ------------------
  |  Branch (4176:17): [True: 0, False: 0]
  ------------------
 4177|      0|                case LOADER_LAYER_LIB_ERROR_OUT_OF_MEMORY:
  ------------------
  |  Branch (4177:17): [True: 0, False: 0]
  ------------------
 4178|       |                    // Shouldn't be able to reach this but if it is, best to report a debug
 4179|      0|                    loader_log(inst, VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_DRIVER_BIT, 0,
 4180|      0|                               "Shouldn't reach this. A valid version of requested ICD %s was loaded but something bad "
 4181|      0|                               "happened afterwards.",
 4182|      0|                               icd_details[i].full_library_path);
 4183|      0|                    break;
 4184|      0|            }
 4185|      0|        }
 4186|      0|    }
 4187|       |
 4188|      4|out:
 4189|      4|    if (NULL != icd_details) {
  ------------------
  |  Branch (4189:9): [True: 4, False: 0]
  ------------------
 4190|       |        // Successfully got the icd_details structure, which means we need to free the paths contained within
 4191|      7|        for (uint32_t i = 0; i < manifest_files.count; i++) {
  ------------------
  |  Branch (4191:30): [True: 3, False: 4]
  ------------------
 4192|      3|            loader_instance_heap_free(inst, icd_details[i].full_library_path);
 4193|      3|        }
 4194|      4|    }
 4195|      4|    free_string_list(inst, &manifest_files);
 4196|      4|    return res;
 4197|      4|}
loader_parse_instance_layers:
 4203|  10.4k|                                      const struct loader_string_list *path_overrides, struct loader_layer_list *instance_layers) {
 4204|  10.4k|    assert(manifest_type == LOADER_DATA_FILE_MANIFEST_IMPLICIT_LAYER || manifest_type == LOADER_DATA_FILE_MANIFEST_EXPLICIT_LAYER);
 4205|  10.4k|    VkResult res = VK_SUCCESS;
 4206|  10.4k|    struct loader_string_list manifest_files = {0};
 4207|       |
 4208|  10.4k|    res = loader_get_data_files(inst, manifest_type, path_overrides, &manifest_files);
 4209|  10.4k|    if (VK_SUCCESS != res) {
  ------------------
  |  Branch (4209:9): [True: 0, False: 10.4k]
  ------------------
 4210|      0|        goto out;
 4211|      0|    }
 4212|       |
 4213|  19.7k|    for (uint32_t i = 0; i < manifest_files.count; i++) {
  ------------------
  |  Branch (4213:26): [True: 9.24k, False: 10.4k]
  ------------------
 4214|  9.24k|        char *file_str = manifest_files.list[i];
 4215|  9.24k|        if (file_str == NULL) {
  ------------------
  |  Branch (4215:13): [True: 0, False: 9.24k]
  ------------------
 4216|      0|            continue;
 4217|      0|        }
 4218|       |
 4219|       |        // Parse file into JSON struct
 4220|  9.24k|        cJSON *json = NULL;
 4221|  9.24k|        VkResult local_res = loader_get_json(inst, file_str, &json);
 4222|  9.24k|        if (VK_ERROR_OUT_OF_HOST_MEMORY == local_res) {
  ------------------
  |  Branch (4222:13): [True: 0, False: 9.24k]
  ------------------
 4223|      0|            res = VK_ERROR_OUT_OF_HOST_MEMORY;
 4224|      0|            goto out;
 4225|  9.24k|        } else if (VK_SUCCESS != local_res || NULL == json) {
  ------------------
  |  Branch (4225:20): [True: 94, False: 9.14k]
  |  Branch (4225:47): [True: 3.96k, False: 5.18k]
  ------------------
 4226|  4.05k|            continue;
 4227|  4.05k|        }
 4228|       |
 4229|  5.18k|        local_res = loader_add_layer_properties(inst, instance_layers, json,
 4230|  5.18k|                                                manifest_type == LOADER_DATA_FILE_MANIFEST_IMPLICIT_LAYER, file_str);
 4231|  5.18k|        loader_cJSON_Delete(json);
 4232|       |
 4233|       |        // If the error is anything other than out of memory we still want to try to load the other layers
 4234|  5.18k|        if (VK_ERROR_OUT_OF_HOST_MEMORY == local_res) {
  ------------------
  |  Branch (4234:13): [True: 0, False: 5.18k]
  ------------------
 4235|      0|            res = VK_ERROR_OUT_OF_HOST_MEMORY;
 4236|      0|            goto out;
 4237|      0|        }
 4238|  5.18k|    }
 4239|  10.4k|out:
 4240|  10.4k|    free_string_list(inst, &manifest_files);
 4241|       |
 4242|  10.4k|    return res;
 4243|  10.4k|}
get_override_layer_override_paths:
 4248|    244|                                           struct loader_string_list *override_paths) {
 4249|    244|    if (prop->override_paths.count > 0) {
  ------------------
  |  Branch (4249:9): [True: 244, False: 0]
  ------------------
 4250|  14.3k|        for (uint32_t j = 0; j < prop->override_paths.count; j++) {
  ------------------
  |  Branch (4250:30): [True: 14.1k, False: 244]
  ------------------
 4251|  14.1k|            VkResult result = copy_data_file_info(inst, prop->override_paths.list[j], NULL, 0, override_paths);
 4252|  14.1k|            if (VK_SUCCESS != result) {
  ------------------
  |  Branch (4252:17): [True: 0, False: 14.1k]
  ------------------
 4253|      0|                return result;
 4254|      0|            }
 4255|  14.1k|            loader_log(inst, VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_LAYER_BIT, 0, "Override layer has override path %s",
 4256|  14.1k|                       prop->override_paths.list[j]);
 4257|  14.1k|        }
 4258|    244|    }
 4259|    244|    return VK_SUCCESS;
 4260|    244|}
loader_remove_duplicate_layers:
 4262|  5.24k|void loader_remove_duplicate_layers(struct loader_instance *inst, struct loader_layer_list *layers) {
 4263|       |    // Remove duplicate layers (that share the same layerName)
 4264|  12.2k|    for (uint32_t i = 0; i < layers->count; ++i) {
  ------------------
  |  Branch (4264:26): [True: 7.04k, False: 5.24k]
  ------------------
 4265|  7.04k|        bool has_duplicate = false;
 4266|  7.04k|        uint32_t duplicate_index = 0;
 4267|  31.4k|        for (uint32_t j = i + 1; j < layers->count; ++j) {
  ------------------
  |  Branch (4267:34): [True: 28.6k, False: 2.80k]
  ------------------
 4268|  28.6k|            if (strcmp(layers->list[i].info.layerName, layers->list[j].info.layerName) == 0) {
  ------------------
  |  Branch (4268:17): [True: 4.23k, False: 24.4k]
  ------------------
 4269|  4.23k|                has_duplicate = true;
 4270|  4.23k|                duplicate_index = j;
 4271|  4.23k|                break;
 4272|  4.23k|            }
 4273|  28.6k|        }
 4274|  7.04k|        if (has_duplicate) {
  ------------------
  |  Branch (4274:13): [True: 4.23k, False: 2.80k]
  ------------------
 4275|  4.23k|            loader_log(inst, VULKAN_LOADER_WARN_BIT, 0, "Removing layer %s (%s) because it is a duplicate of %s (%s)",
 4276|  4.23k|                       layers->list[duplicate_index].info.layerName, layers->list[duplicate_index].manifest_file_name,
 4277|  4.23k|                       layers->list[i].info.layerName, layers->list[i].manifest_file_name);
 4278|  4.23k|            loader_remove_layer_in_list(inst, layers, duplicate_index);
 4279|  4.23k|        }
 4280|  7.04k|    }
 4281|  5.24k|}
loader_scan_for_layers:
 4284|  7.00k|                                const struct loader_envvar_all_filters *filters) {
 4285|  7.00k|    VkResult res = VK_SUCCESS;
 4286|  7.00k|    struct loader_layer_list settings_layers = {0};
 4287|  7.00k|    struct loader_layer_list regular_instance_layers = {0};
 4288|  7.00k|    bool override_layer_valid = false;
 4289|  7.00k|    struct loader_string_list override_paths = {0};
 4290|       |
 4291|  7.00k|    bool should_search_for_other_layers = true;
 4292|  7.00k|    res = get_settings_layers(inst, &settings_layers, &should_search_for_other_layers);
 4293|  7.00k|    if (VK_SUCCESS != res) {
  ------------------
  |  Branch (4293:9): [True: 0, False: 7.00k]
  ------------------
 4294|      0|        goto out;
 4295|      0|    }
 4296|       |
 4297|       |    // If we should not look for layers using other mechanisms, assign settings_layers to instance_layers and jump to the
 4298|       |    // output
 4299|  7.00k|    if (!should_search_for_other_layers) {
  ------------------
  |  Branch (4299:9): [True: 1.75k, False: 5.24k]
  ------------------
 4300|  1.75k|        *instance_layers = settings_layers;
 4301|  1.75k|        memset(&settings_layers, 0, sizeof(struct loader_layer_list));
 4302|  1.75k|        goto out;
 4303|  1.75k|    }
 4304|       |
 4305|  5.24k|    res = loader_parse_instance_layers(inst, LOADER_DATA_FILE_MANIFEST_IMPLICIT_LAYER, NULL, &regular_instance_layers);
 4306|  5.24k|    if (VK_SUCCESS != res) {
  ------------------
  |  Branch (4306:9): [True: 0, False: 5.24k]
  ------------------
 4307|      0|        goto out;
 4308|      0|    }
 4309|       |
 4310|       |    // Remove any extraneous override layers.
 4311|  5.24k|    remove_all_non_valid_override_layers(inst, &regular_instance_layers);
 4312|       |
 4313|       |    // Check to see if the override layer is present, and use it's override paths.
 4314|  10.5k|    for (uint32_t i = 0; i < regular_instance_layers.count; i++) {
  ------------------
  |  Branch (4314:26): [True: 5.52k, False: 5.00k]
  ------------------
 4315|  5.52k|        struct loader_layer_properties *prop = &regular_instance_layers.list[i];
 4316|  5.52k|        if (prop->is_override && loader_implicit_layer_is_enabled(inst, filters, prop) && prop->override_paths.count > 0) {
  ------------------
  |  Branch (4316:13): [True: 505, False: 5.01k]
  |  Branch (4316:34): [True: 411, False: 94]
  |  Branch (4316:91): [True: 244, False: 167]
  ------------------
 4317|    244|            res = get_override_layer_override_paths(inst, prop, &override_paths);
 4318|    244|            if (VK_SUCCESS != res) {
  ------------------
  |  Branch (4318:17): [True: 0, False: 244]
  ------------------
 4319|      0|                goto out;
 4320|      0|            }
 4321|    244|            break;
 4322|    244|        }
 4323|  5.52k|    }
 4324|       |
 4325|       |    // Get a list of manifest files for explicit layers
 4326|  5.24k|    res = loader_parse_instance_layers(inst, LOADER_DATA_FILE_MANIFEST_EXPLICIT_LAYER, &override_paths, &regular_instance_layers);
 4327|  5.24k|    if (VK_SUCCESS != res) {
  ------------------
  |  Branch (4327:9): [True: 0, False: 5.24k]
  ------------------
 4328|      0|        goto out;
 4329|      0|    }
 4330|       |
 4331|       |    // Verify any meta-layers in the list are valid and all the component layers are
 4332|       |    // actually present in the available layer list
 4333|  5.24k|    res = verify_all_meta_layers(inst, filters, &regular_instance_layers, &override_layer_valid);
 4334|  5.24k|    if (VK_ERROR_OUT_OF_HOST_MEMORY == res) {
  ------------------
  |  Branch (4334:9): [True: 0, False: 5.24k]
  ------------------
 4335|      0|        return res;
 4336|      0|    }
 4337|       |
 4338|  5.24k|    if (override_layer_valid) {
  ------------------
  |  Branch (4338:9): [True: 395, False: 4.85k]
  ------------------
 4339|    395|        loader_remove_layers_in_blacklist(inst, &regular_instance_layers);
 4340|    395|        if (NULL != inst) {
  ------------------
  |  Branch (4340:13): [True: 395, False: 0]
  ------------------
 4341|    395|            inst->override_layer_present = true;
 4342|    395|        }
 4343|    395|    }
 4344|       |
 4345|       |    // Remove disabled layers
 4346|  16.5k|    for (uint32_t i = 0; i < regular_instance_layers.count; ++i) {
  ------------------
  |  Branch (4346:26): [True: 11.2k, False: 5.24k]
  ------------------
 4347|  11.2k|        if (!loader_layer_is_available(inst, filters, &regular_instance_layers.list[i])) {
  ------------------
  |  Branch (4347:13): [True: 0, False: 11.2k]
  ------------------
 4348|      0|            loader_remove_layer_in_list(inst, &regular_instance_layers, i);
 4349|      0|            i--;
 4350|      0|        }
 4351|  11.2k|    }
 4352|       |
 4353|       |    // Make sure no layers have the same layerName
 4354|  5.24k|    loader_remove_duplicate_layers(inst, &regular_instance_layers);
 4355|       |
 4356|  5.24k|    res = combine_settings_layers_with_regular_layers(inst, &settings_layers, &regular_instance_layers, instance_layers);
 4357|       |
 4358|  7.00k|out:
 4359|  7.00k|    loader_delete_layer_list_and_properties(inst, &settings_layers);
 4360|  7.00k|    loader_delete_layer_list_and_properties(inst, &regular_instance_layers);
 4361|       |
 4362|  7.00k|    free_string_list(inst, &override_paths);
 4363|  7.00k|    return res;
 4364|  5.24k|}
loader_validate_layers:
 5566|  7.00k|                                const char *const *ppEnabledLayerNames, const struct loader_layer_list *list) {
 5567|  7.00k|    struct loader_layer_properties *prop;
 5568|       |
 5569|  7.00k|    if (layer_count > 0 && ppEnabledLayerNames == NULL) {
  ------------------
  |  Branch (5569:9): [True: 7.00k, False: 0]
  |  Branch (5569:28): [True: 0, False: 7.00k]
  ------------------
 5570|      0|        loader_log(inst, VULKAN_LOADER_ERROR_BIT, 0,
 5571|      0|                   "loader_validate_layers: ppEnabledLayerNames is NULL but enabledLayerCount is greater than zero");
 5572|      0|        return VK_ERROR_LAYER_NOT_PRESENT;
 5573|      0|    }
 5574|       |
 5575|  7.00k|    for (uint32_t i = 0; i < layer_count; i++) {
  ------------------
  |  Branch (5575:26): [True: 7.00k, False: 4]
  ------------------
 5576|  7.00k|        VkStringErrorFlags result = vk_string_validate(MaxLoaderStringLength, ppEnabledLayerNames[i]);
 5577|  7.00k|        if (result != VK_STRING_ERROR_NONE) {
  ------------------
  |  Branch (5577:13): [True: 0, False: 7.00k]
  ------------------
 5578|      0|            loader_log(inst, VULKAN_LOADER_ERROR_BIT, 0,
 5579|      0|                       "loader_validate_layers: ppEnabledLayerNames contains string that is too long or is badly formed");
 5580|      0|            return VK_ERROR_LAYER_NOT_PRESENT;
 5581|      0|        }
 5582|       |
 5583|  7.00k|        prop = loader_find_layer_property(ppEnabledLayerNames[i], list);
 5584|  7.00k|        if (NULL == prop) {
  ------------------
  |  Branch (5584:13): [True: 6.99k, False: 4]
  ------------------
 5585|  6.99k|            loader_log(inst, VULKAN_LOADER_ERROR_BIT, 0,
 5586|  6.99k|                       "loader_validate_layers: Layer %d does not exist in the list of available layers", i);
 5587|  6.99k|            return VK_ERROR_LAYER_NOT_PRESENT;
 5588|  6.99k|        }
 5589|      4|        if (inst->settings.settings_active && inst->settings.layer_configurations_active &&
  ------------------
  |  Branch (5589:13): [True: 3, False: 1]
  |  Branch (5589:47): [True: 2, False: 1]
  ------------------
 5590|      2|            prop->settings_control_value != LOADER_SETTINGS_LAYER_CONTROL_ON &&
  ------------------
  |  Branch (5590:13): [True: 2, False: 0]
  ------------------
 5591|      2|            prop->settings_control_value != LOADER_SETTINGS_LAYER_CONTROL_DEFAULT) {
  ------------------
  |  Branch (5591:13): [True: 0, False: 2]
  ------------------
 5592|      0|            loader_log(inst, VULKAN_LOADER_ERROR_BIT, 0,
 5593|      0|                       "loader_validate_layers: Layer %d was explicitly prevented from being enabled by the loader settings file",
 5594|      0|                       i);
 5595|      0|            return VK_ERROR_LAYER_NOT_PRESENT;
 5596|      0|        }
 5597|      4|    }
 5598|      4|    return VK_SUCCESS;
 5599|  7.00k|}
vk_string_validate:
 7492|  7.00k|TEST_FUNCTION_EXPORT VkStringErrorFlags vk_string_validate(const int max_length, const char *utf8) {
 7493|  7.00k|    VkStringErrorFlags result = VK_STRING_ERROR_NONE;
 7494|  7.00k|    int num_char_bytes = 0;
 7495|  7.00k|    int i, j;
 7496|       |
 7497|  7.00k|    if (utf8 == NULL) {
  ------------------
  |  Branch (7497:9): [True: 0, False: 7.00k]
  ------------------
 7498|      0|        return VK_STRING_ERROR_NULL_PTR;
 7499|      0|    }
 7500|       |
 7501|   196k|    for (i = 0; i <= max_length; i++) {
  ------------------
  |  Branch (7501:17): [True: 196k, False: 0]
  ------------------
 7502|   196k|        if (utf8[i] == 0) {
  ------------------
  |  Branch (7502:13): [True: 7.00k, False: 189k]
  ------------------
 7503|  7.00k|            break;
 7504|   189k|        } else if (i == max_length) {
  ------------------
  |  Branch (7504:20): [True: 0, False: 189k]
  ------------------
 7505|      0|            result |= VK_STRING_ERROR_LENGTH;
 7506|      0|            break;
 7507|   189k|        } else if ((utf8[i] >= 0x20) && (utf8[i] < 0x7f)) {
  ------------------
  |  Branch (7507:20): [True: 189k, False: 0]
  |  Branch (7507:41): [True: 189k, False: 0]
  ------------------
 7508|   189k|            num_char_bytes = 0;
 7509|   189k|        } else if ((utf8[i] & UTF8_ONE_BYTE_MASK) == UTF8_ONE_BYTE_CODE) {
  ------------------
  |  Branch (7509:20): [True: 0, False: 0]
  ------------------
 7510|      0|            num_char_bytes = 1;
 7511|      0|        } else if ((utf8[i] & UTF8_TWO_BYTE_MASK) == UTF8_TWO_BYTE_CODE) {
  ------------------
  |  Branch (7511:20): [True: 0, False: 0]
  ------------------
 7512|      0|            num_char_bytes = 2;
 7513|      0|        } else if ((utf8[i] & UTF8_THREE_BYTE_MASK) == UTF8_THREE_BYTE_CODE) {
  ------------------
  |  Branch (7513:20): [True: 0, False: 0]
  ------------------
 7514|      0|            num_char_bytes = 3;
 7515|      0|        } else {
 7516|      0|            result = VK_STRING_ERROR_BAD_DATA;
 7517|      0|        }
 7518|       |
 7519|       |        // Validate the following num_char_bytes of data
 7520|   189k|        for (j = 0; (j < num_char_bytes) && (i < max_length); j++) {
  ------------------
  |  Branch (7520:21): [True: 0, False: 189k]
  |  Branch (7520:45): [True: 0, False: 0]
  ------------------
 7521|      0|            if (++i == max_length) {
  ------------------
  |  Branch (7521:17): [True: 0, False: 0]
  ------------------
 7522|      0|                result |= VK_STRING_ERROR_LENGTH;
 7523|      0|                break;
 7524|      0|            }
 7525|      0|            if (utf8[i] == 0) {
  ------------------
  |  Branch (7525:17): [True: 0, False: 0]
  ------------------
 7526|       |                // The string terminated in the middle of a multi-byte character. Stop here so the
 7527|       |                // continuation-byte scan doesn't read past the terminator.
 7528|      0|                result |= VK_STRING_ERROR_BAD_DATA;
 7529|      0|                return result;
 7530|      0|            }
 7531|      0|            if ((utf8[i] & UTF8_DATA_BYTE_MASK) != UTF8_DATA_BYTE_CODE) {
  ------------------
  |  Branch (7531:17): [True: 0, False: 0]
  ------------------
 7532|      0|                result |= VK_STRING_ERROR_BAD_DATA;
 7533|      0|            }
 7534|      0|        }
 7535|   189k|    }
 7536|  7.00k|    return result;
 7537|  7.00k|}

loader_getenv:
   43|  1.02k|char *loader_getenv(const char *name, const struct loader_instance *inst) {
   44|  1.02k|    if (NULL == name) return NULL;
  ------------------
  |  Branch (44:9): [True: 0, False: 1.02k]
  ------------------
   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|  1.02k|    (void)inst;
   48|  1.02k|    return getenv(name);
   49|  1.02k|}
loader_secure_getenv:
   51|   129k|char *loader_secure_getenv(const char *name, const struct loader_instance *inst) {
   52|       |#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__)
   53|       |    // Apple does not appear to have a secure getenv implementation.
   54|       |    // The main difference between secure getenv and getenv is that secure getenv
   55|       |    // returns NULL if the process is being run with elevated privileges by a normal user.
   56|       |    // The idea is to prevent the reading of malicious environment variables by a process
   57|       |    // that can do damage.
   58|       |    // This algorithm is derived from glibc code that sets an internal
   59|       |    // variable (__libc_enable_secure) if the process is running under setuid or setgid.
   60|       |    return is_high_integrity() ? NULL : loader_getenv(name, inst);
   61|       |#elif defined(__Fuchsia__)
   62|       |    return loader_getenv(name, inst);
   63|       |#else
   64|       |    // Linux
   65|   129k|    char *out;
   66|   129k|#if defined(HAVE_SECURE_GETENV) && !defined(LOADER_USE_UNSAFE_FILE_SEARCH)
   67|   129k|    (void)inst;
   68|   129k|    out = secure_getenv(name);
   69|       |#elif defined(HAVE___SECURE_GETENV) && !defined(LOADER_USE_UNSAFE_FILE_SEARCH)
   70|       |    (void)inst;
   71|       |    out = __secure_getenv(name);
   72|       |#else
   73|       |    out = loader_getenv(name, inst);
   74|       |#if !defined(LOADER_USE_UNSAFE_FILE_SEARCH)
   75|       |    loader_log(inst, VULKAN_LOADER_INFO_BIT, 0, "Loader is using non-secure environment variable lookup for %s", name);
   76|       |#endif
   77|       |#endif
   78|   129k|    return out;
   79|   129k|#endif
   80|   129k|}
loader_free_getenv:
   82|  99.0k|void loader_free_getenv(char *val, const struct loader_instance *inst) {
   83|       |    // No freeing of memory necessary for Linux, but we should at least touch
   84|       |    // the val and inst pointers to get rid of compiler warnings.
   85|  99.0k|    (void)val;
   86|  99.0k|    (void)inst;
   87|  99.0k|}
determine_filter_type:
  192|  7.00k|                           size_t *new_length) {
  193|  7.00k|    size_t filter_length = strlen(filter_string);
  194|  7.00k|    bool star_begin = false;
  195|  7.00k|    bool star_end = false;
  196|  7.00k|    if ('~' == filter_string[0]) {
  ------------------
  |  Branch (196:9): [True: 0, False: 7.00k]
  ------------------
  197|       |        // One of the special identifiers like: ~all~, ~implicit~, or ~explicit~
  198|      0|        *filter_type = FILTER_STRING_SPECIAL;
  199|      0|        *new_start = filter_string;
  200|      0|        *new_length = filter_length;
  201|  7.00k|    } else {
  202|  7.00k|        if ('*' == filter_string[0]) {
  ------------------
  |  Branch (202:13): [True: 0, False: 7.00k]
  ------------------
  203|       |            // Only the * means everything
  204|      0|            if (filter_length == 1) {
  ------------------
  |  Branch (204:17): [True: 0, False: 0]
  ------------------
  205|      0|                *filter_type = FILTER_STRING_SPECIAL;
  206|      0|                *new_start = filter_string;
  207|      0|                *new_length = filter_length;
  208|      0|                return;
  209|      0|            } else {
  210|      0|                star_begin = true;
  211|      0|            }
  212|      0|        }
  213|  7.00k|        if ('*' == filter_string[filter_length - 1]) {
  ------------------
  |  Branch (213:13): [True: 0, False: 7.00k]
  ------------------
  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|            } else {
  221|      0|                star_end = true;
  222|      0|            }
  223|      0|        }
  224|  7.00k|        if (star_begin && star_end) {
  ------------------
  |  Branch (224:13): [True: 0, False: 7.00k]
  |  Branch (224:27): [True: 0, False: 0]
  ------------------
  225|      0|            *filter_type = FILTER_STRING_SUBSTRING;
  226|      0|            *new_start = &filter_string[1];
  227|      0|            *new_length = filter_length - 2;
  228|  7.00k|        } else if (star_begin) {
  ------------------
  |  Branch (228:20): [True: 0, False: 7.00k]
  ------------------
  229|      0|            *new_start = &filter_string[1];
  230|      0|            *new_length = filter_length - 1;
  231|      0|            *filter_type = FILTER_STRING_SUFFIX;
  232|  7.00k|        } else if (star_end) {
  ------------------
  |  Branch (232:20): [True: 0, False: 7.00k]
  ------------------
  233|      0|            *filter_type = FILTER_STRING_PREFIX;
  234|      0|            *new_start = filter_string;
  235|      0|            *new_length = filter_length - 1;
  236|  7.00k|        } else {
  237|  7.00k|            *filter_type = FILTER_STRING_FULLNAME;
  238|  7.00k|            *new_start = filter_string;
  239|  7.00k|            *new_length = filter_length;
  240|  7.00k|        }
  241|  7.00k|    }
  242|  7.00k|}
parse_generic_filter_environment_var:
  247|  14.0k|                                              struct loader_envvar_filter *filter_struct) {
  248|  14.0k|    VkResult result = VK_SUCCESS;
  249|  14.0k|    memset(filter_struct, 0, sizeof(struct loader_envvar_filter));
  250|  14.0k|    char *parsing_string = NULL;
  251|  14.0k|    char *env_var_value = loader_secure_getenv(env_var_name, inst);
  252|  14.0k|    if (NULL == env_var_value) {
  ------------------
  |  Branch (252:9): [True: 7.01k, False: 7.00k]
  ------------------
  253|  7.01k|        return result;
  254|  7.01k|    }
  255|  7.00k|    const size_t env_var_len = strlen(env_var_value);
  256|  7.00k|    if (env_var_len == 0) {
  ------------------
  |  Branch (256:9): [True: 0, False: 7.00k]
  ------------------
  257|      0|        goto out;
  258|      0|    }
  259|       |    // Allocate a separate string since scan_for_next_comma modifies the original string
  260|  7.00k|    parsing_string = loader_instance_heap_calloc(inst, env_var_len + 1, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
  261|  7.00k|    if (NULL == parsing_string) {
  ------------------
  |  Branch (261:9): [True: 0, False: 7.00k]
  ------------------
  262|      0|        loader_log(inst, VULKAN_LOADER_ERROR_BIT, 0,
  263|      0|                   "parse_generic_filter_environment_var: Failed to allocate space for parsing env var \'%s\'", env_var_name);
  264|      0|        result = VK_ERROR_OUT_OF_HOST_MEMORY;
  265|      0|        goto out;
  266|      0|    }
  267|       |
  268|  28.0k|    for (uint32_t iii = 0; iii < env_var_len; ++iii) {
  ------------------
  |  Branch (268:28): [True: 21.0k, False: 7.00k]
  ------------------
  269|  21.0k|        parsing_string[iii] = (char)tolower((unsigned char)env_var_value[iii]);
  ------------------
  |  Branch (269:37): [True: 0, False: 0]
  |  Branch (269:37): [True: 0, False: 0]
  |  Branch (269:37): [Folded, False: 21.0k]
  ------------------
  270|  21.0k|    }
  271|  7.00k|    parsing_string[env_var_len] = '\0';
  272|       |
  273|  7.00k|    char *context = NULL;
  274|  7.00k|    char *token = thread_safe_strtok(parsing_string, ",", &context);
  275|  14.0k|    while (NULL != token) {
  ------------------
  |  Branch (275:12): [True: 7.00k, False: 7.00k]
  ------------------
  276|  7.00k|        enum loader_filter_string_type cur_filter_type;
  277|  7.00k|        const char *actual_start;
  278|  7.00k|        size_t actual_len;
  279|  7.00k|        determine_filter_type(token, &cur_filter_type, &actual_start, &actual_len);
  280|       |        // value holds at most VK_MAX_EXTENSION_NAME_SIZE - 1 chars plus the null terminator. Keep the stored length in sync
  281|       |        // with what actually fits so the matcher never walks past the buffer, and make sure it stays null terminated.
  282|  7.00k|        size_t stored_len = actual_len < VK_MAX_EXTENSION_NAME_SIZE - 1 ? actual_len : VK_MAX_EXTENSION_NAME_SIZE - 1;
  ------------------
  |  Branch (282:29): [True: 7.00k, False: 0]
  ------------------
  283|  7.00k|        loader_strncpy(filter_struct->filters[filter_struct->count].value, VK_MAX_EXTENSION_NAME_SIZE, actual_start, stored_len);
  284|  7.00k|        filter_struct->filters[filter_struct->count].value[stored_len] = '\0';
  285|  7.00k|        filter_struct->filters[filter_struct->count].length = stored_len;
  286|  7.00k|        filter_struct->filters[filter_struct->count++].type = cur_filter_type;
  287|  7.00k|        if (filter_struct->count >= MAX_ADDITIONAL_FILTERS) {
  ------------------
  |  |  529|  7.00k|#define MAX_ADDITIONAL_FILTERS 16
  ------------------
  |  Branch (287:13): [True: 0, False: 7.00k]
  ------------------
  288|      0|            break;
  289|      0|        }
  290|  7.00k|        token = thread_safe_strtok(NULL, ",", &context);
  291|  7.00k|    }
  292|       |
  293|  7.00k|out:
  294|       |
  295|  7.00k|    loader_instance_heap_free(inst, parsing_string);
  296|  7.00k|    loader_free_getenv(env_var_value, inst);
  297|  7.00k|    return result;
  298|  7.00k|}
parse_layers_disable_filter_environment_var:
  304|  7.00k|                                                     struct loader_envvar_disable_layers_filter *disable_struct) {
  305|  7.00k|    VkResult result = VK_SUCCESS;
  306|  7.00k|    memset(disable_struct, 0, sizeof(struct loader_envvar_disable_layers_filter));
  307|  7.00k|    char *parsing_string = NULL;
  308|  7.00k|    char *env_var_value = loader_secure_getenv(VK_LAYERS_DISABLE_ENV_VAR, inst);
  ------------------
  |  |  120|  7.00k|#define VK_LAYERS_DISABLE_ENV_VAR "VK_LOADER_LAYERS_DISABLE"
  ------------------
  309|  7.00k|    if (NULL == env_var_value) {
  ------------------
  |  Branch (309:9): [True: 7.00k, False: 0]
  ------------------
  310|  7.00k|        goto out;
  311|  7.00k|    }
  312|      0|    const size_t env_var_len = strlen(env_var_value);
  313|      0|    if (env_var_len == 0) {
  ------------------
  |  Branch (313:9): [True: 0, False: 0]
  ------------------
  314|      0|        goto out;
  315|      0|    }
  316|       |    // Allocate a separate string since scan_for_next_comma modifies the original string
  317|      0|    parsing_string = loader_instance_heap_calloc(inst, env_var_len + 1, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
  318|      0|    if (NULL == parsing_string) {
  ------------------
  |  Branch (318:9): [True: 0, False: 0]
  ------------------
  319|      0|        loader_log(inst, VULKAN_LOADER_ERROR_BIT, 0,
  320|      0|                   "parse_layers_disable_filter_environment_var: Failed to allocate space for parsing env var "
  321|      0|                   "\'VK_LAYERS_DISABLE_ENV_VAR\'");
  322|      0|        result = VK_ERROR_OUT_OF_HOST_MEMORY;
  323|      0|        goto out;
  324|      0|    }
  325|       |
  326|      0|    for (uint32_t iii = 0; iii < env_var_len; ++iii) {
  ------------------
  |  Branch (326:28): [True: 0, False: 0]
  ------------------
  327|      0|        parsing_string[iii] = (char)tolower((unsigned char)env_var_value[iii]);
  ------------------
  |  Branch (327:37): [True: 0, False: 0]
  |  Branch (327:37): [True: 0, False: 0]
  |  Branch (327:37): [Folded, False: 0]
  ------------------
  328|      0|    }
  329|      0|    parsing_string[env_var_len] = '\0';
  330|       |
  331|      0|    char *context = NULL;
  332|      0|    char *token = thread_safe_strtok(parsing_string, ",", &context);
  333|      0|    while (NULL != token) {
  ------------------
  |  Branch (333:12): [True: 0, False: 0]
  ------------------
  334|      0|        uint32_t cur_count = disable_struct->additional_filters.count;
  335|      0|        enum loader_filter_string_type cur_filter_type;
  336|      0|        const char *actual_start;
  337|      0|        size_t actual_len;
  338|      0|        determine_filter_type(token, &cur_filter_type, &actual_start, &actual_len);
  339|      0|        if (cur_filter_type == FILTER_STRING_SPECIAL) {
  ------------------
  |  Branch (339:13): [True: 0, False: 0]
  ------------------
  340|      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 (340:17): [True: 0, False: 0]
  |  Branch (340:71): [True: 0, False: 0]
  ------------------
  341|      0|                !strcmp(VK_LOADER_DISABLE_ALL_LAYERS_VAR_3, token)) {
  ------------------
  |  |  126|      0|#define VK_LOADER_DISABLE_ALL_LAYERS_VAR_3 "**"
  ------------------
  |  Branch (341:17): [True: 0, False: 0]
  ------------------
  342|      0|                disable_struct->disable_all = true;
  343|      0|            } else if (!strcmp(VK_LOADER_DISABLE_IMPLICIT_LAYERS_VAR, token)) {
  ------------------
  |  |  127|      0|#define VK_LOADER_DISABLE_IMPLICIT_LAYERS_VAR "~implicit~"
  ------------------
  |  Branch (343:24): [True: 0, False: 0]
  ------------------
  344|      0|                disable_struct->disable_all_implicit = true;
  345|      0|            } else if (!strcmp(VK_LOADER_DISABLE_EXPLICIT_LAYERS_VAR, token)) {
  ------------------
  |  |  128|      0|#define VK_LOADER_DISABLE_EXPLICIT_LAYERS_VAR "~explicit~"
  ------------------
  |  Branch (345:24): [True: 0, False: 0]
  ------------------
  346|      0|                disable_struct->disable_all_explicit = true;
  347|      0|            }
  348|      0|        } else {
  349|       |            // Keep the stored length in sync with what actually fits (value is VK_MAX_EXTENSION_NAME_SIZE bytes including
  350|       |            // the null terminator) so the matcher never reads past the buffer.
  351|      0|            size_t stored_len = actual_len < VK_MAX_EXTENSION_NAME_SIZE - 1 ? actual_len : VK_MAX_EXTENSION_NAME_SIZE - 1;
  ------------------
  |  Branch (351:33): [True: 0, False: 0]
  ------------------
  352|      0|            loader_strncpy(disable_struct->additional_filters.filters[cur_count].value, VK_MAX_EXTENSION_NAME_SIZE, actual_start,
  353|      0|                           stored_len);
  354|      0|            disable_struct->additional_filters.filters[cur_count].value[stored_len] = '\0';
  355|      0|            disable_struct->additional_filters.filters[cur_count].length = stored_len;
  356|      0|            disable_struct->additional_filters.filters[cur_count].type = cur_filter_type;
  357|      0|            disable_struct->additional_filters.count++;
  358|      0|            if (disable_struct->additional_filters.count >= MAX_ADDITIONAL_FILTERS) {
  ------------------
  |  |  529|      0|#define MAX_ADDITIONAL_FILTERS 16
  ------------------
  |  Branch (358:17): [True: 0, False: 0]
  ------------------
  359|      0|                break;
  360|      0|            }
  361|      0|        }
  362|      0|        token = thread_safe_strtok(NULL, ",", &context);
  363|      0|    }
  364|  7.00k|out:
  365|  7.00k|    loader_instance_heap_free(inst, parsing_string);
  366|  7.00k|    loader_free_getenv(env_var_value, inst);
  367|  7.00k|    return result;
  368|      0|}
parse_layer_environment_var_filters:
  371|  7.00k|VkResult parse_layer_environment_var_filters(const struct loader_instance *inst, struct loader_envvar_all_filters *layer_filters) {
  372|  7.00k|    VkResult res = parse_generic_filter_environment_var(inst, VK_LAYERS_ENABLE_ENV_VAR, &layer_filters->enable_filter);
  ------------------
  |  |  119|  7.00k|#define VK_LAYERS_ENABLE_ENV_VAR "VK_LOADER_LAYERS_ENABLE"
  ------------------
  373|  7.00k|    if (VK_SUCCESS != res) {
  ------------------
  |  Branch (373:9): [True: 0, False: 7.00k]
  ------------------
  374|      0|        return res;
  375|      0|    }
  376|  7.00k|    res = parse_layers_disable_filter_environment_var(inst, &layer_filters->disable_filter);
  377|  7.00k|    if (VK_SUCCESS != res) {
  ------------------
  |  Branch (377:9): [True: 0, False: 7.00k]
  ------------------
  378|      0|        return res;
  379|      0|    }
  380|  7.00k|    res = parse_generic_filter_environment_var(inst, VK_LAYERS_ALLOW_ENV_VAR, &layer_filters->allow_filter);
  ------------------
  |  |  121|  7.00k|#define VK_LAYERS_ALLOW_ENV_VAR "VK_LOADER_LAYERS_ALLOW"
  ------------------
  381|  7.00k|    if (VK_SUCCESS != res) {
  ------------------
  |  Branch (381:9): [True: 0, False: 7.00k]
  ------------------
  382|      0|        return res;
  383|      0|    }
  384|  7.00k|    return res;
  385|  7.00k|}
check_name_matches_filter_environment_var:
  405|  25.3k|bool check_name_matches_filter_environment_var(const char *name, const struct loader_envvar_filter *filter_struct) {
  406|  25.3k|    bool ret_value = false;
  407|  25.3k|    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|  37.9k|    for (uint32_t filt = 0; filt < filter_struct->count; ++filt) {
  ------------------
  |  Branch (411:29): [True: 12.6k, False: 25.2k]
  ------------------
  412|  12.6k|        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|  12.6k|        if (filter->length > name_len) {
  ------------------
  |  Branch (414:13): [True: 3.38k, False: 9.28k]
  ------------------
  415|  3.38k|            continue;
  416|  3.38k|        }
  417|  9.28k|        switch (filter->type) {
  ------------------
  |  Branch (417:17): [True: 9.28k, False: 0]
  ------------------
  418|      0|            case FILTER_STRING_SPECIAL:
  ------------------
  |  Branch (418:13): [True: 0, False: 9.28k]
  ------------------
  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: 9.28k]
  ------------------
  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: 9.28k]
  ------------------
  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: 9.28k]
  ------------------
  441|      0|                ret_value = name_segment_matches_filter_value(name, filter->value, filter->length);
  442|      0|                break;
  443|       |
  444|  9.28k|            case FILTER_STRING_FULLNAME:
  ------------------
  |  Branch (444:13): [True: 9.28k, False: 0]
  ------------------
  445|  9.28k|                ret_value = (name_len == filter->length) && name_segment_matches_filter_value(name, filter->value, filter->length);
  ------------------
  |  Branch (445:29): [True: 559, False: 8.72k]
  |  Branch (445:61): [True: 71, False: 488]
  ------------------
  446|  9.28k|                break;
  447|  9.28k|        }
  448|  9.28k|        if (ret_value) {
  ------------------
  |  Branch (448:13): [True: 71, False: 9.21k]
  ------------------
  449|     71|            break;
  450|     71|        }
  451|  9.28k|    }
  452|  25.3k|    return ret_value;
  453|  25.3k|}
loader_environment.c:name_segment_matches_filter_value:
  390|    559|static bool name_segment_matches_filter_value(const char *name_segment, const char *lowercase_filter_value, size_t count) {
  391|    798|    for (size_t iii = 0; iii < count; ++iii) {
  ------------------
  |  Branch (391:26): [True: 727, False: 71]
  ------------------
  392|    727|        if ((char)tolower((unsigned char)name_segment[iii]) != lowercase_filter_value[iii]) {
  ------------------
  |  Branch (392:13): [True: 488, False: 239]
  |  Branch (392:19): [True: 0, False: 0]
  |  Branch (392:19): [True: 0, False: 0]
  |  Branch (392:19): [Folded, False: 727]
  ------------------
  393|    488|            return false;
  394|    488|        }
  395|    727|    }
  396|     71|    return true;
  397|    559|}

loader_get_json:
  160|  15.4k|TEST_FUNCTION_EXPORT VkResult loader_get_json(const struct loader_instance *inst, const char *filename, cJSON **json) {
  161|  15.4k|    char *json_buf = NULL;
  162|  15.4k|    VkResult res = VK_SUCCESS;
  163|       |
  164|  15.4k|    assert(json != NULL);
  165|       |
  166|  15.4k|    size_t json_len = 0;
  167|  15.4k|    *json = NULL;
  168|  15.4k|    res = loader_read_entire_file(inst, filename, &json_len, &json_buf);
  169|  15.4k|    if (VK_SUCCESS != res) {
  ------------------
  |  Branch (169:9): [True: 165, False: 15.2k]
  ------------------
  170|    165|        goto out;
  171|    165|    }
  172|  15.4k|    bool out_of_memory = false;
  173|       |    // Parse text from file
  174|  15.2k|    *json = loader_cJSON_ParseWithLength(inst ? &inst->alloc_callbacks : NULL, json_buf, json_len, &out_of_memory);
  ------------------
  |  Branch (174:42): [True: 15.2k, False: 0]
  ------------------
  175|  15.2k|    if (out_of_memory) {
  ------------------
  |  Branch (175:9): [True: 0, False: 15.2k]
  ------------------
  176|      0|        loader_log(inst, VULKAN_LOADER_ERROR_BIT, 0, "loader_get_json: Out of Memory error occurred while parsing JSON file %s.",
  177|      0|                   filename);
  178|      0|        res = VK_ERROR_OUT_OF_HOST_MEMORY;
  179|      0|        goto out;
  180|  15.2k|    } else if (*json == NULL) {
  ------------------
  |  Branch (180:16): [True: 6.40k, False: 8.88k]
  ------------------
  181|  6.40k|        loader_log(inst, VULKAN_LOADER_ERROR_BIT, 0, "loader_get_json: Invalid JSON file %s.", filename);
  182|  6.40k|        goto out;
  183|  6.40k|    }
  184|       |
  185|  15.4k|out:
  186|  15.4k|    loader_instance_heap_free(inst, json_buf);
  187|  15.4k|    if (res != VK_SUCCESS && *json != NULL) {
  ------------------
  |  Branch (187:9): [True: 165, False: 15.2k]
  |  Branch (187:30): [True: 0, False: 165]
  ------------------
  188|      0|        loader_cJSON_Delete(*json);
  189|      0|        *json = NULL;
  190|      0|    }
  191|       |
  192|  15.4k|    return res;
  193|  15.2k|}
loader_parse_json_string_to_existing_str:
  195|  52.6k|VkResult loader_parse_json_string_to_existing_str(cJSON *object, const char *key, size_t out_str_len, char *out_string) {
  196|  52.6k|    if (NULL == key) {
  ------------------
  |  Branch (196:9): [True: 0, False: 52.6k]
  ------------------
  197|      0|        return VK_ERROR_INITIALIZATION_FAILED;
  198|      0|    }
  199|  52.6k|    cJSON *item = loader_cJSON_GetObjectItem(object, key);
  200|  52.6k|    if (NULL == item) {
  ------------------
  |  Branch (200:9): [True: 7.72k, False: 44.9k]
  ------------------
  201|  7.72k|        return VK_ERROR_INITIALIZATION_FAILED;
  202|  7.72k|    }
  203|       |
  204|  44.9k|    if (item->type != cJSON_String || item->valuestring == NULL) {
  ------------------
  |  |  101|  89.8k|#define cJSON_String (1 << 4)
  ------------------
  |  Branch (204:9): [True: 49, False: 44.8k]
  |  Branch (204:39): [True: 0, False: 44.8k]
  ------------------
  205|     49|        return VK_ERROR_INITIALIZATION_FAILED;
  206|     49|    }
  207|  44.9k|    bool out_of_memory = false;
  208|  44.8k|    bool success = loader_cJSON_PrintPreallocated(item, out_string, (int)out_str_len, cJSON_False);
  ------------------
  |  |   97|  44.8k|#define cJSON_False (1 << 0)
  ------------------
  209|  44.8k|    if (out_of_memory) {
  ------------------
  |  Branch (209:9): [True: 0, False: 44.8k]
  ------------------
  210|      0|        return VK_ERROR_OUT_OF_HOST_MEMORY;
  211|      0|    }
  212|  44.8k|    if (!success) {
  ------------------
  |  Branch (212:9): [True: 370, False: 44.5k]
  ------------------
  213|    370|        return VK_ERROR_INITIALIZATION_FAILED;
  214|    370|    }
  215|  44.5k|    return VK_SUCCESS;
  216|  44.8k|}
loader_parse_json_string:
  218|  72.8k|VkResult loader_parse_json_string(cJSON *object, const char *key, char **out_string) {
  219|  72.8k|    if (NULL == key) {
  ------------------
  |  Branch (219:9): [True: 0, False: 72.8k]
  ------------------
  220|      0|        return VK_ERROR_INITIALIZATION_FAILED;
  221|      0|    }
  222|       |
  223|  72.8k|    cJSON *item = loader_cJSON_GetObjectItem(object, key);
  224|  72.8k|    if (NULL == item || NULL == item->valuestring) {
  ------------------
  |  Branch (224:9): [True: 18.9k, False: 53.8k]
  |  Branch (224:25): [True: 180, False: 53.6k]
  ------------------
  225|  19.1k|        return VK_ERROR_INITIALIZATION_FAILED;
  226|  19.1k|    }
  227|       |
  228|  72.8k|    bool out_of_memory = false;
  229|  53.6k|    char *str = loader_cJSON_Print(item, &out_of_memory);
  230|  53.6k|    if (out_of_memory || NULL == str) {
  ------------------
  |  Branch (230:9): [True: 0, False: 53.6k]
  |  Branch (230:26): [True: 0, False: 53.6k]
  ------------------
  231|      0|        return VK_ERROR_OUT_OF_HOST_MEMORY;
  232|      0|    }
  233|  53.6k|    if (NULL != out_string) {
  ------------------
  |  Branch (233:9): [True: 53.6k, False: 0]
  ------------------
  234|  53.6k|        *out_string = str;
  235|  53.6k|    }
  236|  53.6k|    return VK_SUCCESS;
  237|  53.6k|}
loader_parse_json_array_of_strings:
  239|  28.0k|                                            struct loader_string_list *string_list) {
  240|  28.0k|    if (NULL == key) {
  ------------------
  |  Branch (240:9): [True: 0, False: 28.0k]
  ------------------
  241|      0|        return VK_ERROR_INITIALIZATION_FAILED;
  242|      0|    }
  243|  28.0k|    cJSON *item = loader_cJSON_GetObjectItem(object, key);
  244|  28.0k|    if (NULL == item) {
  ------------------
  |  Branch (244:9): [True: 16.1k, False: 11.9k]
  ------------------
  245|  16.1k|        return VK_ERROR_INITIALIZATION_FAILED;
  246|  16.1k|    }
  247|       |
  248|  11.9k|    uint32_t count = loader_cJSON_GetArraySize(item);
  249|  11.9k|    if (count == 0) {
  ------------------
  |  Branch (249:9): [True: 5.69k, False: 6.23k]
  ------------------
  250|  5.69k|        return VK_SUCCESS;
  251|  5.69k|    }
  252|       |
  253|  6.23k|    VkResult res = create_string_list(inst, count, string_list);
  254|  6.23k|    if (VK_ERROR_OUT_OF_HOST_MEMORY == res) {
  ------------------
  |  Branch (254:9): [True: 0, False: 6.23k]
  ------------------
  255|      0|        goto out;
  256|      0|    }
  257|  6.23k|    cJSON *element = NULL;
  258|  50.7k|    cJSON_ArrayForEach(element, item) {
  ------------------
  |  |  213|  56.6k|    for (element = (array != NULL) ? (array)->child : NULL; element != NULL; element = element->next)
  |  |  ------------------
  |  |  |  Branch (213:20): [True: 6.23k, False: 0]
  |  |  |  Branch (213:61): [True: 50.7k, False: 5.92k]
  |  |  ------------------
  ------------------
  259|  50.7k|        if (element->type != cJSON_String) {
  ------------------
  |  |  101|  50.7k|#define cJSON_String (1 << 4)
  ------------------
  |  Branch (259:13): [True: 317, False: 50.4k]
  ------------------
  260|    317|            return VK_ERROR_INITIALIZATION_FAILED;
  261|    317|        }
  262|  50.7k|        bool out_of_memory = false;
  263|  50.4k|        char *out_data = loader_cJSON_Print(element, &out_of_memory);
  264|  50.4k|        if (out_of_memory) {
  ------------------
  |  Branch (264:13): [True: 0, False: 50.4k]
  ------------------
  265|      0|            res = VK_ERROR_OUT_OF_HOST_MEMORY;
  266|      0|            goto out;
  267|      0|        }
  268|  50.4k|        res = append_str_to_string_list(inst, string_list, out_data);
  269|  50.4k|        if (VK_ERROR_OUT_OF_HOST_MEMORY == res) {
  ------------------
  |  Branch (269:13): [True: 0, False: 50.4k]
  ------------------
  270|      0|            goto out;
  271|      0|        }
  272|  50.4k|    }
  273|  5.92k|out:
  274|  5.92k|    if (res == VK_ERROR_OUT_OF_HOST_MEMORY && NULL != string_list->list) {
  ------------------
  |  Branch (274:9): [True: 0, False: 5.92k]
  |  Branch (274:47): [True: 0, False: 0]
  ------------------
  275|      0|        free_string_list(inst, string_list);
  276|      0|    }
  277|       |
  278|  5.92k|    return res;
  279|  6.23k|}
loader_json.c:loader_read_entire_file:
  110|  15.4k|                                        char **out_buff) {
  111|  15.4k|    FILE *file = NULL;
  112|  15.4k|    struct stat stats = {0};
  113|  15.4k|    VkResult res = VK_SUCCESS;
  114|       |
  115|       |    // fprintf(stderr, "loader_get_json: Reading JSON file %s\n", filename);
  116|  15.4k|    file = fopen(filename, "rb");
  117|  15.4k|#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
  118|  15.4k|    if (file == NULL) {
  ------------------
  |  Branch (118:9): [True: 738, False: 14.7k]
  ------------------
  119|    738|        create_callback_file(filename);
  120|    738|        file = fopen(filename, "rb");
  121|    738|    }
  122|  15.4k|#endif
  123|  15.4k|    if (NULL == file) {
  ------------------
  |  Branch (123:9): [True: 78, False: 15.3k]
  ------------------
  124|     78|        loader_log(inst, VULKAN_LOADER_ERROR_BIT, 0, "loader_get_json: Failed to open JSON file %s", filename);
  125|     78|        res = VK_ERROR_INITIALIZATION_FAILED;
  126|     78|        goto out;
  127|     78|    }
  128|  15.3k|    if (-1 == fstat(fileno(file), &stats)) {
  ------------------
  |  Branch (128:9): [True: 0, False: 15.3k]
  ------------------
  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|  15.3k|    *out_buff = (char *)loader_instance_heap_calloc(inst, stats.st_size + 1, VK_SYSTEM_ALLOCATION_SCOPE_COMMAND);
  134|  15.3k|    if (NULL == *out_buff) {
  ------------------
  |  Branch (134:9): [True: 0, False: 15.3k]
  ------------------
  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|  15.3k|    if (stats.st_size != (long int)fread(*out_buff, sizeof(char), stats.st_size, file)) {
  ------------------
  |  Branch (139:9): [True: 87, False: 15.2k]
  ------------------
  140|     87|        loader_log(inst, VULKAN_LOADER_ERROR_BIT, 0, "loader_get_json: Failed to read entire JSON file %s", filename);
  141|     87|        res = VK_ERROR_INITIALIZATION_FAILED;
  142|     87|        goto out;
  143|     87|    }
  144|  15.2k|    *out_len = stats.st_size + 1;
  145|  15.2k|    (*out_buff)[stats.st_size] = '\0';
  146|       |
  147|  15.4k|out:
  148|  15.4k|    if (NULL != file) {
  ------------------
  |  Branch (148:9): [True: 15.3k, False: 78]
  ------------------
  149|  15.3k|        fclose(file);
  150|  15.3k|    }
  151|  15.4k|    return res;
  152|  15.2k|}

loader_init_global_debug_level:
   42|      2|void loader_init_global_debug_level(void) {
   43|      2|    char *env, *orig;
   44|       |
   45|      2|    if (g_loader_debug > 0) return;
  ------------------
  |  Branch (45:9): [True: 0, False: 2]
  ------------------
   46|       |
   47|      2|    g_loader_debug = 0;
   48|       |
   49|       |    // Parse comma-separated debug options
   50|      2|    orig = env = loader_getenv("VK_LOADER_DEBUG", NULL);
   51|      2|    while (env) {
  ------------------
  |  Branch (51:12): [True: 0, False: 2]
  ------------------
   52|      0|        char *p = strchr(env, ',');
   53|      0|        size_t len;
   54|       |
   55|      0|        if (p) {
  ------------------
  |  Branch (55:13): [True: 0, False: 0]
  ------------------
   56|      0|            len = p - env;
   57|      0|        } else {
   58|      0|            len = strlen(env);
   59|      0|        }
   60|       |
   61|      0|        if (len > 0) {
  ------------------
  |  Branch (61:13): [True: 0, False: 0]
  ------------------
   62|      0|            if (strncmp(env, "all", len) == 0) {
  ------------------
  |  Branch (62:17): [True: 0, False: 0]
  ------------------
   63|      0|                g_loader_debug = ~0u;
   64|      0|            } else if (strncmp(env, "warn", len) == 0) {
  ------------------
  |  Branch (64:24): [True: 0, False: 0]
  ------------------
   65|      0|                g_loader_debug |= VULKAN_LOADER_WARN_BIT;
   66|      0|            } else if (strncmp(env, "info", len) == 0) {
  ------------------
  |  Branch (66:24): [True: 0, False: 0]
  ------------------
   67|      0|                g_loader_debug |= VULKAN_LOADER_INFO_BIT;
   68|      0|            } else if (strncmp(env, "perf", len) == 0) {
  ------------------
  |  Branch (68:24): [True: 0, False: 0]
  ------------------
   69|      0|                g_loader_debug |= VULKAN_LOADER_PERF_BIT;
   70|      0|            } else if (strncmp(env, "error", len) == 0) {
  ------------------
  |  Branch (70:24): [True: 0, False: 0]
  ------------------
   71|      0|                g_loader_debug |= VULKAN_LOADER_ERROR_BIT;
   72|      0|            } else if (strncmp(env, "debug", len) == 0) {
  ------------------
  |  Branch (72:24): [True: 0, False: 0]
  ------------------
   73|      0|                g_loader_debug |= VULKAN_LOADER_DEBUG_BIT;
   74|      0|            } else if (strncmp(env, "layer", len) == 0) {
  ------------------
  |  Branch (74:24): [True: 0, False: 0]
  ------------------
   75|      0|                g_loader_debug |= VULKAN_LOADER_LAYER_BIT;
   76|      0|            } else if (strncmp(env, "driver", len) == 0 || strncmp(env, "implem", len) == 0 || strncmp(env, "icd", len) == 0) {
  ------------------
  |  Branch (76:24): [True: 0, False: 0]
  |  Branch (76:60): [True: 0, False: 0]
  |  Branch (76:96): [True: 0, False: 0]
  ------------------
   77|      0|                g_loader_debug |= VULKAN_LOADER_DRIVER_BIT;
   78|      0|            }
   79|      0|        }
   80|       |
   81|      0|        if (!p) break;
  ------------------
  |  Branch (81:13): [True: 0, False: 0]
  ------------------
   82|       |
   83|      0|        env = p + 1;
   84|      0|    }
   85|       |
   86|       |    loader_free_getenv(orig, NULL);
   87|      2|}
generate_debug_flag_str:
   91|  2.64k|void generate_debug_flag_str(VkFlags msg_type, size_t cmd_line_size, char *cmd_line_msg) {
   92|  2.64k|    cmd_line_msg[0] = '\0';
   93|       |
   94|  2.64k|    if ((msg_type & VULKAN_LOADER_ERROR_BIT) != 0) {
  ------------------
  |  Branch (94:9): [True: 102, False: 2.53k]
  ------------------
   95|    102|        loader_strncat(cmd_line_msg, cmd_line_size, "ERROR", sizeof("ERROR"));
   96|    102|    }
   97|  2.64k|    if ((msg_type & VULKAN_LOADER_WARN_BIT) != 0) {
  ------------------
  |  Branch (97:9): [True: 108, False: 2.53k]
  ------------------
   98|    108|        if (strlen(cmd_line_msg) > 0) {
  ------------------
  |  Branch (98:13): [True: 92, False: 16]
  ------------------
   99|     92|            loader_strncat(cmd_line_msg, cmd_line_size, " | ", sizeof(" | "));
  100|     92|        }
  101|    108|        loader_strncat(cmd_line_msg, cmd_line_size, "WARNING", sizeof("WARNING"));
  102|    108|    }
  103|  2.64k|    if ((msg_type & VULKAN_LOADER_INFO_BIT) != 0) {
  ------------------
  |  Branch (103:9): [True: 111, False: 2.53k]
  ------------------
  104|    111|        if (strlen(cmd_line_msg) > 0) {
  ------------------
  |  Branch (104:13): [True: 94, False: 17]
  ------------------
  105|     94|            loader_strncat(cmd_line_msg, cmd_line_size, " | ", sizeof(" | "));
  106|     94|        }
  107|    111|        loader_strncat(cmd_line_msg, cmd_line_size, "INFO", sizeof("INFO"));
  108|    111|    }
  109|  2.64k|    if ((msg_type & VULKAN_LOADER_DEBUG_BIT) != 0) {
  ------------------
  |  Branch (109:9): [True: 107, False: 2.53k]
  ------------------
  110|    107|        if (strlen(cmd_line_msg) > 0) {
  ------------------
  |  Branch (110:13): [True: 101, False: 6]
  ------------------
  111|    101|            loader_strncat(cmd_line_msg, cmd_line_size, " | ", sizeof(" | "));
  112|    101|        }
  113|    107|        loader_strncat(cmd_line_msg, cmd_line_size, "DEBUG", sizeof("DEBUG"));
  114|    107|    }
  115|  2.64k|    if ((msg_type & VULKAN_LOADER_PERF_BIT) != 0) {
  ------------------
  |  Branch (115:9): [True: 109, False: 2.53k]
  ------------------
  116|    109|        if (strlen(cmd_line_msg) > 0) {
  ------------------
  |  Branch (116:13): [True: 95, False: 14]
  ------------------
  117|     95|            loader_strncat(cmd_line_msg, cmd_line_size, " | ", sizeof(" | "));
  118|     95|        }
  119|    109|        loader_strncat(cmd_line_msg, cmd_line_size, "PERF", sizeof("PERF"));
  120|    109|    }
  121|  2.64k|    if ((msg_type & VULKAN_LOADER_DRIVER_BIT) != 0) {
  ------------------
  |  Branch (121:9): [True: 95, False: 2.54k]
  ------------------
  122|     95|        if (strlen(cmd_line_msg) > 0) {
  ------------------
  |  Branch (122:13): [True: 91, False: 4]
  ------------------
  123|     91|            loader_strncat(cmd_line_msg, cmd_line_size, " | ", sizeof(" | "));
  124|     91|        }
  125|     95|        loader_strncat(cmd_line_msg, cmd_line_size, "DRIVER", sizeof("DRIVER"));
  126|     95|    }
  127|  2.64k|    if ((msg_type & VULKAN_LOADER_LAYER_BIT) != 0) {
  ------------------
  |  Branch (127:9): [True: 103, False: 2.53k]
  ------------------
  128|    103|        if (strlen(cmd_line_msg) > 0) {
  ------------------
  |  Branch (128:13): [True: 96, False: 7]
  ------------------
  129|     96|            loader_strncat(cmd_line_msg, cmd_line_size, " | ", sizeof(" | "));
  130|     96|        }
  131|    103|        loader_strncat(cmd_line_msg, cmd_line_size, "LAYER", sizeof("LAYER"));
  132|    103|    }
  133|       |
  134|  2.64k|#undef STRNCAT_TO_BUFFER
  135|  2.64k|}
loader_log:
  138|   358k|    loader_log(const struct loader_instance *inst, VkFlags msg_type, int32_t msg_code, const char *format, ...) {
  139|   358k|    (void)msg_code;
  140|   358k|    char msg[512] = {0};
  141|       |
  142|   358k|    va_list ap;
  143|   358k|    va_start(ap, format);
  144|   358k|    int ret = vsnprintf(msg, sizeof(msg), format, ap);
  145|   358k|    if ((ret >= (int)sizeof(msg)) || ret < 0) {
  ------------------
  |  Branch (145:9): [True: 354, False: 358k]
  |  Branch (145:38): [True: 0, False: 358k]
  ------------------
  146|    354|        msg[sizeof(msg) - 1] = '\0';
  147|    354|    }
  148|   358k|    va_end(ap);
  149|       |
  150|   358k|    if (inst) {
  ------------------
  |  Branch (150:9): [True: 358k, False: 2]
  ------------------
  151|   358k|        VkDebugUtilsMessageSeverityFlagBitsEXT severity = 0;
  152|   358k|        VkDebugUtilsMessageTypeFlagsEXT type = 0;
  153|   358k|        VkDebugUtilsMessengerCallbackDataEXT callback_data = {0};
  154|   358k|        VkDebugUtilsObjectNameInfoEXT object_name = {0};
  155|       |
  156|   358k|        if ((msg_type & VULKAN_LOADER_INFO_BIT) != 0) {
  ------------------
  |  Branch (156:13): [True: 68.6k, False: 290k]
  ------------------
  157|  68.6k|            severity = VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT;
  158|   290k|        } else if ((msg_type & VULKAN_LOADER_WARN_BIT) != 0) {
  ------------------
  |  Branch (158:20): [True: 65.0k, False: 225k]
  ------------------
  159|  65.0k|            severity = VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT;
  160|   225k|        } else if ((msg_type & VULKAN_LOADER_ERROR_BIT) != 0) {
  ------------------
  |  Branch (160:20): [True: 13.7k, False: 211k]
  ------------------
  161|  13.7k|            severity = VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT;
  162|   211k|        } else if ((msg_type & VULKAN_LOADER_DEBUG_BIT) != 0) {
  ------------------
  |  Branch (162:20): [True: 91.9k, False: 119k]
  ------------------
  163|  91.9k|            severity = VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT;
  164|   119k|        } else if ((msg_type & VULKAN_LOADER_LAYER_BIT) != 0 || (msg_type & VULKAN_LOADER_DRIVER_BIT) != 0) {
  ------------------
  |  Branch (164:20): [True: 119k, False: 43]
  |  Branch (164:65): [True: 43, False: 0]
  ------------------
  165|       |            // Just driver or just layer bit should be treated as an info message in debug utils.
  166|   119k|            severity = VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT;
  167|   119k|        }
  168|       |
  169|   358k|        if ((msg_type & VULKAN_LOADER_PERF_BIT) != 0) {
  ------------------
  |  Branch (169:13): [True: 0, False: 358k]
  ------------------
  170|      0|            type = VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT;
  171|   358k|        } else if ((msg_type & VULKAN_LOADER_VALIDATION_BIT) != 0) {
  ------------------
  |  Branch (171:20): [True: 0, False: 358k]
  ------------------
  172|       |            // For loader logging, if it's a validation message, we still want to also keep the general flag as well
  173|       |            // so messages of type validation can still be triggered for general message callbacks.
  174|      0|            type = VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT;
  175|   358k|        } else {
  176|   358k|            type = VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT;
  177|   358k|        }
  178|       |
  179|   358k|        callback_data.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_MESSENGER_CALLBACK_DATA_EXT;
  180|   358k|        callback_data.pMessageIdName = "Loader Message";
  181|   358k|        callback_data.pMessage = msg;
  182|   358k|        callback_data.objectCount = 1;
  183|   358k|        callback_data.pObjects = &object_name;
  184|   358k|        object_name.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT;
  185|   358k|        object_name.objectType = VK_OBJECT_TYPE_INSTANCE;
  186|   358k|        object_name.objectHandle = (uint64_t)(uintptr_t)inst;
  187|       |
  188|   358k|        util_SubmitDebugUtilsMessageEXT(inst, severity, type, &callback_data);
  189|   358k|    }
  190|       |
  191|       |    // Always log to stderr if this is a fatal error
  192|   358k|    if (0 == (msg_type & VULKAN_LOADER_FATAL_ERROR_BIT)) {
  ------------------
  |  Branch (192:9): [True: 358k, False: 0]
  ------------------
  193|   358k|        if (inst && inst->settings.settings_active && inst->settings.debug_level > 0) {
  ------------------
  |  Branch (193:13): [True: 358k, False: 2]
  |  Branch (193:21): [True: 144k, False: 214k]
  |  Branch (193:55): [True: 19.4k, False: 125k]
  ------------------
  194|       |            // Exit early if the current instance settings have some debugging options but do match the current msg_type
  195|  19.4k|            if (0 == (msg_type & inst->settings.debug_level)) {
  ------------------
  |  Branch (195:17): [True: 2.29k, False: 17.1k]
  ------------------
  196|  2.29k|                return;
  197|  2.29k|            }
  198|       |            // Check the global settings and if that doesn't say to skip, check the environment variable
  199|   339k|        } else if (0 == (msg_type & g_loader_debug)) {
  ------------------
  |  Branch (199:20): [True: 339k, False: 0]
  ------------------
  200|   339k|            return;
  201|   339k|        }
  202|   358k|    }
  203|       |
  204|       |#if defined(DEBUG)
  205|       |    int debug_flag_mask =
  206|       |        msg_type & (VULKAN_LOADER_ERROR_BIT | VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_INFO_BIT | VULKAN_LOADER_DEBUG_BIT);
  207|       |    assert((debug_flag_mask == 0 || debug_flag_mask == VULKAN_LOADER_ERROR_BIT || debug_flag_mask == VULKAN_LOADER_WARN_BIT ||
  208|       |            debug_flag_mask == VULKAN_LOADER_INFO_BIT || debug_flag_mask == VULKAN_LOADER_DEBUG_BIT) &&
  209|       |           "This log has more than one exclusive debug flags (error, warn, info, debug) set");
  210|       |#endif
  211|       |
  212|       |    // Only need enough space to create the filter description header for log messages
  213|       |    // Also use the same header for all output
  214|  17.1k|    char cmd_line_msg[64] = {0};
  215|  17.1k|    size_t cmd_line_size = sizeof(cmd_line_msg);
  216|       |
  217|  17.1k|    loader_strncat(cmd_line_msg, cmd_line_size, "[Vulkan Loader] ", sizeof("[Vulkan Loader] "));
  218|       |
  219|  17.1k|    bool need_separator = false;
  220|  17.1k|    if ((msg_type & VULKAN_LOADER_ERROR_BIT) != 0) {
  ------------------
  |  Branch (220:9): [True: 499, False: 16.6k]
  ------------------
  221|    499|        loader_strncat(cmd_line_msg, cmd_line_size, "ERROR", sizeof("ERROR"));
  222|    499|        need_separator = true;
  223|  16.6k|    } else if ((msg_type & VULKAN_LOADER_WARN_BIT) != 0) {
  ------------------
  |  Branch (223:16): [True: 5.13k, False: 11.5k]
  ------------------
  224|  5.13k|        loader_strncat(cmd_line_msg, cmd_line_size, "WARNING", sizeof("WARNING"));
  225|  5.13k|        need_separator = true;
  226|  11.5k|    } else if ((msg_type & VULKAN_LOADER_INFO_BIT) != 0) {
  ------------------
  |  Branch (226:16): [True: 3.40k, False: 8.11k]
  ------------------
  227|  3.40k|        loader_strncat(cmd_line_msg, cmd_line_size, "INFO", sizeof("INFO"));
  228|  3.40k|        need_separator = true;
  229|  8.11k|    } else if ((msg_type & VULKAN_LOADER_DEBUG_BIT) != 0) {
  ------------------
  |  Branch (229:16): [True: 6.36k, False: 1.75k]
  ------------------
  230|  6.36k|        loader_strncat(cmd_line_msg, cmd_line_size, "DEBUG", sizeof("DEBUG"));
  231|  6.36k|        need_separator = true;
  232|  6.36k|    }
  233|       |
  234|  17.1k|    if ((msg_type & VULKAN_LOADER_PERF_BIT) != 0) {
  ------------------
  |  Branch (234:9): [True: 0, False: 17.1k]
  ------------------
  235|      0|        if (need_separator) {
  ------------------
  |  Branch (235:13): [True: 0, False: 0]
  ------------------
  236|      0|            loader_strncat(cmd_line_msg, cmd_line_size, " | ", sizeof(" | "));
  237|      0|        }
  238|      0|        loader_strncat(cmd_line_msg, cmd_line_size, "PERF", sizeof("PERF"));
  239|  17.1k|    } else if ((msg_type & VULKAN_LOADER_DRIVER_BIT) != 0) {
  ------------------
  |  Branch (239:16): [True: 0, False: 17.1k]
  ------------------
  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, "DRIVER", sizeof("DRIVER"));
  244|  17.1k|    } else if ((msg_type & VULKAN_LOADER_LAYER_BIT) != 0) {
  ------------------
  |  Branch (244:16): [True: 5.01k, False: 12.1k]
  ------------------
  245|  5.01k|        if (need_separator) {
  ------------------
  |  Branch (245:13): [True: 3.26k, False: 1.75k]
  ------------------
  246|  3.26k|            loader_strncat(cmd_line_msg, cmd_line_size, " | ", sizeof(" | "));
  247|  3.26k|        }
  248|  5.01k|        loader_strncat(cmd_line_msg, cmd_line_size, "LAYER", sizeof("LAYER"));
  249|  5.01k|    }
  250|       |
  251|  17.1k|    loader_strncat(cmd_line_msg, cmd_line_size, ": ", sizeof(": "));
  252|  17.1k|    size_t num_used = strlen(cmd_line_msg);
  253|       |
  254|       |    // Justifies the output to at least 29 spaces
  255|  17.1k|    if (num_used < 32) {
  ------------------
  |  Branch (255:9): [True: 16.7k, False: 354]
  ------------------
  256|  16.7k|        const char space_buffer[] = "                                ";
  257|       |        // Only write (32 - num_used) spaces
  258|  16.7k|        loader_strncat(cmd_line_msg, cmd_line_size, space_buffer, sizeof(space_buffer) - 1 - num_used);
  259|  16.7k|    }
  260|       |    // Assert that we didn't write more than what is available in cmd_line_msg
  261|  17.1k|    assert(cmd_line_size > num_used);
  262|       |
  263|       |    //fputs(cmd_line_msg, stderr);
  264|       |    //fputs(msg, stderr);
  265|       |    //fputc('\n', stderr);
  266|       |#if defined(WIN32)
  267|       |    OutputDebugString(cmd_line_msg);
  268|       |    OutputDebugString(msg);
  269|       |    OutputDebugString("\n");
  270|       |#endif
  271|  17.1k|}

free_layer_configuration:
   41|  19.3k|void free_layer_configuration(const struct loader_instance* inst, loader_settings_layer_configuration* layer_configuration) {
   42|  19.3k|    loader_instance_heap_free(inst, layer_configuration->name);
   43|  19.3k|    loader_instance_heap_free(inst, layer_configuration->path);
   44|  19.3k|    memset(layer_configuration, 0, sizeof(loader_settings_layer_configuration));
   45|  19.3k|}
free_loader_settings:
   57|  7.00k|void free_loader_settings(const struct loader_instance* inst, loader_settings* settings) {
   58|  7.00k|    if (NULL != settings->layer_configurations) {
  ------------------
  |  Branch (58:9): [True: 2.54k, False: 4.46k]
  ------------------
   59|  18.8k|        for (uint32_t i = 0; i < settings->layer_configuration_count; i++) {
  ------------------
  |  Branch (59:30): [True: 16.2k, False: 2.54k]
  ------------------
   60|  16.2k|            free_layer_configuration(inst, &settings->layer_configurations[i]);
   61|  16.2k|        }
   62|  2.54k|        loader_instance_heap_free(inst, settings->layer_configurations);
   63|  2.54k|    }
   64|  7.00k|    if (NULL != settings->additional_drivers) {
  ------------------
  |  Branch (64:9): [True: 0, False: 7.00k]
  ------------------
   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|  7.00k|    if (NULL != settings->device_configurations) {
  ------------------
  |  Branch (70:9): [True: 0, False: 7.00k]
  ------------------
   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|  7.00k|    loader_instance_heap_free(inst, settings->settings_file_path);
   77|  7.00k|    memset(settings, 0, sizeof(loader_settings));
   78|  7.00k|}
parse_control_string:
   80|  16.4k|loader_settings_layer_control parse_control_string(char* control_string) {
   81|  16.4k|    loader_settings_layer_control layer_control = LOADER_SETTINGS_LAYER_CONTROL_DEFAULT;
   82|  16.4k|    if (strcmp(control_string, "auto") == 0)
  ------------------
  |  Branch (82:9): [True: 1.20k, False: 15.2k]
  ------------------
   83|  1.20k|        layer_control = LOADER_SETTINGS_LAYER_CONTROL_DEFAULT;
   84|  15.2k|    else if (strcmp(control_string, "on") == 0)
  ------------------
  |  Branch (84:14): [True: 1.40k, False: 13.8k]
  ------------------
   85|  1.40k|        layer_control = LOADER_SETTINGS_LAYER_CONTROL_ON;
   86|  13.8k|    else if (strcmp(control_string, "off") == 0)
  ------------------
  |  Branch (86:14): [True: 1.84k, False: 12.0k]
  ------------------
   87|  1.84k|        layer_control = LOADER_SETTINGS_LAYER_CONTROL_OFF;
   88|  12.0k|    else if (strcmp(control_string, "unordered_layer_location") == 0)
  ------------------
  |  Branch (88:14): [True: 1.88k, False: 10.1k]
  ------------------
   89|  1.88k|        layer_control = LOADER_SETTINGS_LAYER_UNORDERED_LAYER_LOCATION;
   90|  16.4k|    return layer_control;
   91|  16.4k|}
loader_settings_layer_control_to_string:
   93|  16.2k|const char* loader_settings_layer_control_to_string(loader_settings_layer_control control) {
   94|  16.2k|    switch (control) {
   95|  11.1k|        case (LOADER_SETTINGS_LAYER_CONTROL_DEFAULT):
  ------------------
  |  Branch (95:9): [True: 11.1k, False: 5.12k]
  ------------------
   96|  11.1k|            return "auto";
   97|  1.40k|        case (LOADER_SETTINGS_LAYER_CONTROL_ON):
  ------------------
  |  Branch (97:9): [True: 1.40k, False: 14.8k]
  ------------------
   98|  1.40k|            return "on";
   99|  1.84k|        case (LOADER_SETTINGS_LAYER_CONTROL_OFF):
  ------------------
  |  Branch (99:9): [True: 1.84k, False: 14.4k]
  ------------------
  100|  1.84k|            return "off";
  101|  1.88k|        case (LOADER_SETTINGS_LAYER_UNORDERED_LAYER_LOCATION):
  ------------------
  |  Branch (101:9): [True: 1.88k, False: 14.3k]
  ------------------
  102|  1.88k|            return "unordered_layer_location";
  103|      0|        default:
  ------------------
  |  Branch (103:9): [True: 0, False: 16.2k]
  ------------------
  104|      0|            return "UNKNOWN_LAYER_CONTROl";
  105|  16.2k|    }
  106|  16.2k|}
parse_log_filters_from_strings:
  108|    357|uint32_t parse_log_filters_from_strings(struct loader_string_list* log_filters) {
  109|    357|    uint32_t filters = 0;
  110|  12.2k|    for (uint32_t i = 0; i < log_filters->count; i++) {
  ------------------
  |  Branch (110:26): [True: 11.9k, False: 357]
  ------------------
  111|  11.9k|        if (strcmp(log_filters->list[i], "all") == 0)
  ------------------
  |  Branch (111:13): [True: 233, False: 11.6k]
  ------------------
  112|    233|            filters |= VULKAN_LOADER_INFO_BIT | VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_PERF_BIT | VULKAN_LOADER_ERROR_BIT |
  113|    233|                       VULKAN_LOADER_DEBUG_BIT | VULKAN_LOADER_LAYER_BIT | VULKAN_LOADER_DRIVER_BIT | VULKAN_LOADER_VALIDATION_BIT;
  114|  11.6k|        else if (strcmp(log_filters->list[i], "info") == 0)
  ------------------
  |  Branch (114:18): [True: 876, False: 10.8k]
  ------------------
  115|    876|            filters |= VULKAN_LOADER_INFO_BIT;
  116|  10.8k|        else if (strcmp(log_filters->list[i], "warn") == 0)
  ------------------
  |  Branch (116:18): [True: 576, False: 10.2k]
  ------------------
  117|    576|            filters |= VULKAN_LOADER_WARN_BIT;
  118|  10.2k|        else if (strcmp(log_filters->list[i], "perf") == 0)
  ------------------
  |  Branch (118:18): [True: 462, False: 9.78k]
  ------------------
  119|    462|            filters |= VULKAN_LOADER_PERF_BIT;
  120|  9.78k|        else if (strcmp(log_filters->list[i], "error") == 0)
  ------------------
  |  Branch (120:18): [True: 190, False: 9.59k]
  ------------------
  121|    190|            filters |= VULKAN_LOADER_ERROR_BIT;
  122|  9.59k|        else if (strcmp(log_filters->list[i], "debug") == 0)
  ------------------
  |  Branch (122:18): [True: 1.01k, False: 8.57k]
  ------------------
  123|  1.01k|            filters |= VULKAN_LOADER_DEBUG_BIT;
  124|  8.57k|        else if (strcmp(log_filters->list[i], "layer") == 0)
  ------------------
  |  Branch (124:18): [True: 93, False: 8.48k]
  ------------------
  125|     93|            filters |= VULKAN_LOADER_LAYER_BIT;
  126|  8.48k|        else if (strcmp(log_filters->list[i], "driver") == 0)
  ------------------
  |  Branch (126:18): [True: 96, False: 8.38k]
  ------------------
  127|     96|            filters |= VULKAN_LOADER_DRIVER_BIT;
  128|  8.38k|        else if (strcmp(log_filters->list[i], "validation") == 0)
  ------------------
  |  Branch (128:18): [True: 47, False: 8.33k]
  ------------------
  129|     47|            filters |= VULKAN_LOADER_VALIDATION_BIT;
  130|  11.9k|    }
  131|    357|    return filters;
  132|    357|}
parse_layer_configuration:
  147|  16.4k|                                   loader_settings_layer_configuration* layer_configuration) {
  148|  16.4k|    char* control_string = NULL;
  149|  16.4k|    VkResult res = loader_parse_json_string(layer_configuration_json, "control", &control_string);
  150|  16.4k|    if (res != VK_SUCCESS) {
  ------------------
  |  Branch (150:9): [True: 13, False: 16.4k]
  ------------------
  151|     13|        goto out;
  152|     13|    }
  153|  16.4k|    layer_configuration->control = parse_control_string(control_string);
  154|  16.4k|    loader_instance_heap_free(inst, control_string);
  155|       |
  156|       |    // If that is the only value - do no further parsing
  157|  16.4k|    if (layer_configuration->control == LOADER_SETTINGS_LAYER_UNORDERED_LAYER_LOCATION) {
  ------------------
  |  Branch (157:9): [True: 1.88k, False: 14.5k]
  ------------------
  158|  1.88k|        goto out;
  159|  1.88k|    }
  160|       |
  161|  14.5k|    res = loader_parse_json_string(layer_configuration_json, "name", &(layer_configuration->name));
  162|  14.5k|    if (res != VK_SUCCESS) {
  ------------------
  |  Branch (162:9): [True: 124, False: 14.4k]
  ------------------
  163|    124|        goto out;
  164|    124|    }
  165|       |
  166|  14.4k|    res = loader_parse_json_string(layer_configuration_json, "path", &(layer_configuration->path));
  167|  14.4k|    if (res != VK_SUCCESS) {
  ------------------
  |  Branch (167:9): [True: 7, False: 14.4k]
  ------------------
  168|      7|        goto out;
  169|      7|    }
  170|       |
  171|  14.4k|    cJSON* treat_as_implicit_manifest = loader_cJSON_GetObjectItem(layer_configuration_json, "treat_as_implicit_manifest");
  172|  14.4k|    if (treat_as_implicit_manifest && treat_as_implicit_manifest->type == cJSON_True) {
  ------------------
  |  |   98|    581|#define cJSON_True (1 << 1)
  ------------------
  |  Branch (172:9): [True: 581, False: 13.8k]
  |  Branch (172:39): [True: 414, False: 167]
  ------------------
  173|    414|        layer_configuration->treat_as_implicit_manifest = true;
  174|    414|    }
  175|  16.4k|out:
  176|  16.4k|    if (VK_SUCCESS != res) {
  ------------------
  |  Branch (176:9): [True: 144, False: 16.3k]
  ------------------
  177|    144|        free_layer_configuration(inst, layer_configuration);
  178|    144|    }
  179|  16.4k|    return res;
  180|  14.4k|}
parse_layer_configurations:
  182|  2.97k|VkResult parse_layer_configurations(const struct loader_instance* inst, cJSON* settings_object, loader_settings* loader_settings) {
  183|  2.97k|    VkResult res = VK_SUCCESS;
  184|       |
  185|  2.97k|    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|  2.97k|    if (NULL == layer_configurations) {
  ------------------
  |  Branch (187:9): [True: 273, False: 2.69k]
  ------------------
  188|    273|        return VK_SUCCESS;
  189|    273|    }
  190|       |
  191|  2.69k|    uint32_t layer_configurations_count = loader_cJSON_GetArraySize(layer_configurations);
  192|  2.69k|    if (layer_configurations_count == 0) {
  ------------------
  |  Branch (192:9): [True: 8, False: 2.69k]
  ------------------
  193|      8|        loader_settings->layer_configurations_active = true;
  194|      8|        return VK_SUCCESS;
  195|      8|    }
  196|       |
  197|  2.69k|    loader_settings->layer_configuration_count = layer_configurations_count;
  198|       |
  199|  2.69k|    loader_settings->layer_configurations = loader_instance_heap_calloc(
  200|  2.69k|        inst, sizeof(loader_settings_layer_configuration) * layer_configurations_count, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
  201|  2.69k|    if (NULL == loader_settings->layer_configurations) {
  ------------------
  |  Branch (201:9): [True: 0, False: 2.69k]
  ------------------
  202|      0|        res = VK_ERROR_OUT_OF_HOST_MEMORY;
  203|      0|        goto out;
  204|      0|    }
  205|       |
  206|  2.69k|    cJSON* layer = NULL;
  207|  2.69k|    size_t i = 0;
  208|  16.4k|    cJSON_ArrayForEach(layer, layer_configurations) {
  ------------------
  |  |  213|  19.0k|    for (element = (array != NULL) ? (array)->child : NULL; element != NULL; element = element->next)
  |  |  ------------------
  |  |  |  Branch (213:20): [True: 2.69k, False: 0]
  |  |  |  Branch (213:61): [True: 16.4k, False: 2.54k]
  |  |  ------------------
  ------------------
  209|  16.4k|        if (layer->type != cJSON_Object) {
  ------------------
  |  |  103|  16.4k|#define cJSON_Object (1 << 6)
  ------------------
  |  Branch (209:13): [True: 3, False: 16.4k]
  ------------------
  210|      3|            res = VK_ERROR_INITIALIZATION_FAILED;
  211|      3|            goto out;
  212|      3|        }
  213|  16.4k|        res = parse_layer_configuration(inst, layer, &(loader_settings->layer_configurations[i++]));
  214|  16.4k|        if (VK_SUCCESS != res) {
  ------------------
  |  Branch (214:13): [True: 144, False: 16.3k]
  ------------------
  215|    144|            goto out;
  216|    144|        }
  217|  16.4k|    }
  218|  2.54k|    loader_settings->layer_configurations_active = true;
  219|  2.69k|out:
  220|  2.69k|    if (res != VK_SUCCESS) {
  ------------------
  |  Branch (220:9): [True: 147, False: 2.54k]
  ------------------
  221|    147|        if (loader_settings->layer_configurations) {
  ------------------
  |  Branch (221:13): [True: 147, False: 0]
  ------------------
  222|  3.12k|            for (size_t index = 0; index < loader_settings->layer_configuration_count; index++) {
  ------------------
  |  Branch (222:36): [True: 2.97k, False: 147]
  ------------------
  223|  2.97k|                free_layer_configuration(inst, &(loader_settings->layer_configurations[index]));
  224|  2.97k|            }
  225|    147|            loader_settings->layer_configuration_count = 0;
  226|    147|            loader_instance_heap_free(inst, loader_settings->layer_configurations);
  227|    147|            loader_settings->layer_configurations = NULL;
  228|    147|        }
  229|    147|    }
  230|       |
  231|  2.69k|    return res;
  232|  2.54k|}
parse_additional_drivers:
  248|  2.97k|VkResult parse_additional_drivers(const struct loader_instance* inst, cJSON* settings_object, loader_settings* loader_settings) {
  249|  2.97k|    VkResult res = VK_SUCCESS;
  250|       |
  251|  2.97k|    cJSON* additional_drivers_use_exclusively_json =
  252|  2.97k|        loader_cJSON_GetObjectItem(settings_object, "additional_drivers_use_exclusively");
  253|  2.97k|    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: 2.97k]
  |  Branch (253:52): [True: 0, False: 0]
  ------------------
  254|      0|        loader_settings->additional_drivers_use_exclusively = true;
  255|      0|    }
  256|       |
  257|  2.97k|    cJSON* additional_drivers_json = loader_cJSON_GetObjectItem(settings_object, "additional_drivers");
  258|  2.97k|    if (NULL == additional_drivers_json) {
  ------------------
  |  Branch (258:9): [True: 2.97k, False: 0]
  ------------------
  259|  2.97k|        return VK_SUCCESS;
  260|  2.97k|    }
  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|  2.97k|VkResult parse_device_configurations(const struct loader_instance* inst, cJSON* settings_object, loader_settings* loader_settings) {
  376|  2.97k|    VkResult res = VK_SUCCESS;
  377|       |
  378|  2.97k|    cJSON* device_configurations = loader_cJSON_GetObjectItem(settings_object, "device_configurations");
  379|  2.97k|    if (NULL == device_configurations) {
  ------------------
  |  Branch (379:9): [True: 2.97k, False: 0]
  ------------------
  380|  2.97k|        return VK_SUCCESS;
  381|  2.97k|    }
  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|  31.1k|                                       char** settings_file_path) {
  438|  31.1k|    if (NULL == base || NULL == suffix) {
  ------------------
  |  Branch (438:9): [True: 14.0k, False: 17.1k]
  |  Branch (438:25): [True: 0, False: 17.1k]
  ------------------
  439|  14.0k|        return VK_ERROR_INITIALIZATION_FAILED;
  440|  14.0k|    }
  441|       |
  442|  17.1k|    size_t base_len = strlen(base);
  443|  17.1k|    size_t suffix_len = strlen(suffix);
  444|       |
  445|  17.1k|    uint32_t start = 0;
  446|  17.1k|    uint32_t stop = 0;
  447|  28.8k|    while (base[start] != '\0' && start < base_len && stop < base_len) {
  ------------------
  |  Branch (447:12): [True: 28.8k, False: 0]
  |  Branch (447:35): [True: 28.8k, False: 0]
  |  Branch (447:55): [True: 17.9k, False: 10.9k]
  ------------------
  448|  17.9k|        start = stop;
  449|  17.9k|        stop = start + 1;
  450|  97.7k|        while (base[stop] != PATH_SEPARATOR && base[stop] != '\0' && stop < base_len) {
  ------------------
  |  |  150|   195k|#define PATH_SEPARATOR ':'
  ------------------
  |  Branch (450:16): [True: 96.9k, False: 787]
  |  Branch (450:48): [True: 79.7k, False: 17.1k]
  |  Branch (450:70): [True: 79.7k, False: 0]
  ------------------
  451|  79.7k|            stop++;
  452|  79.7k|        }
  453|       |
  454|  17.9k|        size_t segment_len = (stop - start);
  455|  17.9k|        if (segment_len <= 1) {
  ------------------
  |  Branch (455:13): [True: 0, False: 17.9k]
  ------------------
  456|       |            // segment is *just* a PATH_SEPARATOR, skip it
  457|      0|            continue;
  458|      0|        }
  459|  17.9k|        size_t path_len = segment_len + suffix_len + 1;
  460|  17.9k|        *settings_file_path = loader_instance_heap_calloc(inst, path_len, VK_SYSTEM_ALLOCATION_SCOPE_COMMAND);
  461|  17.9k|        if (NULL == *settings_file_path) {
  ------------------
  |  Branch (461:13): [True: 0, False: 17.9k]
  ------------------
  462|      0|            return VK_ERROR_OUT_OF_HOST_MEMORY;
  463|      0|        }
  464|  17.9k|        loader_strncpy(*settings_file_path, path_len, base + start, segment_len);
  465|  17.9k|        loader_strncat(*settings_file_path, path_len, suffix, suffix_len);
  466|       |
  467|  17.9k|        if (loader_platform_file_exists(*settings_file_path)) {
  ------------------
  |  Branch (467:13): [True: 6.21k, False: 11.7k]
  ------------------
  468|  6.21k|            return VK_SUCCESS;
  469|  6.21k|        }
  470|  11.7k|        loader_instance_heap_free(inst, *settings_file_path);
  471|  11.7k|        *settings_file_path = NULL;
  472|  11.7k|    }
  473|       |
  474|  10.9k|    return VK_ERROR_INITIALIZATION_FAILED;
  475|  17.1k|}
get_unix_settings_path:
  478|  7.00k|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|  7.00k|    char* xdg_config_home = loader_secure_getenv("XDG_CONFIG_HOME", inst);
  481|  7.00k|    char* xdg_config_dirs = loader_secure_getenv("XDG_CONFIG_DIRS", inst);
  482|  7.00k|    char* xdg_data_home = loader_secure_getenv("XDG_DATA_HOME", inst);
  483|  7.00k|    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|  7.00k|#if !defined(__Fuchsia__) && !defined(__QNX__)
  487|  7.00k|    if (NULL == xdg_config_dirs || '\0' == xdg_config_dirs[0]) {
  ------------------
  |  Branch (487:9): [True: 7.00k, False: 0]
  |  Branch (487:36): [True: 0, False: 0]
  ------------------
  488|  7.00k|        xdg_config_dirs = FALLBACK_CONFIG_DIRS;
  489|  7.00k|    }
  490|  7.00k|#endif
  491|       |
  492|  7.00k|#if !defined(__Fuchsia__) && !defined(__QNX__)
  493|  7.00k|    if (NULL == xdg_data_dirs || '\0' == xdg_data_dirs[0]) {
  ------------------
  |  Branch (493:9): [True: 7.00k, False: 0]
  |  Branch (493:34): [True: 0, False: 0]
  ------------------
  494|  7.00k|        xdg_data_dirs = FALLBACK_DATA_DIRS;
  495|  7.00k|    }
  496|  7.00k|#endif
  497|       |
  498|  7.00k|    VkResult res = check_if_settings_path_exists(
  499|  7.00k|        inst, xdg_config_home, "/" VULKAN_DIR "/loader_settings.d/" VK_LOADER_SETTINGS_FILENAME, settings_file_path);
  ------------------
  |  |  141|  7.00k|#define VK_LOADER_SETTINGS_FILENAME "vk_loader_settings.json"
  ------------------
  500|  7.00k|    if (res == VK_SUCCESS) {
  ------------------
  |  Branch (500:9): [True: 0, False: 7.00k]
  ------------------
  501|      0|        return res;
  502|      0|    }
  503|       |
  504|  7.00k|    res = check_if_settings_path_exists(inst, xdg_data_home, "/" VULKAN_DIR "/loader_settings.d/" VK_LOADER_SETTINGS_FILENAME,
  ------------------
  |  |  141|  7.00k|#define VK_LOADER_SETTINGS_FILENAME "vk_loader_settings.json"
  ------------------
  505|  7.00k|                                        settings_file_path);
  506|  7.00k|    if (res == VK_SUCCESS) {
  ------------------
  |  Branch (506:9): [True: 0, False: 7.00k]
  ------------------
  507|      0|        return res;
  508|      0|    }
  509|       |
  510|       |    // Check home if either xdg_config_home or xdg_data_home wasn't set
  511|  7.00k|    char* home = loader_secure_getenv("HOME", inst);
  512|  7.00k|    if (home != NULL) {
  ------------------
  |  Branch (512:9): [True: 7.00k, False: 0]
  ------------------
  513|  7.00k|        if (NULL == xdg_config_home || '\0' == xdg_config_home[0]) {
  ------------------
  |  Branch (513:13): [True: 7.00k, False: 0]
  |  Branch (513:40): [True: 0, False: 0]
  ------------------
  514|  7.00k|            res = check_if_settings_path_exists(
  515|  7.00k|                inst, home, "/.config/" VULKAN_DIR "/loader_settings.d/" VK_LOADER_SETTINGS_FILENAME, settings_file_path);
  ------------------
  |  |  141|  7.00k|#define VK_LOADER_SETTINGS_FILENAME "vk_loader_settings.json"
  ------------------
  516|  7.00k|            if (res == VK_SUCCESS) {
  ------------------
  |  Branch (516:17): [True: 0, False: 7.00k]
  ------------------
  517|      0|                return res;
  518|      0|            }
  519|  7.00k|        }
  520|  7.00k|        if (NULL == xdg_data_home || '\0' == xdg_data_home[0]) {
  ------------------
  |  Branch (520:13): [True: 7.00k, False: 0]
  |  Branch (520:38): [True: 0, False: 0]
  ------------------
  521|  7.00k|            res = check_if_settings_path_exists(
  522|  7.00k|                inst, home, "/.local/share/" VULKAN_DIR "/loader_settings.d/" VK_LOADER_SETTINGS_FILENAME, settings_file_path);
  ------------------
  |  |  141|  7.00k|#define VK_LOADER_SETTINGS_FILENAME "vk_loader_settings.json"
  ------------------
  523|  7.00k|            if (res == VK_SUCCESS) {
  ------------------
  |  Branch (523:17): [True: 6.21k, False: 787]
  ------------------
  524|  6.21k|                return res;
  525|  6.21k|            }
  526|  7.00k|        }
  527|  7.00k|    }
  528|       |
  529|    787|    res = check_if_settings_path_exists(inst, xdg_config_dirs, "/" VULKAN_DIR "/loader_settings.d/" VK_LOADER_SETTINGS_FILENAME,
  ------------------
  |  |  141|    787|#define VK_LOADER_SETTINGS_FILENAME "vk_loader_settings.json"
  ------------------
  530|    787|                                        settings_file_path);
  531|    787|    if (res == VK_SUCCESS) {
  ------------------
  |  Branch (531:9): [True: 0, False: 787]
  ------------------
  532|      0|        return res;
  533|      0|    }
  534|       |
  535|    787|    res = check_if_settings_path_exists(inst, SYSCONFDIR, "/" VULKAN_DIR "/loader_settings.d/" VK_LOADER_SETTINGS_FILENAME,
  ------------------
  |  |  141|    787|#define VK_LOADER_SETTINGS_FILENAME "vk_loader_settings.json"
  ------------------
  536|    787|                                        settings_file_path);
  537|    787|    if (res == VK_SUCCESS) {
  ------------------
  |  Branch (537:9): [True: 0, False: 787]
  ------------------
  538|      0|        return res;
  539|      0|    }
  540|    787|#if defined(EXTRASYSCONFDIR)
  541|       |
  542|    787|    res = check_if_settings_path_exists(inst, EXTRASYSCONFDIR, "/" VULKAN_DIR "/loader_settings.d/" VK_LOADER_SETTINGS_FILENAME,
  ------------------
  |  |  141|    787|#define VK_LOADER_SETTINGS_FILENAME "vk_loader_settings.json"
  ------------------
  543|    787|                                        settings_file_path);
  544|    787|    if (res == VK_SUCCESS) {
  ------------------
  |  Branch (544:9): [True: 0, False: 787]
  ------------------
  545|      0|        return res;
  546|      0|    }
  547|    787|#endif
  548|    787|    res = check_if_settings_path_exists(inst, xdg_data_dirs, "/" VULKAN_DIR "/loader_settings.d/" VK_LOADER_SETTINGS_FILENAME,
  ------------------
  |  |  141|    787|#define VK_LOADER_SETTINGS_FILENAME "vk_loader_settings.json"
  ------------------
  549|    787|                                        settings_file_path);
  550|    787|    if (res == VK_SUCCESS) {
  ------------------
  |  Branch (550:9): [True: 0, False: 787]
  ------------------
  551|      0|        return res;
  552|      0|    }
  553|       |
  554|    787|    return VK_ERROR_INITIALIZATION_FAILED;
  555|    787|}
log_settings:
  614|  2.64k|void log_settings(const struct loader_instance* inst, loader_settings* settings) {
  615|  2.64k|    if (settings == NULL) {
  ------------------
  |  Branch (615:9): [True: 0, False: 2.64k]
  ------------------
  616|      0|        return;
  617|      0|    }
  618|  2.64k|    loader_log(inst, VULKAN_LOADER_INFO_BIT, 0, "Using layer configurations found in loader settings from %s",
  619|  2.64k|               settings->settings_file_path);
  620|       |
  621|  2.64k|    char cmd_line_msg[64] = {0};
  622|  2.64k|    size_t cmd_line_size = sizeof(cmd_line_msg);
  623|       |
  624|  2.64k|    cmd_line_msg[0] = '\0';
  625|       |
  626|  2.64k|    generate_debug_flag_str(settings->debug_level, cmd_line_size, cmd_line_msg);
  627|  2.64k|    if (strlen(cmd_line_msg)) {
  ------------------
  |  Branch (627:9): [True: 166, False: 2.47k]
  ------------------
  628|    166|        loader_log(inst, VULKAN_LOADER_DEBUG_BIT, 0, "Loader Settings Filters for Logging to Standard Error: %s", cmd_line_msg);
  629|    166|    }
  630|  2.64k|    if (settings->layer_configurations_active) {
  ------------------
  |  Branch (630:9): [True: 2.55k, False: 90]
  ------------------
  631|  2.55k|        loader_log(inst, VULKAN_LOADER_DEBUG_BIT, 0, "Layer Configurations count = %d", settings->layer_configuration_count);
  632|  18.8k|        for (uint32_t i = 0; i < settings->layer_configuration_count; i++) {
  ------------------
  |  Branch (632:30): [True: 16.2k, False: 2.55k]
  ------------------
  633|  16.2k|            loader_log(inst, VULKAN_LOADER_DEBUG_BIT, 0, "---- Layer Configuration [%d] ----", i);
  634|  16.2k|            if (settings->layer_configurations[i].control != LOADER_SETTINGS_LAYER_UNORDERED_LAYER_LOCATION) {
  ------------------
  |  Branch (634:17): [True: 14.3k, False: 1.88k]
  ------------------
  635|  14.3k|                loader_log(inst, VULKAN_LOADER_DEBUG_BIT, 0, "Name: %s", settings->layer_configurations[i].name);
  636|  14.3k|                loader_log(inst, VULKAN_LOADER_DEBUG_BIT, 0, "Path: %s", settings->layer_configurations[i].path);
  637|  14.3k|                loader_log(inst, VULKAN_LOADER_DEBUG_BIT, 0, "Layer Type: %s",
  638|  14.3k|                           settings->layer_configurations[i].treat_as_implicit_manifest ? "Implicit" : "Explicit");
  ------------------
  |  Branch (638:28): [True: 404, False: 13.9k]
  ------------------
  639|  14.3k|            }
  640|  16.2k|            loader_log(inst, VULKAN_LOADER_DEBUG_BIT, 0, "Control: %s",
  641|  16.2k|                       loader_settings_layer_control_to_string(settings->layer_configurations[i].control));
  642|  16.2k|        }
  643|  2.55k|    }
  644|  2.64k|    if (settings->additional_driver_count > 0) {
  ------------------
  |  Branch (644:9): [True: 0, False: 2.64k]
  ------------------
  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|  2.64k|    if (settings->device_configurations_active) {
  ------------------
  |  Branch (655:9): [True: 0, False: 2.64k]
  ------------------
  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|  2.64k|    loader_log(inst, VULKAN_LOADER_DEBUG_BIT, 0, "---------------------------------");
  676|  2.64k|}
get_loader_settings:
  681|  7.00k|VkResult get_loader_settings(const struct loader_instance* inst, loader_settings* loader_settings) {
  682|  7.00k|    VkResult res = VK_SUCCESS;
  683|  7.00k|    cJSON* json = NULL;
  684|  7.00k|    char* file_format_version_string = NULL;
  685|  7.00k|    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|  7.00k|    if (res != VK_SUCCESS) {
  ------------------
  |  Branch (696:9): [True: 787, False: 6.21k]
  ------------------
  697|    787|        loader_log(inst, VULKAN_LOADER_INFO_BIT, 0,
  698|    787|                   "No valid vk_loader_settings.json file found, no loader settings will be active");
  699|    787|        goto out;
  700|    787|    }
  701|       |#else
  702|       |#warning "Unsupported platform - must specify platform specific location for vk_loader_settings.json"
  703|       |#endif
  704|       |
  705|  6.21k|    res = loader_get_json(inst, settings_file_path, &json);
  706|       |    // Make sure sure the top level json value is an object
  707|  6.21k|    if (res != VK_SUCCESS || NULL == json || json->type != cJSON_Object) {
  ------------------
  |  |  103|  3.70k|#define cJSON_Object (1 << 6)
  ------------------
  |  Branch (707:9): [True: 71, False: 6.14k]
  |  Branch (707:30): [True: 2.44k, False: 3.70k]
  |  Branch (707:46): [True: 239, False: 3.46k]
  ------------------
  708|  2.75k|        goto out;
  709|  2.75k|    }
  710|       |
  711|  3.46k|    res = loader_parse_json_string(json, "file_format_version", &file_format_version_string);
  712|  3.46k|    if (res != VK_SUCCESS) {
  ------------------
  |  Branch (712:9): [True: 20, False: 3.44k]
  ------------------
  713|     20|        if (res != VK_ERROR_OUT_OF_HOST_MEMORY) {
  ------------------
  |  Branch (713:13): [True: 20, False: 0]
  ------------------
  714|     20|            loader_log(
  715|     20|                inst, VULKAN_LOADER_DEBUG_BIT, 0,
  716|     20|                "Loader settings file from %s missing required field file_format_version - no loader settings will be active",
  717|     20|                settings_file_path);
  718|     20|        }
  719|     20|        goto out;
  720|     20|    }
  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|  3.44k|    cJSON settings_iter_parent = {0};
  725|       |
  726|  3.44k|    cJSON* settings_array = loader_cJSON_GetObjectItem(json, "settings_array");
  727|  3.44k|    cJSON* single_settings_object = loader_cJSON_GetObjectItem(json, "settings");
  728|  3.44k|    if (NULL != settings_array) {
  ------------------
  |  Branch (728:9): [True: 3.02k, False: 415]
  ------------------
  729|  3.02k|        memcpy(&settings_iter_parent, settings_array, sizeof(cJSON));
  730|  3.02k|    } else if (NULL != single_settings_object) {
  ------------------
  |  Branch (730:16): [True: 33, False: 382]
  ------------------
  731|     33|        settings_iter_parent.child = single_settings_object;
  732|    382|    } else {
  733|    382|        loader_log(inst, VULKAN_LOADER_DEBUG_BIT, 0,
  734|    382|                   "Loader settings file from %s missing required settings objects: Either one of the \"settings\" or "
  735|    382|                   "\"settings_array\" objects must be present - no loader settings will be active",
  736|    382|                   settings_file_path);
  737|    382|        res = VK_ERROR_INITIALIZATION_FAILED;
  738|    382|        goto out;
  739|    382|    }
  740|       |
  741|       |    // Corresponds to the settings object that has no app keys
  742|  3.06k|    cJSON* global_settings = NULL;
  743|       |    // Corresponds to the settings object which has a matching app key
  744|  3.06k|    cJSON* settings_to_use = NULL;
  745|       |
  746|  3.06k|    char current_process_path[1024];
  747|  3.06k|    bool valid_exe_path = NULL != loader_platform_executable_path(current_process_path, 1024);
  748|       |
  749|  3.06k|    cJSON* settings_object_iter = NULL;
  750|  4.73k|    cJSON_ArrayForEach(settings_object_iter, &settings_iter_parent) {
  ------------------
  |  |  213|  7.71k|    for (element = (array != NULL) ? (array)->child : NULL; element != NULL; element = element->next)
  |  |  ------------------
  |  |  |  Branch (213:20): [True: 3.06k, Folded]
  |  |  |  Branch (213:61): [True: 4.73k, False: 2.98k]
  |  |  ------------------
  ------------------
  751|  4.73k|        if (settings_object_iter->type != cJSON_Object) {
  ------------------
  |  |  103|  4.73k|#define cJSON_Object (1 << 6)
  ------------------
  |  Branch (751:13): [True: 74, False: 4.65k]
  ------------------
  752|     74|            loader_log(inst, VULKAN_LOADER_DEBUG_BIT, 0,
  753|     74|                       "Loader settings file from %s has a settings element that is not an object", settings_file_path);
  754|     74|            break;
  755|     74|        }
  756|       |
  757|  4.65k|        cJSON* app_keys = loader_cJSON_GetObjectItem(settings_object_iter, "app_keys");
  758|  4.65k|        if (NULL == app_keys) {
  ------------------
  |  Branch (758:13): [True: 4.38k, False: 271]
  ------------------
  759|       |            // use the first 'global' settings that has no app keys as the global one
  760|  4.38k|            if (global_settings == NULL) {
  ------------------
  |  Branch (760:17): [True: 2.97k, False: 1.41k]
  ------------------
  761|  2.97k|                global_settings = settings_object_iter;
  762|  2.97k|            }
  763|  4.38k|            continue;
  764|  4.38k|        }
  765|       |        // No sense iterating if we couldn't get the executable path
  766|    271|        if (!valid_exe_path) {
  ------------------
  |  Branch (766:13): [True: 0, False: 271]
  ------------------
  767|      0|            break;
  768|      0|        }
  769|    271|        cJSON* app_key = NULL;
  770|    581|        cJSON_ArrayForEach(app_key, app_keys) {
  ------------------
  |  |  213|    852|    for (element = (array != NULL) ? (array)->child : NULL; element != NULL; element = element->next)
  |  |  ------------------
  |  |  |  Branch (213:20): [True: 271, False: 0]
  |  |  |  Branch (213:61): [True: 581, False: 271]
  |  |  ------------------
  ------------------
  771|    581|            char* app_key_str = loader_cJSON_GetStringValue(app_key);
  772|    581|            if (app_key_str && strcmp(current_process_path, app_key_str) == 0) {
  ------------------
  |  Branch (772:17): [True: 322, False: 259]
  |  Branch (772:32): [True: 0, False: 322]
  ------------------
  773|      0|                settings_to_use = settings_object_iter;
  774|      0|                break;
  775|      0|            }
  776|    581|        }
  777|       |
  778|       |        // Break if we have found a matching current_process_path
  779|    271|        if (NULL != settings_to_use) {
  ------------------
  |  Branch (779:13): [True: 0, False: 271]
  ------------------
  780|      0|            break;
  781|      0|        }
  782|    271|    }
  783|       |
  784|       |    // No app specific settings match - either use global settings or exit
  785|  3.06k|    if (settings_to_use == NULL) {
  ------------------
  |  Branch (785:9): [True: 3.06k, False: 0]
  ------------------
  786|  3.06k|        if (global_settings == NULL) {
  ------------------
  |  Branch (786:13): [True: 91, False: 2.97k]
  ------------------
  787|     91|            loader_log(inst, VULKAN_LOADER_DEBUG_BIT, 0,
  788|     91|                       "Loader settings file from %s missing global settings and none of the app specific settings matched the "
  789|     91|                       "current application - no loader settings will be active",
  790|     91|                       settings_file_path);
  791|     91|            goto out;  // No global settings were found - exit
  792|  2.97k|        } else {
  793|  2.97k|            settings_to_use = global_settings;  // Global settings are present - use it
  794|  2.97k|        }
  795|  3.06k|    }
  796|       |
  797|       |    // optional
  798|  2.97k|    cJSON* stderr_filter = loader_cJSON_GetObjectItem(settings_to_use, "stderr_log");
  799|  2.97k|    if (NULL != stderr_filter) {
  ------------------
  |  Branch (799:9): [True: 357, False: 2.61k]
  ------------------
  800|    357|        struct loader_string_list stderr_log = {0};
  801|    357|        VkResult stderr_log_result = VK_SUCCESS;
  802|    357|        stderr_log_result = loader_parse_json_array_of_strings(inst, settings_to_use, "stderr_log", &stderr_log);
  803|    357|        if (VK_ERROR_OUT_OF_HOST_MEMORY == stderr_log_result) {
  ------------------
  |  Branch (803:13): [True: 0, False: 357]
  ------------------
  804|      0|            res = VK_ERROR_OUT_OF_HOST_MEMORY;
  805|      0|            goto out;
  806|      0|        }
  807|    357|        loader_settings->debug_level = parse_log_filters_from_strings(&stderr_log);
  808|    357|        free_string_list(inst, &stderr_log);
  809|    357|    }
  810|       |
  811|       |    // optional
  812|  2.97k|    cJSON* logs_to_use = loader_cJSON_GetObjectItem(settings_to_use, "log_locations");
  813|  2.97k|    if (NULL != logs_to_use) {
  ------------------
  |  Branch (813:9): [True: 44, False: 2.92k]
  ------------------
  814|     44|        cJSON* log_element = NULL;
  815|    487|        cJSON_ArrayForEach(log_element, logs_to_use) {
  ------------------
  |  |  213|    531|    for (element = (array != NULL) ? (array)->child : NULL; element != NULL; element = element->next)
  |  |  ------------------
  |  |  |  Branch (213:20): [True: 44, False: 0]
  |  |  |  Branch (213:61): [True: 487, False: 44]
  |  |  ------------------
  ------------------
  816|       |            // bool is_valid = true;
  817|    487|            struct loader_string_list log_destinations = {0};
  818|    487|            VkResult parse_dest_res = loader_parse_json_array_of_strings(inst, log_element, "destinations", &log_destinations);
  819|    487|            if (parse_dest_res != VK_SUCCESS) {
  ------------------
  |  Branch (819:17): [True: 478, False: 9]
  ------------------
  820|       |                // is_valid = false;
  821|    478|            }
  822|    487|            free_string_list(inst, &log_destinations);
  823|    487|            struct loader_string_list log_filters = {0};
  824|    487|            VkResult parse_filters_res = loader_parse_json_array_of_strings(inst, log_element, "filters", &log_filters);
  825|    487|            if (parse_filters_res != VK_SUCCESS) {
  ------------------
  |  Branch (825:17): [True: 350, False: 137]
  ------------------
  826|       |                // is_valid = false;
  827|    350|            }
  828|    487|            free_string_list(inst, &log_filters);
  829|    487|        }
  830|     44|    }
  831|       |
  832|  2.97k|    VkResult layer_configurations_res = parse_layer_configurations(inst, settings_to_use, loader_settings);
  833|  2.97k|    if (VK_ERROR_OUT_OF_HOST_MEMORY == layer_configurations_res) {
  ------------------
  |  Branch (833:9): [True: 0, False: 2.97k]
  ------------------
  834|      0|        res = layer_configurations_res;
  835|      0|        goto out;
  836|      0|    }
  837|       |
  838|       |    // Determine if there exists a layer configuration indicating where to put layers not contained in the settings file
  839|       |    // LOADER_SETTINGS_LAYER_UNORDERED_LAYER_LOCATION
  840|  13.9k|    for (uint32_t i = 0; i < loader_settings->layer_configuration_count; i++) {
  ------------------
  |  Branch (840:26): [True: 11.7k, False: 2.17k]
  ------------------
  841|  11.7k|        if (loader_settings->layer_configurations[i].control == LOADER_SETTINGS_LAYER_UNORDERED_LAYER_LOCATION) {
  ------------------
  |  Branch (841:13): [True: 796, False: 10.9k]
  ------------------
  842|    796|            loader_settings->has_unordered_layer_location = true;
  843|    796|            break;
  844|    796|        }
  845|  11.7k|    }
  846|       |
  847|  2.97k|    VkResult additional_drivers_res = parse_additional_drivers(inst, settings_to_use, loader_settings);
  848|  2.97k|    if (VK_ERROR_OUT_OF_HOST_MEMORY == additional_drivers_res) {
  ------------------
  |  Branch (848:9): [True: 0, False: 2.97k]
  ------------------
  849|      0|        res = additional_drivers_res;
  850|      0|        goto out;
  851|      0|    }
  852|       |
  853|  2.97k|    VkResult device_configurations_res = parse_device_configurations(inst, settings_to_use, loader_settings);
  854|  2.97k|    if (VK_ERROR_OUT_OF_HOST_MEMORY == device_configurations_res) {
  ------------------
  |  Branch (854:9): [True: 0, False: 2.97k]
  ------------------
  855|      0|        res = device_configurations_res;
  856|      0|        goto out;
  857|      0|    }
  858|       |
  859|       |    // Only consider the settings active if there is at least one "setting" active.
  860|       |    // Those are either logging, layers, additional_drivers, or device_configurations.
  861|  2.97k|    if (loader_settings->debug_level != 0 || loader_settings->layer_configurations_active ||
  ------------------
  |  Branch (861:9): [True: 171, False: 2.80k]
  |  Branch (861:46): [True: 2.47k, False: 330]
  ------------------
  862|  2.64k|        loader_settings->additional_driver_count != 0 || loader_settings->device_configurations_active) {
  ------------------
  |  Branch (862:9): [True: 0, False: 330]
  |  Branch (862:58): [True: 0, False: 330]
  ------------------
  863|  2.64k|        loader_settings->settings_file_path = settings_file_path;
  864|  2.64k|        settings_file_path = NULL;
  865|  2.64k|        loader_settings->settings_active = true;
  866|  2.64k|    } else {
  867|    330|        loader_log(inst, VULKAN_LOADER_INFO_BIT, 0,
  868|    330|                   "vk_loader_settings.json file found at \"%s\" but did not contain any valid settings.", settings_file_path);
  869|    330|    }
  870|  7.00k|out:
  871|  7.00k|    if (NULL != json) {
  ------------------
  |  Branch (871:9): [True: 3.70k, False: 3.30k]
  ------------------
  872|  3.70k|        loader_cJSON_Delete(json);
  873|  3.70k|    }
  874|       |
  875|  7.00k|    loader_instance_heap_free(inst, settings_file_path);
  876|       |
  877|  7.00k|    loader_instance_heap_free(inst, file_format_version_string);
  878|  7.00k|    return res;
  879|  2.97k|}
init_global_loader_settings:
  900|      2|void init_global_loader_settings(void) {
  901|      2|    loader_platform_thread_create_mutex(&global_loader_settings_lock);
  902|       |    // Free out the global settings in case the process was loaded & unloaded
  903|       |    free_loader_settings(NULL, &global_loader_settings);
  904|      2|}
get_current_settings_and_lock:
  920|  7.01k|const loader_settings* get_current_settings_and_lock(const struct loader_instance* inst) {
  921|  7.01k|    if (inst) {
  ------------------
  |  Branch (921:9): [True: 7.01k, False: 0]
  ------------------
  922|  7.01k|        return &inst->settings;
  923|  7.01k|    }
  924|      0|    loader_platform_thread_lock_mutex(&global_loader_settings_lock);
  925|      0|    return &global_loader_settings;
  926|  7.01k|}
release_current_settings_lock:
  928|  7.01k|void release_current_settings_lock(const struct loader_instance* inst) {
  929|  7.01k|    if (inst == NULL) {
  ------------------
  |  Branch (929:9): [True: 0, False: 7.01k]
  ------------------
  930|      0|        loader_platform_thread_unlock_mutex(&global_loader_settings_lock);
  931|      0|    }
  932|  7.01k|}
get_settings_layers:
  935|  7.00k|                                                  bool* should_search_for_other_layers) {
  936|  7.00k|    VkResult res = VK_SUCCESS;
  937|  7.00k|    *should_search_for_other_layers = true;  // default to true
  938|       |
  939|  7.00k|    const loader_settings* settings = get_current_settings_and_lock(inst);
  940|       |
  941|  7.00k|    if (NULL == settings || !settings->settings_active || !settings->layer_configurations_active) {
  ------------------
  |  Branch (941:9): [True: 0, False: 7.00k]
  |  Branch (941:29): [True: 4.36k, False: 2.64k]
  |  Branch (941:59): [True: 90, False: 2.55k]
  ------------------
  942|  4.45k|        goto out;
  943|  4.45k|    }
  944|       |
  945|       |    // Assume the list doesn't contain LOADER_SETTINGS_LAYER_UNORDERED_LAYER_LOCATION at first
  946|  2.55k|    *should_search_for_other_layers = false;
  947|       |
  948|  18.8k|    for (uint32_t i = 0; i < settings->layer_configuration_count; i++) {
  ------------------
  |  Branch (948:26): [True: 16.2k, False: 2.55k]
  ------------------
  949|  16.2k|        loader_settings_layer_configuration* layer_config = &settings->layer_configurations[i];
  950|       |
  951|       |        // If we encountered a layer that should be forced off, we add it to the settings_layers list but only
  952|       |        // with the data required to compare it with layers not in the settings file (aka name and manifest path)
  953|  16.2k|        if (layer_config->control == LOADER_SETTINGS_LAYER_CONTROL_OFF) {
  ------------------
  |  Branch (953:13): [True: 1.84k, False: 14.4k]
  ------------------
  954|  1.84k|            struct loader_layer_properties props = {0};
  955|  1.84k|            props.settings_control_value = LOADER_SETTINGS_LAYER_CONTROL_OFF;
  956|  1.84k|            loader_strncpy(props.info.layerName, VK_MAX_EXTENSION_NAME_SIZE, layer_config->name, VK_MAX_EXTENSION_NAME_SIZE);
  957|  1.84k|            props.info.layerName[VK_MAX_EXTENSION_NAME_SIZE - 1] = '\0';
  958|  1.84k|            res = loader_copy_to_new_str(inst, layer_config->path, &props.manifest_file_name);
  959|  1.84k|            if (VK_ERROR_OUT_OF_HOST_MEMORY == res) {
  ------------------
  |  Branch (959:17): [True: 0, False: 1.84k]
  ------------------
  960|      0|                goto out;
  961|      0|            }
  962|  1.84k|            res = loader_append_layer_property(inst, settings_layers, &props);
  963|  1.84k|            if (VK_ERROR_OUT_OF_HOST_MEMORY == res) {
  ------------------
  |  Branch (963:17): [True: 0, False: 1.84k]
  ------------------
  964|      0|                loader_free_layer_properties(inst, &props);
  965|      0|                goto out;
  966|      0|            }
  967|  1.84k|            continue;
  968|  1.84k|        }
  969|       |
  970|       |        // The special layer location that indicates where unordered layers should go only should have the
  971|       |        // settings_control_value set - everything else should be NULL
  972|  14.4k|        if (layer_config->control == LOADER_SETTINGS_LAYER_UNORDERED_LAYER_LOCATION) {
  ------------------
  |  Branch (972:13): [True: 1.88k, False: 12.5k]
  ------------------
  973|  1.88k|            struct loader_layer_properties props = {0};
  974|  1.88k|            props.settings_control_value = LOADER_SETTINGS_LAYER_UNORDERED_LAYER_LOCATION;
  975|  1.88k|            res = loader_append_layer_property(inst, settings_layers, &props);
  976|  1.88k|            if (VK_ERROR_OUT_OF_HOST_MEMORY == res) {
  ------------------
  |  Branch (976:17): [True: 0, False: 1.88k]
  ------------------
  977|      0|                loader_free_layer_properties(inst, &props);
  978|      0|                goto out;
  979|      0|            }
  980|  1.88k|            *should_search_for_other_layers = true;
  981|  1.88k|            continue;
  982|  1.88k|        }
  983|       |
  984|  12.5k|        if (layer_config->path == NULL) {
  ------------------
  |  Branch (984:13): [True: 0, False: 12.5k]
  ------------------
  985|      0|            continue;
  986|      0|        }
  987|       |
  988|  12.5k|        if (!is_json(layer_config->path, strlen(layer_config->path))) {
  ------------------
  |  Branch (988:13): [True: 12.5k, False: 0]
  ------------------
  989|  12.5k|            continue;
  990|  12.5k|        }
  991|       |
  992|      0|        cJSON* json = NULL;
  993|      0|        VkResult local_res = loader_get_json(inst, layer_config->path, &json);
  994|      0|        if (VK_ERROR_OUT_OF_HOST_MEMORY == local_res) {
  ------------------
  |  Branch (994:13): [True: 0, False: 0]
  ------------------
  995|      0|            res = VK_ERROR_OUT_OF_HOST_MEMORY;
  996|      0|            goto out;
  997|      0|        } else if (VK_SUCCESS != local_res || NULL == json) {
  ------------------
  |  Branch (997:20): [True: 0, False: 0]
  |  Branch (997:47): [True: 0, False: 0]
  ------------------
  998|      0|            continue;
  999|      0|        }
 1000|       |
 1001|       |        // Makes it possible to know if a new layer was added or not, since the only return value is VkResult
 1002|      0|        uint32_t count_before_adding = settings_layers->count;
 1003|       |
 1004|      0|        local_res =
 1005|      0|            loader_add_layer_properties(inst, settings_layers, json, layer_config->treat_as_implicit_manifest, layer_config->path);
 1006|      0|        loader_cJSON_Delete(json);
 1007|       |
 1008|       |        // If the error is anything other than out of memory we still want to try to load the other layers
 1009|      0|        if (VK_ERROR_OUT_OF_HOST_MEMORY == local_res) {
  ------------------
  |  Branch (1009:13): [True: 0, False: 0]
  ------------------
 1010|      0|            res = VK_ERROR_OUT_OF_HOST_MEMORY;
 1011|      0|            goto out;
 1012|      0|        } else if (local_res != VK_SUCCESS || count_before_adding == settings_layers->count) {
  ------------------
  |  Branch (1012:20): [True: 0, False: 0]
  |  Branch (1012:47): [True: 0, False: 0]
  ------------------
 1013|       |            // Indicates something was wrong with the layer, can't add it to the list
 1014|      0|            continue;
 1015|      0|        }
 1016|       |
 1017|      0|        for (uint32_t j = count_before_adding; j < settings_layers->count; j++) {
  ------------------
  |  Branch (1017:48): [True: 0, False: 0]
  ------------------
 1018|      0|            struct loader_layer_properties* newly_added_layer = &settings_layers->list[j];
 1019|      0|            newly_added_layer->settings_control_value = layer_config->control;
 1020|       |            // If the manifest file found has a name that differs from the one in the settings, remove this layer from
 1021|       |            // consideration
 1022|      0|            if (strncmp(newly_added_layer->info.layerName, layer_config->name, VK_MAX_EXTENSION_NAME_SIZE) != 0) {
  ------------------
  |  Branch (1022:17): [True: 0, False: 0]
  ------------------
 1023|      0|                loader_remove_layer_in_list(inst, settings_layers, j);
 1024|      0|                j--;
 1025|      0|                continue;
 1026|      0|            }
 1027|      0|            bool should_remove = false;
 1028|       |            // Make sure the layer isn't already in the list
 1029|      0|            for (uint32_t k = 0; k < j; k++) {
  ------------------
  |  Branch (1029:34): [True: 0, False: 0]
  ------------------
 1030|      0|                if (0 == strncmp(settings_layers->list[k].info.layerName, newly_added_layer->info.layerName,
  ------------------
  |  Branch (1030:21): [True: 0, False: 0]
  ------------------
 1031|      0|                                 VK_MAX_EXTENSION_NAME_SIZE)) {
 1032|      0|                    if (0 == (newly_added_layer->type_flags & VK_LAYER_TYPE_FLAG_META_LAYER) &&
  ------------------
  |  Branch (1032:25): [True: 0, False: 0]
  ------------------
 1033|      0|                        settings_layers->list[k].lib_name != NULL && newly_added_layer->lib_name != NULL &&
  ------------------
  |  Branch (1033:25): [True: 0, False: 0]
  |  Branch (1033:70): [True: 0, False: 0]
  ------------------
 1034|      0|                        strcmp(settings_layers->list[k].lib_name, newly_added_layer->lib_name) == 0) {
  ------------------
  |  Branch (1034:25): [True: 0, False: 0]
  ------------------
 1035|      0|                        should_remove = true;
 1036|      0|                        break;
 1037|      0|                    }
 1038|      0|                }
 1039|      0|            }
 1040|      0|            if (should_remove) {
  ------------------
  |  Branch (1040:17): [True: 0, False: 0]
  ------------------
 1041|      0|                loader_remove_layer_in_list(inst, settings_layers, j);
 1042|      0|                j--;
 1043|      0|            }
 1044|      0|        }
 1045|      0|    }
 1046|       |
 1047|  7.00k|out:
 1048|  7.00k|    release_current_settings_lock(inst);
 1049|  7.00k|    return res;
 1050|  2.55k|}
check_if_layer_is_in_list:
 1061|  4.79k|                               bool consider_lib_path) {
 1062|       |    // If the layer is a meta layer, just check against the name
 1063|   146k|    for (uint32_t i = 0; i < layer_list->count; i++) {
  ------------------
  |  Branch (1063:26): [True: 143k, False: 2.82k]
  ------------------
 1064|   143k|        if (0 == strncmp(layer_list->list[i].info.layerName, layer_property->info.layerName, VK_MAX_EXTENSION_NAME_SIZE)) {
  ------------------
  |  Branch (1064:13): [True: 131k, False: 11.9k]
  ------------------
 1065|   131k|            if (layer_list->list[i].settings_control_value == LOADER_SETTINGS_LAYER_CONTROL_OFF) {
  ------------------
  |  Branch (1065:17): [True: 678, False: 131k]
  ------------------
 1066|    678|                return true;
 1067|    678|            }
 1068|   131k|            if (VK_LAYER_TYPE_FLAG_META_LAYER == (layer_property->type_flags & VK_LAYER_TYPE_FLAG_META_LAYER)) {
  ------------------
  |  Branch (1068:17): [True: 476, False: 130k]
  ------------------
 1069|    476|                return true;
 1070|    476|            }
 1071|   130k|            if (!consider_lib_path) {
  ------------------
  |  Branch (1071:17): [True: 821, False: 129k]
  ------------------
 1072|    821|                return true;
 1073|    821|            }
 1074|   129k|            if (layer_list->list[i].lib_name && layer_property->lib_name) {
  ------------------
  |  Branch (1074:17): [True: 0, False: 129k]
  |  Branch (1074:49): [True: 0, False: 0]
  ------------------
 1075|      0|                return strcmp(layer_list->list[i].lib_name, layer_property->lib_name) == 0;
 1076|      0|            }
 1077|   129k|        }
 1078|   143k|    }
 1079|  2.82k|    return false;
 1080|  4.79k|}
combine_settings_layers_with_regular_layers:
 1084|  5.24k|                                                     struct loader_layer_list* output_layers) {
 1085|  5.24k|    VkResult res = VK_SUCCESS;
 1086|  5.24k|    bool has_unordered_layer_location = false;
 1087|  5.24k|    uint32_t unordered_layer_location_index = 0;
 1088|       |    // Location to put layers that aren't known to the settings file
 1089|       |    // Find it here so we dont have to pass in a loader_settings struct
 1090|  5.52k|    for (uint32_t i = 0; i < settings_layers->count; i++) {
  ------------------
  |  Branch (1090:26): [True: 1.07k, False: 4.45k]
  ------------------
 1091|  1.07k|        if (settings_layers->list[i].settings_control_value == LOADER_SETTINGS_LAYER_UNORDERED_LAYER_LOCATION) {
  ------------------
  |  Branch (1091:13): [True: 796, False: 275]
  ------------------
 1092|    796|            has_unordered_layer_location = true;
 1093|    796|            unordered_layer_location_index = i;
 1094|    796|            break;
 1095|    796|        }
 1096|  1.07k|    }
 1097|       |
 1098|  5.24k|    if (settings_layers->count == 0 && regular_layers->count == 0) {
  ------------------
  |  Branch (1098:9): [True: 4.45k, False: 796]
  |  Branch (1098:40): [True: 3.43k, False: 1.01k]
  ------------------
 1099|       |        // No layers to combine
 1100|  3.43k|        goto out;
 1101|  3.43k|    } else if (settings_layers->count == 0) {
  ------------------
  |  Branch (1101:16): [True: 1.01k, False: 796]
  ------------------
 1102|       |        // No settings layers - just copy regular to output_layers - memset regular layers to prevent double frees
 1103|  1.01k|        *output_layers = *regular_layers;
 1104|  1.01k|        memset(regular_layers, 0, sizeof(struct loader_layer_list));
 1105|  1.01k|        goto out;
 1106|  1.01k|    } else if (regular_layers->count == 0 || !has_unordered_layer_location) {
  ------------------
  |  Branch (1106:16): [True: 211, False: 585]
  |  Branch (1106:46): [True: 0, False: 585]
  ------------------
 1107|       |        // No regular layers or has_unordered_layer_location is false - just copy settings to output_layers -
 1108|       |        // memset settings layers to prevent double frees
 1109|    211|        *output_layers = *settings_layers;
 1110|    211|        memset(settings_layers, 0, sizeof(struct loader_layer_list));
 1111|    211|        goto out;
 1112|    211|    }
 1113|       |
 1114|    585|    res = loader_init_generic_list(inst, (struct loader_generic_list*)output_layers,
 1115|    585|                                   (settings_layers->count + regular_layers->count) * sizeof(struct loader_layer_properties));
 1116|    585|    if (VK_SUCCESS != res) {
  ------------------
  |  Branch (1116:9): [True: 0, False: 585]
  ------------------
 1117|      0|        goto out;
 1118|      0|    }
 1119|       |
 1120|       |    // Insert the settings layers into output_layers up to unordered_layer_index
 1121|    760|    for (uint32_t i = 0; i < unordered_layer_location_index; i++) {
  ------------------
  |  Branch (1121:26): [True: 175, False: 585]
  ------------------
 1122|    175|        if (!check_if_layer_is_in_list(output_layers, &settings_layers->list[i], true)) {
  ------------------
  |  Branch (1122:13): [True: 142, False: 33]
  ------------------
 1123|    142|            res = loader_append_layer_property(inst, output_layers, &settings_layers->list[i]);
 1124|    142|            if (VK_SUCCESS != res) {
  ------------------
  |  Branch (1124:17): [True: 0, False: 142]
  ------------------
 1125|      0|                goto out;
 1126|      0|            }
 1127|    142|        }
 1128|    175|    }
 1129|       |
 1130|  2.86k|    for (uint32_t i = 0; i < regular_layers->count; i++) {
  ------------------
  |  Branch (1130:26): [True: 2.28k, False: 585]
  ------------------
 1131|       |        // Check if its already been put in the output_layers list as well as the remaining settings_layers
 1132|  2.28k|        bool regular_layer_is_ordered = check_if_layer_is_in_list(output_layers, &regular_layers->list[i], false) ||
  ------------------
  |  Branch (1132:41): [True: 1.20k, False: 1.07k]
  ------------------
 1133|  1.07k|                                        check_if_layer_is_in_list(settings_layers, &regular_layers->list[i], false);
  ------------------
  |  Branch (1133:41): [True: 97, False: 982]
  ------------------
 1134|       |        // If it isn't found, add it
 1135|  2.28k|        if (!regular_layer_is_ordered) {
  ------------------
  |  Branch (1135:13): [True: 982, False: 1.30k]
  ------------------
 1136|    982|            res = loader_append_layer_property(inst, output_layers, &regular_layers->list[i]);
 1137|    982|            if (VK_SUCCESS != res) {
  ------------------
  |  Branch (1137:17): [True: 0, False: 982]
  ------------------
 1138|      0|                goto out;
 1139|      0|            }
 1140|  1.30k|        } else {
 1141|       |            // layer is already ordered and can be safely freed
 1142|  1.30k|            loader_free_layer_properties(inst, &regular_layers->list[i]);
 1143|  1.30k|        }
 1144|  2.28k|    }
 1145|       |
 1146|       |    // Insert the rest of the settings layers into combined_layers from  unordered_layer_index to the end
 1147|       |    // start at one after the unordered_layer_index
 1148|  1.84k|    for (uint32_t i = unordered_layer_location_index + 1; i < settings_layers->count; i++) {
  ------------------
  |  Branch (1148:59): [True: 1.26k, False: 585]
  ------------------
 1149|  1.26k|        if (!check_if_layer_is_in_list(output_layers, &settings_layers->list[i], true)) {
  ------------------
  |  Branch (1149:13): [True: 620, False: 642]
  ------------------
 1150|    620|            res = loader_append_layer_property(inst, output_layers, &settings_layers->list[i]);
 1151|    620|            if (VK_SUCCESS != res) {
  ------------------
  |  Branch (1151:17): [True: 0, False: 620]
  ------------------
 1152|      0|                goto out;
 1153|      0|            }
 1154|    620|        }
 1155|  1.26k|    }
 1156|       |
 1157|  5.24k|out:
 1158|  5.24k|    if (res != VK_SUCCESS) {
  ------------------
  |  Branch (1158:9): [True: 0, False: 5.24k]
  ------------------
 1159|      0|        loader_delete_layer_list_and_properties(inst, output_layers);
 1160|      0|    }
 1161|       |
 1162|  5.24k|    return res;
 1163|    585|}
loader_settings_get_additional_driver_files:
 1283|      4|VkResult loader_settings_get_additional_driver_files(const struct loader_instance* inst, struct loader_string_list* out_files) {
 1284|      4|    VkResult res = VK_SUCCESS;
 1285|       |
 1286|      4|    const loader_settings* settings = get_current_settings_and_lock(inst);
 1287|       |
 1288|      4|    if (NULL == settings || !settings->settings_active) {
  ------------------
  |  Branch (1288:9): [True: 0, False: 4]
  |  Branch (1288:29): [True: 1, False: 3]
  ------------------
 1289|      1|        goto out;
 1290|      1|    }
 1291|       |
 1292|      3|    if (settings->additional_drivers_use_exclusively) {
  ------------------
  |  Branch (1292:9): [True: 0, False: 3]
  ------------------
 1293|      0|        free_string_list(inst, out_files);
 1294|      0|    }
 1295|       |
 1296|      3|    for (uint32_t i = 0; i < settings->additional_driver_count; i++) {
  ------------------
  |  Branch (1296:26): [True: 0, False: 3]
  ------------------
 1297|      0|        res = prepend_if_manifest_file(inst, settings->additional_drivers[i].path, out_files);
 1298|      0|    }
 1299|       |
 1300|      4|out:
 1301|      4|    release_current_settings_lock(inst);
 1302|      4|    return res;
 1303|      3|}
loader_settings_should_use_driver_environment_variables:
 1305|      8|bool loader_settings_should_use_driver_environment_variables(const struct loader_instance* inst) {
 1306|      8|    bool should_use = true;
 1307|      8|    const loader_settings* settings = get_current_settings_and_lock(inst);
 1308|      8|    if (NULL == settings || !settings->settings_active) {
  ------------------
  |  Branch (1308:9): [True: 0, False: 8]
  |  Branch (1308:29): [True: 2, False: 6]
  ------------------
 1309|      2|        goto out;
 1310|      2|    }
 1311|      6|    if (settings->device_configurations_active) {
  ------------------
  |  Branch (1311:9): [True: 0, False: 6]
  ------------------
 1312|      0|        should_use = false;
 1313|      0|    }
 1314|      8|out:
 1315|      8|    release_current_settings_lock(inst);
 1316|      8|    return should_use;
 1317|      6|}

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

trampoline.c:loader_platform_thread_lock_mutex:
  453|  7.00k|static inline void loader_platform_thread_lock_mutex(loader_platform_thread_mutex *pMutex) { pthread_mutex_lock(pMutex); }
trampoline.c:loader_platform_thread_unlock_mutex:
  454|  7.00k|static inline void loader_platform_thread_unlock_mutex(loader_platform_thread_mutex *pMutex) { pthread_mutex_unlock(pMutex); }
loader.c:loader_strncpy:
  464|  80.7k|static inline char *loader_strncpy(char *dest, size_t dest_sz, const char *src, size_t count) {
  465|  80.7k|    (void)dest_sz;
  466|  80.7k|    return strncpy(dest, src, count);
  467|  80.7k|}
loader.c:thread_safe_strtok:
  457|  39.1k|static inline void *thread_safe_strtok(char *str, const char *delim, char **saveptr) { return strtok_r(str, delim, saveptr); }
loader.c:loader_platform_thread_create_mutex:
  447|      4|static inline void loader_platform_thread_create_mutex(loader_platform_thread_mutex *pMutex) {
  448|      4|    pthread_mutexattr_t attr;
  449|      4|    pthread_mutexattr_init(&attr);
  450|      4|    pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
  451|      4|    pthread_mutex_init(pMutex, &attr);
  452|      4|}
loader.c:loader_platform_is_path_absolute:
  294|  4.74k|static inline bool loader_platform_is_path_absolute(const char *path) {
  295|  4.74k|    if (path[0] == '/')
  ------------------
  |  Branch (295:9): [True: 991, False: 3.75k]
  ------------------
  296|    991|        return true;
  297|  3.75k|    else
  298|  3.75k|        return false;
  299|  4.74k|}
loader.c:loader_platform_is_path:
  248|  22.7k|static inline bool loader_platform_is_path(const char *path) { return strchr(path, DIRECTORY_SYMBOL) != NULL; }
  ------------------
  |  |  151|  22.7k|#define DIRECTORY_SYMBOL '/'
  ------------------
loader.c:loader_platform_file_exists:
  285|  22.6k|static inline bool loader_platform_file_exists(const char *path) {
  286|  22.6k|    if (access(path, F_OK))
  ------------------
  |  Branch (286:9): [True: 774, False: 21.8k]
  ------------------
  287|    774|        return false;
  288|  21.8k|    else
  289|  21.8k|        return true;
  290|  22.6k|}
loader.c:loader_platform_executable_path:
  306|  5.24k|static inline char *loader_platform_executable_path(char *buffer, size_t size) {
  307|  5.24k|    ssize_t count = readlink("/proc/self/exe", buffer, size);
  308|  5.24k|    if (count == -1) return NULL;
  ------------------
  |  Branch (308:9): [True: 0, False: 5.24k]
  ------------------
  309|  5.24k|    if (count == 0) return NULL;
  ------------------
  |  Branch (309:9): [True: 0, False: 5.24k]
  ------------------
  310|       |    // readlink does not append a null terminator and returns up to size bytes, so a target of size or more
  311|       |    // would leave no room for the terminator and buffer[count] would write past the end.
  312|  5.24k|    if ((size_t)count >= size) return NULL;
  ------------------
  |  Branch (312:9): [True: 0, False: 5.24k]
  ------------------
  313|  5.24k|    buffer[count] = '\0';
  314|  5.24k|    return buffer;
  315|  5.24k|}
loader_environment.c:thread_safe_strtok:
  457|  14.0k|static inline void *thread_safe_strtok(char *str, const char *delim, char **saveptr) { return strtok_r(str, delim, saveptr); }
loader_environment.c:loader_strncpy:
  464|  7.00k|static inline char *loader_strncpy(char *dest, size_t dest_sz, const char *src, size_t count) {
  465|  7.00k|    (void)dest_sz;
  466|  7.00k|    return strncpy(dest, src, count);
  467|  7.00k|}
log.c:loader_strncat:
  460|  76.0k|static inline char *loader_strncat(char *dest, size_t dest_sz, const char *src, size_t count) {
  461|  76.0k|    (void)dest_sz;
  462|  76.0k|    return strncat(dest, src, count);
  463|  76.0k|}
settings.c:loader_strncpy:
  464|  19.7k|static inline char *loader_strncpy(char *dest, size_t dest_sz, const char *src, size_t count) {
  465|  19.7k|    (void)dest_sz;
  466|  19.7k|    return strncpy(dest, src, count);
  467|  19.7k|}
settings.c:loader_strncat:
  460|  17.9k|static inline char *loader_strncat(char *dest, size_t dest_sz, const char *src, size_t count) {
  461|  17.9k|    (void)dest_sz;
  462|  17.9k|    return strncat(dest, src, count);
  463|  17.9k|}
settings.c:loader_platform_file_exists:
  285|  17.9k|static inline bool loader_platform_file_exists(const char *path) {
  286|  17.9k|    if (access(path, F_OK))
  ------------------
  |  Branch (286:9): [True: 11.7k, False: 6.21k]
  ------------------
  287|  11.7k|        return false;
  288|  6.21k|    else
  289|  6.21k|        return true;
  290|  17.9k|}
settings.c:loader_platform_executable_path:
  306|  3.06k|static inline char *loader_platform_executable_path(char *buffer, size_t size) {
  307|  3.06k|    ssize_t count = readlink("/proc/self/exe", buffer, size);
  308|  3.06k|    if (count == -1) return NULL;
  ------------------
  |  Branch (308:9): [True: 0, False: 3.06k]
  ------------------
  309|  3.06k|    if (count == 0) return NULL;
  ------------------
  |  Branch (309:9): [True: 0, False: 3.06k]
  ------------------
  310|       |    // readlink does not append a null terminator and returns up to size bytes, so a target of size or more
  311|       |    // would leave no room for the terminator and buffer[count] would write past the end.
  312|  3.06k|    if ((size_t)count >= size) return NULL;
  ------------------
  |  Branch (312:9): [True: 0, False: 3.06k]
  ------------------
  313|  3.06k|    buffer[count] = '\0';
  314|  3.06k|    return buffer;
  315|  3.06k|}
settings.c:loader_platform_thread_create_mutex:
  447|      2|static inline void loader_platform_thread_create_mutex(loader_platform_thread_mutex *pMutex) {
  448|      2|    pthread_mutexattr_t attr;
  449|      2|    pthread_mutexattr_init(&attr);
  450|      2|    pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
  451|      2|    pthread_mutex_init(pMutex, &attr);
  452|      2|}

wsi_unsupported_instance_extension:
  273|  3.85k|bool wsi_unsupported_instance_extension(const VkExtensionProperties *ext_prop) {
  274|       |#if !defined(VK_USE_PLATFORM_WAYLAND_KHR)
  275|       |    if (!strcmp(ext_prop->extensionName, "VK_KHR_wayland_surface")) return true;
  276|       |#endif  // VK_USE_PLATFORM_WAYLAND_KHR
  277|       |#if !defined(VK_USE_PLATFORM_XCB_KHR)
  278|       |    if (!strcmp(ext_prop->extensionName, "VK_KHR_xcb_surface")) return true;
  279|       |#endif  // VK_USE_PLATFORM_XCB_KHR
  280|       |#if !defined(VK_USE_PLATFORM_XLIB_KHR)
  281|       |    if (!strcmp(ext_prop->extensionName, "VK_KHR_xlib_surface")) return true;
  282|       |#endif  // VK_USE_PLATFORM_XLIB_KHR
  283|  3.85k|#if !defined(VK_USE_PLATFORM_DIRECTFB_EXT)
  284|  3.85k|    if (!strcmp(ext_prop->extensionName, "VK_EXT_directfb_surface")) return true;
  ------------------
  |  Branch (284:9): [True: 50, False: 3.80k]
  ------------------
  285|  3.80k|#endif  // VK_USE_PLATFORM_DIRECTFB_EXT
  286|  3.80k|#if !defined(VK_USE_PLATFORM_SCREEN_QNX)
  287|  3.80k|    if (!strcmp(ext_prop->extensionName, "VK_QNX_screen_surface")) return true;
  ------------------
  |  Branch (287:9): [True: 12, False: 3.79k]
  ------------------
  288|  3.79k|#endif  // VK_USE_PLATFORM_SCREEN_QNX
  289|       |
  290|  3.79k|    return false;
  291|  3.80k|}

