feat(dap): Added debugger from cpptools
Added: - OpenDebugAD7 from [vscode-cpptools](https://github.com/microsoft/vscode-cpptools) It works better with `nvim-dap-ui`. With GDB you have to wait for stdout flush to see program output, the output is in the repl instead of the console, etc. The VSCode debugger doesn't have such issues.
This commit is contained in:
parent
1441e90711
commit
db5a3f56b4
71
nix/cpptools.nix
Normal file
71
nix/cpptools.nix
Normal file
@ -0,0 +1,71 @@
|
||||
{ stdenv, lib
|
||||
, system ? builtins.currentSystem
|
||||
, fetchurl
|
||||
, unzip
|
||||
, libz
|
||||
, libcxx
|
||||
, lttng-ust_2_12
|
||||
, autoPatchelfHook
|
||||
}:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "cpptools";
|
||||
version = "1.21.6";
|
||||
|
||||
# Get the current system architecture
|
||||
# arch = builtins.currentSystem;
|
||||
|
||||
linux-x64 = "https://github.com/microsoft/vscode-cpptools/releases/download/v${version}/cpptools-linux-x64.vsix";
|
||||
linux-arm64 = "https://github.com/microsoft/vscode-cpptools/releases/download/v${version}/cpptools-linux-arm64.vsix";
|
||||
darwin-x64 = "https://github.com/microsoft/vscode-cpptools/releases/download/v${version}/cpptools-macos-x64.vsix";
|
||||
darwin-arm64 = "https://github.com/microsoft/vscode-cpptools/releases/download/v${version}/cpptools-macos-arm64.vsix";
|
||||
|
||||
|
||||
src = fetchurl {
|
||||
url = lib.getAttr system {
|
||||
x86_64-linux = "https://github.com/microsoft/vscode-cpptools/releases/download/v${version}/cpptools-linux-x64.vsix";
|
||||
aarch64-linux = "https://github.com/microsoft/vscode-cpptools/releases/download/v${version}/cpptools-linux-arm64.vsix";
|
||||
aarch64-darwin = "https://github.com/microsoft/vscode-cpptools/releases/download/v${version}/cpptools-macos-arm64.vsix";
|
||||
x86_64-darwin = "https://github.com/microsoft/vscode-cpptools/releases/download/v${version}/cpptools-macos-x64.vsix";
|
||||
};
|
||||
hash = lib.getAttr system {
|
||||
x86_64-linux = "sha256-q6SDImUppICJopOi+HiIUMg7Ue1Qu0A41uewNxRdzeA=";
|
||||
aarch64-linux = "sha256-/Zci8P5RAK26FASHpQnIYR5fvSF9lgTTrgVAT33Wfwc=";
|
||||
x86_64-darwin = "sha256-P2LacAaCRXnsGUQOLuIyvfgxweeVHsDFTrAEuN/lBIQ=";
|
||||
aarch64-darwin = "sha256-P2LacAaCRXnsGUQOLuIyvfgxweeVHsDFTrAEuN/lBIQ=";
|
||||
};
|
||||
};
|
||||
|
||||
nativeBuildInputs = [
|
||||
autoPatchelfHook
|
||||
];
|
||||
|
||||
buildInputs = [
|
||||
unzip
|
||||
libz
|
||||
libcxx
|
||||
lttng-ust_2_12
|
||||
];
|
||||
|
||||
unpackPhase = ''
|
||||
unzip $src
|
||||
'';
|
||||
|
||||
sourceRoot = ".";
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
mkdir -p $out/bin
|
||||
mkdir -p $out/opt
|
||||
cp -r extension/debugAdapters/* $out/opt
|
||||
install -m755 -D extension/debugAdapters/bin/OpenDebugAD7 $out/opt/bin/OpenDebugAD7
|
||||
ln -s $out/opt/bin/OpenDebugAD7 $out/bin/OpenDebugAD7
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
meta = with lib; {
|
||||
homepage = "https://github.com/microsoft/vscode-cpptools";
|
||||
description = "Official repository for the Microsoft C/C++ extension for VS Code. ";
|
||||
platforms = platforms.linux;
|
||||
};
|
||||
}
|
@ -120,6 +120,7 @@ with final.pkgs.lib; let
|
||||
# language servers, etc.
|
||||
asm-lsp # Assembly language server
|
||||
clang-tools # C/C++ language server
|
||||
(callPackage ./cpptools.nix {}) # C/C++ debugger from VSCode | https://github.com/microsoft/vscode-cpptools
|
||||
nodePackages.bash-language-server # Bash language server
|
||||
lua-language-server
|
||||
nil # nix LSP
|
||||
|
@ -35,20 +35,16 @@ dap.adapters.gdb = {
|
||||
args = { "-i", "dap" }
|
||||
}
|
||||
|
||||
dap.adapters.cppdbg = {
|
||||
id = 'cppdbg',
|
||||
type = 'executable',
|
||||
command = 'OpenDebugAD7',
|
||||
}
|
||||
|
||||
dap.configurations.c = {
|
||||
-- {
|
||||
-- name = "Launch",
|
||||
-- type = "gdb",
|
||||
-- request = "launch",
|
||||
-- program = function()
|
||||
-- return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
|
||||
-- end,
|
||||
-- cwd = "${workspaceFolder}",
|
||||
-- stopAtBeginningOfMainSubprogram = false,
|
||||
-- },
|
||||
{
|
||||
name = "Launch an executable",
|
||||
type = "gdb",
|
||||
type = "cppdbg",
|
||||
request = "launch",
|
||||
cwd = "${workspaceFolder}",
|
||||
program = function()
|
||||
@ -70,6 +66,6 @@ dap.configurations.c = {
|
||||
:find()
|
||||
end)
|
||||
end,
|
||||
stopAtBeginningOfMainSubprogram = false,
|
||||
stopAtBeginningOfMainSubprogram = true,
|
||||
},
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user