mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-06 03:50:02 +02:00
Merge remote-tracking branch 'origin/GP-3183_emteere_CParser_parse_fail'
into patch (Closes #4903)
This commit is contained in:
commit
cbdb6955ed
2 changed files with 18 additions and 1 deletions
|
@ -307,6 +307,8 @@ public class CParser {
|
|||
private DataType addDef(Map<String, DataType> table, String name, DataType dt) {
|
||||
// System.out.println("** addDef " + name + " = " + (dt != null ? dt.getName() : " - no type -") );
|
||||
|
||||
lastDataType = dt;
|
||||
|
||||
DataType existingDT = table.get(name);
|
||||
if (existingDT != null && dt.isEquivalent(existingDT)) {
|
||||
return existingDT;
|
||||
|
@ -426,7 +428,7 @@ public class CParser {
|
|||
|
||||
hasNoComponents = (dtComp.getNumDefinedComponents() == 0 ? true : false);
|
||||
|
||||
hasSameSourceArchive = dt.getSourceArchive().equals(dtMgr.getLocalSourceArchive());
|
||||
hasSameSourceArchive = Objects.equals(dt.getSourceArchive(), dtMgr.getLocalSourceArchive());
|
||||
}
|
||||
|
||||
// make sure comp is a Composite, if existing dt is empty, in same category and archive
|
||||
|
|
|
@ -51,6 +51,21 @@ public class CParserTest extends AbstractGenericTest {
|
|||
DataType dt = parser.getDataTypeManager().getDataType("/int32_t");
|
||||
assertTrue(dt != null);
|
||||
assertTrue(dt instanceof TypeDef);
|
||||
|
||||
dt = parser.parse("struct mystruct {" +
|
||||
" int field1;" +
|
||||
" char field2;" +
|
||||
" };");
|
||||
|
||||
assertTrue(dt != null);
|
||||
assertTrue(dt instanceof Structure);
|
||||
Structure sdt = (Structure) dt;
|
||||
DataTypeComponent comp = sdt.getComponent(0);
|
||||
assertEquals("field1", comp.getFieldName());
|
||||
assertEquals(comp.getDataType().getName(),"int");
|
||||
comp = sdt.getComponent(1);
|
||||
assertEquals("field2", comp.getFieldName());
|
||||
assertEquals(comp.getDataType().getName(),"char");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue