local dap = require('dap') local async = require('plenary.async') --- Gets a path for a given program in the environment ---@param program @The string of a program in the PATH ---@return @The full path to the program if found, or nil if not local function get_program_path(program) local fd = io.popen('which ' .. program) local program_path = fd:read('*all') fd:close() program_path = program_path.gsub(program_path, '\n', '') if program_path == nil or program_path == '' then async.run(function() vim.notify.async(('Failed to find (%s) in your path'):format(program), 'error', { title = 'DAP', }).events.close() end) program_path = nil end return program_path end local lldb_path = get_program_path('lldb-vscode') -- Adapaters dap.adapters.lldb = { type = 'executable', command = lldb_path, name = 'lldb', } -- configurations dap.configurations.cpp = { { name = 'Launch', type = 'lldb', request = 'launch', program = function() return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file') end, cwd = '${workspaceFolder}', stopOnEntry = false, targetArchitecture = 'arm64', args = {}, -- if you change `runInTerminal` to true, you might need to change the yama/ptrace_scope setting: -- -- echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope -- -- Otherwise you might get the following error: -- -- Error on launch: Failed to attach to the target process -- -- But you should be aware of the implications: -- https://www.kernel.org/doc/html/latest/admin-guide/LSM/Yama.html runInTerminal = false, }, } dap.configurations.c = dap.configurations.cpp dap.configurations.rust = dap.configurations.cpp