1// RUN: %clangxx_asan -O0 %s -o %t
2// RUN: not %run %t 0 2>&1 | FileCheck %s
3
4#include <sanitizer/asan_interface.h>
5#include <stdio.h>
6
7static void ErrorReportCallbackOneToZ(const char *report) {
8 fprintf(stderr, format: "ABCDEF%sGHIJKL", report);
9 fflush(stderr);
10}
11
12int main(int argc, char **argv) {
13 __asan_set_error_report_callback(callback: ErrorReportCallbackOneToZ);
14 __asan_report_error(
15 pc: (void *)__builtin_extract_return_addr(__builtin_return_address(0)), bp: 0, sp: 0,
16 addr: 0, is_write: true, access_size: 1);
17 // CHECK: ABCDEF
18 // CHECK: ERROR: AddressSanitizer
19 // CHECK: GHIJKL
20 return 0;
21}
22

source code of compiler-rt/test/asan/TestCases/error_report_callback.cpp