debugging 在VSCode MacOS上调试C++:包含此断点的模块尚未加载或无法获取断点地址

jgzswidk  于 2023-08-06  发布在  Vscode
关注(0)|答案(1)|浏览(128)

我有三个文件:
main.cpp

#include <iostream>
#include "log.h"

int main()
{
    int a = 8; // Breakpoint on this line
    a++;
    const char *string = "Hello";

    for (int i = 0; i < 5; i++)
    {
        const char c = string[i];
        std::cout << c << std::endl;
    }

    Log("Hello, World!");
    std::cin.get();
}

字符串
log.cpp

#include "log.h"

#include <iostream>

void Log(const char* message)
{
    std::cout << message << std::endl;
}


log.h

#pragma once

void Log(const char* message);


我的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": "(lldb) Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}/${fileBasenameNoExtension}",
            "args": [],
            "stopAtEntry": true,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "lldb"
        }
    ]
}


终端中的输出为:

H
e
l
l
o
Hello, World!


当我使用VSCode调试器进行调试时,断点显示一个白色圆圈,悬停在上面时显示以下内容:“包含此断点的模块尚未加载或无法获得断点地址”。我是新的语言和调试,不能弄清楚该怎么做的基础上解决类似的问题在互联网上。请帮帮忙,谢谢!

x3naxklr

x3naxklr1#

有一件事对我很有效,并且允许我继续进行调试,那就是转到launch.json文件,并将“程序”更改为您试图调试的文件的路径。
所以在我的情况下

"program": "${workspaceFolder}/cpp/main.cpp"

字符串

相关问题