Merge remote-tracking branch 'origin/GP-1724_ghizard_Fix_MDMangGenericize_processing'

This commit is contained in:
Ryan Kurtz 2022-02-04 10:41:10 -05:00
commit b7bfb6b992
7 changed files with 26 additions and 34 deletions

View File

@ -70,13 +70,15 @@ public class MDMang {
}
/**
* Demangles the string passed in.
* Demangles the string passed in and returns a parsed item.
*
* @param mangledIn
* the string to be demangled.
* @param errorOnRemainingChars
* boolean flag indicating whether remaining characters causes an
* error.
* @return the item that has been parsed.
* @throws MDException upon parsing error
*/
public MDParsableItem demangle(String mangledIn, boolean errorOnRemainingChars)
throws MDException {
@ -88,7 +90,7 @@ public class MDMang {
}
/**
* Demangles the string passed in.
* Demangles the string already stored and returns a parsed item.
*
* @param errorOnRemainingChars
* boolean flag indicating whether remaining characters causes an

View File

@ -257,7 +257,7 @@ public class MDObjectCPP extends MDObject {
break;
}
builder.append(ch);
dmang.next();
dmang.increment();
}
int end = dmang.getIndex();
if ((end - start) != 32 || ch != '@') {

View File

@ -15,8 +15,7 @@
*/
package mdemangler;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.*;
import org.junit.rules.TestName;
@ -87,7 +86,8 @@ public class MDBaseTestConfiguration {
}
// Meant to be overridden, as needed by extended classes
doDemangleSymbol();
demangItem = doDemangleSymbol(mdm, mangled);
demangled = (demangItem == null) ? "" : demangItem.toString();
doBasicTestsAndOutput();
@ -192,15 +192,12 @@ public class MDBaseTestConfiguration {
}
// Meant to be overridden, as needed by extended classes
protected void doDemangleSymbol() throws Exception {
protected MDParsableItem doDemangleSymbol(MDMang mdmIn, String mangledIn) throws Exception {
try {
demangItem = mdm.demangle(mangled, true);
demangled = demangItem.toString();
return mdmIn.demangle(mangledIn, true);
}
catch (MDException e) {
Msg.info(this, "Could not demangle: " + mangled, e);
demangItem = null;
demangled = "";
return null;
}
}

View File

@ -41,13 +41,10 @@ public class MDGenericizeTestConfiguration extends MDBaseTestConfiguration {
outputInfo.append(mangledGeneric);
outputInfo.append("\n");
MDMang mdmGeneric = new MDMang();
MDParsableItem demangItemGeneric = mdmGeneric.demangle(mangledGeneric, false);
String demangledGeneric;
MDParsableItem demangItemGeneric = doDemangleSymbol(mdmGeneric, mangledGeneric);
String demangledGeneric = (demangItemGeneric == null) ? "" : demangItemGeneric.toString();
if (demangItemGeneric == null) {
demangledGeneric = "";
}
else {
demangledGeneric = demangItemGeneric.toString();
demangled = ""; // Make sure test value is set properly when failure
}
outputInfo.append("GDemang: ");
outputInfo.append(demangledGeneric);

View File

@ -46,17 +46,17 @@ public class MDGhidraTestConfiguration extends MDBaseTestConfiguration {
}
@Override
protected void doDemangleSymbol() throws Exception {
protected MDParsableItem doDemangleSymbol(MDMang mdmIn, String mangledIn) throws Exception {
MDParsableItem returnItem;
try {
//Set true in operational mode.
demangItem = ((MDMangGhidra) mdm).demangle(mangled, false); // "false" is different
demangled = demangItem.toString();
demangledObject = ((MDMangGhidra) mdm).getObject();
returnItem = ((MDMangGhidra) mdmIn).demangle(mangledIn, false); // "false" is different
demangledObject = ((MDMangGhidra) mdmIn).getObject();
}
catch (MDException e) {
demangItem = null;
demangled = "";
returnItem = null;
}
return returnItem;
}
@Override

View File

@ -40,14 +40,12 @@ public class MDVS2013TestConfiguration extends MDBaseTestConfiguration {
}
@Override
protected void doDemangleSymbol() throws Exception {
protected MDParsableItem doDemangleSymbol(MDMang mdmIn, String mangledIn) throws Exception {
try {
demangItem = mdm.demangle(mangled, false); // "false" is different
demangled = demangItem.toString();
return mdmIn.demangle(mangledIn, false); // "false" is different
}
catch (MDException e) {
demangItem = null;
demangled = "";
return null;
}
}
}

View File

@ -35,14 +35,12 @@ public class MDVS2015TestConfiguration extends MDBaseTestConfiguration {
}
@Override
protected void doDemangleSymbol() throws Exception {
protected MDParsableItem doDemangleSymbol(MDMang mdmIn, String mangledIn) throws Exception {
try {
demangItem = mdm.demangle(mangled, false); // "false" is different
demangled = demangItem.toString();
return mdmIn.demangle(mangledIn, false); // "false" is different
}
catch (MDException e) {
demangItem = null;
demangled = "";
return null;
}
}
}