Einrichten von C ++ - Debugger in NeovimC++

Programme in C++. Entwicklerforum
Anonymous
 Einrichten von C ++ - Debugger in Neovim

Post by Anonymous »

Ich habe seit einiger Zeit versucht, einen Debugger für mein NVIM -CPP -Setup einzurichten, und ich kann einfach nicht herausfinden, wie ich es zum Laufen bringen kann. Ich kann keine guten Quellen online finden. Hier ist mein aktueller Versuch, NVIM-DAP zu konfigurieren, aber es stürzt nach Beginn des Programms ab und zeigt die Demontage anstelle des CPP-Quellcodes an. < /P>

Code: Select all

return {
{
"rcarriga/nvim-dap-ui",
dependencies = "mfussenegger/nvim-dap",
config = function()
local dap = require("dap")
local dapui = require("dapui")

dapui.setup({
layouts = {
{
elements = {
{ id = "scopes", size = 0.25 },
{ id = "breakpoints", size = 0.25 },
{ id = "stacks", size = 0.25 },
{ id = "watches", size = 0.25 },
},
size = 40,
position = "left",
},
{
elements = {
{ id = "repl", size = 0.5 },
{ id = "console", size = 0.5 },
},
size = 10,
position = "bottom",
},
},
})

dap.listeners.after.event_initialized["dapui_config"] = function()
dapui.open()
end
dap.listeners.before.event_terminated["dapui_config"] = function()
dapui.close()
end
dap.listeners.before.event_exited["dapui_config"] = function()
dapui.close()
end
end,
},
{
"jay-babu/mason-nvim-dap.nvim",
dependencies = {
"williamboman/mason.nvim",
"mfussenegger/nvim-dap",
},
opts = {
handlers = {},
},
config = function()
require("mason-nvim-dap").setup({
ensure_installed = { "codelldb" },
})
end,
},
{
"mfussenegger/nvim-dap",
config = function()
local dap = require("dap")

-- Get the grandparent directory (project name)
local project_name = vim.fn.fnamemodify(vim.fn.getcwd(), ":t")
project_name = project_name:gsub(" ", "_")

-- Construct the path to the executable
local executable_path = vim.fn.getcwd() .. "\\bin\\debug\\" .. project_name .. ".exe"

dap.adapters.codelldb = {
type = "executable",
command = "C:/Users/camer/AppData/Local/nvim-data/mason/packages/codelldb/extension/adapter/codelldb.exe",
name = "codelldb",
}

dap.configurations.cpp = {
{
name = "Launch",
type = "codelldb",
request = "launch",
program = function()
return vim.fn.input("Path to executable: ", vim.fn.getcwd() ..  "/bin/debug/ICS4U.exe", "file")
end,
cwd = "${workspaceFolder}",
},
}

local cwd = vim.fn.fnamemodify(executable_path, ":h:h:h")

dap.set_log_level("DEBUG")

-- Breakpoints
vim.keymap.set("n", "db", dap.toggle_breakpoint)
vim.keymap.set("n", "dB", function()
dap.set_breakpoint(vim.fn.input("Breakpoint condition: "))
end)
vim.keymap.set("n", "dc", dap.clear_breakpoints)

-- Debugging controls
vim.keymap.set("n", "dr", dap.continue) -- Start/Continue debugging
vim.keymap.set("n", "do", dap.step_over) -- Step over
vim.keymap.set("n", "di", dap.step_into) -- Step into
vim.keymap.set("n", "dO", dap.step_out) -- Step out
end,
},
{
"nvim-neotest/nvim-nio",
},
}

Hier sind meine CMakelists# Set C++ standard to C++11
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

set(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_RC_COMPILER_WORKS 1)
set(CMAKE_RC_COMPILER "CMAKE_RC_COMPILER-NOTFOUND")

cmake_minimum_required(VERSION 3.10)

# Set Clang and Clang++ as the C and C++ compilers
set(CMAKE_C_COMPILER "C:/Program Files/LLVM/bin/clang.exe")
set(CMAKE_CXX_COMPILER "C:/Program Files/LLVM/bin/clang++.exe")
set(CMAKE_RC_COMPILER "C:/Program Files (x86)/Windows Kits/10/bin/10.0.22621.0/x86/rc.exe")

# Get the directory above the source directory
get_filename_component(PROJECT_ROOT_DIR ${CMAKE_SOURCE_DIR}/ ABSOLUTE)
get_filename_component(PROJECT_NAME_RAW ${PROJECT_ROOT_DIR} NAME)
string(REPLACE " " "_" PROJECT_NAME_CLEAN ${PROJECT_NAME_RAW})
project(${PROJECT_NAME_CLEAN})

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fuse-ld=lld")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fuse-ld=lld")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=lld")

# Explicitly set 32-bit flags for Clang
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32")

# Set build type configurations
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug)
endif()

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

set(PROJECT_BIN_DIR ${CMAKE_SOURCE_DIR}/../bin)

# Set output directories for executables
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/$)

set(PROJECT_SOURCE_FILES
${CMAKE_SOURCE_DIR}/ICS_ConsoleHelper.cpp
)

# Create executable
add_executable(${PROJECT_NAME}
${PROJECT_SOURCE_FILES}
)

# Add Windows-specific libraries
if(WIN32)
target_link_libraries(${PROJECT_NAME}
C:/Users/camer/Neovim/projects/ICS4U/main.cpp
-luser32
-lgdi32
-lwinspool
-lshell32
-lole32
-loleaut32
-luuid
-lcomdlg32
-ladvapi32
)
endif()

# Suppress warnings for C source files
set_source_files_properties(${C_SOURCE_FILES}
PROPERTIES COMPILE_FLAGS "-w"
)

# Set compiler-specific flags
if(CMAKE_BUILD_TYPE MATCHES Debug)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BIN_DIR}/debug)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g")
else()
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BIN_DIR}/release)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3")
endif()

< /code>
Ich habe CodellDB auf dem aufgelisteten Pfad installiert, und ich habe überprüft, ob der Pfad korrekt ist und dass die dort reaktionsschnelle .exe reagiert. Ich habe keine Ahnung, was das Problem mit diesem Programm ist.

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post