8

Yesterday I had done a lot of things like updating GCC, Clang and reinstalling Qt Creator.Today when debugging my code step by step, the debugger was showing the disassembley rather than the C++ code I wrote. Pressing F10 or F11, the debugger was moving into assembly code not the .cpp nor .h files I wrote. F11 can only go into the library files but never into the files I wrote.

The arrow appeared in disassembler: enter image description here

Rather than in main.cpp: enter image description here

How can I configure Qt Creator such that the debugging arrow tracks each line in the C++ code?

dandan78
  • 13,328
  • 13
  • 64
  • 78
Yue Wang
  • 1,710
  • 3
  • 18
  • 43
  • 1
    1) You are not trying to debug a release version of binary 2) You are not pressing F11 (step-into) on a function which doesn't have code in your project. Can you confirm? – 72DFBF5B A0DF5BE9 Jan 08 '14 at 02:05
  • @M.C. For 1), I can confirm it's not a release version. For 2) I have tried many times, F10 moves the arrow within disassembler. F11 sometimes can go into the library files but never into my codes.. – Yue Wang Jan 08 '14 at 02:15
  • @M.C. As shown in the image, all 4 .h and 5 .cpp were written by me. F11 sometimes go into the library files but never into these 9 files. – Yue Wang Jan 08 '14 at 02:19
  • related question on Qt Forum: [Debugging external application & showing C++ code, not assembly](https://forum.qt.io/topic/53926/debugging-external-application-showing-c-code-not-assembly) – Geremia May 05 '15 at 18:33

5 Answers5

3

For others who also had this problem but none of the solutions above worked (like me), I found out that the issue for me was simply happening because my project was inside of a directory with special characters (/home/fabio/criação/project) the criação folder seems to have caused the problem. After I changed to /home/fabio/Desktop/project it stop happening.

Fnr
  • 2,096
  • 7
  • 41
  • 76
2

I ran into a very similar problem debugging code built with the clang toolset in qtcreator, and this answer fixed me up:

gdb doesn't find source files compiled by clang++

You can quickly check if that solution will work for you by navigating to the root of your solution in a shell window and then invoking qtcreator from there...set a break point in main() and try debugging - if it stops and shows source in main.cpp, it's quite likely this is the problem.

If that does work for you, there are probably several better ways to implement the permanent solution suggested by https://stackoverflow.com/users/1632219/rene, but the method that worked for me was to modify my qmake mkspec file for the clang toolset. On my system, it lives in /usr/local/Trolltech/Qt-4.8.5/mkspecs/common/clang.conf, so all I had to do was put a clang invoker script with 'clang++ "$@"' in ~/bin/clang-compile and then set QMAKE_CXX in the mkspec to clang-compile. With that change, when the clang toolset is selected, qmake builds make files that use clang-compile instead of clang++ and then debugging works everywhere.

Community
  • 1
  • 1
sarah
  • 116
  • 6
1

At last, I found that it was Clang that had caused this problem. After changed the kit back to using gcc, it just worked fine. But not sure whether it's Clang's fault or that the script Qt produced for compiling has any problem. Anyway just put the answer here in case anyone else who might encounter the same situation.

Yue Wang
  • 1,710
  • 3
  • 18
  • 43
0

Goto "Help->About Plugins" and check the "ClangCodeModel" and restart QT.

There is a bug in version Qt 5.6.1 (MSVC 2013, 32 bit) QT Creator4.0.3. In debug mode put your breakpoint. Then hit the step into(F11) it will start debugging now. To go to your code hit the step-over(F10) until you come to the code page.

I have searched about this problem but nothing worked. Some solution, i didn't get. This is very annoying issue.

BTech
  • 23
  • 3
0

Maybe it will work if you clean, qmake and rebuild.I solved this problem by using this method.

Dharman
  • 30,962
  • 25
  • 85
  • 135
StephennQin
  • 81
  • 1
  • 5