How to source debug external static or dynamic C library?
I am debugging a C application which is linking statically with a version of OpenSSL that I've built. Since I built the library, I have the source, and I want to be able to step into the OpenSSL functions during a debugging session. While linking with the library works fine, when I attempt to step into it, it steps over the function - it doesn't know where the source for that external is apparently.
I have built OpenSSL outside of CMake using typical OpenSSL build commands. I've built it with debug options on so all the symbols should be available. (./config -d) I built it with a --prefix of /opt/openssl-1.0.2l and the source lives within my user directory (~/Documents/openssl-1.0.2l) where I've done the build.
My CMakeLists.txt uses:
include_directories( /opt/openssl-1.0.2l )
to get to the header files. I'm using this to point the linker to the right place:
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L /opt/openssl-1.0.2l -lcrypto -lssl")
Everything is compiling and linking fine with OpenSSL. However...
I'm not seeing a way to link with an external library like OpenSSL and also point CLion to the source of the external library it's linking with. I need to be able to seamlessly step into the source of that external library which lives in my ~/Documents/openssl-1.0.2l directory.
I don't want to build OpenSSL directly with CLion along with my application. I should be able to link with it like I would normally, but need to point CLion to the source so I can step into the external library.
I would greatly appreciate someone pointing me in the right direction to be able to step debug into an external .a or .so if the source is available for that library.
Thank you,
Landon
Please sign in to leave a comment.
Hi!
It's strange since this should work if the library is built with debug info.
To investigate the issue we need some additional information. Please enable debug logging by entering #com.jetbrains.cidr.execution.debugger into Help | Debug Log Settings, reproduce the problem (the moment when you try step into the library) and send the idea.log (Help | Show Log in Finder) to our email (clion-support at jetbrains.com). Do not forget to disable debug logging after that. Please also send us your CMakeLists.txt file. Thanks in advance!
Same problem with CLion 2017.3.3.
I have OpenSSL installed with debug symbols ("openssl-dbgsym" Ubuntu package) and I'm trying to step into "i2d_X509" but CLion just steps over the function.
Now I will just send my idea.log and CMakeLists.txt to the provided email.
Edit: I managed to step into OpenSSL functions from CLion (although in a hacky way) as explained in https://stackoverflow.com/a/49039254/320594.