eclipse-cdt-cloud / cdt-gdb-vscode

CDT GDB Visual Studio Code Extension
Eclipse Public License 2.0
21 stars 24 forks source link

v0.0.106: Can't launch debugger #111

Closed XingMicrochip closed 1 year ago

XingMicrochip commented 1 year ago

Download source: https://open-vsx.org/api/eclipse-cdt/cdt-gdb-vscode/0.0.106/file/eclipse-cdt.cdt-gdb-vscode-0.0.106.vsix. Issue: After having a valid launch.json file and clicking "Start Debugging", something appears under "Threads" but quickly disappears. The debug session doesn't start. image I don't think this was introduced by the change in v0.0.106 - MI parser fix. The last working version we used in our IDE was v0.0.103. So I think the issue might be introduced by the packaging change or some change between v0.0.103 and v0.0.106.

jonahgraham commented 1 year ago

Can you start with verbose to launch.json and see if anything shows up in the Debugger Console?

      "verbose": true,
jonahgraham commented 1 year ago

@XingMicrochip do you want to do a call/screen share and maybe we can debug this quicker? If so, send me an email and we can sort that out (jonah at kichwacoders.com)

XingMicrochip commented 1 year ago

@XingMicrochip do you want to do a call/screen share and maybe we can debug this quicker? If so, send me an email and we can sort that out (jonah at kichwacoders.com)

Sounds good. I sent you an email.

jonahgraham commented 1 year ago

I think I found the issue - there is a problem with the @serialport module which only exists in the target adapter, not the local adapter. So type = gdb works, but type = gdbtarget fails.

The whole adapter fails to start, here is the problem:

jonah@ditto /scratch/debug/git/cdt-gdb-vscode (main) ()
[1995] 15:16:33 $ node dist/debugAdapter.js --server=4711
waiting for debug protocol on port 4711
^C

jonah@ditto /scratch/debug/git/cdt-gdb-vscode (main) ()
[1996] 15:16:37 $ node dist/debugTargetAdapter.js --server=4711
/scratch/debug/git/cdt-gdb-vscode/dist/debugTargetAdapter.js:6563
      throw new Error("No native build was found for " + target + "\n    loaded from: " + dir + "\n");
      ^

Error: No native build was found for platform=linux arch=x64 runtime=node abi=93 uv=1 libc=glibc node=16.17.0
    loaded from: /scratch/debug/git/cdt-gdb-vscode

    at Function.load.resolve.load.path (/scratch/debug/git/cdt-gdb-vscode/dist/debugTargetAdapter.js:6563:13)
    at load (/scratch/debug/git/cdt-gdb-vscode/dist/debugTargetAdapter.js:6526:34)
    at node_modules/@serialport/bindings-cpp/dist/load-bindings.js (/scratch/debug/git/cdt-gdb-vscode/dist/debugTargetAdapter.js:6722:48)
    at __require (/scratch/debug/git/cdt-gdb-vscode/dist/debugTargetAdapter.js:5:50)
    at node_modules/@serialport/bindings-cpp/dist/darwin.js (/scratch/debug/git/cdt-gdb-vscode/dist/debugTargetAdapter.js:7011:27)
    at __require (/scratch/debug/git/cdt-gdb-vscode/dist/debugTargetAdapter.js:5:50)
    at node_modules/@serialport/bindings-cpp/dist/index.js (/scratch/debug/git/cdt-gdb-vscode/dist/debugTargetAdapter.js:7699:20)
    at __require (/scratch/debug/git/cdt-gdb-vscode/dist/debugTargetAdapter.js:5:50)
    at node_modules/serialport/dist/serialport.js (/scratch/debug/git/cdt-gdb-vscode/dist/debugTargetAdapter.js:7732:26)
    at __require (/scratch/debug/git/cdt-gdb-vscode/dist/debugTargetAdapter.js:5:50)

as you can see the normal adapter starts fine, but the target one fails.

jonahgraham commented 1 year ago

It looks like the serialport comes with the natives pre-built, but we aren't including that in the dist:

$ find node_modules/ -name \*.node
node_modules/@serialport/bindings-cpp/prebuilds/win32-ia32/node.napi.node
node_modules/@serialport/bindings-cpp/prebuilds/android-arm/node.napi.armv7.node
node_modules/@serialport/bindings-cpp/prebuilds/linux-arm64/node.napi.armv8.node
node_modules/@serialport/bindings-cpp/prebuilds/linux-arm/node.napi.armv6.node
node_modules/@serialport/bindings-cpp/prebuilds/linux-arm/node.napi.armv7.node
node_modules/@serialport/bindings-cpp/prebuilds/android-arm64/node.napi.armv8.node
node_modules/@serialport/bindings-cpp/prebuilds/win32-x64/node.napi.node
node_modules/@serialport/bindings-cpp/prebuilds/linux-x64/node.napi.musl.node
node_modules/@serialport/bindings-cpp/prebuilds/linux-x64/node.napi.glibc.node
node_modules/@serialport/bindings-cpp/prebuilds/darwin-x64+arm64/node.napi.node
jonahgraham commented 1 year ago

@colin-grant-work can advise on this area? Since we released the repackaged extension it hasn't worked for target debugging and I didn't realize because I was testing local debugging in my smoke tests.

colin-grant-work commented 1 year ago

Hm... if we're importing it, it should have been caught, but I'll take a look to see what's necessary.

colin-grant-work commented 1 year ago

It looks like there a number of dynamic require statements, which make bundling that difficult. I'll experiment with how much we need to include to get at least the tests in the adapter working, and make a PR shortly.

jonahgraham commented 1 year ago

Once I merge https://github.com/eclipse-cdt-cloud/cdt-gdb-vscode/pull/113 then v0.0.107 will be good to go and @XingMicrochip this should resolve the issue fully.

XingMicrochip commented 1 year ago

I tested v0.0.107 fixes this issue. Thanks for everyone's help!

jonahgraham commented 1 year ago

Thank you everyone for fixing this.

Thank you @XingMicrochip for confirming the fix works.