hello everybody
i'm having some strange behaviour when trying to watch some specific variables in codeblocks and GDB in Linux
to be honest, i didn't even knew in which forum post this :(
I have this code in C++ and SFML (a lib):
#include <SFML/Graphics.hpp>
int main(){
int a = 0;
sf::VertexArray v(sf::Quads, 88);
int b = 0;
return 0;
}
this runs fine and I can debug it and watch variables. BUT if I change the VertexArray to 89, when I start the debugger and try to open the watches window, the whole system freezes. not even the mouse or keyboard respond, and I have to hard reset. if I dont open the watches window, it runs ok.
this is what VertexArray looks like (its simple, actually): https://www.sfml-dev.org/documentation/2.5.1/classsf_1_1VertexArray.php
OS: Linux Debian 64 Testing with Cinnamon
C::B is
Name : Code::Blocks
Version : 20.03-r11997
SDK Version : 2.0.0
Scintilla Version: 3.7.5
gcc (Debian 9.3.0-15) 9.3.0
GNU gdb (Debian 9.2-1) 9.2
i tried rebuilding the whole project, doing make/install to the SFML files again, updating the system, reinstalling code::blocks and GDB, but the problem persists. if idebug it in command line, nothing seems to freeze and I can close the application.
any help ins this case is appreciated. thanks in advance :)
unfortunately no... i could only get a smaller class that causes the problem, sf::Color
#include <SFML/Graphics.hpp>
#include <vector>
int main(){
int a = 0;
std::vector<sf::Color> v(200);
int b = 0;
return 0;
}
https://www.sfml-dev.org/documentation/2.5.1/Color_8hpp_source.php
https://www.sfml-dev.org/documentation/2.5.1/Graphics_2Export_8hpp_source.php
https://www.sfml-dev.org/documentation/2.5.1/Config_8hpp_source.php
right, I actually trimmed the results directly from the source code, which is avaliable at github: https://github.com/SFML/SFML
this is the simplest I could get to, and if i set a breakpoint at line 25, it freezes the whole system while trying to watch local variables:
typedef unsigned char Uint8;
class Color{
public:
Color();
Color(Uint8 red, Uint8 green, Uint8 blue, Uint8 alpha = 255);
static const Color Black; ///< Black predefined color
static const Color White; ///< White predefined color
static const Color Red; ///< Red predefined color
static const Color Green; ///< Green predefined color
static const Color Blue; ///< Blue predefined color
static const Color Yellow; ///< Yellow predefined color
Uint8 r; ///< Red component
Uint8 g; ///< Green component
Uint8 b; ///< Blue component
Uint8 a; ///< Alpha (opacity) component
};
#include <vector>
int main(){
int a = 0;
std::vector<Color> v(2);
int b = 0;
return 0;
}
const Color Color::Black(0, 0, 0);
const Color Color::White(255, 255, 255);
const Color Color::Red(255, 0, 0);
const Color Color::Green(0, 255, 0);
const Color Color::Blue(0, 0, 255);
const Color Color::Yellow(255, 255, 0);
Color::Color() : r(0), g(0), b(0), a(255) {
}
Color::Color(Uint8 red, Uint8 green, Uint8 blue, Uint8 alpha) : r(red), g(green), b(blue), a(alpha) {
}
for some reason, if I remove one of the predefined colors, it works. now i'm thinking this may be a GDB problem, as running the same code in this site (https://www.onlinegdb.com/online_c++_compiler/) also makes the application unresponsive
yeah, it really looks like an infinite recursion :( does that mean i'm not able to watch static members then?
well, maybe it is temporary...
my GDB is version 9.2-1, I think that there isn't a newer one.
adding set print static-members off
to 'Debugger initialization commands' in Settings->Debugger->GDB/CDG debugger->Default did the trick. thanks for the help.
gdb 9.2 on gentoo, works just fine with your example.
This is how the gdb output looks like:
{static Black = {static Black = <same as static member of an already seen type>, static ...