LEFT | RIGHT |
1 // Copyright 2011 The Go Authors. All rights reserved. | 1 // Copyright 2011 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 // Implementation of the race detector API. | 5 // Implementation of the race detector API. |
6 // +build race | 6 // +build race |
7 | 7 |
8 #include "runtime.h" | 8 #include "runtime.h" |
9 #include "arch_GOARCH.h" | 9 #include "arch_GOARCH.h" |
10 #include "malloc.h" | 10 #include "malloc.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 // start/end of heap for race_amd64.s | 52 // start/end of heap for race_amd64.s |
53 uintptr runtime·racearenastart; | 53 uintptr runtime·racearenastart; |
54 uintptr runtime·racearenaend; | 54 uintptr runtime·racearenaend; |
55 | 55 |
56 void runtime·racefuncenter(void *callpc); | 56 void runtime·racefuncenter(void *callpc); |
57 void runtime·racefuncexit(void); | 57 void runtime·racefuncexit(void); |
58 void runtime·racereadrangepc1(void *addr, uintptr sz, void *pc); | 58 void runtime·racereadrangepc1(void *addr, uintptr sz, void *pc); |
59 void runtime·racewriterangepc1(void *addr, uintptr sz, void *pc); | 59 void runtime·racewriterangepc1(void *addr, uintptr sz, void *pc); |
60 void runtime·racesymbolizethunk(void*); | 60 void runtime·racesymbolizethunk(void*); |
61 | 61 |
62 // racecall allows to call an arbitrary function f from C race runtime | 62 // racecall allows calling an arbitrary function f from C race runtime |
63 // with up to 4 uintptr arguments. | 63 // with up to 4 uintptr arguments. |
64 void runtime·racecall(void(*f)(void), ...); | 64 void runtime·racecall(void(*f)(void), ...); |
65 | 65 |
66 uintptr | 66 uintptr |
67 runtime·raceinit(void) | 67 runtime·raceinit(void) |
68 { | 68 { |
69 uintptr racectx, start, size; | 69 uintptr racectx, start, size; |
70 | 70 |
71 // cgo is required to initialize libc, which is used by race runtime | 71 // cgo is required to initialize libc, which is used by race runtime |
72 if(!runtime·iscgo) | 72 if(!runtime·iscgo) |
(...skipping 18 matching lines...) Expand all Loading... |
91 if(runtime·racearenastart == 0) | 91 if(runtime·racearenastart == 0) |
92 runtime·racearenastart = (uintptr)addr; | 92 runtime·racearenastart = (uintptr)addr; |
93 if(runtime·racearenaend < (uintptr)addr+size) | 93 if(runtime·racearenaend < (uintptr)addr+size) |
94 runtime·racearenaend = (uintptr)addr+size; | 94 runtime·racearenaend = (uintptr)addr+size; |
95 runtime·racecall(__tsan_map_shadow, addr, size); | 95 runtime·racecall(__tsan_map_shadow, addr, size); |
96 } | 96 } |
97 | 97 |
98 void | 98 void |
99 runtime·racemalloc(void *p, uintptr sz) | 99 runtime·racemalloc(void *p, uintptr sz) |
100 { | 100 { |
101 » // use m->curg because runtime·stackalloc() is called from g0 | 101 » runtime·racecall(__tsan_malloc, p, sz); |
102 » if(m->curg == nil) | |
103 » » return; | |
104 » runtime·racecall(__tsan_malloc, m->curg->racectx, p, sz); | |
105 } | 102 } |
106 | 103 |
107 uintptr | 104 uintptr |
108 runtime·racegostart(void *pc) | 105 runtime·racegostart(void *pc) |
109 { | 106 { |
110 uintptr racectx; | 107 uintptr racectx; |
111 | 108 |
112 runtime·racecall(__tsan_go_start, g->racectx, &racectx, pc); | 109 runtime·racecall(__tsan_go_start, g->racectx, &racectx, pc); |
113 return racectx; | 110 return racectx; |
114 } | 111 } |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 ctx->off = ctx->pc; | 283 ctx->off = ctx->pc; |
287 ctx->res = 1; | 284 ctx->res = 1; |
288 return; | 285 return; |
289 } | 286 } |
290 ctx->func = runtime·funcname(f); | 287 ctx->func = runtime·funcname(f); |
291 ctx->line = runtime·funcline(f, ctx->pc, &file); | 288 ctx->line = runtime·funcline(f, ctx->pc, &file); |
292 ctx->file = (int8*)file.str; // assume zero-terminated | 289 ctx->file = (int8*)file.str; // assume zero-terminated |
293 ctx->off = ctx->pc - f->entry; | 290 ctx->off = ctx->pc - f->entry; |
294 ctx->res = 1; | 291 ctx->res = 1; |
295 } | 292 } |
LEFT | RIGHT |