Skip to content

Commit a1d3a45

Browse files
committed
Merge remote-tracking branch 'origin/GP-0_dev747368_fix_dwarf_rust_test' into Ghidra_11.0
2 parents df4dd32 + aee606f commit a1d3a45

File tree

1 file changed

+4
-33
lines changed

1 file changed

+4
-33
lines changed

Ghidra/Features/Base/src/test.slow/java/ghidra/app/util/bin/format/dwarf4/next/DWARFFunctionImporterTest.java

Lines changed: 4 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,8 @@
1717

1818
import static org.junit.Assert.*;
1919

20-
import java.util.List;
21-
2220
import java.io.IOException;
21+
import java.util.List;
2322

2423
import org.junit.Test;
2524

@@ -31,6 +30,7 @@
3130
import ghidra.program.database.function.OverlappingFunctionException;
3231
import ghidra.program.model.address.AddressSet;
3332
import ghidra.program.model.data.*;
33+
import ghidra.program.model.lang.CompilerSpec;
3434
import ghidra.program.model.listing.*;
3535
import ghidra.program.model.symbol.Namespace;
3636
import ghidra.program.model.symbol.SourceType;
@@ -72,10 +72,8 @@ public void testRustMethod_HasParamDefs()
7272
}
7373

7474
@Test
75-
public void testRustMethod_NoParamDefs()
75+
public void testRustMethod_SetsRustCC()
7676
throws CancelledException, IOException, DWARFException {
77-
// test that Ghidra functions in a Rust compilation unit don't have their info set
78-
// if they look like they are one of the stub DIE entries that Rust creates
7977
cu = new MockDWARFCompilationUnit(dwarfProg, 0x1000, 0x2000, 0,
8078
DWARFCompilationUnit.DWARF_32, (short) 4, 0, (byte) 8, 0,
8179
DWARFSourceLanguage.DW_LANG_Rust);
@@ -91,34 +89,7 @@ public void testRustMethod_NoParamDefs()
9189
assertNotNull(fooFunc);
9290

9391
assertEquals("foo", fooFunc.getName());
94-
DataType returnType = fooFunc.getReturnType();
95-
assertNotNull(returnType);
96-
assertEquals("undefined", returnType.getName());
97-
}
98-
99-
@Test
100-
public void testNotRustMethod_NoParamDefs()
101-
throws CancelledException, IOException, DWARFException {
102-
// test that Ghidra functions in a non-Rust compilation unit do have their info set
103-
// even if their param info is empty.
104-
cu = new MockDWARFCompilationUnit(dwarfProg, 0x1000, 0x2000, 0,
105-
DWARFCompilationUnit.DWARF_32, (short) 4, 0, (byte) 8, 0,
106-
DWARFSourceLanguage.DW_LANG_C);
107-
cu2 = null;
108-
setMockCompilationUnits(cu);
109-
110-
DebugInfoEntry intDIE = addInt(cu);
111-
newSubprogram("foo", intDIE, 0x410, 10).create(cu);
112-
113-
importFunctions();
114-
115-
Function fooFunc = program.getListing().getFunctionAt(addr(0x410));
116-
assertNotNull(fooFunc);
117-
118-
assertEquals("foo", fooFunc.getName());
119-
DataType returnType = fooFunc.getReturnType();
120-
assertNotNull(returnType);
121-
assertEquals("int", returnType.getName());
92+
assertEquals(CompilerSpec.CALLING_CONVENTION_rustcall, fooFunc.getCallingConventionName());
12293
}
12394

12495
@Test

0 commit comments

Comments
 (0)