diff options
| author | KyleMiles <krm504@nyu.edu> | 2020-10-09 20:57:42 +0000 |
|---|---|---|
| committer | KyleMiles <krm504@nyu.edu> | 2020-10-19 18:17:44 +0000 |
| commit | c7ccd714ceeaabbe5ee682e361250c3cfd54f78f (patch) | |
| tree | e9f9a6da19ca097f82b4a8f8c00ebba4ea14a590 /suite | |
| parent | 3083903d0ee4ccd18099cb3315e0220c7f5993fb (diff) | |
Expose Template Simplifier to the API, Adds Tests, and Adds Rust String FFI support to Python (see note)
This introduces the ability to receive and free string from Rust in Python.
For it to work, your exposed function name needs to begin with "BNRust", and the generator will create the appropriate code for freeing string return values and arguments.
Diffstat (limited to 'suite')
| -rw-r--r-- | suite/testcommon.py | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/suite/testcommon.py b/suite/testcommon.py index 09f9d589..b7251d42 100644 --- a/suite/testcommon.py +++ b/suite/testcommon.py @@ -590,6 +590,44 @@ class TestBuilder(Builder): testfunction = binja.Type.function(inttype, [inttype, inttype, inttype]) return ["Test_function params: " + str(testfunction.parameters), "Test_function pointer: " + str(testfunction.pointer(binja.Architecture["x86"], testfunction))] + def test_Simplifier(self): + """Template Simplification""" + result = [binja.demangle.simplify_name_to_string(s) for s in [ + # Simple + "std::__cxx11::basic_string<T, std::char_traits<T>, std::allocator<T> >", + "std::vector<T, std::allocator<T> >", + "std::vector<T, std::allocator<T>, std::lessthan<T> >", + "std::deque<T, std::allocator<T> >", + "std::forward_list<T, std::allocator<T> >", + "std::list<T, std::allocator<T> >", + "std::stack<T, std::deque<T> >", + "std::queue<T, std::deque<T> >", + "std::set<T, std::less<T>, std::allocator<T> >", + "std::multiset<T, std::less<T>, std::allocator<T> >", + "std::map<T1, T2, std::less<T1>, std::allocator<std::pair<const T1, T2> > >", + "std::multimap<T1, T2, std::less<T1>, std::allocator<std::pair<const T1, T2> > >", + "std::unordered_set<T, std::hash<T>, std::equal_to<T>, std::allocator<T> >", + "std::unordered_multiset<T, std::hash<T>, std::equal_to<T>, std::allocator<T> >", + "std::unordered_map<T1, T2, std::hash<T1>, std::equal_to<T1>, std::allocator<std::pair<const T1, T2> > >", + "std::unordered_multimap<T1, T2, std::hash<T1>, std::equal_to<T1>, std::allocator<std::pair<const T1, T2> > >", + + # More complex + "std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string", + "std::vector<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::array<uint32_t, 5ul> >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::array<uint32_t, 5ul> > > >::_M_default_append(uint64_t)", + "std::vector<std::vector<T, std::allocator<T> >, std::allocator<std::vector<T, std::allocator<T> > > >::_M_check_len(uint64_t, char const*) const", + ]] + + # Test all the APIs + qName = binja.types.QualifiedName(["std", "__cxx11", "basic_string<T, std::char_traits<T>, std::allocator<T> >"]) + result.append(binja.demangle.simplify_name_to_string(qName)) + result.append(str(binja.demangle.simplify_name_to_qualified_name(qName))) + result.append(str(binja.demangle.simplify_name_to_qualified_name(str(qName)))) + result.append(str(binja.demangle.simplify_name_to_qualified_name(str(qName), False).name)) + result.append("::".join(binja.demangle_gnu3(binja.Architecture['x86_64'], "_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_createERmm", False)[1])) + result.append("::".join(binja.demangle_gnu3(binja.Architecture['x86_64'], "_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_createERmm", True)[1])) + + return result + def test_Struct(self): """Struct produced different result""" retinfo = [] |
