为什么我在 gdb 回溯中看不到行号?

Why I cannot see line numbers in gdb backtrace?

我在 gdb 中看不到行号。我用 mpiicc 编译了所有带有 -g 标志的东西。

对于我来说,即使是断点,gdb 也不显示行号。

可能是 "Missing separate debuginfos, use: debuginfo-install glibc-2.12-1.166.el6_7.7.x86_64 numactl-2.0.9-2.el6.x86_64" 的问题,但我不是超级用户,所以我无法安装这些。

 gdb  --args ./central -g 5 51
GNU gdb (GDB) Red Hat Enterprise Linux (7.2-83.el6)
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/dslavchev/NuclearTesting/MPI/project-a-test-mpi/central...done.
(gdb) break direct.c:55
Breakpoint 1 at 0x40855d: file direct.c, line 55.
(gdb) l direct.c:55
50  
51  void direct(int* N, double **PA, Coord **points)
52  {
53      int     i ,j ,k ,l, ir, irr,
54              md = suma(N , NUM_AIRFOILS) - NUM_AIRFOILS,
55              m;
56      double  *D, // **D,
57              *A, *sv;
58  
59      int matrix_size_D = md*md;
(gdb) r
Starting program: /home/dslavchev/NuclearTesting/MPI/project-a-test-mpi/central -g 5 51
[Thread debugging using libthread_db enabled]

Breakpoint 1, 0x000000000040855d in direct ()
Missing separate debuginfos, use: debuginfo-install glibc-2.12-1.166.el6_7.7.x86_64 numactl-2.0.9-2.el6.x86_64
(gdb) bt
#0  0x000000000040855d in direct ()
#1  0x0000000000405ee9 in main ()
(gdb) s
Single stepping until exit from function direct,
which has no line number information.
PMPI_Comm_size (comm=1140850688, size=0x7fffffffc240) at ../../src/mpi/comm/comm_size.c:57
57  ../../src/mpi/comm/comm_size.c: No such file or directory.
    in ../../src/mpi/comm/comm_size.c
(gdb) s
65  in ../../src/mpi/comm/comm_size.c
(gdb) s
57  in ../../src/mpi/comm/comm_size.c
(gdb) 
58  in ../../src/mpi/comm/comm_size.c
(gdb) 
59  in ../../src/mpi/comm/comm_size.c
(gdb) 
65  in ../../src/mpi/comm/comm_size.c
(gdb) 

这里还有构建命令:

mpiicc -g -c -o central.o central.c -qopenmp 
mpiicc -g -c -o contours.o contours.c -qopenmp 
mpiicc -g -c -o mymath.o mymath.c -qopenmp 
mpiicc -g -c -o vort.o vort.c -qopenmp 
mpiicc -g -qopenmp   -I/opt/intel/parallel_studio_xe_2017.2.050/compilers_and_libraries_2017/linux/mkl/include -c -o  direct.o direct.c 
mpiicc -g -c -o a_liftarg.o a_liftarg.c -qopenmp 
mpiicc -g -c -o psavel.o psavel.c -qopenmp 
mpiicc -g -c -o euler.o euler.c -qopenmp 
mpiicc -g -c -o streamline.o streamline.c -qopenmp 
mpiicc -g -c -o speedmap.o speedmap.c -qopenmp 
mpiicc -g -o central central.o contours.o mymath.o vort.o direct.o a_liftarg.o psavel.o euler.o streamline.o speedmap.o /opt/intel/parallel_studio_xe_2017.2.050/compilers_and_libraries_2017/linux/mkl/lib/intel64/libmkl_scalapack_lp64.a -Wl,--start-group /opt/intel/parallel_studio_xe_2017.2.050/compilers_and_libraries_2017/linux/mkl/lib/intel64/libmkl_intel_lp64.a /opt/intel/parallel_studio_xe_2017.2.050/compilers_and_libraries_2017/linux/mkl/lib/intel64/libmkl_intel_thread.a /opt/intel/parallel_studio_xe_2017.2.050/compilers_and_libraries_2017/linux/mkl/lib/intel64/libmkl_core.a /opt/intel/parallel_studio_xe_2017.2.050/compilers_and_libraries_2017/linux/mkl/lib/intel64/libmkl_blacs_intelmpi_lp64.a -Wl,--end-group -liomp5 -lpthread -lm -ldl -qopenmp

尝试添加标志

-debug expr-source-pos

应该加上线路信息

https://software.intel.com/en-us/cpp-compiler-developer-guide-and-reference-debug-linux-and-macos

May be the problem is

否:问题不在于(maindirect 均未在 libc 中定义)。

这似乎是GDB中的一个错误:在你执行run之前,它清楚地知道地址0x40855d对应于direct.c, line 55

但在 run 之后,它以某种方式忘记了它知道这一点。

你的 GDB 版本也有 9 年了。作为第一步,我建议构建一个当前版本 (8.3 as of today)。