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

无法调试 #33

Closed
playgithub opened this issue May 19, 2020 · 19 comments
Closed

无法调试 #33

playgithub opened this issue May 19, 2020 · 19 comments

Comments

@playgithub
Copy link

test.cpp

#include <iostream>

int main()
{
    std::cout << "Hello, world!" << std::endl;
    return 0;
}

用工具栏操作,点击编译和运行都可以,但是点击调试不行(无限等待),截图:
2020-05-19_23-14

Version Info

  • XMake (vscode plugin): 1.3.4
  • VSCodium (variant of vscode): 1.45.1
  • OS: Manjaro
@waruqi
Copy link
Member

waruqi commented May 19, 2020

你点的哪个调试?看下readme里面的演示图片,点底下toolbar里面的bug button调试按钮

并确保c/c++ vscode插件也装了

@playgithub
Copy link
Author

2020-05-19_23-39
2020-05-19_23-40
是这样的,不能调试

@waruqi
Copy link
Member

waruqi commented May 19, 2020

gdb装了么?录个屏我看下呢?

@playgithub
Copy link
Author

playgithub commented May 19, 2020

$ whereis gdb
gdb: /usr/bin/gdb /etc/gdb /usr/include/gdb /usr/share/gdb /usr/share/man/man1/gdb.1.gz /usr/share/info/gdb.info.gz
$ whereis lldb
lldb: /usr/bin/lldb /usr/include/lldb /usr/share/man/man1/lldb.1.gz

@playgithub
Copy link
Author

用的VSCodium,我马上用vscode试一下

@playgithub
Copy link
Author

playgithub commented May 19, 2020

image
vscode也一样不行,箭头所指进度条无限循环。
BTW, 之前用Lua Debug调试lua的hello world也是这样。

@waruqi
Copy link
Member

waruqi commented May 20, 2020

调试前,main入口断点下了么。。

BTW, 之前用Lua Debug调试lua的hello world也是这样。

这个跟xmake没啥关系吧,如果其他插件也带不起调试,那我就不清楚了

我现在也没linux的可视化环境,要么你直接clone下代码,用vscode打开项目根目录,然后点加载运行,帮忙调下插件里面debugger.ts地方,也没几行代码。

@playgithub
Copy link
Author

playgithub commented May 20, 2020

调试前,main入口断点下了么。。

没有

我现在也没linux的可视化环境,要么你直接clone下代码,用vscode打开项目根目录,然后点加载运行,帮忙调下插件里面debugger.ts地方,也没几行代码。

vscode插件零经验,上手有点麻烦,用不用vscode还不一定,我还是先学习xmake再说吧。

@waruqi
Copy link
Member

waruqi commented May 20, 2020

调试前,main入口断点下了么。。
没有

需要自己现在main入库设置好断点,才能点调试运行,进行断点调试,你加上试试,如果还是不行 我现在也没环境给你调试,之前测试过 断点调试应该没问题的。

@playgithub
Copy link
Author

加了,不行

@waruqi
Copy link
Member

waruqi commented May 20, 2020

那就不知道了

@playgithub
Copy link
Author

用launch.json,路径固定可以调试,先这样了,也不麻烦。

@waruqi
Copy link
Member

waruqi commented May 21, 2020

用launch.json,路径固定可以调试,先这样了,也不麻烦。

既然launch.json可以了,那就帮忙对比下插件内置的launch.json配置差异,看下是那个配置不对导致的呗。。我也好改进下插件

} else if (os.platform() == "linux") {
debugConfig = {
name: `launch: ${targetName}`,
type: 'cppdbg',
request: 'launch',
program: targetProgram,
args: args,
stopAtEntry: true,
cwd: targetRunDir,
environment: [],
externalConsole: true,
MIMode: "gdb",
miDebuggerPath: "",
description: "Enable pretty-printing for gdb",
text: "-enable-pretty-printing",
ignoreFailures: true
};

@playgithub
Copy link
Author

playgithub commented May 21, 2020

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": "(gdb) Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "/path/to/linux/x86_64/debug/test",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ]
        }
    ]
}

@waruqi
Copy link
Member

waruqi commented May 21, 2020

            "program": "/path/to/linux/x86_64/debug/test",
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "externalConsole": false,
         program: targetProgram, 
         stopAtEntry: true, 
         cwd: targetRunDir, 
         externalConsole: true, 

主要就是这四个的差异,你可以先在你这里的launch.json里面吧 stopAtEntry/externalConsole设置成False,排除下这两个,如果这两没问题,多半是传入program的path有问题导致。。

可以git clone下xmake-vscode的源码,用vscode打开根目录,

在xmake.ts的下面代码块最后加上

        log.info("targetName: " + targetName);
        log.info("targetProgram: " + targetProgram);

xmake-vscode/src/xmake.ts

Lines 704 to 712 in ab6032f

var targetProgram = null;
let getTargetPathScript = path.join(__dirname, `../../assets/targetpath.lua`);
if (fs.existsSync(getTargetPathScript)) {
targetProgram = (await process.iorunv("xmake", ["l", getTargetPathScript, targetName], {"COLORTERM": "nocolor"}, config.workingDirectory)).stdout.trim();
if (targetProgram) {
targetProgram = targetProgram.split("__end__")[0].trim();
targetProgram = targetProgram.split('\n')[0].trim();
}
}

然后点调试运行,然后在里面打开你的项目,调试你的程序时候在output里面给我看下输出,基本上就能查出原因了

@playgithub
Copy link
Author

先这样,打算先学一下vscode插件和xmake。

@waruqi
Copy link
Member

waruqi commented May 24, 2020

可以看下这个,#36 人家应该找到问题原因了,你可以试试最新版本

@littlewater
Copy link

从这里来看貌似使用F5好像还是不支持,F5默认是调用的launch.json,编辑launch.json的方法意义不大,毕竟多个配置不可能一个个去改动的。

@waruqi
Copy link
Member

waruqi commented Oct 5, 2020

不用自己编辑launch.json,xmake-vscode内置传递了 launch.json,只需要点 工具栏最下面,xmake-vscode插件提供的调试按钮就行了。。f5等快捷键我暂时没加

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

3 participants