Skip to content

Commit a12e79a

Browse files
authored
[rtsan] NFC: Update docs with customizable functions (#117086)
1 parent 595e484 commit a12e79a

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

clang/docs/RealtimeSanitizer.rst

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,44 @@ Some issues with flags can be debugged using the ``verbosity=$NUM`` flag:
203203
misspelled_flag
204204
...
205205
206+
Additional customization
207+
------------------------
208+
209+
In addition to ``__rtsan_default_options`` outlined above, you can provide definitions of other functions that affect how RTSan operates.
210+
211+
To be notified on every error reported by RTsan, provide a definition of ``__sanitizer_report_error_summary``.
212+
213+
.. code-block:: c
214+
215+
extern "C" void __sanitizer_report_error_summary(const char *error_summary) {
216+
fprintf(stderr, "%s %s\n", "In custom handler! ", error_summary);
217+
/* do other custom things */
218+
}
219+
220+
The error summary will be of the form:
221+
222+
.. code-block:: console
223+
224+
SUMMARY: RealtimeSanitizer: unsafe-library-call main.cpp:8 in process(std::__1::vector<int, std::__1::allocator<int>>&)
225+
226+
To register a callback which will be invoked before a RTSan kills the process:
227+
228+
.. code-block:: c
229+
230+
extern "C" void __sanitizer_set_death_callback(void (*callback)(void));
231+
232+
void custom_on_die_callback() {
233+
fprintf(stderr, "In custom handler!")
234+
/* do other custom things */
235+
}
236+
237+
int main()
238+
{
239+
__sanitizer_set_death_callback(custom_on_die_callback);
240+
...
241+
}
242+
243+
206244
Disabling and suppressing
207245
-------------------------
208246

0 commit comments

Comments
 (0)