MCPcopy Index your code
hub / github.com/encounter/objdiff / display_instruction

Method display_instruction

objdiff-core/src/arch/arm64.rs:76–105  ·  view source on GitHub ↗
(
        &self,
        resolved: ResolvedInstructionRef,
        _diff_config: &DiffObjConfig,
        cb: &mut dyn FnMut(InstructionPart) -> Result<()>,
    )

Source from the content-addressed store, hash-verified

74 }
75
76 fn display_instruction(
77 &self,
78 resolved: ResolvedInstructionRef,
79 _diff_config: &DiffObjConfig,
80 cb: &mut dyn FnMut(InstructionPart) -> Result<()>,
81 ) -> Result<()> {
82 let mut reader = U8Reader::new(resolved.code);
83 let decoder = InstDecoder::default();
84 let mut ins = Instruction::default();
85 if decoder.decode_into(&mut ins, &mut reader).is_err() {
86 cb(InstructionPart::opcode("<invalid>", OPCODE_INVALID))?;
87 return Ok(());
88 }
89
90 let mut ctx = DisplayCtx {
91 address: resolved.ins_ref.address,
92 section_index: 0,
93 start_address: resolved.symbol.address,
94 end_address: resolved.symbol.address + resolved.symbol.size,
95 reloc: resolved.relocation,
96 };
97
98 let mut display_args = Vec::with_capacity(16);
99 let mnemonic = display_instruction(&mut |ret| display_args.push(ret), &ins, &mut ctx);
100 cb(InstructionPart::opcode(mnemonic, resolved.ins_ref.opcode))?;
101 for arg in display_args {
102 cb(arg)?;
103 }
104 Ok(())
105 }
106
107 fn reloc_name(&self, flags: RelocationFlags) -> Option<&'static str> {
108 match flags {

Callers

nothing calls this directly

Calls 2

display_instructionFunction · 0.85
pushMethod · 0.80

Tested by

no test coverage detected