Bug 295085 - KDevelop doesn't stop at breakpoints
Summary: KDevelop doesn't stop at breakpoints
Status: RESOLVED FIXED
Alias: None
Product: kdevelop
Classification: Applications
Component: CPP Debugger (show other bugs)
Version: 4.3.0
Platform: Ubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: kdevelop-bugs-null
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-02-29 19:03 UTC by Andreas Pietzowski
Modified: 2015-01-09 21:50 UTC (History)
8 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Debug output from KDevelop an its (not working) gdb breakpoints (32.13 KB, text/plain)
2012-03-01 23:46 UTC, Andreas Pietzowski
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Andreas Pietzowski 2012-02-29 19:03:40 UTC
Version:           4.2.81 (using KDE 4.8.0) 
OS:                Linux

Today I upgraded to Qt 4.8 (with apt-get, standard ubuntu installation with backports enabled). Since then KDevelop doesn't halt at the specified breakpoints. The application was started through gdb (it is slow as usual when debugging) but it runs over all breakpoints.

I can confirm this on two different machines - same Ubuntu setup (standard)...

Can you confirm this anyhow?

Reproducible: Always

Steps to Reproduce:
Set a breakpoint in some cpp-file. Start the binary with F9 (debugging).

Actual Results:  
Normal running of the app without halting.

Expected Results:  
It should halt at the breakpoint. It doesn't even work in main.cpp.
Comment 1 Milian Wolff 2012-02-29 20:50:50 UTC
are you sure you compile your app in debug mode? debugging in release mode will not work since without debug symbols, it doesn't know where to place break points.

please verify this, e.g. by running your app from the cli in gdb:

gdb yourapp
break main
run

-> if that doesn't stop either, you did not compile with debug symbols
Comment 2 Andreas Pietzowski 2012-02-29 22:01:35 UTC
I always compile it with KDevelops F8. And I also testen in the shell. Shell gdb works perfectly. It just doesn't connect to kdevelop somehow when I start the app with F9.

I also can remember that the ladybugs aside the source code turend to red dots when debugging is started. They do remain lady bugs since today.

I had this problem now in many releases but after some updates it always started to work again although I didn't change anything.

I also deleted all kdevelop files in ~/.kde/share but this didn't resulted in success to me ;-(

I guess it has to do something with my last "apt-get upgrade" but can't figure out what... Are there any other ways to investigate the problem more further?
Comment 3 Niko Sams 2012-03-01 05:21:33 UTC
plase activate gdb output in kdebugdialog and post the output you get.
Comment 4 Andreas Pietzowski 2012-03-01 10:40:53 UTC
I started kdebugdialog and gdb was checked already. But there is no output in this little application. Who should give me the output? KDevelop or the KDebugDialog-application?
Comment 5 Milian Wolff 2012-03-01 12:15:40 UTC
kdevelop
Comment 6 Andreas Pietzowski 2012-03-01 23:46:36 UTC
Created attachment 69232 [details]
Debug output from KDevelop an its (not working) gdb breakpoints

Okay thanks. Now I got the clue :) I enabled gdb-debugging-output. I hope I extracted the correct lines in my attachment. I put a breakpoint in the file myapplication.cpp at line 93. This is the main application and I put the breakpoint at the first line of the constructor.

Line 93 is also mentioned in the debug output but I am not familiar with the gdb outputs. Maybe you can find something why KDevelop just runs through the breakpoint an shows the main window on my desktop.

Thanks, Andreas
Comment 7 Niko Sams 2012-03-02 06:32:49 UTC
Gdb returns that error:
kdevelop(2192)/kdevelop (gdb debugger) GDBDebugger::GDB::execute: SEND: "-break-insert -f "\"/home/pietz/devel/svn/myapplication/src/myapplication/application/myapplication.cpp\":93" " kdevelop(2192)/kdevelop (gdb debugger) GDBDebugger::GDB::processLine: GDB output: "(gdb) " kdevelop(2192)/kdevelop (gdb debugger) GDBDebugger::GDB::processLine: GDB output: "&"No source file named /home/pietz/devel/svn/myapplication/src/myapplication/application/myapplication.cpp.\n""

Can you post the output of a plain gdb (cli) debug session?
Comment 8 Andreas Pietzowski 2012-03-02 15:53:04 UTC
Sorry for a stupid question but I am not so familiar with KDevelop <-> gdb. Do I have to set the breakpoint again in gdb cli or should the breakpoint already be set in gdb when I put the breakpoint in KDeevelop in advance and then start gdb from cli afterwards?
Comment 9 Niko Sams 2012-03-02 17:30:43 UTC
with gdb cli I mean gdb alone - without kdevelop.
basic example:
gdb yourdebuggee
break main.cpp:10
run
Comment 10 Andreas Pietzowski 2012-03-05 18:06:33 UTC
okay, I tested gdb from cli and in just stop at the right line (e.g. line 93 in the constructor of the main window) and it just stops.

KDevelop just opens up the main window if there wasn't set any breakpoint. But I really placed the "lady bug" at exactly the same line in the same cpp-file.

Do you have any ideas? I can reproduce this on two different machines since I upgraded to Qt 4.8 with apt-upgrade...
Comment 11 Niko Sams 2012-03-05 20:01:41 UTC
please attach the cli debug session output
Comment 12 Andreas Pietzowski 2012-03-05 20:24:32 UTC
this is gdb in cli:

$ gdb ./myapplication 
GNU gdb (Ubuntu/Linaro 7.3-0ubuntu2) 7.3-2011.08
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
For bug reporting instructions, please see:
<http://bugs.launchpad.net/gdb-linaro/>...
Reading symbols from /home/pietz/devel/svn/myapplication/bin/myapplication...done.
(gdb) break myapplication.cpp:93
Breakpoint 1 at 0x44bba6: file application/myapplication.cpp, line 93.
(gdb) run
Starting program: /home/pietz/devel/svn/myapplication/bin/myapplication 
[Thread debugging using libthread_db enabled]
[New Thread 0x7fffe5e3a700 (LWP 20368)]

Breakpoint 1, MyApplication::MyApplication (this=0x1a8bbb0, parent=0x0, fl=...) at application/myapplication.cpp:93
93          setWindowIcon(Ressource::icon(Ressource::IconAbisco));
(gdb)

...thats it and now it waits for input. No main window is displayed. Not very much output, but as expected. Any ideas? Thanks anyways!
Comment 13 Niko Sams 2012-03-11 17:24:53 UTC
Ok, and does it work if you specify an absolute file path?
break /home/pietz/devel/svn/myapplication/src/myapplication/application/myapplication.cpp:93
Comment 14 Andreas Pietzowski 2012-03-14 22:00:54 UTC
No, this doesn't work. It says:

No source file named /home/pietz/devel/svn/myapplication/src/myapplication/application/myapplication.cpp

This is strange. This path exists in the shell. What could be the reason for this behavior? Maybe we come close to the bug or miss configuration somehow...
Comment 15 Andreas Pietzowski 2012-03-14 22:22:14 UTC
Maybe I have to mention that my project is driven by qmake. It is (IMHO) just a normal simple qmake-pro-file which only contains relative paths in it. I don't use absolute paths because I checkout the repository to different directories sometimes.

But something has changed since Qt 4.8 - maybe it is a change in qmake or a change in KDevelop. Before I started my Ubuntu update, debugging worked fine within KDevelop.

I assume that KDevelop tells gdb absolute paths, right? This is the only logic solution why debugging doesn't work right now.

Can I tell KDevelop to use relative paths within gdb? Or can I change qmake to create my Makefile to use absolute paths within gdb as before?
Comment 16 Niko Sams 2012-03-15 06:16:50 UTC
sounds like a gdb problem.

I just did the following test and couldn't reproduce.
cat main.cpp 
#include <QDebug>
int main()
{
    qDebug() << "main";
}

qmake -project
qmake CONFIG+="debug"
make
gdb main.cpp

break /home/niko/qmaketest/main.cpp:4
run


qmake --version
QMake version 2.01a
Using Qt version 4.8.0 in /usr/lib

gdb --version
GNU gdb (GDB) 7.4
Comment 17 Andreas Pietzowski 2012-03-15 14:21:27 UTC
This also works for me with gdb. Strange! What could be the reason why absolute paths don't work with gdb in my project although  the path exists in the file system?
Comment 18 Niko Sams 2012-03-15 15:38:53 UTC
try to reproduce the issue by simplifying your application. Maybe it's some qmake option?
Comment 19 Andreas Pietzowski 2012-03-17 11:15:24 UTC
I doubt it's a qmake or Makefile problem because the same qmake project works on another machine where no Ubuntu updates were made. Could it really be an ubunutu update problem? On two different machines the same problem?
Comment 20 Dmitriy Matison 2012-03-17 22:28:18 UTC
I experience the same problem on the latest stable ubuntu. Kdevelop doesn't stop at brekpoints. Yes, gdb works well with my executable in the command line, but no integration into Kdevelop. My project is just a "Hello, World" application based on the custom makefile.
Version 4.2.3
Using KDE Development Platform 4.7.4 (4.7.4)
Comment 21 Niko Sams 2012-03-18 18:06:26 UTC
Andreas, I would say it's a gdb regression. It should be reported to the gdb bug tracker - though you will need to track down the issue to a simplified testcase that allows the gdb developers to reproduce the issue.

Dmitriy, did you try with absolute file path when setting the breakpoint (on gdb cli)?
Comment 22 Andreas Pietzowski 2012-03-18 20:54:53 UTC
I doubt it's a gdb issue because gdb didn't change in the update. And this is not the first time debugging is broken in KDE/KDevelop/Kubuntu updates. It happened very often that KDevelop releases have broken debugging functionality.

At least Dmitriy Matison can reproduce the problem.
Comment 23 Niko Sams 2012-03-19 09:44:13 UTC
well, you said you can reproduce with plain gdb when using absolute paths. No KDevelop involved.
That needs to be fixed first, KDevelop can't do anything about it. (and using relative paths isn't so easy to shouldn't be necessary)
Comment 24 Andreas Pietzowski 2012-03-19 19:55:29 UTC
Is it really a gdb issue or can I tell g++ to use absolute paths or not within the Makefile? Maybe qmake produces a stange Makefile?
Comment 25 Andreas Pietzowski 2012-03-19 21:24:28 UTC
Ahhhh... :-D I have new information on the issue. I finally got gdb breaking at an absolute file path. It works after I type "list" in the gdb shell. To explain it better, here is exactly what I did:

$ gdb ./myapplication

(gdb) break /absolute/file/path/to/main.cpp:34
No source file named /absolute/file/path/to/main.cpp.
Make breakpoint pending on future shared library load? (y or [n]) n

(gdb) list
31      #include "blabla.h"
32
33      int main(int argc, char *argv[]) {
34          QApplication a( argc, argv );

(gdb) break /absolute/file/path/to/main.cpp:34
Breakpoint 1 at 0xC0FFEE: file relative/path/to/main.cpp, line 34.

(gdb) run
Breakpoint 1, main (argc=1, argv=0x7fffffffe108) at application/main.cpp:34
34          QApplication a( argc, argv );

Isn't that strange? Two times the same command to gdb with different results? What could be the reason for this behavior? I know it seems more like a gdb issue but maybe you have some ideas? By the way: My project has about 1500 source files...
Comment 26 Niko Sams 2012-03-20 06:37:01 UTC
Wow, that is strange.

The only idea I have is that you should reduce your code to a basic testcase that still allows to reproduce the issue. And yes, it know that is is quite some work...

Other than that you could ask for help on the gdb mailinglist, they are the specialists :D
Comment 27 Andreas Pietzowski 2012-04-04 00:45:19 UTC
I posted the issue at the gdb bugzilla but no respnse yet ;-(
http://sourceware.org/bugzilla/show_bug.cgi?id=13870

But I have a (maybe) solution for the problem within KDevelop. When I tell gdb in command line:

directory /absolute/path/to/my/kdevelop/project

then gdb is aware of all files and breakpoints work immediately. Maybe you could tell gdb an additional directory before running the app? I would suggest, to pass it the directory which the user configured in the specific launch-configuration as working directory for the app. Or just the kdev project direcorty?

Is it worth a try? Can I test this somehow with parameters in KDevelop?
Comment 28 Andreas Pietzowski 2012-04-20 10:47:57 UTC
What do you think about my solution to explicitly add the source-directory of the project?

Is someone able to implement this?
Comment 29 Andreas Pietzowski 2012-04-20 19:27:11 UTC
...or is there a way to pass additional parameters to gdb within KDevelop? I could then pass "-c /absolute/path/to/my/project" to hopefully enable debugging with KDevelop.
Comment 30 Andreas Pietzowski 2012-04-20 20:25:47 UTC
I can also debug my Qt-application with ddd. It works perfectly - so I guess it still has something to do with KDevelop (or its gdb configuration) and not with gdb itself.
Comment 31 Niko Sams 2012-04-21 17:54:07 UTC
This is a gdb bug, as you could reproduce it using plain gdb on cli. It should be fixed upstream.

Possible Workaround:
create a file containing this directory command and specify that file as "Config gdb script" in launch configuration. KDevelop will source that script before running the application. Maybe it's too early (because the application isn't loaded yet at this point) but it's worth a try.
Comment 32 Andreas Pietzowski 2012-04-22 01:29:51 UTC
Again: Debugging my Qt-source with "ddd" works perfectly. How could this be a problem with gdb then? IMHO it is just an issue of KDevelop. Plus, there are a bunch of issues in the internet telling problems with KDevelop and gdb...

It would be nice to get some more preference variables in KDevelop to try something out regarding the gdb connectivity.
Comment 33 Niko Sams 2012-04-22 11:42:52 UTC
As I can't reproduce your problem you have to investigate yourself what ddd does different than kdevelop.

Do the "bunch of issues" have anything to do with this bug?
Comment 34 Andreas Pietzowski 2012-04-22 11:53:01 UTC
I would investigate. But the problem is, that gdb is nearly not configurable at all within KDevelop. Can I pass arguments somehow to gdb within KDevelop to test different parameters?

I also tried to setup my ~/.gdbinit and pass some lines like

directory /abs/path/to/my/project

and this really helped out. KDevelop stopped at breakpoints but really on wrong lines in code. But at least it stopped again.

Is ~/.gdbinit the only way to configure gdb? The problem is, that this is a global system setup which works for general gdb and isn't project specific.
Comment 35 Niko Sams 2012-04-22 12:01:19 UTC
see comment 31
Comment 36 Andreas Pietzowski 2012-06-18 16:28:49 UTC
I still think it is an issue of KDevelop because the same Qt project works perfectly when I use Qt Creator instead of KDevelop. Debugging in there works just as expected. In KDevelop every breakpoint in my application is mentioned as "dirty" and thus no breakpoint works in KDevelop.

Maybe Qt Creator triggers gdb with different arguments?
Comment 37 Emad Gad 2012-07-24 18:22:36 UTC
Hello
I just encountered the same problem, after upgrading from Kubntu 11.04 to 12.04.
Kdevelop 4.2 used to run with no problem for almost a year. At the beginning, 4.3 seemed to work just fine, but something triggered this problem.
Comment 38 Andreas Pietzowski 2012-07-28 14:26:23 UTC
Can nobody tell the difference why QtCreator works fine and KDevelop just doen't stop at breakpoints? Seems like more people have this problem with debugging since Kubuntu 11.04 ....
Comment 39 elof_sam 2012-08-02 01:43:32 UTC
*** This bug has been confirmed by popular vote. ***
Comment 40 Niko Sams 2012-08-26 18:05:38 UTC
Hm, still seem to be an issue. But I can't reproduce, just tried on Kubuntu 12.04 (with a very basic example, "Simple CMake-base C++ application" Template).

So I need help:
I need a way to reproduce.
- anyone having this issue please create an project using that template and try debugging that (same issue?)
- send me a example project where I can see the issue (if the template isn't effected)
- post the internal debugger output QtCreator produces (there is a way to activate that in the UI) - so we can find what QtCreator executes and KDevelop doesn't
Comment 41 Niko Sams 2012-08-26 18:06:50 UTC
I suspect the issue is caused by the gdb upgrade, not by the KDevelop upgrade. (and the Kubuntu upgrade did both at the same time)
Comment 42 Niko Sams 2012-10-24 22:33:39 UTC
please give me input on this. Can anyone reproduce and post logs?
Comment 43 ivan.noob.dmitrov 2013-01-24 13:28:19 UTC
I've met similar issue. It happens every time, when I create a project(e.g. from template -> Standard -> Terminal) in a directory with the colon in the path like "~/first : second/my_project". (KDevelop 4.4)
Comment 44 Niko Sams 2013-01-24 20:03:28 UTC
Ilya, that sounds like a unrelated issue if it's about the double colon. Please create a new bug for that.
Comment 45 Gabriele Menna 2013-04-17 08:18:37 UTC
Kdevelop is still skipping breakpoints, here.

By exploring the GDB output, inside the GDB view, here's what append when a breakpoint is being set:

(gdb) -break-insert -f "\"/home/gabo/md/flapui_builder/flap_ui/src/widgets/gridparameterswidget.cpp\":54"
No source file named /home/gabo/md/flapui_builder/flap_ui/src/widgets/gridparameterswidget.cpp

I tried to play with GDB mi2 interface: I run gdb --interpreter=mi2 and triggered the command:

-break-insert -f "\"/home/gabo/md/flapui_builder/flap_ui/src/widgets/gridparameterswidget.cpp\":54"

the breakpoint is properly set.

If I do

-environment-cd /home/gabo/md/flapui_builder/flap_ui/bin
-break-insert -f "\"/home/gabo/md/flapui_builder/flap_ui/src/widgets/gridparameterswidget.cpp\":54"

I get

&"No source file named /home/gabo/md/flapui_builder/flap_ui/src/widgets/gridparameterswidget.cpp.\n"

Breakpoint has not been set.

What is that -environment-cd command for? Is there any workaround to such strange GDB behaviour?

Kdevelop 4.4.1 on KDE 4.10.2.
gdb 7.5.1.
gcc 4.8.0.
Comment 46 Gabriele Menna 2013-04-17 10:20:10 UTC
Same issue in 4.5 revision, just recompiled from git.

When setting a breakpoint from the editor, the breakpoint is properly added to breakpoints view. The full name of the source file where the breakpoint was set is shown. 
GDB, when program is started in debugging mode, complains about this breakpoint:

(gdb) -break-insert -f "\"/home/gabo/md/flapui_builder/flap_ui/src/molexplorer/molviewwrapper.cpp\":732"
No source file named /home/gabo/md/flapui_builder/flap_ui/src/molexplorer/molviewwrapper.cpp.

Anyway, if I alter the breakpoint source file, in the breakpoint view, replacing the absolute file path with the path relative to the project root, the breakpoint is properly set and hit.
Comment 47 Gabriele Menna 2013-04-29 08:18:53 UTC
This bug disappeared with kdevelop 4.5 + gdb 7.6.

Everything is working like a charm, here!
Comment 48 Aleksey Midenkov 2014-06-02 12:27:07 UTC
kdevelop 4.6.0
gdb 7.2-60.el6_4.1

kdevelop breakpoints work sometimes in wrong places. I put BP in my code inside new thread and it stops inside pthread_join.c:pthread_join() which is absolutely wrong place. Btw, that BP from terminal works perfectly well! After removing this BP in kdevelop and adding it again it started to work correctly! This indicates possible memory corruption and may be related to Bug 335534.
Comment 49 Nicolai Hähnle 2014-12-12 15:46:46 UTC
Aleksey, I suspect your issue (comment #48) is the same as bug #283379: KDevelop simply fails to pick up the correct thread when the breakpoint is hit. This is a known issue for which we should have a fix soon.

Since we never found a reliable reproduction sequence for this rather old bug, and Gabriele reports that the problem disappeared with a gdb upgrade, I'm closing this report.
Comment 50 Marco Gamberoni 2015-01-09 20:57:43 UTC
Had the same problem, got here through a search engine, and found no answer, nor here nor elsewhere, to why kdevelop was ignoring breakpoints.
With the suggestion in comment 3, to use kdebugdialog, I have discovered what was going on.
The explanation is in this bugreport on gdb's bugzilla:
https://sourceware.org/bugzilla/show_bug.cgi?id=17824

The bug, both in kdevelop and gdb, is a lack of documentation on how to setup them to debug an executable when the source files are in another location than the one declared in the symbol table.
Comment 51 Nicolai Hähnle 2015-01-09 21:26:05 UTC
Dear Marco, thanks for taking the time to track your particular issue down.

From what I understand, this issue is really a problem in GDB, right? As soon as the referenced GDB is fixed, we're good, and in the meantime there isn't really anything KDevelop can do to fix that (at least nothing that is within our limited manpower plus non-existent funding). So I'm leaving this bug closed.

If you do feel like KDevelop could/should do something separately from any fix in GDB, please open a _separate_ bug (together with steps for reproduction), since your issue appears different from the originally reported one.
Comment 52 Marco Gamberoni 2015-01-09 21:50:50 UTC
> So I'm leaving this bug closed.

Correct.
I wanted to put a comment here because this bugreport is number 1 in a search for "kdevelop ignores breakpoint", and the tips I got here about kdebugdialog and the direct testing of gdb/mi were really useful to me. Now here one can also find why, after the original real bug was solved, the same wrong behaviour could still happen, as a consequence of incorrect usage.