17
17
18
18
import static org .junit .Assert .*;
19
19
20
- import java .util .List ;
21
-
22
20
import java .io .IOException ;
21
+ import java .util .List ;
23
22
24
23
import org .junit .Test ;
25
24
31
30
import ghidra .program .database .function .OverlappingFunctionException ;
32
31
import ghidra .program .model .address .AddressSet ;
33
32
import ghidra .program .model .data .*;
33
+ import ghidra .program .model .lang .CompilerSpec ;
34
34
import ghidra .program .model .listing .*;
35
35
import ghidra .program .model .symbol .Namespace ;
36
36
import ghidra .program .model .symbol .SourceType ;
@@ -72,10 +72,8 @@ public void testRustMethod_HasParamDefs()
72
72
}
73
73
74
74
@ Test
75
- public void testRustMethod_NoParamDefs ()
75
+ public void testRustMethod_SetsRustCC ()
76
76
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
79
77
cu = new MockDWARFCompilationUnit (dwarfProg , 0x1000 , 0x2000 , 0 ,
80
78
DWARFCompilationUnit .DWARF_32 , (short ) 4 , 0 , (byte ) 8 , 0 ,
81
79
DWARFSourceLanguage .DW_LANG_Rust );
@@ -91,34 +89,7 @@ public void testRustMethod_NoParamDefs()
91
89
assertNotNull (fooFunc );
92
90
93
91
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 ());
122
93
}
123
94
124
95
@ Test
0 commit comments