Results 1 to 17 of 17

Thread: qt creator - breakpoints don't work

  1. #1
    Join Date
    May 2010
    Posts
    15
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default qt creator - breakpoints don't work

    Hi,

    I'm having problems with debugging stuff in qt creator.

    I write a simple test app:
    Qt Code:
    1. int main(int argc, char** argv)
    2. {
    3. QApplication app(argc, argv);
    4. QLabel* lol = new QLabel("test");
    5. lol->show();
    6. return app.exec();
    7. }
    To copy to clipboard, switch view to plain text mode 

    Then I set a breakpoint on any of the lines (or even on all lines) and run the debugger. It skips right through all the breakpoints and enters the main loop. If I then pause the execution and look at the stack trace, it shows the main function is at line 0 and is grayed out, like this: http://i.imgur.com/3EZ3g.png . Double clicking it takes me to the assembly view.

    What's going on?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: qt creator - breakpoints don't work

    Hard to say without any additional info. You may look at the output from Creator to see if there aren't any warnings related to the debugger.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    May 2010
    Posts
    15
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: qt creator - breakpoints don't work

    I've kind of tracked down the issue - qtcreator doesn't add -g option to CFLAGS when building in debug mode. In fact it doesn't add any optimization options when building in release mode either...

    Here's a build line in debug mode:
    Qt Code:
    1. g++ -c -pipe -Wall -W -D_REENTRANT -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I. -o main.o main.cpp
    To copy to clipboard, switch view to plain text mode 

    ant this is in release mode:
    Qt Code:
    1. g++ -c -pipe -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I. -o main.o main.cpp
    To copy to clipboard, switch view to plain text mode 

    The only difference is -DQT_NO_DEBUG.

    I clearly remember, that this stuff used to work in the past. What could have happened that broke it?

  4. #4
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: qt creator - breakpoints don't work

    As a side note, and one I did encounter.
    Do not use-o optimisation and -g dwarf information at the same time.

    Some breakpoints will fail because the code is optimised.
    A debugger making use of the dwarf information will not report the correct line numbers. It will report line numbers of the optimised code.

  5. #5
    Join Date
    May 2010
    Posts
    15
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: qt creator - breakpoints don't work

    Oddly, I rebuilt qt-core (I'm on Gentoo) without optimized-qmake and it started including -g in debug mode, but still is not doing any optimizations in release mode.

    I did some snooping around and found the file /usr/share/qt4/mkspecs/common/g++.conf. There I found the lines:
    Qt Code:
    1. QMAKE_CFLAGS_RELEASE +=
    2. QMAKE_CFLAGS_DEBUG += -g
    To copy to clipboard, switch view to plain text mode 

    Should the first line be empty?

  6. #6
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: qt creator - breakpoints don't work

    Did you recently change /etc/make.conf ?
    On my system it contains the CXX_FLAGS (or something like that) environment variable.

    Edit: note that optimisation isn't always wanted, so you should set the level yourself.

  7. #7
    Join Date
    May 2010
    Posts
    15
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: qt creator - breakpoints don't work

    No, I didn't change /etc/make.conf C(XX)FLAGS lately. It's set to:
    Qt Code:
    1. CFLAGS="-O2 -march=core2 -msse3 -mssse3 -msse4.1 -pipe -g"
    2. CXXFLAGS="${CFLAGS}"
    To copy to clipboard, switch view to plain text mode 

    I also remember, that in the past the release mode used some or all of these flags.

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: qt creator - breakpoints don't work

    I don't think qmake takes /etc/make.conf into consideration when generating the Makefile. It should work solely based upon $QTDIR/mkspecs/*.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  9. #9
    Join Date
    May 2010
    Posts
    15
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: qt creator - breakpoints don't work

    Well then, should the QMAKE_CFLAGS_RELEASE variable be empty?

  10. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: qt creator - breakpoints don't work

    I think you should care more about QMAKE_CXXFLAGS and family.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  11. #11
    Join Date
    May 2010
    Posts
    15
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: qt creator - breakpoints don't work

    Quote Originally Posted by wysota View Post
    I think you should care more about QMAKE_CXXFLAGS and family.
    This one's set to just "-pipe".

  12. #12
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: qt creator - breakpoints don't work

    What about QMAKE_CXXFLAGS_DEBUG and others like it?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  13. #13
    Join Date
    May 2010
    Posts
    15
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: qt creator - breakpoints don't work

    Here are all the defaults:
    Qt Code:
    1. QMAKE_CC = gcc
    2. QMAKE_CFLAGS += -pipe
    3. QMAKE_CFLAGS_DEPS += -M
    4. QMAKE_CFLAGS_WARN_ON += -Wall -W
    5. QMAKE_CFLAGS_WARN_OFF += -w
    6. QMAKE_CFLAGS_RELEASE +=
    7. QMAKE_CFLAGS_DEBUG += -g
    8. QMAKE_CFLAGS_SHLIB += -fPIC
    9. QMAKE_CFLAGS_STATIC_LIB += -fPIC
    10. QMAKE_CFLAGS_YACC += -Wno-unused -Wno-parentheses
    11. QMAKE_CFLAGS_HIDESYMS += -fvisibility=hidden
    12. QMAKE_CFLAGS_PRECOMPILE += -x c-header -c ${QMAKE_PCH_INPUT} -o ${QMAKE_PCH_OUTPUT}
    13. QMAKE_CFLAGS_USE_PRECOMPILE += -include ${QMAKE_PCH_OUTPUT_BASE}
    14.  
    15. QMAKE_CXX = g++
    16. QMAKE_CXXFLAGS += $$QMAKE_CFLAGS
    17. QMAKE_CXXFLAGS_DEPS += $$QMAKE_CFLAGS_DEPS
    18. QMAKE_CXXFLAGS_WARN_ON += $$QMAKE_CFLAGS_WARN_ON
    19. QMAKE_CXXFLAGS_WARN_OFF += $$QMAKE_CFLAGS_WARN_OFF
    20. QMAKE_CXXFLAGS_RELEASE += $$QMAKE_CFLAGS_RELEASE
    21. QMAKE_CXXFLAGS_DEBUG += $$QMAKE_CFLAGS_DEBUG
    22. QMAKE_CXXFLAGS_SHLIB += $$QMAKE_CFLAGS_SHLIB
    23. QMAKE_CXXFLAGS_STATIC_LIB += $$QMAKE_CFLAGS_STATIC_LIB
    24. QMAKE_CXXFLAGS_YACC += $$QMAKE_CFLAGS_YACC
    25. QMAKE_CXXFLAGS_HIDESYMS += $$QMAKE_CFLAGS_HIDESYMS -fvisibility-inlines-hidden
    26. QMAKE_CXXFLAGS_PRECOMPILE += -x c++-header -c ${QMAKE_PCH_INPUT} -o ${QMAKE_PCH_OUTPUT}
    27. QMAKE_CXXFLAGS_USE_PRECOMPILE = $$QMAKE_CFLAGS_USE_PRECOMPILE
    To copy to clipboard, switch view to plain text mode 

  14. #14
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: qt creator - breakpoints don't work

    Looks fine to me. According to this -g should be in debug mode and not in release mode. My qmake gives me -g in release mode as well (it might be platform dependent, I'm using 'linux-g++' platform) but it's more important that it's there for debug. If -g is missing from your debug makefile, then obviously something had to remove it - maybe you are using some 3rd party addition that introduces such effect.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  15. #15
    Join Date
    May 2010
    Posts
    15
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: qt creator - breakpoints don't work

    I'm not saying -g should be in the release mode. I'm saying that at least -O2 should be in the release mode. Am I not right?

    I just want to know if some optimization flags are SUPPOSED to be there or is it up to the distribution's maintainers. Or maybe it's supposed to be empty after all?

    -g was missing from debug, but then I rebuilt qt-core and it popped back. Weird, but it happens, this problem is solved now. I just want to know about the release thing and I'll be gone
    Last edited by pmitas; 8th September 2010 at 11:33.

  16. #16
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: qt creator - breakpoints don't work

    Quote Originally Posted by pmitas View Post
    I'm saying that at least -O2 should be in the release mode. Am I not right?
    I wouldn't say that was relevant to breakpoints working (or not) in debug mode.

    I just want to know if some optimization flags are SUPPOSED to be there or is it up to the distribution's maintainers. Or maybe it's supposed to be empty after all?
    It depends on where do you have Qt from. If you installed it from the verbatim package downloaded from Nokia then you should have the defaults. But if you installed it through a package manager for your distro, the maintainer of the package might have changed some of the specs (I don't say that is the case). Take a look at the mkspecs directory of your installation and compare it to the Makefile generated by qmake. See if the variable values are consistent.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  17. #17
    Join Date
    May 2010
    Posts
    15
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: qt creator - breakpoints don't work

    That's all then. Thanks for your time.

Similar Threads

  1. Breakpoints set at a slot will not stop?
    By MorrisLiang in forum Newbie
    Replies: 7
    Last Post: 19th May 2010, 17:18
  2. Replies: 2
    Last Post: 13th December 2009, 21:27
  3. Qt Creator doesn't stop at breakpoints
    By TheSaw in forum Qt Tools
    Replies: 3
    Last Post: 12th May 2009, 16:53
  4. Replies: 0
    Last Post: 18th March 2009, 12:56
  5. Replies: 3
    Last Post: 15th January 2008, 13:11

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.