~ubuntu-branches/ubuntu/raring/codeblocks/raring-proposed

« back to all changes in this revision

Viewing changes to src/scripts/gdb_types.script

  • Committer: Bazaar Package Importer
  • Author(s): Cosme Domínguez Díaz
  • Date: 2010-08-09 04:38:38 UTC
  • mfrom: (1.1.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: james.westby@ubuntu.com-20100809043838-a59ygguym4eg0jgw
Tags: 10.05-0ubuntu1
* New upstream release. Closes (LP: #322350)
 - Switch to dpkg-source 3.0 (quilt) format
 - Remove unneeded README.source
 - Add debian/get-source-orig script that removes all
   Windows prebuilt binaries
* Bump Standards-Version to 3.9.1
 - Stop shipping *.la files
* debian/control
 - Add cdbs package as Build-Depend
 - Add libbz2-dev and zlib1g-dev packages as
   Build-Depends (needed by libhelp_plugin.so)
 - Remove dpatch package of Build-Depends
 - Add codeblocks-contrib-debug package
 - Split architecture-independent files of codeblocks
   package in codeblocks-common package
* debian/rules
 - Switch to CDBS rules system
 - Add parallel build support
 - Add a call to debian/get-source-orig script
 - Use lzma compression (saves 23,5 MB of free space)
* debian/patches
 - Refresh 01_codeblocks_plugin_path
 - Add 02_no_Makefiles_in_debian_dir to remove any link
   in codeblocks build system to deleted Makefiles of debian directory
 - Drop 02_ftbfs_gcc44 and 03_ftbfs_glib221 (merged in upstream)
* debian/watch
 - Update to use the new host (berlios.de)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
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
4
 
 *
5
 
 * $Revision: 4909 $
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 $
8
 
 */
9
 
 
10
 
// Registers new types with driver
11
 
function RegisterTypes(driver)
12
 
{
13
 
//    signature:
14
 
//    driver.RegisterType(type_name, regex, eval_func, parse_func);
15
 
 
16
 
    // wxString
17
 
    driver.RegisterType(
18
 
        _T("wxString"),
19
 
        _T("[^[:alnum:]_]*wxString[^[:alnum:]_]*"),
20
 
        _T("Evaluate_wxString"),
21
 
        _T("Parse_wxString")
22
 
    );
23
 
 
24
 
    // STL String
25
 
    driver.RegisterType(
26
 
        _T("STL String"),
27
 
        _T("[^[:alnum:]_]*string[^[:alnum:]_]*"),
28
 
        _T("Evaluate_StlString"),
29
 
        _T("Parse_StlString")
30
 
    );
31
 
 
32
 
    // STL Vector
33
 
    driver.RegisterType(
34
 
        _T("STL Vector"),
35
 
        _T("[^[:alnum:]_]*vector<.*"),
36
 
        _T("Evaluate_StlVector"),
37
 
        _T("Parse_StlVector")
38
 
    );
39
 
}
40
 
 
41
 
////////////////////////////////////////////////////////////////////////////////
42
 
// wxString
43
 
////////////////////////////////////////////////////////////////////////////////
44
 
 
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)
51
 
{
52
 
    local oper = _T(".");
53
 
 
54
 
    if (type.Find(_T("*"), false) > 0)
55
 
        oper = _T("->");
56
 
 
57
 
    local result = _T("output /c ") + a_str + oper + _T("m_pchData[") + start + _T("]@");
58
 
    if (count != 0)
59
 
        result = result + count;
60
 
    else
61
 
        result = result + _T("((wxStringData*)") + a_str + oper + _T("m_pchData - 1)->nDataLength");
62
 
    return result;
63
 
}
64
 
 
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)
68
 
{
69
 
    local result = _T("\"");
70
 
    local len = a_str.length();
71
 
    local c = 0;
72
 
    while (c < len)
73
 
    {
74
 
        switch (a_str.GetChar(c))
75
 
        {
76
 
            case '\'':
77
 
                ++c;
78
 
                while (c < len)
79
 
                {
80
 
                    switch (a_str.GetChar(c))
81
 
                    {
82
 
                        case '\\':
83
 
                            result.AddChar(a_str.GetChar(c++));
84
 
                            result.AddChar(a_str.GetChar(c++));
85
 
                            break;
86
 
                        default:
87
 
                            result.AddChar(a_str.GetChar(c++));
88
 
                            break;
89
 
                    }
90
 
                    if (a_str.GetChar(c) == '\'')
91
 
                        break;
92
 
                }
93
 
                break;
94
 
 
95
 
            default:
96
 
                break;
97
 
        }
98
 
        ++c;
99
 
    }
100
 
    result = result + _T("\"");
101
 
    return result;
102
 
}
103
 
 
104
 
////////////////////////////////////////////////////////////////////////////////
105
 
// STL String
106
 
////////////////////////////////////////////////////////////////////////////////
107
 
 
108
 
function Evaluate_StlString(type, a_str, start, count)
109
 
{
110
 
    local oper = _T(".");
111
 
 
112
 
    if (type.Find(_T("*"), false) > 0)
113
 
        oper = _T("->");
114
 
 
115
 
    local result = _T("output ") + a_str + oper + _T("c_str()[") + start + _T("]@");
116
 
    if (count != 0)
117
 
        result = result + count;
118
 
    else
119
 
        result = result + a_str + oper + _T("size()");
120
 
    return result;
121
 
}
122
 
 
123
 
function Parse_StlString(a_str, start)
124
 
{
125
 
    // nothing needs to be done
126
 
    return a_str;
127
 
}
128
 
 
129
 
////////////////////////////////////////////////////////////////////////////////
130
 
// STL Vector
131
 
////////////////////////////////////////////////////////////////////////////////
132
 
 
133
 
function Evaluate_StlVector(type, a_str, start, count)
134
 
{
135
 
    local oper = _T(".");
136
 
 
137
 
    if (type.Find(_T("*"), false) > 0)
138
 
        oper = _T("->");
139
 
 
140
 
    local t = type.AfterFirst('<').BeforeFirst(',');
141
 
    local result = _T("output ((") + t + _T("*)") + a_str + oper + _T("begin())[") + start + _T("]@");
142
 
    if (count != 0)
143
 
        result = result + count;
144
 
    else
145
 
        result = result + a_str + oper + _T("size() - ") + start;
146
 
    return result;
147
 
}
148
 
 
149
 
function Parse_StlVector(a_str, start)
150
 
{
151
 
    // add [] indexes in front of each value
152
 
    local len = a_str.length();
153
 
    local c = 0;
154
 
    local index = start;
155
 
    local result = _T("");
156
 
    while (c < len)
157
 
    {
158
 
        local char = a_str.GetChar(c);
159
 
        result.AddChar(char);
160
 
        switch (char)
161
 
        {
162
 
            case '{':
163
 
            case ',':
164
 
                result = result + _T("[") + (index++) + _T("] = ");
165
 
                break;
166
 
            default: break;
167
 
        }
168
 
        ++c;
169
 
    }
170
 
    return result;
171
 
}
 
1
/*
 
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
 
4
 *
 
5
 * $Revision: 5783 $
 
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 $
 
8
 */
 
9
 
 
10
// Registers new types with driver
 
11
function RegisterTypes(driver)
 
12
{
 
13
//    signature:
 
14
//    driver.RegisterType(type_name, regex, eval_func, parse_func);
 
15
 
 
16
    // wxString
 
17
    driver.RegisterType(
 
18
        _T("wxString"),
 
19
        _T("[^[:alnum:]_]*wxString[^[:alnum:]_]*"),
 
20
        _T("Evaluate_wxString"),
 
21
        _T("Parse_wxString")
 
22
    );
 
23
 
 
24
    // STL String
 
25
    driver.RegisterType(
 
26
        _T("STL String"),
 
27
        _T("[^[:alnum:]_]*string[^[:alnum:]_]*"),
 
28
        _T("Evaluate_StlString"),
 
29
        _T("Parse_StlString")
 
30
    );
 
31
 
 
32
    // STL Vector
 
33
    driver.RegisterType(
 
34
        _T("STL Vector"),
 
35
        _T("[^[:alnum:]_]*vector<.*"),
 
36
        _T("Evaluate_StlVector"),
 
37
        _T("Parse_StlVector")
 
38
    );
 
39
 
 
40
    Log(_T("Registering types for the debugger."));
 
41
}
 
42
 
 
43
////////////////////////////////////////////////////////////////////////////////
 
44
// wxString
 
45
////////////////////////////////////////////////////////////////////////////////
 
46
 
 
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)
 
53
{
 
54
    local oper = _T(".");
 
55
 
 
56
    if (type.Find(_T("*"), false) > 0)
 
57
        oper = _T("->");
 
58
 
 
59
    local result = _T("output /c ") + a_str + oper + _T("m_pchData[") + start + _T("]@");
 
60
    if (count != 0)
 
61
        result = result + count;
 
62
    else
 
63
        result = result + _T("((wxStringData*)") + a_str + oper + _T("m_pchData - 1)->nDataLength");
 
64
    return result;
 
65
}
 
66
 
 
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)
 
70
{
 
71
    local result = _T("\"");
 
72
    local len = a_str.length();
 
73
    local c = 0;
 
74
    while (c < len)
 
75
    {
 
76
        switch (a_str.GetChar(c))
 
77
        {
 
78
            case '\'':
 
79
                ++c;
 
80
                while (c < len)
 
81
                {
 
82
                    switch (a_str.GetChar(c))
 
83
                    {
 
84
                        case '\\':
 
85
                            result.AddChar(a_str.GetChar(c++));
 
86
                            result.AddChar(a_str.GetChar(c++));
 
87
                            break;
 
88
                        default:
 
89
                            result.AddChar(a_str.GetChar(c++));
 
90
                            break;
 
91
                    }
 
92
                    if (a_str.GetChar(c) == '\'')
 
93
                        break;
 
94
                }
 
95
                break;
 
96
 
 
97
            default:
 
98
                break;
 
99
        }
 
100
        ++c;
 
101
    }
 
102
    result = result + _T("\"");
 
103
    return result;
 
104
}
 
105
 
 
106
////////////////////////////////////////////////////////////////////////////////
 
107
// STL String
 
108
////////////////////////////////////////////////////////////////////////////////
 
109
 
 
110
function Evaluate_StlString(type, a_str, start, count)
 
111
{
 
112
    local oper = _T(".");
 
113
 
 
114
    if (type.Find(_T("*"), false) > 0)
 
115
        oper = _T("->");
 
116
 
 
117
    local result = _T("output ") + a_str + oper + _T("c_str()[") + start + _T("]@");
 
118
    if (count != 0)
 
119
        result = result + count;
 
120
    else
 
121
        result = result + a_str + oper + _T("size()");
 
122
    return result;
 
123
}
 
124
 
 
125
function Parse_StlString(a_str, start)
 
126
{
 
127
    // nothing needs to be done
 
128
    return a_str;
 
129
}
 
130
 
 
131
////////////////////////////////////////////////////////////////////////////////
 
132
// STL Vector
 
133
////////////////////////////////////////////////////////////////////////////////
 
134
 
 
135
function Evaluate_StlVector(type, a_str, start, count)
 
136
{
 
137
    local result = _T("pvector ") + a_str;
 
138
    return result;
 
139
}
 
140
 
 
141
function Parse_StlVector(a_str, start)
 
142
{
 
143
    local size_pos = a_str.Find(_T("Vector size = "));
 
144
 
 
145
    if (size_pos < 0)
 
146
        return _T("");
 
147
 
 
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);
 
150
    size_pos = 0;
 
151
 
 
152
    local capacity_pos = vector_info_str.Find(_T("Vector capacity = "));
 
153
    if (capacity_pos < 0)
 
154
        return _T("");
 
155
 
 
156
    local size_value = vector_info_str.Mid(14, capacity_pos - 15);
 
157
    local size = wxString_ToLong(size_value);
 
158
 
 
159
    local capacity_end_pos = vector_info_str.Find(_T("Element"));
 
160
    if(capacity_end_pos < 0)
 
161
        return _T("");
 
162
    capacity_pos += 18;
 
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);
 
166
 
 
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;
 
170
 
 
171
    if(size > 0)
 
172
        result += _T(",\n");
 
173
 
 
174
    local value_str = a_str;
 
175
    for(local item = 0; item < size; item += 1)
 
176
    {
 
177
        local elem_str = _T("elem[") + item + _T("]: ");
 
178
        local elem_start = value_str.Find(elem_str);
 
179
        local elem_end = 0;
 
180
        if(item == size - 1)
 
181
            elem_end = value_str.Find(_T("Vector size"));
 
182
        else
 
183
            elem_end = value_str.Find(_T("elem[") + (item + 1) + _T("]: "));
 
184
 
 
185
        if(elem_start >= 0 && elem_end >= 0)
 
186
        {
 
187
            local elem_value = value_str.Mid(elem_start, elem_end - elem_start);
 
188
            local equal_pos = elem_value.Find(_T(" = "));
 
189
            if(equal_pos >= 0)
 
190
                elem_value.Remove(0, equal_pos + 3);
 
191
            if(item > 0)
 
192
                result += _T(",");
 
193
            result += _T("[") + item + _T("] = ") + elem_value + _T("\n");
 
194
        }
 
195
        else
 
196
            break;
 
197
 
 
198
        value_str.Remove(0, elem_end);
 
199
    }
 
200
    if(result.length() > 0)
 
201
    {
 
202
        return _T("{ " ) + result + _T(" } ");
 
203
    }
 
204
    return "";
 
205
}