@@ -27,7 +27,7 @@ pub fn roundtrip(inst: &Inst<FuzzRegs>) {
27
27
// off the instruction offset first.
28
28
let expected = expected. split_once ( ' ' ) . unwrap ( ) . 1 ;
29
29
let actual = inst. to_string ( ) ;
30
- if expected != actual && expected != replace_signed_immediates ( & actual) {
30
+ if expected != actual && expected != fix_up ( & actual) {
31
31
println ! ( "> {inst}" ) ;
32
32
println ! ( " debug: {inst:x?}" ) ;
33
33
println ! ( " assembled: {}" , pretty_print_hexadecimal( & assembled) ) ;
@@ -166,6 +166,33 @@ fn replace() {
166
166
) ;
167
167
}
168
168
169
+ /// Remove everything after the first semicolon in the disassembly and trim any
170
+ /// trailing spaces. This is necessary to remove the implicit operands we end up
171
+ /// printing for Cranelift's sake.
172
+ fn remove_after_semicolon ( dis : & str ) -> & str {
173
+ match dis. find ( ';' ) {
174
+ None => dis,
175
+ Some ( idx) => {
176
+ let ( prefix, _) = dis. split_at ( idx) ;
177
+ prefix. trim ( )
178
+ }
179
+ }
180
+ }
181
+
182
+ #[ test]
183
+ fn remove_after_parenthesis_test ( ) {
184
+ assert_eq ! (
185
+ remove_after_semicolon( "imulb 0x7658eddd(%rcx) ;; implicit: %ax" ) ,
186
+ "imulb 0x7658eddd(%rcx)"
187
+ ) ;
188
+ }
189
+
190
+ /// Run some post-processing on the disassembly to make it match Capstone.
191
+ fn fix_up ( dis : & str ) -> std:: borrow:: Cow < str > {
192
+ let dis = remove_after_semicolon ( dis) ;
193
+ replace_signed_immediates ( & dis)
194
+ }
195
+
169
196
/// Fuzz-specific registers.
170
197
///
171
198
/// For the fuzzer, we do not need any fancy register types; see [`FuzzReg`].
0 commit comments