xmake-io / xmake-vscode

🍩 A XMake integration in Visual Studio Code
https://xmake.io
Apache License 2.0
229 stars 54 forks source link

Debug doesn't work from launch.json, but works from button on the panel #270

Closed yh-sb closed 1 month ago

yh-sb commented 1 month ago

Xmake Version

2.9.3

Operating System Version and Architecture

Windows 11 23H2 22631.3880

Describe Bug

Debug doesn't work from launch.json, but works from button on the panel. This reproduced with MinGW only. With MSVC it works fine in both ways.

See the .gif where I:

  1. Started debug with xmake using launch.json, but it failed
  2. Then I started debug with xmake via button on the panel. In this case, debug started successfully

xmake-mingw-debug-issue

NOTE: I am also able to start debug via cpptools vscode extension. So there are no problem with .exe which I want to debug. The problem here is handling xmake debug config in launch.json.

Expected Behavior

Debug session with xmake configuration from launch.json starts fine.

Project Configuration

Basic xmake C++ project. Can be even without Qt. xmake f -p mingw -m debug xmake

launch.json:

{
    "version": "0.2.0",
    "configurations":
    [
        {
            "name": "xmake",
            "type": "xmake",
            "request": "launch",
            "target": "qt-app"
        }
    ]
}

Additional Information and Error Logs

DEBUG CONSOLE:

=thread-group-added,id="i1"
GNU gdb (GDB for MinGW-W64 x86_64, built by Brecht Sanders, r1) 14.2
Copyright (C) 2023 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-w64-mingw32".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word".
Warning: Debuggee TargetArchitecture not detected, assuming x86_64.
=cmd-param-changed,param="pagination",value="off"
[New Thread 4144.0xca0]
[New Thread 4144.0x22dc]
[New Thread 4144.0x1098]
[Thread 4144.0x1098 exited with code 3221225781]
[Thread 4144.0x22dc exited with code 3221225781]
[Thread 4144.0x22b0 exited with code 3221225781]
ERROR: Unable to start debugging. Unexpected GDB output from command "-exec-run". During startup program exited with code 0xc0000135.
The program 'd:\dev\cpp\qt6-example\build\qt-app.exe' has exited with code 0 (0x00000000).

TERMINAL:

PS D:\dev\cpp\qt6-example>  & 'c:\Users\Y\.vscode\extensions\ms-vscode.cpptools-1.21.3-win32-x64\debugAdapters\bin\WindowsDebugLauncher.exe' '--stdin=Microsoft-MIEngine-In-uv3xm3uu.3if' '--stdout=Microsoft-MIEngine-Out-fblpadg0.kry' '--stderr=Microsoft-MIEngine-Error-zcpj40gi.o20' '--pid=Microsoft-MIEngine-Pid-31dqf3uo.isy' '--dbgExe=C:\Program Files\mydevtools\MinGW-w64\bin\gdb.exe' '--interpreter=mi
waruqi commented 1 month ago

xmake-vscode does not use launch.json, it will generate it in memory and pass it to debugger directly. It is not a bug.

if you want to custom some launch configs, you should use xmake.customDebugConfig

https://github.com/xmake-io/xmake-vscode/issues/77 https://github.com/xmake-io/xmake-vscode/issues/246