简体   繁体   English

gdb和makefile

[英]gdb and makefile

hello everyone i try to debug a program, which have been installed by makefile. 大家好我试着调试一个已经由makefile安装的程序。 it have a binary file of OpenDPI_demo.o and a shell shellscript OpenDPI_demo. 它有一个OpenDPI_demo.o的二进制文件和一个shell shellscript OpenDPI_demo。 when i gdb OpenDPI_demo.o,i have a problem. 当我gdb OpenDPI_demo.o,我有一个问题。 i can't run it. 我无法运行它。 the error is: 错误是:

Starting program: /home/lx/ntop/test/opendpi/src/examples/OpenDPI_demo/OpenDPI_demo.o 
/bin/bash: /home/lx/ntop/test/opendpi/src/examples/OpenDPI_demo/OpenDPI_demo.o:can't execute the binary file.

please tell me why. 请告诉我为什么。 actually i can run the program by ./OpenDPI_demo. 实际上我可以通过./OpenDPI_demo来运行程序。 thank you. 谢谢。

Based on the extension, the file is an object file . 根据扩展名,该文件是一个目标文件 It is used by the linker (alongside other object files) to produce an executable. 链接器(以及其他对象文件)使用它来生成可执行文件。 It's the real executable the one you want to run/debug. 它是您想要运行/调试的真正可执行文件。

Suggest you use 建议你使用

gdb OpenDPI_demo

instead 代替

In your makefile if it depens on the object, make it depend on OpenDPI_demo, eg 在makefile中,如果它依赖于对象,则使其依赖于OpenDPI_demo,例如

This is another example of difficulties encountered with programs using libtool. 这是使用libtool的程序遇到的困难的另一个例子。

the file OpenDPI_demo alongside OpenDPI_demo.o is actually, as you said, a shell script which wraps the execution of the real compiled file, probably in .libs/OpenDPI_demo . 实际上, OpenDPI_demoOpenDPI_demo.o文件实际上是一个shell脚本,它包含了真实编译文件的执行,可能是在.libs/OpenDPI_demo

libtool needs this wrapper to adjust the runtime library paths and such so that you can execute the program transparently, as if it was actually installed on your system. libtool需要这个包装器来调整运行时库路径等,以便您可以透明地执行程序,就好像它实际安装在您的系统上一样。

The way to correctly debug this application is not 正确调试此应用程序的方法不是

/home/lx/ntop/test/opendpi $ gdb src/examples/OpenDPI_demo/.libs/OpenDPI_demo

but rather using libtool --mode=execute on the shell script, like the following (it's an example): 而是在shell脚本上使用libtool --mode=execute ,如下所示(这是一个例子):

/home/lx/ntop/test/opendpi $ ./libtool --mode=execute gdb --args \
  src/examples/OpenDPI_demo/OpenDPI_demo -f capture.pcap

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM