首页 > 其他分享 >vscode launch

vscode launch

时间:2024-05-17 19:54:10浏览次数:24  
标签:name launch vscode request program debug type

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "C/C++ Runner: Debug Session",
      "type": "cppdbg",
      "request": "launch",
      "args": [],
      "stopAtEntry": false,
      "externalConsole": true,
      "cwd": "d:/Project/leetcode",
      "program": "d:/Project/leetcode/build/Debug/outDebug",
      "MIMode": "gdb",
      "miDebuggerPath": "gdb",
      "setupCommands": [
        {
          "description": "Enable pretty-printing for gdb",
          "text": "-enable-pretty-printing",
          "ignoreFailures": true
        }
      ]
    }
  ]
}

必选属性

  • type : type of debugger --- 每个debug扩展都有一个 type 名称
  • request : 请求类型 -- launch / attach
  • name : 自定义名称

可选属性

  • presentation : order, group,hidden , 用于 debug 侧边栏的展示
  "presentation": {
	"hidden": false,
	"group": "",
	"order": 1
  },
  • preLaunchTask : 在 debug 之前执行一个 task, 名称为 task.json 中的任务
  • postDebugTask : 在 debug 结束后执行一个 task
  • internalConsoleOptions : debug 期间的 终端面板控制选项
  • debugServer : 仅对debug扩展 : 此属性允许您连接到指定的端口,而不是启动调试适配器。
  • serverReadyAction : if you want to open a URL in a web browser whenever the program under debugging outputs a specific message to the debug console or integrated terminal. For details see section Automatically open a URI when debugging a server program below.

常见选项

  • program - executable or file to run when launching the debugger
  • args - arguments passed to the program to debug
  • env - environment variables (the value null can be used to "undefine" a variable)
  • envFile - path to dotenv file with environment variables
  • cwd - current working directory for finding dependencies and other files
  • port - port when attaching to a running process
  • stopOnEntry - break immediately when the program launches
  • console - what kind of console to use, for example, internalConsoleintegratedTerminal, or externalTerminal

变量替换

[[vscode variable substitution]]

不同平台指定配置

![[vscode tasks#操作系统特定属性]]

断点

行内断点

shift - F9

一些其他断点

函数断点,数据断点

重定向输入或输出

两种方法 : 使用 attach 方法信息调试 ,或者使用管道(如果支持的话)

{
  "name": "launch program that reads a file from stdin",
  "type": "node",
  "request": "launch",
  "program": "program.js",
  "console": "integratedTerminal",
  "args": ["<", "in.txt"]
}

Multi-target debugging

同时启动多个 debug 程序

组合 launch 配置

{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "node",
      "request": "launch",
      "name": "Server",
      "program": "${workspaceFolder}/server.js"
    },
    {
      "type": "node",
      "request": "launch",
      "name": "Client",
      "program": "${workspaceFolder}/client.js"
    }
  ],
  "compounds": [
    {
      "name": "Server/Client",
      "configurations": ["Server", "Client"],
      "preLaunchTask": "${defaultBuildTask}",
      "stopAll": true
    }
  ]
}

自动打开URL -- need more use

{
  "type": "node",
  "request": "launch",
  "name": "Launch Program",
  "program": "${workspaceFolder}/app.js",

  "serverReadyAction": {
    "pattern": "listening on port ([0-9]+)",
    "uriFormat": "http://localhost:%s",
    "action": "openExternally"
  }
}

pattern 定义了一个正则,用于捕获终端的输出

uriFormat属性描述如何将端口号转换为URI,The first %s is substituted by the first capture group of the matching pattern.

Alternatively, the action can be set to debugWithEdge or debugWithChrome. In this mode, a webRoot property can be added that is passed to the Chrome or Edge debug session.

Triggering an Arbitrary Launch Config

In some cases, you may need to configure additional options for the browser debug session--or use a different debugger entirely. You can do this by setting action to startDebugging with a name property set to the name of the launch configuration to start when the pattern is matched.

The named launch configuration must be in the same file or folder as the one with the serverReadyAction.

标签:name,launch,vscode,request,program,debug,type
From: https://www.cnblogs.com/bigsharker/p/18198547

相关文章

  • vscode leetcode 插件
    区域测试//@lcprcase=start//"PAYPALISHIRINGGGG"\n3\n//@lcprcase=enddiy参数用于调试不同类型的参数和函数//@lcpr-div-debug-arg-start//funName=alternateDigitSum//paramTypes=["number"]//@lcpr-div-debug-arg-endfunName:函数名称paramTypes......
  • vscode tasks
    vscodecustomtasktask模板{//Seehttps://go.microsoft.com/fwlink/?LinkId=733558//forthedocumentationaboutthetasks.jsonformat"version":"2.0.0","tasks":[{"label":"Runtests&quo......
  • ESP32+RS485参考代码要点+@环境esp-idf-v5.1.2 +vscode 草稿
    在环境esp-idf-v5.1.2+vscode 中,如何在一个文件内,调用另外一个文件夹内定义的函数。 设置帧内间隔(在传输线上,两个发送的字节之间的时间间隔,不超过3.5发送单个字节的时间。)通过函数esp_err_tuart_set_rx_timeout(uart_port_tuart_num,constuint8_ttout_thresh)实现此......
  • 韭菜盒子!VSCode 也可以看股票&基金了!
    大家好,我是Java陈序员。“打工这辈子是不可能打工的”!仅仅靠打工、上班是很难实现财务自由的,当我们积累了一定的财富,就会去理财。将自己的资本投入到一些理财产品中,如基金、股票等。但常常操作不当,就会被“割韭菜”!今天,给大家介绍一款VSCode插件,支持实时查看股票、基金数据,......
  • vscode 避免每次ssh校验
    在本地生成public_key将文件传到虚拟机上[email protected]:.ssh将id_rsa.pub内容写到authorized_keys中catid_rsa.pub>>authorized_keys......
  • VScode 运行 jupyter 心得
    在服务器上,用vscode运行.ipynb文件是常用的手段,但是搞多了就会发现还是会有各种问题,在这里记录一下。os.environ的使用经常在这个运行一个程序前,我们需要加载一些环境变量,来设置比如代理转发(用于下载外面的东西),例:importosproxy_list=['HTTP_PROXY','HTTPS_PROXY',......
  • [997] Launch the first AWS EC2 Windows Instance
    ref:SetuptouseAmazonEC2ref:Tutorial:GetstartedwithAmazonEC2Windowsinstancesref:EC2-Video3-LaunchFirstEC2WindowsInstanceStep1:CreateakeypairAWSusespublic-keycryptographytosecurethelogininformationforyourinstance......
  • 使用vscode在线打开github项目
    使用vscode在线打开github项目方式1:使用github1s项目操作方式非常的简单,只需要在浏览器网址部分中的“github”后边,添加一个“1s”就可以了。缺点:代码都是以只读模式打开的,只能看,没法改。测试项目地址https://github.com/Ponderfly/GoogleTranslateIpCheck/github后面加个1s......
  • 【VSCode】VSCode常用设置
    1、中文插件安装     使用按下“Ctrl+Shift+P”组合键以显示“命令面板”,然后键入“display”以筛选并显示“ConfigureDisplayLanguage”命令。按“Enter”,然后会按区域设置显示安装的语言列表,并突出显示当前语言设置。选择另一个“语言”以切换UI语......
  • windows和vscode终端美化
    win商店下载powershell,保证版本在7以上.然后配置背景图,背景图透明度50.浏览器下载ohmypush,安装程序,重启powershelloh-my-poshfontinstall安装字体,选择Meslonotepad$PROFILE如果没有这个文件.先New-Item-Path$PROFILE-TypeFile-Force然后输入oh-my-pos......