簡體   English   中英

在 Visual Studio Code 的 C/C++ 擴展中啟動調試器后,如何運行命令?

[英]How do I run a command after launching the debugger in the C/C++ extension for Visual Studio Code?

我有一個嵌入式 C 項目,我在定制板或 devkit 上的 ARM Cortex M4 上運行,在 Mac 上使用 gcc。 我一直在使用 Visual Studio Code 作為嵌入式 C 工作的 IDE,現在我希望使用其中的調試器來控制 gdb。

調試時需要運行三個進程:

  1. gdb 服務器
  2. gdb 客戶端
  3. 一個 Segger RTT 可執行文件,它知道在目標內存中查找日志的位置並將其顯示在終端上。

我現在有一個可以處理 #1 和 #2 的 launch.json 文件設置,但我仍然需要設置 #3。

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "gdb launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceRoot}/app/pca10040/_build/app.out",
            "logging": {
                "exceptions": true,
                "moduleLoad": true,
                "programOutput": true,
                "engineLogging": true,
                "trace": true,
                "traceResponse": true
            },
            "args": [],
            "stopAtEntry": true,
            "cwd": "${workspaceRoot}/app/pca10040",
            "environment": [],
            "externalConsole": false,
            "osx": {
                "MIMode": "gdb",
                "debugServerPath": "/Applications/SEGGER/JLink/JLinkGDBServer",
                "debugServerArgs": "-device nRF52832_xxAA -if swd -speed 4000",
                "serverStarted": "Connected to target",
                "miDebuggerPath": "${env:HOME}/dev/gcc-arm-none-eabi-4_9-2015q3/bin/arm-none-eabi-gdb",
                "miDebuggerServerAddress": "localhost:2331",
                "args": [
                    "-x ${workspaceRoot}/app/pca10040/_build/.gdbinit"
                ]
            }
        }
    ]
}

#3 的可執行文件必須在#2 運行之后運行。 它不需要任何論據。 我希望它的輸出顯示在底部的窗格之一中(“輸出”或“調試控制台”,沒關系)。

文檔( https://github.com/Microsoft/vscode-cpptools/blob/master/launch.md )提到了一個launchCompleteCommand ,但這不是我需要的——它適用於 gdb。

我想我可以為此創建一個任務,但這是在我點擊“調試”之后手動運行的另一件事,我希望這能很快。

假設您的調試器已經在工作並且您將 Segger 庫添加到您的項目中,您必須將其添加到您的launch.json配置中:

            "rttConfig": {
            "enabled": true,
            "address": "auto",
            "decoders": [
                {
                    "label": "",
                    "port": 0,
                    "type": "console"
                }
            ]
        }

然后你應該能夠在 VS Code 的終端窗格中獲得 RTT 輸出。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM