Does the mingw-64 gdb does not have python support?
The gdb supplied by mingw-w64 site
does have python support. But my personal build 32bit gdb has some special fixes which the they don't have.
The main issue the the "inferior call", for example, you have such code snippet.
#include <iostream>
using namespace std;
class Box {
public:
double length; // Length of a box
double breadth; // Breadth of a box
double height; // Height of a box
// Member functions declaration
double getVolume(void);
void setLength( double len );
void setBreadth( double bre );
void setHeight( double hei );
};
// Member functions definitions
double Box::getVolume(void) {
return length * breadth * height;
}
void Box::setLength( double len ) {
length = len;
}
void Box::setBreadth( double bre ) {
breadth = bre;
}
void Box::setHeight( double hei ) {
height = hei;
}
// Main function for the program
int main() {
Box Box1; // Declare Box1 of type Box
Box Box2; // Declare Box2 of type Box
double volume = 0.0; // Store the volume of a box here
// box 1 specification
Box1.setLength(6.0);
Box1.setBreadth(7.0);
Box1.setHeight(5.0);
// box 2 specification
Box2.setLength(12.0);
Box2.setBreadth(13.0);
Box2.setHeight(10.0);
// volume of box 1
volume = Box1.getVolume();
cout << "Volume of Box1 : " << volume <<endl;
// volume of box 2
volume = Box2.getVolume();
cout << "Volume of Box2 : " << volume <<endl;
return 0;
}
Now, you can set a breakpoint at the line
volume = Box1.getVolume();
And you can type the command to modify the object, see the C::B log below:
> p Box1.setLength(18.0)
[debug]> p Box1.setLength(18.0)
[debug]$1 = void
[debug]>>>>>>cb_gdb:
$1 = void
> p Box1
[debug]> p Box1
[debug]$2 = {length = 18, breadth = 7, height = 5}
[debug]>>>>>>cb_gdb:
$2 = {length = 18, breadth = 7, height = 5}
You see, the object can be modified by the inferior call, while if you use the vanilla 32bit GDB or mingw-w64's current GDB, the inferior call just get failed. I remember they use my patch some years ago, but in recent years, my patch was dropped by them, and I don't know why. This issue will happens when you try to run a member function of an object, such as if you want to call a function like std::string::length()
e.g
// string::length
#include <iostream>
#include <string>
int main ()
{
std::string str ("Test string");
std::cout << "The size of str is " << str.length() << " bytes.\n";
return 0;
}
Set a breakpoint at the return statement, if you type "p str.length()", you get wrong result (this is tested under msys2's 32bit mingw-w64 gdb):
Debugger name and version: GNU gdb (GDB) 8.0.1
Child process PID: 4848
At E:\msys2-32bit\test\test-gdb-cpp-call\main.cpp:9
> p str.length()
$1 = 4294873232
There are other issues my build gdb fixes.
I think without those patch, it is hard to debug a C++ program.