mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2024-11-21 11:31:43 +00:00
GP-5109 - MDMang and MicrosoftDemangler - add demangleType tests
This commit is contained in:
parent
b80cfdff3f
commit
74292aa77e
@ -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