OLD | NEW |
---|---|
(Empty) | |
1 # Use Qt Creator as IDE or GUI Debugger | |
2 | |
3 [Qt Creator](https://www.qt.io/ide/) | |
4 ([Wiki](https://en.wikipedia.org/wiki/Qt_Creator)) is a cross-platform C++ IDE. | |
5 | |
6 You can use Qt Creator as a daily IDE or just as a GDB frontend and that does | |
7 not require project configuration. | |
8 | |
9 [TOC] | |
10 | |
11 ## IDE | |
12 | |
13 ### Workflow | |
14 | |
15 1. `ctrl+k` Activate Locator, you can open file(not support sublime-like-search) or type `. ` go to symbol. | |
16 2. `ctrl+r` Build and Run, `F5` Debug. | |
17 3. `F4` switch between header file and cpp file. | |
18 4. `ctrl+shift+r` rename symbol under cursor. | |
19 5. Code completion is built-in. And you can add your snippets. | |
20 | |
21 ### Setup as IDE | |
22 | |
23 1. Install latest Qt Creator | |
24 2. under chromium/src `gn gen out/Default --ide=qtcreator` | |
25 3. qtcreator out/Default/qtcreator_project/all.creator | |
26 | |
27 It takes 3 minutes to parsing C++ files in my workstation!!! And It will not | |
28 block you while parsing. | |
29 | |
30 #### Code Style | |
31 | |
32 1. Help - About Plugins enable Beautifier. | |
33 2. Tools - Options - Beautifier - Clang Format, select use predefined style: | |
Nico
2017/03/03 15:57:16
The following things seem important to me:
1. cla
| |
34 chromium. You can also set a keyboard shortcut for it. | |
35 3. Tools - Options - Code Style import this xml file | |
36 | |
37 ``` | |
38 <?xml version="1.0" encoding="UTF-8"?> | |
39 <!DOCTYPE QtCreatorCodeStyle> | |
40 <!-- Written by QtCreator 4.2.1, 2017-02-08T19:07:34. --> | |
41 <qtcreator> | |
42 <data> | |
43 <variable>CodeStyleData</variable> | |
44 <valuemap type="QVariantMap"> | |
45 <value type="bool" key="AlignAssignments">true</value> | |
46 <value type="bool" key="AutoSpacesForTabs">false</value> | |
47 <value type="bool" key="BindStarToIdentifier">false</value> | |
48 <value type="bool" key="BindStarToLeftSpecifier">false</value> | |
49 <value type="bool" key="BindStarToRightSpecifier">false</value> | |
50 <value type="bool" key="BindStarToTypeName">true</value> | |
51 <value type="bool" | |
52 key="ExtraPaddingForConditionsIfConfusingAlign">true</value> | |
53 <value type="bool" key="IndentAccessSpecifiers">true</value> | |
54 <value type="bool" key="IndentBlockBody">true</value> | |
55 <value type="bool" key="IndentBlockBraces">false</value> | |
56 <value type="bool" key="IndentBlocksRelativeToSwitchLabels">false</value> | |
57 <value type="bool" key="IndentClassBraces">false</value> | |
58 <value type="bool" key="IndentControlFlowRelativeToSwitchLabels">true</value> | |
59 <value type="bool" | |
60 key="IndentDeclarationsRelativeToAccessSpecifiers">false</value> | |
61 <value type="bool" key="IndentEnumBraces">false</value> | |
62 <value type="bool" key="IndentFunctionBody">true</value> | |
63 <value type="bool" key="IndentFunctionBraces">false</value> | |
64 <value type="bool" key="IndentNamespaceBody">false</value> | |
65 <value type="bool" key="IndentNamespaceBraces">false</value> | |
66 <value type="int" key="IndentSize">2</value> | |
67 <value type="bool" key="IndentStatementsRelativeToSwitchLabels">true</value> | |
68 <value type="bool" key="IndentSwitchLabels">false</value> | |
69 <value type="int" key="PaddingMode">2</value> | |
70 <value type="bool" key="ShortGetterName">true</value> | |
71 <value type="bool" key="SpacesForTabs">true</value> | |
72 <value type="int" key="TabSize">2</value> | |
73 </valuemap> | |
74 </data> | |
75 <data> | |
76 <variable>DisplayName</variable> | |
77 <value type="QString">chrome</value> | |
78 </data> | |
79 </qtcreator> | |
80 ``` | |
81 | |
82 #### Build & Run | |
83 | |
84 In left panel, projects - setup the ninja command in build and clean step and | |
85 executable chrome path in run. | |
86 | |
87 ## Debugger | |
88 | |
89 **You can skip the project settings and use QtCreator as a single file | |
90 standalone GDB frontend. ** | |
91 | |
92 1. Tools - Options - Build & Run - Debuggers, make sure GDB is set. | |
93 2. Tools - Options - Kits, change the Desktop kit to GDB(LLDB doesnot work in | |
94 Linux). | |
95 3. Open file you want to debug. | |
96 4. Debug - Start Debugging - Attach to running Application, you may need to | |
97 open chrome's task manager to find the process number. | |
98 | |
99 ### Tips, tricks, and troubleshooting | |
100 | |
101 #### Make GDB start fast | |
102 | |
103 Add `gdb_index = true` to `gn args`. | |
104 | |
105 #### Debugger shows start then finish | |
106 | |
107 ``` | |
108 $ echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope | |
109 ``` | |
110 | |
111 Ensure yama allow you to attach another process. | |
112 | |
113 #### Debugger do not stop in break point | |
114 | |
115 Ensure you are using GDB not LLDB in Linux. | |
116 | |
117 #### More | |
118 | |
119 See | |
120 https://chromium.googlesource.com/chromium/src/+/master/docs/linux_debugging.md | |
OLD | NEW |