User forums > Using Code::Blocks
Any reasonable procedure for debugging with GDB?
ta0:
I have tried googling for an answer, but haven't found anything that didn't look very outdated.
What I want to do is simply to have sane debugging for C++ code, using MinGW under Windows. Almost every variable and function is inaccessible, the best I can get is the hex value of pointers.
Is there any tutorial or walk through on how to use GDB in a productive fashion for C++ code in Code::Blocks? As it is, I'm happy when I can even get to see the content of an std::string. Almost no matter what I put into the "watch" fields, I get an "Not available in current context!" or "<optimized out>". If I try to use the GDB console, it is always a bunch of "Couldn't find method std::istream::eof" this and "Cannot evaluate function -- may be inlined" that.
Of course I use -o0 -g3 -fno-inline, __attribute__ ((used, noinline)) on everything, etc. Rarely helps. (yes, I understand the difference between target and project options)
There is some talk in the wiki of squirrel scripting for making custom views of objects. However, it says (in a somewhat snarky way, I might add) that if you have to ask you ain't never gonna know, and that user scripts are planned to be implemented sometime in the future.
Other forum posts talks about using a python-enabled GDB, didn't get it.
To be honest, I've only ever used the basics of GDB, that was always enough for C code, and with Python it was never a problem. It still bothers me that we seem to be expected to program C++ with basicly no debugging support other than basic break points and prints. After having programmed dynamic languages for some years, where you generally the kind of debugging support you'd logically expect, the whole thing feels a bit retarded, because obviously you need a proper debugger much more desperately when doing the things that C++ is good for, such as bare metal coding. But googling for an answer, it really seems that people still in 2015 do C++ debugging with mere line breaks and vardumps.
ollydbg:
--- Quote from: ta0 on May 20, 2015, 03:50:14 am ---
Is there any tutorial or walk through on how to use GDB in a productive fashion for C++ code in Code::Blocks? As it is, I'm happy when I can even get to see the content of an std::string. Almost no matter what I put into the "watch" fields, I get an "Not available in current context!" or "<optimized out>". If I try to use the GDB console, it is always a bunch of "Couldn't find method std::istream::eof" this and "Cannot evaluate function -- may be inlined" that.
Of course I use -o0 -g3 -fno-inline, __attribute__ ((used, noinline)) on everything, etc. Rarely helps. (yes, I understand the difference between target and project options)
--- End quote ---
Can you give us a minimal example(test code and the debugger log) to demonstrate your issue, thanks.
ta0:
Ok, I'll condense it into a minimal example reproducing the problems.
Just a question though. It sounds from your reply that what I describe is not how it's supposed to work and that there must be some error somewhere, be it user errors, config errors or bugs. Is this correct? Because from my googling, it seems that my experience with debugging C++ code with GDB is the same as for most people and that eventually you are supposed to switch to Visual Studio if you want to do serious development.
What I would really want is a good explanation of how to use the debug scripting with C::B.
ollydbg:
--- Quote from: ta0 on May 20, 2015, 12:59:38 pm ---Ok, I'll condense it into a minimal example reproducing the problems.
Just a question though. It sounds from your reply that what I describe is not how it's supposed to work and that there must be some error somewhere, be it user errors, config errors or bugs. Is this correct? Because from my googling, it seems that my experience with debugging C++ code with GDB is the same as for most people and that eventually you are supposed to switch to Visual Studio if you want to do serious development.
--- End quote ---
GDB works OK here in my system(WinXP), so I have no idea what is your problem.
--- Quote ---What I would really want is a good explanation of how to use the debug scripting with C::B.
--- End quote ---
What do you mean by "debug scripting with C::B"? I use python pretty printer with GDB. I don't know much about other debug scripts.
oBFusCATed:
--- Quote from: ta0 on May 20, 2015, 12:59:38 pm ---Ok, I'll condense it into a minimal example reproducing the problems.
--- End quote ---
Basic debugging feature should work fine.
--- Quote from: ta0 on May 20, 2015, 12:59:38 pm ---... Because from my googling, it seems that my experience with debugging C++ code with GDB is the same as for most people and that eventually you are supposed to switch to Visual Studio if you want to do serious development.
--- End quote ---
If you're building all your code with mingw, then debugging should work fine.
If you're calling external libraries build with vc++, then it won't work, because gdb doesn't understand the debug info produced by vc++.
--- Quote from: ta0 on May 20, 2015, 12:59:38 pm ---What I would really want is a good explanation of how to use the debug scripting with C::B.
--- End quote ---
Just don't, they are outdated and broken. Their proper replacement are gdb python printer scripts.
But if I were you I'd first make simple variables show in the watches window correctly and then bother with the more complex ones.
Navigation
[0] Message Index
[#] Next page
Go to full version