Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - HelbMePlease

Pages: [1]
1
General / Problem with debugging in VSCode+gdb
« on: July 31, 2023, 09:35:56 pm »
Hey everyone,
I used the CMake Tools VSCode extension to set up a debugging environment (I hardly did anything) using the gcc kit. It was all going fine until I tried to inspect the contents of a vector and it shows empty even though I know (almost for certain) it isn't. Here's the relevant code:
void squares(std::vector<sf::RectangleShape> &squares_vec)
{
    for (size_t i = 0; i < 81; i++)
    {
        sf::Color grey(140,140,140);
        sf::Color gainsboro_grey(207,208,207);
        sf::RectangleShape square(sf::Vector2f(70,70));
        square.setFillColor(gainsboro_grey);
        square.setOutlineColor(grey);
        square.setOutlineThickness(3);
        squares_vec.push_back(square);
    }
    std::cout<<"Number of squares in vec: "<<squares_vec.size()<<std::endl;
    place_squares(squares_vec);        
}
 
The std::cout prints 81 squares in vec (as intended) so everything in that function seems okay  but I need the debugger to be working well to debug the subsequent function ( place_squares() ) which is not working okay. What I mean by the debugger is telling me the vector is empty is that is what it shows in the VSCode debugging GUI on the left panel of VSCode, which I am using. Below are some more documents you may find useful.

CMakeLists.txt:

Quote

#This CMakeLists.txt is a frankenstein mixture between what CMake Tools auto generates and some changes I made based on
#this Example CMake script (so it would link the libraries): https://en.sfml-dev.org/forums/index.php?topic=24070.0

cmake_minimum_required(VERSION 3.0.0)
project(sfml-app VERSION 0.1.0 LANGUAGES C CXX)

include(CTest)
enable_testing()

find_package(SFML 2.5 COMPONENTS graphics audio REQUIRED)
add_executable(sfml-app main.cpp)
target_link_libraries(sfml-app sfml-graphics sfml-audio)

set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
set(SFML_DIR "<sfml root prefix>/lib/cmake/SFML")
include(CPack)

cmake_minimum_required(VERSION 3.1)

project(SFMLTest)

## If you want to link SFML statically
# set(SFML_STATIC_LIBRARIES TRUE)

## In most cases better set in the CMake cache


compile_commands.json:

Quote
[
{
  "directory": "/home/dudefellaman/Desktop/SFML Code/Sudoku/build",
  "command": "/usr/bin/g++   -g -o CMakeFiles/sfml-app.dir/main.cpp.o -c \"/home/dudefellaman/Desktop/SFML Code/Sudoku/main.cpp\"",
  "file": "/home/dudefellaman/Desktop/SFML Code/Sudoku/main.cpp"
}
]

If you need anymore info, ask away!

Pages: [1]