1// RUN: %clang_hwasan %s -o %t && %env_hwasan_opts=verbose_threads=1 %run %t 2>&1 | FileCheck %s --implicit-check-not=0x000000000000
2
3#include <pthread.h>
4#include <stdlib.h>
5#include <stdio.h>
6
7#include <sanitizer/hwasan_interface.h>
8
9// CHECK: sizeof(Thread): [[#]] sizeof(HeapRB): [[#]] sizeof(StackRB): [[#]]
10// CHECK: Creating : T0 0x[[#%x,T0:]] stack: [0x[[#%x,SB0:]],0x[[#%x,SE0:]]) sz: [[#]] tls: [0x[[#%x,TB0:]],0x[[#%x,TE0:]])
11// CHECK: Creating : T1 0x[[#%x,T1:]] stack: [0x[[#%x,SB1:]],0x[[#%x,SE1:]]) sz: [[#]] tls: [0x[[#%x,TB1:]],0x[[#%x,TE1:]])
12// CHECK: Creating : T2 0x[[#%x,T2:]] stack: [0x[[#%x,SB2:]],0x[[#%x,SE2:]]) sz: [[#]] tls: [0x[[#%x,TB2:]],0x[[#%x,TE2:]])
13// CHECK: Destroying: T2 0x{{0*}}[[#T2]] stack: [0x{{0*}}[[#SB2]],0x{{0*}}[[#SE2]]) sz: [[#]] tls: [0x{{0*}}[[#TB2]],0x{{0*}}[[#TE2]])
14// CHECK: Destroying: T1 0x{{0*}}[[#T1]] stack: [0x{{0*}}[[#SB1]],0x{{0*}}[[#SE1]]) sz: [[#]] tls: [0x{{0*}}[[#TB1]],0x{{0*}}[[#TE1]])
15
16void *Empty(void *arg) {
17 if (arg) return NULL;
18 pthread_t t;
19 pthread_create(newthread: &t, NULL, start_routine: Empty, arg: &t);
20 pthread_join(th: t, NULL);
21 return NULL;
22}
23
24int main() {
25 pthread_t t;
26 pthread_create(newthread: &t, NULL, start_routine: Empty, NULL);
27 pthread_join(th: t, NULL);
28 return 0;
29}
30

source code of compiler-rt/test/hwasan/TestCases/verbose_threads.c