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

Function instruction_hover

objdiff-core/src/diff/display.rs:652–714  ·  view source on GitHub ↗
(
    obj: &Object,
    resolved: ResolvedInstructionRef,
    ins: &ParsedInstruction,
    diff_config: &DiffObjConfig,
)

Source from the content-addressed store, hash-verified

650}
651
652pub fn instruction_hover(
653 obj: &Object,
654 resolved: ResolvedInstructionRef,
655 ins: &ParsedInstruction,
656 diff_config: &DiffObjConfig,
657) -> Vec<HoverItem> {
658 let mut out = Vec::new();
659 out.push(HoverItem::Text {
660 label: Default::default(),
661 value: format!("{:02x?}", resolved.code),
662 color: HoverItemColor::Normal,
663 });
664 out.append(&mut obj.arch.instruction_hover(obj, resolved));
665 if let Some(virtual_address) = resolved.symbol.virtual_address {
666 let offset = resolved.ins_ref.address - resolved.symbol.address;
667 out.push(HoverItem::Text {
668 label: "Virtual address".into(),
669 value: format!("{:x}", virtual_address + offset),
670 color: HoverItemColor::Special,
671 });
672 }
673 for arg in &ins.args {
674 if let InstructionArg::Value(arg) = arg {
675 match arg {
676 InstructionArgValue::Signed(v) => {
677 out.push(HoverItem::Text {
678 label: Default::default(),
679 value: format!("{arg} == {v}"),
680 color: HoverItemColor::Normal,
681 });
682 }
683 InstructionArgValue::Unsigned(v) => {
684 out.push(HoverItem::Text {
685 label: Default::default(),
686 value: format!("{arg} == {v}"),
687 color: HoverItemColor::Normal,
688 });
689 }
690 _ => {}
691 }
692 }
693 }
694 if let Some(reloc) = resolved.relocation {
695 out.push(HoverItem::Separator);
696 out.append(&mut relocation_hover(obj, reloc, None));
697 let bytes = obj.symbol_data(reloc.relocation.target_symbol).unwrap_or(&[]);
698 if let Some(ty) = obj.arch.guess_data_type(resolved, bytes) {
699 let mut literals = display_ins_data_literals(obj, resolved);
700 literals.retain(|lit_info| !lit_info.hidden(Some(diff_config)));
701 if !literals.is_empty() {
702 out.push(HoverItem::Separator);
703 for lit_info in literals {
704 out.push(HoverItem::Text {
705 label: lit_info.label_override.unwrap_or_else(|| ty.to_string()),
706 value: format!("{:?}", lit_info.literal),
707 color: HoverItemColor::Normal,
708 });
709 }

Callers 2

instruction_hoverMethod · 0.85
ins_hover_uiFunction · 0.85

Calls 7

relocation_hoverFunction · 0.85
pushMethod · 0.80
symbol_dataMethod · 0.80
instruction_hoverMethod · 0.45
guess_data_typeMethod · 0.45
hiddenMethod · 0.45

Tested by

no test coverage detected