[Decompiler] Add offline tests (#303)

* add offline test for gcommon as an example.

* fix test

* unused var
This commit is contained in:
water111
2021-03-03 15:42:55 -05:00
committed by GitHub
parent 2eca9ab801
commit 413c1f5c74
17 changed files with 1743 additions and 43 deletions
+19 -6
View File
@@ -153,7 +153,8 @@ std::string careful_function_to_string(
std::string write_from_top_level(const Function& top_level,
const DecompilerTypeSystem& dts,
const LinkedObjectFile& file) {
const LinkedObjectFile& file,
const std::unordered_set<std::string>& skip_functions) {
auto top_form = top_level.ir2.top_form;
if (!top_form) {
return ";; ERROR: top level function was not converted to expressions. Cannot decompile.\n\n";
@@ -212,7 +213,11 @@ std::string write_from_top_level(const Function& top_level,
something_matched = true;
result += fmt::format(";; definition for function {}\n",
global_match_result.maps.strings.at(func_name));
result += careful_function_to_string(func, dts);
if (skip_functions.find(func->guessed_name.to_string()) == skip_functions.end()) {
result += careful_function_to_string(func, dts);
} else {
result += ";; skipped.\n\n";
}
}
}
@@ -224,7 +229,11 @@ std::string write_from_top_level(const Function& top_level,
something_matched = true;
result += fmt::format(";; definition for method of type {}\n",
method_match_result.maps.strings.at(type_name));
result += careful_function_to_string(func, dts);
if (skip_functions.find(func->guessed_name.to_string()) == skip_functions.end()) {
result += careful_function_to_string(func, dts);
} else {
result += ";; skipped.\n\n";
}
}
}
}
@@ -238,8 +247,8 @@ std::string write_from_top_level(const Function& top_level,
result += dts.ts.generate_deftype(dts.ts.lookup_type(name));
result += "\n\n";
} else {
result +=
fmt::format(";; type {} defintion, but it is unknown to the decompiler\n\n", name);
result += fmt::format(
";; type {} is defined here, but it is unknown to the decompiler\n\n", name);
}
something_matched = true;
}
@@ -256,7 +265,11 @@ std::string write_from_top_level(const Function& top_level,
something_matched = true;
result += fmt::format(";; definition (debug) for function {}\n",
debug_match_result.maps.strings.at(0));
result += careful_function_to_string(func, dts, FunctionDefSpecials::DEFUN_DEBUG);
if (skip_functions.find(func->guessed_name.to_string()) == skip_functions.end()) {
result += careful_function_to_string(func, dts, FunctionDefSpecials::DEFUN_DEBUG);
} else {
result += ";; skipped.\n\n";
}
}
}
}