Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to configure qt creator to show C++ code rather than disassembler?

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?

like image 926
Yue Wang Avatar asked Jan 08 '14 02:01

Yue Wang


People also ask

Does Qt Creator support C?

In addition, the Qt Creator Bare Metal Device plugin provides support for the following compilers: IAREW is a group of C and C++ bare-metal compilers from the various IAR Embedded Workbench development environments. Note: Currently supported architectures are 8051 , AVR , ARM , STM8 , and MSP430 .

How to Set breakpoint in Qt Creator?

Adding BreakpointsIn the code editor, click the left margin or press F9 (F8 on macOS) on a particular line you want the program to stop. In the Breakpoint Preset view or the Breakpoints view: Double-click the empty part of the view. Right-click the view, and select Add Breakpoint in the context menu.


2 Answers

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.

like image 134
Fnr Avatar answered Sep 27 '22 22:09

Fnr


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.

like image 38
sarah Avatar answered Sep 27 '22 22:09

sarah