Skip to content

Commit 3f157f3

Browse files
committed
Reorder tooltip/context items slightly
1 parent a1ea291 commit 3f157f3

File tree

2 files changed

+25
-18
lines changed

2 files changed

+25
-18
lines changed

objdiff-core/src/arch/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ impl DataType {
124124
}
125125
DataType::Double => {
126126
let bytes: [u8; 8] = bytes.try_into().unwrap();
127-
strs.push(format!("{:?}f", match endian {
127+
strs.push(format!("{:?}", match endian {
128128
object::Endianness::Little => f64::from_le_bytes(bytes),
129129
object::Endianness::Big => f64::from_be_bytes(bytes),
130130
}));

objdiff-core/src/diff/display.rs

+24-17
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ pub fn symbol_context(obj: &Object, symbol_index: usize) -> Vec<ContextItem> {
346346
if symbol.section.is_some() {
347347
if let Some(address) = symbol.virtual_address {
348348
out.push(ContextItem::Copy {
349-
value: format!("{:#x}", address),
349+
value: format!("{:x}", address),
350350
label: Some("virtual address".to_string()),
351351
});
352352
}
@@ -409,7 +409,7 @@ pub fn symbol_hover(obj: &Object, symbol_index: usize, addend: i64) -> Vec<Hover
409409
if let Some(address) = symbol.virtual_address {
410410
out.push(HoverItem::Text {
411411
label: "Virtual address".into(),
412-
value: format!("{:#x}", address),
412+
value: format!("{:x}", address),
413413
color: HoverItemColor::Special,
414414
});
415415
}
@@ -430,32 +430,34 @@ pub fn relocation_context(
430430
ins: Option<ResolvedInstructionRef>,
431431
) -> Vec<ContextItem> {
432432
let mut out = Vec::new();
433+
out.append(&mut symbol_context(obj, reloc.relocation.target_symbol));
433434
if let Some(ins) = ins {
434-
for literal in display_ins_data_literals(obj, ins) {
435-
out.push(ContextItem::Copy { value: literal, label: None });
435+
let literals = display_ins_data_literals(obj, ins);
436+
if !literals.is_empty() {
437+
out.push(ContextItem::Separator);
438+
for literal in literals {
439+
out.push(ContextItem::Copy { value: literal, label: None });
440+
}
436441
}
437-
out.push(ContextItem::Separator);
438442
}
439-
out.append(&mut symbol_context(obj, reloc.relocation.target_symbol));
440443
out
441444
}
442445

443446
pub fn relocation_hover(obj: &Object, reloc: ResolvedRelocation) -> Vec<HoverItem> {
444447
let mut out = Vec::new();
445448
if let Some(name) = obj.arch.reloc_name(reloc.relocation.flags) {
446449
out.push(HoverItem::Text {
447-
label: "Relocation type".into(),
450+
label: "Relocation".into(),
448451
value: name.to_string(),
449452
color: HoverItemColor::Normal,
450453
});
451454
} else {
452455
out.push(HoverItem::Text {
453-
label: "Relocation type".into(),
456+
label: "Relocation".into(),
454457
value: format!("<{:?}>", reloc.relocation.flags),
455458
color: HoverItemColor::Normal,
456459
});
457460
}
458-
out.push(HoverItem::Separator);
459461
out.append(&mut symbol_hover(obj, reloc.relocation.target_symbol, reloc.relocation.addend));
460462
out
461463
}
@@ -494,6 +496,7 @@ pub fn instruction_context(
494496
}
495497
}
496498
if let Some(reloc) = resolved.relocation {
499+
out.push(ContextItem::Separator);
497500
out.append(&mut relocation_context(obj, reloc, Some(resolved)));
498501
}
499502
out
@@ -515,7 +518,7 @@ pub fn instruction_hover(
515518
let offset = resolved.ins_ref.address - resolved.symbol.address;
516519
out.push(HoverItem::Text {
517520
label: "Virtual address".into(),
518-
value: format!("{:#x}", virtual_address + offset),
521+
value: format!("{:x}", virtual_address + offset),
519522
color: HoverItemColor::Special,
520523
});
521524
}
@@ -541,15 +544,19 @@ pub fn instruction_hover(
541544
}
542545
}
543546
if let Some(reloc) = resolved.relocation {
544-
out.append(&mut relocation_hover(obj, reloc));
545547
out.push(HoverItem::Separator);
548+
out.append(&mut relocation_hover(obj, reloc));
546549
if let Some(ty) = obj.arch.guess_data_type(resolved) {
547-
for literal in display_ins_data_literals(obj, resolved) {
548-
out.push(HoverItem::Text {
549-
label: format!("{}", ty),
550-
value: literal,
551-
color: HoverItemColor::Normal,
552-
});
550+
let literals = display_ins_data_literals(obj, resolved);
551+
if !literals.is_empty() {
552+
out.push(HoverItem::Separator);
553+
for literal in literals {
554+
out.push(HoverItem::Text {
555+
label: format!("{}", ty),
556+
value: literal,
557+
color: HoverItemColor::Normal,
558+
});
559+
}
553560
}
554561
}
555562
}

0 commit comments

Comments
 (0)