Skip to content

Commit 0bd2ec5

Browse files
committed
Improve formatting of developer notes
Summary of changes: * Add a TOC to the page * Make tips and tricks section use h3 headings * Reformat and clarify some sections
1 parent 624bee9 commit 0bd2ec5

File tree

1 file changed

+66
-28
lines changed

1 file changed

+66
-28
lines changed

doc/developer-notes.md

Lines changed: 66 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,43 @@
11
Developer Notes
22
===============
33

4+
<!-- markdown-toc start -->
5+
**Table of Contents**
6+
7+
- [Developer Notes](#developer-notes)
8+
- [Coding Style](#coding-style)
9+
- [Doxygen comments](#doxygen-comments)
10+
- [Development tips and tricks](#development-tips-and-tricks)
11+
- [Compiling for debugging](#compiling-for-debugging)
12+
- [Compiling for gprof profiling](#compiling-for-gprof-profiling)
13+
- [debug.log](#debuglog)
14+
- [Testnet and Regtest modes](#testnet-and-regtest-modes)
15+
- [DEBUG_LOCKORDER](#debug_lockorder)
16+
- [Valgrind suppressions file](#valgrind-suppressions-file)
17+
- [Compiling for test coverage](#compiling-for-test-coverage)
18+
- [Locking/mutex usage notes](#lockingmutex-usage-notes)
19+
- [Threads](#threads)
20+
- [Ignoring IDE/editor files](#ignoring-ideeditor-files)
21+
- [Development guidelines](#development-guidelines)
22+
- [General Bitcoin Core](#general-bitcoin-core)
23+
- [Wallet](#wallet)
24+
- [General C++](#general-c)
25+
- [C++ data structures](#c-data-structures)
26+
- [Strings and formatting](#strings-and-formatting)
27+
- [Variable names](#variable-names)
28+
- [Threads and synchronization](#threads-and-synchronization)
29+
- [Source code organization](#source-code-organization)
30+
- [GUI](#gui)
31+
- [Subtrees](#subtrees)
32+
- [Git and GitHub tips](#git-and-github-tips)
33+
- [Scripted diffs](#scripted-diffs)
34+
- [RPC interface guidelines](#rpc-interface-guidelines)
35+
36+
<!-- markdown-toc end -->
37+
38+
Coding Style
39+
---------------
40+
441
Various coding styles have been used during the history of the codebase,
542
and the result is not very consistent. However, we're now trying to converge to
643
a single style, which is specified below. When writing patches, favor the new
@@ -138,43 +175,44 @@ Documentation can be generated with `make docs` and cleaned up with `make clean-
138175
Development tips and tricks
139176
---------------------------
140177

141-
**compiling for debugging**
178+
### Compiling for debugging
142179

143-
Run configure with the --enable-debug option, then make. Or run configure with
144-
CXXFLAGS="-g -ggdb -O0" or whatever debug flags you need.
180+
Run configure with `--enable-debug` to add additional compiler flags that
181+
produce better debugging builds.
145182

146-
**compiling for gprof profiling**
183+
### Compiling for gprof profiling
147184

148-
Run configure with the --enable-gprof option, then make.
185+
Run configure with the `--enable-gprof` option, then make.
149186

150-
**debug.log**
187+
### debug.log
151188

152189
If the code is behaving strangely, take a look in the debug.log file in the data directory;
153190
error and debugging messages are written there.
154191

155-
The -debug=... command-line option controls debugging; running with just -debug or -debug=1 will turn
192+
The `-debug=...` command-line option controls debugging; running with just `-debug` or `-debug=1` will turn
156193
on all categories (and give you a very large debug.log file).
157194

158-
The Qt code routes qDebug() output to debug.log under category "qt": run with -debug=qt
195+
The Qt code routes `qDebug()` output to debug.log under category "qt": run with `-debug=qt`
159196
to see it.
160197

161-
**testnet and regtest modes**
198+
### Testnet and Regtest modes
162199

163-
Run with the -testnet option to run with "play bitcoins" on the test network, if you
200+
Run with the `-testnet` option to run with "play bitcoins" on the test network, if you
164201
are testing multi-machine code that needs to operate across the internet.
165202

166-
If you are testing something that can run on one machine, run with the -regtest option.
167-
In regression test mode, blocks can be created on-demand; see test/functional/ for tests
168-
that run in -regtest mode.
203+
If you are testing something that can run on one machine, run with the `-regtest` option.
204+
In regression test mode, blocks can be created on-demand; see [test/functional/](/test/functional) for tests
205+
that run in `-regtest` mode.
169206

170-
**DEBUG_LOCKORDER**
207+
### DEBUG_LOCKORDER
171208

172-
Bitcoin Core is a multithreaded application, and deadlocks or other multithreading bugs
173-
can be very difficult to track down. Compiling with -DDEBUG_LOCKORDER (configure
174-
CXXFLAGS="-DDEBUG_LOCKORDER -g") inserts run-time checks to keep track of which locks
175-
are held, and adds warnings to the debug.log file if inconsistencies are detected.
209+
Bitcoin Core is a multi-threaded application, and deadlocks or other
210+
multi-threading bugs can be very difficult to track down. The `--enable-debug`
211+
configure option adds `-DDEBUG_LOCKORDER` to the compiler flags. This inserts
212+
run-time checks to keep track of which locks are held, and adds warnings to the
213+
debug.log file if inconsistencies are detected.
176214

177-
**Valgrind suppressions file**
215+
### Valgrind suppressions file
178216

179217
Valgrind is a programming tool for memory debugging, memory leak detection, and
180218
profiling. The repo contains a Valgrind suppressions file
@@ -189,7 +227,7 @@ $ valgrind --suppressions=contrib/valgrind.supp --leak-check=full \
189227
$ valgrind -v --leak-check=full src/bitcoind -printtoconsole
190228
```
191229

192-
**compiling for test coverage**
230+
### Compiling for test coverage
193231

194232
LCOV can be used to generate a test coverage report based upon `make check`
195233
execution. LCOV must be installed on your system (e.g. the `lcov` package
@@ -209,18 +247,18 @@ Locking/mutex usage notes
209247
-------------------------
210248

211249
The code is multi-threaded, and uses mutexes and the
212-
LOCK/TRY_LOCK macros to protect data structures.
250+
`LOCK` and `TRY_LOCK` macros to protect data structures.
213251

214-
Deadlocks due to inconsistent lock ordering (thread 1 locks cs_main
215-
and then cs_wallet, while thread 2 locks them in the opposite order:
216-
result, deadlock as each waits for the other to release its lock) are
217-
a problem. Compile with -DDEBUG_LOCKORDER to get lock order
218-
inconsistencies reported in the debug.log file.
252+
Deadlocks due to inconsistent lock ordering (thread 1 locks `cs_main` and then
253+
`cs_wallet`, while thread 2 locks them in the opposite order: result, deadlock
254+
as each waits for the other to release its lock) are a problem. Compile with
255+
`-DDEBUG_LOCKORDER` (or use `--enable-debug`) to get lock order inconsistencies
256+
reported in the debug.log file.
219257

220258
Re-architecting the core code so there are better-defined interfaces
221259
between the various components is a goal, with any necessary locking
222-
done by the components (e.g. see the self-contained CBasicKeyStore class
223-
and its cs_KeyStore lock for example).
260+
done by the components (e.g. see the self-contained `CBasicKeyStore` class
261+
and its `cs_KeyStore` lock for example).
224262

225263
Threads
226264
-------

0 commit comments

Comments
 (0)