Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VSCode 1.66.0 appears to have broken Native Debug #335

Closed
zfields opened this issue Apr 1, 2022 · 9 comments
Closed

VSCode 1.66.0 appears to have broken Native Debug #335

zfields opened this issue Apr 1, 2022 · 9 comments

Comments

@zfields
Copy link

zfields commented Apr 1, 2022

The VSCode team made multiple updates to debugging, and it appears one is incompatible with Native Debug.

Changes:

Experience: No errors are thrown on any of the VSCode windows, and the debugger appears to work momentarily, but it immediately detaches before hitting any breakpoints.

When I revert to VSCode 1.65.2, then everything works as expected.

@zfields
Copy link
Author

zfields commented Apr 1, 2022

I am using an ESP32 and the ESP-Prog. Here is a repository I followed to get setup.
https://github.com/makercrew/esp_prog_vscode_debug/

Specifically, here is the 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": "ESP-Prog Debug",
            "type": "gdb",
            "request": "launch",
            "target": "./build/esp_prog_vscode_debug.elf",
            "cwd": "${workspaceRoot}",
            "env": {
                "PATH": "${config:esp_toolchain_paths}:${env:PATH}"
            },
            "gdbpath": "xtensa-esp32-elf-gdb",
            "preLaunchTask": "Launch OpenOCD GDB Server",
            "autorun": [
                "target extended-remote :3333",
                "mon reset halt",
                "flushregs",
                "thb app_main",
                "c",
                "monitor [target current] configure -event gdb-detach { shutdown }",
            ],
        }
    ]
}

Here is the pre-launch task, from tasks.json

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Launch OpenOCD GDB Server",
            "type": "shell",
            "isBackground": true,
            "options": {
                "cwd": "${workspaceRoot}",
                "env": {
                    "PATH": "${config:esp_toolchain_paths}:${env:PATH}"
                }
            },
            "command": "openocd -f interface/ftdi/esp32_devkitj_v1.cfg -f target/esp32.cfg",
            "problemMatcher": {
                "pattern": {
                    "regexp": "(Error|Warn) ?: .*",
                    "file": 1,
                    "location": 2,
                    "message": 3
                },
                "background": {
                    "activeOnStart": true,
                    "beginsPattern": "Open On-Chip Debugger.*",
                    "endsPattern": "Info : Listening on port [0-9]{1,5} for gdb connections"
                }
            }
        },
        ...
    ]
}

@GitMensch
Copy link
Collaborator

please share a session log of the working and not-working environment doing the same after adding "printCalls": true,"showDevDebugOutput": true to your launch configuration, so we can see the difference.

@zfields
Copy link
Author

zfields commented Apr 4, 2022

I don't have the ability to debug the debugger at the moment. FWIW, I was able to switch over to the Microsoft debugger and get it to connect, although it's not working flawlessly either.

The most curious thing is, everything works perfectly when run directly from the command line.

@SKyletoft
Copy link

SKyletoft commented Apr 5, 2022

Doesn't work on Linux or Windows either (x64 for remote debugging on 32 bit arm) for me.

It used to throw an exception on some machines and then just continue on just fine, now it just never connects to the remote target.

		{
			"linux": {
				"gdbpath": "arm-none-eabi-gdb" // Relies on $PATH
			},
			"windows": {
				"gdbpath": "correct/but/weird/path/to/arm-none-eabi-gdb.exe"
			},
			"osx": {
				"gdbpath": "correct/but/weird/path/to/arm-none-eabi-gdb"
			},
			"name": "1-2",
			"type": "gdb",
			"request": "attach",
			"executable": "1-2/debug/MOP",
			"target": ":1234",
			"remote": true,
			"cwd": "${workspaceRoot}",
			"valuesFormatting": "parseText",
			"autorun": [
				"file 1-2/debug/MOP",
				"target extended-remote :1234",
				"load",
				"monitor restart",
				"b main"
			],
			"preLaunchTask": "build 1-2"
		}

@SKyletoft
Copy link

SKyletoft commented Apr 5, 2022

I added "printCalls": true,"showDevDebugOutput": true and got this output on Linux:
(Also, sorry for not making it collapsable, I can't figure out how)

1-gdb-set target-async on
2-environment-directory "[/home/u3836/Documents/mop_testing]()"
3-target-select remote :1234
GDB -> App: {"outOfBandRecord":[{"isStream":false,"type":"notify","asyncClass":"thread-group-added","output":[["id","i1"]]}]}
GDB -> App: {"outOfBandRecord":[{"isStream":false,"type":"notify","asyncClass":"cmd-param-changed","output":[["param","auto-load safe-path"],["value",""]]}]}
GDB -> App: {"outOfBandRecord":[{"isStream":true,"type":"console","content":"Reading symbols from [/home/u3836/Documents/mop_testing/1-2/debug/MOP...]()\n"}]}
Reading symbols from [/home/u3836/Documents/mop_testing/1-2/debug/MOP...]()
GDB -> App: {"token":1,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[]}}
GDB -> App: {"token":2,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["source-path","[/home/u3836/Documents/mop_testing]():$cdir:$cwd"]]}}
GDB -> App: {"outOfBandRecord":[{"isStream":false,"type":"notify","asyncClass":"thread-group-started","output":[["id","i1"],["pid","42000"]]}]}
GDB -> App: {"outOfBandRecord":[{"isStream":false,"type":"notify","asyncClass":"thread-created","output":[["id","1"],["group-id","i1"]]}]}
GDB -> App: {"outOfBandRecord":[{"isStream":true,"type":"console","content":"0x20000022 in print_char (c=13 '\\r') at debug.c:25\n"}]}
0x20000022 in print_char (c=13 '\r') at debug.c:25
GDB -> App: {"outOfBandRecord":[{"isStream":true,"type":"console","content":"25\t\twhile ((USART1->sr & 0x80) == 0)\n"}]}
25		while ((USART1->sr & 0x80) == 0)
GDB -> App: {"outOfBandRecord":[{"isStream":false,"type":"exec","asyncClass":"stopped","output":[["frame",[["addr","0x20000022"],["func","print_char"],["args",[[["name","c"],["value","13 '\\r'"]]]],["file","debug.c"],["fullname","[/home/u3836/Documents/mop_testing/1-2/debug.c]()"],["line","25"],["arch","armv6-m"]]],["thread-id","1"],["stopped-threads","all"]]}]}
Not implemented stop reason (assuming exception): undefined
4-thread-info
GDB -> App: {"token":3,"outOfBandRecord":[],"resultRecords":{"resultClass":"connected","results":[]}}
5-interpreter-exec console "target extended-remote :1234"
6-interpreter-exec console "load"
7-interpreter-exec console "monitor restart"
8-interpreter-exec console "b main"

GDB -> App: {"token":4,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["threads",[[["id","1"],["target-id","Thread <main>"],["frame",[["level","0"],["addr","0x20000022"],["func","print_char"],["args",[[["name","c"],["value","13 '\\r'"]]]],["file","debug.c"],["fullname","[/home/u3836/Documents/mop_testing/1-2/debug.c]()"],["line","25"],["arch","armv6-m"]]],["state","stopped"]]]],["current-thread-id","1"]]}}
GDB -> App: {"outOfBandRecord":[{"isStream":true,"type":"console","content":"A program is being debugged already.  Kill it? (y or n) [answered Y; input not from terminal]\n"}]}
A program is being debugged already.  Kill it? (y or n) [answered Y; input not from terminal]
GDB -> App: {"outOfBandRecord":[{"isStream":false,"type":"notify","asyncClass":"thread-exited","output":[["id","1"],["group-id","i1"]]}]}
GDB -> App: {"outOfBandRecord":[{"isStream":false,"type":"notify","asyncClass":"thread-group-exited","output":[["id","i1"]]}]}
GDB -> App: {"outOfBandRecord":[{"isStream":true,"type":"console","content":"Remote debugging using :1234\n"}]}
Remote debugging using :1234
GDB -> App: {"outOfBandRecord":[{"isStream":false,"type":"notify","asyncClass":"thread-group-started","output":[["id","i1"],["pid","42000"]]}]}
GDB -> App: {"outOfBandRecord":[{"isStream":false,"type":"notify","asyncClass":"thread-created","output":[["id","1"],["group-id","i1"]]}]}
GDB -> App: {"outOfBandRecord":[{"isStream":true,"type":"console","content":"0xfffffffe in ?? ()\n"}]}
0xfffffffe in ?? ()
GDB -> App: {"outOfBandRecord":[{"isStream":false,"type":"exec","asyncClass":"stopped","output":[["frame",[["addr","0xfffffffe"],["func","??"],["args",[]],["arch","armv6-m"]]],["thread-id","1"],["stopped-threads","all"]]}]}
Not implemented stop reason (assuming exception): undefined
GDB -> App: {"token":5,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[]}}
GDB -> App: {"outOfBandRecord":[{"isStream":true,"type":"console","content":"Loading section .text, size 0xec lma 0x20000000\n"}]}
Loading section .text, size 0xec lma 0x20000000
2
GDB -> App: {"token":6,"outOfBandRecord":[{"isStream":false,"type":"status","asyncClass":"download","output":[]}]}
GDB -> App: {"outOfBandRecord":[{"isStream":true,"type":"console","content":"Start address 0x20000000, load size 236\n"}]}
Start address 0x20000000, load size 236
GDB -> App: {"outOfBandRecord":[{"isStream":true,"type":"console","content":"Transfer rate: 1888 bits in <1 sec, 236 bytes[/write.]()\n"}]}
Transfer rate: 1888 bits in <1 sec, 236 bytes[/write.]()
GDB -> App: {"token":6,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[]}}
GDB -> App: {"outOfBandRecord":[{"isStream":true,"type":"target","content":"User restart target\n"}]}
User restart target
9-exec-continue
GDB -> App: {"token":7,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[]}}
10-stack-list-frames --thread 1 0 20
GDB -> App: {"outOfBandRecord":[{"isStream":true,"type":"console","content":"Breakpoint 1 at 0x20000082: file main.c, line 7.\n"}]}
Breakpoint 1 at 0x20000082: file main.c, line 7.
GDB -> App: {"outOfBandRecord":[{"isStream":false,"type":"notify","asyncClass":"breakpoint-created","output":[["bkpt",[["number","1"],["type","breakpoint"],["disp","keep"],["enabled","y"],["addr","0x20000082"],["func","main"],["file","main.c"],["fullname","[/home/u3836/Documents/mop_testing/1-2/main.c]()"],["line","7"],["thread-groups",["i1"]],["times","0"],["original-location","main"]]]]}]}
GDB -> App: {"token":8,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[]}}
GDB -> App: {"token":9,"outOfBandRecord":[],"resultRecords":{"resultClass":"running","results":[]}}
GDB -> App: {"outOfBandRecord":[{"isStream":false,"type":"exec","asyncClass":"running","output":[["thread-id","all"]]}]}
GDB -> App: {"token":10,"outOfBandRecord":[],"resultRecords":{"resultClass":"error","results":[["msg","Selected thread is running."]]}}
11-thread-info
GDB -> App: {"token":11,"outOfBandRecord":[],"resultRecords":{"resultClass":"error","results":[["msg","Cannot execute this command while the target is running.\nUse the \"interrupt\" command to stop the target\nand then try again."]]}}

@GitMensch
Copy link
Collaborator

That is a good start - if you can now provide the same with an older vscode version where it works we'd have everything needed to check for the actual difference.

@SKyletoft
Copy link

Here's a log from 1.65.2. Starting the program and then stepping a couple of times before killing it

1-gdb-set target-async on
2-environment-directory "/home/u3836/Documents/mop_testing"
3-target-select remote :1234
GDB -> App: {"outOfBandRecord":[{"isStream":false,"type":"notify","asyncClass":"thread-group-added","output":[["id","i1"]]}]}
GDB -> App: {"outOfBandRecord":[{"isStream":false,"type":"notify","asyncClass":"cmd-param-changed","output":[["param","auto-load safe-path"],["value","/"]]}]}
GDB -> App: {"outOfBandRecord":[{"isStream":true,"type":"console","content":"Reading symbols from /home/u3836/Documents/mop_testing/1-2/debug/MOP...\n"}]}
Reading symbols from /home/u3836/Documents/mop_testing/1-2/debug/MOP...
GDB -> App: {"token":1,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[]}}
GDB -> App: {"token":2,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["source-path","/home/u3836/Documents/mop_testing:$cdir:$cwd"]]}}
GDB -> App: {"outOfBandRecord":[{"isStream":false,"type":"notify","asyncClass":"thread-group-started","output":[["id","i1"],["pid","42000"]]}]}
GDB -> App: {"outOfBandRecord":[{"isStream":false,"type":"notify","asyncClass":"thread-created","output":[["id","1"],["group-id","i1"]]}]}
GDB -> App: {"outOfBandRecord":[{"isStream":true,"type":"console","content":"0xfffffffe in ?? ()\n"}]}
0xfffffffe in ?? ()
GDB -> App: {"outOfBandRecord":[{"isStream":false,"type":"exec","asyncClass":"stopped","output":[["frame",[["addr","0xfffffffe"],["func","??"],["args",[]],["arch","armv6-m"]]],["thread-id","1"],["stopped-threads","all"]]}]}
Not implemented stop reason (assuming exception): undefined
GDB -> App: {"token":3,"outOfBandRecord":[],"resultRecords":{"resultClass":"connected","results":[]}}
4-interpreter-exec console "target extended-remote :1234"
5-interpreter-exec console "load"
6-interpreter-exec console "monitor restart"
7-interpreter-exec console "b main"
GDB -> App: {"outOfBandRecord":[{"isStream":true,"type":"console","content":"A program is being debugged already.  Kill it? (y or n) [answered Y; input not from terminal]\n"}]}
A program is being debugged already.  Kill it? (y or n) [answered Y; input not from terminal]
GDB -> App: {"outOfBandRecord":[{"isStream":false,"type":"notify","asyncClass":"thread-exited","output":[["id","1"],["group-id","i1"]]}]}
GDB -> App: {"outOfBandRecord":[{"isStream":false,"type":"notify","asyncClass":"thread-group-exited","output":[["id","i1"]]}]}
GDB -> App: {"outOfBandRecord":[{"isStream":true,"type":"console","content":"Remote debugging using :1234\n"}]}
Remote debugging using :1234
8-thread-info
9-exec-continue
GDB -> App: {"outOfBandRecord":[{"isStream":false,"type":"notify","asyncClass":"thread-group-started","output":[["id","i1"],["pid","42000"]]}]}
GDB -> App: {"outOfBandRecord":[{"isStream":false,"type":"notify","asyncClass":"thread-created","output":[["id","1"],["group-id","i1"]]}]}
GDB -> App: {"outOfBandRecord":[{"isStream":true,"type":"console","content":"0xfffffffe in ?? ()\n"}]}
0xfffffffe in ?? ()
GDB -> App: {"outOfBandRecord":[{"isStream":false,"type":"exec","asyncClass":"stopped","output":[["frame",[["addr","0xfffffffe"],["func","??"],["args",[]],["arch","armv6-m"]]],["thread-id","1"],["stopped-threads","all"]]}]}
Not implemented stop reason (assuming exception): undefined
GDB -> App: {"token":4,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[]}}
GDB -> App: {"outOfBandRecord":[{"isStream":true,"type":"console","content":"Loading section .text, size 0xec lma 0x20000000\n"}]}
Loading section .text, size 0xec lma 0x20000000
2
GDB -> App: {"token":5,"outOfBandRecord":[{"isStream":false,"type":"status","asyncClass":"download","output":[]}]}
GDB -> App: {"outOfBandRecord":[{"isStream":true,"type":"console","content":"Start address 0x20000000, load size 236\n"}]}
Start address 0x20000000, load size 236
GDB -> App: {"outOfBandRecord":[{"isStream":true,"type":"console","content":"Transfer rate: 1888 bits in <1 sec, 236 bytes/write.\n"}]}
Transfer rate: 1888 bits in <1 sec, 236 bytes/write.
GDB -> App: {"token":5,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[]}}
GDB -> App: {"outOfBandRecord":[{"isStream":true,"type":"target","content":"User restart target\n"}]}
User restart target
GDB -> App: {"token":6,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[]}}
10-thread-info
11-thread-info
GDB -> App: {"outOfBandRecord":[{"isStream":true,"type":"console","content":"Breakpoint 1 at 0x20000082: file main.c, line 7.\n"}]}
Breakpoint 1 at 0x20000082: file main.c, line 7.
GDB -> App: {"outOfBandRecord":[{"isStream":false,"type":"notify","asyncClass":"breakpoint-created","output":[["bkpt",[["number","1"],["type","breakpoint"],["disp","keep"],["enabled","y"],["addr","0x20000082"],["func","main"],["file","main.c"],["fullname","/home/u3836/Documents/mop_testing/1-2/main.c"],["line","7"],["thread-groups",["i1"]],["times","0"],["original-location","main"]]]]}]}
GDB -> App: {"token":7,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[]}}
GDB -> App: {"token":8,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["threads",[[["id","1"],["target-id","Thread <main>"],["frame",[["level","0"],["addr","0x20000000"],["func","startup"],["args",[]],["file","startup.c"],["fullname","/home/u3836/Documents/mop_testing/1-2/startup.c"],["line","7"],["arch","armv6-m"]]],["state","stopped"]]]],["current-thread-id","1"]]}}
GDB -> App: {"token":9,"outOfBandRecord":[],"resultRecords":{"resultClass":"running","results":[]}}
GDB -> App: {"outOfBandRecord":[{"isStream":false,"type":"exec","asyncClass":"running","output":[["thread-id","all"]]}]}
GDB -> App: {"token":10,"outOfBandRecord":[],"resultRecords":{"resultClass":"error","results":[["msg","Cannot execute this command while the target is running.\nUse the \"interrupt\" command to stop the target\nand then try again."]]}}
GDB -> App: {"token":11,"outOfBandRecord":[],"resultRecords":{"resultClass":"error","results":[["msg","Cannot execute this command while the target is running.\nUse the \"interrupt\" command to stop the target\nand then try again."]]}}
12-stack-list-frames --thread 1 0 20
13-thread-info
GDB -> App: {"token":12,"outOfBandRecord":[],"resultRecords":{"resultClass":"error","results":[["msg","Selected thread is running."]]}}
GDB -> App: {"token":13,"outOfBandRecord":[],"resultRecords":{"resultClass":"error","results":[["msg","Cannot execute this command while the target is running.\nUse the \"interrupt\" command to stop the target\nand then try again."]]}}
GDB -> App: {"outOfBandRecord":[{"isStream":false,"type":"notify","asyncClass":"breakpoint-modified","output":[["bkpt",[["number","1"],["type","breakpoint"],["disp","keep"],["enabled","y"],["addr","0x20000082"],["func","main"],["file","main.c"],["fullname","/home/u3836/Documents/mop_testing/1-2/main.c"],["line","7"],["thread-groups",["i1"]],["times","1"],["original-location","main"]]]]}]}
GDB -> App: {"outOfBandRecord":[{"isStream":true,"type":"console","content":"\n"}]}

GDB -> App: {"outOfBandRecord":[{"isStream":true,"type":"console","content":"Breakpoint 1, main () at main.c:7\n"}]}
Breakpoint 1, main () at main.c:7
GDB -> App: {"outOfBandRecord":[{"isStream":true,"type":"console","content":"7\t\tlong long x = 15;\n"}]}
7		long long x = 15;
GDB -> App: {"outOfBandRecord":[{"isStream":false,"type":"exec","asyncClass":"stopped","output":[["reason","breakpoint-hit"],["disp","keep"],["bkptno","1"],["frame",[["addr","0x20000082"],["func","main"],["args",[]],["file","main.c"],["fullname","/home/u3836/Documents/mop_testing/1-2/main.c"],["line","7"],["arch","armv6-m"]]],["thread-id","1"],["stopped-threads","all"]]}]}
14-thread-info
GDB -> App: {"token":14,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["threads",[[["id","1"],["target-id","Thread <main>"],["frame",[["level","0"],["addr","0x20000082"],["func","main"],["args",[]],["file","main.c"],["fullname","/home/u3836/Documents/mop_testing/1-2/main.c"],["line","7"],["arch","armv6-m"]]],["state","stopped"]]]],["current-thread-id","1"]]}}
15-thread-info
GDB -> App: {"token":15,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["threads",[[["id","1"],["target-id","Thread <main>"],["frame",[["level","0"],["addr","0x20000082"],["func","main"],["args",[]],["file","main.c"],["fullname","/home/u3836/Documents/mop_testing/1-2/main.c"],["line","7"],["arch","armv6-m"]]],["state","stopped"]]]],["current-thread-id","1"]]}}
16-stack-list-frames --thread 1 0 20
GDB -> App: {"token":16,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["stack",[["frame",[["level","0"],["addr","0x20000082"],["func","main"],["file","main.c"],["fullname","/home/u3836/Documents/mop_testing/1-2/main.c"],["line","7"],["arch","armv6-m"]]]]]]}}
17-stack-list-variables --thread 1 --frame 0 --simple-values
GDB -> App: {"token":17,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["variables",[[["name","x"],["type","long long"],["value","15"]],[["name","y"],["type","long long"],["value","0"]],[["name","z"],["type","long long"],["value","0"]]]]]}}
18-exec-next
GDB -> App: {"token":18,"outOfBandRecord":[],"resultRecords":{"resultClass":"running","results":[]}}
GDB -> App: {"outOfBandRecord":[{"isStream":false,"type":"exec","asyncClass":"running","output":[["thread-id","all"]]}]}
GDB -> App: {"outOfBandRecord":[{"isStream":false,"type":"exec","asyncClass":"stopped","output":[["reason","end-stepping-range"],["frame",[["addr","0x2000008a"],["func","main"],["args",[]],["file","main.c"],["fullname","/home/u3836/Documents/mop_testing/1-2/main.c"],["line","8"],["arch","armv6-m"]]],["thread-id","1"],["stopped-threads","all"]]}]}
19-thread-info
GDB -> App: {"token":19,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["threads",[[["id","1"],["target-id","Thread <main>"],["frame",[["level","0"],["addr","0x2000008a"],["func","main"],["args",[]],["file","main.c"],["fullname","/home/u3836/Documents/mop_testing/1-2/main.c"],["line","8"],["arch","armv6-m"]]],["state","stopped"]]]],["current-thread-id","1"]]}}
20-stack-list-frames --thread 1 0 20
GDB -> App: {"token":20,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["stack",[["frame",[["level","0"],["addr","0x2000008a"],["func","main"],["file","main.c"],["fullname","/home/u3836/Documents/mop_testing/1-2/main.c"],["line","8"],["arch","armv6-m"]]]]]]}}
21-exec-next
GDB -> App: {"token":21,"outOfBandRecord":[],"resultRecords":{"resultClass":"running","results":[]}}

GDB -> App: {"outOfBandRecord":[{"isStream":false,"type":"exec","asyncClass":"running","output":[["thread-id","all"]]}]}
22-stack-list-variables --thread 1 --frame 0 --simple-values
GDB -> App: {"outOfBandRecord":[{"isStream":false,"type":"exec","asyncClass":"stopped","output":[["reason","end-stepping-range"],["frame",[["addr","0x20000092"],["func","main"],["args",[]],["file","main.c"],["fullname","/home/u3836/Documents/mop_testing/1-2/main.c"],["line","9"],["arch","armv6-m"]]],["thread-id","1"],["stopped-threads","all"]]}]}
GDB -> App: {"token":22,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["variables",[[["name","x"],["type","long long"],["value","15"]],[["name","y"],["type","long long"],["value","13"]],[["name","z"],["type","long long"],["value","0"]]]]]}}
23-thread-info
GDB -> App: {"token":23,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["threads",[[["id","1"],["target-id","Thread <main>"],["frame",[["level","0"],["addr","0x20000092"],["func","main"],["args",[]],["file","main.c"],["fullname","/home/u3836/Documents/mop_testing/1-2/main.c"],["line","9"],["arch","armv6-m"]]],["state","stopped"]]]],["current-thread-id","1"]]}}
24-stack-list-frames --thread 1 0 20
GDB -> App: {"token":24,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["stack",[["frame",[["level","0"],["addr","0x20000092"],["func","main"],["file","main.c"],["fullname","/home/u3836/Documents/mop_testing/1-2/main.c"],["line","9"],["arch","armv6-m"]]]]]]}}
25-exec-next
GDB -> App: {"token":25,"outOfBandRecord":[],"resultRecords":{"resultClass":"running","results":[]}}
GDB -> App: {"outOfBandRecord":[{"isStream":false,"type":"exec","asyncClass":"running","output":[["thread-id","all"]]}]}
GDB -> App: {"outOfBandRecord":[{"isStream":false,"type":"exec","asyncClass":"stopped","output":[["reason","end-stepping-range"],["frame",[["addr","0x200000a2"],["func","main"],["args",[]],["file","main.c"],["fullname","/home/u3836/Documents/mop_testing/1-2/main.c"],["line","10"],["arch","armv6-m"]]],["thread-id","1"],["stopped-threads","all"]]}]}
26-thread-info
GDB -> App: {"token":26,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["threads",[[["id","1"],["target-id","Thread <main>"],["frame",[["level","0"],["addr","0x200000a2"],["func","main"],["args",[]],["file","main.c"],["fullname","/home/u3836/Documents/mop_testing/1-2/main.c"],["line","10"],["arch","armv6-m"]]],["state","stopped"]]]],["current-thread-id","1"]]}}
27-stack-list-frames --thread 1 0 20
GDB -> App: {"token":27,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["stack",[["frame",[["level","0"],["addr","0x200000a2"],["func","main"],["file","main.c"],["fullname","/home/u3836/Documents/mop_testing/1-2/main.c"],["line","10"],["arch","armv6-m"]]]]]]}}
28-stack-list-variables --thread 1 --frame 0 --simple-values
GDB -> App: {"token":28,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["variables",[[["name","x"],["type","long long"],["value","15"]],[["name","y"],["type","long long"],["value","13"]],[["name","z"],["type","long long"],["value","28"]]]]]}}
29-stack-list-variables --thread 1 --frame 0 --simple-values
GDB -> App: {"token":29,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["variables",[[["name","x"],["type","long long"],["value","15"]],[["name","y"],["type","long long"],["value","13"]],[["name","z"],["type","long long"],["value","28"]]]]]}}
30-exec-next
GDB -> App: {"token":30,"outOfBandRecord":[],"resultRecords":{"resultClass":"running","results":[]}}
GDB -> App: {"outOfBandRecord":[{"isStream":false,"type":"exec","asyncClass":"running","output":[["thread-id","all"]]}]}
GDB -> App: {"outOfBandRecord":[{"isStream":false,"type":"exec","asyncClass":"stopped","output":[["reason","end-stepping-range"],["frame",[["addr","0x200000be"],["func","main"],["args",[]],["file","main.c"],["fullname","/home/u3836/Documents/mop_testing/1-2/main.c"],["line","13"],["arch","armv6-m"]]],["thread-id","1"],["stopped-threads","all"]]}]}
31-thread-info
GDB -> App: {"token":31,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["threads",[[["id","1"],["target-id","Thread <main>"],["frame",[["level","0"],["addr","0x200000be"],["func","main"],["args",[]],["file","main.c"],["fullname","/home/u3836/Documents/mop_testing/1-2/main.c"],["line","13"],["arch","armv6-m"]]],["state","stopped"]]]],["current-thread-id","1"]]}}
32-stack-list-frames --thread 1 0 20
GDB -> App: {"token":32,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["stack",[["frame",[["level","0"],["addr","0x200000be"],["func","main"],["file","main.c"],["fullname","/home/u3836/Documents/mop_testing/1-2/main.c"],["line","13"],["arch","armv6-m"]]]]]]}}
33-stack-list-variables --thread 1 --frame 0 --simple-values
GDB -> App: {"token":33,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["variables",[[["name","x"],["type","long long"],["value","15"]],[["name","y"],["type","long long"],["value","13"]],[["name","z"],["type","long long"],["value","28"]]]]]}}
34-exec-next
GDB -> App: {"token":34,"outOfBandRecord":[],"resultRecords":{"resultClass":"running","results":[]}}
GDB -> App: {"outOfBandRecord":[{"isStream":false,"type":"exec","asyncClass":"running","output":[["thread-id","all"]]}]}
GDB -> App: {"outOfBandRecord":[{"isStream":false,"type":"exec","asyncClass":"stopped","output":[["reason","end-stepping-range"],["frame",[["addr","0x200000c6"],["func","main"],["args",[]],["file","main.c"],["fullname","/home/u3836/Documents/mop_testing/1-2/main.c"],["line","16"],["arch","armv6-m"]]],["thread-id","1"],["stopped-threads","all"]]}]}
35-thread-info
GDB -> App: {"token":35,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["threads",[[["id","1"],["target-id","Thread <main>"],["frame",[["level","0"],["addr","0x200000c6"],["func","main"],["args",[]],["file","main.c"],["fullname","/home/u3836/Documents/mop_testing/1-2/main.c"],["line","16"],["arch","armv6-m"]]],["state","stopped"]]]],["current-thread-id","1"]]}}
36-stack-list-frames --thread 1 0 20
GDB -> App: {"token":36,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["stack",[["frame",[["level","0"],["addr","0x200000c6"],["func","main"],["file","main.c"],["fullname","/home/u3836/Documents/mop_testing/1-2/main.c"],["line","16"],["arch","armv6-m"]]]]]]}}
37-stack-list-variables --thread 1 --frame 0 --simple-values
GDB -> App: {"token":37,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["variables",[[["name","x"],["type","long long"],["value","15"]],[["name","y"],["type","long long"],["value","1"]],[["name","z"],["type","long long"],["value","28"]]]]]}}
38-exec-next
GDB -> App: {"token":38,"outOfBandRecord":[],"resultRecords":{"resultClass":"running","results":[]}}
GDB -> App: {"outOfBandRecord":[{"isStream":false,"type":"exec","asyncClass":"running","output":[["thread-id","all"]]}]}
-gdb-exit
GDB -> App: {"outOfBandRecord":[],"resultRecords":{"resultClass":"exit","results":[]}}
GDB -> App: {"outOfBandRecord":[{"isStream":true,"type":"log","content":"Cannot execute this command while the target is running.\n"}]}
Cannot execute this command while the target is running.
GDB -> App: {"outOfBandRecord":[{"isStream":true,"type":"log","content":"Use the \"interrupt\" command to stop the target\n"}]}
Use the "interrupt" command to stop the target
GDB -> App: {"outOfBandRecord":[{"isStream":true,"type":"log","content":"and then try again.\n"}]}
and then try again.

@GitMensch GitMensch changed the title VSCode 1.66.0 appears to have broken Native Debug (at least for darwin arm64) VSCode 1.66.0 appears to have broken Native Debug Apr 7, 2022
@brownts
Copy link
Collaborator

brownts commented Apr 13, 2022

I took a look at this today. I wasn't able to replicate this with the latest in the repository, so I ran against the last released version (i.e., v0.25.1) and was able to reproduce the symptoms. I was pretty sure this was being caused by an internal exception within the debug adapter. Therefore, I pulled the commit for this version from the repository and ran the same scenario. The scenario I used was just an attach using a remote gdbserver. The issues identified above showed both a launch which ultimately used an extended remote, and also an attach to a remote server. I constructed a simple attach to a remote gdbserver, so that I could test this without special hardware. With this setup, I was able to run the v0.25.1 version of the debug adapter within the node debugger and was able to pin-point the source of the issue.

Screenshot_code-debug_2022-04-12_1

Screenshot_code-debug_2022-04-12_2

Investigation

So this appears to be an unhandled exception when the thread-info command can't complete because the debugger is actively running. I'm not sure why the current version of VSCode behaves differently than the previous version (i.e., why the debugger is able to continue in one version but not the other), but for some reason they do. Anyway, this is an issue in the debug adapter and was fixed in #282 which has not yet been rolled into a released version. This explains why the problem does not manifest using the latest in the repository, but does show up with v0.25.1.

Workaround / Confirmation

The fix in #282 should be in the next released version of the debug adapter, but for now you should be able to work around and confirm the issue by patching the installed version to apply the changes as performed in #282. The following shows the diff that you can apply to the installed version of the extension, which should be located at $HOME/.vscode/extensions/webfreak.debug-0.25.1/out/src/mibase.js:

    threadsRequest(response) {
        if (!this.miDebugger) {
            this.sendResponse(response);
            return;
        }
        this.miDebugger.getThreads().then(threads => {
            response.body = {
                threads: []
            };
            for (const thread of threads) {
                let threadName = thread.name || thread.targetId || "<unnamed>";
                response.body.threads.push(new vscode_debugadapter_1.Thread(thread.id, thread.id + ":" + threadName));
            }
            this.sendResponse(response);
+	}).catch(error => {
+		this.sendErrorResponse(response, 17, `Could not get threads: ${error}`);
        });
    }

@GitMensch
Copy link
Collaborator

GitMensch commented Apr 13, 2022

Thanks for this thorough check and explanation!

So "luckily" we can close this as "already solved", @brownts if I don't do it today (if time permits I'll tackle #332 today) please trigger a release by creating the appropriate version tag (after checking / updating version number in package.json and the ChangeLog).

As you were able to debug the debugger, it seems you could help with #176.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants