te')); return $arr; } /* 遍历用户所有主题 * @param $uid 用户ID * @param int $page 页数 * @param int $pagesize 每页记录条数 * @param bool $desc 排序方式 TRUE降序 FALSE升序 * @param string $key 返回的数组用那一列的值作为 key * @param array $col 查询哪些列 */ function thread_tid_find_by_uid($uid, $page = 1, $pagesize = 1000, $desc = TRUE, $key = 'tid', $col = array()) { if (empty($uid)) return array(); $orderby = TRUE == $desc ? -1 : 1; $arr = thread_tid__find($cond = array('uid' => $uid), array('tid' => $orderby), $page, $pagesize, $key, $col); return $arr; } // 遍历栏目下tid 支持数组 $fid = array(1,2,3) function thread_tid_find_by_fid($fid, $page = 1, $pagesize = 1000, $desc = TRUE) { if (empty($fid)) return array(); $orderby = TRUE == $desc ? -1 : 1; $arr = thread_tid__find($cond = array('fid' => $fid), array('tid' => $orderby), $page, $pagesize, 'tid', array('tid', 'verify_date')); return $arr; } function thread_tid_delete($tid) { if (empty($tid)) return FALSE; $r = thread_tid__delete(array('tid' => $tid)); return $r; } function thread_tid_count() { $n = thread_tid__count(); return $n; } // 统计用户主题数 大数量下严谨使用非主键统计 function thread_uid_count($uid) { $n = thread_tid__count(array('uid' => $uid)); return $n; } // 统计栏目主题数 大数量下严谨使用非主键统计 function thread_fid_count($fid) { $n = thread_tid__count(array('fid' => $fid)); return $n; } ?>c++ - How do I get GDB to work with MacOS 15.3 and Eclipse? - Stack Overflow
最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

c++ - How do I get GDB to work with MacOS 15.3 and Eclipse? - Stack Overflow

programmeradmin3浏览0评论

I was working with Eclipse and C++, using a configuration for Vulkan with the GNU toolchain, and I decided to try compiling in release mode. At this point, my debug configuration was working. I got my program to compile in release mode, but when I switched back to debug mode I got this error from Eclipse:

Could not determine GDB version using command: gdb --version

When I try running that command in my MacOS terminal, it works, but when I run it in my Eclipse terminal, it returns an empty line; it doesn't show an error or the typical johndoe@nameOfComputer ~ %. The same thing happens when I try to run

gdb

with no --version flag.

I tried redownloading GDB with Homebrew and codesigning it, which was successful, but did not fix the problem. I then changed my Eclipse configuration to include /usr/local/Cellar/gdb/16.2/bin in the PATH variable. However, when I run the command

echo $PATH

in my Eclipse terminal, I get the following output:

/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

which doesn't include /usr/local/Cellar/gdb/16.2/bin, although it should include an alias to GDB. I specified /usr/local/Cellar/gdb/16.2/bin to make absolutely sure it would find GDB, although it probably doesn't make a difference. I also tried changing my gdb debugger in Eclipse from "gdb" to "/usr/local/Cellar/gdb/16.2/bin/gdb", which works, but it only changes my error message to:

Could not determine GDB version using command: /usr/local/Cellar/gdb/16.2/bin/gdb --version

Even when I run

export PATH=/usr/local/Cellar/gdb/16.2/bin/gdb/version:$PATH

in my Eclipse terminal to manually add the correct path to gdb, running

gdb --version

or

/usr/local/Cellar/gdb/16.2/bin/gdb

still returns an empty line, as described before. All of these things work, though, when I run them in my MacOS terminal.

Here's the code I'm using; I don't think it will be relevant, but I'm relatively new to using C++ and Vulkan, so I'm not sure.

#define GLFW_INCLUDE_VULKAN

#include <GLFW/glfw3.h>
#include <iostream>
#include <cstdint>
#include <cstring>

#ifdef NDEBUG
    #define MAIN_WINDOW_NAME ""
#else
    #define MAIN_WINDOW_NAME "Main Window"
#endif

#define WINDOW_RESIZABLE GLFW_FALSE
#define WINDOW_WIDTH 800
#define WINDOW_HEIGHT 600

#define APPLICATION_NAME "VulkanGame"

#ifdef NDEBUG
    #define DEBUG_STATEMENT(statement)
    #define RELEASE_STATEMENT(statement) statement
    #define MODE_STATEMENT(debug, release) release

    #define DEBUG_MESSAGE(message)
    #define ERROR(message) throw nullptr
    #define RESULT_FUNC(func) func;
#else
    #define DEBUG_STATEMENT(statement) statement
    #define RELEASE_STATEMENT(statement)
    #define MODE_STATEMENT(debug, release) debug
    #define DEBUG_MESSAGE(message) std::cout << message << std::endl;
    #define ERROR(message) throw message
#define RESULT_FUNC(func) VkResult result = func; if (result != VK_SUCCESS) {throw result;}

    #define VALIDATION_LAYER_COUNT 1
#endif

/* Here's an explanation of the macros I'm using:
DEBUG_STATEMENT() Only adds the code when in Debug mode
RELEASE_STATEMENT() Only adds the code when in Release mode
MODE_STATEMENT() Adds the first argument of code when in Debug mode, and the second argument when in Release mode.
DEBUG_MESSAGE() Outputs the string to the console when in Debug mode
ERROR() Throws the error if in Debug mode; if in release mode, throws nullptr.
RESULT_FUNC() Runs the Vulkan function if in Release mode; if in Debug mode, makes sure it returns VK_SUCCESS */

GLFWwindow* mainWindow;

DEBUG_STATEMENT(const char* const validationLayers[VALIDATION_LAYER_COUNT] = {"VK_LAYER_KHRONOS_validation"};)

void destroyApplication()
{
    DEBUG_MESSAGE("Shutting down application...");

    glfwDestroyWindow(mainWindow);
    glfwTerminate();

    DEBUG_MESSAGE("Application shut down. Terminating application.");
}

int main()
{
    try
    {
        DEBUG_STATEMENT(std::cout << "Debug mode active" << std::endl;)

        glfwInit();
        glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
        glfwWindowHint(GLFW_RESIZABLE, WINDOW_RESIZABLE);
        mainWindow = glfwCreateWindow(WINDOW_WIDTH, WINDOW_HEIGHT, MAIN_WINDOW_NAME, nullptr, nullptr);

        VkInstance mainVulkanInstance;
        VkApplicationInfo vulkanAppInfo;
        VkInstanceCreateInfo defaultVulkanInstanceCreateInfo;

        vulkanAppInfo.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
        vulkanAppInfo.pApplicationName = APPLICATION_NAME;
        vulkanAppInfo.applicationVersion = VK_MAKE_VERSION(1, 0, 0);
        vulkanAppInfo.pEngineName = "No Engine";
        vulkanAppInfo.engineVersion = VK_MAKE_VERSION(1, 0, 0);
        vulkanAppInfo.apiVersion = VK_API_VERSION_1_3;

        defaultVulkanInstanceCreateInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
        defaultVulkanInstanceCreateInfo.pApplicationInfo = &vulkanAppInfo;
        defaultVulkanInstanceCreateInfo.ppEnabledExtensionNames = glfwGetRequiredInstanceExtensions(&defaultVulkanInstanceCreateInfo.enabledExtensionCount);

        DEBUG_STATEMENT
        (
            {
                uint32_t availableLayers;
                vkEnumerateInstanceLayerProperties(&availableLayers, nullptr);
                std::vector<VkLayerProperties> availableLayerProperties(availableLayers);
                vkEnumerateInstanceLayerProperties(&availableLayers, availableLayerProperties.data());

                for (uint8_t i = 0; i < VALIDATION_LAYER_COUNT; i++)
                {
                    bool layeravailable = false;

                    for (uint8_t j = 0; j < availableLayers; j++)
                    {
                        if (strcmp(validationLayers[i], availableLayerProperties[j].layerName) == 0)
                        {
                            layeravailable = true;
                            break;
                        }
                    }
                    if (!layeravailable)
                    {
                        MODE_STATEMENT
                        (
                            {
                                char errorMessage[293] = "Validation layer ";
                                strcat(errorMessage, validationLayers[i]);
                                strcat(errorMessage, " could not be found!");
                                throw errorMessage;
                            },
                            {
                                throw nullptr;
                            }
                        )
                    }
                }
            }
            defaultVulkanInstanceCreateInfo.enabledLayerCount = VALIDATION_LAYER_COUNT;
            defaultVulkanInstanceCreateInfo.ppEnabledLayerNames = validationLayers;
        )

        RELEASE_STATEMENT
        (
            defaultVulkanInstanceCreateInfo.enabledLayerCount = 0;
            defaultVulkanInstanceCreateInfo.ppEnabledLayerNames = nullptr;
        )

        RESULT_FUNC(vkCreateInstance(&defaultVulkanInstanceCreateInfo, nullptr, &mainVulkanInstance))

        while (!glfwWindowShouldClose(mainWindow))
        {
            glfwPollEvents();
        }

        destroyApplication();

    }
    DEBUG_STATEMENT
    (
        catch (const char* const &e)
        {
            std::cerr << "Exception caught of type string (const char* const). Error: "
                    << e << std::endl;

            destroyApplication();
        }
        catch (VkResult &e)
        {
                        //this catch statement just converts return values of VkResult into const char*
            char* errorMessage = nullptr;
            const char* result;

            switch (e)
            {
            case VK_SUCCESS : result = "VK_SUCCESS"; break;
            case VK_NOT_READY : result = "VK_NOT_READY"; break;
            case VK_TIMEOUT : result = "VK_TIMEOUT"; break;
            case VK_EVENT_SET : result = "VK_EVENT_SET"; break;
            case VK_EVENT_RESET : result = "VK_EVENT_RESET"; break;
            case VK_INCOMPLETE : result = "VK_INCOMPLETE"; break;
            case VK_ERROR_OUT_OF_HOST_MEMORY : result = "VK_ERROR_OUT_OF_HOST_MEMORY"; break;
            case VK_ERROR_OUT_OF_DEVICE_MEMORY : result = "VK_ERROR_OUT_OF_DEVICE_MEMORY"; break;
            case VK_ERROR_INITIALIZATION_FAILED : result = "VK_ERROR_INITIALIZATION_FAILED"; break;
            case VK_ERROR_DEVICE_LOST : result = "VK_ERROR_DEVICE_LOST"; break;
            case VK_ERROR_MEMORY_MAP_FAILED : result = "VK_ERROR_MEMORY_MAP_FAILED"; break;
            case VK_ERROR_LAYER_NOT_PRESENT : result = "VK_ERROR_LAYER_NOT_PRESENT"; break;
            case VK_ERROR_EXTENSION_NOT_PRESENT : result = "VK_ERROR_EXTENSION_NOT_PRESENT"; break;
            case VK_ERROR_FEATURE_NOT_PRESENT : result = "VK_ERROR_FEATURE_NOT_PRESENT"; break;
            case VK_ERROR_INCOMPATIBLE_DRIVER : result = "VK_ERROR_INCOMPATIBLE_DRIVER"; break;
            case VK_ERROR_TOO_MANY_OBJECTS : result = "VK_ERROR_TOO_MANY_OBJECTS"; break;
            case VK_ERROR_FORMAT_NOT_SUPPORTED : result = "VK_ERROR_FORMAT_NOT_SUPPORTED"; break;
            case VK_ERROR_FRAGMENTED_POOL : result = "VK_ERROR_FRAGMENTED_POOL"; break;
            case VK_ERROR_UNKNOWN : result = "VK_ERROR_UNKNOWN"; break;
            case VK_ERROR_OUT_OF_POOL_MEMORY : result = "VK_ERROR_OUT_OF_POOL_MEMORY or VK_ERROR_OUT_OF_POOL_MEMORY_KHR"; break;
            case VK_ERROR_INVALID_EXTERNAL_HANDLE : result = "VK_ERROR_INVALID_EXTERNAL_HANDLE or VK_ERROR_INVALID_EXTERNAL_HANDLE_KHR"; break;
            case VK_ERROR_FRAGMENTATION : result = "VK_ERROR_FRAGMENTATION or VK_ERROR_FRAGMENTATION_EXT"; break;
            case VK_ERROR_INVALID_OPAQUE_CAPTURE_ADDRESS : result = "VK_ERROR_INVALID_OPAQUE_CAPTURE_ADDRESS, VK_ERROR_INVALID_DEVICE_ADDRESS_EXT, or VK_ERROR_INVALID_OPAQUE_CAPTURE_ADDRESS_KHR"; break;
            case VK_PIPELINE_COMPILE_REQUIRED : result = "VK_PIPELINE_COMPILE_REQUIRED, VK_PIPELINE_COMPILE_REQUIRED_EXT, or VK_ERROR_PIPELINE_COMPILE_REQUIRED_EXT"; break;
            //case VK_ERROR_NOT_PERMITTED : result = "VK_ERROR_NOT_PERMITTED"; break;
            case VK_ERROR_SURFACE_LOST_KHR : result = "VK_ERROR_SURFACE_LOST_KHR"; break;
            case VK_ERROR_NATIVE_WINDOW_IN_USE_KHR : result = "VK_ERROR_NATIVE_WINDOW_IN_USE_KHR"; break;
            case VK_SUBOPTIMAL_KHR : result = "VK_SUBOPTIMAL_KHR"; break;
            case VK_ERROR_OUT_OF_DATE_KHR : result = "VK_ERROR_OUT_OF_DATE_KHR"; break;
            case VK_ERROR_INCOMPATIBLE_DISPLAY_KHR : result = "VK_ERROR_INCOMPATIBLE_DISPLAY_KHR"; break;
            case VK_ERROR_VALIDATION_FAILED_EXT : result = "VK_ERROR_VALIDATION_FAILED_EXT"; break;
            case VK_ERROR_INVALID_SHADER_NV : result = "VK_ERROR_INVALID_SHADER_NV"; break;
            case VK_ERROR_IMAGE_USAGE_NOT_SUPPORTED_KHR : result = "VK_ERROR_IMAGE_USAGE_NOT_SUPPORTED_KHR"; break;
            case VK_ERROR_VIDEO_PICTURE_LAYOUT_NOT_SUPPORTED_KHR : result = "VK_ERROR_VIDEO_PICTURE_LAYOUT_NOT_SUPPORTED_KHR"; break;
            case VK_ERROR_VIDEO_PROFILE_OPERATION_NOT_SUPPORTED_KHR : result = "VK_ERROR_VIDEO_PROFILE_OPERATION_NOT_SUPPORTED_KHR"; break;
            case VK_ERROR_VIDEO_PROFILE_FORMAT_NOT_SUPPORTED_KHR : result = "VK_ERROR_VIDEO_PROFILE_FORMAT_NOT_SUPPORTED_KHR"; break;
            case VK_ERROR_VIDEO_PROFILE_CODEC_NOT_SUPPORTED_KHR : result = "VK_ERROR_VIDEO_PROFILE_CODEC_NOT_SUPPORTED_KHR"; break;
            case VK_ERROR_VIDEO_STD_VERSION_NOT_SUPPORTED_KHR : result = "VK_ERROR_VIDEO_STD_VERSION_NOT_SUPPORTED_KHR"; break;
            case VK_ERROR_INVALID_DRM_FORMAT_MODIFIER_PLANE_LAYOUT_EXT : result = "VK_ERROR_INVALID_DRM_FORMAT_MODIFIER_PLANE_LAYOUT_EXT"; break;
            case VK_ERROR_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT : result = "VK_ERROR_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT"; break;
            case VK_THREAD_IDLE_KHR : result = "VK_THREAD_IDLE_KHR"; break;
            case VK_THREAD_DONE_KHR : result = "VK_THREAD_DONE_KHR"; break;
            case VK_OPERATION_DEFERRED_KHR : result = "VK_OPERATION_DEFERRED_KHR"; break;
            case VK_OPERATION_NOT_DEFERRED_KHR : result = "VK_OPERATION_NOT_DEFERRED_KHR"; break;
            case VK_ERROR_INVALID_VIDEO_STD_PARAMETERS_KHR : result = "VK_ERROR_INVALID_VIDEO_STD_PARAMETERS_KHR"; break;
            case VK_ERROR_COMPRESSION_EXHAUSTED_EXT : result = "VK_ERROR_COMPRESSION_EXHAUSTED_EXT"; break;
            case VK_INCOMPATIBLE_SHADER_BINARY_EXT : result = "VK_INCOMPATIBLE_SHADER_BINARY_EXT or VK_ERROR_INCOMPATIBLE_SHADER_BINARY_EXT"; break;
            case VK_PIPELINE_BINARY_MISSING_KHR : result = "VK_PIPELINE_BINARY_MISSING_KHR"; break;
            case VK_ERROR_NOT_ENOUGH_SPACE_KHR : result = "VK_ERROR_NOT_ENOUGH_SPACE_KHR"; break;
            //case VK_ERROR_OUT_OF_POOL_MEMORY_KHR : result = "VK_ERROR_OUT_OF_POOL_MEMORY_KHR"; break;
            //case VK_ERROR_INVALID_EXTERNAL_HANDLE_KHR : result = "VK_ERROR_INVALID_EXTERNAL_HANDLE_KHR"; break;
            //case VK_ERROR_FRAGMENTATION_EXT : result = "VK_ERROR_FRAGMENTATION_EXT"; break;
            case VK_ERROR_NOT_PERMITTED_EXT : result = "VK_ERROR_NOT_PERMITTED_EXT or VK_ERROR_NOT_PERMITTED_KHR"; break;
            //case VK_ERROR_NOT_PERMITTED_KHR : result = "VK_ERROR_NOT_PERMITTED_KHR"; break;
            //case VK_ERROR_INVALID_DEVICE_ADDRESS_EXT : result = "VK_ERROR_INVALID_DEVICE_ADDRESS_EXT"; break;
            //case VK_ERROR_INVALID_OPAQUE_CAPTURE_ADDRESS_KHR : result = "VK_ERROR_INVALID_OPAQUE_CAPTURE_ADDRESS_KHR"; break;
            //case VK_PIPELINE_COMPILE_REQUIRED_EXT : result = "VK_PIPELINE_COMPILE_REQUIRED_EXT"; break;
            //case VK_ERROR_PIPELINE_COMPILE_REQUIRED_EXT : result = "VK_ERROR_PIPELINE_COMPILE_REQUIRED_EXT"; break;
            //case VK_ERROR_INCOMPATIBLE_SHADER_BINARY_EXT : result = "VK_ERROR_INCOMPATIBLE_SHADER_BINARY_EXT"; break;
            case VK_RESULT_MAX_ENUM : result = "VK_RESULT_MAX_ENUM"; break;
            default : result = "an unknown value!";
            }
            strcat(errorMessage, "Execption caught of type VkResult: Vulkan function returned ");
            strcat(errorMessage, result);
            std::cerr << errorMessage << std::endl;
        }
    )
    catch (...)
    {
        DEBUG_STATEMENT(std::cerr << "Exception caught of an unknown type");
        destroyApplication();
    }
}
发布评论

评论列表(0)

  1. 暂无评论