Compiling source code for debugging (KDevelop/cmake)
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Compiling source code for debugging (KDevelop/cmake)
Hi all,
I want to make a small improvement to the Krdc source code.
For that I want to debug the code.
However after building the binary file, gdb krdc,
setting a breakpoint and make the breakpoint being triggered... I step through the code and I want to use the print function to see the value of an integer.
I get the message:
<Value optimized out>
After a short search I noticed this is due to optimizations in the compilation code and the debugger not being able to read the value out.
I am using gentoo so I know about the -O option.
I created the project in KDevelop as a "Debug" project.
I changed some flags in the "Open Options", "Advanced settings" to use -O0.
CMAKE_CXX_FLAGS
CMAKE_CXX_FLAGS_DEBUG
CMAKE_C_FLAGS
CMAKE_C_FLAGS_DEBUG
...
Even then I still get the same issue.
DOes someone know what I should do? (I am not experienced with debugging and programming)
Thanks in advance!
You may need to do a make clean after changing the flags to force the object files to be recompiled with the new optimization settings. You may need to recompile the libraries used by the program as well.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.