-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinterface.cpp
More file actions
81 lines (67 loc) · 2.62 KB
/
Copy pathinterface.cpp
File metadata and controls
81 lines (67 loc) · 2.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#include "interface.h"
#include "src/traced_analyzer.hpp"
PyTsan pytsan_global;
inline TracedAnalyzer *get_backend(PyTsan *pytsan) {
return (TracedAnalyzer *)pytsan->backend;
}
int pytsan_init(PyTsan *pytsan) {
char *env = getenv("PYTSAN");
pytsan->enabled = env != nullptr;
if (pytsan->enabled)
pytsan->backend = new TracedAnalyzer();
return true;
}
int pytsan_finalize(PyTsan *pytsan) {
delete get_backend(pytsan);
return true;
}
void pytsan_comment(PyTsan *pytsan, char *comment) {
get_backend(pytsan)->comment(comment);
}
ContextInfo
build_context_from_pytsan_context(const PyTsanContextInfo &context) {
return {.tid = context.tid,
.pid = context.pid,
.opcode = context.opcode,
.filename = context.filename,
.lineno = context.lineno};
}
void pytsan_handle_event_with_name(PyTsan *pytsan, PyTsanPyObject *object,
const char *name, int is_write,
const PyTsanContextInfo *context) {
get_backend(pytsan)->handle_event_with_name(
(ObjectId)object, name, is_write,
build_context_from_pytsan_context(*context));
}
void pytsan_new_segment(PyTsan *pytsan, const PyTsanContextInfo *context) {
get_backend(pytsan)->new_segment(build_context_from_pytsan_context(*context));
}
void pytsan_acquire_lock(PyTsan *pytsan, PyTsanPyObject *lock,
const PyTsanContextInfo *context) {
get_backend(pytsan)->acquire_lock(
(Lock)lock, build_context_from_pytsan_context(*context));
}
void pytsan_release_lock(PyTsan *pytsan, PyTsanPyObject *lock,
const PyTsanContextInfo *context) {
get_backend(pytsan)->release_lock(
(Lock)lock, build_context_from_pytsan_context(*context));
}
void pytsan_start_new_thread(PyTsan *pytsan, PyTsanTid new_tid,
const PyTsanContextInfo *context) {
get_backend(pytsan)->start_new_thread(
new_tid, build_context_from_pytsan_context(*context));
}
void pytsan_delete_thread(PyTsan *pytsan, const PyTsanContextInfo *context) {
get_backend(pytsan)->delete_thread(
build_context_from_pytsan_context(*context));
}
void pytsan_join_wait(PyTsan *pytsan, PyTsanTid target_tid,
const PyTsanContextInfo *context) {
get_backend(pytsan)->join_wait(target_tid,
build_context_from_pytsan_context(*context));
}
void pytsan_dealloc_id(PyTsan *pytsan, PyTsanPyObject *object,
const PyTsanContextInfo *context) {
get_backend(pytsan)->dealloc_id((ObjectId)object,
build_context_from_pytsan_context(*context));
}