@@ -94,6 +94,77 @@ Available settings:
9494
9595 Use ` 0 ` to disable this check.
9696
97+ Address Naught
98+ --------------
99+
100+ Often writing to address naught is a mistake, it indicates that some target address is unset,
101+ especially in larger modes. ` address_naught ` mode detects all writes to this address and gives a
102+ new (to VM) error in that case - ` AMX_ERR_ADDRESS_0 ` . Note that this isn't always an error, it is a
103+ valid address and real data can be stored there, so if this detection is enabled the mode must
104+ ensure that nothing important will be written there (fixes.inc does this by defining and not using
105+ the anonymous automata). This is also the reason why there is no global config option for this
106+ detection - it is by necessity done on a per-mode basis, is off by default, and can only be enabled
107+ by functions (technically by registers).
108+
109+ Functions
110+ ---------
111+
112+ There are several functions defined in ` crashdetect.inc ` to access plugin information. These are
113+ all just wrappers around direct register accesses, but provide a much nicer API.
114+
115+ * ` bool:IsCrashDetectPresent(); ` - Is the crashdetect plugin loaded?
116+ * ` SetCrashDetectLongCallTime(us_time); ` - Set the long call warning threshold.
117+ * ` GetCrashDetectLongCallTime(); ` - Get the long call warning threshold.
118+ * ` DisableCrashDetectLongCall(); ` - Disable the long call warning.
119+ * ` EnableCrashDetectLongCall(); ` - Disable the long call warning.
120+ * ` ResetCrashDetectLongCallTime(); ` - Reset the long call threshold to the default (from ` server.cfg ` ).
121+ * ` RestartCrashDetectLongCall(); ` - Restart the long call timer.
122+ * ` bool:IsCrashDetectLongCallEnabled(); ` - Is long function call detection enabled?
123+ * ` bool:HasCrashDetectLongCall(); ` - Does the current version of crashdetect support this feature?
124+ * ` GetCrashDetectDefaultTime(); ` - Get the default long call time threshold.
125+ * ` DisableCrashDetectAddr0(); ` - Disable address naught write detection in this mode.
126+ * ` EnableCrashDetectAddr0(); ` - Enable address naught write detection in this mode.
127+ * ` bool:IsCrashDetectAddr0Enabled(); ` - Is the error currently enabled?
128+ * ` bool:HasCrashDetectAddr0(); ` - Does the current version of crashdetect support this feature?
129+
130+ Registers
131+ ---------
132+
133+ The plugin adds two control registers accessed via ` LCTRL ` and ` SCTRL ` - ` 0xFF ` for general flags
134+ and ` 0xFE ` for long call time values:
135+
136+ ``` pawn
137+ // Get the current long call time (even when it is disabled).
138+ #emit ZERO.pri // Always set pri to 0 before `LCTRL` calls.
139+ #emit LCTRL 0xFE // Will set `pri` if the plugin is loaded.
140+ #emit STOR.pri var // Save the result.
141+ ```
142+
143+ ``` pawn
144+ // Enable address naught write detection.
145+ #emit CONST.pri 192 // 64 (address_naught control bit) | 128 (address_naught enable).
146+ #emit SCTRL 0xFF // Set the register.
147+ ```
148+
149+ The flags are:
150+
151+ * ` 1 ` - Cashdetect present (read only).
152+ * ` 2 ` - long_call_time checks enabled (write ignored when ` server.cfg ` has ` long_call_time 0 ` ).
153+ * ` 4 ` - long_call_time reset to default time (write ` 1 ` only).
154+ * ` 8 ` - long_call_time restart check from now (write ` 1 ` only).
155+ * ` 16 ` - Error with the crashdetect user data.
156+ * ` 32 ` - long_call_time control bit.
157+ * ` 64 ` - address_naught control bit.
158+ * ` 128 ` - address_naught detection enabled.
159+
160+ When read-only values are set, they are ignored. When write-only bits are returned they are always
161+ ` 0 ` . When write-1-only bits are ` 0 ` they are ignored, the ` 1 ` is a signal to trigger something. To
162+ set most registers the relevant control bit must also be set. So to enable address naught detection
163+ requires bit ` 6 ` (` 64 ` ) and bit ` 7 ` (` 128 ` ). To disable it just requires bit ` 6 ` . Note that while
164+ many of these bits would seem to be independent you cannot disable address naught detection, enable
165+ long call detection, and reset and restart the timer all at once with ` 0x6E ` ; only one command at
166+ once will work.
167+
97168Building from source code
98169-------------------------
99170
0 commit comments