Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make the "Locals and Expressions" debugging window operational with gcc 4.8?

Tags:

gcc

qt-creator

I am using gcc 4.7 and gcc 4.8 together with QtCreator 2.7.1.

The problem is that when I use gcc 4.8, I am unable to see the values of my variables in the "Locals and Expressions" window in debug mode:

enter image description here

While gcc 4.7 works fine:

enter image description here

I have tried to repair this by playing with the QtCreator options, but to no avail.

I am not sure, if this has actually something to do with the compiler version, but the problem goes away once I rebuild with the older version.

like image 687
Martin Drozdik Avatar asked May 17 '13 14:05

Martin Drozdik


2 Answers

The reason probably is that gcc 4.8 is using by default newer format for storing debugging information (http://gcc.gnu.org/gcc-4.8/changes.html). If you are using gdb version less than 7.5 (see gdb --version) you need to provide -gdwarf-3 argument for compiling with debug info using gcc 4.8.

like image 53
hluk Avatar answered Oct 12 '22 23:10

hluk


The same symptom can result from having a debugger that is too new, instead of too old!

In this case it's not about the GDB version, it's about the version of Python which was embedded into it when it was built. Ubuntu 13.10 ships with a GDB that's built with embedded Python3 instead of Python2. Qt Creator (at the time of this writing) is not compatible with that.

You can check to see if you've got a Python2 GDB by running it from a terminal and typing:

(gdb) python print sys.version

If you get an invalid syntax error, you've probably got Python3. That requires parentheses around what to print, so try:

(gdb) python print(sys.version)

When that comes back with a 3.x.x answer, Qt Creator's Python debugging scripts won't work (yet). So you'll need to get a GDB with Python2.

Here's my blog entry about it: QtCreator Debugger Not Showing Locals in Ubuntu 13.10.

like image 24
HostileFork says dont trust SE Avatar answered Oct 13 '22 00:10

HostileFork says dont trust SE