0
votes

I'm experimenting with LunarG's vulkan SDK for macOS. Everythings works great so far. However I'm struggling when it comes to debugging validation layers as I'm unable to find a solution for stepping up to layers code to debug them. I have simple CMake setup, for really simple project that basically does nothing but queries layers, extensions & stuff like that. This is my top level CMakeLists.txt:

cmake_minimum_required(VERSION 3.7)
project(TestApp)
find_package(vulkan REQUIRED)

set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD 17)

set(MACOS_APPLICATION_SRCS
    ${CMAKE_CURRENT_SOURCE_DIR}/Demo.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/main.mm
    ${CMAKE_CURRENT_SOURCE_DIR}/Application.mm
    ${CMAKE_CURRENT_SOURCE_DIR}/DemoViewController.mm
)

set(MACOS_APPLICATION_HEADERS
    ${CMAKE_CURRENT_SOURCE_DIR}/Demo.h
    ${CMAKE_CURRENT_SOURCE_DIR}/Application.h
    ${CMAKE_CURRENT_SOURCE_DIR}/DemoViewController.h
)

set(MACOS_APPLICATION_RESOURCES
    ${CMAKE_CURRENT_SOURCE_DIR}/Main.storyboard
)

add_definitions(-DVK_USE_PLATFORM_MACOS_MVK)
include_directories(./)

add_executable(TestApp MACOSX_BUNDLE
    ${MACOS_APPLICATION_HEADERS}
    ${MACOS_APPLICATION_SRCS}
    ${MACOS_APPLICATION_RESOURCES})

target_link_libraries(TestApp Vulkan::Vulkan "-framework AppKit -framework QuartzCore")

set_target_properties(TestApp PROPERTIES
    MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist
)

set_source_files_properties(${MACOS_APPLICATION_RESOURCES} PROPERTIES
    MACOSX_PACKAGE_LOCATION "Resources"
)

I'm creating bundled application, but right now I'm NOT storing any resources (vulkan loader, moltenvk lib, manifest files for layers & icd) in the bundle. I've just added env. variables (VK_ICD_FILENAMES, VK_LAYER_PATH) in Xcode, so they point to molten's icd manifest file that come's with sdk & layers variable to layers folder. I've tried to build layers myself with Debug configuration, so my VK_LAYER_PATH points to the layer build folder, where are manifest files. With this setup when I run my application, everything works fine, layers are loaded & my debug callback is properly called. But when I try to step into layer nothing happens, looks like xcode can't find symbols for layers. That would be ok I guess, but then I tried to set VK_LAYER_PATH pointing to my layers build folder in cubepp demo project which I've also builded. I was able to step into layers code then, which made me think that xcode not finding symbols might not be an issue. However I did some changes to cubepp CMakeLists.txt to find which properties I might be missing in my project, but after those changes I wasn't able to step into layers code again, even if I reverted my changes to CMakeLists. I'm guessing it might be some XCode issue, or I'm missing some @rpath etc settings, but these things as well as macOS platform are new to me. Any ideas how should I set up this to work properly?

Thanks

1

1 Answers

0
votes

Remember that when trying to step into the layers from your application, you have to step through the loader first because the loader is in between your application and the layers. I suspect that your bundled application is linked to a loader that was built without debug symbols and that's why you could not step into it.

The reason why cubepp worked is because it was probably linked (via rpath) to a loader that was built debuggable.

I had some success with:

  • Building the layers from the KhronosGroup/Vulkan-ValidationLayers repo in Debug mode
  • Setting VK_LAYER_PATH to the layer build directory of this repo in my XCode project scheme
  • Setting a Symbolic Breakpoint in Xcode (e.g., CreateInstance in libVkLayer_core_validation.dylib)

This causes XCode to stop in the debugger and display full source code for the layer.

Another approach would be to link your application with a loader that was built debuggable.