Warning: This file is not a C or C++ file. It does not have highlighting.
1 | #include <stdio.h> |
---|---|
2 | #include <stdarg.h> |
3 | |
4 | #ifndef __SANITIZER_COMMON_PRINT_ADDRESS_H__ |
5 | # define __SANITIZER_COMMON_PRINT_ADDRESS_H__ |
6 | |
7 | void print_address(const char *str, int n, ...) { |
8 | fprintf(stderr, "%s", str); |
9 | va_list ap; |
10 | va_start(ap, n); |
11 | while (n--) { |
12 | void *p = va_arg(ap, void *); |
13 | #if defined(__x86_64__) || defined(__aarch64__) || defined(__powerpc64__) || \ |
14 | defined(__s390x__) || (defined(__riscv) && __riscv_xlen == 64) || \ |
15 | defined(__loongarch_lp64) |
16 | // On FreeBSD, the %p conversion specifier works as 0x%x and thus does not |
17 | // match to the format used in the diagnotic message. |
18 | fprintf(stderr, "0x%012lx ", (unsigned long) p); |
19 | #elif defined(__i386__) || defined(__arm__) |
20 | fprintf(stderr, "0x%08lx ", (unsigned long) p); |
21 | #elif defined(__mips64) |
22 | fprintf(stderr, "0x%010lx ", (unsigned long) p); |
23 | #endif |
24 | } |
25 | fprintf(stderr, "\n"); |
26 | } |
27 | |
28 | #endif // __SANITIZER_COMMON_PRINT_ADDRESS_H__ |
Warning: This file is not a C or C++ file. It does not have highlighting.