Author Topic: std::vector debugging improvement  (Read 4026 times)

ghorwin

  • Guest
std::vector debugging improvement
« on: October 03, 2006, 01:38:39 am »
Hi there,

since the debugger plugin and the scripts currently work only with GDB anyway, I created a modified version of the StlVector gdb script that does not require usage of the member functions size() and begin() but uses the internal data structure of the std::vector itself. Here is the snipped from the gdb_types.script:

Code: cpp
    local result = _T("output ") + a_str + oper + _T("_M_impl._M_end_of_storage == ") + a_str + oper + _T("_M_impl._M_start") 
      + _T(" ? \"empty\" : ")
      + _T("((") + t + _T("*)") + a_str + oper + _T("_M_impl._M_start)")
      + _T("[") + start + _T("]@");
    if (count != 0)
        result = result + count;
    else
        result = result + _T("(") + a_str + oper + _T("_M_impl._M_finish - ") + a_str + oper + _T("_M_impl._M_start") + _T(" - ") + start + _T(")");

The whole thing isn't perfect, but works for me. Problem is, if the internal std::vector implementation should change in future versions of GDB, this script has to be adjusted. Anyway, at least anyone working with g++ shouldn't have any problems anylonger, even if the member functions size() and begin() haven't been used in the source code.

Still, the script doesn't do range checking, but could be added as well.

Btw, a quick request: please remove the "start" index limitation (currently set to max=100) in the Add/edit watch dialog.

Andreas