node.js(express)在vscode中打断点

node.js(express)在vscode中打断点,第1张

首先点击vscode菜单栏的运行 >打开配置,进行配置断点启动内容

{

            "type": "node",

            "request": "launch",

            "name": "node debugger",

            "program": "${workspaceFolder}/bin/www"

        }

然后运行调试即可

如果这个项目已经通过node start 或者其他配置启动了项目,用调试的启动项目是启动不了的,端口已经被占用。所以应该直接点击启动调试

一、VSCode 自带

新建文件夹 Test ->VSCode 打开 Test ->新建文件 main.cpp -> 

DEBUG “执行按钮”右边“add configuration...”  选择 “g++ build and debug” -> 

VSCode 自动生成 tasks.json 和 laugh.json 即可断点调试

二、makefile 文件

1. VSCode 新建文件 makefile 内容如下:

.default: all

all: main

main: main.o

    g++ -Wall -Werror -std=c++14 -g -O -o $@ $^

%.o: %.cpp

    g++ -Wall -Werror -std=c++14 -g -O -c $^

clean:

    rm -rf qwirkle *.o *.dSYM

此时,打开命令行,make,可以生成可执行文件

2. task.json 改成如下:

{

    "tasks": [

        {

            "type": "shell",

            "label": "shell",

            "command": "/usr/bin/make",

        }

    ],

    "version": "2.0.0"

}

3. launch.json 改成如下:

{

    // Use IntelliSense to learn about possible attributes.

    // Hover to view descriptions of existing attributes.

    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387

    "version": "0.2.0",

    "configurations": [

        {

            "name": "g++ build and debug active file",  // 配置名称,将会在启动配置的下拉菜单中显示

            "type": "cppdbg",

            "request": "launch",  // 请求配置类型,可以为launch(启动)或attach(附加)

            "program": "${fileDirname}/main",  //将要进行调试的程序的路径,与 makefile 中的 main 一致

            "args": [],

            "stopAtEntry": true,  // 设为true时程序将暂停在程序入口处

            "cwd": "${workspaceFolder}",

            "environment": [],

            "externalConsole": true, // 调试时是否显示控制台窗口,必须为true显示控制台,才能输入,交互

            "MIMode": "lldb",  // 指定连接的调试器,可以为gdb或lldb。

            "preLaunchTask": "shell"   //调试会话开始前执行的任务,一般为编译程序。与 tasks.json 的 label 一致

        }

    ]

}

点击 VSCode 执行按钮即可断点调试,找到d出的窗口,即可输入,交互

注意断点打到  std::cout<<"start"<<std::endl 不停留


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/bake/11530920.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-16
下一篇2023-05-16

发表评论

登录后才能评论

评论列表(0条)

    保存