|
From: asmwarrior <asm...@gm...> - 2011-12-02 03:46:30
|
Hi, gdb developers.
When debugger with python pretty printer, I sometimes get the gdb crash
when I try to show the value of uninitialized local variables. As you
know, an uninitialized local variable can contain some random value, so
the pretty printer try to interpret those values, and can cause the gdb
to an long loop or crash.
The patch is just a work-around/hack to handle this problem.
I just first check if the symbol is a local variable, and then check the
current line SAL is smaller than the variable's declaration line. If
true, which means this local variable is OK to show, if not, than I just
skip it.
The first patch try to deal with the "info locals" problem, the local
variable defined later than the current line will be skipped.
The second patch try to skip/filter the same local variables.
For example:
void fun()
{
wxString *psty = (wxString*) NULL;
wxString wxStr(L"wxString");
wxStr += L" Value";
std::string stdStr("std::string");
stdStr.append(" value");
std::map<int, std::string> m;
m[0] = "000";
m[1] = "111"; //break point here, we stop here
wxString& wxStrRef = wxStr;
wxStrRef += L" Ref";
std::string& stdStrRef = stdStr;
stdStrRef += " Ref";
std::list<std::string> l = {"a", "b", "c"};
std::vector<std::string> v = {"a", "b", "c"};
std::queue<std::string> q;
q.push("a");
q.push("b");
std::stack<std::string> s;
s.push("a");
s.push("b");
}
Now, you have stopped on the breakpoint. the local variable "l,v,q" is
after the breakpoint line.
If you try to run "print v", or "info locals", then gdb will crash (I'm
using gdb cvs build under WindowsXP, mingw, python 2.7)
I believe that this patch will not be applied, because it is just a
hack, right?
I just also CC to mingw maillist hope they have some interests.
Basically, gdb should alive with out any crash in any condition, but
sometimes, I think a workaround is also necessary. I have see that in
QTcreator, when they want to show the contents of a stl container, it do
many sanity check. like:
The length of the std::vector should be positive, and it's size should
be limited.
Also many other sanity checks
asmwarrior
ollydbg from codeblocks forum
|