Author Topic: FYI: GDB has a big bug to support MinGW GCC (4.7.x and later)  (Read 6613 times)

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
FYI: GDB has a big bug to support MinGW GCC (4.7.x and later)
« on: October 05, 2013, 04:39:48 pm »
I just noticed that GDB has this bug: (the reasons are also shown in this bug report)
Bug 15559 – Method call and calling convention

This prevent you using a "inferior call" on the GDB, such as "p v[0]" or "p v.size()".

Test sample code below:
Code
#include <string>
#include <vector>

int fff()
{
    return 3;
}

int main()
{
    std::vector<std::string> v;
    v.push_back("a");
    v.push_back("b");
    std::string abc = v[0];
    abc.c_str();
    abc.size();
    int i = v.size();
    i++;
    i = fff();
    return 0;      
}

If you set a breakpoint in the "return 0" line, then you try to see watch some values like "v[0]" or "v[1]", also you can enter "p abc.size()", "p abc.c_str()", "p v[0]", you will get wrong result or error in GDB.

GCC 4.6.x and earlier version don't cause such issue.
« Last Edit: October 09, 2013, 04:17:50 am by ollydbg »
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: FYI: GDB has a big bug to support MinGW GCC (4.7.x and later)
« Reply #1 on: October 09, 2013, 03:15:24 am »
I have post a new release for MinGW GDB to fix this issue, see: [OT] unofficial MinGW GDB gdb with python released.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.