简体   繁体   中英

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/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. 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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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