SSH into your DUT and run “dlv” on it. If it doesn‘t work, delve likely isn’t supported for your DUT, and you can try two things:
emerge-${BOARD} dev-go/delve && cros deploy dut dev-go/delve
Instructions to install delve are here, but TLDR is:
$ git clone https://github.com/go-delve/delve $ cd delve $ go install github.com/go-delve/delve/cmd/dlv $ rm -rf ../delve
In your chroot, run tast run -attachdebugger=local:2345 <DUT ip> meta.LocalPass
Wait for it to say “Waiting for debugger on port 2345”.
Outside, the chroot, run dlv connect :2345
Once you see (dlv) prompt, type “c” (without quotes) and press enter.
Check that the tast command completed successfully
Note that people have had issues with vscode’s SSH extension with this. If this failed with vscode with the SSH extension open, then close vscode and try again.
If you haven't already, follow the instructions in the quickstart guide to get your gopath working
Open up the folder $CHROMEOS_SRC/src/platform/tast-tests
in vscode (or reload vscode if it’s already open)
If you don’t have a tasks.json, press control-shift-p, then select the option “tasks: configure task” -> “create tasks.json file from template”, select any template, then delete all of your tasks it created for you.
If you don't have a launch.json, click Run -> Add configuration -> select any configuration, then delete the configuration it created for you.
Replace tasks.json with the following (or if you already had useful tasks, merge the files). Make sure to swap out DUT_IP for your own DUT’s IP
{ // See https://go.microsoft.com/fwlink/?LinkId=733558 // for the documentation about the tasks.json format "version": "2.0.0", "tasks": [ { "label": "prep debugger", "type": "shell", "command": "cros_sdk -- /mnt/host/source/src/platform/tast-tests/tools/run_debugger.py --dut=DUT_IP --current-file=${file}", "isBackground": true, "problemMatcher": [ { "owner": "tast", "fileLocation": [ "relative", "${workspaceFolder}/src/platform" ], "pattern": { // 2021/01/20 11:53:25 ../platform/tast-tests/src/chromiumos/tast/local/bundlemain/main.go:274:3: unknown field 'BeforeDownload' in struct literal of type "chromiumos/tast/internal/bundle".LocalDelegate // ../platform/tast-tests/src/chromiumos/tast/common/perf/timeline_test.go:217:51: cannot use d1 (type *testTimelineDatasource) as type TimelineDatasource in array or slice literal: "regexp": "(..\/platform\/[^:]+):(\\d+):(\\d+):\\s+(.+)$", "file": 1, "line": 2, "column": 3, // "severity": 2, "message": 4 }, "background": { "activeOnStart": true, "beginsPattern": ".*", "endsPattern": ".*Waiting for debugger on port.*", } } ], } ] }
{ // 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": "Debug tast test", "type": "go", "request": "attach", "mode": "remote", "remotePath": "", "port": 2345, "host": "127.0.0.1", "apiVersion": 2, "preLaunchTask": "prep debugger" }, ] }
Open a test file
Add a breakpoint at the start of your test
Click on the debug button in vscode