User forums > General (but related to Code::Blocks)
[OT] unofficial MinGW GDB gdb with python released(2018-07-25)
ollydbg:
The description is in the old thread, see here: [OT] unofficial MinGW GDB gdb with python released, since that thread is locked, so I created a new thread. The download binary is here: gdb2018-07-25.zip(this zip file does not contains python2.7, so you have to install a python 2.7 on your system) or gdb2018-07-25-bundle-python27.zip(this zip file already contains a python2.7), the patches are also uploaded as gdb2018-07-25patches.zip.
I have explained why my personal build of 32bit gdb is suitable for debugging a C++ program, see this post.
The change log:
2018-08-02 for those who are lazy to download and install a python2.7. I have now a new package: gdb2018-07-25-bundle-python27.zip, see this post for more details.
2018-07-25 New build against GDB git master HEAD is uploaded, and the patches are also uploaded.
2017-10-06 I build the gdb-git master head against my own patches(the patches are still the same as the old ones). I use the new compiler: i686-5.4.0-release-posix-dwarf-rt_v5-rev0 which is from mingw-w64 site, and I use the latest zlib and expat library from their official site. The build instructions and how to use python (the gdb need a 32bit python 2.7 environment, you can download from https://www.python.org/downloads/). More details can be from the old thread [OT] unofficial MinGW GDB gdb with python released.
ollydbg:
FYI:
The new build gdb2018-07-25 version is out, the patches are also uploaded. Please try it. :)
BlueHazzard:
Does the mingw-64 gdb does not have python support?
ollydbg:
--- Quote from: BlueHazzard on July 25, 2018, 02:50:23 am ---Does the mingw-64 gdb does not have python support?
--- End quote ---
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.
--- Code: ---#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;
}
--- End code ---
Now, you can set a breakpoint at the line
--- Code: --- volume = Box1.getVolume();
--- End code ---
And you can type the command to modify the object, see the C::B log below:
--- Code: ---> 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}
--- End code ---
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
--- Code: ---// 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;
}
--- End code ---
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):
--- Code: ---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
--- End code ---
There are other issues my build gdb fixes. :)
I think without those patch, it is hard to debug a C++ program.
BlueHazzard:
Ok! Thank you for your writeup!
Navigation
[0] Message Index
[#] Next page
Go to full version