1 /****************************************************************************
2 **
3 ** Copyright (C) 2016 The Qt Company Ltd.
4 ** Contact: https://www.qt.io/licensing/
5 **
6 ** This file is part of Qt Creator.
7 **
8 ** Commercial License Usage
9 ** Licensees holding valid commercial Qt licenses may use this file in
10 ** accordance with the commercial license agreement provided with the
11 ** Software or, alternatively, in accordance with the terms contained in
12 ** a written agreement between you and The Qt Company. For licensing terms
13 ** and conditions see https://www.qt.io/terms-conditions. For further
14 ** information use the contact form at https://www.qt.io/contact-us.
15 **
16 ** GNU General Public License Usage
17 ** Alternatively, this file may be used under the terms of the GNU
18 ** General Public License version 3 as published by the Free Software
19 ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
20 ** included in the packaging of this file. Please review the following
21 ** information to ensure the GNU General Public License requirements will
22 ** be met: https://www.gnu.org/licenses/gpl-3.0.html.
23 **
24 ****************************************************************************/
25 
26 #pragma once
27 
28 #include <QCoreApplication>
29 #include <QHash>
30 #include <QMap>
31 #include <QVector>
32 
33 #include <utils/aspects.h>
34 
35 namespace Debugger {
36 namespace Internal {
37 
38 class SourcePathMapAspectPrivate;
39 
40 // Entries starting with '(' are considered regular expressions in the ElfReader.
41 // This is useful when there are multiple build machines with different
42 // path, and the user would like to match anything up to some known
43 // directory to his local project.
44 // Syntax: (/home/.*)/KnownSubdir -> /home/my/project
45 using SourcePathMap = QMap<QString, QString>;
46 
47 class SourcePathMapAspect : public Utils::BaseAspect
48 {
49 public:
50     SourcePathMapAspect();
51     ~SourcePathMapAspect() override;
52 
53     void fromMap(const QVariantMap &map) override;
54     void toMap(QVariantMap &map) const override;
55 
56     void addToLayout(Utils::LayoutBuilder &builder) override;
57 
58     QVariant volatileValue() const override;
59     void setVolatileValue(const QVariant &val) override;
60 
61     void readSettings(const QSettings *settings) override;
62     void writeSettings(QSettings *settings) const override;
63 
64     SourcePathMap value() const;
65 
66 private:
67     SourcePathMapAspectPrivate *d = nullptr;
68 };
69 
70 class GeneralSettings
71 {
72     GeneralSettings();
73     ~GeneralSettings();
74 };
75 
76 class DebuggerSettings
77 {
78     Q_DECLARE_TR_FUNCTIONS(Debugger::Internal::DebuggerSettings)
79 
80 public:
81     explicit DebuggerSettings();
82     ~DebuggerSettings();
83 
84     static QString dump();
85 
86     // Page 1: General
87     Utils::BoolAspect useAlternatingRowColors;
88     Utils::BoolAspect useAnnotationsInMainEditor;
89     Utils::BoolAspect useToolTipsInMainEditor;
90     Utils::BoolAspect closeSourceBuffersOnExit;
91     Utils::BoolAspect closeMemoryBuffersOnExit;
92     Utils::BoolAspect raiseOnInterrupt;
93     Utils::BoolAspect breakpointsFullPathByDefault;
94     Utils::BoolAspect warnOnReleaseBuilds;
95     Utils::IntegerAspect maximalStackDepth;
96 
97     Utils::BoolAspect fontSizeFollowsEditor;
98     Utils::BoolAspect switchModeOnExit;
99     Utils::BoolAspect showQmlObjectTree;
100     Utils::BoolAspect stationaryEditorWhileStepping;
101     Utils::BoolAspect forceLoggingToConsole;
102 
103     SourcePathMapAspect sourcePathMap;
104 
105     // Page 2: GDB
106     Utils::IntegerAspect gdbWatchdogTimeout;
107     Utils::BoolAspect skipKnownFrames;
108     Utils::BoolAspect useMessageBoxForSignals;
109     Utils::BoolAspect adjustBreakpointLocations;
110     Utils::BoolAspect useDynamicType;
111     Utils::BoolAspect loadGdbInit;
112     Utils::BoolAspect loadGdbDumpers;
113     Utils::BoolAspect intelFlavor;
114     Utils::BoolAspect usePseudoTracepoints;
115     Utils::BoolAspect useIndexCache;
116     Utils::StringAspect gdbStartupCommands;
117     Utils::StringAspect gdbPostAttachCommands;
118 
119     // Page 3: GDB Extended
120     Utils::BoolAspect targetAsync;
121     Utils::BoolAspect autoEnrichParameters;
122     Utils::BoolAspect breakOnThrow;
123     Utils::BoolAspect breakOnCatch;
124     Utils::BoolAspect breakOnWarning;
125     Utils::BoolAspect breakOnFatal;
126     Utils::BoolAspect breakOnAbort;
127     Utils::BoolAspect enableReverseDebugging;
128     Utils::BoolAspect multiInferior;
129 
130     // Page 4: Locals and expressions
131     Utils::BoolAspect useDebuggingHelpers;
132     Utils::BoolAspect useCodeModel;
133     Utils::BoolAspect showThreadNames;
134     Utils::StringAspect extraDumperFile;     // For loading a file. Recommended.
135     Utils::StringAspect extraDumperCommands; // To modify an existing setup.
136 
137     Utils::BoolAspect showStdNamespace;
138     Utils::BoolAspect showQtNamespace;
139     Utils::BoolAspect showQObjectNames;
140 
141     // Page 5: CDB
142     Utils::StringAspect cdbAdditionalArguments;
143     Utils::StringListAspect cdbBreakEvents;
144     Utils::BoolAspect cdbBreakOnCrtDbgReport;
145     Utils::BoolAspect useCdbConsole;
146     Utils::BoolAspect cdbBreakPointCorrection;
147     Utils::BoolAspect cdbUsePythonDumper;
148     Utils::BoolAspect firstChanceExceptionTaskEntry;
149     Utils::BoolAspect secondChanceExceptionTaskEntry;
150     Utils::BoolAspect ignoreFirstChanceAccessViolation;
151 
152     Utils::BoolAspect *registerForPostMortem = nullptr;
153 
154     // Page 6: CDB Paths
155     Utils::StringListAspect cdbSymbolPaths;
156     Utils::StringListAspect cdbSourcePaths;
157 
158     // Without pages
159     Utils::BoolAspect alwaysAdjustColumnWidths;
160     Utils::BaseAspect settingsDialog;
161     Utils::BoolAspect autoQuit;
162     Utils::BoolAspect lockView;
163     Utils::BoolAspect logTimeStamps;
164 
165     // Stack
166     Utils::BaseAspect expandStack;
167     Utils::BaseAspect createFullBacktrace;
168     Utils::BoolAspect useToolTipsInStackView;
169 
170     // Watchers & Locals
171     Utils::BoolAspect autoDerefPointers;
172     Utils::IntegerAspect maximalStringLength;
173     Utils::IntegerAspect displayStringLimit;
174     Utils::BoolAspect sortStructMembers;
175     Utils::BoolAspect useToolTipsInLocalsView;
176 
177     // Breakpoints
178     Utils::BoolAspect synchronizeBreakpoints; // ?
179     Utils::BoolAspect allPluginBreakpoints;
180     Utils::BoolAspect selectedPluginBreakpoints;
181     Utils::BoolAspect noPluginBreakpoints;
182     Utils::StringAspect selectedPluginBreakpointsPattern;
183     Utils::BoolAspect useToolTipsInBreakpointsView;
184 
185     // QML Tools
186     Utils::BoolAspect showAppOnTop;
187 
188     Utils::AspectContainer all; // All
189     Utils::AspectContainer page1; // General
190     Utils::AspectContainer page2; // GDB
191     Utils::AspectContainer page3; // GDB Extended
192     Utils::AspectContainer page4; // Locals & Expressions
193     Utils::AspectContainer page5; // CDB
194     Utils::AspectContainer page6; // CDB Paths
195 
196     void readSettings();
197     void writeSettings() const;
198 
199 private:
200     DebuggerSettings(const DebuggerSettings &) = delete;
201     DebuggerSettings &operator=(const DebuggerSettings &) = delete;
202 };
203 
204 DebuggerSettings *debuggerSettings();
205 
206 ///////////////////////////////////////////////////////////
207 
208 } // namespace Internal
209 } // namespace Debugger
210 
211 Q_DECLARE_METATYPE(Debugger::Internal::SourcePathMap)
212