开发者

gdb and makefile

hello everyone i try to debug a program, which have been installed by makefile. it have a binary file of OpenDPI_demo.o and a shell shellscript OpenDPI_demo. when i gdb OpenDPI_demo.o,i have a problem. 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/open开发者_运维百科dpi/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. 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.


This is another example of difficulties encountered with programs using 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.

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.

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):

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


Suggest you use

gdb OpenDPI_demo

instead

In your makefile if it depens on the object, make it depend on OpenDPI_demo, e.g.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜