This source file includes following definitions.
- runtime·raceinit
- runtime·racefini
- runtime·racemapshadow
- runtime·racemalloc
- runtime·racegostart
- runtime·racegoend
- runtime·racewriterangepc
- runtime·racereadrangepc
- runtime·racewriteobjectpc
- runtime·racereadobjectpc
- runtime·raceacquire
- runtime·raceacquireg
- runtime·racerelease
- runtime·racereleaseg
- runtime·racereleasemerge
- runtime·racereleasemergeg
- runtime·racefingo
- runtime·RaceAcquire
- runtime·RaceRelease
- runtime·RaceReleaseMerge
- runtime·RaceSemacquire
- runtime·RaceSemrelease
- runtime·RaceDisable
- runtime·RaceEnable
- runtime·racesymbolize
#include "runtime.h"
#include "arch_GOARCH.h"
#include "malloc.h"
#include "race.h"
#include "type.h"
#include "typekind.h"
void __tsan_init(void);
void __tsan_fini(void);
void __tsan_map_shadow(void);
void __tsan_finalizer_goroutine(void);
void __tsan_go_start(void);
void __tsan_go_end(void);
void __tsan_malloc(void);
void __tsan_acquire(void);
void __tsan_release(void);
void __tsan_release_merge(void);
#pragma cgo_import_static __tsan_init
#pragma cgo_import_static __tsan_fini
#pragma cgo_import_static __tsan_map_shadow
#pragma cgo_import_static __tsan_finalizer_goroutine
#pragma cgo_import_static __tsan_go_start
#pragma cgo_import_static __tsan_go_end
#pragma cgo_import_static __tsan_malloc
#pragma cgo_import_static __tsan_acquire
#pragma cgo_import_static __tsan_release
#pragma cgo_import_static __tsan_release_merge
#pragma cgo_import_static __tsan_read
#pragma cgo_import_static __tsan_read_pc
#pragma cgo_import_static __tsan_read_range
#pragma cgo_import_static __tsan_write
#pragma cgo_import_static __tsan_write_pc
#pragma cgo_import_static __tsan_write_range
#pragma cgo_import_static __tsan_func_enter
#pragma cgo_import_static __tsan_func_exit
extern byte noptrdata[];
extern byte enoptrbss[];
uintptr runtime·racearenastart;
uintptr runtime·racearenaend;
void runtime·racefuncenter(void *callpc);
void runtime·racefuncexit(void);
void runtime·racereadrangepc1(void *addr, uintptr sz, void *pc);
void runtime·racewriterangepc1(void *addr, uintptr sz, void *pc);
void runtime·racesymbolizethunk(void*);
void runtime·racecall(void(*f)(void), ...);
uintptr
runtime·raceinit(void)
{
uintptr racectx, start, size;
if(!runtime·iscgo)
runtime·throw("raceinit: race build must use cgo");
runtime·racecall(__tsan_init, &racectx, runtime·racesymbolizethunk);
start = (uintptr)noptrdata & ~(PageSize-1);
size = ROUND((uintptr)enoptrbss - start, PageSize);
runtime·racecall(__tsan_map_shadow, start, size);
return racectx;
}
void
runtime·racefini(void)
{
runtime·racecall(__tsan_fini);
}
void
runtime·racemapshadow(void *addr, uintptr size)
{
if(runtime·racearenastart == 0)
runtime·racearenastart = (uintptr)addr;
if(runtime·racearenaend < (uintptr)addr+size)
runtime·racearenaend = (uintptr)addr+size;
runtime·racecall(__tsan_map_shadow, addr, size);
}
void
runtime·racemalloc(void *p, uintptr sz)
{
runtime·racecall(__tsan_malloc, p, sz);
}
uintptr
runtime·racegostart(void *pc)
{
uintptr racectx;
runtime·racecall(__tsan_go_start, g->racectx, &racectx, pc);
return racectx;
}
void
runtime·racegoend(void)
{
runtime·racecall(__tsan_go_end, g->racectx);
}
void
runtime·racewriterangepc(void *addr, uintptr sz, void *callpc, void *pc)
{
if(callpc != nil)
runtime·racefuncenter(callpc);
runtime·racewriterangepc1(addr, sz, pc);
if(callpc != nil)
runtime·racefuncexit();
}
void
runtime·racereadrangepc(void *addr, uintptr sz, void *callpc, void *pc)
{
if(callpc != nil)
runtime·racefuncenter(callpc);
runtime·racereadrangepc1(addr, sz, pc);
if(callpc != nil)
runtime·racefuncexit();
}
void
runtime·racewriteobjectpc(void *addr, Type *t, void *callpc, void *pc)
{
uint8 kind;
kind = t->kind & ~KindNoPointers;
if(kind == KindArray || kind == KindStruct)
runtime·racewriterangepc(addr, t->size, callpc, pc);
else
runtime·racewritepc(addr, callpc, pc);
}
void
runtime·racereadobjectpc(void *addr, Type *t, void *callpc, void *pc)
{
uint8 kind;
kind = t->kind & ~KindNoPointers;
if(kind == KindArray || kind == KindStruct)
runtime·racereadrangepc(addr, t->size, callpc, pc);
else
runtime·racereadpc(addr, callpc, pc);
}
void
runtime·raceacquire(void *addr)
{
runtime·raceacquireg(g, addr);
}
void
runtime·raceacquireg(G *gp, void *addr)
{
if(g->raceignore)
return;
runtime·racecall(__tsan_acquire, gp->racectx, addr);
}
void
runtime·racerelease(void *addr)
{
runtime·racereleaseg(g, addr);
}
void
runtime·racereleaseg(G *gp, void *addr)
{
if(g->raceignore)
return;
runtime·racecall(__tsan_release, gp->racectx, addr);
}
void
runtime·racereleasemerge(void *addr)
{
runtime·racereleasemergeg(g, addr);
}
void
runtime·racereleasemergeg(G *gp, void *addr)
{
if(g->raceignore)
return;
runtime·racecall(__tsan_release_merge, gp->racectx, addr);
}
void
runtime·racefingo(void)
{
runtime·racecall(__tsan_finalizer_goroutine, g->racectx);
}
void
runtime·RaceAcquire(void *addr)
{
runtime·raceacquire(addr);
}
void
runtime·RaceRelease(void *addr)
{
runtime·racerelease(addr);
}
void
runtime·RaceReleaseMerge(void *addr)
{
runtime·racereleasemerge(addr);
}
void
runtime·RaceSemacquire(uint32 *s)
{
runtime·semacquire(s, false);
}
void
runtime·RaceSemrelease(uint32 *s)
{
runtime·semrelease(s);
}
void
runtime·RaceDisable(void)
{
g->raceignore++;
}
void
runtime·RaceEnable(void)
{
g->raceignore--;
}
typedef struct SymbolizeContext SymbolizeContext;
struct SymbolizeContext
{
uintptr pc;
int8* func;
int8* file;
uintptr line;
uintptr off;
uintptr res;
};
void
runtime·racesymbolize(SymbolizeContext *ctx)
{
Func *f;
String file;
f = runtime·findfunc(ctx->pc);
if(f == nil) {
ctx->func = "??";
ctx->file = "-";
ctx->line = 0;
ctx->off = ctx->pc;
ctx->res = 1;
return;
}
ctx->func = runtime·funcname(f);
ctx->line = runtime·funcline(f, ctx->pc, &file);
ctx->file = (int8*)file.str;
ctx->off = ctx->pc - f->entry;
ctx->res = 1;
}