icpc debug info with Eigen library

两盒软妹~` 提交于 2019-12-12 03:03:32

问题


Eigen is a popular C++ library, but icpc seems to have a problem generating debugging info from code that uses Eigen. I'm using the compiler icpc version 13.1.1. I checked with both Eigen 3.2.8 and 3.1.3. It's going to be hard to recompile all the libraries I need with another compiler, so does anyone see a good solution to get Eigen to work with a debugger?

The problem is that variable values don't always get updated in the debugger. Here is main.cpp

#include "stdio.h"
#include "/home/mylogin/include/Eigen/Core"
using namespace std;
int main(int argc, char* argv[])
{
    printf("Starting main\n");
    double mytest = 3.0;
    // If the next line is commented out, the debugger works
    Eigen::Vector3d v(1,2,3);
    printf("This is mytest %f \n",mytest);
    return 0;
}

I compile with

icpc -O0 -debug -I/home/mylogin/include/ main.cpp

Then you can run the debugger

idbc ./a.out 
Intel(R) Debugger for applications running on Intel(R) 64, Version 13.0, Build [80.215.23]
------------------ 
object file name: ./a.out 
Reading symbols from /mnt/io1/home/mylogin/a.out...done.
(idb) break main
Breakpoint 1 at 0x4005fb: file     /mnt/io1/home/mylogin/main.cpp, line 142.
(idb) run
Starting program:     /mnt/io1/home/mylogin/a.out
[New Thread 18379 (LWP 18379)]
Breakpoint 1, main (argc=1, argv=0x7fff8b2e89b8) at /mnt/io1/home/mylogin/main.cpp:8
8               printf("Starting main\n");
(idb) next
Starting main
11              Eigen::Vector3d v(1,2,3);
(idb) next
12              printf("This is mytest %f \n",mytest);
(idb) next
This is mytest 3.000000 
13             return 0;
(idb) print mytest
$1 = 5.9415882155426741e-313

You see in the last few lines that the executable prints "3.0" correctly. You also see that the variable is not printed correctly by the debugger.

Both gdb and idbc show the problem. It doesn't seem to be because it's near the start or end of the function main(). The CPU is

Intel(R) Xeon(R) CPU E5-2650 0 @ 2.00GHz

Linux version is

Description:    Scientific Linux release 6.4 (Carbon)

Thanks for ideas!

来源:https://stackoverflow.com/questions/38205285/icpc-debug-info-with-eigen-library

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!