forked from OSchip/llvm-project
Revert "[TSanRuntime] Upstream thread swift race detector."
Sometimes it's easier to resolve merge conflict than arguing. llvm-svn: 370385
This commit is contained in:
parent
6289ee941d
commit
6347aa5d16
|
@ -88,7 +88,6 @@ extern "C"
|
|||
// TODO: dlsym won't work on Windows.
|
||||
void *dlsym(void* handle, const char* symbol);
|
||||
int (*ptr__tsan_get_report_loc_object_type)(void *report, unsigned long idx, const char **object_type);
|
||||
int (*ptr__tsan_get_report_tag)(void *report, unsigned long *tag);
|
||||
}
|
||||
|
||||
const int REPORT_TRACE_SIZE = 128;
|
||||
|
@ -98,7 +97,6 @@ struct data {
|
|||
void *report;
|
||||
const char *description;
|
||||
int report_count;
|
||||
unsigned long tag;
|
||||
|
||||
void *sleep_trace[REPORT_TRACE_SIZE];
|
||||
|
||||
|
@ -165,14 +163,10 @@ const char *thread_sanitizer_retrieve_report_data_command = R"(
|
|||
data t = {0};
|
||||
|
||||
ptr__tsan_get_report_loc_object_type = (typeof(ptr__tsan_get_report_loc_object_type))(void *)dlsym((void*)-2 /*RTLD_DEFAULT*/, "__tsan_get_report_loc_object_type");
|
||||
ptr__tsan_get_report_tag = (typeof(ptr__tsan_get_report_tag))(void *)dlsym((void*)-2 /*RTLD_DEFAULT*/, "__tsan_get_report_tag");
|
||||
|
||||
t.report = __tsan_get_current_report();
|
||||
__tsan_get_report_data(t.report, &t.description, &t.report_count, &t.stack_count, &t.mop_count, &t.loc_count, &t.mutex_count, &t.thread_count, &t.unique_tid_count, t.sleep_trace, REPORT_TRACE_SIZE);
|
||||
|
||||
if (ptr__tsan_get_report_tag)
|
||||
ptr__tsan_get_report_tag(t.report, &t.tag);
|
||||
|
||||
if (t.stack_count > REPORT_ARRAY_SIZE) t.stack_count = REPORT_ARRAY_SIZE;
|
||||
for (int i = 0; i < t.stack_count; i++) {
|
||||
t.stacks[i].idx = i;
|
||||
|
@ -353,9 +347,6 @@ ThreadSanitizerRuntime::RetrieveReportData(ExecutionContextRef exe_ctx_ref) {
|
|||
->GetValueAsUnsigned(0));
|
||||
dict->AddItem("sleep_trace", StructuredData::ObjectSP(CreateStackTrace(
|
||||
main_value, ".sleep_trace")));
|
||||
dict->AddIntegerItem(
|
||||
"tag",
|
||||
main_value->GetValueForExpressionPath(".tag")->GetValueAsUnsigned(0));
|
||||
|
||||
StructuredData::Array *stacks = ConvertToStructuredArray(
|
||||
main_value, ".stacks", ".stack_count",
|
||||
|
@ -494,8 +485,8 @@ ThreadSanitizerRuntime::RetrieveReportData(ExecutionContextRef exe_ctx_ref) {
|
|||
return StructuredData::ObjectSP(dict);
|
||||
}
|
||||
|
||||
std::string ThreadSanitizerRuntime::FormatDescription(
|
||||
StructuredData::ObjectSP report, bool &is_swift_access_race) {
|
||||
std::string
|
||||
ThreadSanitizerRuntime::FormatDescription(StructuredData::ObjectSP report) {
|
||||
std::string description = report->GetAsDictionary()
|
||||
->GetValueForKey("issue_type")
|
||||
->GetAsString()
|
||||
|
@ -530,18 +521,8 @@ std::string ThreadSanitizerRuntime::FormatDescription(
|
|||
} else if (description == "lock-order-inversion") {
|
||||
return "Lock order inversion (potential deadlock)";
|
||||
} else if (description == "external-race") {
|
||||
auto tag = report->GetAsDictionary()
|
||||
->GetValueForKey("tag")
|
||||
->GetAsInteger()
|
||||
->GetValue();
|
||||
static const unsigned long kSwiftAccessRaceTag = 0x1;
|
||||
if (tag == kSwiftAccessRaceTag) {
|
||||
is_swift_access_race = true;
|
||||
return "Swift access race";
|
||||
}
|
||||
return "Race on a library object";
|
||||
} else if (description == "swift-access-race") {
|
||||
is_swift_access_race = true;
|
||||
return "Swift access race";
|
||||
}
|
||||
|
||||
|
@ -635,14 +616,9 @@ ThreadSanitizerRuntime::GenerateSummary(StructuredData::ObjectSP report) {
|
|||
->GetValueForKey("description")
|
||||
->GetAsString()
|
||||
->GetValue();
|
||||
bool is_swift_access_race = report->GetAsDictionary()
|
||||
->GetValueForKey("is_swift_access_race")
|
||||
->GetAsBoolean()
|
||||
->GetValue();
|
||||
|
||||
bool skip_one_frame =
|
||||
(report->GetObjectForDotSeparatedPath("issue_type")->GetStringValue() ==
|
||||
"external-race") && (!is_swift_access_race);
|
||||
report->GetObjectForDotSeparatedPath("issue_type")->GetStringValue() ==
|
||||
"external-race";
|
||||
|
||||
addr_t pc = 0;
|
||||
if (report->GetAsDictionary()
|
||||
|
@ -834,12 +810,8 @@ bool ThreadSanitizerRuntime::NotifyBreakpointHit(
|
|||
instance->RetrieveReportData(context->exe_ctx_ref);
|
||||
std::string stop_reason_description;
|
||||
if (report) {
|
||||
bool is_swift_access_race = false;
|
||||
std::string issue_description =
|
||||
instance->FormatDescription(report, is_swift_access_race);
|
||||
std::string issue_description = instance->FormatDescription(report);
|
||||
report->GetAsDictionary()->AddStringItem("description", issue_description);
|
||||
report->GetAsDictionary()->AddBooleanItem("is_swift_access_race",
|
||||
is_swift_access_race);
|
||||
stop_reason_description = issue_description + " detected";
|
||||
report->GetAsDictionary()->AddStringItem("stop_description",
|
||||
stop_reason_description);
|
||||
|
|
|
@ -61,8 +61,7 @@ private:
|
|||
|
||||
StructuredData::ObjectSP RetrieveReportData(ExecutionContextRef exe_ctx_ref);
|
||||
|
||||
std::string FormatDescription(StructuredData::ObjectSP report,
|
||||
bool &is_swift_access_race);
|
||||
std::string FormatDescription(StructuredData::ObjectSP report);
|
||||
|
||||
std::string GenerateSummary(StructuredData::ObjectSP report);
|
||||
|
||||
|
|
Loading…
Reference in New Issue