debuggeractions.cpp 10.2 KB
Newer Older
hjk's avatar
hjk committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact:  Qt Software Information (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file.  Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
**
**************************************************************************/

#include "debuggeractions.h"

32
33
34
#include <utils/qtcassert.h>
#include <utils/pathchooser.h>

35
#include <QtCore/QDebug>
36
#include <QtCore/QSettings>
37

hjk's avatar
hjk committed
38
#include <QtGui/QAction>
39
#include <QtGui/QActionGroup>
40
41
42
43
#include <QtGui/QAbstractButton>
#include <QtGui/QRadioButton>
#include <QtGui/QCheckBox>
#include <QtGui/QLineEdit>
hjk's avatar
hjk committed
44

45
using namespace Core::Utils;
hjk's avatar
hjk committed
46

47
48
namespace Debugger {
namespace Internal {
49

hjk's avatar
hjk committed
50
51
//////////////////////////////////////////////////////////////////////////
//
hjk's avatar
hjk committed
52
// DebuggerSettings
hjk's avatar
hjk committed
53
54
55
//
//////////////////////////////////////////////////////////////////////////

hjk's avatar
hjk committed
56
DebuggerSettings::DebuggerSettings(QObject *parent)
57
58
59
    : QObject(parent)
{}

hjk's avatar
hjk committed
60
DebuggerSettings::~DebuggerSettings()
hjk's avatar
hjk committed
61
{
62
63
64
    qDeleteAll(m_items);
}
    
65
void DebuggerSettings::insertItem(int code, SavedAction *item)
hjk's avatar
hjk committed
66
{
hjk's avatar
hjk committed
67
    QTC_ASSERT(!m_items.contains(code), qDebug() << code << item->toString(); return);
68
69
70
    m_items[code] = item;
}

hjk's avatar
hjk committed
71
void DebuggerSettings::readSettings(QSettings *settings)
72
{
73
    foreach (SavedAction *item, m_items)
74
75
76
        item->readSettings(settings);
}

hjk's avatar
hjk committed
77
void DebuggerSettings::writeSettings(QSettings *settings)
78
{
79
    foreach (SavedAction *item, m_items)
80
81
82
        item->writeSettings(settings);
}
   
83
SavedAction *DebuggerSettings::item(int code)
84
85
86
87
88
{
    QTC_ASSERT(m_items.value(code, 0), return 0);
    return m_items.value(code, 0);
}

hjk's avatar
hjk committed
89
QString DebuggerSettings::dump()
90
91
92
93
{
    QString out;
    QTextStream ts(&out);
    ts  << "Debugger settings: ";
94
    foreach (SavedAction *item, m_items)
95
96
97
98
        ts << "\n" << item->value().toString();
    return out;
}

99
DebuggerSettings *DebuggerSettings::instance()
100
{
hjk's avatar
hjk committed
101
    static DebuggerSettings *instance = 0;
102
103
104
    if (instance)
        return instance;

hjk's avatar
hjk committed
105
    instance = new DebuggerSettings;
106

107
    SavedAction *item = 0;
108

hjk's avatar
hjk committed
109
110
    item = new SavedAction(instance);
    instance->insertItem(SettingsDialog, item);
111
    item->setText(tr("Debugger properties..."));
hjk's avatar
hjk committed
112

113
114
115
    //
    // View
    //
116
    item = new SavedAction(instance);
hjk's avatar
hjk committed
117
    instance->insertItem(AdjustColumnWidths, item);
118
    item->setText(tr("Adjust column widths to contents"));
119

120
    item = new SavedAction(instance);
hjk's avatar
hjk committed
121
    instance->insertItem(AlwaysAdjustColumnWidths, item);
122
    item->setText(tr("Always adjust column widths to contents"));
123
    item->setCheckable(true);
124

125
126
127
    //
    // Locals & Watchers
    //
128
    item = new SavedAction(instance);
hjk's avatar
hjk committed
129
    instance->insertItem(WatchExpression, item);
130
    item->setTextPattern(tr("Watch expression \"%1\""));
131

132
    item = new SavedAction(instance);
hjk's avatar
hjk committed
133
    instance->insertItem(RemoveWatchExpression, item);
134
    item->setTextPattern(tr("Remove watch expression \"%1\""));
135

136
    item = new SavedAction(instance);
137
    instance->insertItem(WatchExpressionInWindow, item);
138
    item->setTextPattern(tr("Watch expression \"%1\" in separate window"));
139

140
    item = new SavedAction(instance);
141
    instance->insertItem(AssignValue, item);
142

hjk's avatar
hjk committed
143
144
145
    item = new SavedAction(instance);
    instance->insertItem(AssignType, item);

146
    item = new SavedAction(instance);
147
    instance->insertItem(ExpandItem, item);
148
    item->setText(tr("Expand item"));
149

150
    item = new SavedAction(instance);
151
    instance->insertItem(CollapseItem, item);
152
    item->setText(tr("Collapse item"));
153

154
    //
155
    // DebuggingHelper
156
    //
157
    item = new SavedAction(instance);
158
    instance->insertItem(UseDebuggingHelpers, item);
hjk's avatar
hjk committed
159
    item->setDefaultValue(true);
con's avatar
con committed
160
    item->setSettingsKey("DebugMode", "UseDebuggingHelper");
hjk's avatar
hjk committed
161
    item->setText(tr("Use debugging helper"));
hjk's avatar
hjk committed
162
163
164
165
    item->setCheckable(true);
    item->setDefaultValue(true);

    item = new SavedAction(instance);
166
167
    instance->insertItem(UseCustomDebuggingHelperLocation, item);
    item->setSettingsKey("DebugMode", "CustomDebuggingHelperLocation");
hjk's avatar
hjk committed
168
169
170
    item->setCheckable(true);

    item = new SavedAction(instance);
171
172
    instance->insertItem(CustomDebuggingHelperLocation, item);
    item->setSettingsKey("DebugMode", "CustomDebuggingHelperLocation");
173

174
    item = new SavedAction(instance);
175
176
    instance->insertItem(DebugDebuggingHelpers, item);
    item->setSettingsKey("DebugMode", "DebugDebuggingHelpers");
177
    item->setText(tr("Debug debugging helper"));
178
    item->setCheckable(true);
179

hjk's avatar
hjk committed
180

181
    item = new SavedAction(instance);
182
    item->setText(tr("Recheck debugging helper availability"));
183
    instance->insertItem(RecheckDebuggingHelpers, item);
hjk's avatar
hjk committed
184
185

    //
186
    // Breakpoints
hjk's avatar
hjk committed
187
    //
188
    item = new SavedAction(instance);
189
    item->setText(tr("Syncronize breakpoints"));
190
    instance->insertItem(SynchronizeBreakpoints, item);
hjk's avatar
hjk committed
191

192
193
194
195
196
197
198
    //
    // Registers
    //

    QActionGroup *registerFormatGroup = new QActionGroup(instance);
    registerFormatGroup->setExclusive(true);

199
    item = new SavedAction(instance);
200
    item->setText(tr("Hexadecimal"));
201
202
203
204
205
206
    item->setCheckable(true);
    item->setSettingsKey("DebugMode", "FormatHexadecimal");
    item->setChecked(true);
    instance->insertItem(FormatHexadecimal, item);
    registerFormatGroup->addAction(item);

207
    item = new SavedAction(instance);
208
    item->setText(tr("Decimal"));
209
210
211
212
213
    item->setCheckable(true);
    item->setSettingsKey("DebugMode", "FormatDecimal");
    instance->insertItem(FormatDecimal, item);
    registerFormatGroup->addAction(item);

214
    item = new SavedAction(instance);
215
    item->setText(tr("Octal"));
216
217
218
219
220
    item->setCheckable(true);
    item->setSettingsKey("DebugMode", "FormatOctal");
    instance->insertItem(FormatOctal, item);
    registerFormatGroup->addAction(item);

221
    item = new SavedAction(instance);
222
    item->setText(tr("Binary"));
223
224
225
226
227
    item->setCheckable(true);
    item->setSettingsKey("DebugMode", "FormatBinary");
    instance->insertItem(FormatBinary, item);
    registerFormatGroup->addAction(item);

228
    item = new SavedAction(instance);
229
    item->setText(tr("Raw"));
230
231
232
233
234
    item->setCheckable(true);
    item->setSettingsKey("DebugMode", "FormatRaw");
    instance->insertItem(FormatRaw, item);
    registerFormatGroup->addAction(item);

235
    item = new SavedAction(instance);
236
    item->setText(tr("Natural"));
237
238
239
240
241
    item->setCheckable(true);
    item->setSettingsKey("DebugMode", "FormatNatural");
    instance->insertItem(FormatNatural, item);
    registerFormatGroup->addAction(item);

242
243
244

    //
    // Settings
hjk's avatar
hjk committed
245
    //
246
    item = new SavedAction(instance);
247
    item->setSettingsKey("DebugMode", "Location");
hjk's avatar
hjk committed
248
    item->setDefaultValue("gdb");
249
    instance->insertItem(GdbLocation, item);
hjk's avatar
hjk committed
250

251
    item = new SavedAction(instance);
252
    item->setSettingsKey("DebugMode", "Environment");
253
    instance->insertItem(GdbEnvironment, item);
hjk's avatar
hjk committed
254

255
    item = new SavedAction(instance);
256
    item->setSettingsKey("DebugMode", "ScriptFile");
257
    instance->insertItem(GdbScriptFile, item);
258

259
    item = new SavedAction(instance);
260
    item->setSettingsKey("DebugMode", "AutoQuit");
261
    item->setText(tr("Automatically quit debugger"));
hjk's avatar
hjk committed
262
263
    item->setCheckable(true);
    instance->insertItem(AutoQuit, item);
264

265
    item = new SavedAction(instance);
266
    item->setSettingsKey("DebugMode", "UseToolTips");
267
    item->setText(tr("Use tooltips when debugging"));
hjk's avatar
hjk committed
268
    item->setCheckable(true);
269
    instance->insertItem(UseToolTips, item);
hjk's avatar
hjk committed
270

271
    item = new SavedAction(instance);
272
    item->setSettingsKey("DebugMode", "ListSourceFiles");
273
    item->setText(tr("List source files"));
274
    item->setCheckable(true);
275
    instance->insertItem(ListSourceFiles, item);
276

277
    item = new SavedAction(instance);
278
    item->setSettingsKey("DebugMode", "SkipKnownFrames");
279
    item->setText(tr("Skip known frames"));
hjk's avatar
hjk committed
280
    item->setCheckable(true);
281
    instance->insertItem(SkipKnownFrames, item);
282

283
    item = new SavedAction(instance);
284
    item->setSettingsKey("DebugMode", "AllPluginBreakpoints");
hjk's avatar
hjk committed
285
    item->setDefaultValue(true);
286
    instance->insertItem(AllPluginBreakpoints, item);
287

288
    item = new SavedAction(instance);
289
    item->setSettingsKey("DebugMode", "SelectedPluginBreakpoints");
290
    instance->insertItem(SelectedPluginBreakpoints, item);
291

292
    item = new SavedAction(instance);
293
    item->setSettingsKey("DebugMode", "NoPluginBreakpoints");
294
    instance->insertItem(NoPluginBreakpoints, item);
295

296
    item = new SavedAction(instance);
297
    item->setSettingsKey("DebugMode", "SelectedPluginBreakpointsPattern");
298
299
300
301
302
303
    instance->insertItem(SelectedPluginBreakpointsPattern, item);

    item = new SavedAction(instance);
    item->setSettingsKey("DebugMode", "MaximalStackDepth");
    item->setDefaultValue(20);
    instance->insertItem(MaximalStackDepth, item);
hjk's avatar
hjk committed
304

305
    item = new SavedAction(instance);
306
    item->setText(tr("Reload full stack"));
307
308
    instance->insertItem(ExpandStack, item);

309
    item = new SavedAction(instance);
310
    item->setText(tr("Execute line"));
311
312
    instance->insertItem(ExecuteCommand, item);

313
    return instance;
hjk's avatar
hjk committed
314
315
}

316
317
318
319
320
321
//////////////////////////////////////////////////////////////////////////
//
// DebuggerActions
//
//////////////////////////////////////////////////////////////////////////

322
SavedAction *theDebuggerAction(int code)
hjk's avatar
hjk committed
323
{
324
    return DebuggerSettings::instance()->item(code);
hjk's avatar
hjk committed
325
326
327
328
}

bool theDebuggerBoolSetting(int code)
{
329
    return DebuggerSettings::instance()->item(code)->value().toBool();
hjk's avatar
hjk committed
330
331
332
333
}

QString theDebuggerStringSetting(int code)
{
334
    return DebuggerSettings::instance()->item(code)->value().toString();
hjk's avatar
hjk committed
335
336
}

hjk's avatar
hjk committed
337
338
339
} // namespace Internal
} // namespace Debugger