1

I found an old solution to this problem that suggested compiling with -gdwarf-2, but this solution does not or no longer work for me.

So, running ddd on a compiled file and then double clicking variables always results in the error no symbol <var> in current context

My program is this:

int main()
{
    for (int i = 0; i < 10; ++i)
    {

    }
}

the commands I used are these:

 g++ -g -O0 -gdwarf-2 test.cpp; ddd. ./a.out

Versions of the programs:

ddd: GNU DDD 3.3.12 (x86_64-pc-linux-gnu)
gdb: GNU gdb (Ubuntu 7.7.1-0ubuntu5~14.04.2) 7.7.1
gcc: gcc version 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04.3)

How can I make this work?

4

2 回答 2

1

为了打印/显示变量,它们必须在范围内,因此对于局部变量/参数,这意味着您必须在该范围内的断点处。

我可以通过使用示例程序启动 ddd 并立即尝试 print/display 来重现您遇到的错误i

一旦我for在行上设置断点并运行程序,我就可以按预期打印/显示它们。

我编译:

g++ -Wall -O0 -ggdb -o test.exe test.cpp

并运行 ddd

ddd ./test.exe

我有

GNU DDD 3.3.12 (x86_64-pc-linux-gnu)
GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.04) 7.11.1
gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.1)
于 2016-08-07T20:22:52.697 回答
0

您是否尝试从编译标志中删除 -gdwarf-2 ?在带有旧调试器的系统上使用新编译器时,我遇到了类似的问题。然后编译器使用的默认调试符号格式对于调试器来说太新了,我不得不让编译器使用旧格式。如果最近更新了调试器,这可能是相似的。

于 2016-08-07T19:20:37.250 回答