How to make the “Locals and Expressions” debugging

2019-01-18 20:22发布

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.

3条回答
仙女界的扛把子
2楼-- · 2019-01-18 20:38

In my case, it was what HostileFork described: ubuntu 13.10 + Qt Creator 2.8

This bug has been fixed in Qt Creator 3, not yet released.

To solve this without recompiling GDB, just use the release candidate of Qt Creator 3.

There are builds available on Qt project website or a PPA (ppa:p12/qtcreator) with last git version but build is broken as of today.

查看更多
Melony?
3楼-- · 2019-01-18 20:46

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.

查看更多
Lonely孤独者°
4楼-- · 2019-01-18 20:49

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.

查看更多
登录 后发表回答