|
1 | 1 | #pragma once
|
2 | 2 |
|
3 |
| -// TODO: documentation |
| 3 | +// 1. Define `BAD_ACCESS_GUARDS_ENABLE=1` for your **in-house** builds (you probably want it off in production...) |
| 4 | +// 2. Declare the shadow memory that will hold the state and pointer to stack with `BA_GUARD_DECL(varname)` |
| 5 | +// 3. For all (relevant) read operations of the container / object, use the scope guard `BA_GUARD_READ(varname)`. |
| 6 | +// 4. For all (relevant) write operations of the container / object, use the scope guard `BA_GUARD_WRITE(varname)`. |
| 7 | +// Do this only if it always writes! For example, don't use it on `operator[]` even though it returns a reference, use `BA_GUARD_READ` instead. |
| 8 | +// 5. Add `BA_GUARD_DESTROY(varname)` at the beginning of the destructor. |
| 9 | +// 6. Enjoy! |
| 10 | +// |
| 11 | +// You may optionally configure it with `BadAccessGuardSetConfig`. |
4 | 12 |
|
5 | 13 | #if !defined(BAD_ACCESS_GUARDS_ENABLE)
|
6 | 14 | # if defined(NDEBUG)
|
@@ -207,18 +215,19 @@ struct BadAccessGuardDestroy
|
207 | 215 |
|
208 | 216 | struct BadAccessGuardConfig
|
209 | 217 | {
|
210 |
| - // Should we allow to break at all, or simply call BadAccessGuardReport |
211 |
| - // Default: true |
| 218 | + // Should we allow to break at all, or simply call `reportBadAccess` |
| 219 | + // Default: true. |
212 | 220 | bool allowBreak;
|
213 | 221 | // Set this to true if you want to break early.
|
214 | 222 | // Usually you would want to set this to true when the debugger is connected.
|
215 | 223 | // If no debugger is connected, you most likely want this set to false to get the error in your logs.
|
216 | 224 | // Of course, if you save minidumps, logging is probably unnecessary.
|
217 |
| - // Default true on windows if a debugger is detected during startup |
| 225 | + // Default: true on Windows if a debugger is detected during startup, false otherwise. |
218 | 226 | bool breakASAP;
|
219 | 227 |
|
220 | 228 | // If non-null, used to report errors instead of the default function.
|
221 |
| - // Breaking is still controlled by allowBreak and breakASAP. |
| 229 | + // Breaking is still controlled by `allowBreak` and `breakASAP`. |
| 230 | + // Returning false can prevent triggering the breakpoint (except if `breakASAP` is true) |
222 | 231 | using ReportBadAccessFunction = bool(StateAndStackAddr previousOperation, BadAccessGuardState toState, bool assertionOrWarning, const char* message);
|
223 | 232 | ReportBadAccessFunction* reportBadAccess;
|
224 | 233 | };
|
|
0 commit comments