mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-03 09:49:23 +02:00
Merge remote-tracking branch 'origin/GP-0-dragonmacher-patch-test-fixes-4-2-25' into patch
This commit is contained in:
commit
f3cd8f54b8
4 changed files with 41 additions and 20 deletions
|
@ -28,14 +28,14 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
//
|
//
|
||||||
// Note: these have been disabled. Some binaries have a class namespace with the same name in more
|
// Note: some of these have been disabled. Some binaries have a class namespace with the same name
|
||||||
// than one namespace that may include these values. In that case, if we drop these values, then
|
// in more than one namespace that may include these values. In that case, if we drop these values,
|
||||||
// instead of 2 distinct namespaces, we will have only 1, which is incorrect. If we decide that
|
// then instead of 2 distinct namespaces, we will have only 1, which is incorrect. If we decide that
|
||||||
// these values are not desired, then we will have to figure out a way to create 2 distinct
|
// these values are not desired, then we will have to figure out a way to create 2 distinct
|
||||||
// namespaces after we apply the simplification.
|
// namespaces after we apply the simplification.
|
||||||
//
|
//
|
||||||
// current tests show this is a non-leading mangled namespace placeholder
|
// current tests show this is a non-leading mangled namespace placeholder
|
||||||
//"" ::__1
|
"" ::__1
|
||||||
|
|
||||||
// current tests show this is a non-leading mangled namespace placeholder
|
// current tests show this is a non-leading mangled namespace placeholder
|
||||||
//"" ::__cxx11
|
//"" ::__cxx11
|
||||||
|
|
|
@ -1550,17 +1550,16 @@ public class GnuDemanglerParser {
|
||||||
for (ResourceFile file : files) {
|
for (ResourceFile file : files) {
|
||||||
List<String> lines = getReplacementLines(file);
|
List<String> lines = getReplacementLines(file);
|
||||||
for (String line : lines) {
|
for (String line : lines) {
|
||||||
GnuDemanglerReplacement replacement = parseReplacement(line, file);
|
parseReplacement(line, file, results);
|
||||||
if (replacement != null) {
|
|
||||||
results.add(replacement);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static GnuDemanglerReplacement parseReplacement(String line, ResourceFile file) {
|
private static void parseReplacement(String line, ResourceFile file,
|
||||||
|
List<GnuDemanglerReplacement> results) {
|
||||||
|
|
||||||
for (int i = 0; i < line.length(); i++) {
|
for (int i = 0; i < line.length(); i++) {
|
||||||
char c = line.charAt(i);
|
char c = line.charAt(i);
|
||||||
if (Character.isWhitespace(c)) {
|
if (Character.isWhitespace(c)) {
|
||||||
|
@ -1572,13 +1571,35 @@ public class GnuDemanglerParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
String find = line.substring(i).trim();
|
String find = line.substring(i).trim();
|
||||||
return new GnuDemanglerReplacement(find, replace, file);
|
results.add(new GnuDemanglerReplacement(find, replace, file));
|
||||||
|
|
||||||
|
//
|
||||||
|
// We have disabled some global text replacements. Instead of globally replacing
|
||||||
|
// them, we will update each replacement to handle the special case when it starts
|
||||||
|
// at the beginning of the replacement.
|
||||||
|
//
|
||||||
|
createAlternateReplacement("std::__cxx11::", find, replace, file, results);
|
||||||
|
createAlternateReplacement("__gnu_cxx::", find, replace, file, results);
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Msg.warn(GnuDemanglerParser.class,
|
Msg.warn(GnuDemanglerParser.class,
|
||||||
"Malformed replacement line. No spaces found: " + line + ". In file: " + file);
|
"Malformed replacement line. No spaces found: " + line + ". In file: " + file);
|
||||||
return null;
|
}
|
||||||
|
|
||||||
|
private static void createAlternateReplacement(String alternate, String find, String replace,
|
||||||
|
ResourceFile file, List<GnuDemanglerReplacement> results) {
|
||||||
|
|
||||||
|
if (!(find.startsWith("std::") && replace.startsWith("std::"))) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String altFind = find.replaceFirst("std::", alternate);
|
||||||
|
String altReplace = replace.replaceFirst("std::", alternate);
|
||||||
|
results.add(new GnuDemanglerReplacement(altFind, altReplace, file));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<String> getReplacementLines(ResourceFile file) {
|
private static List<String> getReplacementLines(ResourceFile file) {
|
||||||
|
|
|
@ -197,15 +197,15 @@ public class GnuDemanglerParserTest extends AbstractGenericTest {
|
||||||
List<DemangledParameter> parameters = function.getParameters();
|
List<DemangledParameter> parameters = function.getParameters();
|
||||||
|
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"__insertion_sort<__normal_iterator<std::pair<unsigned_long,PcodeOp*>*,std::vector<std::pair<unsigned_long,PcodeOp*>,std::allocator<std::pair<unsigned_long,PcodeOp*>>>>,bool(*)(std::pair<unsigned_long,PcodeOp*>const&,std::pair<unsigned_long,PcodeOp*>const&)>",
|
"__insertion_sort<__gnu_cxx::__normal_iterator<std::pair<unsigned_long,PcodeOp*>*,std::vector<std::pair<unsigned_long,PcodeOp*>,std::allocator<std::pair<unsigned_long,PcodeOp*>>>>,bool(*)(std::pair<unsigned_long,PcodeOp*>const&,std::pair<unsigned_long,PcodeOp*>const&)>",
|
||||||
function.getName());
|
function.getName());
|
||||||
assertEquals("std", function.getNamespace().getName());
|
assertEquals("std", function.getNamespace().getName());
|
||||||
|
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"__normal_iterator<std::pair<unsigned long,PcodeOp *> *,std::vector<std::pair<unsigned long,PcodeOp *>,std::allocator<std::pair<unsigned long,PcodeOp *>>>>",
|
"__gnu_cxx::__normal_iterator<std::pair<unsigned long,PcodeOp *> *,std::vector<std::pair<unsigned long,PcodeOp *>,std::allocator<std::pair<unsigned long,PcodeOp *>>>>",
|
||||||
parameters.get(0).toString());
|
parameters.get(0).toString());
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"__normal_iterator<std::pair<unsigned long,PcodeOp *> *,std::vector<std::pair<unsigned long,PcodeOp *>,std::allocator<std::pair<unsigned long,PcodeOp *>>>>",
|
"__gnu_cxx::__normal_iterator<std::pair<unsigned long,PcodeOp *> *,std::vector<std::pair<unsigned long,PcodeOp *>,std::allocator<std::pair<unsigned long,PcodeOp *>>>>",
|
||||||
parameters.get(1).toString());
|
parameters.get(1).toString());
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"bool (*)(std::pair<unsigned long,PcodeOp *> const &,std::pair<unsigned long,PcodeOp *> const &)",
|
"bool (*)(std::pair<unsigned long,PcodeOp *> const &,std::pair<unsigned long,PcodeOp *> const &)",
|
||||||
|
@ -1112,7 +1112,7 @@ public class GnuDemanglerParserTest extends AbstractGenericTest {
|
||||||
|
|
||||||
String signature = object.getSignature(false);
|
String signature = object.getSignature(false);
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"std::string std::_Bind<std::string(EduAppConfigs::*(EduAppConfigs_const*))()const>::operator()<missing_argument,std::string>(void)",
|
"std::__cxx11::string std::_Bind<std::__cxx11::string(EduAppConfigs::*(EduAppConfigs_const*))()const>::operator()<missing_argument,std::__cxx11::string>(void)",
|
||||||
signature);
|
signature);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1145,7 +1145,7 @@ public class GnuDemanglerParserTest extends AbstractGenericTest {
|
||||||
|
|
||||||
String signature = object.getSignature(false);
|
String signature = object.getSignature(false);
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"std::string gsl::to_string<char_const,-1l>(gsl::basic_string_span<char const,long>)",
|
"std::__cxx11::string gsl::to_string<char_const,-1l>(gsl::basic_string_span<char const,long>)",
|
||||||
signature);
|
signature);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1630,7 +1630,7 @@ public class GnuDemanglerParserTest extends AbstractGenericTest {
|
||||||
"vector<boost::function<void()>,std::allocator<boost::function<void()>>>");
|
"vector<boost::function<void()>,std::allocator<boost::function<void()>>>");
|
||||||
|
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"undefined std::vector<boost::function<void()>,std::allocator<boost::function<void()>>>::_M_insert_aux(__normal_iterator<boost::function<void ()> *,std::vector<boost::function<void ()>,std::allocator<boost::function<void ()>>>>,boost::function<void ()> const &)",
|
"undefined std::vector<boost::function<void()>,std::allocator<boost::function<void()>>>::_M_insert_aux(__gnu_cxx::__normal_iterator<boost::function<void ()> *,std::vector<boost::function<void ()>,std::allocator<boost::function<void ()>>>>,boost::function<void ()> const &)",
|
||||||
object.getSignature(false));
|
object.getSignature(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1770,7 +1770,7 @@ public class GnuDemanglerParserTest extends AbstractGenericTest {
|
||||||
|
|
||||||
String signature = object.getSignature(false);
|
String signature = object.getSignature(false);
|
||||||
assertEquals("undefined " +
|
assertEquals("undefined " +
|
||||||
"__stoa<long,int,char,int>(long(*)(char_const*,char**,int),char_const*,char_const*,unsigned_long*,int)" +
|
"__gnu_cxx::__stoa<long,int,char,int>(long(*)(char_const*,char**,int),char_const*,char_const*,unsigned_long*,int)" +
|
||||||
"::_Save_errno::_Save_errno(void)", signature);
|
"::_Save_errno::_Save_errno(void)", signature);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -154,14 +154,14 @@ public class GnuDemanglerTest extends AbstractGenericTest {
|
||||||
assertNotNull(dobj);
|
assertNotNull(dobj);
|
||||||
|
|
||||||
String signature = dobj.getSignature();
|
String signature = dobj.getSignature();
|
||||||
assertEquals("undefined Greeter::greet(std::string)", signature);
|
assertEquals("undefined Greeter::greet(std::__cxx11::string)", signature);
|
||||||
|
|
||||||
DemangledParameter demangledParameter = dobj.getParameters().get(0);
|
DemangledParameter demangledParameter = dobj.getParameters().get(0);
|
||||||
DemangledDataType type = demangledParameter.getType();
|
DemangledDataType type = demangledParameter.getType();
|
||||||
DataType dt = type.getDataType(program.getDataTypeManager());
|
DataType dt = type.getDataType(program.getDataTypeManager());
|
||||||
assertTrue(dt.isNotYetDefined());
|
assertTrue(dt.isNotYetDefined());
|
||||||
//@formatter:off
|
//@formatter:off
|
||||||
assertEquals("/Demangler/std/string\n" +
|
assertEquals("/Demangler/std/__cxx11/string\n" +
|
||||||
"pack(disabled)\n" +
|
"pack(disabled)\n" +
|
||||||
"Structure string {\n" +
|
"Structure string {\n" +
|
||||||
"}\n" +
|
"}\n" +
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue