Search code examples
c++eclipsegdbeclipse-cdteclipse-juno

Eclipse - Error in re-setting breakpoint in C++ Project


I'm using Eclipse Juno with the CDT Plugin, but I've tried in Indigo as well and this problem happens there too. I'm on Ubuntu 12.04.

I've created a new C++ project with the following code. I've set a breakpoint on the second line.

#include <iostream>

using namespace std;

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

And my Makefile is this

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

When I run this in Debug mode in eclipse, everything builds fine, but when it runs, gdb spits out this message:

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

It might be worth noting that in this case I've unchecked the option eclipse gives you to break at startup, but when that option is check, it is able to break at the first line without any problem.

What's going on? Here is the GDB trace in case that helps.

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

Solution

  • Looks like there's a bug in GDB 7.4 that has a problem with setting breakpoints using paths with spaces: http://sourceware.org/bugzilla/show_bug.cgi?id=13798

    I've removed all of the spaces in the path containing the file and it works now.