Skip to content

Commit 794fe91

Browse files
committed
doc: Update and improve Developer Notes
1 parent 3052130 commit 794fe91

File tree

1 file changed

+16
-24
lines changed

1 file changed

+16
-24
lines changed

doc/developer-notes.md

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@ Developer Notes
1212
- [Development tips and tricks](#development-tips-and-tricks)
1313
- [Compiling for debugging](#compiling-for-debugging)
1414
- [Compiling for gprof profiling](#compiling-for-gprof-profiling)
15-
- [debug.log](#debuglog)
15+
- [`debug.log`](#debuglog)
1616
- [Testnet and Regtest modes](#testnet-and-regtest-modes)
1717
- [DEBUG_LOCKORDER](#debug_lockorder)
1818
- [Valgrind suppressions file](#valgrind-suppressions-file)
1919
- [Compiling for test coverage](#compiling-for-test-coverage)
2020
- [Performance profiling with perf](#performance-profiling-with-perf)
21+
- [Sanitizers](#sanitizers)
2122
- [Locking/mutex usage notes](#lockingmutex-usage-notes)
2223
- [Threads](#threads)
2324
- [Ignoring IDE/editor files](#ignoring-ideeditor-files)
@@ -62,7 +63,7 @@ tool to clean up patches automatically before submission.
6263
- Braces on the same line for everything else.
6364
- 4 space indentation (no tabs) for every block except namespaces.
6465
- No indentation for `public`/`protected`/`private` or for `namespace`.
65-
- No extra spaces inside parenthesis; don't do ( this ).
66+
- No extra spaces inside parenthesis; don't do `( this )`.
6667
- No space after function names; one space after `if`, `for` and `while`.
6768
- If an `if` only has a single-statement `then`-clause, it can appear
6869
on the same line as the `if`, without braces. In every other case,
@@ -76,7 +77,7 @@ code.
7677
separate words (snake_case).
7778
- Class member variables have a `m_` prefix.
7879
- Global variables have a `g_` prefix.
79-
- Constant names are all uppercase, and use `_` to separate words.
80+
- Compile-time constant names are all uppercase, and use `_` to separate words.
8081
- Class names, function names, and method names are UpperCamelCase
8182
(PascalCase). Do not prefix class names with `C`.
8283
- Test suite naming convention: The Boost test suite in file
@@ -207,15 +208,15 @@ produce better debugging builds.
207208

208209
Run configure with the `--enable-gprof` option, then make.
209210

210-
### debug.log
211+
### `debug.log`
211212

212-
If the code is behaving strangely, take a look in the debug.log file in the data directory;
213+
If the code is behaving strangely, take a look in the `debug.log` file in the data directory;
213214
error and debugging messages are written there.
214215

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

218-
The Qt code routes `qDebug()` output to debug.log under category "qt": run with `-debug=qt`
219+
The Qt code routes `qDebug()` output to `debug.log` under category "qt": run with `-debug=qt`
219220
to see it.
220221

221222
### Testnet and Regtest modes
@@ -233,7 +234,7 @@ Bitcoin Core is a multi-threaded application, and deadlocks or other
233234
multi-threading bugs can be very difficult to track down. The `--enable-debug`
234235
configure option adds `-DDEBUG_LOCKORDER` to the compiler flags. This inserts
235236
run-time checks to keep track of which locks are held and adds warnings to the
236-
debug.log file if inconsistencies are detected.
237+
`debug.log` file if inconsistencies are detected.
237238

238239
### Valgrind suppressions file
239240

@@ -275,8 +276,7 @@ the functional test framework. Perf can observe a running process and sample
275276
(at some frequency) where its execution is.
276277

277278
Perf installation is contingent on which kernel version you're running; see
278-
[this StackExchange
279-
thread](https://askubuntu.com/questions/50145/how-to-install-perf-monitoring-tool)
279+
[this thread](https://askubuntu.com/questions/50145/how-to-install-perf-monitoring-tool)
280280
for specific instructions.
281281

282282
Certain kernel parameters may need to be set for perf to be able to inspect the
@@ -311,7 +311,7 @@ or using a graphical tool like [Hotspot](https://github.com/KDAB/hotspot).
311311
See the functional test documentation for how to invoke perf within tests.
312312

313313

314-
**Sanitizers**
314+
### Sanitizers
315315

316316
Bitcoin Core can be compiled with various "sanitizers" enabled, which add
317317
instrumentation for issues regarding things like memory safety, thread race
@@ -372,7 +372,7 @@ Deadlocks due to inconsistent lock ordering (thread 1 locks `cs_main` and then
372372
`cs_wallet`, while thread 2 locks them in the opposite order: result, deadlock
373373
as each waits for the other to release its lock) are a problem. Compile with
374374
`-DDEBUG_LOCKORDER` (or use `--enable-debug`) to get lock order inconsistencies
375-
reported in the debug.log file.
375+
reported in the `debug.log` file.
376376

377377
Re-architecting the core code so there are better-defined interfaces
378378
between the various components is a goal, with any necessary locking
@@ -386,8 +386,6 @@ Threads
386386

387387
- ThreadImport : Loads blocks from `blk*.dat` files or `-loadblock=<file>`.
388388

389-
- StartNode : Starts other threads.
390-
391389
- ThreadDNSAddressSeed : Loads addresses of peers from the DNS.
392390

393391
- ThreadMapPort : Universal plug-and-play startup/shutdown.
@@ -400,7 +398,7 @@ Threads
400398

401399
- ThreadMessageHandler : Higher-level message handling (sending and receiving).
402400

403-
- DumpAddresses : Dumps IP addresses of nodes to peers.dat.
401+
- DumpAddresses : Dumps IP addresses of nodes to `peers.dat`.
404402

405403
- ThreadRPCServer : Remote procedure call handler, listens on port 8332 for connections and services them.
406404

@@ -466,11 +464,6 @@ Wallet
466464

467465
- Make sure that no crashes happen with run-time option `-disablewallet`.
468466

469-
- *Rationale*: In RPC code that conditionally uses the wallet (such as
470-
`validateaddress`), it is easy to forget that global pointer `pwalletMain`
471-
can be nullptr. See `test/functional/disablewallet.py` for functional tests
472-
exercising the API with `-disablewallet`.
473-
474467
- Include `db_cxx.h` (BerkeleyDB header) only when `ENABLE_WALLET` is set.
475468

476469
- *Rationale*: Otherwise compilation of the disable-wallet build will fail in environments without BerkeleyDB.
@@ -545,11 +538,10 @@ class A
545538
}
546539
```
547540
548-
- By default, declare single-argument constructors `explicit`.
541+
- By default, declare constructors `explicit`.
549542
550-
- *Rationale*: This is a precaution to avoid unintended conversions that might
551-
arise when single-argument constructors are used as implicit conversion
552-
functions.
543+
- *Rationale*: This is a precaution to avoid unintended
544+
[conversions](https://en.cppreference.com/w/cpp/language/converting_constructor).
553545
554546
- Use explicitly signed or unsigned `char`s, or even better `uint8_t` and
555547
`int8_t`. Do not use bare `char` unless it is to pass to a third-party API.

0 commit comments

Comments
 (0)