Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why i must use libtool --mode==execute gdb wireshark to make it possible debugging wireshark

I am trying to view the source code of Wireshark to understand protocol analysis, but I found that when I just use gdb ./wireshark, when I press Ctrl+C and set a breakpoint, then type C, the process dies. I want to know what libtool does to make GDB debugging possible.

I've already read man libtool and it says libtool is a tool make it easy to use all kinds of .a or .o by a simple interface, but I don't know what the key is to make gdb wireshark possible with libtool.

like image 263
turing.huang Avatar asked Jun 15 '12 09:06

turing.huang


1 Answers

When you use libtool to build a program, it will handle all the difficulties and particularities of using shared libraries in your platform.

One of the difficulties is debugging, because when debugging you want to load shared libraries that are not installed in the system (they are just compiled). So when libtool builds an executable, it will move it into a hidden directory (.libs) and will usually place a script or similar with the same name where you can see it. This script will do all the magic to run the correct program with the correct libraries.

But, obviously you cannot debug a script with gdb! So, in order to pass the correct parameters to gdb for it to be able to debug the right program with the right libraries, you have to run the command:

$ libtool --mode=execute gdb ./wireshark

You can see what it does by running:

$ libtool --mode=execute echo ./wireshark

Just do not use the files from .libs directly: use always libtool or the wrapper scripts.

like image 63
rodrigo Avatar answered Sep 23 '22 20:09

rodrigo