Changeset View
Changeset View
Standalone View
Standalone View
doc/developer-notes.md
Show All 11 Lines | - [Developer Notes](#developer-notes) | ||||
- [Development tips and tricks](#development-tips-and-tricks) | - [Development tips and tricks](#development-tips-and-tricks) | ||||
- [Compiling for debugging](#compiling-for-debugging) | - [Compiling for debugging](#compiling-for-debugging) | ||||
- [Compiling for gprof profiling](#compiling-for-gprof-profiling) | - [Compiling for gprof profiling](#compiling-for-gprof-profiling) | ||||
- [debug.log](#debuglog) | - [debug.log](#debuglog) | ||||
- [Writing tests](#writing-tests) | - [Writing tests](#writing-tests) | ||||
- [Writing script integration tests](#writing-script-integration-tests) | - [Writing script integration tests](#writing-script-integration-tests) | ||||
- [Testnet and Regtest modes](#testnet-and-regtest-modes) | - [Testnet and Regtest modes](#testnet-and-regtest-modes) | ||||
- [DEBUG_LOCKORDER](#debug_lockorder) | - [DEBUG_LOCKORDER](#debug_lockorder) | ||||
- [DEBUG_LOCKCONTENTION](#debug_lockcontention) | |||||
- [Valgrind suppressions file](#valgrind-suppressions-file) | - [Valgrind suppressions file](#valgrind-suppressions-file) | ||||
- [Compiling for test coverage](#compiling-for-test-coverage) | - [Compiling for test coverage](#compiling-for-test-coverage) | ||||
- [Performance profiling with perf](#performance-profiling-with-perf) | - [Performance profiling with perf](#performance-profiling-with-perf) | ||||
- [Sanitizers](#sanitizers) | - [Sanitizers](#sanitizers) | ||||
- [Locking/mutex usage notes](#lockingmutex-usage-notes) | - [Locking/mutex usage notes](#lockingmutex-usage-notes) | ||||
- [Threads](#threads) | - [Threads](#threads) | ||||
- [Ignoring IDE/editor files](#ignoring-ideeditor-files) | - [Ignoring IDE/editor files](#ignoring-ideeditor-files) | ||||
- [Development guidelines](#development-guidelines) | - [Development guidelines](#development-guidelines) | ||||
▲ Show 20 Lines • Show All 243 Lines • ▼ Show 20 Lines | |||||
### DEBUG_LOCKORDER | ### DEBUG_LOCKORDER | ||||
Bitcoin ABC is a multi-threaded application, and deadlocks or other | Bitcoin ABC is a multi-threaded application, and deadlocks or other | ||||
multi-threading bugs can be very difficult to track down. | multi-threading bugs can be very difficult to track down. | ||||
The `-DCMAKE_BUILD_TYPE=Debug` cmake option adds `-DDEBUG_LOCKORDER` to the | The `-DCMAKE_BUILD_TYPE=Debug` cmake option adds `-DDEBUG_LOCKORDER` to the | ||||
compiler flags. This inserts run-time checks to keep track of which locks are | compiler flags. This inserts run-time checks to keep track of which locks are | ||||
held, and adds warnings to the debug.log file if inconsistencies are detected. | held, and adds warnings to the debug.log file if inconsistencies are detected. | ||||
### DEBUG_LOCKCONTENTION | |||||
Defining `DEBUG_LOCKCONTENTION` adds a "lock" logging category that, when enabled, | |||||
logs the location and duration of each lock contention to the `debug.log` file. | |||||
To enable it, run cmake with `-DDEBUG_LOCKCONTENTION` added to your CPPFLAGS, | |||||
e.g. `-DCMAKE_CXX_FLAGS="-DDEBUG_LOCKCONTENTION"`, then build and run bitcoind. | |||||
You can then use the `-debug=lock` configuration option at bitcoind startup or | |||||
`bitcoin-cli logging '["lock"]'` at runtime to turn on lock contention logging. | |||||
It can be toggled off again with `bitcoin-cli logging [] '["lock"]'`. | |||||
### Assertions and Checks | ### Assertions and Checks | ||||
The util file `src/util/check.h` offers helpers to protect against coding and | The util file `src/util/check.h` offers helpers to protect against coding and | ||||
internal logic bugs. They must never be used to validate user, network or any | internal logic bugs. They must never be used to validate user, network or any | ||||
other input. | other input. | ||||
* `assert` or `Assert` should be used to document assumptions when any | * `assert` or `Assert` should be used to document assumptions when any | ||||
violation would mean that it is not safe to continue program execution. The | violation would mean that it is not safe to continue program execution. The | ||||
▲ Show 20 Lines • Show All 960 Lines • Show Last 20 Lines |