How can I completely disable .pdb generation in CMake for MSVC when building a DLL? I need C/C++ -> General -> Debug Information Format set to None and Linker -> Debugging -> Generate Debug Info set to None . As far as I know that just means omit any flags for both, how can I set this?
Related
I realize a question with the exact title has already been answered, but the steps there requires running the compiler and linker manually, whereas I want to use cmake.
I am trying to debug a C program with WinDbg. But I'm getting this error:
*** WARNING: Unable to verify checksum for main.exe
Reading a mailing list thread1, I'm guessing I need to add a few flags, namely '/Zi' and '/Release'. But I'm building my project with cmake, and I don't know how to add those flags properly so that I can build my program using GNU toolchain with debug symbols too.
My CMakeLists.txt:
cmake_minimum_required(VERSION 3.00)
project(Hello LANGUAGES C)
add_executable(main src/main.c)
With the above cmake file, my program is built properly. Even a pdb file is generated, which is read by WinDbg no problem. But I can't see the line information with .lines and no source file is shown when debugging the EXE; only assembly commands are shown.
After the reading the mail thread (mentioned above), I checked the checksum value of my EXE. It's zero. Now I need to know how to set up a cmake file so it produces EXE with debug symbols with proper checksum.
The checksum-verification warning turned out not to be the issue (it was just a warning after all, not an error). WinDbg didn't load line information. Either it's the default (although I don't know why that would be) or I mistakenly turned it off myself. Whatever the case, here is how you turn it on:
.lines -e
After that, WinDbg was able to bring up the source window by its own accord when I started debugging.
When I attach to process with GDB I saw that warning:
Reading symbols from /CloneFileSystem/lib/ld-uClibc.so.0...
(No debugging symbols found in /CloneFileSystem/lib/ld-uClibc.so.0)
warning: Unable to find dynamic linker breakpoint function.
GDB will be unable to debug shared library initializers
and track explicitly loaded dynamic code.
Even I use set sysroot /CloneFileSystem with all the libraries there, that not help.
My process call to function in shared library and that function call to another function in another shared library.
For example ProcessFunc-> Lib1Func -> Lib2Func
I want to debug Lib2Func but when I run command
b Lib2Func
gdb can't set a breakpoint there event that library is already loaded
file myexe -> interpreter /lib/ld-uClibc.so.0
When I use info sharedlibrary in GDB I can't the value in From and To (address of loaded are empty)
You might want to try recompiling the library with a -g option. It's saying it can't find the debug info. -g provides for debugging info if you are using gcc. This is the first thing i'd check. If the library is big this may take awhile.
When running the executable in the debugger, I don't see any meaningful stacktrace for the shared library -- but only the address of the function and the path of the shared library.
This applies to cmake version 3.7.2.
CMake does not strip your debug symbols by default.
You need to compile your shared libs with proper debug options, e.g.
cmake -DCMAKE_BUILD_TYPE=Debug ..
Or you can modify your CMakeLists.txt to add the debug flags.
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wall")
Edit
CMake is a build scripting tool, itself does not do stripping on your binary, but you can ask it to help with this if you want. See my other post here: Android NDK path variable for **strip** command in CMake build tool chain
Below lines will do symbol stripping if you want to let CMake to strip your debug symbols.
add_custom_command(TARGET ${SHARED_LIBRARY_NAME} POST_BUILD
COMMAND "<path-to-your-bin>/strip" -g -S -d --strip-debug --verbose
"<path-to-your-lib>/lib${SHARED_LIBRARY_NAME}.so"
COMMENT "strip debug symbols done on final binary.")
For the warnings, you can choose to have it or not, doesn't really matter.
Get back to the question and clarify further, in order to have debug symbols, you need to build your binary in DEBUG or RelWithDebInfo build type by typing below cmake command.
cmake -DCMAKE_BUILD_TYPE=Debug ..
or
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo ..
If you are building C source code (not the cpp which I assumed), then you can check the corresponding CMAKE_C_FLAGS.
See the official document from here: https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html
I have created a shared library with Code::Blocks under Linux and now I need to update it to a newer version and I want/need to increment its version.
If I were to use command line I would use a parameter like -Wl soname my_lib.so.2.0.1 but cannot find how to do it under Code:Blocks IDE
Any ideas/help?
thnx
In your project Build options -> Linker settings -> Other linker options
enter, e.g.
-Wl,-soname=my_lib.so.2.0.1
Then OK out and build.
i had a problem in my native android application saying libc: Fatal signal 7 (SIGBUS) at 0x66f0001d (code=1), thread 30165 (xample.fft_test)
which i think is a memory problem on the device(nexus 4).
So, i tried to debug the application to know the source of this problem.
In eclipse, i get warning: Could not load shared library symbols for 94 libraries, e.g. /system/bin/linker.
Use the "info sharedlibrary" command to see the complete listing.
Do you need "set solib-search-path" or "set sysroot"?
warning: Unable to find dynamic linker breakpoint function.
GDB will retry eventurally. Meanwhile, it is likely
that GDB is unable to debug shared library initializers
or resolve pending breakpoints after dlopen().
what does that mean?
here's also the output of the allocation tracker in eclipse:
If your application.mk has flags:
APP_STL := gnustl_static
APP_OPTIM := debug
You have a problem with the compilation´s flags.
The warning means those libraries have not compiled with debug flags, and then, you have not debug info so you cannot debug. Maybe you can stop in breakpoints and follow step by step, but you cannot read in real time the value of the variables.
So, to solve the problem, you must re-compile the libraries that you want to read variables with debug information flags. In Cmake I usually use flag -d or -gdwarf-4 to crosscompile in Android.
I had the same issue and I solved it by using another phone.
I tested on a lot of phones. Finally, I find out that debug NDK on Nexus 6 is ok.
So I think maybe the issue is that the support for debugging NDK was removed on some phones.