mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2024-11-23 04:39:55 +00:00
Merge remote-tracking branch 'origin/GP-5109_ghizard_add_MDMang_and_MicrosoftDemangler_demangleType_tests'
This commit is contained in:
commit
bd362f1b5c
@ -238,6 +238,20 @@ public class MicrosoftDemanglerTest extends AbstractGenericTest {
|
||||
fail(); // We are expecting an exception.
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSimpleDemangleType() throws Exception {
|
||||
String mangled = ".?AUname0@name1@@";
|
||||
Address address = addr("01001000");
|
||||
String expected = "struct name1::name0";
|
||||
|
||||
MicrosoftDemangler demangler = new MicrosoftDemangler();
|
||||
DemanglerOptions options = new MicrosoftDemanglerOptions();
|
||||
MangledContext mangledContext =
|
||||
demangler.createMangledContext(mangled, options, program, address);
|
||||
DemangledDataType dt = demangler.demangleType(mangledContext);
|
||||
assertEquals(expected, dt.toString());
|
||||
}
|
||||
|
||||
private Address addr(String address) {
|
||||
return program.getAddressFactory().getAddress(address);
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ import java.util.List;
|
||||
import org.junit.Test;
|
||||
|
||||
import generic.test.AbstractGenericTest;
|
||||
import mdemangler.datatype.MDDataType;
|
||||
import mdemangler.naming.MDQualification;
|
||||
import mdemangler.object.MDObjectCPP;
|
||||
import mdemangler.typeinfo.MDVxTable;
|
||||
@ -136,6 +137,20 @@ public class MDMangExtraTest extends AbstractGenericTest {
|
||||
assertEquals("_anon_FEDCBA98::a", qualifications.get(1).toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSimpleDemangleType() throws Exception {
|
||||
String mangled = ".?AUname0@name1@@";
|
||||
String expected = "struct name1::name0";
|
||||
|
||||
MDMangGhidra demangler = new MDMangGhidra();
|
||||
demangler.setMangledSymbol(mangled);
|
||||
demangler.setErrorOnRemainingChars(true);
|
||||
MDDataType item = demangler.demangleType();
|
||||
|
||||
String demangled = item.toString();
|
||||
assertEquals(expected, demangled);
|
||||
}
|
||||
|
||||
// Need to test the demangleType() method to make sure it does the retry with LLVM mode
|
||||
@Test
|
||||
public void testDemangleTypeWithRetry() throws Exception {
|
||||
|
Loading…
Reference in New Issue
Block a user