Eclipse - 在C ++ Project中重新设置断点时出错

时间:2012-10-07 16:24:42

标签: c++ eclipse gdb eclipse-cdt eclipse-juno

我正在使用Eclipse Juno和CDT插件,但我也尝试过Indigo,这个问题也在那里发生。我在Ubuntu 12.04上。

我使用以下代码创建了一个新的C ++项目。我在第二行设置了一个断点。

#include <iostream>

using namespace std;

int main() {
    cout << "Hello world" << endl;
    cout << "Hi there" << endl; // I've set a breakpoint here using eclipse
}

我的Makefile就是这个

CXX := g++
CXXFLAGS := -g -c
LDFLAGS := -g -std=c++11
OBJ_FILES := main.o

.PHONY: all clean

all: $(OBJ_FILES)
    $(CXX) $(LDFLAGS) $(OBJ_FILES) -o proj2

main.o: main.cpp
    $(CXX) $(CXXFLAGS) main.cpp -o main.o 

clean:
    rm -rf *.o proj2

当我在eclipse中以调试模式运行时,一切都很好,但是当它运行时,gdb会发出这条消息:

Error in re-setting breakpoint 1: Function "/home/gulshan/Code/EECS281Workspace/Project 2/main.cpp:7" not defined.

值得注意的是,在这种情况下,我已经取消选中eclipse让你在启动时中断的选项,但是当检查该选项时,它可以在第一行中断而没有任何问题。

发生了什么事?如果有帮助,这是GDB跟踪。

707,811 2-environment-cd "/home/gulshan/Code/EECS281Workspace/Project 2"
707,811 2^done
707,812 (gdb) 
707,812 3-gdb-set breakpoint pending on
707,813 3^done
707,813 (gdb) 
707,814 4-gdb-set detach-on-fork on
707,814 4^done
707,814 (gdb) 
707,815 5-enable-pretty-printing
707,815 5^done
707,815 (gdb) 
707,815 6-gdb-set python print-stack none
707,816 6^done
707,816 (gdb) 
707,816 7-gdb-set print object on
707,817 7^done
707,817 (gdb) 
707,818 8-gdb-set print sevenbit-strings on
707,818 8^done
707,818 (gdb) 
707,818 9-gdb-set host-charset UTF-8
707,818 9^done
707,819 (gdb) 
707,819 10-gdb-set target-charset UTF-8
707,819 10^done
707,819 (gdb) 
707,820 11-gdb-set target-wide-charset UTF-32
707,820 11^done
707,820 (gdb) 
707,820 12source .gdbinit
707,821 &"source .gdbinit\n"
707,821 &".gdbinit: No such file or directory.\n"
707,821 12^error,msg=".gdbinit: No such file or directory."
707,821 (gdb) 
707,822 13-gdb-set target-async off
707,822 13^done
707,822 (gdb) 
707,823 14-gdb-set auto-solib-add on
707,823 14^done
707,824 (gdb) 
707,827 15-file-exec-and-symbols --thread-group i1 "/home/gulshan/Code/EECS281Workspace/Project 2/pr\
oj2"
707,828 15^done
707,828 (gdb) 
707,834 16-break-insert --thread-group i1 -f "\"/home/gulshan/Code/EECS281Workspace/Project 2/main.c\
pp\":7"
707,836 16^done,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x00000000004007d4"\
,func="main()",file="main.cpp",fullname="/home/gulshan/Code/EECS281Workspace/Project 2/main.cpp",lin\
e="7",times="0",original-location="/home/gulshan/Code/EECS281Workspace/Project 2/main.cpp:7"}
707,837 (gdb) 
707,843 17-inferior-tty-set --thread-group i1 /dev/pts/2
707,844 17^done
707,844 (gdb) 
707,847 18-exec-run --thread-group i1
707,848 =thread-group-started,id="i1",pid="22982"
707,848 =thread-created,id="1",group-id="i1"
707,848 18^running
707,848 *running,thread-id="all"
707,848 (gdb) 
707,849 19-list-thread-groups --available
707,851 =library-loaded,id="/lib64/ld-linux-x86-64.so.2",target-name="/lib64/ld-linux-x86-64.so.2",h\
ost-name="/lib64/ld-linux-x86-64.so.2",symbols-loaded="0",thread-group="i1"
707,870 &"Error in re-setting breakpoint 1: Function \"/home/gulshan/Code/EECS281Workspace/Project 2\
/main.cpp:7\" not defined.\n"
707,872 =breakpoint-modified,bkpt={number="1",type="breakpoint",disp="keep",enabled="n",addr="<PENDI\
NG>",pending="/home/gulshan/Code/EECS281Workspace/Project 2/main.cpp:7",times="0",original-location=\
"/home/gulshan/Code/EECS281Workspace/Project 2/main.cpp:7"}
707,873 =library-loaded,id="/usr/lib/x86_64-linux-gnu/libstdc++.so.6",target-name="/usr/lib/x86_64-l\
inux-gnu/libstdc++.so.6",host-name="/usr/lib/x86_64-linux-gnu/libstdc++.so.6",symbols-loaded="0",thr\
ead-group="i1"
707,874 =library-loaded,id="/lib/x86_64-linux-gnu/libc.so.6",target-name="/lib/x86_64-linux-gnu/libc\
.so.6",host-name="/lib/x86_64-linux-gnu/libc.so.6",symbols-loaded="0",thread-group="i1"
707,874 =library-loaded,id="/lib/x86_64-linux-gnu/libm.so.6",target-name="/lib/x86_64-linux-gnu/libm\
.so.6",host-name="/lib/x86_64-linux-gnu/libm.so.6",symbols-loaded="0",thread-group="i1"
707,874 =library-loaded,id="/lib/x86_64-linux-gnu/libgcc_s.so.1",target-name="/lib/x86_64-linux-gnu/\
libgcc_s.so.1",host-name="/lib/x86_64-linux-gnu/libgcc_s.so.1",symbols-loaded="0",thread-group="i1"
708,269 =thread-exited,id="1",group-id="i1"
708,270 =thread-group-exited,id="i1",exit-code="0"
708,270 *stopped,reason="exited-normally"
708,270 (gdb) 
708,278 20-gdb-exit
708,278 21-data-evaluate-expression $_exitcode
708,291 19^error,msg="Quit"
708,291 (gdb) 
708,292 20^exit
708,292 22-break-delete --thread-group i1 1

2 个答案:

答案 0 :(得分:1)

看起来GDB 7.4中存在使用带空格的路径设置断点的问题:http://sourceware.org/bugzilla/show_bug.cgi?id=13798

我已删除包含该文件的路径中的所有空格,现在可以正常工作。

答案 1 :(得分:1)

如果您在调试会话期间修改了代码,也可能发生这种情况。只需运行/“删除所有断点”即可解决问题。