batman
batman

Reputation: 5380

Why doesn't Netbeans stop at my breakpoints?

I created a C++ project on Netbeans 8.0.1 with existing sources and a Makefile.

I ran build which ran the Makefile fine and built the executable named a.out.

The problem is that when I set a breakpoint in the IDE it just doesn't pause there.

What is the issue?

None of the other questions on this site solved the issue.

Makefile:

CC=g++

build: foo.cpp foo.h main.cpp
    $(CC) foo.cpp foo.h main.cpp

Upvotes: 1

Views: 10186

Answers (3)

morteza
morteza

Reputation: 153

for mine, it was a wrong attribute value in project properties that NetBeans didn't detect it. I set my project building to 'Debug', but in Build>C++ Compiler>Development Mode the value was set to 'Release'. That was my fault in editing attributes. By changing back it to 'Debug' the problem solved.

Upvotes: 0

rwhenderson
rwhenderson

Reputation: 84

The -g option is the first thing -- make sure that's on the compile line. if it still doesn't work then run gdb directly to see if it works. If there's a problem, gdb will spit out an error or warning, which might be obscured when running it via netbeans. For example:

gdb <progname>

and set a breakpoint, for example

(gdb) break main

Then run it:

(gdb) run

If it breaks ok on the first statement but not in netbeans, then something else is wrong. But if it runs to the end and spits out a warning, e.g. this re. missing packages:

Missing separate debuginfos, use: debuginfo-install glibc-2.12-1.149.el6.x86_64

then just do what it tells you. Once gdb is happy, netbeans should be too.

Upvotes: 1

John Zwinck
John Zwinck

Reputation: 249333

I have sometimes encountered this issue too. There are a few possible solutions:

  1. Make sure you're building a Debug build, and that -g is part of your compiler command when you build (it should be by default, but you must double check, especially since you seem to be using your own Makefile).
  2. Restart NetBeans and do a Clean Build. Maybe this helps.
  3. Use gdb directly, rather than via the NetBeans GUI. In my experience gdb always works, but NetBeans is not reliable for debugging, and sometimes has problems for reasons unknown to me. I mostly use good old command-line debuggers for this reason.

Upvotes: 7

Related Questions