C代码在RHEL7中构建并部署在RHEL6中,gdb不工作

标签 c gdb proc rhel7 rhel6

我正在 RHEL7 中构建 ProC 代码并将其部署到 RHEL6 服务器。它工作正常,但我无法正确使用 gdb。它说 - “单步执行直到从函数退出,该函数没有行号信息。”

如果我部署在 RHEL7 服务器中,我不会看到此错误,并且我可以逐行执行 gdb。

当 gdb 在 RHEL6 中部署的应用程序中运行时:

$> gdb progname
GNU gdb (GDB) Red Hat Enterprise Linux (7.2-92.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 progname...done.
(gdb) b progname.c:main
Breakpoint 1 at 0x8048fe8
(gdb) run arguments
Starting program: progname argments
[Thread debugging using libthread_db enabled]

Breakpoint 1, 0x08048fe8 in main ()
Missing separate debuginfos, use: debuginfo-install glibc-2.12-1.212.el6.i686
(gdb) n
*Single stepping until exit from function main,
which has no line number information.*

当 gdb 在 RHEL7 部署的应用程序中运行时,我们将看到以下结果,这在 RHEL6 版本中也是预期的

 $> gdb progname
GNU gdb (GDB) Red Hat Enterprise Linux 7.6.1-100.el7_4.1
Copyright (C) 2013 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 progname...done.
(gdb) b progname.c:main
Breakpoint 1 at 0x8048ff1: file progname.c, line 87.
(gdb) run arguments
Starting program: progname arguments
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib64/libthread_db.so.1".

Breakpoint 1, main (argc=8, argv=0xffffbd14) at progname.c:87
87      progname.c: 
Missing separate debuginfos, use: debuginfo-install glibc-2.17-196.el7_4.2.i686 libgcc-4.8.5-16.el7_4.3.i686 libstdc++-4.8.5-16.el7_4.3.i686
(gdb) n
88      in /progname.c

最佳答案

I am building my ProC code in RHEL7 and deploying it to RHEL6 server.

这只在偶然情况下有效,并且随时可能崩溃。

I am not able to gdb properly

您在 RHEL6 上使用较旧的 GDB,它可能无法理解 RHEL7 编译器创建的一些调试信息。

您可以尝试在 RHEL6 上构建新版本的 GDB,并使用它。

关于C代码在RHEL7中构建并部署在RHEL6中,gdb不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56531310/

相关文章:

c - 如何为没有空字符的字符串计算 strlen?

GDB 初始化文件 .gdbinit 中的 Python 代码

linux - 两个 open/proc 条目的处理方式不同

linux -/proc/thread-self 的用途?

C lang exponential long double output (Mac OS, Xcode)

c - fork 和子/父进程

c - char * 指针可以指向什么(是不是像 void *)?

c - 了解 gdb 生成的程序集

gdb - 如何使用GDB远程串行协议(protocol)查询线程堆栈帧和局部变量?

ruby-on-rails - Ruby block 作为数组元素用于在 public_send 中展开