~ubuntu-branches/ubuntu/trusty/codeblocks/trusty-proposed

« back to all changes in this revision

Viewing changes to src/plugins/debuggergdb/debugger_defs.cpp

  • Committer: Package Import Robot
  • Author(s): Vincent Cheng
  • Date: 2013-05-06 00:20:02 UTC
  • mfrom: (6.1.2 experimental)
  • Revision ID: package-import@ubuntu.com-20130506002002-ngc7bwkewnak8fja
Tags: 12.11-3
* Upload to unstable.
* Update watch file, thanks to Bart Martens.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 * This file is part of the Code::Blocks IDE and licensed under the GNU General Public License, version 3
3
3
 * http://www.gnu.org/licenses/gpl-3.0.html
4
4
 *
5
 
 * $Revision: 6104 $
6
 
 * $Id: debugger_defs.cpp 6104 2010-01-23 12:56:12Z mortenmacfly $
7
 
 * $HeadURL: svn+ssh://jenslody@svn.berlios.de/svnroot/repos/codeblocks/trunk/src/plugins/debuggergdb/debugger_defs.cpp $
 
5
 * $Revision$
 
6
 * $Id$
 
7
 * $HeadURL$
8
8
 */
9
9
 
10
10
#include "sdk.h"
16
16
#include <wx/frame.h>
17
17
#include "manager.h"
18
18
#endif
 
19
#include <cbdebugger_interfaces.h>
19
20
#include "debugger_defs.h"
20
21
#include "debuggerdriver.h"
21
 
#include "debuggertree.h"
22
22
 
23
23
#include <wx/arrimpl.cpp>
24
 
WX_DEFINE_OBJARRAY(WatchesArray);
 
24
 
 
25
#if !defined(CB_TEST_PROJECT)
25
26
 
26
27
const int DEBUGGER_CURSOR_CHANGED = wxNewId();
27
28
const int DEBUGGER_SHOW_FILE_LINE = wxNewId();
39
40
        m_pDriver->Log(output);
40
41
}
41
42
 
42
 
DbgCmd_UpdateWatchesTree::DbgCmd_UpdateWatchesTree(DebuggerDriver* driver, DebuggerTree* tree)
43
 
    : DebuggerCmd(driver),
44
 
    m_pTree(tree)
 
43
DbgCmd_UpdateWatchesTree::DbgCmd_UpdateWatchesTree(DebuggerDriver* driver)
 
44
    : DebuggerCmd(driver)
45
45
{
46
46
}
47
47
 
48
48
void DbgCmd_UpdateWatchesTree::Action()
49
49
{
50
 
    m_pTree->EndUpdateTree();
 
50
    Manager::Get()->GetDebuggerManager()->GetWatchesDialog()->UpdateWatches();
51
51
}
52
52
 
53
53
// Custom window to display output of DebuggerInfoCmd
75
75
    DebuggerInfoWindow win(Manager::Get()->GetAppWindow(), m_Title, output);
76
76
    win.ShowModal();
77
77
}
 
78
 
 
79
#endif // !defined(CB_TEST_PROJECT)
 
80
 
 
81
void DebuggerBreakpoint::SetEnabled(bool flag)
 
82
{
 
83
    enabled = flag;
 
84
}
 
85
 
 
86
wxString DebuggerBreakpoint::GetLocation() const
 
87
{
 
88
    switch (type)
 
89
    {
 
90
        case bptData:
 
91
            return breakAddress;
 
92
        case bptCode:
 
93
            return filenameAsPassed;
 
94
        case bptFunction:
 
95
            return func;
 
96
        default:
 
97
            return _("Unknown");
 
98
    }
 
99
}
 
100
 
 
101
int DebuggerBreakpoint::GetLine() const
 
102
{
 
103
    return line;
 
104
}
 
105
 
 
106
wxString DebuggerBreakpoint::GetLineString() const
 
107
{
 
108
    return (type == bptCode) ? wxString::Format(wxT("%d"), line) : wxString(wxEmptyString);
 
109
}
 
110
 
 
111
wxString DebuggerBreakpoint::GetType() const
 
112
{
 
113
    switch (type)
 
114
    {
 
115
        case bptData:
 
116
            return _("Data");
 
117
        case bptCode:
 
118
            return _("Code");
 
119
        case bptFunction:
 
120
            return _("Function");
 
121
        default:
 
122
            return _("Unknown");
 
123
    }
 
124
}
 
125
 
 
126
wxString DebuggerBreakpoint::GetInfo() const
 
127
{
 
128
    switch (type)
 
129
    {
 
130
        case bptData:
 
131
            if (breakOnRead && breakOnWrite)
 
132
                return  _("type: read-write");
 
133
            else if (breakOnRead)
 
134
                return _("type: read");
 
135
            else if (breakOnWrite)
 
136
                return _("type: write");
 
137
            else
 
138
                return _("type: unknown");
 
139
        case bptCode:
 
140
        {
 
141
            wxString s;
 
142
            if (useCondition)
 
143
                s += _("condition: ") + condition;
 
144
            if (useIgnoreCount)
 
145
            {
 
146
                if (!s.empty())
 
147
                    s += wxT(" ");
 
148
                s += wxString::Format(_("ignore count: %d"), ignoreCount);
 
149
            }
 
150
            if (temporary)
 
151
            {
 
152
                if (!s.empty())
 
153
                    s += wxT(" ");
 
154
                s += _("temporary");
 
155
            }
 
156
            s += wxString::Format(wxT(" (index: %ld)"), index);
 
157
            return s;
 
158
        }
 
159
        case bptFunction:
 
160
        default:
 
161
            return wxEmptyString;
 
162
    }
 
163
}
 
164
 
 
165
bool DebuggerBreakpoint::IsEnabled() const
 
166
{
 
167
    return enabled;
 
168
}
 
169
 
 
170
bool DebuggerBreakpoint::IsVisibleInEditor() const
 
171
{
 
172
    return type == bptCode;
 
173
}
 
174
 
 
175
bool DebuggerBreakpoint::IsTemporary() const
 
176
{
 
177
    return temporary;
 
178
}
 
179
 
 
180
 
 
181
GDBWatch::GDBWatch(wxString const &symbol) :
 
182
    m_symbol(symbol),
 
183
    m_format(Undefined),
 
184
    m_array_start(0),
 
185
    m_array_count(0),
 
186
    m_is_array(false),
 
187
    m_forTooltip(false)
 
188
{
 
189
}
 
190
GDBWatch::~GDBWatch()
 
191
{
 
192
}
 
193
void GDBWatch::GetSymbol(wxString &symbol) const
 
194
{
 
195
    symbol = m_symbol;
 
196
}
 
197
void GDBWatch::GetValue(wxString &value) const
 
198
{
 
199
    value = m_raw_value;
 
200
}
 
201
bool GDBWatch::SetValue(const wxString &value)
 
202
{
 
203
    if(m_raw_value != value)
 
204
    {
 
205
        MarkAsChanged(true);
 
206
        m_raw_value = value;
 
207
    }
 
208
    return true;
 
209
}
 
210
void GDBWatch::GetFullWatchString(wxString &full_watch) const
 
211
{
 
212
    cb::shared_ptr<const cbWatch> parent = GetParent();
 
213
    if (parent)
 
214
    {
 
215
        parent->GetFullWatchString(full_watch);
 
216
        full_watch += wxT(".") + m_symbol;
 
217
    }
 
218
    else
 
219
        full_watch = m_symbol;
 
220
}
 
221
 
 
222
void GDBWatch::GetType(wxString &type) const
 
223
{
 
224
    type = m_type;
 
225
}
 
226
void GDBWatch::SetType(const wxString &type)
 
227
{
 
228
    m_type = type;
 
229
}
 
230
 
 
231
wxString const & GDBWatch::GetDebugString() const
 
232
{
 
233
    return m_debug_value;
 
234
}
 
235
void GDBWatch::SetDebugValue(wxString const &value)
 
236
{
 
237
    m_debug_value = value;
 
238
}
 
239
 
 
240
void GDBWatch::SetSymbol(const wxString& symbol)
 
241
{
 
242
    m_symbol = symbol;
 
243
}
 
244
 
 
245
void GDBWatch::DoDestroy()
 
246
{
 
247
    delete this;
 
248
}
 
249
 
 
250
void GDBWatch::SetFormat(WatchFormat format)
 
251
{
 
252
    m_format = format;
 
253
}
 
254
 
 
255
WatchFormat GDBWatch::GetFormat() const
 
256
{
 
257
    return m_format;
 
258
}
 
259
 
 
260
void GDBWatch::SetArray(bool flag)
 
261
{
 
262
    m_is_array = flag;
 
263
}
 
264
 
 
265
bool GDBWatch::IsArray() const
 
266
{
 
267
    return m_is_array;
 
268
}
 
269
 
 
270
void GDBWatch::SetArrayParams(int start, int count)
 
271
{
 
272
    m_array_start = start;
 
273
    m_array_count = count;
 
274
}
 
275
 
 
276
int GDBWatch::GetArrayStart() const
 
277
{
 
278
    return m_array_start;
 
279
}
 
280
 
 
281
int GDBWatch::GetArrayCount() const
 
282
{
 
283
    return m_array_count;
 
284
}
 
285
 
 
286
void GDBWatch::SetForTooltip(bool flag)
 
287
{
 
288
    m_forTooltip = flag;
 
289
}
 
290
 
 
291
bool GDBWatch::GetForTooltip() const
 
292
{
 
293
    return m_forTooltip;
 
294
}
 
295
 
 
296
bool IsPointerType(wxString type)
 
297
{
 
298
    type.Trim(true);
 
299
    type.Trim(false);
 
300
 
 
301
    if (type.Contains(wxT("char *")) || type.Contains(wxT("char const *")))
 
302
        return false;
 
303
    else if (type.EndsWith(wxT("*")))
 
304
        return true;
 
305
    else if (type.EndsWith(wxT("* const")))
 
306
        return true;
 
307
    else if (type.EndsWith(wxT("* volatile")))
 
308
        return true;
 
309
    return false;
 
310
}
 
311
 
 
312
// Use this function to sanitize user input which might end as the last part of GDB commands.
 
313
// If the last character is '\', GDB will treat it as line continuation and it will stall.
 
314
wxString CleanStringValue(wxString value)
 
315
{
 
316
    while (value.EndsWith(wxT("\\")))
 
317
        value.RemoveLast();
 
318
    return value;
 
319
}
 
320