How to Debug OpenSSL with Eclipse


In the OpenSSL source directory, execute the following command:

$ ./config --debug --prefix=/tmp/openssl -Wl,--enable-new-dtags,-rpath,'$(LIBRPATH)'

--debug: compiles in debug mode

--prefix=/tmp/openssl: sets the install directory. You need to set this flag in order for the compiled openssl to link with the compiled libraries libcrypto and libssl (which are part of openssl)

-Wl,--enable-new-dtags,-rpath,'$(LIBRPATH)': same reason as --prefix, this is to make sure that the compiled openssl links with the compiled libraries libcrypto and libssl.

Then, compile OpenSSL:

$ make

Finally, install OpenSSL:

$ make install

Make sure that openssl loads and that you just compiled:

$ ldd /tmp/openssl/bin/openssl (0x00007ffc32241000) => /tmp/openssl/lib/ (0x00007f7acf5ac000) => /tmp/openssl/lib/ (0x00007f7acf0ad000) => /lib64/ (0x00007f7aceea9000) => /lib64/ (0x00007f7acec8a000) => /lib64/ (0x00007f7ace8a5000)
	/lib64/ (0x00007f7acf851000) binds to /tmp/openssl/lib/ (not the system library /lib64/ and binds to /tmp/openssl/lib/ (not the system library /lib64/



Make sure that you have Eclipse CDT.


In the main menu, select File | New | Project:

Choose Makefile Project with Existing Code:

Click on Browse… and go to your OpenSSL source directory. Then, choose your toolchain for the indexer. Finally, click Finish.


Go to Run | Debug Configurations:

Create a new “C/C++ Application” configuration. Choose your OpenSSL project (openssl) and C/C++ Application (apps/openssl):

Set the arguments in the arguments tab (genrsa) and click on Debug:

Eclipse should now have started openssl and paused at the first line of the main:

You can now debug OpenSSL with Eclipse!