首页 > 解决方案 > 为什么没有击中断点?

问题描述

不久前我开始使用 Linux,我正在尝试运行一些为 Windows 制作的旧代码。他们正在运行,但我不能调试,断点没有被击中。我已经看到与此有关的许多问题都与未在“MakeFile”中添加“-g”有关,但似乎不是我的情况。我正在使用Vscode,在调试过程中我的断点是这样的

在此处输入图像描述

这是我的制作文件:

    CC=gcc
    CFLAGS= -o -W -ggdb -g 
    LDFLAGS= -lm -lstdc++
    OBJFILES = main.o Funcoes.o Mat_Vet.o rotinas_matematicas.o Classes.o SME5720.o
    TARGET = ss
    
    all: $(TARGET)
    
    $(TARGET): $(OBJFILES)
            $(CC) $(CFLAGS) -o $(TARGET) $(OBJFILES) $(LDFLAGS)
    
    clean:
        rm -f $(OBJFILES) $(TARGET) *~ 

这是我的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": "${workspaceFolder}/ss",
        "args": [],
        "stopAtEntry": true,
        "cwd": "${workspaceFolder}",
        "environment": [],
        "externalConsole": false,
        "MIMode": "gdb",
        "setupCommands": [
            {
                "description": "Enable pretty-printing for gdb",
                "text": "-enable-pretty-printing",
                "ignoreFailures": true
            }
        ]
    }
]
}

标签: c++cdebuggingvisual-studio-code

解决方案


通过更改“MakeFile”解决了我的问题,我不知道它为什么会起作用。如果有人能说出原因。这是我的新生成文件:

output: main.o Classes.o Funcoes.o Mat_Vet.o rotinas_matematicas.o SME5720.o
    g++ main.o Classes.o Funcoes.o Mat_Vet.o rotinas_matematicas.o SME5720.o -o output

main.o:main.cpp
    g++ -c -g main.cpp

Classes.o: Classes.cpp Classes.h
    g++ -c -g Classes.cpp

Funcoes.o: Funcoes.cpp Funcoes.h
    g++ -c -g Funcoes.cpp

Mat_Vet.o: Mat_Vet.cpp Mat_Vet.h
    g++ -c -g Mat_Vet.cpp

rotinas_matematicas.o: rotinas_matematicas.cpp rotinas_matematicas.h
    g++ -c -g rotinas_matematicas.cpp
SME5720.o: SME5720.cpp SME5720.h
    g++ -c -g SME5720.cpp   

clean:
    rm *.o output

推荐阅读