2
* This file is part of the Code::Blocks IDE and licensed under the GNU General Public License, version 3
3
* http://www.gnu.org/licenses/gpl-3.0.html
6
* $Id: gdb_types.script 4909 2008-02-27 13:15:26Z mortenmacfly $
7
* $HeadURL: svn://svn.berlios.de/codeblocks/tags/8.02/src/scripts/gdb_types.script $
10
// Registers new types with driver
11
function RegisterTypes(driver)
14
// driver.RegisterType(type_name, regex, eval_func, parse_func);
19
_T("[^[:alnum:]_]*wxString[^[:alnum:]_]*"),
20
_T("Evaluate_wxString"),
27
_T("[^[:alnum:]_]*string[^[:alnum:]_]*"),
28
_T("Evaluate_StlString"),
35
_T("[^[:alnum:]_]*vector<.*"),
36
_T("Evaluate_StlVector"),
41
////////////////////////////////////////////////////////////////////////////////
43
////////////////////////////////////////////////////////////////////////////////
45
// This function tells the driver how to evaluate this type.
46
// a_str contains the variable.
47
// start contains the starting position. Useful for arrays.
48
// count contains the count of evaluation. Useful for arrays. If 0, evaluate from start (variable) to end of array.
49
// result must contain the debugger's command when it returns.
50
function Evaluate_wxString(type, a_str, start, count)
54
if (type.Find(_T("*"), false) > 0)
57
local result = _T("output /c ") + a_str + oper + _T("m_pchData[") + start + _T("]@");
59
result = result + count;
61
result = result + _T("((wxStringData*)") + a_str + oper + _T("m_pchData - 1)->nDataLength");
65
// This function parses driver's output.
66
// When it returns, the _T("result") argument contains the parsing result.
67
function Parse_wxString(a_str, start)
69
local result = _T("\"");
70
local len = a_str.length();
74
switch (a_str.GetChar(c))
80
switch (a_str.GetChar(c))
83
result.AddChar(a_str.GetChar(c++));
84
result.AddChar(a_str.GetChar(c++));
87
result.AddChar(a_str.GetChar(c++));
90
if (a_str.GetChar(c) == '\'')
100
result = result + _T("\"");
104
////////////////////////////////////////////////////////////////////////////////
106
////////////////////////////////////////////////////////////////////////////////
108
function Evaluate_StlString(type, a_str, start, count)
110
local oper = _T(".");
112
if (type.Find(_T("*"), false) > 0)
115
local result = _T("output ") + a_str + oper + _T("c_str()[") + start + _T("]@");
117
result = result + count;
119
result = result + a_str + oper + _T("size()");
123
function Parse_StlString(a_str, start)
125
// nothing needs to be done
129
////////////////////////////////////////////////////////////////////////////////
131
////////////////////////////////////////////////////////////////////////////////
133
function Evaluate_StlVector(type, a_str, start, count)
135
local oper = _T(".");
137
if (type.Find(_T("*"), false) > 0)
140
local t = type.AfterFirst('<').BeforeFirst(',');
141
local result = _T("output ((") + t + _T("*)") + a_str + oper + _T("begin())[") + start + _T("]@");
143
result = result + count;
145
result = result + a_str + oper + _T("size() - ") + start;
149
function Parse_StlVector(a_str, start)
151
// add [] indexes in front of each value
152
local len = a_str.length();
155
local result = _T("");
158
local char = a_str.GetChar(c);
159
result.AddChar(char);
164
result = result + _T("[") + (index++) + _T("] = ");
2
* This file is part of the Code::Blocks IDE and licensed under the GNU General Public License, version 3
3
* http://www.gnu.org/licenses/gpl-3.0.html
6
* $Id: gdb_types.script 5783 2009-09-14 15:17:56Z mortenmacfly $
7
* $HeadURL: svn+ssh://jenslody@svn.berlios.de/svnroot/repos/codeblocks/trunk/src/scripts/gdb_types.script $
10
// Registers new types with driver
11
function RegisterTypes(driver)
14
// driver.RegisterType(type_name, regex, eval_func, parse_func);
19
_T("[^[:alnum:]_]*wxString[^[:alnum:]_]*"),
20
_T("Evaluate_wxString"),
27
_T("[^[:alnum:]_]*string[^[:alnum:]_]*"),
28
_T("Evaluate_StlString"),
35
_T("[^[:alnum:]_]*vector<.*"),
36
_T("Evaluate_StlVector"),
40
Log(_T("Registering types for the debugger."));
43
////////////////////////////////////////////////////////////////////////////////
45
////////////////////////////////////////////////////////////////////////////////
47
// This function tells the driver how to evaluate this type.
48
// a_str contains the variable.
49
// start contains the starting position. Useful for arrays.
50
// count contains the count of evaluation. Useful for arrays. If 0, evaluate from start (variable) to end of array.
51
// result must contain the debugger's command when it returns.
52
function Evaluate_wxString(type, a_str, start, count)
56
if (type.Find(_T("*"), false) > 0)
59
local result = _T("output /c ") + a_str + oper + _T("m_pchData[") + start + _T("]@");
61
result = result + count;
63
result = result + _T("((wxStringData*)") + a_str + oper + _T("m_pchData - 1)->nDataLength");
67
// This function parses driver's output.
68
// When it returns, the _T("result") argument contains the parsing result.
69
function Parse_wxString(a_str, start)
71
local result = _T("\"");
72
local len = a_str.length();
76
switch (a_str.GetChar(c))
82
switch (a_str.GetChar(c))
85
result.AddChar(a_str.GetChar(c++));
86
result.AddChar(a_str.GetChar(c++));
89
result.AddChar(a_str.GetChar(c++));
92
if (a_str.GetChar(c) == '\'')
102
result = result + _T("\"");
106
////////////////////////////////////////////////////////////////////////////////
108
////////////////////////////////////////////////////////////////////////////////
110
function Evaluate_StlString(type, a_str, start, count)
112
local oper = _T(".");
114
if (type.Find(_T("*"), false) > 0)
117
local result = _T("output ") + a_str + oper + _T("c_str()[") + start + _T("]@");
119
result = result + count;
121
result = result + a_str + oper + _T("size()");
125
function Parse_StlString(a_str, start)
127
// nothing needs to be done
131
////////////////////////////////////////////////////////////////////////////////
133
////////////////////////////////////////////////////////////////////////////////
135
function Evaluate_StlVector(type, a_str, start, count)
137
local result = _T("pvector ") + a_str;
141
function Parse_StlVector(a_str, start)
143
local size_pos = a_str.Find(_T("Vector size = "));
148
// copy the end of the a_str, so we don't search the whole string when we look for capacity
149
local vector_info_str = a_str.Mid(size_pos, a_str.length() - size_pos);
152
local capacity_pos = vector_info_str.Find(_T("Vector capacity = "));
153
if (capacity_pos < 0)
156
local size_value = vector_info_str.Mid(14, capacity_pos - 15);
157
local size = wxString_ToLong(size_value);
159
local capacity_end_pos = vector_info_str.Find(_T("Element"));
160
if(capacity_end_pos < 0)
163
local capacity_value = vector_info_str.Mid(capacity_pos, capacity_end_pos - capacity_pos - 1);
164
local element_type_value = vector_info_str.Mid(capacity_end_pos + 15,
165
vector_info_str.length() - capacity_end_pos - 15);
167
local result = _T("[size] = ") + size_value + _T(",\n");
168
result += _T("[capacity] = ") + capacity_value + _T(",\n");
169
result += _T("[element type] = ") + element_type_value;
174
local value_str = a_str;
175
for(local item = 0; item < size; item += 1)
177
local elem_str = _T("elem[") + item + _T("]: ");
178
local elem_start = value_str.Find(elem_str);
181
elem_end = value_str.Find(_T("Vector size"));
183
elem_end = value_str.Find(_T("elem[") + (item + 1) + _T("]: "));
185
if(elem_start >= 0 && elem_end >= 0)
187
local elem_value = value_str.Mid(elem_start, elem_end - elem_start);
188
local equal_pos = elem_value.Find(_T(" = "));
190
elem_value.Remove(0, equal_pos + 3);
193
result += _T("[") + item + _T("] = ") + elem_value + _T("\n");
198
value_str.Remove(0, elem_end);
200
if(result.length() > 0)
202
return _T("{ " ) + result + _T(" } ");