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

Function instruction_context

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

Source from the content-addressed store, hash-verified

596}
597
598pub fn instruction_context(
599 obj: &Object,
600 resolved: ResolvedInstructionRef,
601 ins: &ParsedInstruction,
602 diff_config: &DiffObjConfig,
603) -> Vec<ContextItem> {
604 let mut out = Vec::new();
605 let mut hex_string = String::new();
606 for byte in resolved.code {
607 hex_string.push_str(&format!("{byte:02x}"));
608 }
609 out.push(ContextItem::Copy {
610 value: hex_string,
611 label: Some("instruction bytes".to_string()),
612 copy_string: None,
613 });
614 out.append(&mut obj.arch.instruction_context(obj, resolved));
615 if let Some(virtual_address) = resolved.symbol.virtual_address {
616 let offset = resolved.ins_ref.address - resolved.symbol.address;
617 out.push(ContextItem::Copy {
618 value: format!("{:x}", virtual_address + offset),
619 label: Some("virtual address".to_string()),
620 copy_string: None,
621 });
622 }
623 for arg in &ins.args {
624 if let InstructionArg::Value(arg) = arg {
625 out.push(ContextItem::Copy { value: arg.to_string(), label: None, copy_string: None });
626 match arg {
627 InstructionArgValue::Signed(v) => {
628 out.push(ContextItem::Copy {
629 value: v.to_string(),
630 label: None,
631 copy_string: None,
632 });
633 }
634 InstructionArgValue::Unsigned(v) => {
635 out.push(ContextItem::Copy {
636 value: v.to_string(),
637 label: None,
638 copy_string: None,
639 });
640 }
641 _ => {}
642 }
643 }
644 }
645 if let Some(reloc) = resolved.relocation {
646 out.push(ContextItem::Separator);
647 out.append(&mut relocation_context(obj, reloc, Some(resolved), Some(diff_config)));
648 }
649 out
650}
651
652pub fn instruction_hover(
653 obj: &Object,

Callers 2

instruction_contextMethod · 0.85
ins_context_menuFunction · 0.85

Calls 3

relocation_contextFunction · 0.85
pushMethod · 0.80
instruction_contextMethod · 0.45

Tested by

no test coverage detected