I have got three files:
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);
My launch.json looks like this:
{
// 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"
}
]
}
The output in the terminal is:
H
e
l
l
o
Hello, World!
When I debug using the VSCode debugger, the breakpoint shows a white circle and upon hovering on it the following is displayed: "Module containing this breakpoint has not yet loaded or the breakpoint address could not be obtained". I'm new to the language and debugging and cannot figure out what to do based on the solutions to similar questions on the internet. Please help, Thanks!
This could be caused by a lack of debugging information in your program, an issue solved by adding debugging flags when compiling (often, a -g flag, see the gcc and Clang manuals).
Instructing the compiler to add debugging information to the program enables the debugger (in your case lldb) to do various things, such as setting breakpoints in the source code.
If simply adding -g to your compile flags doesn't solve the issue, VSCode's documentation on debug symbols could be of help.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With