diff options
| author | Peter LaFosse <peter@vector35.com> | 2020-11-05 14:49:55 -0500 |
|---|---|---|
| committer | Peter LaFosse <peter@vector35.com> | 2020-11-07 19:02:49 -0500 |
| commit | 4916ad08adec80d697280ebb9d4ed92949551470 (patch) | |
| tree | f76168b0ad584e7aab7f833a7ccaad566d8268f3 | |
| parent | 2c312c8d5bca189241377c564ff5e9fb35fe9de2 (diff) | |
Add unit tests for MS demangler. Remove unnecessary enumeration value (fixes bug in MS demangler)
| -rw-r--r-- | binaryninjacore.h | 3 | ||||
| -rw-r--r-- | suite/api_test.py | 16 |
2 files changed, 17 insertions, 2 deletions
diff --git a/binaryninjacore.h b/binaryninjacore.h index c2d95f7d..5318630a 100644 --- a/binaryninjacore.h +++ b/binaryninjacore.h @@ -626,6 +626,8 @@ extern "C" LvalueSuffix }; + // Caution: these enumeration values are used a lookups into the static NameTypeStrings in the core + // if you modify this you must also modify the string lookups as well enum BNNameType { NoNameType, @@ -640,7 +642,6 @@ extern "C" OperatorEqualNameType, OperatorNotEqualNameType, OperatorArrayNameType, - OperatorDotNameType, OperatorArrowNameType, OperatorStarNameType, OperatorIncrementNameType, diff --git a/suite/api_test.py b/suite/api_test.py index 48d6601d..ccb4d8b0 100644 --- a/suite/api_test.py +++ b/suite/api_test.py @@ -5,7 +5,7 @@ import os from binaryninja.binaryview import BinaryView, BinaryViewType from binaryninja.settings import Settings, SettingsScope from binaryninja.metadata import Metadata -from binaryninja.demangle import demangle_gnu3, get_qualified_name +from binaryninja.demangle import demangle_gnu3, demangle_ms, get_qualified_name from binaryninja.architecture import Architecture @@ -275,6 +275,20 @@ class DemanglerTest(unittest.TestCase): out += str(t.get_string_after_name()) return out + def test_demangle_ms(self): + tests = ( + "??_V@YAPAXI@Z", + "??_U@YAPAXI@Z" + ) + + results = ( + "void* __cdecl operator delete[](uint32_t)", + "void* __cdecl operator new[](uint32_t)" + ) + for i, test in enumerate(tests): + t, n = demangle_ms(Architecture['x86'], test) + self.get_type_string(t, n) == results[i] + def test_demangle_gnu3(self): tests = ("__ZN15BinaryNinjaCore12BinaryReader5Read8Ev", "__ZN5QListIP18QAbstractAnimationE18detach_helper_growEii", |
