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中用xmake调试时没有停在断点处 #227

Open
poemdistance opened this issue Oct 11, 2023 · 6 comments
Open

vscode中用xmake调试时没有停在断点处 #227

poemdistance opened this issue Oct 11, 2023 · 6 comments
Labels

Comments

@poemdistance
Copy link

Xmake 版本

xmake v2.8.3+master.4ea057304

操作系统版本和架构

Windows 版本号: 22H2 操作系统内部版本:19045.3448

描述问题

工程创建好后,在vscode的底部用xmake工具栏进行了build和运行,结果都符合预期,程序正常编译和执行了。但是点击小蜘蛛进行调试,能看到程序已经执行并停住,一直按单步调试程序不会在源码窗口中停住,直到程序终止。
image

期待的结果

停在断点处

工程配置

target("hello")
set_kind("binary")
add_files("hello.c")

附加信息和错误日志

@waruqi
Copy link
Member

waruqi commented Oct 11, 2023

断点你下了么,既然断下了,后面就跟 xmake 插件没啥关系了,完全由 vscode cpptools/codelldb 调试接管了,你得到他们那边反馈

@poemdistance
Copy link
Author

poemdistance commented Oct 11, 2023

装了的,新建launch.json,用以下配置,然后用左侧栏的调试按钮可以正常调试:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(gdb) Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}/build/windows/x64/debug/hello.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${fileDirname}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "miDebuggerPath": "C:\\MinGw\\bin\\gdb.exe",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                },
                {
                    "description": "Set Disassembly Flavor to Intel",
                    "text": "-gdb-set disassembly-flavor intel",
                    "ignoreFailures": true
                }
            ]
        },
    ]
}

请教下点击xmake的调试按钮后,发生了什么,怎么转交调试过程给vscode cpptools/codelldb 的,有没有方法打印出具体的调用信息

@waruqi
Copy link
Member

waruqi commented Oct 11, 2023

xmake-vscode 调试,不用外置的 launch.json,插件内部会生成 launch.json 自动调起 debugger 。。你可以调下插件源码

@poemdistance
Copy link
Author

我只是举例说明不用xmake,自己创建launch.json调试没问题。
刚用xmake又试了下,target platform设置成mingw就可以,windows则不行

可顺利调试:

{
    __toolchains_mingw_x86_64 = {
        "envs",
        "mingw",
        "yasm",
        "nasm",
        "fasm",
        "go"
    },
    arch = "x86_64",
    buildir = "build",
    ccache = true,
    host = "windows",
    kind = "static",
    mingw = [[C:\MinGW]],
    mode = "release",
    ndk_stdcxx = true,
    plat = "mingw"
}

无法进入断点:

{
    __toolchains_windows_x64 = {
        "gcc"
    },
    arch = "x64",
    buildir = "build",
    ccache = true,
    host = "windows",
    kind = "static",
    mode = "release",
    ndk_stdcxx = true,
    plat = "windows",
    toolchain = "gcc"
}

这是什么原因

@waruqi
Copy link
Member

waruqi commented Oct 11, 2023

windows 平台主要是给 msvc 用的,你要用 gcc ,建议切到 mingw 平台,单纯切 gcc toolchain ,平台还是 windows 我不确定是否有其他问题,我现在也没类似的环境去调试。。既然 mingw 可以,就走 mingw,要么就 windows 平台 不要去切 gcc ,走 msvc

@poemdistance
Copy link
Author

好的,感谢解答。
大佬这里能不能搞个检测,对于未预料的配置组合抛个警告,应该可以避免一部分我这样的情况

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

No branches or pull requests

2 participants