I've got a bit of a problem with debugging a C++ program using GDB.
When I use print object.member
, it doesn't always print the value of the variable correctly. Instead, it prints the value of one of the arguments to the function I'm debugging. And it doesn't change through the function, although I change the value of object.member
throughout.
And the thing is, the program is rather large and consists of several modules, with partially specialised templates and such, so I can't post it all here.
Now I tried to create a minimal testcase, but whatever simple I tried, I can't make it work. I mean, not work.
So all I can ask is, has anybody ever seen this behaviour in GDB, and have you found out what caused it and how to solve it?
There are question here about similar behaviour, but those amount to the program not being compiled properly (optimisation levels too high etc). I compiled it with -Wall -Wextra -pedantic -g -O0
, so that can't be it.
And the program runs fine; I can cout << object.member;
and that outputs the expected value, so I don't know what to try now.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…