I am attempting to debug some c++ code. The debugger wont stop at the breakpoints I have set.
I'm using vscode on ubuntu 20.
The breakpoint is hollow, when hovering it says: "Module containing this breakpoint has not yet loaded or the breakpoint address could not be obtained."
My makefile:
CXX = g++
CXX_FLAGS = -g -Wall -std=c++17
O_FILES = main.o \
cache.o
TARGET = main
all: $(TARGET)
$(TARGET): $(O_FILES)
$(CXX) $(CXX_FLAGS) $(O_FILES) -o $@
.phony: clean
clean:
rm -f *~ *.o $(TARGET)
#dependencies
cache.o: cache.cc cache.hh
tasks.json I have tried using g++ instead of make setting the appropriate flags as well, which resulted in error.
{
"tasks": [
{
"type": "shell",
"label": "C/C++: g++ build active file",
"command": "make",
"args": [
],
"options": {
"cwd": "${workspaceFolder}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
}
}
],
"version": "2.0.0"
}
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": "g++ - Build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/main",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"miDebuggerPath": "/usr/bin/gdb"
}
]
}
main:
#include <iostream>
#include <iomanip>
#include <string>
#include <fstream>
#include "cache.hh"
using namespace std;
int main(int argc, char** argv) {
Cache direct_mapped(8, 1);
int a;
cout << direct_mapped.getCacheSize() << endl;
direct_mapped.updateCacheBlock(1, 5, 31);
direct_mapped.printCache(1);
cin >> a;
return 0;
}
terminal ouput after running 'make':
g++ -c -o main.o main.cc
g++ -c -o cache.o cache.cc
g++ -g -Wall -std=c++17 main.o cache.o -o main
Is there something wrong with my task or launch file?
