1

I'm using Visual Studio Code on Ubuntu 18.04 to write some C++ code using external libraries. I'm not sure why, but whenever I run the debugger, the contents of most variables doesn't show.

I've attached an example of this issue.

Why is this happening?

Variables not showing

Edit:

cmake_minimum_required(VERSION 3.10.2)
project(Proj)

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_CXX_COMPILER /usr/bin/g++)

set(ARENA_DIR "~/Arena")

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CC "g++")
set(CFLAGS "-Wall -g -O2 -std=c++14 -Wno-unknown-pragmas")

add_definitions(${CFLAGS})

set(RM "rm -f")

include_directories(${ARENA_DIR}include/Arena)
include_directories(${ARENA_DIR}include/GenTL)
include_directories(${ARENA_DIR}include/Save)
include_directories(${ARENA_DIR}GenICam/library/CPP/include)


...


set(ARENA_DEBUG_LIBS
        ${ARENA_DIR}libarenad.so
        ${ARENA_DIR}libsaved.so
        ${ARENA_DIR}libgentld.so)

set(ARENA_RELEASE_LIBS
        ${ARENA_DIR}libarena.so
        ${ARENA_DIR}libsave.so
        ${ARENA_DIR}libgentl.so)

set(LIBS
        ${GENICAMLIBS}
        ${FFMPEGLIBS}
        "/usr/lib/x86_64-linux-gnu/libpthread.so")


add_executable(main main.cpp)
set_target_properties(main PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
target_link_libraries(main ${LIBS} debug ${ARENA_DEBUG_LIBS})
target_link_libraries(main ${LIBS} optimized ${ARENA_RELEASE_LIBS})

Edit 2:

After changing the g++ flag to -O0 instead of -O2, I get this result:

Variables

But I would expect to be able to see the object's properties.

TheTomer
  • 143
  • 3
  • 11
  • Do you have optimizations on? – ChrisMM Feb 19 '20 at 18:44
  • Are those external libraries compiled *with* debug symbols? If they are optimized builds the answer is probably "no". You could look into changing that, either by building debug/unoptimized versions with debug symbols, or optimized versions with debug symbols. – Jesper Juhl Feb 19 '20 at 18:46
  • "I've attached an example of this issue." - I'd argue that you have *not*. An example would be a [mcve] of your code + build instructions for the external libraries - enough to let us replicate your issue. A screenshot of some random output is *far* from that. – Jesper Juhl Feb 19 '20 at 18:49
  • @JesperJuhl my CMakeLists.txt file is somewhat long, that's why I didn't include it, but I'll update the post with snippets. according to [this](https://stackoverflow.com/questions/1999654/how-can-i-tell-if-a-library-was-compiled-with-g/39480660), when running either of the following lines, it seems that both the optimized and the debug lib objects contain symbols: readelf --debug-dump=decodedline libarena.so stl_tree.h 2292 0x24cfd ... lots of other lines... ... TLBase.cpp 73 0x27c40c – TheTomer Feb 20 '20 at 15:57
  • @ChrisMM apparently, but not intentionally... – TheTomer Feb 20 '20 at 16:03
  • 1
    Optimized builds often remove variables, even when debug symbols are included. The only way (that I know of) to get all the variables, is to use a non-optimized debug build (`-O0`, you are using `-O2`) – ChrisMM Feb 20 '20 at 16:08
  • @ChrisMM I tried changing it to -O0, it changed the variables details a bit, but I still don't get the desired results. I've posted a screenshot in the post. – TheTomer Feb 20 '20 at 17:49
  • What are `nodename` and `value`? It may not know how to display their contents? This is often an issue I see (full Visual Studio, not Code) with third party libraries which define a lot of their own classes with internal data. – ChrisMM Feb 20 '20 at 18:20
  • nodename and value are two instances of a class called GenICam_3_0::gcstring, which according to it's documentation is "A string class which is a clone of std::string". – TheTomer Feb 23 '20 at 12:31

0 Answers0